@mastra/e2b 0.3.0 → 0.3.1-alpha.0

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
@@ -33,6 +33,14 @@ function validateEndpoint(endpoint) {
33
33
  throw new Error(`Invalid endpoint URL: "${endpoint}"`);
34
34
  }
35
35
  }
36
+ var SAFE_REGION = /^[a-z0-9-]{2,32}$/;
37
+ function validateRegion(region) {
38
+ if (typeof region !== "string" || !SAFE_REGION.test(region)) {
39
+ throw new Error(
40
+ `Invalid region: ${JSON.stringify(region)}. Region must be a string of lowercase alphanumeric or hyphens (e.g., "us-east-1", "ap-northeast-1", "auto").`
41
+ );
42
+ }
43
+ }
36
44
  function validatePrefix(prefix) {
37
45
  let normalized = prefix;
38
46
  while (normalized.startsWith("/")) normalized = normalized.slice(1);
@@ -59,6 +67,7 @@ function shellQuote(arg) {
59
67
  async function mountS3(mountPath, config, ctx) {
60
68
  const { sandbox, logger } = ctx;
61
69
  validateBucketName(config.bucket);
70
+ validateRegion(config.region);
62
71
  if (config.endpoint) {
63
72
  validateEndpoint(config.endpoint);
64
73
  }
@@ -118,6 +127,7 @@ Error details: ${installResult.stderr || installResult.stdout}`
118
127
  const endpoint = config.endpoint.replace(/\/$/, "");
119
128
  mountOptions.push(`url=${endpoint}`, "use_path_request_style", "sigv4", "nomultipart");
120
129
  }
130
+ mountOptions.push(`endpoint=${config.region}`);
121
131
  if (config.readOnly) {
122
132
  mountOptions.push("ro");
123
133
  logger.debug(`${LOG_PREFIX} Mounting as read-only`);
@@ -146,6 +156,12 @@ Error details: ${installResult.stderr || installResult.stdout}`
146
156
  logger.error(`${LOG_PREFIX} s3fs error:`, { stderr, stdout, error: String(error) });
147
157
  throw new Error(`Failed to mount S3 bucket: ${stderr || stdout || error}`);
148
158
  }
159
+ const verify = await sandbox.commands.run(`mountpoint -q ${shellQuote(mountPath)}`);
160
+ if (verify.exitCode !== 0) {
161
+ throw new Error(
162
+ `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.`
163
+ );
164
+ }
149
165
  }
150
166
 
151
167
  // src/sandbox/mounts/gcs.ts