@mastra/mcp-docs-server 1.2.13-alpha.9 → 1.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/agents/overview.md +1 -1
- package/.docs/docs/agents/supervisor-agents.md +2 -2
- package/.docs/docs/agents/using-tools.md +29 -0
- package/.docs/docs/capabilities/channels/imessage.md +181 -0
- package/.docs/docs/capabilities/channels/overview.md +1 -0
- package/.docs/docs/{evals/datasets → datasets}/overview.md +3 -3
- package/.docs/docs/{evals/datasets → datasets}/running-experiments.md +59 -2
- package/.docs/docs/editor/overview.md +201 -206
- package/.docs/docs/evals/evals-with-memory.md +1 -1
- package/.docs/docs/getting-started/develop.md +196 -0
- package/.docs/docs/index.md +78 -1
- package/.docs/docs/mastra-platform/workspaces.md +13 -13
- package/.docs/docs/memory/observational-memory.md +23 -0
- package/.docs/docs/studio/observability.md +4 -0
- package/.docs/docs/studio/overview.md +2 -2
- package/.docs/docs/workspace/search.md +1 -1
- package/.docs/guides/getting-started/quickstart.md +3 -3
- package/.docs/{docs → guides}/rag/chunking-and-embedding.md +1 -1
- package/.docs/{docs → guides}/rag/graph-rag.md +1 -1
- package/.docs/{docs → guides}/rag/overview.md +2 -2
- package/.docs/{docs → guides}/rag/retrieval.md +1 -1
- package/.docs/{docs → guides}/voice/overview.md +4 -4
- package/.docs/{docs → guides}/voice/realtime-voice.md +2 -2
- package/.docs/{docs → guides}/voice/speech-to-speech.md +1 -1
- package/.docs/{docs → guides}/voice/speech-to-text.md +1 -1
- package/.docs/{docs → guides}/voice/text-to-speech.md +2 -2
- package/.docs/models/embeddings.md +63 -65
- package/.docs/models/environment-variables.md +5 -1
- package/.docs/models/gateways/netlify.md +1 -2
- package/.docs/models/gateways/openrouter.md +3 -1
- package/.docs/models/gateways/vercel.md +6 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/alibaba-cn.md +3 -1
- package/.docs/models/providers/alibaba-token-plan-cn.md +27 -25
- package/.docs/models/providers/alibaba-token-plan.md +27 -25
- package/.docs/models/providers/alibaba.md +2 -1
- package/.docs/models/providers/ambient.md +13 -12
- package/.docs/models/providers/baseten.md +3 -1
- package/.docs/models/providers/chutes.md +6 -8
- package/.docs/models/providers/crof.md +2 -1
- package/.docs/models/providers/crossmodel.md +4 -1
- package/.docs/models/providers/deepinfra.md +9 -2
- package/.docs/models/providers/digitalocean.md +34 -27
- package/.docs/models/providers/empiriolabs.md +4 -1
- package/.docs/models/providers/fireworks-ai.md +20 -19
- package/.docs/models/providers/greenpt.md +17 -8
- package/.docs/models/providers/groq.md +20 -20
- package/.docs/models/providers/huggingface.md +3 -1
- package/.docs/models/providers/hyper.md +9 -7
- package/.docs/models/providers/impossibl.md +148 -0
- package/.docs/models/providers/infomaniak.md +83 -0
- package/.docs/models/providers/kilo.md +349 -350
- package/.docs/models/providers/llmgateway.md +3 -1
- package/.docs/models/providers/mistral.md +5 -2
- package/.docs/models/providers/modal.md +5 -4
- package/.docs/models/providers/modelis.md +81 -0
- package/.docs/models/providers/nano-gpt.md +146 -148
- package/.docs/models/providers/neuralwatt.md +2 -1
- package/.docs/models/providers/ofox.md +2 -2
- package/.docs/models/providers/ollama-cloud.md +23 -22
- package/.docs/models/providers/opencode-go.md +3 -2
- package/.docs/models/providers/requesty.md +54 -45
- package/.docs/models/providers/scx.md +74 -0
- package/.docs/models/providers/tensorx.md +97 -0
- package/.docs/models/providers/togetherai.md +2 -1
- package/.docs/models/providers/umans-ai-coding-plan.md +11 -9
- package/.docs/models/providers/umans-ai.md +11 -9
- package/.docs/models/providers/wandb.md +2 -2
- package/.docs/models/providers/zai-coding-plan.md +7 -7
- package/.docs/models/providers/zhipuai-coding-plan.md +9 -9
- package/.docs/models/providers.md +5 -1
- package/.docs/reference/agents/agent.md +1 -1
- package/.docs/reference/agents/generate.md +1 -1
- package/.docs/reference/agents/getVoice.md +1 -1
- package/.docs/{docs/getting-started → reference}/build-with-ai.md +5 -110
- package/.docs/reference/cli/create-mastra.md +2 -0
- package/.docs/reference/cli/mastra.md +66 -1
- package/.docs/reference/client-js/agents.md +1 -1
- package/.docs/reference/configuration.md +2 -2
- package/.docs/reference/core/getEditor.md +1 -1
- package/.docs/reference/core/getVector.md +2 -2
- package/.docs/reference/core/listVectors.md +2 -2
- package/.docs/reference/core/mastra-class.md +1 -1
- package/.docs/reference/datasets/startExperiment.md +6 -0
- package/.docs/reference/datasets/startExperimentAsync.md +4 -0
- package/.docs/reference/editor/browser-provider.md +2 -2
- package/.docs/reference/editor/filesystem-provider.md +1 -1
- package/.docs/reference/editor/mastra-editor.md +31 -18
- package/.docs/reference/editor/prompt-blocks.md +137 -0
- package/.docs/reference/editor/sandbox-provider.md +1 -1
- package/.docs/reference/editor/storage-browser-ref.md +3 -3
- package/.docs/reference/editor/storage-workspace-ref.md +3 -3
- package/.docs/reference/editor/tool-provider.md +44 -10
- package/.docs/reference/editor/tools.md +100 -0
- package/.docs/reference/editor/versioning.md +130 -0
- package/.docs/reference/evals/mastra-scorer.md +68 -8
- package/.docs/reference/file-based-agents/config.md +39 -1
- package/.docs/reference/index.md +3 -4
- package/.docs/reference/memory/observational-memory.md +3 -1
- package/.docs/reference/memory/serialized-memory-config.md +3 -3
- package/.docs/reference/observability/tracing/interfaces.md +3 -1
- package/.docs/reference/processors/token-limiter-processor.md +15 -1
- package/.docs/reference/project-structure.md +1 -1
- package/.docs/reference/rag/database-config.md +1 -1
- package/.docs/reference/storage/composite.md +2 -0
- package/.docs/reference/streaming/agents/stream.md +1 -1
- package/.docs/reference/voice/livekit.md +3 -3
- package/.docs/reference/workspace/platform-filesystem.md +3 -3
- package/.docs/reference/workspace/platform-sandbox.md +5 -5
- package/CHANGELOG.md +23 -0
- package/README.md +1 -1
- package/package.json +6 -6
- package/.docs/docs/agent-builder/access-control.md +0 -99
- package/.docs/docs/agent-builder/browser.md +0 -63
- package/.docs/docs/agent-builder/channels.md +0 -78
- package/.docs/docs/agent-builder/configuration.md +0 -132
- package/.docs/docs/agent-builder/deploying.md +0 -124
- package/.docs/docs/agent-builder/integrations.md +0 -115
- package/.docs/docs/agent-builder/memory.md +0 -69
- package/.docs/docs/agent-builder/model-policy.md +0 -50
- package/.docs/docs/agent-builder/overview.md +0 -114
- package/.docs/docs/agent-builder/skill-registries.md +0 -31
- package/.docs/docs/agent-builder/workspace.md +0 -62
- package/.docs/docs/editor/prompts.md +0 -140
- package/.docs/docs/editor/tools.md +0 -148
- package/.docs/docs/getting-started/file-based-agents.md +0 -121
- package/.docs/docs/what-is-mastra.md +0 -161
- package/.docs/reference/client-js/agent-builder.md +0 -163
- package/.docs/reference/editor/agent-builder/agent-builder-options.md +0 -76
- package/.docs/reference/editor/agent-builder/builder-agent-defaults.md +0 -79
- package/.docs/reference/editor/agent-builder/builder-models.md +0 -66
- /package/.docs/{docs → guides}/getting-started/manual-install.md +0 -0
- /package/.docs/{docs → guides}/rag/vector-databases.md +0 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Prompt blocks
|
|
4
|
+
|
|
5
|
+
Prompt blocks are reusable instruction templates managed by Editor. An agent's instructions can combine inline text, embedded prompt blocks, and references to independently versioned prompt blocks.
|
|
6
|
+
|
|
7
|
+
See [Prompt blocks](https://mastra.ai/docs/editor/overview) for the Studio workflow and common uses.
|
|
8
|
+
|
|
9
|
+
## Block types
|
|
10
|
+
|
|
11
|
+
| Type | Description |
|
|
12
|
+
| ------------------ | ----------------------------------------------------------------- |
|
|
13
|
+
| `text` | Free-form text stored only in the agent version |
|
|
14
|
+
| `prompt_block` | A prompt block embedded in the agent version |
|
|
15
|
+
| `prompt_block_ref` | A reference to an independently stored and versioned prompt block |
|
|
16
|
+
|
|
17
|
+
Referenced blocks resolve at runtime. A missing or unpublished reference is omitted from the final instructions. Resolved nonempty blocks are joined with two newlines.
|
|
18
|
+
|
|
19
|
+
The following example attaches a stored block and inline text to an agent:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { mastra } from '../mastra'
|
|
23
|
+
|
|
24
|
+
const editor = mastra.getEditor()!
|
|
25
|
+
|
|
26
|
+
await editor.agent.update({
|
|
27
|
+
id: 'support-agent',
|
|
28
|
+
instructions: [
|
|
29
|
+
{ type: 'prompt_block_ref', id: 'brand-voice' },
|
|
30
|
+
{ type: 'text', content: 'Answer only questions about Acme products.' },
|
|
31
|
+
],
|
|
32
|
+
})
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Template values
|
|
36
|
+
|
|
37
|
+
Templates resolve values from the request context at runtime.
|
|
38
|
+
|
|
39
|
+
| Syntax | Request context | Output |
|
|
40
|
+
| ------------------------- | ---------------------------- | ------------------ |
|
|
41
|
+
| `{{userName}}` | `{ userName: 'Maya' }` | `Maya` |
|
|
42
|
+
| `{{user.name}}` | `{ user: { name: 'Maya' } }` | `Maya` |
|
|
43
|
+
| `{{task \|\| 'request'}}` | `{}` | `request` |
|
|
44
|
+
| `{{missingValue}}` | `{}` | `{{missingValue}}` |
|
|
45
|
+
|
|
46
|
+
Variable names must begin with a letter or underscore. Fallbacks must be single-quoted or double-quoted strings. Unresolved placeholders without a fallback remain unchanged. Objects and arrays are serialized as JSON. Other values are converted to strings.
|
|
47
|
+
|
|
48
|
+
Pass values through [request context](https://mastra.ai/docs/server/request-context). Editor doesn't read a separate agent `variables` field.
|
|
49
|
+
|
|
50
|
+
## Display conditions
|
|
51
|
+
|
|
52
|
+
A prompt block can include a display condition that controls whether it's included in the final instructions. Each condition has three parts:
|
|
53
|
+
|
|
54
|
+
- **Key**: The request-context field to check, such as `user.role` or `account.plan`.
|
|
55
|
+
- **Operator**: The comparison to make, such as `equals`, `contains`, or `exists`.
|
|
56
|
+
- **Value**: The value to compare against. The `exists` and `not_exists` operators don't need one.
|
|
57
|
+
|
|
58
|
+
For example, the condition `user.role` `equals` `admin` includes the block only when request context contains `{ user: { role: 'admin' } }`.
|
|
59
|
+
|
|
60
|
+
| Operator | Example | The block is included when |
|
|
61
|
+
| ---------------------------------------------- | --------------------------------------------- | --------------------------------------------------------- |
|
|
62
|
+
| `equals` / `not_equals` | `user.role` equals `admin` | The field strictly equals, or doesn't equal, the value |
|
|
63
|
+
| `contains` / `not_contains` | `user.tags` contains `beta` | A string contains the value or an array contains the item |
|
|
64
|
+
| `greater_than` / `less_than` | `order.total` greater than `100` | The numeric field is above or below the value |
|
|
65
|
+
| `greater_than_or_equal` / `less_than_or_equal` | `account.seats` greater than or equal to `10` | The numeric field is at or beyond the value |
|
|
66
|
+
| `in` / `not_in` | `user.region` in `['US', 'CA']` | The field is, or isn't, in the supplied array |
|
|
67
|
+
| `exists` / `not_exists` | `account.plan` exists | The field has, or doesn't have, a non-null value |
|
|
68
|
+
|
|
69
|
+
Groups combine conditions with `AND` or `OR`. For example, this group includes a block for admins on a paid plan:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const rules = {
|
|
73
|
+
operator: 'AND',
|
|
74
|
+
conditions: [
|
|
75
|
+
{
|
|
76
|
+
field: 'user.role',
|
|
77
|
+
operator: 'equals',
|
|
78
|
+
value: 'admin',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
field: 'account.plan',
|
|
82
|
+
operator: 'in',
|
|
83
|
+
value: ['pro', 'enterprise'],
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Dot paths are supported. An empty group evaluates to `true`, and an unknown operator evaluates to `false`. The storage type supports up to three nested group levels.
|
|
90
|
+
|
|
91
|
+
Blocks without conditions are always included.
|
|
92
|
+
|
|
93
|
+
## Programmatic API
|
|
94
|
+
|
|
95
|
+
Access prompt blocks through `mastra.getEditor().prompt`. See the [`prompt` namespace](https://mastra.ai/reference/editor/mastra-editor) for complete method signatures.
|
|
96
|
+
|
|
97
|
+
Create a prompt block:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { mastra } from '../mastra'
|
|
101
|
+
|
|
102
|
+
const editor = mastra.getEditor()!
|
|
103
|
+
|
|
104
|
+
await editor.prompt.create({
|
|
105
|
+
id: 'brand-voice',
|
|
106
|
+
name: 'Brand voice',
|
|
107
|
+
description: 'Acme tone and style guidelines',
|
|
108
|
+
content: 'Write in a friendly, concise tone. Address the user as {{userName || "there"}}.',
|
|
109
|
+
})
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Update an existing block:
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
await editor.prompt.update({
|
|
116
|
+
id: 'brand-voice',
|
|
117
|
+
content: 'Write in a friendly, concise tone. Greet the user by name when available.',
|
|
118
|
+
})
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`update()` creates a new draft when the content changes. Use `list()` to paginate through stored blocks, `getById()` to fetch one block, and `preview(blocks, context)` to resolve templates and conditions with draft references.
|
|
122
|
+
|
|
123
|
+
## REST API
|
|
124
|
+
|
|
125
|
+
The default Mastra server prefix is `/api`. A custom server prefix changes the paths below.
|
|
126
|
+
|
|
127
|
+
| Method | Path | Description |
|
|
128
|
+
| -------- | ------------------------------------------------ | ---------------------------- |
|
|
129
|
+
| `GET` | `/api/stored/prompt-blocks` | List stored prompt blocks |
|
|
130
|
+
| `POST` | `/api/stored/prompt-blocks` | Create a stored prompt block |
|
|
131
|
+
| `GET` | `/api/stored/prompt-blocks/:storedPromptBlockId` | Get a stored prompt block |
|
|
132
|
+
| `PATCH` | `/api/stored/prompt-blocks/:storedPromptBlockId` | Update a stored prompt block |
|
|
133
|
+
| `DELETE` | `/api/stored/prompt-blocks/:storedPromptBlockId` | Delete a stored prompt block |
|
|
134
|
+
|
|
135
|
+
## Version resolution
|
|
136
|
+
|
|
137
|
+
Runtime references resolve the active published block. Editor previews resolve the latest draft. See [Editor versioning](https://mastra.ai/docs/editor/overview) for the shared draft, publish, and restore lifecycle.
|
|
@@ -57,7 +57,7 @@ Once registered, admins can reference the provider from an inline workspace conf
|
|
|
57
57
|
|
|
58
58
|
## Related
|
|
59
59
|
|
|
60
|
-
- [Workspace](https://mastra.ai/
|
|
60
|
+
- [Workspace](https://agent-builder.mastra.ai/workspace): Concept and worked examples.
|
|
61
61
|
- [StorageWorkspaceRef](https://mastra.ai/reference/editor/storage-workspace-ref): Stored configuration consumed by `createSandbox`.
|
|
62
62
|
- [FilesystemProvider](https://mastra.ai/reference/editor/filesystem-provider): Sibling provider for file access.
|
|
63
63
|
- [MastraEditor class](https://mastra.ai/reference/editor/mastra-editor): Provider registry.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
`StorageBrowserRef` is the inline browser configuration attached to a stored agent. The `provider` id is resolved at hydration time against the [`BrowserProvider`](https://mastra.ai/reference/editor/browser-provider) registered on [`MastraEditor.browsers`](https://mastra.ai/reference/editor/mastra-editor).
|
|
6
6
|
|
|
7
|
-
It's the type used by [`BuilderAgentDefaults.browser`](https://mastra.ai/reference/
|
|
7
|
+
It's the type used by [`BuilderAgentDefaults.browser`](https://agent-builder.mastra.ai/reference/builder-agent-defaults) and by stored agent records.
|
|
8
8
|
|
|
9
9
|
## Usage example
|
|
10
10
|
|
|
@@ -76,7 +76,7 @@ The shape embedded under `config`. Defined in `@mastra/core/storage`.
|
|
|
76
76
|
|
|
77
77
|
## Related
|
|
78
78
|
|
|
79
|
-
- [Browser](https://mastra.ai/
|
|
79
|
+
- [Browser](https://agent-builder.mastra.ai/browser): Concept and worked examples.
|
|
80
80
|
- [BrowserProvider](https://mastra.ai/reference/editor/browser-provider): Implementer-facing provider interface.
|
|
81
|
-
- [BuilderAgentDefaults](https://mastra.ai/reference/
|
|
81
|
+
- [BuilderAgentDefaults](https://agent-builder.mastra.ai/reference/builder-agent-defaults): Where this type is pinned as the Builder default.
|
|
82
82
|
- [StorageWorkspaceRef](https://mastra.ai/reference/editor/storage-workspace-ref): Sibling reference type for workspace configuration.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
`StorageWorkspaceRef` is the discriminated union used to attach a workspace to a stored agent. It either points at a workspace registered on the Mastra runtime by ID, or embeds a workspace snapshot inline.
|
|
6
6
|
|
|
7
|
-
It's the type used by [`BuilderAgentDefaults.workspace`](https://mastra.ai/reference/
|
|
7
|
+
It's the type used by [`BuilderAgentDefaults.workspace`](https://agent-builder.mastra.ai/reference/builder-agent-defaults) and by stored agent records.
|
|
8
8
|
|
|
9
9
|
## Usage example
|
|
10
10
|
|
|
@@ -89,7 +89,7 @@ The shape embedded under `{ type: 'inline', config }`. Defined in `@mastra/core/
|
|
|
89
89
|
|
|
90
90
|
## Related
|
|
91
91
|
|
|
92
|
-
- [Workspace](https://mastra.ai/
|
|
93
|
-
- [BuilderAgentDefaults](https://mastra.ai/reference/
|
|
92
|
+
- [Workspace](https://agent-builder.mastra.ai/workspace): Concept and worked examples.
|
|
93
|
+
- [BuilderAgentDefaults](https://agent-builder.mastra.ai/reference/builder-agent-defaults): Where this type is pinned as the Builder default.
|
|
94
94
|
- [MastraEditor class](https://mastra.ai/reference/editor/mastra-editor): Registers filesystem and sandbox providers.
|
|
95
95
|
- [StorageBrowserRef](https://mastra.ai/reference/editor/storage-browser-ref): Sibling reference type for browser configuration.
|
|
@@ -4,19 +4,47 @@
|
|
|
4
4
|
|
|
5
5
|
The `ToolProvider` interface defines how the editor discovers and resolves integration tools from external platforms. Mastra includes two built-in implementations: `ComposioToolProvider` and `ArcadeToolProvider`.
|
|
6
6
|
|
|
7
|
-
See [
|
|
7
|
+
See [Editor tools](https://mastra.ai/docs/editor/overview) for provider setup and the Studio workflow. See [tool configuration](https://mastra.ai/reference/editor/tools) for stored selections and resolution behavior.
|
|
8
8
|
|
|
9
9
|
## ToolProvider interface
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Providers expose metadata and the legacy discovery and resolution methods. Agent Builder integrations can also implement the optional VNext catalog, connection, authorization, and health methods.
|
|
12
12
|
|
|
13
|
-
**
|
|
13
|
+
**info** (`ToolProviderInfo`): Provider ID, name, and description.
|
|
14
14
|
|
|
15
|
-
**
|
|
15
|
+
**displayName** (`string`): Optional name shown in the tool picker. Defaults to info.name.
|
|
16
16
|
|
|
17
|
-
**
|
|
17
|
+
**capabilities** (`ToolProviderCapabilities`): Static connection and revocation capabilities. Required for VNext providers.
|
|
18
18
|
|
|
19
|
-
**
|
|
19
|
+
**defaultScope** (`'per-author' | 'caller-supplied'`): Default connection identity scope. Defaults to 'per-author' when omitted.
|
|
20
|
+
|
|
21
|
+
**listToolkits()** (`() => Promise<ToolProviderListResult<ToolProviderToolkit>>`): Lists available toolkits through the legacy interface.
|
|
22
|
+
|
|
23
|
+
**listTools(params?)** (`(params?: ListToolProviderToolsOptions) => Promise<ToolProviderListResult<ToolProviderToolInfo>>`): Lists tools with optional toolkit, search, and pagination filters.
|
|
24
|
+
|
|
25
|
+
**getToolSchema(slug)** (`(slug: string) => Promise<Record<string, unknown> | null>`): Returns a tool input schema through the legacy interface.
|
|
26
|
+
|
|
27
|
+
**resolveTools(slugs, configs?, options?)** (`(slugs: string[], configs?: Record<string, StorageToolConfig>, options?: ResolveToolProviderToolsOptions) => Promise<Record<string, ToolAction>>`): Resolves legacy tool selections into executable Mastra tools.
|
|
28
|
+
|
|
29
|
+
**listToolkitsVNext()** (`() => Promise<ListToolkitsResult>`): Lists allowed toolkits for Agent Builder and Editor.
|
|
30
|
+
|
|
31
|
+
**listToolsVNext(options?)** (`(options?: ListToolsOpts) => Promise<ListToolsResult>`): Lists allowed tools with toolkit, search, and pagination options.
|
|
32
|
+
|
|
33
|
+
**resolveToolsVNext(options)** (`(options: ResolveToolsOpts) => Promise<Record<string, ToolAction>>`): Resolves tools for one set of slugs and one authorized connection.
|
|
34
|
+
|
|
35
|
+
**authorize(options)** (`(options: AuthorizeOpts) => Promise<{ url: string; authId: string }>`): Starts an authorization flow.
|
|
36
|
+
|
|
37
|
+
**listConnectionFields(options)** (`(options: { toolkit: string }) => Promise<ConnectionField[]>`): Lists provider-specific values required to authorize a toolkit.
|
|
38
|
+
|
|
39
|
+
**getAuthStatus(authId)** (`(authId: string) => Promise<AuthFlowStatus>`): Returns the state of an authorization flow.
|
|
40
|
+
|
|
41
|
+
**getConnectionStatus(options)** (`(options: { items: Array<{ connectionId: string; toolkit: string }> }) => Promise<Record<string, { connected: boolean }>>`): Checks whether a batch of connections is still active.
|
|
42
|
+
|
|
43
|
+
**listConnections(options)** (`(options: ListConnectionsOpts) => Promise<ListConnectionsResult>`): Lists existing provider connections for a user and toolkit.
|
|
44
|
+
|
|
45
|
+
**getHealth()** (`() => Promise<ToolProviderHealth>`): Returns provider configuration and reachability health.
|
|
46
|
+
|
|
47
|
+
**revokeConnection(connectionId)** (`(connectionId: string) => Promise<void>`): Revokes a provider connection.
|
|
20
48
|
|
|
21
49
|
***
|
|
22
50
|
|
|
@@ -28,7 +56,7 @@ Connects to [Composio](https://composio.dev) for access to hundreds of integrati
|
|
|
28
56
|
|
|
29
57
|
```typescript
|
|
30
58
|
import { MastraEditor } from '@mastra/editor'
|
|
31
|
-
import { ComposioToolProvider } from '@mastra/editor/
|
|
59
|
+
import { ComposioToolProvider } from '@mastra/editor/composio'
|
|
32
60
|
|
|
33
61
|
const editor = new MastraEditor({
|
|
34
62
|
toolProviders: {
|
|
@@ -43,13 +71,19 @@ const editor = new MastraEditor({
|
|
|
43
71
|
|
|
44
72
|
**apiKey** (`string`): Your Composio API key.
|
|
45
73
|
|
|
74
|
+
**allowedToolkits** (`readonly string[]`): Toolkit slug allowlist. Supports exact matches and suffix wildcards.
|
|
75
|
+
|
|
76
|
+
**allowedTools** (`Readonly<Record<string, readonly string[]>>`): Per-toolkit tool slug allowlists. Supports exact matches and prefix wildcards.
|
|
77
|
+
|
|
78
|
+
**defaultScope** (`'per-author' | 'caller-supplied'`): Connection identity scope. Defaults to per-author. (Default: `'per-author'`)
|
|
79
|
+
|
|
46
80
|
### Tool slugs
|
|
47
81
|
|
|
48
82
|
Composio tools use uppercase slug format: `GITHUB_CREATE_ISSUE`, `SLACK_SEND_MESSAGE`.
|
|
49
83
|
|
|
50
84
|
### Authentication
|
|
51
85
|
|
|
52
|
-
|
|
86
|
+
Connections use per-author scope by default. Set `defaultScope: 'caller-supplied'` to bucket authorization by the caller identity resolved from request context.
|
|
53
87
|
|
|
54
88
|
***
|
|
55
89
|
|
|
@@ -61,7 +95,7 @@ Connects to [Arcade](https://arcade.dev) for a curated tool catalog with built-i
|
|
|
61
95
|
|
|
62
96
|
```typescript
|
|
63
97
|
import { MastraEditor } from '@mastra/editor'
|
|
64
|
-
import { ArcadeToolProvider } from '@mastra/editor/
|
|
98
|
+
import { ArcadeToolProvider } from '@mastra/editor/arcade'
|
|
65
99
|
|
|
66
100
|
const editor = new MastraEditor({
|
|
67
101
|
toolProviders: {
|
|
@@ -84,4 +118,4 @@ Arcade tools use `Toolkit.ToolName` format: `Github.GetRepository`, `Slack.SendM
|
|
|
84
118
|
|
|
85
119
|
### Authentication
|
|
86
120
|
|
|
87
|
-
|
|
121
|
+
The legacy Arcade resolver uses `resourceId` from request context when available. It otherwise falls back to the supplied `userId`, then to a shared `default` identity. Use `default` only for intentionally shared integrations. In tenant-isolated deployments, provide a trusted, stable `resourceId` or explicit `userId`. Omitting both doesn't isolate callers.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Tool configuration
|
|
4
|
+
|
|
5
|
+
Editor stores tool selections as part of an agent version. A stored configuration can add registered tools, tools from integration providers, and tools from Model Context Protocol (MCP) clients.
|
|
6
|
+
|
|
7
|
+
See [Editor tools](https://mastra.ai/docs/editor/overview) for the Studio workflow and common uses.
|
|
8
|
+
|
|
9
|
+
## Tool sources
|
|
10
|
+
|
|
11
|
+
| Source | Description |
|
|
12
|
+
| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
|
|
13
|
+
| Registered tools | Tools registered in the Mastra runtime tool registry |
|
|
14
|
+
| MCP clients | Tools exposed by stored local or remote MCP server configurations |
|
|
15
|
+
| Integration tools | Tools resolved by legacy integration-provider configuration |
|
|
16
|
+
| [Tool providers](https://mastra.ai/reference/editor/tool-provider) | Tools resolved by providers registered on `MastraEditor`, such as Composio or Arcade |
|
|
17
|
+
|
|
18
|
+
Code-defined agents keep their existing tools. The [`editor` override setting](https://mastra.ai/reference/agents/agent) controls whether Editor can add and remove tools or only change descriptions.
|
|
19
|
+
|
|
20
|
+
## Description overrides
|
|
21
|
+
|
|
22
|
+
Each selected tool can store an agent-specific description. The description changes what the model sees without modifying the original tool definition.
|
|
23
|
+
|
|
24
|
+
In description-only mode, Editor applies overrides only to tools that already exist on the code-defined agent. For MCP tools, an agent-level description takes priority over the description stored on the MCP client.
|
|
25
|
+
|
|
26
|
+
If two sources resolve the same tool ID, the later source replaces the complete earlier tool, including its description. See [Resolution order](#resolution-order).
|
|
27
|
+
|
|
28
|
+
## Conditional tool sets
|
|
29
|
+
|
|
30
|
+
Editor can store conditional variants for the `tools`, `mcpClients`, `integrationTools`, and `toolProviders` fields. At runtime, matching variants are shallow-merged based on request-context values.
|
|
31
|
+
|
|
32
|
+
The rule language uses the same operators and nesting behavior as [prompt block display conditions](https://mastra.ai/reference/editor/prompt-blocks).
|
|
33
|
+
|
|
34
|
+
Conditions apply to a tool field variant or MCP client reference. Per-tool `rules` values in stored tool entries aren't evaluated by the current Editor resolver.
|
|
35
|
+
|
|
36
|
+
## Stored MCP clients
|
|
37
|
+
|
|
38
|
+
The `editor.mcp` namespace manages reusable MCP client configurations. See the [`mcp` namespace](https://mastra.ai/reference/editor/mastra-editor) for CRUD method signatures.
|
|
39
|
+
|
|
40
|
+
`@mastra/mcp` is an optional peer dependency of `@mastra/editor`. Install it before configuring stored MCP clients so Editor can load their tools at runtime:
|
|
41
|
+
|
|
42
|
+
**npm**:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install @mastra/mcp
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**pnpm**:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pnpm add @mastra/mcp
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Yarn**:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
yarn add @mastra/mcp
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Bun**:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
bun add @mastra/mcp
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Transports
|
|
67
|
+
|
|
68
|
+
| Transport | Stored configuration |
|
|
69
|
+
| --------- | ---------------------------------------------------- |
|
|
70
|
+
| `stdio` | `command` with optional `args`, `env`, and `timeout` |
|
|
71
|
+
| HTTP | `url` with optional `timeout` |
|
|
72
|
+
|
|
73
|
+
Stored HTTP definitions don't accept arbitrary headers. When the reserved `mastra__authToken` value is present in request context, Editor forwards it as an `Authorization: Bearer` header.
|
|
74
|
+
|
|
75
|
+
### Filtering
|
|
76
|
+
|
|
77
|
+
MCP tools can be allowlisted at two levels:
|
|
78
|
+
|
|
79
|
+
1. **Server level**: The stored server's `tools` map limits tools for every agent that uses the client.
|
|
80
|
+
2. **Agent level**: The agent's MCP client reference limits the remaining tools for that agent.
|
|
81
|
+
|
|
82
|
+
Agent-level tool names can use namespaced or bare names. An explicit empty `tools` map selects all tools. With the current resolver, omitting `tools` from an agent-level MCP reference selects none.
|
|
83
|
+
|
|
84
|
+
### Namespacing
|
|
85
|
+
|
|
86
|
+
MCP tools use `serverName_toolName` IDs to avoid conflicts. A `search` tool from the `docs` server becomes `docs_search`.
|
|
87
|
+
|
|
88
|
+
## Resolution order
|
|
89
|
+
|
|
90
|
+
Editor merges tool records in the following order. Later records replace earlier records with the same ID.
|
|
91
|
+
|
|
92
|
+
1. Code-defined tools
|
|
93
|
+
2. Registered stored tools
|
|
94
|
+
3. MCP tools
|
|
95
|
+
4. Legacy integration tools
|
|
96
|
+
5. V1 tool-provider tools
|
|
97
|
+
|
|
98
|
+
Standalone stored agents use the same order without code-defined tools. Static code-agent overrides stop after legacy integration tools.
|
|
99
|
+
|
|
100
|
+
Use unique tool IDs across sources when possible. A collision replaces the complete earlier tool rather than merging its fields.
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Versioning
|
|
4
|
+
|
|
5
|
+
Editor versions stored agents and prompt blocks. Database-backed resources use draft and publish operations. Code-backed agent overrides use deterministic files and Git history.
|
|
6
|
+
|
|
7
|
+
See [Editor versioning](https://mastra.ai/docs/editor/overview) for release and experimentation patterns.
|
|
8
|
+
|
|
9
|
+
## Database lifecycle
|
|
10
|
+
|
|
11
|
+
The resource record stores an `activeVersionId`. Individual snapshots don't store a lifecycle status.
|
|
12
|
+
|
|
13
|
+
| Term | Meaning |
|
|
14
|
+
| ---------- | -------------------------------------------------------------------------------------------- |
|
|
15
|
+
| Latest | The most recently created configuration snapshot |
|
|
16
|
+
| Published | The snapshot selected by `activeVersionId` |
|
|
17
|
+
| Draft | The latest snapshot when it differs from `activeVersionId`, or when no active version exists |
|
|
18
|
+
| Historical | Any other retained snapshot |
|
|
19
|
+
|
|
20
|
+
Saving changed snapshot fields creates a new latest version. Saving identical snapshot fields or changing metadata alone doesn't create a version.
|
|
21
|
+
|
|
22
|
+
If an active version exists, creating a draft doesn't change the version handling published requests. Publishing updates `activeVersionId`. Restoring a historical version copies its configuration into a new inactive draft.
|
|
23
|
+
|
|
24
|
+
The direct namespace methods and REST APIs differ in one important way. `editor.prompt.update()` creates an inactive draft. `editor.agent.update()` creates a version and immediately assigns it to `activeVersionId`. The stored-agent REST `PATCH` route creates an inactive draft unless `autoPublish` is enabled.
|
|
25
|
+
|
|
26
|
+
When a generic stored resource has no active version, published resolution can fall back to the latest snapshot. For a code-defined agent override, requesting `status: 'published'` without an active override returns the original code agent.
|
|
27
|
+
|
|
28
|
+
## Code source
|
|
29
|
+
|
|
30
|
+
With `source: 'code'`, active agent overrides are serialized as deterministic JSON under `<codePath>/agents/<encodedAgentId>.json`. The default `codePath` is `./mastra/editor`.
|
|
31
|
+
|
|
32
|
+
The initial agent is published to create the file. Later server updates create a draft by default and write the file when that version becomes active. Git versions are read-only in Studio and use the commit message as their change message. The default history scan reads up to 50 recent commits and skips consecutive commits whose parsed JSON snapshot is unchanged.
|
|
33
|
+
|
|
34
|
+
See [`MastraEditor`](https://mastra.ai/reference/editor/mastra-editor) for source options.
|
|
35
|
+
|
|
36
|
+
## Select an agent version
|
|
37
|
+
|
|
38
|
+
Calling [`mastra.getAgentById()`](https://mastra.ai/reference/core/getAgentById) without a selector returns the registered code-defined agent. Pass `status` or `versionId` to apply a stored override. See [Select a version](https://mastra.ai/docs/editor/overview) for a TypeScript example.
|
|
39
|
+
|
|
40
|
+
With the default server prefix, pass selectors as query parameters under `/api`:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Published version
|
|
44
|
+
curl http://localhost:4111/api/agents/support-agent
|
|
45
|
+
|
|
46
|
+
# Latest draft
|
|
47
|
+
curl http://localhost:4111/api/agents/support-agent?status=draft
|
|
48
|
+
|
|
49
|
+
# Exact version
|
|
50
|
+
curl http://localhost:4111/api/agents/support-agent?versionId=abc-123
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
See the [Client SDK agents reference](https://mastra.ai/reference/client-js/agents) for Client SDK and React SDK selectors.
|
|
54
|
+
|
|
55
|
+
## Sub-agent versioning
|
|
56
|
+
|
|
57
|
+
Version overrides propagate through [supervisor-agent delegation](https://mastra.ai/docs/agents/supervisor-agents) in request context. Define selectors at three levels:
|
|
58
|
+
|
|
59
|
+
1. `Mastra` instance `versions`: Defaults for every invocation
|
|
60
|
+
2. Server request-body `versions`: Per-request values added to request context
|
|
61
|
+
3. Direct `generate()` or `stream()` `versions`: Per-invocation values
|
|
62
|
+
|
|
63
|
+
Entries merge by agent ID. For the same ID, precedence is **direct invocation > request body or existing request context > Mastra instance default**.
|
|
64
|
+
|
|
65
|
+
Set defaults on the Mastra instance:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { Mastra } from '@mastra/core'
|
|
69
|
+
import { MastraEditor } from '@mastra/editor'
|
|
70
|
+
|
|
71
|
+
export const mastra = new Mastra({
|
|
72
|
+
agents: { supervisor, researchAgent, writerAgent },
|
|
73
|
+
editor: new MastraEditor(),
|
|
74
|
+
versions: {
|
|
75
|
+
agents: {
|
|
76
|
+
'research-agent': { status: 'published' },
|
|
77
|
+
'writer-agent': { versionId: 'abc-123' },
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
})
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Override one sub-agent for a direct invocation:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
const result = await supervisor.generate('Research and write about AI safety', {
|
|
87
|
+
versions: {
|
|
88
|
+
agents: {
|
|
89
|
+
'research-agent': { status: 'draft' },
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
})
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Or pass selectors in the server request body:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
curl -X POST http://localhost:4111/api/agents/supervisor/generate \
|
|
99
|
+
-H "Content-Type: application/json" \
|
|
100
|
+
-d '{
|
|
101
|
+
"messages": [{ "role": "user", "content": "Research AI safety" }],
|
|
102
|
+
"versions": {
|
|
103
|
+
"agents": {
|
|
104
|
+
"research-agent": { "status": "draft" }
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}'
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
If Editor isn't configured or a version can't be resolved, Mastra logs a warning and uses the code-defined sub-agent.
|
|
111
|
+
|
|
112
|
+
## Stored-agent REST API
|
|
113
|
+
|
|
114
|
+
The default Mastra server prefix is `/api`. A custom server prefix changes the paths below.
|
|
115
|
+
|
|
116
|
+
| Method | Path | Description |
|
|
117
|
+
| -------- | ---------------------------------------------- | -------------------------------------------------------------------- |
|
|
118
|
+
| `GET` | `/api/stored/agents` | List stored agents |
|
|
119
|
+
| `POST` | `/api/stored/agents` | Create a stored agent |
|
|
120
|
+
| `GET` | `/api/stored/agents/:storedAgentId` | Get a stored agent |
|
|
121
|
+
| `PATCH` | `/api/stored/agents/:storedAgentId` | Update a stored agent |
|
|
122
|
+
| `DELETE` | `/api/stored/agents/:storedAgentId` | Delete a stored agent |
|
|
123
|
+
| `GET` | `/api/stored/agents/:storedAgentId/dependents` | List readable dependents and count hidden cross-workspace references |
|
|
124
|
+
| `POST` | `/api/stored/agents/:storedAgentId/export` | Export the allowed override fields as deterministic JSON |
|
|
125
|
+
|
|
126
|
+
The dependents response lists caller-readable agents by `id` and `name`. Its `hiddenCount` field counts cross-workspace references that the caller can't read, but only when the target agent is public.
|
|
127
|
+
|
|
128
|
+
Version-management routes are nested under `/api/stored/agents/:storedAgentId/versions`. See [version management](https://mastra.ai/reference/client-js/agents) for operations and Client SDK methods.
|
|
129
|
+
|
|
130
|
+
The Client SDK exposes `listStoredAgents()`, `createStoredAgent()`, and `getStoredAgent()`. The resource returned by `getStoredAgent(id)` includes methods for updates, deletion, dependents, export, and version management.
|
|
@@ -76,16 +76,19 @@ const result = await scorer.run({
|
|
|
76
76
|
The optional `judge` record contains details about the judge model calls made by prompt-based scorer steps. Its known keys are `preprocess`, `analyze`, `generateScore`, and `generateReason`. Each key contains an ordered `executions` array.
|
|
77
77
|
|
|
78
78
|
```typescript
|
|
79
|
-
interface
|
|
80
|
-
status: 'success'
|
|
79
|
+
interface ScorerJudgeExecutionBase {
|
|
81
80
|
prompt: string
|
|
82
|
-
output: JSONValue
|
|
83
81
|
judgeModelId: string
|
|
84
82
|
judgeProvider?: string
|
|
85
|
-
usage: ScorerJudgeUsage
|
|
86
83
|
attemptCount: number
|
|
87
84
|
modelCallCount: number
|
|
88
85
|
durationMs: number
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface ScorerJudgeExecutionSuccess extends ScorerJudgeExecutionBase {
|
|
89
|
+
status: 'success'
|
|
90
|
+
output: JSONValue
|
|
91
|
+
usage: ScorerJudgeUsage
|
|
89
92
|
cost?: {
|
|
90
93
|
amount: number
|
|
91
94
|
unit: string
|
|
@@ -93,7 +96,20 @@ interface ScorerJudgeExecutionSuccess {
|
|
|
93
96
|
}
|
|
94
97
|
}
|
|
95
98
|
|
|
96
|
-
|
|
99
|
+
interface ScorerJudgeExecutionFailure extends ScorerJudgeExecutionBase {
|
|
100
|
+
status: 'failed'
|
|
101
|
+
output?: JSONValue
|
|
102
|
+
rawOutput?: string
|
|
103
|
+
usage?: ScorerJudgeUsage
|
|
104
|
+
finishReason?: string
|
|
105
|
+
error: {
|
|
106
|
+
name: string
|
|
107
|
+
message: string
|
|
108
|
+
code?: string
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
type ScorerJudgeExecution = ScorerJudgeExecutionSuccess | ScorerJudgeExecutionFailure
|
|
97
113
|
|
|
98
114
|
interface ScorerJudgeUsage {
|
|
99
115
|
inputTokens?: number
|
|
@@ -119,18 +135,62 @@ const execution = result.judge?.generateScore?.executions[0]
|
|
|
119
135
|
|
|
120
136
|
console.log(execution?.status)
|
|
121
137
|
console.log(execution?.judgeModelId)
|
|
122
|
-
console.log(execution?.usage
|
|
138
|
+
console.log(execution?.usage?.totalTokens)
|
|
123
139
|
console.log(execution?.durationMs)
|
|
124
140
|
```
|
|
125
141
|
|
|
126
|
-
The `status` value describes the outcome of the logical prompt-step execution, not the quality of the evaluated response. A structured-output fallback that eventually succeeds creates one `success` execution with an `attemptCount` greater than one.
|
|
142
|
+
The `status` value describes the outcome of the logical prompt-step execution, not the quality of the evaluated response. A structured-output fallback that eventually succeeds creates one `success` execution with an `attemptCount` greater than one. Exhausted attempts create one `failed` execution.
|
|
143
|
+
|
|
144
|
+
Successful executions require validated `output` and normalized `usage`. Failed executions require an `error` summary and include only the evidence the runtime received. A failed execution includes `output` only when the output was validated before a later callback or orchestration failure. Mastra doesn't parse `rawOutput` to create `output`.
|
|
127
145
|
|
|
128
146
|
`attemptCount` counts judge invocations, including a structured-output fallback. `modelCallCount` counts the completed model steps across those attempts. `durationMs` covers the full prompt-step execution.
|
|
129
147
|
|
|
130
|
-
Function steps don't create `judge` entries. Usage in this record belongs to the scorer's judge model, not the agent or workflow being evaluated. The optional `cost` field is present only
|
|
148
|
+
Function steps don't create `judge` entries. Usage in this record belongs to the scorer's judge model, not the agent or workflow being evaluated. Filter by `status` when aggregating successful executions. Include both statuses when aggregating all completed provider usage. The optional `cost` field is present only on successful executions that directly report an authoritative cost, source, and unit.
|
|
131
149
|
|
|
132
150
|
Use Mastra metrics to query aggregate usage, latency, and estimated cost across scorer runs. The `judge` record describes one scorer run and doesn't query metrics or traces.
|
|
133
151
|
|
|
152
|
+
### Failed runs
|
|
153
|
+
|
|
154
|
+
A failed scorer stage still rejects the `.run()` promise. Catch `ScorerRunError` to inspect completed stages and any results they produced:
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
import { ScorerRunError } from '@mastra/core/evals'
|
|
158
|
+
|
|
159
|
+
try {
|
|
160
|
+
const result = await scorer.run({ input, output })
|
|
161
|
+
console.log(result.score)
|
|
162
|
+
} catch (error) {
|
|
163
|
+
if (error instanceof ScorerRunError) {
|
|
164
|
+
console.log(error.failedStep)
|
|
165
|
+
console.log(error.completedSteps)
|
|
166
|
+
console.log(error.result?.score)
|
|
167
|
+
|
|
168
|
+
const failedExecution = error.result?.judge?.[error.failedStep]?.executions.find(
|
|
169
|
+
execution => execution.status === 'failed',
|
|
170
|
+
)
|
|
171
|
+
console.log(failedExecution?.error)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
throw error
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
`ScorerRunError` exposes these properties:
|
|
179
|
+
|
|
180
|
+
**failedStep** (`ScorerStepName`): The scorer stage that failed.
|
|
181
|
+
|
|
182
|
+
**completedSteps** (`ScorerStepName[]`): The scorer stages that completed before the failure, in execution order.
|
|
183
|
+
|
|
184
|
+
**result** (`ScorerRunResultSnapshot | undefined`): Outputs from completed scorer stages and judge execution evidence from attempted prompt stages. This property is omitted when neither is available.
|
|
185
|
+
|
|
186
|
+
The `result` snapshot contains completed stage outputs and judge execution evidence. For example, if `generateReason` fails after `generateScore` returns `0`, `error.result.score` is `0`, the `generateScore` execution has `status: 'success'`, and the `generateReason` execution has `status: 'failed'`. The run remains failed.
|
|
187
|
+
|
|
188
|
+
A prompt failure can create `error.result` with only run identity, input, and a failed `judge` entry. A function stage that fails before producing a scorer field doesn't create a result.
|
|
189
|
+
|
|
190
|
+
`JSON.stringify(error)` uses the standard `MastraError` serialization and omits `result`, including successful and failed judge evidence. Read `result` explicitly when you need scorer artifacts or raw failed output.
|
|
191
|
+
|
|
192
|
+
An in-memory experiment result can keep a completed score or reason from a failed scorer along with `error`, `failedStep`, and `completedSteps`. The scorer is still treated as failed, and a recovered score isn't written to legacy successful-score storage.
|
|
193
|
+
|
|
134
194
|
## Step execution flow
|
|
135
195
|
|
|
136
196
|
When you call `.run()`, the MastraScorer executes the defined steps in this order:
|