@mastra/editor 0.13.4 → 0.13.5

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,72 @@
1
1
  # @mastra/editor
2
2
 
3
+ ## 0.13.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Added workspace-level provider registry to MastraEditor. You can now register WorkspaceProvider factories that build complete Workspace instances as a single unit, instead of composing from separate filesystem and sandbox providers. Stored agents can reference a workspace provider via `{ type: 'provider', provider: 'my-cloud', config: { ... } }` and the editor will call the registered factory during agent hydration. ([#18781](https://github.com/mastra-ai/mastra/pull/18781))
8
+
9
+ ```ts
10
+ import { MastraEditor } from '@mastra/editor';
11
+ import { Workspace } from '@mastra/core/workspace';
12
+
13
+ const editor = new MastraEditor({
14
+ workspaces: {
15
+ 'my-cloud': {
16
+ id: 'my-cloud',
17
+ name: 'My Cloud Workspace',
18
+ createWorkspace: config =>
19
+ new Workspace({
20
+ id: 'cloud-ws',
21
+ name: 'Cloud WS',
22
+ filesystem: new MyCloudFilesystem(config),
23
+ sandbox: new MyCloudSandbox(config),
24
+ }),
25
+ },
26
+ },
27
+ });
28
+
29
+ // Stored agent workspace reference using the provider:
30
+ // { type: 'provider', provider: 'my-cloud', config: { region: 'us-east-1' } }
31
+ ```
32
+
33
+ - Updated dependencies [[`b291760`](https://github.com/mastra-ai/mastra/commit/b291760df9d6c7e4fc72606c8f0a4af2cf6e946c), [`3ffb8b7`](https://github.com/mastra-ai/mastra/commit/3ffb8b720e90f5e6977129ec1f6707d43c2bebe0), [`6ef59fe`](https://github.com/mastra-ai/mastra/commit/6ef59fef1da52ed8da5fbb2a892c71cf4fb6c739), [`4039488`](https://github.com/mastra-ai/mastra/commit/403948898af7293198d9e8b3e7fb47f623c78b94), [`29b7ea6`](https://github.com/mastra-ai/mastra/commit/29b7ea64e72b5523d5bdcbd34ee03d2b854d54e1), [`b2c9d70`](https://github.com/mastra-ai/mastra/commit/b2c9d70757207fb01a9069549e69b6f0d73a6636), [`a51c63d`](https://github.com/mastra-ai/mastra/commit/a51c63d8ee639e4daeba2a0be093efa6a1b5e52f), [`252f63d`](https://github.com/mastra-ai/mastra/commit/252f63d8fec723955adb2202be2f01a75ad0e69c), [`5ea76a7`](https://github.com/mastra-ai/mastra/commit/5ea76a723d966c72da9aa3ab30ae20276e049765), [`6445560`](https://github.com/mastra-ai/mastra/commit/6445560327045d20b239585fc63fed72e9ce36ec), [`e2b9f33`](https://github.com/mastra-ai/mastra/commit/e2b9f33456fd638eca555f9466c6519d8d049666), [`10959d5`](https://github.com/mastra-ai/mastra/commit/10959d509d824f682d40ff96e05ee044aec3b0e5), [`c547a77`](https://github.com/mastra-ai/mastra/commit/c547a7729bdf64dfc2df29c965046c0712a18f10), [`a0085fa`](https://github.com/mastra-ai/mastra/commit/a0085fa0934e52c37c8c8b3d75a6bb5cd199af36), [`911281c`](https://github.com/mastra-ai/mastra/commit/911281c57893ba2630428bf88d0cd0c5101ce76f), [`a2ba369`](https://github.com/mastra-ai/mastra/commit/a2ba369e796dfab610f41c6875965b488272fa55), [`ffc3c17`](https://github.com/mastra-ai/mastra/commit/ffc3c17274ea17c11aa6f73d3140649cd7fc8abc), [`81542c1`](https://github.com/mastra-ai/mastra/commit/81542c1835c35bc32f2ce4fa9136ee11993cd299), [`3908e53`](https://github.com/mastra-ai/mastra/commit/3908e53ce04bbea04f5e0c097d7aa298c35fabee), [`cb24ce7`](https://github.com/mastra-ai/mastra/commit/cb24ce76bd16ca88eb6a963f6277f8780e703029), [`02705fd`](https://github.com/mastra-ai/mastra/commit/02705fd2f5a9062210d64ea061adeeb10dc9452e), [`ae51e81`](https://github.com/mastra-ai/mastra/commit/ae51e818825582d42500338dfc1929a082eff0ba), [`6f304ef`](https://github.com/mastra-ai/mastra/commit/6f304ef319e99725e884bdb8d3193c001b6e5964), [`5f9858f`](https://github.com/mastra-ai/mastra/commit/5f9858f791f1137ca7d52d23559fb4568f7a9026)]:
34
+ - @mastra/core@1.50.0
35
+ - @mastra/mcp@1.13.1
36
+
37
+ ## 0.13.5-alpha.0
38
+
39
+ ### Patch Changes
40
+
41
+ - Added workspace-level provider registry to MastraEditor. You can now register WorkspaceProvider factories that build complete Workspace instances as a single unit, instead of composing from separate filesystem and sandbox providers. Stored agents can reference a workspace provider via `{ type: 'provider', provider: 'my-cloud', config: { ... } }` and the editor will call the registered factory during agent hydration. ([#18781](https://github.com/mastra-ai/mastra/pull/18781))
42
+
43
+ ```ts
44
+ import { MastraEditor } from '@mastra/editor';
45
+ import { Workspace } from '@mastra/core/workspace';
46
+
47
+ const editor = new MastraEditor({
48
+ workspaces: {
49
+ 'my-cloud': {
50
+ id: 'my-cloud',
51
+ name: 'My Cloud Workspace',
52
+ createWorkspace: config =>
53
+ new Workspace({
54
+ id: 'cloud-ws',
55
+ name: 'Cloud WS',
56
+ filesystem: new MyCloudFilesystem(config),
57
+ sandbox: new MyCloudSandbox(config),
58
+ }),
59
+ },
60
+ },
61
+ });
62
+
63
+ // Stored agent workspace reference using the provider:
64
+ // { type: 'provider', provider: 'my-cloud', config: { region: 'us-east-1' } }
65
+ ```
66
+
67
+ - Updated dependencies [[`6ef59fe`](https://github.com/mastra-ai/mastra/commit/6ef59fef1da52ed8da5fbb2a892c71cf4fb6c739), [`e2b9f33`](https://github.com/mastra-ai/mastra/commit/e2b9f33456fd638eca555f9466c6519d8d049666)]:
68
+ - @mastra/core@1.50.0-alpha.0
69
+
3
70
  ## 0.13.4
4
71
 
5
72
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -1183,6 +1183,7 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
1183
1183
  ...workspaceRef.config
1184
1184
  });
1185
1185
  this.logger?.debug(`[ensureStoredWorkspace] Persisted inline workspace '${workspaceId}' to DB`);
1186
+ } else if (workspaceRef.type === "provider") {
1186
1187
  }
1187
1188
  } catch (error) {
1188
1189
  this.logger?.warn("[ensureStoredWorkspace] Failed to persist workspace", { error });
@@ -2092,6 +2093,9 @@ var EditorAgentNamespace = class extends CrudEditorNamespace {
2092
2093
  const configHash = (0, import_node_crypto.createHash)("sha256").update(JSON.stringify(workspaceRef.config)).digest("hex").slice(0, 12);
2093
2094
  return workspaceNs.hydrateSnapshotToWorkspace(`inline-${configHash}`, workspaceRef.config, hydrateOptions);
2094
2095
  }
2096
+ if (workspaceRef.type === "provider") {
2097
+ return workspaceNs.resolveWorkspaceProvider(workspaceRef.provider, workspaceRef.config);
2098
+ }
2095
2099
  return void 0;
2096
2100
  }
2097
2101
  /**
@@ -2685,6 +2689,19 @@ var EditorWorkspaceNamespace = class extends CrudEditorNamespace {
2685
2689
  }
2686
2690
  return await provider.createSandbox(sandboxConfig.config);
2687
2691
  }
2692
+ /**
2693
+ * Resolve a stored workspace provider config to a complete runtime Workspace instance.
2694
+ * Looks up the provider by ID in the editor's workspace provider registry.
2695
+ */
2696
+ async resolveWorkspaceProvider(providerId, config) {
2697
+ const provider = this.editor.__workspaces.get(providerId);
2698
+ if (!provider) {
2699
+ throw new Error(
2700
+ `Workspace provider "${providerId}" is not registered. Register it via new MastraEditor({ workspaces: { '${providerId}': yourProvider } })`
2701
+ );
2702
+ }
2703
+ return await provider.createWorkspace(config);
2704
+ }
2688
2705
  async getStorageAdapter() {
2689
2706
  const storage = this.mastra?.getStorage();
2690
2707
  if (!storage) throw new Error("Storage is not configured");
@@ -2919,6 +2936,10 @@ var MastraEditor = class {
2919
2936
  for (const [id, provider] of Object.entries(config?.browsers ?? {})) {
2920
2937
  this.__browsers.set(id, provider);
2921
2938
  }
2939
+ this.__workspaces = /* @__PURE__ */ new Map();
2940
+ for (const [id, provider] of Object.entries(config?.workspaces ?? {})) {
2941
+ this.__workspaces.set(id, provider);
2942
+ }
2922
2943
  this.agent = new EditorAgentNamespace(this);
2923
2944
  this.mcp = new EditorMCPNamespace(this);
2924
2945
  this.mcpServer = new EditorMCPServerNamespace(this);