@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/dist/index.js CHANGED
@@ -517,10 +517,7 @@ var E2BProcessManager = class extends SandboxProcessManager {
517
517
  async spawn(command, options = {}) {
518
518
  return this.sandbox.retryOnDead(async () => {
519
519
  const e2b = this.sandbox.e2b;
520
- const mergedEnv = {
521
- ...this.env,
522
- ...options.env
523
- };
520
+ const mergedEnv = { ...options.env };
524
521
  const envs = Object.fromEntries(Object.entries(mergedEnv).filter((entry) => entry[1] !== void 0));
525
522
  let handle;
526
523
  handle = new E2BProcessHandle(await e2b.commands.run(command, {
@@ -648,9 +645,9 @@ var E2BSandbox = class E2BSandbox extends MastraSandbox {
648
645
  _isRetrying = false;
649
646
  timeout;
650
647
  templateSpec;
651
- env;
652
648
  metadata;
653
649
  network;
650
+ lifecycle;
654
651
  connectionOpts;
655
652
  _instructionsOverride;
656
653
  _constructorOptions;
@@ -662,14 +659,14 @@ var E2BSandbox = class E2BSandbox extends MastraSandbox {
662
659
  super({
663
660
  ...options,
664
661
  name: "E2BSandbox",
665
- processes: new E2BProcessManager({ env: options.env ?? {} })
662
+ processes: new E2BProcessManager()
666
663
  });
667
664
  this.id = options.id ?? this.generateId();
668
665
  this.timeout = options.timeout ?? 3e5;
669
666
  this.templateSpec = options.template;
670
- this.env = options.env ?? {};
671
667
  this.metadata = options.metadata ?? {};
672
668
  this.network = options.network;
669
+ this.lifecycle = options.lifecycle ?? { onTimeout: "pause" };
673
670
  this.connectionOpts = {
674
671
  ...options.domain && { domain: options.domain },
675
672
  ...options.apiUrl && { apiUrl: options.apiUrl },
@@ -759,7 +756,7 @@ var E2BSandbox = class E2BSandbox extends MastraSandbox {
759
756
  try {
760
757
  this._sandbox = await Sandbox.create(resolvedTemplateId, {
761
758
  ...this.connectionOpts,
762
- lifecycle: { onTimeout: "pause" },
759
+ lifecycle: this.lifecycle,
763
760
  metadata: {
764
761
  ...this.metadata,
765
762
  "mastra-sandbox-id": this.id
@@ -776,7 +773,7 @@ var E2BSandbox = class E2BSandbox extends MastraSandbox {
776
773
  this.logger.debug(`${LOG_PREFIX} Retrying sandbox creation with rebuilt template: ${rebuiltTemplateId}`);
777
774
  this._sandbox = await Sandbox.create(rebuiltTemplateId, {
778
775
  ...this.connectionOpts,
779
- lifecycle: { onTimeout: "pause" },
776
+ lifecycle: this.lifecycle,
780
777
  metadata: {
781
778
  ...this.metadata,
782
779
  "mastra-sandbox-id": this.id
@@ -1238,7 +1235,7 @@ var E2BSandbox = class E2BSandbox extends MastraSandbox {
1238
1235
  isSandboxDeadError(error) {
1239
1236
  if (!error) return false;
1240
1237
  const errorStr = String(error);
1241
- 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");
1238
+ 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");
1242
1239
  }
1243
1240
  /**
1244
1241
  * Handle sandbox timeout by clearing the instance and resetting state.
@@ -1249,7 +1246,10 @@ var E2BSandbox = class E2BSandbox extends MastraSandbox {
1249
1246
  */
1250
1247
  handleSandboxTimeout() {
1251
1248
  this._sandbox = null;
1252
- for (const [path, entry] of this.mounts.entries) if (entry.state === "mounted" || entry.state === "mounting") this.mounts.set(path, { state: "pending" });
1249
+ for (const [path, entry] of this.mounts.entries) if (entry.state === "mounted" || entry.state === "mounting" || entry.state === "error") this.mounts.set(path, {
1250
+ state: "pending",
1251
+ error: void 0
1252
+ });
1253
1253
  this.status = "stopped";
1254
1254
  }
1255
1255
  /**