@mastra/e2b 0.9.0 → 0.10.0-alpha.3

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,50 @@
1
1
  # @mastra/e2b
2
2
 
3
+ ## 0.10.0-alpha.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Honor the sandbox runtime environment (`setEnv()`/`getEnv()` from `@mastra/core`) in every workspace sandbox provider. Environment variables set after construction now reach subsequent commands on all providers: ([#22250](https://github.com/mastra-ai/mastra/pull/22250))
8
+
9
+ - Process-manager-routed providers (E2B, Blaxel, Cloudflare, Daytona, Docker, Modal, Vercel microVM spawns) inherit the merge from the core spawn wrapper; their duplicated per-manager env plumbing is removed.
10
+ - Providers with their own exec transports (AgentCore, Apple Container, Railway, Vercel microVM and serverless `executeCommand`, Platform's private-network, WebSocket lease, and E2B lease paths) now merge `getEnv()` under per-call env.
11
+
12
+ Constructor `env` continues to behave as before: it seeds the sandbox runtime environment, and providers that bake env into the VM or container at creation time (Docker, Modal, Railway, Apple Container, Vercel, Platform) still do so. Per-call `env` on `executeCommand` still takes precedence for that command only.
13
+
14
+ Removed exported types (minor bump for these two packages): `BlaxelProcessManagerOptions` from `@mastra/blaxel` and `RailwayProcessManagerOptions` from `@mastra/railway`. Both existed only to pass `env` into a process manager constructed by hand; the core spawn wrapper now owns that merge, so the option and its type are gone.
15
+
16
+ - Updated dependencies [[`aa3a85d`](https://github.com/mastra-ai/mastra/commit/aa3a85daf094c683bb97efdf4b6a696d2e474af5), [`d29d06f`](https://github.com/mastra-ai/mastra/commit/d29d06fe00bbd35b4571150ea04c59d2ed783c71), [`e6516df`](https://github.com/mastra-ai/mastra/commit/e6516dfcdae4f4ac0e7971d84359a81385ee602f), [`0b2a3d1`](https://github.com/mastra-ai/mastra/commit/0b2a3d1783875c5b97b7b36ab3d03d7360e0dde7), [`6bb5d71`](https://github.com/mastra-ai/mastra/commit/6bb5d7193fe9166b219f0fccae17db7a5ae86e65), [`57de7d6`](https://github.com/mastra-ai/mastra/commit/57de7d644ba7146edb4e9e6111ec4fa98c3a59e9), [`e8e299c`](https://github.com/mastra-ai/mastra/commit/e8e299cc6abdfc39947e2fec25803493015d3882), [`edfc548`](https://github.com/mastra-ai/mastra/commit/edfc548886bc7bae17b681f8b6b41a47eb32bcd2), [`a8a4871`](https://github.com/mastra-ai/mastra/commit/a8a4871215f51da95c47129602157ce5372f634a), [`5165cdc`](https://github.com/mastra-ai/mastra/commit/5165cdcdcf50e144bb8113278535196cc9b07065), [`6bb5d71`](https://github.com/mastra-ai/mastra/commit/6bb5d7193fe9166b219f0fccae17db7a5ae86e65), [`9ee8120`](https://github.com/mastra-ai/mastra/commit/9ee8120ce17f76b9f617489e05a283353742690a), [`d975e92`](https://github.com/mastra-ai/mastra/commit/d975e924d4936f46c386bd3dee39c671720289f6), [`1cfa878`](https://github.com/mastra-ai/mastra/commit/1cfa8784d8da0dfaa0317e5048bc48b6084a5ea5), [`c118318`](https://github.com/mastra-ai/mastra/commit/c1183181c9804303db4b511c2e2648f8b714712b), [`fc07c64`](https://github.com/mastra-ai/mastra/commit/fc07c6465043e08e99193a6751a01c56ffc2e7a1), [`542dee2`](https://github.com/mastra-ai/mastra/commit/542dee254167f974ff8cbbbfc0ce10f9a2616a7b), [`a58483c`](https://github.com/mastra-ai/mastra/commit/a58483cff1a9d41fce7c931843f48cb0ac450f64), [`a58483c`](https://github.com/mastra-ai/mastra/commit/a58483cff1a9d41fce7c931843f48cb0ac450f64), [`895e9df`](https://github.com/mastra-ai/mastra/commit/895e9dfc17d6f34299eca64e317ded9e5f5e5ef8)]:
17
+ - @mastra/core@1.62.0-alpha.8
18
+
19
+ ## 0.10.0-alpha.2
20
+
21
+ ### Patch Changes
22
+
23
+ - Fixed automatic sandbox recovery when E2B reports an ID-specific missing sandbox. ([#22215](https://github.com/mastra-ai/mastra/pull/22215))
24
+
25
+ - Updated dependencies [[`ae8790c`](https://github.com/mastra-ai/mastra/commit/ae8790c4bfaa088d2ab279d1dcc06f326b9fd109), [`04a815f`](https://github.com/mastra-ai/mastra/commit/04a815fc8971d29e97fcdcc5008a1eb472fc00ff), [`cced745`](https://github.com/mastra-ai/mastra/commit/cced745a056ec2225c5bc702e32d848847aa8b65)]:
26
+ - @mastra/core@1.62.0-alpha.7
27
+
28
+ ## 0.10.0-alpha.1
29
+
30
+ ### Patch Changes
31
+
32
+ - Fixed E2B sandbox recovery so configured mounts that previously errored are retried after the physical sandbox is replaced. ([#22169](https://github.com/mastra-ai/mastra/pull/22169))
33
+
34
+ - Updated dependencies [[`c8e4cea`](https://github.com/mastra-ai/mastra/commit/c8e4ceac9a390d78c8327dff3cdb2861dd71957f), [`ed01e9a`](https://github.com/mastra-ai/mastra/commit/ed01e9a807514a904374bf687a7b8f18750f6f78), [`4e9a228`](https://github.com/mastra-ai/mastra/commit/4e9a2283d5fd6ed1b70a2751eb3dc2cbf82ada20), [`63041eb`](https://github.com/mastra-ai/mastra/commit/63041eb4c50b520a0a80e03d4cd6ea99f67715a0)]:
35
+ - @mastra/core@1.62.0-alpha.6
36
+
37
+ ## 0.10.0-alpha.0
38
+
39
+ ### Minor Changes
40
+
41
+ - Added a `lifecycle` option to `E2BSandbox` so you can choose what happens when a sandbox times out. Sandboxes still pause by default and resume on next use; pass `{ onTimeout: 'kill' }` to destroy idle sandboxes instead, which suits workspaces whose data is stored outside the sandbox. ([#22120](https://github.com/mastra-ai/mastra/pull/22120))
42
+
43
+ ### Patch Changes
44
+
45
+ - Updated dependencies [[`2c85f42`](https://github.com/mastra-ai/mastra/commit/2c85f428e04ccd63ea31a7ec80b5b327afdad555), [`11bbeb9`](https://github.com/mastra-ai/mastra/commit/11bbeb9b108ef2264e05acefc6dafb9cbb342921), [`1a485f3`](https://github.com/mastra-ai/mastra/commit/1a485f3538f5ec64d58bd8b5e1e99de0c695c87b), [`0d37487`](https://github.com/mastra-ai/mastra/commit/0d37487d9f349388a3f1cef6a536cf9dcc4b6273), [`8661d7d`](https://github.com/mastra-ai/mastra/commit/8661d7d7179f0a024456aabdd8679bcecd09ac28), [`575e343`](https://github.com/mastra-ai/mastra/commit/575e343900451021d96110916497d334af7bc252), [`cacb839`](https://github.com/mastra-ai/mastra/commit/cacb8392d9e74189b56d857290b0615f98a2683d), [`b47b26e`](https://github.com/mastra-ai/mastra/commit/b47b26e6fe95cb8a3482be2c5e52de157fe59d0b), [`0d37487`](https://github.com/mastra-ai/mastra/commit/0d37487d9f349388a3f1cef6a536cf9dcc4b6273), [`c46eb09`](https://github.com/mastra-ai/mastra/commit/c46eb09ce4987509af57a0ac582c61241a6dd2f1), [`30ed33e`](https://github.com/mastra-ai/mastra/commit/30ed33ee14084a26019aba15fceadda6d6ddefaf), [`91ad69d`](https://github.com/mastra-ai/mastra/commit/91ad69d64994c89199b0c55399e64ed91c61df2f), [`8dc408d`](https://github.com/mastra-ai/mastra/commit/8dc408d34438f9e13297f792c11a5cfd6cf952e1), [`c92def1`](https://github.com/mastra-ai/mastra/commit/c92def10a13c822972c96f0a4ca6ffc1f4258aed), [`c5eaec5`](https://github.com/mastra-ai/mastra/commit/c5eaec5a860d80d0e3805e67db0414b87ac8cbed), [`e66b2ba`](https://github.com/mastra-ai/mastra/commit/e66b2ba100db63eaeab6e21e1ea34b113f2ec781)]:
46
+ - @mastra/core@1.62.0-alpha.3
47
+
3
48
  ## 0.9.0
4
49
 
5
50
  ### Minor Changes
package/README.md CHANGED
@@ -29,6 +29,19 @@ const agent = new Agent({
29
29
  });
30
30
  ```
31
31
 
32
+ ### Timeout Lifecycle
33
+
34
+ When a sandbox reaches its `timeout`, it is paused by default: the whole VM is snapshotted and the next `start()` reconnects and resumes it. For stateless workspaces whose data lives outside the sandbox (for example mounted from S3), you can have idle sandboxes destroyed instead and recreated on next use:
35
+
36
+ ```typescript
37
+ const sandbox = new E2BSandbox({
38
+ timeout: 60_000,
39
+ lifecycle: { onTimeout: 'kill' }, // default: { onTimeout: 'pause' }
40
+ });
41
+ ```
42
+
43
+ Calling `stop()` explicitly always pauses the sandbox, regardless of this setting.
44
+
32
45
  ### Mounting Cloud Storage
33
46
 
34
47
  E2B sandboxes can mount S3, GCS, or Azure Blob filesystems, making cloud storage accessible as a local directory inside the sandbox:
package/dist/index.cjs CHANGED
@@ -518,10 +518,7 @@ var E2BProcessManager = class extends _mastra_core_workspace.SandboxProcessManag
518
518
  async spawn(command, options = {}) {
519
519
  return this.sandbox.retryOnDead(async () => {
520
520
  const e2b = this.sandbox.e2b;
521
- const mergedEnv = {
522
- ...this.env,
523
- ...options.env
524
- };
521
+ const mergedEnv = { ...options.env };
525
522
  const envs = Object.fromEntries(Object.entries(mergedEnv).filter((entry) => entry[1] !== void 0));
526
523
  let handle;
527
524
  handle = new E2BProcessHandle(await e2b.commands.run(command, {
@@ -649,9 +646,9 @@ var E2BSandbox = class E2BSandbox extends _mastra_core_workspace.MastraSandbox {
649
646
  _isRetrying = false;
650
647
  timeout;
651
648
  templateSpec;
652
- env;
653
649
  metadata;
654
650
  network;
651
+ lifecycle;
655
652
  connectionOpts;
656
653
  _instructionsOverride;
657
654
  _constructorOptions;
@@ -663,14 +660,14 @@ var E2BSandbox = class E2BSandbox extends _mastra_core_workspace.MastraSandbox {
663
660
  super({
664
661
  ...options,
665
662
  name: "E2BSandbox",
666
- processes: new E2BProcessManager({ env: options.env ?? {} })
663
+ processes: new E2BProcessManager()
667
664
  });
668
665
  this.id = options.id ?? this.generateId();
669
666
  this.timeout = options.timeout ?? 3e5;
670
667
  this.templateSpec = options.template;
671
- this.env = options.env ?? {};
672
668
  this.metadata = options.metadata ?? {};
673
669
  this.network = options.network;
670
+ this.lifecycle = options.lifecycle ?? { onTimeout: "pause" };
674
671
  this.connectionOpts = {
675
672
  ...options.domain && { domain: options.domain },
676
673
  ...options.apiUrl && { apiUrl: options.apiUrl },
@@ -760,7 +757,7 @@ var E2BSandbox = class E2BSandbox extends _mastra_core_workspace.MastraSandbox {
760
757
  try {
761
758
  this._sandbox = await e2b.Sandbox.create(resolvedTemplateId, {
762
759
  ...this.connectionOpts,
763
- lifecycle: { onTimeout: "pause" },
760
+ lifecycle: this.lifecycle,
764
761
  metadata: {
765
762
  ...this.metadata,
766
763
  "mastra-sandbox-id": this.id
@@ -777,7 +774,7 @@ var E2BSandbox = class E2BSandbox extends _mastra_core_workspace.MastraSandbox {
777
774
  this.logger.debug(`${LOG_PREFIX} Retrying sandbox creation with rebuilt template: ${rebuiltTemplateId}`);
778
775
  this._sandbox = await e2b.Sandbox.create(rebuiltTemplateId, {
779
776
  ...this.connectionOpts,
780
- lifecycle: { onTimeout: "pause" },
777
+ lifecycle: this.lifecycle,
781
778
  metadata: {
782
779
  ...this.metadata,
783
780
  "mastra-sandbox-id": this.id
@@ -1239,7 +1236,7 @@ var E2BSandbox = class E2BSandbox extends _mastra_core_workspace.MastraSandbox {
1239
1236
  isSandboxDeadError(error) {
1240
1237
  if (!error) return false;
1241
1238
  const errorStr = String(error);
1242
- return errorStr.includes("sandbox was not found") || errorStr.includes("Sandbox is probably not running") || errorStr.includes("Sandbox not found") || errorStr.includes("sandbox has been killed");
1239
+ return /\b(?:paused\s+)?sandbox(?:\s+\S+)?\s+(?:was\s+)?not found\b/i.test(errorStr) || errorStr.includes("Sandbox is probably not running") || errorStr.includes("sandbox has been killed");
1243
1240
  }
1244
1241
  /**
1245
1242
  * Handle sandbox timeout by clearing the instance and resetting state.
@@ -1250,7 +1247,10 @@ var E2BSandbox = class E2BSandbox extends _mastra_core_workspace.MastraSandbox {
1250
1247
  */
1251
1248
  handleSandboxTimeout() {
1252
1249
  this._sandbox = null;
1253
- for (const [path, entry] of this.mounts.entries) if (entry.state === "mounted" || entry.state === "mounting") this.mounts.set(path, { state: "pending" });
1250
+ for (const [path, entry] of this.mounts.entries) if (entry.state === "mounted" || entry.state === "mounting" || entry.state === "error") this.mounts.set(path, {
1251
+ state: "pending",
1252
+ error: void 0
1253
+ });
1254
1254
  this.status = "stopped";
1255
1255
  }
1256
1256
  /**