@mastra/e2b 0.11.0-alpha.3 → 0.11.0-alpha.4

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
@@ -1554,6 +1554,31 @@ var E2BSandbox = class E2BSandbox extends _mastra_core_workspace.MastraSandbox {
1554
1554
  }
1555
1555
  };
1556
1556
  //#endregion
1557
+ //#region ../../packages/_internals/workspace/dist/index.js
1558
+ /**
1559
+ * Setup completion marker shared by repo templates and their consumers.
1560
+ *
1561
+ * A repo template writes this file beside the checkout as its last build
1562
+ * step, so it exists only in images where every setup command succeeded. Its
1563
+ * content is a digest of the setup commands the image ran, letting a sandbox
1564
+ * booted from the image tell whether the setup it is about to run already
1565
+ * happened. Relative to the template's build cwd, which is also the runtime
1566
+ * working directory the repo was cloned into.
1567
+ */
1568
+ const SETUP_MARKER_PATH = ".mastra-sandbox/setup";
1569
+ /** Blank entries never become build steps, so they never count toward the digest either. */
1570
+ function normalizeSetupCommands$1(setupCommand) {
1571
+ return (setupCommand === void 0 ? [] : Array.isArray(setupCommand) ? setupCommand : [setupCommand]).filter((command) => command.trim() !== "");
1572
+ }
1573
+ /** The marker content for a setup command list: `sha256:<hex>` over the commands joined by newlines. */
1574
+ function setupMarkerContent(setupCommand) {
1575
+ return `sha256:${(0, crypto.createHash)("sha256").update(normalizeSetupCommands$1(setupCommand).join("\n")).digest("hex")}`;
1576
+ }
1577
+ /** Shell step that writes the marker relative to the cwd. `content` is a digest, so it is shell-safe. */
1578
+ function setupMarkerCommand(content) {
1579
+ return `mkdir -p "$(dirname "${SETUP_MARKER_PATH}")" && printf '%s' '${content}' > "${SETUP_MARKER_PATH}"`;
1580
+ }
1581
+ //#endregion
1557
1582
  //#region src/utils/repo-template.ts
1558
1583
  /**
1559
1584
  * Sha-tagged repo templates.
@@ -1773,7 +1798,9 @@ function buildRepoTemplateSpec(identity, token) {
1773
1798
  }
1774
1799
  template = template.runCmd(`git ${auth}clone ${cloneUrl} "${repoDir}"`);
1775
1800
  if (sha) template = template.runCmd(`git -C "${repoDir}" ${auth}fetch origin ${sha}`).runCmd(`git -C "${repoDir}" checkout ${sha}`);
1776
- for (const command of normalizeSetupCommands(setupCommand)) template = template.runCmd(`cd "${repoDir}" && ${command}`);
1801
+ const setupCommands = normalizeSetupCommands(setupCommand);
1802
+ for (const command of setupCommands) template = template.runCmd(`cd "${repoDir}" && ${command}`);
1803
+ template = template.runCmd(setupMarkerCommand(setupMarkerContent(setupCommands)));
1777
1804
  return {
1778
1805
  ref: repoTemplateRef(identity),
1779
1806
  template,