@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 +21 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -6
- package/dist/index.js.map +1 -1
- package/dist/repo-template.d.ts.map +1 -1
- package/dist/sandbox.d.ts +3 -2
- package/dist/sandbox.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1023,9 +1023,9 @@ var SandboxDestroyedError = class extends Error {
|
|
|
1023
1023
|
* sandbox.
|
|
1024
1024
|
*/
|
|
1025
1025
|
function buildCommand(command, args) {
|
|
1026
|
-
return args?.length ? `${command} ${args.map(shellQuote).join(" ")}` : command;
|
|
1026
|
+
return args?.length ? `${command} ${args.map(shellQuote$1).join(" ")}` : command;
|
|
1027
1027
|
}
|
|
1028
|
-
function shellQuote(arg) {
|
|
1028
|
+
function shellQuote$1(arg) {
|
|
1029
1029
|
if (/^[a-zA-Z0-9._\-/=:@]+$/.test(arg)) return arg;
|
|
1030
1030
|
return `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
1031
1031
|
}
|
|
@@ -1495,14 +1495,15 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
|
|
|
1495
1495
|
* sandbox they can't safely retry.
|
|
1496
1496
|
*
|
|
1497
1497
|
* Railway requires a caller-supplied recovery `id` before it can have a
|
|
1498
|
-
* checkpoint to delete. E2B
|
|
1499
|
-
*
|
|
1498
|
+
* checkpoint to delete. On E2B the sandbox itself is the persistent thing
|
|
1499
|
+
* (idle sandboxes pause and resume in place), so destroy only kills the
|
|
1500
|
+
* VM; any snapshot a caller captured on purpose is the caller's to manage.
|
|
1500
1501
|
*/
|
|
1501
1502
|
async destroy() {
|
|
1502
1503
|
if (!this._sandboxId) return;
|
|
1503
1504
|
const destroyedSandboxId = this._sandboxId;
|
|
1504
1505
|
this._captureInFlight = null;
|
|
1505
|
-
if (this._hasRecoveryKey
|
|
1506
|
+
if (this._hasRecoveryKey && this._client.sandboxProvider !== "e2b") try {
|
|
1506
1507
|
await this._request(`/sandbox/${encodeURIComponent(destroyedSandboxId)}/checkpoint`, {
|
|
1507
1508
|
method: "DELETE",
|
|
1508
1509
|
headers: { "content-type": "application/json" },
|
|
@@ -1965,6 +1966,16 @@ function setupMarkerContent(setupCommand) {
|
|
|
1965
1966
|
function setupMarkerCommand(content) {
|
|
1966
1967
|
return `mkdir -p "$(dirname "${SETUP_MARKER_PATH}")" && printf '%s' '${content}' > "${SETUP_MARKER_PATH}"`;
|
|
1967
1968
|
}
|
|
1969
|
+
function repoCloneCommand({ cloneUrl, destination, branch, tokenEnv }) {
|
|
1970
|
+
return `git ${tokenEnv ? `${gitAuthFlag$1(tokenEnv)} ` : ""}clone --depth=1 --single-branch ${branch ? `--branch ${shellQuote(branch)} ` : ""}${shellQuote(cloneUrl)} ${shellQuote(destination)}`;
|
|
1971
|
+
}
|
|
1972
|
+
/** Per-invocation auth header; `-c` config never reaches `.git/config`. */
|
|
1973
|
+
function gitAuthFlag$1(tokenEnv) {
|
|
1974
|
+
return `-c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$${tokenEnv}" | base64 -w0)"`;
|
|
1975
|
+
}
|
|
1976
|
+
function shellQuote(value) {
|
|
1977
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
1978
|
+
}
|
|
1968
1979
|
//#endregion
|
|
1969
1980
|
//#region src/repo-template.ts
|
|
1970
1981
|
const execFileAsync = promisify(execFile);
|
|
@@ -2046,7 +2057,11 @@ function createRepoTemplate(options) {
|
|
|
2046
2057
|
if (Object.keys(buildEnv).length > 0) template = template.setEnvs(buildEnv, { ephemeral: true });
|
|
2047
2058
|
template = withResources(template, options);
|
|
2048
2059
|
if (workingDirectory) template = template.runCmd(`mkdir -p "${workingDirectory}"`).setWorkdir(workingDirectory);
|
|
2049
|
-
template = template.runCmd(
|
|
2060
|
+
template = template.runCmd(repoCloneCommand({
|
|
2061
|
+
cloneUrl,
|
|
2062
|
+
destination: repoDir,
|
|
2063
|
+
...token ? { tokenEnv: BUILD_TOKEN_ENV } : {}
|
|
2064
|
+
})).runCmd(`git -C "${repoDir}" ${auth}fetch origin ${sha}`).runCmd(`git -C "${repoDir}" checkout ${sha}`);
|
|
2050
2065
|
for (const command of setupCommands) template = template.runCmd(`cd "${repoDir}" && ${command}`);
|
|
2051
2066
|
template = template.runCmd(setupMarkerCommand(setupMarkerContent(setupCommands)));
|
|
2052
2067
|
return template.withFamily(family);
|