@mistflow-ai/mcp 0.3.0 → 0.4.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/{api-client-GWLQOOJZ.js → api-client-5AWPJEHX.js} +1 -1
- package/dist/{browser-manager-K5BT5YXO.js → browser-manager-QW3OYPFB.js} +1 -1
- package/dist/{chunk-3BQGCB7F.js → chunk-POG2UHKW.js} +1 -1
- package/dist/{chunk-ANYHR4WA.js → chunk-UNFTM4B3.js} +1 -1
- package/dist/{chunk-MAAENV5J.js → chunk-Y3F6QWAR.js} +3 -3
- package/dist/index.js +1220 -9639
- package/dist/{self-heal-OGLEOZC4.js → self-heal-IANGU6DO.js} +1 -1
- package/dist/state-manager-HGPAQSNJ.js +1 -0
- package/package.json +1 -1
- package/dist/state-manager-6NJO66MS.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as s,B as t,C as u,D as v,E as w,F as x,G as y,H as z,I as A,J as B,K as C,L as D,M as E,N as F,O as G,P as H,Q as I,R as J,S as K,T as L,U as M,V as N,W as O,X as P,Y as Q,Z as R,h as a,j as b,k as c,l as d,m as e,n as f,o as g,p as h,q as i,r as j,s as k,t as l,u as m,v as n,w as o,x as p,y as q,z as r}from"./chunk-
|
|
1
|
+
import{A as s,B as t,C as u,D as v,E as w,F as x,G as y,H as z,I as A,J as B,K as C,L as D,M as E,N as F,O as G,P as H,Q as I,R as J,S as K,T as L,U as M,V as N,W as O,X as P,Y as Q,Z as R,h as a,j as b,k as c,l as d,m as e,n as f,o as g,p as h,q as i,r as j,s as k,t as l,u as m,v as n,w as o,x as p,y as q,z as r}from"./chunk-Y3F6QWAR.js";export{e as MistflowApiError,t as addDomain,i as checkAuth,j as checkAuthDetailed,l as checkSubdomain,n as createDeployment,m as createProject,C as deleteEnvVar,s as discoverDecisions,J as downloadSource,P as downloadSourceWithToken,M as fetchModule,K as fetchScaffold,L as fetchStepContext,O as forkTemplate,q as generatePlan,f as getAuthHeaders,b as getBaseUrl,d as getDashboardUrl,x as getDbCredentials,D as getDeployLogs,p as getDeploymentStatus,k as getProject,E as getProjectErrors,y as getSeedInfo,c as getSiteUrl,N as getTemplate,a as hasCredentialsOnDisk,h as hasLocalCredentials,F as listDeployments,u as listDomains,A as listEnvVars,Q as markLocalSetupDone,r as modifyPlan,g as pingBackend,H as promotePreview,G as redeployProject,w as removeDomain,I as rollbackDeployment,R as shareProject,o as uploadAndDeploy,z as uploadQAResults,B as upsertEnvVar,v as verifyDomain};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e}from"./chunk-UNFTM4B3.js";export{b as closeBrowser,c as getIsolatedContext,a as getPage,d as getSnapshot,e as takeScreenshot};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as o,b as s,j as i,n as a}from"./chunk-
|
|
1
|
+
import{a as o,b as s,j as i,n as a}from"./chunk-Y3F6QWAR.js";import{existsSync as u,readFileSync as f,writeFileSync as d,mkdirSync as m}from"fs";import{join as l}from"path";function p(t){return l(t,".mistflow","state.json")}function P(t){let e=p(t);if(!u(e))return null;try{return JSON.parse(f(e,"utf-8"))}catch{return null}}function w(t,e){let r=l(t,".mistflow");u(r)||m(r,{recursive:!0}),d(p(t),JSON.stringify(e,null,2)+`
|
|
2
2
|
`)}function C(t,e){return{projectId:t,name:e,template:"",features:[],dbSchema:[],deployCount:0,decisions:[],provenance:[]}}async function x(t){let e;try{e=a()}catch{return null}try{let r=await fetch(`${i()}/api/projects/${encodeURIComponent(t)}/state`,{headers:{...e,"Content-Type":"application/json","X-Mistflow-MCP-Version":o()}});try{s(r.headers)}catch{}return r.ok?await r.json():null}catch{return null}}async function R(t,e){let r;try{r=a()}catch{return!1}try{let n=await fetch(`${i()}/api/projects/${encodeURIComponent(t)}/state`,{method:"PUT",headers:{...r,"Content-Type":"application/json","X-Mistflow-MCP-Version":o()},body:JSON.stringify(e)});try{s(n.headers)}catch{}return n.ok}catch{return!1}}function L(t,e){let r=t.toLowerCase(),n=e.toLowerCase();return n.includes(r)||r.includes(n)?!0:r.split(/\s+/).some(c=>c.length>=3&&n.includes(c))}export{p as a,P as b,w as c,C as d,x as e,R as f,L as g};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=null,a=null,t=null,i=null;async function r(){try{return await import("playwright")}catch{throw new Error("Playwright is not installed. Run: cd packages/mcp-server && pnpm add playwright && npx playwright install chromium")}}async function l(){let n=await r();return(!e||!e.isConnected())&&(e=await n.chromium.launch({headless:!0})),a&&(await a.close().catch(()=>{}),a=null),a=await e.newContext({viewport:{width:1280,height:720},deviceScaleFactor:
|
|
1
|
+
var e=null,a=null,t=null,i=null;async function r(){try{return await import("playwright")}catch{throw new Error("Playwright is not installed. Run: cd packages/mcp-server && pnpm add playwright && npx playwright install chromium")}}async function l(){let n=await r();return(!e||!e.isConnected())&&(e=await n.chromium.launch({headless:!0})),a&&(await a.close().catch(()=>{}),a=null),a=await e.newContext({viewport:{width:1280,height:720},deviceScaleFactor:1}),t=await a.newPage(),t}async function w(){return t&&!t.isClosed()?t:(i||(i=l().finally(()=>{i=null})),i)}async function s(){t&&!t.isClosed()&&await t.close().catch(()=>{}),a&&await a.close().catch(()=>{}),e?.isConnected()&&await e.close().catch(()=>{}),t=null,a=null,e=null}process.once("SIGTERM",()=>{s().finally(()=>process.exit(0))});process.once("SIGINT",()=>{s().finally(()=>process.exit(0))});async function u(){let n=await r();(!e||!e.isConnected())&&(e=await n.chromium.launch({headless:!0}));let o=await e.newContext({viewport:{width:1280,height:720},deviceScaleFactor:1}),c=await o.newPage();return{context:o,page:c}}async function p(n){return await n.locator("body").ariaSnapshot()}async function g(n,o=!1){return await n.screenshot({fullPage:o,type:"png"})}export{w as a,s as b,u as c,p as d,g as e};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{readFileSync as
|
|
2
|
-
`,{mode:384}),Y(s,t)}catch(c){try{G(s)}catch{}throw c}}function Se(){let e=d();return e.ok?e.creds:null}function re(){return d().ok}function ke(e){let t=b(e,"mistflow.json");if(!x(t))return null;try{return JSON.parse(
|
|
1
|
+
import{readFileSync as T,existsSync as x,writeFileSync as z,mkdirSync as X,renameSync as Y,unlinkSync as G}from"fs";import{join as b,dirname as Z}from"path";import{homedir as ee}from"os";import{randomBytes as te}from"crypto";function D(){return b(ee(),".mistflow","credentials.json")}function w(){return(process.env.MISTFLOW_API_URL||"https://api.mistflow.ai").replace(/\/+$/,"")}var ne="https://api.mistflow.ai";function $(){let e=D();if(!x(e))return null;try{let t=JSON.parse(T(e,"utf-8"));return typeof t.apiKey=="string"?{[ne]:t}:t}catch{return null}}function d(){let e=process.env.MISTFLOW_API_KEY;if(e)return{ok:!0,creds:{apiKey:e,orgId:"",orgSlug:"env"}};let t=$();if(!t)return{ok:!1,reason:"missing"};let n=w(),r=t[n];return r&&typeof r.apiKey=="string"&&r.apiKey&&typeof r.orgId=="string"?{ok:!0,creds:r}:{ok:!1,reason:"missing"}}function Re(e){let t=D(),n=Z(t);x(n)||X(n,{recursive:!0});let r=$()??{},o=w();r[o]=e;let s=b(n,`.credentials.tmp.${te(8).toString("hex")}`);try{z(s,JSON.stringify(r,null,2)+`
|
|
2
|
+
`,{mode:384}),Y(s,t)}catch(c){try{G(s)}catch{}throw c}}function Se(){let e=d();return e.ok?e.creds:null}function re(){return d().ok}function ke(e){let t=b(e,"mistflow.json");if(!x(t))return null;try{return JSON.parse(T(t,"utf-8"))}catch{return null}}import{existsSync as P,readFileSync as A,writeFileSync as oe,mkdirSync as se}from"fs";import{join as C,dirname as v}from"path";import{homedir as ie}from"os";import{fileURLToPath as ae}from"url";var _=null;function p(){if(_)return _;try{let e=ae(import.meta.url),t=v(e);for(let n=0;n<6;n++){let r=C(t,"package.json");if(P(r)){let s=JSON.parse(A(r,"utf-8"));if(s.name==="@mistflow-ai/mcp"&&typeof s.version=="string")return _=s.version,s.version}let o=v(t);if(o===t)break;t=o}}catch{}return _="0.0.0","0.0.0"}function R(e){let t=/^(\d+)\.(\d+)\.(\d+)/.exec(e.trim());return t?[parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10)]:null}function M(e,t){let n=R(e),r=R(t);if(!n||!r)return 0;for(let o=0;o<3;o++){if(n[o]<r[o])return-1;if(n[o]>r[o])return 1}return 0}function O(e,t,n){if(n&&M(e,n)<0)return"unsupported";if(!t||M(e,t)>=0)return"none";let o=R(e),s=R(t);return!o||!s?"none":o[0]<s[0]?"major":o[1]<s[1]?"minor":"patch"}var l=null;function F(e){let t=e.get("x-mistflow-mcp-latest")??"",n=e.get("x-mistflow-mcp-min-supported")??"",r=e.get("x-mistflow-mcp-changelog-url")??"";!t&&!n||(l={latest:t,minSupported:n,changelogUrl:r})}function V(){let e=process.env.MISTFLOW_STATE_DIR||C(ie(),".mistflow");return C(e,"upgrade-state.json")}function ce(){try{let e=V();return P(e)?JSON.parse(A(e,"utf-8")):{}}catch{return{}}}function le(e){try{let t=V(),n=v(t);P(n)||se(n,{recursive:!0}),oe(t,JSON.stringify(e,null,2)+`
|
|
3
3
|
`,{mode:384})}catch{}}var j=!1;function ue(e){return e==="patch"?7*864e5:e==="minor"?1*864e5:0}function Ue(){if(process.env.MISTFLOW_NO_UPGRADE_CHECK==="1"||!l)return null;let e=p();if(e==="0.0.0")return null;let t=O(e,l.latest,l.minSupported);if(t==="none")return null;if(t==="unsupported")return E(t,e,l);if(j)return null;let n=ce(),r=Date.now(),o=ue(t);return n.dismissedForVersion===l.latest&&t!=="major"||n.lastLatestSeen===l.latest&&n.lastShownMs&&r-n.lastShownMs<o?null:(j=!0,le({...n,lastShownMs:r,lastLatestSeen:l.latest}),E(t,e,l))}function E(e,t,n){let r="npx -y mistflow-ai install",o=n.changelogUrl?`
|
|
4
4
|
What's new: ${n.changelogUrl}`:"";return e==="unsupported"?`
|
|
5
5
|
|
|
@@ -20,4 +20,4 @@ This is a major update. Run \`${r}\` and restart your editor.${o}
|
|
|
20
20
|
--- Mistflow update available: ${t} -> ${n.latest} ---
|
|
21
21
|
Run \`${r}\` to upgrade, then restart your editor.${o}`:`
|
|
22
22
|
|
|
23
|
-
(Mistflow ${n.latest} is out, you have ${t}. Run \`${r}\` when convenient.)`}function Ie(){let e=p(),t=l??{latest:"",minSupported:"",changelogUrl:""},n=O(e,t.latest,t.minSupported);return{current:e,latest:t.latest,minSupported:t.minSupported,severity:n,upgradeCmd:"npx -y mistflow-ai install",changelogUrl:t.changelogUrl,backendSignalReceived:l!==null}}function g(){return w()}function Me(){let e=process.env.MISTFLOW_API_URL;if(e){if(e.includes("mistflow.localhost"))return e.replace("api.mistflow","mistflow");if(e.includes("localhost:9100"))return e.replace(":9100",":9102")}return"https://mistflow.ai"}function je(){let e=process.env.MISTFLOW_API_URL;if(e){if(e.includes("mistflow.localhost"))return e.replace("api.mistflow","app.mistflow");if(e.includes("localhost:9100"))return e.replace(":9100",":9101")}return"https://app.mistflow.ai"}var a=class extends Error{constructor(n,r,o,s){super(r);this.code=n;this.statusCode=o;this.details=s;this.name="MistflowApiError"}get isAuth(){return this.code.startsWith("auth_")}get isTransient(){return this.code==="server_error"||this.code==="upstream_error"||this.code==="network_error"||this.code==="rate_limited"}};function pe(){let e=d();if(!e.ok)throw new a("auth_missing","No Mistflow credentials found.",401);return de(e.creds)}function de(e){return{Authorization:`ApiKey ${e.apiKey}`,"Content-Type":"application/json","X-Mistflow-MCP-Version":p()}}function f(e){try{F(e.headers)}catch{}}async function Ee(){try{let e=await fetch(`${g()}/health`,{method:"GET",signal:AbortSignal.timeout(5e3)});f(e)}catch{}}async function L(e,t,n){for(let r=0;r<2;r++)try{return await fetch(e,{...t,signal:AbortSignal.timeout(n)})}catch(o){let s=o instanceof Error&&o.name==="TimeoutError",c=o instanceof TypeError;if(r===0&&(s||c)){console.error(`[api] Retrying ${e} after ${s?"timeout":"network error"}`);continue}throw o}throw new Error("fetchWithRetry: exhausted retries")}async function h(e){let t=null;try{t=await e.json()}catch{t=null}let n=t&&typeof t.code=="string"?t.code:void 0,r=t&&typeof t.message=="string"?t.message:t&&typeof t.detail=="string"?t.detail:e.statusText||"Request failed";if(n)return new a(n,r,e.status,t?.details);let o=e.status;return o===401?new a("auth_invalid",r,o):o===403?new a("permission_denied",r,o):o===404?new a("not_found",r,o):o===409?new a("conflict",r,o):o===422?new a("validation_error",r,o):o===429?new a("rate_limited",r,o):o>=500?new a("server_error",e.statusText||"Internal server error",o):new a("client_error",r,o)}async function i(e,t={}){let n=pe(),{timeoutMs:r,...o}=t,s=r??3e4,c;try{c=await L(`${g()}${e}`,{...o,headers:{...n,...o.headers}},s)}catch(m){throw m instanceof Error&&m.name==="TimeoutError"?new a("network_error","Request timed out. Try again in a moment."):new a("network_error","Cannot reach Mistflow servers. Check your network.")}if(f(c),!c.ok)throw await h(c);return c.json()}function ge(){return d().ok}var S=null,N=0,fe=300*1e3;async function Ae(){return(await me()).ok}async function me(){if(S!==null&&Date.now()<N)return S?{ok:!0}:{ok:!1,reason:"no_credentials"};if(!ge())return{ok:!1,reason:"no_credentials"};try{return await i("/api/org"),S=!0,N=Date.now()+fe,{ok:!0}}catch(e){if(S=null,!(e instanceof a))return{ok:!1,reason:"network_error"};switch(e.code){case"auth_missing":case"auth_revoked":return{ok:!1,reason:"no_credentials"};case"auth_expired":case"auth_invalid":case"auth_org_not_found":return{ok:!1,reason:"expired"};case"network_error":return{ok:!1,reason:"network_error"};case"rate_limited":case"server_error":case"upstream_error":return{ok:!1,reason:"server_error"};default:return{ok:!1,reason:"server_error"}}}}async function Oe(e){return i(`/api/projects/${encodeURIComponent(e)}`)}async function Fe(e){return i(`/api/projects/check-subdomain?name=${encodeURIComponent(e)}`)}async function Ve(e,t,n="neon",r){return i("/api/projects",{method:"POST",body:JSON.stringify({name:e,template:t,db_provider:n,requested_subdomain:r})})}async function Ne(e,t){return i("/api/deploy",{method:"POST",body:JSON.stringify({project_id:e,build_output_url:t})})}async function Le(e,t,n="production",r,o,s,c){let{readFileSync:m}=await import("fs"),{basename:B}=await import("path"),U=d();if(!U.ok)throw new a("auth_missing","No Mistflow credentials found.",401);let q=U.creds,K=m(t),J=new Blob([K],{type:"application/gzip"}),u=new FormData;if(u.append("project_id",e),u.append("build",J,B(t)),n!=="production"&&u.append("environment",n),r&&u.append("admin_email",r),o&&u.append("schema_pushed","true"),s){let{existsSync:W}=await import("fs");if(W(s)){let Q=m(s),H=new Blob([Q],{type:"application/gzip"});u.append("source",H,"source.tar.gz")}}c&&u.append("git_commit_sha",c);let y;try{y=await fetch(`${g()}/api/deploy/upload`,{method:"POST",headers:{Authorization:`ApiKey ${q.apiKey}`,"X-Mistflow-MCP-Version":p()},body:u,signal:AbortSignal.timeout(3e5)})}catch{throw new a("network_error","Cannot reach Mistflow servers. Check your network.")}if(f(y),!y.ok)throw await h(y);let I=await y.json();return{...I,id:I.deployment_id}}async function Be(e){return i(`/api/deploy/${encodeURIComponent(e)}/status`)}async function qe(e,t){let n={description:e,conversation_id:t?.conversationId,answers:t?.answers};t?.autonomous&&(n.autonomous=!0),t?.language&&t.language.toLowerCase()!=="english"&&(n.language=t.language);let r=t?.conversationId||t?.answers?12e4:6e4;return i("/api/plan",{method:"POST",body:JSON.stringify(n),timeoutMs:r})}async function Ke(e,t){return i("/api/plan/modify",{method:"POST",body:JSON.stringify({existing_plan:e,modification:t})})}async function Je(e){return i("/api/plan/discover",{method:"POST",body:JSON.stringify({description:e})})}async function We(e,t){return i(`/api/projects/${encodeURIComponent(e)}/domains`,{method:"POST",body:JSON.stringify({domain:t})})}async function Qe(e){return i(`/api/projects/${encodeURIComponent(e)}/domains`)}async function He(e,t){return i(`/api/projects/${encodeURIComponent(e)}/domains/${encodeURIComponent(t)}/verify`)}async function ze(e,t){return i(`/api/projects/${encodeURIComponent(e)}/domains/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Xe(e){return i(`/api/projects/${encodeURIComponent(e)}/db-credentials`)}async function Ye(e){try{return await i(`/api/projects/${encodeURIComponent(e)}/test-accounts`)}catch(t){return t instanceof a&&(t.statusCode===404||t.code==="not_found")||console.error("[api] Failed to fetch seed info:",t instanceof Error?t.message:t),null}}async function Ge(e,t){try{return await i(`/api/deploy/${encodeURIComponent(e)}/qa-results`,{method:"POST",body:JSON.stringify(t)})}catch(n){return console.error("[api] Failed to upload QA results:",n instanceof Error?n.message:n),null}}async function Ze(e){return i(`/api/projects/${encodeURIComponent(e)}/env`)}async function et(e,t,n,r){return i(`/api/projects/${encodeURIComponent(e)}/env`,{method:"PUT",body:JSON.stringify({key:t,value:n,category:r?.category??"custom",description:r?.description,setup_url:r?.setupUrl})})}async function tt(e,t){return i(`/api/projects/${encodeURIComponent(e)}/env/${encodeURIComponent(t)}`,{method:"DELETE"})}async function nt(e){return i(`/api/deploy/${encodeURIComponent(e)}/logs`)}async function rt(e,t="7d"){return i(`/api/projects/${encodeURIComponent(e)}/errors?period=${encodeURIComponent(t)}`)}async function ot(e){return i(`/api/projects/${encodeURIComponent(e)}/deployments`)}async function st(e){return i(`/api/deploy/${encodeURIComponent(e)}/redeploy`,{method:"POST"})}async function it(e,t){let n=new URLSearchParams({preview_deployment_id:t});return i(`/api/deploy/${encodeURIComponent(e)}/promote`,{method:"POST",body:n.toString(),headers:{"Content-Type":"application/x-www-form-urlencoded"}})}async function at(e){return i(`/api/deploy/${encodeURIComponent(e)}/rollback`,{method:"POST"})}async function ct(e,t){let n=d();if(!n.ok)throw new a("auth_missing","Not authenticated.",401);let r=n.creds,o=await fetch(`${g()}/api/deploy/${encodeURIComponent(e)}/source`,{headers:{Authorization:`ApiKey ${r.apiKey}`,"X-Mistflow-MCP-Version":p()},signal:AbortSignal.timeout(12e4)});if(f(o),!o.ok)throw await h(o);let{writeFileSync:s}=await import("fs"),c=Buffer.from(await o.arrayBuffer());s(t,c)}async function k(e,t){let{timeoutMs:n,...r}=t??{},o=n??3e4,s;try{s=await L(`${g()}${e}`,{headers:{"Content-Type":"application/json","X-Mistflow-MCP-Version":p()},...r},o)}catch(c){throw c instanceof Error&&c.name==="TimeoutError"?new a("network_error","Request timed out. Try again in a moment."):new a("network_error","Cannot reach Mistflow servers. Check your network.")}if(f(s),!s.ok)throw await h(s);return s.json()}async function lt(e="nextjs"){return k(`/api/scaffold/${encodeURIComponent(e)}`)}async function ut(e,t){return k(`/api/scaffold/${encodeURIComponent(e)}/context?step_type=${encodeURIComponent(t)}`)}async function pt(e,t,n,r){return k(`/api/scaffold/${encodeURIComponent(e)}/module`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"crud",entity:t,fields:n,entity_plural:r})})}async function dt(e){return k(`/api/templates/${encodeURIComponent(e)}`)}async function gt(e){return i(`/api/templates/${encodeURIComponent(e)}/fork`,{method:"POST"})}async function ft(e,t,n){let r;try{r=await fetch(`${g()}/api/deploy/${encodeURIComponent(e)}/fork-source?fork_token=${encodeURIComponent(t)}`,{headers:{"X-Mistflow-MCP-Version":p()},signal:AbortSignal.timeout(12e4)})}catch{throw new a("network_error","Cannot reach Mistflow servers. Check your network.")}if(f(r),!r.ok)throw r.status===401?new a("validation_error","Fork token expired or invalid. Re-open the project in the dashboard to get a fresh token.",r.status):await h(r);let{writeFileSync:o}=await import("fs"),s=Buffer.from(await r.arrayBuffer());o(n,s)}async function mt(e){await i(`/api/projects/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({local_setup_done:!0})})}async function yt(e,t){return i(`/api/projects/${encodeURIComponent(e)}/share`,{method:"POST",body:JSON.stringify({is_template:t?.isTemplate??!1,template_description:t?.description})})}export{p as a,F as b,Ue as c,Ie as d,d as e,Re as f,Se as g,re as h,ke as i,g as j,Me as k,je as l,a as m,pe as n,Ee as o,ge as p,Ae as q,me as r,Oe as s,Fe as t,Ve as u,Ne as v,Le as w,Be as x,qe as y,Ke as z,Je as A,We as B,Qe as C,He as D,ze as E,Xe as F,Ye as G,Ge as H,Ze as I,et as J,tt as K,nt as L,rt as M,ot as N,st as O,it as P,at as Q,ct as R,lt as S,ut as T,pt as U,dt as V,gt as W,ft as X,mt as Y,yt as Z};
|
|
23
|
+
(Mistflow ${n.latest} is out, you have ${t}. Run \`${r}\` when convenient.)`}function Ie(){let e=p(),t=l??{latest:"",minSupported:"",changelogUrl:""},n=O(e,t.latest,t.minSupported);return{current:e,latest:t.latest,minSupported:t.minSupported,severity:n,upgradeCmd:"npx -y mistflow-ai install",changelogUrl:t.changelogUrl,backendSignalReceived:l!==null}}function g(){return w()}function Me(){let e=process.env.MISTFLOW_API_URL;if(e){if(e.includes("mistflow.localhost"))return e.replace("api.mistflow","mistflow");if(e.includes("localhost:9100"))return e.replace(":9100",":9102")}return"https://mistflow.ai"}function je(){let e=process.env.MISTFLOW_API_URL;if(e){if(e.includes("mistflow.localhost"))return e.replace("api.mistflow","app.mistflow");if(e.includes("localhost:9100"))return e.replace(":9100",":9101")}return"https://app.mistflow.ai"}var a=class extends Error{constructor(n,r,o,s){super(r);this.code=n;this.statusCode=o;this.details=s;this.name="MistflowApiError"}get isAuth(){return this.code.startsWith("auth_")}get isTransient(){return this.code==="server_error"||this.code==="upstream_error"||this.code==="network_error"||this.code==="rate_limited"}};function pe(){let e=d();if(!e.ok)throw new a("auth_missing","No Mistflow credentials found.",401);return de(e.creds)}function de(e){return{Authorization:`ApiKey ${e.apiKey}`,"Content-Type":"application/json","X-Mistflow-MCP-Version":p()}}function f(e){try{F(e.headers)}catch{}}async function Ee(){try{let e=await fetch(`${g()}/health`,{method:"GET",signal:AbortSignal.timeout(5e3)});f(e)}catch{}}async function N(e,t,n){for(let r=0;r<2;r++)try{return await fetch(e,{...t,signal:AbortSignal.timeout(n)})}catch(o){let s=o instanceof Error&&o.name==="TimeoutError",c=o instanceof TypeError;if(r===0&&(s||c)){console.error(`[api] Retrying ${e} after ${s?"timeout":"network error"}`);continue}throw o}throw new Error("fetchWithRetry: exhausted retries")}async function h(e){let t=null;try{t=await e.json()}catch{t=null}let n=t&&typeof t.code=="string"?t.code:void 0,r=t&&typeof t.message=="string"?t.message:t&&typeof t.detail=="string"?t.detail:e.statusText||"Request failed";if(n)return new a(n,r,e.status,t?.details);let o=e.status;return o===401?new a("auth_invalid",r,o):o===403?new a("permission_denied",r,o):o===404?new a("not_found",r,o):o===409?new a("conflict",r,o):o===422?new a("validation_error",r,o):o===429?new a("rate_limited",r,o):o>=500?new a("server_error",e.statusText||"Internal server error",o):new a("client_error",r,o)}async function i(e,t={}){let n=pe(),{timeoutMs:r,...o}=t,s=r??3e4,c;try{c=await N(`${g()}${e}`,{...o,headers:{...n,...o.headers}},s)}catch(m){throw m instanceof Error&&m.name==="TimeoutError"?new a("network_error","Request timed out. Try again in a moment."):new a("network_error","Cannot reach Mistflow servers. Check your network.")}if(f(c),!c.ok)throw await h(c);return c.json()}function ge(){return d().ok}var S=null,L=0,fe=300*1e3;async function Ae(){return(await me()).ok}async function me(){if(S!==null&&Date.now()<L)return S?{ok:!0}:{ok:!1,reason:"no_credentials"};if(!ge())return{ok:!1,reason:"no_credentials"};try{return await i("/api/org"),S=!0,L=Date.now()+fe,{ok:!0}}catch(e){if(S=null,!(e instanceof a))return{ok:!1,reason:"network_error"};switch(e.code){case"auth_missing":case"auth_revoked":return{ok:!1,reason:"no_credentials"};case"auth_expired":case"auth_invalid":case"auth_org_not_found":return{ok:!1,reason:"expired"};case"network_error":return{ok:!1,reason:"network_error"};case"rate_limited":case"server_error":case"upstream_error":return{ok:!1,reason:"server_error"};default:return{ok:!1,reason:"server_error"}}}}async function Oe(e){return i(`/api/projects/${encodeURIComponent(e)}`)}async function Fe(e){return i(`/api/projects/check-subdomain?name=${encodeURIComponent(e)}`)}async function Ve(e,t,n="neon",r){return i("/api/projects",{method:"POST",body:JSON.stringify({name:e,template:t,db_provider:n,requested_subdomain:r})})}async function Le(e,t){return i("/api/deploy",{method:"POST",body:JSON.stringify({project_id:e,build_output_url:t})})}async function Ne(e,t,n="production",r,o,s,c){let{readFileSync:m}=await import("fs"),{basename:B}=await import("path"),U=d();if(!U.ok)throw new a("auth_missing","No Mistflow credentials found.",401);let q=U.creds,K=m(t),J=new Blob([K],{type:"application/gzip"}),u=new FormData;if(u.append("project_id",e),u.append("build",J,B(t)),n!=="production"&&u.append("environment",n),r&&u.append("admin_email",r),o&&u.append("schema_pushed","true"),s){let{existsSync:W}=await import("fs");if(W(s)){let H=m(s),Q=new Blob([H],{type:"application/gzip"});u.append("source",Q,"source.tar.gz")}}c&&u.append("git_commit_sha",c);let y;try{y=await fetch(`${g()}/api/deploy/upload`,{method:"POST",headers:{Authorization:`ApiKey ${q.apiKey}`,"X-Mistflow-MCP-Version":p()},body:u,signal:AbortSignal.timeout(3e5)})}catch{throw new a("network_error","Cannot reach Mistflow servers. Check your network.")}if(f(y),!y.ok)throw await h(y);let I=await y.json();return{...I,id:I.deployment_id}}async function Be(e){return i(`/api/deploy/${encodeURIComponent(e)}/status`)}async function qe(e,t){let n={description:e,conversation_id:t?.conversationId,answers:t?.answers};t?.autonomous&&(n.autonomous=!0),t?.language&&t.language.toLowerCase()!=="english"&&(n.language=t.language),t?.designConversationId&&(n.design_conversation_id=t.designConversationId),t?.designDirection&&(n.design_direction=t.designDirection);let r=t?.conversationId||t?.answers||t?.designConversationId?12e4:6e4;return i("/api/plan",{method:"POST",body:JSON.stringify(n),timeoutMs:r})}async function Ke(e,t){return i("/api/plan/modify",{method:"POST",body:JSON.stringify({existing_plan:e,modification:t})})}async function Je(e){return i("/api/plan/discover",{method:"POST",body:JSON.stringify({description:e})})}async function We(e,t){return i(`/api/projects/${encodeURIComponent(e)}/domains`,{method:"POST",body:JSON.stringify({domain:t})})}async function He(e){return i(`/api/projects/${encodeURIComponent(e)}/domains`)}async function Qe(e,t){return i(`/api/projects/${encodeURIComponent(e)}/domains/${encodeURIComponent(t)}/verify`)}async function ze(e,t){return i(`/api/projects/${encodeURIComponent(e)}/domains/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Xe(e){return i(`/api/projects/${encodeURIComponent(e)}/db-credentials`)}async function Ye(e){try{return await i(`/api/projects/${encodeURIComponent(e)}/test-accounts`)}catch(t){return t instanceof a&&(t.statusCode===404||t.code==="not_found")||console.error("[api] Failed to fetch seed info:",t instanceof Error?t.message:t),null}}async function Ge(e,t){try{return await i(`/api/deploy/${encodeURIComponent(e)}/qa-results`,{method:"POST",body:JSON.stringify(t)})}catch(n){return console.error("[api] Failed to upload QA results:",n instanceof Error?n.message:n),null}}async function Ze(e){return i(`/api/projects/${encodeURIComponent(e)}/env`)}async function et(e,t,n,r){return i(`/api/projects/${encodeURIComponent(e)}/env`,{method:"PUT",body:JSON.stringify({key:t,value:n,category:r?.category??"custom",description:r?.description,setup_url:r?.setupUrl})})}async function tt(e,t){return i(`/api/projects/${encodeURIComponent(e)}/env/${encodeURIComponent(t)}`,{method:"DELETE"})}async function nt(e){return i(`/api/deploy/${encodeURIComponent(e)}/logs`)}async function rt(e,t="7d"){return i(`/api/projects/${encodeURIComponent(e)}/errors?period=${encodeURIComponent(t)}`)}async function ot(e){return i(`/api/projects/${encodeURIComponent(e)}/deployments`)}async function st(e){return i(`/api/deploy/${encodeURIComponent(e)}/redeploy`,{method:"POST"})}async function it(e,t){let n=new URLSearchParams({preview_deployment_id:t});return i(`/api/deploy/${encodeURIComponent(e)}/promote`,{method:"POST",body:n.toString(),headers:{"Content-Type":"application/x-www-form-urlencoded"}})}async function at(e){return i(`/api/deploy/${encodeURIComponent(e)}/rollback`,{method:"POST"})}async function ct(e,t){let n=d();if(!n.ok)throw new a("auth_missing","Not authenticated.",401);let r=n.creds,o=await fetch(`${g()}/api/deploy/${encodeURIComponent(e)}/source`,{headers:{Authorization:`ApiKey ${r.apiKey}`,"X-Mistflow-MCP-Version":p()},signal:AbortSignal.timeout(12e4)});if(f(o),!o.ok)throw await h(o);let{writeFileSync:s}=await import("fs"),c=Buffer.from(await o.arrayBuffer());s(t,c)}async function k(e,t){let{timeoutMs:n,...r}=t??{},o=n??3e4,s;try{s=await N(`${g()}${e}`,{headers:{"Content-Type":"application/json","X-Mistflow-MCP-Version":p()},...r},o)}catch(c){throw c instanceof Error&&c.name==="TimeoutError"?new a("network_error","Request timed out. Try again in a moment."):new a("network_error","Cannot reach Mistflow servers. Check your network.")}if(f(s),!s.ok)throw await h(s);return s.json()}async function lt(e="nextjs"){return k(`/api/scaffold/${encodeURIComponent(e)}`)}async function ut(e,t){return k(`/api/scaffold/${encodeURIComponent(e)}/context?step_type=${encodeURIComponent(t)}`)}async function pt(e,t,n,r){return k(`/api/scaffold/${encodeURIComponent(e)}/module`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"crud",entity:t,fields:n,entity_plural:r})})}async function dt(e){return k(`/api/templates/${encodeURIComponent(e)}`)}async function gt(e){return i(`/api/templates/${encodeURIComponent(e)}/fork`,{method:"POST"})}async function ft(e,t,n){let r;try{r=await fetch(`${g()}/api/deploy/${encodeURIComponent(e)}/fork-source?fork_token=${encodeURIComponent(t)}`,{headers:{"X-Mistflow-MCP-Version":p()},signal:AbortSignal.timeout(12e4)})}catch{throw new a("network_error","Cannot reach Mistflow servers. Check your network.")}if(f(r),!r.ok)throw r.status===401?new a("validation_error","Fork token expired or invalid. Re-open the project in the dashboard to get a fresh token.",r.status):await h(r);let{writeFileSync:o}=await import("fs"),s=Buffer.from(await r.arrayBuffer());o(n,s)}async function mt(e){await i(`/api/projects/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({local_setup_done:!0})})}async function yt(e,t){return i(`/api/projects/${encodeURIComponent(e)}/share`,{method:"POST",body:JSON.stringify({is_template:t?.isTemplate??!1,template_description:t?.description})})}export{p as a,F as b,Ue as c,Ie as d,d as e,Re as f,Se as g,re as h,ke as i,g as j,Me as k,je as l,a as m,pe as n,Ee as o,ge as p,Ae as q,me as r,Oe as s,Fe as t,Ve as u,Le as v,Ne as w,Be as x,qe as y,Ke as z,Je as A,We as B,He as C,Qe as D,ze as E,Xe as F,Ye as G,Ge as H,Ze as I,et as J,tt as K,nt as L,rt as M,ot as N,st as O,it as P,at as Q,ct as R,lt as S,ut as T,pt as U,dt as V,gt as W,ft as X,mt as Y,yt as Z};
|