@mastra/mcp-docs-server 1.2.7-alpha.4 → 1.2.7-alpha.8
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/overview.md +4 -3
- package/.docs/docs/agent-controller/overview.md +2 -1
- package/.docs/docs/agents/a2a.md +2 -1
- package/.docs/docs/agents/guardrails.md +2 -1
- package/.docs/docs/agents/overview.md +2 -2
- package/.docs/docs/agents/skills.md +1 -1
- package/.docs/docs/agents/supervisor-agents.md +2 -1
- package/.docs/docs/browser/overview.md +2 -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 +257 -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/evals/datasets/overview.md +2 -1
- package/.docs/docs/evals/datasets/running-experiments.md +2 -0
- package/.docs/docs/evals/overview.md +4 -1
- package/.docs/docs/getting-started/file-based-agents.md +114 -0
- package/.docs/docs/long-running-agents/signals.md +4 -1
- package/.docs/docs/mastra-platform/observability.md +5 -1
- package/.docs/docs/memory/observational-memory.md +2 -1
- package/.docs/docs/memory/overview.md +2 -0
- package/.docs/docs/memory/semantic-recall.md +1 -1
- package/.docs/docs/memory/working-memory.md +3 -3
- package/.docs/docs/studio/overview.md +1 -1
- package/.docs/docs/workflows/control-flow.md +0 -2
- package/.docs/docs/workflows/overview.md +2 -3
- package/.docs/docs/workspace/overview.md +2 -1
- package/.docs/docs/workspace/sandbox.md +2 -0
- package/.docs/guides/getting-started/quickstart.md +3 -1
- 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/environment-variables.md +2 -0
- package/.docs/models/gateways/netlify.md +4 -1
- package/.docs/models/gateways/openrouter.md +7 -6
- package/.docs/models/gateways/vercel.md +5 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/crossmodel.md +109 -0
- package/.docs/models/providers/llmgateway.md +185 -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/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.md +2 -0
- package/.docs/reference/agents/channels.md +2 -2
- package/.docs/reference/channels/channel-provider.md +1 -1
- package/.docs/reference/channels/slack-provider.md +2 -2
- package/.docs/reference/cli/mastra.md +1 -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 +13 -0
- package/.docs/reference/memory/memory-class.md +1 -1
- package/.docs/reference/memory/serialized-memory-config.md +1 -1
- package/.docs/reference/project-structure.md +1 -1
- package/.docs/reference/pubsub/lease-provider.md +1 -1
- package/.docs/reference/storage/clickhouse.md +32 -0
- package/.docs/reference/storage/composite.md +27 -1
- package/.docs/reference/storage/retention.md +11 -0
- package/CHANGELOG.md +14 -0
- package/package.json +4 -4
- package/.docs/docs/agents/channels.md +0 -225
- package/.docs/docs/agents/file-based-agents.md +0 -297
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Slack
|
|
4
|
+
|
|
5
|
+
Add your agent to Slack so people can message it in shared channel threads or direct messages. When someone sends a message, Mastra runs your agent through the normal agent pipeline and streams the response back to Slack. The Slack adapter handles Slack AI indicators and interactive cards for you.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Install the Slack adapter from the Chat SDK:
|
|
10
|
+
|
|
11
|
+
**npm**:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @chat-adapter/slack
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**pnpm**:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm add @chat-adapter/slack
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Yarn**:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
yarn add @chat-adapter/slack
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Bun**:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
bun add @chat-adapter/slack
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Add `createSlackAdapter()` to the agent's `channels.adapters` object:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { Agent } from '@mastra/core/agent'
|
|
39
|
+
import { createSlackAdapter } from '@chat-adapter/slack'
|
|
40
|
+
|
|
41
|
+
export const yourAgent = new Agent({
|
|
42
|
+
id: 'your-agent',
|
|
43
|
+
name: 'Your Agent',
|
|
44
|
+
instructions: 'Help people plan tasks, answer questions, and coordinate work in Slack.',
|
|
45
|
+
model: 'anthropic/claude-opus-4-7',
|
|
46
|
+
channels: {
|
|
47
|
+
adapters: {
|
|
48
|
+
slack: createSlackAdapter(),
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
})
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Create a Slack app
|
|
55
|
+
|
|
56
|
+
To connect your agent, create a Slack app in the workspace where you want it to run. The Slack app controls how your agent appears in Slack, what it can do, and which events it receives.
|
|
57
|
+
|
|
58
|
+
This guide uses a [manifest](https://docs.slack.dev/app-manifests/configuring-apps-with-app-manifests/#creating_manifests): a configuration file that creates the Slack app settings for you. This is the fastest path when you are adding your agent to your own workspace. It doesn't cover the platform OAuth flow where other workspaces install your agent.
|
|
59
|
+
|
|
60
|
+
Create the Slack app from a manifest:
|
|
61
|
+
|
|
62
|
+
1. Open [api.slack.com/apps](https://api.slack.com/apps).
|
|
63
|
+
2. Select **Create an app**.
|
|
64
|
+
3. Select **From a manifest**.
|
|
65
|
+
4. Choose the workspace where the agent should run.
|
|
66
|
+
5. Paste this manifest, then select **Create**:
|
|
67
|
+
|
|
68
|
+
```yaml
|
|
69
|
+
display_information:
|
|
70
|
+
name: mastra-agent
|
|
71
|
+
features:
|
|
72
|
+
app_home:
|
|
73
|
+
home_tab_enabled: false
|
|
74
|
+
messages_tab_enabled: true
|
|
75
|
+
messages_tab_read_only_enabled: false
|
|
76
|
+
bot_user:
|
|
77
|
+
display_name: mastra-agent
|
|
78
|
+
always_online: true
|
|
79
|
+
oauth_config:
|
|
80
|
+
scopes:
|
|
81
|
+
bot:
|
|
82
|
+
- im:write
|
|
83
|
+
- app_mentions:read
|
|
84
|
+
- channels:history
|
|
85
|
+
- channels:read
|
|
86
|
+
- chat:write
|
|
87
|
+
- users:read
|
|
88
|
+
- im:read
|
|
89
|
+
- im:history
|
|
90
|
+
pkce_enabled: false
|
|
91
|
+
settings:
|
|
92
|
+
event_subscriptions:
|
|
93
|
+
request_url: https://<YOUR-PUBLIC-URL>/api/agents/<YOUR-AGENT-ID>/channels/slack/webhook
|
|
94
|
+
bot_events:
|
|
95
|
+
- app_mention
|
|
96
|
+
- message.channels
|
|
97
|
+
- message.im
|
|
98
|
+
interactivity:
|
|
99
|
+
is_enabled: true
|
|
100
|
+
request_url: https://<YOUR-PUBLIC-URL>/api/agents/<YOUR-AGENT-ID>/channels/slack/webhook
|
|
101
|
+
org_deploy_enabled: false
|
|
102
|
+
socket_mode_enabled: false
|
|
103
|
+
token_rotation_enabled: false
|
|
104
|
+
is_mcp_enabled: false
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
This manifest configures:
|
|
108
|
+
|
|
109
|
+
- `display_information.name` and `features.bot_user.display_name`: Set your agent's name in Slack. You can update it at any time; remember to reinstall the app after changing names or permissions.
|
|
110
|
+
- `app_home.messages_tab_enabled` and `app_home.messages_tab_read_only_enabled`: Enable direct messages from the Slack app's **Messages** tab.
|
|
111
|
+
- `always_online`: Shows the Slack bot user as always available.
|
|
112
|
+
- `oauth_config.scopes.bot`: Grants the bot permission to post messages, read channel messages where it is present, read mentions, read and write direct messages, and look up users.
|
|
113
|
+
- `event_subscriptions`: Tells Slack which message events to send to the webhook.
|
|
114
|
+
- `interactivity`: Enables interactive cards and tells Slack where to send card actions.
|
|
115
|
+
|
|
116
|
+
After the app is created, open **Install App**, select **Install to Workspace**, and approve the requested scopes.
|
|
117
|
+
|
|
118
|
+
## Set Slack credentials
|
|
119
|
+
|
|
120
|
+
Set the Slack credentials in Mastra so it can verify Slack requests and send messages back to Slack.
|
|
121
|
+
|
|
122
|
+
In the Slack app settings, copy these values:
|
|
123
|
+
|
|
124
|
+
- **Basic Information** > **App Credentials** > **Signing Secret**
|
|
125
|
+
- **OAuth & Permissions** > **Bot User OAuth Token**
|
|
126
|
+
|
|
127
|
+
Set them in your Mastra environment:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
SLACK_SIGNING_SECRET=your-signing-secret
|
|
131
|
+
SLACK_BOT_TOKEN=xoxb-your-bot-token
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Mastra reads these environment variables automatically.
|
|
135
|
+
|
|
136
|
+
## Configure the webhook route
|
|
137
|
+
|
|
138
|
+
Slack sends channel activity to Mastra through webhooks. A webhook is an HTTP endpoint Slack calls when something happens, such as a new message, a mention, or a user selecting an interactive card.
|
|
139
|
+
|
|
140
|
+
Mastra automatically registers a Slack webhook route for your agent:
|
|
141
|
+
|
|
142
|
+
```text
|
|
143
|
+
/api/agents/<YOUR-AGENT-ID>/channels/slack/webhook
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Build the webhook URL from your public Mastra server URL and the generated route:
|
|
147
|
+
|
|
148
|
+
```text
|
|
149
|
+
https://<YOUR-PUBLIC-URL>/api/agents/<YOUR-AGENT-ID>/channels/slack/webhook
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Slack can't send events to `localhost`. For local development, keep the Mastra dev server running and expose `http://localhost:4111` with a tunnel before you save the request URL in Slack.
|
|
153
|
+
|
|
154
|
+
Use a tunnel such as `cloudflared` or `ngrok` for local development:
|
|
155
|
+
|
|
156
|
+
**npm**:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
npx cloudflared tunnel --url http://localhost:4111
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**pnpm**:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
pnpm dlx cloudflared tunnel --url http://localhost:4111
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Yarn**:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
yarn dlx cloudflared tunnel --url http://localhost:4111
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Bun**:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
bun x cloudflared tunnel --url http://localhost:4111
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Use the generated tunnel host as `<YOUR-PUBLIC-URL>`, for example:
|
|
181
|
+
|
|
182
|
+
```text
|
|
183
|
+
https://abc123.trycloudflare.com/api/agents/your-agent/channels/slack/webhook
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Update the request URLs in Slack:
|
|
187
|
+
|
|
188
|
+
1. In the Slack app settings, open **Event Subscriptions**.
|
|
189
|
+
2. Replace **Request URL** with the final webhook URL.
|
|
190
|
+
3. Select **Save Changes**.
|
|
191
|
+
4. Open **Interactivity & Shortcuts**.
|
|
192
|
+
5. Replace **Request URL** with the same webhook URL.
|
|
193
|
+
6. Select **Save Changes**.
|
|
194
|
+
7. If Slack asks you to reinstall the app, open **OAuth & Permissions** and select **Reinstall to Workspace**.
|
|
195
|
+
|
|
196
|
+
## Try it in Slack
|
|
197
|
+
|
|
198
|
+
Open a direct message with the Slack bot user and send a message. Direct messages work because the manifest includes the `message.im` event and `im:*` scopes.
|
|
199
|
+
|
|
200
|
+
To use the agent in a channel, invite the Slack bot user first:
|
|
201
|
+
|
|
202
|
+
```text
|
|
203
|
+
/invite @your-bot-name
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Mention the bot in the channel:
|
|
207
|
+
|
|
208
|
+
```text
|
|
209
|
+
@your-bot-name What can you help me with?
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
The agent responds in the thread. Response content depends on the model, instructions, memory, and tools configured on the agent.
|
|
213
|
+
|
|
214
|
+
## Production deployment
|
|
215
|
+
|
|
216
|
+
When you deploy the Mastra server, update both request URLs in the Slack app settings to the production webhook URL. The tunnel URL used for local development is temporary and changes when the tunnel restarts.
|
|
217
|
+
|
|
218
|
+
Channels on serverless platforms may need `waitUntil` and shared pub/sub configuration so background responses and thread leases work across short-lived instances. See [serverless deployment](https://mastra.ai/docs/capabilities/channels/overview) in the channels overview.
|
|
219
|
+
|
|
220
|
+
## Related
|
|
221
|
+
|
|
222
|
+
- [Channels overview](https://mastra.ai/docs/capabilities/channels/overview)
|
|
223
|
+
- [More](https://mastra.ai/docs/capabilities/channels/other-adapters)
|
|
224
|
+
- [Channels reference](https://mastra.ai/reference/agents/channels)
|
|
225
|
+
- [Deployment overview](https://mastra.ai/docs/deployment/overview)
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Microsoft Teams
|
|
4
|
+
|
|
5
|
+
Microsoft Teams channels let a Mastra agent receive mentions and conversation events from Teams. Mastra handles the agent wiring and webhook route; the Chat SDK Teams adapter docs cover Teams app setup, authentication, and permissions.
|
|
6
|
+
|
|
7
|
+
## Install the adapter
|
|
8
|
+
|
|
9
|
+
Install the Teams adapter from the Chat SDK:
|
|
10
|
+
|
|
11
|
+
**npm**:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @chat-adapter/teams
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**pnpm**:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm add @chat-adapter/teams
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Yarn**:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
yarn add @chat-adapter/teams
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Bun**:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
bun add @chat-adapter/teams
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Agent configuration
|
|
36
|
+
|
|
37
|
+
Add `createTeamsAdapter()` to the agent's `channels.adapters` object:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { Agent } from '@mastra/core/agent'
|
|
41
|
+
import { createTeamsAdapter } from '@chat-adapter/teams'
|
|
42
|
+
|
|
43
|
+
export const teamsAgent = new Agent({
|
|
44
|
+
id: 'teams-agent',
|
|
45
|
+
name: 'Teams Agent',
|
|
46
|
+
instructions: 'Answer questions and help with tasks in Microsoft Teams.',
|
|
47
|
+
model: 'openai/gpt-5.5',
|
|
48
|
+
channels: {
|
|
49
|
+
adapters: {
|
|
50
|
+
teams: createTeamsAdapter({
|
|
51
|
+
appType: 'SingleTenant',
|
|
52
|
+
}),
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Register the agent on the Mastra instance:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { Mastra } from '@mastra/core'
|
|
62
|
+
import { teamsAgent } from './agents/teams-agent'
|
|
63
|
+
|
|
64
|
+
export const mastra = new Mastra({
|
|
65
|
+
agents: { teamsAgent },
|
|
66
|
+
})
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Adapter setup
|
|
70
|
+
|
|
71
|
+
Follow the [Chat SDK Teams adapter docs](https://chat-sdk.dev/adapters/official/teams) for Teams-specific setup, including Azure bot registration, Teams CLI usage, authentication options, and required permissions.
|
|
72
|
+
|
|
73
|
+
The adapter reads Teams credentials from environment variables such as:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
TEAMS_APP_ID=your-azure-bot-app-id
|
|
77
|
+
TEAMS_APP_PASSWORD=your-azure-bot-app-password
|
|
78
|
+
TEAMS_APP_TENANT_ID=your-azure-tenant-id
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Webhook URL
|
|
82
|
+
|
|
83
|
+
Mastra generates the Teams webhook route from the agent ID and adapter key:
|
|
84
|
+
|
|
85
|
+
```text
|
|
86
|
+
/api/agents/teams-agent/channels/teams/webhook
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Use your public Mastra server URL as the base URL:
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
https://your-app.example.com/api/agents/teams-agent/channels/teams/webhook
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Use this URL anywhere the Teams adapter docs ask for the bot endpoint or webhook URL. For local development, expose the Mastra dev server with a tunnel and use the tunnel URL as the base URL.
|
|
96
|
+
|
|
97
|
+
## Related
|
|
98
|
+
|
|
99
|
+
- [Channels overview](https://mastra.ai/docs/capabilities/channels/overview)
|
|
100
|
+
- [More](https://mastra.ai/docs/capabilities/channels/other-adapters)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Telegram
|
|
4
|
+
|
|
5
|
+
Telegram channels let a Mastra agent receive direct messages, group messages, and bot mentions from Telegram. Mastra handles the agent wiring and webhook route; the Chat SDK Telegram adapter docs cover bot setup, webhook registration, and polling behavior.
|
|
6
|
+
|
|
7
|
+
## Install the adapter
|
|
8
|
+
|
|
9
|
+
Install the Telegram adapter from the Chat SDK:
|
|
10
|
+
|
|
11
|
+
**npm**:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @chat-adapter/telegram
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**pnpm**:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm add @chat-adapter/telegram
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Yarn**:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
yarn add @chat-adapter/telegram
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Bun**:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
bun add @chat-adapter/telegram
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Agent configuration
|
|
36
|
+
|
|
37
|
+
Add `createTelegramAdapter()` to the agent's `channels.adapters` object:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { Agent } from '@mastra/core/agent'
|
|
41
|
+
import { createTelegramAdapter } from '@chat-adapter/telegram'
|
|
42
|
+
|
|
43
|
+
export const telegramAgent = new Agent({
|
|
44
|
+
id: 'telegram-agent',
|
|
45
|
+
name: 'Telegram Agent',
|
|
46
|
+
instructions: 'Answer questions and help with tasks in Telegram.',
|
|
47
|
+
model: 'openai/gpt-5.5',
|
|
48
|
+
channels: {
|
|
49
|
+
adapters: {
|
|
50
|
+
telegram: createTelegramAdapter(),
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Register the agent on the Mastra instance:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { Mastra } from '@mastra/core'
|
|
60
|
+
import { telegramAgent } from './agents/telegram-agent'
|
|
61
|
+
|
|
62
|
+
export const mastra = new Mastra({
|
|
63
|
+
agents: { telegramAgent },
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Adapter setup
|
|
68
|
+
|
|
69
|
+
Follow the [Chat SDK Telegram adapter docs](https://chat-sdk.dev/adapters/official/telegram) for Telegram-specific setup, including BotFather, webhook registration, secret tokens, and polling mode.
|
|
70
|
+
|
|
71
|
+
The adapter reads Telegram credentials from environment variables such as:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
TELEGRAM_BOT_TOKEN=your-telegram-bot-token
|
|
75
|
+
TELEGRAM_WEBHOOK_SECRET_TOKEN=your-webhook-secret-token
|
|
76
|
+
TELEGRAM_BOT_USERNAME=your_bot_username
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Webhook URL
|
|
80
|
+
|
|
81
|
+
Mastra generates the Telegram webhook route from the agent ID and adapter key:
|
|
82
|
+
|
|
83
|
+
```text
|
|
84
|
+
/api/agents/telegram-agent/channels/telegram/webhook
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Use your public Mastra server URL as the base URL:
|
|
88
|
+
|
|
89
|
+
```text
|
|
90
|
+
https://your-app.example.com/api/agents/telegram-agent/channels/telegram/webhook
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Use this URL anywhere the Telegram adapter docs ask for the webhook URL. Telegram also supports polling mode; follow the Chat SDK adapter docs if you want to use polling for local development.
|
|
94
|
+
|
|
95
|
+
## Related
|
|
96
|
+
|
|
97
|
+
- [Channels overview](https://mastra.ai/docs/capabilities/channels/overview)
|
|
98
|
+
- [More](https://mastra.ai/docs/capabilities/channels/other-adapters)
|
|
@@ -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)
|
|
@@ -205,4 +205,5 @@ You can also pin experiments to a version, see [running experiments](https://mas
|
|
|
205
205
|
- [Running experiments](https://mastra.ai/docs/evals/datasets/running-experiments)
|
|
206
206
|
- [Scorers overview](https://mastra.ai/docs/evals/overview)
|
|
207
207
|
- [DatasetsManager reference](https://mastra.ai/reference/datasets/datasets-manager)
|
|
208
|
-
- [Dataset reference](https://mastra.ai/reference/datasets/dataset)
|
|
208
|
+
- [Dataset reference](https://mastra.ai/reference/datasets/dataset)
|
|
209
|
+
- 📹 [Mastra evals, datasets, and experiments workshop](https://www.youtube.com/watch?v=Vla5LfmOOrM)
|
|
@@ -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
|
|
@@ -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)
|
|
@@ -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.
|
|
@@ -10,6 +10,8 @@ Signals are a way to interact with an agent through a thread. Instead of startin
|
|
|
10
10
|
|
|
11
11
|
Use message APIs for user-authored input. Use `sendSignal()` for lower-level system context, such as background task notifications, policy reminders, or processor-generated context.
|
|
12
12
|
|
|
13
|
+
> **📹 Watch:** Watch [Mastra signals overview](https://www.youtube.com/watch?v=7It2y89TVP4) to see how signals wake and steer long-running agents.
|
|
14
|
+
|
|
13
15
|
## When to use signals
|
|
14
16
|
|
|
15
17
|
Use signals when an agent thread needs new input or context outside the original `stream()` call. Signals are useful when users send follow-up messages while a run is active, when background systems need to add context to a thread, or when external events should wake, update, or notify the agent.
|
|
@@ -430,4 +432,5 @@ Use heartbeats together with client-side reconnect logic. Heartbeats reduce idle
|
|
|
430
432
|
- [Server agent routes](https://mastra.ai/reference/server/routes)
|
|
431
433
|
- [`client.getAgent().subscribeToThread()`](https://mastra.ai/reference/client-js/agents)
|
|
432
434
|
- [`client.getAgent().sendToolApproval()`](https://mastra.ai/reference/client-js/agents)
|
|
433
|
-
- [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams)
|
|
435
|
+
- [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams)
|
|
436
|
+
- 📹 [Mastra signals workshop](https://www.youtube.com/watch?v=KLg6uFKz9aw\&t=3020s)
|