@mastra/mcp-docs-server 1.1.5 → 1.1.6-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/agents/adding-voice.md +349 -0
- package/.docs/docs/agents/agent-approval.md +558 -0
- package/.docs/docs/agents/agent-memory.md +209 -0
- package/.docs/docs/agents/guardrails.md +374 -0
- package/.docs/docs/agents/network-approval.md +275 -0
- package/.docs/docs/agents/networks.md +299 -0
- package/.docs/docs/agents/overview.md +304 -0
- package/.docs/docs/agents/processors.md +622 -0
- package/.docs/docs/agents/structured-output.md +273 -0
- package/.docs/docs/agents/supervisor-agents.md +304 -0
- package/.docs/docs/agents/using-tools.md +214 -0
- package/.docs/docs/build-with-ai/mcp-docs-server.md +238 -0
- package/.docs/docs/build-with-ai/skills.md +35 -0
- package/.docs/docs/community/contributing-templates.md +3 -0
- package/.docs/docs/community/discord.md +9 -0
- package/.docs/docs/community/licensing.md +66 -0
- package/.docs/docs/deployment/cloud-providers.md +15 -0
- package/.docs/docs/deployment/mastra-server.md +122 -0
- package/.docs/docs/deployment/monorepo.md +142 -0
- package/.docs/docs/deployment/overview.md +62 -0
- package/.docs/docs/deployment/studio.md +239 -0
- package/.docs/docs/deployment/web-framework.md +52 -0
- package/.docs/docs/deployment/workflow-runners.md +9 -0
- package/.docs/docs/evals/built-in-scorers.md +47 -0
- package/.docs/docs/evals/custom-scorers.md +519 -0
- package/.docs/docs/evals/overview.md +141 -0
- package/.docs/docs/evals/running-in-ci.md +124 -0
- package/.docs/docs/getting-started/build-with-ai.md +68 -0
- package/.docs/docs/getting-started/manual-install.md +226 -0
- package/.docs/docs/getting-started/project-structure.md +60 -0
- package/.docs/docs/getting-started/start.md +28 -0
- package/.docs/docs/getting-started/studio.md +101 -0
- package/.docs/docs/index.md +43 -0
- package/.docs/docs/mastra-cloud/deployment.md +77 -0
- package/.docs/docs/mastra-cloud/observability.md +38 -0
- package/.docs/docs/mastra-cloud/overview.md +23 -0
- package/.docs/docs/mastra-cloud/setup.md +42 -0
- package/.docs/docs/mastra-cloud/studio.md +24 -0
- package/.docs/docs/mastra-code/configuration.md +299 -0
- package/.docs/docs/mastra-code/customization.md +228 -0
- package/.docs/docs/mastra-code/modes.md +104 -0
- package/.docs/docs/mastra-code/overview.md +135 -0
- package/.docs/docs/mastra-code/tools.md +229 -0
- package/.docs/docs/mcp/overview.md +373 -0
- package/.docs/docs/mcp/publishing-mcp-server.md +95 -0
- package/.docs/docs/memory/memory-processors.md +314 -0
- package/.docs/docs/memory/message-history.md +260 -0
- package/.docs/docs/memory/observational-memory.md +248 -0
- package/.docs/docs/memory/overview.md +45 -0
- package/.docs/docs/memory/semantic-recall.md +272 -0
- package/.docs/docs/memory/storage.md +261 -0
- package/.docs/docs/memory/working-memory.md +400 -0
- package/.docs/docs/observability/datasets/overview.md +198 -0
- package/.docs/docs/observability/datasets/running-experiments.md +274 -0
- package/.docs/docs/observability/logging.md +99 -0
- package/.docs/docs/observability/overview.md +70 -0
- package/.docs/docs/observability/tracing/bridges/otel.md +209 -0
- package/.docs/docs/observability/tracing/exporters/arize.md +272 -0
- package/.docs/docs/observability/tracing/exporters/braintrust.md +111 -0
- package/.docs/docs/observability/tracing/exporters/cloud.md +127 -0
- package/.docs/docs/observability/tracing/exporters/datadog.md +187 -0
- package/.docs/docs/observability/tracing/exporters/default.md +209 -0
- package/.docs/docs/observability/tracing/exporters/laminar.md +100 -0
- package/.docs/docs/observability/tracing/exporters/langfuse.md +213 -0
- package/.docs/docs/observability/tracing/exporters/langsmith.md +198 -0
- package/.docs/docs/observability/tracing/exporters/otel.md +476 -0
- package/.docs/docs/observability/tracing/exporters/posthog.md +148 -0
- package/.docs/docs/observability/tracing/exporters/sentry.md +208 -0
- package/.docs/docs/observability/tracing/overview.md +1112 -0
- package/.docs/docs/observability/tracing/processors/sensitive-data-filter.md +300 -0
- package/.docs/docs/rag/chunking-and-embedding.md +183 -0
- package/.docs/docs/rag/graph-rag.md +215 -0
- package/.docs/docs/rag/overview.md +72 -0
- package/.docs/docs/rag/retrieval.md +515 -0
- package/.docs/docs/rag/vector-databases.md +645 -0
- package/.docs/docs/server/auth/auth0.md +220 -0
- package/.docs/docs/server/auth/better-auth.md +203 -0
- package/.docs/docs/server/auth/clerk.md +132 -0
- package/.docs/docs/server/auth/composite-auth.md +234 -0
- package/.docs/docs/server/auth/custom-auth-provider.md +513 -0
- package/.docs/docs/server/auth/firebase.md +272 -0
- package/.docs/docs/server/auth/jwt.md +110 -0
- package/.docs/docs/server/auth/simple-auth.md +180 -0
- package/.docs/docs/server/auth/supabase.md +117 -0
- package/.docs/docs/server/auth/workos.md +186 -0
- package/.docs/docs/server/auth.md +38 -0
- package/.docs/docs/server/custom-adapters.md +378 -0
- package/.docs/docs/server/custom-api-routes.md +267 -0
- package/.docs/docs/server/mastra-client.md +243 -0
- package/.docs/docs/server/mastra-server.md +71 -0
- package/.docs/docs/server/middleware.md +225 -0
- package/.docs/docs/server/request-context.md +471 -0
- package/.docs/docs/server/server-adapters.md +547 -0
- package/.docs/docs/streaming/events.md +237 -0
- package/.docs/docs/streaming/overview.md +175 -0
- package/.docs/docs/streaming/tool-streaming.md +175 -0
- package/.docs/docs/streaming/workflow-streaming.md +109 -0
- package/.docs/docs/voice/overview.md +959 -0
- package/.docs/docs/voice/speech-to-speech.md +102 -0
- package/.docs/docs/voice/speech-to-text.md +79 -0
- package/.docs/docs/voice/text-to-speech.md +83 -0
- package/.docs/docs/workflows/agents-and-tools.md +166 -0
- package/.docs/docs/workflows/control-flow.md +822 -0
- package/.docs/docs/workflows/error-handling.md +360 -0
- package/.docs/docs/workflows/human-in-the-loop.md +215 -0
- package/.docs/docs/workflows/overview.md +370 -0
- package/.docs/docs/workflows/snapshots.md +238 -0
- package/.docs/docs/workflows/suspend-and-resume.md +205 -0
- package/.docs/docs/workflows/time-travel.md +309 -0
- package/.docs/docs/workflows/workflow-state.md +181 -0
- package/.docs/docs/workspace/filesystem.md +164 -0
- package/.docs/docs/workspace/overview.md +239 -0
- package/.docs/docs/workspace/sandbox.md +63 -0
- package/.docs/docs/workspace/search.md +243 -0
- package/.docs/docs/workspace/skills.md +169 -0
- package/.docs/guides/agent-frameworks/ai-sdk.md +140 -0
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +1499 -0
- package/.docs/guides/build-your-ui/assistant-ui.md +156 -0
- package/.docs/guides/build-your-ui/copilotkit.md +289 -0
- package/.docs/guides/deployment/amazon-ec2.md +130 -0
- package/.docs/guides/deployment/aws-lambda.md +248 -0
- package/.docs/guides/deployment/azure-app-services.md +114 -0
- package/.docs/guides/deployment/cloudflare.md +99 -0
- package/.docs/guides/deployment/digital-ocean.md +168 -0
- package/.docs/guides/deployment/inngest.md +682 -0
- package/.docs/guides/deployment/netlify.md +77 -0
- package/.docs/guides/deployment/vercel.md +101 -0
- package/.docs/guides/getting-started/astro.md +398 -0
- package/.docs/guides/getting-started/electron.md +504 -0
- package/.docs/guides/getting-started/express.md +251 -0
- package/.docs/guides/getting-started/hono.md +190 -0
- package/.docs/guides/getting-started/next-js.md +347 -0
- package/.docs/guides/getting-started/nuxt.md +497 -0
- package/.docs/guides/getting-started/quickstart.md +67 -0
- package/.docs/guides/getting-started/sveltekit.md +296 -0
- package/.docs/guides/getting-started/vite-react.md +425 -0
- package/.docs/guides/guide/ai-recruiter.md +226 -0
- package/.docs/guides/guide/chef-michel.md +211 -0
- package/.docs/guides/guide/code-review-bot.md +226 -0
- package/.docs/guides/guide/dev-assistant.md +307 -0
- package/.docs/guides/guide/docs-manager.md +238 -0
- package/.docs/guides/guide/github-actions-pr-description.md +236 -0
- package/.docs/guides/guide/notes-mcp-server.md +416 -0
- package/.docs/guides/guide/research-assistant.md +348 -0
- package/.docs/guides/guide/research-coordinator.md +416 -0
- package/.docs/guides/guide/stock-agent.md +132 -0
- package/.docs/guides/guide/web-search.md +320 -0
- package/.docs/guides/guide/whatsapp-chat-bot.md +405 -0
- package/.docs/guides/index.md +3 -0
- package/.docs/guides/migrations/agentnetwork.md +97 -0
- package/.docs/guides/migrations/ai-sdk-v4-to-v5.md +112 -0
- package/.docs/guides/migrations/network-to-supervisor.md +261 -0
- package/.docs/guides/migrations/upgrade-to-v1/agent.md +404 -0
- package/.docs/guides/migrations/upgrade-to-v1/cli.md +57 -0
- package/.docs/guides/migrations/upgrade-to-v1/client.md +337 -0
- package/.docs/guides/migrations/upgrade-to-v1/deployment.md +37 -0
- package/.docs/guides/migrations/upgrade-to-v1/evals.md +239 -0
- package/.docs/guides/migrations/upgrade-to-v1/mastra.md +143 -0
- package/.docs/guides/migrations/upgrade-to-v1/mcp.md +97 -0
- package/.docs/guides/migrations/upgrade-to-v1/memory.md +285 -0
- package/.docs/guides/migrations/upgrade-to-v1/overview.md +119 -0
- package/.docs/guides/migrations/upgrade-to-v1/processors.md +68 -0
- package/.docs/guides/migrations/upgrade-to-v1/rag.md +42 -0
- package/.docs/guides/migrations/upgrade-to-v1/storage.md +553 -0
- package/.docs/guides/migrations/upgrade-to-v1/tools.md +180 -0
- package/.docs/guides/migrations/upgrade-to-v1/tracing.md +412 -0
- package/.docs/guides/migrations/upgrade-to-v1/vectors.md +87 -0
- package/.docs/guides/migrations/upgrade-to-v1/voice.md +30 -0
- package/.docs/guides/migrations/upgrade-to-v1/workflows.md +341 -0
- package/.docs/guides/migrations/vnext-to-standard-apis.md +362 -0
- package/.docs/models/embeddings.md +161 -0
- package/.docs/models/gateways/azure-openai.md +128 -0
- package/.docs/models/gateways/custom-gateways.md +545 -0
- package/.docs/models/gateways/netlify.md +88 -0
- package/.docs/models/gateways/openrouter.md +219 -0
- package/.docs/models/gateways/vercel.md +225 -0
- package/.docs/models/gateways.md +14 -0
- package/.docs/models/index.md +286 -0
- package/.docs/models/providers/302ai.md +134 -0
- package/.docs/models/providers/abacus.md +125 -0
- package/.docs/models/providers/agentrouter.md +90 -0
- package/.docs/models/providers/aihubmix.md +107 -0
- package/.docs/models/providers/alibaba-cn.md +135 -0
- package/.docs/models/providers/alibaba.md +111 -0
- package/.docs/models/providers/amazon-bedrock.md +33 -0
- package/.docs/models/providers/anthropic.md +153 -0
- package/.docs/models/providers/azure.md +33 -0
- package/.docs/models/providers/bailing.md +72 -0
- package/.docs/models/providers/baseten.md +77 -0
- package/.docs/models/providers/berget.md +78 -0
- package/.docs/models/providers/cerebras.md +101 -0
- package/.docs/models/providers/chutes.md +136 -0
- package/.docs/models/providers/cloudflare-ai-gateway.md +33 -0
- package/.docs/models/providers/cloudflare-workers-ai.md +109 -0
- package/.docs/models/providers/cohere.md +33 -0
- package/.docs/models/providers/cortecs.md +91 -0
- package/.docs/models/providers/deepinfra.md +112 -0
- package/.docs/models/providers/deepseek.md +88 -0
- package/.docs/models/providers/fastrouter.md +84 -0
- package/.docs/models/providers/fireworks-ai.md +89 -0
- package/.docs/models/providers/firmware.md +85 -0
- package/.docs/models/providers/friendli.md +78 -0
- package/.docs/models/providers/github-models.md +125 -0
- package/.docs/models/providers/google-vertex.md +33 -0
- package/.docs/models/providers/google.md +159 -0
- package/.docs/models/providers/groq.md +107 -0
- package/.docs/models/providers/helicone.md +161 -0
- package/.docs/models/providers/huggingface.md +90 -0
- package/.docs/models/providers/iflowcn.md +84 -0
- package/.docs/models/providers/inception.md +72 -0
- package/.docs/models/providers/inference.md +79 -0
- package/.docs/models/providers/io-intelligence.md +87 -0
- package/.docs/models/providers/io-net.md +87 -0
- package/.docs/models/providers/jiekou.md +131 -0
- package/.docs/models/providers/kilo.md +333 -0
- package/.docs/models/providers/kimi-for-coding.md +100 -0
- package/.docs/models/providers/kuae-cloud-coding-plan.md +71 -0
- package/.docs/models/providers/llama.md +77 -0
- package/.docs/models/providers/lmstudio.md +73 -0
- package/.docs/models/providers/lucidquery.md +72 -0
- package/.docs/models/providers/minimax-cn-coding-plan.md +102 -0
- package/.docs/models/providers/minimax-cn.md +102 -0
- package/.docs/models/providers/minimax-coding-plan.md +102 -0
- package/.docs/models/providers/minimax.md +104 -0
- package/.docs/models/providers/mistral.md +124 -0
- package/.docs/models/providers/moark.md +72 -0
- package/.docs/models/providers/modelscope.md +77 -0
- package/.docs/models/providers/moonshotai-cn.md +76 -0
- package/.docs/models/providers/moonshotai.md +76 -0
- package/.docs/models/providers/morph.md +73 -0
- package/.docs/models/providers/nano-gpt.md +103 -0
- package/.docs/models/providers/nebius.md +116 -0
- package/.docs/models/providers/nova.md +72 -0
- package/.docs/models/providers/novita-ai.md +154 -0
- package/.docs/models/providers/nvidia.md +141 -0
- package/.docs/models/providers/ollama-cloud.md +103 -0
- package/.docs/models/providers/ollama.md +33 -0
- package/.docs/models/providers/openai.md +193 -0
- package/.docs/models/providers/opencode.md +100 -0
- package/.docs/models/providers/ovhcloud.md +83 -0
- package/.docs/models/providers/perplexity.md +100 -0
- package/.docs/models/providers/poe.md +183 -0
- package/.docs/models/providers/privatemode-ai.md +75 -0
- package/.docs/models/providers/requesty.md +90 -0
- package/.docs/models/providers/scaleway.md +84 -0
- package/.docs/models/providers/siliconflow-cn.md +138 -0
- package/.docs/models/providers/siliconflow.md +140 -0
- package/.docs/models/providers/stackit.md +78 -0
- package/.docs/models/providers/stepfun.md +73 -0
- package/.docs/models/providers/submodel.md +79 -0
- package/.docs/models/providers/synthetic.md +96 -0
- package/.docs/models/providers/togetherai.md +115 -0
- package/.docs/models/providers/upstage.md +73 -0
- package/.docs/models/providers/venice.md +95 -0
- package/.docs/models/providers/vivgrid.md +106 -0
- package/.docs/models/providers/vultr.md +75 -0
- package/.docs/models/providers/wandb.md +80 -0
- package/.docs/models/providers/xai.md +141 -0
- package/.docs/models/providers/xiaomi.md +71 -0
- package/.docs/models/providers/zai-coding-plan.md +80 -0
- package/.docs/models/providers/zai.md +79 -0
- package/.docs/models/providers/zenmux.md +161 -0
- package/.docs/models/providers/zhipuai-coding-plan.md +79 -0
- package/.docs/models/providers/zhipuai.md +79 -0
- package/.docs/models/providers.md +81 -0
- package/.docs/reference/agents/agent.md +141 -0
- package/.docs/reference/agents/generate.md +186 -0
- package/.docs/reference/agents/generateLegacy.md +173 -0
- package/.docs/reference/agents/getDefaultGenerateOptions.md +36 -0
- package/.docs/reference/agents/getDefaultOptions.md +34 -0
- package/.docs/reference/agents/getDefaultStreamOptions.md +36 -0
- package/.docs/reference/agents/getDescription.md +21 -0
- package/.docs/reference/agents/getInstructions.md +34 -0
- package/.docs/reference/agents/getLLM.md +37 -0
- package/.docs/reference/agents/getMemory.md +34 -0
- package/.docs/reference/agents/getModel.md +34 -0
- package/.docs/reference/agents/getTools.md +29 -0
- package/.docs/reference/agents/getVoice.md +34 -0
- package/.docs/reference/agents/listAgents.md +35 -0
- package/.docs/reference/agents/listScorers.md +34 -0
- package/.docs/reference/agents/listTools.md +34 -0
- package/.docs/reference/agents/listWorkflows.md +34 -0
- package/.docs/reference/agents/network.md +133 -0
- package/.docs/reference/ai-sdk/chat-route.md +82 -0
- package/.docs/reference/ai-sdk/handle-chat-stream.md +53 -0
- package/.docs/reference/ai-sdk/handle-network-stream.md +37 -0
- package/.docs/reference/ai-sdk/handle-workflow-stream.md +55 -0
- package/.docs/reference/ai-sdk/network-route.md +74 -0
- package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +231 -0
- package/.docs/reference/ai-sdk/to-ai-sdk-v4-messages.md +79 -0
- package/.docs/reference/ai-sdk/to-ai-sdk-v5-messages.md +76 -0
- package/.docs/reference/ai-sdk/with-mastra.md +59 -0
- package/.docs/reference/ai-sdk/workflow-route.md +79 -0
- package/.docs/reference/auth/auth0.md +73 -0
- package/.docs/reference/auth/better-auth.md +71 -0
- package/.docs/reference/auth/clerk.md +36 -0
- package/.docs/reference/auth/firebase.md +80 -0
- package/.docs/reference/auth/jwt.md +26 -0
- package/.docs/reference/auth/supabase.md +33 -0
- package/.docs/reference/auth/workos.md +84 -0
- package/.docs/reference/cli/create-mastra.md +137 -0
- package/.docs/reference/cli/mastra.md +336 -0
- package/.docs/reference/client-js/agents.md +437 -0
- package/.docs/reference/client-js/error-handling.md +16 -0
- package/.docs/reference/client-js/logs.md +24 -0
- package/.docs/reference/client-js/mastra-client.md +63 -0
- package/.docs/reference/client-js/memory.md +221 -0
- package/.docs/reference/client-js/observability.md +72 -0
- package/.docs/reference/client-js/telemetry.md +20 -0
- package/.docs/reference/client-js/tools.md +44 -0
- package/.docs/reference/client-js/vectors.md +79 -0
- package/.docs/reference/client-js/workflows.md +199 -0
- package/.docs/reference/configuration.md +752 -0
- package/.docs/reference/core/addGateway.md +42 -0
- package/.docs/reference/core/getAgent.md +21 -0
- package/.docs/reference/core/getAgentById.md +21 -0
- package/.docs/reference/core/getDeployer.md +22 -0
- package/.docs/reference/core/getGateway.md +38 -0
- package/.docs/reference/core/getGatewayById.md +41 -0
- package/.docs/reference/core/getLogger.md +22 -0
- package/.docs/reference/core/getMCPServer.md +47 -0
- package/.docs/reference/core/getMCPServerById.md +55 -0
- package/.docs/reference/core/getMemory.md +50 -0
- package/.docs/reference/core/getScorer.md +54 -0
- package/.docs/reference/core/getScorerById.md +54 -0
- package/.docs/reference/core/getServer.md +22 -0
- package/.docs/reference/core/getStorage.md +22 -0
- package/.docs/reference/core/getStoredAgentById.md +89 -0
- package/.docs/reference/core/getTelemetry.md +22 -0
- package/.docs/reference/core/getVector.md +22 -0
- package/.docs/reference/core/getWorkflow.md +42 -0
- package/.docs/reference/core/listAgents.md +21 -0
- package/.docs/reference/core/listGateways.md +40 -0
- package/.docs/reference/core/listLogs.md +38 -0
- package/.docs/reference/core/listLogsByRunId.md +36 -0
- package/.docs/reference/core/listMCPServers.md +55 -0
- package/.docs/reference/core/listMemory.md +56 -0
- package/.docs/reference/core/listScorers.md +29 -0
- package/.docs/reference/core/listStoredAgents.md +93 -0
- package/.docs/reference/core/listVectors.md +22 -0
- package/.docs/reference/core/listWorkflows.md +21 -0
- package/.docs/reference/core/mastra-class.md +66 -0
- package/.docs/reference/core/mastra-model-gateway.md +153 -0
- package/.docs/reference/core/setLogger.md +26 -0
- package/.docs/reference/core/setStorage.md +27 -0
- package/.docs/reference/datasets/addItem.md +37 -0
- package/.docs/reference/datasets/addItems.md +35 -0
- package/.docs/reference/datasets/compareExperiments.md +52 -0
- package/.docs/reference/datasets/create.md +51 -0
- package/.docs/reference/datasets/dataset.md +82 -0
- package/.docs/reference/datasets/datasets-manager.md +94 -0
- package/.docs/reference/datasets/delete.md +25 -0
- package/.docs/reference/datasets/deleteExperiment.md +27 -0
- package/.docs/reference/datasets/deleteItem.md +27 -0
- package/.docs/reference/datasets/deleteItems.md +29 -0
- package/.docs/reference/datasets/get.md +31 -0
- package/.docs/reference/datasets/getDetails.md +47 -0
- package/.docs/reference/datasets/getExperiment.md +30 -0
- package/.docs/reference/datasets/getItem.md +33 -0
- package/.docs/reference/datasets/getItemHistory.md +31 -0
- package/.docs/reference/datasets/list.md +31 -0
- package/.docs/reference/datasets/listExperimentResults.md +39 -0
- package/.docs/reference/datasets/listExperiments.md +33 -0
- package/.docs/reference/datasets/listItems.md +46 -0
- package/.docs/reference/datasets/listVersions.md +33 -0
- package/.docs/reference/datasets/startExperiment.md +62 -0
- package/.docs/reference/datasets/startExperimentAsync.md +43 -0
- package/.docs/reference/datasets/update.md +48 -0
- package/.docs/reference/datasets/updateItem.md +38 -0
- package/.docs/reference/deployer/cloudflare.md +79 -0
- package/.docs/reference/deployer/netlify.md +80 -0
- package/.docs/reference/deployer/vercel.md +91 -0
- package/.docs/reference/deployer.md +100 -0
- package/.docs/reference/evals/answer-relevancy.md +105 -0
- package/.docs/reference/evals/answer-similarity.md +99 -0
- package/.docs/reference/evals/bias.md +120 -0
- package/.docs/reference/evals/completeness.md +136 -0
- package/.docs/reference/evals/content-similarity.md +101 -0
- package/.docs/reference/evals/context-precision.md +196 -0
- package/.docs/reference/evals/context-relevance.md +531 -0
- package/.docs/reference/evals/create-scorer.md +270 -0
- package/.docs/reference/evals/faithfulness.md +114 -0
- package/.docs/reference/evals/hallucination.md +213 -0
- package/.docs/reference/evals/keyword-coverage.md +128 -0
- package/.docs/reference/evals/mastra-scorer.md +123 -0
- package/.docs/reference/evals/noise-sensitivity.md +675 -0
- package/.docs/reference/evals/prompt-alignment.md +614 -0
- package/.docs/reference/evals/run-evals.md +179 -0
- package/.docs/reference/evals/scorer-utils.md +326 -0
- package/.docs/reference/evals/textual-difference.md +113 -0
- package/.docs/reference/evals/tone-consistency.md +119 -0
- package/.docs/reference/evals/tool-call-accuracy.md +533 -0
- package/.docs/reference/evals/toxicity.md +123 -0
- package/.docs/reference/harness/harness-class.md +708 -0
- package/.docs/reference/index.md +277 -0
- package/.docs/reference/logging/pino-logger.md +117 -0
- package/.docs/reference/mastra-code/createMastraCode.md +108 -0
- package/.docs/reference/memory/clone-utilities.md +199 -0
- package/.docs/reference/memory/cloneThread.md +130 -0
- package/.docs/reference/memory/createThread.md +68 -0
- package/.docs/reference/memory/deleteMessages.md +38 -0
- package/.docs/reference/memory/getThreadById.md +24 -0
- package/.docs/reference/memory/listThreads.md +145 -0
- package/.docs/reference/memory/memory-class.md +147 -0
- package/.docs/reference/memory/observational-memory.md +565 -0
- package/.docs/reference/memory/recall.md +91 -0
- package/.docs/reference/observability/tracing/bridges/otel.md +131 -0
- package/.docs/reference/observability/tracing/configuration.md +178 -0
- package/.docs/reference/observability/tracing/exporters/arize.md +141 -0
- package/.docs/reference/observability/tracing/exporters/braintrust.md +93 -0
- package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +163 -0
- package/.docs/reference/observability/tracing/exporters/console-exporter.md +138 -0
- package/.docs/reference/observability/tracing/exporters/datadog.md +116 -0
- package/.docs/reference/observability/tracing/exporters/default-exporter.md +174 -0
- package/.docs/reference/observability/tracing/exporters/laminar.md +78 -0
- package/.docs/reference/observability/tracing/exporters/langfuse.md +134 -0
- package/.docs/reference/observability/tracing/exporters/langsmith.md +108 -0
- package/.docs/reference/observability/tracing/exporters/otel.md +199 -0
- package/.docs/reference/observability/tracing/exporters/posthog.md +92 -0
- package/.docs/reference/observability/tracing/exporters/sentry.md +184 -0
- package/.docs/reference/observability/tracing/instances.md +107 -0
- package/.docs/reference/observability/tracing/interfaces.md +743 -0
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +144 -0
- package/.docs/reference/observability/tracing/spans.md +224 -0
- package/.docs/reference/processors/batch-parts-processor.md +61 -0
- package/.docs/reference/processors/language-detector.md +82 -0
- package/.docs/reference/processors/message-history-processor.md +85 -0
- package/.docs/reference/processors/moderation-processor.md +104 -0
- package/.docs/reference/processors/pii-detector.md +108 -0
- package/.docs/reference/processors/processor-interface.md +521 -0
- package/.docs/reference/processors/prompt-injection-detector.md +72 -0
- package/.docs/reference/processors/semantic-recall-processor.md +117 -0
- package/.docs/reference/processors/system-prompt-scrubber.md +80 -0
- package/.docs/reference/processors/token-limiter-processor.md +115 -0
- package/.docs/reference/processors/tool-call-filter.md +85 -0
- package/.docs/reference/processors/tool-search-processor.md +111 -0
- package/.docs/reference/processors/unicode-normalizer.md +62 -0
- package/.docs/reference/processors/working-memory-processor.md +152 -0
- package/.docs/reference/rag/chunk.md +221 -0
- package/.docs/reference/rag/database-config.md +261 -0
- package/.docs/reference/rag/document.md +114 -0
- package/.docs/reference/rag/embeddings.md +92 -0
- package/.docs/reference/rag/extract-params.md +168 -0
- package/.docs/reference/rag/graph-rag.md +111 -0
- package/.docs/reference/rag/metadata-filters.md +216 -0
- package/.docs/reference/rag/rerank.md +75 -0
- package/.docs/reference/rag/rerankWithScorer.md +80 -0
- package/.docs/reference/server/create-route.md +262 -0
- package/.docs/reference/server/express-adapter.md +176 -0
- package/.docs/reference/server/fastify-adapter.md +90 -0
- package/.docs/reference/server/hono-adapter.md +162 -0
- package/.docs/reference/server/koa-adapter.md +127 -0
- package/.docs/reference/server/mastra-server.md +298 -0
- package/.docs/reference/server/register-api-route.md +249 -0
- package/.docs/reference/server/routes.md +306 -0
- package/.docs/reference/storage/cloudflare-d1.md +218 -0
- package/.docs/reference/storage/cloudflare.md +88 -0
- package/.docs/reference/storage/composite.md +235 -0
- package/.docs/reference/storage/convex.md +161 -0
- package/.docs/reference/storage/dynamodb.md +282 -0
- package/.docs/reference/storage/lance.md +131 -0
- package/.docs/reference/storage/libsql.md +135 -0
- package/.docs/reference/storage/mongodb.md +262 -0
- package/.docs/reference/storage/mssql.md +157 -0
- package/.docs/reference/storage/overview.md +121 -0
- package/.docs/reference/storage/postgresql.md +526 -0
- package/.docs/reference/storage/upstash.md +160 -0
- package/.docs/reference/streaming/ChunkType.md +292 -0
- package/.docs/reference/streaming/agents/MastraModelOutput.md +182 -0
- package/.docs/reference/streaming/agents/stream.md +221 -0
- package/.docs/reference/streaming/agents/streamLegacy.md +142 -0
- package/.docs/reference/streaming/workflows/observeStream.md +42 -0
- package/.docs/reference/streaming/workflows/resumeStream.md +61 -0
- package/.docs/reference/streaming/workflows/stream.md +88 -0
- package/.docs/reference/streaming/workflows/timeTravelStream.md +142 -0
- package/.docs/reference/templates/overview.md +194 -0
- package/.docs/reference/tools/create-tool.md +237 -0
- package/.docs/reference/tools/document-chunker-tool.md +89 -0
- package/.docs/reference/tools/graph-rag-tool.md +182 -0
- package/.docs/reference/tools/mcp-client.md +954 -0
- package/.docs/reference/tools/mcp-server.md +1271 -0
- package/.docs/reference/tools/vector-query-tool.md +459 -0
- package/.docs/reference/vectors/astra.md +121 -0
- package/.docs/reference/vectors/chroma.md +264 -0
- package/.docs/reference/vectors/convex.md +300 -0
- package/.docs/reference/vectors/couchbase.md +226 -0
- package/.docs/reference/vectors/duckdb.md +318 -0
- package/.docs/reference/vectors/elasticsearch.md +189 -0
- package/.docs/reference/vectors/lance.md +220 -0
- package/.docs/reference/vectors/libsql.md +305 -0
- package/.docs/reference/vectors/mongodb.md +295 -0
- package/.docs/reference/vectors/opensearch.md +99 -0
- package/.docs/reference/vectors/pg.md +408 -0
- package/.docs/reference/vectors/pinecone.md +168 -0
- package/.docs/reference/vectors/qdrant.md +222 -0
- package/.docs/reference/vectors/s3vectors.md +277 -0
- package/.docs/reference/vectors/turbopuffer.md +157 -0
- package/.docs/reference/vectors/upstash.md +294 -0
- package/.docs/reference/vectors/vectorize.md +147 -0
- package/.docs/reference/voice/azure.md +148 -0
- package/.docs/reference/voice/cloudflare.md +83 -0
- package/.docs/reference/voice/composite-voice.md +121 -0
- package/.docs/reference/voice/deepgram.md +79 -0
- package/.docs/reference/voice/elevenlabs.md +98 -0
- package/.docs/reference/voice/google-gemini-live.md +378 -0
- package/.docs/reference/voice/google.md +228 -0
- package/.docs/reference/voice/mastra-voice.md +311 -0
- package/.docs/reference/voice/murf.md +122 -0
- package/.docs/reference/voice/openai-realtime.md +203 -0
- package/.docs/reference/voice/openai.md +88 -0
- package/.docs/reference/voice/playai.md +80 -0
- package/.docs/reference/voice/sarvam.md +126 -0
- package/.docs/reference/voice/speechify.md +75 -0
- package/.docs/reference/voice/voice.addInstructions.md +55 -0
- package/.docs/reference/voice/voice.addTools.md +67 -0
- package/.docs/reference/voice/voice.answer.md +54 -0
- package/.docs/reference/voice/voice.close.md +51 -0
- package/.docs/reference/voice/voice.connect.md +94 -0
- package/.docs/reference/voice/voice.events.md +37 -0
- package/.docs/reference/voice/voice.getSpeakers.md +129 -0
- package/.docs/reference/voice/voice.listen.md +164 -0
- package/.docs/reference/voice/voice.off.md +54 -0
- package/.docs/reference/voice/voice.on.md +111 -0
- package/.docs/reference/voice/voice.send.md +65 -0
- package/.docs/reference/voice/voice.speak.md +157 -0
- package/.docs/reference/voice/voice.updateConfig.md +60 -0
- package/.docs/reference/workflows/run-methods/cancel.md +86 -0
- package/.docs/reference/workflows/run-methods/restart.md +33 -0
- package/.docs/reference/workflows/run-methods/resume.md +59 -0
- package/.docs/reference/workflows/run-methods/start.md +58 -0
- package/.docs/reference/workflows/run-methods/startAsync.md +67 -0
- package/.docs/reference/workflows/run-methods/timeTravel.md +142 -0
- package/.docs/reference/workflows/run.md +59 -0
- package/.docs/reference/workflows/step.md +119 -0
- package/.docs/reference/workflows/workflow-methods/branch.md +25 -0
- package/.docs/reference/workflows/workflow-methods/commit.md +17 -0
- package/.docs/reference/workflows/workflow-methods/create-run.md +63 -0
- package/.docs/reference/workflows/workflow-methods/dountil.md +25 -0
- package/.docs/reference/workflows/workflow-methods/dowhile.md +25 -0
- package/.docs/reference/workflows/workflow-methods/foreach.md +118 -0
- package/.docs/reference/workflows/workflow-methods/map.md +93 -0
- package/.docs/reference/workflows/workflow-methods/parallel.md +21 -0
- package/.docs/reference/workflows/workflow-methods/sleep.md +35 -0
- package/.docs/reference/workflows/workflow-methods/sleepUntil.md +35 -0
- package/.docs/reference/workflows/workflow-methods/then.md +21 -0
- package/.docs/reference/workflows/workflow.md +157 -0
- package/.docs/reference/workspace/e2b-sandbox.md +289 -0
- package/.docs/reference/workspace/filesystem.md +255 -0
- package/.docs/reference/workspace/gcs-filesystem.md +174 -0
- package/.docs/reference/workspace/local-filesystem.md +343 -0
- package/.docs/reference/workspace/local-sandbox.md +301 -0
- package/.docs/reference/workspace/s3-filesystem.md +175 -0
- package/.docs/reference/workspace/sandbox.md +87 -0
- package/.docs/reference/workspace/workspace-class.md +244 -0
- package/CHANGELOG.md +8 -0
- package/package.json +5 -5
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
# Mastra Guides
|
|
2
|
+
|
|
3
|
+
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.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Migrate from AgentNetwork to `.network()`
|
|
2
|
+
|
|
3
|
+
As of `v0.20.0` for `@mastra/core`, the following changes apply.
|
|
4
|
+
|
|
5
|
+
## Upgrade from AI SDK v4 to v5
|
|
6
|
+
|
|
7
|
+
- Bump all your model provider packages by a major version.
|
|
8
|
+
|
|
9
|
+
> **Note:** This will ensure that they are all v5 models now.
|
|
10
|
+
|
|
11
|
+
## Memory is required
|
|
12
|
+
|
|
13
|
+
- Memory is now required for the agent network to function properly.
|
|
14
|
+
|
|
15
|
+
> **Note:** You must configure memory for the agent.
|
|
16
|
+
|
|
17
|
+
## Migration paths
|
|
18
|
+
|
|
19
|
+
If you were using the `AgentNetwork` primitive, you can replace the `AgentNetwork` with `Agent`.
|
|
20
|
+
|
|
21
|
+
Before:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { AgentNetwork } from '@mastra/core/network'
|
|
25
|
+
|
|
26
|
+
const agent = new AgentNetwork({
|
|
27
|
+
name: 'agent-network',
|
|
28
|
+
agents: [agent1, agent2],
|
|
29
|
+
tools: { tool1, tool2 },
|
|
30
|
+
model: 'openai/gpt-5.1',
|
|
31
|
+
instructions: 'You are a network agent that can help users with a variety of tasks.',
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
await agent.stream('Find me the weather in Tokyo.')
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
After:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { Agent } from '@mastra/core/agent'
|
|
41
|
+
import { Memory } from '@mastra/memory'
|
|
42
|
+
|
|
43
|
+
const memory = new Memory()
|
|
44
|
+
|
|
45
|
+
const agent = new Agent({
|
|
46
|
+
id: 'agent-network',
|
|
47
|
+
name: 'agent-network',
|
|
48
|
+
agents: { agent1, agent2 },
|
|
49
|
+
tools: { tool1, tool2 },
|
|
50
|
+
model: 'openai/gpt-5.1',
|
|
51
|
+
instructions: 'You are a network agent that can help users with a variety of tasks.',
|
|
52
|
+
memory,
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
await agent.network('Find me the weather in Tokyo.')
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
If you were using the `NewAgentNetwork` primitive, you can replace the `NewAgentNetwork` with `Agent`.
|
|
59
|
+
|
|
60
|
+
Before:
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { NewAgentNetwork } from '@mastra/core/network/vnext'
|
|
64
|
+
|
|
65
|
+
const agent = new NewAgentNetwork({
|
|
66
|
+
id: 'agent-network',
|
|
67
|
+
name: 'agent-network',
|
|
68
|
+
agents: { agent1, agent2 },
|
|
69
|
+
workflows: { workflow1 },
|
|
70
|
+
tools: { tool1, tool2 },
|
|
71
|
+
model: 'openai/gpt-5.1',
|
|
72
|
+
instructions: 'You are a network agent that can help users with a variety of tasks.',
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
await agent.loop('Find me the weather in Tokyo.')
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
After:
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import { Agent } from '@mastra/core/agent'
|
|
82
|
+
import { Memory } from '@mastra/memory'
|
|
83
|
+
|
|
84
|
+
const memory = new Memory()
|
|
85
|
+
|
|
86
|
+
const agent = new Agent({
|
|
87
|
+
name: 'agent-network',
|
|
88
|
+
agents: { agent1, agent2 },
|
|
89
|
+
workflows: { workflow1 },
|
|
90
|
+
tools: { tool1, tool2 },
|
|
91
|
+
model: 'openai/gpt-5.1',
|
|
92
|
+
instructions: 'You are a network agent that can help users with a variety of tasks.',
|
|
93
|
+
memory,
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
await agent.network('Find me the weather in Tokyo.')
|
|
97
|
+
```
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Migrate from AI SDK v4 to v5
|
|
2
|
+
|
|
3
|
+
Looking for integration docs? See [Using AI SDK](https://mastra.ai/guides/build-your-ui/ai-sdk-ui).
|
|
4
|
+
|
|
5
|
+
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.
|
|
6
|
+
|
|
7
|
+
This guide covers only the Mastra-specific aspects of the migration.
|
|
8
|
+
|
|
9
|
+
- **Data compatibility**: New data stored in v5 format will no longer work if you downgrade from v5 to v4
|
|
10
|
+
- **Backup recommendation**: Keep DB backups from before you upgrade to v5
|
|
11
|
+
|
|
12
|
+
## Memory and Storage
|
|
13
|
+
|
|
14
|
+
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.
|
|
15
|
+
|
|
16
|
+
## Message Format Conversion
|
|
17
|
+
|
|
18
|
+
For cases where you need to manually convert messages between AI SDK and Mastra formats, use the `convertMessages()` utility:
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { convertMessages } from '@mastra/core/agent'
|
|
22
|
+
|
|
23
|
+
// Convert AI SDK v4 messages to v5
|
|
24
|
+
const aiv5Messages = convertMessages(aiv4Messages).to('AIV5.UI')
|
|
25
|
+
|
|
26
|
+
// Convert Mastra messages to AI SDK v5
|
|
27
|
+
const aiv5Messages = convertMessages(mastraMessages).to('AIV5.Core')
|
|
28
|
+
|
|
29
|
+
// Supported output formats:
|
|
30
|
+
// 'Mastra.V2', 'AIV4.UI', 'AIV5.UI', 'AIV5.Core', 'AIV5.Model'
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
This utility is helpful when you want to fetch messages directly from your storage DB and convert them for use in AI SDK.
|
|
34
|
+
|
|
35
|
+
## Type Inference for Tools
|
|
36
|
+
|
|
37
|
+
When using tools with TypeScript in AI SDK v5, Mastra provides type inference helpers to ensure type safety for your tool inputs and outputs.
|
|
38
|
+
|
|
39
|
+
### `InferUITool`
|
|
40
|
+
|
|
41
|
+
The `InferUITool` type helper infers the input and output types of a single Mastra tool:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { InferUITool, createTool } from '@mastra/core/tools'
|
|
45
|
+
import { z } from 'zod'
|
|
46
|
+
|
|
47
|
+
const weatherTool = createTool({
|
|
48
|
+
id: 'get-weather',
|
|
49
|
+
description: 'Get the current weather',
|
|
50
|
+
inputSchema: z.object({
|
|
51
|
+
location: z.string().describe('The city and state'),
|
|
52
|
+
}),
|
|
53
|
+
outputSchema: z.object({
|
|
54
|
+
temperature: z.number(),
|
|
55
|
+
conditions: z.string(),
|
|
56
|
+
}),
|
|
57
|
+
execute: async inputData => {
|
|
58
|
+
return {
|
|
59
|
+
temperature: 72,
|
|
60
|
+
conditions: 'sunny',
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
// Infer the types from the tool
|
|
66
|
+
type WeatherUITool = InferUITool<typeof weatherTool>
|
|
67
|
+
// This creates:
|
|
68
|
+
// {
|
|
69
|
+
// input: { location: string };
|
|
70
|
+
// output: { temperature: number; conditions: string };
|
|
71
|
+
// }
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### `InferUITools`
|
|
75
|
+
|
|
76
|
+
The `InferUITools` type helper infers the input and output types of multiple tools:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { InferUITools, createTool } from '@mastra/core/tools'
|
|
80
|
+
import { z } from 'zod'
|
|
81
|
+
|
|
82
|
+
// Using weatherTool from the previous example
|
|
83
|
+
const tools = {
|
|
84
|
+
weather: weatherTool,
|
|
85
|
+
calculator: createTool({
|
|
86
|
+
id: 'calculator',
|
|
87
|
+
description: 'Perform basic arithmetic',
|
|
88
|
+
inputSchema: z.object({
|
|
89
|
+
operation: z.enum(['add', 'subtract', 'multiply', 'divide']),
|
|
90
|
+
a: z.number(),
|
|
91
|
+
b: z.number(),
|
|
92
|
+
}),
|
|
93
|
+
outputSchema: z.object({
|
|
94
|
+
result: z.number(),
|
|
95
|
+
}),
|
|
96
|
+
execute: async inputData => {
|
|
97
|
+
// implementation...
|
|
98
|
+
return { result: 0 }
|
|
99
|
+
},
|
|
100
|
+
}),
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Infer types from the tool set
|
|
104
|
+
export type MyUITools = InferUITools<typeof tools>
|
|
105
|
+
// This creates:
|
|
106
|
+
// {
|
|
107
|
+
// weather: { input: { location: string }; output: { temperature: number; conditions: string } };
|
|
108
|
+
// calculator: { input: { operation: "add" | "subtract" | "multiply" | "divide"; a: number; b: number }; output: { result: number } };
|
|
109
|
+
// }
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
These type helpers provide full TypeScript support when using Mastra tools with AI SDK v5 UI components, ensuring type safety across your application.
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# Migrate from `.network()` to Supervisor Pattern
|
|
2
|
+
|
|
3
|
+
The supervisor pattern using `Agent.stream()` and `Agent.generate()` is the recommended approach for coordinating multiple agents, replacing the older `.network()` API. This guide walks you through each step of the migration.
|
|
4
|
+
|
|
5
|
+
> **.network() Deprecation:** `.network()` is deprecated and will be removed in a future release. While existing code will continue to work until then, no new features will be added to it. Migrate to the supervisor pattern as soon as possible.
|
|
6
|
+
|
|
7
|
+
## Replace `.network()` with `.stream()` or `.generate()`
|
|
8
|
+
|
|
9
|
+
The core change is replacing `.network()` calls with `.stream()` (for streaming) or `.generate()` (for non-streaming). The agent configuration stays the same -- you still define `agents`, `workflows`, `tools`, and `memory` on the agent. The difference is how you call it and how you process the results.
|
|
10
|
+
|
|
11
|
+
With `.network()`, you iterated over custom event types like `network-execution-event-step-finish`. With `.stream()`, you use the standard `textStream` or `fullStream` iterators.
|
|
12
|
+
|
|
13
|
+
**Before:**
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
const result = await routingAgent.network('Research AI in education')
|
|
17
|
+
|
|
18
|
+
for await (const chunk of result) {
|
|
19
|
+
if (chunk.type === 'network-execution-event-step-finish') {
|
|
20
|
+
console.log(chunk.payload.result)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**After:**
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
const stream = await supervisorAgent.stream('Research AI in education', {
|
|
29
|
+
maxSteps: 10,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
for await (const chunk of stream.textStream) {
|
|
33
|
+
process.stdout.write(chunk)
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The `maxSteps` option limits how many iterations the supervisor can take. This replaces the implicit iteration limit in `.network()`.
|
|
38
|
+
|
|
39
|
+
For non-streaming use cases, use `generate()` with the same options:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
const result = await supervisorAgent.generate('Research AI in education', {
|
|
43
|
+
maxSteps: 10,
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
console.log(result.text)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Write clear supervisor instructions
|
|
50
|
+
|
|
51
|
+
With `.network()`, the routing agent relied on generic instructions and primitive descriptions to decide what to call. The supervisor pattern works the same way, but clear and specific instructions significantly improve delegation accuracy.
|
|
52
|
+
|
|
53
|
+
Your supervisor's `instructions` should specify what resources are available, when to use each one, how to coordinate them, and when the task is complete.
|
|
54
|
+
|
|
55
|
+
**Before:**
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
const routingAgent = new Agent({
|
|
59
|
+
id: 'routing-agent',
|
|
60
|
+
instructions: 'You are a network of researchers and writers...',
|
|
61
|
+
agents: { researchAgent, writingAgent },
|
|
62
|
+
memory: new Memory(),
|
|
63
|
+
})
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**After:**
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
const supervisorAgent = new Agent({
|
|
70
|
+
id: 'supervisor-agent',
|
|
71
|
+
instructions: `You coordinate research and writing tasks using specialized agents.
|
|
72
|
+
|
|
73
|
+
Available resources:
|
|
74
|
+
- researchAgent: Gathers factual data and sources (returns bullet points)
|
|
75
|
+
- writingAgent: Transforms research into narrative content (returns full paragraphs)
|
|
76
|
+
|
|
77
|
+
Delegation strategy:
|
|
78
|
+
1. For research requests: Delegate to researchAgent first
|
|
79
|
+
2. For writing requests: Delegate to writingAgent (provide research if available)
|
|
80
|
+
3. For complex requests: Delegate to researchAgent first, then writingAgent
|
|
81
|
+
|
|
82
|
+
Success criteria:
|
|
83
|
+
- All user questions are fully answered
|
|
84
|
+
- Response is well-formatted and complete
|
|
85
|
+
- If information is incomplete, continue iterating`,
|
|
86
|
+
agents: { researchAgent, writingAgent },
|
|
87
|
+
memory: new Memory(),
|
|
88
|
+
})
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Add descriptions to subagents
|
|
92
|
+
|
|
93
|
+
Each subagent should have a `description` field that explains what it does, what format it returns, and when it should be used. The supervisor uses these descriptions to decide which agent to delegate to.
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
const researchAgent = new Agent({
|
|
97
|
+
id: 'research-agent',
|
|
98
|
+
description: `Specializes in gathering factual information and data on any topic.
|
|
99
|
+
Returns concise bullet-point summaries with key facts and sources.
|
|
100
|
+
Does not write full articles or narrative content.`,
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
const writingAgent = new Agent({
|
|
104
|
+
id: 'writing-agent',
|
|
105
|
+
description: `Transforms research material into well-structured written content.
|
|
106
|
+
Produces full paragraphs and complete articles.
|
|
107
|
+
Best used after research has been gathered.`,
|
|
108
|
+
})
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Update event handling
|
|
112
|
+
|
|
113
|
+
If you were handling specific `.network()` events, update them to use the standard stream chunk types:
|
|
114
|
+
|
|
115
|
+
| `.network()` event | Supervisor pattern chunk |
|
|
116
|
+
| ------------------------------------- | -------------------------------------- |
|
|
117
|
+
| `routing-agent-start` | `step-start` |
|
|
118
|
+
| `routing-agent-end` | `step-finish` |
|
|
119
|
+
| `agent-execution-start` | `step-start` (when delegating) |
|
|
120
|
+
| `agent-execution-event-text-delta` | `text-delta` |
|
|
121
|
+
| `agent-execution-event-finish` | `step-finish` |
|
|
122
|
+
| `network-execution-event-step-finish` | `step-finish` + `finishReason: 'stop'` |
|
|
123
|
+
| `network-object` | `object-delta` (with structuredOutput) |
|
|
124
|
+
| `network-object-result` | `object` (with structuredOutput) |
|
|
125
|
+
|
|
126
|
+
## Add delegation hooks
|
|
127
|
+
|
|
128
|
+
The supervisor pattern lets you hook into the delegation lifecycle to monitor, modify, or reject delegations. These hooks can be configured in the agent's `defaultOptions` or passed per-call.
|
|
129
|
+
|
|
130
|
+
`onDelegationStart` is called before the supervisor delegates to a subagent. You can modify the prompt, limit the subagent's steps, or reject the delegation entirely:
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
const stream = await supervisorAgent.stream('Research AI in education', {
|
|
134
|
+
maxSteps: 10,
|
|
135
|
+
delegation: {
|
|
136
|
+
onDelegationStart: async context => {
|
|
137
|
+
console.log(`Delegating to: ${context.primitiveId}`)
|
|
138
|
+
|
|
139
|
+
if (context.primitiveId === 'research-agent') {
|
|
140
|
+
return {
|
|
141
|
+
proceed: true,
|
|
142
|
+
modifiedPrompt: `${context.prompt}\n\nFocus on 2024-2025 data.`,
|
|
143
|
+
modifiedMaxSteps: 5,
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (context.iteration > 8) {
|
|
148
|
+
return {
|
|
149
|
+
proceed: false,
|
|
150
|
+
rejectionReason: 'Max iterations reached. Synthesize current findings.',
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return { proceed: true }
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
})
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
`onDelegationComplete` is called after a delegation finishes. You can inspect the result, call `context.bail()` to stop the supervisor loop, and return feedback that gets saved to the supervisor's memory:
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
const stream = await supervisorAgent.stream('Research AI in education', {
|
|
164
|
+
maxSteps: 10,
|
|
165
|
+
delegation: {
|
|
166
|
+
onDelegationComplete: async context => {
|
|
167
|
+
if (context.error) {
|
|
168
|
+
context.bail() // Stop further delegations
|
|
169
|
+
return {
|
|
170
|
+
feedback: `Delegation to ${context.primitiveId} failed: ${context.error}. Try a different approach.`,
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
})
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Add message filtering
|
|
179
|
+
|
|
180
|
+
By default, subagents receive the full conversation context from the supervisor. Use `messageFilter` to control what messages are shared -- for example, to remove sensitive data or limit the number of messages:
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
const stream = await supervisorAgent.stream('Research AI in education', {
|
|
184
|
+
maxSteps: 10,
|
|
185
|
+
delegation: {
|
|
186
|
+
messageFilter: ({ messages, primitiveId, prompt }) => {
|
|
187
|
+
return messages
|
|
188
|
+
.filter(msg => {
|
|
189
|
+
const content =
|
|
190
|
+
typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content)
|
|
191
|
+
return !content.includes('confidential')
|
|
192
|
+
})
|
|
193
|
+
.slice(-10)
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
})
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Add iteration monitoring
|
|
200
|
+
|
|
201
|
+
`onIterationComplete` is called after each iteration of the supervisor loop. You can use it to log progress, provide feedback to guide the agent, or stop execution early:
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
const stream = await supervisorAgent.stream('Research AI in education', {
|
|
205
|
+
maxSteps: 10,
|
|
206
|
+
onIterationComplete: async context => {
|
|
207
|
+
console.log(`Iteration ${context.iteration}/${context.maxIterations}`)
|
|
208
|
+
|
|
209
|
+
if (!context.text.includes('recommendations')) {
|
|
210
|
+
return {
|
|
211
|
+
continue: true,
|
|
212
|
+
feedback: 'Please include specific recommendations in your analysis.',
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (context.text.length > 1000 && context.finishReason === 'stop') {
|
|
217
|
+
return { continue: false }
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return { continue: true }
|
|
221
|
+
},
|
|
222
|
+
})
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Add task completion scoring
|
|
226
|
+
|
|
227
|
+
Task completion scorers automatically validate whether the task is complete. If validation fails, the supervisor continues iterating. The feedback from failed scorers is included in the conversation context so subagents can see what was missing:
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
import { createScorer } from '@mastra/core/evals'
|
|
231
|
+
|
|
232
|
+
const taskCompleteScorer = createScorer({
|
|
233
|
+
id: 'task-complete',
|
|
234
|
+
name: 'Task Completeness',
|
|
235
|
+
}).generateScore(async context => {
|
|
236
|
+
const text = (context.run.output || '').toString()
|
|
237
|
+
const hasAnalysis = text.includes('analysis')
|
|
238
|
+
const hasRecommendations = text.includes('recommendation')
|
|
239
|
+
return hasAnalysis && hasRecommendations ? 1 : 0
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
const stream = await supervisorAgent.stream('Research AI in education', {
|
|
243
|
+
maxSteps: 10,
|
|
244
|
+
isTaskComplete: {
|
|
245
|
+
scorers: [taskCompleteScorer],
|
|
246
|
+
strategy: 'all',
|
|
247
|
+
onComplete: async result => {
|
|
248
|
+
console.log('Task complete:', result.complete)
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
})
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## See also
|
|
255
|
+
|
|
256
|
+
- [Supervisor Agents](https://mastra.ai/docs/agents/supervisor-agents)
|
|
257
|
+
- [Agent Networks](https://mastra.ai/docs/agents/networks)
|
|
258
|
+
- [Agent.stream() Reference](https://mastra.ai/reference/streaming/agents/stream)
|
|
259
|
+
- [Agent.generate() Reference](https://mastra.ai/reference/agents/generate)
|
|
260
|
+
- [Agent Approval](https://mastra.ai/docs/agents/agent-approval)
|
|
261
|
+
- [Guide: Research Coordinator](https://mastra.ai/guides/guide/research-coordinator)
|