@leanmcp/cli 0.5.5-alpha.41.e410a1b → 0.5.5-alpha.42.6df6bbe

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.
Files changed (2) hide show
  1. package/dist/index.js +46 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1786,6 +1786,42 @@ async function debugFetch(url, options = {}) {
1786
1786
  return response;
1787
1787
  }
1788
1788
  __name(debugFetch, "debugFetch");
1789
+ async function fetchWithRetry(fetchFn, options = {}) {
1790
+ const maxRetries = options.maxRetries ?? 15;
1791
+ const initialDelay = options.initialDelay ?? 1e3;
1792
+ const maxDelay = options.maxDelay ?? 1e4;
1793
+ const operation = options.operation ?? "Fetch";
1794
+ const spinner = options.spinner;
1795
+ const retryOnHttpErrors = options.retryOnHttpErrors ?? false;
1796
+ let lastError = null;
1797
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
1798
+ try {
1799
+ const response = await fetchFn();
1800
+ if (retryOnHttpErrors && !response.ok && response.status >= 500) {
1801
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
1802
+ }
1803
+ return response;
1804
+ } catch (error) {
1805
+ lastError = error instanceof Error ? error : new Error(String(error));
1806
+ if (attempt < maxRetries) {
1807
+ const delay = Math.min(initialDelay * Math.pow(2, attempt), maxDelay);
1808
+ const message = `${operation} failed. Retrying... (${attempt + 1}/${maxRetries})`;
1809
+ if (spinner) {
1810
+ spinner.text = message;
1811
+ } else {
1812
+ process.stdout.write("\r" + chalk.yellow(message));
1813
+ }
1814
+ debug3(`Retry ${attempt + 1}/${maxRetries}: ${lastError.message}, waiting ${delay}ms`);
1815
+ await new Promise((resolve) => setTimeout(resolve, delay));
1816
+ }
1817
+ }
1818
+ }
1819
+ if (!spinner) {
1820
+ process.stdout.write("\x1B[2K\r");
1821
+ }
1822
+ throw new Error(`${operation} failed after ${maxRetries + 1} attempts (1 initial + ${maxRetries} retries): ${lastError?.message || "Unknown error"}`);
1823
+ }
1824
+ __name(fetchWithRetry, "fetchWithRetry");
1789
1825
  var API_ENDPOINTS = {
1790
1826
  // Projects
1791
1827
  projects: "/api/projects",
@@ -1872,10 +1908,14 @@ async function waitForBuild(apiUrl, apiKey, buildId, spinner) {
1872
1908
  const maxAttempts = 60;
1873
1909
  let attempts = 0;
1874
1910
  while (attempts < maxAttempts) {
1875
- const response = await debugFetch(`${apiUrl}${API_ENDPOINTS.getBuild}/${buildId}`, {
1911
+ const response = await fetchWithRetry(() => debugFetch(`${apiUrl}${API_ENDPOINTS.getBuild}/${buildId}`, {
1876
1912
  headers: {
1877
1913
  Authorization: `Bearer ${apiKey}`
1878
1914
  }
1915
+ }), {
1916
+ operation: "Build status check",
1917
+ spinner,
1918
+ maxRetries: 3
1879
1919
  });
1880
1920
  if (!response.ok) {
1881
1921
  throw new Error(`Failed to get build status: ${response.statusText}`);
@@ -1901,10 +1941,14 @@ async function waitForDeployment(apiUrl, apiKey, deploymentId, spinner) {
1901
1941
  const maxAttempts = 60;
1902
1942
  let attempts = 0;
1903
1943
  while (attempts < maxAttempts) {
1904
- const response = await debugFetch(`${apiUrl}${API_ENDPOINTS.getDeployment}/${deploymentId}`, {
1944
+ const response = await fetchWithRetry(() => debugFetch(`${apiUrl}${API_ENDPOINTS.getDeployment}/${deploymentId}`, {
1905
1945
  headers: {
1906
1946
  Authorization: `Bearer ${apiKey}`
1907
1947
  }
1948
+ }), {
1949
+ operation: "Deployment status check",
1950
+ spinner,
1951
+ maxRetries: 3
1908
1952
  });
1909
1953
  if (!response.ok) {
1910
1954
  throw new Error(`Failed to get deployment status: ${response.statusText}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leanmcp/cli",
3
- "version": "0.5.5-alpha.41.e410a1b",
3
+ "version": "0.5.5-alpha.42.6df6bbe",
4
4
  "description": "Command-line interface for scaffolding LeanMCP projects",
5
5
  "bin": {
6
6
  "leanmcp": "bin/leanmcp.js"