@mastra/mcp-docs-server 1.1.8 → 1.1.9-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/agent-memory.md +2 -2
- package/.docs/docs/agents/guardrails.md +3 -3
- package/.docs/docs/agents/network-approval.md +4 -1
- package/.docs/docs/agents/networks.md +1 -1
- package/.docs/docs/agents/overview.md +1 -1
- package/.docs/docs/agents/processors.md +35 -17
- package/.docs/docs/agents/structured-output.md +1 -1
- package/.docs/docs/agents/using-tools.md +2 -2
- package/.docs/docs/build-with-ai/mcp-docs-server.md +4 -4
- package/.docs/docs/build-with-ai/skills.md +1 -1
- package/.docs/docs/community/discord.md +1 -1
- package/.docs/docs/community/licensing.md +1 -1
- package/.docs/docs/deployment/mastra-server.md +1 -1
- package/.docs/docs/deployment/studio.md +2 -2
- package/.docs/docs/deployment/web-framework.md +1 -1
- package/.docs/docs/evals/overview.md +1 -1
- package/.docs/docs/getting-started/build-with-ai.md +1 -1
- package/.docs/docs/getting-started/project-structure.md +1 -1
- package/.docs/docs/index.md +62 -16
- package/.docs/docs/mastra-cloud/deployment.md +1 -1
- package/.docs/docs/mastra-cloud/studio.md +1 -1
- package/.docs/docs/mcp/publishing-mcp-server.md +1 -1
- package/.docs/docs/memory/memory-processors.md +1 -1
- package/.docs/docs/memory/message-history.md +2 -2
- package/.docs/docs/memory/observational-memory.md +6 -2
- package/.docs/docs/memory/semantic-recall.md +2 -2
- package/.docs/docs/memory/storage.md +1 -1
- package/.docs/docs/memory/working-memory.md +6 -6
- package/.docs/docs/observability/tracing/bridges/otel.md +2 -2
- package/.docs/docs/observability/tracing/exporters/default.md +1 -1
- package/.docs/docs/observability/tracing/overview.md +4 -4
- package/.docs/docs/observability/tracing/processors/sensitive-data-filter.md +2 -2
- package/.docs/docs/rag/chunking-and-embedding.md +1 -1
- package/.docs/docs/rag/vector-databases.md +2 -2
- package/.docs/docs/server/auth/auth0.md +1 -1
- package/.docs/docs/server/auth/firebase.md +1 -1
- package/.docs/docs/server/auth/simple-auth.md +1 -1
- package/.docs/docs/server/auth.md +1 -1
- package/.docs/docs/server/mastra-client.md +1 -1
- package/.docs/docs/server/mastra-server.md +1 -1
- package/.docs/docs/server/server-adapters.md +2 -2
- package/.docs/docs/streaming/events.md +1 -1
- package/.docs/docs/streaming/overview.md +1 -1
- package/.docs/docs/streaming/tool-streaming.md +44 -30
- package/.docs/docs/streaming/workflow-streaming.md +1 -1
- package/.docs/docs/workflows/control-flow.md +44 -2
- package/.docs/docs/workflows/error-handling.md +1 -1
- package/.docs/docs/workflows/overview.md +3 -3
- package/.docs/docs/workflows/snapshots.md +1 -1
- package/.docs/docs/workflows/time-travel.md +2 -2
- package/.docs/docs/workspace/filesystem.md +2 -2
- package/.docs/docs/workspace/overview.md +52 -7
- package/.docs/docs/workspace/sandbox.md +72 -13
- package/.docs/docs/workspace/skills.md +2 -2
- package/.docs/guides/build-your-ui/copilotkit.md +1 -1
- package/.docs/guides/deployment/inngest.md +4 -4
- package/.docs/guides/guide/ai-recruiter.md +1 -1
- package/.docs/guides/guide/github-actions-pr-description.md +2 -2
- package/.docs/guides/guide/notes-mcp-server.md +1 -1
- package/.docs/guides/guide/stock-agent.md +2 -2
- package/.docs/guides/migrations/agentnetwork.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/client.md +2 -2
- package/.docs/guides/migrations/upgrade-to-v1/deployment.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/memory.md +2 -2
- package/.docs/guides/migrations/upgrade-to-v1/storage.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/tools.md +2 -2
- package/.docs/guides/migrations/upgrade-to-v1/workflows.md +5 -5
- package/.docs/guides/migrations/vnext-to-standard-apis.md +2 -2
- package/.docs/models/gateways/netlify.md +1 -2
- package/.docs/models/gateways/openrouter.md +8 -1
- package/.docs/models/gateways/vercel.md +3 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/abacus.md +21 -11
- package/.docs/models/providers/aihubmix.md +7 -2
- package/.docs/models/providers/alibaba-cn.md +80 -71
- package/.docs/models/providers/alibaba-coding-plan-cn.md +78 -0
- package/.docs/models/providers/alibaba-coding-plan.md +78 -0
- package/.docs/models/providers/chutes.md +1 -1
- package/.docs/models/providers/clarifai.md +81 -0
- package/.docs/models/providers/cloudferro-sherlock.md +5 -4
- package/.docs/models/providers/cloudflare-workers-ai.md +3 -2
- package/.docs/models/providers/cortecs.md +7 -5
- package/.docs/models/providers/deepinfra.md +7 -2
- package/.docs/models/providers/deepseek.md +1 -1
- package/.docs/models/providers/drun.md +73 -0
- package/.docs/models/providers/firmware.md +28 -20
- package/.docs/models/providers/google.md +3 -1
- package/.docs/models/providers/inception.md +4 -2
- package/.docs/models/providers/kilo.md +3 -1
- package/.docs/models/providers/nano-gpt.md +519 -40
- package/.docs/models/providers/nebius.md +34 -34
- package/.docs/models/providers/nvidia.md +4 -2
- package/.docs/models/providers/ollama-cloud.md +1 -2
- package/.docs/models/providers/openai.md +3 -1
- package/.docs/models/providers/opencode.md +36 -33
- package/.docs/models/providers/poe.md +8 -2
- package/.docs/models/providers/qiniu-ai.md +20 -5
- package/.docs/models/providers/requesty.md +17 -1
- package/.docs/models/providers/siliconflow-cn.md +7 -1
- package/.docs/models/providers/togetherai.md +1 -3
- package/.docs/models/providers/xai.md +28 -25
- package/.docs/models/providers/xiaomi.md +1 -1
- package/.docs/models/providers/zenmux.md +3 -1
- package/.docs/models/providers.md +4 -0
- package/.docs/reference/agents/getDefaultGenerateOptions.md +1 -1
- package/.docs/reference/agents/getDefaultOptions.md +1 -1
- package/.docs/reference/agents/getDefaultStreamOptions.md +1 -1
- package/.docs/reference/agents/getDescription.md +1 -1
- package/.docs/reference/agents/network.md +3 -1
- package/.docs/reference/ai-sdk/handle-chat-stream.md +2 -0
- package/.docs/reference/ai-sdk/handle-network-stream.md +2 -0
- package/.docs/reference/ai-sdk/network-route.md +2 -0
- package/.docs/reference/ai-sdk/to-ai-sdk-v4-messages.md +1 -1
- package/.docs/reference/ai-sdk/to-ai-sdk-v5-messages.md +1 -1
- package/.docs/reference/auth/auth0.md +3 -3
- package/.docs/reference/auth/firebase.md +1 -1
- package/.docs/reference/auth/workos.md +2 -2
- package/.docs/reference/cli/mastra.md +4 -4
- package/.docs/reference/client-js/mastra-client.md +1 -1
- package/.docs/reference/configuration.md +62 -6
- package/.docs/reference/core/getDeployer.md +1 -1
- package/.docs/reference/core/getLogger.md +1 -1
- package/.docs/reference/core/getScorer.md +2 -2
- package/.docs/reference/core/getServer.md +1 -1
- package/.docs/reference/core/getStorage.md +1 -1
- package/.docs/reference/core/getStoredAgentById.md +1 -1
- package/.docs/reference/core/getTelemetry.md +1 -1
- package/.docs/reference/core/getWorkflow.md +1 -1
- package/.docs/reference/core/listAgents.md +1 -1
- package/.docs/reference/core/listMCPServers.md +1 -1
- package/.docs/reference/core/listStoredAgents.md +1 -1
- package/.docs/reference/core/listVectors.md +1 -1
- package/.docs/reference/core/mastra-class.md +1 -1
- package/.docs/reference/core/setLogger.md +1 -1
- package/.docs/reference/core/setStorage.md +1 -1
- package/.docs/reference/datasets/dataset.md +1 -1
- package/.docs/reference/datasets/datasets-manager.md +1 -1
- package/.docs/reference/datasets/get.md +2 -2
- package/.docs/reference/datasets/getDetails.md +1 -1
- package/.docs/reference/datasets/listItems.md +1 -1
- package/.docs/reference/deployer/vercel.md +1 -1
- package/.docs/reference/evals/answer-relevancy.md +1 -1
- package/.docs/reference/evals/completeness.md +1 -1
- package/.docs/reference/evals/context-precision.md +3 -3
- package/.docs/reference/evals/context-relevance.md +1 -1
- package/.docs/reference/evals/hallucination.md +3 -9
- package/.docs/reference/evals/keyword-coverage.md +1 -1
- package/.docs/reference/evals/mastra-scorer.md +1 -1
- package/.docs/reference/evals/noise-sensitivity.md +2 -2
- package/.docs/reference/evals/textual-difference.md +1 -1
- package/.docs/reference/evals/tone-consistency.md +1 -1
- package/.docs/reference/evals/tool-call-accuracy.md +1 -1
- package/.docs/reference/harness/harness-class.md +4 -2
- package/.docs/reference/index.md +2 -0
- package/.docs/reference/memory/cloneThread.md +1 -1
- package/.docs/reference/memory/observational-memory.md +7 -5
- package/.docs/reference/observability/tracing/bridges/otel.md +1 -1
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +1 -1
- package/.docs/reference/observability/tracing/spans.md +2 -0
- package/.docs/reference/processors/message-history-processor.md +1 -1
- package/.docs/reference/processors/processor-interface.md +6 -2
- package/.docs/reference/processors/token-limiter-processor.md +2 -2
- package/.docs/reference/rag/metadata-filters.md +10 -10
- package/.docs/reference/server/create-route.md +2 -0
- package/.docs/reference/server/koa-adapter.md +1 -1
- package/.docs/reference/server/register-api-route.md +2 -2
- package/.docs/reference/storage/cloudflare-d1.md +3 -3
- package/.docs/reference/storage/cloudflare.md +1 -1
- package/.docs/reference/storage/convex.md +1 -1
- package/.docs/reference/storage/dynamodb.md +2 -2
- package/.docs/reference/storage/lance.md +2 -2
- package/.docs/reference/storage/mongodb.md +1 -1
- package/.docs/reference/storage/mssql.md +1 -1
- package/.docs/reference/storage/postgresql.md +2 -2
- package/.docs/reference/storage/upstash.md +1 -1
- package/.docs/reference/streaming/workflows/observeStream.md +1 -1
- package/.docs/reference/templates/overview.md +1 -1
- package/.docs/reference/tools/create-tool.md +1 -1
- package/.docs/reference/tools/mcp-server.md +4 -4
- package/.docs/reference/vectors/chroma.md +2 -2
- package/.docs/reference/vectors/couchbase.md +6 -6
- package/.docs/reference/vectors/pg.md +2 -0
- package/.docs/reference/vectors/s3vectors.md +5 -5
- package/.docs/reference/voice/azure.md +4 -2
- package/.docs/reference/voice/cloudflare.md +4 -2
- package/.docs/reference/voice/elevenlabs.md +1 -1
- package/.docs/reference/voice/google-gemini-live.md +2 -2
- package/.docs/reference/voice/google.md +3 -3
- package/.docs/reference/voice/mastra-voice.md +1 -1
- package/.docs/reference/voice/murf.md +2 -2
- package/.docs/reference/voice/openai-realtime.md +3 -1
- package/.docs/reference/voice/openai.md +7 -3
- package/.docs/reference/voice/playai.md +4 -2
- package/.docs/reference/voice/sarvam.md +3 -1
- package/.docs/reference/voice/speechify.md +6 -4
- package/.docs/reference/voice/voice.addInstructions.md +2 -2
- package/.docs/reference/voice/voice.addTools.md +1 -1
- package/.docs/reference/voice/voice.close.md +2 -2
- package/.docs/reference/voice/voice.connect.md +4 -2
- package/.docs/reference/voice/voice.events.md +2 -2
- package/.docs/reference/voice/voice.getSpeakers.md +1 -1
- package/.docs/reference/voice/voice.listen.md +11 -5
- package/.docs/reference/voice/voice.off.md +2 -2
- package/.docs/reference/voice/voice.on.md +2 -2
- package/.docs/reference/voice/voice.speak.md +14 -4
- package/.docs/reference/voice/voice.updateConfig.md +1 -1
- package/.docs/reference/workflows/run-methods/timeTravel.md +1 -1
- package/.docs/reference/workspace/blaxel-sandbox.md +164 -0
- package/.docs/reference/workspace/daytona-sandbox.md +48 -139
- package/.docs/reference/workspace/e2b-sandbox.md +39 -75
- package/.docs/reference/workspace/filesystem.md +24 -10
- package/.docs/reference/workspace/gcs-filesystem.md +20 -0
- package/.docs/reference/workspace/local-filesystem.md +23 -9
- package/.docs/reference/workspace/local-sandbox.md +23 -98
- package/.docs/reference/workspace/process-manager.md +296 -0
- package/.docs/reference/workspace/s3-filesystem.md +20 -0
- package/.docs/reference/workspace/sandbox.md +9 -1
- package/.docs/reference/workspace/workspace-class.md +93 -25
- package/CHANGELOG.md +8 -0
- package/dist/tools/course.d.ts +7 -27
- package/dist/tools/course.d.ts.map +1 -1
- package/dist/tools/docs.d.ts +6 -18
- package/dist/tools/docs.d.ts.map +1 -1
- package/dist/tools/embedded-docs.d.ts +12 -112
- package/dist/tools/embedded-docs.d.ts.map +1 -1
- package/dist/tools/migration.d.ts +6 -26
- package/dist/tools/migration.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **Warning:** **Deprecated**: This method is deprecated and only works with V1 models. For V2 models, use the new [`.getDefaultOptions()`](https://mastra.ai/reference/agents/getDefaultOptions) method instead.
|
|
4
4
|
|
|
5
|
-
Agents can be configured with default generation options for controlling model behavior, output formatting and tool and workflow calls. The `.getDefaultGenerateOptionsLegacy()` method retrieves these defaults, resolving them if they
|
|
5
|
+
Agents can be configured with default generation options for controlling model behavior, output formatting and tool and workflow calls. The `.getDefaultGenerateOptionsLegacy()` method retrieves these defaults, resolving them if they're functions. These options apply to all `generateLegacy()` calls unless overridden and are useful for inspecting an agent’s unknown defaults.
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Agent.getDefaultOptions()
|
|
2
2
|
|
|
3
|
-
Agents can be configured with default options for memory usage, output format, and iteration steps. The `.getDefaultOptions()` method returns these defaults, resolving them if they
|
|
3
|
+
Agents can be configured with default options for memory usage, output format, and iteration steps. The `.getDefaultOptions()` method returns these defaults, resolving them if they're functions. These options apply to all `stream()` and `generate()` calls unless overridden and are useful for inspecting an agent’s unknown defaults.
|
|
4
4
|
|
|
5
5
|
## Usage example
|
|
6
6
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **Warning:** **Deprecated**: This method is deprecated and only works with V1 models. For V2 models, use the new [`.getDefaultOptions()`](https://mastra.ai/reference/agents/getDefaultOptions) method instead.
|
|
4
4
|
|
|
5
|
-
Agents can be configured with default streaming options for memory usage, output format, and iteration steps. The `.getDefaultStreamOptionsLegacy()` method returns these defaults, resolving them if they
|
|
5
|
+
Agents can be configured with default streaming options for memory usage, output format, and iteration steps. The `.getDefaultStreamOptionsLegacy()` method returns these defaults, resolving them if they're functions. These options apply to all `streamLegacy()` calls unless overridden and are useful for inspecting an agent’s unknown defaults.
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Agent.getDescription()
|
|
2
2
|
|
|
3
|
-
The `.getDescription()` method retrieves the description configured for an agent. This method returns a
|
|
3
|
+
The `.getDescription()` method retrieves the description configured for an agent. This method returns a string description that describes the agent's purpose and capabilities.
|
|
4
4
|
|
|
5
5
|
## Usage example
|
|
6
6
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Agent.network()
|
|
2
2
|
|
|
3
|
+
> **Deprecated:** Agent networks are deprecated and will be removed in a future release. Use the [supervisor pattern](https://mastra.ai/docs/agents/supervisor-agents) with `agent.stream()` or `agent.generate()` instead. See the [migration guide](https://mastra.ai/guides/migrations/network-to-supervisor) to upgrade.
|
|
4
|
+
|
|
3
5
|
The `.network()` method enables multi-agent collaboration and routing. This method accepts messages and optional execution options.
|
|
4
6
|
|
|
5
7
|
## Usage example
|
|
@@ -188,7 +190,7 @@ When using structured output, additional chunk types are emitted:
|
|
|
188
190
|
|
|
189
191
|
## Aborting a Network
|
|
190
192
|
|
|
191
|
-
Use `abortSignal` to cancel a running network. When aborted, the network stops routing, cancels any in-progress sub-agent, tool, or workflow execution, and
|
|
193
|
+
Use `abortSignal` to cancel a running network. When aborted, the network stops routing, cancels any in-progress sub-agent, tool, or workflow execution, and doesn't save partial results to memory.
|
|
192
194
|
|
|
193
195
|
```typescript
|
|
194
196
|
const controller = new AbortController()
|
|
@@ -40,6 +40,8 @@ export async function POST(req: Request) {
|
|
|
40
40
|
|
|
41
41
|
**params.runId** (`string`): The run ID. Required when \`resumeData\` is provided.
|
|
42
42
|
|
|
43
|
+
**params.providerOptions** (`Record<string, Record<string, unknown>>`): Provider-specific options passed to the language model (e.g. \`{ openai: { reasoningEffort: "high" } }\`). Merged with \`defaultOptions.providerOptions\`, with \`params\` taking precedence.
|
|
44
|
+
|
|
43
45
|
**params.requestContext** (`RequestContext`): Request context to pass to the agent execution.
|
|
44
46
|
|
|
45
47
|
**defaultOptions** (`AgentExecutionOptions`): Default options passed to agent execution. These are merged with params, with params taking precedence.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# handleNetworkStream()
|
|
2
2
|
|
|
3
|
+
> **Deprecated:** Agent networks are deprecated and will be removed in a future release. Use the [supervisor pattern](https://mastra.ai/docs/agents/supervisor-agents) with `agent.stream()` or `agent.generate()` instead. See the [migration guide](https://mastra.ai/guides/migrations/network-to-supervisor) to upgrade.
|
|
4
|
+
|
|
3
5
|
Framework-agnostic handler for streaming network execution in AI SDK-compatible format. Use this function directly when you need to handle network streaming outside Hono or Mastra's own [apiRoutes](https://mastra.ai/docs/server/custom-api-routes) feature.
|
|
4
6
|
|
|
5
7
|
`handleNetworkStream()` returns a `ReadableStream` that you can wrap with [`createUIMessageStreamResponse()`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/create-ui-message-stream-response).
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# networkRoute()
|
|
2
2
|
|
|
3
|
+
> **Deprecated:** Agent networks are deprecated and will be removed in a future release. Use the [supervisor pattern](https://mastra.ai/docs/agents/supervisor-agents) with `agent.stream()` or `agent.generate()` instead. See the [migration guide](https://mastra.ai/guides/migrations/network-to-supervisor) to upgrade.
|
|
4
|
+
|
|
3
5
|
Creates a network route handler for streaming network execution using the AI SDK format. This function registers an HTTP `POST` endpoint that accepts messages, executes an agent network, and streams the response back to the client in AI SDK-compatible format. Agent networks allow a routing agent to delegate tasks to other agents. You have to use it inside a [custom API route](https://mastra.ai/docs/server/custom-api-routes).
|
|
4
6
|
|
|
5
7
|
Use [`handleNetworkStream()`](https://mastra.ai/reference/ai-sdk/handle-network-stream) if you need a framework-agnostic handler.
|
|
@@ -18,7 +18,7 @@ export const mastra = new Mastra({
|
|
|
18
18
|
})
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
> **Note:** You can omit the constructor parameters if you have the appropriately named environment variables (`AUTH0_DOMAIN` and `AUTH0_AUDIENCE`) set. In that case,
|
|
21
|
+
> **Note:** You can omit the constructor parameters if you have the appropriately named environment variables (`AUTH0_DOMAIN` and `AUTH0_AUDIENCE`) set. In that case, use `new MastraAuthAuth0()` without any arguments.
|
|
22
22
|
|
|
23
23
|
## Constructor parameters
|
|
24
24
|
|
|
@@ -32,7 +32,7 @@ export const mastra = new Mastra({
|
|
|
32
32
|
|
|
33
33
|
## Environment Variables
|
|
34
34
|
|
|
35
|
-
The following environment variables are automatically used when constructor options
|
|
35
|
+
The following environment variables are automatically used when constructor options aren't provided:
|
|
36
36
|
|
|
37
37
|
**AUTH0\_DOMAIN** (`string`): Your Auth0 domain. Can be found in your Auth0 Dashboard under Applications > Settings.
|
|
38
38
|
|
|
@@ -44,7 +44,7 @@ By default, `MastraAuthAuth0` validates Auth0 JWT tokens and allows access to al
|
|
|
44
44
|
|
|
45
45
|
1. **Token Verification**: The JWT token is verified using Auth0's public keys (JWKS)
|
|
46
46
|
2. **Signature Validation**: Ensures the token was signed by your Auth0 tenant
|
|
47
|
-
3. **Expiration Check**: Verifies the token
|
|
47
|
+
3. **Expiration Check**: Verifies the token hasn't expired
|
|
48
48
|
4. **Audience Validation**: Confirms the token was issued for your specific API (audience)
|
|
49
49
|
5. **Issuer Validation**: Ensures the token was issued by your Auth0 domain
|
|
50
50
|
|
|
@@ -46,7 +46,7 @@ export const mastra = new Mastra({
|
|
|
46
46
|
|
|
47
47
|
## Environment Variables
|
|
48
48
|
|
|
49
|
-
The following environment variables are automatically used when constructor options
|
|
49
|
+
The following environment variables are automatically used when constructor options aren't provided:
|
|
50
50
|
|
|
51
51
|
**FIREBASE\_SERVICE\_ACCOUNT** (`string`): Path to Firebase service account JSON file. Used if serviceAccount option is not provided.
|
|
52
52
|
|
|
@@ -18,7 +18,7 @@ export const mastra = new Mastra({
|
|
|
18
18
|
})
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
> **Note:** You can omit the constructor parameters if you have the appropriately named environment variables (`WORKOS_API_KEY` and `WORKOS_CLIENT_ID`) set. In that case,
|
|
21
|
+
> **Note:** You can omit the constructor parameters if you have the appropriately named environment variables (`WORKOS_API_KEY` and `WORKOS_CLIENT_ID`) set. In that case, use `new MastraAuthWorkos()` without any arguments.
|
|
22
22
|
|
|
23
23
|
## Constructor parameters
|
|
24
24
|
|
|
@@ -32,7 +32,7 @@ export const mastra = new Mastra({
|
|
|
32
32
|
|
|
33
33
|
## Environment Variables
|
|
34
34
|
|
|
35
|
-
The following environment variables are automatically used when constructor options
|
|
35
|
+
The following environment variables are automatically used when constructor options aren't provided:
|
|
36
36
|
|
|
37
37
|
**WORKOS\_API\_KEY** (`string`): Your WorkOS API key. Can be found in your WorkOS Dashboard under API Keys.
|
|
38
38
|
|
|
@@ -30,7 +30,7 @@ Comma-separated list of custom arguments to pass to the Node.js process, e.g. `-
|
|
|
30
30
|
|
|
31
31
|
#### `--request-context-presets`
|
|
32
32
|
|
|
33
|
-
Path to a JSON file containing named [request context](https://mastra.ai/docs/server/request-context) presets. When provided, a dropdown
|
|
33
|
+
Path to a JSON file containing named [request context](https://mastra.ai/docs/server/request-context) presets. When provided, a dropdown displays in Studio's request context editor, letting you quickly switch between preset configurations.
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
36
|
mastra dev --request-context-presets ./presets.json
|
|
@@ -57,7 +57,7 @@ Set `MASTRA_SKIP_PEERDEP_CHECK=1` to skip the peer dependency version mismatch c
|
|
|
57
57
|
MASTRA_SKIP_PEERDEP_CHECK=1 mastra dev
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
This is useful during monorepo development when peer dependencies may be bumped but packages
|
|
60
|
+
This is useful during monorepo development when peer dependencies may be bumped but packages aren't yet published.
|
|
61
61
|
|
|
62
62
|
#### Disable build caching
|
|
63
63
|
|
|
@@ -101,7 +101,7 @@ These are forwarded to the Mastra model router and will work with any `"openai/.
|
|
|
101
101
|
|
|
102
102
|
## `mastra build`
|
|
103
103
|
|
|
104
|
-
The `mastra build` command bundles your Mastra project into a production-ready Hono server. [Hono](https://hono.dev/) is a lightweight, type-safe web framework that makes it
|
|
104
|
+
The `mastra build` command bundles your Mastra project into a production-ready Hono server. [Hono](https://hono.dev/) is a lightweight, type-safe web framework that makes it straightforward to deploy Mastra agents as HTTP endpoints with middleware support.
|
|
105
105
|
|
|
106
106
|
Under the hood Mastra's Rollup server locates your Mastra entry file and bundles it to a production-ready Hono server. During that bundling it tree-shakes your code and generates source maps for debugging.
|
|
107
107
|
|
|
@@ -253,7 +253,7 @@ If enabled, example code is written to the list of components (e.g. example agen
|
|
|
253
253
|
|
|
254
254
|
#### `--no-example`
|
|
255
255
|
|
|
256
|
-
|
|
256
|
+
Don't include example code. Useful when using the `--default` flag.
|
|
257
257
|
|
|
258
258
|
#### `--mcp`
|
|
259
259
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Mastra Client SDK
|
|
2
2
|
|
|
3
|
-
The Mastra Client SDK provides a
|
|
3
|
+
The Mastra Client SDK provides a type-safe interface for interacting with your [Mastra Server](https://mastra.ai/docs/deployment/mastra-server) from your client environment.
|
|
4
4
|
|
|
5
5
|
## Usage example
|
|
6
6
|
|
|
@@ -59,7 +59,7 @@ export const mastra = new Mastra({
|
|
|
59
59
|
|
|
60
60
|
Event handlers for the internal pub/sub system. Maps event topics to handler functions that are called when events are published to those topics.
|
|
61
61
|
|
|
62
|
-
> **Warning:** This is used internally by Mastra's workflow engine. Most users
|
|
62
|
+
> **Warning:** This is used internally by Mastra's workflow engine. Most users won't need to configure this option.
|
|
63
63
|
|
|
64
64
|
```typescript
|
|
65
65
|
import { Mastra } from '@mastra/core'
|
|
@@ -94,19 +94,39 @@ export const mastra = new Mastra({
|
|
|
94
94
|
|
|
95
95
|
### idGenerator
|
|
96
96
|
|
|
97
|
-
**Type:** `() => string`\
|
|
97
|
+
**Type:** `(context?: IdGeneratorContext) => string`\
|
|
98
98
|
**Default:** `crypto.randomUUID()`
|
|
99
99
|
|
|
100
|
-
Custom ID generator function for creating unique identifiers.
|
|
100
|
+
Custom ID generator function for creating unique identifiers. Mastra passes optional context so you can generate IDs based on what's being created.
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
`IdGeneratorContext` includes:
|
|
103
|
+
|
|
104
|
+
- `idType`: `'thread' | 'message' | 'run' | 'step' | 'generic'`
|
|
105
|
+
- `source?`: `'agent' | 'workflow' | 'memory'`
|
|
106
|
+
- `entityId?`: ID of the requesting agent/workflow/memory entity
|
|
107
|
+
- `threadId?`: Thread ID when relevant (for example, when creating message IDs)
|
|
108
|
+
- `resourceId?`: Resource ID when relevant (for example, user-scoped threads)
|
|
109
|
+
- `role?`: Message role when creating a message ID
|
|
110
|
+
- `stepType?`: Workflow step type when creating a step ID
|
|
111
|
+
|
|
112
|
+
> **Warning:** This is used internally by Mastra for creating IDs for workflow runs, agent conversations, and other resources. Most users won't need to configure this option.
|
|
103
113
|
|
|
104
114
|
```typescript
|
|
105
115
|
import { Mastra } from '@mastra/core'
|
|
106
116
|
import { nanoid } from 'nanoid'
|
|
107
117
|
|
|
108
118
|
export const mastra = new Mastra({
|
|
109
|
-
idGenerator:
|
|
119
|
+
idGenerator: context => {
|
|
120
|
+
if (context?.idType === 'message' && context?.threadId) {
|
|
121
|
+
return `msg-${context.threadId}-${nanoid(8)}`
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (context?.idType === 'run' && context?.source && context?.entityId) {
|
|
125
|
+
return `${context.source}-run-${context.entityId}-${nanoid(6)}`
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return nanoid()
|
|
129
|
+
},
|
|
110
130
|
})
|
|
111
131
|
```
|
|
112
132
|
|
|
@@ -243,7 +263,7 @@ export const mastra = new Mastra({
|
|
|
243
263
|
|
|
244
264
|
Pub/sub system for event-driven communication between components. Used internally by Mastra for workflow event processing and component communication.
|
|
245
265
|
|
|
246
|
-
> **Warning:** This is used internally by Mastra. Most users
|
|
266
|
+
> **Warning:** This is used internally by Mastra. Most users won't need to configure this option.
|
|
247
267
|
|
|
248
268
|
```typescript
|
|
249
269
|
import { Mastra } from '@mastra/core'
|
|
@@ -693,6 +713,42 @@ export const mastra = new Mastra({
|
|
|
693
713
|
})
|
|
694
714
|
```
|
|
695
715
|
|
|
716
|
+
### server.onValidationError
|
|
717
|
+
|
|
718
|
+
**Type:** `(error: ZodError, context: 'query' | 'body' | 'path') => { status: number; body: unknown } | undefined`
|
|
719
|
+
|
|
720
|
+
Custom handler called when a request fails Zod schema validation. Use this to customize validation error responses, change the status code, or format errors to match your API standards.
|
|
721
|
+
|
|
722
|
+
Return a `{ status, body }` object to override the default `400` response, or `undefined` to fall through to the default behavior. This hook is supported by all server adapters (Hono, Express, Fastify, Koa).
|
|
723
|
+
|
|
724
|
+
The `context` parameter indicates which part of the request failed validation:
|
|
725
|
+
|
|
726
|
+
- `'query'` — query parameters
|
|
727
|
+
- `'body'` — request body
|
|
728
|
+
- `'path'` — path parameters
|
|
729
|
+
|
|
730
|
+
```typescript
|
|
731
|
+
import { Mastra } from '@mastra/core'
|
|
732
|
+
|
|
733
|
+
export const mastra = new Mastra({
|
|
734
|
+
server: {
|
|
735
|
+
onValidationError: (error, context) => ({
|
|
736
|
+
status: 422,
|
|
737
|
+
body: {
|
|
738
|
+
ok: false,
|
|
739
|
+
errors: error.issues.map(i => ({
|
|
740
|
+
path: i.path.join('.'),
|
|
741
|
+
message: i.message,
|
|
742
|
+
})),
|
|
743
|
+
source: context,
|
|
744
|
+
},
|
|
745
|
+
}),
|
|
746
|
+
},
|
|
747
|
+
})
|
|
748
|
+
```
|
|
749
|
+
|
|
750
|
+
You can also set `onValidationError` on individual routes created with `createRoute()`. A route-level hook takes precedence over the server-level hook.
|
|
751
|
+
|
|
696
752
|
### server.port
|
|
697
753
|
|
|
698
754
|
**Type:** `number`\
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# getScorer()
|
|
2
2
|
|
|
3
|
-
The `getScorer()` method retrieves a specific scorer that was registered with the Mastra instance using its registration key. This method provides type-safe access to scorers and throws an error if the requested scorer
|
|
3
|
+
The `getScorer()` method retrieves a specific scorer that was registered with the Mastra instance using its registration key. This method provides type-safe access to scorers and throws an error if the requested scorer isn't found.
|
|
4
4
|
|
|
5
5
|
## Usage Example
|
|
6
6
|
|
|
@@ -34,7 +34,7 @@ await weatherAgent.generate('What is the weather in Rome', {
|
|
|
34
34
|
|
|
35
35
|
This method throws a `MastraError` if:
|
|
36
36
|
|
|
37
|
-
- The scorer with the specified key
|
|
37
|
+
- The scorer with the specified key isn't found
|
|
38
38
|
- No scorers are registered with the Mastra instance
|
|
39
39
|
|
|
40
40
|
```typescript
|
|
@@ -46,7 +46,7 @@ When creating an `Agent` instance from stored configuration, the method resolves
|
|
|
46
46
|
- **Memory**: Resolved from `memory` registered in Mastra config
|
|
47
47
|
- **Scorers**: Resolved from `scorers` registered in Mastra config, including sampling configuration
|
|
48
48
|
|
|
49
|
-
If a referenced primitive
|
|
49
|
+
If a referenced primitive isn't found in the registry, a warning is logged but the agent is still created.
|
|
50
50
|
|
|
51
51
|
## StorageAgentType
|
|
52
52
|
|
|
@@ -25,7 +25,7 @@ For best TypeScript support, use `getWorkflow()` with the workflow's **registrat
|
|
|
25
25
|
- Output data schemas
|
|
26
26
|
- Step results
|
|
27
27
|
|
|
28
|
-
If you need to retrieve a workflow by its `id` property instead of its registration key, you can use `getWorkflowById()`, but note that type inference
|
|
28
|
+
If you need to retrieve a workflow by its `id` property instead of its registration key, you can use `getWorkflowById()`, but note that type inference won't be as precise.
|
|
29
29
|
|
|
30
30
|
## Parameters
|
|
31
31
|
|
|
@@ -63,7 +63,7 @@ When creating `Agent` instances (default behavior), each stored agent's configur
|
|
|
63
63
|
- **Memory**: Resolved from `memory` registered in Mastra config
|
|
64
64
|
- **Scorers**: Resolved from `scorers` registered in Mastra config
|
|
65
65
|
|
|
66
|
-
If a referenced primitive
|
|
66
|
+
If a referenced primitive isn't found, a warning is logged but the agent is still created.
|
|
67
67
|
|
|
68
68
|
## Example: Iterating Through All Stored Agents
|
|
69
69
|
|
|
@@ -41,7 +41,7 @@ Visit the [Configuration reference](https://mastra.ai/reference/configuration) f
|
|
|
41
41
|
|
|
42
42
|
**logger** (`Logger`): Logger instance created with new PinoLogger() (Default: `Console logger with INFO level`)
|
|
43
43
|
|
|
44
|
-
**idGenerator** (`() => string`): Custom ID generator function. Used by agents, workflows, memory, and other components to generate unique identifiers.
|
|
44
|
+
**idGenerator** (`(context?: IdGeneratorContext) => string`): Custom ID generator function. Used by agents, workflows, memory, and other components to generate unique identifiers. Receives optional context such as idType, source, entityId, and threadId to support context-aware ID formats.
|
|
45
45
|
|
|
46
46
|
**workflows** (`Record<string, Workflow>`): Workflows to register. Structured as a key-value pair, with keys being the workflow name and values being the workflow instance. (Default: `{}`)
|
|
47
47
|
|
|
@@ -60,7 +60,7 @@ const history = await dataset.getItemHistory({ itemId: 'item-id' })
|
|
|
60
60
|
|
|
61
61
|
## Access
|
|
62
62
|
|
|
63
|
-
`Dataset`
|
|
63
|
+
`Dataset` isn't instantiated directly. Obtain one via `DatasetsManager`:
|
|
64
64
|
|
|
65
65
|
```typescript
|
|
66
66
|
const dataset = await mastra.datasets.get({ id: 'dataset-id' })
|
|
@@ -78,7 +78,7 @@ const comparison = await mastra.datasets.compareExperiments({
|
|
|
78
78
|
|
|
79
79
|
## Access
|
|
80
80
|
|
|
81
|
-
`DatasetsManager`
|
|
81
|
+
`DatasetsManager` isn't instantiated directly. Access it from a `Mastra` instance:
|
|
82
82
|
|
|
83
83
|
```typescript
|
|
84
84
|
const mastra = new Mastra({
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**Added in:** `@mastra/core@1.4.0`
|
|
4
4
|
|
|
5
|
-
Retrieves an existing dataset by ID. Throws a `MastraError` if the dataset
|
|
5
|
+
Retrieves an existing dataset by ID. Throws a `MastraError` if the dataset doesn't exist.
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
@@ -26,6 +26,6 @@ console.log(details.name)
|
|
|
26
26
|
|
|
27
27
|
## Returns
|
|
28
28
|
|
|
29
|
-
Throws `MastraError` if the dataset
|
|
29
|
+
Throws `MastraError` if the dataset isn't found.
|
|
30
30
|
|
|
31
31
|
**result** (`Promise<Dataset>`): A Dataset instance.
|
|
@@ -26,7 +26,7 @@ This method takes no parameters.
|
|
|
26
26
|
|
|
27
27
|
## Returns
|
|
28
28
|
|
|
29
|
-
Returns a `Promise<DatasetRecord>`. Throws `MastraError` if the dataset
|
|
29
|
+
Returns a `Promise<DatasetRecord>`. Throws `MastraError` if the dataset isn't found.
|
|
30
30
|
|
|
31
31
|
**id** (`string`): Unique identifier of the dataset.
|
|
32
32
|
|
|
@@ -41,7 +41,7 @@ When `version` is specified:
|
|
|
41
41
|
|
|
42
42
|
**result** (`Promise<DatasetItem[]>`): Array of all items at the specified dataset version.
|
|
43
43
|
|
|
44
|
-
When `version`
|
|
44
|
+
When `version` isn't specified:
|
|
45
45
|
|
|
46
46
|
**result** (`Promise<object>`): Paginated response.
|
|
47
47
|
|
|
@@ -113,4 +113,4 @@ With `studio: true`:
|
|
|
113
113
|
|
|
114
114
|
When studio is enabled, the routing is configured so that `/api/*` requests are handled by the serverless function, static assets (JS, CSS) are served from Vercel's Edge CDN with no function invocations, and all other paths fall back to `index.html` for client-side routing.
|
|
115
115
|
|
|
116
|
-
This folder is generated during build and
|
|
116
|
+
This folder is generated during build and shouldn't be committed to version control.
|
|
@@ -58,7 +58,7 @@ A relevancy score between 0 and 1:
|
|
|
58
58
|
- **0.7–0.9**: The response mostly answers the query but may include minor unrelated content.
|
|
59
59
|
- **0.4–0.6**: The response partially answers the query, mixing relevant and unrelated information.
|
|
60
60
|
- **0.1–0.3**: The response includes minimal relevant content and largely misses the intent of the query.
|
|
61
|
-
- **0.0**: The response is entirely unrelated and
|
|
61
|
+
- **0.0**: The response is entirely unrelated and doesn't answer the query.
|
|
62
62
|
|
|
63
63
|
## Example
|
|
64
64
|
|
|
@@ -4,7 +4,7 @@ The `createCompletenessScorer()` function evaluates how thoroughly an LLM's outp
|
|
|
4
4
|
|
|
5
5
|
## Parameters
|
|
6
6
|
|
|
7
|
-
The `createCompletenessScorer()` function
|
|
7
|
+
The `createCompletenessScorer()` function doesn't take any options.
|
|
8
8
|
|
|
9
9
|
This function returns an instance of the MastraScorer class. See the [MastraScorer reference](https://mastra.ai/reference/evals/mastra-scorer) for details on the `.run()` method and its input/output.
|
|
10
10
|
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
The `createContextPrecisionScorer()` function creates a scorer that evaluates how relevant and well-positioned retrieved context pieces are for generating expected outputs. It uses **Mean Average Precision (MAP)** to reward systems that place relevant context earlier in the sequence.
|
|
4
4
|
|
|
5
|
-
It
|
|
5
|
+
It's especially useful for these use cases:
|
|
6
6
|
|
|
7
7
|
## RAG System Evaluation
|
|
8
8
|
|
|
9
9
|
Ideal for evaluating retrieved context in RAG pipelines where:
|
|
10
10
|
|
|
11
11
|
- Context ordering matters for model performance
|
|
12
|
-
- You need to measure retrieval quality beyond
|
|
12
|
+
- You need to measure retrieval quality beyond basic relevance
|
|
13
13
|
- Early relevant context is more valuable than later relevant context
|
|
14
14
|
|
|
15
15
|
## Context Window Optimization
|
|
@@ -77,7 +77,7 @@ The reason field explains:
|
|
|
77
77
|
Use results to:
|
|
78
78
|
|
|
79
79
|
- **Improve retrieval**: Filter out irrelevant context before ranking
|
|
80
|
-
- **Optimize ranking**: Ensure relevant context
|
|
80
|
+
- **Optimize ranking**: Ensure relevant context surfaces early
|
|
81
81
|
- **Tune chunk size**: Balance context detail vs. relevance precision
|
|
82
82
|
- **Evaluate embeddings**: Test different embedding models for better retrieval
|
|
83
83
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The `createContextRelevanceScorerLLM()` function creates a scorer that evaluates how relevant and useful provided context was for generating agent responses. It uses weighted relevance levels and applies penalties for unused high-relevance context and missing information.
|
|
4
4
|
|
|
5
|
-
It
|
|
5
|
+
It's especially useful for these use cases:
|
|
6
6
|
|
|
7
7
|
## Content Generation Evaluation
|
|
8
8
|
|
|
@@ -8,20 +8,14 @@ The `createHallucinationScorer()` function accepts a single options object with
|
|
|
8
8
|
|
|
9
9
|
**model** (`LanguageModel`): Configuration for the model used to evaluate hallucination.
|
|
10
10
|
|
|
11
|
-
**options
|
|
11
|
+
**options** (`Options`): Configuration options.
|
|
12
|
+
|
|
13
|
+
**options.scale** (`number`): Maximum score value.
|
|
12
14
|
|
|
13
15
|
**options.context** (`string[]`): Static context strings to use as ground truth for hallucination detection.
|
|
14
16
|
|
|
15
17
|
**options.getContext** (`(params: GetContextParams) => string[] | Promise<string[]>`): A hook to dynamically resolve context at runtime. Takes priority over static context. Useful for live scoring where context (like tool results) is only available when the scorer runs.
|
|
16
18
|
|
|
17
|
-
**options.getContext.run** (`GetContextRun`): The scorer run containing input, output, runId, requestContext, and tracingContext.
|
|
18
|
-
|
|
19
|
-
**options.getContext.results** (`Record<string, any>`): Accumulated results from previous steps (e.g., preprocessStepResult with extracted claims).
|
|
20
|
-
|
|
21
|
-
**options.getContext.score** (`number`): The computed score. Only present when called from the generateReason step.
|
|
22
|
-
|
|
23
|
-
**options.getContext.step** (`'analyze' | 'generateReason'`): Which step is calling the hook. Useful for caching context between calls.
|
|
24
|
-
|
|
25
19
|
This function returns an instance of the MastraScorer class. The `.run()` method accepts the same input as other scorers (see the [MastraScorer reference](https://mastra.ai/reference/evals/mastra-scorer)), but the return value includes LLM-specific fields as documented below.
|
|
26
20
|
|
|
27
21
|
## .run() Returns
|
|
@@ -4,7 +4,7 @@ The `createKeywordCoverageScorer()` function evaluates how well an LLM's output
|
|
|
4
4
|
|
|
5
5
|
## Parameters
|
|
6
6
|
|
|
7
|
-
The `createKeywordCoverageScorer()` function
|
|
7
|
+
The `createKeywordCoverageScorer()` function doesn't take any options.
|
|
8
8
|
|
|
9
9
|
This function returns an instance of the MastraScorer class. See the [MastraScorer reference](https://mastra.ai/reference/evals/mastra-scorer) for details on the `.run()` method and its input/output.
|
|
10
10
|
|