@mastra/platform-workspace 1.5.0 → 1.5.1-alpha.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 +31 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +31 -7
- package/dist/index.js.map +1 -1
- package/dist/repo-template.d.ts +4 -2
- package/dist/repo-template.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -2015,6 +2015,14 @@ const BUILD_TOKEN_ENV = "MASTRA_REPOSITORY_ACCESS_TOKEN";
|
|
|
2015
2015
|
const CLONE_URL_ALLOWED_CHARS = /^[a-z0-9:/._-]+$/i;
|
|
2016
2016
|
const CLONE_URL_HOST_PATTERN = /^[a-z0-9.-]+$/i;
|
|
2017
2017
|
const CLONE_URL_SEGMENT_PATTERN = /^[\w.-]+$/;
|
|
2018
|
+
/** Last default-branch head resolved per clone URL, shared across resolvers in this process. */
|
|
2019
|
+
const lastKnownHeads = /* @__PURE__ */ new Map();
|
|
2020
|
+
const MAX_LAST_KNOWN_HEADS = 1e3;
|
|
2021
|
+
function rememberHead(cloneUrl, sha) {
|
|
2022
|
+
lastKnownHeads.delete(cloneUrl);
|
|
2023
|
+
lastKnownHeads.set(cloneUrl, sha);
|
|
2024
|
+
if (lastKnownHeads.size > MAX_LAST_KNOWN_HEADS) lastKnownHeads.delete(lastKnownHeads.keys().next().value);
|
|
2025
|
+
}
|
|
2018
2026
|
/**
|
|
2019
2027
|
* Create a lazy repository template definition for PlatformSandbox, mirroring
|
|
2020
2028
|
* `@mastra/e2b`'s `createRepoTemplate`: pass the sandbox context through and a
|
|
@@ -2025,8 +2033,10 @@ const CLONE_URL_SEGMENT_PATTERN = /^[\w.-]+$/;
|
|
|
2025
2033
|
* what gets cloned and what the template is identified by can't drift — and
|
|
2026
2034
|
* pins repositories to their current default-branch commit. Private repository
|
|
2027
2035
|
* credentials are used for head resolution and sent to the provider as
|
|
2028
|
-
* transient build envs; they never enter the serialized definition.
|
|
2029
|
-
*
|
|
2036
|
+
* transient build envs; they never enter the serialized definition. A failed
|
|
2037
|
+
* head lookup reuses the last head resolved for the same clone URL in this
|
|
2038
|
+
* process. If the repository cannot be resolved, or no head has been resolved
|
|
2039
|
+
* yet, the resolver keeps `cpuCount` and
|
|
2030
2040
|
* `memoryMB` in a resources-only template so the sandbox still boots at the
|
|
2031
2041
|
* requested size, and the caller's runtime setup materializes the checkout.
|
|
2032
2042
|
*/
|
|
@@ -2057,16 +2067,30 @@ function createRepoTemplate(options) {
|
|
|
2057
2067
|
}
|
|
2058
2068
|
const token = access.authorization?.token;
|
|
2059
2069
|
let headError;
|
|
2060
|
-
const
|
|
2070
|
+
const resolved = await (token ? resolveHead(cloneUrl, token) : resolveHead(cloneUrl)).catch((error) => {
|
|
2061
2071
|
headError = error;
|
|
2062
2072
|
});
|
|
2063
|
-
|
|
2064
|
-
|
|
2073
|
+
let sha;
|
|
2074
|
+
if (resolved && SHA_PATTERN.test(resolved)) {
|
|
2075
|
+
sha = resolved;
|
|
2076
|
+
rememberHead(cloneUrl, sha);
|
|
2077
|
+
} else {
|
|
2078
|
+
const lastKnown = lastKnownHeads.get(cloneUrl);
|
|
2079
|
+
if (!lastKnown) {
|
|
2080
|
+
console.warn("[platform-workspace] repo template skipped: could not resolve default-branch head", {
|
|
2081
|
+
cloneUrl,
|
|
2082
|
+
sha: resolved,
|
|
2083
|
+
error: redactSecrets(headError)
|
|
2084
|
+
});
|
|
2085
|
+
return resourcesOnly();
|
|
2086
|
+
}
|
|
2087
|
+
console.warn("[platform-workspace] repo template pinned to the last known default-branch head", {
|
|
2065
2088
|
cloneUrl,
|
|
2066
|
-
sha,
|
|
2089
|
+
sha: lastKnown,
|
|
2090
|
+
resolved,
|
|
2067
2091
|
error: redactSecrets(headError)
|
|
2068
2092
|
});
|
|
2069
|
-
|
|
2093
|
+
sha = lastKnown;
|
|
2070
2094
|
}
|
|
2071
2095
|
const workingDirectory = options.workingDirectory === void 0 ? void 0 : trimTrailingSlashes(assertWorkingDirectory(options.workingDirectory));
|
|
2072
2096
|
const repoDir = repoDirName(cloneUrl);
|