@mistflow-ai/mcp 0.1.4-staging.1 → 0.1.5
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/README.md +1 -1
- package/dist/{api-client-WMD2JG5B.js → api-client-UL3OJVLP.js} +1 -1
- package/dist/{chunk-ZRRSZS7A.js → chunk-6ISXH6NJ.js} +1 -1
- package/dist/chunk-FKB6Y7BA.js +23 -0
- package/dist/index.js +2107 -590
- package/dist/state-manager-XY6GQEFE.js +1 -0
- package/package.json +1 -1
- package/dist/chunk-5IQGENNI.js +0 -23
- package/dist/state-manager-73ZUDKOP.js +0 -1
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ The server never calls an LLM itself. It's a tool orchestrator, not a brain.
|
|
|
17
17
|
| `mist_setup` | Device-code auth flow — log in via browser, credentials stored in `~/.mistflow/credentials.json` |
|
|
18
18
|
| `mist_plan` | Contract-first discovery → plan generation for new apps (or new features needing data models) |
|
|
19
19
|
| `mist_build` | Scaffold projects, implement plan steps, run local builds, QA the live app, generate wireframes |
|
|
20
|
-
| `mist_deploy` | Deploy to
|
|
20
|
+
| `mist_deploy` | Deploy to cloud, preview via tunnel, redeploy/rollback, verify live site |
|
|
21
21
|
| `mist_project` | Read/update project state, browse presets, fetch runtime errors and deploy logs |
|
|
22
22
|
| `mist_config` | Manage env vars and custom domains |
|
|
23
23
|
| `mist_browser` | Browser automation for testing the live app |
|
|
@@ -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,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,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-FKB6Y7BA.js";export{e as MistflowApiError,s as addDomain,h as checkAuth,i as checkAuthDetailed,k as checkSubdomain,m as createDeployment,l as createProject,B as deleteEnvVar,r as discoverDecisions,I as downloadSource,O as downloadSourceWithToken,L as fetchModule,J as fetchScaffold,K as fetchStepContext,N as forkTemplate,p as generatePlan,f as getAuthHeaders,b as getBaseUrl,d as getDashboardUrl,w as getDbCredentials,C as getDeployLogs,o as getDeploymentStatus,j as getProject,D as getProjectErrors,x as getSeedInfo,c as getSiteUrl,M as getTemplate,a as hasCredentialsOnDisk,g as hasLocalCredentials,E as listDeployments,t as listDomains,z as listEnvVars,P as markLocalSetupDone,q as modifyPlan,G as promotePreview,F as redeployProject,v as removeDomain,H as rollbackDeployment,Q as shareProject,n as uploadAndDeploy,y as uploadQAResults,A as upsertEnvVar,u as verifyDomain};
|
|
@@ -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-FKB6Y7BA.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};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import{readFileSync as $,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 T(){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 D(){let e=T();if(!x(e))return null;try{let t=JSON.parse($(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=D();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=T(),n=Z(t);x(n)||X(n,{recursive:!0});let r=D()??{},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,"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
|
+
`,{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
|
+
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 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 m(){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 y(e){try{F(e.headers)}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(`${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 ge(){return d().ok}var S=null,N=0,fe=300*1e3;async function Ee(){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 Ae(e){return i(`/api/projects/${encodeURIComponent(e)}`)}async function Oe(e){return i(`/api/projects/check-subdomain?name=${encodeURIComponent(e)}`)}async function Fe(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 Ve(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:g}=await import("fs"),{basename:q}=await import("path"),U=d();if(!U.ok)throw new a("auth_missing","No Mistflow credentials found.",401);let B=U.creds,K=g(t),J=new Blob([K],{type:"application/gzip"}),u=new FormData;if(u.append("project_id",e),u.append("build",J,q(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=g(s),H=new Blob([Q],{type:"application/gzip"});u.append("source",H,"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 ${B.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 I=await f.json();return{...I,id:I.deployment_id}}async function Le(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 Be(e,t){return i("/api/plan/modify",{method:"POST",body:JSON.stringify({existing_plan:e,modification:t})})}async function Ke(e){return i("/api/plan/discover",{method:"POST",body:JSON.stringify({description:e})})}async function Je(e,t){return i(`/api/projects/${encodeURIComponent(e)}/domains`,{method:"POST",body:JSON.stringify({domain:t})})}async function We(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 He(e,t){return i(`/api/projects/${encodeURIComponent(e)}/domains/${encodeURIComponent(t)}`,{method:"DELETE"})}async function ze(e){return i(`/api/projects/${encodeURIComponent(e)}/db-credentials`)}async function Xe(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 Ye(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 Ge(e){return i(`/api/projects/${encodeURIComponent(e)}/env`)}async function Ze(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 et(e,t){return i(`/api/projects/${encodeURIComponent(e)}/env/${encodeURIComponent(t)}`,{method:"DELETE"})}async function tt(e){return i(`/api/deploy/${encodeURIComponent(e)}/logs`)}async function nt(e,t="7d"){return i(`/api/projects/${encodeURIComponent(e)}/errors?period=${encodeURIComponent(t)}`)}async function rt(e){return i(`/api/projects/${encodeURIComponent(e)}/deployments`)}async function ot(e){return i(`/api/deploy/${encodeURIComponent(e)}/redeploy`,{method:"POST"})}async function st(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 it(e){return i(`/api/deploy/${encodeURIComponent(e)}/rollback`,{method:"POST"})}async function at(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 L(`${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 ct(e="nextjs"){return k(`/api/scaffold/${encodeURIComponent(e)}`)}async function lt(e,t){return k(`/api/scaffold/${encodeURIComponent(e)}/context?step_type=${encodeURIComponent(t)}`)}async function ut(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 pt(e){return k(`/api/templates/${encodeURIComponent(e)}`)}async function dt(e){return i(`/api/templates/${encodeURIComponent(e)}/fork`,{method:"POST"})}async function gt(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 ft(e){await i(`/api/projects/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({local_setup_done:!0})})}async function mt(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,m as j,Me as k,je as l,a as m,pe as n,ge as o,Ee as p,me as q,Ae as r,Oe as s,Fe as t,Ve as u,Ne as v,Le as w,qe as x,Be 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};
|