@mcpcloud/runtime 0.12.1 → 0.12.2

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.
@@ -1,4 +1,4 @@
1
- /*! @mcpcloud/runtime v0.12.1 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
1
+ /*! @mcpcloud/runtime v0.12.2 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
2
2
  var x3=Object.defineProperty;var c3=(W)=>W;function u3(W,Q){this[W]=c3.bind(null,Q)}var HY=(W,Q)=>{for(var Y in Q)x3(W,Y,{get:Q[Y],enumerable:!0,configurable:!0,set:u3.bind(Q,Y)})};import k3 from"node:process";var wY;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 V=B[z];if(!(V in w))w[V]=L[V].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 N8=Symbol("zod_brand");class a extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class DW extends Error{constructor(W){super(`Encountered unidirectional transform during encode: ${W}`);this.name="ZodEncodeError"}}(wY=globalThis).__zod_globalConfig??(wY.__zod_globalConfig={});var AW=globalThis.__zod_globalConfig;function l(W){if(W)Object.assign(AW,W);return AW}var F={};HY(F,{unwrapMessage:()=>UW,uint8ArrayToHex:()=>K9,uint8ArrayToBase64url:()=>A9,uint8ArrayToBase64:()=>MY,stringifyPrimitive:()=>uW,slugify:()=>AQ,shallowClone:()=>qY,safeExtend:()=>Y9,required:()=>J9,randomString:()=>i3,propertyKeyTypes:()=>KQ,promiseAllObject:()=>n3,primitiveTypes:()=>KY,prefixIssues:()=>QW,pick:()=>s3,partial:()=>G9,parsedType:()=>MQ,optionalKeys:()=>LQ,omit:()=>W9,objectClone:()=>r3,numKeys:()=>t3,nullish:()=>IW,normalizeParams:()=>U,mergeDefs:()=>s,merge:()=>X9,jsonStringifyReplacer:()=>qW,joinValues:()=>hW,issue:()=>LW,isPlainObject:()=>XW,isObject:()=>HW,hexToUint8Array:()=>q9,getSizableOrigin:()=>BY,getParsedType:()=>e3,getLengthableOrigin:()=>$W,getEnumValues:()=>VW,getElementAtPath:()=>d3,floatSafeRemainder:()=>wQ,finalizeIssue:()=>d,extend:()=>Q9,explicitlyAborted:()=>NQ,escapeRegex:()=>WW,esc:()=>xW,defineLazy:()=>$,createTransparentProxy:()=>a3,cloneDef:()=>p3,clone:()=>t,cleanRegex:()=>FW,cleanEnum:()=>H9,captureStackTrace:()=>cW,cached:()=>KW,base64urlToUint8Array:()=>w9,base64ToUint8Array:()=>NY,assignProp:()=>YW,assertNotEqual:()=>m3,assertNever:()=>o3,assertIs:()=>f3,assertEqual:()=>y3,assert:()=>l3,allowsEval:()=>qQ,aborted:()=>GW,NUMBER_FORMAT_RANGES:()=>BQ,Class:()=>zY,BIGINT_FORMAT_RANGES:()=>LY});function y3(W){return W}function m3(W){return W}function f3(W){}function o3(W){throw Error("Unexpected value in exhaustive check")}function l3(W){}function VW(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 hW(W,Q="|"){return W.map((Y)=>uW(Y)).join(Q)}function qW(W,Q){if(typeof Q==="bigint")return Q.toString();return Q}function KW(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 FW(W){let Q=W.startsWith("^")?1:0,Y=W.endsWith("$")?W.length-1:W.length;return W.slice(Q,Y)}function wQ(W,Q){let Y=W/Q,X=Math.round(Y),G=Number.EPSILON*Math.max(Math.abs(Y),1);if(Math.abs(Y-X)<G)return 0;return Y-X}var AY=Symbol("evaluating");function $(W,Q,Y){let X=void 0;Object.defineProperty(W,Q,{get(){if(X===AY)return;if(X===void 0)X=AY,X=Y();return X},set(G){Object.defineProperty(W,Q,{value:G})},configurable:!0})}function r3(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 p3(W){return s(W._zod.def)}function d3(W,Q){if(!Q)return W;return Q.reduce((Y,X)=>Y?.[X],W)}function n3(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 i3(W=10){let Y="";for(let X=0;X<W;X++)Y+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return Y}function xW(W){return JSON.stringify(W)}function AQ(W){return W.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var cW="captureStackTrace"in Error?Error.captureStackTrace:(...W)=>{};function HW(W){return typeof W==="object"&&W!==null&&!Array.isArray(W)}var qQ=KW(()=>{if(AW.jitless)return!1;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 qY(W){if(XW(W))return{...W};if(Array.isArray(W))return[...W];if(W instanceof Map)return new Map(W);if(W instanceof Set)return new Set(W);return W}function t3(W){let Q=0;for(let Y in W)if(Object.prototype.hasOwnProperty.call(W,Y))Q++;return Q}var e3=(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}`)}},KQ=new Set(["string","number","symbol"]),KY=new Set(["string","number","bigint","boolean","symbol","undefined"]);function WW(W){return W.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function t(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 a3(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 uW(W){if(typeof W==="bigint")return W.toString()+"n";if(typeof W==="string")return`"${W}"`;return`${W}`}function LQ(W){return Object.keys(W).filter((Q)=>{return W[Q]._zod.optin==="optional"&&W[Q]._zod.optout==="optional"})}var BQ={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]},LY={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function s3(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 t(W,J)}function W9(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 t(W,J)}function Q9(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 t(W,G)}function Y9(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 t(W,Y)}function X9(W,Q){if(W._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");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:Q._zod.def.checks??[]});return t(W,Y)}function G9(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 t(Q,H)}function J9(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 t(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 NQ(W,Q=0){if(W.aborted===!0)return!0;for(let Y=Q;Y<W.issues.length;Y++)if(W.issues[Y]?.continue===!1)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 UW(W){return typeof W==="string"?W:W?.message}function d(W,Q,Y){let X=W.message?W.message:UW(W.inst?._zod.def?.error?.(W))??UW(Q?.error?.(W))??UW(Y.customError?.(W))??UW(Y.localeError?.(W))??"Invalid input",{inst:G,continue:J,input:H,...w}=W;if(w.path??(w.path=[]),w.message=X,Q?.reportInput)w.input=H;return w}function BY(W){if(W instanceof Set)return"set";if(W instanceof Map)return"map";if(W instanceof File)return"file";return"unknown"}function $W(W){if(Array.isArray(W))return"array";if(typeof W==="string")return"string";return"unknown"}function MQ(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 LW(...W){let[Q,Y,X]=W;if(typeof Q==="string")return{message:Q,code:"custom",input:Y,inst:X};return{...Q}}function H9(W){return Object.entries(W).filter(([Q,Y])=>{return Number.isNaN(Number.parseInt(Q,10))}).map((Q)=>Q[1])}function NY(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 MY(W){let Q="";for(let Y=0;Y<W.length;Y++)Q+=String.fromCharCode(W[Y]);return btoa(Q)}function w9(W){let Q=W.replace(/-/g,"+").replace(/_/g,"/"),Y="=".repeat((4-Q.length%4)%4);return NY(Q+Y)}function A9(W){return MY(W).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function q9(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 K9(W){return Array.from(W).map((Q)=>Q.toString(16).padStart(2,"0")).join("")}class zY{constructor(...W){}}var DY=(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,qW,2),Object.defineProperty(W,"toString",{value:()=>W.message,enumerable:!1})},yW=K("$ZodError",DY),zQ=K("$ZodError",DY,{Parent:Error});function UY(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 VY(W,Q=(Y)=>Y.message){let Y={_errors:[]},X=(G,J=[])=>{for(let H of G.issues)if(H.code==="invalid_union"&&H.errors.length)H.errors.map((w)=>X({issues:w},[...J,...H.path]));else if(H.code==="invalid_key")X({issues:H.issues},[...J,...H.path]);else if(H.code==="invalid_element")X({issues:H.issues},[...J,...H.path]);else{let w=[...J,...H.path];if(w.length===0)Y._errors.push(Q(H));else{let q=Y,L=0;while(L<w.length){let B=w[L];if(L!==w.length-1)q[B]=q[B]||{_errors:[]};else q[B]=q[B]||{_errors:[]},q[B]._errors.push(Q(H));q=q[B],L++}}}};return X(W),Y}var mW=(W)=>(Q,Y,X,G)=>{let J=X?{...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)=>d(q,J,l())));throw cW(w,G?.callee),w}return H.value};var fW=(W)=>async(Q,Y,X,G)=>{let J=X?{...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)=>d(q,J,l())));throw cW(w,G?.callee),w}return H.value};var EW=(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??yW)(J.issues.map((H)=>d(H,G,l())))}:{success:!0,data:J.value}},IY=EW(zQ),OW=(W)=>async(Q,Y,X)=>{let G=X?{...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)=>d(H,G,l())))}:{success:!0,data:J.value}},FY=OW(zQ),$Y=(W)=>(Q,Y,X)=>{let G=X?{...X,direction:"backward"}:{direction:"backward"};return mW(W)(Q,Y,G)};var EY=(W)=>(Q,Y,X)=>{return mW(W)(Q,Y,X)};var OY=(W)=>async(Q,Y,X)=>{let G=X?{...X,direction:"backward"}:{direction:"backward"};return fW(W)(Q,Y,G)};var PY=(W)=>async(Q,Y,X)=>{return fW(W)(Q,Y,X)};var RY=(W)=>(Q,Y,X)=>{let G=X?{...X,direction:"backward"}:{direction:"backward"};return EW(W)(Q,Y,G)};var SY=(W)=>(Q,Y,X)=>{return EW(W)(Q,Y,X)};var bY=(W)=>async(Q,Y,X)=>{let G=X?{...X,direction:"backward"}:{direction:"backward"};return OW(W)(Q,Y,G)};var TY=(W)=>async(Q,Y,X)=>{return OW(W)(Q,Y,X)};var _Y=/^[cC][0-9a-z]{6,}$/,ZY=/^[0-9a-z]+$/,CY=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,jY=/^[0-9a-vA-V]{20}$/,kY=/^[A-Za-z0-9]{27}$/,vY=/^[a-zA-Z0-9_-]{21}$/,gY=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var hY=/^([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})$/,DQ=(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 xY=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var B9="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function cY(){return new RegExp(B9,"u")}var uY=/^(?:(?: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])$/,yY=/^(([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 mY=/^((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])$/,fY=/^(([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])$/,oY=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,UQ=/^[A-Za-z0-9_-]*$/;var lY=/^https?$/,rY=/^\+[1-9]\d{6,14}$/,pY="(?:(?:\\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])))",dY=new RegExp(`^${pY}$`);function nY(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 iY(W){return new RegExp(`^${nY(W)}$`)}function tY(W){let Q=nY({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(`^${pY}T(?:${X})$`)}var eY=(W)=>{let Q=W?`[\\s\\S]{${W?.minimum??0},${W?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${Q}$`)};var aY=/^-?\d+$/,oW=/^-?\d+(?:\.\d+)?$/,sY=/^(?:true|false)$/i,W0=/^null$/i;var Q0=/^[^A-Z]*$/,Y0=/^[^a-z]*$/;var c=K("$ZodCheck",(W,Q)=>{var Y;W._zod??(W._zod={}),W._zod.def=Q,(Y=W._zod).onattach??(Y.onattach=[])}),X0={number:"number",bigint:"bigint",object:"date"},VQ=K("$ZodCheckLessThan",(W,Q)=>{c.init(W,Q);let Y=X0[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})}}),IQ=K("$ZodCheckGreaterThan",(W,Q)=>{c.init(W,Q);let Y=X0[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})}}),G0=K("$ZodCheckMultipleOf",(W,Q)=>{c.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):wQ(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})}}),J0=K("$ZodCheckNumberFormat",(W,Q)=>{c.init(W,Q),Q.format=Q.format||"float64";let Y=Q.format?.includes("int"),X=Y?"int":"number",[G,J]=BQ[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=aY}),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 H0=K("$ZodCheckMaxLength",(W,Q)=>{var Y;c.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=$W(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;c.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=$W(G);X.issues.push({origin:H,code:"too_small",minimum:Q.minimum,inclusive:!0,input:G,inst:W,continue:!Q.abort})}}),A0=K("$ZodCheckLengthEquals",(W,Q)=>{var Y;c.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=$W(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})}}),PW=K("$ZodCheckStringFormat",(W,Q)=>{var Y,X;if(c.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=()=>{})}),q0=K("$ZodCheckRegex",(W,Q)=>{PW.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})}}),K0=K("$ZodCheckLowerCase",(W,Q)=>{Q.pattern??(Q.pattern=Q0),PW.init(W,Q)}),L0=K("$ZodCheckUpperCase",(W,Q)=>{Q.pattern??(Q.pattern=Y0),PW.init(W,Q)}),B0=K("$ZodCheckIncludes",(W,Q)=>{c.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})}}),N0=K("$ZodCheckStartsWith",(W,Q)=>{c.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})}}),M0=K("$ZodCheckEndsWith",(W,Q)=>{c.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 z0=K("$ZodCheckOverwrite",(W,Q)=>{c.init(W,Q),W._zod.check=(Y)=>{Y.value=Q.tx(Y.value)}});class FQ{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 U0={major:4,minor:4,patch:3};var R=K("$ZodType",(W,Q)=>{var Y;W??(W={}),W._zod.def=Q,W._zod.bag=W._zod.bag||{},W._zod.version=U0;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(NQ(H))continue;if(!z._zod.def.when(H))continue}else if(L)continue;let V=H.issues.length,D=z._zod.check(H);if(D instanceof Promise&&q?.async===!1)throw new a;if(B||D instanceof Promise)B=(B??Promise.resolve()).then(async()=>{if(await D,H.issues.length===V)return;if(!L)L=GW(H,V)});else{if(H.issues.length===V)continue;if(!L)L=GW(H,V)}}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)}}$(W,"~standard",()=>({validate:(G)=>{try{let J=IY(W,G);return J.success?{value:J.data}:{issues:J.error?.issues}}catch(J){return FY(W,G).then((H)=>H.success?{value:H.data}:{issues:H.error?.issues})}},vendor:"zod",version:1}))}),dW=K("$ZodString",(W,Q)=>{R.init(W,Q),W._zod.pattern=[...W?._zod.bag?.patterns??[]].pop()??eY(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}}),S=K("$ZodStringFormat",(W,Q)=>{PW.init(W,Q),dW.init(W,Q)}),S0=K("$ZodGUID",(W,Q)=>{Q.pattern??(Q.pattern=hY),S.init(W,Q)}),b0=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=DQ(X))}else Q.pattern??(Q.pattern=DQ());S.init(W,Q)}),T0=K("$ZodEmail",(W,Q)=>{Q.pattern??(Q.pattern=xY),S.init(W,Q)}),_0=K("$ZodURL",(W,Q)=>{S.init(W,Q),W._zod.check=(Y)=>{try{let X=Y.value.trim();if(!Q.normalize&&Q.protocol?.source===lY.source){if(!/^https?:\/\//i.test(X)){Y.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:Y.value,inst:W,continue:!Q.abort});return}}let 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})}}}),Z0=K("$ZodEmoji",(W,Q)=>{Q.pattern??(Q.pattern=cY()),S.init(W,Q)}),C0=K("$ZodNanoID",(W,Q)=>{Q.pattern??(Q.pattern=vY),S.init(W,Q)}),j0=K("$ZodCUID",(W,Q)=>{Q.pattern??(Q.pattern=_Y),S.init(W,Q)}),k0=K("$ZodCUID2",(W,Q)=>{Q.pattern??(Q.pattern=ZY),S.init(W,Q)}),v0=K("$ZodULID",(W,Q)=>{Q.pattern??(Q.pattern=CY),S.init(W,Q)}),g0=K("$ZodXID",(W,Q)=>{Q.pattern??(Q.pattern=jY),S.init(W,Q)}),h0=K("$ZodKSUID",(W,Q)=>{Q.pattern??(Q.pattern=kY),S.init(W,Q)}),x0=K("$ZodISODateTime",(W,Q)=>{Q.pattern??(Q.pattern=tY(Q)),S.init(W,Q)}),c0=K("$ZodISODate",(W,Q)=>{Q.pattern??(Q.pattern=dY),S.init(W,Q)}),u0=K("$ZodISOTime",(W,Q)=>{Q.pattern??(Q.pattern=iY(Q)),S.init(W,Q)}),y0=K("$ZodISODuration",(W,Q)=>{Q.pattern??(Q.pattern=gY),S.init(W,Q)}),m0=K("$ZodIPv4",(W,Q)=>{Q.pattern??(Q.pattern=uY),S.init(W,Q),W._zod.bag.format="ipv4"}),f0=K("$ZodIPv6",(W,Q)=>{Q.pattern??(Q.pattern=yY),S.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 o0=K("$ZodCIDRv4",(W,Q)=>{Q.pattern??(Q.pattern=mY),S.init(W,Q)}),l0=K("$ZodCIDRv6",(W,Q)=>{Q.pattern??(Q.pattern=fY),S.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 r0(W){if(W==="")return!0;if(/\s/.test(W))return!1;if(W.length%4!==0)return!1;try{return atob(W),!0}catch{return!1}}var p0=K("$ZodBase64",(W,Q)=>{Q.pattern??(Q.pattern=oY),S.init(W,Q),W._zod.bag.contentEncoding="base64",W._zod.check=(Y)=>{if(r0(Y.value))return;Y.issues.push({code:"invalid_format",format:"base64",input:Y.value,inst:W,continue:!Q.abort})}});function N9(W){if(!UQ.test(W))return!1;let Q=W.replace(/[-_]/g,(X)=>X==="-"?"+":"/"),Y=Q.padEnd(Math.ceil(Q.length/4)*4,"=");return r0(Y)}var d0=K("$ZodBase64URL",(W,Q)=>{Q.pattern??(Q.pattern=UQ),S.init(W,Q),W._zod.bag.contentEncoding="base64url",W._zod.check=(Y)=>{if(N9(Y.value))return;Y.issues.push({code:"invalid_format",format:"base64url",input:Y.value,inst:W,continue:!Q.abort})}}),n0=K("$ZodE164",(W,Q)=>{Q.pattern??(Q.pattern=rY),S.init(W,Q)});function M9(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 i0=K("$ZodJWT",(W,Q)=>{S.init(W,Q),W._zod.check=(Y)=>{if(M9(Y.value,Q.alg))return;Y.issues.push({code:"invalid_format",format:"jwt",input:Y.value,inst:W,continue:!Q.abort})}});var EQ=K("$ZodNumber",(W,Q)=>{R.init(W,Q),W._zod.pattern=W._zod.bag.pattern??oW,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}}),t0=K("$ZodNumberFormat",(W,Q)=>{J0.init(W,Q),EQ.init(W,Q)}),e0=K("$ZodBoolean",(W,Q)=>{R.init(W,Q),W._zod.pattern=sY,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 a0=K("$ZodNull",(W,Q)=>{R.init(W,Q),W._zod.pattern=W0,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 s0=K("$ZodUnknown",(W,Q)=>{R.init(W,Q),W._zod.parse=(Y)=>Y}),W4=K("$ZodNever",(W,Q)=>{R.init(W,Q),W._zod.parse=(Y,X)=>{return Y.issues.push({expected:"never",code:"invalid_type",input:Y.value,inst:W}),Y}});function V0(W,Q,Y){if(W.issues.length)Q.issues.push(...QW(Y,W.issues));Q.value[Y]=W.value}var Q4=K("$ZodArray",(W,Q)=>{R.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)=>V0(L,Y,H)));else V0(q,Y,H)}if(J.length)return Promise.all(J).then(()=>Y);return Y}});function pW(W,Q,Y,X,G,J){let H=Y in X;if(W.issues.length){if(G&&J&&!H)return;Q.issues.push(...QW(Y,W.issues))}if(!H&&!G){if(!W.issues.length)Q.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[Y]});return}if(W.value===void 0){if(H)Q.value[Y]=void 0}else Q.value[Y]=W.value}function Y4(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=LQ(W.shape);return{...W,keys:Q,keySet:new Set(Q),numKeys:Q.length,optionalKeys:new Set(Y)}}function X4(W,Q,Y,X,G,J){let H=[],w=G.keySet,q=G.catchall._zod,L=q.def.type,B=q.optin==="optional",z=q.optout==="optional";for(let V in Q){if(V==="__proto__")continue;if(w.has(V))continue;if(L==="never"){H.push(V);continue}let D=q.run({value:Q[V],issues:[]},X);if(D instanceof Promise)W.push(D.then((O)=>pW(O,Y,V,Q,B,z)));else pW(D,Y,V,Q,B,z)}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 z9=K("$ZodObject",(W,Q)=>{if(R.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=KW(()=>Y4(Q));$(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 V of H.keys){let D=z[V],O=D._zod.optin==="optional",zW=D._zod.optout==="optional",g=D._zod.run({value:L[V],issues:[]},q);if(g instanceof Promise)B.push(g.then((JQ)=>pW(JQ,w,V,L,O,zW)));else pW(g,w,V,L,O,zW)}if(!J)return B.length?Promise.all(B).then(()=>w):w;return X4(B,L,w,q,X.value,W)}}),G4=K("$ZodObjectJIT",(W,Q)=>{z9.init(W,Q);let Y=W._zod.parse,X=KW(()=>Y4(Q)),G=(V)=>{let D=new FQ(["shape","payload","ctx"]),O=X.value,zW=(e)=>{let j=xW(e);return`shape[${j}]._zod.run({ value: input[${j}], issues: [] }, ctx)`};D.write("const input = payload.value;");let g=Object.create(null),JQ=0;for(let e of O.keys)g[e]=`key_${JQ++}`;D.write("const newResult = {};");for(let e of O.keys){let j=g[e],x=xW(e),GY=V[e],JY=GY?._zod?.optin==="optional",h3=GY?._zod?.optout==="optional";if(D.write(`const ${j} = ${zW(e)};`),JY&&h3)D.write(`
@@ -1,4 +1,4 @@
1
- /*! @mcpcloud/runtime v0.12.1 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
1
+ /*! @mcpcloud/runtime v0.12.2 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
2
2
  var pK=Object.create;var{getPrototypeOf:dK,defineProperty:m9,getOwnPropertyNames:oK}=Object;var tK=Object.prototype.hasOwnProperty;function aK($){return this[$]}var sK,eK,bz=($,v,U)=>{var J=$!=null&&typeof $==="object";if(J){var z=v?sK??=new WeakMap:eK??=new WeakMap,W=z.get($);if(W)return W}U=$!=null?pK(dK($)):{};let X=v||!$||!$.__esModule?m9(U,"default",{value:$,enumerable:!0}):U;for(let Q of oK($))if(!tK.call(X,Q))m9(X,Q,{get:aK.bind($,Q),enumerable:!0});if(J)z.set($,X);return X};var K=($,v)=>()=>(v||$((v={exports:{}}).exports,v),v.exports);var $F=($)=>$;function vF($,v){this[$]=$F.bind(null,v)}var s4=($,v)=>{for(var U in v)m9($,U,{get:v[U],enumerable:!0,configurable:!0,set:vF.bind(v,U)})};var j0=K(($B)=>{Object.defineProperty($B,"__esModule",{value:!0});$B.regexpCode=$B.getEsmExportName=$B.getProperty=$B.safeStringify=$B.stringify=$B.strConcat=$B.addCodeArg=$B.str=$B._=$B.nil=$B._Code=$B.Name=$B.IDENTIFIER=$B._CodeOrName=void 0;class kX{}$B._CodeOrName=kX;$B.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class A1 extends kX{constructor($){super();if(!$B.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}}}$B.Name=A1;class E4 extends kX{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((v,U)=>`${v}${U}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((v,U)=>{if(U instanceof A1)v[U.str]=(v[U.str]||0)+1;return v},{})}}$B._Code=E4;$B.nil=new E4("");function s3($,...v){let U=[$[0]],J=0;while(J<v.length)yY(U,v[J]),U.push($[++J]);return new E4(U)}$B._=s3;var xY=new E4("+");function e3($,...v){let U=[V0($[0])],J=0;while(J<v.length)U.push(xY),yY(U,v[J]),U.push(xY,V0($[++J]));return hS(U),new E4(U)}$B.str=e3;function yY($,v){if(v instanceof E4)$.push(...v._items);else if(v instanceof A1)$.push(v);else $.push(rS(v))}$B.addCodeArg=yY;function hS($){let v=1;while(v<$.length-1){if($[v]===xY){let U=nS($[v-1],$[v+1]);if(U!==void 0){$.splice(v-1,3,U);continue}$[v++]="+"}v++}}function nS($,v){if(v==='""')return $;if($==='""')return v;if(typeof $=="string"){if(v instanceof A1||$[$.length-1]!=='"')return;if(typeof v!="string")return`${$.slice(0,-1)}${v}"`;if(v[0]==='"')return $.slice(0,-1)+v.slice(1);return}if(typeof v=="string"&&v[0]==='"'&&!($ instanceof A1))return`"${$}${v.slice(1)}`;return}function mS($,v){return v.emptyStr()?$:$.emptyStr()?v:e3`${$}${v}`}$B.strConcat=mS;function rS($){return typeof $=="number"||typeof $=="boolean"||$===null?$:V0(Array.isArray($)?$.join(","):$)}function cS($){return new E4(V0($))}$B.stringify=cS;function V0($){return JSON.stringify($).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}$B.safeStringify=V0;function pS($){return typeof $=="string"&&$B.IDENTIFIER.test($)?new E4(`.${$}`):s3`[${$}]`}$B.getProperty=pS;function dS($){if(typeof $=="string"&&$B.IDENTIFIER.test($))return new E4(`${$}`);throw Error(`CodeGen: invalid export name: ${$}, use explicit $id name mapping`)}$B.getEsmExportName=dS;function oS($){return new E4($.toString())}$B.regexpCode=oS});var nY=K((JB)=>{Object.defineProperty(JB,"__esModule",{value:!0});JB.ValueScope=JB.ValueScopeName=JB.Scope=JB.varKinds=JB.UsedValueState=void 0;var z4=j0();class UB extends Error{constructor($){super(`CodeGen: "code" for ${$} not defined`);this.value=$.value}}var ZX;(function($){$[$.Started=0]="Started",$[$.Completed=1]="Completed"})(ZX||(JB.UsedValueState=ZX={}));JB.varKinds={const:new z4.Name("const"),let:new z4.Name("let"),var:new z4.Name("var")};class iY{constructor({prefixes:$,parent:v}={}){this._names={},this._prefixes=$,this._parent=v}toName($){return $ instanceof z4.Name?$:this.name($)}name($){return new z4.Name(this._newName($))}_newName($){let v=this._names[$]||this._nameGroup($);return`${$}${v.index++}`}_nameGroup($){var v,U;if(((U=(v=this._parent)===null||v===void 0?void 0:v._prefixes)===null||U===void 0?void 0:U.has($))||this._prefixes&&!this._prefixes.has($))throw Error(`CodeGen: prefix "${$}" is not allowed in this scope`);return this._names[$]={prefix:$,index:0}}}JB.Scope=iY;class hY extends z4.Name{constructor($,v){super(v);this.prefix=$}setValue($,{property:v,itemIndex:U}){this.value=$,this.scopePath=z4._`.${new z4.Name(v)}[${U}]`}}JB.ValueScopeName=hY;var GE=z4._`\n`;class zB extends iY{constructor($){super($);this._values={},this._scope=$.scope,this.opts={...$,_n:$.lines?GE:z4.nil}}get(){return this._scope}name($){return new hY($,this._newName($))}value($,v){var U;if(v.ref===void 0)throw Error("CodeGen: ref must be passed in value");let J=this.toName($),{prefix:z}=J,W=(U=v.key)!==null&&U!==void 0?U:v.ref,X=this._values[z];if(X){let D=X.get(W);if(D)return D}else X=this._values[z]=new Map;X.set(W,J);let Q=this._scope[z]||(this._scope[z]=[]),G=Q.length;return Q[G]=v.ref,J.setValue(v,{property:z,itemIndex:G}),J}getValue($,v){let U=this._values[$];if(!U)return;return U.get(v)}scopeRefs($,v=this._values){return this._reduceValues(v,(U)=>{if(U.scopePath===void 0)throw Error(`CodeGen: name "${U}" has no value`);return z4._`${$}${U.scopePath}`})}scopeCode($=this._values,v,U){return this._reduceValues($,(J)=>{if(J.value===void 0)throw Error(`CodeGen: name "${J}" has no value`);return J.value.code},v,U)}_reduceValues($,v,U={},J){let z=z4.nil;for(let W in $){let X=$[W];if(!X)continue;let Q=U[W]=U[W]||new Map;X.forEach((G)=>{if(Q.has(G))return;Q.set(G,ZX.Started);let D=v(G);if(D){let Y=this.opts.es5?JB.varKinds.var:JB.varKinds.const;z=z4._`${z}${Y} ${G} = ${D};${this.opts._n}`}else if(D=J===null||J===void 0?void 0:J(G))z=z4._`${z}${D}${this.opts._n}`;else throw new UB(G);Q.set(G,ZX.Completed)})}return z}}JB.ValueScope=zB});var v$=K((J4)=>{Object.defineProperty(J4,"__esModule",{value:!0});J4.or=J4.and=J4.not=J4.CodeGen=J4.operators=J4.varKinds=J4.ValueScopeName=J4.ValueScope=J4.Scope=J4.Name=J4.regexpCode=J4.stringify=J4.getProperty=J4.nil=J4.strConcat=J4.str=J4._=void 0;var J$=j0(),P4=nY(),g6=j0();Object.defineProperty(J4,"_",{enumerable:!0,get:function(){return g6._}});Object.defineProperty(J4,"str",{enumerable:!0,get:function(){return g6.str}});Object.defineProperty(J4,"strConcat",{enumerable:!0,get:function(){return g6.strConcat}});Object.defineProperty(J4,"nil",{enumerable:!0,get:function(){return g6.nil}});Object.defineProperty(J4,"getProperty",{enumerable:!0,get:function(){return g6.getProperty}});Object.defineProperty(J4,"stringify",{enumerable:!0,get:function(){return g6.stringify}});Object.defineProperty(J4,"regexpCode",{enumerable:!0,get:function(){return g6.regexpCode}});Object.defineProperty(J4,"Name",{enumerable:!0,get:function(){return g6.Name}});var fX=nY();Object.defineProperty(J4,"Scope",{enumerable:!0,get:function(){return fX.Scope}});Object.defineProperty(J4,"ValueScope",{enumerable:!0,get:function(){return fX.ValueScope}});Object.defineProperty(J4,"ValueScopeName",{enumerable:!0,get:function(){return fX.ValueScopeName}});Object.defineProperty(J4,"varKinds",{enumerable:!0,get:function(){return fX.varKinds}});J4.operators={GT:new J$._Code(">"),GTE:new J$._Code(">="),LT:new J$._Code("<"),LTE:new J$._Code("<="),EQ:new J$._Code("==="),NEQ:new J$._Code("!=="),NOT:new J$._Code("!"),OR:new J$._Code("||"),AND:new J$._Code("&&"),ADD:new J$._Code("+")};class f6{optimizeNodes(){return this}optimizeNames($,v){return this}}class XB extends f6{constructor($,v,U){super();this.varKind=$,this.name=v,this.rhs=U}render({es5:$,_n:v}){let U=$?P4.varKinds.var:this.varKind,J=this.rhs===void 0?"":` = ${this.rhs}`;return`${U} ${this.name}${J};`+v}optimizeNames($,v){if(!$[this.name.str])return;if(this.rhs)this.rhs=M1(this.rhs,$,v);return this}get names(){return this.rhs instanceof J$._CodeOrName?this.rhs.names:{}}}class cY extends f6{constructor($,v,U){super();this.lhs=$,this.rhs=v,this.sideEffects=U}render({_n:$}){return`${this.lhs} = ${this.rhs};`+$}optimizeNames($,v){if(this.lhs instanceof J$.Name&&!$[this.lhs.str]&&!this.sideEffects)return;return this.rhs=M1(this.rhs,$,v),this}get names(){let $=this.lhs instanceof J$.Name?{}:{...this.lhs.names};return gX($,this.rhs)}}class QB extends cY{constructor($,v,U,J){super($,U,J);this.op=v}render({_n:$}){return`${this.lhs} ${this.op}= ${this.rhs};`+$}}class GB extends f6{constructor($){super();this.label=$,this.names={}}render({_n:$}){return`${this.label}:`+$}}class DB extends f6{constructor($){super();this.label=$,this.names={}}render({_n:$}){return`break${this.label?` ${this.label}`:""};`+$}}class YB extends f6{constructor($){super();this.error=$}render({_n:$}){return`throw ${this.error};`+$}get names(){return this.error.names}}class bB extends f6{constructor($){super();this.code=$}render({_n:$}){return`${this.code};`+$}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames($,v){return this.code=M1(this.code,$,v),this}get names(){return this.code instanceof J$._CodeOrName?this.code.names:{}}}class xX extends f6{constructor($=[]){super();this.nodes=$}render($){return this.nodes.reduce((v,U)=>v+U.render($),"")}optimizeNodes(){let{nodes:$}=this,v=$.length;while(v--){let U=$[v].optimizeNodes();if(Array.isArray(U))$.splice(v,1,...U);else if(U)$[v]=U;else $.splice(v,1)}return $.length>0?this:void 0}optimizeNames($,v){let{nodes:U}=this,J=U.length;while(J--){let z=U[J];if(z.optimizeNames($,v))continue;HE($,z.names),U.splice(J,1)}return U.length>0?this:void 0}get names(){return this.nodes.reduce(($,v)=>Bv($,v.names),{})}}class x6 extends xX{render($){return"{"+$._n+super.render($)+"}"+$._n}}class HB extends xX{}class K0 extends x6{}K0.kind="else";class G6 extends x6{constructor($,v){super(v);this.condition=$}render($){let v=`if(${this.condition})`+super.render($);if(this.else)v+="else "+this.else.render($);return v}optimizeNodes(){super.optimizeNodes();let $=this.condition;if($===!0)return this.nodes;let v=this.else;if(v){let U=v.optimizeNodes();v=this.else=Array.isArray(U)?new K0(U):U}if(v){if($===!1)return v instanceof G6?v:v.nodes;if(this.nodes.length)return this;return new G6(LB($),v instanceof G6?[v]:v.nodes)}if($===!1||!this.nodes.length)return;return this}optimizeNames($,v){var U;if(this.else=(U=this.else)===null||U===void 0?void 0:U.optimizeNames($,v),!(super.optimizeNames($,v)||this.else))return;return this.condition=M1(this.condition,$,v),this}get names(){let $=super.names;if(gX($,this.condition),this.else)Bv($,this.else.names);return $}}G6.kind="if";class q1 extends x6{}q1.kind="for";class BB extends q1{constructor($){super();this.iteration=$}render($){return`for(${this.iteration})`+super.render($)}optimizeNames($,v){if(!super.optimizeNames($,v))return;return this.iteration=M1(this.iteration,$,v),this}get names(){return Bv(super.names,this.iteration.names)}}class wB extends q1{constructor($,v,U,J){super();this.varKind=$,this.name=v,this.from=U,this.to=J}render($){let v=$.es5?P4.varKinds.var:this.varKind,{name:U,from:J,to:z}=this;return`for(${v} ${U}=${J}; ${U}<${z}; ${U}++)`+super.render($)}get names(){let $=gX(super.names,this.from);return gX($,this.to)}}class mY extends q1{constructor($,v,U,J){super();this.loop=$,this.varKind=v,this.name=U,this.iterable=J}render($){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render($)}optimizeNames($,v){if(!super.optimizeNames($,v))return;return this.iterable=M1(this.iterable,$,v),this}get names(){return Bv(super.names,this.iterable.names)}}class TX extends x6{constructor($,v,U){super();this.name=$,this.args=v,this.async=U}render($){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render($)}}TX.kind="func";class CX extends xX{render($){return"return "+super.render($)}}CX.kind="return";class OB extends x6{render($){let v="try"+super.render($);if(this.catch)v+=this.catch.render($);if(this.finally)v+=this.finally.render($);return v}optimizeNodes(){var $,v;return super.optimizeNodes(),($=this.catch)===null||$===void 0||$.optimizeNodes(),(v=this.finally)===null||v===void 0||v.optimizeNodes(),this}optimizeNames($,v){var U,J;return super.optimizeNames($,v),(U=this.catch)===null||U===void 0||U.optimizeNames($,v),(J=this.finally)===null||J===void 0||J.optimizeNames($,v),this}get names(){let $=super.names;if(this.catch)Bv($,this.catch.names);if(this.finally)Bv($,this.finally.names);return $}}class uX extends x6{constructor($){super();this.error=$}render($){return`catch(${this.error})`+super.render($)}}uX.kind="catch";class _X extends x6{render($){return"finally"+super.render($)}}_X.kind="finally";class IB{constructor($,v={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...v,_n:v.lines?`
3
3
  `:""},this._extScope=$,this._scope=new P4.Scope({parent:$}),this._nodes=[new HB]}toString(){return this._root.render(this.opts)}name($){return this._scope.name($)}scopeName($){return this._extScope.name($)}scopeValue($,v){let U=this._extScope.value($,v);return(this._values[U.prefix]||(this._values[U.prefix]=new Set)).add(U),U}getScopeValue($,v){return this._extScope.getValue($,v)}scopeRefs($){return this._extScope.scopeRefs($,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def($,v,U,J){let z=this._scope.toName(v);if(U!==void 0&&J)this._constants[z.str]=U;return this._leafNode(new XB($,z,U)),z}const($,v,U){return this._def(P4.varKinds.const,$,v,U)}let($,v,U){return this._def(P4.varKinds.let,$,v,U)}var($,v,U){return this._def(P4.varKinds.var,$,v,U)}assign($,v,U){return this._leafNode(new cY($,v,U))}add($,v){return this._leafNode(new QB($,J4.operators.ADD,v))}code($){if(typeof $=="function")$();else if($!==J$.nil)this._leafNode(new bB($));return this}object(...$){let v=["{"];for(let[U,J]of $){if(v.length>1)v.push(",");if(v.push(U),U!==J||this.opts.es5)v.push(":"),(0,J$.addCodeArg)(v,J)}return v.push("}"),new J$._Code(v)}if($,v,U){if(this._blockNode(new G6($)),v&&U)this.code(v).else().code(U).endIf();else if(v)this.code(v).endIf();else if(U)throw Error('CodeGen: "else" body without "then" body');return this}elseIf($){return this._elseNode(new G6($))}else(){return this._elseNode(new K0)}endIf(){return this._endBlockNode(G6,K0)}_for($,v){if(this._blockNode($),v)this.code(v).endFor();return this}for($,v){return this._for(new BB($),v)}forRange($,v,U,J,z=this.opts.es5?P4.varKinds.var:P4.varKinds.let){let W=this._scope.toName($);return this._for(new wB(z,W,v,U),()=>J(W))}forOf($,v,U,J=P4.varKinds.const){let z=this._scope.toName($);if(this.opts.es5){let W=v instanceof J$.Name?v:this.var("_arr",v);return this.forRange("_i",0,J$._`${W}.length`,(X)=>{this.var(z,J$._`${W}[${X}]`),U(z)})}return this._for(new mY("of",J,z,v),()=>U(z))}forIn($,v,U,J=this.opts.es5?P4.varKinds.var:P4.varKinds.const){if(this.opts.ownProperties)return this.forOf($,J$._`Object.keys(${v})`,U);let z=this._scope.toName($);return this._for(new mY("in",J,z,v),()=>U(z))}endFor(){return this._endBlockNode(q1)}label($){return this._leafNode(new GB($))}break($){return this._leafNode(new DB($))}return($){let v=new CX;if(this._blockNode(v),this.code($),v.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(CX)}try($,v,U){if(!v&&!U)throw Error('CodeGen: "try" without "catch" and "finally"');let J=new OB;if(this._blockNode(J),this.code($),v){let z=this.name("e");this._currNode=J.catch=new uX(z),v(z)}if(U)this._currNode=J.finally=new _X,this.code(U);return this._endBlockNode(uX,_X)}throw($){return this._leafNode(new YB($))}block($,v){if(this._blockStarts.push(this._nodes.length),$)this.code($).endBlock(v);return this}endBlock($){let v=this._blockStarts.pop();if(v===void 0)throw Error("CodeGen: not in self-balancing block");let U=this._nodes.length-v;if(U<0||$!==void 0&&U!==$)throw Error(`CodeGen: wrong number of nodes: ${U} vs ${$} expected`);return this._nodes.length=v,this}func($,v=J$.nil,U,J){if(this._blockNode(new TX($,v,U)),J)this.code(J).endFunc();return this}endFunc(){return this._endBlockNode(TX)}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($,v){let U=this._currNode;if(U instanceof $||v&&U instanceof v)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${v?`${$.kind}/${v.kind}`:$.kind}"`)}_elseNode($){let v=this._currNode;if(!(v instanceof G6))throw Error('CodeGen: "else" without "if"');return this._currNode=v.else=$,this}get _root(){return this._nodes[0]}get _currNode(){let $=this._nodes;return $[$.length-1]}set _currNode($){let v=this._nodes;v[v.length-1]=$}}J4.CodeGen=IB;function Bv($,v){for(let U in v)$[U]=($[U]||0)+(v[U]||0);return $}function gX($,v){return v instanceof J$._CodeOrName?Bv($,v.names):$}function M1($,v,U){if($ instanceof J$.Name)return J($);if(!z($))return $;return new J$._Code($._items.reduce((W,X)=>{if(X instanceof J$.Name)X=J(X);if(X instanceof J$._Code)W.push(...X._items);else W.push(X);return W},[]));function J(W){let X=U[W.str];if(X===void 0||v[W.str]!==1)return W;return delete v[W.str],X}function z(W){return W instanceof J$._Code&&W._items.some((X)=>X instanceof J$.Name&&v[X.str]===1&&U[X.str]!==void 0)}}function HE($,v){for(let U in v)$[U]=($[U]||0)-(v[U]||0)}function LB($){return typeof $=="boolean"||typeof $=="number"||$===null?!$:J$._`!${rY($)}`}J4.not=LB;var BE=NB(J4.operators.AND);function wE(...$){return $.reduce(BE)}J4.and=wE;var OE=NB(J4.operators.OR);function IE(...$){return $.reduce(OE)}J4.or=IE;function NB($){return(v,U)=>v===J$.nil?U:U===J$.nil?v:J$._`${rY(v)} ${$} ${rY(U)}`}function rY($){return $ instanceof J$.Name?$:J$._`(${$})`}});var X$=K((EB)=>{Object.defineProperty(EB,"__esModule",{value:!0});EB.checkStrictMode=EB.getErrorPath=EB.Type=EB.useFunc=EB.setEvaluated=EB.evaluatedPropsToName=EB.mergeEvaluated=EB.eachItem=EB.unescapeJsonPointer=EB.escapeJsonPointer=EB.escapeFragment=EB.unescapeFragment=EB.schemaRefOrVal=EB.schemaHasRulesButRef=EB.schemaHasRules=EB.checkUnknownRules=EB.alwaysValidSchema=EB.toHash=void 0;var V$=v$(),jE=j0();function KE($){let v={};for(let U of $)v[U]=!0;return v}EB.toHash=KE;function FE($,v){if(typeof v=="boolean")return v;if(Object.keys(v).length===0)return!0;return FB($,v),!AB(v,$.self.RULES.all)}EB.alwaysValidSchema=FE;function FB($,v=$.schema){let{opts:U,self:J}=$;if(!U.strictSchema)return;if(typeof v==="boolean")return;let z=J.RULES.keywords;for(let W in v)if(!z[W])SB($,`unknown keyword: "${W}"`)}EB.checkUnknownRules=FB;function AB($,v){if(typeof $=="boolean")return!$;for(let U in $)if(v[U])return!0;return!1}EB.schemaHasRules=AB;function AE($,v){if(typeof $=="boolean")return!$;for(let U in $)if(U!=="$ref"&&v.all[U])return!0;return!1}EB.schemaHasRulesButRef=AE;function qE({topSchemaRef:$,schemaPath:v},U,J,z){if(!z){if(typeof U=="number"||typeof U=="boolean")return U;if(typeof U=="string")return V$._`${U}`}return V$._`${$}${v}${(0,V$.getProperty)(J)}`}EB.schemaRefOrVal=qE;function ME($){return qB(decodeURIComponent($))}EB.unescapeFragment=ME;function SE($){return encodeURIComponent(dY($))}EB.escapeFragment=SE;function dY($){if(typeof $=="number")return`${$}`;return $.replace(/~/g,"~0").replace(/\//g,"~1")}EB.escapeJsonPointer=dY;function qB($){return $.replace(/~1/g,"/").replace(/~0/g,"~")}EB.unescapeJsonPointer=qB;function EE($,v){if(Array.isArray($))for(let U of $)v(U);else v($)}EB.eachItem=EE;function jB({mergeNames:$,mergeToName:v,mergeValues:U,resultToName:J}){return(z,W,X,Q)=>{let G=X===void 0?W:X instanceof V$.Name?(W instanceof V$.Name?$(z,W,X):v(z,W,X),X):W instanceof V$.Name?(v(z,X,W),W):U(W,X);return Q===V$.Name&&!(G instanceof V$.Name)?J(z,G):G}}EB.mergeEvaluated={props:jB({mergeNames:($,v,U)=>$.if(V$._`${U} !== true && ${v} !== undefined`,()=>{$.if(V$._`${v} === true`,()=>$.assign(U,!0),()=>$.assign(U,V$._`${U} || {}`).code(V$._`Object.assign(${U}, ${v})`))}),mergeToName:($,v,U)=>$.if(V$._`${U} !== true`,()=>{if(v===!0)$.assign(U,!0);else $.assign(U,V$._`${U} || {}`),oY($,U,v)}),mergeValues:($,v)=>$===!0?!0:{...$,...v},resultToName:MB}),items:jB({mergeNames:($,v,U)=>$.if(V$._`${U} !== true && ${v} !== undefined`,()=>$.assign(U,V$._`${v} === true ? true : ${U} > ${v} ? ${U} : ${v}`)),mergeToName:($,v,U)=>$.if(V$._`${U} !== true`,()=>$.assign(U,v===!0?!0:V$._`${U} > ${v} ? ${U} : ${v}`)),mergeValues:($,v)=>$===!0?!0:Math.max($,v),resultToName:($,v)=>$.var("items",v)})};function MB($,v){if(v===!0)return $.var("props",!0);let U=$.var("props",V$._`{}`);if(v!==void 0)oY($,U,v);return U}EB.evaluatedPropsToName=MB;function oY($,v,U){Object.keys(U).forEach((J)=>$.assign(V$._`${v}${(0,V$.getProperty)(J)}`,!0))}EB.setEvaluated=oY;var KB={};function PE($,v){return $.scopeValue("func",{ref:v,code:KB[v.code]||(KB[v.code]=new jE._Code(v.code))})}EB.useFunc=PE;var pY;(function($){$[$.Num=0]="Num",$[$.Str=1]="Str"})(pY||(EB.Type=pY={}));function kE($,v,U){if($ instanceof V$.Name){let J=v===pY.Num;return U?J?V$._`"[" + ${$} + "]"`:V$._`"['" + ${$} + "']"`:J?V$._`"/" + ${$}`:V$._`"/" + ${$}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return U?(0,V$.getProperty)($).toString():"/"+dY($)}EB.getErrorPath=kE;function SB($,v,U=$.opts.strictSchema){if(!U)return;if(v=`strict mode: ${v}`,U===!0)throw Error(v);$.self.logger.warn(v)}EB.checkStrictMode=SB});var D6=K((kB)=>{Object.defineProperty(kB,"__esModule",{value:!0});var h$=v$(),pE={data:new h$.Name("data"),valCxt:new h$.Name("valCxt"),instancePath:new h$.Name("instancePath"),parentData:new h$.Name("parentData"),parentDataProperty:new h$.Name("parentDataProperty"),rootData:new h$.Name("rootData"),dynamicAnchors:new h$.Name("dynamicAnchors"),vErrors:new h$.Name("vErrors"),errors:new h$.Name("errors"),this:new h$.Name("this"),self:new h$.Name("self"),scope:new h$.Name("scope"),json:new h$.Name("json"),jsonPos:new h$.Name("jsonPos"),jsonLen:new h$.Name("jsonLen"),jsonPart:new h$.Name("jsonPart")};kB.default=pE});var F0=K((CB)=>{Object.defineProperty(CB,"__esModule",{value:!0});CB.extendErrors=CB.resetErrorsCount=CB.reportExtraError=CB.reportError=CB.keyword$DataError=CB.keywordError=void 0;var Q$=v$(),lX=X$(),o$=D6();CB.keywordError={message:({keyword:$})=>Q$.str`must pass "${$}" keyword validation`};CB.keyword$DataError={message:({keyword:$,schemaType:v})=>v?Q$.str`"${$}" keyword must be ${v} ($data)`:Q$.str`"${$}" keyword is invalid ($data)`};function oE($,v=CB.keywordError,U,J){let{it:z}=$,{gen:W,compositeRule:X,allErrors:Q}=z,G=TB($,v,U);if(J!==null&&J!==void 0?J:X||Q)RB(W,G);else ZB(z,Q$._`[${G}]`)}CB.reportError=oE;function tE($,v=CB.keywordError,U){let{it:J}=$,{gen:z,compositeRule:W,allErrors:X}=J,Q=TB($,v,U);if(RB(z,Q),!(W||X))ZB(J,o$.default.vErrors)}CB.reportExtraError=tE;function aE($,v){$.assign(o$.default.errors,v),$.if(Q$._`${o$.default.vErrors} !== null`,()=>$.if(v,()=>$.assign(Q$._`${o$.default.vErrors}.length`,v),()=>$.assign(o$.default.vErrors,null)))}CB.resetErrorsCount=aE;function sE({gen:$,keyword:v,schemaValue:U,data:J,errsCount:z,it:W}){if(z===void 0)throw Error("ajv implementation error");let X=$.name("err");$.forRange("i",z,o$.default.errors,(Q)=>{if($.const(X,Q$._`${o$.default.vErrors}[${Q}]`),$.if(Q$._`${X}.instancePath === undefined`,()=>$.assign(Q$._`${X}.instancePath`,(0,Q$.strConcat)(o$.default.instancePath,W.errorPath))),$.assign(Q$._`${X}.schemaPath`,Q$.str`${W.errSchemaPath}/${v}`),W.opts.verbose)$.assign(Q$._`${X}.schema`,U),$.assign(Q$._`${X}.data`,J)})}CB.extendErrors=sE;function RB($,v){let U=$.const("err",v);$.if(Q$._`${o$.default.vErrors} === null`,()=>$.assign(o$.default.vErrors,Q$._`[${U}]`),Q$._`${o$.default.vErrors}.push(${U})`),$.code(Q$._`${o$.default.errors}++`)}function ZB($,v){let{gen:U,validateName:J,schemaEnv:z}=$;if(z.$async)U.throw(Q$._`new ${$.ValidationError}(${v})`);else U.assign(Q$._`${J}.errors`,v),U.return(!1)}var wv={keyword:new Q$.Name("keyword"),schemaPath:new Q$.Name("schemaPath"),params:new Q$.Name("params"),propertyName:new Q$.Name("propertyName"),message:new Q$.Name("message"),schema:new Q$.Name("schema"),parentSchema:new Q$.Name("parentSchema")};function TB($,v,U){let{createErrors:J}=$.it;if(J===!1)return Q$._`{}`;return eE($,v,U)}function eE($,v,U={}){let{gen:J,it:z}=$,W=[$P(z,U),vP($,U)];return UP($,v,W),J.object(...W)}function $P({errorPath:$},{instancePath:v}){let U=v?Q$.str`${$}${(0,lX.getErrorPath)(v,lX.Type.Str)}`:$;return[o$.default.instancePath,(0,Q$.strConcat)(o$.default.instancePath,U)]}function vP({keyword:$,it:{errSchemaPath:v}},{schemaPath:U,parentSchema:J}){let z=J?v:Q$.str`${v}/${$}`;if(U)z=Q$.str`${z}${(0,lX.getErrorPath)(U,lX.Type.Str)}`;return[wv.schemaPath,z]}function UP($,{params:v,message:U},J){let{keyword:z,data:W,schemaValue:X,it:Q}=$,{opts:G,propertyName:D,topSchemaRef:Y,schemaPath:b}=Q;if(J.push([wv.keyword,z],[wv.params,typeof v=="function"?v($):v||Q$._`{}`]),G.messages)J.push([wv.message,typeof U=="function"?U($):U]);if(G.verbose)J.push([wv.schema,X],[wv.parentSchema,Q$._`${Y}${b}`],[o$.default.data,W]);if(D)J.push([wv.propertyName,D])}});var xB=K((gB)=>{Object.defineProperty(gB,"__esModule",{value:!0});gB.boolOrEmptySchema=gB.topBoolOrEmptySchema=void 0;var QP=F0(),GP=v$(),DP=D6(),YP={message:"boolean schema is false"};function bP($){let{gen:v,schema:U,validateName:J}=$;if(U===!1)_B($,!1);else if(typeof U=="object"&&U.$async===!0)v.return(DP.default.data);else v.assign(GP._`${J}.errors`,null),v.return(!0)}gB.topBoolOrEmptySchema=bP;function HP($,v){let{gen:U,schema:J}=$;if(J===!1)U.var(v,!1),_B($);else U.var(v,!0)}gB.boolOrEmptySchema=HP;function _B($,v){let{gen:U,data:J}=$,z={gen:U,keyword:"false schema",data:J,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:$};(0,QP.reportError)(z,YP,void 0,v)}});var aY=K((yB)=>{Object.defineProperty(yB,"__esModule",{value:!0});yB.getRules=yB.isJSONType=void 0;var wP=["string","number","integer","boolean","null","object","array"],OP=new Set(wP);function IP($){return typeof $=="string"&&OP.has($)}yB.isJSONType=IP;function LP(){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:{}}}yB.getRules=LP});var sY=K((nB)=>{Object.defineProperty(nB,"__esModule",{value:!0});nB.shouldUseRule=nB.shouldUseGroup=nB.schemaHasRulesForType=void 0;function VP({schema:$,self:v},U){let J=v.RULES.types[U];return J&&J!==!0&&iB($,J)}nB.schemaHasRulesForType=VP;function iB($,v){return v.rules.some((U)=>hB($,U))}nB.shouldUseGroup=iB;function hB($,v){var U;return $[v.keyword]!==void 0||((U=v.definition.implements)===null||U===void 0?void 0:U.some((J)=>$[J]!==void 0))}nB.shouldUseRule=hB});var A0=K((dB)=>{Object.defineProperty(dB,"__esModule",{value:!0});dB.reportTypeError=dB.checkDataTypes=dB.checkDataType=dB.coerceAndCheckDataType=dB.getJSONTypes=dB.getSchemaTypes=dB.DataType=void 0;var FP=aY(),AP=sY(),qP=F0(),t=v$(),rB=X$(),S1;(function($){$[$.Correct=0]="Correct",$[$.Wrong=1]="Wrong"})(S1||(dB.DataType=S1={}));function MP($){let v=cB($.type);if(v.includes("null")){if($.nullable===!1)throw Error("type: null contradicts nullable: false")}else{if(!v.length&&$.nullable!==void 0)throw Error('"nullable" cannot be used without "type"');if($.nullable===!0)v.push("null")}return v}dB.getSchemaTypes=MP;function cB($){let v=Array.isArray($)?$:$?[$]:[];if(v.every(FP.isJSONType))return v;throw Error("type must be JSONType or JSONType[]: "+v.join(","))}dB.getJSONTypes=cB;function SP($,v){let{gen:U,data:J,opts:z}=$,W=EP(v,z.coerceTypes),X=v.length>0&&!(W.length===0&&v.length===1&&(0,AP.schemaHasRulesForType)($,v[0]));if(X){let Q=$b(v,J,z.strictNumbers,S1.Wrong);U.if(Q,()=>{if(W.length)PP($,v,W);else vb($)})}return X}dB.coerceAndCheckDataType=SP;var pB=new Set(["string","number","integer","boolean","null"]);function EP($,v){return v?$.filter((U)=>pB.has(U)||v==="array"&&U==="array"):[]}function PP($,v,U){let{gen:J,data:z,opts:W}=$,X=J.let("dataType",t._`typeof ${z}`),Q=J.let("coerced",t._`undefined`);if(W.coerceTypes==="array")J.if(t._`${X} == 'object' && Array.isArray(${z}) && ${z}.length == 1`,()=>J.assign(z,t._`${z}[0]`).assign(X,t._`typeof ${z}`).if($b(v,z,W.strictNumbers),()=>J.assign(Q,z)));J.if(t._`${Q} !== undefined`);for(let D of U)if(pB.has(D)||D==="array"&&W.coerceTypes==="array")G(D);J.else(),vb($),J.endIf(),J.if(t._`${Q} !== undefined`,()=>{J.assign(z,Q),kP($,Q)});function G(D){switch(D){case"string":J.elseIf(t._`${X} == "number" || ${X} == "boolean"`).assign(Q,t._`"" + ${z}`).elseIf(t._`${z} === null`).assign(Q,t._`""`);return;case"number":J.elseIf(t._`${X} == "boolean" || ${z} === null
4
4
  || (${X} == "string" && ${z} && ${z} == +${z})`).assign(Q,t._`+${z}`);return;case"integer":J.elseIf(t._`${X} === "boolean" || ${z} === null
@@ -1,4 +1,4 @@
1
- /*! @mcpcloud/runtime v0.12.1 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
1
+ /*! @mcpcloud/runtime v0.12.2 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
2
2
  var _9=Object.create;var{getPrototypeOf:w9,defineProperty:$8,getOwnPropertyNames:P9}=Object;var N9=Object.prototype.hasOwnProperty;function E9(Z){return this[Z]}var S9,I9,x9=(Z,$,X)=>{var Y=Z!=null&&typeof Z==="object";if(Y){var B=$?S9??=new WeakMap:I9??=new WeakMap,C=B.get(Z);if(C)return C}X=Z!=null?_9(w9(Z)):{};let U=$||!Z||!Z.__esModule?$8(X,"default",{value:Z,enumerable:!0}):X;for(let z of P9(Z))if(!N9.call(U,z))$8(U,z,{get:E9.bind(Z,z),enumerable:!0});if(Y)B.set(Z,U);return U};var A9=(Z,$)=>()=>($||Z(($={exports:{}}).exports,$),$.exports);var b9=(Z)=>Z;function T9(Z,$){this[Z]=b9.bind(null,$)}var f9=(Z,$)=>{for(var X in $)$8(Z,X,{get:$[X],enumerable:!0,configurable:!0,set:T9.bind($,X)})};var X8=(Z,$)=>()=>(Z&&($=Z(Z=0)),$);var k,W8,l,h,c;var i=X8(()=>{k={JS_EVAL_TYPE_GLOBAL:0,JS_EVAL_TYPE_MODULE:1,JS_EVAL_TYPE_DIRECT:2,JS_EVAL_TYPE_INDIRECT:3,JS_EVAL_TYPE_MASK:3,JS_EVAL_FLAG_STRICT:8,JS_EVAL_FLAG_STRIP:16,JS_EVAL_FLAG_COMPILE_ONLY:32,JS_EVAL_FLAG_BACKTRACE_BARRIER:64},W8={BaseObjects:1,Date:2,Eval:4,StringNormalize:8,RegExp:16,RegExpCompiler:32,JSON:64,Proxy:128,MapSet:256,TypedArrays:512,Promise:1024,BigInt:2048,BigFloat:4096,BigDecimal:8192,OperatorOverloading:16384,BignumExt:32768},l={Pending:0,Fulfilled:1,Rejected:2},h={JS_GPN_STRING_MASK:1,JS_GPN_SYMBOL_MASK:2,JS_GPN_PRIVATE_MASK:4,JS_GPN_ENUM_ONLY:16,JS_GPN_SET_ENUM:32,QTS_GPN_NUMBER_MASK:64,QTS_STANDARD_COMPLIANT_NUMBER:128},c={IsStrictlyEqual:0,IsSameValue:1,IsSameValueZero:2}});function m(...Z){B8&&console.log("quickjs-emscripten:",...Z)}function*K9(Z){return yield Z}function m9(Z){return K9(q8(Z))}function u8(Z,$){return(...X)=>{let Y=$.call(Z,J8,...X);return q8(Y)}}function d9(Z,$){let X=$.call(Z,J8);return q8(X)}function q8(Z){function $(X){return X.done?X.value:X.value instanceof Promise?X.value.then((Y)=>$(Z.next(Y)),(Y)=>$(Z.throw(Y))):$(Z.next(X.value))}return $(Z.next())}function K8(Z,$){let X;try{Z.dispose()}catch(Y){X=Y}if($&&X)throw Object.assign($,{message:`${$.message}
3
3
  Then, failed to dispose scope: ${X.message}`,disposeError:X}),$;if($||X)throw $||X}function p9(Z){let $=Z?Array.from(Z):[];function X(){return $.forEach((B)=>B.alive?B.dispose():void 0)}function Y(){return $.some((B)=>B.alive)}return Object.defineProperty($,G8,{configurable:!0,enumerable:!1,value:X}),Object.defineProperty($,"dispose",{configurable:!0,enumerable:!1,value:X}),Object.defineProperty($,"alive",{configurable:!0,enumerable:!1,get:Y}),$}function n(Z){return!!(Z&&(typeof Z=="object"||typeof Z=="function")&&("alive"in Z)&&typeof Z.alive=="boolean"&&("dispose"in Z)&&typeof Z.dispose=="function")}function o9(Z){if(!Z)return 0;let $=0;for(let[X,Y]of Object.entries(Z)){if(!(X in W8))throw new Z9(X);Y&&($|=W8[X])}return $}function n9(Z){if(typeof Z=="number")return Z;if(Z===void 0)return 0;let{type:$,strict:X,strip:Y,compileOnly:B,backtraceBarrier:C}=Z,U=0;return $==="global"&&(U|=k.JS_EVAL_TYPE_GLOBAL),$==="module"&&(U|=k.JS_EVAL_TYPE_MODULE),X&&(U|=k.JS_EVAL_FLAG_STRICT),Y&&(U|=k.JS_EVAL_FLAG_STRIP),B&&(U|=k.JS_EVAL_FLAG_COMPILE_ONLY),C&&(U|=k.JS_EVAL_FLAG_BACKTRACE_BARRIER),U}function a9(Z){if(typeof Z=="number")return Z;if(Z===void 0)return 0;let{strings:$,symbols:X,quickjsPrivate:Y,onlyEnumerable:B,numbers:C,numbersAsStrings:U}=Z,z=0;return $&&(z|=h.JS_GPN_STRING_MASK),X&&(z|=h.JS_GPN_SYMBOL_MASK),Y&&(z|=h.JS_GPN_PRIVATE_MASK),B&&(z|=h.JS_GPN_ENUM_ONLY),C&&(z|=h.QTS_GPN_NUMBER_MASK),U&&(z|=h.QTS_STANDARD_COMPLIANT_NUMBER),z}function s9(...Z){let $=[];for(let X of Z)X!==void 0&&($=$.concat(X));return $}function z8(Z){return Z>>8}function H8(Z,$){$.interruptHandler&&Z.setInterruptHandler($.interruptHandler),$.maxStackSizeBytes!==void 0&&Z.setMaxStackSize($.maxStackSizeBytes),$.memoryLimitBytes!==void 0&&Z.setMemoryLimit($.memoryLimitBytes)}function j8(Z,$){$.moduleLoader&&Z.setModuleLoader($.moduleLoader),$.shouldInterrupt&&Z.setInterruptHandler($.shouldInterrupt),$.memoryLimitBytes!==void 0&&Z.setMemoryLimit($.memoryLimitBytes),$.maxStackSizeBytes!==void 0&&Z.setMaxStackSize($.maxStackSizeBytes)}var k9,h9=(Z,$)=>{for(var X in $)k9(Z,X,{get:$[X],enumerable:!0})},B8=!1,v9,Y8,s8,Q8,t8,r8,e8,g9,c9,Z9,$9,X9,W9,f,J8,A,G8,l8,w,v,i8,I,C8,u9,l9,g,i9,z9=class{constructor(Z){this.module=Z}toPointerArray(Z){let $=new Int32Array(Z.map((B)=>B.value)),X=$.length*$.BYTES_PER_ELEMENT,Y=this.module._malloc(X);return new Uint8Array(this.module.HEAPU8.buffer,Y,X).set(new Uint8Array($.buffer)),new w(Y,void 0,(B)=>this.module._free(B))}newTypedArray(Z,$){let X=new Z(Array($).fill(0)),Y=X.length*X.BYTES_PER_ELEMENT,B=this.module._malloc(Y),C=new Z(this.module.HEAPU8.buffer,B,$);return C.set(X),new w({typedArray:C,ptr:B},void 0,(U)=>this.module._free(U.ptr))}newMutablePointerArray(Z){return this.newTypedArray(Int32Array,Z)}newHeapCharPointer(Z){let $=this.module.lengthBytesUTF8(Z),X=$+1,Y=this.module._malloc(X);return this.module.stringToUTF8(Z,Y,X),new w({ptr:Y,strlen:$},void 0,(B)=>this.module._free(B.ptr))}newHeapBufferPointer(Z){let $=Z.byteLength,X=this.module._malloc($);return this.module.HEAPU8.set(Z,X),new w({pointer:X,numBytes:$},void 0,(Y)=>this.module._free(Y.pointer))}consumeHeapCharPointer(Z){let $=this.module.UTF8ToString(Z);return this.module._free(Z),$}},fZ,yZ,t9,o8=-2147483648,n8=2147483647,o=0,r9=class{constructor(){this.nextId=o8,this.freelist=[],this.groups=new Map}put(Z){let $=this.allocateId(),X=z8($),Y=this.groups.get(X);return Y||(Y=new Map,this.groups.set(X,Y)),Y.set($,Z),$}get(Z){if(Z===o)throw new f("no host reference id defined");let $=z8(Z),X=this.groups.get($);if(!X)throw new f(`host reference id ${Z} is not defined`);let Y=X.get(Z);if(!Y)throw new f(`host reference id ${Z} is not defined`);return Y}delete(Z){if(Z===o)throw new f("no host reference id defined");let $=z8(Z),X=this.groups.get($);if(!X)throw new f(`host reference id ${Z} is not defined`);X.delete(Z),X.size===0&&this.groups.delete($),this.freelist.push(Z)}allocateId(){if(this.freelist.length>0)return this.freelist.shift();if(this.nextId===o&&this.nextId++,this.nextId>n8)throw new W9(`HostRefMap: too many host refs created without disposing. Max simultaneous host refs: ${n8-o8}`);return this.nextId++}},a8,e9,ZZ,$Z,XZ=class{constructor(Z){this.freeHostRef=Z.freeHostRef,this.callFunction=Z.callFunction,this.shouldInterrupt=Z.shouldInterrupt,this.loadModuleSource=Z.loadModuleSource,this.normalizeModule=Z.normalizeModule}},U8=class{constructor(Z){this.contextCallbacks=new Map,this.runtimeCallbacks=new Map,this.suspendedCount=0,this.cToHostCallbacks=new XZ({freeHostRef:($,X,Y)=>{let B=this.runtimeCallbacks.get(X);if(!B)throw Error(`QuickJSRuntime(rt = ${X}) not found when trying to free HostRef(id = ${Y})`);B.freeHostRef(X,Y)},callFunction:($,X,Y,B,C,U)=>this.handleAsyncify($,()=>{try{let z=this.contextCallbacks.get(X);if(!z)throw Error(`QuickJSContext(ctx = ${X}) not found for C function call "${U}"`);return z.callFunction(X,Y,B,C,U)}catch(z){return console.error("[C to host error: returning null]",z),0}}),shouldInterrupt:($,X)=>this.handleAsyncify($,()=>{try{let Y=this.runtimeCallbacks.get(X);if(!Y)throw Error(`QuickJSRuntime(rt = ${X}) not found for C interrupt`);return Y.shouldInterrupt(X)}catch(Y){return console.error("[C to host interrupt: returning error]",Y),1}}),loadModuleSource:($,X,Y,B)=>this.handleAsyncify($,()=>{try{let C=this.runtimeCallbacks.get(X);if(!C)throw Error(`QuickJSRuntime(rt = ${X}) not found for C module loader`);let U=C.loadModuleSource;if(!U)throw Error(`QuickJSRuntime(rt = ${X}) does not support module loading`);return U(X,Y,B)}catch(C){return console.error("[C to host module loader error: returning null]",C),0}}),normalizeModule:($,X,Y,B,C)=>this.handleAsyncify($,()=>{try{let U=this.runtimeCallbacks.get(X);if(!U)throw Error(`QuickJSRuntime(rt = ${X}) not found for C module loader`);let z=U.normalizeModule;if(!z)throw Error(`QuickJSRuntime(rt = ${X}) does not support module loading`);return z(X,Y,B,C)}catch(U){return console.error("[C to host module loader error: returning null]",U),0}})}),this.module=Z,this.module.callbacks=this.cToHostCallbacks}setRuntimeCallbacks(Z,$){this.runtimeCallbacks.set(Z,$)}deleteRuntime(Z){this.runtimeCallbacks.delete(Z)}setContextCallbacks(Z,$){this.contextCallbacks.set(Z,$)}deleteContext(Z){this.contextCallbacks.delete(Z)}handleAsyncify(Z,$){if(Z)return Z.handleSleep((Y)=>{try{let B=$();if(!(B instanceof Promise)){m("asyncify.handleSleep: not suspending:",B),Y(B);return}if(this.suspended)throw new r8(`Already suspended at: ${this.suspended.stack}
4
4
  Attempted to suspend at:`);this.suspended=new e8(`(${this.suspendedCount++})`),m("asyncify.handleSleep: suspending:",this.suspended),B.then((C)=>{this.suspended=void 0,m("asyncify.handleSleep: resolved:",C),Y(C)},(C)=>{m("asyncify.handleSleep: rejected:",C),console.error("QuickJS: cannot handle error in suspended function",C),this.suspended=void 0})}catch(B){throw m("asyncify.handleSleep: error:",B),this.suspended=void 0,B}});let X=$();if(X instanceof Promise)throw Error("Promise return value not supported in non-asyncify context.");return X}},Y9=class{constructor(Z,$){this.module=Z,this.ffi=$,this.callbacks=new U8(Z)}newRuntime(Z={}){let $=new w(this.ffi.QTS_NewRuntime(),void 0,(Y)=>{this.ffi.QTS_FreeRuntime(Y),this.callbacks.deleteRuntime(Y)}),X=new $Z({module:this.module,callbacks:this.callbacks,ffi:this.ffi,rt:$});return H8(X,Z),Z.moduleLoader&&X.setModuleLoader(Z.moduleLoader),X}newContext(Z={}){let $=this.newRuntime(),X=$.newContext({...Z,ownedLifetimes:s9($,Z.ownedLifetimes)});return $.context=X,X}evalCode(Z,$={}){return I.withScope((X)=>{let Y=X.manage(this.newContext());j8(Y.runtime,$);let B=Y.evalCode(Z,"eval.js");if($.memoryLimitBytes!==void 0&&Y.runtime.setMemoryLimit(-1),B.error)throw Y.dump(X.manage(B.error));return Y.dump(X.manage(B.value))})}getWasmMemory(){let Z=this.module.quickjsEmscriptenInit?.(()=>{})?.getWasmMemory?.();if(!Z)throw Error("Variant does not support getting WebAssembly.Memory");return Z}getFFI(){return this.ffi}};var Q9=X8(()=>{i();i();k9=Object.defineProperty;v9={};h9(v9,{QuickJSAsyncifyError:()=>r8,QuickJSAsyncifySuspended:()=>e8,QuickJSEmptyGetOwnPropertyNames:()=>X9,QuickJSEmscriptenModuleError:()=>c9,QuickJSHostRefInvalid:()=>f,QuickJSHostRefRangeExceeded:()=>W9,QuickJSMemoryLeakDetected:()=>g9,QuickJSNotImplemented:()=>t8,QuickJSPromisePending:()=>$9,QuickJSUnknownIntrinsic:()=>Z9,QuickJSUnwrapError:()=>Y8,QuickJSUseAfterFree:()=>Q8,QuickJSWrongOwner:()=>s8});Y8=class extends Error{constructor(Z,$){let X=typeof Z=="object"&&Z&&"message"in Z?String(Z.message):String(Z);super(X);this.cause=Z,this.context=$,this.name="QuickJSUnwrapError"}},s8=class extends Error{constructor(){super(...arguments);this.name="QuickJSWrongOwner"}},Q8=class extends Error{constructor(){super(...arguments);this.name="QuickJSUseAfterFree"}},t8=class extends Error{constructor(){super(...arguments);this.name="QuickJSNotImplemented"}},r8=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifyError"}},e8=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifySuspended"}},g9=class extends Error{constructor(){super(...arguments);this.name="QuickJSMemoryLeakDetected"}},c9=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmscriptenModuleError"}},Z9=class extends TypeError{constructor(){super(...arguments);this.name="QuickJSUnknownIntrinsic"}},$9=class extends Error{constructor(){super(...arguments);this.name="QuickJSPromisePending"}},X9=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmptyGetOwnPropertyNames"}},W9=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefRangeExceeded"}},f=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefInvalid"}};J8=K9;J8.of=m9;A=class{[Symbol.dispose](){return this.dispose()}},G8=Symbol.dispose??Symbol.for("Symbol.dispose"),l8=A.prototype;l8[G8]||(l8[G8]=function(){return this.dispose()});w=class Z extends A{constructor($,X,Y,B){super();this._value=$,this.copier=X,this.disposer=Y,this._owner=B,this._alive=!0,this._constructorStack=B8?Error("Lifetime constructed").stack:void 0}get alive(){return this._alive}get value(){return this.assertAlive(),this._value}get owner(){return this._owner}get dupable(){return!!this.copier}dup(){if(this.assertAlive(),!this.copier)throw Error("Non-dupable lifetime");return new Z(this.copier(this._value),this.copier,this.disposer,this._owner)}consume($){this.assertAlive();let X=$(this);return this.dispose(),X}map($){return this.assertAlive(),$(this)}tap($){return $(this),this}dispose(){this.assertAlive(),this.disposer&&this.disposer(this._value),this._alive=!1}assertAlive(){if(!this.alive)throw this._constructorStack?new Q8(`Lifetime not alive
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @mcpcloud/runtime v0.12.1 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
1
+ /*! @mcpcloud/runtime v0.12.2 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
2
2
  var cI=Object.create;var{getPrototypeOf:rI,defineProperty:qQ,getOwnPropertyNames:pI}=Object;var dI=Object.prototype.hasOwnProperty;function oI($){return this[$]}var tI,aI,NQ=($,U,W)=>{var X=$!=null&&typeof $==="object";if(X){var J=U?tI??=new WeakMap:aI??=new WeakMap,z=J.get($);if(z)return z}W=$!=null?cI(rI($)):{};let Q=U||!$||!$.__esModule?qQ(W,"default",{value:$,enumerable:!0}):W;for(let G of pI($))if(!dI.call(Q,G))qQ(Q,G,{get:oI.bind($,G),enumerable:!0});if(X)J.set($,Q);return Q};var N=($,U)=>()=>(U||$((U={exports:{}}).exports,U),U.exports);var sI=($)=>$;function eI($,U){this[$]=sI.bind(null,U)}var G6=($,U)=>{for(var W in U)qQ($,W,{get:U[W],enumerable:!0,configurable:!0,set:eI.bind(U,W)})};var yW=N((yv)=>{Object.defineProperty(yv,"__esModule",{value:!0});yv.regexpCode=yv.getEsmExportName=yv.getProperty=yv.safeStringify=yv.stringify=yv.strConcat=yv.addCodeArg=yv.str=yv._=yv.nil=yv._Code=yv.Name=yv.IDENTIFIER=yv._CodeOrName=void 0;class W8{}yv._CodeOrName=W8;yv.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class x0 extends W8{constructor($){super();if(!yv.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}}}yv.Name=x0;class g4 extends W8{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 x0)U[W.str]=(U[W.str]||0)+1;return U},{})}}yv._Code=g4;yv.nil=new g4("");function gv($,...U){let W=[$[0]],X=0;while(X<U.length)Z5(W,U[X]),W.push($[++X]);return new g4(W)}yv._=gv;var R5=new g4("+");function fv($,...U){let W=[fW($[0])],X=0;while(X<U.length)W.push(R5),Z5(W,U[X]),W.push(R5,fW($[++X]));return kR(W),new g4(W)}yv.str=fv;function Z5($,U){if(U instanceof g4)$.push(...U._items);else if(U instanceof x0)$.push(U);else $.push(_R(U))}yv.addCodeArg=Z5;function kR($){let U=1;while(U<$.length-1){if($[U]===R5){let W=CR($[U-1],$[U+1]);if(W!==void 0){$.splice(U-1,3,W);continue}$[U++]="+"}U++}}function CR($,U){if(U==='""')return $;if($==='""')return U;if(typeof $=="string"){if(U instanceof x0||$[$.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 x0))return`"${$}${U.slice(1)}`;return}function TR($,U){return U.emptyStr()?$:$.emptyStr()?U:fv`${$}${U}`}yv.strConcat=TR;function _R($){return typeof $=="number"||typeof $=="boolean"||$===null?$:fW(Array.isArray($)?$.join(","):$)}function xR($){return new g4(fW($))}yv.stringify=xR;function fW($){return JSON.stringify($).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}yv.safeStringify=fW;function gR($){return typeof $=="string"&&yv.IDENTIFIER.test($)?new g4(`.${$}`):gv`[${$}]`}yv.getProperty=gR;function fR($){if(typeof $=="string"&&yv.IDENTIFIER.test($))return new g4(`${$}`);throw Error(`CodeGen: invalid export name: ${$}, use explicit $id name mapping`)}yv.getEsmExportName=fR;function yR($){return new g4($.toString())}yv.regexpCode=yR});var _5=N((iv)=>{Object.defineProperty(iv,"__esModule",{value:!0});iv.ValueScope=iv.ValueScopeName=iv.Scope=iv.varKinds=iv.UsedValueState=void 0;var B4=yW();class lv extends Error{constructor($){super(`CodeGen: "code" for ${$} not defined`);this.value=$.value}}var X8;(function($){$[$.Started=0]="Started",$[$.Completed=1]="Completed"})(X8||(iv.UsedValueState=X8={}));iv.varKinds={const:new B4.Name("const"),let:new B4.Name("let"),var:new B4.Name("var")};class C5{constructor({prefixes:$,parent:U}={}){this._names={},this._prefixes=$,this._parent=U}toName($){return $ instanceof B4.Name?$:this.name($)}name($){return new B4.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}}}iv.Scope=C5;class T5 extends B4.Name{constructor($,U){super(U);this.prefix=$}setValue($,{property:U,itemIndex:W}){this.value=$,this.scopePath=B4._`.${new B4.Name(U)}[${W}]`}}iv.ValueScopeName=T5;var aR=B4._`\n`;class hv extends C5{constructor($){super($);this._values={},this._scope=$.scope,this.opts={...$,_n:$.lines?aR:B4.nil}}get(){return this._scope}name($){return new T5($,this._newName($))}value($,U){var W;if(U.ref===void 0)throw Error("CodeGen: ref must be passed in value");let X=this.toName($),{prefix:J}=X,z=(W=U.key)!==null&&W!==void 0?W:U.ref,Q=this._values[J];if(Q){let D=Q.get(z);if(D)return D}else Q=this._values[J]=new Map;Q.set(z,X);let G=this._scope[J]||(this._scope[J]=[]),Y=G.length;return G[Y]=U.ref,X.setValue(U,{property:J,itemIndex:Y}),X}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 B4._`${$}${W.scopePath}`})}scopeCode($=this._values,U,W){return this._reduceValues($,(X)=>{if(X.value===void 0)throw Error(`CodeGen: name "${X}" has no value`);return X.value.code},U,W)}_reduceValues($,U,W={},X){let J=B4.nil;for(let z in $){let Q=$[z];if(!Q)continue;let G=W[z]=W[z]||new Map;Q.forEach((Y)=>{if(G.has(Y))return;G.set(Y,X8.Started);let D=U(Y);if(D){let H=this.opts.es5?iv.varKinds.var:iv.varKinds.const;J=B4._`${J}${H} ${Y} = ${D};${this.opts._n}`}else if(D=X===null||X===void 0?void 0:X(Y))J=B4._`${J}${D}${this.opts._n}`;else throw new lv(Y);G.set(Y,X8.Completed)})}return J}}iv.ValueScope=hv});var J$=N((b4)=>{Object.defineProperty(b4,"__esModule",{value:!0});b4.or=b4.and=b4.not=b4.CodeGen=b4.operators=b4.varKinds=b4.ValueScopeName=b4.ValueScope=b4.Scope=b4.Name=b4.regexpCode=b4.stringify=b4.getProperty=b4.nil=b4.strConcat=b4.str=b4._=void 0;var G$=yW(),f4=_5(),c6=yW();Object.defineProperty(b4,"_",{enumerable:!0,get:function(){return c6._}});Object.defineProperty(b4,"str",{enumerable:!0,get:function(){return c6.str}});Object.defineProperty(b4,"strConcat",{enumerable:!0,get:function(){return c6.strConcat}});Object.defineProperty(b4,"nil",{enumerable:!0,get:function(){return c6.nil}});Object.defineProperty(b4,"getProperty",{enumerable:!0,get:function(){return c6.getProperty}});Object.defineProperty(b4,"stringify",{enumerable:!0,get:function(){return c6.stringify}});Object.defineProperty(b4,"regexpCode",{enumerable:!0,get:function(){return c6.regexpCode}});Object.defineProperty(b4,"Name",{enumerable:!0,get:function(){return c6.Name}});var H8=_5();Object.defineProperty(b4,"Scope",{enumerable:!0,get:function(){return H8.Scope}});Object.defineProperty(b4,"ValueScope",{enumerable:!0,get:function(){return H8.ValueScope}});Object.defineProperty(b4,"ValueScopeName",{enumerable:!0,get:function(){return H8.ValueScopeName}});Object.defineProperty(b4,"varKinds",{enumerable:!0,get:function(){return H8.varKinds}});b4.operators={GT:new G$._Code(">"),GTE:new G$._Code(">="),LT:new G$._Code("<"),LTE:new G$._Code("<="),EQ:new G$._Code("==="),NEQ:new G$._Code("!=="),NOT:new G$._Code("!"),OR:new G$._Code("||"),AND:new G$._Code("&&"),ADD:new G$._Code("+")};class r6{optimizeNodes(){return this}optimizeNames($,U){return this}}class nv extends r6{constructor($,U,W){super();this.varKind=$,this.name=U,this.rhs=W}render({es5:$,_n:U}){let W=$?f4.varKinds.var:this.varKind,X=this.rhs===void 0?"":` = ${this.rhs}`;return`${W} ${this.name}${X};`+U}optimizeNames($,U){if(!$[this.name.str])return;if(this.rhs)this.rhs=f0(this.rhs,$,U);return this}get names(){return this.rhs instanceof G$._CodeOrName?this.rhs.names:{}}}class f5 extends r6{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 G$.Name&&!$[this.lhs.str]&&!this.sideEffects)return;return this.rhs=f0(this.rhs,$,U),this}get names(){let $=this.lhs instanceof G$.Name?{}:{...this.lhs.names};return D8($,this.rhs)}}class cv extends f5{constructor($,U,W,X){super($,W,X);this.op=U}render({_n:$}){return`${this.lhs} ${this.op}= ${this.rhs};`+$}}class rv extends r6{constructor($){super();this.label=$,this.names={}}render({_n:$}){return`${this.label}:`+$}}class pv extends r6{constructor($){super();this.label=$,this.names={}}render({_n:$}){return`break${this.label?` ${this.label}`:""};`+$}}class dv extends r6{constructor($){super();this.error=$}render({_n:$}){return`throw ${this.error};`+$}get names(){return this.error.names}}class ov extends r6{constructor($){super();this.code=$}render({_n:$}){return`${this.code};`+$}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames($,U){return this.code=f0(this.code,$,U),this}get names(){return this.code instanceof G$._CodeOrName?this.code.names:{}}}class B8 extends r6{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,X=W.length;while(X--){let J=W[X];if(J.optimizeNames($,U))continue;UZ($,J.names),W.splice(X,1)}return W.length>0?this:void 0}get names(){return this.nodes.reduce(($,U)=>N1($,U.names),{})}}class p6 extends B8{render($){return"{"+$._n+super.render($)+"}"+$._n}}class tv extends B8{}class uW extends p6{}uW.kind="else";class w6 extends p6{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 uW(W):W}if(U){if($===!1)return U instanceof w6?U:U.nodes;if(this.nodes.length)return this;return new w6(UK($),U instanceof w6?[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=f0(this.condition,$,U),this}get names(){let $=super.names;if(D8($,this.condition),this.else)N1($,this.else.names);return $}}w6.kind="if";class g0 extends p6{}g0.kind="for";class av extends g0{constructor($){super();this.iteration=$}render($){return`for(${this.iteration})`+super.render($)}optimizeNames($,U){if(!super.optimizeNames($,U))return;return this.iteration=f0(this.iteration,$,U),this}get names(){return N1(super.names,this.iteration.names)}}class sv extends g0{constructor($,U,W,X){super();this.varKind=$,this.name=U,this.from=W,this.to=X}render($){let U=$.es5?f4.varKinds.var:this.varKind,{name:W,from:X,to:J}=this;return`for(${U} ${W}=${X}; ${W}<${J}; ${W}++)`+super.render($)}get names(){let $=D8(super.names,this.from);return D8($,this.to)}}class x5 extends g0{constructor($,U,W,X){super();this.loop=$,this.varKind=U,this.name=W,this.iterable=X}render($){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render($)}optimizeNames($,U){if(!super.optimizeNames($,U))return;return this.iterable=f0(this.iterable,$,U),this}get names(){return N1(super.names,this.iterable.names)}}class z8 extends p6{constructor($,U,W){super();this.name=$,this.args=U,this.async=W}render($){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render($)}}z8.kind="func";class Q8 extends B8{render($){return"return "+super.render($)}}Q8.kind="return";class ev extends p6{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,X;return super.optimizeNames($,U),(W=this.catch)===null||W===void 0||W.optimizeNames($,U),(X=this.finally)===null||X===void 0||X.optimizeNames($,U),this}get names(){let $=super.names;if(this.catch)N1($,this.catch.names);if(this.finally)N1($,this.finally.names);return $}}class G8 extends p6{constructor($){super();this.error=$}render($){return`catch(${this.error})`+super.render($)}}G8.kind="catch";class Y8 extends p6{render($){return"finally"+super.render($)}}Y8.kind="finally";class $K{constructor($,U={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...U,_n:U.lines?`
3
3
  `:""},this._extScope=$,this._scope=new f4.Scope({parent:$}),this._nodes=[new tv]}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,X){let J=this._scope.toName(U);if(W!==void 0&&X)this._constants[J.str]=W;return this._leafNode(new nv($,J,W)),J}const($,U,W){return this._def(f4.varKinds.const,$,U,W)}let($,U,W){return this._def(f4.varKinds.let,$,U,W)}var($,U,W){return this._def(f4.varKinds.var,$,U,W)}assign($,U,W){return this._leafNode(new f5($,U,W))}add($,U){return this._leafNode(new cv($,b4.operators.ADD,U))}code($){if(typeof $=="function")$();else if($!==G$.nil)this._leafNode(new ov($));return this}object(...$){let U=["{"];for(let[W,X]of $){if(U.length>1)U.push(",");if(U.push(W),W!==X||this.opts.es5)U.push(":"),(0,G$.addCodeArg)(U,X)}return U.push("}"),new G$._Code(U)}if($,U,W){if(this._blockNode(new w6($)),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 w6($))}else(){return this._elseNode(new uW)}endIf(){return this._endBlockNode(w6,uW)}_for($,U){if(this._blockNode($),U)this.code(U).endFor();return this}for($,U){return this._for(new av($),U)}forRange($,U,W,X,J=this.opts.es5?f4.varKinds.var:f4.varKinds.let){let z=this._scope.toName($);return this._for(new sv(J,z,U,W),()=>X(z))}forOf($,U,W,X=f4.varKinds.const){let J=this._scope.toName($);if(this.opts.es5){let z=U instanceof G$.Name?U:this.var("_arr",U);return this.forRange("_i",0,G$._`${z}.length`,(Q)=>{this.var(J,G$._`${z}[${Q}]`),W(J)})}return this._for(new x5("of",X,J,U),()=>W(J))}forIn($,U,W,X=this.opts.es5?f4.varKinds.var:f4.varKinds.const){if(this.opts.ownProperties)return this.forOf($,G$._`Object.keys(${U})`,W);let J=this._scope.toName($);return this._for(new x5("in",X,J,U),()=>W(J))}endFor(){return this._endBlockNode(g0)}label($){return this._leafNode(new rv($))}break($){return this._leafNode(new pv($))}return($){let U=new Q8;if(this._blockNode(U),this.code($),U.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(Q8)}try($,U,W){if(!U&&!W)throw Error('CodeGen: "try" without "catch" and "finally"');let X=new ev;if(this._blockNode(X),this.code($),U){let J=this.name("e");this._currNode=X.catch=new G8(J),U(J)}if(W)this._currNode=X.finally=new Y8,this.code(W);return this._endBlockNode(G8,Y8)}throw($){return this._leafNode(new dv($))}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=G$.nil,W,X){if(this._blockNode(new z8($,U,W)),X)this.code(X).endFunc();return this}endFunc(){return this._endBlockNode(z8)}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 w6))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]=$}}b4.CodeGen=$K;function N1($,U){for(let W in U)$[W]=($[W]||0)+(U[W]||0);return $}function D8($,U){return U instanceof G$._CodeOrName?N1($,U.names):$}function f0($,U,W){if($ instanceof G$.Name)return X($);if(!J($))return $;return new G$._Code($._items.reduce((z,Q)=>{if(Q instanceof G$.Name)Q=X(Q);if(Q instanceof G$._Code)z.push(...Q._items);else z.push(Q);return z},[]));function X(z){let Q=W[z.str];if(Q===void 0||U[z.str]!==1)return z;return delete U[z.str],Q}function J(z){return z instanceof G$._Code&&z._items.some((Q)=>Q instanceof G$.Name&&U[Q.str]===1&&W[Q.str]!==void 0)}}function UZ($,U){for(let W in U)$[W]=($[W]||0)-(U[W]||0)}function UK($){return typeof $=="boolean"||typeof $=="number"||$===null?!$:G$._`!${g5($)}`}b4.not=UK;var WZ=WK(b4.operators.AND);function JZ(...$){return $.reduce(WZ)}b4.and=JZ;var XZ=WK(b4.operators.OR);function zZ(...$){return $.reduce(XZ)}b4.or=zZ;function WK($){return(U,W)=>U===G$.nil?W:W===G$.nil?U:G$._`${g5(U)} ${$} ${g5(W)}`}function g5($){return $ instanceof G$.Name?$:G$._`(${$})`}});var H$=N((BK)=>{Object.defineProperty(BK,"__esModule",{value:!0});BK.checkStrictMode=BK.getErrorPath=BK.Type=BK.useFunc=BK.setEvaluated=BK.evaluatedPropsToName=BK.mergeEvaluated=BK.eachItem=BK.unescapeJsonPointer=BK.escapeJsonPointer=BK.escapeFragment=BK.unescapeFragment=BK.schemaRefOrVal=BK.schemaHasRulesButRef=BK.schemaHasRules=BK.checkUnknownRules=BK.alwaysValidSchema=BK.toHash=void 0;var A$=J$(),DZ=yW();function HZ($){let U={};for(let W of $)U[W]=!0;return U}BK.toHash=HZ;function BZ($,U){if(typeof U=="boolean")return U;if(Object.keys(U).length===0)return!0;return QK($,U),!GK(U,$.self.RULES.all)}BK.alwaysValidSchema=BZ;function QK($,U=$.schema){let{opts:W,self:X}=$;if(!W.strictSchema)return;if(typeof U==="boolean")return;let J=X.RULES.keywords;for(let z in U)if(!J[z])HK($,`unknown keyword: "${z}"`)}BK.checkUnknownRules=QK;function GK($,U){if(typeof $=="boolean")return!$;for(let W in $)if(U[W])return!0;return!1}BK.schemaHasRules=GK;function bZ($,U){if(typeof $=="boolean")return!$;for(let W in $)if(W!=="$ref"&&U.all[W])return!0;return!1}BK.schemaHasRulesButRef=bZ;function OZ({topSchemaRef:$,schemaPath:U},W,X,J){if(!J){if(typeof W=="number"||typeof W=="boolean")return W;if(typeof W=="string")return A$._`${W}`}return A$._`${$}${U}${(0,A$.getProperty)(X)}`}BK.schemaRefOrVal=OZ;function vZ($){return YK(decodeURIComponent($))}BK.unescapeFragment=vZ;function KZ($){return encodeURIComponent(u5($))}BK.escapeFragment=KZ;function u5($){if(typeof $=="number")return`${$}`;return $.replace(/~/g,"~0").replace(/\//g,"~1")}BK.escapeJsonPointer=u5;function YK($){return $.replace(/~1/g,"/").replace(/~0/g,"~")}BK.unescapeJsonPointer=YK;function LZ($,U){if(Array.isArray($))for(let W of $)U(W);else U($)}BK.eachItem=LZ;function XK({mergeNames:$,mergeToName:U,mergeValues:W,resultToName:X}){return(J,z,Q,G)=>{let Y=Q===void 0?z:Q instanceof A$.Name?(z instanceof A$.Name?$(J,z,Q):U(J,z,Q),Q):z instanceof A$.Name?(U(J,Q,z),z):W(z,Q);return G===A$.Name&&!(Y instanceof A$.Name)?X(J,Y):Y}}BK.mergeEvaluated={props:XK({mergeNames:($,U,W)=>$.if(A$._`${W} !== true && ${U} !== undefined`,()=>{$.if(A$._`${U} === true`,()=>$.assign(W,!0),()=>$.assign(W,A$._`${W} || {}`).code(A$._`Object.assign(${W}, ${U})`))}),mergeToName:($,U,W)=>$.if(A$._`${W} !== true`,()=>{if(U===!0)$.assign(W,!0);else $.assign(W,A$._`${W} || {}`),l5($,W,U)}),mergeValues:($,U)=>$===!0?!0:{...$,...U},resultToName:DK}),items:XK({mergeNames:($,U,W)=>$.if(A$._`${W} !== true && ${U} !== undefined`,()=>$.assign(W,A$._`${U} === true ? true : ${W} > ${U} ? ${W} : ${U}`)),mergeToName:($,U,W)=>$.if(A$._`${W} !== true`,()=>$.assign(W,U===!0?!0:A$._`${W} > ${U} ? ${W} : ${U}`)),mergeValues:($,U)=>$===!0?!0:Math.max($,U),resultToName:($,U)=>$.var("items",U)})};function DK($,U){if(U===!0)return $.var("props",!0);let W=$.var("props",A$._`{}`);if(U!==void 0)l5($,W,U);return W}BK.evaluatedPropsToName=DK;function l5($,U,W){Object.keys(W).forEach((X)=>$.assign(A$._`${U}${(0,A$.getProperty)(X)}`,!0))}BK.setEvaluated=l5;var zK={};function wZ($,U){return $.scopeValue("func",{ref:U,code:zK[U.code]||(zK[U.code]=new DZ._Code(U.code))})}BK.useFunc=wZ;var y5;(function($){$[$.Num=0]="Num",$[$.Str=1]="Str"})(y5||(BK.Type=y5={}));function FZ($,U,W){if($ instanceof A$.Name){let X=U===y5.Num;return W?X?A$._`"[" + ${$} + "]"`:A$._`"['" + ${$} + "']"`:X?A$._`"/" + ${$}`:A$._`"/" + ${$}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return W?(0,A$.getProperty)($).toString():"/"+u5($)}BK.getErrorPath=FZ;function HK($,U,W=$.opts.strictSchema){if(!W)return;if(U=`strict mode: ${U}`,W===!0)throw Error(U);$.self.logger.warn(U)}BK.checkStrictMode=HK});var F6=N((OK)=>{Object.defineProperty(OK,"__esModule",{value:!0});var d$=J$(),gZ={data:new d$.Name("data"),valCxt:new d$.Name("valCxt"),instancePath:new d$.Name("instancePath"),parentData:new d$.Name("parentData"),parentDataProperty:new d$.Name("parentDataProperty"),rootData:new d$.Name("rootData"),dynamicAnchors:new d$.Name("dynamicAnchors"),vErrors:new d$.Name("vErrors"),errors:new d$.Name("errors"),this:new d$.Name("this"),self:new d$.Name("self"),scope:new d$.Name("scope"),json:new d$.Name("json"),jsonPos:new d$.Name("jsonPos"),jsonLen:new d$.Name("jsonLen"),jsonPart:new d$.Name("jsonPart")};OK.default=gZ});var lW=N((wK)=>{Object.defineProperty(wK,"__esModule",{value:!0});wK.extendErrors=wK.resetErrorsCount=wK.reportExtraError=wK.reportError=wK.keyword$DataError=wK.keywordError=void 0;var B$=J$(),O8=H$(),W4=F6();wK.keywordError={message:({keyword:$})=>B$.str`must pass "${$}" keyword validation`};wK.keyword$DataError={message:({keyword:$,schemaType:U})=>U?B$.str`"${$}" keyword must be ${U} ($data)`:B$.str`"${$}" keyword is invalid ($data)`};function yZ($,U=wK.keywordError,W,X){let{it:J}=$,{gen:z,compositeRule:Q,allErrors:G}=J,Y=LK($,U,W);if(X!==null&&X!==void 0?X:Q||G)vK(z,Y);else KK(J,B$._`[${Y}]`)}wK.reportError=yZ;function uZ($,U=wK.keywordError,W){let{it:X}=$,{gen:J,compositeRule:z,allErrors:Q}=X,G=LK($,U,W);if(vK(J,G),!(z||Q))KK(X,W4.default.vErrors)}wK.reportExtraError=uZ;function lZ($,U){$.assign(W4.default.errors,U),$.if(B$._`${W4.default.vErrors} !== null`,()=>$.if(U,()=>$.assign(B$._`${W4.default.vErrors}.length`,U),()=>$.assign(W4.default.vErrors,null)))}wK.resetErrorsCount=lZ;function hZ({gen:$,keyword:U,schemaValue:W,data:X,errsCount:J,it:z}){if(J===void 0)throw Error("ajv implementation error");let Q=$.name("err");$.forRange("i",J,W4.default.errors,(G)=>{if($.const(Q,B$._`${W4.default.vErrors}[${G}]`),$.if(B$._`${Q}.instancePath === undefined`,()=>$.assign(B$._`${Q}.instancePath`,(0,B$.strConcat)(W4.default.instancePath,z.errorPath))),$.assign(B$._`${Q}.schemaPath`,B$.str`${z.errSchemaPath}/${U}`),z.opts.verbose)$.assign(B$._`${Q}.schema`,W),$.assign(B$._`${Q}.data`,X)})}wK.extendErrors=hZ;function vK($,U){let W=$.const("err",U);$.if(B$._`${W4.default.vErrors} === null`,()=>$.assign(W4.default.vErrors,B$._`[${W}]`),B$._`${W4.default.vErrors}.push(${W})`),$.code(B$._`${W4.default.errors}++`)}function KK($,U){let{gen:W,validateName:X,schemaEnv:J}=$;if(J.$async)W.throw(B$._`new ${$.ValidationError}(${U})`);else W.assign(B$._`${X}.errors`,U),W.return(!1)}var I1={keyword:new B$.Name("keyword"),schemaPath:new B$.Name("schemaPath"),params:new B$.Name("params"),propertyName:new B$.Name("propertyName"),message:new B$.Name("message"),schema:new B$.Name("schema"),parentSchema:new B$.Name("parentSchema")};function LK($,U,W){let{createErrors:X}=$.it;if(X===!1)return B$._`{}`;return iZ($,U,W)}function iZ($,U,W={}){let{gen:X,it:J}=$,z=[mZ(J,W),nZ($,W)];return cZ($,U,z),X.object(...z)}function mZ({errorPath:$},{instancePath:U}){let W=U?B$.str`${$}${(0,O8.getErrorPath)(U,O8.Type.Str)}`:$;return[W4.default.instancePath,(0,B$.strConcat)(W4.default.instancePath,W)]}function nZ({keyword:$,it:{errSchemaPath:U}},{schemaPath:W,parentSchema:X}){let J=X?U:B$.str`${U}/${$}`;if(W)J=B$.str`${J}${(0,O8.getErrorPath)(W,O8.Type.Str)}`;return[I1.schemaPath,J]}function cZ($,{params:U,message:W},X){let{keyword:J,data:z,schemaValue:Q,it:G}=$,{opts:Y,propertyName:D,topSchemaRef:H,schemaPath:B}=G;if(X.push([I1.keyword,J],[I1.params,typeof U=="function"?U($):U||B$._`{}`]),Y.messages)X.push([I1.message,typeof W=="function"?W($):W]);if(Y.verbose)X.push([I1.schema,Q],[I1.parentSchema,B$._`${H}${B}`],[W4.default.data,z]);if(D)X.push([I1.propertyName,D])}});var NK=N((VK)=>{Object.defineProperty(VK,"__esModule",{value:!0});VK.boolOrEmptySchema=VK.topBoolOrEmptySchema=void 0;var tZ=lW(),aZ=J$(),sZ=F6(),eZ={message:"boolean schema is false"};function $k($){let{gen:U,schema:W,validateName:X}=$;if(W===!1)jK($,!1);else if(typeof W=="object"&&W.$async===!0)U.return(sZ.default.data);else U.assign(aZ._`${X}.errors`,null),U.return(!0)}VK.topBoolOrEmptySchema=$k;function Uk($,U){let{gen:W,schema:X}=$;if(X===!1)W.var(U,!1),jK($);else W.var(U,!0)}VK.boolOrEmptySchema=Uk;function jK($,U){let{gen:W,data:X}=$,J={gen:W,keyword:"false schema",data:X,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:$};(0,tZ.reportError)(J,eZ,void 0,U)}});var i5=N((IK)=>{Object.defineProperty(IK,"__esModule",{value:!0});IK.getRules=IK.isJSONType=void 0;var Jk=["string","number","integer","boolean","null","object","array"],Xk=new Set(Jk);function zk($){return typeof $=="string"&&Xk.has($)}IK.isJSONType=zk;function Qk(){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:{}}}IK.getRules=Qk});var m5=N((EK)=>{Object.defineProperty(EK,"__esModule",{value:!0});EK.shouldUseRule=EK.shouldUseGroup=EK.schemaHasRulesForType=void 0;function Yk({schema:$,self:U},W){let X=U.RULES.types[W];return X&&X!==!0&&MK($,X)}EK.schemaHasRulesForType=Yk;function MK($,U){return U.rules.some((W)=>SK($,W))}EK.shouldUseGroup=MK;function SK($,U){var W;return $[U.keyword]!==void 0||((W=U.definition.implements)===null||W===void 0?void 0:W.some((X)=>$[X]!==void 0))}EK.shouldUseRule=SK});var hW=N((CK)=>{Object.defineProperty(CK,"__esModule",{value:!0});CK.reportTypeError=CK.checkDataTypes=CK.checkDataType=CK.coerceAndCheckDataType=CK.getJSONTypes=CK.getSchemaTypes=CK.DataType=void 0;var Bk=i5(),bk=m5(),Ok=lW(),s=J$(),RK=H$(),y0;(function($){$[$.Correct=0]="Correct",$[$.Wrong=1]="Wrong"})(y0||(CK.DataType=y0={}));function vk($){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}CK.getSchemaTypes=vk;function ZK($){let U=Array.isArray($)?$:$?[$]:[];if(U.every(Bk.isJSONType))return U;throw Error("type must be JSONType or JSONType[]: "+U.join(","))}CK.getJSONTypes=ZK;function Kk($,U){let{gen:W,data:X,opts:J}=$,z=Lk(U,J.coerceTypes),Q=U.length>0&&!(z.length===0&&U.length===1&&(0,bk.schemaHasRulesForType)($,U[0]));if(Q){let G=c5(U,X,J.strictNumbers,y0.Wrong);W.if(G,()=>{if(z.length)wk($,U,z);else r5($)})}return Q}CK.coerceAndCheckDataType=Kk;var kK=new Set(["string","number","integer","boolean","null"]);function Lk($,U){return U?$.filter((W)=>kK.has(W)||U==="array"&&W==="array"):[]}function wk($,U,W){let{gen:X,data:J,opts:z}=$,Q=X.let("dataType",s._`typeof ${J}`),G=X.let("coerced",s._`undefined`);if(z.coerceTypes==="array")X.if(s._`${Q} == 'object' && Array.isArray(${J}) && ${J}.length == 1`,()=>X.assign(J,s._`${J}[0]`).assign(Q,s._`typeof ${J}`).if(c5(U,J,z.strictNumbers),()=>X.assign(G,J)));X.if(s._`${G} !== undefined`);for(let D of W)if(kK.has(D)||D==="array"&&z.coerceTypes==="array")Y(D);X.else(),r5($),X.endIf(),X.if(s._`${G} !== undefined`,()=>{X.assign(J,G),Fk($,G)});function Y(D){switch(D){case"string":X.elseIf(s._`${Q} == "number" || ${Q} == "boolean"`).assign(G,s._`"" + ${J}`).elseIf(s._`${J} === null`).assign(G,s._`""`);return;case"number":X.elseIf(s._`${Q} == "boolean" || ${J} === null
4
4
  || (${Q} == "string" && ${J} && ${J} == +${J})`).assign(G,s._`+${J}`);return;case"integer":X.elseIf(s._`${Q} === "boolean" || ${J} === null
@@ -109,4 +109,4 @@ ${CI.map(($)=>` ${$}: (...args) => globalThis.${k3}(${JSON.stringify($)}, JSON.
109
109
  `).trim():void 0;return{message:`${W}: ${X}`,...J?{stack:J}:{}}}return{message:String($)}}function jQ($){if($.alive)$.dispose()}function Mn($,U){if($.typeof(U)!=="object")return!1;let W=$.getProp(U,"then"),X=$.typeof(W)==="function";return W.dispose(),X}function Sn($,U){$.setMemoryLimit(U.memoryBytes),$.setMaxStackSize(U.stackBytes);let W=0,X=null,J=Date.now()+U.wallClockMs;return $.setInterruptHandler(()=>{if(W+=1,W>U.opcodeBudget)return X="opcodes",!0;if(Date.now()>J)return X="wall_clock",!0;return!1}),$.setModuleLoader(()=>{throw Error("Module imports are not available in this sandbox.")}),{readTicks:()=>W,readReason:()=>X}}async function T3($,U){let W={...xI,...$.limits},X=$.engine.newRuntime(),{readTicks:J,readReason:z}=Sn(X,W),Q=X.newContext(),G=!1,{entries:Y}=TI(Q),D=[],H=()=>!1,B=()=>!1;if($.bindings){let b=kI(X,Q,$.bindings,W.maxToolCalls);D=b.spans,H=b.exceededCap,B=b.deniedByPolicy}let O=(b,v,K={})=>({ok:!1,kind:b,message:v,opcodesUsed:J(),spans:D,logs:Y,...K});try{let b=Q.evalCode(U,C3);if(b.error){let L=Q.dump(b.error);if(jQ(b.error),B())return O("policy_denied",FQ(L).message);if(H())return O("budget_exhausted",`Execution exceeded its budget of ${W.maxToolCalls} tool calls. Filter before the loop, or page the input.`,{budget:"tool_calls"});let A=z();if(A==="opcodes")return O("budget_exhausted",`Execution exceeded its compute budget of ${W.opcodeBudget.toLocaleString()} opcodes.`,{budget:"opcodes"});if(A==="wall_clock")return O("timeout",`Execution exceeded its ${W.wallClockMs} ms deadline.`,{budget:"wall_clock"});let I=FQ(L);if(/out of memory/i.test(I.message))return O("budget_exhausted",I.message,{budget:"memory"});if(_I(I.message))return O("budget_exhausted",I.message,{budget:"stack"});return O(An(I.message)?"syntax_error":"runtime_error",I.message,I.stack?{stack:I.stack}:{})}if(!Mn(Q,b.value)){let L=Q.dump(b.value);return jQ(b.value),{ok:!0,value:L,opcodesUsed:J(),spans:D,logs:Y}}let v=Q.resolvePromise(b.value);jQ(b.value),X.executePendingJobs();let K=await v;if(K.error){let L=Q.dump(K.error);if(K.error.dispose(),B())return O("policy_denied",FQ(L).message);if(H())return O("budget_exhausted",`Execution exceeded its budget of ${W.maxToolCalls} tool calls. Filter before the loop, or page the input.`,{budget:"tool_calls"});let A=FQ(L);return O("runtime_error",A.message,A.stack?{stack:A.stack}:{})}let w=Q.dump(K.value);return jQ(K.value),{ok:!0,value:w,opcodesUsed:J(),spans:D,logs:Y}}catch(b){if(_I(b))return G=!0,O("budget_exhausted","Execution exceeded the available call stack. Rewrite deep recursion as iteration.",{budget:"stack"});throw b}finally{if(!G)Q.dispose(),X.dispose()}}function g3($){if(!$?.engine)return!1;return($.mode??"opt-in")!=="off"}var yI=null;function lI($){if(!$||$.engine||!yI)return $;return{...$,engine:yI}}function x3($){if(!$)return null;if($.readOnlyHint===!0)return"read";if($.destructiveHint===!0)return"delete";if($.readOnlyHint===!1)return"write";return null}function En($,U){let W=$.content?.[0],X=W&&W.type==="text"&&typeof W.text==="string"?W.text:null;if($.isError)throw Error(X??`Tool "${U}" failed.`);if(X===null)return null;try{return JSON.parse(X)}catch{return X}}function Pn($,U){let{suggestion:W,nearest:X}=xO($,U,5),J=[`Unknown tool "${$}".`];if(W)J.push(`Did you mean "${W}"?`);let z=W?X.filter((Q)=>Q!==W):X;if(z.length)J.push(`Nearest: ${z.join(", ")}`);return J.join(" ")}var _3=12,Rn=8;function Zn($,U){if(!$)return[];let W=$.split(`
110
110
  `);if(U<1||U>W.length)return[];let X=Math.max(1,U-1),J=Math.min(W.length,U+1),z=String(J).length;return Array.from({length:J-X+1},(Q,G)=>{let Y=X+G,D=Y===U?">":" ",H=W[Y-1],B=H.length>100?`${H.slice(0,100)}…`:H;return` ${D} ${String(Y).padStart(z)} | ${B}`})}function hI($,U){if($.ok)return"";let W=[`ExecutionError: ${$.kind}`,` ${$.message}`];if($.budget)W.push(` budget: ${$.budget}`);let X=$.spans;if(X.length){let J=X.filter((Y)=>Y.error),z=J.length===1&&J[0].error===$.message;W.push(` tool calls (${X.length}):`);let Q=X.length<=_3?X:[...X.slice(0,_3-4),null,...X.slice(-3)];for(let Y of Q){if(Y===null){W.push(` … ${X.length-_3+1} more`);continue}let D=Y.error?z?"ERROR (message above)":`ERROR ${Y.error}`:Y.resultShape??"ok",H=Y.mutates&&!Y.error?" ⚠ COMMITTED":"";W.push(` ${Y.name}(${JSON.stringify(Y.args)}) ${Y.durationMs}ms → ${D}${H}`)}let G=X.find((Y)=>Y.facts?.length)?.facts?.[0];if(G)W.push(` shape: ${G}`)}if($.logs.length){let J=$.logs.slice(-Rn),z=$.logs.length-J.length;if(W.push(` console (${$.logs.length}):`),z>0)W.push(` … ${z} earlier`);for(let Q of J)W.push(` ${Q.level}: ${Q.message}`)}if($.stack){let J=$.stack.split(`
111
111
  `)[0].trim();W.push(` at: ${J}`);let z=fI($.stack);if(z)W.push(...Zn(U,z.line))}return W.join(`
112
- `)}function iI($,U,W,X){let J=new Map($.map((z)=>[z.definition.name,z]));return async(z)=>{let Q=z?.code;if(typeof Q!=="string"||!Q.trim())return{isError:!0,content:[{type:"text",text:"Provide JavaScript to run in `code`."}]};let G=await X.engine(),Y=await T3({engine:G,limits:X.limits,bindings:{allowedEffects:X.allowedEffects,isKnownTool:(D)=>J.has(D),describeUnknownTool:(D)=>Pn(D,[...J.keys()]),effectClassFor:(D)=>x3(J.get(D)?.definition.annotations),isMutation:(D)=>x3(J.get(D)?.definition.annotations)!=="read",callTool:async({name:D,args:H})=>{let B=J.get(D);if(!B)throw Error(`Unknown tool "${D}".`);return En(await B.handler(H,U,W),D)}}},Q);if(Y.ok)return{content:[{type:"text",text:JSON.stringify(Y.value??null,null,2)}],_meta:{opcodesUsed:Y.opcodesUsed,toolCalls:Y.spans.length}};return{isError:!0,content:[{type:"text",text:hI(Y)}],_meta:{error:Y.message,errorClass:Y.kind,...Y.budget?{budget:Y.budget}:{},opcodesUsed:Y.opcodesUsed,toolCalls:Y.spans.length}}}}var f3="codemode_execute",uI='Run JavaScript against this server\'s tools and return only the final result. Call tools with `await tool("toolName", { ...args })`. Loops, filtering and Promise.all all work, and intermediate results never enter your context. Read and write tools are available; destructive ones must be called directly.';function y3($){return $==="default"?`${uI} Prefer this over calling many tools one at a time.`:`${uI} Useful when a task chains several tools together.`}function kn($){let U=$.headers.get("accept")||"";return $.method==="GET"&&U.includes("text/html")}function mI($,U){let W=new URL($.url),X=CJ(U),J=z5(X);return Response.json({status:"ok",message:J.protected?"This Worker exposes a protected MCP endpoint. Use the /mcp path with an MCP client plus an MCPCloud runtime access token, and /health for liveness checks.":"This Worker exposes an MCP endpoint. Use the /mcp path with an MCP client, and /health for liveness checks.",accessMode:X,authentication:{required:J.protected,scheme:J.protected?"Bearer runtime token":null,summary:J.summary},endpoints:{health:`${W.origin}/health`,mcp:`${W.origin}/mcp`}},{status:200})}function Cn($,U,W,X){for(let{definition:J,handler:z}of U)$.registerTool(J.name,{title:H5(J.name,J.title),description:D5(J.name,J.description),inputSchema:uz(J.inputSchema),...J.annotations?{annotations:J.annotations}:{}},async(Q)=>jW(()=>z(Q,W,X)))}function nI($,U,W,X,J){let z=iI(U,W,X,J);$.registerTool(f3,{title:"Run code against these tools",description:y3(J.mode??"opt-in"),inputSchema:z$.object({code:z$.string().describe("JavaScript to run. Use `await tool(name, args)`; return the final answer.")}),annotations:{readOnlyHint:!1,destructiveHint:!1,openWorldHint:!0}},async(Q)=>jW(()=>z(Q)))}function Tn($,U,W,X){let J=U.map(({definition:G})=>({name:G.name,title:G.title,description:G.description,tags:G.semanticTags})),z=Object.fromEntries(U.map(({definition:G,handler:Y})=>[G.name,(D)=>Y(D,W,X)])),Q=Object.fromEntries(U.map(({definition:G})=>[G.name,G]));$.registerTool("searchTools",{title:"Search tools",description:"Find tools on this server by keyword or /regex/. Returns matching tool names and summaries WITHOUT their full input schemas, to save tokens. Call getToolDefinition for a tool's input schema, then useTool to run it.",inputSchema:z$.object({query:z$.string(),limit:z$.number().int().optional()})},async(G)=>{let Y=G,D=b5(J,Y.query??"",typeof Y.limit==="number"?Y.limit:10);return{content:[{type:"text",text:JSON.stringify(D,null,2)}]}}),$.registerTool("getToolDefinition",{title:"Get tool definition",description:"Fetch the full definition (input schema, description) for one tool by exact name. Discover names with searchTools first.",inputSchema:z$.object({name:z$.string()})},async(G)=>{let Y=G,D=Y.name?Q[Y.name]:void 0;if(!D)return{isError:!0,content:[{type:"text",text:`Unknown tool '${Y.name??""}'. Use searchTools to list available tools.`}]};return{content:[{type:"text",text:JSON.stringify({name:D.name,title:D.title,description:D.description,inputSchema:D.inputSchema,outputSchema:D.outputSchema},null,2)}]}}),$.registerTool("useTool",{title:"Use tool",description:"Execute a tool by exact name with its arguments. Get the argument shape from getToolDefinition first.",inputSchema:z$.object({name:z$.string(),arguments:z$.object({}).passthrough().optional()})},async(G)=>{let Y=G,D=Y.name?z[Y.name]:void 0;if(!D){let H=`Unknown tool '${Y.name??""}'. Use searchTools to list available tools.`;return{isError:!0,content:[{type:"text",text:H}],_meta:{error:H,errorClass:"BINDING_MISUSE",retryable:!1}}}return jW(()=>D(Y.arguments??{}))})}function _n($,U){return $.replace(/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g,(W,X)=>{let J=U[X];return J==null?"":String(J)})}function xn($,U){let W=$.registerPrompt.bind($);for(let X of U){let J={};for(let z of X.arguments)J[z.name]=z.required===!1?z$.string().optional():z$.string();W(X.name,{title:X.name,description:X.description??void 0,argsSchema:J},(z)=>({messages:[{role:"user",content:{type:"text",text:_n(X.template,z??{})}}]}))}}async function gn($,U,W){if($.resourceType==="static")return $.staticContent??"";let X=U.upstreamBaseUrl;if(!X)return`Dynamic resource "${$.uri}" has no upstream base URL configured.`;let J=$.upstreamPathTemplate??"",z=`${X.replace(/\/+$/,"")}/${J.replace(/^\/+/,"")}`,Q=await LW(U,$.uri,[],W);return await(await fetch(z,{method:"GET",headers:Q})).text()}function fn($,U,W,X){let J=$.registerResource.bind($);for(let z of U)J(z.name,z.uri,{title:z.name,description:z.description??void 0,mimeType:z.mimeType},async()=>({contents:[{uri:z.uri,mimeType:z.mimeType,text:await gn(z,W,X)}]}))}function yn($){function U(z,Q){let G=new LQ({name:z.serverName,version:z.serverVersion},{capabilities:{logging:{}}}),Y=lI($.codeMode),D=g3(Y)?Y:null;if(D?.mode==="default")nI(G,$.tools,z,Q,D);if($.discoveryMode==="wrapper")Tn(G,$.tools,z,Q);else Cn(G,$.tools,z,Q);if(D&&D.mode!=="default")nI(G,$.tools,z,Q,D);if($.prompts&&$.prompts.length>0)xn(G,$.prompts);if($.resources&&$.resources.length>0)fn(G,$.resources,z,Q);return G}function W(z){return U(TJ($.identity,z),{userId:null,runtimeToken:null})}function X(z,Q){if(!Q?.applied||Q.preBytes<=0)return z;let G=new Headers(z.headers);return G.set("x-mcpcloud-projection-pre-bytes",String(Q.preBytes)),G.set("x-mcpcloud-projection-post-bytes",String(Q.postBytes)),new Response(z.body,{status:z.status,statusText:z.statusText,headers:G})}async function J(z,Q){let{pathname:G}=new URL(z.url);if(G==="/health")return Response.json({status:"ok"});if(G==="/")return mI(z,Q);if(G!=="/mcp")return new Response("Not found",{status:404});if(kn(z))return mI(z,Q);let Y=TJ($.identity,Q),D=await Q5(z,Y);if(D.response)return D.response;let H={userId:D.callerUserId,runtimeToken:D.rawToken,projectionUsage:{preBytes:0,postBytes:0,applied:!1}},B=U(Y,H),O=new wQ({sessionIdGenerator:void 0,enableJsonResponse:!0});await B.connect(O);let b=await O.handleRequest(z);return X(b,H.projectionUsage)}return{createServer:W,handleRequest:J,options:$}}function un($){return{async fetch(U,W){return await $.handleRequest(U,W)}}}export{z$ as z,un as toWorkerHandler,VO as toToolErrorResult,RJ as summarizeShape,g3 as shouldRegisterCodeMode,gP as setMetadataOverride,b5 as searchCatalog,jW as runToolHandler,T3 as runInSandbox,wO as resolveUseOAuth,H5 as resolveTitle,TJ as resolveRuntimeConfig,CJ as resolveRuntimeAccessMode,D5 as resolveDescription,MQ as postOAuthRuntimeRequest,HP as parseUpstreamResponse,bP as normalizeUpstreamPayload,J5 as mapUpstreamError,qW as jsonSchemaToZodSchema,uz as jsonSchemaToZodObject,FO as isRetryableUpstreamStatus,RO as isProtectedRuntimeAccessMode,LO as hasOauthSecurity,AQ as getProcessEnv,yP as getMetadataOverrides,OP as formatToolResultText,IO as encodeFormUrlencodedBody,x3 as effectClassFromAnnotations,z5 as describeRuntimeAccess,P3 as describeDistribution,yn as defineServer,y3 as codeModeDescription,fP as clearMetadataOverrides,jO as classifyToolError,DP as buildUpstreamRequest,LW as buildUpstreamHeaders,hI as buildFailureDigest,Q5 as authorizeRuntimeRequest,SP as assertValidInput,_P as applyResponseProjectionMeasured,cO as applyResponseProjection,wQ as WebStandardStreamableHTTPServerTransport,wW as UpstreamHttpError,FW as ToolInputError,LQ as McpServer,y as McpError,xI as DEFAULT_SANDBOX_LIMITS,f3 as CODE_MODE_TOOL_NAME};
112
+ `)}function iI($,U,W,X){let J=new Map($.map((z)=>[z.definition.name,z]));return async(z)=>{let Q=z?.code;if(typeof Q!=="string"||!Q.trim())return{isError:!0,content:[{type:"text",text:"Provide JavaScript to run in `code`."}]};let G=await X.engine(),Y=await T3({engine:G,limits:X.limits,bindings:{allowedEffects:X.allowedEffects,isKnownTool:(D)=>J.has(D),describeUnknownTool:(D)=>Pn(D,[...J.keys()]),effectClassFor:(D)=>x3(J.get(D)?.definition.annotations),isMutation:(D)=>x3(J.get(D)?.definition.annotations)!=="read",callTool:async({name:D,args:H})=>{let B=J.get(D);if(!B)throw Error(`Unknown tool "${D}".`);return En(await B.handler(H,U,W),D)}}},Q);if(Y.ok)return{content:[{type:"text",text:JSON.stringify(Y.value??null,null,2)}],_meta:{opcodesUsed:Y.opcodesUsed,toolCalls:Y.spans.length}};return{isError:!0,content:[{type:"text",text:hI(Y)}],_meta:{error:Y.message,errorClass:Y.kind,...Y.budget?{budget:Y.budget}:{},opcodesUsed:Y.opcodesUsed,toolCalls:Y.spans.length}}}}var f3="codemode_execute",uI='Run JavaScript against this server\'s tools and get back only the final result. Call tools with `await tool("toolName", { ...args })`. Loops, filtering and Promise.all all work, and intermediate results never enter your context. Your code is evaluated as a script, not as a function body: the answer is the value of the last expression, so a top-level `return` is a syntax error. The usual shape is `(async () => { const r = await tool("toolName", {}); return r })()`. Read and write tools are available; destructive ones must be called directly.';function y3($){return $==="default"?`${uI} Prefer this over calling many tools one at a time.`:`${uI} Useful when a task chains several tools together.`}function kn($){let U=$.headers.get("accept")||"";return $.method==="GET"&&U.includes("text/html")}function mI($,U){let W=new URL($.url),X=CJ(U),J=z5(X);return Response.json({status:"ok",message:J.protected?"This Worker exposes a protected MCP endpoint. Use the /mcp path with an MCP client plus an MCPCloud runtime access token, and /health for liveness checks.":"This Worker exposes an MCP endpoint. Use the /mcp path with an MCP client, and /health for liveness checks.",accessMode:X,authentication:{required:J.protected,scheme:J.protected?"Bearer runtime token":null,summary:J.summary},endpoints:{health:`${W.origin}/health`,mcp:`${W.origin}/mcp`}},{status:200})}function Cn($,U,W,X){for(let{definition:J,handler:z}of U)$.registerTool(J.name,{title:H5(J.name,J.title),description:D5(J.name,J.description),inputSchema:uz(J.inputSchema),...J.annotations?{annotations:J.annotations}:{}},async(Q)=>jW(()=>z(Q,W,X)))}function nI($,U,W,X,J){let z=iI(U,W,X,J);$.registerTool(f3,{title:"Run code against these tools",description:y3(J.mode??"opt-in"),inputSchema:z$.object({code:z$.string().describe("JavaScript to run, evaluated as a script. Use `await tool(name, args)`. "+"The answer is the value of the last expression — a top-level `return` "+"will not parse. Usual shape: `(async () => { ... })()`.")}),annotations:{readOnlyHint:!1,destructiveHint:!1,openWorldHint:!0}},async(Q)=>jW(()=>z(Q)))}function Tn($,U,W,X){let J=U.map(({definition:G})=>({name:G.name,title:G.title,description:G.description,tags:G.semanticTags})),z=Object.fromEntries(U.map(({definition:G,handler:Y})=>[G.name,(D)=>Y(D,W,X)])),Q=Object.fromEntries(U.map(({definition:G})=>[G.name,G]));$.registerTool("searchTools",{title:"Search tools",description:"Find tools on this server by keyword or /regex/. Returns matching tool names and summaries WITHOUT their full input schemas, to save tokens. Call getToolDefinition for a tool's input schema, then useTool to run it.",inputSchema:z$.object({query:z$.string(),limit:z$.number().int().optional()})},async(G)=>{let Y=G,D=b5(J,Y.query??"",typeof Y.limit==="number"?Y.limit:10);return{content:[{type:"text",text:JSON.stringify(D,null,2)}]}}),$.registerTool("getToolDefinition",{title:"Get tool definition",description:"Fetch the full definition (input schema, description) for one tool by exact name. Discover names with searchTools first.",inputSchema:z$.object({name:z$.string()})},async(G)=>{let Y=G,D=Y.name?Q[Y.name]:void 0;if(!D)return{isError:!0,content:[{type:"text",text:`Unknown tool '${Y.name??""}'. Use searchTools to list available tools.`}]};return{content:[{type:"text",text:JSON.stringify({name:D.name,title:D.title,description:D.description,inputSchema:D.inputSchema,outputSchema:D.outputSchema},null,2)}]}}),$.registerTool("useTool",{title:"Use tool",description:"Execute a tool by exact name with its arguments. Get the argument shape from getToolDefinition first.",inputSchema:z$.object({name:z$.string(),arguments:z$.object({}).passthrough().optional()})},async(G)=>{let Y=G,D=Y.name?z[Y.name]:void 0;if(!D){let H=`Unknown tool '${Y.name??""}'. Use searchTools to list available tools.`;return{isError:!0,content:[{type:"text",text:H}],_meta:{error:H,errorClass:"BINDING_MISUSE",retryable:!1}}}return jW(()=>D(Y.arguments??{}))})}function _n($,U){return $.replace(/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g,(W,X)=>{let J=U[X];return J==null?"":String(J)})}function xn($,U){let W=$.registerPrompt.bind($);for(let X of U){let J={};for(let z of X.arguments)J[z.name]=z.required===!1?z$.string().optional():z$.string();W(X.name,{title:X.name,description:X.description??void 0,argsSchema:J},(z)=>({messages:[{role:"user",content:{type:"text",text:_n(X.template,z??{})}}]}))}}async function gn($,U,W){if($.resourceType==="static")return $.staticContent??"";let X=U.upstreamBaseUrl;if(!X)return`Dynamic resource "${$.uri}" has no upstream base URL configured.`;let J=$.upstreamPathTemplate??"",z=`${X.replace(/\/+$/,"")}/${J.replace(/^\/+/,"")}`,Q=await LW(U,$.uri,[],W);return await(await fetch(z,{method:"GET",headers:Q})).text()}function fn($,U,W,X){let J=$.registerResource.bind($);for(let z of U)J(z.name,z.uri,{title:z.name,description:z.description??void 0,mimeType:z.mimeType},async()=>({contents:[{uri:z.uri,mimeType:z.mimeType,text:await gn(z,W,X)}]}))}function yn($){function U(z,Q){let G=new LQ({name:z.serverName,version:z.serverVersion},{capabilities:{logging:{}}}),Y=lI($.codeMode),D=g3(Y)?Y:null;if(D?.mode==="default")nI(G,$.tools,z,Q,D);if($.discoveryMode==="wrapper")Tn(G,$.tools,z,Q);else Cn(G,$.tools,z,Q);if(D&&D.mode!=="default")nI(G,$.tools,z,Q,D);if($.prompts&&$.prompts.length>0)xn(G,$.prompts);if($.resources&&$.resources.length>0)fn(G,$.resources,z,Q);return G}function W(z){return U(TJ($.identity,z),{userId:null,runtimeToken:null})}function X(z,Q){if(!Q?.applied||Q.preBytes<=0)return z;let G=new Headers(z.headers);return G.set("x-mcpcloud-projection-pre-bytes",String(Q.preBytes)),G.set("x-mcpcloud-projection-post-bytes",String(Q.postBytes)),new Response(z.body,{status:z.status,statusText:z.statusText,headers:G})}async function J(z,Q){let{pathname:G}=new URL(z.url);if(G==="/health")return Response.json({status:"ok"});if(G==="/")return mI(z,Q);if(G!=="/mcp")return new Response("Not found",{status:404});if(kn(z))return mI(z,Q);let Y=TJ($.identity,Q),D=await Q5(z,Y);if(D.response)return D.response;let H={userId:D.callerUserId,runtimeToken:D.rawToken,projectionUsage:{preBytes:0,postBytes:0,applied:!1}},B=U(Y,H),O=new wQ({sessionIdGenerator:void 0,enableJsonResponse:!0});await B.connect(O);let b=await O.handleRequest(z);return X(b,H.projectionUsage)}return{createServer:W,handleRequest:J,options:$}}function un($){return{async fetch(U,W){return await $.handleRequest(U,W)}}}export{z$ as z,un as toWorkerHandler,VO as toToolErrorResult,RJ as summarizeShape,g3 as shouldRegisterCodeMode,gP as setMetadataOverride,b5 as searchCatalog,jW as runToolHandler,T3 as runInSandbox,wO as resolveUseOAuth,H5 as resolveTitle,TJ as resolveRuntimeConfig,CJ as resolveRuntimeAccessMode,D5 as resolveDescription,MQ as postOAuthRuntimeRequest,HP as parseUpstreamResponse,bP as normalizeUpstreamPayload,J5 as mapUpstreamError,qW as jsonSchemaToZodSchema,uz as jsonSchemaToZodObject,FO as isRetryableUpstreamStatus,RO as isProtectedRuntimeAccessMode,LO as hasOauthSecurity,AQ as getProcessEnv,yP as getMetadataOverrides,OP as formatToolResultText,IO as encodeFormUrlencodedBody,x3 as effectClassFromAnnotations,z5 as describeRuntimeAccess,P3 as describeDistribution,yn as defineServer,y3 as codeModeDescription,fP as clearMetadataOverrides,jO as classifyToolError,DP as buildUpstreamRequest,LW as buildUpstreamHeaders,hI as buildFailureDigest,Q5 as authorizeRuntimeRequest,SP as assertValidInput,_P as applyResponseProjectionMeasured,cO as applyResponseProjection,wQ as WebStandardStreamableHTTPServerTransport,wW as UpstreamHttpError,FW as ToolInputError,LQ as McpServer,y as McpError,xI as DEFAULT_SANDBOX_LIMITS,f3 as CODE_MODE_TOOL_NAME};
package/dist/node.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @mcpcloud/runtime v0.12.1 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
1
+ /*! @mcpcloud/runtime v0.12.2 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
2
2
  var L9=Object.create;var{getPrototypeOf:O9,defineProperty:$8,getOwnPropertyNames:F9}=Object;var R9=Object.prototype.hasOwnProperty;function M9(Z){return this[Z]}var V9,_9,w9=(Z,$,W)=>{var Q=Z!=null&&typeof Z==="object";if(Q){var B=$?V9??=new WeakMap:_9??=new WeakMap,C=B.get(Z);if(C)return C}W=Z!=null?L9(O9(Z)):{};let H=$||!Z||!Z.__esModule?$8(W,"default",{value:Z,enumerable:!0}):W;for(let K of F9(Z))if(!R9.call(H,K))$8(H,K,{get:M9.bind(Z,K),enumerable:!0});if(Q)B.set(Z,H);return H};var P9=(Z,$)=>()=>($||Z(($={exports:{}}).exports,$),$.exports);var N9=(Z)=>Z;function E9(Z,$){this[Z]=N9.bind(null,$)}var S9=(Z,$)=>{for(var W in $)$8(Z,W,{get:$[W],enumerable:!0,configurable:!0,set:E9.bind($,W)})};var X8=(Z,$)=>()=>(Z&&($=Z(Z=0)),$);var k,W8,l,h,c;var i=X8(()=>{k={JS_EVAL_TYPE_GLOBAL:0,JS_EVAL_TYPE_MODULE:1,JS_EVAL_TYPE_DIRECT:2,JS_EVAL_TYPE_INDIRECT:3,JS_EVAL_TYPE_MASK:3,JS_EVAL_FLAG_STRICT:8,JS_EVAL_FLAG_STRIP:16,JS_EVAL_FLAG_COMPILE_ONLY:32,JS_EVAL_FLAG_BACKTRACE_BARRIER:64},W8={BaseObjects:1,Date:2,Eval:4,StringNormalize:8,RegExp:16,RegExpCompiler:32,JSON:64,Proxy:128,MapSet:256,TypedArrays:512,Promise:1024,BigInt:2048,BigFloat:4096,BigDecimal:8192,OperatorOverloading:16384,BignumExt:32768},l={Pending:0,Fulfilled:1,Rejected:2},h={JS_GPN_STRING_MASK:1,JS_GPN_SYMBOL_MASK:2,JS_GPN_PRIVATE_MASK:4,JS_GPN_ENUM_ONLY:16,JS_GPN_SET_ENUM:32,QTS_GPN_NUMBER_MASK:64,QTS_STANDARD_COMPLIANT_NUMBER:128},c={IsStrictlyEqual:0,IsSameValue:1,IsSameValueZero:2}});function m(...Z){B8&&console.log("quickjs-emscripten:",...Z)}function*X9(Z){return yield Z}function y9(Z){return X9(q8(Z))}function d8(Z,$){return(...W)=>{let Q=$.call(Z,J8,...W);return q8(Q)}}function k9(Z,$){let W=$.call(Z,J8);return q8(W)}function q8(Z){function $(W){return W.done?W.value:W.value instanceof Promise?W.value.then((Q)=>$(Z.next(Q)),(Q)=>$(Z.throw(Q))):$(Z.next(W.value))}return $(Z.next())}function z8(Z,$){let W;try{Z.dispose()}catch(Q){W=Q}if($&&W)throw Object.assign($,{message:`${$.message}
3
3
  Then, failed to dispose scope: ${W.message}`,disposeError:W}),$;if($||W)throw $||W}function h9(Z){let $=Z?Array.from(Z):[];function W(){return $.forEach((B)=>B.alive?B.dispose():void 0)}function Q(){return $.some((B)=>B.alive)}return Object.defineProperty($,G8,{configurable:!0,enumerable:!1,value:W}),Object.defineProperty($,"dispose",{configurable:!0,enumerable:!1,value:W}),Object.defineProperty($,"alive",{configurable:!0,enumerable:!1,get:Q}),$}function n(Z){return!!(Z&&(typeof Z=="object"||typeof Z=="function")&&("alive"in Z)&&typeof Z.alive=="boolean"&&("dispose"in Z)&&typeof Z.dispose=="function")}function m9(Z){if(!Z)return 0;let $=0;for(let[W,Q]of Object.entries(Z)){if(!(W in W8))throw new r8(W);Q&&($|=W8[W])}return $}function d9(Z){if(typeof Z=="number")return Z;if(Z===void 0)return 0;let{type:$,strict:W,strip:Q,compileOnly:B,backtraceBarrier:C}=Z,H=0;return $==="global"&&(H|=k.JS_EVAL_TYPE_GLOBAL),$==="module"&&(H|=k.JS_EVAL_TYPE_MODULE),W&&(H|=k.JS_EVAL_FLAG_STRICT),Q&&(H|=k.JS_EVAL_FLAG_STRIP),B&&(H|=k.JS_EVAL_FLAG_COMPILE_ONLY),C&&(H|=k.JS_EVAL_FLAG_BACKTRACE_BARRIER),H}function p9(Z){if(typeof Z=="number")return Z;if(Z===void 0)return 0;let{strings:$,symbols:W,quickjsPrivate:Q,onlyEnumerable:B,numbers:C,numbersAsStrings:H}=Z,K=0;return $&&(K|=h.JS_GPN_STRING_MASK),W&&(K|=h.JS_GPN_SYMBOL_MASK),Q&&(K|=h.JS_GPN_PRIVATE_MASK),B&&(K|=h.JS_GPN_ENUM_ONLY),C&&(K|=h.QTS_GPN_NUMBER_MASK),H&&(K|=h.QTS_STANDARD_COMPLIANT_NUMBER),K}function u9(...Z){let $=[];for(let W of Z)W!==void 0&&($=$.concat(W));return $}function K8(Z){return Z>>8}function H8(Z,$){$.interruptHandler&&Z.setInterruptHandler($.interruptHandler),$.maxStackSizeBytes!==void 0&&Z.setMaxStackSize($.maxStackSizeBytes),$.memoryLimitBytes!==void 0&&Z.setMemoryLimit($.memoryLimitBytes)}function j8(Z,$){$.moduleLoader&&Z.setModuleLoader($.moduleLoader),$.shouldInterrupt&&Z.setInterruptHandler($.shouldInterrupt),$.memoryLimitBytes!==void 0&&Z.setMemoryLimit($.memoryLimitBytes),$.maxStackSizeBytes!==void 0&&Z.setMaxStackSize($.maxStackSizeBytes)}var x9,b9=(Z,$)=>{for(var W in $)x9(Z,W,{get:$[W],enumerable:!0})},B8=!1,A9,Y8,n8,Q8,a8,s8,t8,T9,f9,r8,e8,Z9,$9,f,J8,b,G8,p8,w,v,u8,I,C8,v9,g9,g,c9,W9=class{constructor(Z){this.module=Z}toPointerArray(Z){let $=new Int32Array(Z.map((B)=>B.value)),W=$.length*$.BYTES_PER_ELEMENT,Q=this.module._malloc(W);return new Uint8Array(this.module.HEAPU8.buffer,Q,W).set(new Uint8Array($.buffer)),new w(Q,void 0,(B)=>this.module._free(B))}newTypedArray(Z,$){let W=new Z(Array($).fill(0)),Q=W.length*W.BYTES_PER_ELEMENT,B=this.module._malloc(Q),C=new Z(this.module.HEAPU8.buffer,B,$);return C.set(W),new w({typedArray:C,ptr:B},void 0,(H)=>this.module._free(H.ptr))}newMutablePointerArray(Z){return this.newTypedArray(Int32Array,Z)}newHeapCharPointer(Z){let $=this.module.lengthBytesUTF8(Z),W=$+1,Q=this.module._malloc(W);return this.module.stringToUTF8(Z,Q,W),new w({ptr:Q,strlen:$},void 0,(B)=>this.module._free(B.ptr))}newHeapBufferPointer(Z){let $=Z.byteLength,W=this.module._malloc($);return this.module.HEAPU8.set(Z,W),new w({pointer:W,numBytes:$},void 0,(Q)=>this.module._free(Q.pointer))}consumeHeapCharPointer(Z){let $=this.module.UTF8ToString(Z);return this.module._free(Z),$}},RZ,MZ,l9,l8=-2147483648,i8=2147483647,o=0,i9=class{constructor(){this.nextId=l8,this.freelist=[],this.groups=new Map}put(Z){let $=this.allocateId(),W=K8($),Q=this.groups.get(W);return Q||(Q=new Map,this.groups.set(W,Q)),Q.set($,Z),$}get(Z){if(Z===o)throw new f("no host reference id defined");let $=K8(Z),W=this.groups.get($);if(!W)throw new f(`host reference id ${Z} is not defined`);let Q=W.get(Z);if(!Q)throw new f(`host reference id ${Z} is not defined`);return Q}delete(Z){if(Z===o)throw new f("no host reference id defined");let $=K8(Z),W=this.groups.get($);if(!W)throw new f(`host reference id ${Z} is not defined`);W.delete(Z),W.size===0&&this.groups.delete($),this.freelist.push(Z)}allocateId(){if(this.freelist.length>0)return this.freelist.shift();if(this.nextId===o&&this.nextId++,this.nextId>i8)throw new $9(`HostRefMap: too many host refs created without disposing. Max simultaneous host refs: ${i8-l8}`);return this.nextId++}},o8,o9,n9,a9,s9=class{constructor(Z){this.freeHostRef=Z.freeHostRef,this.callFunction=Z.callFunction,this.shouldInterrupt=Z.shouldInterrupt,this.loadModuleSource=Z.loadModuleSource,this.normalizeModule=Z.normalizeModule}},U8=class{constructor(Z){this.contextCallbacks=new Map,this.runtimeCallbacks=new Map,this.suspendedCount=0,this.cToHostCallbacks=new s9({freeHostRef:($,W,Q)=>{let B=this.runtimeCallbacks.get(W);if(!B)throw Error(`QuickJSRuntime(rt = ${W}) not found when trying to free HostRef(id = ${Q})`);B.freeHostRef(W,Q)},callFunction:($,W,Q,B,C,H)=>this.handleAsyncify($,()=>{try{let K=this.contextCallbacks.get(W);if(!K)throw Error(`QuickJSContext(ctx = ${W}) not found for C function call "${H}"`);return K.callFunction(W,Q,B,C,H)}catch(K){return console.error("[C to host error: returning null]",K),0}}),shouldInterrupt:($,W)=>this.handleAsyncify($,()=>{try{let Q=this.runtimeCallbacks.get(W);if(!Q)throw Error(`QuickJSRuntime(rt = ${W}) not found for C interrupt`);return Q.shouldInterrupt(W)}catch(Q){return console.error("[C to host interrupt: returning error]",Q),1}}),loadModuleSource:($,W,Q,B)=>this.handleAsyncify($,()=>{try{let C=this.runtimeCallbacks.get(W);if(!C)throw Error(`QuickJSRuntime(rt = ${W}) not found for C module loader`);let H=C.loadModuleSource;if(!H)throw Error(`QuickJSRuntime(rt = ${W}) does not support module loading`);return H(W,Q,B)}catch(C){return console.error("[C to host module loader error: returning null]",C),0}}),normalizeModule:($,W,Q,B,C)=>this.handleAsyncify($,()=>{try{let H=this.runtimeCallbacks.get(W);if(!H)throw Error(`QuickJSRuntime(rt = ${W}) not found for C module loader`);let K=H.normalizeModule;if(!K)throw Error(`QuickJSRuntime(rt = ${W}) does not support module loading`);return K(W,Q,B,C)}catch(H){return console.error("[C to host module loader error: returning null]",H),0}})}),this.module=Z,this.module.callbacks=this.cToHostCallbacks}setRuntimeCallbacks(Z,$){this.runtimeCallbacks.set(Z,$)}deleteRuntime(Z){this.runtimeCallbacks.delete(Z)}setContextCallbacks(Z,$){this.contextCallbacks.set(Z,$)}deleteContext(Z){this.contextCallbacks.delete(Z)}handleAsyncify(Z,$){if(Z)return Z.handleSleep((Q)=>{try{let B=$();if(!(B instanceof Promise)){m("asyncify.handleSleep: not suspending:",B),Q(B);return}if(this.suspended)throw new s8(`Already suspended at: ${this.suspended.stack}
4
4
  Attempted to suspend at:`);this.suspended=new t8(`(${this.suspendedCount++})`),m("asyncify.handleSleep: suspending:",this.suspended),B.then((C)=>{this.suspended=void 0,m("asyncify.handleSleep: resolved:",C),Q(C)},(C)=>{m("asyncify.handleSleep: rejected:",C),console.error("QuickJS: cannot handle error in suspended function",C),this.suspended=void 0})}catch(B){throw m("asyncify.handleSleep: error:",B),this.suspended=void 0,B}});let W=$();if(W instanceof Promise)throw Error("Promise return value not supported in non-asyncify context.");return W}},z9=class{constructor(Z,$){this.module=Z,this.ffi=$,this.callbacks=new U8(Z)}newRuntime(Z={}){let $=new w(this.ffi.QTS_NewRuntime(),void 0,(Q)=>{this.ffi.QTS_FreeRuntime(Q),this.callbacks.deleteRuntime(Q)}),W=new a9({module:this.module,callbacks:this.callbacks,ffi:this.ffi,rt:$});return H8(W,Z),Z.moduleLoader&&W.setModuleLoader(Z.moduleLoader),W}newContext(Z={}){let $=this.newRuntime(),W=$.newContext({...Z,ownedLifetimes:u9($,Z.ownedLifetimes)});return $.context=W,W}evalCode(Z,$={}){return I.withScope((W)=>{let Q=W.manage(this.newContext());j8(Q.runtime,$);let B=Q.evalCode(Z,"eval.js");if($.memoryLimitBytes!==void 0&&Q.runtime.setMemoryLimit(-1),B.error)throw Q.dump(W.manage(B.error));return Q.dump(W.manage(B.value))})}getWasmMemory(){let Z=this.module.quickjsEmscriptenInit?.(()=>{})?.getWasmMemory?.();if(!Z)throw Error("Variant does not support getting WebAssembly.Memory");return Z}getFFI(){return this.ffi}};var K9=X8(()=>{i();i();x9=Object.defineProperty;A9={};b9(A9,{QuickJSAsyncifyError:()=>s8,QuickJSAsyncifySuspended:()=>t8,QuickJSEmptyGetOwnPropertyNames:()=>Z9,QuickJSEmscriptenModuleError:()=>f9,QuickJSHostRefInvalid:()=>f,QuickJSHostRefRangeExceeded:()=>$9,QuickJSMemoryLeakDetected:()=>T9,QuickJSNotImplemented:()=>a8,QuickJSPromisePending:()=>e8,QuickJSUnknownIntrinsic:()=>r8,QuickJSUnwrapError:()=>Y8,QuickJSUseAfterFree:()=>Q8,QuickJSWrongOwner:()=>n8});Y8=class extends Error{constructor(Z,$){let W=typeof Z=="object"&&Z&&"message"in Z?String(Z.message):String(Z);super(W);this.cause=Z,this.context=$,this.name="QuickJSUnwrapError"}},n8=class extends Error{constructor(){super(...arguments);this.name="QuickJSWrongOwner"}},Q8=class extends Error{constructor(){super(...arguments);this.name="QuickJSUseAfterFree"}},a8=class extends Error{constructor(){super(...arguments);this.name="QuickJSNotImplemented"}},s8=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifyError"}},t8=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifySuspended"}},T9=class extends Error{constructor(){super(...arguments);this.name="QuickJSMemoryLeakDetected"}},f9=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmscriptenModuleError"}},r8=class extends TypeError{constructor(){super(...arguments);this.name="QuickJSUnknownIntrinsic"}},e8=class extends Error{constructor(){super(...arguments);this.name="QuickJSPromisePending"}},Z9=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmptyGetOwnPropertyNames"}},$9=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefRangeExceeded"}},f=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefInvalid"}};J8=X9;J8.of=y9;b=class{[Symbol.dispose](){return this.dispose()}},G8=Symbol.dispose??Symbol.for("Symbol.dispose"),p8=b.prototype;p8[G8]||(p8[G8]=function(){return this.dispose()});w=class Z extends b{constructor($,W,Q,B){super();this._value=$,this.copier=W,this.disposer=Q,this._owner=B,this._alive=!0,this._constructorStack=B8?Error("Lifetime constructed").stack:void 0}get alive(){return this._alive}get value(){return this.assertAlive(),this._value}get owner(){return this._owner}get dupable(){return!!this.copier}dup(){if(this.assertAlive(),!this.copier)throw Error("Non-dupable lifetime");return new Z(this.copier(this._value),this.copier,this.disposer,this._owner)}consume($){this.assertAlive();let W=$(this);return this.dispose(),W}map($){return this.assertAlive(),$(this)}tap($){return $(this),this}dispose(){this.assertAlive(),this.disposer&&this.disposer(this._value),this._alive=!1}assertAlive(){if(!this.alive)throw this._constructorStack?new Q8(`Lifetime not alive
package/dist/stdio.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @mcpcloud/runtime v0.12.1 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
1
+ /*! @mcpcloud/runtime v0.12.2 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
2
2
  var A3=Object.create;var{getPrototypeOf:j3,defineProperty:t1,getOwnPropertyNames:S3}=Object;var b3=Object.prototype.hasOwnProperty;function T3(W){return this[W]}var k3,v3,x3=(W,X,Y)=>{var Q=W!=null&&typeof W==="object";if(Q){var K=X?k3??=new WeakMap:v3??=new WeakMap,q=K.get(W);if(q)return q}Y=W!=null?A3(j3(W)):{};let J=X||!W||!W.__esModule?t1(Y,"default",{value:W,enumerable:!0}):Y;for(let G of S3(W))if(!b3.call(J,G))t1(J,G,{get:T3.bind(W,G),enumerable:!0});if(Q)K.set(W,J);return J};var g3=(W,X)=>()=>(X||W((X={exports:{}}).exports,X),X.exports);var h3=(W)=>W;function y3(W,X){this[W]=h3.bind(null,X)}var a1=(W,X)=>{for(var Y in X)t1(W,Y,{get:X[Y],enumerable:!0,configurable:!0,set:y3.bind(X,Y)})};var s1=(W,X)=>()=>(W&&(X=W(W=0)),X);var S0,a9,m1,b0,$1;var u1=s1(()=>{S0={JS_EVAL_TYPE_GLOBAL:0,JS_EVAL_TYPE_MODULE:1,JS_EVAL_TYPE_DIRECT:2,JS_EVAL_TYPE_INDIRECT:3,JS_EVAL_TYPE_MASK:3,JS_EVAL_FLAG_STRICT:8,JS_EVAL_FLAG_STRIP:16,JS_EVAL_FLAG_COMPILE_ONLY:32,JS_EVAL_FLAG_BACKTRACE_BARRIER:64},a9={BaseObjects:1,Date:2,Eval:4,StringNormalize:8,RegExp:16,RegExpCompiler:32,JSON:64,Proxy:128,MapSet:256,TypedArrays:512,Promise:1024,BigInt:2048,BigFloat:4096,BigDecimal:8192,OperatorOverloading:16384,BignumExt:32768},m1={Pending:0,Fulfilled:1,Rejected:2},b0={JS_GPN_STRING_MASK:1,JS_GPN_SYMBOL_MASK:2,JS_GPN_PRIVATE_MASK:4,JS_GPN_ENUM_ONLY:16,JS_GPN_SET_ENUM:32,QTS_GPN_NUMBER_MASK:64,QTS_STANDARD_COMPLIANT_NUMBER:128},$1={IsStrictlyEqual:0,IsSameValue:1,IsSameValueZero:2}});function H1(...W){Q4&&console.log("quickjs-emscripten:",...W)}function*L3(W){return yield W}function M7(W){return L3(G4(W))}function eW(W,X){return(...Y)=>{let Q=X.call(W,K4,...Y);return G4(Q)}}function F7(W,X){let Y=X.call(W,K4);return G4(Y)}function G4(W){function X(Y){return Y.done?Y.value:Y.value instanceof Promise?Y.value.then((Q)=>X(W.next(Q)),(Q)=>X(W.throw(Q))):X(W.next(Y.value))}return X(W.next())}function s9(W,X){let Y;try{W.dispose()}catch(Q){Y=Q}if(X&&Y)throw Object.assign(X,{message:`${X.message}
3
3
  Then, failed to dispose scope: ${Y.message}`,disposeError:Y}),X;if(X||Y)throw X||Y}function O7(W){let X=W?Array.from(W):[];function Y(){return X.forEach((K)=>K.alive?K.dispose():void 0)}function Q(){return X.some((K)=>K.alive)}return Object.defineProperty(X,Y4,{configurable:!0,enumerable:!1,value:Y}),Object.defineProperty(X,"dispose",{configurable:!0,enumerable:!1,value:Y}),Object.defineProperty(X,"alive",{configurable:!0,enumerable:!1,get:Q}),X}function l1(W){return!!(W&&(typeof W=="object"||typeof W=="function")&&("alive"in W)&&typeof W.alive=="boolean"&&("dispose"in W)&&typeof W.dispose=="function")}function Z7(W){if(!W)return 0;let X=0;for(let[Y,Q]of Object.entries(W)){if(!(Y in a9))throw new B3(Y);Q&&(X|=a9[Y])}return X}function R7(W){if(typeof W=="number")return W;if(W===void 0)return 0;let{type:X,strict:Y,strip:Q,compileOnly:K,backtraceBarrier:q}=W,J=0;return X==="global"&&(J|=S0.JS_EVAL_TYPE_GLOBAL),X==="module"&&(J|=S0.JS_EVAL_TYPE_MODULE),Y&&(J|=S0.JS_EVAL_FLAG_STRICT),Q&&(J|=S0.JS_EVAL_FLAG_STRIP),K&&(J|=S0.JS_EVAL_FLAG_COMPILE_ONLY),q&&(J|=S0.JS_EVAL_FLAG_BACKTRACE_BARRIER),J}function E7(W){if(typeof W=="number")return W;if(W===void 0)return 0;let{strings:X,symbols:Y,quickjsPrivate:Q,onlyEnumerable:K,numbers:q,numbersAsStrings:J}=W,G=0;return X&&(G|=b0.JS_GPN_STRING_MASK),Y&&(G|=b0.JS_GPN_SYMBOL_MASK),Q&&(G|=b0.JS_GPN_PRIVATE_MASK),K&&(G|=b0.JS_GPN_ENUM_ONLY),q&&(G|=b0.QTS_GPN_NUMBER_MASK),J&&(G|=b0.QTS_STANDARD_COMPLIANT_NUMBER),G}function I7(...W){let X=[];for(let Y of W)Y!==void 0&&(X=X.concat(Y));return X}function e9(W){return W>>8}function z4(W,X){X.interruptHandler&&W.setInterruptHandler(X.interruptHandler),X.maxStackSizeBytes!==void 0&&W.setMaxStackSize(X.maxStackSizeBytes),X.memoryLimitBytes!==void 0&&W.setMemoryLimit(X.memoryLimitBytes)}function B4(W,X){X.moduleLoader&&W.setModuleLoader(X.moduleLoader),X.shouldInterrupt&&W.setInterruptHandler(X.shouldInterrupt),X.memoryLimitBytes!==void 0&&W.setMemoryLimit(X.memoryLimitBytes),X.maxStackSizeBytes!==void 0&&W.setMaxStackSize(X.maxStackSizeBytes)}var H7,U7=(W,X)=>{for(var Y in X)H7(W,Y,{get:X[Y],enumerable:!0})},Q4=!1,L7,W4,G3,X4,q3,J3,z3,D7,w7,B3,$3,H3,U3,C0,K4,V0,Y4,W3,X0,T0,X3,D0,q4,V7,N7,m0,P7,D3=class{constructor(W){this.module=W}toPointerArray(W){let X=new Int32Array(W.map((K)=>K.value)),Y=X.length*X.BYTES_PER_ELEMENT,Q=this.module._malloc(Y);return new Uint8Array(this.module.HEAPU8.buffer,Q,Y).set(new Uint8Array(X.buffer)),new X0(Q,void 0,(K)=>this.module._free(K))}newTypedArray(W,X){let Y=new W(Array(X).fill(0)),Q=Y.length*Y.BYTES_PER_ELEMENT,K=this.module._malloc(Q),q=new W(this.module.HEAPU8.buffer,K,X);return q.set(Y),new X0({typedArray:q,ptr:K},void 0,(J)=>this.module._free(J.ptr))}newMutablePointerArray(W){return this.newTypedArray(Int32Array,W)}newHeapCharPointer(W){let X=this.module.lengthBytesUTF8(W),Y=X+1,Q=this.module._malloc(Y);return this.module.stringToUTF8(W,Q,Y),new X0({ptr:Q,strlen:X},void 0,(K)=>this.module._free(K.ptr))}newHeapBufferPointer(W){let X=W.byteLength,Y=this.module._malloc(X);return this.module.HEAPU8.set(W,Y),new X0({pointer:Y,numBytes:X},void 0,(Q)=>this.module._free(Q.pointer))}consumeHeapCharPointer(W){let X=this.module.UTF8ToString(W);return this.module._free(W),X}},ZG,RG,C7,Y3=-2147483648,Q3=2147483647,p1=0,_7=class{constructor(){this.nextId=Y3,this.freelist=[],this.groups=new Map}put(W){let X=this.allocateId(),Y=e9(X),Q=this.groups.get(Y);return Q||(Q=new Map,this.groups.set(Y,Q)),Q.set(X,W),X}get(W){if(W===p1)throw new C0("no host reference id defined");let X=e9(W),Y=this.groups.get(X);if(!Y)throw new C0(`host reference id ${W} is not defined`);let Q=Y.get(W);if(!Q)throw new C0(`host reference id ${W} is not defined`);return Q}delete(W){if(W===p1)throw new C0("no host reference id defined");let X=e9(W),Y=this.groups.get(X);if(!Y)throw new C0(`host reference id ${W} is not defined`);Y.delete(W),Y.size===0&&this.groups.delete(X),this.freelist.push(W)}allocateId(){if(this.freelist.length>0)return this.freelist.shift();if(this.nextId===p1&&this.nextId++,this.nextId>Q3)throw new U3(`HostRefMap: too many host refs created without disposing. Max simultaneous host refs: ${Q3-Y3}`);return this.nextId++}},K3,A7,j7,S7,b7=class{constructor(W){this.freeHostRef=W.freeHostRef,this.callFunction=W.callFunction,this.shouldInterrupt=W.shouldInterrupt,this.loadModuleSource=W.loadModuleSource,this.normalizeModule=W.normalizeModule}},J4=class{constructor(W){this.contextCallbacks=new Map,this.runtimeCallbacks=new Map,this.suspendedCount=0,this.cToHostCallbacks=new b7({freeHostRef:(X,Y,Q)=>{let K=this.runtimeCallbacks.get(Y);if(!K)throw Error(`QuickJSRuntime(rt = ${Y}) not found when trying to free HostRef(id = ${Q})`);K.freeHostRef(Y,Q)},callFunction:(X,Y,Q,K,q,J)=>this.handleAsyncify(X,()=>{try{let G=this.contextCallbacks.get(Y);if(!G)throw Error(`QuickJSContext(ctx = ${Y}) not found for C function call "${J}"`);return G.callFunction(Y,Q,K,q,J)}catch(G){return console.error("[C to host error: returning null]",G),0}}),shouldInterrupt:(X,Y)=>this.handleAsyncify(X,()=>{try{let Q=this.runtimeCallbacks.get(Y);if(!Q)throw Error(`QuickJSRuntime(rt = ${Y}) not found for C interrupt`);return Q.shouldInterrupt(Y)}catch(Q){return console.error("[C to host interrupt: returning error]",Q),1}}),loadModuleSource:(X,Y,Q,K)=>this.handleAsyncify(X,()=>{try{let q=this.runtimeCallbacks.get(Y);if(!q)throw Error(`QuickJSRuntime(rt = ${Y}) not found for C module loader`);let J=q.loadModuleSource;if(!J)throw Error(`QuickJSRuntime(rt = ${Y}) does not support module loading`);return J(Y,Q,K)}catch(q){return console.error("[C to host module loader error: returning null]",q),0}}),normalizeModule:(X,Y,Q,K,q)=>this.handleAsyncify(X,()=>{try{let J=this.runtimeCallbacks.get(Y);if(!J)throw Error(`QuickJSRuntime(rt = ${Y}) not found for C module loader`);let G=J.normalizeModule;if(!G)throw Error(`QuickJSRuntime(rt = ${Y}) does not support module loading`);return G(Y,Q,K,q)}catch(J){return console.error("[C to host module loader error: returning null]",J),0}})}),this.module=W,this.module.callbacks=this.cToHostCallbacks}setRuntimeCallbacks(W,X){this.runtimeCallbacks.set(W,X)}deleteRuntime(W){this.runtimeCallbacks.delete(W)}setContextCallbacks(W,X){this.contextCallbacks.set(W,X)}deleteContext(W){this.contextCallbacks.delete(W)}handleAsyncify(W,X){if(W)return W.handleSleep((Q)=>{try{let K=X();if(!(K instanceof Promise)){H1("asyncify.handleSleep: not suspending:",K),Q(K);return}if(this.suspended)throw new J3(`Already suspended at: ${this.suspended.stack}
4
4
  Attempted to suspend at:`);this.suspended=new z3(`(${this.suspendedCount++})`),H1("asyncify.handleSleep: suspending:",this.suspended),K.then((q)=>{this.suspended=void 0,H1("asyncify.handleSleep: resolved:",q),Q(q)},(q)=>{H1("asyncify.handleSleep: rejected:",q),console.error("QuickJS: cannot handle error in suspended function",q),this.suspended=void 0})}catch(K){throw H1("asyncify.handleSleep: error:",K),this.suspended=void 0,K}});let Y=X();if(Y instanceof Promise)throw Error("Promise return value not supported in non-asyncify context.");return Y}},w3=class{constructor(W,X){this.module=W,this.ffi=X,this.callbacks=new J4(W)}newRuntime(W={}){let X=new X0(this.ffi.QTS_NewRuntime(),void 0,(Q)=>{this.ffi.QTS_FreeRuntime(Q),this.callbacks.deleteRuntime(Q)}),Y=new S7({module:this.module,callbacks:this.callbacks,ffi:this.ffi,rt:X});return z4(Y,W),W.moduleLoader&&Y.setModuleLoader(W.moduleLoader),Y}newContext(W={}){let X=this.newRuntime(),Y=X.newContext({...W,ownedLifetimes:I7(X,W.ownedLifetimes)});return X.context=Y,Y}evalCode(W,X={}){return D0.withScope((Y)=>{let Q=Y.manage(this.newContext());B4(Q.runtime,X);let K=Q.evalCode(W,"eval.js");if(X.memoryLimitBytes!==void 0&&Q.runtime.setMemoryLimit(-1),K.error)throw Q.dump(Y.manage(K.error));return Q.dump(Y.manage(K.value))})}getWasmMemory(){let W=this.module.quickjsEmscriptenInit?.(()=>{})?.getWasmMemory?.();if(!W)throw Error("Variant does not support getting WebAssembly.Memory");return W}getFFI(){return this.ffi}};var M3=s1(()=>{u1();u1();H7=Object.defineProperty;L7={};U7(L7,{QuickJSAsyncifyError:()=>J3,QuickJSAsyncifySuspended:()=>z3,QuickJSEmptyGetOwnPropertyNames:()=>H3,QuickJSEmscriptenModuleError:()=>w7,QuickJSHostRefInvalid:()=>C0,QuickJSHostRefRangeExceeded:()=>U3,QuickJSMemoryLeakDetected:()=>D7,QuickJSNotImplemented:()=>q3,QuickJSPromisePending:()=>$3,QuickJSUnknownIntrinsic:()=>B3,QuickJSUnwrapError:()=>W4,QuickJSUseAfterFree:()=>X4,QuickJSWrongOwner:()=>G3});W4=class extends Error{constructor(W,X){let Y=typeof W=="object"&&W&&"message"in W?String(W.message):String(W);super(Y);this.cause=W,this.context=X,this.name="QuickJSUnwrapError"}},G3=class extends Error{constructor(){super(...arguments);this.name="QuickJSWrongOwner"}},X4=class extends Error{constructor(){super(...arguments);this.name="QuickJSUseAfterFree"}},q3=class extends Error{constructor(){super(...arguments);this.name="QuickJSNotImplemented"}},J3=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifyError"}},z3=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifySuspended"}},D7=class extends Error{constructor(){super(...arguments);this.name="QuickJSMemoryLeakDetected"}},w7=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmscriptenModuleError"}},B3=class extends TypeError{constructor(){super(...arguments);this.name="QuickJSUnknownIntrinsic"}},$3=class extends Error{constructor(){super(...arguments);this.name="QuickJSPromisePending"}},H3=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmptyGetOwnPropertyNames"}},U3=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefRangeExceeded"}},C0=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefInvalid"}};K4=L3;K4.of=M7;V0=class{[Symbol.dispose](){return this.dispose()}},Y4=Symbol.dispose??Symbol.for("Symbol.dispose"),W3=V0.prototype;W3[Y4]||(W3[Y4]=function(){return this.dispose()});X0=class W extends V0{constructor(X,Y,Q,K){super();this._value=X,this.copier=Y,this.disposer=Q,this._owner=K,this._alive=!0,this._constructorStack=Q4?Error("Lifetime constructed").stack:void 0}get alive(){return this._alive}get value(){return this.assertAlive(),this._value}get owner(){return this._owner}get dupable(){return!!this.copier}dup(){if(this.assertAlive(),!this.copier)throw Error("Non-dupable lifetime");return new W(this.copier(this._value),this.copier,this.disposer,this._owner)}consume(X){this.assertAlive();let Y=X(this);return this.dispose(),Y}map(X){return this.assertAlive(),X(this)}tap(X){return X(this),this}dispose(){this.assertAlive(),this.disposer&&this.disposer(this._value),this._alive=!1}assertAlive(){if(!this.alive)throw this._constructorStack?new X4(`Lifetime not alive
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpcloud/runtime",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
4
4
  "description": "MCPCloud generated-server runtime: transports, config, upstream auth/HTTP, validation, projection, and discovery for MCP servers built on MCPCloud.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",