@mastra/editor 0.13.14-alpha.0 → 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 +43 -0
- package/dist/index.cjs +18 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -8
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
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
|
+
|
|
37
|
+
## 0.13.14-alpha.1
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- Keep agent snapshot updates as drafts until explicitly published. ([#21528](https://github.com/mastra-ai/mastra/pull/21528))
|
|
42
|
+
|
|
43
|
+
- Updated dependencies [[`7e096f0`](https://github.com/mastra-ai/mastra/commit/7e096f02f0dddbf09b85d306458351245ed2f886), [`8f0a332`](https://github.com/mastra-ai/mastra/commit/8f0a3321bf180368d76fe7b36aa1a8f60f00b6de), [`b098de9`](https://github.com/mastra-ai/mastra/commit/b098de9d7cb9f672e0883a5c716465a3a689693d), [`ef6e295`](https://github.com/mastra-ai/mastra/commit/ef6e295b59bc25a5b61b633a89c97bcfce9fb465), [`208e1b3`](https://github.com/mastra-ai/mastra/commit/208e1b39f30f4b386e494394e9d71d96f0f90241), [`c938d34`](https://github.com/mastra-ai/mastra/commit/c938d34739936c8ecbabd67ad6a4a4396f41c4c6), [`1d9a0ea`](https://github.com/mastra-ai/mastra/commit/1d9a0ea4a9901baee6cd56737243bd6d1f631ac0), [`3667679`](https://github.com/mastra-ai/mastra/commit/3667679db057edfb086846d13369fdda4902ad65), [`49696e8`](https://github.com/mastra-ai/mastra/commit/49696e8e42f870674a0a58f5abcd22cc54dd2864), [`512100a`](https://github.com/mastra-ai/mastra/commit/512100a7d8b7e9c920f2590c6b3612f5de0d3cff), [`9ef432b`](https://github.com/mastra-ai/mastra/commit/9ef432b6faa534b57b0d182a610e13dd9a7123ff), [`b9cf308`](https://github.com/mastra-ai/mastra/commit/b9cf30846f97f99ac1906ee8a68f4f2d117b0378)]:
|
|
44
|
+
- @mastra/core@1.60.0-alpha.2
|
|
45
|
+
|
|
3
46
|
## 0.13.14-alpha.0
|
|
4
47
|
|
|
5
48
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -707,18 +707,15 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
|
|
|
707
707
|
if (!await store.getById(input.id)) throw new Error(`Agent with id ${input.id} not found`);
|
|
708
708
|
const providedConfig = getProvidedSnapshotFields(input, AGENT_SNAPSHOT_CONFIG_FIELDS);
|
|
709
709
|
if ("workspace" in providedConfig) await this.ensureStoredWorkspaceRefs(providedConfig.workspace);
|
|
710
|
-
|
|
710
|
+
if (Object.keys(providedConfig).length > 0) await createVersionFromSnapshotUpdate({
|
|
711
711
|
store,
|
|
712
712
|
parentId: input.id,
|
|
713
713
|
parentIdField: "agentId",
|
|
714
714
|
snapshotFields: AGENT_SNAPSHOT_CONFIG_FIELDS,
|
|
715
715
|
providedConfig
|
|
716
|
-
}) : { versionCreated: false };
|
|
717
|
-
const recordFields = getProvidedAgentRecordFields(input);
|
|
718
|
-
if (recordFields || versionResult.versionCreated) await store.update({
|
|
719
|
-
...recordFields ?? { id: input.id },
|
|
720
|
-
...versionResult.versionCreated ? { activeVersionId: versionResult.version.id } : {}
|
|
721
716
|
});
|
|
717
|
+
const recordFields = getProvidedAgentRecordFields(input);
|
|
718
|
+
if (recordFields) await store.update(recordFields);
|
|
722
719
|
this._cache.delete(input.id);
|
|
723
720
|
this.onCacheEvict(input.id);
|
|
724
721
|
const existingCodeAgent = this.getCodeDefinedAgent(input.id);
|
|
@@ -863,6 +860,11 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
|
|
|
863
860
|
const toolsConfig = editorConfig === void 0 ? true : editorConfig.tools;
|
|
864
861
|
const toolsEditable = toolsConfig === true;
|
|
865
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
|
+
};
|
|
866
868
|
let storedConfig = null;
|
|
867
869
|
try {
|
|
868
870
|
this.ensureRegistered();
|
|
@@ -871,10 +873,18 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
|
|
|
871
873
|
storedConfig = await adapter.getByIdResolved(agent.id, resolvedOptions);
|
|
872
874
|
} catch (error) {
|
|
873
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");
|
|
874
885
|
return agent;
|
|
875
886
|
}
|
|
876
|
-
if (
|
|
877
|
-
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");
|
|
878
888
|
const fork = agent.__fork();
|
|
879
889
|
this.logger?.debug(`[applyStoredOverrides] Applying stored overrides to code agent "${agent.id}"`);
|
|
880
890
|
if (instructionsEditable && storedConfig.instructions !== void 0 && storedConfig.instructions !== null) {
|