xmcp 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/runtime/adapter-express.js +13 -13
- package/dist/runtime/adapter-fastify.js +13 -13
- package/dist/runtime/adapter-nestjs.js +13 -13
- package/dist/runtime/adapter-nextjs.js +13 -13
- package/dist/runtime/adapter-tanstack-cloudflare.js +13 -13
- package/dist/runtime/adapter-tanstack.js +13 -13
- package/dist/runtime/cloudflare-worker.js +20 -20
- package/dist/runtime/http.js +19 -19
- package/dist/runtime/stdio.js +11 -11
- package/dist/runtime/utils/component-metadata.d.ts +9 -0
- package/dist/runtime/vercel.js +20 -20
- package/dist/types/component.d.ts +10 -0
- package/dist/types/prompt.d.ts +4 -1
- package/dist/types/resource.d.ts +2 -1
- package/dist/types/tool.d.ts +2 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
let e,t,r,i,n,a,o,s,l,c,d,u,p,m;import{AsyncLocalStorage as h}from"async_hooks";var f,g,y,v,_,b,S,w,R,k,x,C,$,T={},E={};function P(e){var t=E[e];if(void 0!==t)return t.exports;var r=E[e]={exports:{}};return T[e](r,r.exports,P),r.exports}P.d=(e,t)=>{for(var r in t)P.o(t,r)&&!P.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},P.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),P.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var I={};P.d(I,{A:()=>ma});var q=Object.create,O=Object.defineProperty,j=Object.getOwnPropertyDescriptor,z=Object.getOwnPropertyNames,L=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;let A=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),M=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),Z=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),U=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]),H=Object.freeze({status:"aborted"});function F(e,t,r){function i(r,i){if(r._zod||Object.defineProperty(r,"_zod",{value:{def:i,constr:o,traits:new Set},enumerable:!1}),r._zod.traits.has(e))return;r._zod.traits.add(e),t(r,i);let n=o.prototype,a=Object.keys(n);for(let e=0;e<a.length;e++){let t=a[e];t in r||(r[t]=n[t].bind(r))}}let n=r?.Parent??Object;class a extends n{}function o(e){var t;let n=r?.Parent?new a:this;for(let r of(i(n,e),(t=n._zod).deferred??(t.deferred=[]),n._zod.deferred))r();return n}return Object.defineProperty(a,"name",{value:e}),Object.defineProperty(o,"init",{value:i}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>!!r?.Parent&&t instanceof r.Parent||t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}Symbol("zod_brand");class V extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class D extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(S=globalThis).__zod_globalConfig??(S.__zod_globalConfig={});let J=globalThis.__zod_globalConfig;function B(e){return e&&Object.assign(J,e),J}let W=/^[cC][0-9a-z]{6,}$/,G=/^[0-9a-z]+$/,K=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Y=/^[0-9a-vA-V]{20}$/,X=/^[A-Za-z0-9]{27}$/,Q=/^[a-zA-Z0-9_-]{21}$/,ee=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,et=/^([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})$/,er=e=>e?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)$/,ei=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,en=/^(?:(?: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])$/,ea=/^(([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}|:))$/,eo=/^((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])$/,es=/^(([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])$/,el=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ec=/^[A-Za-z0-9_-]*$/,ed=/^https?$/,eu=/^\+[1-9]\d{6,14}$/,ep="(?:(?:\\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])))",em=RegExp(`^${ep}$`);function eh(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}let ef=/^-?\d+$/,eg=/^-?\d+(?:\.\d+)?$/,ey=/^(?:true|false)$/i,ev=/^null$/i,e_=/^[^A-Z]*$/,eb=/^[^a-z]*$/;function eS(e){let t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,r])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function ew(e,t){return"bigint"==typeof t?t.toString():t}function eR(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ek(e){let t=+!!e.startsWith("^"),r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}let ex=Symbol("evaluating");function eC(e,t,r){let i;Object.defineProperty(e,t,{get(){if(i!==ex)return void 0===i&&(i=ex,i=r()),i},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function e$(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function eT(...e){let t={};for(let r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}function eE(e){return JSON.stringify(e)}let eP="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function eI(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let eq=eR(()=>{if(J.jitless||"undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(e){return!1}});function eO(e){if(!1===eI(e))return!1;let t=e.constructor;if(void 0===t||"function"!=typeof t)return!0;let r=t.prototype;return!1!==eI(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}function ej(e){return eO(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let ez=new Set(["string","number","symbol"]);function eL(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function eN(e,t,r){let i=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(i._zod.parent=e),i}function eA(e){if(!e)return{};if("string"==typeof e)return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");e.error=e.message}return(delete e.message,"string"==typeof e.error)?{...e,error:()=>e.error}:e}let eM={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-0x80000000,0x7fffffff],uint32:[0,0xffffffff],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function eZ(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function eU(e,t){return t.map(t=>(t.path??(t.path=[]),t.path.unshift(e),t))}function eH(e){return"string"==typeof e?e:e?.message}function eF(e,t,r){let i=e.message?e.message:eH(e.inst?._zod.def?.error?.(e))??eH(t?.error?.(e))??eH(r.customError?.(e))??eH(r.localeError?.(e))??"Invalid input",{inst:n,continue:a,input:o,...s}=e;return s.path??(s.path=[]),s.message=i,t?.reportInput&&(s.input=o),s}function eV(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function eD(...e){let[t,r,i]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:i}:{...t}}let eJ=F("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),eB={number:"number",bigint:"bigint",object:"date"},eW=F("$ZodCheckLessThan",(e,t)=>{eJ.init(e,t);let r=eB[typeof t.value];e._zod.onattach.push(e=>{let r=e._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??1/0;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:r,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),eG=F("$ZodCheckGreaterThan",(e,t)=>{eJ.init(e,t);let r=eB[typeof t.value];e._zod.onattach.push(e=>{let r=e._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??-1/0;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:r,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),eK=F("$ZodCheckMultipleOf",(e,t)=>{eJ.init(e,t),e._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=r=>{let i,n,a;if(typeof r.value!=typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof r.value?r.value%t.value===BigInt(0):0==(n=Math.round(i=r.value/t.value),a=Number.EPSILON*Math.max(Math.abs(i),1),Math.abs(i-n)<a?0:i-n))||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),eY=F("$ZodCheckNumberFormat",(e,t)=>{eJ.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),i=r?"int":"number",[n,a]=eM[t.format];e._zod.onattach.push(e=>{let i=e._zod.bag;i.format=t.format,i.minimum=n,i.maximum=a,r&&(i.pattern=ef)}),e._zod.check=o=>{let s=o.value;if(r){if(!Number.isInteger(s))return void o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?o.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}))}s<n&&o.issues.push({origin:"number",input:s,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:"number",input:s,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),eX=F("$ZodCheckMaxLength",(e,t)=>{var r;eJ.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return null!=t&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag.maximum??1/0;t.maximum<r&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let i=r.value;if(i.length<=t.maximum)return;let n=eV(i);r.issues.push({origin:n,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),eQ=F("$ZodCheckMinLength",(e,t)=>{var r;eJ.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return null!=t&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag.minimum??-1/0;t.minimum>r&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let i=r.value;if(i.length>=t.minimum)return;let n=eV(i);r.issues.push({origin:n,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),e0=F("$ZodCheckLengthEquals",(e,t)=>{var r;eJ.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return null!=t&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=r=>{let i=r.value,n=i.length;if(n===t.length)return;let a=eV(i),o=n>t.length;r.issues.push({origin:a,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),e1=F("$ZodCheckStringFormat",(e,t)=>{var r,i;eJ.init(e,t),e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,t.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),e2=F("$ZodCheckRegex",(e,t)=>{e1.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})}}),e9=F("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=e_),e1.init(e,t)}),e4=F("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=eb),e1.init(e,t)}),e5=F("$ZodCheckIncludes",(e,t)=>{eJ.init(e,t);let r=eL(t.includes),i=new RegExp("number"==typeof t.position?`^.{${t.position}}${r}`:r);t.pattern=i,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(i)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),e3=F("$ZodCheckStartsWith",(e,t)=>{eJ.init(e,t);let r=RegExp(`^${eL(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),e6=F("$ZodCheckEndsWith",(e,t)=>{eJ.init(e,t);let r=RegExp(`.*${eL(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),e7=F("$ZodCheckOverwrite",(e,t)=>{eJ.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class e8{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let t=e.split("\n").filter(e=>e),r=Math.min(...t.map(e=>e.length-e.trimStart().length));for(let e of t.map(e=>e.slice(r)).map(e=>" ".repeat(2*this.indent)+e))this.content.push(e)}compile(){return Function(...this?.args,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}let te=(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,ew,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},tt=F("$ZodError",te),tr=F("$ZodError",te,{Parent:Error}),ti=e=>(t,r,i,n)=>{let a=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise)throw new V;if(o.issues.length){let t=new(n?.Err??e)(o.issues.map(e=>eF(e,a,B())));throw eP(t,n?.callee),t}return o.value},tn=e=>async(t,r,i,n)=>{let a=i?{...i,async:!0}:{async:!0},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(n?.Err??e)(o.issues.map(e=>eF(e,a,B())));throw eP(t,n?.callee),t}return o.value},ta=e=>(t,r,i)=>{let n=i?{...i,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},n);if(a instanceof Promise)throw new V;return a.issues.length?{success:!1,error:new(e??tt)(a.issues.map(e=>eF(e,n,B())))}:{success:!0,data:a.value}},to=ta(tr),ts=e=>async(t,r,i)=>{let n=i?{...i,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},n);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>eF(e,n,B())))}:{success:!0,data:a.value}},tl=ts(tr),tc={major:4,minor:4,patch:3},td=F("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=tc;let i=[...e._zod.def.checks??[]];for(let t of(e._zod.traits.has("$ZodCheck")&&i.unshift(e),i))for(let r of t._zod.onattach)r(e);if(0===i.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,r)=>{let i,n=eZ(e);for(let a of t){if(a._zod.def.when){if(function(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}(e)||!a._zod.def.when(e))continue}else if(n)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&r?.async===!1)throw new V;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(n||(n=eZ(e,t)))});else{if(e.issues.length===t)continue;n||(n=eZ(e,t))}}return i?i.then(()=>e):e},r=(r,n,a)=>{if(eZ(r))return r.aborted=!0,r;let o=t(n,i,a);if(o instanceof Promise){if(!1===a.async)throw new V;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(n,a)=>{if(a.skipChecks)return e._zod.parse(n,a);if("backward"===a.direction){let t=e._zod.parse({value:n.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,n,a)):r(t,n,a)}let o=e._zod.parse(n,a);if(o instanceof Promise){if(!1===a.async)throw new V;return o.then(e=>t(e,i,a))}return t(o,i,a)}}eC(e,"~standard",()=>({validate:t=>{try{let r=to(e,t);return r.success?{value:r.data}:{issues:r.error?.issues}}catch(r){return tl(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),tu=F("$ZodString",(e,t)=>{var r;let i;td.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(i=(r=e._zod.bag)?`[\\s\\S]{${r?.minimum??0},${r?.maximum??""}}`:"[\\s\\S]*",RegExp(`^${i}$`)),e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch(e){}return"string"==typeof r.value||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),tp=F("$ZodStringFormat",(e,t)=>{e1.init(e,t),tu.init(e,t)}),tm=F("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=et),tp.init(e,t)}),th=F("$ZodUUID",(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=er(e))}else t.pattern??(t.pattern=er());tp.init(e,t)}),tf=F("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ei),tp.init(e,t)}),tg=F("$ZodURL",(e,t)=>{tp.init(e,t),e._zod.check=r=>{try{let i=r.value.trim();if(!t.normalize&&t.protocol?.source===ed.source&&!/^https?:\/\//i.test(i))return void r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});let n=new URL(i);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=i;return}catch(i){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),ty=F("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),tp.init(e,t)}),tv=F("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Q),tp.init(e,t)}),t_=F("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=W),tp.init(e,t)}),tb=F("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=G),tp.init(e,t)}),tS=F("$ZodULID",(e,t)=>{t.pattern??(t.pattern=K),tp.init(e,t)}),tw=F("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Y),tp.init(e,t)}),tR=F("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=X),tp.init(e,t)}),tk=F("$ZodISODateTime",(e,t)=>{let r,i,n;t.pattern??(r=eh({precision:t.precision}),i=["Z"],t.local&&i.push(""),t.offset&&i.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)"),n=`${r}(?:${i.join("|")})`,t.pattern=RegExp(`^${ep}T(?:${n})$`)),tp.init(e,t)}),tx=F("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=em),tp.init(e,t)}),tC=F("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=RegExp(`^${eh(t)}$`)),tp.init(e,t)}),t$=F("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ee),tp.init(e,t)}),tT=F("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=en),tp.init(e,t),e._zod.bag.format="ipv4"}),tE=F("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ea),tp.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})}}}),tP=F("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=eo),tp.init(e,t)}),tI=F("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=es),tp.init(e,t),e._zod.check=r=>{let i=r.value.split("/");try{if(2!==i.length)throw Error();let[e,t]=i;if(!t)throw Error();let r=Number(t);if(`${r}`!==t||r<0||r>128)throw Error();new URL(`http://[${e}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function tq(e){if(""===e)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let tO=F("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=el),tp.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{tq(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),tj=F("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ec),tp.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{!function(e){if(!ec.test(e))return!1;let t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return tq(t.padEnd(4*Math.ceil(t.length/4),"="))}(r.value)&&r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),tz=F("$ZodE164",(e,t)=>{t.pattern??(t.pattern=eu),tp.init(e,t)}),tL=F("$ZodJWT",(e,t)=>{tp.init(e,t),e._zod.check=r=>{!function(e,t=null){try{let r=e.split(".");if(3!==r.length)return!1;let[i]=r;if(!i)return!1;let n=JSON.parse(atob(i));if("typ"in n&&n?.typ!=="JWT"||!n.alg||t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}(r.value,t.alg)&&r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),tN=F("$ZodNumber",(e,t)=>{td.init(e,t),e._zod.pattern=e._zod.bag.pattern??eg,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=Number(r.value)}catch(e){}let n=r.value;if("number"==typeof n&&!Number.isNaN(n)&&Number.isFinite(n))return r;let a="number"==typeof n?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,...a?{received:a}:{}}),r}}),tA=F("$ZodNumberFormat",(e,t)=>{eY.init(e,t),tN.init(e,t)}),tM=F("$ZodBoolean",(e,t)=>{td.init(e,t),e._zod.pattern=ey,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=!!r.value}catch(e){}let n=r.value;return"boolean"==typeof n||r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),tZ=F("$ZodNull",(e,t)=>{td.init(e,t),e._zod.pattern=ev,e._zod.values=new Set([null]),e._zod.parse=(t,r)=>{let i=t.value;return null===i||t.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),t}}),tU=F("$ZodAny",(e,t)=>{td.init(e,t),e._zod.parse=e=>e}),tH=F("$ZodUnknown",(e,t)=>{td.init(e,t),e._zod.parse=e=>e}),tF=F("$ZodNever",(e,t)=>{td.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function tV(e,t,r){e.issues.length&&t.issues.push(...eU(r,e.issues)),t.value[r]=e.value}let tD=F("$ZodArray",(e,t)=>{td.init(e,t),e._zod.parse=(r,i)=>{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 a=[];for(let e=0;e<n.length;e++){let o=n[e],s=t.element._zod.run({value:o,issues:[]},i);s instanceof Promise?a.push(s.then(t=>tV(t,r,e))):tV(s,r,e)}return a.length?Promise.all(a).then(()=>r):r}});function tJ(e,t,r,i,n,a){let o=r in i;if(e.issues.length){if(n&&a&&!o)return;t.issues.push(...eU(r,e.issues))}if(!o&&!n){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}void 0===e.value?o&&(t.value[r]=void 0):t.value[r]=e.value}function tB(e){var t;let r=Object.keys(e.shape);for(let t of r)if(!e.shape?.[t]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${t}": expected a Zod schema`);let i=Object.keys(t=e.shape).filter(e=>"optional"===t[e]._zod.optin&&"optional"===t[e]._zod.optout);return{...e,keys:r,keySet:new Set(r),numKeys:r.length,optionalKeys:new Set(i)}}function tW(e,t,r,i,n,a){let o=[],s=n.keySet,l=n.catchall._zod,c=l.def.type,d="optional"===l.optin,u="optional"===l.optout;for(let n in t){if("__proto__"===n||s.has(n))continue;if("never"===c){o.push(n);continue}let a=l.run({value:t[n],issues:[]},i);a instanceof Promise?e.push(a.then(e=>tJ(e,r,n,t,d,u))):tJ(a,r,n,t,d,u)}return(o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:a}),e.length)?Promise.all(e).then(()=>r):r}let tG=F("$ZodObject",(e,t)=>{let r;td.init(e,t);let i=Object.getOwnPropertyDescriptor(t,"shape");if(!i?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let r={...e};return Object.defineProperty(t,"shape",{value:r}),r}})}let n=eR(()=>tB(t));eC(e._zod,"propValues",()=>{let e=t.shape,r={};for(let t in e){let i=e[t]._zod;if(i.values)for(let e of(r[t]??(r[t]=new Set),i.values))r[t].add(e)}return r});let a=t.catchall;e._zod.parse=(t,i)=>{r??(r=n.value);let o=t.value;if(!eI(o))return t.issues.push({expected:"object",code:"invalid_type",input:o,inst:e}),t;t.value={};let s=[],l=r.shape;for(let e of r.keys){let r=l[e],n="optional"===r._zod.optin,a="optional"===r._zod.optout,c=r._zod.run({value:o[e],issues:[]},i);c instanceof Promise?s.push(c.then(r=>tJ(r,t,e,o,n,a))):tJ(c,t,e,o,n,a)}return a?tW(s,o,t,i,n.value,e):s.length?Promise.all(s).then(()=>t):t}}),tK=F("$ZodObjectJIT",(e,t)=>{let r,i;tG.init(e,t);let n=e._zod.parse,a=eR(()=>tB(t)),o=!J.jitless,s=o&&eq.value,l=t.catchall;e._zod.parse=(c,d)=>{i??(i=a.value);let u=c.value;return eI(u)?o&&s&&d?.async===!1&&!0!==d.jitless?(r||(r=(e=>{let t=new e8(["shape","payload","ctx"]),r=a.value,i=e=>{let t=eE(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");let n=Object.create(null),o=0;for(let e of r.keys)n[e]=`key_${o++}`;for(let a of(t.write("const newResult = {};"),r.keys)){let r=n[a],o=eE(a),s=e[a],l=s?._zod?.optin==="optional",c=s?._zod?.optout==="optional";t.write(`const ${r} = ${i(a)};`),l&&c?t.write(`
|
|
1
|
+
let e,t,r,i,n,a,o,s,l,c,d,u,p,m;import{AsyncLocalStorage as h}from"async_hooks";var f,g,y,v,_,b,S,w,R,k,x,C,$,T={},E={};function P(e){var t=E[e];if(void 0!==t)return t.exports;var r=E[e]={exports:{}};return T[e](r,r.exports,P),r.exports}P.d=(e,t)=>{for(var r in t)P.o(t,r)&&!P.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},P.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),P.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var I={};P.d(I,{A:()=>mo});var q=Object.create,O=Object.defineProperty,j=Object.getOwnPropertyDescriptor,z=Object.getOwnPropertyNames,L=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;let A=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),M=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),Z=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),U=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]),H=Object.freeze({status:"aborted"});function F(e,t,r){function i(r,i){if(r._zod||Object.defineProperty(r,"_zod",{value:{def:i,constr:o,traits:new Set},enumerable:!1}),r._zod.traits.has(e))return;r._zod.traits.add(e),t(r,i);let n=o.prototype,a=Object.keys(n);for(let e=0;e<a.length;e++){let t=a[e];t in r||(r[t]=n[t].bind(r))}}let n=r?.Parent??Object;class a extends n{}function o(e){var t;let n=r?.Parent?new a:this;for(let r of(i(n,e),(t=n._zod).deferred??(t.deferred=[]),n._zod.deferred))r();return n}return Object.defineProperty(a,"name",{value:e}),Object.defineProperty(o,"init",{value:i}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>!!r?.Parent&&t instanceof r.Parent||t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}Symbol("zod_brand");class V extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class D extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(S=globalThis).__zod_globalConfig??(S.__zod_globalConfig={});let J=globalThis.__zod_globalConfig;function B(e){return e&&Object.assign(J,e),J}let W=/^[cC][0-9a-z]{6,}$/,G=/^[0-9a-z]+$/,K=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Y=/^[0-9a-vA-V]{20}$/,X=/^[A-Za-z0-9]{27}$/,Q=/^[a-zA-Z0-9_-]{21}$/,ee=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,et=/^([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})$/,er=e=>e?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)$/,ei=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,en=/^(?:(?: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])$/,ea=/^(([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}|:))$/,eo=/^((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])$/,es=/^(([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])$/,el=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ec=/^[A-Za-z0-9_-]*$/,ed=/^https?$/,eu=/^\+[1-9]\d{6,14}$/,ep="(?:(?:\\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])))",em=RegExp(`^${ep}$`);function eh(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}let ef=/^-?\d+$/,eg=/^-?\d+(?:\.\d+)?$/,ey=/^(?:true|false)$/i,ev=/^null$/i,e_=/^[^A-Z]*$/,eb=/^[^a-z]*$/;function eS(e){let t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,r])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function ew(e,t){return"bigint"==typeof t?t.toString():t}function eR(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ek(e){let t=+!!e.startsWith("^"),r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}let ex=Symbol("evaluating");function eC(e,t,r){let i;Object.defineProperty(e,t,{get(){if(i!==ex)return void 0===i&&(i=ex,i=r()),i},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function e$(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function eT(...e){let t={};for(let r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}function eE(e){return JSON.stringify(e)}let eP="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function eI(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let eq=eR(()=>{if(J.jitless||"undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(e){return!1}});function eO(e){if(!1===eI(e))return!1;let t=e.constructor;if(void 0===t||"function"!=typeof t)return!0;let r=t.prototype;return!1!==eI(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}function ej(e){return eO(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let ez=new Set(["string","number","symbol"]);function eL(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function eN(e,t,r){let i=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(i._zod.parent=e),i}function eA(e){if(!e)return{};if("string"==typeof e)return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");e.error=e.message}return(delete e.message,"string"==typeof e.error)?{...e,error:()=>e.error}:e}let eM={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-0x80000000,0x7fffffff],uint32:[0,0xffffffff],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function eZ(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function eU(e,t){return t.map(t=>(t.path??(t.path=[]),t.path.unshift(e),t))}function eH(e){return"string"==typeof e?e:e?.message}function eF(e,t,r){let i=e.message?e.message:eH(e.inst?._zod.def?.error?.(e))??eH(t?.error?.(e))??eH(r.customError?.(e))??eH(r.localeError?.(e))??"Invalid input",{inst:n,continue:a,input:o,...s}=e;return s.path??(s.path=[]),s.message=i,t?.reportInput&&(s.input=o),s}function eV(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function eD(...e){let[t,r,i]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:i}:{...t}}let eJ=F("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),eB={number:"number",bigint:"bigint",object:"date"},eW=F("$ZodCheckLessThan",(e,t)=>{eJ.init(e,t);let r=eB[typeof t.value];e._zod.onattach.push(e=>{let r=e._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??1/0;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:r,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),eG=F("$ZodCheckGreaterThan",(e,t)=>{eJ.init(e,t);let r=eB[typeof t.value];e._zod.onattach.push(e=>{let r=e._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??-1/0;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:r,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),eK=F("$ZodCheckMultipleOf",(e,t)=>{eJ.init(e,t),e._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=r=>{let i,n,a;if(typeof r.value!=typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof r.value?r.value%t.value===BigInt(0):0==(n=Math.round(i=r.value/t.value),a=Number.EPSILON*Math.max(Math.abs(i),1),Math.abs(i-n)<a?0:i-n))||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),eY=F("$ZodCheckNumberFormat",(e,t)=>{eJ.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),i=r?"int":"number",[n,a]=eM[t.format];e._zod.onattach.push(e=>{let i=e._zod.bag;i.format=t.format,i.minimum=n,i.maximum=a,r&&(i.pattern=ef)}),e._zod.check=o=>{let s=o.value;if(r){if(!Number.isInteger(s))return void o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?o.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}))}s<n&&o.issues.push({origin:"number",input:s,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:"number",input:s,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),eX=F("$ZodCheckMaxLength",(e,t)=>{var r;eJ.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return null!=t&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag.maximum??1/0;t.maximum<r&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let i=r.value;if(i.length<=t.maximum)return;let n=eV(i);r.issues.push({origin:n,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),eQ=F("$ZodCheckMinLength",(e,t)=>{var r;eJ.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return null!=t&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag.minimum??-1/0;t.minimum>r&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let i=r.value;if(i.length>=t.minimum)return;let n=eV(i);r.issues.push({origin:n,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),e0=F("$ZodCheckLengthEquals",(e,t)=>{var r;eJ.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return null!=t&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=r=>{let i=r.value,n=i.length;if(n===t.length)return;let a=eV(i),o=n>t.length;r.issues.push({origin:a,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),e1=F("$ZodCheckStringFormat",(e,t)=>{var r,i;eJ.init(e,t),e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,t.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),e2=F("$ZodCheckRegex",(e,t)=>{e1.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})}}),e9=F("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=e_),e1.init(e,t)}),e4=F("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=eb),e1.init(e,t)}),e5=F("$ZodCheckIncludes",(e,t)=>{eJ.init(e,t);let r=eL(t.includes),i=new RegExp("number"==typeof t.position?`^.{${t.position}}${r}`:r);t.pattern=i,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(i)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),e3=F("$ZodCheckStartsWith",(e,t)=>{eJ.init(e,t);let r=RegExp(`^${eL(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),e6=F("$ZodCheckEndsWith",(e,t)=>{eJ.init(e,t);let r=RegExp(`.*${eL(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),e7=F("$ZodCheckOverwrite",(e,t)=>{eJ.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class e8{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let t=e.split("\n").filter(e=>e),r=Math.min(...t.map(e=>e.length-e.trimStart().length));for(let e of t.map(e=>e.slice(r)).map(e=>" ".repeat(2*this.indent)+e))this.content.push(e)}compile(){return Function(...this?.args,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}let te=(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,ew,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},tt=F("$ZodError",te),tr=F("$ZodError",te,{Parent:Error}),ti=e=>(t,r,i,n)=>{let a=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise)throw new V;if(o.issues.length){let t=new(n?.Err??e)(o.issues.map(e=>eF(e,a,B())));throw eP(t,n?.callee),t}return o.value},tn=e=>async(t,r,i,n)=>{let a=i?{...i,async:!0}:{async:!0},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(n?.Err??e)(o.issues.map(e=>eF(e,a,B())));throw eP(t,n?.callee),t}return o.value},ta=e=>(t,r,i)=>{let n=i?{...i,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},n);if(a instanceof Promise)throw new V;return a.issues.length?{success:!1,error:new(e??tt)(a.issues.map(e=>eF(e,n,B())))}:{success:!0,data:a.value}},to=ta(tr),ts=e=>async(t,r,i)=>{let n=i?{...i,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},n);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>eF(e,n,B())))}:{success:!0,data:a.value}},tl=ts(tr),tc={major:4,minor:4,patch:3},td=F("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=tc;let i=[...e._zod.def.checks??[]];for(let t of(e._zod.traits.has("$ZodCheck")&&i.unshift(e),i))for(let r of t._zod.onattach)r(e);if(0===i.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,r)=>{let i,n=eZ(e);for(let a of t){if(a._zod.def.when){if(function(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}(e)||!a._zod.def.when(e))continue}else if(n)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&r?.async===!1)throw new V;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(n||(n=eZ(e,t)))});else{if(e.issues.length===t)continue;n||(n=eZ(e,t))}}return i?i.then(()=>e):e},r=(r,n,a)=>{if(eZ(r))return r.aborted=!0,r;let o=t(n,i,a);if(o instanceof Promise){if(!1===a.async)throw new V;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(n,a)=>{if(a.skipChecks)return e._zod.parse(n,a);if("backward"===a.direction){let t=e._zod.parse({value:n.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,n,a)):r(t,n,a)}let o=e._zod.parse(n,a);if(o instanceof Promise){if(!1===a.async)throw new V;return o.then(e=>t(e,i,a))}return t(o,i,a)}}eC(e,"~standard",()=>({validate:t=>{try{let r=to(e,t);return r.success?{value:r.data}:{issues:r.error?.issues}}catch(r){return tl(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),tu=F("$ZodString",(e,t)=>{var r;let i;td.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(i=(r=e._zod.bag)?`[\\s\\S]{${r?.minimum??0},${r?.maximum??""}}`:"[\\s\\S]*",RegExp(`^${i}$`)),e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch(e){}return"string"==typeof r.value||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),tp=F("$ZodStringFormat",(e,t)=>{e1.init(e,t),tu.init(e,t)}),tm=F("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=et),tp.init(e,t)}),th=F("$ZodUUID",(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=er(e))}else t.pattern??(t.pattern=er());tp.init(e,t)}),tf=F("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ei),tp.init(e,t)}),tg=F("$ZodURL",(e,t)=>{tp.init(e,t),e._zod.check=r=>{try{let i=r.value.trim();if(!t.normalize&&t.protocol?.source===ed.source&&!/^https?:\/\//i.test(i))return void r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});let n=new URL(i);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=i;return}catch(i){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),ty=F("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),tp.init(e,t)}),tv=F("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Q),tp.init(e,t)}),t_=F("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=W),tp.init(e,t)}),tb=F("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=G),tp.init(e,t)}),tS=F("$ZodULID",(e,t)=>{t.pattern??(t.pattern=K),tp.init(e,t)}),tw=F("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Y),tp.init(e,t)}),tR=F("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=X),tp.init(e,t)}),tk=F("$ZodISODateTime",(e,t)=>{let r,i,n;t.pattern??(r=eh({precision:t.precision}),i=["Z"],t.local&&i.push(""),t.offset&&i.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)"),n=`${r}(?:${i.join("|")})`,t.pattern=RegExp(`^${ep}T(?:${n})$`)),tp.init(e,t)}),tx=F("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=em),tp.init(e,t)}),tC=F("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=RegExp(`^${eh(t)}$`)),tp.init(e,t)}),t$=F("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ee),tp.init(e,t)}),tT=F("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=en),tp.init(e,t),e._zod.bag.format="ipv4"}),tE=F("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ea),tp.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})}}}),tP=F("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=eo),tp.init(e,t)}),tI=F("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=es),tp.init(e,t),e._zod.check=r=>{let i=r.value.split("/");try{if(2!==i.length)throw Error();let[e,t]=i;if(!t)throw Error();let r=Number(t);if(`${r}`!==t||r<0||r>128)throw Error();new URL(`http://[${e}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function tq(e){if(""===e)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let tO=F("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=el),tp.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{tq(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),tj=F("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ec),tp.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{!function(e){if(!ec.test(e))return!1;let t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return tq(t.padEnd(4*Math.ceil(t.length/4),"="))}(r.value)&&r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),tz=F("$ZodE164",(e,t)=>{t.pattern??(t.pattern=eu),tp.init(e,t)}),tL=F("$ZodJWT",(e,t)=>{tp.init(e,t),e._zod.check=r=>{!function(e,t=null){try{let r=e.split(".");if(3!==r.length)return!1;let[i]=r;if(!i)return!1;let n=JSON.parse(atob(i));if("typ"in n&&n?.typ!=="JWT"||!n.alg||t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}(r.value,t.alg)&&r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),tN=F("$ZodNumber",(e,t)=>{td.init(e,t),e._zod.pattern=e._zod.bag.pattern??eg,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=Number(r.value)}catch(e){}let n=r.value;if("number"==typeof n&&!Number.isNaN(n)&&Number.isFinite(n))return r;let a="number"==typeof n?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,...a?{received:a}:{}}),r}}),tA=F("$ZodNumberFormat",(e,t)=>{eY.init(e,t),tN.init(e,t)}),tM=F("$ZodBoolean",(e,t)=>{td.init(e,t),e._zod.pattern=ey,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=!!r.value}catch(e){}let n=r.value;return"boolean"==typeof n||r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),tZ=F("$ZodNull",(e,t)=>{td.init(e,t),e._zod.pattern=ev,e._zod.values=new Set([null]),e._zod.parse=(t,r)=>{let i=t.value;return null===i||t.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),t}}),tU=F("$ZodAny",(e,t)=>{td.init(e,t),e._zod.parse=e=>e}),tH=F("$ZodUnknown",(e,t)=>{td.init(e,t),e._zod.parse=e=>e}),tF=F("$ZodNever",(e,t)=>{td.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function tV(e,t,r){e.issues.length&&t.issues.push(...eU(r,e.issues)),t.value[r]=e.value}let tD=F("$ZodArray",(e,t)=>{td.init(e,t),e._zod.parse=(r,i)=>{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 a=[];for(let e=0;e<n.length;e++){let o=n[e],s=t.element._zod.run({value:o,issues:[]},i);s instanceof Promise?a.push(s.then(t=>tV(t,r,e))):tV(s,r,e)}return a.length?Promise.all(a).then(()=>r):r}});function tJ(e,t,r,i,n,a){let o=r in i;if(e.issues.length){if(n&&a&&!o)return;t.issues.push(...eU(r,e.issues))}if(!o&&!n){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}void 0===e.value?o&&(t.value[r]=void 0):t.value[r]=e.value}function tB(e){var t;let r=Object.keys(e.shape);for(let t of r)if(!e.shape?.[t]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${t}": expected a Zod schema`);let i=Object.keys(t=e.shape).filter(e=>"optional"===t[e]._zod.optin&&"optional"===t[e]._zod.optout);return{...e,keys:r,keySet:new Set(r),numKeys:r.length,optionalKeys:new Set(i)}}function tW(e,t,r,i,n,a){let o=[],s=n.keySet,l=n.catchall._zod,c=l.def.type,d="optional"===l.optin,u="optional"===l.optout;for(let n in t){if("__proto__"===n||s.has(n))continue;if("never"===c){o.push(n);continue}let a=l.run({value:t[n],issues:[]},i);a instanceof Promise?e.push(a.then(e=>tJ(e,r,n,t,d,u))):tJ(a,r,n,t,d,u)}return(o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:a}),e.length)?Promise.all(e).then(()=>r):r}let tG=F("$ZodObject",(e,t)=>{let r;td.init(e,t);let i=Object.getOwnPropertyDescriptor(t,"shape");if(!i?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let r={...e};return Object.defineProperty(t,"shape",{value:r}),r}})}let n=eR(()=>tB(t));eC(e._zod,"propValues",()=>{let e=t.shape,r={};for(let t in e){let i=e[t]._zod;if(i.values)for(let e of(r[t]??(r[t]=new Set),i.values))r[t].add(e)}return r});let a=t.catchall;e._zod.parse=(t,i)=>{r??(r=n.value);let o=t.value;if(!eI(o))return t.issues.push({expected:"object",code:"invalid_type",input:o,inst:e}),t;t.value={};let s=[],l=r.shape;for(let e of r.keys){let r=l[e],n="optional"===r._zod.optin,a="optional"===r._zod.optout,c=r._zod.run({value:o[e],issues:[]},i);c instanceof Promise?s.push(c.then(r=>tJ(r,t,e,o,n,a))):tJ(c,t,e,o,n,a)}return a?tW(s,o,t,i,n.value,e):s.length?Promise.all(s).then(()=>t):t}}),tK=F("$ZodObjectJIT",(e,t)=>{let r,i;tG.init(e,t);let n=e._zod.parse,a=eR(()=>tB(t)),o=!J.jitless,s=o&&eq.value,l=t.catchall;e._zod.parse=(c,d)=>{i??(i=a.value);let u=c.value;return eI(u)?o&&s&&d?.async===!1&&!0!==d.jitless?(r||(r=(e=>{let t=new e8(["shape","payload","ctx"]),r=a.value,i=e=>{let t=eE(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");let n=Object.create(null),o=0;for(let e of r.keys)n[e]=`key_${o++}`;for(let a of(t.write("const newResult = {};"),r.keys)){let r=n[a],o=eE(a),s=e[a],l=s?._zod?.optin==="optional",c=s?._zod?.optout==="optional";t.write(`const ${r} = ${i(a)};`),l&&c?t.write(`
|
|
2
2
|
if (${r}.issues.length) {
|
|
3
3
|
if (${o} in input) {
|
|
4
4
|
payload.issues = payload.issues.concat(${r}.issues.map(iss => ({
|
|
@@ -81,13 +81,13 @@ data:
|
|
|
81
81
|
]))`;continue}else if("$"===i[e]){n+=`($|(?=[\r
|
|
82
82
|
]))`;continue}}if(r.s&&"."===i[e]){n+=o?`${i[e]}\r
|
|
83
83
|
`:`[${i[e]}\r
|
|
84
|
-
]`;continue}n+=i[e],"\\"===i[e]?a=!0:o&&"]"===i[e]?o=!1:o||"["!==i[e]||(o=!0)}try{new RegExp(n)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return n}function uH(e,t){if("openAi"===t.target&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),"openApi3"===t.target&&e.keyType?._def.typeName===$.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((r,i)=>({...r,[i]:uD(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",i]})??uS(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:uD(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if("openApi3"===t.target)return r;if(e.keyType?._def.typeName===$.ZodString&&e.keyType._def.checks?.length){let{type:i,...n}=uL(e.keyType._def,t);return{...r,propertyNames:n}}if(e.keyType?._def.typeName===$.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===$.ZodBranded&&e.keyType._def.type._def.typeName===$.ZodString&&e.keyType._def.type._def.checks?.length){let{type:i,...n}=uk(e.keyType._def,t);return{...r,propertyNames:n}}return r}let uF={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"},uV=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,r)=>uD(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${r}`]})).filter(e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0));return r.length?{anyOf:r}:void 0};function uD(e,t,r=!1){let i=t.seen.get(e);if(t.override){let n=t.override?.(e,t,i,r);if(n!==du)return n}if(i&&!r){let e=uJ(i,t);if(void 0!==e)return e}let n={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,n);let a=((e,t,r)=>{switch(t){case $.ZodString:return uL(e,r);case $.ZodNumber:let i={type:"number"};if(!e.checks)return i;for(let t of e.checks)switch(t.kind){case"int":i.type="integer",uw(i,"type",t.message,r);break;case"min":"jsonSchema7"===r.target?t.inclusive?uR(i,"minimum",t.value,t.message,r):uR(i,"exclusiveMinimum",t.value,t.message,r):(t.inclusive||(i.exclusiveMinimum=!0),uR(i,"minimum",t.value,t.message,r));break;case"max":"jsonSchema7"===r.target?t.inclusive?uR(i,"maximum",t.value,t.message,r):uR(i,"exclusiveMaximum",t.value,t.message,r):(t.inclusive||(i.exclusiveMaximum=!0),uR(i,"maximum",t.value,t.message,r));break;case"multipleOf":uR(i,"multipleOf",t.value,t.message,r)}return i;case $.ZodObject:return function(e,t){let r="openAi"===t.target,i={type:"object",properties:{}},n=[],a=e.shape();for(let e in a){let o=a[e];if(void 0===o||void 0===o._def)continue;let s=function(e){try{return e.isOptional()}catch{return!0}}(o);s&&r&&("ZodOptional"===o._def.typeName&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),s=!1);let l=uD(o._def,{...t,currentPath:[...t.currentPath,"properties",e],propertyPath:[...t.currentPath,"properties",e]});void 0!==l&&(i.properties[e]=l,s||n.push(e))}n.length&&(i.required=n);let o=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return uD(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return"strict"===t.removeAdditionalStrategy?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}(e,t);return void 0!==o&&(i.additionalProperties=o),i}(e,r);case $.ZodBigInt:let n={type:"integer",format:"int64"};if(!e.checks)return n;for(let t of e.checks)switch(t.kind){case"min":"jsonSchema7"===r.target?t.inclusive?uR(n,"minimum",t.value,t.message,r):uR(n,"exclusiveMinimum",t.value,t.message,r):(t.inclusive||(n.exclusiveMinimum=!0),uR(n,"minimum",t.value,t.message,r));break;case"max":"jsonSchema7"===r.target?t.inclusive?uR(n,"maximum",t.value,t.message,r):uR(n,"exclusiveMaximum",t.value,t.message,r):(t.inclusive||(n.exclusiveMaximum=!0),uR(n,"maximum",t.value,t.message,r));break;case"multipleOf":uR(n,"multipleOf",t.value,t.message,r)}return n;case $.ZodBoolean:return{type:"boolean"};case $.ZodDate:return function e(t,r,i){let n=i??r.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((i,n)=>e(t,r,i))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":var a=t,o=r;let s={type:"integer",format:"unix-time"};if("openApi3"===o.target)return s;for(let e of a.checks)switch(e.kind){case"min":uR(s,"minimum",e.value,e.message,o);break;case"max":uR(s,"maximum",e.value,e.message,o)}return s}}(e,r);case $.ZodUndefined:return{not:uS(r)};case $.ZodNull:return"openApi3"===r.target?{enum:["null"],nullable:!0}:{type:"null"};case $.ZodArray:let a;return a={type:"array"},e.type?._def&&e.type?._def?.typeName!==$.ZodAny&&(a.items=uD(e.type._def,{...r,currentPath:[...r.currentPath,"items"]})),e.minLength&&uR(a,"minItems",e.minLength.value,e.minLength.message,r),e.maxLength&&uR(a,"maxItems",e.maxLength.value,e.maxLength.message,r),e.exactLength&&(uR(a,"minItems",e.exactLength.value,e.exactLength.message,r),uR(a,"maxItems",e.exactLength.value,e.exactLength.message,r)),a;case $.ZodUnion:case $.ZodDiscriminatedUnion:if("openApi3"===r.target)return uV(e,r);let o=e.options instanceof Map?Array.from(e.options.values()):e.options;if(o.every(e=>e._def.typeName in uF&&(!e._def.checks||!e._def.checks.length))){let e=o.reduce((e,t)=>{let r=uF[t._def.typeName];return r&&!e.includes(r)?[...e,r]:e},[]);return{type:e.length>1?e:e[0]}}if(o.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){let e=o.reduce((e,t)=>{let r=typeof t._def.value;switch(r){case"string":case"number":case"boolean":return[...e,r];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}},[]);if(e.length===o.length){let t=e.filter((e,t,r)=>r.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:o.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(o.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:o.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return uV(e,r);case $.ZodIntersection:let s,l,c;return s=[uD(e.left._def,{...r,currentPath:[...r.currentPath,"allOf","0"]}),uD(e.right._def,{...r,currentPath:[...r.currentPath,"allOf","1"]})].filter(e=>!!e),l="jsonSchema2019-09"===r.target?{unevaluatedProperties:!1}:void 0,c=[],s.forEach(e=>{if((!("type"in e)||"string"!==e.type)&&"allOf"in e)c.push(...e.allOf),void 0===e.unevaluatedProperties&&(l=void 0);else{let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){let{additionalProperties:r,...i}=e;t=i}else l=void 0;c.push(t)}}),c.length?{allOf:c,...l}:void 0;case $.ZodTuple:return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,t)=>uD(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:uD(e.rest._def,{...r,currentPath:[...r.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,t)=>uD(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])};case $.ZodRecord:return uH(e,r);case $.ZodLiteral:let d;return"bigint"!=(d=typeof e.value)&&"number"!==d&&"boolean"!==d&&"string"!==d?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===r.target?{type:"bigint"===d?"integer":d,enum:[e.value]}:{type:"bigint"===d?"integer":d,const:e.value};case $.ZodEnum:return{type:"string",enum:Array.from(e.values)};case $.ZodNativeEnum:let u,p,m;return u=e.values,{type:1===(m=Array.from(new Set((p=Object.keys(e.values).filter(e=>"number"!=typeof u[u[e]]).map(e=>u[e])).map(e=>typeof e)))).length?"string"===m[0]?"string":"number":["string","number"],enum:p};case $.ZodNullable:if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return"openApi3"===r.target?{type:uF[e.innerType._def.typeName],nullable:!0}:{type:[uF[e.innerType._def.typeName],"null"]};if("openApi3"===r.target){let t=uD(e.innerType._def,{...r,currentPath:[...r.currentPath]});return t&&"$ref"in t?{allOf:[t],nullable:!0}:t&&{...t,nullable:!0}}let h=uD(e.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","0"]});return h&&{anyOf:[h,{type:"null"}]};case $.ZodOptional:if(r.currentPath.toString()===r.propertyPath?.toString())return uD(e.innerType._def,r);let f=uD(e.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","1"]});return f?{anyOf:[{not:uS(r)},f]}:uS(r);case $.ZodMap:if("record"===r.mapStrategy)return uH(e,r);return{type:"array",maxItems:125,items:{type:"array",items:[uD(e.keyType._def,{...r,currentPath:[...r.currentPath,"items","items","0"]})||uS(r),uD(e.valueType._def,{...r,currentPath:[...r.currentPath,"items","items","1"]})||uS(r)],minItems:2,maxItems:2}};case $.ZodSet:let g;return g={type:"array",uniqueItems:!0,items:uD(e.valueType._def,{...r,currentPath:[...r.currentPath,"items"]})},e.minSize&&uR(g,"minItems",e.minSize.value,e.minSize.message,r),e.maxSize&&uR(g,"maxItems",e.maxSize.value,e.maxSize.message,r),g;case $.ZodLazy:return()=>e.getter()._def;case $.ZodPromise:return uD(e.type._def,r);case $.ZodNaN:case $.ZodNever:return"openAi"===r.target?void 0:{not:uS({...r,currentPath:[...r.currentPath,"not"]})};case $.ZodEffects:return"input"===r.effectStrategy?uD(e.schema._def,r):uS(r);case $.ZodAny:case $.ZodUnknown:return uS(r);case $.ZodDefault:return{...uD(e.innerType._def,r),default:e.defaultValue()};case $.ZodBranded:return uk(e,r);case $.ZodReadonly:case $.ZodCatch:return uD(e.innerType._def,r);case $.ZodPipeline:if("input"===r.pipeStrategy)return uD(e.in._def,r);if("output"===r.pipeStrategy)return uD(e.out._def,r);let y=uD(e.in._def,{...r,currentPath:[...r.currentPath,"allOf","0"]}),v=uD(e.out._def,{...r,currentPath:[...r.currentPath,"allOf",y?"1":"0"]});return{allOf:[y,v].filter(e=>void 0!==e)};case $.ZodFunction:case $.ZodVoid:case $.ZodSymbol:default:return}})(e,e.typeName,t),o="function"==typeof a?uD(a(),t):a;if(o&&uB(e,t,o),t.postProcess){let r=t.postProcess(o,e,t);return n.jsonSchema=o,r}return n.jsonSchema=o,o}let uJ=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:ub(t.currentPath,e.path)};case"none":case"seen":if(e.path.length<t.currentPath.length&&e.path.every((e,r)=>t.currentPath[r]===e))return console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),uS(t);return"seen"===t.$refStrategy?uS(t):void 0}},uB=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);function uW(e,t={}){let{strict:r=!1}=t,i=Object.entries(e),n=e=>({target:t})=>{let n={},a=[];for(let[r,o]of i)n[r]=function(e,t,r){let i=e["~standard"];if(i.jsonSchema)return i.jsonSchema[r]({target:t});if("zod"===e["~standard"].vendor&&!("_zod"in e)&&"_def"in e){let r=((e,t)=>{let r,i,n=(i=void 0!==(r="string"==typeof t?{...dp,name:t}:{...dp,...t}).name?[...r.basePath,r.definitionPath,r.name]:r.basePath,{...r,flags:{hasReferencedOpenAiAnyType:!1},currentPath:i,propertyPath:void 0,seen:new Map(Object.entries(r.definitions).map(([e,t])=>[t._def,{def:t._def,path:[...r.basePath,r.definitionPath,e],jsonSchema:void 0}]))}),a="object"==typeof t&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:uD(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??uS(n)}),{}):void 0,o="string"==typeof t?t:t?.nameStrategy==="title"?void 0:t?.name,s=uD(e._def,void 0===o?n:{...n,currentPath:[...n.basePath,n.definitionPath,o]},!1)??uS(n),l="object"==typeof t&&void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==l&&(s.title=l),n.flags.hasReferencedOpenAiAnyType&&(a||(a={}),a[n.openAiAnyTypeName]||(a[n.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:"relative"===n.$refStrategy?"1":[...n.basePath,n.definitionPath,n.openAiAnyTypeName].join("/")}}));let c=void 0===o?a?{...s,[n.definitionPath]:a}:s:{$ref:[..."relative"===n.$refStrategy?[]:n.basePath,n.definitionPath,o].join("/"),[n.definitionPath]:{...a,[o]:s}};return"jsonSchema7"===n.target?c.$schema="http://json-schema.org/draft-07/schema#":("jsonSchema2019-09"===n.target||"openAi"===n.target)&&(c.$schema="https://json-schema.org/draft/2019-09/schema#"),"openAi"===n.target&&("anyOf"in c||"oneOf"in c||"allOf"in c||"type"in c&&Array.isArray(c.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),c})(e,{$refStrategy:"none",target:"openapi-3.0"===t?"openApi3":"jsonSchema7"});return delete r.$schema,r}if("zod"===i.vendor&&"_zod"in e)try{let t=r5(e);return delete t.$schema,t}catch(e){throw Error(`Failed to convert a zod schema to JSON Schema (zod v4 without "~standard.jsonSchema"). Upgrade to zod >= 4.2.0. Original error: ${e instanceof Error?e.message:String(e)}`)}throw Error(`Schema library "${i.vendor}" cannot be converted to JSON Schema. Use zod v3 (>= 3.25.76), zod >= 4.2.0, or a Standard Schema library implementing "~standard.jsonSchema".`)}(o,t,e),!function(e,t){if("function"!=typeof e.safeParse)return!1;try{let r=e.safeParse(void 0);return r.success&&("input"===t||void 0===r.data)}catch{return!1}}(o,e)&&a.push(r);let o={type:"object",properties:n};return a.length>0&&(o.required=a),r&&(o.additionalProperties=!1),o},a=async t=>{if("object"!=typeof t||null===t||Array.isArray(t))return{issues:[{message:"Expected an object."}]};let n={},a=[];for(let[e,r]of i){let i=await r["~standard"].validate(t[e]);if(i.issues)for(let t of i.issues)a.push({message:t.message,path:[e,...t.path??[]]});else(e in t||void 0!==i.value)&&(n[e]=i.value)}if(r)for(let r of Object.keys(t))r in e||a.push({message:`Unrecognized key: "${r}"`,path:[r]});return a.length>0?{issues:a}:{value:n}};return{shape:e,"~standard":{version:1,vendor:"xmcp",validate:a,jsonSchema:{input:n("input"),output:n("output")}}}}let uG=(e,t)=>{globalThis[e]=t},uK=e=>globalThis[e];function uY({name:e,fallback:t=!0}){let r=Symbol.for(`xmcp-context-${e}`),i=Symbol.for(`xmcp-context-${e}-fallback-store`);if(uK(r))return uK(r);let n=new h,a=globalThis[i]??{current:null};uG(i,a);let o={provider:(e,r)=>(t&&(a.current=e),n.run(e,r)),getContext:()=>{let r=n.getStore();if(r)return r;if(t&&a.current)return a.current;throw Error(`getContext() can only be used within the ${e} context.`)},setContext:r=>{let i=n.getStore()??(t?a.current:null);if(!i)throw Error(`setContext() can only be used within the ${e} context.`);Object.assign(i,r)}};return uG(r,o),o}let uX=uY({name:"http-request-context"});uX.setContext;let uQ=uX.getContext,u0=uX.provider,u1=uY({name:"client-info-context"});u1.setContext;let u2=u1.getContext;u1.provider;let u9=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),u4=e=>{if(!u9(e)||"string"!=typeof e.name||"string"!=typeof e.version)return;let t={name:e.name,version:e.version};return"string"==typeof e.title&&(t.title=e.title),"string"==typeof e.websiteUrl&&(t.websiteUrl=e.websiteUrl),"string"==typeof e.description&&(t.description=e.description),t},u5=e=>{if(e&&"initialize"===e.method&&u9(e.params))return u4(e.params.clientInfo)},u3=(e,t)=>{let r=t.toLowerCase();for(let[t,i]of Object.entries(e)){if(t.toLowerCase()!==r)continue;let e=Array.isArray(i)?i[0]:i;if("string"!=typeof e)break;let n=e.trim();return n.length>0?n:void 0}},u6=new Set(["message","mode","requestedSchema"]),u7=new Set(["elicitationId","message","mode","url"]),u8=new Set(["properties","required","type"]),pe=new Set(["default","description","format","maxLength","minLength","title","type"]),pt=new Set(["default","description","enum","enumNames","title","type"]),pr=new Set(["default","description","title","type"]),pi=new Set(["default","description","maximum","minimum","title","type"]),pn=new Set(["date","date-time","email","uri"]);async function pa(e,t,r){let i=function(e){let t=e.mode??"form";if("url"===t)return function(e){let t;ps(e,"Elicitation request must be a plain object."),po(e,u7,"URL elicitation"),pl(e.message,"URL elicitation requires a string message."),pc(e.elicitationId,"URL elicitation requires a non-empty elicitationId."),pc(e.url,"URL elicitation requires a non-empty URL.");try{t=new URL(e.url)}catch{throw Error("URL elicitation requires a valid http or https URL.")}if("http:"!==t.protocol&&"https:"!==t.protocol)throw Error("URL elicitation requires a valid http or https URL.")}(e),e;if("form"!==t)throw Error(`Unsupported elicitation mode "${String(e.mode)}". Expected "form" or "url".`);return function(e){ps(e,"Elicitation request must be a plain object."),po(e,u6,"Form elicitation"),pl(e.message,"Form elicitation requires a string message.");let t=e.requestedSchema;if(ps(t,"Form elicitation requires a flat object schema."),po(t,u8,"Form elicitation schema"),"object"!==t.type)throw Error('Form elicitation schema must use type "object".');for(let[e,r]of(ps(t.properties,"Form elicitation schema requires a properties object."),Object.entries(t.properties)))!function(e,t){if(ps(t,`Form elicitation field "${e}" must be a plain object.`),pd(t.title,`Form elicitation field "${e}" title must be a string.`),pd(t.description,`Form elicitation field "${e}" description must be a string.`),"string"===t.type&&"enum"in t){var r,i;if(po(t,pt,`Form elicitation field "${e}"`),pp(t.enum,`Form elicitation field "${e}" enum values must be strings.`),r=t.enumNames,i=`Form elicitation field "${e}" enumNames must be strings.`,void 0!==r&&pp(r,i),void 0!==t.enumNames&&t.enumNames.length!==t.enum.length)throw Error(`Form elicitation field "${e}" enumNames length must match enum length.`);if(pd(t.default,`Form elicitation field "${e}" default must be a string.`),void 0!==t.default&&!t.enum.includes(t.default))throw Error(`Form elicitation field "${e}" default must be one of its enum values.`);return}if("string"===t.type&&!("enum"in t)){po(t,pe,`Form elicitation field "${e}"`),pu(t.minLength,`Form elicitation field "${e}" minLength must be a number.`),pu(t.maxLength,`Form elicitation field "${e}" maxLength must be a number.`),pd(t.default,`Form elicitation field "${e}" default must be a string.`);let r=t.format;if(pd(r,`Form elicitation field "${e}" format must be a string.`),void 0!==r&&!pn.has(r))throw Error(`Form elicitation field "${e}" format must be one of: ${Array.from(pn).join(", ")}.`);return}if("boolean"===t.type){if(po(t,pr,`Form elicitation field "${e}"`),void 0!==t.default&&"boolean"!=typeof t.default)throw Error(`Form elicitation field "${e}" default must be a boolean.`);return}if("number"===t.type||"integer"===t.type){po(t,pi,`Form elicitation field "${e}"`),pu(t.minimum,`Form elicitation field "${e}" minimum must be a number.`),pu(t.maximum,`Form elicitation field "${e}" maximum must be a number.`),pu(t.default,`Form elicitation field "${e}" default must be a number.`);return}throw Error(`Form elicitation field "${e}" uses unsupported type "${String(t.type)}". Supported types are string, boolean, number, integer, and string enums.`)}(e,r);if(void 0!==t.required){if(!Array.isArray(t.required)||t.required.some(e=>"string"!=typeof e))throw Error("Form elicitation schema required fields must be a string array.");for(let e of t.required)if(!(e in t.properties))throw Error(`Form elicitation schema required field "${e}" is not defined in properties.`)}}(e),{...e,mode:"form"}}(t);try{let t=await e.mcpReq.elicitInput(i,r);return{...t,content:t.content??void 0}}catch(e){if(e instanceof s$&&e.code===sC.MethodNotSupportedByProtocolVersion)throw Error("extra.elicit() is not available on protocol revision 2026-07-28: server-initiated elicitation was replaced by multi round-trip requests. Return inputRequired({ ... }) from the tool handler instead (re-exported from xmcp); the client fulfils the embedded requests and retries the tool call.");throw e}}function po(e,t,r){let i=Object.keys(e).filter(e=>!t.has(e));if(0!==i.length)throw Error(`${r} includes unsupported key(s): ${i.join(", ")}.`)}function ps(e,t){if("object"!=typeof e||null===e||Array.isArray(e))throw Error(t)}function pl(e,t){if("string"!=typeof e)throw Error(t)}function pc(e,t){if("string"!=typeof e||0===e.trim().length)throw Error(t)}function pd(e,t){if(void 0!==e&&"string"!=typeof e)throw Error(t)}function pu(e,t){if(void 0!==e&&"number"!=typeof e)throw Error(t)}function pp(e,t){if(!Array.isArray(e)||e.some(e=>"string"!=typeof e))throw Error(t)}let pm=new Set(["_meta","includeContext","maxTokens","messages","metadata","modelPreferences","stopSequences","systemPrompt","temperature"]),ph=new Set(["task","toolChoice","tools"]),pf=new Set(["text","image","audio"]);async function pg(e,t,r){let i=function(e){py(e,"Sampling request must be a plain object.");let t=Object.keys(e),r=t.filter(e=>ph.has(e));if(r.length>0)throw Error(`Sampling request key(s) not supported by xmcp yet: ${r.join(", ")}.`);let i=t.filter(e=>!pm.has(e));if(i.length>0)throw Error(`Sampling request includes unsupported key(s): ${i.join(", ")}.`);if(!Array.isArray(e.messages)||0===e.messages.length)throw Error("Sampling requires at least one message.");for(let[t,r]of e.messages.entries())!function(e,t){if(py(t,`Sampling message at index ${e} must be a plain object.`),"user"!==t.role&&"assistant"!==t.role)throw Error(`Sampling message at index ${e} requires role "user" or "assistant".`);let r=t.content;py(r,`Sampling message at index ${e} requires a content object.`);let i=r.type;if("string"!=typeof i||!pf.has(i))throw Error(`Sampling message at index ${e} uses unsupported content type "${String(i)}". Supported types are text, image, and audio.`);if("text"===i&&"string"!=typeof r.text)throw Error(`Sampling message at index ${e} requires string text content.`);if(("image"===i||"audio"===i)&&("string"!=typeof r.data||"string"!=typeof r.mimeType))throw Error(`Sampling message at index ${e} requires base64 data and a mimeType.`)}(t,r);if("number"!=typeof e.maxTokens)throw Error("Sampling requires a numeric maxTokens.");return e}(t);try{return await e.mcpReq.requestSampling(i,r)}catch(e){if(e instanceof s$&&e.code===sC.MethodNotSupportedByProtocolVersion)throw Error("extra.sample() is not available on protocol revision 2026-07-28: server-initiated sampling was replaced by multi round-trip requests. Return inputRequired({ ... }) with inputRequired.createMessage(...) from the tool handler instead (re-exported from xmcp); the client fulfils the embedded requests and retries the tool call.");throw e}}function py(e,t){if("object"!=typeof e||null===e||Array.isArray(e))throw Error(t)}let pv={text:e=>"string"!=typeof e.text?{valid:!1,error:'Text content must have a "text" property of type string'}:{valid:!0},image:e=>"string"!=typeof e.data?{valid:!1,error:'Image content must have a "data" property of type string (base64-encoded image)'}:"string"!=typeof e.mimeType?{valid:!1,error:'Image content must have a "mimeType" property of type string'}:{valid:!0},audio:e=>"string"!=typeof e.data?{valid:!1,error:'Audio content must have a "data" property of type string (base64-encoded audio)'}:"string"!=typeof e.mimeType?{valid:!1,error:'Audio content must have a "mimeType" property of type string'}:{valid:!0},resource_link:e=>"string"!=typeof e.name?{valid:!1,error:'Resource link content must have a "name" property of type string'}:"string"!=typeof e.uri?{valid:!1,error:'Resource link content must have a "uri" property of type string'}:void 0!==e.title&&"string"!=typeof e.title?{valid:!1,error:'Resource link "title" property must be a string if provided'}:void 0!==e.description&&"string"!=typeof e.description?{valid:!1,error:'Resource link "description" property must be a string if provided'}:void 0!==e.mimeType&&"string"!=typeof e.mimeType?{valid:!1,error:'Resource link "mimeType" property must be a string if provided'}:{valid:!0}};function p_(e){if(!e||"object"!=typeof e)return{valid:!1,error:"Content must be an object"};if("string"!=typeof e.type)return{valid:!1,error:'Content must have a "type" property of type string'};if(void 0!==e._meta&&(null===e._meta||"object"!=typeof e._meta))return{valid:!1,error:'Content "_meta" property must be an object if provided'};let t=pv[e.type];return t?t(e):{valid:!0}}function pb(e,t,r,i){if(null===e||"object"!=typeof e||Array.isArray(e))throw Error(`Tool "${r}" ${i}: expected a plain object.`);let n=new Set(Object.keys(t)),a=Object.keys(e).filter(e=>!n.has(e));if(a.length>0)throw Error(`Tool "${r}" ${i}: unrecognized key(s): ${a.join(", ")}`);for(let[n,a]of Object.entries(t))try{a.parse(e[n])}catch(e){throw Error(`Tool "${r}" ${i}: ${e?.message??`invalid field "${n}"`}`)}}function pS(e){return!!(e&&"object"==typeof e&&Object.keys(e).some(e=>e.startsWith("ui/")))}function pw(e){let t=e.mcpReq.envelope,r=u4(t?.[nP]);if(!r)try{let e,t=uQ();r=t.clientInfo??(e=t.headers,u4({name:u3(e,"x-mcp-client-name"),version:u3(e,"x-mcp-client-version"),title:u3(e,"x-mcp-client-title"),websiteUrl:u3(e,"x-mcp-client-website-url"),description:u3(e,"x-mcp-client-description")}))}catch{}if(!r)try{r=u2().clientInfo}catch{}return r}function pR(e){return e.endsWith(".tsx")}let pk=new class{add(e,t){this.resources.set(e,t)}getAll(){return this.resources}clear(){this.resources.clear()}has(e){return this.resources.has(e)}constructor(){var e,t;e="resources",t=new Map,e in this?Object.defineProperty(this,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):this[e]=t}};function px(e){let t={};return!function e(r,i=""){if(r&&"object"==typeof r)for(let[n,a]of Object.entries(r)){let r=i?`${i}/${n}`:n;!a||"object"!=typeof a||Array.isArray(a)||a instanceof Date||a instanceof RegExp?t[r]=a:e(a,r)}}(e),t}let pC=["ui/resourceUri","resourceUri","visibility"],p$=["prefersBorder","domain","csp","permissions","connectDomains","resourceDomains","frameDomains","baseUriDomains"],pT=uY({name:"request-context",fallback:!1});function pE(e){let t=[...e];return(e,r,i)=>(function(e,t,r){let i,n=new Map;if(e.http){let e=uQ(),t=Object.fromEntries(Object.entries(e.headers).map(([e,t])=>[e,Array.isArray(t)?Object.freeze([...t]):t]));i=Object.freeze({id:e.id,headers:Object.freeze(t)})}return pT.provider(Object.freeze({clientInfo:t?Object.freeze({...t}):void 0,http:i,signal:e.mcpReq.signal,set(e,t){n.set(e,t)},get:e=>n.get(e),async progress(t,r){let i=e.mcpReq._meta?.progressToken;void 0!==i&&await e.mcpReq.notify({method:"notifications/progress",params:{progressToken:i,progress:t,...void 0===r?{}:{total:r}}})},log:(t,r)=>e.mcpReq.log(t,r)}),r)})(r,pw(r),async()=>{if(0===t.length)return i();let r=Object.freeze({...function(){try{return pT.getContext()}catch{throw Error("getRequestContext() can only be used while handling an MCP request.")}}(),method:e.method,params:Object.freeze({...e.params})}),n=-1,a=async e=>{if(e<=n)throw Error("MCP middleware next() can only be called once");n=e;let o=t[e];return o?o(r,()=>a(e+1)):i()};return a(0)})}let pP=new Set(["tools/list","prompts/get","prompts/list","resources/read","resources/list","resources/templates/list","completion/complete"]);function pI(e){return"object"==typeof e&&null!==e&&Object.entries(e).every(([e,t])=>"string"==typeof e&&"object"==typeof t&&null!==t&&"parse"in t&&"function"==typeof t.parse)}function pq(e){return(e.split("/").pop()||e).replace(/\.[^/.]+$/,"")}function pO(e){let t=e.split("/").filter(e=>""!==e),r=t.findIndex(e=>e.match(/^\(.+\)$/));if(-1===r)return null;let i=t[t.length-1];if(i&&i.match(/^\[.+\]\.ts$/))return null;let n=t[r].slice(1,-1),a=t.slice(r+1),o=a[a.length-1];if(o&&o.includes(".")){let e=o.split(".")[0];"index"!==e?a[a.length-1]=e:a.pop()}let s=[],l=[],c=a.map(e=>{if(!e.match(/^\[.+\]$/))return l.push(e),e;{let t=e.slice(1,-1);return s.push(t),`{${t}}`}}),d=`${n}://${c.join("/")}`,u=s.length>0?"template":"direct";return{filePath:e,uriTemplate:d,scheme:n,parameters:s,pathSegments:l,type:u}}function pj(e){let t=e.replace(/\\/g,"/");if(!t)throw Error("Invalid tool path: path is empty");let r=t.replace(/\.[^/.]+$/,"").replace(/\//g,"_");return{normalizedPath:t,baseName:r}}function pz(e){return Error(`[xmcp] Invalid prompt file: ${e}
|
|
85
|
-
-> Default export must be a prompt handler function.`)}async function
|
|
86
|
-
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} prompt${1===n?"":"s"} skipped due to empty files or missing default exports`)}}();function
|
|
87
|
-
-> Default export must be a resource handler function.`)}async function
|
|
88
|
-
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} resource${1===n?"":"s"} skipped due to empty files or missing default exports`)}}();function
|
|
89
|
-
-> Default export must be a tool handler function.`)}async function
|
|
90
|
-
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} tool${1===n?"":"s"} skipped due to empty files or missing default exports`)}}(),
|
|
84
|
+
]`;continue}n+=i[e],"\\"===i[e]?a=!0:o&&"]"===i[e]?o=!1:o||"["!==i[e]||(o=!0)}try{new RegExp(n)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return n}function uH(e,t){if("openAi"===t.target&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),"openApi3"===t.target&&e.keyType?._def.typeName===$.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((r,i)=>({...r,[i]:uD(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",i]})??uS(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:uD(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if("openApi3"===t.target)return r;if(e.keyType?._def.typeName===$.ZodString&&e.keyType._def.checks?.length){let{type:i,...n}=uL(e.keyType._def,t);return{...r,propertyNames:n}}if(e.keyType?._def.typeName===$.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===$.ZodBranded&&e.keyType._def.type._def.typeName===$.ZodString&&e.keyType._def.type._def.checks?.length){let{type:i,...n}=uk(e.keyType._def,t);return{...r,propertyNames:n}}return r}let uF={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"},uV=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,r)=>uD(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${r}`]})).filter(e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0));return r.length?{anyOf:r}:void 0};function uD(e,t,r=!1){let i=t.seen.get(e);if(t.override){let n=t.override?.(e,t,i,r);if(n!==du)return n}if(i&&!r){let e=uJ(i,t);if(void 0!==e)return e}let n={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,n);let a=((e,t,r)=>{switch(t){case $.ZodString:return uL(e,r);case $.ZodNumber:let i={type:"number"};if(!e.checks)return i;for(let t of e.checks)switch(t.kind){case"int":i.type="integer",uw(i,"type",t.message,r);break;case"min":"jsonSchema7"===r.target?t.inclusive?uR(i,"minimum",t.value,t.message,r):uR(i,"exclusiveMinimum",t.value,t.message,r):(t.inclusive||(i.exclusiveMinimum=!0),uR(i,"minimum",t.value,t.message,r));break;case"max":"jsonSchema7"===r.target?t.inclusive?uR(i,"maximum",t.value,t.message,r):uR(i,"exclusiveMaximum",t.value,t.message,r):(t.inclusive||(i.exclusiveMaximum=!0),uR(i,"maximum",t.value,t.message,r));break;case"multipleOf":uR(i,"multipleOf",t.value,t.message,r)}return i;case $.ZodObject:return function(e,t){let r="openAi"===t.target,i={type:"object",properties:{}},n=[],a=e.shape();for(let e in a){let o=a[e];if(void 0===o||void 0===o._def)continue;let s=function(e){try{return e.isOptional()}catch{return!0}}(o);s&&r&&("ZodOptional"===o._def.typeName&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),s=!1);let l=uD(o._def,{...t,currentPath:[...t.currentPath,"properties",e],propertyPath:[...t.currentPath,"properties",e]});void 0!==l&&(i.properties[e]=l,s||n.push(e))}n.length&&(i.required=n);let o=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return uD(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return"strict"===t.removeAdditionalStrategy?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}(e,t);return void 0!==o&&(i.additionalProperties=o),i}(e,r);case $.ZodBigInt:let n={type:"integer",format:"int64"};if(!e.checks)return n;for(let t of e.checks)switch(t.kind){case"min":"jsonSchema7"===r.target?t.inclusive?uR(n,"minimum",t.value,t.message,r):uR(n,"exclusiveMinimum",t.value,t.message,r):(t.inclusive||(n.exclusiveMinimum=!0),uR(n,"minimum",t.value,t.message,r));break;case"max":"jsonSchema7"===r.target?t.inclusive?uR(n,"maximum",t.value,t.message,r):uR(n,"exclusiveMaximum",t.value,t.message,r):(t.inclusive||(n.exclusiveMaximum=!0),uR(n,"maximum",t.value,t.message,r));break;case"multipleOf":uR(n,"multipleOf",t.value,t.message,r)}return n;case $.ZodBoolean:return{type:"boolean"};case $.ZodDate:return function e(t,r,i){let n=i??r.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((i,n)=>e(t,r,i))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":var a=t,o=r;let s={type:"integer",format:"unix-time"};if("openApi3"===o.target)return s;for(let e of a.checks)switch(e.kind){case"min":uR(s,"minimum",e.value,e.message,o);break;case"max":uR(s,"maximum",e.value,e.message,o)}return s}}(e,r);case $.ZodUndefined:return{not:uS(r)};case $.ZodNull:return"openApi3"===r.target?{enum:["null"],nullable:!0}:{type:"null"};case $.ZodArray:let a;return a={type:"array"},e.type?._def&&e.type?._def?.typeName!==$.ZodAny&&(a.items=uD(e.type._def,{...r,currentPath:[...r.currentPath,"items"]})),e.minLength&&uR(a,"minItems",e.minLength.value,e.minLength.message,r),e.maxLength&&uR(a,"maxItems",e.maxLength.value,e.maxLength.message,r),e.exactLength&&(uR(a,"minItems",e.exactLength.value,e.exactLength.message,r),uR(a,"maxItems",e.exactLength.value,e.exactLength.message,r)),a;case $.ZodUnion:case $.ZodDiscriminatedUnion:if("openApi3"===r.target)return uV(e,r);let o=e.options instanceof Map?Array.from(e.options.values()):e.options;if(o.every(e=>e._def.typeName in uF&&(!e._def.checks||!e._def.checks.length))){let e=o.reduce((e,t)=>{let r=uF[t._def.typeName];return r&&!e.includes(r)?[...e,r]:e},[]);return{type:e.length>1?e:e[0]}}if(o.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){let e=o.reduce((e,t)=>{let r=typeof t._def.value;switch(r){case"string":case"number":case"boolean":return[...e,r];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}},[]);if(e.length===o.length){let t=e.filter((e,t,r)=>r.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:o.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(o.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:o.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return uV(e,r);case $.ZodIntersection:let s,l,c;return s=[uD(e.left._def,{...r,currentPath:[...r.currentPath,"allOf","0"]}),uD(e.right._def,{...r,currentPath:[...r.currentPath,"allOf","1"]})].filter(e=>!!e),l="jsonSchema2019-09"===r.target?{unevaluatedProperties:!1}:void 0,c=[],s.forEach(e=>{if((!("type"in e)||"string"!==e.type)&&"allOf"in e)c.push(...e.allOf),void 0===e.unevaluatedProperties&&(l=void 0);else{let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){let{additionalProperties:r,...i}=e;t=i}else l=void 0;c.push(t)}}),c.length?{allOf:c,...l}:void 0;case $.ZodTuple:return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,t)=>uD(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:uD(e.rest._def,{...r,currentPath:[...r.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,t)=>uD(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])};case $.ZodRecord:return uH(e,r);case $.ZodLiteral:let d;return"bigint"!=(d=typeof e.value)&&"number"!==d&&"boolean"!==d&&"string"!==d?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===r.target?{type:"bigint"===d?"integer":d,enum:[e.value]}:{type:"bigint"===d?"integer":d,const:e.value};case $.ZodEnum:return{type:"string",enum:Array.from(e.values)};case $.ZodNativeEnum:let u,p,m;return u=e.values,{type:1===(m=Array.from(new Set((p=Object.keys(e.values).filter(e=>"number"!=typeof u[u[e]]).map(e=>u[e])).map(e=>typeof e)))).length?"string"===m[0]?"string":"number":["string","number"],enum:p};case $.ZodNullable:if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return"openApi3"===r.target?{type:uF[e.innerType._def.typeName],nullable:!0}:{type:[uF[e.innerType._def.typeName],"null"]};if("openApi3"===r.target){let t=uD(e.innerType._def,{...r,currentPath:[...r.currentPath]});return t&&"$ref"in t?{allOf:[t],nullable:!0}:t&&{...t,nullable:!0}}let h=uD(e.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","0"]});return h&&{anyOf:[h,{type:"null"}]};case $.ZodOptional:if(r.currentPath.toString()===r.propertyPath?.toString())return uD(e.innerType._def,r);let f=uD(e.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","1"]});return f?{anyOf:[{not:uS(r)},f]}:uS(r);case $.ZodMap:if("record"===r.mapStrategy)return uH(e,r);return{type:"array",maxItems:125,items:{type:"array",items:[uD(e.keyType._def,{...r,currentPath:[...r.currentPath,"items","items","0"]})||uS(r),uD(e.valueType._def,{...r,currentPath:[...r.currentPath,"items","items","1"]})||uS(r)],minItems:2,maxItems:2}};case $.ZodSet:let g;return g={type:"array",uniqueItems:!0,items:uD(e.valueType._def,{...r,currentPath:[...r.currentPath,"items"]})},e.minSize&&uR(g,"minItems",e.minSize.value,e.minSize.message,r),e.maxSize&&uR(g,"maxItems",e.maxSize.value,e.maxSize.message,r),g;case $.ZodLazy:return()=>e.getter()._def;case $.ZodPromise:return uD(e.type._def,r);case $.ZodNaN:case $.ZodNever:return"openAi"===r.target?void 0:{not:uS({...r,currentPath:[...r.currentPath,"not"]})};case $.ZodEffects:return"input"===r.effectStrategy?uD(e.schema._def,r):uS(r);case $.ZodAny:case $.ZodUnknown:return uS(r);case $.ZodDefault:return{...uD(e.innerType._def,r),default:e.defaultValue()};case $.ZodBranded:return uk(e,r);case $.ZodReadonly:case $.ZodCatch:return uD(e.innerType._def,r);case $.ZodPipeline:if("input"===r.pipeStrategy)return uD(e.in._def,r);if("output"===r.pipeStrategy)return uD(e.out._def,r);let y=uD(e.in._def,{...r,currentPath:[...r.currentPath,"allOf","0"]}),v=uD(e.out._def,{...r,currentPath:[...r.currentPath,"allOf",y?"1":"0"]});return{allOf:[y,v].filter(e=>void 0!==e)};case $.ZodFunction:case $.ZodVoid:case $.ZodSymbol:default:return}})(e,e.typeName,t),o="function"==typeof a?uD(a(),t):a;if(o&&uB(e,t,o),t.postProcess){let r=t.postProcess(o,e,t);return n.jsonSchema=o,r}return n.jsonSchema=o,o}let uJ=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:ub(t.currentPath,e.path)};case"none":case"seen":if(e.path.length<t.currentPath.length&&e.path.every((e,r)=>t.currentPath[r]===e))return console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),uS(t);return"seen"===t.$refStrategy?uS(t):void 0}},uB=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);function uW(e,t={}){let{strict:r=!1}=t,i=Object.entries(e),n=e=>({target:t})=>{let n={},a=[];for(let[r,o]of i)n[r]=function(e,t,r){let i=e["~standard"];if(i.jsonSchema)return i.jsonSchema[r]({target:t});if("zod"===e["~standard"].vendor&&!("_zod"in e)&&"_def"in e){let r=((e,t)=>{let r,i,n=(i=void 0!==(r="string"==typeof t?{...dp,name:t}:{...dp,...t}).name?[...r.basePath,r.definitionPath,r.name]:r.basePath,{...r,flags:{hasReferencedOpenAiAnyType:!1},currentPath:i,propertyPath:void 0,seen:new Map(Object.entries(r.definitions).map(([e,t])=>[t._def,{def:t._def,path:[...r.basePath,r.definitionPath,e],jsonSchema:void 0}]))}),a="object"==typeof t&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:uD(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??uS(n)}),{}):void 0,o="string"==typeof t?t:t?.nameStrategy==="title"?void 0:t?.name,s=uD(e._def,void 0===o?n:{...n,currentPath:[...n.basePath,n.definitionPath,o]},!1)??uS(n),l="object"==typeof t&&void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==l&&(s.title=l),n.flags.hasReferencedOpenAiAnyType&&(a||(a={}),a[n.openAiAnyTypeName]||(a[n.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:"relative"===n.$refStrategy?"1":[...n.basePath,n.definitionPath,n.openAiAnyTypeName].join("/")}}));let c=void 0===o?a?{...s,[n.definitionPath]:a}:s:{$ref:[..."relative"===n.$refStrategy?[]:n.basePath,n.definitionPath,o].join("/"),[n.definitionPath]:{...a,[o]:s}};return"jsonSchema7"===n.target?c.$schema="http://json-schema.org/draft-07/schema#":("jsonSchema2019-09"===n.target||"openAi"===n.target)&&(c.$schema="https://json-schema.org/draft/2019-09/schema#"),"openAi"===n.target&&("anyOf"in c||"oneOf"in c||"allOf"in c||"type"in c&&Array.isArray(c.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),c})(e,{$refStrategy:"none",target:"openapi-3.0"===t?"openApi3":"jsonSchema7"});return delete r.$schema,r}if("zod"===i.vendor&&"_zod"in e)try{let t=r5(e);return delete t.$schema,t}catch(e){throw Error(`Failed to convert a zod schema to JSON Schema (zod v4 without "~standard.jsonSchema"). Upgrade to zod >= 4.2.0. Original error: ${e instanceof Error?e.message:String(e)}`)}throw Error(`Schema library "${i.vendor}" cannot be converted to JSON Schema. Use zod v3 (>= 3.25.76), zod >= 4.2.0, or a Standard Schema library implementing "~standard.jsonSchema".`)}(o,t,e),!function(e,t){if("function"!=typeof e.safeParse)return!1;try{let r=e.safeParse(void 0);return r.success&&("input"===t||void 0===r.data)}catch{return!1}}(o,e)&&a.push(r);let o={type:"object",properties:n};return a.length>0&&(o.required=a),r&&(o.additionalProperties=!1),o},a=async t=>{if("object"!=typeof t||null===t||Array.isArray(t))return{issues:[{message:"Expected an object."}]};let n={},a=[];for(let[e,r]of i){let i=await r["~standard"].validate(t[e]);if(i.issues)for(let t of i.issues)a.push({message:t.message,path:[e,...t.path??[]]});else(e in t||void 0!==i.value)&&(n[e]=i.value)}if(r)for(let r of Object.keys(t))r in e||a.push({message:`Unrecognized key: "${r}"`,path:[r]});return a.length>0?{issues:a}:{value:n}};return{shape:e,"~standard":{version:1,vendor:"xmcp",validate:a,jsonSchema:{input:n("input"),output:n("output")}}}}let uG=(e,t)=>{globalThis[e]=t},uK=e=>globalThis[e];function uY({name:e,fallback:t=!0}){let r=Symbol.for(`xmcp-context-${e}`),i=Symbol.for(`xmcp-context-${e}-fallback-store`);if(uK(r))return uK(r);let n=new h,a=globalThis[i]??{current:null};uG(i,a);let o={provider:(e,r)=>(t&&(a.current=e),n.run(e,r)),getContext:()=>{let r=n.getStore();if(r)return r;if(t&&a.current)return a.current;throw Error(`getContext() can only be used within the ${e} context.`)},setContext:r=>{let i=n.getStore()??(t?a.current:null);if(!i)throw Error(`setContext() can only be used within the ${e} context.`);Object.assign(i,r)}};return uG(r,o),o}let uX=uY({name:"http-request-context"});uX.setContext;let uQ=uX.getContext,u0=uX.provider,u1=uY({name:"client-info-context"});u1.setContext;let u2=u1.getContext;u1.provider;let u9=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),u4=e=>{if(!u9(e)||"string"!=typeof e.name||"string"!=typeof e.version)return;let t={name:e.name,version:e.version};return"string"==typeof e.title&&(t.title=e.title),"string"==typeof e.websiteUrl&&(t.websiteUrl=e.websiteUrl),"string"==typeof e.description&&(t.description=e.description),t},u5=e=>{if(e&&"initialize"===e.method&&u9(e.params))return u4(e.params.clientInfo)},u3=(e,t)=>{let r=t.toLowerCase();for(let[t,i]of Object.entries(e)){if(t.toLowerCase()!==r)continue;let e=Array.isArray(i)?i[0]:i;if("string"!=typeof e)break;let n=e.trim();return n.length>0?n:void 0}},u6=new Set(["message","mode","requestedSchema"]),u7=new Set(["elicitationId","message","mode","url"]),u8=new Set(["properties","required","type"]),pe=new Set(["default","description","format","maxLength","minLength","title","type"]),pt=new Set(["default","description","enum","enumNames","title","type"]),pr=new Set(["default","description","title","type"]),pi=new Set(["default","description","maximum","minimum","title","type"]),pn=new Set(["date","date-time","email","uri"]);async function pa(e,t,r){let i=function(e){let t=e.mode??"form";if("url"===t)return function(e){let t;ps(e,"Elicitation request must be a plain object."),po(e,u7,"URL elicitation"),pl(e.message,"URL elicitation requires a string message."),pc(e.elicitationId,"URL elicitation requires a non-empty elicitationId."),pc(e.url,"URL elicitation requires a non-empty URL.");try{t=new URL(e.url)}catch{throw Error("URL elicitation requires a valid http or https URL.")}if("http:"!==t.protocol&&"https:"!==t.protocol)throw Error("URL elicitation requires a valid http or https URL.")}(e),e;if("form"!==t)throw Error(`Unsupported elicitation mode "${String(e.mode)}". Expected "form" or "url".`);return function(e){ps(e,"Elicitation request must be a plain object."),po(e,u6,"Form elicitation"),pl(e.message,"Form elicitation requires a string message.");let t=e.requestedSchema;if(ps(t,"Form elicitation requires a flat object schema."),po(t,u8,"Form elicitation schema"),"object"!==t.type)throw Error('Form elicitation schema must use type "object".');for(let[e,r]of(ps(t.properties,"Form elicitation schema requires a properties object."),Object.entries(t.properties)))!function(e,t){if(ps(t,`Form elicitation field "${e}" must be a plain object.`),pd(t.title,`Form elicitation field "${e}" title must be a string.`),pd(t.description,`Form elicitation field "${e}" description must be a string.`),"string"===t.type&&"enum"in t){var r,i;if(po(t,pt,`Form elicitation field "${e}"`),pp(t.enum,`Form elicitation field "${e}" enum values must be strings.`),r=t.enumNames,i=`Form elicitation field "${e}" enumNames must be strings.`,void 0!==r&&pp(r,i),void 0!==t.enumNames&&t.enumNames.length!==t.enum.length)throw Error(`Form elicitation field "${e}" enumNames length must match enum length.`);if(pd(t.default,`Form elicitation field "${e}" default must be a string.`),void 0!==t.default&&!t.enum.includes(t.default))throw Error(`Form elicitation field "${e}" default must be one of its enum values.`);return}if("string"===t.type&&!("enum"in t)){po(t,pe,`Form elicitation field "${e}"`),pu(t.minLength,`Form elicitation field "${e}" minLength must be a number.`),pu(t.maxLength,`Form elicitation field "${e}" maxLength must be a number.`),pd(t.default,`Form elicitation field "${e}" default must be a string.`);let r=t.format;if(pd(r,`Form elicitation field "${e}" format must be a string.`),void 0!==r&&!pn.has(r))throw Error(`Form elicitation field "${e}" format must be one of: ${Array.from(pn).join(", ")}.`);return}if("boolean"===t.type){if(po(t,pr,`Form elicitation field "${e}"`),void 0!==t.default&&"boolean"!=typeof t.default)throw Error(`Form elicitation field "${e}" default must be a boolean.`);return}if("number"===t.type||"integer"===t.type){po(t,pi,`Form elicitation field "${e}"`),pu(t.minimum,`Form elicitation field "${e}" minimum must be a number.`),pu(t.maximum,`Form elicitation field "${e}" maximum must be a number.`),pu(t.default,`Form elicitation field "${e}" default must be a number.`);return}throw Error(`Form elicitation field "${e}" uses unsupported type "${String(t.type)}". Supported types are string, boolean, number, integer, and string enums.`)}(e,r);if(void 0!==t.required){if(!Array.isArray(t.required)||t.required.some(e=>"string"!=typeof e))throw Error("Form elicitation schema required fields must be a string array.");for(let e of t.required)if(!(e in t.properties))throw Error(`Form elicitation schema required field "${e}" is not defined in properties.`)}}(e),{...e,mode:"form"}}(t);try{let t=await e.mcpReq.elicitInput(i,r);return{...t,content:t.content??void 0}}catch(e){if(e instanceof s$&&e.code===sC.MethodNotSupportedByProtocolVersion)throw Error("extra.elicit() is not available on protocol revision 2026-07-28: server-initiated elicitation was replaced by multi round-trip requests. Return inputRequired({ ... }) from the tool handler instead (re-exported from xmcp); the client fulfils the embedded requests and retries the tool call.");throw e}}function po(e,t,r){let i=Object.keys(e).filter(e=>!t.has(e));if(0!==i.length)throw Error(`${r} includes unsupported key(s): ${i.join(", ")}.`)}function ps(e,t){if("object"!=typeof e||null===e||Array.isArray(e))throw Error(t)}function pl(e,t){if("string"!=typeof e)throw Error(t)}function pc(e,t){if("string"!=typeof e||0===e.trim().length)throw Error(t)}function pd(e,t){if(void 0!==e&&"string"!=typeof e)throw Error(t)}function pu(e,t){if(void 0!==e&&"number"!=typeof e)throw Error(t)}function pp(e,t){if(!Array.isArray(e)||e.some(e=>"string"!=typeof e))throw Error(t)}let pm=new Set(["_meta","includeContext","maxTokens","messages","metadata","modelPreferences","stopSequences","systemPrompt","temperature"]),ph=new Set(["task","toolChoice","tools"]),pf=new Set(["text","image","audio"]);async function pg(e,t,r){let i=function(e){py(e,"Sampling request must be a plain object.");let t=Object.keys(e),r=t.filter(e=>ph.has(e));if(r.length>0)throw Error(`Sampling request key(s) not supported by xmcp yet: ${r.join(", ")}.`);let i=t.filter(e=>!pm.has(e));if(i.length>0)throw Error(`Sampling request includes unsupported key(s): ${i.join(", ")}.`);if(!Array.isArray(e.messages)||0===e.messages.length)throw Error("Sampling requires at least one message.");for(let[t,r]of e.messages.entries())!function(e,t){if(py(t,`Sampling message at index ${e} must be a plain object.`),"user"!==t.role&&"assistant"!==t.role)throw Error(`Sampling message at index ${e} requires role "user" or "assistant".`);let r=t.content;py(r,`Sampling message at index ${e} requires a content object.`);let i=r.type;if("string"!=typeof i||!pf.has(i))throw Error(`Sampling message at index ${e} uses unsupported content type "${String(i)}". Supported types are text, image, and audio.`);if("text"===i&&"string"!=typeof r.text)throw Error(`Sampling message at index ${e} requires string text content.`);if(("image"===i||"audio"===i)&&("string"!=typeof r.data||"string"!=typeof r.mimeType))throw Error(`Sampling message at index ${e} requires base64 data and a mimeType.`)}(t,r);if("number"!=typeof e.maxTokens)throw Error("Sampling requires a numeric maxTokens.");return e}(t);try{return await e.mcpReq.requestSampling(i,r)}catch(e){if(e instanceof s$&&e.code===sC.MethodNotSupportedByProtocolVersion)throw Error("extra.sample() is not available on protocol revision 2026-07-28: server-initiated sampling was replaced by multi round-trip requests. Return inputRequired({ ... }) with inputRequired.createMessage(...) from the tool handler instead (re-exported from xmcp); the client fulfils the embedded requests and retries the tool call.");throw e}}function py(e,t){if("object"!=typeof e||null===e||Array.isArray(e))throw Error(t)}let pv={text:e=>"string"!=typeof e.text?{valid:!1,error:'Text content must have a "text" property of type string'}:{valid:!0},image:e=>"string"!=typeof e.data?{valid:!1,error:'Image content must have a "data" property of type string (base64-encoded image)'}:"string"!=typeof e.mimeType?{valid:!1,error:'Image content must have a "mimeType" property of type string'}:{valid:!0},audio:e=>"string"!=typeof e.data?{valid:!1,error:'Audio content must have a "data" property of type string (base64-encoded audio)'}:"string"!=typeof e.mimeType?{valid:!1,error:'Audio content must have a "mimeType" property of type string'}:{valid:!0},resource_link:e=>"string"!=typeof e.name?{valid:!1,error:'Resource link content must have a "name" property of type string'}:"string"!=typeof e.uri?{valid:!1,error:'Resource link content must have a "uri" property of type string'}:void 0!==e.title&&"string"!=typeof e.title?{valid:!1,error:'Resource link "title" property must be a string if provided'}:void 0!==e.description&&"string"!=typeof e.description?{valid:!1,error:'Resource link "description" property must be a string if provided'}:void 0!==e.mimeType&&"string"!=typeof e.mimeType?{valid:!1,error:'Resource link "mimeType" property must be a string if provided'}:{valid:!0}};function p_(e){if(!e||"object"!=typeof e)return{valid:!1,error:"Content must be an object"};if("string"!=typeof e.type)return{valid:!1,error:'Content must have a "type" property of type string'};if(void 0!==e._meta&&(null===e._meta||"object"!=typeof e._meta))return{valid:!1,error:'Content "_meta" property must be an object if provided'};let t=pv[e.type];return t?t(e):{valid:!0}}function pb(e,t,r,i){if(null===e||"object"!=typeof e||Array.isArray(e))throw Error(`Tool "${r}" ${i}: expected a plain object.`);let n=new Set(Object.keys(t)),a=Object.keys(e).filter(e=>!n.has(e));if(a.length>0)throw Error(`Tool "${r}" ${i}: unrecognized key(s): ${a.join(", ")}`);for(let[n,a]of Object.entries(t))try{a.parse(e[n])}catch(e){throw Error(`Tool "${r}" ${i}: ${e?.message??`invalid field "${n}"`}`)}}function pS(e){return!!(e&&"object"==typeof e&&Object.keys(e).some(e=>e.startsWith("ui/")))}function pw(e){let t=e.mcpReq.envelope,r=u4(t?.[nP]);if(!r)try{let e,t=uQ();r=t.clientInfo??(e=t.headers,u4({name:u3(e,"x-mcp-client-name"),version:u3(e,"x-mcp-client-version"),title:u3(e,"x-mcp-client-title"),websiteUrl:u3(e,"x-mcp-client-website-url"),description:u3(e,"x-mcp-client-description")}))}catch{}if(!r)try{r=u2().clientInfo}catch{}return r}function pR(e){return e.endsWith(".tsx")}let pk=new class{add(e,t){this.resources.set(e,t)}getAll(){return this.resources}clear(){this.resources.clear()}has(e){return this.resources.has(e)}constructor(){var e,t;e="resources",t=new Map,e in this?Object.defineProperty(this,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):this[e]=t}};function px(e){let t={};return!function e(r,i=""){if(r&&"object"==typeof r)for(let[n,a]of Object.entries(r)){let r=i?`${i}/${n}`:n;!a||"object"!=typeof a||Array.isArray(a)||a instanceof Date||a instanceof RegExp?t[r]=a:e(a,r)}}(e),t}let pC=["ui/resourceUri","resourceUri","visibility"],p$=["prefersBorder","domain","csp","permissions","connectDomains","resourceDomains","frameDomains","baseUriDomains"],pT=uY({name:"request-context",fallback:!1});function pE(e){let t=[...e];return(e,r,i)=>(function(e,t,r){let i,n=new Map;if(e.http){let e=uQ(),t=Object.fromEntries(Object.entries(e.headers).map(([e,t])=>[e,Array.isArray(t)?Object.freeze([...t]):t]));i=Object.freeze({id:e.id,headers:Object.freeze(t)})}return pT.provider(Object.freeze({clientInfo:t?Object.freeze({...t}):void 0,http:i,signal:e.mcpReq.signal,set(e,t){n.set(e,t)},get:e=>n.get(e),async progress(t,r){let i=e.mcpReq._meta?.progressToken;void 0!==i&&await e.mcpReq.notify({method:"notifications/progress",params:{progressToken:i,progress:t,...void 0===r?{}:{total:r}}})},log:(t,r)=>e.mcpReq.log(t,r)}),r)})(r,pw(r),async()=>{if(0===t.length)return i();let r=Object.freeze({...function(){try{return pT.getContext()}catch{throw Error("getRequestContext() can only be used while handling an MCP request.")}}(),method:e.method,params:Object.freeze({...e.params})}),n=-1,a=async e=>{if(e<=n)throw Error("MCP middleware next() can only be called once");n=e;let o=t[e];return o?o(r,()=>a(e+1)):i()};return a(0)})}let pP=new Set(["tools/list","prompts/get","prompts/list","resources/read","resources/list","resources/templates/list","completion/complete"]);function pI(e){let{tags:t,enabled:r,...i}=e;return{...i,_meta:void 0===t?i._meta:{...i._meta,"xmcp/tags":t}}}function pq(e){return"object"==typeof e&&null!==e&&Object.entries(e).every(([e,t])=>"string"==typeof e&&"object"==typeof t&&null!==t&&"parse"in t&&"function"==typeof t.parse)}function pO(e){return(e.split("/").pop()||e).replace(/\.[^/.]+$/,"")}function pj(e){let t=e.split("/").filter(e=>""!==e),r=t.findIndex(e=>e.match(/^\(.+\)$/));if(-1===r)return null;let i=t[t.length-1];if(i&&i.match(/^\[.+\]\.ts$/))return null;let n=t[r].slice(1,-1),a=t.slice(r+1),o=a[a.length-1];if(o&&o.includes(".")){let e=o.split(".")[0];"index"!==e?a[a.length-1]=e:a.pop()}let s=[],l=[],c=a.map(e=>{if(!e.match(/^\[.+\]$/))return l.push(e),e;{let t=e.slice(1,-1);return s.push(t),`{${t}}`}}),d=`${n}://${c.join("/")}`,u=s.length>0?"template":"direct";return{filePath:e,uriTemplate:d,scheme:n,parameters:s,pathSegments:l,type:u}}function pz(e){let t=e.replace(/\\/g,"/");if(!t)throw Error("Invalid tool path: path is empty");let r=t.replace(/\.[^/.]+$/,"").replace(/\//g,"_");return{normalizedPath:t,baseName:r}}function pL(e){return Error(`[xmcp] Invalid prompt file: ${e}
|
|
85
|
+
-> Default export must be a prompt handler function.`)}async function pN(e){let t=new Map,r=[];for(let i of(await Promise.all(Object.entries(e).map(async([e,t])=>{let r=await t(),i=function(e,t){if("object"!=typeof e||null===e)throw pL(t);let r=Object.keys(e),i=e.default,n=r.filter(e=>"__esModule"!==e);if(0===r.length||1===n.length&&"default"===n[0]&&"object"==typeof i&&null!==i&&0===Object.keys(i).length)return"empty";if(!("default"in e)||void 0===e.default)return"missing-default";if("function"!=typeof e.default)throw pL(t);return"valid"}(r,e);return"empty"===i?{skipped:!0,issue:{path:e,message:"File is empty."}}:"missing-default"===i?{skipped:!0,issue:{path:e,message:"File does not export a default prompt handler."}}:{skipped:!1,path:e,promptModule:r}})))){if(i.skipped){r.push(i.issue);continue}t.set(i.path,i.promptModule)}return{promptModules:t,skippedPrompts:r}}let pA=function(e=console){let t="";return r=>{let i=r.map(({path:e,message:t})=>`${e}:${t}`).sort().join("|");if(i===t||(t=i,0===r.length))return;r.forEach(({path:t,message:r})=>{e.warn(`[xmcp] Failed to load prompt file: ${t}
|
|
86
|
+
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} prompt${1===n?"":"s"} skipped due to empty files or missing default exports`)}}();function pM(e){return Error(`[xmcp] Invalid resource file: ${e}
|
|
87
|
+
-> Default export must be a resource handler function.`)}async function pZ(e){let t=new Map,r=[];for(let i of(await Promise.all(Object.entries(e).map(async([e,t])=>{let r=await t(),i=function(e,t){if("object"!=typeof e||null===e)throw pM(t);let r=Object.keys(e),i=e.default,n=r.filter(e=>"__esModule"!==e);if(0===r.length||1===n.length&&"default"===n[0]&&"object"==typeof i&&null!==i&&0===Object.keys(i).length)return"empty";if(!("default"in e)||void 0===e.default)return"missing-default";if("function"!=typeof e.default)throw pM(t);return"valid"}(r,e);return"empty"===i?{skipped:!0,issue:{path:e,message:"File is empty."}}:"missing-default"===i?{skipped:!0,issue:{path:e,message:"File does not export a default resource handler."}}:{skipped:!1,path:e,resourceModule:r}})))){if(i.skipped){r.push(i.issue);continue}t.set(i.path,i.resourceModule)}return{resourceModules:t,skippedResources:r}}let pU=function(e=console){let t="";return r=>{let i=r.map(({path:e,message:t})=>`${e}:${t}`).sort().join("|");if(i===t||(t=i,0===r.length))return;r.forEach(({path:t,message:r})=>{e.warn(`[xmcp] Failed to load resource file: ${t}
|
|
88
|
+
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} resource${1===n?"":"s"} skipped due to empty files or missing default exports`)}}();function pH(e){return Error(`[xmcp] Invalid tool file: ${e}
|
|
89
|
+
-> Default export must be a tool handler function.`)}async function pF(e){let t=new Map,r=[];for(let i of(await Promise.all(Object.entries(e).map(async([e,t])=>{let r=await t(),i=function(e,t){if("object"!=typeof e||null===e)throw pH(t);let r=Object.keys(e),i=e.default,n=r.filter(e=>"__esModule"!==e);if(0===r.length||1===n.length&&"default"===n[0]&&"object"==typeof i&&null!==i&&0===Object.keys(i).length)return"empty";if(!("default"in e)||void 0===e.default)return"missing-default";if("function"!=typeof e.default)throw pH(t);return"valid"}(r,e);return"empty"===i?{skipped:!0,issue:{path:e,message:"File is empty."}}:"missing-default"===i?{skipped:!0,issue:{path:e,message:"File does not export a default tool handler."}}:{skipped:!1,path:e,toolModule:r}})))){if(i.skipped){r.push(i.issue);continue}t.set(i.path,i.toolModule)}return{toolModules:t,skippedTools:r}}let pV=function(e=console){let t="";return r=>{let i=r.map(({path:e,message:t})=>`${e}:${t}`).sort().join("|");if(i===t||(t=i,0===r.length))return;r.forEach(({path:t,message:r})=>{e.warn(`[xmcp] Failed to load tool file: ${t}
|
|
90
|
+
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} tool${1===n?"":"s"} skipped due to empty files or missing default exports`)}}(),pD=INJECTED_TOOLS,pJ=INJECTED_PROMPTS,pB=INJECTED_RESOURCES,pW=SERVER_INFO;async function pG(e,t,r,i){let n=await INJECTED_MIDDLEWARE?.(),a=function(e){if(void 0===e)return[];let t=Array.isArray(e)?[...e]:[e];if(!t.every(e=>"function"==typeof e))throw Error("src/middleware.ts must export mcp as a function or an array of functions");return t}(n?.mcp);return pk.clear(),!function(e,t,r){let i=e.server,n=i.setRequestHandler,a=pE(t);i.setRequestHandler=(e,...t)=>{if(pP.has(e)&&1===t.length&&"function"==typeof t[0]){let e=t[0];t[0]=(t,r)=>a({method:t.method,params:t.params??{}},r,()=>e(t,r))}Reflect.apply(n,i,[e,...t])};try{r()}finally{i.setRequestHandler=n}}(e,a,()=>{!function(e,t,r=[]){t.forEach((t,i)=>{var n,a;let o,s,l,c={name:pO(i),description:"No description provided"},{default:d,metadata:u,schema:p,outputSchema:m}=t;if("object"==typeof u&&null!==u&&Object.assign(c,u),!1===c.enabled)return;if("function"==typeof d&&"__x402"in d){let e=P.g.__XMCP_X402_REGISTRY;e&&e.set(c.name,d.__x402)}let h={};if(pq(p)?h=p:null!=p&&console.warn(`Invalid schema for tool "${c.name}" at ${i}. Expected Record<string, z.ZodType>`),null!=m)if(pq(m))o=m;else throw Error(`Invalid outputSchema for tool "${c.name}" at ${i}. Expected Record<string, z.ZodType>`);c.annotations={...c.annotations??{}},void 0===c.annotations.title&&(c.annotations.title=c.name),c._meta={...pI(c)._meta};let f=pR(i),g=!!(n=c._meta)&&"object"==typeof n&&"ui"in n&&"object"==typeof n.ui||f,y=c._meta;if(g){let e=`ui://app/${c.name}.html`;c._meta.ui||(c._meta.ui={}),c._meta.ui.resourceUri||(c._meta.ui.resourceUri=e);let t=function(e){let t={},r={};if(e.ui&&"object"==typeof e.ui){let i=e.ui,n={},a={};for(let[e,t]of Object.entries(i))pC.includes(e)?n[e]=t:p$.includes(e)?a[e]=t:n[e]=t;Object.keys(n).length>0&&(t.ui=n),Object.keys(a).length>0&&(r.ui=a)}for(let[r,i]of Object.entries(e))"ui"!==r&&(t[r]=i);return{toolMeta:t,resourceMeta:r}}(y);y=t.toolMeta;let r=t.resourceMeta;r.ui=r.ui||{},r.ui.csp=r.ui.csp||{},r.ui.csp.resourceDomains=r.ui.csp.resourceDomains||[],r.ui.csp.resourceDomains.includes("https://esm.sh")||r.ui.csp.resourceDomains.push("https://esm.sh"),pk.add(c.name,{name:c.name,uri:e,handler:d,mimeType:"text/html;profile=mcp-app",_meta:r,toolPath:f?i:void 0})}let v=px(y),_=g?v:void 0;s=pR(i)&&g?async(e,t)=>({content:[{type:"text",text:""}],_meta:_,structuredContent:{args:e}}):function(e,t,r,i="unknown-tool"){return async(n,a)=>{let o,s,l=e(n,(o=pw(a),s=function(e){if(!e)return;let t={};return e.headers.forEach((e,r)=>{t[r]=e}),t}(a.http?.req),{signal:a.mcpReq.signal,authInfo:a.http?.authInfo,sessionId:a.sessionId,_meta:a.mcpReq._meta,requestId:a.mcpReq.id,requestInfo:s?{headers:s}:void 0,clientInfo:o,sendNotification:e=>a.mcpReq.notify(e),sendRequest:(e,t,r)=>a.mcpReq.send(e,t,r),elicit:(e,t)=>pa(a,e,t),sample:(e,t)=>pg(a,e,t),inputResponses:a.mcpReq.inputResponses,requestState:a.mcpReq.requestState}));if(l instanceof Promise&&(l=await l),lO(l))return l;if("string"==typeof l||"number"==typeof l){if(r){let e=Object.entries(r);if(1===e.length){let[t,r]=e[0];try{return r.parse(l),{content:[{type:"text",text:"number"==typeof l?`${l}`:l}],structuredContent:{[t]:l}}}catch{}}}return pS(t)?{content:[{type:"text",text:""}],structuredContent:{args:n},_meta:t}:{content:[{type:"text",text:"number"==typeof l?`${l}`:l}]}}if(!r||!l||"object"!=typeof l||Array.isArray(l)||"structuredContent"in l||"content"in l&&Array.isArray(l.content)||"_meta"in l||"isError"in l||(pb(l,r,i,"returned data that does not match outputSchema"),l={structuredContent:l}),l&&"object"==typeof l&&"_meta"in l&&!("content"in l)&&!("structuredContent"in l)){let e=l._meta;if(pS(e))return{content:[{type:"text",text:""}],_meta:e}}if(!l||"object"!=typeof l){let e=null===l?"null":typeof l,t=void 0===l?"undefined":null===l?"null":"object"==typeof l?JSON.stringify(l,null,2):String(l);throw Error(`Tool handler must return a CallToolResult, string, or number. Got ${e}: ${t}
|
|
91
91
|
|
|
92
92
|
Expected CallToolResult format:
|
|
93
93
|
{
|
|
@@ -154,7 +154,7 @@ Expected format:
|
|
|
154
154
|
key: "value",
|
|
155
155
|
nested: { data: "here" }
|
|
156
156
|
}
|
|
157
|
-
}`)}}return l}}(d,_,o,c.name);let b={title:c.annotations?.title,description:c.description,inputSchema:uW(h),outputSchema:o?uW(o,{strict:!0}):void 0,annotations:c.annotations,_meta:v};e.registerTool(c.name,b,(a=c.name,l=pE(r),(e,t)=>l({method:"tools/call",params:{name:a,arguments:e}},t,()=>s(e,t))))})}(e,t,a),r.forEach((t,r)=>{let i=
|
|
157
|
+
}`)}}return l}}(d,_,o,c.name);let b={title:c.annotations?.title,description:c.description,inputSchema:uW(h),outputSchema:o?uW(o,{strict:!0}):void 0,annotations:c.annotations,icons:c.icons,_meta:v};e.registerTool(c.name,b,(a=c.name,l=pE(r),(e,t)=>l({method:"tools/call",params:{name:a,arguments:e}},t,()=>s(e,t))))})}(e,t,a),r.forEach((t,r)=>{let i=pO(r),n={name:i,title:i,description:"No description provided"},a={},{default:o,metadata:s,schema:l}=t;if("object"==typeof s&&null!==s&&Object.assign(n,s),!1===n.enabled)return;let c=function(e,t="assistant"){return async(r,i)=>{let n,a=e(r,i);if(a instanceof Promise&&(a=await a),Array.isArray(a)||null!==a&&"object"==typeof a&&"messages"in a){let e=Array.isArray(a)?{messages:a}:a,t=await ca.GetPromptResult["~standard"].validate(e);if(t.issues){let e=t.issues.map(e=>{let t=e.path?.map(e=>"object"==typeof e?e.key:e).join(".");return`${t||"result"}: ${e.message}`});throw Error(`Invalid prompt result: ${e.join("; ")}`)}return e}if("string"==typeof a||"number"==typeof a)n={type:"text",text:"number"==typeof a?`${a}`:a};else{let e=p_(a);if(e.valid)n=a;else{let t=null===a?"null":typeof a,r=void 0===a?"undefined":null===a?"null":"object"==typeof a?JSON.stringify(a,null,2):String(a);throw Error(`Prompt handler must return a PromptContent object, string, number, PromptMessage[], or GetPromptResult. Got ${t}: ${r}
|
|
158
158
|
|
|
159
159
|
Validation error: ${e.error}
|
|
160
160
|
|
|
@@ -167,7 +167,7 @@ Expected formats:
|
|
|
167
167
|
- Image content: { type: "image", data: "base64data", mimeType: "image/jpeg" }
|
|
168
168
|
- Audio content: { type: "audio", data: "base64data", mimeType: "audio/mpeg" }
|
|
169
169
|
- Resource link: { type: "resource_link", name: "resource name", uri: "resource://uri" }
|
|
170
|
-
- All content types support an optional "_meta" object property`)}}if("user"!==t&&"assistant"!==t)throw Error(`Invalid role: ${t}`);return{messages:[{role:t,content:n}]}}}(o,n.role||"assistant");
|
|
170
|
+
- All content types support an optional "_meta" object property`)}}if("user"!==t&&"assistant"!==t)throw Error(`Invalid role: ${t}`);return{messages:[{role:t,content:n}]}}}(o,n.role||"assistant");pq(l)?Object.assign(a,l):null!=l&&console.warn(`Invalid schema for prompt "${n.name}" at ${r}. Expected Record<string, z.ZodType>`),e.registerPrompt(n.name,{title:n.title,description:n.description,icons:n.icons,_meta:pI(n)._meta,argsSchema:uW(a)},c)}),[...pk.getAll()].forEach(([t,r])=>{let i=r.mimeType||"text/html;profile=mcp-app",n=r?._meta?px(r._meta):void 0,a={name:r.name,description:`Auto-generated resource for ${r.name} tool`,mimeType:r.mimeType,_meta:n},o=async(e,t)=>{if(r.mimeType&&r.toolPath)try{var n;let e,t,a=(n=r.toolPath,IS_CLOUDFLARE?function(e){let{normalizedPath:t,baseName:r}=pz(e),i=5381;for(let e=0;e<t.length;e++)i=Math.imul(i,33)+t.charCodeAt(e)>>>0;let n=i.toString(16).slice(0,6).padStart(6,"0");return`${r}_${n}`}(n):function(e){let{normalizedPath:t,baseName:r}=pz(e),i=P(Object(function(){var e=Error("Cannot find module 'crypto'");throw e.code="MODULE_NOT_FOUND",e}())).createHash("md5").update(t).digest("hex").slice(0,6);return`${r}_${i}`}(n)),o=function(e){if(INJECTED_CLIENT_BUNDLES)return INJECTED_CLIENT_BUNDLES[e]||null;if(!IS_CLOUDFLARE)try{let t=P(Object(function(){var e=Error("Cannot find module 'fs'");throw e.code="MODULE_NOT_FOUND",e}())),r=P(Object(function(){var e=Error("Cannot find module 'path'");throw e.code="MODULE_NOT_FOUND",e}()));for(let i of[r.join(process.cwd(),"dist","client"),r.join(process.cwd(),"client")]){let n=r.join(i,`${e}.bundle.js`),a=r.join(i,`${e}.bundle.css`);if(t.existsSync(n)){let e,r=t.readFileSync(n,"utf-8");return t.existsSync(a)&&(e=t.readFileSync(a,"utf-8")),{js:r,css:e}}}}catch{}return null}(a);if(!o)throw Error(`React client bundle not found for "${r.name}" (bundle: "${a}").
|
|
171
171
|
React tool bundles are generated automatically when you run "xmcp build" (or "xmcp dev").
|
|
172
172
|
Please re-run the build so the framework can regenerate the bundle.`);let s=o.js,l=o.css,c=(e=`
|
|
173
173
|
<script type="module">
|
|
@@ -222,7 +222,7 @@ Please re-run the build so the framework can regenerate the bundle.`);let s=o.js
|
|
|
222
222
|
<div id="root"></div>
|
|
223
223
|
${e}
|
|
224
224
|
</body>
|
|
225
|
-
</html>`);return{contents:[{uri:r.uri,text:c,mimeType:i,_meta:r._meta}]}}catch(e){throw console.error(`React failed for ${r.name}:`,e),e}let a=r.handler({},t);if(a instanceof Promise&&(a=await a),"string"==typeof a)return{contents:[{uri:r.uri,text:a,mimeType:i,_meta:r._meta}]};if(a&&"object"==typeof a&&"_meta"in a&&!("content"in a))return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]};if(a&&"object"==typeof a&&"content"in a&&Array.isArray(a.content)){let e=a.content.find(e=>"text"===e.type);if(e&&"text"===e.type&&"string"==typeof e.text)return{contents:[{uri:r.uri,text:e.text,mimeType:i,_meta:r._meta}]}}return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]}};e.registerResource(r.name,r.uri,a,o)}),i.forEach((t,r)=>{let i={name:
|
|
225
|
+
</html>`);return{contents:[{uri:r.uri,text:c,mimeType:i,_meta:r._meta}]}}catch(e){throw console.error(`React failed for ${r.name}:`,e),e}let a=r.handler({},t);if(a instanceof Promise&&(a=await a),"string"==typeof a)return{contents:[{uri:r.uri,text:a,mimeType:i,_meta:r._meta}]};if(a&&"object"==typeof a&&"_meta"in a&&!("content"in a))return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]};if(a&&"object"==typeof a&&"content"in a&&Array.isArray(a.content)){let e=a.content.find(e=>"text"===e.type);if(e&&"text"===e.type&&"string"==typeof e.text)return{contents:[{uri:r.uri,text:e.text,mimeType:i,_meta:r._meta}]}}return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]}};e.registerResource(r.name,r.uri,a,o)}),i.forEach((t,r)=>{let i={name:pO(r),description:"No description provided"},{default:n,metadata:a,schema:o,complete:s}=t;if("object"==typeof a&&null!==a&&Object.assign(i,a),!1===i.enabled)return;let l={};pq(o)?l=o:null!=o&&console.warn(`Invalid schema for resource "${i.name}" at ${r}. Expected Record<string, z.ZodType>`);let c=pj(r);if(!c)return void console.warn(`Skipping resource "${i.name}" at ${r}: Invalid file path format`);let d=c.uriTemplate;i.mimeType&&i.mimeType.includes("html")&&(d=d.endsWith(".html")?d:`${d}.html`);let u=function(e,t,r={}){let i=pj(t);if(!i)throw Error(`Invalid resource file path: ${t}. Must follow (scheme)/path/[param] convention.`);return async(t,n)=>{let a=e(function(e,t,r){let i={},n={};if(0===t.parameters.length)return n;let a=t.uriTemplate.split("://")[1]||"",o=e.split("://")[1]||"",s=a.split("/"),l=o.split("/");for(let e=0;e<s.length&&e<l.length;e++){let t=s[e],r=l[e],n=t.match(/^\{(.+)\}$/);n&&(i[n[1]]=r)}for(let e of t.parameters){let t=i[e],a=r[e];if(void 0===t)throw Error(`Missing required parameter: ${e}`);if(!a){n[e]=t;continue}try{n[e]=a.parse(t)}catch(r){throw Error(`Invalid parameter "${e}": ${t}. Validation error: ${r instanceof Error?r.message:String(r)}`)}}return n}(t.href,i,r),n);if(a instanceof Promise&&(a=await a),"string"==typeof a)return{contents:[{uri:t.href,text:a}]};if(!a||"object"!=typeof a||!Array.isArray(a.contents)){let e=null===a?"null":typeof a,t=void 0===a?"undefined":null===a?"null":"object"==typeof a?JSON.stringify(a,null,2):String(a);throw Error(`Resource handler must return a ReadResourceResult or string. Got ${e}: ${t}
|
|
226
226
|
|
|
227
227
|
Expected ReadResourceResult format:
|
|
228
228
|
{
|
|
@@ -231,7 +231,7 @@ Expected ReadResourceResult format:
|
|
|
231
231
|
{ uri: "resource://uri", mimeType: "application/json", text: "json content" },
|
|
232
232
|
{ uri: "resource://uri", blob: base64data }
|
|
233
233
|
]
|
|
234
|
-
}`)}return a.contents.forEach(e=>{e.uri||(e.uri=t.href)}),a}}(n,r,l);if("direct"===c.type)e.registerResource(i.name,d,i,u);else{let t=Object.create(null);for(let e of c.parameters)s&&Object.hasOwn(s,e)&&(t[e]=s[e]);let r=new c2(d,{list:void 0,complete:t}),a=async(e,t,r)=>{let i={};for(let e of c.parameters){let r=t[e],n=l[e];if(void 0===r)throw Error(`Missing required parameter: ${e}. Available variables: ${Object.keys(t)}`);n?i[e]=n.parse(r):i[e]=r}let a=n(i,r);return a instanceof Promise&&(a=await a),"string"==typeof a?{contents:[{uri:e.href,text:a}]}:a};e.registerResource(i.name,r,i,a)}})}),e}async function
|
|
234
|
+
}`)}return a.contents.forEach(e=>{e.uri||(e.uri=t.href)}),a}}(n,r,l);if("direct"===c.type)e.registerResource(i.name,d,pI(i),u);else{let t=Object.create(null);for(let e of c.parameters)s&&Object.hasOwn(s,e)&&(t[e]=s[e]);let r=new c2(d,{list:void 0,complete:t}),a=async(e,t,r)=>{let i={};for(let e of c.parameters){let r=t[e],n=l[e];if(void 0===r)throw Error(`Missing required parameter: ${e}. Available variables: ${Object.keys(t)}`);n?i[e]=n.parse(r):i[e]=r}let a=n(i,r);return a instanceof Promise&&(a=await a),"string"==typeof a?{contents:[{uri:e.href,text:a}]}:a};e.registerResource(i.name,r,pI(i),a)}})}),e}async function pK(){let{toolModules:e,skippedTools:t}=await pF(pD);return pV(t),e}async function pY(){let{promptModules:e,skippedPrompts:t}=await pN(pJ);return pA(t),e}async function pX(){let{resourceModules:e,skippedResources:t}=await pZ(pB);return pU(t),e}async function pQ(){let{instructions:e,...t}=pW,r=new c1(t,{instructions:e}),i=pK(),n=pY(),a=pX(),[o,s,l]=await Promise.all([i,n,a]);return pG(r,o,s,l)}let p0="This MCP server was bootstrapped with xmcp.",p1={cursor:`
|
|
235
235
|
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
236
236
|
<g clip-path="url(#cursor)">
|
|
237
237
|
<path d="M18.1937 4.73376L10.1872 0.111231C9.93007 -0.0372398 9.61283 -0.0372398 9.35573 0.111231L1.34956 4.73376C1.13344 4.85855 1 5.08934 1 5.33929V14.6606C1 14.9106 1.13344 15.1414 1.34956 15.2662L9.3561 19.8887C9.6132 20.0372 9.93044 20.0372 10.1875 19.8887L18.1941 15.2662C18.4102 15.1414 18.5436 14.9106 18.5436 14.6606V5.33929C18.5436 5.08934 18.4102 4.85855 18.1941 4.73376H18.1937ZM17.6908 5.71291L9.96164 19.1001C9.90939 19.1903 9.77145 19.1535 9.77145 19.049V10.2832C9.77145 10.108 9.67785 9.94603 9.526 9.85808L1.9348 5.47536C1.84459 5.42311 1.88143 5.28517 1.98592 5.28517H17.4442C17.6637 5.28517 17.8009 5.5231 17.6912 5.71329H17.6908V5.71291Z" fill="currentColor" />
|
|
@@ -286,7 +286,7 @@ Expected ReadResourceResult format:
|
|
|
286
286
|
</clipPath>
|
|
287
287
|
</defs>
|
|
288
288
|
</svg>
|
|
289
|
-
`},
|
|
289
|
+
`},p2=String.raw`
|
|
290
290
|
:root {
|
|
291
291
|
color-scheme: dark;
|
|
292
292
|
--brand-white: #f7f7f7;
|
|
@@ -585,13 +585,13 @@ Expected ReadResourceResult format:
|
|
|
585
585
|
clip: rect(0, 0, 0, 0);
|
|
586
586
|
border: 0;
|
|
587
587
|
}
|
|
588
|
-
`;function
|
|
588
|
+
`;function p9(e,t){let r={};if(void 0!==e.origin){if(!0===e.origin)t&&(r["Access-Control-Allow-Origin"]=t);else if(!1!==e.origin)if(Array.isArray(e.origin)){let i=t&&e.origin.includes(t)?t:e.origin[0]||"*";r["Access-Control-Allow-Origin"]=i}else r["Access-Control-Allow-Origin"]=String(e.origin)}return void 0!==e.methods&&(r["Access-Control-Allow-Methods"]=Array.isArray(e.methods)?e.methods.join(","):String(e.methods)),void 0!==e.allowedHeaders&&(r["Access-Control-Allow-Headers"]=Array.isArray(e.allowedHeaders)?e.allowedHeaders.join(","):String(e.allowedHeaders)),void 0!==e.exposedHeaders&&(r["Access-Control-Expose-Headers"]=Array.isArray(e.exposedHeaders)?e.exposedHeaders.join(","):String(e.exposedHeaders)),"boolean"==typeof e.credentials&&(r["Access-Control-Allow-Credentials"]=String(e.credentials)),"number"==typeof e.maxAge&&(r["Access-Control-Max-Age"]=String(e.maxAge)),r}let p4=HTTP_CORS_CONFIG;function p5(e,t){let r=new Headers(e.headers);for(let[e,i]of Object.entries(p9(p4,t)))r.set(e,i);return new Response(e.body,{status:e.status,statusText:e.statusText,headers:r})}let p3=HTTP_CONFIG,p6=TEMPLATE_CONFIG,p7=INJECTED_MIDDLEWARE,p8=null;async function me(){return p7?(p8||(p8=(async()=>{try{var e;let t=await p7();return e=t?.default,Array.isArray(e)?e.filter(mt):mt(e)?[e]:e&&"object"==typeof e&&"middleware"in e&&"function"==typeof e.middleware?[e.middleware]:[]}catch(e){return console.error("[Cloudflare-MCP] Failed to load middleware:",e),[]}})()),p8):[]}function mt(e){return"function"==typeof e}async function mr(e){let t=await me();if(0===t.length)return{};let r={auth:void 0,setAuth:e=>{r.auth=e}};for(let i of t){let t=await i(e,r);if(t instanceof Response)return{response:t,authInfo:r.auth}}return{authInfo:r.auth}}function mi(e,...t){p3.debug&&console.log(`[Cloudflare-MCP] ${e}`,...t)}cw();let mn=function(e,t={}){var r;let{legacy:i,onerror:n,responseMode:c}=t;if("function"==typeof i)throw TypeError("The 'legacy' option only accepts 'stateless' or 'reject', not a handler function. To serve 2025-era traffic with your own handler, route in user land with the exported isLegacyRequest(request) predicate in front of a strict (legacy: 'reject') handler.");let d=new Set,u=!1,p=e=>{try{n?.(e)}catch{}},m=t.bus??new cB(p),h={toolsChanged:()=>m.publish({kind:"tools_list_changed"}),promptsChanged:()=>m.publish({kind:"prompts_list_changed"}),resourcesChanged:()=>m.publish({kind:"resources_list_changed"}),resourceUpdated:e=>m.publish({kind:"resource_updated",uri:e})},f=function(e){let{bus:t,onerror:r}=e,i=e.maxSubscriptions??1024,n=e.keepAliveMs??15e3,a=new Set;return{serve:function(e,o,s,l){var c,d,u;let p,m,h,f,g,y,v;if(a.size>=i)return r?.(Error(`subscriptions/listen refused: subscription limit reached (${i})`)),cW(e.id,-32603,"Subscription limit reached");let _=(c=e,(g=lv(ly).validateRequest("subscriptions/listen",c)).ok?g.value.params?.notifications:void 0);if(void 0===_)return cW(e.id,-32602,"Invalid params: 'notifications' is required and must be a valid SubscriptionFilter");let b=(d=_,u=s,y={},v=e=>void 0===u||!0===e,!0===d.toolsListChanged&&v(u?.tools?.listChanged)&&(y.toolsListChanged=!0),!0===d.promptsListChanged&&v(u?.prompts?.listChanged)&&(y.promptsListChanged=!0),!0===d.resourcesListChanged&&v(u?.resources?.listChanged)&&(y.resourcesListChanged=!0),void 0!==d.resourceSubscriptions&&d.resourceSubscriptions.length>0&&v(u?.resources?.subscribe)&&(y.resourceSubscriptions=[...d.resourceSubscriptions]),y),S=e.id,w=new TextEncoder,R=!1,k=e=>{if(!R)try{p.enqueue(w.encode(e))}catch(e){r?.(e instanceof Error?e:Error(String(e)))}},x=(e,t)=>{k(`event: message
|
|
589
589
|
data: ${JSON.stringify({jsonrpc:"2.0",method:e,params:t})}
|
|
590
590
|
|
|
591
591
|
`)},C=e=>{if(!R){e&&k(`event: message
|
|
592
592
|
data: ${JSON.stringify({jsonrpc:"2.0",id:S,result:{resultType:"complete",_meta:{[nO]:S,[nI]:l}}})}
|
|
593
593
|
|
|
594
|
-
`),R=!0;try{m?.()}catch(e){r?.(e instanceof Error?e:Error(String(e)))}void 0!==h&&clearInterval(h),f?.(),a.delete(C);try{p.close()}catch{}}},$=new ReadableStream({start(e){p=e;let r=cG({method:"notifications/subscriptions/acknowledged",params:{notifications:b}},S);x(r.method,r.params),m=t.subscribe(e=>{if(R||!function(e,t){switch(t.kind){case"tools_list_changed":return!0===e.toolsListChanged;case"prompts_list_changed":return!0===e.promptsListChanged;case"resources_list_changed":return!0===e.resourcesListChanged;case"resource_updated":return void 0!==e.resourceSubscriptions&&e.resourceSubscriptions.includes(t.uri)}}(b,e))return;let t=cG(function(e){switch(e.kind){case"tools_list_changed":return{method:"notifications/tools/list_changed"};case"prompts_list_changed":return{method:"notifications/prompts/list_changed"};case"resources_list_changed":return{method:"notifications/resources/list_changed"};case"resource_updated":return{method:"notifications/resources/updated",params:{uri:e.uri}}}}(e),S);x(t.method,t.params)}),h=cJ(n,()=>k(": keepalive\n\n")),a.add(C)},cancel(){C(!1)}});if(void 0!==o)if(o.aborted)C(!1);else{let e=()=>C(!1);o.addEventListener("abort",e,{once:!0}),f=()=>o.removeEventListener("abort",e)}return new Response($,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}})},closeAll(){for(let e of a)e(!0)},get openCount(){return a.size}}}({bus:m,maxSubscriptions:t.maxSubscriptions??1024,keepAliveMs:t.keepAliveMs??15e3,onerror:p});"json"===c&&console.warn("responseMode: 'json' drops mid-call notifications. subscriptions/listen streams are always served over SSE regardless; other notifications emitted before a result are dropped.");let g="reject"===i?void 0:(r=t.keepAliveMs,async(t,i)=>{if("POST"!==t.method.toUpperCase())return da(405,-32e3,"Method not allowed.");try{let n=await e({era:"legacy",...i?.authInfo!==void 0&&{authInfo:i.authInfo},requestInfo:t}),a=new di({sessionIdGenerator:void 0,...void 0!==r&&{keepAliveMs:r}});await n.connect(a);let o=()=>{a.close().catch(()=>{}),n.close().catch(()=>{})};t.signal?.addEventListener("abort",o,{once:!0});let s=await a.handleRequest(t,{...i?.authInfo!==void 0&&{authInfo:i.authInfo},...i?.parsedBody!==void 0&&{parsedBody:i.parsedBody}});if(null===s.body||"text/event-stream"!==cg(s.headers.get("content-type")))return o(),s;let l=s.body.getReader(),c=!1,d=()=>{c||(c=!0,o())},u=new ReadableStream({pull:async e=>{try{let{done:t,value:r}=await l.read();if(t){d(),e.close();return}void 0!==r&&e.enqueue(r)}catch(t){d(),e.error(t)}},cancel:e=>(d(),l.cancel(e).catch(()=>{}))});return new Response(u,{status:s.status,statusText:s.statusText,headers:s.headers})}catch(e){try{p?.(dl(e))}catch{}return dc(dn(i?.parsedBody))}});async function y(r,i,n){var u,m;let h=r.classification.revision;if(void 0===h||!sq.includes(h)){let e=new le({supported:[...sq],requested:h??"unknown"});return p(e),da(400,e.code,e.message,e.data,dn(r.message))}let g=function(e,t){if("request"!==t.messageKind)return;let r=t.message.method;if(void 0===e.mcpMethodHeader)return lW("method-header-missing","(missing)",`the body names method ${r} but the required Mcp-Method header is absent`,"standard-header-validation");let i=Object.hasOwn(lG,r)?lG[r]:void 0;if(void 0===i)return;let n=t.message.params?.[i],a="string"==typeof n?n:void 0;if(void 0===e.mcpNameHeader){if(void 0===a)return;return lW("name-header-missing","(missing)",`the body carries params.${i}="${a}" but the required Mcp-Name header is absent`,"standard-header-validation")}let o=lK(e.mcpNameHeader),s=lF(o);return void 0===s?lW("name-header-invalid-encoding",o,"the Mcp-Name header carries an invalid Base64 sentinel value","standard-header-validation"):void 0!==a&&s!==a?lW("name-header-mismatch",o,`the body carries params.${i}="${a}" but the Mcp-Name header names "${s}"`,"standard-header-validation"):void 0}({httpMethod:i.method,mcpMethodHeader:i.headers.get("mcp-method")??void 0,mcpNameHeader:i.headers.get("mcp-name")??void 0},r);if(void 0!==g)return p(Error(`Rejected inbound request (${g.cell}): ${g.message}`)),ds(g,dn(r.message));let y="request"===r.messageKind?lk(r.message.params):void 0,v=y?.[nq];if("request"===r.messageKind){let e=Object.hasOwn(sT,u=r.message.method)?sT[u]:void 0;if(void 0!==e){let t=sP(e,v);if(void 0!==t){let e=new lt({requiredCapabilities:t});return p(e),da(lJ[e.code]??400,e.code,e.message,e.data,r.message.id)}}}let _=await e({era:"modern",...void 0!==n&&{authInfo:n},requestInfo:i}),b=_ instanceof c1?_.server:_;if("request"===r.messageKind&&"subscriptions/listen"===r.message.method){let e=b.getCapabilities(),t=l(b);return _.close().catch(p),f.serve(r.message,i.signal,e,t)}if("request"===r.messageKind&&"tools/call"===r.message.method&&_ instanceof c1){let e=r.message.params,t="string"==typeof e?.name?e.name:void 0,n=void 0===t?void 0:_.toolInputSchemaJson(t);if(void 0!==n){let t=lN(n);if(t.valid&&t.declarations.length>0){let n=function(e,t,r){for(let i of e){let e=`Mcp-Param-${i.headerName}`,n=r.get(e),a=function(e,t){let r=e;for(let e of t){if(null===r||"object"!=typeof r)return;r=r[e]}return r}(t,i.path);if(null==a)continue;let o=function(e){if("string"==typeof e)return e;if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e){if(!Number.isFinite(e)||Number.isInteger(e)&&!Number.isSafeInteger(e))return;return String(e)}}(a);if(void 0===o)continue;if(null===n)return lV("param-header-missing",e,`the body carries ${lZ(i.path)}=${JSON.stringify(a)} but the ${e} header is absent`);let s=lF(n);if(void 0===s)return lV("param-header-invalid-encoding",e,`the ${e} header carries an invalid Base64 sentinel value`);if(!(("integer"===i.type||"number"===i.type)&&lH.test(s)&&"number"==typeof a?Number(s)===a:s===o))return lV("param-header-mismatch",e,`the ${e} header decodes to ${JSON.stringify(s)} but the body carries ${lZ(i.path)}=${JSON.stringify(a)}`)}}(t.declarations,e?.arguments,i.headers);if(void 0!==n)return _.close().catch(p),p(Error(`Rejected inbound request (${n.cell}): ${n.message}`)),ds(n,r.message.id)}}}a(b,h),s(b,sq),void 0!==y&&(m={clientInfo:y[nP],clientCapabilities:v},o(b,m));let S=b.onclose;d.add(b),b.onclose=()=>{d.delete(b),S?.()};try{let e=await dr(_,r.message,{classification:r.classification,request:i,...void 0!==n&&{authInfo:n},...void 0!==c&&{responseMode:c},...void 0!==t.keepAliveMs&&{keepAliveMs:t.keepAliveMs}});return"notification"===r.messageKind&&queueMicrotask(()=>void b.close().catch(()=>{})),e}catch(e){if(e instanceof s$&&e.code===sC.ConnectionClosed)return new Response(null,{status:499});return await b.close().catch(()=>{}),d.delete(b),p(dl(e)),dc(dn(r.message))}}async function v(e,t,r,i){if(void 0!==g)return g(t,{...void 0!==r&&{authInfo:r},...void 0!==i&&{parsedBody:i}});let n=function(e,t){switch(e.reason){case"http-method":return lB("http-method","modern-only-method-not-allowed",405,new s6(-32e3,"Method not allowed."),!0);case"batch":return lB("jsonrpc-shape","modern-only-batch-not-supported",400,new s6(s3.InvalidRequest,"Bad Request: JSON-RPC batches are not supported by this endpoint"),!0);case"response":return lB("jsonrpc-shape","modern-only-response-post",400,new s6(s3.InvalidRequest,"Bad Request: JSON-RPC responses cannot be posted to this endpoint"),!0);case"notification":return;case"initialize":case"no-claim":{let r=e.requestedVersion;return lB("era-classification","modern-only-missing-envelope",400,void 0===r?new s6(s3.UnsupportedProtocolVersion,"Unsupported protocol version: the request did not name a protocol version",{supported:[...t]}):new le({supported:[...t],requested:r}),!0)}}}(e,sq);return void 0===n?new Response(null,{status:202}):(p(Error(`Rejected 2025-era request on a modern-only endpoint (${n.cell}): ${n.message}`)),ds(n,dn(i)))}async function _(e,t){let r=t?.authInfo;if("POST"===e.method.toUpperCase()&&!cy(e.headers.get("content-type")))return p(Error("Unsupported Media Type: Content-Type must be application/json")),da(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let i=await dd(e,t?.parsedBody);if("unreadable-body"===i.step)return da(400,-32700,"Parse error: the request body could not be read");if("no-json-body"===i.step)return void 0!==g?g(i.forwardRequest,{...void 0!==r&&{authInfo:r}}):da(400,-32700,"Parse error: the request body is not valid JSON");let{outcome:n,body:a,parsedBody:o,forwardRequest:s}=i;try{switch(n.kind){case"reject":return p(Error(`Rejected inbound request (${n.cell}): ${n.message}`)),ds(n,dn(a));case"modern":return await y(n,e,r);case"legacy":return await v(n,s,r,o)}}catch(e){return p(dl(e)),dc(dn(a))}}return{fetch:async(e,t)=>{if(u)throw Error("This MCP handler has been closed");try{return await _(e,t)}catch(e){return p(dl(e)),dc(dn(t?.parsedBody))}},notify:h,bus:m,close:async()=>{u=!0,f.closeAll();let e=[...d].map(e=>e.close().catch(()=>{}));d.clear(),await Promise.all(e)}}}(pX,{legacy:"stateless",responseMode:"json",onerror:e=>mr("MCP handler error:",e)});async function mn(e,t,r,i){let n=crypto.randomUUID(),a=await e.clone().json().catch(()=>void 0),o=(e=>{for(let t of Array.isArray(e)?e:[e]){let e=u5(t);if(e)return e}})(a),s={};return e.headers.forEach((e,t)=>{s[t]=e}),u0({id:n,headers:s,clientInfo:o},async()=>{try{let r=await mi.fetch(e,{authInfo:i,parsedBody:a});return p4(r,t)}catch(e){return console.error("[Cloudflare-MCP] Error handling MCP request:",e),p4(new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32603,message:"Internal server error"},id:null}),{status:500,headers:{"Content-Type":"application/json"}}),t)}})}let ma={async fetch(e,t,r){let i=new URL(e.url).pathname,n=e.headers.get("origin");if(mr(`${e.method} ${i}`),"OPTIONS"===e.method)return new Response(null,{status:204,headers:new Headers(p2(p9,n))});let a=p5.endpoint?.startsWith("/")?p5.endpoint:`/${p5.endpoint||"mcp"}`;if("/health"===i)return p4(new Response(JSON.stringify({status:"ok",transport:"cloudflare-workers",mode:"stateless",auth:"none"}),{status:200,headers:{"Content-Type":"application/json"}}),n);if("/"===i&&"GET"===e.method){var o,s;return p4(new Response((o=p3.name,s=p3.description,`
|
|
594
|
+
`),R=!0;try{m?.()}catch(e){r?.(e instanceof Error?e:Error(String(e)))}void 0!==h&&clearInterval(h),f?.(),a.delete(C);try{p.close()}catch{}}},$=new ReadableStream({start(e){p=e;let r=cG({method:"notifications/subscriptions/acknowledged",params:{notifications:b}},S);x(r.method,r.params),m=t.subscribe(e=>{if(R||!function(e,t){switch(t.kind){case"tools_list_changed":return!0===e.toolsListChanged;case"prompts_list_changed":return!0===e.promptsListChanged;case"resources_list_changed":return!0===e.resourcesListChanged;case"resource_updated":return void 0!==e.resourceSubscriptions&&e.resourceSubscriptions.includes(t.uri)}}(b,e))return;let t=cG(function(e){switch(e.kind){case"tools_list_changed":return{method:"notifications/tools/list_changed"};case"prompts_list_changed":return{method:"notifications/prompts/list_changed"};case"resources_list_changed":return{method:"notifications/resources/list_changed"};case"resource_updated":return{method:"notifications/resources/updated",params:{uri:e.uri}}}}(e),S);x(t.method,t.params)}),h=cJ(n,()=>k(": keepalive\n\n")),a.add(C)},cancel(){C(!1)}});if(void 0!==o)if(o.aborted)C(!1);else{let e=()=>C(!1);o.addEventListener("abort",e,{once:!0}),f=()=>o.removeEventListener("abort",e)}return new Response($,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}})},closeAll(){for(let e of a)e(!0)},get openCount(){return a.size}}}({bus:m,maxSubscriptions:t.maxSubscriptions??1024,keepAliveMs:t.keepAliveMs??15e3,onerror:p});"json"===c&&console.warn("responseMode: 'json' drops mid-call notifications. subscriptions/listen streams are always served over SSE regardless; other notifications emitted before a result are dropped.");let g="reject"===i?void 0:(r=t.keepAliveMs,async(t,i)=>{if("POST"!==t.method.toUpperCase())return da(405,-32e3,"Method not allowed.");try{let n=await e({era:"legacy",...i?.authInfo!==void 0&&{authInfo:i.authInfo},requestInfo:t}),a=new di({sessionIdGenerator:void 0,...void 0!==r&&{keepAliveMs:r}});await n.connect(a);let o=()=>{a.close().catch(()=>{}),n.close().catch(()=>{})};t.signal?.addEventListener("abort",o,{once:!0});let s=await a.handleRequest(t,{...i?.authInfo!==void 0&&{authInfo:i.authInfo},...i?.parsedBody!==void 0&&{parsedBody:i.parsedBody}});if(null===s.body||"text/event-stream"!==cg(s.headers.get("content-type")))return o(),s;let l=s.body.getReader(),c=!1,d=()=>{c||(c=!0,o())},u=new ReadableStream({pull:async e=>{try{let{done:t,value:r}=await l.read();if(t){d(),e.close();return}void 0!==r&&e.enqueue(r)}catch(t){d(),e.error(t)}},cancel:e=>(d(),l.cancel(e).catch(()=>{}))});return new Response(u,{status:s.status,statusText:s.statusText,headers:s.headers})}catch(e){try{p?.(dl(e))}catch{}return dc(dn(i?.parsedBody))}});async function y(r,i,n){var u,m;let h=r.classification.revision;if(void 0===h||!sq.includes(h)){let e=new le({supported:[...sq],requested:h??"unknown"});return p(e),da(400,e.code,e.message,e.data,dn(r.message))}let g=function(e,t){if("request"!==t.messageKind)return;let r=t.message.method;if(void 0===e.mcpMethodHeader)return lW("method-header-missing","(missing)",`the body names method ${r} but the required Mcp-Method header is absent`,"standard-header-validation");let i=Object.hasOwn(lG,r)?lG[r]:void 0;if(void 0===i)return;let n=t.message.params?.[i],a="string"==typeof n?n:void 0;if(void 0===e.mcpNameHeader){if(void 0===a)return;return lW("name-header-missing","(missing)",`the body carries params.${i}="${a}" but the required Mcp-Name header is absent`,"standard-header-validation")}let o=lK(e.mcpNameHeader),s=lF(o);return void 0===s?lW("name-header-invalid-encoding",o,"the Mcp-Name header carries an invalid Base64 sentinel value","standard-header-validation"):void 0!==a&&s!==a?lW("name-header-mismatch",o,`the body carries params.${i}="${a}" but the Mcp-Name header names "${s}"`,"standard-header-validation"):void 0}({httpMethod:i.method,mcpMethodHeader:i.headers.get("mcp-method")??void 0,mcpNameHeader:i.headers.get("mcp-name")??void 0},r);if(void 0!==g)return p(Error(`Rejected inbound request (${g.cell}): ${g.message}`)),ds(g,dn(r.message));let y="request"===r.messageKind?lk(r.message.params):void 0,v=y?.[nq];if("request"===r.messageKind){let e=Object.hasOwn(sT,u=r.message.method)?sT[u]:void 0;if(void 0!==e){let t=sP(e,v);if(void 0!==t){let e=new lt({requiredCapabilities:t});return p(e),da(lJ[e.code]??400,e.code,e.message,e.data,r.message.id)}}}let _=await e({era:"modern",...void 0!==n&&{authInfo:n},requestInfo:i}),b=_ instanceof c1?_.server:_;if("request"===r.messageKind&&"subscriptions/listen"===r.message.method){let e=b.getCapabilities(),t=l(b);return _.close().catch(p),f.serve(r.message,i.signal,e,t)}if("request"===r.messageKind&&"tools/call"===r.message.method&&_ instanceof c1){let e=r.message.params,t="string"==typeof e?.name?e.name:void 0,n=void 0===t?void 0:_.toolInputSchemaJson(t);if(void 0!==n){let t=lN(n);if(t.valid&&t.declarations.length>0){let n=function(e,t,r){for(let i of e){let e=`Mcp-Param-${i.headerName}`,n=r.get(e),a=function(e,t){let r=e;for(let e of t){if(null===r||"object"!=typeof r)return;r=r[e]}return r}(t,i.path);if(null==a)continue;let o=function(e){if("string"==typeof e)return e;if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e){if(!Number.isFinite(e)||Number.isInteger(e)&&!Number.isSafeInteger(e))return;return String(e)}}(a);if(void 0===o)continue;if(null===n)return lV("param-header-missing",e,`the body carries ${lZ(i.path)}=${JSON.stringify(a)} but the ${e} header is absent`);let s=lF(n);if(void 0===s)return lV("param-header-invalid-encoding",e,`the ${e} header carries an invalid Base64 sentinel value`);if(!(("integer"===i.type||"number"===i.type)&&lH.test(s)&&"number"==typeof a?Number(s)===a:s===o))return lV("param-header-mismatch",e,`the ${e} header decodes to ${JSON.stringify(s)} but the body carries ${lZ(i.path)}=${JSON.stringify(a)}`)}}(t.declarations,e?.arguments,i.headers);if(void 0!==n)return _.close().catch(p),p(Error(`Rejected inbound request (${n.cell}): ${n.message}`)),ds(n,r.message.id)}}}a(b,h),s(b,sq),void 0!==y&&(m={clientInfo:y[nP],clientCapabilities:v},o(b,m));let S=b.onclose;d.add(b),b.onclose=()=>{d.delete(b),S?.()};try{let e=await dr(_,r.message,{classification:r.classification,request:i,...void 0!==n&&{authInfo:n},...void 0!==c&&{responseMode:c},...void 0!==t.keepAliveMs&&{keepAliveMs:t.keepAliveMs}});return"notification"===r.messageKind&&queueMicrotask(()=>void b.close().catch(()=>{})),e}catch(e){if(e instanceof s$&&e.code===sC.ConnectionClosed)return new Response(null,{status:499});return await b.close().catch(()=>{}),d.delete(b),p(dl(e)),dc(dn(r.message))}}async function v(e,t,r,i){if(void 0!==g)return g(t,{...void 0!==r&&{authInfo:r},...void 0!==i&&{parsedBody:i}});let n=function(e,t){switch(e.reason){case"http-method":return lB("http-method","modern-only-method-not-allowed",405,new s6(-32e3,"Method not allowed."),!0);case"batch":return lB("jsonrpc-shape","modern-only-batch-not-supported",400,new s6(s3.InvalidRequest,"Bad Request: JSON-RPC batches are not supported by this endpoint"),!0);case"response":return lB("jsonrpc-shape","modern-only-response-post",400,new s6(s3.InvalidRequest,"Bad Request: JSON-RPC responses cannot be posted to this endpoint"),!0);case"notification":return;case"initialize":case"no-claim":{let r=e.requestedVersion;return lB("era-classification","modern-only-missing-envelope",400,void 0===r?new s6(s3.UnsupportedProtocolVersion,"Unsupported protocol version: the request did not name a protocol version",{supported:[...t]}):new le({supported:[...t],requested:r}),!0)}}}(e,sq);return void 0===n?new Response(null,{status:202}):(p(Error(`Rejected 2025-era request on a modern-only endpoint (${n.cell}): ${n.message}`)),ds(n,dn(i)))}async function _(e,t){let r=t?.authInfo;if("POST"===e.method.toUpperCase()&&!cy(e.headers.get("content-type")))return p(Error("Unsupported Media Type: Content-Type must be application/json")),da(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let i=await dd(e,t?.parsedBody);if("unreadable-body"===i.step)return da(400,-32700,"Parse error: the request body could not be read");if("no-json-body"===i.step)return void 0!==g?g(i.forwardRequest,{...void 0!==r&&{authInfo:r}}):da(400,-32700,"Parse error: the request body is not valid JSON");let{outcome:n,body:a,parsedBody:o,forwardRequest:s}=i;try{switch(n.kind){case"reject":return p(Error(`Rejected inbound request (${n.cell}): ${n.message}`)),ds(n,dn(a));case"modern":return await y(n,e,r);case"legacy":return await v(n,s,r,o)}}catch(e){return p(dl(e)),dc(dn(a))}}return{fetch:async(e,t)=>{if(u)throw Error("This MCP handler has been closed");try{return await _(e,t)}catch(e){return p(dl(e)),dc(dn(t?.parsedBody))}},notify:h,bus:m,close:async()=>{u=!0,f.closeAll();let e=[...d].map(e=>e.close().catch(()=>{}));d.clear(),await Promise.all(e)}}}(pQ,{legacy:"stateless",responseMode:"json",onerror:e=>mi("MCP handler error:",e)});async function ma(e,t,r,i){let n=crypto.randomUUID(),a=await e.clone().json().catch(()=>void 0),o=(e=>{for(let t of Array.isArray(e)?e:[e]){let e=u5(t);if(e)return e}})(a),s={};return e.headers.forEach((e,t)=>{s[t]=e}),u0({id:n,headers:s,clientInfo:o},async()=>{try{let r=await mn.fetch(e,{authInfo:i,parsedBody:a});return p5(r,t)}catch(e){return console.error("[Cloudflare-MCP] Error handling MCP request:",e),p5(new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32603,message:"Internal server error"},id:null}),{status:500,headers:{"Content-Type":"application/json"}}),t)}})}let mo={async fetch(e,t,r){let i=new URL(e.url).pathname,n=e.headers.get("origin");if(mi(`${e.method} ${i}`),"OPTIONS"===e.method)return new Response(null,{status:204,headers:new Headers(p9(p4,n))});let a=p3.endpoint?.startsWith("/")?p3.endpoint:`/${p3.endpoint||"mcp"}`;if("/health"===i)return p5(new Response(JSON.stringify({status:"ok",transport:"cloudflare-workers",mode:"stateless",auth:"none"}),{status:200,headers:{"Content-Type":"application/json"}}),n);if("/"===i&&"GET"===e.method){var o,s;return p5(new Response((o=p6.name,s=p6.description,`
|
|
595
595
|
<!DOCTYPE html>
|
|
596
596
|
<html lang="en">
|
|
597
597
|
<head>
|
|
@@ -612,7 +612,7 @@ data: ${JSON.stringify({jsonrpc:"2.0",id:S,result:{resultType:"complete",_meta:{
|
|
|
612
612
|
rel="stylesheet"
|
|
613
613
|
/>
|
|
614
614
|
<style>
|
|
615
|
-
${
|
|
615
|
+
${p2}
|
|
616
616
|
</style>
|
|
617
617
|
</head>
|
|
618
618
|
<body>
|
|
@@ -622,7 +622,7 @@ ${p1}
|
|
|
622
622
|
<div class="section-header">
|
|
623
623
|
<h2 id="server-name" class="display text-gradient">xmcp server</h2>
|
|
624
624
|
<p id="server-description" class="lead">
|
|
625
|
-
${s||
|
|
625
|
+
${s||p0}
|
|
626
626
|
</p>
|
|
627
627
|
</div>
|
|
628
628
|
</div>
|
|
@@ -729,7 +729,7 @@ ${`
|
|
|
729
729
|
(templateConfig.serverName && templateConfig.serverName.trim()) || "xmcp server";
|
|
730
730
|
const resolvedDescription =
|
|
731
731
|
(templateConfig.serverDescription && templateConfig.serverDescription.trim()) ||
|
|
732
|
-
"${
|
|
732
|
+
"${p0}";
|
|
733
733
|
const endpointPath =
|
|
734
734
|
(templateConfig.endpoint && templateConfig.endpoint.trim()) || "/";
|
|
735
735
|
const normalizedEndpoint = endpointPath.startsWith("/")
|
|
@@ -751,7 +751,7 @@ ${`
|
|
|
751
751
|
elements.description.textContent = resolvedDescription;
|
|
752
752
|
}
|
|
753
753
|
|
|
754
|
-
const icons = ${JSON.stringify(
|
|
754
|
+
const icons = ${JSON.stringify(p1)};
|
|
755
755
|
|
|
756
756
|
const connectionOptions = [
|
|
757
757
|
{
|
|
@@ -954,4 +954,4 @@ args = ["-y", "mcp-remote", "\${serverUrl}"]\`,
|
|
|
954
954
|
</script>
|
|
955
955
|
</body>
|
|
956
956
|
</html>
|
|
957
|
-
`),{status:200,headers:{"Content-Type":"text/html"}}),n)}if(i===a)try{let{response:t,authInfo:i}=await
|
|
957
|
+
`),{status:200,headers:{"Content-Type":"text/html"}}),n)}if(i===a)try{let{response:t,authInfo:i}=await mr(e);if(t)return p5(t,n);return ma(e,n,r,i)}catch(e){return console.error("[Cloudflare-MCP] Middleware error:",e),p5(new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32603,message:"Internal server error"},id:null}),{status:500,headers:{"Content-Type":"application/json"}}),n)}return p5(new Response(JSON.stringify({error:"Not found"}),{status:404,headers:{"Content-Type":"application/json"}}),n)}};var ms=I.A;export{ms as default};
|