Lines 95-135javascript
95//#region src/utils/shell-quote.ts
97* Shell-quote a single argument for safe use in a command string.
99* Arguments containing only safe characters are returned as-is.
100* All others are wrapped in single quotes with embedded single quotes escaped.
102function shellQuote(arg) {
103 if (/^[a-zA-Z0-9._\-/@:=]+$/.test(arg)) return arg;
104 return "'" + arg.replace(/'/g, "'\\''") + "'";
107//#region src/sandbox/mounts/s3.ts
109* Mount an S3 bucket using s3fs-fuse.
111async function mountS3(mountPath, config, ctx) {
112 const { sandbox, logger } = ctx;
113 validateBucketName(config.bucket);
114 validateRegion(config.region);
115 if (config.endpoint) validateEndpoint(config.endpoint);
116 if ((await sandbox.commands.run("which s3fs || echo \"not found\"")).stdout.includes("not found")) {
117 logger.warn(`${LOG_PREFIX} s3fs not found, attempting runtime installation...`);
LowWeak Crypto
Package source references weak cryptographic algorithms.
dist/index.jsView on unpkg · L115 118 logger.info(`${LOG_PREFIX} Tip: For faster startup, use createMountableTemplate() to pre-install s3fs in your sandbox template`);
119 await sandbox.commands.run("sudo apt-get update 2>&1", { timeoutMs: 6e4 });
120 const installResult = await sandbox.commands.run("sudo apt-get install -y s3fs fuse 2>&1 || sudo apt-get install -y s3fs-fuse fuse 2>&1", { timeoutMs: 12e4 });
121 if (installResult.exitCode !== 0) throw new Error(`Failed to install s3fs. For S3 mounting, your template needs s3fs and fuse packages.
123Option 1: Use createMountableTemplate() helper:
124 import { E2BSandbox, createMountableTemplate } from '@mastra/e2b';
125 const sandbox = new E2BSandbox({ template: createMountableTemplate() });
127Option 2: Customize the base template:
128 new E2BSandbox({ template: base => base.aptInstall(['your-packages']) })
130Error details: ${installResult.stderr || installResult.stdout}`);
132 const [uid, gid] = (await sandbox.commands.run("id -u && id -g")).stdout.trim().split("\n");
133 const hasAccessKey = !!config.accessKeyId;
134 const hasSecretKey = !!config.secretAccessKey;
135 if (hasAccessKey !== hasSecretKey) throw new Error("Both accessKeyId and secretAccessKey must be provided together.");