@mastra/editor 0.3.0-alpha.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/CHANGELOG.md +192 -0
  2. package/package.json +7 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,197 @@
1
1
  # @mastra/editor
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added `requestContextSchema` and rule-based conditional fields for stored agents. ([#12896](https://github.com/mastra-ai/mastra/pull/12896))
8
+
9
+ Stored agent fields (`tools`, `model`, `workflows`, `agents`, `memory`, `scorers`, `inputProcessors`, `outputProcessors`, `defaultOptions`) can now be configured as conditional variants with rule groups that evaluate against request context at runtime. All matching variants accumulate — arrays are concatenated and objects are shallow-merged — so agents dynamically compose their configuration based on the incoming request context.
10
+
11
+ **New `requestContextSchema` field**
12
+
13
+ Stored agents now accept an optional `requestContextSchema` (JSON Schema) that is converted to a Zod schema and passed to the Agent constructor, enabling request context validation.
14
+
15
+ **Conditional field example**
16
+
17
+ ```ts
18
+ await agentsStore.create({
19
+ agent: {
20
+ id: 'my-agent',
21
+ name: 'My Agent',
22
+ instructions: 'You are a helpful assistant',
23
+ model: { provider: 'openai', name: 'gpt-4' },
24
+ tools: [
25
+ { value: { 'basic-tool': {} } },
26
+ {
27
+ value: { 'premium-tool': {} },
28
+ rules: {
29
+ operator: 'AND',
30
+ conditions: [{ field: 'tier', operator: 'equals', value: 'premium' }],
31
+ },
32
+ },
33
+ ],
34
+ requestContextSchema: {
35
+ type: 'object',
36
+ properties: { tier: { type: 'string' } },
37
+ },
38
+ },
39
+ });
40
+ ```
41
+
42
+ - 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. ([#12861](https://github.com/mastra-ai/mastra/pull/12861))
43
+
44
+ **Instruction blocks** can be mixed in an agent's instructions array:
45
+ - `text` — static text with `{{variable}}` interpolation
46
+ - `prompt_block_ref` — reference to a versioned prompt block stored in the database
47
+ - `prompt_block` — inline prompt block with optional conditional rules
48
+
49
+ **Creating a prompt block and using it in a stored agent:**
50
+
51
+ ```ts
52
+ // Create a reusable prompt block
53
+ const block = await editor.createPromptBlock({
54
+ id: 'security-rules',
55
+ name: 'Security Rules',
56
+ content: "You must verify the user's identity. The user's role is {{user.role}}.",
57
+ rules: {
58
+ operator: 'AND',
59
+ conditions: [{ field: 'user.isAuthenticated', operator: 'equals', value: true }],
60
+ },
61
+ });
62
+
63
+ // Create a stored agent that references the prompt block
64
+ await editor.createStoredAgent({
65
+ id: 'support-agent',
66
+ name: 'Support Agent',
67
+ instructions: [
68
+ { type: 'text', content: 'You are a helpful support agent for {{company}}.' },
69
+ { type: 'prompt_block_ref', id: 'security-rules' },
70
+ {
71
+ type: 'prompt_block',
72
+ content: 'Always be polite.',
73
+ rules: { operator: 'AND', conditions: [{ field: 'tone', operator: 'equals', value: 'formal' }] },
74
+ },
75
+ ],
76
+ model: { provider: 'openai', name: 'gpt-4o' },
77
+ });
78
+
79
+ // At runtime, instructions resolve dynamically based on request context
80
+ const agent = await editor.getStoredAgentById('support-agent');
81
+ const result = await agent.generate('Help me reset my password', {
82
+ requestContext: new RequestContext([
83
+ ['company', 'Acme Corp'],
84
+ ['user.isAuthenticated', true],
85
+ ['user.role', 'admin'],
86
+ ['tone', 'formal'],
87
+ ]),
88
+ });
89
+ ```
90
+
91
+ Prompt blocks are versioned — updating a block's content takes effect immediately for all agents referencing it, with no cache clearing required.
92
+
93
+ - **Added stored scorer definitions, editor namespace pattern, and generic storage domains** ([#12846](https://github.com/mastra-ai/mastra/pull/12846))
94
+ - Added a new `scorer-definitions` storage domain for storing LLM-as-judge and preset scorer configurations in the database
95
+ - Introduced a `VersionedStorageDomain` generic base class that unifies `AgentsStorage`, `PromptBlocksStorage`, and `ScorerDefinitionsStorage` with shared CRUD methods (`create`, `getById`, `getByIdResolved`, `update`, `delete`, `list`, `listResolved`)
96
+ - Flattened stored scorer type system: replaced nested `preset`/`customLLMJudge` config with top-level `type`, `instructions`, `scoreRange`, and `presetConfig` fields
97
+ - Refactored `MastraEditor` to use a namespace pattern (`editor.agent.*`, `editor.scorer.*`, `editor.prompt.*`) backed by a `CrudEditorNamespace` base class with built-in caching and an `onCacheEvict` hook
98
+ - Added `rawConfig` support to `MastraBase` and `MastraScorer` via `toRawConfig()`, so hydrated primitives carry their stored configuration
99
+ - Added prompt block and scorer registration to the `Mastra` class (`addPromptBlock`, `removePromptBlock`, `addScorer`, `removeScorer`)
100
+
101
+ **Creating a stored scorer (LLM-as-judge):**
102
+
103
+ ```ts
104
+ const scorer = await editor.scorer.create({
105
+ id: 'my-scorer',
106
+ name: 'Response Quality',
107
+ type: 'llm-judge',
108
+ instructions: 'Evaluate the response for accuracy and helpfulness.',
109
+ model: { provider: 'openai', name: 'gpt-4o' },
110
+ scoreRange: { min: 0, max: 1 },
111
+ });
112
+ ```
113
+
114
+ **Retrieving and resolving a stored scorer:**
115
+
116
+ ```ts
117
+ // Fetch the stored definition from DB
118
+ const definition = await editor.scorer.getById('my-scorer');
119
+
120
+ // Resolve it into a runnable MastraScorer instance
121
+ const runnableScorer = editor.scorer.resolve(definition);
122
+
123
+ // Execute the scorer
124
+ const result = await runnableScorer.run({
125
+ input: 'What is the capital of France?',
126
+ output: 'The capital of France is Paris.',
127
+ });
128
+ ```
129
+
130
+ **Editor namespace pattern (before/after):**
131
+
132
+ ```ts
133
+ // Before
134
+ const agent = await editor.getStoredAgentById('abc');
135
+ const prompts = await editor.listPromptBlocks();
136
+
137
+ // After
138
+ const agent = await editor.agent.getById('abc');
139
+ const prompts = await editor.prompt.list();
140
+ ```
141
+
142
+ **Generic storage domain methods (before/after):**
143
+
144
+ ```ts
145
+ // Before
146
+ const store = storage.getStore('agents');
147
+ await store.createAgent({ agent: input });
148
+ await store.getAgentById({ id: 'abc' });
149
+ await store.deleteAgent({ id: 'abc' });
150
+
151
+ // After
152
+ const store = storage.getStore('agents');
153
+ await store.create({ agent: input });
154
+ await store.getById('abc');
155
+ await store.delete('abc');
156
+ ```
157
+
158
+ - Add tool description overrides for stored agents: ([#12794](https://github.com/mastra-ai/mastra/pull/12794))
159
+ - Changed stored agent `tools` field from `string[]` to `Record<string, { description?: string }>` to allow per-tool description overrides
160
+ - When a stored agent specifies a custom `description` for a tool, the override is applied at resolution time
161
+ - Updated server API schemas, client SDK types, and editor resolution logic accordingly
162
+
163
+ - **Breaking:** Removed `cloneAgent()` from the `Agent` class. Agent cloning is now handled by the editor package via `editor.agent.clone()`. ([#12904](https://github.com/mastra-ai/mastra/pull/12904))
164
+
165
+ If you were calling `agent.cloneAgent()` directly, use the editor's agent namespace instead:
166
+
167
+ ```ts
168
+ // Before
169
+ const result = await agent.cloneAgent({ newId: 'my-clone' });
170
+
171
+ // After
172
+ const editor = mastra.getEditor();
173
+ const result = await editor.agent.clone(agent, { newId: 'my-clone' });
174
+ ```
175
+
176
+ **Why:** The `Agent` class should not be responsible for storage serialization. The editor package already handles converting between runtime agents and stored configurations, so cloning belongs there.
177
+
178
+ **Added** `getConfiguredProcessorIds()` to the `Agent` class, which returns raw input/output processor IDs for the agent's configuration.
179
+
180
+ ### Patch Changes
181
+
182
+ - 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))
183
+
184
+ - Fixed stored scorers not being registered on the Mastra instance. Scorers created via the editor are now automatically discoverable through `mastra.getScorer()` and `mastra.getScorerById()`, matching the existing behavior of stored agents. Previously, stored scorers could only be resolved inline but were invisible to the runtime registry, causing lookups to fail. ([#12903](https://github.com/mastra-ai/mastra/pull/12903))
185
+
186
+ - Fix memory persistence: ([#12704](https://github.com/mastra-ai/mastra/pull/12704))
187
+ - Fixed memory persistence bug by handling missing vector store gracefully
188
+ - When semantic recall is enabled but no vector store is configured, it now disables semantic recall instead of failing
189
+ - Fixed type compatibility for `embedder` field when creating agents from stored config
190
+
191
+ - Updated dependencies [[`717ffab`](https://github.com/mastra-ai/mastra/commit/717ffab42cfd58ff723b5c19ada4939997773004), [`b31c922`](https://github.com/mastra-ai/mastra/commit/b31c922215b513791d98feaea1b98784aa00803a), [`e4b6dab`](https://github.com/mastra-ai/mastra/commit/e4b6dab171c5960e340b3ea3ea6da8d64d2b8672), [`5719fa8`](https://github.com/mastra-ai/mastra/commit/5719fa8880e86e8affe698ec4b3807c7e0e0a06f), [`83cda45`](https://github.com/mastra-ai/mastra/commit/83cda4523e588558466892bff8f80f631a36945a), [`11804ad`](https://github.com/mastra-ai/mastra/commit/11804adf1d6be46ebe216be40a43b39bb8b397d7), [`2e02cd7`](https://github.com/mastra-ai/mastra/commit/2e02cd7e08ba2d84a275c80d80c069d2b8b66211), [`aa95f95`](https://github.com/mastra-ai/mastra/commit/aa95f958b186ae5c9f4219c88e268f5565c277a2), [`90f7894`](https://github.com/mastra-ai/mastra/commit/90f7894568dc9481f40a4d29672234fae23090bb), [`f5501ae`](https://github.com/mastra-ai/mastra/commit/f5501aedb0a11106c7db7e480d6eaf3971b7bda8), [`44573af`](https://github.com/mastra-ai/mastra/commit/44573afad0a4bc86f627d6cbc0207961cdcb3bc3), [`00e3861`](https://github.com/mastra-ai/mastra/commit/00e3861863fbfee78faeb1ebbdc7c0223aae13ff), [`8109aee`](https://github.com/mastra-ai/mastra/commit/8109aeeab758e16cd4255a6c36f044b70eefc6a6), [`7bfbc52`](https://github.com/mastra-ai/mastra/commit/7bfbc52a8604feb0fff2c0a082c13c0c2a3df1a2), [`1445994`](https://github.com/mastra-ai/mastra/commit/1445994aee19c9334a6a101cf7bd80ca7ed4d186), [`61f44a2`](https://github.com/mastra-ai/mastra/commit/61f44a26861c89e364f367ff40825bdb7f19df55), [`37145d2`](https://github.com/mastra-ai/mastra/commit/37145d25f99dc31f1a9105576e5452609843ce32), [`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), [`44eb452`](https://github.com/mastra-ai/mastra/commit/44eb4529b10603c279688318bebf3048543a1d61), [`6c40593`](https://github.com/mastra-ai/mastra/commit/6c40593d6d2b1b68b0c45d1a3a4c6ac5ecac3937), [`8c1135d`](https://github.com/mastra-ai/mastra/commit/8c1135dfb91b057283eae7ee11f9ec28753cc64f), [`dd39e54`](https://github.com/mastra-ai/mastra/commit/dd39e54ea34532c995b33bee6e0e808bf41a7341), [`b6fad9a`](https://github.com/mastra-ai/mastra/commit/b6fad9a602182b1cc0df47cd8c55004fa829ad61), [`4129c07`](https://github.com/mastra-ai/mastra/commit/4129c073349b5a66643fd8136ebfe9d7097cf793), [`5b930ab`](https://github.com/mastra-ai/mastra/commit/5b930aba1834d9898e8460a49d15106f31ac7c8d), [`4be93d0`](https://github.com/mastra-ai/mastra/commit/4be93d09d68e20aaf0ea3f210749422719618b5f), [`047635c`](https://github.com/mastra-ai/mastra/commit/047635ccd7861d726c62d135560c0022a5490aec), [`8c90ff4`](https://github.com/mastra-ai/mastra/commit/8c90ff4d3414e7f2a2d216ea91274644f7b29133), [`ed232d1`](https://github.com/mastra-ai/mastra/commit/ed232d1583f403925dc5ae45f7bee948cf2a182b), [`3891795`](https://github.com/mastra-ai/mastra/commit/38917953518eb4154a984ee36e6ededdcfe80f72), [`4f955b2`](https://github.com/mastra-ai/mastra/commit/4f955b20c7f66ed282ee1fd8709696fa64c4f19d), [`55a4c90`](https://github.com/mastra-ai/mastra/commit/55a4c9044ac7454349b9f6aeba0bbab5ee65d10f)]:
192
+ - @mastra/core@1.3.0
193
+ - @mastra/memory@1.2.0
194
+
3
195
  ## 0.3.0-alpha.3
4
196
 
5
197
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/editor",
3
- "version": "0.3.0-alpha.3",
3
+ "version": "0.3.0",
4
4
  "description": "Mastra Editor for agent management and instantiation",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "url": "https://github.com/mastra-ai/mastra/issues"
21
21
  },
22
22
  "dependencies": {
23
- "@mastra/memory": "1.2.0-alpha.2",
23
+ "@mastra/memory": "1.2.0",
24
24
  "@mastra/schema-compat": "1.1.0"
25
25
  },
26
26
  "devDependencies": {
@@ -28,11 +28,11 @@
28
28
  "typescript": "^5.9.3",
29
29
  "vitest": "4.0.16",
30
30
  "zod": "^3.25.76",
31
- "@internal/ai-sdk-v4": "0.0.4",
32
- "@internal/ai-sdk-v5": "0.0.4",
33
- "@internal/ai-v6": "0.0.4",
34
- "@mastra/libsql": "1.3.0-alpha.1",
35
- "@mastra/core": "1.3.0-alpha.2"
31
+ "@internal/ai-sdk-v4": "0.0.5",
32
+ "@internal/ai-sdk-v5": "0.0.5",
33
+ "@mastra/core": "1.3.0",
34
+ "@mastra/libsql": "1.3.0",
35
+ "@internal/ai-v6": "0.0.5"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@mastra/core": ">=1.0.0-0 <2.0.0-0",