@mcp-use/cli 4.0.2-canary.2 → 4.0.2-canary.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/bin.js +1 -1
- package/dist/{chunk-XHPZPKHH.js → chunk-23BW3OXH.js} +4 -4
- package/dist/chunk-AUVTUYMK.js +1 -0
- package/dist/commands/dev.js +1 -1
- package/dist/commands/start.js +1 -1
- package/dist/dist-WKBHGU46.js +1 -0
- package/dist/index.js +1 -1
- package/dist/{start-7S5RBWJP.js → start-Z5UXFGTP.js} +1 -1
- package/package.json +3 -2
- package/dist/chunk-N35NYWRW.js +0 -1
- package/dist/tunnel-ROVTBKBW.js +0 -1
package/dist/bin.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as o}from"./chunk-
|
|
2
|
+
import{a as o}from"./chunk-23BW3OXH.js";import"./chunk-RXKUVCL7.js";import"./chunk-WOT6VMZA.js";import{readFileSync as i}from"fs";import{createRequire as a}from"module";import{dirname as t,join as c,parse as m}from"path";function p(){try{let e=a(import.meta.url).resolve("mcp-use"),n=t(e),s=m(n).root;for(;n!==s;){try{let r=JSON.parse(i(c(n,"package.json"),"utf8"));if(r.name==="mcp-use"&&typeof r.version=="string")return r.version}catch{}n=t(n)}}catch{}}o(process.argv.slice(2),{frameworkVersion:p()??"4.0.2-canary.3"}).then(e=>{process.exitCode=e},e=>{console.error(e instanceof Error?e.message:String(e)),process.exitCode=1});
|
|
@@ -32,7 +32,7 @@ Options:
|
|
|
32
32
|
--no-open Do not auto-open the inspector in a browser (dev only)
|
|
33
33
|
--no-inspector Start dev without loading the optional Inspector
|
|
34
34
|
-h, --help Show this help
|
|
35
|
-
-v, --version Print the version`,
|
|
35
|
+
-v, --version Print the version`,h={dev:`Usage: mcp-use dev [options]
|
|
36
36
|
|
|
37
37
|
Start the development MCP server with view hot reload.
|
|
38
38
|
|
|
@@ -84,7 +84,7 @@ Options:
|
|
|
84
84
|
--tunnel Start a public tunnel
|
|
85
85
|
-h, --help Show this help
|
|
86
86
|
|
|
87
|
-
Exit codes: 0 started/help, 2 invalid arguments, 1 startup failure`};async function
|
|
87
|
+
Exit codes: 0 started/help, 2 invalid arguments, 1 startup failure`};async function m(t,e={frameworkVersion:"unknown"}){if(t.length===1&&["--version","-v"].includes(t[0]??""))return console.log(e.frameworkVersion),0;if(t.some(r=>r==="--help"||r==="-h")){let r=t[0];if(r===void 0||r==="--help"||r==="-h")return console.log(s),0;let a=h[r];if(a!==void 0)return console.log(a),0}let o=t[0],i=p(t.slice(1));if(o==="login"||o==="logout"||o==="whoami"){let{runIdentity:r}=await import("./commands/identity.js");return r(o,i)}if(o==="org"){let{runOrganizations:r}=await import("./commands/organizations.js");return r(i)}if(o==="servers"){let{runServers:r}=await import("./commands/servers.js");return r(i)}if(o==="deployments"){let{runDeployments:r}=await import("./commands/deployments.js");return r(i)}if(o==="deploy"){let{runDeploy:r}=await import("./commands/deploy.js");return r(i)}if(o==="client"){let{runClient:r}=await import("./commands/client.js");return r(i)}if(o==="screenshot"){let{runScreenshot:r}=await import("./commands/screenshot.js");return r(i)}let n;try{n=l(t)}catch(r){return console.error(r instanceof Error?r.message:String(r)),2}if(n.version)return console.log(e.frameworkVersion),0;if(n.help)return console.log(s),0;switch(n.command){case"start":return y(n);case"dev":case"build":return w(n.command,n);case"typecheck":return f(n);case void 0:return console.error(s),2;default:return console.error(`Unknown command: ${n.command}
|
|
88
88
|
|
|
89
|
-
${s}`),2}}async function f(t){try{let{runTypecheck:e}=await import("./commands/typecheck.js");return await e({cwd:u(process.cwd(),t.path??"."),...t.entry!==void 0&&{entry:t.entry},...t.mcpDir!==void 0&&{mcpDir:t.mcpDir},...t.passthrough.length>0&&{tscArgs:t.passthrough}})}catch(e){return console.error(d(e)),1}}async function y(t){let e;try{let{runStart:n}=await import("./commands/start.js");e=await n({cwd:u(process.cwd(),t.path??"."),port:t.port,host:t.host,...t.inspector===!0&&{withInspector:!0},tunnel:t.tunnel})}catch(n){return console.error(n instanceof Error?n.message:String(n)),1}console.log(`mcp-use server running at ${e.url}`),t.inspector===!0&&console.log(`mcp-use inspector at ${e.url.replace(/\/$/,"")}/inspector`),e.tunnelUrl!==void 0&&console.log(`mcp-use public MCP URL: ${e.tunnelUrl}`);let o=!1,i=()=>{o||(o=!0,e.close().then(()=>process.exit(0),n=>{console.error(n instanceof Error?n.message:String(n)),process.exit(1)}))};return process.once("SIGINT",i),process.once("SIGTERM",i),0}async function w(t,e){let o={cwd:u(process.cwd(),e.path??"."),...e.entry!==void 0&&{entry:e.entry},...e.mcpDir!==void 0&&{mcpDir:e.mcpDir},...e.viewsDir!==void 0&&{viewsDir:e.viewsDir},...e.port!==void 0&&{port:e.port},...e.host!==void 0&&{host:e.host},...e.tunnel&&{tunnel:!0},...!e.open&&{open:!1},...e.inspector===!1&&{inspector:!1},...e.sourceMaps&&{sourceMaps:!0},...e.inline&&{inline:!0}};try{if(t==="dev"){let{runDev:i}=await import("./commands/dev.js");await i(o)}else{let{runBuild:i}=await import("./commands/build.js");await i(o)}return 0}catch(i){return console.error(d(i)),1}}function d(t){let e=t instanceof Error?t.message:String(t);return/tunnel
|
|
90
|
-
`):e}export{
|
|
89
|
+
${s}`),2}}async function f(t){try{let{runTypecheck:e}=await import("./commands/typecheck.js");return await e({cwd:u(process.cwd(),t.path??"."),...t.entry!==void 0&&{entry:t.entry},...t.mcpDir!==void 0&&{mcpDir:t.mcpDir},...t.passthrough.length>0&&{tscArgs:t.passthrough}})}catch(e){return console.error(d(e)),1}}async function y(t){let e;try{let{runStart:n}=await import("./commands/start.js");e=await n({cwd:u(process.cwd(),t.path??"."),port:t.port,host:t.host,...t.inspector===!0&&{withInspector:!0},tunnel:t.tunnel})}catch(n){return console.error(n instanceof Error?n.message:String(n)),1}console.log(`mcp-use server running at ${e.url}`),t.inspector===!0&&console.log(`mcp-use inspector at ${e.url.replace(/\/$/,"")}/inspector`),e.tunnelUrl!==void 0&&console.log(`mcp-use public MCP URL: ${e.tunnelUrl}`);let o=!1,i=()=>{o||(o=!0,e.close().then(()=>process.exit(0),n=>{console.error(n instanceof Error?n.message:String(n)),process.exit(1)}))};return process.once("SIGINT",i),process.once("SIGTERM",i),0}async function w(t,e){let o={cwd:u(process.cwd(),e.path??"."),...e.entry!==void 0&&{entry:e.entry},...e.mcpDir!==void 0&&{mcpDir:e.mcpDir},...e.viewsDir!==void 0&&{viewsDir:e.viewsDir},...e.port!==void 0&&{port:e.port},...e.host!==void 0&&{host:e.host},...e.tunnel&&{tunnel:!0},...!e.open&&{open:!1},...e.inspector===!1&&{inspector:!1},...e.sourceMaps&&{sourceMaps:!0},...e.inline&&{inline:!0}};try{if(t==="dev"){let{runDev:i}=await import("./commands/dev.js");await i(o)}else{let{runBuild:i}=await import("./commands/build.js");await i(o)}return 0}catch(i){return console.error(d(i)),1}}function d(t){let e=t instanceof Error?t.message:String(t);return/tunnel/i.test(e)?["[tunnel_connection_timeout] Public tunnel could not establish a connection.",`Cause: ${e}`,"","Retry:"," mcp-use dev --tunnel","","Verify outbound network access and relay health:"," https://api.tunnel.mcp-use.run/health"].join(`
|
|
90
|
+
`):e}export{m as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import D from"http";import{mkdir as z,readFile as H,writeFile as K}from"fs/promises";import{dirname as J}from"path";var X="https://api.tunnel.mcp-use.run",Q=3e4,$=64*1024,m=256*1024,x=1024*1024,C=100,j=25e3,M=5,G=1,V=2,O=3,Z=4,ee=5,te=6,_=36;function Y(a){let i=a??process.env.MCP_USE_WS_RELAY??X,c=new URL(i);if(c.protocol!=="https:"&&c.protocol!=="http:")throw new Error("Tunnel relay URL must use HTTP or HTTPS");return c.toString()}var g=1e3,N=3e4,ne=new Set(["connection","keep-alive","proxy-authenticate","proxy-authorization","proxy-connection","te","trailer","transfer-encoding","upgrade"]);function W(a){return new Promise(i=>{setTimeout(i,a)})}function R(a){process.env.MCP_USE_TUNNEL_DEBUG==="1"&&console.log(`[mcp-use] ${a}`)}function A(a){return typeof a=="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(a)}function U(a,i=!1){let c={};for(let[r,u]of Object.entries(a)){let d=r.toLowerCase();u===void 0||ne.has(d)||i&&(d==="host"||d==="content-length")||(c[d]=typeof u=="number"?String(u):u)}return c}function P(a,i,c){let r=new TextEncoder().encode(i);if(r.byteLength!==_)throw new Error("Invalid tunnel request identifier");let u=new Uint8Array(1+_+c.byteLength);return u[0]=a,u.set(r,1),u.set(c,1+_),u}function re(a){let i=Buffer.from(a);if(i.byteLength<1+_||i.byteLength>1+_+m)return;let c=i.subarray(1,1+_).toString("ascii");if(A(c))return{kind:i[0]??0,requestId:c,body:i.subarray(1+_)}}function F(a){let i=new Uint8Array(a.byteLength);return i.set(a),i}async function oe(a){for(;a.readyState===WebSocket.OPEN&&a.bufferedAmount>x;)await W(5);if(a.readyState!==WebSocket.OPEN)throw new Error("Tunnel socket closed while applying backpressure")}function v(a,i){let c=JSON.stringify(i);if(Buffer.byteLength(c)>$)throw new Error("Tunnel control message exceeds 64 KiB");a.send(c)}async function ae(a){let i=await a.text(),c={};try{c=JSON.parse(i)}catch{}if(!a.ok)throw new Error(c.error??`Tunnel relay returned HTTP ${a.status}`);return c}async function ie(a,i){let c=await fetch(new URL("/api/tunnels/request",a),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i===void 0?{}:{subdomain:i}),signal:AbortSignal.timeout(1e4)}),r=await ae(c);if(typeof r.tunnel_id!="string"||typeof r.token!="string"||typeof r.connect_url!="string"||typeof r.public_url!="string")throw new Error("Tunnel relay returned an invalid reservation");return r}async function L(a,i){if(i.token!==void 0)try{await fetch(new URL(`/api/tunnels/${encodeURIComponent(i.subdomain)}`,a),{method:"DELETE",headers:{authorization:`Bearer ${i.token}`},signal:AbortSignal.timeout(2e3)})}catch{}}async function se(a,i,c){let r=new WebSocket(i.connect_url);r.binaryType="arraybuffer";let u=new Map,d=new Map,w=!1,S=!1,p=!1,b,h=(n,l)=>{let s=u.get(n);if(s!==void 0&&(u.delete(n),s.request.destroy(),s.response?.destroy(),r.readyState===WebSocket.OPEN))try{v(r,{type:"response-error",requestId:n,message:l instanceof Error?l.message:String(l)})}catch{}},q=n=>{if(!A(n.requestId)||u.has(n.requestId)||u.size>=C||typeof n.method!="string"||typeof n.path!="string"||!n.path.startsWith("/")){r.close(1008,"Invalid request");return}let l=U(n.headers,!0),s=n.headers["x-forwarded-host"];typeof s=="string"&&(l.host=s);let e=D.request({hostname:"127.0.0.1",port:a,method:n.method,path:n.path,headers:l}),o={request:e};u.set(n.requestId,o),e.on("response",t=>{o.response=t,(async()=>{v(r,{type:"response-start",requestId:n.requestId,status:t.statusCode??502,headers:U(t.headers)});for await(let f of t){let y=Buffer.from(f);for(let T=0;T<y.byteLength;T+=m)await oe(r),r.send(P(V,n.requestId,y.subarray(T,T+m)))}u.has(n.requestId)&&(u.delete(n.requestId),v(r,{type:"response-end",requestId:n.requestId}))})().catch(f=>{h(n.requestId,f)})}),e.on("error",t=>{h(n.requestId,t)})},E=(n,l=1e3,s="")=>{let e=d.get(n);if(e!==void 0){d.delete(n);try{e.socket.close(l,s.slice(0,123))}catch{e.socket.close()}}},I=(n,l,s)=>{let e=d.get(n);if(e!==void 0){if(!e.open){if(e.queuedBytes+s.byteLength>x){E(n,1009,"WebSocket buffer limit reached"),v(r,{type:"websocket-error",requestId:n,message:"WebSocket buffer limit reached"});return}e.queue.push({kind:l,body:s}),e.queuedBytes+=s.byteLength;return}e.socket.send(l===O?s.toString("utf8"):F(s))}},B=n=>{if(!A(n.requestId)||d.has(n.requestId)||u.size+d.size>=C||typeof n.path!="string"||!n.path.startsWith("/")||n.protocols!==void 0&&(!Array.isArray(n.protocols)||n.protocols.some(o=>typeof o!="string"||!/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/.test(o)))){r.close(1008,"Invalid WebSocket request");return}let l=new URL(n.path,`ws://127.0.0.1:${a}`);if(l.origin!==`ws://127.0.0.1:${a}`){r.close(1008,"Invalid WebSocket path");return}let s=new WebSocket(l,n.protocols??[]);s.binaryType="arraybuffer";let e={socket:s,open:!1,queue:[],queuedBytes:0};d.set(n.requestId,e),s.addEventListener("open",()=>{if(d.get(n.requestId)===e){e.open=!0;for(let o of e.queue)s.send(o.kind===O?o.body.toString("utf8"):F(o.body));e.queue=[],e.queuedBytes=0,v(r,{type:"websocket-ready",requestId:n.requestId,...s.protocol!==""&&{protocol:s.protocol}})}}),s.addEventListener("message",o=>{if(r.readyState===WebSocket.OPEN){if(typeof o.data=="string"){let t=Buffer.from(o.data);if(t.byteLength>m){E(n.requestId,1009,"WebSocket message too large");return}r.send(P(ee,n.requestId,t))}else if(o.data instanceof ArrayBuffer){let t=Buffer.from(o.data);if(t.byteLength>m){E(n.requestId,1009,"WebSocket message too large");return}r.send(P(te,n.requestId,t))}}}),s.addEventListener("close",o=>{d.get(n.requestId)===e&&(d.delete(n.requestId),r.readyState===WebSocket.OPEN&&v(r,{type:"websocket-close",requestId:n.requestId,code:o.code,reason:o.reason}))}),s.addEventListener("error",()=>{d.get(n.requestId)===e&&r.readyState===WebSocket.OPEN&&v(r,{type:"websocket-error",requestId:n.requestId,message:"Local WebSocket connection failed"})})},k=new Promise((n,l)=>{let s=setTimeout(()=>{r.close(),l(new Error("Tunnel setup timed out"))},Q);r.addEventListener("open",()=>{v(r,{type:"authenticate",token:i.token})}),r.addEventListener("message",e=>{if(e.data instanceof ArrayBuffer){let y=re(e.data);if(y===void 0){r.close(1003,"Invalid body frame");return}y.kind===G?u.get(y.requestId)?.request.write(y.body):y.kind===O||y.kind===Z?I(y.requestId,y.kind,y.body):r.close(1003,"Invalid body frame");return}if(typeof e.data!="string"){r.close(1003,"Invalid message");return}let o=e.data;if(Buffer.byteLength(o)>$){r.close(1009,"Control message too large");return}let t;try{t=JSON.parse(o)}catch{r.close(1003,"Invalid JSON");return}if(t.type==="auth-required")return;if(t.type==="ready"){w||(w=!0,clearTimeout(s),t.keepalive===!0&&(b=setInterval(()=>{if(r.readyState===WebSocket.OPEN){if(p){r.close(1011,"Tunnel keepalive timed out");return}p=!0,v(r,{type:"ping"})}},j),b.unref()),n());return}if(t.type==="pong"){p=!1;return}if(t.type==="request-start"){q(t);return}if(t.type==="websocket-open"){B(t);return}if(!A(t.requestId)){r.close(1008,"Invalid request identifier");return}let f=u.get(t.requestId);if(t.type==="request-end")f?.request.end();else if(t.type==="cancel"&&f!==void 0)u.delete(t.requestId),f.request.destroy(),f.response?.destroy();else if(t.type==="websocket-close"){let y=Number.isInteger(t.code)&&(t.code??0)>=1e3&&(t.code??0)<=4999?t.code:1e3;E(t.requestId,y,t.reason??"")}else r.close(1003,"Unsupported message")}),r.addEventListener("error",()=>{w||(clearTimeout(s),l(new Error("Tunnel WebSocket connection failed")))},{once:!0})});return r.addEventListener("close",n=>{b!==void 0&&clearInterval(b);for(let[l,s]of u)u.delete(l),s.request.destroy(),s.response?.destroy();for(let l of d.keys())E(l,1011,"Tunnel disconnected");!S&&w&&c(n)}),await k,Object.defineProperty(r,"__mcpUseIntentionalClose",{value:()=>{S=!0}}),{url:i.public_url,subdomain:i.tunnel_id,token:i.token,socket:r,reservation:i}}function ue(a){let i=a.__mcpUseIntentionalClose;i?.()}function ce(a,i={}){let c=Y(i.relayUrl),r,u=null,d,w=!1,S,p=g,b,h=0,q=async()=>{try{let e=await H(a,"utf8"),o=JSON.parse(e);return typeof o.subdomain=="string"?{subdomain:o.subdomain,...typeof o.token=="string"&&{token:o.token},...typeof o.connect_url=="string"&&{connect_url:o.connect_url},...typeof o.public_url=="string"&&{public_url:o.public_url}}:void 0}catch{return}},E=async e=>{try{await z(J(a),{recursive:!0}),await K(a,JSON.stringify(e,null,2),{encoding:"utf8",mode:384})}catch(o){console.warn(`[mcp-use] failed to save tunnel state: ${o instanceof Error?o.message:String(o)}`)}},I=()=>{},B=e=>e?.token!==void 0&&e.connect_url!==void 0&&e.public_url!==void 0?{tunnel_id:e.subdomain,token:e.token,connect_url:e.connect_url,public_url:e.public_url}:void 0,k=e=>({subdomain:e.tunnel_id,token:e.token,connect_url:e.connect_url,public_url:e.public_url}),n=async e=>{await E(k(e.reservation))},l=async(e,o)=>se(e,o,t=>{r=void 0,u=null;let f=t.code===1008||t.reason==="Tunnel expired"||t.reason==="Tunnel deleted";b=f?void 0:o,R(`tunnel connection closed (${t.code}${t.reason===""?"":`: ${t.reason}`}); ${f?"allocating a replacement":"reattaching"}`),I()}),s=async(e,o)=>{console.log(`[mcp-use] starting tunnel for port ${e}\u2026`);let t=await ie(c,i.subdomain??o);return l(e,t)};return I=()=>{w||d===void 0||u!==null||S!==void 0||(S=(async()=>{for(;!w&&d!==void 0&&u===null;)try{if(b!==void 0&&h<M)try{let t=await l(d,b);r=t,u=t.url,h=0,p=g,await n(t),R("tunnel reattached");return}catch(t){if(h+=1,R(`tunnel reattach attempt ${h} failed: ${t instanceof Error?t.message:String(t)}`),h<M){await W(p),p=Math.min(p*2,N);continue}}let e=await q();e!==void 0&&await L(c,e),b=void 0,h=0;let o;try{o=await s(d,e?.subdomain)}catch(t){if(e?.subdomain===void 0)throw t;console.log(`[mcp-use] tunnel "${e.subdomain}" unavailable, requesting a new one\u2026`),o=await s(d)}r=o,u=o.url,await n(o),p=g;return}catch(e){console.warn(`[mcp-use] tunnel restart failed: ${e instanceof Error?e.message:String(e)}`),await W(p),p=Math.min(p*2,N)}})().finally(()=>{S=void 0}))},{status(){return{url:u}},async start(e){if(w=!1,d=e,r!==void 0&&u!==null)return{url:u,subdomain:r.subdomain};let o=await q(),t,f=B(o);if(f!==void 0&&(i.subdomain===void 0||f.tunnel_id===i.subdomain))try{t=await l(e,f)}catch{await L(c,k(f)),t=await s(e,f.tunnel_id).catch(async()=>(console.log(`[mcp-use] tunnel "${f.tunnel_id}" unavailable, requesting a new one\u2026`),s(e)))}else{o!==void 0&&await L(c,o);try{t=await s(e,o?.subdomain)}catch(y){if(o?.subdomain===void 0)throw y;console.log(`[mcp-use] tunnel "${o.subdomain}" unavailable, requesting a new one\u2026`),t=await s(e)}}return r=t,u=t.url,b=t.reservation,h=0,await n(t),{url:t.url,subdomain:t.subdomain}},async stop(){w=!0,S!==void 0&&await S;let e=r,o=e?.reservation??b;r=void 0,u=null,d=void 0,p=g,b=void 0,h=0,o!==void 0&&await L(c,k(o)),e!==void 0&&(ue(e.socket),e.socket.close(1e3,"Client shutdown"))}}}export{Y as a,ce as b};
|
package/dist/commands/dev.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ju}from"../chunk-N35NYWRW.js";import{a as Uu,b as Vu}from"../chunk-4EER3N42.js";import{c as xu,d as Lu}from"../chunk-RXKUVCL7.js";import{a as Bu,b as Ku,c as Gu,d as Wu,e as ci,g as ui,h as Yu,j as Xu,k as Qu,l as el}from"../chunk-JRCSP5WH.js";import{b as Fu,c as Hu,d as ii}from"../chunk-OMRWADFK.js";import{a as ai,b as Zu}from"../chunk-LUVZUL5C.js";import{a as Du}from"../chunk-S3WHXP7I.js";import{a as si}from"../chunk-WOT6VMZA.js";import{existsSync as xy}from"fs";import{createServer as Ly}from"http";import{createRequire as Dy}from"module";import{networkInterfaces as Zy}from"os";import{join as Lf,resolve as Uy}from"path";import{pathToFileURL as Vy}from"url";import Fy from"@tailwindcss/vite";import Hy from"@vitejs/plugin-react";import{createServer as Jy,createServerModuleRunner as By}from"vite";var Zf=Object.create,In=Object.defineProperty,Uf=Object.getOwnPropertyDescriptor,Vf=Object.getOwnPropertyNames,Ff=Object.getPrototypeOf,Hf=Object.prototype.hasOwnProperty,V=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),tl=(e,t)=>{let r={};for(var o in e)In(r,o,{get:e[o],enumerable:!0});return t&&In(r,Symbol.toStringTag,{value:"Module"}),r},Jf=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(var n=Vf(t),s=0,a=n.length,i;s<a;s++)i=n[s],!Hf.call(e,i)&&i!==r&&In(e,i,{get:(c=>t[c]).bind(null,i),enumerable:!(o=Uf(t,i))||o.enumerable});return e},On=(e,t,r)=>(r=e!=null?Zf(Ff(e)):{},Jf(t||!e||!e.__esModule?In(r,"default",{value:e,enumerable:!0}):r,e));var Bf=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),rl=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),Kf=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),Gf=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function ol(e){return typeof e=="string"&&rl.has(e.replace(/#$/,""))}function nl(e,t){if(!("$schema"in e)||typeof e.$schema!="string")return"2020-12";let r=e.$schema.replace(/#$/,"");if(Bf.has(r))return"2020-12";if(rl.has(r))return"2019-09";if(Kf.has(r)||Gf.has(r))return"draft-7";throw new Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}var sl,li=Object.freeze({status:"aborted"});function x(e,t,r){function o(i,c){if(i._zod||Object.defineProperty(i,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1}),i._zod.traits.has(e))return;i._zod.traits.add(e),t(i,c);let u=a.prototype,m=Object.keys(u);for(let _=0;_<m.length;_++){let z=m[_];z in i||(i[z]=u[z].bind(i))}}let n=r?.Parent??Object;class s extends n{}Object.defineProperty(s,"name",{value:e});function a(i){var c;let u=r?.Parent?new s:this;o(u,i),(c=u._zod).deferred??(c.deferred=[]);for(let m of u._zod.deferred)m();return u}return Object.defineProperty(a,"init",{value:o}),Object.defineProperty(a,Symbol.hasInstance,{value:i=>r?.Parent&&i instanceof r.Parent?!0:i?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var it=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},gr=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(sl=globalThis).__zod_globalConfig??(sl.__zod_globalConfig={});var _r=globalThis.__zod_globalConfig;function Ke(e){return e&&Object.assign(_r,e),_r}var ve={};si(ve,{BIGINT_FORMAT_RANGES:()=>ul,Class:()=>mi,NUMBER_FORMAT_RANGES:()=>Si,aborted:()=>Et,allowsEval:()=>fi,assert:()=>eg,assertEqual:()=>Wf,assertIs:()=>Xf,assertNever:()=>Qf,assertNotEqual:()=>Yf,assignProp:()=>wt,base64ToUint8Array:()=>dl,base64urlToUint8Array:()=>_g,cached:()=>vr,captureStackTrace:()=>qn,cleanEnum:()=>gg,cleanRegex:()=>yo,clone:()=>et,cloneDef:()=>rg,createTransparentProxy:()=>cg,defineLazy:()=>Se,esc:()=>jn,escapeRegex:()=>mt,explicitlyAborted:()=>vi,extend:()=>dg,finalizeIssue:()=>tt,floatSafeRemainder:()=>pi,getElementAtPath:()=>og,getEnumValues:()=>So,getLengthableOrigin:()=>bo,getParsedType:()=>ig,getSizableOrigin:()=>ll,hexToUint8Array:()=>vg,isObject:()=>Gt,isPlainObject:()=>Pt,issue:()=>yr,joinValues:()=>Nn,jsonStringifyReplacer:()=>Sr,merge:()=>pg,mergeDefs:()=>dt,normalizeParams:()=>se,nullish:()=>vo,numKeys:()=>ag,objectClone:()=>tg,omit:()=>lg,optionalKeys:()=>_i,parsedType:()=>yi,partial:()=>hg,pick:()=>ug,prefixIssues:()=>pt,primitiveTypes:()=>cl,promiseAllObject:()=>ng,propertyKeyTypes:()=>gi,randomString:()=>sg,required:()=>fg,safeExtend:()=>mg,shallowClone:()=>il,slugify:()=>hi,stringifyPrimitive:()=>Mn,uint8ArrayToBase64:()=>ml,uint8ArrayToBase64url:()=>Sg,uint8ArrayToHex:()=>yg,unwrapMessage:()=>_o});function Wf(e){return e}function Yf(e){return e}function Xf(e){}function Qf(e){throw new Error("Unexpected value in exhaustive check")}function eg(e){}function So(e){let t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function Nn(e,t="|"){return e.map(r=>Mn(r)).join(t)}function Sr(e,t){return typeof t=="bigint"?t.toString():t}function vr(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function vo(e){return e==null}function yo(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function pi(e,t){let r=e/t,o=Math.round(r),n=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-o)<n?0:r-o}var al=Symbol("evaluating");function Se(e,t,r){let o;Object.defineProperty(e,t,{get(){if(o!==al)return o===void 0&&(o=al,o=r()),o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function tg(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function wt(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function dt(...e){let t={};for(let r of e){let o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function rg(e){return dt(e._zod.def)}function og(e,t){return t?t.reduce((r,o)=>r?.[o],e):e}function ng(e){let t=Object.keys(e),r=t.map(o=>e[o]);return Promise.all(r).then(o=>{let n={};for(let s=0;s<t.length;s++)n[t[s]]=o[s];return n})}function sg(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let o=0;o<e;o++)r+=t[Math.floor(Math.random()*t.length)];return r}function jn(e){return JSON.stringify(e)}function hi(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var qn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Gt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var fi=vr(()=>{if(_r.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Pt(e){if(Gt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Gt(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function il(e){return Pt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function ag(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var ig=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},gi=new Set(["string","number","symbol"]),cl=new Set(["string","number","bigint","boolean","symbol","undefined"]);function mt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function et(e,t,r){let o=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(o._zod.parent=e),o}function se(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function cg(e){let t;return new Proxy({},{get(r,o,n){return t??(t=e()),Reflect.get(t,o,n)},set(r,o,n,s){return t??(t=e()),Reflect.set(t,o,n,s)},has(r,o){return t??(t=e()),Reflect.has(t,o)},deleteProperty(r,o){return t??(t=e()),Reflect.deleteProperty(t,o)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,o){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,o)},defineProperty(r,o,n){return t??(t=e()),Reflect.defineProperty(t,o,n)}})}function Mn(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function _i(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Si={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ul={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function ug(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s=dt(e._zod.def,{get shape(){let a={};for(let i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(a[i]=r.shape[i])}return wt(this,"shape",a),a},checks:[]});return et(e,s)}function lg(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=dt(e._zod.def,{get shape(){let a={...e._zod.def.shape};for(let i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete a[i]}return wt(this,"shape",a),a},checks:[]});return et(e,s)}function dg(e,t){if(!Pt(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let s=e._zod.def.shape;for(let a in t)if(Object.getOwnPropertyDescriptor(s,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=dt(e._zod.def,{get shape(){let s={...e._zod.def.shape,...t};return wt(this,"shape",s),s}});return et(e,n)}function mg(e,t){if(!Pt(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=dt(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return wt(this,"shape",o),o}});return et(e,r)}function pg(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=dt(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t._zod.def.shape};return wt(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return et(e,r)}function hg(e,t,r){let n=t._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let a=dt(t._zod.def,{get shape(){let i=t._zod.def.shape,c={...i};if(r)for(let u in r){if(!(u in i))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=e?new e({type:"optional",innerType:i[u]}):i[u])}else for(let u in i)c[u]=e?new e({type:"optional",innerType:i[u]}):i[u];return wt(this,"shape",c),c},checks:[]});return et(t,a)}function fg(e,t,r){let o=dt(t._zod.def,{get shape(){let n=t._zod.def.shape,s={...n};if(r)for(let a in r){if(!(a in s))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(s[a]=new e({type:"nonoptional",innerType:n[a]}))}else for(let a in n)s[a]=new e({type:"nonoptional",innerType:n[a]});return wt(this,"shape",s),s}});return et(t,o)}function Et(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function vi(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function pt(e,t){return t.map(r=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function _o(e){return typeof e=="string"?e:e?.message}function tt(e,t,r){let o=e.message?e.message:_o(e.inst?._zod.def?.error?.(e))??_o(t?.error?.(e))??_o(r.customError?.(e))??_o(r.localeError?.(e))??"Invalid input",{inst:n,continue:s,input:a,...i}=e;return i.path??(i.path=[]),i.message=o,t?.reportInput&&(i.input=a),i}function ll(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function bo(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function yi(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function yr(...e){let[t,r,o]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:o}:{...t}}function gg(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function dl(e){let t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return r}function ml(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function _g(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return dl(t+r)}function Sg(e){return ml(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function vg(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let o=0;o<t.length;o+=2)r[o/2]=Number.parseInt(t.slice(o,o+2),16);return r}function yg(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var mi=class{constructor(...t){}};var pl=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Sr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},An=x("$ZodError",pl),bi=x("$ZodError",pl,{Parent:Error});function zi(e,t=r=>r.message){let r={},o=[];for(let n of e.issues)n.path.length>0?(r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n))):o.push(t(n));return{formErrors:o,fieldErrors:r}}function Ri(e,t=r=>r.message){let r={_errors:[]},o=(n,s=[])=>{for(let a of n.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(i=>o({issues:i},[...s,...a.path]));else if(a.code==="invalid_key")o({issues:a.issues},[...s,...a.path]);else if(a.code==="invalid_element")o({issues:a.issues},[...s,...a.path]);else{let i=[...s,...a.path];if(i.length===0)r._errors.push(t(a));else{let c=r,u=0;for(;u<i.length;){let m=i[u];u===i.length-1?(c[m]=c[m]||{_errors:[]},c[m]._errors.push(t(a))):c[m]=c[m]||{_errors:[]},c=c[m],u++}}}};return o(e),r}var xn=e=>(t,r,o,n)=>{let s=o?{...o,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new it;if(a.issues.length){let i=new(n?.Err??e)(a.issues.map(c=>tt(c,s,Ke())));throw qn(i,n?.callee),i}return a.value};var Ln=e=>async(t,r,o,n)=>{let s=o?{...o,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){let i=new(n?.Err??e)(a.issues.map(c=>tt(c,s,Ke())));throw qn(i,n?.callee),i}return a.value};var zo=e=>(t,r,o)=>{let n=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},n);if(s instanceof Promise)throw new it;return s.issues.length?{success:!1,error:new(e??An)(s.issues.map(a=>tt(a,n,Ke())))}:{success:!0,data:s.value}},hl=zo(bi),Ro=e=>async(t,r,o)=>{let n=o?{...o,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},n);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(a=>tt(a,n,Ke())))}:{success:!0,data:s.value}},fl=Ro(bi),gl=e=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return xn(e)(t,r,n)};var _l=e=>(t,r,o)=>xn(e)(t,r,o);var Sl=e=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Ln(e)(t,r,n)};var vl=e=>async(t,r,o)=>Ln(e)(t,r,o);var yl=e=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return zo(e)(t,r,n)};var bl=e=>(t,r,o)=>zo(e)(t,r,o);var zl=e=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Ro(e)(t,r,n)};var Rl=e=>async(t,r,o)=>Ro(e)(t,r,o);var $l=/^[cC][0-9a-z]{6,}$/,wl=/^[0-9a-z]+$/,Pl=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,El=/^[0-9a-vA-V]{20}$/,Tl=/^[A-Za-z0-9]{27}$/,kl=/^[a-zA-Z0-9_-]{21}$/,Cl=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Il=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,$i=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;var Ol=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var zg="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Nl(){return new RegExp(zg,"u")}var jl=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ql=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Ml=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Al=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,xl=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,wi=/^[A-Za-z0-9_-]*$/;var Ll=/^https?$/,Dl=/^\+[1-9]\d{6,14}$/,Zl="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Ul=new RegExp(`^${Zl}$`);function Vl(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Fl(e){return new RegExp(`^${Vl(e)}$`)}function Hl(e){let t=Vl({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let o=`${t}(?:${r.join("|")})`;return new RegExp(`^${Zl}T(?:${o})$`)}var Jl=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Bl=/^-?\d+n?$/,Kl=/^-?\d+$/,Pi=/^-?\d+(?:\.\d+)?$/,Gl=/^(?:true|false)$/i,Wl=/^null$/i;var Yl=/^[^A-Z]*$/,Xl=/^[^a-z]*$/;var Le=x("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Ql={number:"number",bigint:"bigint",object:"date"},Ei=x("$ZodCheckLessThan",(e,t)=>{Le.init(e,t);let r=Ql[typeof t.value];e._zod.onattach.push(o=>{let n=o._zod.bag,s=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ti=x("$ZodCheckGreaterThan",(e,t)=>{Le.init(e,t);let r=Ql[typeof t.value];e._zod.onattach.push(o=>{let n=o._zod.bag,s=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ed=x("$ZodCheckMultipleOf",(e,t)=>{Le.init(e,t),e._zod.onattach.push(r=>{var o;(o=r._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):pi(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),td=x("$ZodCheckNumberFormat",(e,t)=>{Le.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),o=r?"int":"number",[n,s]=Si[t.format];e._zod.onattach.push(a=>{let i=a._zod.bag;i.format=t.format,i.minimum=n,i.maximum=s,r&&(i.pattern=Kl)}),e._zod.check=a=>{let i=a.value;if(r){if(!Number.isInteger(i)){a.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:i,inst:e});return}if(!Number.isSafeInteger(i)){i>0?a.issues.push({input:i,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}):a.issues.push({input:i,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}i<n&&a.issues.push({origin:"number",input:i,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),i>s&&a.issues.push({origin:"number",input:i,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var rd=x("$ZodCheckMaxLength",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=o=>{let n=o.value;return!vo(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{let n=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{let n=o.value;if(n.length<=t.maximum)return;let a=bo(n);o.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),od=x("$ZodCheckMinLength",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=o=>{let n=o.value;return!vo(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{let n=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{let n=o.value;if(n.length>=t.minimum)return;let a=bo(n);o.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),nd=x("$ZodCheckLengthEquals",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=o=>{let n=o.value;return!vo(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{let n=o._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=o=>{let n=o.value,s=n.length;if(s===t.length)return;let a=bo(n),i=s>t.length;o.issues.push({origin:a,...i?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),wo=x("$ZodCheckStringFormat",(e,t)=>{var r,o;Le.init(e,t),e._zod.onattach.push(n=>{let s=n._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),sd=x("$ZodCheckRegex",(e,t)=>{wo.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ad=x("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Yl),wo.init(e,t)}),id=x("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Xl),wo.init(e,t)}),cd=x("$ZodCheckIncludes",(e,t)=>{Le.init(e,t);let r=mt(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=o,e._zod.onattach.push(n=>{let s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(o)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),ud=x("$ZodCheckStartsWith",(e,t)=>{Le.init(e,t);let r=new RegExp(`^${mt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(o=>{let n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),ld=x("$ZodCheckEndsWith",(e,t)=>{Le.init(e,t);let r=new RegExp(`.*${mt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(o=>{let n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});var dd=x("$ZodCheckOverwrite",(e,t)=>{Le.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Dn=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let o=t.split(`
|
|
1
|
+
import{b as Ju}from"../chunk-AUVTUYMK.js";import{a as Uu,b as Vu}from"../chunk-4EER3N42.js";import{c as xu,d as Lu}from"../chunk-RXKUVCL7.js";import{a as Bu,b as Ku,c as Gu,d as Wu,e as ci,g as ui,h as Yu,j as Xu,k as Qu,l as el}from"../chunk-JRCSP5WH.js";import{b as Fu,c as Hu,d as ii}from"../chunk-OMRWADFK.js";import{a as ai,b as Zu}from"../chunk-LUVZUL5C.js";import{a as Du}from"../chunk-S3WHXP7I.js";import{a as si}from"../chunk-WOT6VMZA.js";import{existsSync as xy}from"fs";import{createServer as Ly}from"http";import{createRequire as Dy}from"module";import{networkInterfaces as Zy}from"os";import{join as Lf,resolve as Uy}from"path";import{pathToFileURL as Vy}from"url";import Fy from"@tailwindcss/vite";import Hy from"@vitejs/plugin-react";import{createServer as Jy,createServerModuleRunner as By}from"vite";var Zf=Object.create,In=Object.defineProperty,Uf=Object.getOwnPropertyDescriptor,Vf=Object.getOwnPropertyNames,Ff=Object.getPrototypeOf,Hf=Object.prototype.hasOwnProperty,V=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),tl=(e,t)=>{let r={};for(var o in e)In(r,o,{get:e[o],enumerable:!0});return t&&In(r,Symbol.toStringTag,{value:"Module"}),r},Jf=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(var n=Vf(t),s=0,a=n.length,i;s<a;s++)i=n[s],!Hf.call(e,i)&&i!==r&&In(e,i,{get:(c=>t[c]).bind(null,i),enumerable:!(o=Uf(t,i))||o.enumerable});return e},On=(e,t,r)=>(r=e!=null?Zf(Ff(e)):{},Jf(t||!e||!e.__esModule?In(r,"default",{value:e,enumerable:!0}):r,e));var Bf=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),rl=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),Kf=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),Gf=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function ol(e){return typeof e=="string"&&rl.has(e.replace(/#$/,""))}function nl(e,t){if(!("$schema"in e)||typeof e.$schema!="string")return"2020-12";let r=e.$schema.replace(/#$/,"");if(Bf.has(r))return"2020-12";if(rl.has(r))return"2019-09";if(Kf.has(r)||Gf.has(r))return"draft-7";throw new Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}var sl,li=Object.freeze({status:"aborted"});function x(e,t,r){function o(i,c){if(i._zod||Object.defineProperty(i,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1}),i._zod.traits.has(e))return;i._zod.traits.add(e),t(i,c);let u=a.prototype,m=Object.keys(u);for(let _=0;_<m.length;_++){let z=m[_];z in i||(i[z]=u[z].bind(i))}}let n=r?.Parent??Object;class s extends n{}Object.defineProperty(s,"name",{value:e});function a(i){var c;let u=r?.Parent?new s:this;o(u,i),(c=u._zod).deferred??(c.deferred=[]);for(let m of u._zod.deferred)m();return u}return Object.defineProperty(a,"init",{value:o}),Object.defineProperty(a,Symbol.hasInstance,{value:i=>r?.Parent&&i instanceof r.Parent?!0:i?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var it=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},gr=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(sl=globalThis).__zod_globalConfig??(sl.__zod_globalConfig={});var _r=globalThis.__zod_globalConfig;function Ke(e){return e&&Object.assign(_r,e),_r}var ve={};si(ve,{BIGINT_FORMAT_RANGES:()=>ul,Class:()=>mi,NUMBER_FORMAT_RANGES:()=>Si,aborted:()=>Et,allowsEval:()=>fi,assert:()=>eg,assertEqual:()=>Wf,assertIs:()=>Xf,assertNever:()=>Qf,assertNotEqual:()=>Yf,assignProp:()=>wt,base64ToUint8Array:()=>dl,base64urlToUint8Array:()=>_g,cached:()=>vr,captureStackTrace:()=>qn,cleanEnum:()=>gg,cleanRegex:()=>yo,clone:()=>et,cloneDef:()=>rg,createTransparentProxy:()=>cg,defineLazy:()=>Se,esc:()=>jn,escapeRegex:()=>mt,explicitlyAborted:()=>vi,extend:()=>dg,finalizeIssue:()=>tt,floatSafeRemainder:()=>pi,getElementAtPath:()=>og,getEnumValues:()=>So,getLengthableOrigin:()=>bo,getParsedType:()=>ig,getSizableOrigin:()=>ll,hexToUint8Array:()=>vg,isObject:()=>Gt,isPlainObject:()=>Pt,issue:()=>yr,joinValues:()=>Nn,jsonStringifyReplacer:()=>Sr,merge:()=>pg,mergeDefs:()=>dt,normalizeParams:()=>se,nullish:()=>vo,numKeys:()=>ag,objectClone:()=>tg,omit:()=>lg,optionalKeys:()=>_i,parsedType:()=>yi,partial:()=>hg,pick:()=>ug,prefixIssues:()=>pt,primitiveTypes:()=>cl,promiseAllObject:()=>ng,propertyKeyTypes:()=>gi,randomString:()=>sg,required:()=>fg,safeExtend:()=>mg,shallowClone:()=>il,slugify:()=>hi,stringifyPrimitive:()=>Mn,uint8ArrayToBase64:()=>ml,uint8ArrayToBase64url:()=>Sg,uint8ArrayToHex:()=>yg,unwrapMessage:()=>_o});function Wf(e){return e}function Yf(e){return e}function Xf(e){}function Qf(e){throw new Error("Unexpected value in exhaustive check")}function eg(e){}function So(e){let t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function Nn(e,t="|"){return e.map(r=>Mn(r)).join(t)}function Sr(e,t){return typeof t=="bigint"?t.toString():t}function vr(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function vo(e){return e==null}function yo(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function pi(e,t){let r=e/t,o=Math.round(r),n=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-o)<n?0:r-o}var al=Symbol("evaluating");function Se(e,t,r){let o;Object.defineProperty(e,t,{get(){if(o!==al)return o===void 0&&(o=al,o=r()),o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function tg(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function wt(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function dt(...e){let t={};for(let r of e){let o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function rg(e){return dt(e._zod.def)}function og(e,t){return t?t.reduce((r,o)=>r?.[o],e):e}function ng(e){let t=Object.keys(e),r=t.map(o=>e[o]);return Promise.all(r).then(o=>{let n={};for(let s=0;s<t.length;s++)n[t[s]]=o[s];return n})}function sg(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let o=0;o<e;o++)r+=t[Math.floor(Math.random()*t.length)];return r}function jn(e){return JSON.stringify(e)}function hi(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var qn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Gt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var fi=vr(()=>{if(_r.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Pt(e){if(Gt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Gt(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function il(e){return Pt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function ag(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var ig=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},gi=new Set(["string","number","symbol"]),cl=new Set(["string","number","bigint","boolean","symbol","undefined"]);function mt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function et(e,t,r){let o=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(o._zod.parent=e),o}function se(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function cg(e){let t;return new Proxy({},{get(r,o,n){return t??(t=e()),Reflect.get(t,o,n)},set(r,o,n,s){return t??(t=e()),Reflect.set(t,o,n,s)},has(r,o){return t??(t=e()),Reflect.has(t,o)},deleteProperty(r,o){return t??(t=e()),Reflect.deleteProperty(t,o)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,o){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,o)},defineProperty(r,o,n){return t??(t=e()),Reflect.defineProperty(t,o,n)}})}function Mn(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function _i(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Si={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ul={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function ug(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s=dt(e._zod.def,{get shape(){let a={};for(let i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(a[i]=r.shape[i])}return wt(this,"shape",a),a},checks:[]});return et(e,s)}function lg(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=dt(e._zod.def,{get shape(){let a={...e._zod.def.shape};for(let i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete a[i]}return wt(this,"shape",a),a},checks:[]});return et(e,s)}function dg(e,t){if(!Pt(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let s=e._zod.def.shape;for(let a in t)if(Object.getOwnPropertyDescriptor(s,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=dt(e._zod.def,{get shape(){let s={...e._zod.def.shape,...t};return wt(this,"shape",s),s}});return et(e,n)}function mg(e,t){if(!Pt(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=dt(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return wt(this,"shape",o),o}});return et(e,r)}function pg(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=dt(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t._zod.def.shape};return wt(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return et(e,r)}function hg(e,t,r){let n=t._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let a=dt(t._zod.def,{get shape(){let i=t._zod.def.shape,c={...i};if(r)for(let u in r){if(!(u in i))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=e?new e({type:"optional",innerType:i[u]}):i[u])}else for(let u in i)c[u]=e?new e({type:"optional",innerType:i[u]}):i[u];return wt(this,"shape",c),c},checks:[]});return et(t,a)}function fg(e,t,r){let o=dt(t._zod.def,{get shape(){let n=t._zod.def.shape,s={...n};if(r)for(let a in r){if(!(a in s))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(s[a]=new e({type:"nonoptional",innerType:n[a]}))}else for(let a in n)s[a]=new e({type:"nonoptional",innerType:n[a]});return wt(this,"shape",s),s}});return et(t,o)}function Et(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function vi(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function pt(e,t){return t.map(r=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function _o(e){return typeof e=="string"?e:e?.message}function tt(e,t,r){let o=e.message?e.message:_o(e.inst?._zod.def?.error?.(e))??_o(t?.error?.(e))??_o(r.customError?.(e))??_o(r.localeError?.(e))??"Invalid input",{inst:n,continue:s,input:a,...i}=e;return i.path??(i.path=[]),i.message=o,t?.reportInput&&(i.input=a),i}function ll(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function bo(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function yi(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function yr(...e){let[t,r,o]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:o}:{...t}}function gg(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function dl(e){let t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return r}function ml(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function _g(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return dl(t+r)}function Sg(e){return ml(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function vg(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let o=0;o<t.length;o+=2)r[o/2]=Number.parseInt(t.slice(o,o+2),16);return r}function yg(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var mi=class{constructor(...t){}};var pl=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Sr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},An=x("$ZodError",pl),bi=x("$ZodError",pl,{Parent:Error});function zi(e,t=r=>r.message){let r={},o=[];for(let n of e.issues)n.path.length>0?(r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n))):o.push(t(n));return{formErrors:o,fieldErrors:r}}function Ri(e,t=r=>r.message){let r={_errors:[]},o=(n,s=[])=>{for(let a of n.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(i=>o({issues:i},[...s,...a.path]));else if(a.code==="invalid_key")o({issues:a.issues},[...s,...a.path]);else if(a.code==="invalid_element")o({issues:a.issues},[...s,...a.path]);else{let i=[...s,...a.path];if(i.length===0)r._errors.push(t(a));else{let c=r,u=0;for(;u<i.length;){let m=i[u];u===i.length-1?(c[m]=c[m]||{_errors:[]},c[m]._errors.push(t(a))):c[m]=c[m]||{_errors:[]},c=c[m],u++}}}};return o(e),r}var xn=e=>(t,r,o,n)=>{let s=o?{...o,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new it;if(a.issues.length){let i=new(n?.Err??e)(a.issues.map(c=>tt(c,s,Ke())));throw qn(i,n?.callee),i}return a.value};var Ln=e=>async(t,r,o,n)=>{let s=o?{...o,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){let i=new(n?.Err??e)(a.issues.map(c=>tt(c,s,Ke())));throw qn(i,n?.callee),i}return a.value};var zo=e=>(t,r,o)=>{let n=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},n);if(s instanceof Promise)throw new it;return s.issues.length?{success:!1,error:new(e??An)(s.issues.map(a=>tt(a,n,Ke())))}:{success:!0,data:s.value}},hl=zo(bi),Ro=e=>async(t,r,o)=>{let n=o?{...o,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},n);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(a=>tt(a,n,Ke())))}:{success:!0,data:s.value}},fl=Ro(bi),gl=e=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return xn(e)(t,r,n)};var _l=e=>(t,r,o)=>xn(e)(t,r,o);var Sl=e=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Ln(e)(t,r,n)};var vl=e=>async(t,r,o)=>Ln(e)(t,r,o);var yl=e=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return zo(e)(t,r,n)};var bl=e=>(t,r,o)=>zo(e)(t,r,o);var zl=e=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Ro(e)(t,r,n)};var Rl=e=>async(t,r,o)=>Ro(e)(t,r,o);var $l=/^[cC][0-9a-z]{6,}$/,wl=/^[0-9a-z]+$/,Pl=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,El=/^[0-9a-vA-V]{20}$/,Tl=/^[A-Za-z0-9]{27}$/,kl=/^[a-zA-Z0-9_-]{21}$/,Cl=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Il=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,$i=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;var Ol=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var zg="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Nl(){return new RegExp(zg,"u")}var jl=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ql=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Ml=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Al=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,xl=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,wi=/^[A-Za-z0-9_-]*$/;var Ll=/^https?$/,Dl=/^\+[1-9]\d{6,14}$/,Zl="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Ul=new RegExp(`^${Zl}$`);function Vl(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Fl(e){return new RegExp(`^${Vl(e)}$`)}function Hl(e){let t=Vl({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let o=`${t}(?:${r.join("|")})`;return new RegExp(`^${Zl}T(?:${o})$`)}var Jl=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Bl=/^-?\d+n?$/,Kl=/^-?\d+$/,Pi=/^-?\d+(?:\.\d+)?$/,Gl=/^(?:true|false)$/i,Wl=/^null$/i;var Yl=/^[^A-Z]*$/,Xl=/^[^a-z]*$/;var Le=x("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Ql={number:"number",bigint:"bigint",object:"date"},Ei=x("$ZodCheckLessThan",(e,t)=>{Le.init(e,t);let r=Ql[typeof t.value];e._zod.onattach.push(o=>{let n=o._zod.bag,s=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ti=x("$ZodCheckGreaterThan",(e,t)=>{Le.init(e,t);let r=Ql[typeof t.value];e._zod.onattach.push(o=>{let n=o._zod.bag,s=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ed=x("$ZodCheckMultipleOf",(e,t)=>{Le.init(e,t),e._zod.onattach.push(r=>{var o;(o=r._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):pi(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),td=x("$ZodCheckNumberFormat",(e,t)=>{Le.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),o=r?"int":"number",[n,s]=Si[t.format];e._zod.onattach.push(a=>{let i=a._zod.bag;i.format=t.format,i.minimum=n,i.maximum=s,r&&(i.pattern=Kl)}),e._zod.check=a=>{let i=a.value;if(r){if(!Number.isInteger(i)){a.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:i,inst:e});return}if(!Number.isSafeInteger(i)){i>0?a.issues.push({input:i,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}):a.issues.push({input:i,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}i<n&&a.issues.push({origin:"number",input:i,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),i>s&&a.issues.push({origin:"number",input:i,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var rd=x("$ZodCheckMaxLength",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=o=>{let n=o.value;return!vo(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{let n=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{let n=o.value;if(n.length<=t.maximum)return;let a=bo(n);o.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),od=x("$ZodCheckMinLength",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=o=>{let n=o.value;return!vo(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{let n=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{let n=o.value;if(n.length>=t.minimum)return;let a=bo(n);o.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),nd=x("$ZodCheckLengthEquals",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=o=>{let n=o.value;return!vo(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{let n=o._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=o=>{let n=o.value,s=n.length;if(s===t.length)return;let a=bo(n),i=s>t.length;o.issues.push({origin:a,...i?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),wo=x("$ZodCheckStringFormat",(e,t)=>{var r,o;Le.init(e,t),e._zod.onattach.push(n=>{let s=n._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),sd=x("$ZodCheckRegex",(e,t)=>{wo.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ad=x("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Yl),wo.init(e,t)}),id=x("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Xl),wo.init(e,t)}),cd=x("$ZodCheckIncludes",(e,t)=>{Le.init(e,t);let r=mt(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=o,e._zod.onattach.push(n=>{let s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(o)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),ud=x("$ZodCheckStartsWith",(e,t)=>{Le.init(e,t);let r=new RegExp(`^${mt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(o=>{let n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),ld=x("$ZodCheckEndsWith",(e,t)=>{Le.init(e,t);let r=new RegExp(`.*${mt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(o=>{let n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});var dd=x("$ZodCheckOverwrite",(e,t)=>{Le.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Dn=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let o=t.split(`
|
|
2
2
|
`).filter(a=>a),n=Math.min(...o.map(a=>a.length-a.trimStart().length)),s=o.map(a=>a.slice(n)).map(a=>" ".repeat(this.indent*2)+a);for(let a of s)this.content.push(a)}compile(){let t=Function,r=this?.args,n=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...r,n.join(`
|
|
3
3
|
`))}};var pd={major:4,minor:4,patch:3};var be=x("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=pd;let o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(let n of o)for(let s of n._zod.onattach)s(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(a,i,c)=>{let u=Et(a),m;for(let _ of i){if(_._zod.def.when){if(vi(a)||!_._zod.def.when(a))continue}else if(u)continue;let z=a.issues.length,$=_._zod.check(a);if($ instanceof Promise&&c?.async===!1)throw new it;if(m||$ instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await $,a.issues.length!==z&&(u||(u=Et(a,z)))});else{if(a.issues.length===z)continue;u||(u=Et(a,z))}}return m?m.then(()=>a):a},s=(a,i,c)=>{if(Et(a))return a.aborted=!0,a;let u=n(i,o,c);if(u instanceof Promise){if(c.async===!1)throw new it;return u.then(m=>e._zod.parse(m,c))}return e._zod.parse(u,c)};e._zod.run=(a,i)=>{if(i.skipChecks)return e._zod.parse(a,i);if(i.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...i,skipChecks:!0});return u instanceof Promise?u.then(m=>s(m,a,i)):s(u,a,i)}let c=e._zod.parse(a,i);if(c instanceof Promise){if(i.async===!1)throw new it;return c.then(u=>n(u,o,i))}return n(c,o,i)}}Se(e,"~standard",()=>({validate:n=>{try{let s=hl(e,n);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return fl(e,n).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),Vn=x("$ZodString",(e,t)=>{be.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Jl(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),we=x("$ZodStringFormat",(e,t)=>{wo.init(e,t),Vn.init(e,t)}),zd=x("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Il),we.init(e,t)}),Rd=x("$ZodUUID",(e,t)=>{if(t.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=$i(o))}else t.pattern??(t.pattern=$i());we.init(e,t)}),$d=x("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ol),we.init(e,t)}),wd=x("$ZodURL",(e,t)=>{we.init(e,t),e._zod.check=r=>{try{let o=r.value.trim();if(!t.normalize&&t.protocol?.source===Ll.source&&!/^https?:\/\//i.test(o)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}let n=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(n.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=n.href:r.value=o;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Pd=x("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Nl()),we.init(e,t)}),Ed=x("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=kl),we.init(e,t)}),Td=x("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=$l),we.init(e,t)}),kd=x("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=wl),we.init(e,t)}),Cd=x("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Pl),we.init(e,t)}),Id=x("$ZodXID",(e,t)=>{t.pattern??(t.pattern=El),we.init(e,t)}),Od=x("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Tl),we.init(e,t)}),Nd=x("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Hl(t)),we.init(e,t)}),jd=x("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ul),we.init(e,t)}),qd=x("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Fl(t)),we.init(e,t)}),Md=x("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Cl),we.init(e,t)}),Ad=x("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=jl),we.init(e,t),e._zod.bag.format="ipv4"}),xd=x("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ql),we.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}});var Ld=x("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ml),we.init(e,t)}),Dd=x("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Al),we.init(e,t),e._zod.check=r=>{let o=r.value.split("/");try{if(o.length!==2)throw new Error;let[n,s]=o;if(!s)throw new Error;let a=Number(s);if(`${a}`!==s)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Zd(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Ud=x("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=xl),we.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{Zd(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Rg(e){if(!wi.test(e))return!1;let t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Zd(r)}var Vd=x("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=wi),we.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{Rg(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Fd=x("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Dl),we.init(e,t)});function $g(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[o]=r;if(!o)return!1;let n=JSON.parse(atob(o));return!("typ"in n&&n?.typ!=="JWT"||!n.alg||t&&(!("alg"in n)||n.alg!==t))}catch{return!1}}var Hd=x("$ZodJWT",(e,t)=>{we.init(e,t),e._zod.check=r=>{$g(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Ci=x("$ZodNumber",(e,t)=>{be.init(e,t),e._zod.pattern=e._zod.bag.pattern??Pi,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let n=r.value;if(typeof n=="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let s=typeof n=="number"?Number.isNaN(n)?"NaN":Number.isFinite(n)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...s?{received:s}:{}}),r}}),Jd=x("$ZodNumberFormat",(e,t)=>{td.init(e,t),Ci.init(e,t)}),Bd=x("$ZodBoolean",(e,t)=>{be.init(e,t),e._zod.pattern=Gl,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=!!r.value}catch{}let n=r.value;return typeof n=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),Kd=x("$ZodBigInt",(e,t)=>{be.init(e,t),e._zod.pattern=Bl,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}});var Gd=x("$ZodNull",(e,t)=>{be.init(e,t),e._zod.pattern=Wl,e._zod.values=new Set([null]),e._zod.parse=(r,o)=>{let n=r.value;return n===null||r.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),r}}),Wd=x("$ZodAny",(e,t)=>{be.init(e,t),e._zod.parse=r=>r}),Yd=x("$ZodUnknown",(e,t)=>{be.init(e,t),e._zod.parse=r=>r}),Xd=x("$ZodNever",(e,t)=>{be.init(e,t),e._zod.parse=(r,o)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});var Qd=x("$ZodDate",(e,t)=>{be.init(e,t),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let n=r.value,s=n instanceof Date;return s&&!Number.isNaN(n.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:n,...s?{received:"Invalid Date"}:{},inst:e}),r}});function hd(e,t,r){e.issues.length&&t.issues.push(...pt(r,e.issues)),t.value[r]=e.value}var em=x("$ZodArray",(e,t)=>{be.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!Array.isArray(n))return r.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),r;r.value=Array(n.length);let s=[];for(let a=0;a<n.length;a++){let i=n[a],c=t.element._zod.run({value:i,issues:[]},o);c instanceof Promise?s.push(c.then(u=>hd(u,r,a))):hd(c,r,a)}return s.length?Promise.all(s).then(()=>r):r}});function Un(e,t,r,o,n,s){let a=r in o;if(e.issues.length){if(n&&s&&!a)return;t.issues.push(...pt(r,e.issues))}if(!a&&!n){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?a&&(t.value[r]=void 0):t.value[r]=e.value}function tm(e){let t=Object.keys(e.shape);for(let o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);let r=_i(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function rm(e,t,r,o,n,s){let a=[],i=n.keySet,c=n.catchall._zod,u=c.def.type,m=c.optin==="optional",_=c.optout==="optional";for(let z in t){if(z==="__proto__"||i.has(z))continue;if(u==="never"){a.push(z);continue}let $=c.run({value:t[z],issues:[]},o);$ instanceof Promise?e.push($.then(f=>Un(f,r,z,t,m,_))):Un($,r,z,t,m,_)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s}),e.length?Promise.all(e).then(()=>r):r}var wg=x("$ZodObject",(e,t)=>{if(be.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let i=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...i};return Object.defineProperty(t,"shape",{value:c}),c}})}let o=vr(()=>tm(t));Se(e._zod,"propValues",()=>{let i=t.shape,c={};for(let u in i){let m=i[u]._zod;if(m.values){c[u]??(c[u]=new Set);for(let _ of m.values)c[u].add(_)}}return c});let n=Gt,s=t.catchall,a;e._zod.parse=(i,c)=>{a??(a=o.value);let u=i.value;if(!n(u))return i.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),i;i.value={};let m=[],_=a.shape;for(let z of a.keys){let $=_[z],f=$._zod.optin==="optional",y=$._zod.optout==="optional",g=$._zod.run({value:u[z],issues:[]},c);g instanceof Promise?m.push(g.then(d=>Un(d,i,z,u,f,y))):Un(g,i,z,u,f,y)}return s?rm(m,u,i,c,o.value,e):m.length?Promise.all(m).then(()=>i):i}}),om=x("$ZodObjectJIT",(e,t)=>{wg.init(e,t);let r=e._zod.parse,o=vr(()=>tm(t)),n=z=>{let $=new Dn(["shape","payload","ctx"]),f=o.value,y=p=>{let S=jn(p);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};$.write("const input = payload.value;");let g=Object.create(null),d=0;for(let p of f.keys)g[p]=`key_${d++}`;$.write("const newResult = {};");for(let p of f.keys){let S=g[p],w=jn(p),v=z[p],h=v?._zod?.optin==="optional",E=v?._zod?.optout==="optional";$.write(`const ${S} = ${y(p)};`),h&&E?$.write(`
|
|
4
4
|
if (${S}.issues.length) {
|
package/dist/commands/start.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunk-WOT6VMZA.js";async function e(t){return(await import("../start-
|
|
1
|
+
import"../chunk-WOT6VMZA.js";async function e(t){return(await import("../start-Z5UXFGTP.js")).runStart(t)}export{e as runStart};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./chunk-AUVTUYMK.js";import"./chunk-WOT6VMZA.js";export{b as createTunnelManager,a as tunnelApiBase};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-23BW3OXH.js";import"./chunk-RXKUVCL7.js";import"./chunk-WOT6VMZA.js";export{a as main};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{a as E}from"./chunk-4EER3N42.js";import{c as g,d as v}from"./chunk-RXKUVCL7.js";import{c as I}from"./chunk-OMRWADFK.js";import"./chunk-WOT6VMZA.js";import{readFile as M}from"fs/promises";import{join as d}from"path";import{pathToFileURL as R}from"url";var k=".mcp-use",L="build",N="manifest.json";async function H(t){let o=d(t.cwd,k,L),s=d(o,N),c;try{c=await M(s,"utf8")}catch{throw new Error(`No production build found (missing ${s}).
|
|
2
2
|
Run \`mcp-use build\` first, then \`mcp-use start\`.`)}let a;try{let n=JSON.parse(c);if(typeof n.entryPoint!="string"||n.entryPoint==="")throw new Error("missing entryPoint");a=n.entryPoint}catch(n){let r=n instanceof Error?n.message:String(n);throw new Error(`Invalid build manifest at ${s} (${r}).
|
|
3
3
|
Re-run \`mcp-use build\`.`)}process.env.NODE_ENV??="production",I(t.cwd,"production");let i=d(o,a),u=await import(R(i).href);if(!("default"in u)||u.default===void 0)throw new Error(`The built entry (${i}) has no default export.
|
|
4
|
-
The server entry must \`export default\` its MCPServer instance (see the mcp-use entry contract).`);let e=u.default;if(!A(e))throw new Error(`The default export of ${i} is not an MCPServer: it has no listen() method. Export the MCPServer instance as the default export.`);let S=typeof e.port=="number"?e.port:void 0,U=typeof e.host=="string"?e.host:void 0,h=g(t.port,process.env,S),y=v(t.host,process.env,U),l=await(t.withInspector===!0?_(e,h,y):e.listen(h,{host:y})),m=typeof l?.port=="number"?l.port:h,b=typeof l?.url=="string"?l.url:`http://localhost:${m}`,p,w;if(t.tunnel===!0)try{let{createTunnelManager:n}=await import("./
|
|
4
|
+
The server entry must \`export default\` its MCPServer instance (see the mcp-use entry contract).`);let e=u.default;if(!A(e))throw new Error(`The default export of ${i} is not an MCPServer: it has no listen() method. Export the MCPServer instance as the default export.`);let S=typeof e.port=="number"?e.port:void 0,U=typeof e.host=="string"?e.host:void 0,h=g(t.port,process.env,S),y=v(t.host,process.env,U),l=await(t.withInspector===!0?_(e,h,y):e.listen(h,{host:y})),m=typeof l?.port=="number"?l.port:h,b=typeof l?.url=="string"?l.url:`http://localhost:${m}`,p,w;if(t.tunnel===!0)try{let{createTunnelManager:n}=await import("./dist-WKBHGU46.js");p=n(d(t.cwd,k,"state","tunnel.json"));let r=await p.start(m),P=new URL(b);w=new URL(`${P.pathname}${P.search}`,`${r.url}/`).toString()}catch(n){try{await p?.stop()}catch{}try{await e.close?.()}catch{}throw n}return{port:m,url:b,...w!==void 0&&{tunnelUrl:w},close:async()=>{let n;try{await p?.stop()}catch(r){n=r}try{await e.close?.()}catch(r){n??=r}if(n!==void 0)throw n}}}async function _(t,o,s){let{mountInspector:c}=await x(),a=typeof t.basePath=="string"?t.basePath:"/mcp",i=c({basePath:a,devMode:!1,oauthProxyAllowLoopback:!1,manufactChatUrl:process.env.MANUFACT_CHAT_URL});return t.app.use("*",async(f,u)=>{if(E(f.req.raw,a))return i(f.req.raw);await u()}),t.listen(o,{host:s})}async function x(){let t;try{t=await import("@mcp-use/inspector")}catch(o){throw O(o)?new Error("Built-in Inspector is unavailable; reinstall mcp-use to restore it."):o}if(typeof t.mountInspector!="function")throw new Error("The installed @mcp-use/inspector is incompatible: its package entry does not export mountInspector(). Reinstall mcp-use.");return{mountInspector:t.mountInspector}}function A(t){return typeof t=="object"&&t!==null&&typeof t.listen=="function"}function O(t){return t!==null&&typeof t=="object"&&"code"in t&&(t.code==="ERR_MODULE_NOT_FOUND"||t.code==="MODULE_NOT_FOUND")}export{H as runStart};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-use/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.2-canary.
|
|
4
|
+
"version": "4.0.2-canary.3",
|
|
5
5
|
"description": "Prebuilt CLI, development server, and build pipeline for mcp-use",
|
|
6
6
|
"author": "mcp-use, Inc.",
|
|
7
7
|
"license": "MIT",
|
|
@@ -69,7 +69,8 @@
|
|
|
69
69
|
"typescript": "^5.9.3",
|
|
70
70
|
"vitest": "^4.1.9",
|
|
71
71
|
"zod": "^4.4.3",
|
|
72
|
-
"@mcp-use/client": "2.0.2-canary.2"
|
|
72
|
+
"@mcp-use/client": "2.0.2-canary.2",
|
|
73
|
+
"@mcp-use/tunnel": "0.2.0-canary.0"
|
|
73
74
|
},
|
|
74
75
|
"publishConfig": {
|
|
75
76
|
"access": "public"
|
package/dist/chunk-N35NYWRW.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import Y from"http";import{mkdir as D,readFile as H,writeFile as X}from"fs/promises";import{dirname as z}from"path";var J="https://api.tunnel.mcp-use.run",Q=3e4,$=64*1024,w=256*1024,K=1024*1024,O=100,j=25e3,W=5,G=1,V=2,L=3,Z=4,ee=5,te=6,T=36;function x(){return process.env.MCP_USE_TUNNEL_API??J}var v=1e3,F=3e4,ne=new Set(["connection","keep-alive","proxy-authenticate","proxy-authorization","proxy-connection","te","trailer","transfer-encoding","upgrade"]);function M(s){return new Promise(i=>{setTimeout(i,s)})}function C(s){process.env.MCP_USE_TUNNEL_DEBUG==="1"&&console.log(`[mcp-use] ${s}`)}function B(s){return typeof s=="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(s)}function U(s,i=!1){let u={};for(let[o,d]of Object.entries(s)){let l=o.toLowerCase();d===void 0||ne.has(l)||i&&(l==="host"||l==="content-length")||(u[l]=typeof d=="number"?String(d):d)}return u}function P(s,i,u){let o=new TextEncoder().encode(i);if(o.byteLength!==T)throw new Error("Invalid tunnel request identifier");let d=new Uint8Array(1+T+u.byteLength);return d[0]=s,d.set(o,1),d.set(u,1+T),d}function re(s){let i=Buffer.from(s);if(i.byteLength<1+T||i.byteLength>1+T+w)return;let u=i.subarray(1,1+T).toString("ascii");if(B(u))return{kind:i[0]??0,requestId:u,body:i.subarray(1+T)}}function N(s){let i=new Uint8Array(s.byteLength);return i.set(s),i}async function oe(s){for(;s.readyState===WebSocket.OPEN&&s.bufferedAmount>K;)await M(5);if(s.readyState!==WebSocket.OPEN)throw new Error("Tunnel socket closed while applying backpressure")}function b(s,i){let u=JSON.stringify(i);if(Buffer.byteLength(u)>$)throw new Error("Tunnel control message exceeds 64 KiB");s.send(u)}async function se(s){let i=await s.text(),u={};try{u=JSON.parse(i)}catch{}if(!s.ok)throw new Error(u.error??`Tunnel relay returned HTTP ${s.status}`);return u}async function ie(s){let i=await fetch(new URL("/api/tunnels/request",x()),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s===void 0?{}:{subdomain:s}),signal:AbortSignal.timeout(1e4)}),u=await se(i);if(typeof u.tunnel_id!="string"||typeof u.token!="string"||typeof u.connect_url!="string"||typeof u.public_url!="string")throw new Error("Tunnel relay returned an invalid reservation");return u}async function A(s){if(s.token!==void 0)try{await fetch(new URL(`/api/tunnels/${encodeURIComponent(s.subdomain)}`,x()),{method:"DELETE",headers:{authorization:`Bearer ${s.token}`},signal:AbortSignal.timeout(2e3)})}catch{}}async function ae(s,i,u){let o=new WebSocket(i.connect_url);o.binaryType="arraybuffer";let d=new Map,l=new Map,f=!1,g=!1,y=!1,_,q=(n,e)=>{let t=d.get(n);if(t!==void 0&&(d.delete(n),t.request.destroy(),t.response?.destroy(),o.readyState===WebSocket.OPEN))try{b(o,{type:"response-error",requestId:n,message:e instanceof Error?e.message:String(e)})}catch{}},I=n=>{if(!B(n.requestId)||d.has(n.requestId)||d.size>=O||typeof n.method!="string"||typeof n.path!="string"||!n.path.startsWith("/")){o.close(1008,"Invalid request");return}let e=U(n.headers,!0),t=n.headers["x-forwarded-host"];typeof t=="string"&&(e.host=t);let r=Y.request({hostname:"127.0.0.1",port:s,method:n.method,path:n.path,headers:e}),c={request:r};d.set(n.requestId,c),r.on("response",a=>{c.response=a,(async()=>{b(o,{type:"response-start",requestId:n.requestId,status:a.statusCode??502,headers:U(a.headers)});for await(let S of a){let p=Buffer.from(S);for(let R=0;R<p.byteLength;R+=w)await oe(o),o.send(P(V,n.requestId,p.subarray(R,R+w)))}d.has(n.requestId)&&(d.delete(n.requestId),b(o,{type:"response-end",requestId:n.requestId}))})().catch(S=>{q(n.requestId,S)})}),r.on("error",a=>{q(n.requestId,a)})},E=(n,e=1e3,t="")=>{let r=l.get(n);if(r!==void 0){l.delete(n);try{r.socket.close(e,t.slice(0,123))}catch{r.socket.close()}}},m=(n,e,t)=>{let r=l.get(n);if(r!==void 0){if(!r.open){if(r.queuedBytes+t.byteLength>K){E(n,1009,"WebSocket buffer limit reached"),b(o,{type:"websocket-error",requestId:n,message:"WebSocket buffer limit reached"});return}r.queue.push({kind:e,body:t}),r.queuedBytes+=t.byteLength;return}r.socket.send(e===L?t.toString("utf8"):N(t))}},h=n=>{if(!B(n.requestId)||l.has(n.requestId)||d.size+l.size>=O||typeof n.path!="string"||!n.path.startsWith("/")||n.protocols!==void 0&&(!Array.isArray(n.protocols)||n.protocols.some(c=>typeof c!="string"||!/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/.test(c)))){o.close(1008,"Invalid WebSocket request");return}let e=new URL(n.path,`ws://127.0.0.1:${s}`);if(e.origin!==`ws://127.0.0.1:${s}`){o.close(1008,"Invalid WebSocket path");return}let t=new WebSocket(e,n.protocols??[]);t.binaryType="arraybuffer";let r={socket:t,open:!1,queue:[],queuedBytes:0};l.set(n.requestId,r),t.addEventListener("open",()=>{if(l.get(n.requestId)===r){r.open=!0;for(let c of r.queue)t.send(c.kind===L?c.body.toString("utf8"):N(c.body));r.queue=[],r.queuedBytes=0,b(o,{type:"websocket-ready",requestId:n.requestId,...t.protocol!==""&&{protocol:t.protocol}})}}),t.addEventListener("message",c=>{if(o.readyState===WebSocket.OPEN){if(typeof c.data=="string"){let a=Buffer.from(c.data);if(a.byteLength>w){E(n.requestId,1009,"WebSocket message too large");return}o.send(P(ee,n.requestId,a))}else if(c.data instanceof ArrayBuffer){let a=Buffer.from(c.data);if(a.byteLength>w){E(n.requestId,1009,"WebSocket message too large");return}o.send(P(te,n.requestId,a))}}}),t.addEventListener("close",c=>{l.get(n.requestId)===r&&(l.delete(n.requestId),o.readyState===WebSocket.OPEN&&b(o,{type:"websocket-close",requestId:n.requestId,code:c.code,reason:c.reason}))}),t.addEventListener("error",()=>{l.get(n.requestId)===r&&o.readyState===WebSocket.OPEN&&b(o,{type:"websocket-error",requestId:n.requestId,message:"Local WebSocket connection failed"})})},k=new Promise((n,e)=>{let t=setTimeout(()=>{o.close(),e(new Error("Tunnel setup timed out"))},Q);o.addEventListener("open",()=>{b(o,{type:"authenticate",token:i.token})}),o.addEventListener("message",r=>{if(r.data instanceof ArrayBuffer){let p=re(r.data);if(p===void 0){o.close(1003,"Invalid body frame");return}p.kind===G?d.get(p.requestId)?.request.write(p.body):p.kind===L||p.kind===Z?m(p.requestId,p.kind,p.body):o.close(1003,"Invalid body frame");return}if(typeof r.data!="string"){o.close(1003,"Invalid message");return}let c=r.data;if(Buffer.byteLength(c)>$){o.close(1009,"Control message too large");return}let a;try{a=JSON.parse(c)}catch{o.close(1003,"Invalid JSON");return}if(a.type==="auth-required")return;if(a.type==="ready"){f||(f=!0,clearTimeout(t),a.keepalive===!0&&(_=setInterval(()=>{if(o.readyState===WebSocket.OPEN){if(y){o.close(1011,"Tunnel keepalive timed out");return}y=!0,b(o,{type:"ping"})}},j),_.unref()),n());return}if(a.type==="pong"){y=!1;return}if(a.type==="request-start"){I(a);return}if(a.type==="websocket-open"){h(a);return}if(!B(a.requestId)){o.close(1008,"Invalid request identifier");return}let S=d.get(a.requestId);if(a.type==="request-end")S?.request.end();else if(a.type==="cancel"&&S!==void 0)d.delete(a.requestId),S.request.destroy(),S.response?.destroy();else if(a.type==="websocket-close"){let p=Number.isInteger(a.code)&&(a.code??0)>=1e3&&(a.code??0)<=4999?a.code:1e3;E(a.requestId,p,a.reason??"")}else o.close(1003,"Unsupported message")}),o.addEventListener("error",()=>{f||(clearTimeout(t),e(new Error("Tunnel WebSocket connection failed")))},{once:!0})});return o.addEventListener("close",n=>{_!==void 0&&clearInterval(_);for(let[e,t]of d)d.delete(e),t.request.destroy(),t.response?.destroy();for(let e of l.keys())E(e,1011,"Tunnel disconnected");!g&&f&&u(n)}),await k,Object.defineProperty(o,"__mcpUseIntentionalClose",{value:()=>{g=!0}}),{url:i.public_url,subdomain:i.tunnel_id,token:i.token,socket:o,reservation:i}}function ue(s){let i=s.__mcpUseIntentionalClose;i?.()}function fe(s){let i,u=null,o,d=!1,l,f=v,g,y=0,_=async()=>{try{let e=await H(s,"utf8"),t=JSON.parse(e);return typeof t.subdomain=="string"?{subdomain:t.subdomain,...typeof t.token=="string"&&{token:t.token},...typeof t.connect_url=="string"&&{connect_url:t.connect_url},...typeof t.public_url=="string"&&{public_url:t.public_url}}:void 0}catch{return}},q=async e=>{try{await D(z(s),{recursive:!0}),await X(s,JSON.stringify(e,null,2),{encoding:"utf8",mode:384})}catch(t){console.warn(`[mcp-use] failed to save tunnel state: ${t instanceof Error?t.message:String(t)}`)}},I=()=>{},E=e=>e?.token!==void 0&&e.connect_url!==void 0&&e.public_url!==void 0?{tunnel_id:e.subdomain,token:e.token,connect_url:e.connect_url,public_url:e.public_url}:void 0,m=e=>({subdomain:e.tunnel_id,token:e.token,connect_url:e.connect_url,public_url:e.public_url}),h=async e=>{await q(m(e.reservation))},k=async(e,t)=>ae(e,t,r=>{i=void 0,u=null;let c=r.code===1008||r.reason==="Tunnel expired"||r.reason==="Tunnel deleted";g=c?void 0:t,C(`tunnel connection closed (${r.code}${r.reason===""?"":`: ${r.reason}`}); ${c?"allocating a replacement":"reattaching"}`),I()}),n=async(e,t)=>{console.log(`[mcp-use] starting tunnel for port ${e}\u2026`);let r=await ie(t);return k(e,r)};return I=()=>{d||o===void 0||u!==null||l!==void 0||(l=(async()=>{for(;!d&&o!==void 0&&u===null;)try{if(g!==void 0&&y<W)try{let r=await k(o,g);i=r,u=r.url,y=0,f=v,await h(r),C("tunnel reattached");return}catch(r){if(y+=1,C(`tunnel reattach attempt ${y} failed: ${r instanceof Error?r.message:String(r)}`),y<W){await M(f),f=Math.min(f*2,F);continue}}let e=await _();e!==void 0&&await A(e),g=void 0,y=0;let t;try{t=await n(o,e?.subdomain)}catch(r){if(e?.subdomain===void 0)throw r;console.log(`[mcp-use] tunnel "${e.subdomain}" unavailable, requesting a new one\u2026`),t=await n(o)}i=t,u=t.url,await h(t),f=v;return}catch(e){console.warn(`[mcp-use] tunnel restart failed: ${e instanceof Error?e.message:String(e)}`),await M(f),f=Math.min(f*2,F)}})().finally(()=>{l=void 0}))},{status(){return{url:u}},async start(e){if(d=!1,o=e,i!==void 0&&u!==null)return{url:u,subdomain:i.subdomain};let t=await _(),r,c=E(t);if(c!==void 0)try{r=await k(e,c)}catch{await A(m(c)),r=await n(e,c.tunnel_id).catch(async()=>(console.log(`[mcp-use] tunnel "${c.tunnel_id}" unavailable, requesting a new one\u2026`),n(e)))}else{t!==void 0&&await A(t);try{r=await n(e,t?.subdomain)}catch(a){if(t?.subdomain===void 0)throw a;console.log(`[mcp-use] tunnel "${t.subdomain}" unavailable, requesting a new one\u2026`),r=await n(e)}}return i=r,u=r.url,g=r.reservation,y=0,await h(r),{url:r.url,subdomain:r.subdomain}},async stop(){d=!0,l!==void 0&&await l;let e=i,t=e?.reservation??g;i=void 0,u=null,o=void 0,f=v,g=void 0,y=0,t!==void 0&&await A(m(t)),e!==void 0&&(ue(e.socket),e.socket.close(1e3,"Client shutdown"))}}}export{fe as a};
|
package/dist/tunnel-ROVTBKBW.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a}from"./chunk-N35NYWRW.js";import"./chunk-WOT6VMZA.js";export{a as createTunnelManager};
|