@mastra/platform-workspace 1.5.0-alpha.5 → 1.5.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.cjs CHANGED
@@ -1047,9 +1047,9 @@ var SandboxDestroyedError = class extends Error {
1047
1047
  * sandbox.
1048
1048
  */
1049
1049
  function buildCommand(command, args) {
1050
- return args?.length ? `${command} ${args.map(shellQuote).join(" ")}` : command;
1050
+ return args?.length ? `${command} ${args.map(shellQuote$1).join(" ")}` : command;
1051
1051
  }
1052
- function shellQuote(arg) {
1052
+ function shellQuote$1(arg) {
1053
1053
  if (/^[a-zA-Z0-9._\-/=:@]+$/.test(arg)) return arg;
1054
1054
  return `'${arg.replace(/'/g, `'\\''`)}'`;
1055
1055
  }
@@ -1519,14 +1519,15 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1519
1519
  * sandbox they can't safely retry.
1520
1520
  *
1521
1521
  * Railway requires a caller-supplied recovery `id` before it can have a
1522
- * checkpoint to delete. E2B also permits capture with the automatic id, so
1523
- * destroy releases that named snapshot even when no recovery id was supplied.
1522
+ * checkpoint to delete. On E2B the sandbox itself is the persistent thing
1523
+ * (idle sandboxes pause and resume in place), so destroy only kills the
1524
+ * VM; any snapshot a caller captured on purpose is the caller's to manage.
1524
1525
  */
1525
1526
  async destroy() {
1526
1527
  if (!this._sandboxId) return;
1527
1528
  const destroyedSandboxId = this._sandboxId;
1528
1529
  this._captureInFlight = null;
1529
- if (this._hasRecoveryKey || this._client.sandboxProvider === "e2b") try {
1530
+ if (this._hasRecoveryKey && this._client.sandboxProvider !== "e2b") try {
1530
1531
  await this._request(`/sandbox/${encodeURIComponent(destroyedSandboxId)}/checkpoint`, {
1531
1532
  method: "DELETE",
1532
1533
  headers: { "content-type": "application/json" },
@@ -1989,6 +1990,16 @@ function setupMarkerContent(setupCommand) {
1989
1990
  function setupMarkerCommand(content) {
1990
1991
  return `mkdir -p "$(dirname "${SETUP_MARKER_PATH}")" && printf '%s' '${content}' > "${SETUP_MARKER_PATH}"`;
1991
1992
  }
1993
+ function repoCloneCommand({ cloneUrl, destination, branch, tokenEnv }) {
1994
+ return `git ${tokenEnv ? `${gitAuthFlag$1(tokenEnv)} ` : ""}clone --depth=1 --single-branch ${branch ? `--branch ${shellQuote(branch)} ` : ""}${shellQuote(cloneUrl)} ${shellQuote(destination)}`;
1995
+ }
1996
+ /** Per-invocation auth header; `-c` config never reaches `.git/config`. */
1997
+ function gitAuthFlag$1(tokenEnv) {
1998
+ return `-c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$${tokenEnv}" | base64 -w0)"`;
1999
+ }
2000
+ function shellQuote(value) {
2001
+ return `'${value.replace(/'/g, `'\\''`)}'`;
2002
+ }
1992
2003
  //#endregion
1993
2004
  //#region src/repo-template.ts
1994
2005
  const execFileAsync = (0, util.promisify)(child_process.execFile);
@@ -2070,7 +2081,11 @@ function createRepoTemplate(options) {
2070
2081
  if (Object.keys(buildEnv).length > 0) template = template.setEnvs(buildEnv, { ephemeral: true });
2071
2082
  template = withResources(template, options);
2072
2083
  if (workingDirectory) template = template.runCmd(`mkdir -p "${workingDirectory}"`).setWorkdir(workingDirectory);
2073
- template = template.runCmd(`git ${auth}clone ${cloneUrl} "${repoDir}"`).runCmd(`git -C "${repoDir}" ${auth}fetch origin ${sha}`).runCmd(`git -C "${repoDir}" checkout ${sha}`);
2084
+ template = template.runCmd(repoCloneCommand({
2085
+ cloneUrl,
2086
+ destination: repoDir,
2087
+ ...token ? { tokenEnv: BUILD_TOKEN_ENV } : {}
2088
+ })).runCmd(`git -C "${repoDir}" ${auth}fetch origin ${sha}`).runCmd(`git -C "${repoDir}" checkout ${sha}`);
2074
2089
  for (const command of setupCommands) template = template.runCmd(`cd "${repoDir}" && ${command}`);
2075
2090
  template = template.runCmd(setupMarkerCommand(setupMarkerContent(setupCommands)));
2076
2091
  return template.withFamily(family);