@mastra/mcp-docs-server 1.2.11 → 1.2.12-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/using-tools.md +25 -0
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +5 -5
- package/.docs/guides/build-your-ui/copilotkit/generative-ui.md +8 -8
- package/.docs/guides/build-your-ui/copilotkit/overview.md +2 -2
- package/.docs/guides/build-your-ui/openui.md +1 -1
- package/.docs/guides/concepts/multi-agent-systems.md +5 -5
- package/.docs/guides/concepts/streaming.md +9 -9
- package/.docs/guides/deployment/amazon-ec2.md +1 -1
- package/.docs/guides/deployment/aws-lambda.md +1 -1
- package/.docs/guides/deployment/azure-app-services.md +1 -1
- package/.docs/guides/deployment/cloudflare.md +1 -1
- package/.docs/guides/deployment/inngest.md +6 -6
- package/.docs/guides/deployment/temporal.md +1 -1
- package/.docs/guides/deployment/vercel.md +1 -1
- package/.docs/guides/getting-started/astro.md +1 -1
- package/.docs/guides/getting-started/electron.md +1 -1
- package/.docs/guides/getting-started/nestjs.md +5 -5
- package/.docs/guides/getting-started/vite-react.md +1 -1
- package/.docs/guides/guide/chef-michel.md +1 -1
- package/.docs/guides/guide/code-review-bot.md +1 -1
- package/.docs/guides/guide/coding-agent.md +4 -4
- package/.docs/guides/guide/dev-assistant.md +1 -1
- package/.docs/guides/guide/docs-manager.md +3 -3
- package/.docs/guides/guide/github-actions-pr-description.md +4 -4
- package/.docs/guides/guide/research-assistant.md +3 -3
- package/.docs/guides/guide/research-coordinator.md +3 -3
- package/.docs/guides/guide/slack-assistant.md +1 -1
- package/.docs/guides/guide/stock-agent.md +1 -1
- package/.docs/guides/index.md +1 -1
- package/.docs/guides/migrations/ai-sdk-v4-to-v5.md +1 -1
- package/.docs/guides/migrations/mastra-cloud.md +6 -6
- package/.docs/guides/migrations/network-to-supervisor.md +9 -9
- package/.docs/guides/migrations/upgrade-to-v1/agent.md +5 -5
- package/.docs/guides/migrations/upgrade-to-v1/cli.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/client.md +3 -3
- package/.docs/guides/migrations/upgrade-to-v1/evals.md +2 -2
- package/.docs/guides/migrations/upgrade-to-v1/memory.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/overview.md +3 -3
- package/.docs/guides/migrations/upgrade-to-v1/processors.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/storage.md +11 -11
- package/.docs/guides/migrations/upgrade-to-v1/tools.md +3 -3
- package/.docs/guides/migrations/upgrade-to-v1/tracing.md +2 -2
- package/.docs/guides/migrations/upgrade-to-v1/voice.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/workflows.md +1 -1
- package/.docs/models/environment-variables.md +1 -0
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/modal.md +73 -0
- package/.docs/models/providers.md +1 -0
- package/.docs/reference/acp/acp-agent.md +3 -3
- package/.docs/reference/acp/create-acp-tool.md +2 -2
- package/.docs/reference/agent-controller/agent-controller-class.md +36 -36
- package/.docs/reference/agent-controller/session.md +6 -6
- package/.docs/reference/agents/agent.md +7 -7
- package/.docs/reference/agents/channels.md +3 -3
- package/.docs/reference/agents/durable-agent.md +3 -3
- package/.docs/reference/agents/generate.md +3 -3
- package/.docs/reference/agents/getDefaultOptions.md +1 -1
- package/.docs/reference/agents/getDefaultStreamOptions.md +1 -1
- package/.docs/reference/agents/listScorers.md +1 -1
- package/.docs/reference/agents/listSkills.md +1 -1
- package/.docs/reference/agents/listSuspendedRuns.md +2 -2
- package/.docs/reference/ai-sdk/chat-route.md +1 -1
- package/.docs/reference/ai-sdk/network-route.md +1 -1
- package/.docs/reference/ai-sdk/to-ai-sdk-messages.md +1 -1
- 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/ai-sdk/workflow-route.md +1 -1
- package/.docs/reference/ai-sdk/workflow-snapshot-to-stream.md +2 -2
- package/.docs/reference/auth/auth0.md +1 -1
- package/.docs/reference/auth/fga.md +2 -2
- package/.docs/reference/auth/google.md +2 -2
- package/.docs/reference/auth/okta.md +1 -1
- package/.docs/reference/auth/workos.md +2 -2
- package/.docs/reference/browser/agent-browser.md +2 -2
- package/.docs/reference/browser/browser-viewer.md +3 -3
- package/.docs/reference/browser/mastra-browser.md +3 -3
- package/.docs/reference/browser/stagehand-browser.md +4 -4
- package/.docs/reference/channels/slack-provider.md +2 -2
- package/.docs/reference/cli/create-mastra.md +1 -1
- package/.docs/reference/cli/mastra.md +23 -23
- package/.docs/reference/client-js/agents.md +9 -9
- package/.docs/reference/client-js/memory.md +2 -2
- package/.docs/reference/client-js/workflows.md +1 -1
- package/.docs/reference/coding-agent/build-base-prompt.md +2 -2
- package/.docs/reference/coding-agent/create-coding-agent.md +2 -2
- package/.docs/reference/configuration.md +6 -6
- package/.docs/reference/core/getMCPServer.md +1 -1
- package/.docs/reference/core/getScorer.md +1 -1
- package/.docs/reference/datasets/addItem.md +1 -1
- package/.docs/reference/datasets/listItems.md +1 -1
- package/.docs/reference/deployer/netlify.md +4 -4
- package/.docs/reference/deployer/vercel.md +7 -7
- package/.docs/reference/editor/agent-builder/agent-builder-options.md +4 -4
- package/.docs/reference/editor/agent-builder/builder-agent-defaults.md +6 -6
- package/.docs/reference/editor/agent-builder/builder-models.md +3 -3
- package/.docs/reference/editor/blob-store-provider.md +1 -1
- package/.docs/reference/editor/browser-provider.md +3 -3
- package/.docs/reference/editor/filesystem-provider.md +4 -4
- package/.docs/reference/editor/mastra-editor.md +5 -5
- package/.docs/reference/editor/processor-provider.md +3 -3
- package/.docs/reference/editor/sandbox-provider.md +4 -4
- package/.docs/reference/editor/storage-browser-ref.md +6 -6
- package/.docs/reference/editor/storage-workspace-ref.md +4 -4
- package/.docs/reference/editor/tool-provider.md +1 -1
- package/.docs/reference/evals/answer-relevancy.md +4 -4
- package/.docs/reference/evals/bias.md +3 -3
- package/.docs/reference/evals/checks.md +3 -3
- package/.docs/reference/evals/completeness.md +5 -5
- package/.docs/reference/evals/content-similarity.md +5 -5
- package/.docs/reference/evals/context-precision.md +2 -2
- package/.docs/reference/evals/context-recall.md +8 -8
- package/.docs/reference/evals/context-relevance.md +4 -4
- package/.docs/reference/evals/create-scorer.md +1 -1
- package/.docs/reference/evals/faithfulness.md +3 -3
- package/.docs/reference/evals/filter-run.md +2 -2
- package/.docs/reference/evals/hallucination.md +6 -6
- package/.docs/reference/evals/keyword-coverage.md +6 -6
- package/.docs/reference/evals/mastra-scorer.md +2 -2
- package/.docs/reference/evals/noise-sensitivity.md +5 -5
- package/.docs/reference/evals/prompt-alignment.md +5 -5
- package/.docs/reference/evals/rubric.md +1 -1
- package/.docs/reference/evals/run-evals.md +3 -3
- package/.docs/reference/evals/scorer-utils.md +4 -4
- package/.docs/reference/evals/textual-difference.md +4 -4
- package/.docs/reference/evals/tool-call-accuracy.md +1 -1
- package/.docs/reference/evals/toxicity.md +4 -4
- package/.docs/reference/evals/trajectory-accuracy.md +10 -10
- package/.docs/reference/file-based-agents/instructions.md +2 -2
- package/.docs/reference/file-based-agents/logger.md +1 -1
- package/.docs/reference/file-based-agents/observability.md +1 -1
- package/.docs/reference/file-based-agents/processors.md +1 -1
- package/.docs/reference/file-based-agents/skills.md +1 -1
- package/.docs/reference/file-based-agents/storage.md +1 -1
- package/.docs/reference/file-based-agents/studio.md +1 -1
- package/.docs/reference/file-based-agents/subagents.md +1 -1
- package/.docs/reference/file-based-agents/tools.md +1 -1
- package/.docs/reference/file-based-agents/workspace.md +1 -1
- package/.docs/reference/logging/pino-logger.md +3 -3
- package/.docs/reference/memory/clone-utilities.md +1 -1
- package/.docs/reference/memory/cloneThread.md +3 -3
- package/.docs/reference/memory/listThreads.md +1 -1
- package/.docs/reference/memory/memory-class.md +1 -1
- package/.docs/reference/memory/observational-memory.md +11 -11
- package/.docs/reference/memory/recall.md +2 -2
- package/.docs/reference/memory/serialized-memory-config.md +4 -4
- package/.docs/reference/memory/summarizeConversation.md +3 -3
- package/.docs/reference/memory/summarizeThread.md +3 -3
- package/.docs/reference/observability/feedback.md +1 -1
- package/.docs/reference/observability/metrics/automatic-metrics.md +7 -7
- package/.docs/reference/observability/tracing/bridges/datadog.md +2 -2
- package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +3 -3
- package/.docs/reference/observability/tracing/exporters/default-exporter.md +1 -1
- package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +4 -4
- package/.docs/reference/observability/tracing/exporters/mastra-storage-exporter.md +1 -1
- package/.docs/reference/observability/tracing/interfaces.md +1 -1
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +1 -1
- package/.docs/reference/observability/tracing/span-filtering.md +1 -1
- package/.docs/reference/processors/cost-guard-processor.md +1 -1
- package/.docs/reference/processors/pii-detector.md +1 -1
- package/.docs/reference/processors/processor-interface.md +12 -12
- package/.docs/reference/processors/prompt-injection-detector.md +1 -1
- package/.docs/reference/processors/provider-history-compat.md +1 -1
- package/.docs/reference/processors/regex-filter-processor.md +1 -1
- package/.docs/reference/processors/response-cache.md +8 -8
- package/.docs/reference/processors/system-prompt-scrubber.md +1 -1
- package/.docs/reference/processors/token-limiter-processor.md +1 -1
- package/.docs/reference/processors/tool-search-processor.md +7 -7
- package/.docs/reference/processors/unicode-normalizer.md +1 -1
- package/.docs/reference/project-structure.md +1 -1
- package/.docs/reference/pubsub/base.md +4 -4
- package/.docs/reference/pubsub/google-cloud-pubsub.md +2 -2
- package/.docs/reference/pubsub/lease-provider.md +4 -4
- package/.docs/reference/pubsub/redis-streams.md +1 -1
- package/.docs/reference/pubsub/unix-socket-pubsub.md +1 -1
- package/.docs/reference/rag/chunk.md +5 -5
- package/.docs/reference/rag/database-config.md +2 -2
- package/.docs/reference/rag/metadata-filters.md +2 -2
- package/.docs/reference/schedules/overview.md +1 -1
- package/.docs/reference/server/register-api-route.md +1 -1
- package/.docs/reference/server/routes.md +1 -1
- package/.docs/reference/signals/signal-provider.md +8 -8
- package/.docs/reference/storage/clickhouse.md +4 -4
- package/.docs/reference/storage/cloudflare-d1.md +4 -4
- package/.docs/reference/storage/convex.md +4 -4
- package/.docs/reference/storage/dsql.md +2 -2
- package/.docs/reference/storage/dynamodb.md +7 -7
- package/.docs/reference/storage/lance.md +1 -1
- package/.docs/reference/storage/mongodb.md +1 -1
- package/.docs/reference/storage/mssql.md +1 -1
- package/.docs/reference/storage/postgresql.md +1 -1
- package/.docs/reference/storage/retention.md +33 -33
- package/.docs/reference/storage/spanner.md +8 -8
- package/.docs/reference/streaming/ChunkType.md +2 -2
- package/.docs/reference/streaming/agents/MastraModelOutput.md +1 -1
- package/.docs/reference/streaming/agents/stream.md +1 -1
- package/.docs/reference/streaming/agents/streamUntilIdle.md +2 -2
- package/.docs/reference/streaming/workflows/observeStream.md +1 -1
- package/.docs/reference/streaming/workflows/resumeStream.md +1 -1
- package/.docs/reference/streaming/workflows/stream.md +1 -1
- package/.docs/reference/streaming/workflows/timeTravelStream.md +2 -2
- package/.docs/reference/templates/overview.md +1 -1
- package/.docs/reference/tools/brightdata.md +1 -1
- package/.docs/reference/tools/create-tool.md +1 -1
- package/.docs/reference/tools/graph-rag-tool.md +1 -1
- package/.docs/reference/tools/mcp-client.md +13 -13
- package/.docs/reference/tools/mcp-server.md +20 -20
- package/.docs/reference/tools/submit-plan-tool.md +1 -1
- package/.docs/reference/tools/tavily.md +1 -1
- package/.docs/reference/tools/vector-query-tool.md +4 -4
- package/.docs/reference/vectors/astra.md +1 -1
- package/.docs/reference/vectors/chroma.md +2 -2
- package/.docs/reference/vectors/convex.md +2 -2
- package/.docs/reference/vectors/couchbase.md +4 -4
- package/.docs/reference/vectors/libsql.md +1 -1
- package/.docs/reference/vectors/mongodb.md +1 -1
- package/.docs/reference/vectors/pg.md +4 -4
- package/.docs/reference/vectors/qdrant.md +2 -2
- package/.docs/reference/vectors/s3vectors.md +4 -4
- package/.docs/reference/vectors/turbopuffer.md +1 -1
- package/.docs/reference/voice/aws-nova-sonic.md +1 -1
- package/.docs/reference/voice/azure.md +1 -1
- package/.docs/reference/voice/google-gemini-live.md +4 -4
- package/.docs/reference/voice/inworld-realtime.md +7 -7
- package/.docs/reference/voice/livekit.md +13 -13
- package/.docs/reference/voice/mistral.md +1 -1
- package/.docs/reference/voice/openai-realtime.md +1 -1
- package/.docs/reference/voice/sarvam.md +1 -1
- package/.docs/reference/voice/voice.addTools.md +1 -1
- package/.docs/reference/voice/voice.events.md +1 -1
- package/.docs/reference/voice/voice.getSpeakers.md +2 -2
- package/.docs/reference/voice/voice.on.md +2 -2
- package/.docs/reference/voice/xai-realtime.md +2 -2
- package/.docs/reference/workflows/run-methods/cancel.md +1 -1
- package/.docs/reference/workflows/run-methods/startAsync.md +1 -1
- package/.docs/reference/workflows/run-methods/timeTravel.md +1 -1
- package/.docs/reference/workflows/workflow-methods/foreach.md +1 -1
- package/.docs/reference/workflows/workflow-methods/sleep.md +1 -1
- package/.docs/reference/workflows/workflow-state-reader.md +2 -2
- package/.docs/reference/workspace/apple-container-sandbox.md +2 -2
- package/.docs/reference/workspace/daytona-sandbox.md +3 -3
- package/.docs/reference/workspace/docker-sandbox.md +2 -2
- package/.docs/reference/workspace/e2b-sandbox.md +2 -2
- package/.docs/reference/workspace/files-sdk-filesystem.md +3 -3
- package/.docs/reference/workspace/google-drive-filesystem.md +4 -4
- package/.docs/reference/workspace/local-filesystem.md +2 -2
- package/.docs/reference/workspace/local-sandbox.md +2 -2
- package/.docs/reference/workspace/modal-sandbox.md +1 -1
- package/.docs/reference/workspace/platform-filesystem.md +3 -3
- package/.docs/reference/workspace/platform-sandbox.md +2 -2
- package/.docs/reference/workspace/process-manager.md +1 -1
- package/.docs/reference/workspace/railway-sandbox.md +4 -4
- package/.docs/reference/workspace/s3-filesystem.md +1 -1
- package/.docs/reference/workspace/sandbox.md +1 -1
- package/.docs/reference/workspace/vercel-sandbox.md +1 -1
- package/.docs/reference/workspace/workspace-class.md +10 -10
- package/CHANGELOG.md +7 -0
- package/package.json +5 -5
|
@@ -20,7 +20,7 @@ export const mastra = new Mastra({
|
|
|
20
20
|
})
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
> **Note:** You can omit the constructor parameters if
|
|
23
|
+
> **Note:** You can omit the constructor parameters if the required environment variables (`AUTH0_DOMAIN` and `AUTH0_AUDIENCE`) are set. In that case, use `new MastraAuthAuth0()` without any arguments.
|
|
24
24
|
|
|
25
25
|
## Constructor parameters
|
|
26
26
|
|
|
@@ -61,7 +61,7 @@ Returns: `Promise<T[]>`
|
|
|
61
61
|
|
|
62
62
|
Authorizes a non-user system actor, such as an autonomous or scheduled agent. Optional.
|
|
63
63
|
|
|
64
|
-
System actors skip the user-centric `require()` path, so implement `requireActor` to enforce per-agent least privilege for them. Throw `FGADeniedError` to deny. When a provider doesn't implement `requireActor`, Mastra preserves the trusted-actor bypass (allow after the tenant-scope check), so adding
|
|
64
|
+
System actors skip the user-centric `require()` path, so implement `requireActor` to enforce per-agent least privilege for them. Throw `FGADeniedError` to deny. When a provider doesn't implement `requireActor`, Mastra preserves the trusted-actor bypass (allow after the tenant-scope check), so adding the method remains backward compatible.
|
|
65
65
|
|
|
66
66
|
Treat `actor.permissions` as an untrusted claim. Resolve the agent's authoritative grants from a trusted source keyed by `actor.agentId`, rather than trusting the inline values. See [System actors](https://mastra.ai/docs/server/auth/fga).
|
|
67
67
|
|
|
@@ -110,7 +110,7 @@ The `params` argument passed to `check`, `require`, and `requireActor`.
|
|
|
110
110
|
|
|
111
111
|
## `ActorSignal`
|
|
112
112
|
|
|
113
|
-
Identifies a call made by a trusted non-user actor rather than an authenticated end user. It
|
|
113
|
+
Identifies a call made by a trusted non-user actor rather than an authenticated end user. It's either `true` (the anonymous system shorthand) or an object that names the acting agent and carries the grants a provider can enforce.
|
|
114
114
|
|
|
115
115
|
**actorKind** (`'system'`): Marks the object form of the signal.
|
|
116
116
|
|
|
@@ -24,7 +24,7 @@ export const mastra = new Mastra({
|
|
|
24
24
|
})
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
> **Note:** You can omit the constructor parameters if
|
|
27
|
+
> **Note:** You can omit the constructor parameters if the required environment variables are set. In that case, use `new MastraAuthGoogle()` without any arguments.
|
|
28
28
|
|
|
29
29
|
### Constructor parameters
|
|
30
30
|
|
|
@@ -72,7 +72,7 @@ The following environment variables are automatically used when constructor opti
|
|
|
72
72
|
|
|
73
73
|
`MastraAuthGoogle` authenticates requests in the following order:
|
|
74
74
|
|
|
75
|
-
1. **Session cookie
|
|
75
|
+
1. **Session cookie.** With SSO enabled, the provider reads and decrypts the encrypted session cookie. A valid, unexpired session authenticates the user.
|
|
76
76
|
2. **Google ID token fallback**: If no valid session cookie is present, verifies the `Authorization` header token against Google's JWKS endpoint.
|
|
77
77
|
|
|
78
78
|
After authentication, `authorizeUser` checks that the user has a valid Google user ID, the token-derived expiration hasn't passed, and the user's verified `hd` claim matches `allowedDomains` when domains are configured.
|
|
@@ -24,7 +24,7 @@ export const mastra = new Mastra({
|
|
|
24
24
|
})
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
> **Note:** You can omit the constructor parameters if
|
|
27
|
+
> **Note:** You can omit the constructor parameters if the required environment variables are set. In that case, use `new MastraAuthOkta()` without any arguments.
|
|
28
28
|
|
|
29
29
|
### Constructor parameters
|
|
30
30
|
|
|
@@ -20,7 +20,7 @@ export const mastra = new Mastra({
|
|
|
20
20
|
})
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
> **Note:** You can omit the constructor parameters if
|
|
23
|
+
> **Note:** You can omit the constructor parameters if the required environment variables (`WORKOS_API_KEY` and `WORKOS_CLIENT_ID`) are set. In that case, use `new MastraAuthWorkos()` without any arguments.
|
|
24
24
|
|
|
25
25
|
## Constructor parameters
|
|
26
26
|
|
|
@@ -56,7 +56,7 @@ By default, `MastraAuthWorkos` authorizes any authenticated WorkOS user whose re
|
|
|
56
56
|
2. **User Retrieval**: User information is extracted from the verified token
|
|
57
57
|
3. **Authorization Decision**: Access is granted if the resolved user contains the required identifiers
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
`MastraAuthWorkos` acts as an authentication provider rather than a role gate by default.
|
|
60
60
|
|
|
61
61
|
## FGA membership loading
|
|
62
62
|
|
|
@@ -107,7 +107,7 @@ Navigate to a URL.
|
|
|
107
107
|
|
|
108
108
|
| Parameter | Type | Description |
|
|
109
109
|
| ----------- | ----------------------------------------------- | ----------------------------------------------- |
|
|
110
|
-
| `url` | `string` | URL to
|
|
110
|
+
| `url` | `string` | URL to open |
|
|
111
111
|
| `waitUntil` | `"load" \| "domcontentloaded" \| "networkidle"` | When to consider navigation complete (optional) |
|
|
112
112
|
| `timeout` | `number` | Navigation timeout in ms (optional) |
|
|
113
113
|
|
|
@@ -358,7 +358,7 @@ Execute JavaScript in the page context. Use as an escape hatch when other tools
|
|
|
358
358
|
|
|
359
359
|
### `browser_screenshot`
|
|
360
360
|
|
|
361
|
-
Capture a screenshot of the current page as PNG (viewport by default
|
|
361
|
+
Capture a screenshot of the current page as PNG (viewport by default. Set `fullPage: true` for full-page capture). Returns image content that vision-capable models can interpret directly. Use `browser_snapshot` when you only need text or structured data.
|
|
362
362
|
|
|
363
363
|
```text
|
|
364
364
|
// Viewport only (default)
|
|
@@ -227,6 +227,6 @@ browse skills install
|
|
|
227
227
|
|
|
228
228
|
## Related
|
|
229
229
|
|
|
230
|
-
- [BrowserViewer guide](https://mastra.ai/docs/browser/browser-viewer)
|
|
231
|
-
- [MastraBrowser](https://mastra.ai/reference/browser/mastra-browser)
|
|
232
|
-
- [Workspace overview](https://mastra.ai/docs/workspace/overview)
|
|
230
|
+
- [BrowserViewer guide](https://mastra.ai/docs/browser/browser-viewer): Setup and usage walkthrough
|
|
231
|
+
- [MastraBrowser](https://mastra.ai/reference/browser/mastra-browser): Base class API reference
|
|
232
|
+
- [Workspace overview](https://mastra.ai/docs/workspace/overview): Workspace configuration
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# MastraBrowser class
|
|
4
4
|
|
|
5
|
-
The `MastraBrowser` class is the abstract base class for browser automation providers.
|
|
5
|
+
The `MastraBrowser` class is the abstract base class for browser automation providers. Its common interface covers browser launch and thread isolation, plus screencast streaming and input events.
|
|
6
6
|
|
|
7
7
|
You don't instantiate `MastraBrowser` directly. Instead, use a provider implementation:
|
|
8
8
|
|
|
@@ -135,7 +135,7 @@ const hasSession = browser.hasThreadSession('thread-123')
|
|
|
135
135
|
|
|
136
136
|
#### `closeThreadSession(threadId)`
|
|
137
137
|
|
|
138
|
-
Closes a specific thread's browser session.
|
|
138
|
+
Closes a specific thread's browser session. With 'thread' scope, it closes that thread's browser instance. With 'shared' scope, it clears the thread state.
|
|
139
139
|
|
|
140
140
|
```typescript
|
|
141
141
|
await browser.closeThreadSession('thread-123')
|
|
@@ -145,7 +145,7 @@ await browser.closeThreadSession('thread-123')
|
|
|
145
145
|
|
|
146
146
|
#### `getTools()`
|
|
147
147
|
|
|
148
|
-
Returns the browser tools for use with agents. Each provider returns different tools based on its
|
|
148
|
+
Returns the browser tools for use with agents. Each provider returns different tools based on its model.
|
|
149
149
|
|
|
150
150
|
```typescript
|
|
151
151
|
const tools = browser.getTools()
|
|
@@ -79,7 +79,7 @@ Core tools:
|
|
|
79
79
|
| ---------------------- | ------------------------------------------------------------------------------------- |
|
|
80
80
|
| `stagehand_act` | Perform actions using natural language instructions |
|
|
81
81
|
| `stagehand_extract` | Extract structured data from pages |
|
|
82
|
-
| `stagehand_observe` | Discover
|
|
82
|
+
| `stagehand_observe` | Discover useful elements on a page |
|
|
83
83
|
| `stagehand_navigate` | Navigate to a URL |
|
|
84
84
|
| `stagehand_tabs` | Manage browser tabs |
|
|
85
85
|
| `stagehand_screenshot` | Capture a screenshot as PNG (viewport by default; set `fullPage: true` for full page) |
|
|
@@ -171,7 +171,7 @@ interface ExtractResult<T = unknown> {
|
|
|
171
171
|
|
|
172
172
|
### `stagehand_observe`
|
|
173
173
|
|
|
174
|
-
Discover
|
|
174
|
+
Discover useful elements on a page. Returns a list of elements with their selectors and descriptions.
|
|
175
175
|
|
|
176
176
|
```text
|
|
177
177
|
// Find specific elements
|
|
@@ -222,7 +222,7 @@ Navigate to a URL.
|
|
|
222
222
|
|
|
223
223
|
| Parameter | Type | Description |
|
|
224
224
|
| ----------- | ----------------------------------------------- | ----------------------------------------------- |
|
|
225
|
-
| `url` | `string` | URL to
|
|
225
|
+
| `url` | `string` | URL to open (required) |
|
|
226
226
|
| `waitUntil` | `"load" \| "domcontentloaded" \| "networkidle"` | When to consider navigation complete (optional) |
|
|
227
227
|
|
|
228
228
|
### `stagehand_tabs`
|
|
@@ -245,7 +245,7 @@ Manage browser tabs.
|
|
|
245
245
|
|
|
246
246
|
### `stagehand_screenshot`
|
|
247
247
|
|
|
248
|
-
Capture a screenshot of the current page as PNG (viewport by default
|
|
248
|
+
Capture a screenshot of the current page as PNG (viewport by default. Set `fullPage: true` for full-page capture). Returns image content that vision-capable models can interpret directly. Use `stagehand_observe` or `stagehand_extract` when you only need text or structured data.
|
|
249
249
|
|
|
250
250
|
```text
|
|
251
251
|
// Viewport only (default)
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
9
|
-
Register the provider on the `Mastra` constructor. The refresh token is single-use and rotates on startup
|
|
9
|
+
Register the provider on the `Mastra` constructor. The refresh token is single-use and rotates on startup. The resulting access tokens are persisted to `Mastra.storage`.
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
12
|
import { Mastra } from '@mastra/core/mastra'
|
|
@@ -171,7 +171,7 @@ slack.setBaseUrl('https://abc123.trycloudflare.com')
|
|
|
171
171
|
|
|
172
172
|
#### `initialize()`
|
|
173
173
|
|
|
174
|
-
Recreates a `SlackAdapter` for each active installation in storage and injects `AgentChannels` into the corresponding agent so it receives Slack events on startup. Doesn't auto-provision new apps
|
|
174
|
+
Recreates a `SlackAdapter` for each active installation in storage and injects `AgentChannels` into the corresponding agent so it receives Slack events on startup. Doesn't auto-provision new apps. Use `connect()` to create one. Mastra calls this automatically, so you rarely call it directly.
|
|
175
175
|
|
|
176
176
|
```typescript
|
|
177
177
|
await slack.initialize()
|
|
@@ -60,7 +60,7 @@ yarn dlx create-mastra@latest my-mastra-project --llm anthropic
|
|
|
60
60
|
bun x create-mastra@latest my-mastra-project --llm anthropic
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
Omit `--llm` to select the provider and optionally enter its API key interactively. The interactive setup also offers to connect your project to the Mastra platform. If enabled, the command opens the browser authentication flow
|
|
63
|
+
Omit `--llm` to select the provider and optionally enter its API key interactively. The interactive setup also offers to connect your project to the Mastra platform. If enabled, the command opens the browser authentication flow and creates a platform project with the same name as the local project. It then writes `MASTRA_PLATFORM_ACCESS_TOKEN` and `MASTRA_PROJECT_ID` to `.env`.
|
|
64
64
|
|
|
65
65
|
### Template
|
|
66
66
|
|
|
@@ -32,7 +32,7 @@ Comma-separated list of custom arguments to pass to the Node.js process, e.g. `-
|
|
|
32
32
|
|
|
33
33
|
#### `--request-context-presets`
|
|
34
34
|
|
|
35
|
-
Path to a JSON file containing
|
|
35
|
+
Path to a JSON file containing [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.
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
38
|
mastra dev --request-context-presets ./presets.json
|
|
@@ -49,7 +49,7 @@ The file must be a JSON object where each key is a preset name and each value is
|
|
|
49
49
|
|
|
50
50
|
### Configs
|
|
51
51
|
|
|
52
|
-
You can set
|
|
52
|
+
You can set environment variables to modify the behavior of `mastra dev`.
|
|
53
53
|
|
|
54
54
|
#### Skip peer dependency check
|
|
55
55
|
|
|
@@ -121,7 +121,7 @@ Under the hood Mastra's Rollup server locates your Mastra entry file and bundles
|
|
|
121
121
|
|
|
122
122
|
The output in `.mastra` can be deployed to any cloud server using [`mastra start`](#mastra-start).
|
|
123
123
|
|
|
124
|
-
If you're deploying to a [serverless platform](https://mastra.ai/docs/deployment/cloud-providers) you need to install the correct deployer
|
|
124
|
+
If you're deploying to a [serverless platform](https://mastra.ai/docs/deployment/cloud-providers) you need to install the correct deployer to receive the correct output in `.mastra`.
|
|
125
125
|
|
|
126
126
|
It accepts [common flags](#common-flags).
|
|
127
127
|
|
|
@@ -133,7 +133,7 @@ Bundle the Studio UI with the build.
|
|
|
133
133
|
|
|
134
134
|
### Configs
|
|
135
135
|
|
|
136
|
-
You can set
|
|
136
|
+
You can set environment variables to modify the behavior of `mastra build`.
|
|
137
137
|
|
|
138
138
|
#### Skip peer dependency check
|
|
139
139
|
|
|
@@ -199,7 +199,7 @@ The API route prefix of the Mastra API server. Defaults to `/api`.
|
|
|
199
199
|
|
|
200
200
|
#### `--request-context-presets`
|
|
201
201
|
|
|
202
|
-
Path to a JSON file containing
|
|
202
|
+
Path to a JSON file containing [request context](https://mastra.ai/docs/server/request-context) presets. Works the same as the [`mastra dev` flag](#--request-context-presets).
|
|
203
203
|
|
|
204
204
|
```bash
|
|
205
205
|
mastra studio --request-context-presets ./presets.json
|
|
@@ -207,7 +207,7 @@ mastra studio --request-context-presets ./presets.json
|
|
|
207
207
|
|
|
208
208
|
## `mastra deploy`
|
|
209
209
|
|
|
210
|
-
Builds and deploys your project to
|
|
210
|
+
Builds and deploys your project to the Mastra platform environment selected by `--env`. This is the recommended command for all new deploys and replaces both [`mastra studio deploy`](#mastra-studio-deploy) and [`mastra server deploy`](#mastra-server-deploy), which continue to work but should no longer be used for new setups.
|
|
211
211
|
|
|
212
212
|
Requires authentication via [`mastra auth login`](#mastra-auth-login) or a `MASTRA_API_TOKEN` environment variable.
|
|
213
213
|
|
|
@@ -217,7 +217,7 @@ mastra deploy --env staging
|
|
|
217
217
|
mastra deploy --env production --region eu
|
|
218
218
|
```
|
|
219
219
|
|
|
220
|
-
The command runs `mastra build
|
|
220
|
+
The command runs `mastra build` and zips the output before uploading it to the selected environment. It then polls the deploy status while streaming build logs until the deploy reaches a terminal state.
|
|
221
221
|
|
|
222
222
|
Organization, project, and environment are resolved in order from: environment variable (`MASTRA_ORG_ID`, `MASTRA_PROJECT_ID`), CLI flag (`--org`, `--project`, `--env`), `.mastra-project.json` config file, current org from credentials, and lastly interactive prompt. On first deploy, the CLI saves the resolved org and project IDs to `.mastra-project.json` so subsequent deploys skip the prompts.
|
|
223
223
|
|
|
@@ -294,9 +294,9 @@ mastra deploy --env staging --yes
|
|
|
294
294
|
|
|
295
295
|
## `mastra env`
|
|
296
296
|
|
|
297
|
-
Manages environments on Mastra platform. Environments are
|
|
297
|
+
Manages environments on Mastra platform. Environments are deploy targets (for example `production`, `staging`, `preview-42`) that belong to a project. The current organization is resolved from stored credentials.
|
|
298
298
|
|
|
299
|
-
Every subcommand resolves its project
|
|
299
|
+
Every subcommand resolves its project in a fixed order. It first checks the `MASTRA_PROJECT_ID` environment variable and the `--project <name|slug|id>` flag. It then reads the `.mastra-project.json` file written by [`mastra deploy`](#mastra-deploy) in the current directory. Run from your project directory and you never need to name the project.
|
|
300
300
|
|
|
301
301
|
### `mastra env list`
|
|
302
302
|
|
|
@@ -356,7 +356,7 @@ mastra env restart <env>
|
|
|
356
356
|
|
|
357
357
|
### `mastra env vars pull`
|
|
358
358
|
|
|
359
|
-
Pulls an environment's env vars into a local env file (default: `.env`). The file contains the merged set a deploy
|
|
359
|
+
Pulls an environment's env vars into a local env file (default: `.env`). The file contains the merged set used by a deploy. It combines vars stored on the environment (for example, added in the dashboard's environment editor) with project-level vars. Project values win on conflict. Managed vars injected by attached databases are listed as comments (names only) since their values are platform-managed secrets.
|
|
360
360
|
|
|
361
361
|
```bash
|
|
362
362
|
mastra env vars pull
|
|
@@ -373,7 +373,7 @@ File to write. Defaults to `.env`.
|
|
|
373
373
|
|
|
374
374
|
Manages databases attached to a project on Mastra platform. Databases are provisioned from a managed provider (for example Turso or Neon) and inject their connection env vars into deploys automatically.
|
|
375
375
|
|
|
376
|
-
A database is either **environment-scoped** (its env vars only go to one environment) or **shared** (project-scoped: its env vars go to all environments). Environment-scoped is the default for `mastra env db create
|
|
376
|
+
A database is either **environment-scoped** (its env vars only go to one environment) or **shared** (project-scoped: its env vars go to all environments). Environment-scoped is the default for `mastra env db create`: pass an environment argument, or let the CLI pick or prompt for one. Pass `--shared` on create to attach a shared database instead. For other subcommands (`list`, `delete`, `keys`), pass the environment argument to work with environment-scoped databases and omit it for shared databases.
|
|
377
377
|
|
|
378
378
|
Creating and deleting databases requires the `admin` role in the organization.
|
|
379
379
|
|
|
@@ -392,7 +392,7 @@ Emit machine-readable JSON.
|
|
|
392
392
|
|
|
393
393
|
### `mastra env db create`
|
|
394
394
|
|
|
395
|
-
Provisions a managed database,
|
|
395
|
+
Provisions and attaches a managed database, then polls until it's ready. Provisioning errors are printed with the provider's error detail.
|
|
396
396
|
|
|
397
397
|
By default the database is scoped to a single environment: pass an environment argument to pick it, or omit the argument to have the CLI pick for you. When the project has one environment, that environment is used. When it has several, the CLI prompts you to select one interactively; in non-interactive contexts (CI, `--json`) an environment argument is required. Pass `--shared` to attach a project-scoped database that's shared by every environment instead.
|
|
398
398
|
|
|
@@ -419,7 +419,7 @@ Provider region ID for shared databases. Ignored for environment-scoped database
|
|
|
419
419
|
|
|
420
420
|
#### `--shared`
|
|
421
421
|
|
|
422
|
-
Attach as a project-scoped database that's shared by every environment.
|
|
422
|
+
Attach as a project-scoped database that's shared by every environment. Can't be combined with an environment argument.
|
|
423
423
|
|
|
424
424
|
#### `--no-wait`
|
|
425
425
|
|
|
@@ -475,7 +475,7 @@ Emit machine-readable JSON.
|
|
|
475
475
|
|
|
476
476
|
## `mastra studio deploy`
|
|
477
477
|
|
|
478
|
-
> **Info:** `mastra studio deploy` continues to work but is superseded by [`mastra deploy`](#mastra-deploy), which supports
|
|
478
|
+
> **Info:** `mastra studio deploy` continues to work but is superseded by [`mastra deploy`](#mastra-deploy), which supports environments (`--env staging`, `--env production`) on a single project. New setups should use `mastra deploy`.
|
|
479
479
|
|
|
480
480
|
Builds and deploys your project to Mastra platform. Requires authentication via [`mastra auth login`](#mastra-auth-login) or a `MASTRA_API_TOKEN` environment variable.
|
|
481
481
|
|
|
@@ -483,11 +483,11 @@ Builds and deploys your project to Mastra platform. Requires authentication via
|
|
|
483
483
|
mastra studio deploy
|
|
484
484
|
```
|
|
485
485
|
|
|
486
|
-
The command runs `mastra build
|
|
486
|
+
The command runs `mastra build` and zips the output. It reads an env file from the project directory before uploading everything to the platform. After uploading, it polls the deploy status and streams build logs until the deploy reaches a terminal state.
|
|
487
487
|
|
|
488
488
|
The deploy command auto-loads the project's `.env` file. If `MASTRA_PROJECT_ID` points to a project that was provisioned for Observability, the deploy links to that project instead of creating a new one. Deploying Studio to an observability-only project converts it into a Studio project on the platform side.
|
|
489
489
|
|
|
490
|
-
The CLI requires at least one `.env` or `.env.*` file (excluding `.env.example`) in the project directory and fails with `Error: No env file found for deploy.` if none exists. When multiple env files are present, the CLI prompts you to pick one (defaulting to `.env.production`)
|
|
490
|
+
The CLI requires at least one `.env` or `.env.*` file (excluding `.env.example`) in the project directory and fails with `Error: No env file found for deploy.` if none exists. When multiple env files are present, the CLI prompts you to pick one (defaulting to `.env.production`). Pass `--env-file` to choose explicitly. With `--yes` and multiple env files, you must pass `--env-file` or the deploy errors.
|
|
491
491
|
|
|
492
492
|
Organization and project are resolved in order from: Environment variable flag, `.mastra-project.json` config file, current org from credentials, and lastly interactive prompt. On first deploy, the CLI saves the resolved IDs to `.mastra-project.json` so subsequent deploys skip the prompts.
|
|
493
493
|
|
|
@@ -581,7 +581,7 @@ Shows diagnosis results and suggested fixes for a failed Studio deploy.
|
|
|
581
581
|
mastra studio deploy suggestions [deploy-id]
|
|
582
582
|
```
|
|
583
583
|
|
|
584
|
-
If you omit `deploy-id`, the command uses the latest deploy for the linked project. If a diagnosis doesn't exist yet, the command starts one and polls until results are ready.
|
|
584
|
+
If you omit `deploy-id`, the command uses the latest deploy for the linked project. If a diagnosis doesn't exist yet, the command starts one and polls until results are ready. Suggestions appear only when the diagnosis finds a problem.
|
|
585
585
|
|
|
586
586
|
### `mastra studio projects`
|
|
587
587
|
|
|
@@ -593,7 +593,7 @@ Creates a new project through an interactive prompt. This command doesn't accept
|
|
|
593
593
|
|
|
594
594
|
## `mastra server deploy`
|
|
595
595
|
|
|
596
|
-
> **Info:** `mastra server deploy` continues to work but is superseded by [`mastra deploy`](#mastra-deploy), which deploys a single project to multiple
|
|
596
|
+
> **Info:** `mastra server deploy` continues to work but is superseded by [`mastra deploy`](#mastra-deploy), which deploys a single project to multiple environments instead of separate Studio and Server commands. New setups should use `mastra deploy`.
|
|
597
597
|
|
|
598
598
|
Builds and deploys your project to Server on Mastra platform. Works the same as [`mastra studio deploy`](#mastra-studio-deploy) with the same flags, arguments, and resolution logic.
|
|
599
599
|
|
|
@@ -611,7 +611,7 @@ Shows diagnosis results and suggested fixes for a failed Server deploy.
|
|
|
611
611
|
mastra server deploy suggestions [deploy-id]
|
|
612
612
|
```
|
|
613
613
|
|
|
614
|
-
If you omit `deploy-id`, the command uses the latest deploy for the linked project. If a diagnosis doesn't exist yet, the command starts one and polls until results are ready.
|
|
614
|
+
If you omit `deploy-id`, the command uses the latest deploy for the linked project. If a diagnosis doesn't exist yet, the command starts one and polls until results are ready. Suggestions appear only when the diagnosis finds a problem.
|
|
615
615
|
|
|
616
616
|
## `mastra server pause`
|
|
617
617
|
|
|
@@ -649,7 +649,7 @@ Same flags as [`mastra server pause`](#mastra-server-pause): **`--org`**, **`--p
|
|
|
649
649
|
mastra server restart
|
|
650
650
|
```
|
|
651
651
|
|
|
652
|
-
Fails if a deployment is still active for this project (running, building, deploying, etc.)
|
|
652
|
+
Fails if a deployment is still active for this project (running, building, deploying, etc.). That's a platform restriction so you can't restart while another deploy is in progress.
|
|
653
653
|
|
|
654
654
|
## `mastra server env`
|
|
655
655
|
|
|
@@ -892,7 +892,7 @@ Configure your code editor with Mastra's MCP server. Choose from: `"cursor" | "c
|
|
|
892
892
|
|
|
893
893
|
#### `--observability`
|
|
894
894
|
|
|
895
|
-
Enable Observability on the Mastra platform. The CLI prompts you to select an existing platform project or create a new one
|
|
895
|
+
Enable Observability on the Mastra platform. The CLI prompts you to select an existing platform project or create a new one. It then writes the required environment variables and configures the observability exporters.
|
|
896
896
|
|
|
897
897
|
#### `--no-observability`
|
|
898
898
|
|
|
@@ -906,7 +906,7 @@ Set the platform project name to use when Mastra Observability is enabled.
|
|
|
906
906
|
|
|
907
907
|
Runs database migrations to update your storage schema. This command is useful when upgrading Mastra versions that include storage schema changes.
|
|
908
908
|
|
|
909
|
-
The command bundles your project
|
|
909
|
+
The command bundles your project and connects to your configured storage backend. It then executes any pending migrations. Currently supports:
|
|
910
910
|
|
|
911
911
|
- **Duplicate spans migration**: Removes duplicate `(traceId, spanId)` entries and adds a unique constraint to ensure data integrity.
|
|
912
912
|
- **ClickHouse legacy-to-vNext span migration**: Copies historical spans from the legacy `mastra_ai_spans` table to the vNext `mastra_span_events` schema. Runs in batches to stay within memory limits. See the [ClickHouse storage reference](https://mastra.ai/reference/storage/clickhouse) for details.
|
|
@@ -1417,7 +1417,7 @@ curl -sS "https://observability.mastra.ai/api/observability/traces/<trace-id>/sp
|
|
|
1417
1417
|
|
|
1418
1418
|
#### `mastra api score create`
|
|
1419
1419
|
|
|
1420
|
-
Creates an observability score. The input uses the server score body shape
|
|
1420
|
+
Creates an observability score. The input uses the server score body shape. Inspect it with `--schema`.
|
|
1421
1421
|
|
|
1422
1422
|
```bash
|
|
1423
1423
|
mastra api score create <input>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Agents API
|
|
4
4
|
|
|
5
|
-
The Agents API provides methods to interact with Mastra AI agents, including generating responses
|
|
5
|
+
The Agents API provides methods to interact with Mastra AI agents, including generating responses and streaming interactions. It also provides methods for managing agent tools.
|
|
6
6
|
|
|
7
7
|
## Getting all agents
|
|
8
8
|
|
|
@@ -155,7 +155,7 @@ for await (const part of uiMessageStream) {
|
|
|
155
155
|
|
|
156
156
|
### `sendMessage()`
|
|
157
157
|
|
|
158
|
-
Send user-authored input to an active agent run or idle memory thread. Use this with `subscribeToThread()` so the client can render the stream that wakes from, or receives
|
|
158
|
+
Send user-authored input to an active agent run or idle memory thread. Use this with `subscribeToThread()` so the client can render the stream that wakes from, or receives the message.
|
|
159
159
|
|
|
160
160
|
```typescript
|
|
161
161
|
const agent = mastraClient.getAgent('support-agent')
|
|
@@ -285,7 +285,7 @@ await subscription.processDataStream({
|
|
|
285
285
|
|
|
286
286
|
### `streamUntilIdle()`
|
|
287
287
|
|
|
288
|
-
Stream a response and keep the stream open until every [background task](https://mastra.ai/docs/long-running-agents/background-tasks) dispatched during the run completes. The server re-enters the agentic loop on each task completion so the LLM can react to results in the same call. Requires background tasks to be [enabled on the Mastra instance](https://mastra.ai/reference/configuration) and a memory thread; otherwise the call
|
|
288
|
+
Stream a response and keep the stream open until every [background task](https://mastra.ai/docs/long-running-agents/background-tasks) dispatched during the run completes. The server re-enters the agentic loop on each task completion so the LLM can react to results in the same call. Requires background tasks to be [enabled on the Mastra instance](https://mastra.ai/reference/configuration) and a memory thread; otherwise the call uses a plain `stream()`.
|
|
289
289
|
|
|
290
290
|
```typescript
|
|
291
291
|
const response = await agent.streamUntilIdle('Research solana for me', {
|
|
@@ -307,7 +307,7 @@ response.processDataStream({
|
|
|
307
307
|
|
|
308
308
|
### `resumeStreamUntilIdle()`
|
|
309
309
|
|
|
310
|
-
Resume a suspended agent stream with custom data and keep the stream open until every [background task](https://mastra.ai/docs/long-running-agents/background-tasks) dispatched during the run completes. Use this to continue execution after a suspension point, such as a workflow suspend within an agent. Requires background tasks to be [enabled on the Mastra instance](https://mastra.ai/reference/configuration) and a memory thread; otherwise the call
|
|
310
|
+
Resume a suspended agent stream with custom data and keep the stream open until every [background task](https://mastra.ai/docs/long-running-agents/background-tasks) dispatched during the run completes. Use this to continue execution after a suspension point, such as a workflow suspend within an agent. Requires background tasks to be [enabled on the Mastra instance](https://mastra.ai/reference/configuration) and a memory thread; otherwise the call uses a plain `resumeStream()`:
|
|
311
311
|
|
|
312
312
|
```typescript
|
|
313
313
|
const response = await agent.resumeStreamUntilIdle(
|
|
@@ -366,7 +366,7 @@ response.processDataStream({
|
|
|
366
366
|
|
|
367
367
|
### `listSuspendedRuns()`
|
|
368
368
|
|
|
369
|
-
List suspended runs for the agent from storage
|
|
369
|
+
List suspended runs for the agent from storage: runs waiting on a tool-call approval or on a tool that suspended. Discovery is backed by storage, so it works after a server restart and across server instances. Pass the returned `runId` to `approveToolCall()`, `declineToolCall()`, or `resumeStream()`.
|
|
370
370
|
|
|
371
371
|
```typescript
|
|
372
372
|
const { runs, total } = await agent.listSuspendedRuns({
|
|
@@ -655,9 +655,9 @@ const screenshotTool = createTool({
|
|
|
655
655
|
|
|
656
656
|
### Tracing client tools
|
|
657
657
|
|
|
658
|
-
When `@mastra/observability` is installed and configured on the server, a client-side tool records a `CLIENT_TOOL_CALL` span as a child of the current `AGENT_RUN` span. The server creates that span when the model emits the client tool call
|
|
658
|
+
When `@mastra/observability` is installed and configured on the server, a client-side tool records a `CLIENT_TOOL_CALL` span as a child of the current `AGENT_RUN` span. The server creates that span when the model emits the client tool call and injects a W3C trace carrier into the outgoing tool-call chunk. It ends the span once the tool arguments are available. Without server-side observability configured, client tool tracing is a no-op.
|
|
659
659
|
|
|
660
|
-
The client SDK also measures the wall-clock duration of each client tool's `execute` function and
|
|
660
|
+
The client SDK also measures the wall-clock duration of each client tool's `execute` function and sends it back to the server, where it's emitted as a `mastra_tool_duration_ms` metric with `toolType: "client"`.
|
|
661
661
|
|
|
662
662
|
For richer telemetry from inside your tool's `execute` function, use the `observe` helper on the execution context to add child spans and structured logs:
|
|
663
663
|
|
|
@@ -680,9 +680,9 @@ const fetchUserTool = createTool({
|
|
|
680
680
|
})
|
|
681
681
|
```
|
|
682
682
|
|
|
683
|
-
`observe` is always available
|
|
683
|
+
`observe` is always available: when no tracing context is active (e.g. running outside a traced agent), `span` runs the function directly and `log` is a no-op. No null-checking needed.
|
|
684
684
|
|
|
685
|
-
The SDK serializes everything the collector buffered as OTLP/JSON and
|
|
685
|
+
The SDK serializes everything the collector buffered as OTLP/JSON and sends it back in the next request body. The server's `@mastra/observability` package validates that the spans belong to the correct trace (preventing cross-trace injection) and forwards each span/log into the same observability bus that server-side telemetry uses. Your existing exporters pick them up automatically after observability is configured.
|
|
686
686
|
|
|
687
687
|
## Stored agents
|
|
688
688
|
|
|
@@ -168,7 +168,7 @@ const result = await thread.listMessages({
|
|
|
168
168
|
})
|
|
169
169
|
```
|
|
170
170
|
|
|
171
|
-
Metadata filters match shallow scalar values only: `string`, finite `number`, `boolean`, and `null`. Every key-value pair must match with AND semantics. `null` matches
|
|
171
|
+
Metadata filters match shallow scalar values only: `string`, finite `number`, `boolean`, and `null`. Every key-value pair must match with AND semantics. `null` matches only keys explicitly set to `null`. Metadata keys must start with a letter or underscore and contain only alphanumeric or underscore characters. The limit is 128 characters. Reserved prototype keys such as `__proto__`, `constructor`, and `prototype` aren't allowed. Performance depends on the server storage backend, and arbitrary metadata filters may scan candidate messages.
|
|
172
172
|
|
|
173
173
|
### Delete Messages
|
|
174
174
|
|
|
@@ -226,7 +226,7 @@ await mastraClient.updateWorkingMemory({
|
|
|
226
226
|
// Returns: { success: true }
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
For resource-scoped working memory, you must provide the `resourceId` parameter. It allows the memory to persist across all conversation threads for that user.
|
|
230
230
|
|
|
231
231
|
### Get Memory Status
|
|
232
232
|
|
|
@@ -142,7 +142,7 @@ await run.resume({
|
|
|
142
142
|
})
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
-
When a [`.foreach()`](https://mastra.ai/reference/workflows/workflow-methods/foreach) step suspends across multiple iterations, pass `forEachIndex` (zero-based
|
|
145
|
+
When a [`.foreach()`](https://mastra.ai/reference/workflows/workflow-methods/foreach) step suspends across multiple iterations, pass `forEachIndex` (zero-based. `0` targets the first iteration) to resume one iteration at a time. Iterations you don't target remain suspended.
|
|
146
146
|
|
|
147
147
|
```typescript
|
|
148
148
|
await run.resume({
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
# buildBasePrompt()
|
|
4
4
|
|
|
5
|
-
`buildBasePrompt()` builds the shared base system prompt for a coding agent
|
|
5
|
+
`buildBasePrompt()` builds the shared base system prompt for a coding agent: the behavioral instructions that make the agent a good coding assistant. It takes a `PromptContext` describing the current environment (project, platform, git branch, mode, model) and returns the prompt as a string.
|
|
6
6
|
|
|
7
7
|
Product-specific strings are parameterized through `productName`, `coAuthorName`, and `coAuthorEmail`, so you can rebrand the prompt and commit trailer without forking it. They default to `"Mastra Code"` / `"noreply@mastra.ai"`, so existing callers keep identical output.
|
|
8
8
|
|
|
9
|
-
Use this with [`createCodingAgent()`](https://mastra.ai/reference/coding-agent/create-coding-agent) when you build
|
|
9
|
+
Use this with [`createCodingAgent()`](https://mastra.ai/reference/coding-agent/create-coding-agent) when you build runtime-defined instructions for the agent.
|
|
10
10
|
|
|
11
11
|
## Usage example
|
|
12
12
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
`createCodingAgent()` builds a coding [`Agent`](https://mastra.ai/reference/agents/agent) with portable defaults for the pieces a coding agent always needs: a local workspace, the task-list signal provider, network-retry error processors, and the goal judge prompt. Supply only `model`, `instructions`, and `tools` to get a working agent, or override any default.
|
|
6
6
|
|
|
7
|
-
The returned value is a standard `Agent`, so it works anywhere an `Agent` does
|
|
7
|
+
The returned value is a standard `Agent`, so it works anywhere an `Agent` does: including as the agent passed to an [`AgentController`](https://mastra.ai/reference/agent-controller/agent-controller-class).
|
|
8
8
|
|
|
9
9
|
## Usage example
|
|
10
10
|
|
|
@@ -70,7 +70,7 @@ new Workspace({
|
|
|
70
70
|
})
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
To opt out
|
|
73
|
+
To opt out (for example, when the workspace is injected at the [`AgentController`](https://mastra.ai/reference/agent-controller/agent-controller-class) level), pass `workspace: undefined` explicitly:
|
|
74
74
|
|
|
75
75
|
```typescript
|
|
76
76
|
const agent = createCodingAgent({
|
|
@@ -242,7 +242,7 @@ export const mastra = new Mastra({
|
|
|
242
242
|
|
|
243
243
|
**Type:** `Record<string, MastraMemory>`
|
|
244
244
|
|
|
245
|
-
A registry of memory instances that can be referenced by agents. Memory gives agents coherence across interactions by retaining relevant information from past conversations. Mastra supports
|
|
245
|
+
A registry of memory instances that can be referenced by agents. Memory gives agents coherence across interactions by retaining relevant information from past conversations. Mastra supports message history for recent messages and working memory for persistent user-specific details. Semantic recall retrieves older messages based on relevance.
|
|
246
246
|
|
|
247
247
|
Visit the [Memory documentation](https://mastra.ai/docs/memory/overview) to learn more.
|
|
248
248
|
|
|
@@ -343,7 +343,7 @@ export const mastra = new Mastra({
|
|
|
343
343
|
|
|
344
344
|
**Type:** `Record<string, Scorer>`
|
|
345
345
|
|
|
346
|
-
Scorers assess the quality of agent responses and workflow outputs. They provide quantifiable metrics for measuring agent quality using model-graded, rule-based, and statistical methods. Use scorers to track performance
|
|
346
|
+
Scorers assess the quality of agent responses and workflow outputs. They provide quantifiable metrics for measuring agent quality using model-graded, rule-based, and statistical methods. Use scorers to track performance and compare approaches. They can also identify areas for improvement.
|
|
347
347
|
|
|
348
348
|
Visit the [Scorers documentation](https://mastra.ai/docs/evals/overview) to learn more.
|
|
349
349
|
|
|
@@ -505,11 +505,11 @@ const mastra = new Mastra({
|
|
|
505
505
|
**Type:** `boolean | string[]`\
|
|
506
506
|
**Default:** `true`
|
|
507
507
|
|
|
508
|
-
When `mastra build` is run, Mastra bundles your project into the `.mastra/output` directory. This option controls which packages are excluded from the bundle (marked as "external") and installed separately through a package manager. This is useful when the internal Mastra bundler ([Rollup](https://rollupjs.org/configuration-options/#external)) has trouble bundling
|
|
508
|
+
When `mastra build` is run, Mastra bundles your project into the `.mastra/output` directory. This option controls which packages are excluded from the bundle (marked as "external") and installed separately through a package manager. This is useful when the internal Mastra bundler ([Rollup](https://rollupjs.org/configuration-options/#external)) has trouble bundling packages.
|
|
509
509
|
|
|
510
510
|
By default, `mastra build` sets this option to `true`.
|
|
511
511
|
|
|
512
|
-
|
|
512
|
+
The values have these meanings:
|
|
513
513
|
|
|
514
514
|
- `true`: All dependencies listed in your project's `package.json` are marked as external
|
|
515
515
|
- `false`: No dependencies are marked as external; everything is bundled together
|
|
@@ -784,7 +784,7 @@ export const mastra = new Mastra({
|
|
|
784
784
|
|
|
785
785
|
Custom error handler called when an unhandled error occurs. Use this to customize error responses, log errors to external services like Sentry, or implement custom error formatting.
|
|
786
786
|
|
|
787
|
-
This hook is supported by all server adapters. The `c` parameter provides a Hono-compatible context object
|
|
787
|
+
This hook is supported by all server adapters. The `c` parameter provides a Hono-compatible context object: for non-Hono adapters (Koa, Express, Fastify), a shim is provided with commonly used methods like `c.json()` and `c.req.path`.
|
|
788
788
|
|
|
789
789
|
```typescript
|
|
790
790
|
import { Mastra } from '@mastra/core'
|
|
@@ -813,7 +813,7 @@ export const mastra = new Mastra({
|
|
|
813
813
|
|
|
814
814
|
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.
|
|
815
815
|
|
|
816
|
-
Return a `{ status, body }` object to override the default `400` response, or `undefined` to
|
|
816
|
+
Return a `{ status, body }` object to override the default `400` response, or `undefined` to use the default behavior. This hook is supported by all server adapters (Hono, Express, Fastify, Koa).
|
|
817
817
|
|
|
818
818
|
The `context` parameter indicates which part of the request failed validation:
|
|
819
819
|
|
|
@@ -30,7 +30,7 @@ const serverById = mastra.getMCPServerById('my-mcp-server')
|
|
|
30
30
|
|
|
31
31
|
## Parameters
|
|
32
32
|
|
|
33
|
-
**registryKey** (`string`): The registry key used when registering the MCP server in the mcpServers configuration object.
|
|
33
|
+
**registryKey** (`string`): The registry key used when registering the MCP server in the mcpServers configuration object. It is the configuration key in the key-value pair, not the server's intrinsic id property.
|
|
34
34
|
|
|
35
35
|
## Returns
|
|
36
36
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# getScorer()
|
|
4
4
|
|
|
5
|
-
The `getScorer()` method retrieves a specific scorer that was registered with the Mastra instance using its registration key.
|
|
5
|
+
The `getScorer()` method retrieves a specific scorer that was registered with the Mastra instance using its registration key. The method provides type-safe access to scorers and throws an error if the requested scorer isn't found.
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|