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

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