@mastra/e2b 0.13.0-alpha.1 → 0.13.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.cjs CHANGED
@@ -862,10 +862,15 @@ var E2BSandbox = class E2BSandbox extends _mastra_core_workspace.MastraSandbox {
862
862
  if (!isTemplateUnusable(createError)) throw createError;
863
863
  const namedSpec = this.templateSpec && isNamedTemplateSpec(this.templateSpec) ? this.templateSpec : this._resolvedNamedSpec;
864
864
  if (namedSpec) {
865
+ const { fallbackTemplate } = namedSpec;
866
+ if (fallbackTemplate === false) {
867
+ this._resolvedTemplateId = void 0;
868
+ this.logger.error(`${LOG_PREFIX} Creating from '${resolvedTemplateId}' failed (fallback disabled): ${createError}`);
869
+ throw createError;
870
+ }
865
871
  this.logger.warn(`${LOG_PREFIX} Creating from '${resolvedTemplateId}' failed, retrying on fallback: ${createError}`);
866
872
  this._resolvedTemplateId = void 0;
867
- const spec = namedSpec;
868
- const fallbackId = resolvedTemplateId === spec.ref ? await this.resolveFallbackTemplate(spec.fallbackTemplate) : await this.buildOrReuseDefaultTemplate();
873
+ const fallbackId = resolvedTemplateId === namedSpec.ref ? await this.resolveFallbackTemplate(fallbackTemplate) : await this.buildOrReuseDefaultTemplate();
869
874
  try {
870
875
  sdkSandbox = await createFromTemplate(fallbackId);
871
876
  this._resolvedTemplateId = fallbackId;
@@ -1258,6 +1263,11 @@ var E2BSandbox = class E2BSandbox extends _mastra_core_workspace.MastraSandbox {
1258
1263
  if (this._preferredSandboxId) {
1259
1264
  const preferred = await this.connectToPreferredSandbox(this._preferredSandboxId);
1260
1265
  if (preferred) return preferred;
1266
+ if (this._constructorOptions.reattach === "required") throw new _mastra_core_workspace.SandboxError(`E2B sandbox ${this._preferredSandboxId} could not be reattached (gone); refusing to provision a replacement because reattach is 'required'. Clear the persisted sandboxId to start a fresh sandbox.`, "SANDBOX_REATTACH_FAILED", {
1267
+ provider: "e2b",
1268
+ sandboxId: this._preferredSandboxId,
1269
+ logicalId: this.id
1270
+ });
1261
1271
  }
1262
1272
  return this.findExistingSandbox();
1263
1273
  }
@@ -1386,6 +1396,11 @@ var E2BSandbox = class E2BSandbox extends _mastra_core_workspace.MastraSandbox {
1386
1396
  this._resolvedTemplateId = ref;
1387
1397
  return ref;
1388
1398
  } catch (error) {
1399
+ if (fallbackTemplate === false) {
1400
+ this._resolvedTemplateId = void 0;
1401
+ this.logger.error(`${LOG_PREFIX} Template '${ref}' resolution failed (fallback disabled): ${error}`);
1402
+ throw error;
1403
+ }
1389
1404
  this.logger.warn(`${LOG_PREFIX} Template '${ref}' resolution failed, falling back: ${error}`);
1390
1405
  return await this.resolveFallbackTemplate(fallbackTemplate);
1391
1406
  }