@mastra/mcp-docs-server 1.2.13-alpha.0 → 1.2.13-alpha.11

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.
Files changed (131) hide show
  1. package/.docs/docs/agents/agent-approval.md +72 -0
  2. package/.docs/docs/agents/overview.md +1 -1
  3. package/.docs/docs/agents/supervisor-agents.md +2 -2
  4. package/.docs/docs/agents/using-tools.md +61 -33
  5. package/.docs/docs/{evals/datasets → datasets}/overview.md +3 -3
  6. package/.docs/docs/{evals/datasets → datasets}/running-experiments.md +57 -9
  7. package/.docs/docs/deployment/workers.md +14 -14
  8. package/.docs/docs/editor/overview.md +201 -206
  9. package/.docs/docs/evals/evals-with-memory.md +1 -1
  10. package/.docs/docs/getting-started/develop.md +196 -0
  11. package/.docs/docs/index.md +78 -1
  12. package/.docs/docs/long-running-agents/durable-agents.md +2 -2
  13. package/.docs/docs/mastra-platform/overview.md +1 -1
  14. package/.docs/docs/mastra-platform/workspaces.md +152 -0
  15. package/.docs/docs/memory/observational-memory.md +53 -13
  16. package/.docs/docs/memory/overview.md +14 -0
  17. package/.docs/docs/server/auth/workers.md +7 -5
  18. package/.docs/docs/server/mastra-client.md +60 -0
  19. package/.docs/docs/server/pubsub.md +2 -2
  20. package/.docs/docs/studio/observability.md +4 -0
  21. package/.docs/docs/studio/overview.md +2 -2
  22. package/.docs/docs/workflows/overview.md +1 -1
  23. package/.docs/docs/workflows/scheduled-workflows.md +1 -0
  24. package/.docs/docs/workspace/search.md +1 -1
  25. package/.docs/guides/deployment/kubernetes.md +2 -0
  26. package/.docs/guides/deployment/mastra-workers.md +350 -6
  27. package/.docs/guides/deployment/vercel.md +2 -0
  28. package/.docs/guides/getting-started/quickstart.md +3 -3
  29. package/.docs/{docs → guides}/rag/chunking-and-embedding.md +1 -1
  30. package/.docs/{docs → guides}/rag/graph-rag.md +1 -1
  31. package/.docs/{docs → guides}/rag/overview.md +2 -2
  32. package/.docs/{docs → guides}/rag/retrieval.md +1 -1
  33. package/.docs/{docs → guides}/voice/overview.md +4 -4
  34. package/.docs/{docs → guides}/voice/realtime-voice.md +2 -2
  35. package/.docs/{docs → guides}/voice/speech-to-speech.md +1 -1
  36. package/.docs/{docs → guides}/voice/speech-to-text.md +1 -1
  37. package/.docs/{docs → guides}/voice/text-to-speech.md +2 -2
  38. package/.docs/models/embeddings.md +63 -65
  39. package/.docs/models/environment-variables.md +2 -1
  40. package/.docs/models/gateways/openrouter.md +3 -6
  41. package/.docs/models/gateways/vercel.md +4 -1
  42. package/.docs/models/index.md +1 -1
  43. package/.docs/models/providers/cortecs.md +2 -1
  44. package/.docs/models/providers/crof.md +2 -1
  45. package/.docs/models/providers/crossmodel.md +4 -3
  46. package/.docs/models/providers/empiriolabs.md +2 -1
  47. package/.docs/models/providers/greenpt.md +98 -0
  48. package/.docs/models/providers/huggingface.md +3 -1
  49. package/.docs/models/providers/hyper.md +10 -7
  50. package/.docs/models/providers/llmgateway.md +5 -4
  51. package/.docs/models/providers/minimax.md +1 -1
  52. package/.docs/models/providers/neuralwatt.md +3 -1
  53. package/.docs/models/providers/openai.md +2 -2
  54. package/.docs/models/providers/opencode-go.md +2 -1
  55. package/.docs/models/providers/opencode.md +1 -1
  56. package/.docs/models/providers/perplexity-agent.md +3 -1
  57. package/.docs/models/providers/scaleway.md +1 -3
  58. package/.docs/models/providers/the-grid-ai.md +3 -3
  59. package/.docs/models/providers/zai-coding-plan.md +11 -13
  60. package/.docs/models/providers/zhipuai-coding-plan.md +12 -12
  61. package/.docs/models/providers.md +1 -0
  62. package/.docs/reference/agents/agent.md +1 -1
  63. package/.docs/reference/agents/durable-agent.md +12 -1
  64. package/.docs/reference/agents/generate.md +1 -1
  65. package/.docs/reference/agents/getVoice.md +1 -1
  66. package/.docs/{docs/getting-started → reference}/build-with-ai.md +5 -110
  67. package/.docs/reference/cli/create-mastra.md +2 -0
  68. package/.docs/reference/cli/mastra.md +36 -16
  69. package/.docs/reference/client-js/agents.md +1 -1
  70. package/.docs/reference/configuration.md +2 -2
  71. package/.docs/reference/core/getEditor.md +1 -1
  72. package/.docs/reference/core/getVector.md +2 -2
  73. package/.docs/reference/core/listVectors.md +2 -2
  74. package/.docs/reference/core/mastra-class.md +2 -2
  75. package/.docs/reference/datasets/startExperiment.md +8 -0
  76. package/.docs/reference/datasets/startExperimentAsync.md +4 -0
  77. package/.docs/reference/editor/browser-provider.md +2 -2
  78. package/.docs/reference/editor/filesystem-provider.md +1 -1
  79. package/.docs/reference/editor/mastra-editor.md +31 -18
  80. package/.docs/reference/editor/prompt-blocks.md +137 -0
  81. package/.docs/reference/editor/sandbox-provider.md +1 -1
  82. package/.docs/reference/editor/storage-browser-ref.md +3 -3
  83. package/.docs/reference/editor/storage-workspace-ref.md +3 -3
  84. package/.docs/reference/editor/tool-provider.md +44 -10
  85. package/.docs/reference/editor/tools.md +100 -0
  86. package/.docs/reference/editor/versioning.md +130 -0
  87. package/.docs/reference/evals/mastra-scorer.md +68 -8
  88. package/.docs/reference/evals/summarization.md +203 -0
  89. package/.docs/reference/file-based-agents/config.md +39 -1
  90. package/.docs/reference/index.md +4 -4
  91. package/.docs/reference/memory/observational-memory.md +76 -24
  92. package/.docs/reference/memory/serialized-memory-config.md +3 -3
  93. package/.docs/reference/observability/tracing/interfaces.md +6 -1
  94. package/.docs/reference/processors/processor-interface.md +14 -2
  95. package/.docs/reference/processors/regex-filter-processor.md +81 -9
  96. package/.docs/reference/processors/token-limiter-processor.md +15 -1
  97. package/.docs/reference/project-structure.md +1 -1
  98. package/.docs/reference/rag/database-config.md +1 -1
  99. package/.docs/reference/storage/composite.md +2 -0
  100. package/.docs/reference/streaming/agents/stream.md +1 -1
  101. package/.docs/reference/tools/isolated-vm-transport.md +1 -1
  102. package/.docs/reference/vectors/mongodb.md +13 -13
  103. package/.docs/reference/voice/livekit.md +3 -3
  104. package/.docs/reference/workers/overview.md +10 -8
  105. package/.docs/reference/workspace/platform-filesystem.md +8 -5
  106. package/.docs/reference/workspace/platform-sandbox.md +83 -7
  107. package/CHANGELOG.md +51 -0
  108. package/README.md +1 -1
  109. package/package.json +5 -5
  110. package/.docs/docs/agent-builder/access-control.md +0 -99
  111. package/.docs/docs/agent-builder/browser.md +0 -63
  112. package/.docs/docs/agent-builder/channels.md +0 -78
  113. package/.docs/docs/agent-builder/configuration.md +0 -132
  114. package/.docs/docs/agent-builder/deploying.md +0 -124
  115. package/.docs/docs/agent-builder/integrations.md +0 -115
  116. package/.docs/docs/agent-builder/memory.md +0 -69
  117. package/.docs/docs/agent-builder/model-policy.md +0 -50
  118. package/.docs/docs/agent-builder/overview.md +0 -114
  119. package/.docs/docs/agent-builder/skill-registries.md +0 -31
  120. package/.docs/docs/agent-builder/workspace.md +0 -62
  121. package/.docs/docs/editor/prompts.md +0 -140
  122. package/.docs/docs/editor/tools.md +0 -148
  123. package/.docs/docs/getting-started/file-based-agents.md +0 -121
  124. package/.docs/docs/mastra-platform/workspace.md +0 -111
  125. package/.docs/docs/what-is-mastra.md +0 -161
  126. package/.docs/reference/client-js/agent-builder.md +0 -163
  127. package/.docs/reference/editor/agent-builder/agent-builder-options.md +0 -76
  128. package/.docs/reference/editor/agent-builder/builder-agent-defaults.md +0 -79
  129. package/.docs/reference/editor/agent-builder/builder-models.md +0 -66
  130. /package/.docs/{docs → guides}/getting-started/manual-install.md +0 -0
  131. /package/.docs/{docs → guides}/rag/vector-databases.md +0 -0
@@ -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/editor/agent-builder/builder-agent-defaults) and by stored agent records.
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/docs/agent-builder/browser): Concept and worked examples.
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/editor/agent-builder/builder-agent-defaults): Where this type is pinned as the Builder default.
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/editor/agent-builder/builder-agent-defaults) and by stored agent records.
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/docs/agent-builder/workspace): Concept and worked examples.
93
- - [BuilderAgentDefaults](https://mastra.ai/reference/editor/agent-builder/builder-agent-defaults): Where this type is pinned as the Builder default.
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 [Tools](https://mastra.ai/docs/editor/tools) for a guide on setting up tool providers.
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
- Tool providers implement these methods:
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
- **listToolkits()** (`() => Promise<Toolkit[]>`): Returns a list of available toolkits (tool categories) from the provider.
13
+ **info** (`ToolProviderInfo`): Provider ID, name, and description.
14
14
 
15
- **listTools(params?)** (`(params?) => Promise<Tool[]>`): Returns a list of available tools. Accepts optional filtering by toolkit, search query, and limit.
15
+ **displayName** (`string`): Optional name shown in the tool picker. Defaults to info.name.
16
16
 
17
- **getToolSchema(slug)** (`(slug: string) => Promise<JSONSchema>`): Returns the JSON schema for a specific tool identified by its slug.
17
+ **capabilities** (`ToolProviderCapabilities`): Static connection and revocation capabilities. Required for VNext providers.
18
18
 
19
- **resolveTools(slugs, options?)** (`(slugs: string[], options?) => Promise<Record<string, ToolAction>>`): Resolves tool slugs into executable Mastra tool actions. Built-in providers use resourceId from request context for per-user authentication.
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/providers/composio'
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
- Tool execution is scoped to the `resourceId` passed through request context. The provider maps that value to the user identity required by Composio's auth flow.
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/providers/arcade'
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
- Like Composio, tool execution uses `resourceId` from request context for per-user authorization. The provider maps that value to the user identity required by Arcade's auth flow.
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 ScorerJudgeExecutionSuccess {
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
- type ScorerJudgeExecution = ScorerJudgeExecutionSuccess
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.totalTokens)
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 when the execution directly reports an authoritative cost, source, and unit.
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: