@mastra/core 1.24.0 → 1.24.1-alpha.1
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/CHANGELOG.md +12 -0
- package/dist/agent/index.cjs +8 -8
- package/dist/agent/index.js +1 -1
- package/dist/browser/index.cjs +2 -2
- package/dist/browser/index.js +1 -1
- package/dist/channels/index.cjs +4 -4
- package/dist/channels/index.js +1 -1
- package/dist/{chunk-PN7CBIVV.js → chunk-35VW6IXX.js} +3 -3
- package/dist/{chunk-PN7CBIVV.js.map → chunk-35VW6IXX.js.map} +1 -1
- package/dist/{chunk-ADPPBTVG.js → chunk-47CEV52O.js} +6 -6
- package/dist/{chunk-ADPPBTVG.js.map → chunk-47CEV52O.js.map} +1 -1
- package/dist/{chunk-F3P6BFYU.cjs → chunk-4MTDYIII.cjs} +6825 -6815
- package/dist/chunk-4MTDYIII.cjs.map +1 -0
- package/dist/{chunk-SE7ST47S.js → chunk-5SVDDL2G.js} +6 -6
- package/dist/{chunk-SE7ST47S.js.map → chunk-5SVDDL2G.js.map} +1 -1
- package/dist/{chunk-6ZHFLCZD.js → chunk-7RO64H5E.js} +4 -4
- package/dist/{chunk-6ZHFLCZD.js.map → chunk-7RO64H5E.js.map} +1 -1
- package/dist/{chunk-3P6XSZUF.js → chunk-ABEBCXBS.js} +3 -3
- package/dist/{chunk-3P6XSZUF.js.map → chunk-ABEBCXBS.js.map} +1 -1
- package/dist/{chunk-TKMPRHAK.js → chunk-AX4KVIF5.js} +3 -3
- package/dist/chunk-AX4KVIF5.js.map +1 -0
- package/dist/{chunk-N7S3MTPO.cjs → chunk-CWGTLGSP.cjs} +17 -17
- package/dist/{chunk-N7S3MTPO.cjs.map → chunk-CWGTLGSP.cjs.map} +1 -1
- package/dist/{chunk-SDH6X2XL.cjs → chunk-IIKJ5JCQ.cjs} +3 -3
- package/dist/chunk-IIKJ5JCQ.cjs.map +1 -0
- package/dist/{chunk-6XE5DGL4.js → chunk-LWVE3M3O.js} +9 -9
- package/dist/{chunk-6XE5DGL4.js.map → chunk-LWVE3M3O.js.map} +1 -1
- package/dist/{chunk-IZQ4UPH5.cjs → chunk-M4SXMLXQ.cjs} +48 -48
- package/dist/{chunk-IZQ4UPH5.cjs.map → chunk-M4SXMLXQ.cjs.map} +1 -1
- package/dist/{chunk-BRLXMVIG.js → chunk-ME233XCK.js} +3 -3
- package/dist/{chunk-BRLXMVIG.js.map → chunk-ME233XCK.js.map} +1 -1
- package/dist/{chunk-4BKNCJU7.cjs → chunk-NLXCE3DZ.cjs} +185 -185
- package/dist/{chunk-4BKNCJU7.cjs.map → chunk-NLXCE3DZ.cjs.map} +1 -1
- package/dist/{chunk-V7H57YBW.cjs → chunk-NPYKTS7A.cjs} +16 -16
- package/dist/{chunk-V7H57YBW.cjs.map → chunk-NPYKTS7A.cjs.map} +1 -1
- package/dist/{chunk-B5643WMN.js → chunk-OFDFDY4Z.js} +3 -3
- package/dist/{chunk-B5643WMN.js.map → chunk-OFDFDY4Z.js.map} +1 -1
- package/dist/{chunk-MJJVDIL7.cjs → chunk-PPO7XBMN.cjs} +6 -6
- package/dist/{chunk-MJJVDIL7.cjs.map → chunk-PPO7XBMN.cjs.map} +1 -1
- package/dist/{chunk-AQXJ6EOF.cjs → chunk-PYASEKXX.cjs} +7 -7
- package/dist/{chunk-AQXJ6EOF.cjs.map → chunk-PYASEKXX.cjs.map} +1 -1
- package/dist/{chunk-5FMGGMTA.cjs → chunk-PZM6K6FM.cjs} +9 -9
- package/dist/{chunk-5FMGGMTA.cjs.map → chunk-PZM6K6FM.cjs.map} +1 -1
- package/dist/{chunk-KDLCZTD3.cjs → chunk-UHYAP2CY.cjs} +5 -5
- package/dist/{chunk-KDLCZTD3.cjs.map → chunk-UHYAP2CY.cjs.map} +1 -1
- package/dist/{chunk-XQKBUR5Q.cjs → chunk-UO7YAJUZ.cjs} +77 -77
- package/dist/{chunk-XQKBUR5Q.cjs.map → chunk-UO7YAJUZ.cjs.map} +1 -1
- package/dist/{chunk-TAJYHQ4N.js → chunk-VU6HRJVR.js} +4 -4
- package/dist/{chunk-TAJYHQ4N.js.map → chunk-VU6HRJVR.js.map} +1 -1
- package/dist/{chunk-7YGIQZZU.js → chunk-ZOAOX42T.js} +6813 -6803
- package/dist/chunk-ZOAOX42T.js.map +1 -0
- package/dist/datasets/index.cjs +11 -11
- package/dist/datasets/index.js +1 -1
- package/dist/docs/SKILL.md +2 -1
- package/dist/docs/assets/SOURCE_MAP.json +133 -133
- package/dist/docs/references/docs-editor-overview.md +66 -0
- package/dist/docs/references/docs-editor-prompts.md +63 -0
- package/dist/docs/references/docs-editor-tools.md +2 -2
- package/dist/docs/references/reference-core-getEditor.md +35 -0
- package/dist/docs/references/reference-editor-mastra-editor.md +79 -1
- package/dist/docs/references/reference.md +1 -0
- package/dist/evals/index.cjs +5 -5
- package/dist/evals/index.js +2 -2
- package/dist/evals/scoreTraces/index.cjs +3 -3
- package/dist/evals/scoreTraces/index.js +1 -1
- package/dist/harness/index.cjs +15 -10
- package/dist/harness/index.cjs.map +1 -1
- package/dist/harness/index.js +13 -8
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/tools.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/llm/index.cjs +20 -20
- package/dist/llm/index.js +5 -5
- package/dist/llm/model/provider-types.generated.d.ts +3134 -3129
- package/dist/loop/index.cjs +14 -14
- package/dist/loop/index.js +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/mastra-OH6I32WA.cjs +12 -0
- package/dist/{mastra-JVY5NHTL.cjs.map → mastra-OH6I32WA.cjs.map} +1 -1
- package/dist/mastra-YHTRM6PO.js +3 -0
- package/dist/{mastra-JEGLT2N7.js.map → mastra-YHTRM6PO.js.map} +1 -1
- package/dist/memory/index.cjs +19 -19
- package/dist/memory/index.js +1 -1
- package/dist/models-dev-AK3PM7JN.js +3 -0
- package/dist/{models-dev-2VN4JSFK.js.map → models-dev-AK3PM7JN.js.map} +1 -1
- package/dist/models-dev-EG6RENUZ.cjs +12 -0
- package/dist/{models-dev-IKQIKFSM.cjs.map → models-dev-EG6RENUZ.cjs.map} +1 -1
- package/dist/netlify-UT6JYWWM.js +3 -0
- package/dist/{netlify-Z6K3THHN.js.map → netlify-UT6JYWWM.js.map} +1 -1
- package/dist/netlify-YRTIOZZA.cjs +12 -0
- package/dist/{netlify-JEENQP7S.cjs.map → netlify-YRTIOZZA.cjs.map} +1 -1
- package/dist/processor-provider/index.cjs +10 -10
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/index.cjs +44 -44
- package/dist/processors/index.js +1 -1
- package/dist/provider-registry-LIYLQVA7.js +3 -0
- package/dist/{provider-registry-DVP23DC2.js.map → provider-registry-LIYLQVA7.js.map} +1 -1
- package/dist/provider-registry-W3UHSSXG.cjs +44 -0
- package/dist/{provider-registry-2RFGIGU5.cjs.map → provider-registry-W3UHSSXG.cjs.map} +1 -1
- package/dist/provider-registry.json +6805 -6795
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/stream/index.cjs +8 -8
- package/dist/stream/index.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +24 -24
- package/dist/workflows/index.js +1 -1
- package/package.json +3 -3
- package/src/llm/model/provider-types.generated.d.ts +3134 -3129
- package/dist/chunk-7YGIQZZU.js.map +0 -1
- package/dist/chunk-F3P6BFYU.cjs.map +0 -1
- package/dist/chunk-SDH6X2XL.cjs.map +0 -1
- package/dist/chunk-TKMPRHAK.js.map +0 -1
- package/dist/mastra-JEGLT2N7.js +0 -3
- package/dist/mastra-JVY5NHTL.cjs +0 -12
- package/dist/models-dev-2VN4JSFK.js +0 -3
- package/dist/models-dev-IKQIKFSM.cjs +0 -12
- package/dist/netlify-JEENQP7S.cjs +0 -12
- package/dist/netlify-Z6K3THHN.js +0 -3
- package/dist/provider-registry-2RFGIGU5.cjs +0 -44
- package/dist/provider-registry-DVP23DC2.js +0 -3
|
@@ -72,6 +72,72 @@ Go to the **Agents** tab in Studio and select an agent to edit. Select the **Edi
|
|
|
72
72
|
|
|
73
73
|
Modify the system prompt and save a new draft version. Afterwards, publish the draft to make it the active version.
|
|
74
74
|
|
|
75
|
+
## Programmatic control
|
|
76
|
+
|
|
77
|
+
Everything you can do in Studio is also available programmatically through [`mastra.getEditor()`](https://mastra.ai/reference/core/getEditor). This is useful for scripting bulk updates, seeding stored configurations from code, or building automation that tunes agents based on evaluation results.
|
|
78
|
+
|
|
79
|
+
Call `mastra.getEditor()` from anywhere you have access to the `Mastra` instance. It returns the `MastraEditor` instance you registered, with namespaces for each resource type:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { mastra } from '../mastra'
|
|
83
|
+
|
|
84
|
+
const editor = mastra.getEditor()
|
|
85
|
+
if (!editor) throw new Error('Editor is not registered on Mastra')
|
|
86
|
+
|
|
87
|
+
// Create a stored agent override for an existing code-defined agent
|
|
88
|
+
await editor.agent.create({
|
|
89
|
+
id: 'support-agent',
|
|
90
|
+
instructions: 'You are a friendly support agent for Acme Inc.',
|
|
91
|
+
tools: {
|
|
92
|
+
search_kb: { description: 'Search the Acme knowledge base' },
|
|
93
|
+
},
|
|
94
|
+
})
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Use `editor.agent.update()` to change an existing stored configuration. Every update creates a new draft version automatically:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { mastra } from '../mastra'
|
|
101
|
+
|
|
102
|
+
const editor = mastra.getEditor()!
|
|
103
|
+
|
|
104
|
+
await editor.agent.update({
|
|
105
|
+
id: 'support-agent',
|
|
106
|
+
instructions:
|
|
107
|
+
"You are a friendly support agent for Acme Inc. Always respond in the user's language.",
|
|
108
|
+
})
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The `editor.agent` namespace also exposes `getById`, `list`, `listResolved`, and `delete`. The `editor.prompt` namespace exposes the same CRUD methods for prompt blocks. See [Prompts](https://mastra.ai/docs/editor/prompts) for examples.
|
|
112
|
+
|
|
113
|
+
### Server endpoints
|
|
114
|
+
|
|
115
|
+
The same operations are available over HTTP through the Mastra server. Use these when you want to manage stored agents from a separate service or from a non-TypeScript client:
|
|
116
|
+
|
|
117
|
+
| Method | Path | Description |
|
|
118
|
+
| -------- | ------------------------------- | ------------------------- |
|
|
119
|
+
| `GET` | `/stored/agents` | List all stored agents. |
|
|
120
|
+
| `POST` | `/stored/agents` | Create a stored agent. |
|
|
121
|
+
| `GET` | `/stored/agents/:storedAgentId` | Get a stored agent by ID. |
|
|
122
|
+
| `PATCH` | `/stored/agents/:storedAgentId` | Update a stored agent. |
|
|
123
|
+
| `DELETE` | `/stored/agents/:storedAgentId` | Delete a stored agent. |
|
|
124
|
+
|
|
125
|
+
The Client SDK wraps these endpoints with `client.listStoredAgents()`, `client.createStoredAgent()`, and `client.getStoredAgent()`. Version management endpoints live under `/stored/agents/:storedAgentId/versions`, see [version management](https://mastra.ai/reference/client-js/agents) for the full list.
|
|
126
|
+
|
|
127
|
+
### Automated experimentation
|
|
128
|
+
|
|
129
|
+
Because stored agents are just data, you can build automation loops that tune agents without human involvement. A common pattern is to pair the editor API with [datasets](https://mastra.ai/docs/evals/datasets/overview) and [experiments](https://mastra.ai/docs/evals/datasets/running-experiments):
|
|
130
|
+
|
|
131
|
+
- Run a dataset through the current version of an agent and score the results.
|
|
132
|
+
- Have another agent read the failing cases and propose changes to the instructions or tools.
|
|
133
|
+
- Apply those changes with `editor.agent.update()` to create a new draft.
|
|
134
|
+
- Re-run the experiment against the draft and compare scores to the baseline.
|
|
135
|
+
- Promote the draft to the published version when the scores improve.
|
|
136
|
+
|
|
137
|
+
This turns agent tuning into a closed feedback loop. One agent owns the production configuration, another agent iterates on it, and every change is versioned so you can roll back if a round of automated edits makes things worse. Combine this with [version targeting](#version-targeting-and-experimentation) to keep production traffic on the published version while the draft is being tested.
|
|
138
|
+
|
|
139
|
+
> **Note:** See the [MastraEditor reference](https://mastra.ai/reference/editor/mastra-editor) for the full namespace API.
|
|
140
|
+
|
|
75
141
|
## What can be overridden
|
|
76
142
|
|
|
77
143
|
When you edit a code-defined agent through the editor, only specific fields can be changed:
|
|
@@ -59,6 +59,69 @@ Rule groups can be nested, so you can combine AND and OR conditions for complex
|
|
|
59
59
|
|
|
60
60
|
In the Studio, open a block's **Display conditions** panel to set up rules visually. You can also configure conditions programmatically through the API. Blocks without conditions are always included.
|
|
61
61
|
|
|
62
|
+
## Programmatic control
|
|
63
|
+
|
|
64
|
+
Prompt blocks can be managed from code through [`mastra.getEditor().prompt`](https://mastra.ai/reference/editor/mastra-editor). This is useful for seeding a set of starter prompts, syncing blocks between environments, or generating prompt variants from a script.
|
|
65
|
+
|
|
66
|
+
Create a new prompt block with `editor.prompt.create()`:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { mastra } from '../mastra'
|
|
70
|
+
|
|
71
|
+
const editor = mastra.getEditor()!
|
|
72
|
+
|
|
73
|
+
await editor.prompt.create({
|
|
74
|
+
id: 'brand-voice',
|
|
75
|
+
name: 'Brand voice',
|
|
76
|
+
description: 'Acme Inc. tone and style guidelines',
|
|
77
|
+
content:
|
|
78
|
+
'You write in a friendly, concise tone. Always address the user as {{userName || "there"}}.',
|
|
79
|
+
})
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Update an existing block with `editor.prompt.update()`. Each update creates a new draft version:
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { mastra } from '../mastra'
|
|
86
|
+
|
|
87
|
+
const editor = mastra.getEditor()!
|
|
88
|
+
|
|
89
|
+
await editor.prompt.update({
|
|
90
|
+
id: 'brand-voice',
|
|
91
|
+
content: 'You write in a friendly, concise tone. Always greet the user by name when available.',
|
|
92
|
+
})
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Use `editor.prompt.list()` to paginate through stored blocks or `editor.prompt.getById()` to fetch a specific block. To preview an agent's full instructions with a set of prompt blocks applied, call `editor.prompt.preview()` with the draft content.
|
|
96
|
+
|
|
97
|
+
The same operations are available over HTTP through the Mastra server:
|
|
98
|
+
|
|
99
|
+
| Method | Path | Description |
|
|
100
|
+
| -------- | -------------------------------------------- | -------------------------------- |
|
|
101
|
+
| `GET` | `/stored/prompt-blocks` | List all stored prompt blocks. |
|
|
102
|
+
| `POST` | `/stored/prompt-blocks` | Create a stored prompt block. |
|
|
103
|
+
| `GET` | `/stored/prompt-blocks/:storedPromptBlockId` | Get a stored prompt block by ID. |
|
|
104
|
+
| `PATCH` | `/stored/prompt-blocks/:storedPromptBlockId` | Update a stored prompt block. |
|
|
105
|
+
| `DELETE` | `/stored/prompt-blocks/:storedPromptBlockId` | Delete a stored prompt block. |
|
|
106
|
+
|
|
107
|
+
Once a prompt block is created, reference it from an agent's `instructions` field as a `prompt_block_ref`:
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
import { mastra } from '../mastra'
|
|
111
|
+
|
|
112
|
+
const editor = mastra.getEditor()!
|
|
113
|
+
|
|
114
|
+
await editor.agent.update({
|
|
115
|
+
id: 'support-agent',
|
|
116
|
+
instructions: [
|
|
117
|
+
{ type: 'prompt_block_ref', id: 'brand-voice' },
|
|
118
|
+
{ type: 'text', content: 'Answer only questions about Acme products.' },
|
|
119
|
+
],
|
|
120
|
+
})
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
> **Note:** See the [MastraEditor reference](https://mastra.ai/reference/editor/mastra-editor) for the full `editor.prompt` API.
|
|
124
|
+
|
|
62
125
|
## Versioning
|
|
63
126
|
|
|
64
127
|
Prompt blocks follow the same [versioning lifecycle](https://mastra.ai/docs/editor/overview) as agents. Each prompt block has a draft that you can edit and publish as a versioned snapshot. This means prompt content can be versioned and rolled back independently from the agent that uses it.
|
|
@@ -57,7 +57,7 @@ Integration providers connect external tool platforms to the editor. Once regist
|
|
|
57
57
|
```typescript
|
|
58
58
|
import { Mastra } from '@mastra/core'
|
|
59
59
|
import { MastraEditor } from '@mastra/editor'
|
|
60
|
-
import { ComposioToolProvider } from '@mastra/editor/
|
|
60
|
+
import { ComposioToolProvider } from '@mastra/editor/composio'
|
|
61
61
|
|
|
62
62
|
export const mastra = new Mastra({
|
|
63
63
|
agents: {
|
|
@@ -86,7 +86,7 @@ Integration providers connect external tool platforms to the editor. Once regist
|
|
|
86
86
|
```typescript
|
|
87
87
|
import { Mastra } from '@mastra/core'
|
|
88
88
|
import { MastraEditor } from '@mastra/editor'
|
|
89
|
-
import { ArcadeToolProvider } from '@mastra/editor/
|
|
89
|
+
import { ArcadeToolProvider } from '@mastra/editor/arcade'
|
|
90
90
|
|
|
91
91
|
export const mastra = new Mastra({
|
|
92
92
|
agents: {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Mastra.getEditor()
|
|
2
|
+
|
|
3
|
+
The `.getEditor()` method is used to retrieve the editor instance that has been configured on the Mastra instance. The editor exposes CRUD namespaces for managing stored agents, prompt blocks, MCP clients, scorers, skills, and workspaces programmatically.
|
|
4
|
+
|
|
5
|
+
## Usage example
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { Mastra } from '@mastra/core'
|
|
9
|
+
import { MastraEditor } from '@mastra/editor'
|
|
10
|
+
|
|
11
|
+
const mastra = new Mastra({
|
|
12
|
+
editor: new MastraEditor(),
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const editor = mastra.getEditor()
|
|
16
|
+
|
|
17
|
+
const agent = await editor?.agent.create({
|
|
18
|
+
id: 'support-agent',
|
|
19
|
+
name: 'Support Agent',
|
|
20
|
+
instructions: 'Help customers with their questions.',
|
|
21
|
+
})
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Parameters
|
|
25
|
+
|
|
26
|
+
This method doesn't accept any parameters.
|
|
27
|
+
|
|
28
|
+
## Returns
|
|
29
|
+
|
|
30
|
+
**editor** (`MastraEditor | undefined`): The configured editor instance, or undefined if no editor has been configured.
|
|
31
|
+
|
|
32
|
+
## Related
|
|
33
|
+
|
|
34
|
+
- [Editor overview](https://mastra.ai/docs/editor/overview)
|
|
35
|
+
- [MastraEditor reference](https://mastra.ai/reference/editor/mastra-editor)
|
|
@@ -41,18 +41,96 @@ export const mastra = new Mastra({
|
|
|
41
41
|
|
|
42
42
|
## Namespaces
|
|
43
43
|
|
|
44
|
-
The editor exposes namespaces for managing different entity types.
|
|
44
|
+
The editor exposes namespaces for managing different entity types. Access them from any Mastra instance with `mastra.getEditor()` and call the CRUD methods directly in application code, or rely on the Mastra server routes that use them under the hood.
|
|
45
|
+
|
|
46
|
+
All namespaces extend a shared CRUD base class, so they expose the same `create`, `getById`, `update`, `delete`, `list`, `listResolved`, and `clearCache` methods. The namespace-specific property tables below also document any additional methods.
|
|
45
47
|
|
|
46
48
|
**agent** (`EditorAgentNamespace`): CRUD operations and version management for stored agents. Handles applying stored overrides to code-defined agents.
|
|
47
49
|
|
|
50
|
+
**agent.create** (`(input: StorageCreateAgentInput) => Promise<Agent>`): Create a new stored agent and return a hydrated Agent instance. Accepts an id, authorId, metadata, and the initial snapshot (name, description, instructions, model, tools, memory, and so on).
|
|
51
|
+
|
|
52
|
+
**agent.getById** (`(id: string, options?: GetByIdOptions) => Promise<Agent | null>`): Return a hydrated Agent instance for a stored agent. Pass options with versionId, versionNumber, or status ("draft" | "published" | "archived") to target a specific version. Default version requests are cached.
|
|
53
|
+
|
|
54
|
+
**agent.update** (`(input: StorageUpdateAgentInput) => Promise<Agent>`): Partially update a stored agent. Creates a new draft version with the provided snapshot fields (instructions, tools, memory, and so on) and invalidates the cache. Set memory to null to disable memory.
|
|
55
|
+
|
|
56
|
+
**agent.delete** (`(id: string) => Promise<void>`): Delete a stored agent and remove it from the Mastra runtime registry.
|
|
57
|
+
|
|
58
|
+
**agent.list** (`(args?: StorageListAgentsInput) => Promise<StorageListAgentsOutput>`): List stored agents with optional pagination, orderBy, authorId, and metadata filters. Returns raw stored snapshots.
|
|
59
|
+
|
|
60
|
+
**agent.listResolved** (`(args?: StorageListAgentsInput) => Promise<StorageListAgentsResolvedOutput>`): Same as list, but returns fully resolved configurations with references dereferenced.
|
|
61
|
+
|
|
62
|
+
**agent.applyStoredOverrides** (`(agent: Agent, options?: { versionId?: string; status?: "draft" | "published" }) => Promise<Agent>`): Mutate a code-defined agent in place to apply any stored overrides (instructions, tools, variables). Called internally by mastra.getAgent() — you rarely call it directly.
|
|
63
|
+
|
|
64
|
+
**agent.clone** (`(agent: Agent, options: { newId: string; newName?: string; metadata?: Record<string, unknown>; authorId?: string; requestContext?: RequestContext; }) => Promise<Agent>`): Create a new stored agent by cloning an existing agent.
|
|
65
|
+
|
|
66
|
+
**agent.clearCache** (`(agentId?: string) => void`): Clear the in-memory cache for one agent or all agents. Called automatically after mutations.
|
|
67
|
+
|
|
48
68
|
**prompt** (`EditorPromptNamespace`): CRUD operations for prompt blocks. Includes a preview method for resolving instruction blocks with draft content.
|
|
49
69
|
|
|
70
|
+
**prompt.create** (`(input: StorageCreatePromptBlockInput) => Promise<StorageResolvedPromptBlockType>`): Create a new stored prompt block. Accepts an id, authorId, metadata, and the initial snapshot (name, description, content, rules, requestContextSchema).
|
|
71
|
+
|
|
72
|
+
**prompt.getById** (`(id: string, options?: GetByIdOptions) => Promise<StorageResolvedPromptBlockType | null>`): Return a resolved prompt block. Pass options to target a specific version or status.
|
|
73
|
+
|
|
74
|
+
**prompt.update** (`(input: StorageUpdatePromptBlockInput) => Promise<StorageResolvedPromptBlockType>`): Partially update a stored prompt block. Creates a new draft version with the provided snapshot fields.
|
|
75
|
+
|
|
76
|
+
**prompt.delete** (`(id: string) => Promise<void>`): Delete a stored prompt block and remove it from the Mastra runtime registry.
|
|
77
|
+
|
|
78
|
+
**prompt.list** (`(args?: StorageListPromptBlocksInput) => Promise<StorageListPromptBlocksOutput>`): List stored prompt blocks with optional pagination, orderBy, authorId, metadata, and status filters.
|
|
79
|
+
|
|
80
|
+
**prompt.listResolved** (`(args?: StorageListPromptBlocksInput) => Promise<StorageListPromptBlocksResolvedOutput>`): Same as list, but returns fully resolved prompt block content.
|
|
81
|
+
|
|
82
|
+
**prompt.preview** (`(blocks: AgentInstructionBlock[], context: Record<string, unknown>) => Promise<string>`): Resolve an array of instruction blocks against a context, rendering template variables and evaluating display conditions. Includes draft content for referenced prompt blocks.
|
|
83
|
+
|
|
84
|
+
**prompt.clearCache** (`(id?: string) => void`): Clear the in-memory cache for one prompt block or all prompt blocks.
|
|
85
|
+
|
|
50
86
|
**mcp** (`EditorMCPNamespace`): CRUD operations for stored MCP client configurations.
|
|
51
87
|
|
|
88
|
+
**mcp.create** (`(input: StorageCreateMCPClientInput) => Promise<MCPClient>`): Create a new stored MCP client. Accepts an id, authorId, metadata, and the initial snapshot (servers, tool filtering).
|
|
89
|
+
|
|
90
|
+
**mcp.getById** (`(id: string, options?: GetByIdOptions) => Promise<MCPClient | null>`): Return a hydrated MCPClient instance for a stored MCP client.
|
|
91
|
+
|
|
92
|
+
**mcp.update** (`(input: StorageUpdateMCPClientInput) => Promise<MCPClient>`): Partially update a stored MCP client and invalidate the cache.
|
|
93
|
+
|
|
94
|
+
**mcp.delete** (`(id: string) => Promise<void>`): Delete a stored MCP client and remove it from the Mastra runtime registry.
|
|
95
|
+
|
|
96
|
+
**mcp.list** (`(args?: StorageListMCPClientsInput) => Promise<StorageListMCPClientsOutput>`): List stored MCP clients with optional pagination and filters.
|
|
97
|
+
|
|
98
|
+
**mcp.listResolved** (`(args?: StorageListMCPClientsInput) => Promise<StorageListMCPClientsResolvedOutput>`): Same as list, but returns fully resolved MCP client configurations.
|
|
99
|
+
|
|
100
|
+
**mcp.clearCache** (`(id?: string) => void`): Clear the in-memory cache for one MCP client or all MCP clients.
|
|
101
|
+
|
|
52
102
|
**mcpServer** (`EditorMCPServerNamespace`): CRUD operations for MCP server configurations.
|
|
53
103
|
|
|
104
|
+
**mcpServer.create** (`(input: StorageCreateMCPServerInput) => Promise<MCPServerBase>`): Create a new stored MCP server configuration and return a hydrated server instance.
|
|
105
|
+
|
|
106
|
+
**mcpServer.getById** (`(id: string, options?: GetByIdOptions) => Promise<MCPServerBase | null>`): Return a hydrated MCP server for a given id.
|
|
107
|
+
|
|
108
|
+
**mcpServer.update** (`(input: StorageUpdateMCPServerInput) => Promise<MCPServerBase>`): Partially update a stored MCP server configuration.
|
|
109
|
+
|
|
110
|
+
**mcpServer.delete** (`(id: string) => Promise<void>`): Delete a stored MCP server configuration.
|
|
111
|
+
|
|
112
|
+
**mcpServer.list** (`(args?: StorageListMCPServersInput) => Promise<StorageListMCPServersOutput>`): List stored MCP server configurations.
|
|
113
|
+
|
|
114
|
+
**mcpServer.listResolved** (`(args?: StorageListMCPServersInput) => Promise<StorageListMCPServersResolvedOutput>`): Same as list, but returns fully resolved server configurations.
|
|
115
|
+
|
|
116
|
+
**mcpServer.clearCache** (`(id?: string) => void`): Clear the in-memory cache for one MCP server or all MCP servers.
|
|
117
|
+
|
|
54
118
|
**scorer** (`EditorScorerNamespace`): CRUD operations for scorer configurations.
|
|
55
119
|
|
|
120
|
+
**scorer.create** (`(input: StorageCreateScorerInput) => Promise<MastraScorer>`): Create a new stored scorer and return a hydrated MastraScorer instance.
|
|
121
|
+
|
|
122
|
+
**scorer.getById** (`(id: string, options?: GetByIdOptions) => Promise<MastraScorer | null>`): Return a hydrated scorer for a given id.
|
|
123
|
+
|
|
124
|
+
**scorer.update** (`(input: StorageUpdateScorerInput) => Promise<MastraScorer>`): Partially update a stored scorer.
|
|
125
|
+
|
|
126
|
+
**scorer.delete** (`(id: string) => Promise<void>`): Delete a stored scorer and remove it from the Mastra runtime registry.
|
|
127
|
+
|
|
128
|
+
**scorer.list** (`(args?: StorageListScorersInput) => Promise<StorageListScorersOutput>`): List stored scorers with optional pagination and filters.
|
|
129
|
+
|
|
130
|
+
**scorer.listResolved** (`(args?: StorageListScorersInput) => Promise<StorageListScorersResolvedOutput>`): Same as list, but returns fully resolved scorer configurations.
|
|
131
|
+
|
|
132
|
+
**scorer.clearCache** (`(id?: string) => void`): Clear the in-memory cache for one scorer or all scorers.
|
|
133
|
+
|
|
56
134
|
## Methods
|
|
57
135
|
|
|
58
136
|
### Provider access
|
|
@@ -63,6 +63,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
63
63
|
- [.getAgent()](https://mastra.ai/reference/core/getAgent)
|
|
64
64
|
- [.getAgentById()](https://mastra.ai/reference/core/getAgentById)
|
|
65
65
|
- [.getDeployer()](https://mastra.ai/reference/core/getDeployer)
|
|
66
|
+
- [.getEditor()](https://mastra.ai/reference/core/getEditor)
|
|
66
67
|
- [.getGateway()](https://mastra.ai/reference/core/getGateway)
|
|
67
68
|
- [.getGatewayById()](https://mastra.ai/reference/core/getGatewayById)
|
|
68
69
|
- [.getLogger()](https://mastra.ai/reference/core/getLogger)
|
package/dist/evals/index.cjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkUHYAP2CY_cjs = require('../chunk-UHYAP2CY.cjs');
|
|
4
|
+
var chunkNPYKTS7A_cjs = require('../chunk-NPYKTS7A.cjs');
|
|
5
5
|
var chunkP5C4HEAB_cjs = require('../chunk-P5C4HEAB.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, "runEvals", {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunkUHYAP2CY_cjs.runEvals; }
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, "MastraScorer", {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunkNPYKTS7A_cjs.MastraScorer; }
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "createScorer", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunkNPYKTS7A_cjs.createScorer; }
|
|
20
20
|
});
|
|
21
21
|
Object.defineProperty(exports, "extractTrajectory", {
|
|
22
22
|
enumerable: true,
|
package/dist/evals/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { runEvals } from '../chunk-
|
|
2
|
-
export { MastraScorer, createScorer } from '../chunk-
|
|
1
|
+
export { runEvals } from '../chunk-ABEBCXBS.js';
|
|
2
|
+
export { MastraScorer, createScorer } from '../chunk-5SVDDL2G.js';
|
|
3
3
|
export { extractTrajectory, extractTrajectoryFromTrace, extractWorkflowTrajectory, listScoresResponseSchema, saveScorePayloadSchema, scoreResultSchema, scoreRowDataSchema, scoringEntityTypeSchema, scoringExtractStepResultSchema, scoringHookInputSchema, scoringInputSchema, scoringInputWithExtractStepResultAndAnalyzeStepResultSchema, scoringInputWithExtractStepResultAndScoreAndReasonSchema, scoringInputWithExtractStepResultSchema, scoringPromptsSchema, scoringSourceSchema, scoringValueSchema } from '../chunk-Y4SL4WJQ.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkM4SXMLXQ_cjs = require('../../chunk-M4SXMLXQ.cjs');
|
|
4
4
|
var chunkP5C4HEAB_cjs = require('../../chunk-P5C4HEAB.cjs');
|
|
5
5
|
var chunkQFGYBEP3_cjs = require('../../chunk-QFGYBEP3.cjs');
|
|
6
6
|
var chunk4U7ZLI36_cjs = require('../../chunk-4U7ZLI36.cjs');
|
|
@@ -234,7 +234,7 @@ function transformTraceToScorerInputAndOutput(trace) {
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
// src/evals/scoreTraces/scoreTracesWorkflow.ts
|
|
237
|
-
var getTraceStep =
|
|
237
|
+
var getTraceStep = chunkM4SXMLXQ_cjs.createStep({
|
|
238
238
|
id: "__process-trace-scoring",
|
|
239
239
|
inputSchema: v4.z.object({
|
|
240
240
|
targets: v4.z.array(
|
|
@@ -429,7 +429,7 @@ async function attachScoreToSpan({
|
|
|
429
429
|
} catch {
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
|
-
var scoreTracesWorkflow =
|
|
432
|
+
var scoreTracesWorkflow = chunkM4SXMLXQ_cjs.createWorkflow({
|
|
433
433
|
id: "__batch-scoring-traces",
|
|
434
434
|
inputSchema: v4.z.object({
|
|
435
435
|
targets: v4.z.array(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createStep, createWorkflow } from '../../chunk-
|
|
1
|
+
import { createStep, createWorkflow } from '../../chunk-OFDFDY4Z.js';
|
|
2
2
|
import { saveScorePayloadSchema } from '../../chunk-Y4SL4WJQ.js';
|
|
3
3
|
import { getEntityTypeForSpan } from '../../chunk-E7PBOS66.js';
|
|
4
4
|
import { MastraError } from '../../chunk-FJEVLHJT.js';
|
package/dist/harness/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkCWGTLGSP_cjs = require('../chunk-CWGTLGSP.cjs');
|
|
4
|
+
var chunkNPYKTS7A_cjs = require('../chunk-NPYKTS7A.cjs');
|
|
5
5
|
var chunkRNJ2FXGD_cjs = require('../chunk-RNJ2FXGD.cjs');
|
|
6
6
|
var chunkXS3FHQ34_cjs = require('../chunk-XS3FHQ34.cjs');
|
|
7
7
|
var chunkLDLHW3QN_cjs = require('../chunk-LDLHW3QN.cjs');
|
|
@@ -313,7 +313,7 @@ Use this tool when:
|
|
|
313
313
|
};
|
|
314
314
|
}
|
|
315
315
|
const workspace = context?.workspace;
|
|
316
|
-
const subagent = new
|
|
316
|
+
const subagent = new chunkNPYKTS7A_cjs.Agent({
|
|
317
317
|
id: `subagent-${definition.id}`,
|
|
318
318
|
name: `${definition.name} Subagent`,
|
|
319
319
|
instructions: definition.instructions,
|
|
@@ -340,15 +340,20 @@ Use this tool when:
|
|
|
340
340
|
});
|
|
341
341
|
let partialText = "";
|
|
342
342
|
const toolCallLog = [];
|
|
343
|
+
let subagentRequestContext;
|
|
344
|
+
if (context?.requestContext) {
|
|
345
|
+
subagentRequestContext = new chunk5WBEMKE2_cjs.RequestContext(context.requestContext.entries());
|
|
346
|
+
if (harnessCtx) {
|
|
347
|
+
subagentRequestContext.set("harness", { ...harnessCtx, threadId: null, resourceId: "" });
|
|
348
|
+
}
|
|
349
|
+
}
|
|
343
350
|
try {
|
|
344
351
|
const response = await subagent.stream(task, {
|
|
345
352
|
maxSteps: definition.maxSteps ?? (definition.stopWhen ? void 0 : 50),
|
|
346
353
|
stopWhen: definition.stopWhen,
|
|
347
354
|
abortSignal,
|
|
348
355
|
requireToolApproval: false,
|
|
349
|
-
|
|
350
|
-
// sandbox allowed paths and other harness state.
|
|
351
|
-
requestContext: context?.requestContext,
|
|
356
|
+
requestContext: subagentRequestContext,
|
|
352
357
|
// When allowedWorkspaceTools is set, hide workspace tools not in
|
|
353
358
|
// the list. Non-workspace tools always pass through.
|
|
354
359
|
prepareStep: allowedWs && allWorkspaceToolNames ? ({ tools }) => ({
|
|
@@ -576,7 +581,7 @@ var Harness = class {
|
|
|
576
581
|
*/
|
|
577
582
|
async init() {
|
|
578
583
|
if (this.config.storage) {
|
|
579
|
-
this.#internalMastra = new
|
|
584
|
+
this.#internalMastra = new chunkCWGTLGSP_cjs.Mastra({ logger: false, storage: this.config.storage });
|
|
580
585
|
await this.#internalMastra.getStorage().init();
|
|
581
586
|
}
|
|
582
587
|
if (this.config.workspace && !this.workspaceInitialized && !this.workspaceFn) {
|
|
@@ -832,7 +837,7 @@ var Harness = class {
|
|
|
832
837
|
}
|
|
833
838
|
}
|
|
834
839
|
try {
|
|
835
|
-
const { PROVIDER_REGISTRY } = await import('../provider-registry-
|
|
840
|
+
const { PROVIDER_REGISTRY } = await import('../provider-registry-W3UHSSXG.cjs');
|
|
836
841
|
const registry = PROVIDER_REGISTRY;
|
|
837
842
|
const providerConfig = registry[provider];
|
|
838
843
|
const envVars = providerConfig?.apiKeyEnvVar;
|
|
@@ -852,7 +857,7 @@ var Harness = class {
|
|
|
852
857
|
*/
|
|
853
858
|
async listAvailableModels() {
|
|
854
859
|
try {
|
|
855
|
-
const { PROVIDER_REGISTRY } = await import('../provider-registry-
|
|
860
|
+
const { PROVIDER_REGISTRY } = await import('../provider-registry-W3UHSSXG.cjs');
|
|
856
861
|
if (!PROVIDER_REGISTRY) return [];
|
|
857
862
|
const registry = PROVIDER_REGISTRY;
|
|
858
863
|
const providers = Object.keys(registry);
|
|
@@ -911,7 +916,7 @@ var Harness = class {
|
|
|
911
916
|
}
|
|
912
917
|
async getProviderApiKeyEnvVar(provider) {
|
|
913
918
|
try {
|
|
914
|
-
const { PROVIDER_REGISTRY } = await import('../provider-registry-
|
|
919
|
+
const { PROVIDER_REGISTRY } = await import('../provider-registry-W3UHSSXG.cjs');
|
|
915
920
|
const registry = PROVIDER_REGISTRY;
|
|
916
921
|
const envVars = registry[provider]?.apiKeyEnvVar;
|
|
917
922
|
return Array.isArray(envVars) ? envVars[0] : envVars;
|