@mastra/editor 0.2.0 → 0.2.1-alpha.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @mastra/editor
2
2
 
3
+ ## 0.2.1-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 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))
8
+
9
+ - Fix memory persistence: ([#12704](https://github.com/mastra-ai/mastra/pull/12704))
10
+ - Fixed memory persistence bug by handling missing vector store gracefully
11
+ - When semantic recall is enabled but no vector store is configured, it now disables semantic recall instead of failing
12
+ - Fixed type compatibility for `embedder` field when creating agents from stored config
13
+
14
+ - Updated dependencies [[`90f7894`](https://github.com/mastra-ai/mastra/commit/90f7894568dc9481f40a4d29672234fae23090bb), [`8109aee`](https://github.com/mastra-ai/mastra/commit/8109aeeab758e16cd4255a6c36f044b70eefc6a6)]:
15
+ - @mastra/core@1.2.1-alpha.0
16
+
3
17
  ## 0.2.0
4
18
 
5
19
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -115,7 +115,6 @@ var MastraEditor = class {
115
115
  if (agentCache2) {
116
116
  const cached = agentCache2.get(id);
117
117
  if (cached) {
118
- this.logger?.debug(`[getStoredAgentById] Returning cached agent "${id}"`);
119
118
  return cached;
120
119
  }
121
120
  this.logger?.debug(`[getStoredAgentById] Cache miss for agent "${id}", fetching from storage`);
@@ -161,16 +160,22 @@ var MastraEditor = class {
161
160
  }
162
161
  /**
163
162
  * Clear the stored agent cache for a specific agent ID, or all cached agents.
163
+ * When clearing a specific agent, also removes it from Mastra's agent registry
164
+ * so that fresh data is loaded on next access.
164
165
  */
165
166
  clearStoredAgentCache(agentId) {
166
167
  if (!this.mastra) return;
167
168
  const agentCache = this.mastra.getStoredAgentCache();
168
- if (!agentCache) return;
169
169
  if (agentId) {
170
- agentCache.delete(agentId);
171
- this.logger?.debug(`[clearStoredAgentCache] Cleared cache for agent "${agentId}"`);
170
+ if (agentCache) {
171
+ agentCache.delete(agentId);
172
+ }
173
+ this.mastra.removeAgent(agentId);
174
+ this.logger?.debug(`[clearStoredAgentCache] Cleared cache and registry for agent "${agentId}"`);
172
175
  } else {
173
- agentCache.clear();
176
+ if (agentCache) {
177
+ agentCache.clear();
178
+ }
174
179
  this.logger?.debug("[clearStoredAgentCache] Cleared all cached agents");
175
180
  }
176
181
  }
@@ -188,10 +193,6 @@ var MastraEditor = class {
188
193
  const workflows = this.resolveStoredWorkflows(storedAgent.workflows);
189
194
  const agents = this.resolveStoredAgents(storedAgent.agents);
190
195
  const memory = this.resolveStoredMemory(storedAgent.memory);
191
- console.log(
192
- `[createAgentFromStoredConfig] Resolved memory: ${memory ? "Memory instance created" : "No memory"} for agent "${storedAgent.id}"`,
193
- { memory }
194
- );
195
196
  const scorers = this.resolveStoredScorers(storedAgent.scorers);
196
197
  const inputProcessors = this.resolveStoredInputProcessors(storedAgent.inputProcessors);
197
198
  const outputProcessors = this.resolveStoredOutputProcessors(storedAgent.outputProcessors);
@@ -310,7 +311,6 @@ var MastraEditor = class {
310
311
  * Uses @mastra/memory Memory class to instantiate from serialized config.
311
312
  */
312
313
  resolveStoredMemory(memoryConfig) {
313
- this.logger?.debug(`[resolveStoredMemory] Called with config:`, { memoryConfig });
314
314
  if (!memoryConfig) {
315
315
  this.logger?.debug(`[resolveStoredMemory] No memory config provided`);
316
316
  return void 0;
@@ -328,14 +328,31 @@ var MastraEditor = class {
328
328
  this.logger?.warn(`Vector provider "${memoryConfig.vector}" not found in Mastra instance`);
329
329
  }
330
330
  }
331
+ if (memoryConfig.options?.semanticRecall && (!vector || !memoryConfig.embedder)) {
332
+ this.logger?.warn(
333
+ "Semantic recall is enabled but no vector store or embedder are configured. Creating memory without semantic recall. To use semantic recall, configure a vector store and embedder in your Mastra instance."
334
+ );
335
+ const adjustedOptions = { ...memoryConfig.options, semanticRecall: false };
336
+ const sharedConfig2 = {
337
+ storage: this.mastra.getStorage(),
338
+ vector,
339
+ options: adjustedOptions,
340
+ embedder: memoryConfig.embedder,
341
+ embedderOptions: memoryConfig.embedderOptions
342
+ };
343
+ const memoryInstance2 = new import_memory.Memory(sharedConfig2);
344
+ return memoryInstance2;
345
+ }
346
+ const storage = this.mastra.getStorage();
331
347
  const sharedConfig = {
332
- storage: this.mastra.getStorage(),
348
+ storage,
333
349
  vector,
334
350
  options: memoryConfig.options,
335
351
  embedder: memoryConfig.embedder,
336
352
  embedderOptions: memoryConfig.embedderOptions
337
353
  };
338
- return new import_memory.Memory(sharedConfig);
354
+ const memoryInstance = new import_memory.Memory(sharedConfig);
355
+ return memoryInstance;
339
356
  } catch (error) {
340
357
  this.logger?.error("Failed to resolve memory from config", { error });
341
358
  return void 0;
package/dist/index.d.cts CHANGED
@@ -56,6 +56,8 @@ declare class MastraEditor implements IMastraEditor {
56
56
  }>;
57
57
  /**
58
58
  * Clear the stored agent cache for a specific agent ID, or all cached agents.
59
+ * When clearing a specific agent, also removes it from Mastra's agent registry
60
+ * so that fresh data is loaded on next access.
59
61
  */
60
62
  clearStoredAgentCache(agentId?: string): void;
61
63
  /**
package/dist/index.d.ts CHANGED
@@ -56,6 +56,8 @@ declare class MastraEditor implements IMastraEditor {
56
56
  }>;
57
57
  /**
58
58
  * Clear the stored agent cache for a specific agent ID, or all cached agents.
59
+ * When clearing a specific agent, also removes it from Mastra's agent registry
60
+ * so that fresh data is loaded on next access.
59
61
  */
60
62
  clearStoredAgentCache(agentId?: string): void;
61
63
  /**
package/dist/index.js CHANGED
@@ -91,7 +91,6 @@ var MastraEditor = class {
91
91
  if (agentCache2) {
92
92
  const cached = agentCache2.get(id);
93
93
  if (cached) {
94
- this.logger?.debug(`[getStoredAgentById] Returning cached agent "${id}"`);
95
94
  return cached;
96
95
  }
97
96
  this.logger?.debug(`[getStoredAgentById] Cache miss for agent "${id}", fetching from storage`);
@@ -137,16 +136,22 @@ var MastraEditor = class {
137
136
  }
138
137
  /**
139
138
  * Clear the stored agent cache for a specific agent ID, or all cached agents.
139
+ * When clearing a specific agent, also removes it from Mastra's agent registry
140
+ * so that fresh data is loaded on next access.
140
141
  */
141
142
  clearStoredAgentCache(agentId) {
142
143
  if (!this.mastra) return;
143
144
  const agentCache = this.mastra.getStoredAgentCache();
144
- if (!agentCache) return;
145
145
  if (agentId) {
146
- agentCache.delete(agentId);
147
- this.logger?.debug(`[clearStoredAgentCache] Cleared cache for agent "${agentId}"`);
146
+ if (agentCache) {
147
+ agentCache.delete(agentId);
148
+ }
149
+ this.mastra.removeAgent(agentId);
150
+ this.logger?.debug(`[clearStoredAgentCache] Cleared cache and registry for agent "${agentId}"`);
148
151
  } else {
149
- agentCache.clear();
152
+ if (agentCache) {
153
+ agentCache.clear();
154
+ }
150
155
  this.logger?.debug("[clearStoredAgentCache] Cleared all cached agents");
151
156
  }
152
157
  }
@@ -164,10 +169,6 @@ var MastraEditor = class {
164
169
  const workflows = this.resolveStoredWorkflows(storedAgent.workflows);
165
170
  const agents = this.resolveStoredAgents(storedAgent.agents);
166
171
  const memory = this.resolveStoredMemory(storedAgent.memory);
167
- console.log(
168
- `[createAgentFromStoredConfig] Resolved memory: ${memory ? "Memory instance created" : "No memory"} for agent "${storedAgent.id}"`,
169
- { memory }
170
- );
171
172
  const scorers = this.resolveStoredScorers(storedAgent.scorers);
172
173
  const inputProcessors = this.resolveStoredInputProcessors(storedAgent.inputProcessors);
173
174
  const outputProcessors = this.resolveStoredOutputProcessors(storedAgent.outputProcessors);
@@ -286,7 +287,6 @@ var MastraEditor = class {
286
287
  * Uses @mastra/memory Memory class to instantiate from serialized config.
287
288
  */
288
289
  resolveStoredMemory(memoryConfig) {
289
- this.logger?.debug(`[resolveStoredMemory] Called with config:`, { memoryConfig });
290
290
  if (!memoryConfig) {
291
291
  this.logger?.debug(`[resolveStoredMemory] No memory config provided`);
292
292
  return void 0;
@@ -304,14 +304,31 @@ var MastraEditor = class {
304
304
  this.logger?.warn(`Vector provider "${memoryConfig.vector}" not found in Mastra instance`);
305
305
  }
306
306
  }
307
+ if (memoryConfig.options?.semanticRecall && (!vector || !memoryConfig.embedder)) {
308
+ this.logger?.warn(
309
+ "Semantic recall is enabled but no vector store or embedder are configured. Creating memory without semantic recall. To use semantic recall, configure a vector store and embedder in your Mastra instance."
310
+ );
311
+ const adjustedOptions = { ...memoryConfig.options, semanticRecall: false };
312
+ const sharedConfig2 = {
313
+ storage: this.mastra.getStorage(),
314
+ vector,
315
+ options: adjustedOptions,
316
+ embedder: memoryConfig.embedder,
317
+ embedderOptions: memoryConfig.embedderOptions
318
+ };
319
+ const memoryInstance2 = new Memory(sharedConfig2);
320
+ return memoryInstance2;
321
+ }
322
+ const storage = this.mastra.getStorage();
307
323
  const sharedConfig = {
308
- storage: this.mastra.getStorage(),
324
+ storage,
309
325
  vector,
310
326
  options: memoryConfig.options,
311
327
  embedder: memoryConfig.embedder,
312
328
  embedderOptions: memoryConfig.embedderOptions
313
329
  };
314
- return new Memory(sharedConfig);
330
+ const memoryInstance = new Memory(sharedConfig);
331
+ return memoryInstance;
315
332
  } catch (error) {
316
333
  this.logger?.error("Failed to resolve memory from config", { error });
317
334
  return void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/editor",
3
- "version": "0.2.0",
3
+ "version": "0.2.1-alpha.0",
4
4
  "description": "Mastra Editor for agent management and instantiation",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -29,8 +29,8 @@
29
29
  "zod": "^3.25.76",
30
30
  "@internal/ai-sdk-v4": "0.0.4",
31
31
  "@internal/ai-v6": "0.0.4",
32
- "@mastra/core": "1.2.0",
33
32
  "@internal/ai-sdk-v5": "0.0.4",
33
+ "@mastra/core": "1.2.1-alpha.0",
34
34
  "@mastra/libsql": "1.2.0"
35
35
  },
36
36
  "peerDependencies": {