@mastra/mcp-docs-server 1.2.6 → 1.2.7-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/agent-builder/integrations.md +1 -1
- package/.docs/docs/agent-builder/overview.md +4 -3
- package/.docs/docs/agent-builder/skill-registries.md +1 -3
- package/.docs/docs/agent-controller/modes.md +1 -1
- package/.docs/docs/agent-controller/overview.md +4 -3
- package/.docs/docs/agent-controller/session.md +3 -5
- package/.docs/docs/agents/a2a.md +2 -1
- package/.docs/docs/agents/agent-approval.md +2 -2
- package/.docs/docs/agents/code-mode.md +1 -1
- package/.docs/docs/agents/guardrails.md +10 -9
- package/.docs/docs/agents/networks.md +1 -1
- package/.docs/docs/agents/overview.md +5 -5
- package/.docs/docs/agents/skills.md +3 -5
- package/.docs/docs/agents/structured-output.md +1 -1
- package/.docs/docs/agents/supervisor-agents.md +3 -4
- package/.docs/docs/agents/using-tools.md +2 -4
- package/.docs/docs/browser/agent-browser.md +1 -3
- package/.docs/docs/browser/browser-viewer.md +1 -3
- package/.docs/docs/browser/overview.md +2 -1
- package/.docs/docs/browser/recording.md +1 -1
- package/.docs/docs/browser/stagehand.md +1 -1
- package/.docs/docs/capabilities/channels/discord.md +98 -0
- package/.docs/docs/capabilities/channels/other-adapters.md +68 -0
- package/.docs/docs/capabilities/channels/overview.md +255 -0
- package/.docs/docs/capabilities/channels/slack.md +225 -0
- package/.docs/docs/capabilities/channels/teams.md +100 -0
- package/.docs/docs/capabilities/channels/telegram.md +98 -0
- package/.docs/docs/capabilities/channels/whatsapp.md +99 -0
- package/.docs/docs/deployment/mastra-server.md +2 -4
- package/.docs/docs/editor/overview.md +2 -6
- package/.docs/docs/editor/prompts.md +1 -1
- package/.docs/docs/editor/tools.md +1 -3
- package/.docs/docs/evals/built-in-scorers.md +2 -2
- package/.docs/docs/evals/custom-scorers.md +1 -3
- package/.docs/docs/evals/datasets/overview.md +4 -5
- package/.docs/docs/evals/datasets/running-experiments.md +10 -8
- package/.docs/docs/evals/evals-with-memory.md +1 -3
- package/.docs/docs/evals/gates-and-verdicts.md +2 -4
- package/.docs/docs/evals/overview.md +4 -1
- package/.docs/docs/evals/quick-checks.md +3 -5
- package/.docs/docs/getting-started/file-based-agents.md +114 -0
- package/.docs/docs/getting-started/manual-install.md +17 -4
- package/.docs/docs/index.md +1 -1
- package/.docs/docs/long-running-agents/background-tasks.md +3 -3
- package/.docs/docs/long-running-agents/durable-agents.md +5 -7
- package/.docs/docs/long-running-agents/goals.md +5 -7
- package/.docs/docs/long-running-agents/schedules.md +1 -1
- package/.docs/docs/long-running-agents/signal-providers.md +1 -3
- package/.docs/docs/long-running-agents/signals.md +12 -23
- package/.docs/docs/mastra-platform/database.md +2 -2
- package/.docs/docs/mastra-platform/github.md +1 -1
- package/.docs/docs/mastra-platform/observability.md +5 -1
- package/.docs/docs/mcp/mcp-apps.md +3 -3
- package/.docs/docs/mcp/overview.md +6 -10
- package/.docs/docs/memory/memory-processors.md +67 -0
- package/.docs/docs/memory/message-history.md +56 -2
- package/.docs/docs/memory/observational-memory.md +5 -4
- package/.docs/docs/memory/overview.md +8 -6
- package/.docs/docs/memory/semantic-recall.md +36 -2
- package/.docs/docs/memory/working-memory.md +3 -3
- package/.docs/docs/observability/integrations/exporters/mastra-platform.md +1 -3
- package/.docs/docs/observability/integrations/exporters/mastra-storage.md +1 -1
- package/.docs/docs/observability/logging.md +1 -1
- package/.docs/docs/observability/tracing/overview.md +1 -1
- package/.docs/docs/rag/vector-databases.md +7 -2
- package/.docs/docs/server/auth/auth0.md +1 -1
- package/.docs/docs/server/auth/better-auth.md +2 -2
- package/.docs/docs/server/auth/clerk.md +1 -1
- package/.docs/docs/server/auth/firebase.md +1 -1
- package/.docs/docs/server/auth/google.md +3 -3
- package/.docs/docs/server/auth/jwt.md +2 -2
- package/.docs/docs/server/auth/okta.md +2 -2
- package/.docs/docs/server/auth/workos.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/pubsub.md +1 -1
- package/.docs/docs/server/request-context.md +4 -4
- package/.docs/docs/server/server-adapters.md +8 -8
- package/.docs/docs/storage/overview.md +214 -0
- package/.docs/docs/studio/auth.md +1 -3
- package/.docs/docs/studio/overview.md +1 -1
- package/.docs/docs/voice/livekit.md +101 -4
- package/.docs/docs/workflows/agents-and-tools.md +3 -5
- package/.docs/docs/workflows/control-flow.md +1 -3
- package/.docs/docs/workflows/overview.md +6 -7
- package/.docs/docs/workflows/snapshots.md +1 -1
- package/.docs/docs/workspace/overview.md +2 -1
- package/.docs/docs/workspace/sandbox.md +2 -0
- package/.docs/guides/build-your-ui/assistant-ui.md +1 -1
- package/.docs/guides/build-your-ui/copilotkit/channels.md +1 -1
- package/.docs/guides/build-your-ui/copilotkit/generative-ui.md +2 -2
- package/.docs/guides/build-your-ui/copilotkit/overview.md +1 -1
- package/.docs/guides/concepts/streaming.md +3 -3
- package/.docs/guides/getting-started/quickstart.md +4 -2
- package/.docs/guides/guide/chef-michel.md +0 -2
- package/.docs/guides/guide/slack-assistant.md +2 -2
- package/.docs/guides/guide/stock-agent.md +0 -2
- package/.docs/models/embeddings.md +119 -0
- package/.docs/models/environment-variables.md +3 -0
- package/.docs/models/gateways/netlify.md +4 -1
- package/.docs/models/gateways/openrouter.md +12 -6
- package/.docs/models/gateways/vercel.md +7 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/crossmodel.md +109 -0
- package/.docs/models/providers/google.md +2 -1
- package/.docs/models/providers/llmgateway.md +184 -181
- package/.docs/models/providers/meta.md +101 -0
- package/.docs/models/providers/nano-gpt.md +2 -2
- package/.docs/models/providers/neon.md +40 -29
- package/.docs/models/providers/openai.md +5 -1
- package/.docs/models/providers/opencode.md +2 -1
- package/.docs/models/providers/poolside.md +6 -5
- package/.docs/models/providers/routing-run.md +20 -34
- package/.docs/models/providers/the-grid-ai.md +3 -3
- package/.docs/models/providers/wandb.md +21 -14
- package/.docs/models/providers/xai.md +2 -1
- package/.docs/models/providers/zenifra.md +73 -0
- package/.docs/models/providers.md +3 -0
- package/.docs/reference/agent-controller/agent-controller-class.md +3 -3
- package/.docs/reference/agent-controller/session.md +4 -4
- package/.docs/reference/agents/agent.md +1 -1
- package/.docs/reference/agents/channels.md +2 -2
- package/.docs/reference/agents/inngest-agent.md +1 -1
- package/.docs/reference/agents/listSkills.md +1 -1
- package/.docs/reference/agents/listSuspendedRuns.md +3 -3
- package/.docs/reference/auth/google.md +5 -5
- package/.docs/reference/channels/channel-provider.md +1 -1
- package/.docs/reference/channels/slack-provider.md +3 -3
- package/.docs/reference/cli/mastra.md +119 -12
- package/.docs/reference/code-sdk/mount-agent-controller.md +76 -0
- package/.docs/reference/coding-agent/create-coding-agent.md +1 -1
- package/.docs/reference/configuration.md +1 -1
- package/.docs/reference/evals/checks.md +4 -4
- package/.docs/reference/evals/create-scorer.md +8 -0
- package/.docs/reference/file-based-agents/config.md +97 -0
- package/.docs/reference/file-based-agents/instructions.md +54 -0
- package/.docs/reference/file-based-agents/memory.md +58 -0
- package/.docs/reference/file-based-agents/observability.md +32 -0
- package/.docs/reference/file-based-agents/processors.md +56 -0
- package/.docs/reference/file-based-agents/server.md +37 -0
- package/.docs/reference/file-based-agents/skills.md +56 -0
- package/.docs/reference/file-based-agents/storage.md +30 -0
- package/.docs/reference/file-based-agents/studio.md +56 -0
- package/.docs/reference/file-based-agents/subagents.md +123 -0
- package/.docs/reference/file-based-agents/tools.md +63 -0
- package/.docs/reference/file-based-agents/workflows.md +52 -0
- package/.docs/reference/file-based-agents/workspace.md +74 -0
- package/.docs/reference/index.md +16 -0
- package/.docs/reference/memory/memory-class.md +1 -1
- package/.docs/reference/memory/observational-memory.md +1 -1
- package/.docs/reference/memory/serialized-memory-config.md +1 -1
- package/.docs/reference/memory/summarizeConversation.md +99 -0
- package/.docs/reference/memory/summarizeThread.md +93 -0
- package/.docs/{docs/getting-started → reference}/project-structure.md +3 -10
- package/.docs/reference/pubsub/lease-provider.md +5 -5
- package/.docs/reference/server/express-adapter.md +1 -3
- package/.docs/reference/server/fastify-adapter.md +1 -3
- package/.docs/reference/server/hono-adapter.md +1 -3
- package/.docs/reference/server/koa-adapter.md +1 -3
- package/.docs/reference/server/nestjs-adapter.md +1 -3
- package/.docs/reference/signals/task-signal-provider.md +1 -1
- package/.docs/reference/storage/clickhouse.md +34 -2
- package/.docs/reference/storage/cloudflare-d1.md +1 -1
- package/.docs/reference/storage/composite.md +64 -6
- package/.docs/reference/storage/convex.md +1 -1
- package/.docs/reference/storage/dynamodb.md +1 -1
- package/.docs/reference/storage/mongodb.md +46 -46
- package/.docs/reference/storage/retention.md +74 -6
- package/.docs/reference/tools/create-tool.md +2 -2
- package/.docs/reference/tools/mcp-client.md +22 -0
- package/.docs/reference/tools/mcp-server.md +161 -4
- package/.docs/reference/vectors/mongodb.md +93 -4
- package/.docs/reference/voice/livekit.md +272 -8
- package/.docs/reference/workspace/agentcore-runtime-sandbox.md +1 -3
- package/.docs/reference/workspace/agentfs-filesystem.md +1 -3
- package/.docs/reference/workspace/apple-container-sandbox.md +6 -8
- package/.docs/reference/workspace/archil-filesystem.md +1 -3
- package/.docs/reference/workspace/azure-blob-filesystem.md +1 -3
- package/.docs/reference/workspace/blaxel-sandbox.md +1 -3
- package/.docs/reference/workspace/daytona-sandbox.md +1 -3
- package/.docs/reference/workspace/docker-sandbox.md +1 -3
- package/.docs/reference/workspace/e2b-sandbox.md +1 -3
- package/.docs/reference/workspace/files-sdk-filesystem.md +1 -3
- package/.docs/reference/workspace/gcs-filesystem.md +1 -3
- package/.docs/reference/workspace/google-drive-filesystem.md +1 -3
- package/.docs/reference/workspace/local-filesystem.md +1 -3
- package/.docs/reference/workspace/local-sandbox.md +1 -3
- package/.docs/reference/workspace/mesa-filesystem.md +4 -4
- package/.docs/reference/workspace/modal-sandbox.md +1 -3
- package/.docs/reference/workspace/railway-sandbox.md +2 -4
- package/.docs/reference/workspace/s3-filesystem.md +1 -3
- package/.docs/reference/workspace/vercel-sandbox.md +5 -7
- package/.docs/reference/workspace/vercel-serverless.md +2 -4
- package/CHANGELOG.md +36 -0
- package/package.json +5 -5
- package/.docs/docs/agents/channels.md +0 -225
- package/.docs/docs/agents/file-based-agents.md +0 -297
- package/.docs/docs/memory/storage.md +0 -267
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# WhatsApp
|
|
4
|
+
|
|
5
|
+
WhatsApp channels let a Mastra agent receive customer messages through WhatsApp Business Cloud. Mastra handles the agent wiring and webhook route; the Chat SDK WhatsApp adapter docs cover Meta app setup, credentials, and webhook configuration.
|
|
6
|
+
|
|
7
|
+
## Install the adapter
|
|
8
|
+
|
|
9
|
+
Install the WhatsApp adapter from the Chat SDK:
|
|
10
|
+
|
|
11
|
+
**npm**:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @chat-adapter/whatsapp
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**pnpm**:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm add @chat-adapter/whatsapp
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Yarn**:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
yarn add @chat-adapter/whatsapp
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Bun**:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
bun add @chat-adapter/whatsapp
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Agent configuration
|
|
36
|
+
|
|
37
|
+
Add `createWhatsAppAdapter()` to the agent's `channels.adapters` object:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { Agent } from '@mastra/core/agent'
|
|
41
|
+
import { createWhatsAppAdapter } from '@chat-adapter/whatsapp'
|
|
42
|
+
|
|
43
|
+
export const whatsappAgent = new Agent({
|
|
44
|
+
id: 'whatsapp-agent',
|
|
45
|
+
name: 'WhatsApp Agent',
|
|
46
|
+
instructions: 'Answer customer questions and help with tasks in WhatsApp.',
|
|
47
|
+
model: 'openai/gpt-5.5',
|
|
48
|
+
channels: {
|
|
49
|
+
adapters: {
|
|
50
|
+
whatsapp: createWhatsAppAdapter(),
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Register the agent on the Mastra instance:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { Mastra } from '@mastra/core'
|
|
60
|
+
import { whatsappAgent } from './agents/whatsapp-agent'
|
|
61
|
+
|
|
62
|
+
export const mastra = new Mastra({
|
|
63
|
+
agents: { whatsappAgent },
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Adapter setup
|
|
68
|
+
|
|
69
|
+
Follow the [Chat SDK WhatsApp adapter docs](https://chat-sdk.dev/adapters/official/whatsapp) for WhatsApp-specific setup, including Meta app configuration, access tokens, phone number IDs, webhook verification, and message limits.
|
|
70
|
+
|
|
71
|
+
The adapter reads WhatsApp credentials from environment variables such as:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
WHATSAPP_ACCESS_TOKEN=your-meta-access-token
|
|
75
|
+
WHATSAPP_APP_SECRET=your-meta-app-secret
|
|
76
|
+
WHATSAPP_PHONE_NUMBER_ID=your-whatsapp-phone-number-id
|
|
77
|
+
WHATSAPP_VERIFY_TOKEN=your-webhook-verify-token
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Webhook URL
|
|
81
|
+
|
|
82
|
+
Mastra generates the WhatsApp webhook route from the agent ID and adapter key:
|
|
83
|
+
|
|
84
|
+
```text
|
|
85
|
+
/api/agents/whatsapp-agent/channels/whatsapp/webhook
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Use your public Mastra server URL as the base URL:
|
|
89
|
+
|
|
90
|
+
```text
|
|
91
|
+
https://your-app.example.com/api/agents/whatsapp-agent/channels/whatsapp/webhook
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Use this URL for incoming WhatsApp event delivery. The generated Mastra route handles POST events from WhatsApp; follow the Chat SDK WhatsApp adapter docs for the Meta callback and webhook verification flow.
|
|
95
|
+
|
|
96
|
+
## Related
|
|
97
|
+
|
|
98
|
+
- [Channels overview](https://mastra.ai/docs/capabilities/channels/overview)
|
|
99
|
+
- [More](https://mastra.ai/docs/capabilities/channels/other-adapters)
|
|
@@ -14,9 +14,7 @@ Run the build command from your project root:
|
|
|
14
14
|
mastra build
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
This creates a `.mastra` directory containing your production-ready server.
|
|
18
|
-
|
|
19
|
-
> **Info:** Read the [`mastra build`](https://mastra.ai/reference/cli/mastra) reference for all available flags.
|
|
17
|
+
This creates a `.mastra` directory containing your production-ready server. Read the [`mastra build`](https://mastra.ai/reference/cli/mastra) reference for all available flags.
|
|
20
18
|
|
|
21
19
|
## Build output
|
|
22
20
|
|
|
@@ -59,7 +57,7 @@ The `mastra start` command provides additional features:
|
|
|
59
57
|
- Provides helpful error messages for missing modules
|
|
60
58
|
- Handles process signals for graceful shutdown
|
|
61
59
|
|
|
62
|
-
|
|
60
|
+
Read the [`mastra start`](https://mastra.ai/reference/cli/mastra) reference for all available flags.
|
|
63
61
|
|
|
64
62
|
## Build configuration
|
|
65
63
|
|
|
@@ -64,9 +64,7 @@ export const mastra = new Mastra({
|
|
|
64
64
|
})
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
Once registered, you can manage agents through [Studio](https://mastra.ai/docs/studio/overview) or programmatically through the server API and Client SDK.
|
|
68
|
-
|
|
69
|
-
> **Note:** See the [MastraEditor reference](https://mastra.ai/reference/editor/mastra-editor) for all configuration options.
|
|
67
|
+
Once registered, you can manage agents through [Studio](https://mastra.ai/docs/studio/overview) or programmatically through the server API and Client SDK. See the [MastraEditor reference](https://mastra.ai/reference/editor/mastra-editor) for all configuration options.
|
|
70
68
|
|
|
71
69
|
## Code and database sources
|
|
72
70
|
|
|
@@ -173,9 +171,7 @@ Because stored agents are data, you can build automation loops that tune agents
|
|
|
173
171
|
- Re-run the experiment against the draft and compare scores to the baseline.
|
|
174
172
|
- Promote the draft to the published version when the scores improve.
|
|
175
173
|
|
|
176
|
-
This turns agent tuning into a closed feedback loop. One agent owns the production configuration, another agent iterates on it, and every change is versioned so you can roll back if a round of automated edits makes things worse. Combine this with [version targeting](#version-targeting-and-experimentation) to keep production traffic on the published version while the draft is being tested.
|
|
177
|
-
|
|
178
|
-
> **Note:** See the [MastraEditor reference](https://mastra.ai/reference/editor/mastra-editor) for the full namespace API.
|
|
174
|
+
This turns agent tuning into a closed feedback loop. One agent owns the production configuration, another agent iterates on it, and every change is versioned so you can roll back if a round of automated edits makes things worse. Combine this with [version targeting](#version-targeting-and-experimentation) to keep production traffic on the published version while the draft is being tested. See the [MastraEditor reference](https://mastra.ai/reference/editor/mastra-editor) for the full namespace API.
|
|
179
175
|
|
|
180
176
|
## What can be overridden
|
|
181
177
|
|
|
@@ -122,7 +122,7 @@ await editor.agent.update({
|
|
|
122
122
|
})
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
See the [MastraEditor reference](https://mastra.ai/reference/editor/mastra-editor) for the full `editor.prompt` API.
|
|
126
126
|
|
|
127
127
|
## Versioning
|
|
128
128
|
|
|
@@ -142,9 +142,7 @@ When an agent runs, tools from all sources are merged in this order:
|
|
|
142
142
|
2. Integration tools
|
|
143
143
|
3. MCP tools
|
|
144
144
|
|
|
145
|
-
If a tool ID exists in multiple sources, later sources take precedence. Description overrides set at the agent level always take priority over the original tool description.
|
|
146
|
-
|
|
147
|
-
> **Note:** See the [ToolProvider reference](https://mastra.ai/reference/editor/tool-provider) for the full provider API.
|
|
145
|
+
If a tool ID exists in multiple sources, later sources take precedence. Description overrides set at the agent level always take priority over the original tool description. See the [ToolProvider reference](https://mastra.ai/reference/editor/tool-provider) for the full provider API.
|
|
148
146
|
|
|
149
147
|
## Related
|
|
150
148
|
|
|
@@ -54,12 +54,12 @@ These scorers evaluate adherence to format, style, and safety requirements:
|
|
|
54
54
|
Zero-LLM micro-scorers for fast, deterministic assertions. See the [Quick Checks](https://mastra.ai/docs/evals/quick-checks) guide for usage details.
|
|
55
55
|
|
|
56
56
|
- [`checks.includes`](https://mastra.ai/reference/evals/checks): Scores 1 if output contains a substring (`0` or `1`)
|
|
57
|
-
- [`checks.excludes`](https://mastra.ai/reference/evals/checks): Scores 1 if output
|
|
57
|
+
- [`checks.excludes`](https://mastra.ai/reference/evals/checks): Scores 1 if output doesn't contain a substring (`0` or `1`)
|
|
58
58
|
- [`checks.equals`](https://mastra.ai/reference/evals/checks): Scores 1 if output exactly matches a string (`0` or `1`)
|
|
59
59
|
- [`checks.matches`](https://mastra.ai/reference/evals/checks): Scores 1 if output matches a regex (`0` or `1`)
|
|
60
60
|
- [`checks.similarity`](https://mastra.ai/reference/evals/checks): String similarity via Dice coefficient (`0-1`, or binary with threshold)
|
|
61
61
|
- [`checks.calledTool`](https://mastra.ai/reference/evals/checks): Scores 1 if a tool was called at least N times (`0` or `1`)
|
|
62
|
-
- [`checks.didNotCall`](https://mastra.ai/reference/evals/checks): Scores 1 if a tool
|
|
62
|
+
- [`checks.didNotCall`](https://mastra.ai/reference/evals/checks): Scores 1 if a tool wasn't called (`0` or `1`)
|
|
63
63
|
- [`checks.toolOrder`](https://mastra.ai/reference/evals/checks): Scores 1 if tools were called in order (`0` or `1`)
|
|
64
64
|
- [`checks.maxToolCalls`](https://mastra.ai/reference/evals/checks): Scores 1 if tool call count is within limit (`0` or `1`)
|
|
65
65
|
- [`checks.usedNoTools`](https://mastra.ai/reference/evals/checks): Scores 1 if no tools were called (`0` or `1`)
|
|
@@ -341,9 +341,7 @@ A custom scorer in Mastra uses `createScorer` with four core components:
|
|
|
341
341
|
3. [**Score Generation**](#score-generation)
|
|
342
342
|
4. [**Reason Generation**](#reason-generation)
|
|
343
343
|
|
|
344
|
-
Together, these components allow you to define custom evaluation logic using LLMs as judges.
|
|
345
|
-
|
|
346
|
-
> **Info:** Visit [createScorer](https://mastra.ai/reference/evals/create-scorer) for the full API and configuration options.
|
|
344
|
+
Together, these components allow you to define custom evaluation logic using LLMs as judges. Visit [createScorer](https://mastra.ai/reference/evals/create-scorer) for the full API and configuration options.
|
|
347
345
|
|
|
348
346
|
```typescript
|
|
349
347
|
import { createScorer } from '@mastra/core/evals'
|
|
@@ -41,7 +41,7 @@ const existing = await datasets.get({ id: 'dataset-id' })
|
|
|
41
41
|
const { datasets: all } = await datasets.list()
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
Visit the [`DatasetsManager` reference](https://mastra.ai/reference/datasets/datasets-manager) for the full list of methods.
|
|
45
45
|
|
|
46
46
|
## Studio
|
|
47
47
|
|
|
@@ -196,13 +196,12 @@ Fetch the exact items that existed at a past version:
|
|
|
196
196
|
const items = await dataset.listItems({ version: 2 })
|
|
197
197
|
```
|
|
198
198
|
|
|
199
|
-
You can also pin experiments to a version, see [running experiments](https://mastra.ai/docs/evals/datasets/running-experiments).
|
|
200
|
-
|
|
201
|
-
> **Info:** Visit the [`Dataset` reference](https://mastra.ai/reference/datasets/dataset) for the full list of methods and parameters.
|
|
199
|
+
You can also pin experiments to a version, see [running experiments](https://mastra.ai/docs/evals/datasets/running-experiments). Visit the [`Dataset` reference](https://mastra.ai/reference/datasets/dataset) for the full list of methods and parameters.
|
|
202
200
|
|
|
203
201
|
## Related
|
|
204
202
|
|
|
205
203
|
- [Running experiments](https://mastra.ai/docs/evals/datasets/running-experiments)
|
|
206
204
|
- [Scorers overview](https://mastra.ai/docs/evals/overview)
|
|
207
205
|
- [DatasetsManager reference](https://mastra.ai/reference/datasets/datasets-manager)
|
|
208
|
-
- [Dataset reference](https://mastra.ai/reference/datasets/dataset)
|
|
206
|
+
- [Dataset reference](https://mastra.ai/reference/datasets/dataset)
|
|
207
|
+
- 📹 [Mastra evals, datasets, and experiments workshop](https://www.youtube.com/watch?v=Vla5LfmOOrM)
|
|
@@ -127,7 +127,7 @@ for (const item of summary.results) {
|
|
|
127
127
|
}
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
Visit the [Scorers overview](https://mastra.ai/docs/evals/overview) for details on available and custom scorers.
|
|
131
131
|
|
|
132
132
|
## Tool mocks
|
|
133
133
|
|
|
@@ -154,11 +154,11 @@ Tool mocks are supported for `agent` targets only.
|
|
|
154
154
|
|
|
155
155
|
Arguments are matched strictly: object key order is ignored, array order is significant, and there is no type coercion. A mock is served only when the agent calls the tool with arguments that deep-equal the mock's `args`.
|
|
156
156
|
|
|
157
|
-
When an item declares several mocks for the same tool and arguments, they
|
|
157
|
+
When an item declares several mocks for the same tool and arguments, they're consumed in order — the first call gets the first mock, the next call gets the second, and so on. Ordering is tracked per `(toolName, args)` group and is independent across different arguments.
|
|
158
158
|
|
|
159
159
|
### Matching mode
|
|
160
160
|
|
|
161
|
-
By default each mock matches strictly on its `args`. Set `matchArgs: 'ignore'` to match on the tool name only — the mock's `args`
|
|
161
|
+
By default each mock matches strictly on its `args`. Set `matchArgs: 'ignore'` to match on the tool name only — the mock's `args` aren't compared and the next unconsumed mock for that tool is served regardless of how the agent called it:
|
|
162
162
|
|
|
163
163
|
```typescript
|
|
164
164
|
const subAgentMock = {
|
|
@@ -173,12 +173,12 @@ This is useful when a tool's arguments are noisy or generated by the model. The
|
|
|
173
173
|
|
|
174
174
|
### Failures
|
|
175
175
|
|
|
176
|
-
A mocked tool call fails the item when the arguments
|
|
176
|
+
A mocked tool call fails the item when the arguments don't match or all matching mocks have been consumed:
|
|
177
177
|
|
|
178
178
|
- `TOOL_MOCK_MISMATCH` — the tool was called with arguments that no mock matches.
|
|
179
179
|
- `TOOL_MOCK_EXHAUSTED` — every matching mock has already been consumed.
|
|
180
180
|
|
|
181
|
-
When a mocked tool is mis-called, the agent run is aborted immediately, so the model
|
|
181
|
+
When a mocked tool is mis-called, the agent run is aborted immediately, so the model can't go on to call any further tools — including unmocked, side-effecting tools that would otherwise run live. These failures are deterministic, so they're not retried. Mocks that are declared but never used don't fail the item — they're reported as unconsumed.
|
|
182
182
|
|
|
183
183
|
While an item has mocks, the agent's tools execute sequentially so repeated `(toolName, args)` mocks are consumed in the provider's call order. This serialization applies only to items that declare mocks.
|
|
184
184
|
|
|
@@ -202,8 +202,8 @@ In [Studio](https://mastra.ai/docs/studio/overview), edit a dataset item to auth
|
|
|
202
202
|
|
|
203
203
|
### Limitations
|
|
204
204
|
|
|
205
|
-
- **No tool span for mocked calls.** A mocked call returns its output before the tool executes, so it
|
|
206
|
-
- **Storage support.** Tool mocks and tool mock reports are persisted by the LibSQL, PostgreSQL, MongoDB, and Spanner adapters. The MySQL adapter
|
|
205
|
+
- **No tool span for mocked calls.** A mocked call returns its output before the tool executes, so it doesn't create a tool span. Trajectory scorers backed by stored traces may therefore not see mocked tool calls. Trajectory extraction that falls back to the agent's message output still sees them, so trajectory scoring can differ depending on your observability configuration.
|
|
206
|
+
- **Storage support.** Tool mocks and tool mock reports are persisted by the LibSQL, PostgreSQL, MongoDB, and Spanner adapters. The MySQL adapter doesn't support them and rejects writes that carry tool mocks or a tool mock report so the feature never silently runs tools live.
|
|
207
207
|
|
|
208
208
|
## Async experiments
|
|
209
209
|
|
|
@@ -321,6 +321,8 @@ console.log(experiment.startedAt)
|
|
|
321
321
|
console.log(experiment.completedAt)
|
|
322
322
|
```
|
|
323
323
|
|
|
324
|
+
> **📹 Watch:** Watch [Mastra datasets and experiments workflow](https://www.youtube.com/watch?v=R6pjAdGhxhQ) to see how datasets and experiments help improve reliability.
|
|
325
|
+
|
|
324
326
|
### Item-level results
|
|
325
327
|
|
|
326
328
|
```typescript
|
|
@@ -342,7 +344,7 @@ for (const result of results) {
|
|
|
342
344
|
- `completedWithErrors` is `true` when the experiment finished but some items failed.
|
|
343
345
|
- Items cancelled via `signal` appear in `skippedCount`.
|
|
344
346
|
|
|
345
|
-
|
|
347
|
+
Visit the [`startExperiment` reference](https://mastra.ai/reference/datasets/startExperiment) for the full parameter and return type documentation.
|
|
346
348
|
|
|
347
349
|
## Related
|
|
348
350
|
|
|
@@ -136,9 +136,7 @@ const summary = await dataset.startExperiment({
|
|
|
136
136
|
})
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
-
The inline `task` receives the item's `metadata`, so each row can drive its own thread without changing the agent or any scorer.
|
|
140
|
-
|
|
141
|
-
> **Note:** Visit [runEvals reference](https://mastra.ai/reference/evals/run-evals) and [Dataset reference](https://mastra.ai/reference/datasets/dataset) for full configuration.
|
|
139
|
+
The inline `task` receives the item's `metadata`, so each row can drive its own thread without changing the agent or any scorer. Visit [runEvals reference](https://mastra.ai/reference/evals/run-evals) and [Dataset reference](https://mastra.ai/reference/datasets/dataset) for full configuration.
|
|
142
140
|
|
|
143
141
|
## Related
|
|
144
142
|
|
|
@@ -64,9 +64,7 @@ const result = await runEvals({
|
|
|
64
64
|
// result.gateResults: [{ id: 'check-called-tool', passed: true, score: 1 }]
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
Any scorer works as a gate. Quick Checks are a natural fit because they return binary 1/0 scores.
|
|
68
|
-
|
|
69
|
-
> **Note:** Visit [runEvals() reference](https://mastra.ai/reference/evals/run-evals) for the full parameter and return type documentation.
|
|
67
|
+
Any scorer works as a gate. Quick Checks are a natural fit because they return binary 1/0 scores. Visit [runEvals() reference](https://mastra.ai/reference/evals/run-evals) for the full parameter and return type documentation.
|
|
70
68
|
|
|
71
69
|
## Thresholds
|
|
72
70
|
|
|
@@ -101,7 +99,7 @@ const result = await runEvals({
|
|
|
101
99
|
// ]
|
|
102
100
|
```
|
|
103
101
|
|
|
104
|
-
A bare scorer (no threshold) still
|
|
102
|
+
A bare scorer (no threshold) still shows up in `result.scores` but doesn't affect the verdict.
|
|
105
103
|
|
|
106
104
|
## Using verdicts in CI
|
|
107
105
|
|
|
@@ -8,6 +8,8 @@ Scorers are automated tests that evaluate Agents outputs using model-graded, rul
|
|
|
8
8
|
|
|
9
9
|
Scorers can be run in the cloud, capturing real-time results. But scorers can also be part of your CI/CD pipeline, allowing you to test and monitor your agents over time.
|
|
10
10
|
|
|
11
|
+
> **📹 Watch:** Watch [Mastra evals overview](https://www.youtube.com/watch?v=12WN6u2DrBk) for an introduction to evals and how to reason about agent quality.
|
|
12
|
+
|
|
11
13
|
## Types of scorers
|
|
12
14
|
|
|
13
15
|
Mastra provides different kinds of scorers, each serving a specific purpose. Here are some common types:
|
|
@@ -142,4 +144,5 @@ Once registered, you can score traces interactively within Studio under the **Ob
|
|
|
142
144
|
- Add [gates and verdicts](https://mastra.ai/docs/evals/gates-and-verdicts) to enforce hard requirements and quality thresholds
|
|
143
145
|
- Learn how to create your own scorers in the [Creating Custom Scorers](https://mastra.ai/docs/evals/custom-scorers) guide
|
|
144
146
|
- Explore built-in scorers in the [Built-in Scorers](https://mastra.ai/docs/evals/built-in-scorers) section
|
|
145
|
-
- Test scorers with [Studio](https://mastra.ai/docs/studio/overview)
|
|
147
|
+
- Test scorers with [Studio](https://mastra.ai/docs/studio/overview)
|
|
148
|
+
- 📹 [Mastra evals workshop](https://www.youtube.com/watch?v=OHOZ5PgPj5M\&t=3578s)
|
|
@@ -44,7 +44,7 @@ These scorers evaluate the agent's text output:
|
|
|
44
44
|
| Check | What it does | Score |
|
|
45
45
|
| ------------------------ | ------------------------------------- | -------------------------------- |
|
|
46
46
|
| `checks.includes(str)` | Output contains substring | 1 or 0 |
|
|
47
|
-
| `checks.excludes(str)` | Output
|
|
47
|
+
| `checks.excludes(str)` | Output doesn't contain substring | 1 or 0 |
|
|
48
48
|
| `checks.equals(str)` | Output exactly equals string | 1 or 0 |
|
|
49
49
|
| `checks.matches(regex)` | Output matches regular expression | 1 or 0 |
|
|
50
50
|
| `checks.similarity(str)` | Dice coefficient similarity to string | 0-1 (or binary with `threshold`) |
|
|
@@ -56,7 +56,7 @@ These scorers evaluate tool usage from the agent's run:
|
|
|
56
56
|
| Check | What it does | Score |
|
|
57
57
|
| ------------------------- | -------------------------------- | ------ |
|
|
58
58
|
| `checks.calledTool(name)` | Tool was called at least N times | 1 or 0 |
|
|
59
|
-
| `checks.didNotCall(name)` | Tool
|
|
59
|
+
| `checks.didNotCall(name)` | Tool wasn't called | 1 or 0 |
|
|
60
60
|
| `checks.toolOrder([...])` | Tools called in expected order | 1 or 0 |
|
|
61
61
|
| `checks.maxToolCalls(n)` | No more than N tool calls total | 1 or 0 |
|
|
62
62
|
| `checks.usedNoTools()` | No tools called at all | 1 or 0 |
|
|
@@ -127,9 +127,7 @@ Each check is a standard `createScorer()` instance with a `preprocess` step and
|
|
|
127
127
|
1. **preprocess**: Extracts and normalizes relevant data from the agent run (text content, tool calls)
|
|
128
128
|
2. **generateScore**: Converts the preprocessed result into a score (typically binary 1 or 0)
|
|
129
129
|
|
|
130
|
-
Because checks skip the `analyze` and `generateReason` steps and make no LLM calls, they run in microseconds.
|
|
131
|
-
|
|
132
|
-
> **Note:** Visit the [Quick Checks reference](https://mastra.ai/reference/evals/checks) for the full API, including all parameters and options for each check.
|
|
130
|
+
Because checks skip the `analyze` and `generateReason` steps and make no LLM calls, they run in microseconds. Visit the [Quick Checks reference](https://mastra.ai/reference/evals/checks) for the full API, including all parameters and options for each check.
|
|
133
131
|
|
|
134
132
|
## Related
|
|
135
133
|
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# File-based agents
|
|
4
|
+
|
|
5
|
+
**Added in:** `@mastra/core@1.50.0`
|
|
6
|
+
|
|
7
|
+
> **Beta:** This feature is in beta. Breaking changes may occur without a major version bump until the API is stable.
|
|
8
|
+
|
|
9
|
+
File-based agents are a new, convention-based way to define Mastra agents and project primitives from a directory structure under `src/mastra/`. You'll like this approach if you want an agent to be self-contained, easy to scan and extend.
|
|
10
|
+
|
|
11
|
+
Adopting this feature is a fundamental decision about how to structure your project. You'll need to follow the file conventions and be aware of its limitations, namely that you can't use dynamic configuration or runtime wiring.
|
|
12
|
+
|
|
13
|
+
However, you can use file-based agents, code-defined agents, or both in the same project. All Mastra docs currently use code-first examples. As file-based agents mature, more examples may use this structure where it makes sense.
|
|
14
|
+
|
|
15
|
+
Under the hood Mastra is assembling code-defined agents and primitives from the files you create. So explanations and concepts you can find on other docs pages apply to file-based agents as well.
|
|
16
|
+
|
|
17
|
+
## Basic layout
|
|
18
|
+
|
|
19
|
+
A small file-based agent looks like this:
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
src/mastra/
|
|
23
|
+
agents/
|
|
24
|
+
weather/
|
|
25
|
+
config.ts
|
|
26
|
+
instructions.md
|
|
27
|
+
tools/
|
|
28
|
+
get-weather.ts
|
|
29
|
+
skills/
|
|
30
|
+
forecast-review.md
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The main files in an agent directory are:
|
|
34
|
+
|
|
35
|
+
- [`config.ts`](https://mastra.ai/reference/file-based-agents/config): Model selection and runtime options
|
|
36
|
+
- [`instructions.md`](https://mastra.ai/reference/file-based-agents/instructions): The prompt that applies to every response
|
|
37
|
+
- [`tools/`](https://mastra.ai/reference/file-based-agents/tools): Typed functions the model can call
|
|
38
|
+
- [`skills/`](https://mastra.ai/reference/file-based-agents/skills): Reusable instructions
|
|
39
|
+
|
|
40
|
+
You need to define `config.ts` and `instructions.md` at a minimum. Add optional files as needed. Learn more in the [add capabilities](#add-capabilities) section.
|
|
41
|
+
|
|
42
|
+
## Quickstart
|
|
43
|
+
|
|
44
|
+
Create a folder at `src/mastra/agents/weather`. Inside, add a `config.ts` and an `instructions.md` file with these contents:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { agentConfig } from '@mastra/core/agent'
|
|
48
|
+
|
|
49
|
+
export default agentConfig({
|
|
50
|
+
model: 'openai/gpt-5.5',
|
|
51
|
+
})
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```markdown
|
|
55
|
+
You are a helpful weather assistant. Answer questions about current conditions and forecasts.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Start Mastra's development server with `mastra dev`. Inside Studio, you can now call the `weather` agent and ask it about the weather.
|
|
59
|
+
|
|
60
|
+
## Add capabilities
|
|
61
|
+
|
|
62
|
+
Map each primitive or feature to its file convention:
|
|
63
|
+
|
|
64
|
+
| Primitive or feature | File convention |
|
|
65
|
+
| -------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
|
|
66
|
+
| [Agent config](https://mastra.ai/reference/file-based-agents/config) | `src/mastra/agents/<agent-id>/config.ts` |
|
|
67
|
+
| [Agent instructions](https://mastra.ai/reference/file-based-agents/instructions) | `src/mastra/agents/<agent-id>/instructions.md` |
|
|
68
|
+
| [Tools](https://mastra.ai/reference/file-based-agents/tools) | `src/mastra/agents/<agent-id>/tools/` |
|
|
69
|
+
| [Skills](https://mastra.ai/reference/file-based-agents/skills) | `src/mastra/agents/<agent-id>/skills/` |
|
|
70
|
+
| [Memory](https://mastra.ai/reference/file-based-agents/memory) | `src/mastra/agents/<agent-id>/memory.ts` |
|
|
71
|
+
| [Workspace](https://mastra.ai/reference/file-based-agents/workspace) | `src/mastra/agents/<agent-id>/workspace.ts` and `src/mastra/agents/<agent-id>/workspace/` |
|
|
72
|
+
| [Processors](https://mastra.ai/reference/file-based-agents/processors) | `src/mastra/agents/<agent-id>/processors/` |
|
|
73
|
+
| [Subagents](https://mastra.ai/reference/file-based-agents/subagents) | `src/mastra/agents/<agent-id>/subagents/` |
|
|
74
|
+
| [Workflows](https://mastra.ai/reference/file-based-agents/workflows) | `src/mastra/workflows/` |
|
|
75
|
+
| [Storage](https://mastra.ai/reference/file-based-agents/storage) | `src/mastra/storage.ts` |
|
|
76
|
+
| [Observability](https://mastra.ai/reference/file-based-agents/observability) | `src/mastra/observability.ts` |
|
|
77
|
+
| [Server config](https://mastra.ai/reference/file-based-agents/server) | `src/mastra/server.ts` |
|
|
78
|
+
| [Studio config](https://mastra.ai/reference/file-based-agents/studio) | `src/mastra/studio.ts` |
|
|
79
|
+
|
|
80
|
+
## Discovery lifecycle
|
|
81
|
+
|
|
82
|
+
File-based primitives are discovered by the Mastra bundler under `mastra dev` and `mastra build`. During discovery, Mastra reads supported files under `src/mastra/`, imports TypeScript and JavaScript modules, reads markdown instructions and skills, copies workspace seed files, and registers the assembled primitives with your Mastra app.
|
|
83
|
+
|
|
84
|
+
After discovery, a file-based agent runs as a normal [`Agent`](https://mastra.ai/reference/agents/agent). Calling it from the Agent API, Studio, workflows, or your application code uses the same runtime as a code-defined agent.
|
|
85
|
+
|
|
86
|
+
Discovery is source-based and conservative. It skips symlinks, ignores test files, treats workflows and singleton project files as file-routed only when they have a default export, and ignores directories that aren't agent directories.
|
|
87
|
+
|
|
88
|
+
Start your app through the Mastra CLI so discovery runs:
|
|
89
|
+
|
|
90
|
+
**npm**:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
npx mastra dev
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**pnpm**:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
pnpm dlx mastra dev
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Yarn**:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
yarn dlx mastra dev
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Bun**:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
bun x mastra dev
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
If you import your `mastra` instance directly, `agents/<name>/` directories and the other conventions aren't discovered. When you consume Mastra as a library, register those primitives in code instead.
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
# Manual install
|
|
4
4
|
|
|
5
|
-
**For AI agents:** Use this guide when tasked to create a runnable Mastra project from scratch without a CLI/boilerplate. It provides code examples for agents, tools, model configuration and how to install dependencies. Do not navigate to the quickstart guide, which is for humans.
|
|
5
|
+
**For AI agents:** Use this guide when tasked to create a runnable Mastra project from scratch without a CLI/boilerplate. It provides code examples for agents, tools, model configuration and how to install dependencies. Do not navigate to the quickstart guide, which is for humans. The model string is Mastra's model router format ('provider/model'; use / and not : to separate provider and model). Do not install any ai-sdk packages.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Use this guide to manually build a standalone Mastra server step by step. In most cases, it's quicker to follow the [quickstart guide](https://mastra.ai/guides/getting-started/quickstart), which achieves the same result using the [`mastra create`](https://mastra.ai/reference/cli/create-mastra) command. For existing projects, you can also use [`mastra init`](https://mastra.ai/reference/cli/mastra).
|
|
8
|
+
|
|
9
|
+
## Instructions
|
|
8
10
|
|
|
9
11
|
If you prefer not to use our automatic CLI tool, you can set up your project yourself by following the guide below.
|
|
10
12
|
|
|
@@ -163,7 +165,7 @@ If you prefer not to use our automatic CLI tool, you can set up your project you
|
|
|
163
165
|
mkdir -p src/mastra/agents && touch src/mastra/agents/weather-agent.ts
|
|
164
166
|
```
|
|
165
167
|
|
|
166
|
-
Use `import { Agent } from "@mastra/core/agent"`. Constructor takes `{ id, name, instructions, model: 'openai/gpt-5.5' }`. The model string is Mastra's model router format ('provider/model'; use / and not : to separate provider and model). Do not install any ai-sdk
|
|
168
|
+
Use `import { Agent } from "@mastra/core/agent"`. Constructor takes `{ id, name, instructions, model: 'openai/gpt-5.5' }`. The model string is Mastra's model router format ('provider/model'; use / and not : to separate provider and model). Do not install any ai-sdk packages.
|
|
167
169
|
|
|
168
170
|
Add the following code:
|
|
169
171
|
|
|
@@ -234,4 +236,15 @@ If you prefer not to use our automatic CLI tool, you can set up your project you
|
|
|
234
236
|
|
|
235
237
|
```bash
|
|
236
238
|
bun run dev
|
|
237
|
-
```
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**For AI agents:** To validate your work, run a build and do a typecheck with `tsc --noEmit`.
|
|
242
|
+
|
|
243
|
+
## Next steps
|
|
244
|
+
|
|
245
|
+
- [Review the project structure](https://mastra.ai/reference/project-structure): Understand how `src/mastra/` files map to agents, tools, workflows, storage, and configuration.
|
|
246
|
+
- [Test your agent in Studio](https://mastra.ai/docs/studio/overview): Open the local Studio UI and run the weather agent.
|
|
247
|
+
- [Use tools with agents](https://mastra.ai/docs/agents/using-tools): Replace the example weather tool with a real tool that calls an API or service.
|
|
248
|
+
- [Add memory](https://mastra.ai/docs/memory/overview): Persist conversation history and user-specific context.
|
|
249
|
+
- [Configure storage](https://mastra.ai/docs/storage/overview): Add a persistent storage adapter for memory, workflows, observability, and other runtime state.
|
|
250
|
+
- [Build and deploy](https://mastra.ai/docs/deployment/overview): Build the Mastra server and deploy it to a hosting platform.
|
package/.docs/docs/index.md
CHANGED
|
@@ -54,7 +54,7 @@ export const weatherTool = createTool({
|
|
|
54
54
|
})
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
If you need to create an agent, create a new file and use `import { Agent } from "@mastra/core/agent"`. The constructor takes `{ id, name, instructions, model }`. The `model` property is a string in Mastra's model router format: `provider/model`, for example `openai/gpt-5.5`. For OpenAI models, use `openai/<model>`, not `openai:<model>`, and don't pass a provider object. No provider import is needed for this format.
|
|
57
|
+
If you need to create an agent, create a new file and use `import { Agent } from "@mastra/core/agent"`. The constructor takes `{ id, name, instructions, model }`. The `model` property is a string in Mastra's model router format: `provider/model`, for example `openai/gpt-5.5`. For OpenAI models, use `openai/<model>`, not `openai:<model>`, and don't pass a provider object. No provider import is needed for this format. Don't install any AI SDK package unless Mastra's documentation says otherwise.
|
|
58
58
|
|
|
59
59
|
Add a tool an agent by importing the tool and passing it to the agent constructor as a tools object.
|
|
60
60
|
|
|
@@ -16,7 +16,7 @@ Use background tasks when a tool call may take long enough that the user shouldn
|
|
|
16
16
|
|
|
17
17
|
For tool calls that return quickly, foreground execution using `agent.stream()` and `agent.generate()` is simpler.
|
|
18
18
|
|
|
19
|
-
> **Note:** Background tasks require a configured [storage](https://mastra.ai/docs/
|
|
19
|
+
> **Note:** Background tasks require a configured [storage](https://mastra.ai/docs/storage/overview) backend on the Mastra instance. Tasks are persisted so they survive process restarts.
|
|
20
20
|
|
|
21
21
|
## Quickstart
|
|
22
22
|
|
|
@@ -168,7 +168,7 @@ const stream = await agent.stream('Research solana for me', {
|
|
|
168
168
|
})
|
|
169
169
|
```
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
Visit [`Agent.stream()`](https://mastra.ai/reference/streaming/agents/stream) for the full API.
|
|
172
172
|
|
|
173
173
|
### Aggregate properties
|
|
174
174
|
|
|
@@ -379,4 +379,4 @@ These read from storage rather than the pubsub stream, so they're suitable for p
|
|
|
379
379
|
- [Durable agents](https://mastra.ai/docs/long-running-agents/durable-agents)
|
|
380
380
|
- [Supervisor agents](https://mastra.ai/docs/agents/supervisor-agents)
|
|
381
381
|
- [Stream chunk types](https://mastra.ai/reference/streaming/ChunkType)
|
|
382
|
-
- [Storage](https://mastra.ai/docs/
|
|
382
|
+
- [Storage](https://mastra.ai/docs/storage/overview)
|
|
@@ -60,9 +60,7 @@ for await (const chunk of output.fullStream) {
|
|
|
60
60
|
cleanup()
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
The returned `runId` identifies the execution. Pass it to `observe()` to reconnect from a different client.
|
|
64
|
-
|
|
65
|
-
> **Note:** Visit the [DurableAgent reference](https://mastra.ai/reference/agents/durable-agent) for the full configuration and method API.
|
|
63
|
+
The returned `runId` identifies the execution. Pass it to `observe()` to reconnect from a different client. Visit the [DurableAgent reference](https://mastra.ai/reference/agents/durable-agent) for the full configuration and method API.
|
|
66
64
|
|
|
67
65
|
## How it works
|
|
68
66
|
|
|
@@ -105,7 +103,7 @@ export const durableHelper = createDurableAgent({ agent })
|
|
|
105
103
|
|
|
106
104
|
### Fire-and-forget with `createEventedAgent()`
|
|
107
105
|
|
|
108
|
-
The workflow starts in the background without blocking the caller. You still receive chunks through PubSub, so `stream()` returns a result you can consume. The HTTP handler that triggered the run
|
|
106
|
+
The workflow starts in the background without blocking the caller. You still receive chunks through PubSub, so `stream()` returns a result you can consume. The HTTP handler that triggered the run doesn't need to wait for the workflow to finish:
|
|
109
107
|
|
|
110
108
|
```typescript
|
|
111
109
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -140,7 +138,7 @@ const agent = new Agent({
|
|
|
140
138
|
export const inngestAnalyst = createInngestAgent({ agent, inngest })
|
|
141
139
|
```
|
|
142
140
|
|
|
143
|
-
|
|
141
|
+
Visit the [`createInngestAgent()` reference](https://mastra.ai/reference/agents/inngest-agent) for the full API, including Inngest-specific options like PubSub and cache configuration.
|
|
144
142
|
|
|
145
143
|
## Resumable streams
|
|
146
144
|
|
|
@@ -170,7 +168,7 @@ export const durableAgent = createDurableAgent({
|
|
|
170
168
|
})
|
|
171
169
|
```
|
|
172
170
|
|
|
173
|
-
`createInngestAgent()`
|
|
171
|
+
`createInngestAgent()` doesn't enable caching by default. Pass a `cache` option or register the agent with a `Mastra` instance that has a `serverCache` configured to enable resumable streams.
|
|
174
172
|
|
|
175
173
|
## Streaming with background tasks
|
|
176
174
|
|
|
@@ -199,7 +197,7 @@ await durableAgent.stream('Research topic', {
|
|
|
199
197
|
})
|
|
200
198
|
```
|
|
201
199
|
|
|
202
|
-
|
|
200
|
+
Visit [Background tasks](https://mastra.ai/docs/long-running-agents/background-tasks) for the full background task guide, including configuration, subagents, and suspend/resume.
|
|
203
201
|
|
|
204
202
|
## Cleanup
|
|
205
203
|
|