@mastra/platform-workspace 1.5.0-alpha.3 → 1.5.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 +27 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -1
- package/dist/repo-template.d.ts.map +1 -1
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { FileExistsError, FileNotFoundError, MastraFilesystem, MastraSandbox, Pr
|
|
|
4
4
|
import { CommandExitError, Sandbox, TimeoutError } from "e2b";
|
|
5
5
|
import { execFile } from "child_process";
|
|
6
6
|
import { promisify } from "util";
|
|
7
|
+
import { createHash } from "crypto";
|
|
7
8
|
//#region src/client.ts
|
|
8
9
|
const DEFAULT_PROXY_URL = "https://workspaces.mastra.ai";
|
|
9
10
|
/**
|
|
@@ -1940,6 +1941,31 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
|
|
|
1940
1941
|
}
|
|
1941
1942
|
};
|
|
1942
1943
|
//#endregion
|
|
1944
|
+
//#region ../../packages/_internals/workspace/dist/index.js
|
|
1945
|
+
/**
|
|
1946
|
+
* Setup completion marker shared by repo templates and their consumers.
|
|
1947
|
+
*
|
|
1948
|
+
* A repo template writes this file beside the checkout as its last build
|
|
1949
|
+
* step, so it exists only in images where every setup command succeeded. Its
|
|
1950
|
+
* content is a digest of the setup commands the image ran, letting a sandbox
|
|
1951
|
+
* booted from the image tell whether the setup it is about to run already
|
|
1952
|
+
* happened. Relative to the template's build cwd, which is also the runtime
|
|
1953
|
+
* working directory the repo was cloned into.
|
|
1954
|
+
*/
|
|
1955
|
+
const SETUP_MARKER_PATH = ".mastra-sandbox/setup";
|
|
1956
|
+
/** Blank entries never become build steps, so they never count toward the digest either. */
|
|
1957
|
+
function normalizeSetupCommands(setupCommand) {
|
|
1958
|
+
return (setupCommand === void 0 ? [] : Array.isArray(setupCommand) ? setupCommand : [setupCommand]).filter((command) => command.trim() !== "");
|
|
1959
|
+
}
|
|
1960
|
+
/** The marker content for a setup command list: `sha256:<hex>` over the commands joined by newlines. */
|
|
1961
|
+
function setupMarkerContent(setupCommand) {
|
|
1962
|
+
return `sha256:${createHash("sha256").update(normalizeSetupCommands(setupCommand).join("\n")).digest("hex")}`;
|
|
1963
|
+
}
|
|
1964
|
+
/** Shell step that writes the marker relative to the cwd. `content` is a digest, so it is shell-safe. */
|
|
1965
|
+
function setupMarkerCommand(content) {
|
|
1966
|
+
return `mkdir -p "$(dirname "${SETUP_MARKER_PATH}")" && printf '%s' '${content}' > "${SETUP_MARKER_PATH}"`;
|
|
1967
|
+
}
|
|
1968
|
+
//#endregion
|
|
1943
1969
|
//#region src/repo-template.ts
|
|
1944
1970
|
const execFileAsync = promisify(execFile);
|
|
1945
1971
|
const SHA_PATTERN = /^[0-9a-f]{7,40}$/i;
|
|
@@ -2022,6 +2048,7 @@ function createRepoTemplate(options) {
|
|
|
2022
2048
|
if (workingDirectory) template = template.runCmd(`mkdir -p "${workingDirectory}"`).setWorkdir(workingDirectory);
|
|
2023
2049
|
template = template.runCmd(`git ${auth}clone ${cloneUrl} "${repoDir}"`).runCmd(`git -C "${repoDir}" ${auth}fetch origin ${sha}`).runCmd(`git -C "${repoDir}" checkout ${sha}`);
|
|
2024
2050
|
for (const command of setupCommands) template = template.runCmd(`cd "${repoDir}" && ${command}`);
|
|
2051
|
+
template = template.runCmd(setupMarkerCommand(setupMarkerContent(setupCommands)));
|
|
2025
2052
|
return template.withFamily(family);
|
|
2026
2053
|
};
|
|
2027
2054
|
}
|