@mcpcloud/runtime 0.3.0 → 0.3.1
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/compat-stdio.js +1 -1
- package/dist/compat-worker.js +1 -1
- package/dist/config.d.ts +11 -0
- package/dist/container-host.js +2 -2
- package/dist/http.d.ts +1 -0
- package/dist/index.js +14 -14
- package/dist/node.js +2 -2
- package/dist/stdio.js +1 -1
- package/package.json +1 -1
package/dist/compat-stdio.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @mcpcloud/runtime v0.3.
|
|
1
|
+
/*! @mcpcloud/runtime v0.3.1 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
|
|
2
2
|
var T4=Object.defineProperty;var _4=(W)=>W;function Z4(W,Q){this[W]=_4.bind(null,Q)}var QY=(W,Q)=>{for(var Y in Q)T4(W,Y,{get:Q[Y],enumerable:!0,configurable:!0,set:Z4.bind(Q,Y)})};import P4 from"node:process";var G2=Object.freeze({status:"aborted"});function K(W,Q,Y){function X(w,q){if(!w._zod)Object.defineProperty(w,"_zod",{value:{def:q,constr:H,traits:new Set},enumerable:!1});if(w._zod.traits.has(W))return;w._zod.traits.add(W),Q(w,q);let L=H.prototype,B=Object.keys(L);for(let z=0;z<B.length;z++){let I=B[z];if(!(I in w))w[I]=L[I].bind(w)}}let G=Y?.Parent??Object;class J extends G{}Object.defineProperty(J,"name",{value:W});function H(w){var q;let L=Y?.Parent?new J:this;X(L,w),(q=L._zod).deferred??(q.deferred=[]);for(let B of L._zod.deferred)B();return L}return Object.defineProperty(H,"init",{value:X}),Object.defineProperty(H,Symbol.hasInstance,{value:(w)=>{if(Y?.Parent&&w instanceof Y.Parent)return!0;return w?._zod?.traits?.has(W)}}),Object.defineProperty(H,"name",{value:W}),H}var J2=Symbol("zod_brand");class a extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class MW extends Error{constructor(W){super(`Encountered unidirectional transform during encode: ${W}`);this.name="ZodEncodeError"}}var vW={};function r(W){if(W)Object.assign(vW,W);return vW}var D={};QY(D,{unwrapMessage:()=>zW,uint8ArrayToHex:()=>Q6,uint8ArrayToBase64url:()=>s4,uint8ArrayToBase64:()=>AY,stringifyPrimitive:()=>cW,slugify:()=>HQ,shallowClone:()=>XY,safeExtend:()=>d4,required:()=>t4,randomString:()=>y4,propertyKeyTypes:()=>AQ,promiseAllObject:()=>u4,primitiveTypes:()=>GY,prefixIssues:()=>QW,pick:()=>l4,partial:()=>i4,parsedType:()=>LQ,optionalKeys:()=>qQ,omit:()=>r4,objectClone:()=>h4,numKeys:()=>m4,nullish:()=>IW,normalizeParams:()=>U,mergeDefs:()=>s,merge:()=>n4,jsonStringifyReplacer:()=>AW,joinValues:()=>gW,issue:()=>KW,isPlainObject:()=>XW,isObject:()=>HW,hexToUint8Array:()=>W6,getSizableOrigin:()=>HY,getParsedType:()=>f4,getLengthableOrigin:()=>OW,getEnumValues:()=>UW,getElementAtPath:()=>c4,floatSafeRemainder:()=>JQ,finalizeIssue:()=>t,extend:()=>p4,escapeRegex:()=>WW,esc:()=>hW,defineLazy:()=>F,createTransparentProxy:()=>o4,cloneDef:()=>x4,clone:()=>i,cleanRegex:()=>VW,cleanEnum:()=>e4,captureStackTrace:()=>xW,cached:()=>qW,base64urlToUint8Array:()=>a4,base64ToUint8Array:()=>wY,assignProp:()=>YW,assertNotEqual:()=>j4,assertNever:()=>v4,assertIs:()=>k4,assertEqual:()=>C4,assert:()=>g4,allowsEval:()=>wQ,aborted:()=>GW,NUMBER_FORMAT_RANGES:()=>KQ,Class:()=>qY,BIGINT_FORMAT_RANGES:()=>JY});function C4(W){return W}function j4(W){return W}function k4(W){}function v4(W){throw Error("Unexpected value in exhaustive check")}function g4(W){}function UW(W){let Q=Object.values(W).filter((X)=>typeof X==="number");return Object.entries(W).filter(([X,G])=>Q.indexOf(+X)===-1).map(([X,G])=>G)}function gW(W,Q="|"){return W.map((Y)=>cW(Y)).join(Q)}function AW(W,Q){if(typeof Q==="bigint")return Q.toString();return Q}function qW(W){return{get value(){{let Y=W();return Object.defineProperty(this,"value",{value:Y}),Y}throw Error("cached value already set")}}}function IW(W){return W===null||W===void 0}function VW(W){let Q=W.startsWith("^")?1:0,Y=W.endsWith("$")?W.length-1:W.length;return W.slice(Q,Y)}function JQ(W,Q){let Y=(W.toString().split(".")[1]||"").length,X=Q.toString(),G=(X.split(".")[1]||"").length;if(G===0&&/\d?e-\d?/.test(X)){let q=X.match(/\d?e-(\d?)/);if(q?.[1])G=Number.parseInt(q[1])}let J=Y>G?Y:G,H=Number.parseInt(W.toFixed(J).replace(".","")),w=Number.parseInt(Q.toFixed(J).replace(".",""));return H%w/10**J}var YY=Symbol("evaluating");function F(W,Q,Y){let X=void 0;Object.defineProperty(W,Q,{get(){if(X===YY)return;if(X===void 0)X=YY,X=Y();return X},set(G){Object.defineProperty(W,Q,{value:G})},configurable:!0})}function h4(W){return Object.create(Object.getPrototypeOf(W),Object.getOwnPropertyDescriptors(W))}function YW(W,Q,Y){Object.defineProperty(W,Q,{value:Y,writable:!0,enumerable:!0,configurable:!0})}function s(...W){let Q={};for(let Y of W){let X=Object.getOwnPropertyDescriptors(Y);Object.assign(Q,X)}return Object.defineProperties({},Q)}function x4(W){return s(W._zod.def)}function c4(W,Q){if(!Q)return W;return Q.reduce((Y,X)=>Y?.[X],W)}function u4(W){let Q=Object.keys(W),Y=Q.map((X)=>W[X]);return Promise.all(Y).then((X)=>{let G={};for(let J=0;J<Q.length;J++)G[Q[J]]=X[J];return G})}function y4(W=10){let Y="";for(let X=0;X<W;X++)Y+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return Y}function hW(W){return JSON.stringify(W)}function HQ(W){return W.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var xW="captureStackTrace"in Error?Error.captureStackTrace:(...W)=>{};function HW(W){return typeof W==="object"&&W!==null&&!Array.isArray(W)}var wQ=qW(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(W){return!1}});function XW(W){if(HW(W)===!1)return!1;let Q=W.constructor;if(Q===void 0)return!0;if(typeof Q!=="function")return!0;let Y=Q.prototype;if(HW(Y)===!1)return!1;if(Object.prototype.hasOwnProperty.call(Y,"isPrototypeOf")===!1)return!1;return!0}function XY(W){if(XW(W))return{...W};if(Array.isArray(W))return[...W];return W}function m4(W){let Q=0;for(let Y in W)if(Object.prototype.hasOwnProperty.call(W,Y))Q++;return Q}var f4=(W)=>{let Q=typeof W;switch(Q){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(W)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(W))return"array";if(W===null)return"null";if(W.then&&typeof W.then==="function"&&W.catch&&typeof W.catch==="function")return"promise";if(typeof Map<"u"&&W instanceof Map)return"map";if(typeof Set<"u"&&W instanceof Set)return"set";if(typeof Date<"u"&&W instanceof Date)return"date";if(typeof File<"u"&&W instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${Q}`)}},AQ=new Set(["string","number","symbol"]),GY=new Set(["string","number","bigint","boolean","symbol","undefined"]);function WW(W){return W.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function i(W,Q,Y){let X=new W._zod.constr(Q??W._zod.def);if(!Q||Y?.parent)X._zod.parent=W;return X}function U(W){let Q=W;if(!Q)return{};if(typeof Q==="string")return{error:()=>Q};if(Q?.message!==void 0){if(Q?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");Q.error=Q.message}if(delete Q.message,typeof Q.error==="string")return{...Q,error:()=>Q.error};return Q}function o4(W){let Q;return new Proxy({},{get(Y,X,G){return Q??(Q=W()),Reflect.get(Q,X,G)},set(Y,X,G,J){return Q??(Q=W()),Reflect.set(Q,X,G,J)},has(Y,X){return Q??(Q=W()),Reflect.has(Q,X)},deleteProperty(Y,X){return Q??(Q=W()),Reflect.deleteProperty(Q,X)},ownKeys(Y){return Q??(Q=W()),Reflect.ownKeys(Q)},getOwnPropertyDescriptor(Y,X){return Q??(Q=W()),Reflect.getOwnPropertyDescriptor(Q,X)},defineProperty(Y,X,G){return Q??(Q=W()),Reflect.defineProperty(Q,X,G)}})}function cW(W){if(typeof W==="bigint")return W.toString()+"n";if(typeof W==="string")return`"${W}"`;return`${W}`}function qQ(W){return Object.keys(W).filter((Q)=>{return W[Q]._zod.optin==="optional"&&W[Q]._zod.optout==="optional"})}var KQ={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},JY={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function l4(W,Q){let Y=W._zod.def,X=Y.checks;if(X&&X.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let J=s(W._zod.def,{get shape(){let H={};for(let w in Q){if(!(w in Y.shape))throw Error(`Unrecognized key: "${w}"`);if(!Q[w])continue;H[w]=Y.shape[w]}return YW(this,"shape",H),H},checks:[]});return i(W,J)}function r4(W,Q){let Y=W._zod.def,X=Y.checks;if(X&&X.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let J=s(W._zod.def,{get shape(){let H={...W._zod.def.shape};for(let w in Q){if(!(w in Y.shape))throw Error(`Unrecognized key: "${w}"`);if(!Q[w])continue;delete H[w]}return YW(this,"shape",H),H},checks:[]});return i(W,J)}function p4(W,Q){if(!XW(Q))throw Error("Invalid input to extend: expected a plain object");let Y=W._zod.def.checks;if(Y&&Y.length>0){let J=W._zod.def.shape;for(let H in Q)if(Object.getOwnPropertyDescriptor(J,H)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let G=s(W._zod.def,{get shape(){let J={...W._zod.def.shape,...Q};return YW(this,"shape",J),J}});return i(W,G)}function d4(W,Q){if(!XW(Q))throw Error("Invalid input to safeExtend: expected a plain object");let Y=s(W._zod.def,{get shape(){let X={...W._zod.def.shape,...Q};return YW(this,"shape",X),X}});return i(W,Y)}function n4(W,Q){let Y=s(W._zod.def,{get shape(){let X={...W._zod.def.shape,...Q._zod.def.shape};return YW(this,"shape",X),X},get catchall(){return Q._zod.def.catchall},checks:[]});return i(W,Y)}function i4(W,Q,Y){let G=Q._zod.def.checks;if(G&&G.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let H=s(Q._zod.def,{get shape(){let w=Q._zod.def.shape,q={...w};if(Y)for(let L in Y){if(!(L in w))throw Error(`Unrecognized key: "${L}"`);if(!Y[L])continue;q[L]=W?new W({type:"optional",innerType:w[L]}):w[L]}else for(let L in w)q[L]=W?new W({type:"optional",innerType:w[L]}):w[L];return YW(this,"shape",q),q},checks:[]});return i(Q,H)}function t4(W,Q,Y){let X=s(Q._zod.def,{get shape(){let G=Q._zod.def.shape,J={...G};if(Y)for(let H in Y){if(!(H in J))throw Error(`Unrecognized key: "${H}"`);if(!Y[H])continue;J[H]=new W({type:"nonoptional",innerType:G[H]})}else for(let H in G)J[H]=new W({type:"nonoptional",innerType:G[H]});return YW(this,"shape",J),J}});return i(Q,X)}function GW(W,Q=0){if(W.aborted===!0)return!0;for(let Y=Q;Y<W.issues.length;Y++)if(W.issues[Y]?.continue!==!0)return!0;return!1}function QW(W,Q){return Q.map((Y)=>{var X;return(X=Y).path??(X.path=[]),Y.path.unshift(W),Y})}function zW(W){return typeof W==="string"?W:W?.message}function t(W,Q,Y){let X={...W,path:W.path??[]};if(!W.message){let G=zW(W.inst?._zod.def?.error?.(W))??zW(Q?.error?.(W))??zW(Y.customError?.(W))??zW(Y.localeError?.(W))??"Invalid input";X.message=G}if(delete X.inst,delete X.continue,!Q?.reportInput)delete X.input;return X}function HY(W){if(W instanceof Set)return"set";if(W instanceof Map)return"map";if(W instanceof File)return"file";return"unknown"}function OW(W){if(Array.isArray(W))return"array";if(typeof W==="string")return"string";return"unknown"}function LQ(W){let Q=typeof W;switch(Q){case"number":return Number.isNaN(W)?"nan":"number";case"object":{if(W===null)return"null";if(Array.isArray(W))return"array";let Y=W;if(Y&&Object.getPrototypeOf(Y)!==Object.prototype&&"constructor"in Y&&Y.constructor)return Y.constructor.name}}return Q}function KW(...W){let[Q,Y,X]=W;if(typeof Q==="string")return{message:Q,code:"custom",input:Y,inst:X};return{...Q}}function e4(W){return Object.entries(W).filter(([Q,Y])=>{return Number.isNaN(Number.parseInt(Q,10))}).map((Q)=>Q[1])}function wY(W){let Q=atob(W),Y=new Uint8Array(Q.length);for(let X=0;X<Q.length;X++)Y[X]=Q.charCodeAt(X);return Y}function AY(W){let Q="";for(let Y=0;Y<W.length;Y++)Q+=String.fromCharCode(W[Y]);return btoa(Q)}function a4(W){let Q=W.replace(/-/g,"+").replace(/_/g,"/"),Y="=".repeat((4-Q.length%4)%4);return wY(Q+Y)}function s4(W){return AY(W).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function W6(W){let Q=W.replace(/^0x/,"");if(Q.length%2!==0)throw Error("Invalid hex string length");let Y=new Uint8Array(Q.length/2);for(let X=0;X<Q.length;X+=2)Y[X/2]=Number.parseInt(Q.slice(X,X+2),16);return Y}function Q6(W){return Array.from(W).map((Q)=>Q.toString(16).padStart(2,"0")).join("")}class qY{constructor(...W){}}var KY=(W,Q)=>{W.name="$ZodError",Object.defineProperty(W,"_zod",{value:W._zod,enumerable:!1}),Object.defineProperty(W,"issues",{value:Q,enumerable:!1}),W.message=JSON.stringify(Q,AW,2),Object.defineProperty(W,"toString",{value:()=>W.message,enumerable:!1})},uW=K("$ZodError",KY),BQ=K("$ZodError",KY,{Parent:Error});function LY(W,Q=(Y)=>Y.message){let Y={},X=[];for(let G of W.issues)if(G.path.length>0)Y[G.path[0]]=Y[G.path[0]]||[],Y[G.path[0]].push(Q(G));else X.push(Q(G));return{formErrors:X,fieldErrors:Y}}function BY(W,Q=(Y)=>Y.message){let Y={_errors:[]},X=(G)=>{for(let J of G.issues)if(J.code==="invalid_union"&&J.errors.length)J.errors.map((H)=>X({issues:H}));else if(J.code==="invalid_key")X({issues:J.issues});else if(J.code==="invalid_element")X({issues:J.issues});else if(J.path.length===0)Y._errors.push(Q(J));else{let H=Y,w=0;while(w<J.path.length){let q=J.path[w];if(w!==J.path.length-1)H[q]=H[q]||{_errors:[]};else H[q]=H[q]||{_errors:[]},H[q]._errors.push(Q(J));H=H[q],w++}}};return X(W),Y}var yW=(W)=>(Q,Y,X,G)=>{let J=X?Object.assign(X,{async:!1}):{async:!1},H=Q._zod.run({value:Y,issues:[]},J);if(H instanceof Promise)throw new a;if(H.issues.length){let w=new(G?.Err??W)(H.issues.map((q)=>t(q,J,r())));throw xW(w,G?.callee),w}return H.value};var mW=(W)=>async(Q,Y,X,G)=>{let J=X?Object.assign(X,{async:!0}):{async:!0},H=Q._zod.run({value:Y,issues:[]},J);if(H instanceof Promise)H=await H;if(H.issues.length){let w=new(G?.Err??W)(H.issues.map((q)=>t(q,J,r())));throw xW(w,G?.callee),w}return H.value};var DW=(W)=>(Q,Y,X)=>{let G=X?{...X,async:!1}:{async:!1},J=Q._zod.run({value:Y,issues:[]},G);if(J instanceof Promise)throw new a;return J.issues.length?{success:!1,error:new(W??uW)(J.issues.map((H)=>t(H,G,r())))}:{success:!0,data:J.value}},NY=DW(BQ),FW=(W)=>async(Q,Y,X)=>{let G=X?Object.assign(X,{async:!0}):{async:!0},J=Q._zod.run({value:Y,issues:[]},G);if(J instanceof Promise)J=await J;return J.issues.length?{success:!1,error:new W(J.issues.map((H)=>t(H,G,r())))}:{success:!0,data:J.value}},MY=FW(BQ),zY=(W)=>(Q,Y,X)=>{let G=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return yW(W)(Q,Y,G)};var UY=(W)=>(Q,Y,X)=>{return yW(W)(Q,Y,X)};var IY=(W)=>async(Q,Y,X)=>{let G=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return mW(W)(Q,Y,G)};var VY=(W)=>async(Q,Y,X)=>{return mW(W)(Q,Y,X)};var OY=(W)=>(Q,Y,X)=>{let G=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return DW(W)(Q,Y,G)};var DY=(W)=>(Q,Y,X)=>{return DW(W)(Q,Y,X)};var FY=(W)=>async(Q,Y,X)=>{let G=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return FW(W)(Q,Y,G)};var $Y=(W)=>async(Q,Y,X)=>{return FW(W)(Q,Y,X)};var PY=/^[cC][^\s-]{8,}$/,EY=/^[0-9a-z]+$/,RY=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,SY=/^[0-9a-vA-V]{20}$/,bY=/^[A-Za-z0-9]{27}$/,TY=/^[a-zA-Z0-9_-]{21}$/,_Y=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var ZY=/^([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})$/,NQ=(W)=>{if(!W)return/^([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)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${W}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var CY=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var X6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function jY(){return new RegExp(X6,"u")}var kY=/^(?:(?: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])$/,vY=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var gY=/^((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])$/,hY=/^(([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])$/,xY=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,MQ=/^[A-Za-z0-9_-]*$/;var cY=/^\+[1-9]\d{6,14}$/,uY="(?:(?:\\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])))",yY=new RegExp(`^${uY}$`);function mY(W){return typeof W.precision==="number"?W.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":W.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${W.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function fY(W){return new RegExp(`^${mY(W)}$`)}function oY(W){let Q=mY({precision:W.precision}),Y=["Z"];if(W.local)Y.push("");if(W.offset)Y.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let X=`${Q}(?:${Y.join("|")})`;return new RegExp(`^${uY}T(?:${X})$`)}var lY=(W)=>{let Q=W?`[\\s\\S]{${W?.minimum??0},${W?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${Q}$`)};var rY=/^-?\d+$/,fW=/^-?\d+(?:\.\d+)?$/,pY=/^(?:true|false)$/i,dY=/^null$/i;var nY=/^[^A-Z]*$/,iY=/^[^a-z]*$/;var g=K("$ZodCheck",(W,Q)=>{var Y;W._zod??(W._zod={}),W._zod.def=Q,(Y=W._zod).onattach??(Y.onattach=[])}),tY={number:"number",bigint:"bigint",object:"date"},zQ=K("$ZodCheckLessThan",(W,Q)=>{g.init(W,Q);let Y=tY[typeof Q.value];W._zod.onattach.push((X)=>{let G=X._zod.bag,J=(Q.inclusive?G.maximum:G.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(Q.value<J)if(Q.inclusive)G.maximum=Q.value;else G.exclusiveMaximum=Q.value}),W._zod.check=(X)=>{if(Q.inclusive?X.value<=Q.value:X.value<Q.value)return;X.issues.push({origin:Y,code:"too_big",maximum:typeof Q.value==="object"?Q.value.getTime():Q.value,input:X.value,inclusive:Q.inclusive,inst:W,continue:!Q.abort})}}),UQ=K("$ZodCheckGreaterThan",(W,Q)=>{g.init(W,Q);let Y=tY[typeof Q.value];W._zod.onattach.push((X)=>{let G=X._zod.bag,J=(Q.inclusive?G.minimum:G.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(Q.value>J)if(Q.inclusive)G.minimum=Q.value;else G.exclusiveMinimum=Q.value}),W._zod.check=(X)=>{if(Q.inclusive?X.value>=Q.value:X.value>Q.value)return;X.issues.push({origin:Y,code:"too_small",minimum:typeof Q.value==="object"?Q.value.getTime():Q.value,input:X.value,inclusive:Q.inclusive,inst:W,continue:!Q.abort})}}),eY=K("$ZodCheckMultipleOf",(W,Q)=>{g.init(W,Q),W._zod.onattach.push((Y)=>{var X;(X=Y._zod.bag).multipleOf??(X.multipleOf=Q.value)}),W._zod.check=(Y)=>{if(typeof Y.value!==typeof Q.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof Y.value==="bigint"?Y.value%Q.value===BigInt(0):JQ(Y.value,Q.value)===0)return;Y.issues.push({origin:typeof Y.value,code:"not_multiple_of",divisor:Q.value,input:Y.value,inst:W,continue:!Q.abort})}}),aY=K("$ZodCheckNumberFormat",(W,Q)=>{g.init(W,Q),Q.format=Q.format||"float64";let Y=Q.format?.includes("int"),X=Y?"int":"number",[G,J]=KQ[Q.format];W._zod.onattach.push((H)=>{let w=H._zod.bag;if(w.format=Q.format,w.minimum=G,w.maximum=J,Y)w.pattern=rY}),W._zod.check=(H)=>{let w=H.value;if(Y){if(!Number.isInteger(w)){H.issues.push({expected:X,format:Q.format,code:"invalid_type",continue:!1,input:w,inst:W});return}if(!Number.isSafeInteger(w)){if(w>0)H.issues.push({input:w,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:W,origin:X,inclusive:!0,continue:!Q.abort});else H.issues.push({input:w,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:W,origin:X,inclusive:!0,continue:!Q.abort});return}}if(w<G)H.issues.push({origin:"number",input:w,code:"too_small",minimum:G,inclusive:!0,inst:W,continue:!Q.abort});if(w>J)H.issues.push({origin:"number",input:w,code:"too_big",maximum:J,inclusive:!0,inst:W,continue:!Q.abort})}});var sY=K("$ZodCheckMaxLength",(W,Q)=>{var Y;g.init(W,Q),(Y=W._zod.def).when??(Y.when=(X)=>{let G=X.value;return!IW(G)&&G.length!==void 0}),W._zod.onattach.push((X)=>{let G=X._zod.bag.maximum??Number.POSITIVE_INFINITY;if(Q.maximum<G)X._zod.bag.maximum=Q.maximum}),W._zod.check=(X)=>{let G=X.value;if(G.length<=Q.maximum)return;let H=OW(G);X.issues.push({origin:H,code:"too_big",maximum:Q.maximum,inclusive:!0,input:G,inst:W,continue:!Q.abort})}}),W0=K("$ZodCheckMinLength",(W,Q)=>{var Y;g.init(W,Q),(Y=W._zod.def).when??(Y.when=(X)=>{let G=X.value;return!IW(G)&&G.length!==void 0}),W._zod.onattach.push((X)=>{let G=X._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(Q.minimum>G)X._zod.bag.minimum=Q.minimum}),W._zod.check=(X)=>{let G=X.value;if(G.length>=Q.minimum)return;let H=OW(G);X.issues.push({origin:H,code:"too_small",minimum:Q.minimum,inclusive:!0,input:G,inst:W,continue:!Q.abort})}}),Q0=K("$ZodCheckLengthEquals",(W,Q)=>{var Y;g.init(W,Q),(Y=W._zod.def).when??(Y.when=(X)=>{let G=X.value;return!IW(G)&&G.length!==void 0}),W._zod.onattach.push((X)=>{let G=X._zod.bag;G.minimum=Q.length,G.maximum=Q.length,G.length=Q.length}),W._zod.check=(X)=>{let G=X.value,J=G.length;if(J===Q.length)return;let H=OW(G),w=J>Q.length;X.issues.push({origin:H,...w?{code:"too_big",maximum:Q.length}:{code:"too_small",minimum:Q.length},inclusive:!0,exact:!0,input:X.value,inst:W,continue:!Q.abort})}}),$W=K("$ZodCheckStringFormat",(W,Q)=>{var Y,X;if(g.init(W,Q),W._zod.onattach.push((G)=>{let J=G._zod.bag;if(J.format=Q.format,Q.pattern)J.patterns??(J.patterns=new Set),J.patterns.add(Q.pattern)}),Q.pattern)(Y=W._zod).check??(Y.check=(G)=>{if(Q.pattern.lastIndex=0,Q.pattern.test(G.value))return;G.issues.push({origin:"string",code:"invalid_format",format:Q.format,input:G.value,...Q.pattern?{pattern:Q.pattern.toString()}:{},inst:W,continue:!Q.abort})});else(X=W._zod).check??(X.check=()=>{})}),Y0=K("$ZodCheckRegex",(W,Q)=>{$W.init(W,Q),W._zod.check=(Y)=>{if(Q.pattern.lastIndex=0,Q.pattern.test(Y.value))return;Y.issues.push({origin:"string",code:"invalid_format",format:"regex",input:Y.value,pattern:Q.pattern.toString(),inst:W,continue:!Q.abort})}}),X0=K("$ZodCheckLowerCase",(W,Q)=>{Q.pattern??(Q.pattern=nY),$W.init(W,Q)}),G0=K("$ZodCheckUpperCase",(W,Q)=>{Q.pattern??(Q.pattern=iY),$W.init(W,Q)}),J0=K("$ZodCheckIncludes",(W,Q)=>{g.init(W,Q);let Y=WW(Q.includes),X=new RegExp(typeof Q.position==="number"?`^.{${Q.position}}${Y}`:Y);Q.pattern=X,W._zod.onattach.push((G)=>{let J=G._zod.bag;J.patterns??(J.patterns=new Set),J.patterns.add(X)}),W._zod.check=(G)=>{if(G.value.includes(Q.includes,Q.position))return;G.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:Q.includes,input:G.value,inst:W,continue:!Q.abort})}}),H0=K("$ZodCheckStartsWith",(W,Q)=>{g.init(W,Q);let Y=new RegExp(`^${WW(Q.prefix)}.*`);Q.pattern??(Q.pattern=Y),W._zod.onattach.push((X)=>{let G=X._zod.bag;G.patterns??(G.patterns=new Set),G.patterns.add(Y)}),W._zod.check=(X)=>{if(X.value.startsWith(Q.prefix))return;X.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:Q.prefix,input:X.value,inst:W,continue:!Q.abort})}}),w0=K("$ZodCheckEndsWith",(W,Q)=>{g.init(W,Q);let Y=new RegExp(`.*${WW(Q.suffix)}$`);Q.pattern??(Q.pattern=Y),W._zod.onattach.push((X)=>{let G=X._zod.bag;G.patterns??(G.patterns=new Set),G.patterns.add(Y)}),W._zod.check=(X)=>{if(X.value.endsWith(Q.suffix))return;X.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:Q.suffix,input:X.value,inst:W,continue:!Q.abort})}});var A0=K("$ZodCheckOverwrite",(W,Q)=>{g.init(W,Q),W._zod.check=(Y)=>{Y.value=Q.tx(Y.value)}});class IQ{constructor(W=[]){if(this.content=[],this.indent=0,this)this.args=W}indented(W){this.indent+=1,W(this),this.indent-=1}write(W){if(typeof W==="function"){W(this,{execution:"sync"}),W(this,{execution:"async"});return}let Y=W.split(`
|
|
3
3
|
`).filter((J)=>J),X=Math.min(...Y.map((J)=>J.length-J.trimStart().length)),G=Y.map((J)=>J.slice(X)).map((J)=>" ".repeat(this.indent*2)+J);for(let J of G)this.content.push(J)}compile(){let W=Function,Q=this?.args,X=[...(this?.content??[""]).map((G)=>` ${G}`)];return new W(...Q,X.join(`
|
|
4
4
|
`))}}var K0={major:4,minor:3,patch:6};var E=K("$ZodType",(W,Q)=>{var Y;W??(W={}),W._zod.def=Q,W._zod.bag=W._zod.bag||{},W._zod.version=K0;let X=[...W._zod.def.checks??[]];if(W._zod.traits.has("$ZodCheck"))X.unshift(W);for(let G of X)for(let J of G._zod.onattach)J(W);if(X.length===0)(Y=W._zod).deferred??(Y.deferred=[]),W._zod.deferred?.push(()=>{W._zod.run=W._zod.parse});else{let G=(H,w,q)=>{let L=GW(H),B;for(let z of w){if(z._zod.def.when){if(!z._zod.def.when(H))continue}else if(L)continue;let I=H.issues.length,V=z._zod.check(H);if(V instanceof Promise&&q?.async===!1)throw new a;if(B||V instanceof Promise)B=(B??Promise.resolve()).then(async()=>{if(await V,H.issues.length===I)return;if(!L)L=GW(H,I)});else{if(H.issues.length===I)continue;if(!L)L=GW(H,I)}}if(B)return B.then(()=>{return H});return H},J=(H,w,q)=>{if(GW(H))return H.aborted=!0,H;let L=G(w,X,q);if(L instanceof Promise){if(q.async===!1)throw new a;return L.then((B)=>W._zod.parse(B,q))}return W._zod.parse(L,q)};W._zod.run=(H,w)=>{if(w.skipChecks)return W._zod.parse(H,w);if(w.direction==="backward"){let L=W._zod.parse({value:H.value,issues:[]},{...w,skipChecks:!0});if(L instanceof Promise)return L.then((B)=>{return J(B,H,w)});return J(L,H,w)}let q=W._zod.parse(H,w);if(q instanceof Promise){if(w.async===!1)throw new a;return q.then((L)=>G(L,X,w))}return G(q,X,w)}}F(W,"~standard",()=>({validate:(G)=>{try{let J=NY(W,G);return J.success?{value:J.data}:{issues:J.error?.issues}}catch(J){return MY(W,G).then((H)=>H.success?{value:H.data}:{issues:H.error?.issues})}},vendor:"zod",version:1}))}),pW=K("$ZodString",(W,Q)=>{E.init(W,Q),W._zod.pattern=[...W?._zod.bag?.patterns??[]].pop()??lY(W._zod.bag),W._zod.parse=(Y,X)=>{if(Q.coerce)try{Y.value=String(Y.value)}catch(G){}if(typeof Y.value==="string")return Y;return Y.issues.push({expected:"string",code:"invalid_type",input:Y.value,inst:W}),Y}}),R=K("$ZodStringFormat",(W,Q)=>{$W.init(W,Q),pW.init(W,Q)}),O0=K("$ZodGUID",(W,Q)=>{Q.pattern??(Q.pattern=ZY),R.init(W,Q)}),D0=K("$ZodUUID",(W,Q)=>{if(Q.version){let X={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[Q.version];if(X===void 0)throw Error(`Invalid UUID version: "${Q.version}"`);Q.pattern??(Q.pattern=NQ(X))}else Q.pattern??(Q.pattern=NQ());R.init(W,Q)}),F0=K("$ZodEmail",(W,Q)=>{Q.pattern??(Q.pattern=CY),R.init(W,Q)}),$0=K("$ZodURL",(W,Q)=>{R.init(W,Q),W._zod.check=(Y)=>{try{let X=Y.value.trim(),G=new URL(X);if(Q.hostname){if(Q.hostname.lastIndex=0,!Q.hostname.test(G.hostname))Y.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Q.hostname.source,input:Y.value,inst:W,continue:!Q.abort})}if(Q.protocol){if(Q.protocol.lastIndex=0,!Q.protocol.test(G.protocol.endsWith(":")?G.protocol.slice(0,-1):G.protocol))Y.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:Q.protocol.source,input:Y.value,inst:W,continue:!Q.abort})}if(Q.normalize)Y.value=G.href;else Y.value=X;return}catch(X){Y.issues.push({code:"invalid_format",format:"url",input:Y.value,inst:W,continue:!Q.abort})}}}),P0=K("$ZodEmoji",(W,Q)=>{Q.pattern??(Q.pattern=jY()),R.init(W,Q)}),E0=K("$ZodNanoID",(W,Q)=>{Q.pattern??(Q.pattern=TY),R.init(W,Q)}),R0=K("$ZodCUID",(W,Q)=>{Q.pattern??(Q.pattern=PY),R.init(W,Q)}),S0=K("$ZodCUID2",(W,Q)=>{Q.pattern??(Q.pattern=EY),R.init(W,Q)}),b0=K("$ZodULID",(W,Q)=>{Q.pattern??(Q.pattern=RY),R.init(W,Q)}),T0=K("$ZodXID",(W,Q)=>{Q.pattern??(Q.pattern=SY),R.init(W,Q)}),_0=K("$ZodKSUID",(W,Q)=>{Q.pattern??(Q.pattern=bY),R.init(W,Q)}),Z0=K("$ZodISODateTime",(W,Q)=>{Q.pattern??(Q.pattern=oY(Q)),R.init(W,Q)}),C0=K("$ZodISODate",(W,Q)=>{Q.pattern??(Q.pattern=yY),R.init(W,Q)}),j0=K("$ZodISOTime",(W,Q)=>{Q.pattern??(Q.pattern=fY(Q)),R.init(W,Q)}),k0=K("$ZodISODuration",(W,Q)=>{Q.pattern??(Q.pattern=_Y),R.init(W,Q)}),v0=K("$ZodIPv4",(W,Q)=>{Q.pattern??(Q.pattern=kY),R.init(W,Q),W._zod.bag.format="ipv4"}),g0=K("$ZodIPv6",(W,Q)=>{Q.pattern??(Q.pattern=vY),R.init(W,Q),W._zod.bag.format="ipv6",W._zod.check=(Y)=>{try{new URL(`http://[${Y.value}]`)}catch{Y.issues.push({code:"invalid_format",format:"ipv6",input:Y.value,inst:W,continue:!Q.abort})}}});var h0=K("$ZodCIDRv4",(W,Q)=>{Q.pattern??(Q.pattern=gY),R.init(W,Q)}),x0=K("$ZodCIDRv6",(W,Q)=>{Q.pattern??(Q.pattern=hY),R.init(W,Q),W._zod.check=(Y)=>{let X=Y.value.split("/");try{if(X.length!==2)throw Error();let[G,J]=X;if(!J)throw Error();let H=Number(J);if(`${H}`!==J)throw Error();if(H<0||H>128)throw Error();new URL(`http://[${G}]`)}catch{Y.issues.push({code:"invalid_format",format:"cidrv6",input:Y.value,inst:W,continue:!Q.abort})}}});function c0(W){if(W==="")return!0;if(W.length%4!==0)return!1;try{return atob(W),!0}catch{return!1}}var u0=K("$ZodBase64",(W,Q)=>{Q.pattern??(Q.pattern=xY),R.init(W,Q),W._zod.bag.contentEncoding="base64",W._zod.check=(Y)=>{if(c0(Y.value))return;Y.issues.push({code:"invalid_format",format:"base64",input:Y.value,inst:W,continue:!Q.abort})}});function G6(W){if(!MQ.test(W))return!1;let Q=W.replace(/[-_]/g,(X)=>X==="-"?"+":"/"),Y=Q.padEnd(Math.ceil(Q.length/4)*4,"=");return c0(Y)}var y0=K("$ZodBase64URL",(W,Q)=>{Q.pattern??(Q.pattern=MQ),R.init(W,Q),W._zod.bag.contentEncoding="base64url",W._zod.check=(Y)=>{if(G6(Y.value))return;Y.issues.push({code:"invalid_format",format:"base64url",input:Y.value,inst:W,continue:!Q.abort})}}),m0=K("$ZodE164",(W,Q)=>{Q.pattern??(Q.pattern=cY),R.init(W,Q)});function J6(W,Q=null){try{let Y=W.split(".");if(Y.length!==3)return!1;let[X]=Y;if(!X)return!1;let G=JSON.parse(atob(X));if("typ"in G&&G?.typ!=="JWT")return!1;if(!G.alg)return!1;if(Q&&(!("alg"in G)||G.alg!==Q))return!1;return!0}catch{return!1}}var f0=K("$ZodJWT",(W,Q)=>{R.init(W,Q),W._zod.check=(Y)=>{if(J6(Y.value,Q.alg))return;Y.issues.push({code:"invalid_format",format:"jwt",input:Y.value,inst:W,continue:!Q.abort})}});var OQ=K("$ZodNumber",(W,Q)=>{E.init(W,Q),W._zod.pattern=W._zod.bag.pattern??fW,W._zod.parse=(Y,X)=>{if(Q.coerce)try{Y.value=Number(Y.value)}catch(H){}let G=Y.value;if(typeof G==="number"&&!Number.isNaN(G)&&Number.isFinite(G))return Y;let J=typeof G==="number"?Number.isNaN(G)?"NaN":!Number.isFinite(G)?"Infinity":void 0:void 0;return Y.issues.push({expected:"number",code:"invalid_type",input:G,inst:W,...J?{received:J}:{}}),Y}}),o0=K("$ZodNumberFormat",(W,Q)=>{aY.init(W,Q),OQ.init(W,Q)}),l0=K("$ZodBoolean",(W,Q)=>{E.init(W,Q),W._zod.pattern=pY,W._zod.parse=(Y,X)=>{if(Q.coerce)try{Y.value=Boolean(Y.value)}catch(J){}let G=Y.value;if(typeof G==="boolean")return Y;return Y.issues.push({expected:"boolean",code:"invalid_type",input:G,inst:W}),Y}});var r0=K("$ZodNull",(W,Q)=>{E.init(W,Q),W._zod.pattern=dY,W._zod.values=new Set([null]),W._zod.parse=(Y,X)=>{let G=Y.value;if(G===null)return Y;return Y.issues.push({expected:"null",code:"invalid_type",input:G,inst:W}),Y}});var p0=K("$ZodUnknown",(W,Q)=>{E.init(W,Q),W._zod.parse=(Y)=>Y}),d0=K("$ZodNever",(W,Q)=>{E.init(W,Q),W._zod.parse=(Y,X)=>{return Y.issues.push({expected:"never",code:"invalid_type",input:Y.value,inst:W}),Y}});function L0(W,Q,Y){if(W.issues.length)Q.issues.push(...QW(Y,W.issues));Q.value[Y]=W.value}var n0=K("$ZodArray",(W,Q)=>{E.init(W,Q),W._zod.parse=(Y,X)=>{let G=Y.value;if(!Array.isArray(G))return Y.issues.push({expected:"array",code:"invalid_type",input:G,inst:W}),Y;Y.value=Array(G.length);let J=[];for(let H=0;H<G.length;H++){let w=G[H],q=Q.element._zod.run({value:w,issues:[]},X);if(q instanceof Promise)J.push(q.then((L)=>L0(L,Y,H)));else L0(q,Y,H)}if(J.length)return Promise.all(J).then(()=>Y);return Y}});function rW(W,Q,Y,X,G){if(W.issues.length){if(G&&!(Y in X))return;Q.issues.push(...QW(Y,W.issues))}if(W.value===void 0){if(Y in X)Q.value[Y]=void 0}else Q.value[Y]=W.value}function i0(W){let Q=Object.keys(W.shape);for(let X of Q)if(!W.shape?.[X]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${X}": expected a Zod schema`);let Y=qQ(W.shape);return{...W,keys:Q,keySet:new Set(Q),numKeys:Q.length,optionalKeys:new Set(Y)}}function t0(W,Q,Y,X,G,J){let H=[],w=G.keySet,q=G.catchall._zod,L=q.def.type,B=q.optout==="optional";for(let z in Q){if(w.has(z))continue;if(L==="never"){H.push(z);continue}let I=q.run({value:Q[z],issues:[]},X);if(I instanceof Promise)W.push(I.then((V)=>rW(V,Y,z,Q,B)));else rW(I,Y,z,Q,B)}if(H.length)Y.issues.push({code:"unrecognized_keys",keys:H,input:Q,inst:J});if(!W.length)return Y;return Promise.all(W).then(()=>{return Y})}var H6=K("$ZodObject",(W,Q)=>{if(E.init(W,Q),!Object.getOwnPropertyDescriptor(Q,"shape")?.get){let w=Q.shape;Object.defineProperty(Q,"shape",{get:()=>{let q={...w};return Object.defineProperty(Q,"shape",{value:q}),q}})}let X=qW(()=>i0(Q));F(W._zod,"propValues",()=>{let w=Q.shape,q={};for(let L in w){let B=w[L]._zod;if(B.values){q[L]??(q[L]=new Set);for(let z of B.values)q[L].add(z)}}return q});let G=HW,J=Q.catchall,H;W._zod.parse=(w,q)=>{H??(H=X.value);let L=w.value;if(!G(L))return w.issues.push({expected:"object",code:"invalid_type",input:L,inst:W}),w;w.value={};let B=[],z=H.shape;for(let I of H.keys){let V=z[I],c=V._zod.optout==="optional",v=V._zod.run({value:L[I],issues:[]},q);if(v instanceof Promise)B.push(v.then((kW)=>rW(kW,w,I,L,c)));else rW(v,w,I,L,c)}if(!J)return B.length?Promise.all(B).then(()=>w):w;return t0(B,L,w,q,X.value,W)}}),e0=K("$ZodObjectJIT",(W,Q)=>{H6.init(W,Q);let Y=W._zod.parse,X=qW(()=>i0(Q)),G=(I)=>{let V=new IQ(["shape","payload","ctx"]),c=X.value,v=(e)=>{let m=hW(e);return`shape[${m}]._zod.run({ value: input[${m}], issues: [] }, ctx)`};V.write("const input = payload.value;");let kW=Object.create(null),R4=0;for(let e of c.keys)kW[e]=`key_${R4++}`;V.write("const newResult = {};");for(let e of c.keys){let m=kW[e],n=hW(e),b4=I[e]?._zod?.optout==="optional";if(V.write(`const ${m} = ${v(e)};`),b4)V.write(`
|
package/dist/compat-worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @mcpcloud/runtime v0.3.
|
|
1
|
+
/*! @mcpcloud/runtime v0.3.1 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
|
|
2
2
|
var XP=Object.create;var{getPrototypeOf:JP,defineProperty:C9,getOwnPropertyNames:vP}=Object;var zP=Object.prototype.hasOwnProperty;function QP($){return this[$]}var GP,YP,_9=($,U,W)=>{var J=$!=null&&typeof $==="object";if(J){var X=U?GP??=new WeakMap:YP??=new WeakMap,v=X.get($);if(v)return v}W=$!=null?XP(JP($)):{};let z=U||!$||!$.__esModule?C9(W,"default",{value:$,enumerable:!0}):W;for(let Q of vP($))if(!zP.call(z,Q))C9(z,Q,{get:QP.bind($,Q),enumerable:!0});if(J)X.set($,z);return z};var q=($,U)=>()=>(U||$((U={exports:{}}).exports,U),U.exports);var DP=($)=>$;function HP($,U){this[$]=DP.bind(null,U)}var x4=($,U)=>{for(var W in U)C9($,W,{get:U[W],enumerable:!0,configurable:!0,set:HP.bind(U,W)})};var vW=q((wI)=>{Object.defineProperty(wI,"__esModule",{value:!0});wI.regexpCode=wI.getEsmExportName=wI.getProperty=wI.safeStringify=wI.stringify=wI.strConcat=wI.addCodeArg=wI.str=wI._=wI.nil=wI._Code=wI.Name=wI.IDENTIFIER=wI._CodeOrName=void 0;class hJ{}wI._CodeOrName=hJ;wI.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class H0 extends hJ{constructor($){super();if(!wI.IDENTIFIER.test($))throw Error("CodeGen: name must be a valid identifier");this.str=$}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}wI.Name=H0;class m4 extends hJ{constructor($){super();this._items=typeof $==="string"?[$]:$}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let $=this._items[0];return $===""||$==='""'}get str(){var $;return($=this._str)!==null&&$!==void 0?$:this._str=this._items.reduce((U,W)=>`${U}${W}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((U,W)=>{if(W instanceof H0)U[W.str]=(U[W.str]||0)+1;return U},{})}}wI._Code=m4;wI.nil=new m4("");function bI($,...U){let W=[$[0]],J=0;while(J<U.length)u8(W,U[J]),W.push($[++J]);return new m4(W)}wI._=bI;var g8=new m4("+");function BI($,...U){let W=[JW($[0])],J=0;while(J<U.length)W.push(g8),u8(W,U[J]),W.push(g8,JW($[++J]));return _T(W),new m4(W)}wI.str=BI;function u8($,U){if(U instanceof m4)$.push(...U._items);else if(U instanceof H0)$.push(U);else $.push(xT(U))}wI.addCodeArg=u8;function _T($){let U=1;while(U<$.length-1){if($[U]===g8){let W=gT($[U-1],$[U+1]);if(W!==void 0){$.splice(U-1,3,W);continue}$[U++]="+"}U++}}function gT($,U){if(U==='""')return $;if($==='""')return U;if(typeof $=="string"){if(U instanceof H0||$[$.length-1]!=='"')return;if(typeof U!="string")return`${$.slice(0,-1)}${U}"`;if(U[0]==='"')return $.slice(0,-1)+U.slice(1);return}if(typeof U=="string"&&U[0]==='"'&&!($ instanceof H0))return`"${$}${U.slice(1)}`;return}function uT($,U){return U.emptyStr()?$:$.emptyStr()?U:BI`${$}${U}`}wI.strConcat=uT;function xT($){return typeof $=="number"||typeof $=="boolean"||$===null?$:JW(Array.isArray($)?$.join(","):$)}function yT($){return new m4(JW($))}wI.stringify=yT;function JW($){return JSON.stringify($).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}wI.safeStringify=JW;function fT($){return typeof $=="string"&&wI.IDENTIFIER.test($)?new m4(`.${$}`):bI`[${$}]`}wI.getProperty=fT;function hT($){if(typeof $=="string"&&wI.IDENTIFIER.test($))return new m4(`${$}`);throw Error(`CodeGen: invalid export name: ${$}, use explicit $id name mapping`)}wI.getEsmExportName=hT;function lT($){return new m4($.toString())}wI.regexpCode=lT});var h8=q((KI)=>{Object.defineProperty(KI,"__esModule",{value:!0});KI.ValueScope=KI.ValueScopeName=KI.Scope=KI.varKinds=KI.UsedValueState=void 0;var D4=vW();class LI extends Error{constructor($){super(`CodeGen: "code" for ${$} not defined`);this.value=$.value}}var mJ;(function($){$[$.Started=0]="Started",$[$.Completed=1]="Completed"})(mJ||(KI.UsedValueState=mJ={}));KI.varKinds={const:new D4.Name("const"),let:new D4.Name("let"),var:new D4.Name("var")};class y8{constructor({prefixes:$,parent:U}={}){this._names={},this._prefixes=$,this._parent=U}toName($){return $ instanceof D4.Name?$:this.name($)}name($){return new D4.Name(this._newName($))}_newName($){let U=this._names[$]||this._nameGroup($);return`${$}${U.index++}`}_nameGroup($){var U,W;if(((W=(U=this._parent)===null||U===void 0?void 0:U._prefixes)===null||W===void 0?void 0:W.has($))||this._prefixes&&!this._prefixes.has($))throw Error(`CodeGen: prefix "${$}" is not allowed in this scope`);return this._names[$]={prefix:$,index:0}}}KI.Scope=y8;class f8 extends D4.Name{constructor($,U){super(U);this.prefix=$}setValue($,{property:U,itemIndex:W}){this.value=$,this.scopePath=D4._`.${new D4.Name(U)}[${W}]`}}KI.ValueScopeName=f8;var $C=D4._`\n`;class II extends y8{constructor($){super($);this._values={},this._scope=$.scope,this.opts={...$,_n:$.lines?$C:D4.nil}}get(){return this._scope}name($){return new f8($,this._newName($))}value($,U){var W;if(U.ref===void 0)throw Error("CodeGen: ref must be passed in value");let J=this.toName($),{prefix:X}=J,v=(W=U.key)!==null&&W!==void 0?W:U.ref,z=this._values[X];if(z){let Y=z.get(v);if(Y)return Y}else z=this._values[X]=new Map;z.set(v,J);let Q=this._scope[X]||(this._scope[X]=[]),G=Q.length;return Q[G]=U.ref,J.setValue(U,{property:X,itemIndex:G}),J}getValue($,U){let W=this._values[$];if(!W)return;return W.get(U)}scopeRefs($,U=this._values){return this._reduceValues(U,(W)=>{if(W.scopePath===void 0)throw Error(`CodeGen: name "${W}" has no value`);return D4._`${$}${W.scopePath}`})}scopeCode($=this._values,U,W){return this._reduceValues($,(J)=>{if(J.value===void 0)throw Error(`CodeGen: name "${J}" has no value`);return J.value.code},U,W)}_reduceValues($,U,W={},J){let X=D4.nil;for(let v in $){let z=$[v];if(!z)continue;let Q=W[v]=W[v]||new Map;z.forEach((G)=>{if(Q.has(G))return;Q.set(G,mJ.Started);let Y=U(G);if(Y){let D=this.opts.es5?KI.varKinds.var:KI.varKinds.const;X=D4._`${X}${D} ${G} = ${Y};${this.opts._n}`}else if(Y=J===null||J===void 0?void 0:J(G))X=D4._`${X}${Y}${this.opts._n}`;else throw new LI(G);Q.set(G,mJ.Completed)})}return X}}KI.ValueScope=II});var s=q((H4)=>{Object.defineProperty(H4,"__esModule",{value:!0});H4.or=H4.and=H4.not=H4.CodeGen=H4.operators=H4.varKinds=H4.ValueScopeName=H4.ValueScope=H4.Scope=H4.Name=H4.regexpCode=H4.stringify=H4.getProperty=H4.nil=H4.strConcat=H4.str=H4._=void 0;var z$=vW(),i4=h8(),c6=vW();Object.defineProperty(H4,"_",{enumerable:!0,get:function(){return c6._}});Object.defineProperty(H4,"str",{enumerable:!0,get:function(){return c6.str}});Object.defineProperty(H4,"strConcat",{enumerable:!0,get:function(){return c6.strConcat}});Object.defineProperty(H4,"nil",{enumerable:!0,get:function(){return c6.nil}});Object.defineProperty(H4,"getProperty",{enumerable:!0,get:function(){return c6.getProperty}});Object.defineProperty(H4,"stringify",{enumerable:!0,get:function(){return c6.stringify}});Object.defineProperty(H4,"regexpCode",{enumerable:!0,get:function(){return c6.regexpCode}});Object.defineProperty(H4,"Name",{enumerable:!0,get:function(){return c6.Name}});var oJ=h8();Object.defineProperty(H4,"Scope",{enumerable:!0,get:function(){return oJ.Scope}});Object.defineProperty(H4,"ValueScope",{enumerable:!0,get:function(){return oJ.ValueScope}});Object.defineProperty(H4,"ValueScopeName",{enumerable:!0,get:function(){return oJ.ValueScopeName}});Object.defineProperty(H4,"varKinds",{enumerable:!0,get:function(){return oJ.varKinds}});H4.operators={GT:new z$._Code(">"),GTE:new z$._Code(">="),LT:new z$._Code("<"),LTE:new z$._Code("<="),EQ:new z$._Code("==="),NEQ:new z$._Code("!=="),NOT:new z$._Code("!"),OR:new z$._Code("||"),AND:new z$._Code("&&"),ADD:new z$._Code("+")};class p6{optimizeNodes(){return this}optimizeNames($,U){return this}}class OI extends p6{constructor($,U,W){super();this.varKind=$,this.name=U,this.rhs=W}render({es5:$,_n:U}){let W=$?i4.varKinds.var:this.varKind,J=this.rhs===void 0?"":` = ${this.rhs}`;return`${W} ${this.name}${J};`+U}optimizeNames($,U){if(!$[this.name.str])return;if(this.rhs)this.rhs=B0(this.rhs,$,U);return this}get names(){return this.rhs instanceof z$._CodeOrName?this.rhs.names:{}}}class i8 extends p6{constructor($,U,W){super();this.lhs=$,this.rhs=U,this.sideEffects=W}render({_n:$}){return`${this.lhs} = ${this.rhs};`+$}optimizeNames($,U){if(this.lhs instanceof z$.Name&&!$[this.lhs.str]&&!this.sideEffects)return;return this.rhs=B0(this.rhs,$,U),this}get names(){let $=this.lhs instanceof z$.Name?{}:{...this.lhs.names};return pJ($,this.rhs)}}class qI extends i8{constructor($,U,W,J){super($,W,J);this.op=U}render({_n:$}){return`${this.lhs} ${this.op}= ${this.rhs};`+$}}class VI extends p6{constructor($){super();this.label=$,this.names={}}render({_n:$}){return`${this.label}:`+$}}class FI extends p6{constructor($){super();this.label=$,this.names={}}render({_n:$}){return`break${this.label?` ${this.label}`:""};`+$}}class jI extends p6{constructor($){super();this.error=$}render({_n:$}){return`throw ${this.error};`+$}get names(){return this.error.names}}class MI extends p6{constructor($){super();this.code=$}render({_n:$}){return`${this.code};`+$}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames($,U){return this.code=B0(this.code,$,U),this}get names(){return this.code instanceof z$._CodeOrName?this.code.names:{}}}class dJ extends p6{constructor($=[]){super();this.nodes=$}render($){return this.nodes.reduce((U,W)=>U+W.render($),"")}optimizeNodes(){let{nodes:$}=this,U=$.length;while(U--){let W=$[U].optimizeNodes();if(Array.isArray(W))$.splice(U,1,...W);else if(W)$[U]=W;else $.splice(U,1)}return $.length>0?this:void 0}optimizeNames($,U){let{nodes:W}=this,J=W.length;while(J--){let X=W[J];if(X.optimizeNames($,U))continue;JC($,X.names),W.splice(J,1)}return W.length>0?this:void 0}get names(){return this.nodes.reduce(($,U)=>M1($,U.names),{})}}class o6 extends dJ{render($){return"{"+$._n+super.render($)+"}"+$._n}}class EI extends dJ{}class zW extends o6{}zW.kind="else";class F6 extends o6{constructor($,U){super(U);this.condition=$}render($){let U=`if(${this.condition})`+super.render($);if(this.else)U+="else "+this.else.render($);return U}optimizeNodes(){super.optimizeNodes();let $=this.condition;if($===!0)return this.nodes;let U=this.else;if(U){let W=U.optimizeNodes();U=this.else=Array.isArray(W)?new zW(W):W}if(U){if($===!1)return U instanceof F6?U:U.nodes;if(this.nodes.length)return this;return new F6(ZI($),U instanceof F6?[U]:U.nodes)}if($===!1||!this.nodes.length)return;return this}optimizeNames($,U){var W;if(this.else=(W=this.else)===null||W===void 0?void 0:W.optimizeNames($,U),!(super.optimizeNames($,U)||this.else))return;return this.condition=B0(this.condition,$,U),this}get names(){let $=super.names;if(pJ($,this.condition),this.else)M1($,this.else.names);return $}}F6.kind="if";class b0 extends o6{}b0.kind="for";class SI extends b0{constructor($){super();this.iteration=$}render($){return`for(${this.iteration})`+super.render($)}optimizeNames($,U){if(!super.optimizeNames($,U))return;return this.iteration=B0(this.iteration,$,U),this}get names(){return M1(super.names,this.iteration.names)}}class PI extends b0{constructor($,U,W,J){super();this.varKind=$,this.name=U,this.from=W,this.to=J}render($){let U=$.es5?i4.varKinds.var:this.varKind,{name:W,from:J,to:X}=this;return`for(${U} ${W}=${J}; ${W}<${X}; ${W}++)`+super.render($)}get names(){let $=pJ(super.names,this.from);return pJ($,this.to)}}class l8 extends b0{constructor($,U,W,J){super();this.loop=$,this.varKind=U,this.name=W,this.iterable=J}render($){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render($)}optimizeNames($,U){if(!super.optimizeNames($,U))return;return this.iterable=B0(this.iterable,$,U),this}get names(){return M1(super.names,this.iterable.names)}}class iJ extends o6{constructor($,U,W){super();this.name=$,this.args=U,this.async=W}render($){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render($)}}iJ.kind="func";class nJ extends dJ{render($){return"return "+super.render($)}}nJ.kind="return";class RI extends o6{render($){let U="try"+super.render($);if(this.catch)U+=this.catch.render($);if(this.finally)U+=this.finally.render($);return U}optimizeNodes(){var $,U;return super.optimizeNodes(),($=this.catch)===null||$===void 0||$.optimizeNodes(),(U=this.finally)===null||U===void 0||U.optimizeNodes(),this}optimizeNames($,U){var W,J;return super.optimizeNames($,U),(W=this.catch)===null||W===void 0||W.optimizeNames($,U),(J=this.finally)===null||J===void 0||J.optimizeNames($,U),this}get names(){let $=super.names;if(this.catch)M1($,this.catch.names);if(this.finally)M1($,this.finally.names);return $}}class rJ extends o6{constructor($){super();this.error=$}render($){return`catch(${this.error})`+super.render($)}}rJ.kind="catch";class cJ extends o6{render($){return"finally"+super.render($)}}cJ.kind="finally";class kI{constructor($,U={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...U,_n:U.lines?`
|
|
3
3
|
`:""},this._extScope=$,this._scope=new i4.Scope({parent:$}),this._nodes=[new EI]}toString(){return this._root.render(this.opts)}name($){return this._scope.name($)}scopeName($){return this._extScope.name($)}scopeValue($,U){let W=this._extScope.value($,U);return(this._values[W.prefix]||(this._values[W.prefix]=new Set)).add(W),W}getScopeValue($,U){return this._extScope.getValue($,U)}scopeRefs($){return this._extScope.scopeRefs($,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def($,U,W,J){let X=this._scope.toName(U);if(W!==void 0&&J)this._constants[X.str]=W;return this._leafNode(new OI($,X,W)),X}const($,U,W){return this._def(i4.varKinds.const,$,U,W)}let($,U,W){return this._def(i4.varKinds.let,$,U,W)}var($,U,W){return this._def(i4.varKinds.var,$,U,W)}assign($,U,W){return this._leafNode(new i8($,U,W))}add($,U){return this._leafNode(new qI($,H4.operators.ADD,U))}code($){if(typeof $=="function")$();else if($!==z$.nil)this._leafNode(new MI($));return this}object(...$){let U=["{"];for(let[W,J]of $){if(U.length>1)U.push(",");if(U.push(W),W!==J||this.opts.es5)U.push(":"),(0,z$.addCodeArg)(U,J)}return U.push("}"),new z$._Code(U)}if($,U,W){if(this._blockNode(new F6($)),U&&W)this.code(U).else().code(W).endIf();else if(U)this.code(U).endIf();else if(W)throw Error('CodeGen: "else" body without "then" body');return this}elseIf($){return this._elseNode(new F6($))}else(){return this._elseNode(new zW)}endIf(){return this._endBlockNode(F6,zW)}_for($,U){if(this._blockNode($),U)this.code(U).endFor();return this}for($,U){return this._for(new SI($),U)}forRange($,U,W,J,X=this.opts.es5?i4.varKinds.var:i4.varKinds.let){let v=this._scope.toName($);return this._for(new PI(X,v,U,W),()=>J(v))}forOf($,U,W,J=i4.varKinds.const){let X=this._scope.toName($);if(this.opts.es5){let v=U instanceof z$.Name?U:this.var("_arr",U);return this.forRange("_i",0,z$._`${v}.length`,(z)=>{this.var(X,z$._`${v}[${z}]`),W(X)})}return this._for(new l8("of",J,X,U),()=>W(X))}forIn($,U,W,J=this.opts.es5?i4.varKinds.var:i4.varKinds.const){if(this.opts.ownProperties)return this.forOf($,z$._`Object.keys(${U})`,W);let X=this._scope.toName($);return this._for(new l8("in",J,X,U),()=>W(X))}endFor(){return this._endBlockNode(b0)}label($){return this._leafNode(new VI($))}break($){return this._leafNode(new FI($))}return($){let U=new nJ;if(this._blockNode(U),this.code($),U.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(nJ)}try($,U,W){if(!U&&!W)throw Error('CodeGen: "try" without "catch" and "finally"');let J=new RI;if(this._blockNode(J),this.code($),U){let X=this.name("e");this._currNode=J.catch=new rJ(X),U(X)}if(W)this._currNode=J.finally=new cJ,this.code(W);return this._endBlockNode(rJ,cJ)}throw($){return this._leafNode(new jI($))}block($,U){if(this._blockStarts.push(this._nodes.length),$)this.code($).endBlock(U);return this}endBlock($){let U=this._blockStarts.pop();if(U===void 0)throw Error("CodeGen: not in self-balancing block");let W=this._nodes.length-U;if(W<0||$!==void 0&&W!==$)throw Error(`CodeGen: wrong number of nodes: ${W} vs ${$} expected`);return this._nodes.length=U,this}func($,U=z$.nil,W,J){if(this._blockNode(new iJ($,U,W)),J)this.code(J).endFunc();return this}endFunc(){return this._endBlockNode(iJ)}optimize($=1){while($-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode($){return this._currNode.nodes.push($),this}_blockNode($){this._currNode.nodes.push($),this._nodes.push($)}_endBlockNode($,U){let W=this._currNode;if(W instanceof $||U&&W instanceof U)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${U?`${$.kind}/${U.kind}`:$.kind}"`)}_elseNode($){let U=this._currNode;if(!(U instanceof F6))throw Error('CodeGen: "else" without "if"');return this._currNode=U.else=$,this}get _root(){return this._nodes[0]}get _currNode(){let $=this._nodes;return $[$.length-1]}set _currNode($){let U=this._nodes;U[U.length-1]=$}}H4.CodeGen=kI;function M1($,U){for(let W in U)$[W]=($[W]||0)+(U[W]||0);return $}function pJ($,U){return U instanceof z$._CodeOrName?M1($,U.names):$}function B0($,U,W){if($ instanceof z$.Name)return J($);if(!X($))return $;return new z$._Code($._items.reduce((v,z)=>{if(z instanceof z$.Name)z=J(z);if(z instanceof z$._Code)v.push(...z._items);else v.push(z);return v},[]));function J(v){let z=W[v.str];if(z===void 0||U[v.str]!==1)return v;return delete U[v.str],z}function X(v){return v instanceof z$._Code&&v._items.some((z)=>z instanceof z$.Name&&U[z.str]===1&&W[z.str]!==void 0)}}function JC($,U){for(let W in U)$[W]=($[W]||0)-(U[W]||0)}function ZI($){return typeof $=="boolean"||typeof $=="number"||$===null?!$:z$._`!${m8($)}`}H4.not=ZI;var vC=TI(H4.operators.AND);function zC(...$){return $.reduce(vC)}H4.and=zC;var QC=TI(H4.operators.OR);function GC(...$){return $.reduce(QC)}H4.or=GC;function TI($){return(U,W)=>U===z$.nil?W:W===z$.nil?U:z$._`${m8(U)} ${$} ${m8(W)}`}function m8($){return $ instanceof z$.Name?$:z$._`(${$})`}});var Y$=q((lI)=>{Object.defineProperty(lI,"__esModule",{value:!0});lI.checkStrictMode=lI.getErrorPath=lI.Type=lI.useFunc=lI.setEvaluated=lI.evaluatedPropsToName=lI.mergeEvaluated=lI.eachItem=lI.unescapeJsonPointer=lI.escapeJsonPointer=lI.escapeFragment=lI.unescapeFragment=lI.schemaRefOrVal=lI.schemaHasRulesButRef=lI.schemaHasRules=lI.checkUnknownRules=lI.alwaysValidSchema=lI.toHash=void 0;var O$=s(),bC=vW();function BC($){let U={};for(let W of $)U[W]=!0;return U}lI.toHash=BC;function wC($,U){if(typeof U=="boolean")return U;if(Object.keys(U).length===0)return!0;return uI($,U),!xI(U,$.self.RULES.all)}lI.alwaysValidSchema=wC;function uI($,U=$.schema){let{opts:W,self:J}=$;if(!W.strictSchema)return;if(typeof U==="boolean")return;let X=J.RULES.keywords;for(let v in U)if(!X[v])hI($,`unknown keyword: "${v}"`)}lI.checkUnknownRules=uI;function xI($,U){if(typeof $=="boolean")return!$;for(let W in $)if(U[W])return!0;return!1}lI.schemaHasRules=xI;function AC($,U){if(typeof $=="boolean")return!$;for(let W in $)if(W!=="$ref"&&U.all[W])return!0;return!1}lI.schemaHasRulesButRef=AC;function LC({topSchemaRef:$,schemaPath:U},W,J,X){if(!X){if(typeof W=="number"||typeof W=="boolean")return W;if(typeof W=="string")return O$._`${W}`}return O$._`${$}${U}${(0,O$.getProperty)(J)}`}lI.schemaRefOrVal=LC;function IC($){return yI(decodeURIComponent($))}lI.unescapeFragment=IC;function KC($){return encodeURIComponent(r8($))}lI.escapeFragment=KC;function r8($){if(typeof $=="number")return`${$}`;return $.replace(/~/g,"~0").replace(/\//g,"~1")}lI.escapeJsonPointer=r8;function yI($){return $.replace(/~1/g,"/").replace(/~0/g,"~")}lI.unescapeJsonPointer=yI;function NC($,U){if(Array.isArray($))for(let W of $)U(W);else U($)}lI.eachItem=NC;function _I({mergeNames:$,mergeToName:U,mergeValues:W,resultToName:J}){return(X,v,z,Q)=>{let G=z===void 0?v:z instanceof O$.Name?(v instanceof O$.Name?$(X,v,z):U(X,v,z),z):v instanceof O$.Name?(U(X,z,v),v):W(v,z);return Q===O$.Name&&!(G instanceof O$.Name)?J(X,G):G}}lI.mergeEvaluated={props:_I({mergeNames:($,U,W)=>$.if(O$._`${W} !== true && ${U} !== undefined`,()=>{$.if(O$._`${U} === true`,()=>$.assign(W,!0),()=>$.assign(W,O$._`${W} || {}`).code(O$._`Object.assign(${W}, ${U})`))}),mergeToName:($,U,W)=>$.if(O$._`${W} !== true`,()=>{if(U===!0)$.assign(W,!0);else $.assign(W,O$._`${W} || {}`),c8($,W,U)}),mergeValues:($,U)=>$===!0?!0:{...$,...U},resultToName:fI}),items:_I({mergeNames:($,U,W)=>$.if(O$._`${W} !== true && ${U} !== undefined`,()=>$.assign(W,O$._`${U} === true ? true : ${W} > ${U} ? ${W} : ${U}`)),mergeToName:($,U,W)=>$.if(O$._`${W} !== true`,()=>$.assign(W,U===!0?!0:O$._`${W} > ${U} ? ${W} : ${U}`)),mergeValues:($,U)=>$===!0?!0:Math.max($,U),resultToName:($,U)=>$.var("items",U)})};function fI($,U){if(U===!0)return $.var("props",!0);let W=$.var("props",O$._`{}`);if(U!==void 0)c8($,W,U);return W}lI.evaluatedPropsToName=fI;function c8($,U,W){Object.keys(W).forEach((J)=>$.assign(O$._`${U}${(0,O$.getProperty)(J)}`,!0))}lI.setEvaluated=c8;var gI={};function OC($,U){return $.scopeValue("func",{ref:U,code:gI[U.code]||(gI[U.code]=new bC._Code(U.code))})}lI.useFunc=OC;var n8;(function($){$[$.Num=0]="Num",$[$.Str=1]="Str"})(n8||(lI.Type=n8={}));function qC($,U,W){if($ instanceof O$.Name){let J=U===n8.Num;return W?J?O$._`"[" + ${$} + "]"`:O$._`"['" + ${$} + "']"`:J?O$._`"/" + ${$}`:O$._`"/" + ${$}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return W?(0,O$.getProperty)($).toString():"/"+r8($)}lI.getErrorPath=qC;function hI($,U,W=$.opts.strictSchema){if(!W)return;if(U=`strict mode: ${U}`,W===!0)throw Error(U);$.self.logger.warn(U)}lI.checkStrictMode=hI});var j6=q((iI)=>{Object.defineProperty(iI,"__esModule",{value:!0});var o$=s(),fC={data:new o$.Name("data"),valCxt:new o$.Name("valCxt"),instancePath:new o$.Name("instancePath"),parentData:new o$.Name("parentData"),parentDataProperty:new o$.Name("parentDataProperty"),rootData:new o$.Name("rootData"),dynamicAnchors:new o$.Name("dynamicAnchors"),vErrors:new o$.Name("vErrors"),errors:new o$.Name("errors"),this:new o$.Name("this"),self:new o$.Name("self"),scope:new o$.Name("scope"),json:new o$.Name("json"),jsonPos:new o$.Name("jsonPos"),jsonLen:new o$.Name("jsonLen"),jsonPart:new o$.Name("jsonPart")};iI.default=fC});var QW=q((pI)=>{Object.defineProperty(pI,"__esModule",{value:!0});pI.extendErrors=pI.resetErrorsCount=pI.reportExtraError=pI.reportError=pI.keyword$DataError=pI.keywordError=void 0;var D$=s(),aJ=Y$(),U4=j6();pI.keywordError={message:({keyword:$})=>D$.str`must pass "${$}" keyword validation`};pI.keyword$DataError={message:({keyword:$,schemaType:U})=>U?D$.str`"${$}" keyword must be ${U} ($data)`:D$.str`"${$}" keyword is invalid ($data)`};function lC($,U=pI.keywordError,W,J){let{it:X}=$,{gen:v,compositeRule:z,allErrors:Q}=X,G=cI($,U,W);if(J!==null&&J!==void 0?J:z||Q)nI(v,G);else rI(X,D$._`[${G}]`)}pI.reportError=lC;function mC($,U=pI.keywordError,W){let{it:J}=$,{gen:X,compositeRule:v,allErrors:z}=J,Q=cI($,U,W);if(nI(X,Q),!(v||z))rI(J,U4.default.vErrors)}pI.reportExtraError=mC;function iC($,U){$.assign(U4.default.errors,U),$.if(D$._`${U4.default.vErrors} !== null`,()=>$.if(U,()=>$.assign(D$._`${U4.default.vErrors}.length`,U),()=>$.assign(U4.default.vErrors,null)))}pI.resetErrorsCount=iC;function nC({gen:$,keyword:U,schemaValue:W,data:J,errsCount:X,it:v}){if(X===void 0)throw Error("ajv implementation error");let z=$.name("err");$.forRange("i",X,U4.default.errors,(Q)=>{if($.const(z,D$._`${U4.default.vErrors}[${Q}]`),$.if(D$._`${z}.instancePath === undefined`,()=>$.assign(D$._`${z}.instancePath`,(0,D$.strConcat)(U4.default.instancePath,v.errorPath))),$.assign(D$._`${z}.schemaPath`,D$.str`${v.errSchemaPath}/${U}`),v.opts.verbose)$.assign(D$._`${z}.schema`,W),$.assign(D$._`${z}.data`,J)})}pI.extendErrors=nC;function nI($,U){let W=$.const("err",U);$.if(D$._`${U4.default.vErrors} === null`,()=>$.assign(U4.default.vErrors,D$._`[${W}]`),D$._`${U4.default.vErrors}.push(${W})`),$.code(D$._`${U4.default.errors}++`)}function rI($,U){let{gen:W,validateName:J,schemaEnv:X}=$;if(X.$async)W.throw(D$._`new ${$.ValidationError}(${U})`);else W.assign(D$._`${J}.errors`,U),W.return(!1)}var E1={keyword:new D$.Name("keyword"),schemaPath:new D$.Name("schemaPath"),params:new D$.Name("params"),propertyName:new D$.Name("propertyName"),message:new D$.Name("message"),schema:new D$.Name("schema"),parentSchema:new D$.Name("parentSchema")};function cI($,U,W){let{createErrors:J}=$.it;if(J===!1)return D$._`{}`;return rC($,U,W)}function rC($,U,W={}){let{gen:J,it:X}=$,v=[cC(X,W),pC($,W)];return oC($,U,v),J.object(...v)}function cC({errorPath:$},{instancePath:U}){let W=U?D$.str`${$}${(0,aJ.getErrorPath)(U,aJ.Type.Str)}`:$;return[U4.default.instancePath,(0,D$.strConcat)(U4.default.instancePath,W)]}function pC({keyword:$,it:{errSchemaPath:U}},{schemaPath:W,parentSchema:J}){let X=J?U:D$.str`${U}/${$}`;if(W)X=D$.str`${X}${(0,aJ.getErrorPath)(W,aJ.Type.Str)}`;return[E1.schemaPath,X]}function oC($,{params:U,message:W},J){let{keyword:X,data:v,schemaValue:z,it:Q}=$,{opts:G,propertyName:Y,topSchemaRef:D,schemaPath:H}=Q;if(J.push([E1.keyword,X],[E1.params,typeof U=="function"?U($):U||D$._`{}`]),G.messages)J.push([E1.message,typeof W=="function"?W($):W]);if(G.verbose)J.push([E1.schema,z],[E1.parentSchema,D$._`${D}${H}`],[U4.default.data,v]);if(Y)J.push([E1.propertyName,Y])}});var eI=q((tI)=>{Object.defineProperty(tI,"__esModule",{value:!0});tI.boolOrEmptySchema=tI.topBoolOrEmptySchema=void 0;var sC=QW(),$2=s(),U2=j6(),W2={message:"boolean schema is false"};function X2($){let{gen:U,schema:W,validateName:J}=$;if(W===!1)dI($,!1);else if(typeof W=="object"&&W.$async===!0)U.return(U2.default.data);else U.assign($2._`${J}.errors`,null),U.return(!0)}tI.topBoolOrEmptySchema=X2;function J2($,U){let{gen:W,schema:J}=$;if(J===!1)W.var(U,!1),dI($);else W.var(U,!0)}tI.boolOrEmptySchema=J2;function dI($,U){let{gen:W,data:J}=$,X={gen:W,keyword:"false schema",data:J,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:$};(0,sC.reportError)(X,W2,void 0,U)}});var o8=q((sI)=>{Object.defineProperty(sI,"__esModule",{value:!0});sI.getRules=sI.isJSONType=void 0;var z2=["string","number","integer","boolean","null","object","array"],Q2=new Set(z2);function G2($){return typeof $=="string"&&Q2.has($)}sI.isJSONType=G2;function Y2(){let $={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...$,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},$.number,$.string,$.array,$.object],post:{rules:[]},all:{},keywords:{}}}sI.getRules=Y2});var d8=q((XK)=>{Object.defineProperty(XK,"__esModule",{value:!0});XK.shouldUseRule=XK.shouldUseGroup=XK.schemaHasRulesForType=void 0;function H2({schema:$,self:U},W){let J=U.RULES.types[W];return J&&J!==!0&&UK($,J)}XK.schemaHasRulesForType=H2;function UK($,U){return U.rules.some((W)=>WK($,W))}XK.shouldUseGroup=UK;function WK($,U){var W;return $[U.keyword]!==void 0||((W=U.definition.implements)===null||W===void 0?void 0:W.some((J)=>$[J]!==void 0))}XK.shouldUseRule=WK});var GW=q((GK)=>{Object.defineProperty(GK,"__esModule",{value:!0});GK.reportTypeError=GK.checkDataTypes=GK.checkDataType=GK.coerceAndCheckDataType=GK.getJSONTypes=GK.getSchemaTypes=GK.DataType=void 0;var w2=o8(),A2=d8(),L2=QW(),a=s(),vK=Y$(),w0;(function($){$[$.Correct=0]="Correct",$[$.Wrong=1]="Wrong"})(w0||(GK.DataType=w0={}));function I2($){let U=zK($.type);if(U.includes("null")){if($.nullable===!1)throw Error("type: null contradicts nullable: false")}else{if(!U.length&&$.nullable!==void 0)throw Error('"nullable" cannot be used without "type"');if($.nullable===!0)U.push("null")}return U}GK.getSchemaTypes=I2;function zK($){let U=Array.isArray($)?$:$?[$]:[];if(U.every(w2.isJSONType))return U;throw Error("type must be JSONType or JSONType[]: "+U.join(","))}GK.getJSONTypes=zK;function K2($,U){let{gen:W,data:J,opts:X}=$,v=N2(U,X.coerceTypes),z=U.length>0&&!(v.length===0&&U.length===1&&(0,A2.schemaHasRulesForType)($,U[0]));if(z){let Q=a8(U,J,X.strictNumbers,w0.Wrong);W.if(Q,()=>{if(v.length)O2($,U,v);else e8($)})}return z}GK.coerceAndCheckDataType=K2;var QK=new Set(["string","number","integer","boolean","null"]);function N2($,U){return U?$.filter((W)=>QK.has(W)||U==="array"&&W==="array"):[]}function O2($,U,W){let{gen:J,data:X,opts:v}=$,z=J.let("dataType",a._`typeof ${X}`),Q=J.let("coerced",a._`undefined`);if(v.coerceTypes==="array")J.if(a._`${z} == 'object' && Array.isArray(${X}) && ${X}.length == 1`,()=>J.assign(X,a._`${X}[0]`).assign(z,a._`typeof ${X}`).if(a8(U,X,v.strictNumbers),()=>J.assign(Q,X)));J.if(a._`${Q} !== undefined`);for(let Y of W)if(QK.has(Y)||Y==="array"&&v.coerceTypes==="array")G(Y);J.else(),e8($),J.endIf(),J.if(a._`${Q} !== undefined`,()=>{J.assign(X,Q),q2($,Q)});function G(Y){switch(Y){case"string":J.elseIf(a._`${z} == "number" || ${z} == "boolean"`).assign(Q,a._`"" + ${X}`).elseIf(a._`${X} === null`).assign(Q,a._`""`);return;case"number":J.elseIf(a._`${z} == "boolean" || ${X} === null
|
|
4
4
|
|| (${z} == "string" && ${X} && ${X} == +${X})`).assign(Q,a._`+${X}`);return;case"integer":J.elseIf(a._`${z} === "boolean" || ${X} === null
|
package/dist/config.d.ts
CHANGED
|
@@ -18,6 +18,9 @@ export interface RuntimeEnv {
|
|
|
18
18
|
MCP_OAUTH_MODE?: string;
|
|
19
19
|
MCP_OAUTH_APPLY_ALL?: string;
|
|
20
20
|
MCP_OAUTH_TOOL_OVERRIDES?: string;
|
|
21
|
+
MCP_MEMBER_KEY_MODE?: string;
|
|
22
|
+
MCP_MEMBER_KEY_RUNTIME_URL?: string;
|
|
23
|
+
MCP_MEMBER_KEY_RUNTIME_TOKEN?: string;
|
|
21
24
|
MCP_RUNTIME_AUTH_ACCESS_MODE?: string;
|
|
22
25
|
MCP_RUNTIME_AUTH_AUDIENCE?: string;
|
|
23
26
|
MCP_RUNTIME_AUTH_DEPLOYMENT_ID?: string;
|
|
@@ -50,6 +53,9 @@ export interface RuntimeOAuthConfig {
|
|
|
50
53
|
applyToAllTools: boolean;
|
|
51
54
|
toolOverrides: Partial<Record<string, 'on' | 'off'>>;
|
|
52
55
|
}
|
|
56
|
+
export interface RuntimeMemberKeyConfig {
|
|
57
|
+
runtimeUrl: string;
|
|
58
|
+
}
|
|
53
59
|
export interface CallerContext {
|
|
54
60
|
userId: string | null;
|
|
55
61
|
runtimeToken: string | null;
|
|
@@ -73,6 +79,7 @@ export interface RuntimeConfig {
|
|
|
73
79
|
customHeaders: Record<string, string>;
|
|
74
80
|
accessMode: RuntimeAccessMode;
|
|
75
81
|
oauth: RuntimeOAuthConfig | null;
|
|
82
|
+
memberKey: RuntimeMemberKeyConfig | null;
|
|
76
83
|
runtimeAuth: RuntimeAccessConfig | null;
|
|
77
84
|
}
|
|
78
85
|
export declare function getProcessEnv(): RuntimeEnv;
|
|
@@ -88,3 +95,7 @@ export declare function postOAuthRuntimeRequest(config: RuntimeConfig, body: {
|
|
|
88
95
|
forceRefresh: boolean;
|
|
89
96
|
callerRuntimeToken: string | null;
|
|
90
97
|
}): Promise<Response>;
|
|
98
|
+
export declare function postMemberKeyRuntimeRequest(config: RuntimeConfig, body: {
|
|
99
|
+
callerRuntimeToken: string;
|
|
100
|
+
reportInvalid: boolean;
|
|
101
|
+
}): Promise<Response>;
|
package/dist/container-host.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @mcpcloud/runtime v0.3.
|
|
2
|
-
import{mkdirSync as
|
|
1
|
+
/*! @mcpcloud/runtime v0.3.1 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
|
|
2
|
+
import{mkdirSync as P,mkdtempSync as S,writeFileSync as R}from"node:fs";import{tmpdir as E}from"node:os";import{dirname as w,join as C}from"node:path";import{pathToFileURL as k}from"node:url";import{timingSafeEqual as K}from"node:crypto";import{createServer as D}from"node:http";import{Readable as M}from"node:stream";function H(){return typeof process>"u"?{}:process.env}function j(G=H()){return G.MCP_BEARER_TOKEN?.trim()||null}function U(G,Q){let J=Buffer.from(G),X=Buffer.from(Q);return J.length===X.length&&K(J,X)}function B(G,Q){let J=j(Q);if(!J)return null;if(new URL(G.url).pathname==="/health")return null;let X=G.headers.get("authorization")??"",Y=/^Bearer\s+(.+)$/i.exec(X.trim());if(Y&&U(Y[1].trim(),J))return null;return Response.json({error:"unauthorized",message:"This MCP endpoint requires a bearer token (set in Authorization: Bearer <token>)."},{status:401,headers:{"www-authenticate":"Bearer"}})}function A(G,Q){let J=new URL(G.url??"/",Q),X=new Headers;for(let[$,F]of Object.entries(G.headers))if(Array.isArray(F))for(let L of F)X.append($,L);else if(typeof F==="string")X.set($,F);let Y=G.method??"GET",Z=Y==="GET"||Y==="HEAD"?void 0:M.toWeb(G);return new Request(J,{method:Y,headers:X,body:Z,...Z?{duplex:"half"}:{}})}async function V(G,Q){if(Q.statusCode=G.status,G.headers.forEach((X,Y)=>{Q.setHeader(Y,X)}),!G.body){Q.end();return}let J=G.body.getReader();for(;;){let{done:X,value:Y}=await J.read();if(X)break;Q.write(Y)}Q.end()}function z(G,Q={}){let J=Q.port??Number(process.env.PORT??8080),X=Q.hostname??"0.0.0.0",Y=D((Z,$)=>{let F=`http://${Z.headers.host??`${X}:${J}`}`,L=A(Z,F),W=B(L,Q.env);(W?Promise.resolve(W):G.handleRequest(L,Q.env)).then((x)=>V(x,$)).catch(()=>{$.statusCode=500,$.end(JSON.stringify({error:"internal_error"}))})});return Y.listen(J,X),Y}var N=1;function I(G=process.env){let Q=G.BUNDLE_URL?.trim(),J=G.BUNDLE_SHA256?.trim();if(!Q)throw Error("BUNDLE_URL is not set; the runtime host has no code to run.");if(!J)throw Error("BUNDLE_SHA256 is not set; refusing to boot unverified code.");let X=Number(G.PORT??8080);if(!Number.isInteger(X)||X<=0)throw Error(`Invalid PORT: ${String(G.PORT)}`);return{bundleUrl:Q,bundleSha256:J,port:X}}async function g(G){let Q=G.buffer.slice(G.byteOffset,G.byteOffset+G.byteLength),J=await crypto.subtle.digest("SHA-256",Q);return Array.from(new Uint8Array(J)).map((X)=>X.toString(16).padStart(2,"0")).join("")}function T(G){let Q=JSON.parse(new TextDecoder().decode(G));if(!Q||typeof Q!=="object")throw Error("Boot artifact must be a JSON object.");let J=Q;if(J.schemaVersion!==N)throw Error(`Unsupported boot artifact schemaVersion: ${String(J.schemaVersion)}.`);if(typeof J.runtimeVersion!=="string"||typeof J.mainEntry!=="string"||!Array.isArray(J.files))throw Error("Boot artifact is malformed.");let X=J.files.map((Y)=>{if(!Y||typeof Y!=="object"||typeof Y.path!=="string"||typeof Y.content!=="string")throw Error("Boot artifact files must be { path, content }.");let Z=Y;return{path:Z.path,content:Z.content}});return{schemaVersion:N,runtimeVersion:J.runtimeVersion,mainEntry:J.mainEntry,files:X}}async function _(G,Q=fetch){let J=await Q(G.bundleUrl);if(!J.ok)throw Error(`Bundle fetch failed (HTTP ${J.status}).`);let X=new Uint8Array(await J.arrayBuffer()),Y=await g(X);if(Y!==G.bundleSha256.toLowerCase())throw Error(`Bundle sha256 mismatch (expected ${G.bundleSha256}, got ${Y}).`);return T(X)}function O(G,Q){for(let J of G.files){let X=C(Q,J.path);P(w(X),{recursive:!0}),R(X,J.content)}return{entryPath:C(Q,G.mainEntry)}}async function q(G={}){let Q=G.bootConfig??I(),J=await _(Q,G.fetchImpl),X=G.workDir??S(C(E(),"mcpcloud-server-")),{entryPath:Y}=O(J,X),Z=await import(k(Y).href),$=Z.server??Z.default;if(!$)throw Error(`Boot module ${J.mainEntry} does not export a \`server\`.`);let F={port:Q.port,...G.hostname?{hostname:G.hostname}:{},...G.env?{env:G.env}:{}};return z($,F)}export{q as serveFromBundle,I as resolveBootConfig,O as materializeBundle,_ as fetchAndVerifyBundle,N as BOOT_ARTIFACT_SCHEMA_VERSION};
|
package/dist/http.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CallerContext, RuntimeConfig } from './config';
|
|
2
2
|
import type { ToolDefinition } from './types';
|
|
3
|
+
export declare function joinUpstreamUrl(baseUrl: string, path: string): URL;
|
|
3
4
|
export declare function buildUpstreamRequest(tool: ToolDefinition, rawInput: Record<string, unknown>, config: RuntimeConfig, caller: CallerContext, forceOauthRefresh?: boolean): Promise<{
|
|
4
5
|
url: string;
|
|
5
6
|
init: RequestInit;
|