@mastra/editor 0.13.14-alpha.1 → 0.13.14-alpha.2

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,39 @@
1
1
  # @mastra/editor
2
2
 
3
+ ## 0.13.14-alpha.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed editor-owned agent instructions failing silently. Agents configured with `editor: { instructions: true }` now throw a clear error instead of running with empty instructions when no published version is available in Studio. This affected agents that were never provisioned, only had a draft version, were deleted, had a published version with no instructions, or hit a storage error while loading. Fixes https://github.com/mastra-ai/mastra/issues/21373 ([#21395](https://github.com/mastra-ai/mastra/pull/21395))
8
+
9
+ **Before:** the agent ran normally with an empty system prompt.
10
+
11
+ **After:** resolving or generating with the agent throws until a published version with instructions exists.
12
+
13
+ ```ts
14
+ // Agent definition — Studio owns the instructions:
15
+ export const agent = new Agent({
16
+ id: 'support-agent',
17
+ editor: { instructions: true },
18
+ model: 'openai/gpt-4o',
19
+ });
20
+ ```
21
+
22
+ ```ts
23
+ // Throws until a version is published in Studio:
24
+ const agent = client.getAgent('support-agent', { status: 'published' });
25
+ await agent.generate('hi');
26
+
27
+ // Use status: 'draft' to run against the latest draft instead, without publishing:
28
+ const draftAgent = client.getAgent('support-agent', { status: 'draft' });
29
+ await draftAgent.generate('hi');
30
+ ```
31
+
32
+ - Updated dependencies [[`d7e6745`](https://github.com/mastra-ai/mastra/commit/d7e67456954863c55440ea9c49bc6ceb9949972d), [`9acb50f`](https://github.com/mastra-ai/mastra/commit/9acb50f71cec9c362f06820033f90ae6b1f8282f), [`46e9e3f`](https://github.com/mastra-ai/mastra/commit/46e9e3f73babe1bc70080a596cf2ac0b9da48519), [`3f9a190`](https://github.com/mastra-ai/mastra/commit/3f9a19057c027155867b9317294ee4ca7bd0581a), [`e8808e3`](https://github.com/mastra-ai/mastra/commit/e8808e3d8eb585a2565be53e56a7e0e1477352a4), [`eede4de`](https://github.com/mastra-ai/mastra/commit/eede4de104f59b391d28aa249659388e9a1cf558), [`eede4de`](https://github.com/mastra-ai/mastra/commit/eede4de104f59b391d28aa249659388e9a1cf558), [`d4be8c1`](https://github.com/mastra-ai/mastra/commit/d4be8c1739d22d621e3f78790e1dd5eb5ecc3589), [`a5d2eb1`](https://github.com/mastra-ai/mastra/commit/a5d2eb10347eade1ae2816d88f466c25186c54a5), [`13d49d8`](https://github.com/mastra-ai/mastra/commit/13d49d82f434f319d4bd9a4234369d8186f8e102), [`a97044b`](https://github.com/mastra-ai/mastra/commit/a97044b00cc79e189b07509701b2694c728dfeac), [`e81744c`](https://github.com/mastra-ai/mastra/commit/e81744cd13c46619c142dc521dc0baac47607a84)]:
33
+ - @mastra/core@1.60.0-alpha.4
34
+ - @mastra/memory@1.27.0-alpha.0
35
+ - @mastra/mcp@1.17.0-alpha.0
36
+
3
37
  ## 0.13.14-alpha.1
4
38
 
5
39
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -860,6 +860,11 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
860
860
  const toolsConfig = editorConfig === void 0 ? true : editorConfig.tools;
861
861
  const toolsEditable = toolsConfig === true;
862
862
  const toolDescriptionsEditable = typeof toolsConfig === "object" && toolsConfig !== null && toolsConfig.description === true;
863
+ const instructionsOwnedByEditor = editorConfig !== void 0 && editorConfig.instructions === true;
864
+ const requestedStatus = options && !("versionId" in options) ? options.status ?? "draft" : void 0;
865
+ const failClosed = (reason) => {
866
+ throw new Error(`Agent "${agent.id}" delegates instructions to the editor ("editor: { instructions: true }") but ${reason}. Publish a version in Studio before running this agent${requestedStatus === "published" ? ", or request status: 'draft' instead" : ""}.`);
867
+ };
863
868
  let storedConfig = null;
864
869
  try {
865
870
  this.ensureRegistered();
@@ -868,10 +873,18 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
868
873
  storedConfig = await adapter.getByIdResolved(agent.id, resolvedOptions);
869
874
  } catch (error) {
870
875
  if (options && "versionId" in options) throw error;
876
+ if (instructionsOwnedByEditor) throw new Error(`Agent "${agent.id}" delegates instructions to the editor ("editor: { instructions: true }") but the stored configuration could not be loaded: ${error instanceof Error ? error.message : String(error)}`);
877
+ return agent;
878
+ }
879
+ if (!storedConfig) {
880
+ if (instructionsOwnedByEditor) failClosed("no stored agent configuration exists yet");
881
+ return agent;
882
+ }
883
+ if (options && !("versionId" in options) && options.status === "published" && !storedConfig.activeVersionId) {
884
+ if (instructionsOwnedByEditor) failClosed("no version has been published");
871
885
  return agent;
872
886
  }
873
- if (!storedConfig) return agent;
874
- if (options && !("versionId" in options) && options.status === "published" && !storedConfig.activeVersionId) return agent;
887
+ if (instructionsOwnedByEditor && (storedConfig.instructions === void 0 || storedConfig.instructions === null)) failClosed("the stored agent configuration has no instructions");
875
888
  const fork = agent.__fork();
876
889
  this.logger?.debug(`[applyStoredOverrides] Applying stored overrides to code agent "${agent.id}"`);
877
890
  if (instructionsEditable && storedConfig.instructions !== void 0 && storedConfig.instructions !== null) {