@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 +17 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/dist/sandbox/index.d.ts +10 -0
- package/dist/sandbox/index.d.ts.map +1 -1
- package/dist/utils/template.d.ts +7 -2
- package/dist/utils/template.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MastraSandbox, ProcessHandle, SandboxNotReadyError, SandboxProcessManager, UnsupportedStdinCloseError, assertModesUnsupported } from "@mastra/core/workspace";
|
|
1
|
+
import { MastraSandbox, ProcessHandle, SandboxError, SandboxNotReadyError, SandboxProcessManager, UnsupportedStdinCloseError, assertModesUnsupported } from "@mastra/core/workspace";
|
|
2
2
|
import { Sandbox, Template } from "e2b";
|
|
3
3
|
import { createHash } from "crypto";
|
|
4
4
|
import { execFile } from "child_process";
|
|
@@ -861,10 +861,15 @@ var E2BSandbox = class E2BSandbox extends MastraSandbox {
|
|
|
861
861
|
if (!isTemplateUnusable(createError)) throw createError;
|
|
862
862
|
const namedSpec = this.templateSpec && isNamedTemplateSpec(this.templateSpec) ? this.templateSpec : this._resolvedNamedSpec;
|
|
863
863
|
if (namedSpec) {
|
|
864
|
+
const { fallbackTemplate } = namedSpec;
|
|
865
|
+
if (fallbackTemplate === false) {
|
|
866
|
+
this._resolvedTemplateId = void 0;
|
|
867
|
+
this.logger.error(`${LOG_PREFIX} Creating from '${resolvedTemplateId}' failed (fallback disabled): ${createError}`);
|
|
868
|
+
throw createError;
|
|
869
|
+
}
|
|
864
870
|
this.logger.warn(`${LOG_PREFIX} Creating from '${resolvedTemplateId}' failed, retrying on fallback: ${createError}`);
|
|
865
871
|
this._resolvedTemplateId = void 0;
|
|
866
|
-
const
|
|
867
|
-
const fallbackId = resolvedTemplateId === spec.ref ? await this.resolveFallbackTemplate(spec.fallbackTemplate) : await this.buildOrReuseDefaultTemplate();
|
|
872
|
+
const fallbackId = resolvedTemplateId === namedSpec.ref ? await this.resolveFallbackTemplate(fallbackTemplate) : await this.buildOrReuseDefaultTemplate();
|
|
868
873
|
try {
|
|
869
874
|
sdkSandbox = await createFromTemplate(fallbackId);
|
|
870
875
|
this._resolvedTemplateId = fallbackId;
|
|
@@ -1257,6 +1262,11 @@ var E2BSandbox = class E2BSandbox extends MastraSandbox {
|
|
|
1257
1262
|
if (this._preferredSandboxId) {
|
|
1258
1263
|
const preferred = await this.connectToPreferredSandbox(this._preferredSandboxId);
|
|
1259
1264
|
if (preferred) return preferred;
|
|
1265
|
+
if (this._constructorOptions.reattach === "required") throw new 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", {
|
|
1266
|
+
provider: "e2b",
|
|
1267
|
+
sandboxId: this._preferredSandboxId,
|
|
1268
|
+
logicalId: this.id
|
|
1269
|
+
});
|
|
1260
1270
|
}
|
|
1261
1271
|
return this.findExistingSandbox();
|
|
1262
1272
|
}
|
|
@@ -1385,6 +1395,11 @@ var E2BSandbox = class E2BSandbox extends MastraSandbox {
|
|
|
1385
1395
|
this._resolvedTemplateId = ref;
|
|
1386
1396
|
return ref;
|
|
1387
1397
|
} catch (error) {
|
|
1398
|
+
if (fallbackTemplate === false) {
|
|
1399
|
+
this._resolvedTemplateId = void 0;
|
|
1400
|
+
this.logger.error(`${LOG_PREFIX} Template '${ref}' resolution failed (fallback disabled): ${error}`);
|
|
1401
|
+
throw error;
|
|
1402
|
+
}
|
|
1388
1403
|
this.logger.warn(`${LOG_PREFIX} Template '${ref}' resolution failed, falling back: ${error}`);
|
|
1389
1404
|
return await this.resolveFallbackTemplate(fallbackTemplate);
|
|
1390
1405
|
}
|