@mastra/e2b 0.11.0-alpha.2 → 0.11.0-alpha.3
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 +42 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +42 -3
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1786,13 +1786,52 @@ function buildRepoTemplateSpec(identity, token) {
|
|
|
1786
1786
|
};
|
|
1787
1787
|
}
|
|
1788
1788
|
/**
|
|
1789
|
-
*
|
|
1790
|
-
*
|
|
1791
|
-
*
|
|
1789
|
+
* `owner/repo` for a github.com clone URL, else undefined. Only the public
|
|
1790
|
+
* host is API-resolvable: GitHub Enterprise and other forges keep the git
|
|
1791
|
+
* path.
|
|
1792
|
+
*/
|
|
1793
|
+
function parseGithubRepo(cloneUrl) {
|
|
1794
|
+
let url;
|
|
1795
|
+
try {
|
|
1796
|
+
url = new URL(cloneUrl);
|
|
1797
|
+
} catch {
|
|
1798
|
+
return;
|
|
1799
|
+
}
|
|
1800
|
+
if (url.hostname.toLowerCase() !== "github.com") return void 0;
|
|
1801
|
+
const [owner, repo, ...rest] = url.pathname.split("/").filter(Boolean);
|
|
1802
|
+
if (!owner || !repo || rest.length > 0) return void 0;
|
|
1803
|
+
return {
|
|
1804
|
+
owner,
|
|
1805
|
+
repo: repo.replace(/\.git$/i, "")
|
|
1806
|
+
};
|
|
1807
|
+
}
|
|
1808
|
+
/**
|
|
1809
|
+
* Resolve the repository's current default-branch head without cloning.
|
|
1810
|
+
* github.com repositories go through the REST API so resolution works
|
|
1811
|
+
* wherever the host runs, including images without a git binary; other
|
|
1812
|
+
* hosts use `git ls-remote <url> HEAD`, authenticated via an in-process
|
|
1813
|
+
* `http.extraheader` when a token is provided. Returns undefined when the
|
|
1792
1814
|
* head cannot be resolved (inaccessible repo, offline, no git binary);
|
|
1793
1815
|
* callers degrade to the untagged template ref.
|
|
1794
1816
|
*/
|
|
1795
1817
|
async function resolveDefaultBranchHead(cloneUrl, token) {
|
|
1818
|
+
const github = parseGithubRepo(cloneUrl);
|
|
1819
|
+
if (github) try {
|
|
1820
|
+
const response = await fetch(`https://api.github.com/repos/${github.owner}/${github.repo}/commits/HEAD`, {
|
|
1821
|
+
headers: {
|
|
1822
|
+
Accept: "application/vnd.github.sha",
|
|
1823
|
+
"X-GitHub-Api-Version": "2022-11-28",
|
|
1824
|
+
"User-Agent": "mastra-e2b",
|
|
1825
|
+
...token ? { Authorization: `Bearer ${token}` } : {}
|
|
1826
|
+
},
|
|
1827
|
+
signal: AbortSignal.timeout(1e4)
|
|
1828
|
+
});
|
|
1829
|
+
if (!response.ok) return void 0;
|
|
1830
|
+
const sha = (await response.text()).trim();
|
|
1831
|
+
return SHA_PATTERN.test(sha) ? sha : void 0;
|
|
1832
|
+
} catch {
|
|
1833
|
+
return;
|
|
1834
|
+
}
|
|
1796
1835
|
try {
|
|
1797
1836
|
const authArgs = token ? ["-c", `http.extraheader=AUTHORIZATION: basic ${Buffer.from(`x-access-token:${token}`).toString("base64")}`] : [];
|
|
1798
1837
|
const { stdout } = await execFileAsync("git", [
|