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