@mastra/mcp-docs-server 1.1.46 → 1.1.49-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/agent-builder/access-control.md +17 -17
- package/.docs/docs/agent-builder/browser.md +7 -7
- package/.docs/docs/agent-builder/channels.md +4 -4
- package/.docs/docs/agent-builder/configuration.md +12 -29
- package/.docs/docs/agent-builder/deploying.md +10 -10
- package/.docs/docs/agent-builder/memory.md +3 -3
- package/.docs/docs/agent-builder/model-policy.md +3 -3
- package/.docs/docs/agent-builder/overview.md +21 -12
- package/.docs/docs/agent-builder/skill-registries.md +2 -2
- package/.docs/docs/agent-builder/workspace.md +6 -6
- package/.docs/docs/agents/goals.md +110 -0
- package/.docs/docs/agents/using-tools.md +2 -0
- package/.docs/docs/browser/agent-browser.md +16 -0
- package/.docs/docs/browser/overview.md +2 -0
- package/.docs/docs/browser/recording.md +108 -0
- package/.docs/docs/browser/stagehand.md +17 -0
- package/.docs/docs/mastra-platform/configuration.md +1 -1
- package/.docs/docs/mastra-platform/database.md +150 -0
- package/.docs/docs/mastra-platform/github.md +131 -0
- package/.docs/docs/mastra-platform/overview.md +4 -0
- package/.docs/docs/mastra-platform/server.md +72 -0
- package/.docs/docs/mastra-platform/studio.md +2 -0
- package/.docs/reference/browser/agent-browser.md +4 -0
- package/.docs/reference/browser/stagehand-browser.md +7 -1
- package/.docs/reference/client-js/agents.md +20 -0
- package/.docs/reference/streaming/ChunkType.md +30 -0
- package/.docs/reference/templates/overview.md +10 -0
- package/CHANGELOG.md +17 -0
- package/package.json +10 -10
|
@@ -15,18 +15,18 @@ The Agent Builder ships with two supported roles: `admin` and `member`. Wire the
|
|
|
15
15
|
|
|
16
16
|
The Builder UI calls several resources on load, so a usable `member` role needs explicit grants on each. The Builder action layer (`/agent-builder/*`) is one resource; the data it reads and writes lives under separate resources.
|
|
17
17
|
|
|
18
|
-
| Permission | Used for
|
|
19
|
-
| ------------------------------------- |
|
|
20
|
-
| `agent-builder:*` | Load Builder actions
|
|
21
|
-
| `agents:read`, `agents:execute` | List registered agents and chat with the Builder agent
|
|
22
|
-
| `stored-agents:*` | List, view, create, and edit agents
|
|
23
|
-
| `stored-skills:*` | List, view, create, and edit stored skills
|
|
24
|
-
| `stored-workspaces:*` | Pick a workspace when editing an agent
|
|
25
|
-
| `tools:read`, `tools:execute` | Populate the tool picker and run tools through agents
|
|
26
|
-
| `workflows:read`, `workflows:execute` | Populate the workflow picker and run workflows through agents
|
|
27
|
-
| `memory:read` | Preview memory configuration in the picker
|
|
28
|
-
| `channels:read` | Show Slack/channel chips on agent pages
|
|
29
|
-
| `infrastructure:read` | Builder diagnostics banner on the shell
|
|
18
|
+
| Permission | Used for |
|
|
19
|
+
| ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
20
|
+
| `agent-builder:*` | Load Builder actions and run Builder workflows. The derived Builder actions are `agent-builder:read` and `agent-builder:execute`; the wildcard grants both. |
|
|
21
|
+
| `agents:read`, `agents:execute` | List registered agents and chat with the Builder agent |
|
|
22
|
+
| `stored-agents:*` | List, view, create, and edit agents |
|
|
23
|
+
| `stored-skills:*` | List, view, create, and edit stored skills |
|
|
24
|
+
| `stored-workspaces:*` | Pick a workspace when editing an agent |
|
|
25
|
+
| `tools:read`, `tools:execute` | Populate the tool picker and run tools through agents |
|
|
26
|
+
| `workflows:read`, `workflows:execute` | Populate the workflow picker and run workflows through agents |
|
|
27
|
+
| `memory:read` | Preview memory configuration in the picker |
|
|
28
|
+
| `channels:read` | Show Slack/channel chips on agent pages |
|
|
29
|
+
| `infrastructure:read` | Builder diagnostics banner on the shell |
|
|
30
30
|
|
|
31
31
|
Grant `:write`, `:delete`, and `:publish` on `stored-agents` and `stored-skills` for users who should create or modify agents. The `:*` wildcards in the table above cover those actions. `admin` covers everything through the `*` wildcard.
|
|
32
32
|
|
|
@@ -85,13 +85,13 @@ export const mastra = new Mastra({
|
|
|
85
85
|
|
|
86
86
|
Permission patterns follow `resource:action`. Wildcards are supported on either side:
|
|
87
87
|
|
|
88
|
-
-
|
|
89
|
-
- `agent-builder
|
|
90
|
-
- `*:read
|
|
88
|
+
- `*`: Full access (every resource, every action). Used by `admin`.
|
|
89
|
+
- `agent-builder:*`: Every action on the `agent-builder` resource.
|
|
90
|
+
- `*:read`: `read` Across every resource.
|
|
91
91
|
|
|
92
92
|
Patterns resolve through `matchesPermission()`. The first matching role permission grants the action.
|
|
93
93
|
|
|
94
94
|
## Related
|
|
95
95
|
|
|
96
|
-
- [Configuration](https://mastra.ai/docs/agent-builder/configuration)
|
|
97
|
-
- [Deploying](https://mastra.ai/docs/agent-builder/deploying)
|
|
96
|
+
- [Configuration](https://mastra.ai/docs/agent-builder/configuration): Wire RBAC alongside the rest of the Builder config.
|
|
97
|
+
- [Deploying](https://mastra.ai/docs/agent-builder/deploying): Auth, RBAC, and EE license setup for production.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **Note:** The Agent Builder is part of the Mastra Enterprise Edition. Production deployments require a valid EE license. [Contact sales](https://mastra.ai/contact) for more information.
|
|
4
4
|
|
|
5
|
-
The Agent Builder can give end-user agents a browser tool driven by a registered provider. Unlike filesystems and sandboxes, **there are no built-in browser providers**
|
|
5
|
+
The Agent Builder can give end-user agents a browser tool driven by a registered provider. Unlike filesystems and sandboxes, **there are no built-in browser providers** and you must register one through `MastraEditor.browsers`.
|
|
6
6
|
|
|
7
7
|
## Quickstart
|
|
8
8
|
|
|
@@ -44,9 +44,9 @@ new MastraEditor({
|
|
|
44
44
|
|
|
45
45
|
`MastraEditor.browsers` accepts a `Record<string, BrowserProvider>`. Each provider exposes:
|
|
46
46
|
|
|
47
|
-
- `id
|
|
48
|
-
- `name
|
|
49
|
-
- `createBrowser(config)
|
|
47
|
+
- `id`: Provider identifier, matched against `StorageBrowserConfig.provider` (e.g., `'stagehand'`).
|
|
48
|
+
- `name`: Display name shown in the Builder UI.
|
|
49
|
+
- `createBrowser(config)`: Hydrates a stored browser config into a runtime `MastraBrowser`. This is where you inject runtime-only credentials (API keys, project IDs) that aren't stored in the agent snapshot.
|
|
50
50
|
|
|
51
51
|
Browser classes ship as separate packages (e.g., `@mastra/stagehand`, `@mastra/agent-browser`). The provider entry is a plain object wrapping the class — register one entry per browser you want the Builder to expose to end users. See the [StorageBrowserRef reference](https://mastra.ai/reference/editor/storage-browser-ref) for the full `browser` field schema, including all `StorageBrowserConfig` options.
|
|
52
52
|
|
|
@@ -56,6 +56,6 @@ The `features.agent.browser` toggle controls whether end users can enable browse
|
|
|
56
56
|
|
|
57
57
|
## Related
|
|
58
58
|
|
|
59
|
-
- [BuilderAgentDefaults reference](https://mastra.ai/reference/editor/agent-builder/builder-agent-defaults)
|
|
60
|
-
- [AgentBuilderOptions reference](https://mastra.ai/reference/editor/agent-builder/agent-builder-options)
|
|
61
|
-
- [Configuration](https://mastra.ai/docs/agent-builder/configuration)
|
|
59
|
+
- [BuilderAgentDefaults reference](https://mastra.ai/reference/editor/agent-builder/builder-agent-defaults): The full `browser` field schema.
|
|
60
|
+
- [AgentBuilderOptions reference](https://mastra.ai/reference/editor/agent-builder/agent-builder-options): The full Builder config surface, including `features.agent.browser`.
|
|
61
|
+
- [Configuration](https://mastra.ai/docs/agent-builder/configuration): Wire `browser` alongside the rest of the Builder config.
|
|
@@ -63,8 +63,8 @@ The Slack provider handles app creation, OAuth, slash commands, and message rout
|
|
|
63
63
|
|
|
64
64
|
`SlackProvider` requires one environment variable and accepts one optional override:
|
|
65
65
|
|
|
66
|
-
- `SLACK_APP_CONFIG_REFRESH_TOKEN` (required):
|
|
67
|
-
- `baseUrl` (optional):
|
|
66
|
+
- `SLACK_APP_CONFIG_REFRESH_TOKEN` (required): The refresh token from your Slack app configuration tokens, available under **Your App Configuration Tokens** on [api.slack.com/apps](https://api.slack.com/apps). The refresh token doesn't expire, but the access tokens it issues rotate every 12 hours and are auto-persisted to `Mastra.storage`.
|
|
67
|
+
- `baseUrl` (optional): The public URL Slack should send events and OAuth callbacks to. Defaults to the running Mastra server's host and port (for example, `http://localhost:4111` in local development). Pass `baseUrl` explicitly when the public URL differs from the server's resolved address — typically a tunnel for local development (`cloudflared tunnel --url http://localhost:4111`) or a deployed URL in production.
|
|
68
68
|
|
|
69
69
|
## Storage requirement
|
|
70
70
|
|
|
@@ -72,5 +72,5 @@ The Slack provider handles app creation, OAuth, slash commands, and message rout
|
|
|
72
72
|
|
|
73
73
|
## Related
|
|
74
74
|
|
|
75
|
-
- [Deploying](https://mastra.ai/docs/agent-builder/deploying)
|
|
76
|
-
- [Configuration](https://mastra.ai/docs/agent-builder/configuration)
|
|
75
|
+
- [Deploying](https://mastra.ai/docs/agent-builder/deploying): Set a public `baseUrl` for production deployments.
|
|
76
|
+
- [Configuration](https://mastra.ai/docs/agent-builder/configuration): Wire channel toggles into the Builder UI.
|
|
@@ -39,43 +39,26 @@ new MastraEditor({
|
|
|
39
39
|
tools: true,
|
|
40
40
|
agents: true,
|
|
41
41
|
workflows: true,
|
|
42
|
+
scorers: true,
|
|
42
43
|
skills: true,
|
|
43
44
|
memory: true,
|
|
45
|
+
variables: true,
|
|
46
|
+
favorites: true,
|
|
47
|
+
avatarUpload: true,
|
|
44
48
|
model: true,
|
|
45
49
|
browser: true,
|
|
46
|
-
avatarUpload: true,
|
|
47
|
-
favorites: true,
|
|
48
50
|
},
|
|
49
51
|
},
|
|
50
52
|
},
|
|
51
53
|
})
|
|
52
54
|
```
|
|
53
55
|
|
|
54
|
-
The shipping UI consumes these `AgentFeatures` keys: `tools`, `agents`, `workflows`, `skills`, `memory`, `
|
|
56
|
+
The shipping UI consumes these `AgentFeatures` keys: `tools`, `agents`, `workflows`, `scorers`, `skills`, `memory`, `variables`, `favorites`, `avatarUpload`, `model`, and `browser`. See the [AgentBuilderOptions reference](https://mastra.ai/reference/editor/agent-builder/agent-builder-options) for the full schema.
|
|
55
57
|
|
|
56
58
|
## Admin defaults
|
|
57
59
|
|
|
58
60
|
`builder.configuration.agent` pins admin-controlled defaults onto every agent the Builder produces.
|
|
59
61
|
|
|
60
|
-
```typescript
|
|
61
|
-
new MastraEditor({
|
|
62
|
-
builder: {
|
|
63
|
-
enabled: true,
|
|
64
|
-
configuration: {
|
|
65
|
-
agent: {
|
|
66
|
-
models: {
|
|
67
|
-
allowed: [
|
|
68
|
-
{ provider: 'openai', modelId: 'gpt-5.4-mini' },
|
|
69
|
-
{ provider: 'openai', modelId: 'gpt-5.4' },
|
|
70
|
-
{ provider: 'anthropic', modelId: 'claude-opus-4-7' },
|
|
71
|
-
],
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
})
|
|
77
|
-
```
|
|
78
|
-
|
|
79
62
|
`configuration.agent` accepts `models`, `memory`, `workspace`, `browser`, `tools`, `agents`, and `workflows`. See the [BuilderAgentDefaults reference](https://mastra.ai/reference/editor/agent-builder/builder-agent-defaults) for the full shape.
|
|
80
63
|
|
|
81
64
|
## Making tools, agents, and workflows available
|
|
@@ -118,9 +101,9 @@ MCP tools work the same way: load them via `MCPClient.getTools()` and spread the
|
|
|
118
101
|
|
|
119
102
|
`configuration.agent.tools`, `configuration.agent.agents`, and `configuration.agent.workflows` constrain which registered entries appear in the Builder's pickers. Allowlist semantics are the same for all three:
|
|
120
103
|
|
|
121
|
-
- **Omitted**:
|
|
122
|
-
- **`allowed: []`**:
|
|
123
|
-
- **`allowed: [...ids]`**:
|
|
104
|
+
- **Omitted**: Unrestricted. The picker shows every registered entry.
|
|
105
|
+
- **`allowed: []`**: Explicit lockdown. The picker is empty.
|
|
106
|
+
- **`allowed: [...ids]`**: The picker shows only the listed IDs.
|
|
124
107
|
|
|
125
108
|
Unknown IDs are dropped and surfaced as warnings through `getModelPolicyWarnings()` and the server logs.
|
|
126
109
|
|
|
@@ -141,7 +124,7 @@ new MastraEditor({
|
|
|
141
124
|
|
|
142
125
|
## Related
|
|
143
126
|
|
|
144
|
-
- [Model policy](https://mastra.ai/docs/agent-builder/model-policy)
|
|
145
|
-
- [Memory](https://mastra.ai/docs/agent-builder/memory)
|
|
146
|
-
- [AgentBuilderOptions reference](https://mastra.ai/reference/editor/agent-builder/agent-builder-options)
|
|
147
|
-
- [BuilderAgentDefaults reference](https://mastra.ai/reference/editor/agent-builder/builder-agent-defaults)
|
|
127
|
+
- [Model policy](https://mastra.ai/docs/agent-builder/model-policy): Pin the allowed models and default model.
|
|
128
|
+
- [Memory](https://mastra.ai/docs/agent-builder/memory): Set the default memory shape for new agents.
|
|
129
|
+
- [AgentBuilderOptions reference](https://mastra.ai/reference/editor/agent-builder/agent-builder-options): Full property list.
|
|
130
|
+
- [BuilderAgentDefaults reference](https://mastra.ai/reference/editor/agent-builder/builder-agent-defaults): Every field on `configuration.agent`.
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
> **Note:** The Agent Builder is part of the Mastra Enterprise Edition. Production deployments require a valid EE license. [Contact sales](https://mastra.ai/contact) for more information.
|
|
4
4
|
|
|
5
|
-
Production deployments swap the local primitives in the Quickstart for cloud-backed equivalents. The shape of the `Mastra` and `MastraEditor` config doesn't change
|
|
5
|
+
Production deployments swap the local primitives in the Quickstart for cloud-backed equivalents. The shape of the `Mastra` and `MastraEditor` config doesn't change, only the providers behind it.
|
|
6
6
|
|
|
7
7
|
## What a production deployment needs
|
|
8
8
|
|
|
9
|
-
1. **EE license
|
|
10
|
-
2. **Hosted storage
|
|
11
|
-
3. **Shared workspace filesystem
|
|
12
|
-
4. **Cloud sandbox
|
|
13
|
-
5. **Auth and RBAC
|
|
14
|
-
6. **Public base URL for channels
|
|
9
|
+
1. **EE license**: A valid `MASTRA_EE_LICENSE` so the server will start with the Builder enabled.
|
|
10
|
+
2. **Hosted storage**: A shared store for agents, skills, runs, and memory.
|
|
11
|
+
3. **Shared workspace filesystem**: Survives across instances; `local` is single-node only.
|
|
12
|
+
4. **Cloud sandbox**: Runs agent commands safely; `local` is unsafe in shared environments.
|
|
13
|
+
5. **Auth and RBAC**: Gates the Builder UI and `/agent-builder/*` routes.
|
|
14
|
+
6. **Public base URL for channels**: Slack and other channel providers need a reachable URL.
|
|
15
15
|
|
|
16
16
|
## EE license
|
|
17
17
|
|
|
@@ -101,7 +101,7 @@ new Mastra({
|
|
|
101
101
|
|
|
102
102
|
`S3Filesystem` uses the default AWS credential chain (environment variables, `~/.aws` config, IAM roles, EC2 instance profile). For long-running deployments, use a credential provider function so credentials refresh automatically.
|
|
103
103
|
|
|
104
|
-
`DockerSandbox` and `VercelSandbox` are alternative cloud sandbox providers
|
|
104
|
+
`DockerSandbox` and `VercelSandbox` are alternative cloud sandbox providers, pick whichever matches your runtime.
|
|
105
105
|
|
|
106
106
|
> **Warning:** A local sandbox can't run commands safely in a shared environment. Always register a cloud sandbox provider and reference it in the workspace config before deploying.
|
|
107
107
|
|
|
@@ -117,5 +117,5 @@ Slack needs to reach your server through a public URL. Pass `baseUrl` to `SlackP
|
|
|
117
117
|
|
|
118
118
|
## Related
|
|
119
119
|
|
|
120
|
-
- [Access control](https://mastra.ai/docs/agent-builder/access-control)
|
|
121
|
-
- [Channels](https://mastra.ai/docs/agent-builder/channels)
|
|
120
|
+
- [Access control](https://mastra.ai/docs/agent-builder/access-control): Auth and RBAC setup.
|
|
121
|
+
- [Channels](https://mastra.ai/docs/agent-builder/channels): Slack `baseUrl` and channel-specific setup.
|
|
@@ -60,6 +60,6 @@ If a required adapter is missing, Mastra throws a descriptive error at agent run
|
|
|
60
60
|
|
|
61
61
|
## Related
|
|
62
62
|
|
|
63
|
-
- [Memory overview](https://mastra.ai/docs/memory/overview)
|
|
64
|
-
- [BuilderAgentDefaults reference](https://mastra.ai/reference/editor/agent-builder/builder-agent-defaults)
|
|
65
|
-
- [Configuration](https://mastra.ai/docs/agent-builder/configuration)
|
|
63
|
+
- [Memory overview](https://mastra.ai/docs/memory/overview): Concepts and core configuration.
|
|
64
|
+
- [BuilderAgentDefaults reference](https://mastra.ai/reference/editor/agent-builder/builder-agent-defaults): The full `memory` field schema.
|
|
65
|
+
- [Configuration](https://mastra.ai/docs/agent-builder/configuration): Wire `memory` alongside the rest of the Builder config.
|
|
@@ -43,6 +43,6 @@ See the [`builder.configuration.agent.models`](https://mastra.ai/reference/edito
|
|
|
43
43
|
|
|
44
44
|
## Related
|
|
45
45
|
|
|
46
|
-
- [Configuration](https://mastra.ai/docs/agent-builder/configuration)
|
|
47
|
-
- [`builder.configuration.agent.models`](https://mastra.ai/reference/editor/agent-builder/builder-models)
|
|
48
|
-
- [Provider registry](https://github.com/mastra-ai/mastra/blob/main/packages/core/src/llm/model/provider-registry.json)
|
|
46
|
+
- [Configuration](https://mastra.ai/docs/agent-builder/configuration): Wire the model policy into the broader Builder config.
|
|
47
|
+
- [`builder.configuration.agent.models`](https://mastra.ai/reference/editor/agent-builder/builder-models): Full property list.
|
|
48
|
+
- [Provider registry](https://github.com/mastra-ai/mastra/blob/main/packages/core/src/llm/model/provider-registry.json): Every model ID Mastra recognizes out of the box.
|
|
@@ -7,6 +7,8 @@ The Agent Builder lets you build, configure, and operate Mastra agents all withi
|
|
|
7
7
|
- [**Configuration**](https://mastra.ai/docs/agent-builder/configuration): Toggle UI sections and pin admin-controlled defaults for every new agent.
|
|
8
8
|
- [**Model policy**](https://mastra.ai/docs/agent-builder/model-policy): Restrict which providers and models the Builder exposes, and pin a default.
|
|
9
9
|
- [**Memory**](https://mastra.ai/docs/agent-builder/memory): Configure the default memory shape for every Builder-created agent.
|
|
10
|
+
- [**Workspace**](https://mastra.ai/docs/agent-builder/workspace): Configure the default filesystem, sandbox, and skills workspace for Builder-created agents.
|
|
11
|
+
- [**Browser**](https://mastra.ai/docs/agent-builder/browser): Register browser providers and pin a default browser configuration.
|
|
10
12
|
- [**Access control**](https://mastra.ai/docs/agent-builder/access-control): Gate the Builder behind Mastra RBAC roles and permissions.
|
|
11
13
|
- [**Channels**](https://mastra.ai/docs/agent-builder/channels): Connect Builder-created agents to Slack and other channels.
|
|
12
14
|
- [**Tool providers**](https://mastra.ai/docs/agent-builder/integrations): Connect Builder-created agents to third-party apps through OAuth-backed tool providers.
|
|
@@ -15,9 +17,18 @@ The Agent Builder lets you build, configure, and operate Mastra agents all withi
|
|
|
15
17
|
|
|
16
18
|
For building agents entirely in code, see the [Agents overview](https://mastra.ai/docs/agents/overview). For editing code-defined agents through Studio, see the [Editor overview](https://mastra.ai/docs/editor/overview).
|
|
17
19
|
|
|
20
|
+
## Prerequisites
|
|
21
|
+
|
|
22
|
+
The Agent Builder requires:
|
|
23
|
+
|
|
24
|
+
- An existing Mastra project (Follow the [installation guide](https://mastra.ai/guides/getting-started/quickstart) to set up a new project)
|
|
25
|
+
- **Storage**: A `@mastra/core` storage adapter on the `Mastra` instance. Agents, memory, and workspace state all persist through `Mastra.storage`.
|
|
26
|
+
- **A builder agent**: Register a `builderAgent` created with the `createBuilderAgent()` factory from `@mastra/editor/ee` on `Mastra.agents`. The chat-based editor invokes it through the same `Mastra.getAgent(id)` lookup as any other agent. Without this registration, the chat-based editor returns 404.
|
|
27
|
+
- **Model credentials**: `createBuilderAgent()` uses an OpenAI model by default, which requires `OPENAI_API_KEY`. To use a different provider, pass a `model` override to `createBuilderAgent({ model })` and set that provider's credentials instead.
|
|
28
|
+
|
|
18
29
|
## Get started
|
|
19
30
|
|
|
20
|
-
Install `@mastra/editor` alongside a storage adapter
|
|
31
|
+
Install `@mastra/editor` alongside a storage adapter. This example uses `@mastra/libsql`:
|
|
21
32
|
|
|
22
33
|
**npm**:
|
|
23
34
|
|
|
@@ -43,7 +54,7 @@ yarn add @mastra/editor @mastra/libsql
|
|
|
43
54
|
bun add @mastra/editor @mastra/libsql
|
|
44
55
|
```
|
|
45
56
|
|
|
46
|
-
|
|
57
|
+
The example below defines a storage adapter, registers a builder agent, and enables the editor as explained in the prerequisites:
|
|
47
58
|
|
|
48
59
|
```typescript
|
|
49
60
|
import { Mastra } from '@mastra/core/mastra'
|
|
@@ -67,7 +78,7 @@ export const mastra = new Mastra({
|
|
|
67
78
|
})
|
|
68
79
|
```
|
|
69
80
|
|
|
70
|
-
Start
|
|
81
|
+
Start Mastra's development server:
|
|
71
82
|
|
|
72
83
|
```bash
|
|
73
84
|
npx mastra dev
|
|
@@ -75,14 +86,6 @@ npx mastra dev
|
|
|
75
86
|
|
|
76
87
|
The Agent Builder is mounted at `http://localhost:4111/agent-builder`.
|
|
77
88
|
|
|
78
|
-
## Prerequisites
|
|
79
|
-
|
|
80
|
-
The Agent Builder requires:
|
|
81
|
-
|
|
82
|
-
- **Storage**: An `@mastra/core` storage adapter on the `Mastra` instance. Agents, memory, and workspace state all persist through `Mastra.storage`.
|
|
83
|
-
- **The Builder agent**: Register a Builder agent created with the `createBuilderAgent()` factory from `@mastra/editor/ee` on `Mastra.agents`. The chat-based editor invokes it through the same `Mastra.getAgent(id)` lookup as any other agent. Without this registration, the chat-based editor returns 404.
|
|
84
|
-
- **`OPENAI_API_KEY`**: The Builder agent created by `createBuilderAgent()` runs on an OpenAI model, so an `OPENAI_API_KEY` environment variable is required.
|
|
85
|
-
|
|
86
89
|
## Disabling the Builder
|
|
87
90
|
|
|
88
91
|
Set `enabled: false` to keep the config in place but turn the surface off:
|
|
@@ -95,4 +98,10 @@ new MastraEditor({
|
|
|
95
98
|
})
|
|
96
99
|
```
|
|
97
100
|
|
|
98
|
-
Omitting the `builder` field has the same effect.
|
|
101
|
+
Omitting the `builder` field has the same effect.
|
|
102
|
+
|
|
103
|
+
## Next steps
|
|
104
|
+
|
|
105
|
+
- [Configuration](https://mastra.ai/docs/agent-builder/configuration): Toggle Builder surfaces and pin defaults for new agents.
|
|
106
|
+
- [Access control](https://mastra.ai/docs/agent-builder/access-control): Gate the Builder with authentication and role-based access control.
|
|
107
|
+
- [Deploying](https://mastra.ai/docs/agent-builder/deploying): Replace local development primitives with production-ready storage, filesystems, and sandboxes.
|
|
@@ -27,5 +27,5 @@ The Builder library tab now exposes a **Browse** view backed by skills.sh. End u
|
|
|
27
27
|
|
|
28
28
|
## Related
|
|
29
29
|
|
|
30
|
-
- [Configuration](https://mastra.ai/docs/agent-builder/configuration)
|
|
31
|
-
- [AgentBuilderOptions reference](https://mastra.ai/reference/editor/agent-builder/agent-builder-options)
|
|
30
|
+
- [Configuration](https://mastra.ai/docs/agent-builder/configuration): Wire registries alongside the rest of the Builder config.
|
|
31
|
+
- [AgentBuilderOptions reference](https://mastra.ai/reference/editor/agent-builder/agent-builder-options): Every field on `builder`.
|
|
@@ -41,8 +41,8 @@ The Builder derives a deterministic id from the inline config and persists the s
|
|
|
41
41
|
|
|
42
42
|
`configuration.agent.workspace` accepts a `StorageWorkspaceRef`:
|
|
43
43
|
|
|
44
|
-
- **`{ type: 'inline', config }
|
|
45
|
-
- **`{ type: 'id', workspaceId }
|
|
44
|
+
- **`{ type: 'inline', config }`**: Embeds a serialized workspace snapshot directly on the agent. Useful for per-agent, ad-hoc configurations.
|
|
45
|
+
- **`{ type: 'id', workspaceId }`**: References a workspace already registered on the `Mastra` instance via `new Mastra({ workspace })` or `mastra.addWorkspace(...)`. Use this for shared, named workspaces.
|
|
46
46
|
|
|
47
47
|
See the [StorageWorkspaceRef reference](https://mastra.ai/reference/editor/storage-workspace-ref) for both variants.
|
|
48
48
|
|
|
@@ -54,7 +54,7 @@ For cloud deployments, swap `LocalFilesystem` / `LocalSandbox` for managed provi
|
|
|
54
54
|
|
|
55
55
|
## Related
|
|
56
56
|
|
|
57
|
-
- [Workspace overview](https://mastra.ai/docs/workspace/overview)
|
|
58
|
-
- [Filesystem](https://mastra.ai/docs/workspace/filesystem) and [Sandbox](https://mastra.ai/docs/workspace/sandbox)
|
|
59
|
-
- [BuilderAgentDefaults reference](https://mastra.ai/reference/editor/agent-builder/builder-agent-defaults)
|
|
60
|
-
- [Configuration](https://mastra.ai/docs/agent-builder/configuration)
|
|
57
|
+
- [Workspace overview](https://mastra.ai/docs/workspace/overview): The underlying workspace model.
|
|
58
|
+
- [Filesystem](https://mastra.ai/docs/workspace/filesystem) and [Sandbox](https://mastra.ai/docs/workspace/sandbox): The building blocks.
|
|
59
|
+
- [BuilderAgentDefaults reference](https://mastra.ai/reference/editor/agent-builder/builder-agent-defaults): The full `workspace` field schema.
|
|
60
|
+
- [Configuration](https://mastra.ai/docs/agent-builder/configuration): Wire `workspace` alongside the rest of the Builder config.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Goals
|
|
2
|
+
|
|
3
|
+
**Added in:** `@mastra/core@1.42.0`
|
|
4
|
+
|
|
5
|
+
A goal is a durable, thread-scoped objective: a standing instruction the agent keeps working toward across loop iterations until a judge model decides it is satisfied or a run budget is exhausted. The objective is persisted in thread state, so it survives reloads and is evaluated in-loop — even when a new message arrives in the middle of an already-running turn.
|
|
6
|
+
|
|
7
|
+
Goals build on the same machinery as [`isTaskComplete`](https://mastra.ai/docs/agents/supervisor-agents): an LLM-as-judge scores the agent's output each iteration and gates the loop. The difference is that a goal is **durable** (stored in thread state, not passed per call) and is set and updated through `Agent` methods rather than per-`stream()` options.
|
|
8
|
+
|
|
9
|
+
> **Note:** Goals are experimental and may change in a future release.
|
|
10
|
+
|
|
11
|
+
## When to use goals
|
|
12
|
+
|
|
13
|
+
Use a goal when you want an agent to keep working toward a single objective across many iterations and messages, without re-supplying the success criteria on every call:
|
|
14
|
+
|
|
15
|
+
- A standing objective the agent should pursue until a judge says it's done.
|
|
16
|
+
- Work that should continue across mid-run messages (a message delivered into a live run is still judged against the goal).
|
|
17
|
+
- An objective that must persist across thread reloads or process restarts.
|
|
18
|
+
|
|
19
|
+
For a one-off completion check within a single `stream()` call, use [`isTaskComplete`](https://mastra.ai/docs/agents/supervisor-agents) instead.
|
|
20
|
+
|
|
21
|
+
## Quickstart
|
|
22
|
+
|
|
23
|
+
Goals require a configured [storage](https://mastra.ai/docs/memory/storage) backend and a memory-backed thread. Add a `goal` config to the agent — a judge model is required for the goal to do anything — then set an objective for a thread:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { Agent } from '@mastra/core/agent'
|
|
27
|
+
|
|
28
|
+
const worker = new Agent({
|
|
29
|
+
name: 'worker',
|
|
30
|
+
instructions: 'You complete software tasks end to end.',
|
|
31
|
+
model: 'openai/gpt-5.5',
|
|
32
|
+
memory,
|
|
33
|
+
goal: {
|
|
34
|
+
judge: 'openai/gpt-5-mini',
|
|
35
|
+
maxRuns: 50,
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
// Set the durable objective for a thread.
|
|
40
|
+
await worker.setObjective('Add and test a /health endpoint', {
|
|
41
|
+
threadId,
|
|
42
|
+
resourceId,
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
// The objective is judged each iteration until it's complete or maxRuns is hit.
|
|
46
|
+
const stream = await worker.stream('Start working on the goal', {
|
|
47
|
+
memory: { thread: threadId, resource: resourceId },
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The `goal` config auto-registers the state-signal projection, so the model always sees the current objective as `<current-objective>` in its context — no extra setup needed.
|
|
52
|
+
|
|
53
|
+
## How the goal step works
|
|
54
|
+
|
|
55
|
+
A goal step runs inside the agentic execution loop, right after `isTaskComplete`. On a real candidate answer it scores the conversation against the objective and gates the loop:
|
|
56
|
+
|
|
57
|
+
- **Not satisfied, budget remaining** → the loop continues; per-evaluation feedback is injected so the agent iterates.
|
|
58
|
+
- **Satisfied** → the loop stops and the objective is marked `done`.
|
|
59
|
+
- **Budget exhausted** (`runsUsed >= maxRuns`) → the loop stops but the objective stays `active`, so raising `maxRuns` later can resume it.
|
|
60
|
+
|
|
61
|
+
The step is a no-op for background-task, mid-tool-loop, and working-memory-only iterations — the same gating as `isTaskComplete`.
|
|
62
|
+
|
|
63
|
+
**The judge model is the activation switch.** If no judge resolves (neither the per-objective override nor the agent's `goal.judge`), the goal step does nothing: no scoring, no budget consumed, no `goal` chunk. Effective settings resolve as per-objective record value → agent `goal` config → built-in default (`maxRuns` `50`, a default judge prompt).
|
|
64
|
+
|
|
65
|
+
By default the step uses a built-in LLM-as-judge scorer that returns `1` when the objective is achieved and `0` otherwise. Supply your own scorer with `goal.scorer` to customize judging.
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
const worker = new Agent({
|
|
69
|
+
name: 'worker',
|
|
70
|
+
instructions: 'You complete software tasks end to end.',
|
|
71
|
+
model: 'openai/gpt-5.5',
|
|
72
|
+
memory,
|
|
73
|
+
goal: {
|
|
74
|
+
// A resolver function lets you inject provider credentials and read the
|
|
75
|
+
// current judge selection at runtime; returning `undefined` keeps the
|
|
76
|
+
// goal step a no-op.
|
|
77
|
+
judge: ({ requestContext }) => resolveJudgeModel(requestContext),
|
|
78
|
+
maxRuns: 30,
|
|
79
|
+
prompt: 'Only mark the goal complete when tests pass.',
|
|
80
|
+
},
|
|
81
|
+
})
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Each evaluation emits a typed `goal` stream chunk (`GoalEvaluationPayload`: `objective`, `iteration`, `maxRuns`, `passed`, `status`, `results`, `reason`, `duration`, `timedOut`, `maxRunsReached`, `suppressFeedback`) so a UI can show goal progress mid-run.
|
|
85
|
+
|
|
86
|
+
## Managing the objective
|
|
87
|
+
|
|
88
|
+
Control the objective for a thread with `Agent` methods. All of them no-op when the run is not memory-backed (they require storage and a `threadId`):
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
// Read the current objective record.
|
|
92
|
+
const record = await worker.getObjective({ threadId })
|
|
93
|
+
|
|
94
|
+
// Update options on the active objective (only provided fields are written;
|
|
95
|
+
// unset fields fall back to the agent's `goal` config).
|
|
96
|
+
await worker.updateObjectiveOptions({ threadId, maxRuns: 100 })
|
|
97
|
+
|
|
98
|
+
// Drop the objective.
|
|
99
|
+
await worker.clearObjective({ threadId })
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Per-objective values written by `setObjective` / `updateObjectiveOptions` take precedence over the agent's `goal` config, and that precedence is remembered in thread state.
|
|
103
|
+
|
|
104
|
+
> **Note:** See the [`GoalEvaluationPayload` in the ChunkType reference](https://mastra.ai/reference/streaming/ChunkType) for the full goal chunk shape.
|
|
105
|
+
|
|
106
|
+
## Related
|
|
107
|
+
|
|
108
|
+
- [Supervisor agents](https://mastra.ai/docs/agents/supervisor-agents) — `isTaskComplete` and the rubric scorer
|
|
109
|
+
- [Signal providers](https://mastra.ai/docs/agents/signal-providers) — how the objective is projected into context
|
|
110
|
+
- [Memory storage](https://mastra.ai/docs/memory/storage) — the storage backend goals require
|
|
@@ -224,6 +224,8 @@ export const weatherTool = createTool({
|
|
|
224
224
|
})
|
|
225
225
|
```
|
|
226
226
|
|
|
227
|
+
`toModelOutput` also works on client-side tools passed through `clientTools`. The mapping runs on the client after the tool executes, and the transformed output is sent back to the server alongside the raw result.
|
|
228
|
+
|
|
227
229
|
## Transform tool payloads for UI and transcripts
|
|
228
230
|
|
|
229
231
|
Use `transform` when a tool returns raw data your application needs, but browser-facing streams or user-visible transcript messages should receive a smaller or safer shape. `transform` is separate from `toModelOutput`: `toModelOutput` shapes the payload sent back to the model, while `transform` shapes tool input, output, errors, approval payloads, and suspension payloads for `display` and `transcript` targets.
|
|
@@ -84,10 +84,26 @@ const browser = new AgentBrowser({
|
|
|
84
84
|
|
|
85
85
|
AgentBrowser uses accessibility tree refs to identify elements. When an agent calls `browser_snapshot`, it receives a text representation of the page with refs like `@e1`, `@e2`, etc. The agent then uses these refs with other tools to interact with elements.
|
|
86
86
|
|
|
87
|
+
## Recording
|
|
88
|
+
|
|
89
|
+
AgentBrowser can opt into alpha browser recording tools:
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
const browser = new AgentBrowser({
|
|
93
|
+
headless: false,
|
|
94
|
+
recording: {
|
|
95
|
+
outputDir: './browser-recordings',
|
|
96
|
+
},
|
|
97
|
+
})
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
This adds `browser_record` and `browser_record_caption` to the agent's toolset. See [Browser recording (alpha)](https://mastra.ai/docs/browser/recording) for details.
|
|
101
|
+
|
|
87
102
|
> **Note:** See [AgentBrowser reference](https://mastra.ai/reference/browser/agent-browser) for all configuration options and tool details.
|
|
88
103
|
|
|
89
104
|
## Related
|
|
90
105
|
|
|
91
106
|
- [Browser overview](https://mastra.ai/docs/browser/overview)
|
|
92
107
|
- [Stagehand](https://mastra.ai/docs/browser/stagehand)
|
|
108
|
+
- [Browser recording (alpha)](https://mastra.ai/docs/browser/recording)
|
|
93
109
|
- [AgentBrowser reference](https://mastra.ai/reference/browser/agent-browser)
|
|
@@ -7,6 +7,7 @@ Mastra supports two SDK providers and one CLI provider:
|
|
|
7
7
|
- [**AgentBrowser**](https://mastra.ai/docs/browser/agent-browser): A Playwright-based provider with accessibility-first element targeting. Best for general web automation and scraping.
|
|
8
8
|
- [**Stagehand**](https://mastra.ai/docs/browser/stagehand): A Browserbase provider with AI-powered element detection. Best for complex interactions that benefit from natural language selectors.
|
|
9
9
|
- [**BrowserViewer**](https://mastra.ai/docs/browser/browser-viewer): A CLI provider that launches Chrome and injects CDP URLs into CLI tools like agent-browser, browser-use, and browse. Best for workspace agents that drive browsers through shell commands.
|
|
10
|
+
- [**Browser recording (alpha)**](https://mastra.ai/docs/browser/recording): An opt-in tool layer that saves browser sessions as Motion-JPEG AVI videos with optional captions.
|
|
10
11
|
|
|
11
12
|
## When to use browser
|
|
12
13
|
|
|
@@ -164,5 +165,6 @@ const browser = new AgentBrowser({
|
|
|
164
165
|
|
|
165
166
|
- [AgentBrowser](https://mastra.ai/docs/browser/agent-browser)
|
|
166
167
|
- [Stagehand](https://mastra.ai/docs/browser/stagehand)
|
|
168
|
+
- [Browser recording (alpha)](https://mastra.ai/docs/browser/recording)
|
|
167
169
|
- [BrowserViewer](https://mastra.ai/docs/browser/browser-viewer)
|
|
168
170
|
- [MastraBrowser reference](https://mastra.ai/reference/browser/mastra-browser)
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Browser recording (alpha)
|
|
2
|
+
|
|
3
|
+
Browser recording adds two opt-in tools that let an agent save a browser session as a Motion-JPEG AVI video. The agent can also add short captions while it works.
|
|
4
|
+
|
|
5
|
+
> **Caution:** Browser recording is an alpha feature. The API and output format may change.
|
|
6
|
+
|
|
7
|
+
## When to use browser recording
|
|
8
|
+
|
|
9
|
+
Use browser recording when you need to:
|
|
10
|
+
|
|
11
|
+
- Review what an agent did in a browser
|
|
12
|
+
- Share a short browser automation run with a teammate
|
|
13
|
+
- Debug missed actions, slow page loads, or unexpected navigation
|
|
14
|
+
- Add short captions that explain each major step
|
|
15
|
+
|
|
16
|
+
Recording tools are disabled by default. Enable them only for agents that need to write video files.
|
|
17
|
+
|
|
18
|
+
## Enable recording
|
|
19
|
+
|
|
20
|
+
Pass `recording.outputDir` to `AgentBrowser` or `StagehandBrowser`. The browser provider adds the `browser_record` and `browser_record_caption` tools to the agent's toolset.
|
|
21
|
+
|
|
22
|
+
The following example enables recording for `AgentBrowser`:
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { join } from 'node:path'
|
|
26
|
+
import { AgentBrowser } from '@mastra/agent-browser'
|
|
27
|
+
|
|
28
|
+
export const browser = new AgentBrowser({
|
|
29
|
+
headless: false,
|
|
30
|
+
recording: {
|
|
31
|
+
outputDir: join(process.cwd(), 'browser-recordings'),
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The same option works with `StagehandBrowser`:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { join } from 'node:path'
|
|
40
|
+
import { StagehandBrowser } from '@mastra/stagehand'
|
|
41
|
+
|
|
42
|
+
export const browser = new StagehandBrowser({
|
|
43
|
+
headless: false,
|
|
44
|
+
recording: {
|
|
45
|
+
outputDir: join(process.cwd(), 'browser-recordings'),
|
|
46
|
+
},
|
|
47
|
+
})
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Recording tools
|
|
51
|
+
|
|
52
|
+
Enabling recording adds these tools:
|
|
53
|
+
|
|
54
|
+
| Tool | Description |
|
|
55
|
+
| ------------------------ | ------------------------------------------------------------ |
|
|
56
|
+
| `browser_record` | Starts, stops, or checks the status of a recording. |
|
|
57
|
+
| `browser_record_caption` | Adds a short caption at the current moment in the recording. |
|
|
58
|
+
|
|
59
|
+
`browser_record` accepts an `action` field:
|
|
60
|
+
|
|
61
|
+
- `start`: Start recording the current browser session.
|
|
62
|
+
- `status`: Check whether a recording is active.
|
|
63
|
+
- `stop`: Stop recording and write the `.avi` file.
|
|
64
|
+
|
|
65
|
+
The `outputPath` option for `browser_record` must be an absolute path inside the configured `recording.outputDir`. If you omit it, Mastra creates a file in `outputDir`.
|
|
66
|
+
|
|
67
|
+
## Example agent instructions
|
|
68
|
+
|
|
69
|
+
Tell the agent when to record and when to add captions:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { Agent } from '@mastra/core/agent'
|
|
73
|
+
import { browser } from '../browsers'
|
|
74
|
+
|
|
75
|
+
export const browserAgent = new Agent({
|
|
76
|
+
id: 'browser-agent',
|
|
77
|
+
name: 'Browser Agent',
|
|
78
|
+
model: 'openai/gpt-5.5',
|
|
79
|
+
browser,
|
|
80
|
+
instructions: `Use browser tools to complete the requested task.
|
|
81
|
+
|
|
82
|
+
When the user asks for a recording:
|
|
83
|
+
1. Call browser_record with action="start" before browser work begins.
|
|
84
|
+
2. After each major action, call browser_record_caption with a caption of about six words.
|
|
85
|
+
3. Call browser_record with action="stop" as soon as the task is complete.
|
|
86
|
+
4. Return the saved video path to the user.`,
|
|
87
|
+
})
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Output format and limits
|
|
91
|
+
|
|
92
|
+
Recordings are saved as Motion-JPEG AVI files. This format is encoded in JavaScript and does not require `ffmpeg` or native dependencies.
|
|
93
|
+
|
|
94
|
+
Default limits:
|
|
95
|
+
|
|
96
|
+
- Maximum duration: 30 seconds
|
|
97
|
+
- Hard duration cap: 120 seconds
|
|
98
|
+
- Maximum frame size: 1024 × 720
|
|
99
|
+
- Captions: 80 characters each
|
|
100
|
+
- One active recording per process
|
|
101
|
+
|
|
102
|
+
Use shorter recordings when possible. Long browser sessions produce larger files and are harder to review.
|
|
103
|
+
|
|
104
|
+
## Next steps
|
|
105
|
+
|
|
106
|
+
- [AgentBrowser](https://mastra.ai/docs/browser/agent-browser)
|
|
107
|
+
- [Stagehand](https://mastra.ai/docs/browser/stagehand)
|
|
108
|
+
- [Browser overview](https://mastra.ai/docs/browser/overview)
|