@mastra/editor 0.0.0-auth-rbac-cms-20260211172515
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 +205 -0
- package/LICENSE.md +15 -0
- package/dist/index.cjs +715 -0
- package/dist/index.d.cts +209 -0
- package/dist/index.d.ts +209 -0
- package/dist/index.js +687 -0
- package/package.json +51 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# @mastra/editor
|
|
2
|
+
|
|
3
|
+
## 0.0.0-auth-rbac-cms-20260211172515
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added dynamic instructions for stored agents. Agent instructions can now be composed from reusable prompt blocks with conditional rules and variable interpolation, enabling a prompt-CMS-like editing experience. ([#12776](https://github.com/mastra-ai/mastra/pull/12776))
|
|
8
|
+
|
|
9
|
+
**Instruction blocks** can be mixed in an agent's instructions array:
|
|
10
|
+
- `text` — static text with `{{variable}}` interpolation
|
|
11
|
+
- `prompt_block_ref` — reference to a versioned prompt block stored in the database
|
|
12
|
+
- `prompt_block` — inline prompt block with optional conditional rules
|
|
13
|
+
|
|
14
|
+
**Creating a prompt block and using it in a stored agent:**
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
// Create a reusable prompt block
|
|
18
|
+
const block = await editor.createPromptBlock({
|
|
19
|
+
id: 'security-rules',
|
|
20
|
+
name: 'Security Rules',
|
|
21
|
+
content: "You must verify the user's identity. The user's role is {{user.role}}.",
|
|
22
|
+
rules: {
|
|
23
|
+
operator: 'AND',
|
|
24
|
+
conditions: [{ field: 'user.isAuthenticated', operator: 'equals', value: true }],
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Create a stored agent that references the prompt block
|
|
29
|
+
await editor.createStoredAgent({
|
|
30
|
+
id: 'support-agent',
|
|
31
|
+
name: 'Support Agent',
|
|
32
|
+
instructions: [
|
|
33
|
+
{ type: 'text', content: 'You are a helpful support agent for {{company}}.' },
|
|
34
|
+
{ type: 'prompt_block_ref', id: 'security-rules' },
|
|
35
|
+
{
|
|
36
|
+
type: 'prompt_block',
|
|
37
|
+
content: 'Always be polite.',
|
|
38
|
+
rules: { operator: 'AND', conditions: [{ field: 'tone', operator: 'equals', value: 'formal' }] },
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
model: { provider: 'openai', name: 'gpt-4o' },
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// At runtime, instructions resolve dynamically based on request context
|
|
45
|
+
const agent = await editor.getStoredAgentById('support-agent');
|
|
46
|
+
const result = await agent.generate('Help me reset my password', {
|
|
47
|
+
requestContext: new RequestContext([
|
|
48
|
+
['company', 'Acme Corp'],
|
|
49
|
+
['user.isAuthenticated', true],
|
|
50
|
+
['user.role', 'admin'],
|
|
51
|
+
['tone', 'formal'],
|
|
52
|
+
]),
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Prompt blocks are versioned — updating a block's content takes effect immediately for all agents referencing it, with no cache clearing required.
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- Fixed stale agent data in CMS pages by adding removeAgent method to Mastra and updating clearStoredAgentCache to clear both Editor cache and Mastra registry when stored agents are updated or deleted ([#12693](https://github.com/mastra-ai/mastra/pull/12693))
|
|
61
|
+
|
|
62
|
+
- Fix memory persistence: ([#12704](https://github.com/mastra-ai/mastra/pull/12704))
|
|
63
|
+
- Fixed memory persistence bug by handling missing vector store gracefully
|
|
64
|
+
- When semantic recall is enabled but no vector store is configured, it now disables semantic recall instead of failing
|
|
65
|
+
- Fixed type compatibility for `embedder` field when creating agents from stored config
|
|
66
|
+
|
|
67
|
+
- Updated dependencies [[`717ffab`](https://github.com/mastra-ai/mastra/commit/717ffab42cfd58ff723b5c19ada4939997773004), [`5719fa8`](https://github.com/mastra-ai/mastra/commit/5719fa8880e86e8affe698ec4b3807c7e0e0a06f), [`83cda45`](https://github.com/mastra-ai/mastra/commit/83cda4523e588558466892bff8f80f631a36945a), [`aa95f95`](https://github.com/mastra-ai/mastra/commit/aa95f958b186ae5c9f4219c88e268f5565c277a2), [`90f7894`](https://github.com/mastra-ai/mastra/commit/90f7894568dc9481f40a4d29672234fae23090bb), [`8109aee`](https://github.com/mastra-ai/mastra/commit/8109aeeab758e16cd4255a6c36f044b70eefc6a6), [`fdad759`](https://github.com/mastra-ai/mastra/commit/fdad75939ff008b27625f5ec0ce9c6915d99d9ec), [`e4569c5`](https://github.com/mastra-ai/mastra/commit/e4569c589e00c4061a686c9eb85afe1b7050b0a8), [`7309a85`](https://github.com/mastra-ai/mastra/commit/7309a85427281a8be23f4fb80ca52e18eaffd596), [`99424f6`](https://github.com/mastra-ai/mastra/commit/99424f6862ffb679c4ec6765501486034754a4c2), [`a211248`](https://github.com/mastra-ai/mastra/commit/a21124845b1b1321b6075a8377c341c7f5cda1b6), [`8c1135d`](https://github.com/mastra-ai/mastra/commit/8c1135dfb91b057283eae7ee11f9ec28753cc64f)]:
|
|
68
|
+
- @mastra/core@0.0.0-auth-rbac-cms-20260211172515
|
|
69
|
+
- @mastra/memory@0.0.0-auth-rbac-cms-20260211172515
|
|
70
|
+
|
|
71
|
+
## 0.2.1-alpha.0
|
|
72
|
+
|
|
73
|
+
### Patch Changes
|
|
74
|
+
|
|
75
|
+
- Fixed stale agent data in CMS pages by adding removeAgent method to Mastra and updating clearStoredAgentCache to clear both Editor cache and Mastra registry when stored agents are updated or deleted ([#12693](https://github.com/mastra-ai/mastra/pull/12693))
|
|
76
|
+
|
|
77
|
+
- Fix memory persistence: ([#12704](https://github.com/mastra-ai/mastra/pull/12704))
|
|
78
|
+
- Fixed memory persistence bug by handling missing vector store gracefully
|
|
79
|
+
- When semantic recall is enabled but no vector store is configured, it now disables semantic recall instead of failing
|
|
80
|
+
- Fixed type compatibility for `embedder` field when creating agents from stored config
|
|
81
|
+
|
|
82
|
+
- Updated dependencies [[`90f7894`](https://github.com/mastra-ai/mastra/commit/90f7894568dc9481f40a4d29672234fae23090bb), [`8109aee`](https://github.com/mastra-ai/mastra/commit/8109aeeab758e16cd4255a6c36f044b70eefc6a6)]:
|
|
83
|
+
- @mastra/core@1.2.1-alpha.0
|
|
84
|
+
|
|
85
|
+
## 0.2.0
|
|
86
|
+
|
|
87
|
+
### Minor Changes
|
|
88
|
+
|
|
89
|
+
- Created @mastra/editor package for managing and resolving stored agent configurations ([#12631](https://github.com/mastra-ai/mastra/pull/12631))
|
|
90
|
+
|
|
91
|
+
This major addition introduces the editor package, which provides a complete solution for storing, versioning, and instantiating agent configurations from a database. The editor seamlessly integrates with Mastra's storage layer to enable dynamic agent management.
|
|
92
|
+
|
|
93
|
+
**Key Features:**
|
|
94
|
+
- **Agent Storage & Retrieval**: Store complete agent configurations including instructions, model settings, tools, workflows, nested agents, scorers, processors, and memory configuration
|
|
95
|
+
- **Version Management**: Create and manage multiple versions of agents, with support for activating specific versions
|
|
96
|
+
- **Dependency Resolution**: Automatically resolves and instantiates all agent dependencies (tools, workflows, sub-agents, etc.) from the Mastra registry
|
|
97
|
+
- **Caching**: Built-in caching for improved performance when repeatedly accessing stored agents
|
|
98
|
+
- **Type Safety**: Full TypeScript support with proper typing for stored configurations
|
|
99
|
+
|
|
100
|
+
**Usage Example:**
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
import { MastraEditor } from '@mastra/editor';
|
|
104
|
+
import { Mastra } from '@mastra/core';
|
|
105
|
+
|
|
106
|
+
// Initialize editor with Mastra
|
|
107
|
+
const mastra = new Mastra({
|
|
108
|
+
/* config */
|
|
109
|
+
editor: new MastraEditor(),
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Store an agent configuration
|
|
113
|
+
const agentId = await mastra.storage.stores?.agents?.createAgent({
|
|
114
|
+
name: 'customer-support',
|
|
115
|
+
instructions: 'Help customers with inquiries',
|
|
116
|
+
model: { provider: 'openai', name: 'gpt-4' },
|
|
117
|
+
tools: ['search-kb', 'create-ticket'],
|
|
118
|
+
workflows: ['escalation-flow'],
|
|
119
|
+
memory: { vector: 'pinecone-db' },
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Retrieve and use the stored agent
|
|
123
|
+
const agent = await mastra.getEditor()?.getStoredAgentById(agentId);
|
|
124
|
+
const response = await agent?.generate('How do I reset my password?');
|
|
125
|
+
|
|
126
|
+
// List all stored agents
|
|
127
|
+
const agents = await mastra.getEditor()?.listStoredAgents({ pageSize: 10 });
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Storage Improvements:**
|
|
131
|
+
- Fixed JSONB handling in LibSQL, PostgreSQL, and MongoDB adapters
|
|
132
|
+
- Improved agent resolution queries to properly merge version data
|
|
133
|
+
- Enhanced type safety for serialized configurations
|
|
134
|
+
|
|
135
|
+
### Patch Changes
|
|
136
|
+
|
|
137
|
+
- Updated dependencies [[`e6fc281`](https://github.com/mastra-ai/mastra/commit/e6fc281896a3584e9e06465b356a44fe7faade65), [`97be6c8`](https://github.com/mastra-ai/mastra/commit/97be6c8963130fca8a664fcf99d7b3a38e463595), [`2770921`](https://github.com/mastra-ai/mastra/commit/2770921eec4d55a36b278d15c3a83f694e462ee5), [`b1695db`](https://github.com/mastra-ai/mastra/commit/b1695db2d7be0c329d499619c7881899649188d0), [`5fe1fe0`](https://github.com/mastra-ai/mastra/commit/5fe1fe0109faf2c87db34b725d8a4571a594f80e), [`4133d48`](https://github.com/mastra-ai/mastra/commit/4133d48eaa354cdb45920dc6265732ffbc96788d), [`5dd01cc`](https://github.com/mastra-ai/mastra/commit/5dd01cce68d61874aa3ecbd91ee17884cfd5aca2), [`13e0a2a`](https://github.com/mastra-ai/mastra/commit/13e0a2a2bcec01ff4d701274b3727d5e907a6a01), [`f6673b8`](https://github.com/mastra-ai/mastra/commit/f6673b893b65b7d273ad25ead42e990704cc1e17), [`cd6be8a`](https://github.com/mastra-ai/mastra/commit/cd6be8ad32741cd41cabf508355bb31b71e8a5bd), [`9eb4e8e`](https://github.com/mastra-ai/mastra/commit/9eb4e8e39efbdcfff7a40ff2ce07ce2714c65fa8), [`c987384`](https://github.com/mastra-ai/mastra/commit/c987384d6c8ca844a9701d7778f09f5a88da7f9f), [`cb8cc12`](https://github.com/mastra-ai/mastra/commit/cb8cc12bfadd526aa95a01125076f1da44e4afa7), [`aa37c84`](https://github.com/mastra-ai/mastra/commit/aa37c84d29b7db68c72517337932ef486c316275), [`62f5d50`](https://github.com/mastra-ai/mastra/commit/62f5d5043debbba497dacb7ab008fe86b38b8de3), [`47eba72`](https://github.com/mastra-ai/mastra/commit/47eba72f0397d0d14fbe324b97940c3d55e5a525)]:
|
|
138
|
+
- @mastra/core@1.2.0
|
|
139
|
+
- @mastra/memory@1.1.0
|
|
140
|
+
|
|
141
|
+
## 0.2.0-alpha.0
|
|
142
|
+
|
|
143
|
+
### Minor Changes
|
|
144
|
+
|
|
145
|
+
- Created @mastra/editor package for managing and resolving stored agent configurations ([#12631](https://github.com/mastra-ai/mastra/pull/12631))
|
|
146
|
+
|
|
147
|
+
This major addition introduces the editor package, which provides a complete solution for storing, versioning, and instantiating agent configurations from a database. The editor seamlessly integrates with Mastra's storage layer to enable dynamic agent management.
|
|
148
|
+
|
|
149
|
+
**Key Features:**
|
|
150
|
+
- **Agent Storage & Retrieval**: Store complete agent configurations including instructions, model settings, tools, workflows, nested agents, scorers, processors, and memory configuration
|
|
151
|
+
- **Version Management**: Create and manage multiple versions of agents, with support for activating specific versions
|
|
152
|
+
- **Dependency Resolution**: Automatically resolves and instantiates all agent dependencies (tools, workflows, sub-agents, etc.) from the Mastra registry
|
|
153
|
+
- **Caching**: Built-in caching for improved performance when repeatedly accessing stored agents
|
|
154
|
+
- **Type Safety**: Full TypeScript support with proper typing for stored configurations
|
|
155
|
+
|
|
156
|
+
**Usage Example:**
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
import { MastraEditor } from '@mastra/editor';
|
|
160
|
+
import { Mastra } from '@mastra/core';
|
|
161
|
+
|
|
162
|
+
// Initialize editor with Mastra
|
|
163
|
+
const mastra = new Mastra({
|
|
164
|
+
/* config */
|
|
165
|
+
editor: new MastraEditor(),
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// Store an agent configuration
|
|
169
|
+
const agentId = await mastra.storage.stores?.agents?.createAgent({
|
|
170
|
+
name: 'customer-support',
|
|
171
|
+
instructions: 'Help customers with inquiries',
|
|
172
|
+
model: { provider: 'openai', name: 'gpt-4' },
|
|
173
|
+
tools: ['search-kb', 'create-ticket'],
|
|
174
|
+
workflows: ['escalation-flow'],
|
|
175
|
+
memory: { vector: 'pinecone-db' },
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// Retrieve and use the stored agent
|
|
179
|
+
const agent = await mastra.getEditor()?.getStoredAgentById(agentId);
|
|
180
|
+
const response = await agent?.generate('How do I reset my password?');
|
|
181
|
+
|
|
182
|
+
// List all stored agents
|
|
183
|
+
const agents = await mastra.getEditor()?.listStoredAgents({ pageSize: 10 });
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**Storage Improvements:**
|
|
187
|
+
- Fixed JSONB handling in LibSQL, PostgreSQL, and MongoDB adapters
|
|
188
|
+
- Improved agent resolution queries to properly merge version data
|
|
189
|
+
- Enhanced type safety for serialized configurations
|
|
190
|
+
|
|
191
|
+
### Patch Changes
|
|
192
|
+
|
|
193
|
+
- Updated dependencies [[`2770921`](https://github.com/mastra-ai/mastra/commit/2770921eec4d55a36b278d15c3a83f694e462ee5), [`b1695db`](https://github.com/mastra-ai/mastra/commit/b1695db2d7be0c329d499619c7881899649188d0), [`4133d48`](https://github.com/mastra-ai/mastra/commit/4133d48eaa354cdb45920dc6265732ffbc96788d), [`5dd01cc`](https://github.com/mastra-ai/mastra/commit/5dd01cce68d61874aa3ecbd91ee17884cfd5aca2), [`13e0a2a`](https://github.com/mastra-ai/mastra/commit/13e0a2a2bcec01ff4d701274b3727d5e907a6a01), [`c987384`](https://github.com/mastra-ai/mastra/commit/c987384d6c8ca844a9701d7778f09f5a88da7f9f), [`cb8cc12`](https://github.com/mastra-ai/mastra/commit/cb8cc12bfadd526aa95a01125076f1da44e4afa7), [`62f5d50`](https://github.com/mastra-ai/mastra/commit/62f5d5043debbba497dacb7ab008fe86b38b8de3)]:
|
|
194
|
+
- @mastra/memory@1.1.0-alpha.1
|
|
195
|
+
- @mastra/core@1.2.0-alpha.1
|
|
196
|
+
|
|
197
|
+
## 0.1.0
|
|
198
|
+
|
|
199
|
+
### Minor Changes
|
|
200
|
+
|
|
201
|
+
- Initial release of @mastra/editor
|
|
202
|
+
- Agent storage and retrieval from database
|
|
203
|
+
- Dynamic agent creation from stored configurations
|
|
204
|
+
- Support for tools, workflows, nested agents, memory, and scorers
|
|
205
|
+
- Integration with Mastra core for seamless agent management
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Apache License 2.0
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|