@mastra/e2b 0.11.0-alpha.5 → 0.11.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
@@ -126,7 +126,7 @@ function validatePrefix(prefix) {
126
126
  * Arguments containing only safe characters are returned as-is.
127
127
  * All others are wrapped in single quotes with embedded single quotes escaped.
128
128
  */
129
- function shellQuote(arg) {
129
+ function shellQuote$1(arg) {
130
130
  if (/^[a-zA-Z0-9._\-/@:=]+$/.test(arg)) return arg;
131
131
  return "'" + arg.replace(/'/g, "'\\''") + "'";
132
132
  }
@@ -191,7 +191,7 @@ Error details: ${installResult.stderr || installResult.stdout}`);
191
191
  const normalizedPrefix = validatePrefix(config.prefix);
192
192
  bucketArg = `${config.bucket}:/${normalizedPrefix}`;
193
193
  }
194
- const mountCmd = `sudo s3fs ${shellQuote(bucketArg)} ${shellQuote(mountPath)} -o ${mountOptions.join(" -o ")}`;
194
+ const mountCmd = `sudo s3fs ${shellQuote$1(bucketArg)} ${shellQuote$1(mountPath)} -o ${mountOptions.join(" -o ")}`;
195
195
  logger.debug(`${LOG_PREFIX} Mounting S3:`, hasCredentials ? mountCmd.replace(credentialsPath, "***") : mountCmd);
196
196
  try {
197
197
  const result = await sandbox.commands.run(mountCmd, { timeoutMs: 6e4 });
@@ -212,7 +212,7 @@ Error details: ${installResult.stderr || installResult.stdout}`);
212
212
  });
213
213
  throw new Error(`Failed to mount S3 bucket: ${stderr || stdout || error}`);
214
214
  }
215
- 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.`);
215
+ if ((await sandbox.commands.run(`mountpoint -q ${shellQuote$1(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.`);
216
216
  }
217
217
  //#endregion
218
218
  //#region src/sandbox/mounts/gcs.ts
@@ -232,7 +232,7 @@ async function mountGCS(mountPath, config, ctx) {
232
232
  }
233
233
  const [uid, gid] = (await sandbox.commands.run("id -u && id -g")).stdout.trim().split("\n");
234
234
  const uidGidFlags = uid && gid ? `--uid=${uid} --gid=${gid}` : "";
235
- const onlyDirFlag = config.prefix ? ` --only-dir=${shellQuote(validatePrefix(config.prefix))}` : "";
235
+ const onlyDirFlag = config.prefix ? ` --only-dir=${shellQuote$1(validatePrefix(config.prefix))}` : "";
236
236
  const hasCredentials = !!config.serviceAccountKey;
237
237
  let mountCmd;
238
238
  if (hasCredentials) {
@@ -440,9 +440,9 @@ Error details: ${verifyResult.stderr || verifyResult.stdout || installResult?.st
440
440
  await sandbox.commands.run(`sudo rm -f ${configPath}`);
441
441
  await sandbox.files.write(configPath, yaml);
442
442
  await sandbox.commands.run(`sudo chown root:root ${configPath} && sudo chmod 600 ${configPath}`);
443
- await sandbox.commands.run(`sudo rm -rf ${shellQuote(cachePath)} && sudo mkdir -p ${shellQuote(cachePath)}`);
444
- const prefixFlags = prefix ? ` --virtual-directory=true --subdirectory=${shellQuote(prefix)}` : "";
445
- const mountCmd = `sudo blobfuse2 mount ${shellQuote(mountPath)} --config-file=${shellQuote(configPath)}${prefixFlags}`;
443
+ await sandbox.commands.run(`sudo rm -rf ${shellQuote$1(cachePath)} && sudo mkdir -p ${shellQuote$1(cachePath)}`);
444
+ const prefixFlags = prefix ? ` --virtual-directory=true --subdirectory=${shellQuote$1(prefix)}` : "";
445
+ const mountCmd = `sudo blobfuse2 mount ${shellQuote$1(mountPath)} --config-file=${shellQuote$1(configPath)}${prefixFlags}`;
446
446
  logger.debug(`${LOG_PREFIX} Mounting Azure Blob:`, mountCmd);
447
447
  try {
448
448
  const result = await sandbox.commands.run(mountCmd, { timeoutMs: 6e4 });
@@ -1577,6 +1577,16 @@ function setupMarkerContent(setupCommand) {
1577
1577
  function setupMarkerCommand(content) {
1578
1578
  return `mkdir -p "$(dirname "${SETUP_MARKER_PATH}")" && printf '%s' '${content}' > "${SETUP_MARKER_PATH}"`;
1579
1579
  }
1580
+ function repoCloneCommand({ cloneUrl, destination, branch, tokenEnv }) {
1581
+ return `git ${tokenEnv ? `${gitAuthFlag$1(tokenEnv)} ` : ""}clone --depth=1 --single-branch ${branch ? `--branch ${shellQuote(branch)} ` : ""}${shellQuote(cloneUrl)} ${shellQuote(destination)}`;
1582
+ }
1583
+ /** Per-invocation auth header; `-c` config never reaches `.git/config`. */
1584
+ function gitAuthFlag$1(tokenEnv) {
1585
+ return `-c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$${tokenEnv}" | base64 -w0)"`;
1586
+ }
1587
+ function shellQuote(value) {
1588
+ return `'${value.replace(/'/g, `'\\''`)}'`;
1589
+ }
1580
1590
  //#endregion
1581
1591
  //#region src/utils/repo-template.ts
1582
1592
  /**
@@ -1795,7 +1805,11 @@ function buildRepoTemplateSpec(identity, token) {
1795
1805
  const dir = trimTrailingSlashes(workingDirectory);
1796
1806
  template = template.runCmd(`mkdir -p "${dir}"`).setWorkdir(dir);
1797
1807
  }
1798
- template = template.runCmd(`git ${auth}clone ${cloneUrl} "${repoDir}"`);
1808
+ template = template.runCmd(repoCloneCommand({
1809
+ cloneUrl,
1810
+ destination: repoDir,
1811
+ ...token ? { tokenEnv: BUILD_TOKEN_ENV } : {}
1812
+ }));
1799
1813
  if (sha) template = template.runCmd(`git -C "${repoDir}" ${auth}fetch origin ${sha}`).runCmd(`git -C "${repoDir}" checkout ${sha}`);
1800
1814
  const setupCommands = normalizeSetupCommands(setupCommand);
1801
1815
  for (const command of setupCommands) template = template.runCmd(`cd "${repoDir}" && ${command}`);