@mistflow-ai/mcp 0.1.4-staging.1 → 0.1.4

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.
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g}from"./chunk-6ISXH6NJ.js";import"./chunk-FKB6Y7BA.js";export{d as emptyState,e as fetchRemoteState,g as fuzzyMatch,a as getLocalStatePath,b as readLocalState,f as syncRemoteState,c as writeLocalState};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistflow-ai/mcp",
3
- "version": "0.1.4-staging.1",
3
+ "version": "0.1.4",
4
4
  "description": "Mistflow MCP server for AI coding editors. Installed into Claude Code, Cursor, Codex CLI, and VS Code Copilot by the mistflow-ai installer.",
5
5
  "license": "Elastic-2.0",
6
6
  "type": "module",
@@ -1,23 +0,0 @@
1
- import{readFileSync as I,existsSync as S,writeFileSync as Q,mkdirSync as H,renameSync as z,unlinkSync as X}from"fs";import{join as x,dirname as Y}from"path";import{homedir as G}from"os";import{randomBytes as Z}from"crypto";function T(){return x(G(),".mistflow","credentials.json")}function d(){let e=process.env.MISTFLOW_API_KEY;if(e)return{ok:!0,creds:{apiKey:e,orgId:"",orgSlug:"env"}};let t=T();if(!S(t))return{ok:!1,reason:"missing"};try{let n=JSON.parse(I(t,"utf-8"));return typeof n.apiKey=="string"&&n.apiKey&&typeof n.orgId=="string"?{ok:!0,creds:n}:{ok:!1,reason:"invalid"}}catch{return{ok:!1,reason:"invalid"}}}function he(e){let t=T(),n=Y(t);S(n)||H(n,{recursive:!0});let r=x(n,`.credentials.tmp.${Z(8).toString("hex")}`);try{Q(r,JSON.stringify(e,null,2)+`
2
- `,{mode:384}),z(r,t)}catch(o){try{X(r)}catch{}throw o}}function we(){let e=d();return e.ok?e.creds:null}function ee(){return d().ok}function _e(e){let t=x(e,"mistflow.json");if(!S(t))return null;try{return JSON.parse(I(t,"utf-8"))}catch{return null}}import{existsSync as v,readFileSync as M,writeFileSync as te,mkdirSync as ne}from"fs";import{join as b,dirname as C}from"path";import{homedir as re}from"os";import{fileURLToPath as oe}from"url";var w=null;function p(){if(w)return w;try{let e=oe(import.meta.url),t=C(e);for(let n=0;n<6;n++){let r=b(t,"package.json");if(v(r)){let s=JSON.parse(M(r,"utf-8"));if(s.name==="@mistflow-ai/mcp"&&typeof s.version=="string")return w=s.version,s.version}let o=C(t);if(o===t)break;t=o}}catch{}return w="0.0.0","0.0.0"}function _(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 $(e,t){let n=_(e),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 A(e,t,n){if(n&&$(e,n)<0)return"unsupported";if(!t||$(e,t)>=0)return"none";let o=_(e),s=_(t);return!o||!s?"none":o[0]<s[0]?"major":o[1]<s[1]?"minor":"patch"}var l=null;function E(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 O(){let e=process.env.MISTFLOW_STATE_DIR||b(re(),".mistflow");return b(e,"upgrade-state.json")}function se(){try{let e=O();return v(e)?JSON.parse(M(e,"utf-8")):{}}catch{return{}}}function ie(e){try{let t=O(),n=C(t);v(n)||ne(n,{recursive:!0}),te(t,JSON.stringify(e,null,2)+`
3
- `,{mode:384})}catch{}}var D=!1;function ae(e){return e==="patch"?7*864e5:e==="minor"?1*864e5:0}function Ce(){if(process.env.MISTFLOW_NO_UPGRADE_CHECK==="1"||!l)return null;let e=p();if(e==="0.0.0")return null;let t=A(e,l.latest,l.minSupported);if(t==="none")return null;if(t==="unsupported")return j(t,e,l);if(D)return null;let n=se(),r=Date.now(),o=ae(t);return n.dismissedForVersion===l.latest&&t!=="major"||n.lastLatestSeen===l.latest&&n.lastShownMs&&r-n.lastShownMs<o?null:(D=!0,ie({...n,lastShownMs:r,lastLatestSeen:l.latest}),j(t,e,l))}function j(e,t,n){let r="npx -y mistflow-ai install",o=n.changelogUrl?`
4
- What's new: ${n.changelogUrl}`:"";return e==="unsupported"?`
5
-
6
- ---
7
- Mistflow ${t} is no longer supported.
8
- You must upgrade to ${n.latest} or newer to continue:
9
-
10
- ${r}
11
-
12
- After upgrading, restart your AI editor.${o}
13
- ---`:e==="major"?`
14
-
15
- ---
16
- Mistflow ${n.latest} is available (you have ${t}).
17
- This is a major update. Run \`${r}\` and restart your editor.${o}
18
- ---`:e==="minor"?`
19
-
20
- --- Mistflow update available: ${t} -> ${n.latest} ---
21
- Run \`${r}\` to upgrade, then restart your editor.${o}`:`
22
-
23
- (Mistflow ${n.latest} is out, you have ${t}. Run \`${r}\` when convenient.)`}function ve(){let e=p(),t=l??{latest:"",minSupported:"",changelogUrl:""},n=A(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 m(){return process.env.MISTFLOW_API_URL||"https://api.mistflow.ai"}function Te(){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 $e(){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 ce(){let e=d();if(!e.ok)throw new a("auth_missing","No Mistflow credentials found.",401);return le(e.creds)}function le(e){return{Authorization:`ApiKey ${e.apiKey}`,"Content-Type":"application/json","X-Mistflow-MCP-Version":p()}}function y(e){try{E(e.headers)}catch{}}async function V(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=ce(),{timeoutMs:r,...o}=t,s=r??3e4,c;try{c=await V(`${m()}${e}`,{...o,headers:{...n,...o.headers}},s)}catch(g){throw g instanceof Error&&g.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(y(c),!c.ok)throw await h(c);return c.json()}function ue(){return d().ok}var R=null,F=0,pe=300*1e3;async function De(){return(await de()).ok}async function de(){if(R!==null&&Date.now()<F)return R?{ok:!0}:{ok:!1,reason:"no_credentials"};if(!ue())return{ok:!1,reason:"no_credentials"};try{return await i("/api/org"),R=!0,F=Date.now()+pe,{ok:!0}}catch(e){if(R=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 je(e){return i(`/api/projects/${encodeURIComponent(e)}`)}async function Me(e){return i(`/api/projects/check-subdomain?name=${encodeURIComponent(e)}`)}async function Ae(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 Ee(e,t){return i("/api/deploy",{method:"POST",body:JSON.stringify({project_id:e,build_output_url:t})})}async function Oe(e,t,n="production",r,o,s,c){let{readFileSync:g}=await import("fs"),{basename:N}=await import("path"),P=d();if(!P.ok)throw new a("auth_missing","No Mistflow credentials found.",401);let L=P.creds,q=g(t),J=new Blob([q],{type:"application/gzip"}),u=new FormData;if(u.append("project_id",e),u.append("build",J,N(t)),n!=="production"&&u.append("environment",n),r&&u.append("admin_email",r),o&&u.append("schema_pushed","true"),s){let{existsSync:K}=await import("fs");if(K(s)){let B=g(s),W=new Blob([B],{type:"application/gzip"});u.append("source",W,"source.tar.gz")}}c&&u.append("git_commit_sha",c);let f;try{f=await fetch(`${m()}/api/deploy/upload`,{method:"POST",headers:{Authorization:`ApiKey ${L.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(y(f),!f.ok)throw await h(f);let U=await f.json();return{...U,id:U.deployment_id}}async function Fe(e){return i(`/api/deploy/${encodeURIComponent(e)}/status`)}async function Ve(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 Ne(e,t){return i("/api/plan/modify",{method:"POST",body:JSON.stringify({existing_plan:e,modification:t})})}async function Le(e){return i("/api/plan/discover",{method:"POST",body:JSON.stringify({description:e})})}async function qe(e,t){return i(`/api/projects/${encodeURIComponent(e)}/domains`,{method:"POST",body:JSON.stringify({domain:t})})}async function Je(e){return i(`/api/projects/${encodeURIComponent(e)}/domains`)}async function Ke(e,t){return i(`/api/projects/${encodeURIComponent(e)}/domains/${encodeURIComponent(t)}/verify`)}async function Be(e,t){return i(`/api/projects/${encodeURIComponent(e)}/domains/${encodeURIComponent(t)}`,{method:"DELETE"})}async function We(e){return i(`/api/projects/${encodeURIComponent(e)}/db-credentials`)}async function Qe(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 test accounts:",t instanceof Error?t.message:t),null}}async function He(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 Xe(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 Ye(e,t){return i(`/api/projects/${encodeURIComponent(e)}/env/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Ge(e){return i(`/api/deploy/${encodeURIComponent(e)}/logs`)}async function Ze(e,t="7d"){return i(`/api/projects/${encodeURIComponent(e)}/errors?period=${encodeURIComponent(t)}`)}async function et(e){return i(`/api/projects/${encodeURIComponent(e)}/deployments`)}async function tt(e){return i(`/api/deploy/${encodeURIComponent(e)}/redeploy`,{method:"POST"})}async function nt(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 rt(e){return i(`/api/deploy/${encodeURIComponent(e)}/rollback`,{method:"POST"})}async function ot(e,t){let n=d();if(!n.ok)throw new a("auth_missing","Not authenticated.",401);let r=n.creds,o=await fetch(`${m()}/api/deploy/${encodeURIComponent(e)}/source`,{headers:{Authorization:`ApiKey ${r.apiKey}`,"X-Mistflow-MCP-Version":p()},signal:AbortSignal.timeout(12e4)});if(y(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 V(`${m()}${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(y(s),!s.ok)throw await h(s);return s.json()}async function st(e="nextjs"){return k(`/api/scaffold/${encodeURIComponent(e)}`)}async function it(e,t){return k(`/api/scaffold/${encodeURIComponent(e)}/context?step_type=${encodeURIComponent(t)}`)}async function at(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 ct(e){return k(`/api/templates/${encodeURIComponent(e)}`)}async function lt(e){return i(`/api/templates/${encodeURIComponent(e)}/fork`,{method:"POST"})}async function ut(e,t,n){let r;try{r=await fetch(`${m()}/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(y(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 pt(e){await i(`/api/projects/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({local_setup_done:!0})})}async function dt(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,E as b,Ce as c,ve as d,d as e,he as f,we as g,ee as h,_e as i,m as j,Te as k,$e as l,a as m,ce as n,ue as o,De as p,de as q,je as r,Me as s,Ae as t,Ee as u,Oe as v,Fe as w,Ve as x,Ne as y,Le as z,qe as A,Je as B,Ke as C,Be as D,We as E,Qe as F,He as G,ze as H,Xe as I,Ye as J,Ge as K,Ze as L,et as M,tt as N,nt as O,rt as P,ot as Q,st as R,it as S,at as T,ct as U,lt as V,ut as W,pt as X,dt as Y};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e,f,g}from"./chunk-ZRRSZS7A.js";import"./chunk-5IQGENNI.js";export{d as emptyState,e as fetchRemoteState,g as fuzzyMatch,a as getLocalStatePath,b as readLocalState,f as syncRemoteState,c as writeLocalState};