@mastra/editor 0.11.2-alpha.1 → 0.12.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,46 @@
1
1
  # @mastra/editor
2
2
 
3
+ ## 0.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added source-backed storage primitives for code-mode agent editing. ([#17582](https://github.com/mastra-ai/mastra/pull/17582))
8
+
9
+ Mastra now exposes a `SourceControlProvider` interface for hosted source-control-backed editor storage, and `MastraEditor` can persist code-mode agent overrides through either local filesystem storage or a source provider.
10
+
11
+ ```ts
12
+ const editor = new MastraEditor({
13
+ source: 'code',
14
+ sourceControlProvider,
15
+ });
16
+ ```
17
+
18
+ Code-defined agents still respect their `editor` ownership config, while source-backed storage can read, write, list history, and open change requests through a provider implementation.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [[`de66bb0`](https://github.com/mastra-ai/mastra/commit/de66bb040570444c702ce4d8e1e228a5de2949cb), [`67bf8e2`](https://github.com/mastra-ai/mastra/commit/67bf8e206dfe583954d96015cf0d09f7ac50e45f), [`8216d05`](https://github.com/mastra-ai/mastra/commit/8216d0528d866eb9a07f5d4c87ea3bb1e1139b45), [`d18b23c`](https://github.com/mastra-ai/mastra/commit/d18b23c5e29dfc381e73e3c51fcf6c779afd1823), [`5eb94eb`](https://github.com/mastra-ai/mastra/commit/5eb94ebcf66d4e28c9e26d5821ac93379bab20a0), [`1fa3e12`](https://github.com/mastra-ai/mastra/commit/1fa3e123582b63cfe49de4ee52dc6a065e8d956a), [`f9ee2ac`](https://github.com/mastra-ai/mastra/commit/f9ee2ac661af584e61bc063ac208c9035cd752ef), [`c853d53`](https://github.com/mastra-ai/mastra/commit/c853d535d2df84ab89db1adb4c28900c54c9a2d2), [`d8df1f8`](https://github.com/mastra-ai/mastra/commit/d8df1f8e947e1966c9d4e54713df56d0d0d65226), [`9192ddb`](https://github.com/mastra-ai/mastra/commit/9192ddbced8949113b30de444cbe763f075b59f5), [`ae96523`](https://github.com/mastra-ai/mastra/commit/ae965231f562d9766b0c90c49a69fc68acaa031c), [`17d5a92`](https://github.com/mastra-ai/mastra/commit/17d5a9211aa293b4d4418de3de70dc0394d58101), [`5573693`](https://github.com/mastra-ai/mastra/commit/5573693b589822250e20dfe6cf66e9ff3bc96da8), [`ec4da8a`](https://github.com/mastra-ai/mastra/commit/ec4da8a09e0d2ab452c6ee2c786042ea826b77e5), [`adc44e1`](https://github.com/mastra-ai/mastra/commit/adc44e13c7e570b91e86b20ea7556e61d819db31), [`218d952`](https://github.com/mastra-ai/mastra/commit/218d952ec09e5111c10ccd143b5bc0ef19434376), [`7c987b4`](https://github.com/mastra-ai/mastra/commit/7c987b4cfcc498bb579f986d07f794633f8e0ff8), [`ed346c0`](https://github.com/mastra-ai/mastra/commit/ed346c0bee2d8496690a4e538bfba1e46894660f), [`9b1adf7`](https://github.com/mastra-ai/mastra/commit/9b1adf7f39943c869182106bc4016e793b3304ac), [`c9ce1b2`](https://github.com/mastra-ai/mastra/commit/c9ce1b28d10871110648f9d7b6d76e880b9fa999), [`3ef01fd`](https://github.com/mastra-ai/mastra/commit/3ef01fd130b53d5bd4f828beb174e516a2eb1158), [`245a9a3`](https://github.com/mastra-ai/mastra/commit/245a9a315705fce17ddd980f78a92504b6615c4a), [`dc0b611`](https://github.com/mastra-ai/mastra/commit/dc0b6119b769bd00ee2c5df9259fb376fe63077a), [`38b5de8`](https://github.com/mastra-ai/mastra/commit/38b5de8e5d1d41a69522addf53d96f4b3a1d5bf0), [`eae1556`](https://github.com/mastra-ai/mastra/commit/eae1556eedac109b67d91b627689cdf70a83bab7), [`efe917d`](https://github.com/mastra-ai/mastra/commit/efe917d524f285d9d131804027c7201bf7aee110), [`dc0b611`](https://github.com/mastra-ai/mastra/commit/dc0b6119b769bd00ee2c5df9259fb376fe63077a), [`dd6a66e`](https://github.com/mastra-ai/mastra/commit/dd6a66ea0b32e0dea8059aec6b35d151e2c87dc4), [`d785c59`](https://github.com/mastra-ai/mastra/commit/d785c593b67fcb4cdc4fab9fdbde5f3b7665efc0), [`1fa3e12`](https://github.com/mastra-ai/mastra/commit/1fa3e123582b63cfe49de4ee52dc6a065e8d956a), [`8b984f4`](https://github.com/mastra-ai/mastra/commit/8b984f4361c202270ceb69257185c4756c9a7c56), [`bf08402`](https://github.com/mastra-ai/mastra/commit/bf084022374fa5d06ca70ed67a86dd64e379071b), [`81fe587`](https://github.com/mastra-ai/mastra/commit/81fe587275035715c1720ddf3fee0505cf053036), [`1fa3e12`](https://github.com/mastra-ai/mastra/commit/1fa3e123582b63cfe49de4ee52dc6a065e8d956a), [`403c438`](https://github.com/mastra-ai/mastra/commit/403c438e417278989ce247233d2c465b8d902cdd), [`f8ba195`](https://github.com/mastra-ai/mastra/commit/f8ba1954e27ee2b20586cc6cd9cf13c002c232f2)]:
23
+ - @mastra/core@1.43.0
24
+ - @mastra/memory@1.20.4
25
+ - @mastra/schema-compat@1.2.12
26
+ - @mastra/mcp@1.10.0
27
+
28
+ ## 0.11.2
29
+
30
+ ### Patch Changes
31
+
32
+ - dependencies updates: ([#17144](https://github.com/mastra-ai/mastra/pull/17144))
33
+ - Updated dependency [`@arcadeai/arcadejs@^2.4.1` ↗︎](https://www.npmjs.com/package/@arcadeai/arcadejs/v/2.4.1) (from `^2.3.0`, in `dependencies`)
34
+
35
+ - Improved Agent Builder defaults so generated agent instructions stay concise while still covering the required operating checklist. Agent Builder chat requests now also use lower OpenAI reasoning effort by default. ([#17604](https://github.com/mastra-ai/mastra/pull/17604))
36
+
37
+ - Update ai-sdk deps ([#17144](https://github.com/mastra-ai/mastra/pull/17144))
38
+
39
+ - Updated dependencies [[`d468acb`](https://github.com/mastra-ai/mastra/commit/d468acb07aec1bb19a2cb0ada8042b05b46746b2), [`575f815`](https://github.com/mastra-ai/mastra/commit/575f815c5c3567b71c0b83cbb7fa98c8253a9d9c), [`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`053735a`](https://github.com/mastra-ai/mastra/commit/053735a75c2c18e23ce34d9468007efa4a45f4c4), [`306909a`](https://github.com/mastra-ai/mastra/commit/306909a693de77d709b38706e2673c9547d24a28), [`5191af8`](https://github.com/mastra-ai/mastra/commit/5191af80c799eea25357c545fc05d91b3883531d), [`43bd3d4`](https://github.com/mastra-ai/mastra/commit/43bd3d421987463fdf35386a45199c49499ed069), [`e6fa79e`](https://github.com/mastra-ai/mastra/commit/e6fa79ec72a2ddffdd25e85270398951e9d552a4), [`904bcdf`](https://github.com/mastra-ai/mastra/commit/904bcdf7b8004aa7be823f9f70ca63580e47e470), [`7f5ee1d`](https://github.com/mastra-ai/mastra/commit/7f5ee1dca46daee8d2817f2ebe49e6335da81956), [`1e9aab5`](https://github.com/mastra-ai/mastra/commit/1e9aab50ff11e6e88fde4d7cbf512c44a9fe8d61), [`2bccba4`](https://github.com/mastra-ai/mastra/commit/2bccba4c03cadc815c2d54cbf4dd43a922140a8d), [`bec4678`](https://github.com/mastra-ai/mastra/commit/bec46781f31a2760b09b4aade1a87a62a40bee7b), [`bf8eb6d`](https://github.com/mastra-ai/mastra/commit/bf8eb6d0ec213a403eb9265a594ad283c44ab3dc), [`e9be4e7`](https://github.com/mastra-ai/mastra/commit/e9be4e747ec3d8b65548bff92f9377db06105376), [`493a328`](https://github.com/mastra-ai/mastra/commit/493a328f4346a1deeb9f1e2e44c8f2a3a4d7591b), [`d53cfc2`](https://github.com/mastra-ai/mastra/commit/d53cfc2c7f8d78343a4aa84ec4e129ba25f3325e), [`65799d4`](https://github.com/mastra-ai/mastra/commit/65799d4d549e5ebb9c848fbe3f51ac090f64becf), [`c268c89`](https://github.com/mastra-ai/mastra/commit/c268c89f4c63a93ee474d3cffdf3ea60bf00d4f2), [`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`014e00f`](https://github.com/mastra-ai/mastra/commit/014e00f2b3a597a016b72f9901c6ab27d491f822), [`029a414`](https://github.com/mastra-ai/mastra/commit/029a4141719793bd3e898a39eb5a0466a55f5f3a), [`d468acb`](https://github.com/mastra-ai/mastra/commit/d468acb07aec1bb19a2cb0ada8042b05b46746b2), [`7ef9ebf`](https://github.com/mastra-ai/mastra/commit/7ef9ebf79ec3c90536643ef169c7a306f105fb9d), [`b147b29`](https://github.com/mastra-ai/mastra/commit/b147b2907f0cd1aa812efe6d6e3f58d22e66fc88), [`d371ac1`](https://github.com/mastra-ai/mastra/commit/d371ac1d9820afaaf7cfdbc380a475946a994d8f), [`2bccba4`](https://github.com/mastra-ai/mastra/commit/2bccba4c03cadc815c2d54cbf4dd43a922140a8d), [`0c72f03`](https://github.com/mastra-ai/mastra/commit/0c72f032abb13254df5a7856d64be2f207b8006d), [`75adfb8`](https://github.com/mastra-ai/mastra/commit/75adfb81e3fca1fe8dc9ab382bed7b714854ba4f), [`cf182b7`](https://github.com/mastra-ai/mastra/commit/cf182b7fb495767946d9840ef29f19cfa906f31f), [`3b45ea9`](https://github.com/mastra-ai/mastra/commit/3b45ea95015557a6cb9d70dc5252af54ab1b78ac), [`a049c2a`](https://github.com/mastra-ai/mastra/commit/a049c2a9dfb41d0ee2e7a28874a88cd64fd5669f), [`f084be1`](https://github.com/mastra-ai/mastra/commit/f084be1fcbe33ad7480913e44d6130c421c0976f), [`b147b29`](https://github.com/mastra-ai/mastra/commit/b147b2907f0cd1aa812efe6d6e3f58d22e66fc88), [`2a96528`](https://github.com/mastra-ai/mastra/commit/2a9652848dfa3c5a2426f952e9d93554c26fd90f), [`f2ab060`](https://github.com/mastra-ai/mastra/commit/f2ab060162bea81505fda553e2cee29c1979fd04), [`5d302c8`](https://github.com/mastra-ai/mastra/commit/5d302c8eda1a6ac74eab5e442c4f64db6cc97a06), [`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`a952852`](https://github.com/mastra-ai/mastra/commit/a952852c971a21fb646cd907c75fcf4443cdc963), [`2656d9c`](https://github.com/mastra-ai/mastra/commit/2656d9c2976d4f3354253bfbbbf9b88a1b2bbf34), [`63e3fe1`](https://github.com/mastra-ai/mastra/commit/63e3fe13cc1ea96f91d7c68aea92f400faf9e4da), [`1d4ce8d`](https://github.com/mastra-ai/mastra/commit/1d4ce8daaa54511f325c1b609d31b8e54009d677), [`8c68372`](https://github.com/mastra-ai/mastra/commit/8c68372e85fe0b066ec12c58bd29ffb93e54c552)]:
40
+ - @mastra/core@1.42.0
41
+ - @mastra/memory@1.20.3
42
+ - @mastra/mcp@1.10.0
43
+
3
44
  ## 0.11.2-alpha.1
4
45
 
5
46
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -956,8 +956,24 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
956
956
  finalInput = applyBuilderDefaults(input, agentConfig);
957
957
  }
958
958
  await this.ensureStoredWorkspace(finalInput.workspace);
959
+ const existingCodeAgent = this.getCodeDefinedAgent(finalInput.id);
960
+ if (existingCodeAgent) {
961
+ const adapter = await this.getStorageAdapter();
962
+ await adapter.create(finalInput);
963
+ this._cache.set(finalInput.id, existingCodeAgent);
964
+ return existingCodeAgent;
965
+ }
959
966
  return super.create(finalInput);
960
967
  }
968
+ getCodeDefinedAgent(id) {
969
+ let agent;
970
+ try {
971
+ agent = this.mastra?.getAgentById(id);
972
+ } catch {
973
+ return void 0;
974
+ }
975
+ return agent?.source === "code" ? agent : void 0;
976
+ }
961
977
  /**
962
978
  * Ensure a workspace reference is persisted in the DB.
963
979
  *
@@ -1449,14 +1465,7 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
1449
1465
  browser,
1450
1466
  ...skillsFormat && { skillsFormat }
1451
1467
  });
1452
- const existingCodeAgent = (() => {
1453
- try {
1454
- return this.mastra?.getAgentById(storedAgent.id);
1455
- } catch {
1456
- return void 0;
1457
- }
1458
- })();
1459
- if (!existingCodeAgent || existingCodeAgent.source !== "code") {
1468
+ if (!this.getCodeDefinedAgent(storedAgent.id)) {
1460
1469
  this.mastra?.addAgent(agent, storedAgent.id, { source: "stored" });
1461
1470
  }
1462
1471
  this.logger?.debug(`[createAgentFromStoredConfig] Successfully created agent "${storedAgent.id}"`);
@@ -2605,6 +2614,7 @@ var MastraEditor = class {
2605
2614
  this.__processorProviders = { ...import_processor_provider2.BUILT_IN_PROCESSOR_PROVIDERS, ...config?.processorProviders };
2606
2615
  this.__source = config?.source;
2607
2616
  this.__codePath = config?.codePath ?? "./mastra/editor";
2617
+ this.__sourceControlProvider = config?.sourceControlProvider ?? (0, import_storage.createGitHubSourceControlProviderFromEnv)(process.env, { pathPrefix: this.__codePath });
2608
2618
  this.__filesystems = /* @__PURE__ */ new Map();
2609
2619
  this.__filesystems.set(localFilesystemProvider.id, localFilesystemProvider);
2610
2620
  for (const [id, provider] of Object.entries(config?.filesystems ?? {})) {
@@ -2643,18 +2653,33 @@ var MastraEditor = class {
2643
2653
  this.__logger = mastra.getLogger();
2644
2654
  }
2645
2655
  if (this.__source === "code") {
2646
- const filesystemStore = new import_storage.FilesystemStore({ dir: this.__codePath });
2647
2656
  const existingStorage = mastra.getStorage();
2648
- if (existingStorage) {
2657
+ if (this.__sourceControlProvider) {
2658
+ const sourceAgentsStore = new import_storage.SourceAgentsSourceControl({
2659
+ provider: this.__sourceControlProvider
2660
+ });
2661
+ const filesystemStore = new import_storage.FilesystemStore({ dir: this.__codePath });
2649
2662
  mastra.setStorage(
2650
2663
  new import_storage.MastraCompositeStore({
2651
- id: `${existingStorage.id}-with-editor-filesystem`,
2652
- default: existingStorage,
2653
- editor: filesystemStore
2664
+ id: `${existingStorage?.id ?? "mastra"}-with-editor-source-control`,
2665
+ ...existingStorage ? { default: existingStorage } : {},
2666
+ editor: filesystemStore,
2667
+ domains: { agents: sourceAgentsStore }
2654
2668
  })
2655
2669
  );
2656
2670
  } else {
2657
- mastra.setStorage(filesystemStore);
2671
+ const filesystemStore = new import_storage.FilesystemStore({ dir: this.__codePath });
2672
+ if (existingStorage) {
2673
+ mastra.setStorage(
2674
+ new import_storage.MastraCompositeStore({
2675
+ id: `${existingStorage.id}-with-editor-filesystem`,
2676
+ default: existingStorage,
2677
+ editor: filesystemStore
2678
+ })
2679
+ );
2680
+ } else {
2681
+ mastra.setStorage(filesystemStore);
2682
+ }
2658
2683
  }
2659
2684
  }
2660
2685
  this.ensureBuilderWorkspaces().then(() => this.reconcileBuilderWorkspaces()).catch((err) => {
@@ -2809,6 +2834,10 @@ var MastraEditor = class {
2809
2834
  getSource() {
2810
2835
  return this.__source;
2811
2836
  }
2837
+ /** Returns the configured source control provider, if any. */
2838
+ getSourceControlProvider() {
2839
+ return this.__sourceControlProvider;
2840
+ }
2812
2841
  /** Registered tool providers */
2813
2842
  getToolProvider(id) {
2814
2843
  return this.__toolProviders[id];