@mastra/e2b 0.15.1-alpha.0 → 0.15.1
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 +16 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -32
- package/dist/index.js.map +1 -1
- package/package.json +15 -15
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DirectoryNotEmptyError, DirectoryNotFoundError, FactorySandbox, FileExistsError, FileNotFoundError, IsDirectoryError, MastraFilesystem, MastraSandbox, NotDirectoryError, ProcessHandle, SandboxError, SandboxNotReadyError, SandboxProcessManager, UnsupportedStdinCloseError, assertModesUnsupported } from "@mastra/core/workspace";
|
|
1
|
+
import { DirectoryNotEmptyError, DirectoryNotFoundError, FactorySandbox, FileExistsError, FileNotFoundError, IsDirectoryError, MastraFilesystem, MastraSandbox, NotDirectoryError, ProcessHandle, SandboxError, SandboxNotReadyError, SandboxProcessManager, UnsupportedStdinCloseError, assertModesUnsupported, getMimeType } from "@mastra/core/workspace";
|
|
2
2
|
import { ApiClient, ConnectionConfig, InvalidArgumentError, NotFoundError, Sandbox, SandboxNotFoundError, Template } from "e2b";
|
|
3
3
|
import { createHash } from "crypto";
|
|
4
4
|
import { posix } from "path";
|
|
@@ -75,8 +75,7 @@ function createDefaultMountableTemplate(options) {
|
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
//#region ../../packages/_internals/workspace/dist/index.js
|
|
78
|
+
// ../../packages/_internals/workspace/dist/index.js
|
|
80
79
|
/** Directory, relative to the template's build cwd, that holds every marker below. */
|
|
81
80
|
const SETUP_MARKER_DIR = ".mastra-sandbox";
|
|
82
81
|
/**
|
|
@@ -476,7 +475,8 @@ var FilesApiFilesystem = class extends MastraFilesystem {
|
|
|
476
475
|
type: info.type === "dir" ? "directory" : "file",
|
|
477
476
|
size: info.type === "dir" ? 0 : info.size,
|
|
478
477
|
createdAt: modifiedAt,
|
|
479
|
-
modifiedAt
|
|
478
|
+
modifiedAt,
|
|
479
|
+
...info.type !== "dir" && { mimeType: getMimeType(abs) }
|
|
480
480
|
};
|
|
481
481
|
});
|
|
482
482
|
}
|
|
@@ -722,8 +722,7 @@ var CommandsApiProcessManager = class extends SandboxProcessManager {
|
|
|
722
722
|
}
|
|
723
723
|
}
|
|
724
724
|
};
|
|
725
|
-
|
|
726
|
-
//#region src/sandbox/filesystem.ts
|
|
725
|
+
// src/sandbox/filesystem.ts
|
|
727
726
|
/**
|
|
728
727
|
* envd's edge answers a paused or missing sandbox with a 404 that the SDK
|
|
729
728
|
* reports as `FileNotFoundError`. Same pattern as `E2BSandbox`'s dead-sandbox
|
|
@@ -778,8 +777,7 @@ var E2BSandboxFilesystem = class extends FilesApiFilesystem {
|
|
|
778
777
|
if (error instanceof InvalidArgumentError) return "invalid-argument";
|
|
779
778
|
}
|
|
780
779
|
};
|
|
781
|
-
|
|
782
|
-
//#region src/sandbox/mounts/types.ts
|
|
780
|
+
// src/sandbox/mounts/types.ts
|
|
783
781
|
const LOG_PREFIX = "[@mastra/e2b]";
|
|
784
782
|
const SAFE_S3_BUCKET_NAME = /^[a-z0-9][a-z0-9.\-]{1,61}[a-z0-9]$/;
|
|
785
783
|
const SAFE_GCS_BUCKET_NAME = /^[a-z0-9][a-z0-9._-]{1,61}[a-z0-9]$/;
|
|
@@ -823,8 +821,7 @@ function validatePrefix(prefix) {
|
|
|
823
821
|
if (/[\x00-\x1f\x7f]/.test(normalized)) throw new Error(`Invalid mount prefix: "${prefix}". Control characters are not allowed.`);
|
|
824
822
|
return normalized;
|
|
825
823
|
}
|
|
826
|
-
|
|
827
|
-
//#region src/utils/shell-quote.ts
|
|
824
|
+
// src/utils/shell-quote.ts
|
|
828
825
|
/**
|
|
829
826
|
* Shell-quote a single argument for safe use in a command string.
|
|
830
827
|
*
|
|
@@ -835,8 +832,7 @@ function shellQuote(arg) {
|
|
|
835
832
|
if (/^[a-zA-Z0-9._\-/@:=]+$/.test(arg)) return arg;
|
|
836
833
|
return "'" + arg.replace(/'/g, "'\\''") + "'";
|
|
837
834
|
}
|
|
838
|
-
|
|
839
|
-
//#region src/sandbox/mounts/s3.ts
|
|
835
|
+
// src/sandbox/mounts/s3.ts
|
|
840
836
|
/**
|
|
841
837
|
* Mount an S3 bucket using s3fs-fuse.
|
|
842
838
|
*/
|
|
@@ -943,8 +939,7 @@ Error details: ${installResult.stderr || installResult.stdout}`);
|
|
|
943
939
|
}
|
|
944
940
|
if ((await sandbox.commands.run(`mountpoint -q ${shellQuote(mountPath)}`)).exitCode !== 0) throw new Error(`s3fs returned exit 0 but ${mountPath} is not a mountpoint. The s3fs daemon likely failed during FUSE init (common causes: region mismatch, invalid credentials, or an S3-compatible endpoint that rejects the signature). Re-run inside the sandbox with '-f -o dbglevel=info' to see the underlying error.`);
|
|
945
941
|
}
|
|
946
|
-
|
|
947
|
-
//#region src/sandbox/mounts/gcs.ts
|
|
942
|
+
// src/sandbox/mounts/gcs.ts
|
|
948
943
|
/**
|
|
949
944
|
* Mount a GCS bucket using gcsfuse.
|
|
950
945
|
*
|
|
@@ -995,8 +990,7 @@ async function mountGCS(mountPath, config, ctx) {
|
|
|
995
990
|
throw new Error(`Failed to mount GCS bucket: ${stderr || stdout || error}`);
|
|
996
991
|
}
|
|
997
992
|
}
|
|
998
|
-
|
|
999
|
-
//#region src/sandbox/mounts/azure.ts
|
|
993
|
+
// src/sandbox/mounts/azure.ts
|
|
1000
994
|
const SAFE_CONTAINER_NAME = /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/;
|
|
1001
995
|
const BLOBFUSE2_GITHUB_DEB = "https://github.com/Azure/azure-storage-fuse/releases/download/blobfuse2-2.5.1/blobfuse2-2.5.1-Ubuntu-22.04.x86_64.deb";
|
|
1002
996
|
function validateContainerName(name) {
|
|
@@ -1193,8 +1187,7 @@ Error details: ${verifyResult.stderr || verifyResult.stdout || installResult?.st
|
|
|
1193
1187
|
throw new Error(`Failed to mount Azure Blob container: ${stderr || stdout || error}`);
|
|
1194
1188
|
}
|
|
1195
1189
|
}
|
|
1196
|
-
|
|
1197
|
-
//#region src/sandbox/process-manager.ts
|
|
1190
|
+
// src/sandbox/process-manager.ts
|
|
1198
1191
|
/**
|
|
1199
1192
|
* E2B Process Manager
|
|
1200
1193
|
*
|
|
@@ -1211,8 +1204,7 @@ var E2BProcessManager = class extends CommandsApiProcessManager {
|
|
|
1211
1204
|
return fn(this.sandbox.e2b.commands);
|
|
1212
1205
|
}
|
|
1213
1206
|
};
|
|
1214
|
-
|
|
1215
|
-
//#region src/sandbox/index.ts
|
|
1207
|
+
// src/sandbox/index.ts
|
|
1216
1208
|
/** Allowlist pattern for mount paths — absolute path with safe characters only. */
|
|
1217
1209
|
const SAFE_MOUNT_PATH = /^\/[a-zA-Z0-9_.\-/]+$/;
|
|
1218
1210
|
function validateMountPath(mountPath) {
|
|
@@ -2204,8 +2196,7 @@ var E2BSandbox = class E2BSandbox extends MastraSandbox {
|
|
|
2204
2196
|
}
|
|
2205
2197
|
}
|
|
2206
2198
|
};
|
|
2207
|
-
|
|
2208
|
-
//#region src/utils/repo-template.ts
|
|
2199
|
+
// src/utils/repo-template.ts
|
|
2209
2200
|
/**
|
|
2210
2201
|
* Sha-tagged repo templates.
|
|
2211
2202
|
*
|
|
@@ -2618,8 +2609,7 @@ function assertWorkingDirectory(dir) {
|
|
|
2618
2609
|
if (!(/^\/[A-Za-z0-9._/-]*$/.test(dir) && !dir.split("/").includes(".."))) throw new Error(`Repo template workingDirectory must be an absolute path of plain path characters (got ${JSON.stringify(dir)}); ~ and $HOME are not expanded.`);
|
|
2619
2610
|
return dir;
|
|
2620
2611
|
}
|
|
2621
|
-
|
|
2622
|
-
//#region src/provider.ts
|
|
2612
|
+
// src/provider.ts
|
|
2623
2613
|
const e2bSandboxProvider = {
|
|
2624
2614
|
id: "e2b",
|
|
2625
2615
|
name: "E2B Sandbox",
|
|
@@ -2666,8 +2656,7 @@ const e2bSandboxProvider = {
|
|
|
2666
2656
|
},
|
|
2667
2657
|
createSandbox: (config) => new E2BSandbox(config)
|
|
2668
2658
|
};
|
|
2669
|
-
|
|
2670
|
-
//#region src/factory-sandbox.ts
|
|
2659
|
+
// src/factory-sandbox.ts
|
|
2671
2660
|
/** Applied when neither the environment setting nor a host default is set. */
|
|
2672
2661
|
const DEFAULT_SETTINGS = {
|
|
2673
2662
|
cpuCount: 2,
|
|
@@ -2902,8 +2891,7 @@ function mapStatus(status) {
|
|
|
2902
2891
|
default: return "unknown";
|
|
2903
2892
|
}
|
|
2904
2893
|
}
|
|
2905
|
-
|
|
2906
|
-
//#region src/code-mode/transport.ts
|
|
2894
|
+
// src/code-mode/transport.ts
|
|
2907
2895
|
/**
|
|
2908
2896
|
* Code Mode — E2B transport
|
|
2909
2897
|
*
|
|
@@ -3043,9 +3031,7 @@ var E2BCodeModeTransport = class {
|
|
|
3043
3031
|
};
|
|
3044
3032
|
resolveDone();
|
|
3045
3033
|
return;
|
|
3046
|
-
case "rpc":
|
|
3047
|
-
serveRpc(frame.id, frame.tool, frame.args).catch(() => {});
|
|
3048
|
-
return;
|
|
3034
|
+
case "rpc": serveRpc(frame.id, frame.tool, frame.args).catch(() => {});
|
|
3049
3035
|
}
|
|
3050
3036
|
};
|
|
3051
3037
|
handle = await sandbox.processes.spawn(`node ${runnerPath}`, {
|
|
@@ -3107,7 +3093,6 @@ var E2BCodeModeTransport = class {
|
|
|
3107
3093
|
}
|
|
3108
3094
|
}
|
|
3109
3095
|
};
|
|
3110
|
-
//#endregion
|
|
3111
3096
|
export { DEFAULT_NODE_VERSION, E2BCodeModeTransport, E2BFactorySandbox, E2BProcessManager, E2BSandbox, E2BSandboxFilesystem, createDefaultMountableTemplate, createRepoTemplate, e2bSandboxProvider, isDeferredNamedTemplateSpec, isNamedTemplateSpec, refreshRepoTemplate, repoTemplateRef };
|
|
3112
3097
|
|
|
3113
3098
|
//# sourceMappingURL=index.js.map
|