@mcpcloud/runtime 0.1.1 → 0.1.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.
- package/dist/adapters/container-host.d.ts +60 -0
- package/dist/compat-stdio.js +1 -1
- package/dist/compat-worker.js +1 -1
- package/dist/container-host.d.ts +7 -0
- package/dist/container-host.js +2 -0
- package/dist/index.js +1 -1
- package/dist/node.js +1 -1
- package/dist/stdio.js +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { serve } from './node';
|
|
2
|
+
import type { NodeServeOptions } from './node';
|
|
3
|
+
/**
|
|
4
|
+
* Generic runtime-host entry for the dedicated-container deploy target
|
|
5
|
+
* (architecture-evolution Phase 5). ONE image per `runtimeVersion` runs this;
|
|
6
|
+
* the per-server code is fetched as DATA at boot — there are no per-server image
|
|
7
|
+
* builds. The host reads a signed, content-addressed bundle pointer from the
|
|
8
|
+
* environment, fetches it, verifies its sha256, materializes the module set to
|
|
9
|
+
* disk, dynamic-imports the server module, and serves it on :8080.
|
|
10
|
+
*
|
|
11
|
+
* The boot-artifact format mirrors repo-root `shared/containerBootArtifact.ts`;
|
|
12
|
+
* this file re-implements the tiny parse because `@mcpcloud/runtime` is published
|
|
13
|
+
* to npm and cannot reach across that boundary. `BOOT_ARTIFACT_SCHEMA_VERSION`
|
|
14
|
+
* must match the producer's `CONTAINER_BOOT_ARTIFACT_SCHEMA_VERSION`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const BOOT_ARTIFACT_SCHEMA_VERSION = 1;
|
|
17
|
+
export interface ContainerHostBootConfig {
|
|
18
|
+
bundleUrl: string;
|
|
19
|
+
bundleSha256: string;
|
|
20
|
+
port: number;
|
|
21
|
+
}
|
|
22
|
+
interface BootArtifactFile {
|
|
23
|
+
path: string;
|
|
24
|
+
content: string;
|
|
25
|
+
}
|
|
26
|
+
interface BootArtifact {
|
|
27
|
+
schemaVersion: number;
|
|
28
|
+
runtimeVersion: string;
|
|
29
|
+
mainEntry: string;
|
|
30
|
+
files: BootArtifactFile[];
|
|
31
|
+
}
|
|
32
|
+
export interface ServeFromBundleOptions extends NodeServeOptions {
|
|
33
|
+
/** Override the bundle pointer instead of reading it from `process.env`. */
|
|
34
|
+
bootConfig?: ContainerHostBootConfig;
|
|
35
|
+
/** Directory the bundle is materialized into. Defaults to a fresh temp dir. */
|
|
36
|
+
workDir?: string;
|
|
37
|
+
/** Injected for tests; defaults to the global `fetch`. */
|
|
38
|
+
fetchImpl?: typeof fetch;
|
|
39
|
+
}
|
|
40
|
+
/** Read + validate the bundle pointer from the container environment. */
|
|
41
|
+
export declare function resolveBootConfig(env?: Record<string, string | undefined>): ContainerHostBootConfig;
|
|
42
|
+
/** Fetch the bundle, verify its sha256, and return the validated artifact. */
|
|
43
|
+
export declare function fetchAndVerifyBundle(config: Pick<ContainerHostBootConfig, 'bundleUrl' | 'bundleSha256'>, fetchImpl?: typeof fetch): Promise<BootArtifact>;
|
|
44
|
+
/** Write the artifact's files to `workDir`, returning the absolute entry path. */
|
|
45
|
+
export declare function materializeBundle(artifact: BootArtifact, workDir: string): {
|
|
46
|
+
entryPath: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Boot a dedicated-container deployment: resolve the bundle pointer, fetch +
|
|
50
|
+
* verify it, materialize it to disk, dynamic-import the server module, and serve
|
|
51
|
+
* it on the configured port. Returns the `node:http` server.
|
|
52
|
+
*
|
|
53
|
+
* The materialize + dynamic-import + serve glue runs only inside the container
|
|
54
|
+
* (Bun executes the TypeScript module set directly), so it is exercised by the
|
|
55
|
+
* live container e2e gate, not the offline unit suite. The pure pieces it
|
|
56
|
+
* composes — {@link resolveBootConfig}, {@link fetchAndVerifyBundle},
|
|
57
|
+
* {@link materializeBundle} — are unit-tested.
|
|
58
|
+
*/
|
|
59
|
+
export declare function serveFromBundle(options?: ServeFromBundleOptions): Promise<ReturnType<typeof serve>>;
|
|
60
|
+
export {};
|
package/dist/compat-stdio.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @mcpcloud/runtime v0.1.
|
|
1
|
+
/*! @mcpcloud/runtime v0.1.2 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
|
|
2
2
|
var T4=Object.defineProperty;var QY=(W,Q)=>{for(var Y in Q)T4(W,Y,{get:Q[Y],enumerable:!0,configurable:!0,set:(X)=>Q[Y]=()=>X})};import P4 from"node:process";var Y2=Object.freeze({status:"aborted"});function K(W,Q,Y){function X(w,q){if(!w._zod)Object.defineProperty(w,"_zod",{value:{def:q,constr:H,traits:new Set},enumerable:!1});if(w._zod.traits.has(W))return;w._zod.traits.add(W),Q(w,q);let L=H.prototype,B=Object.keys(L);for(let z=0;z<B.length;z++){let I=B[z];if(!(I in w))w[I]=L[I].bind(w)}}let G=Y?.Parent??Object;class J extends G{}Object.defineProperty(J,"name",{value:W});function H(w){var q;let L=Y?.Parent?new J:this;X(L,w),(q=L._zod).deferred??(q.deferred=[]);for(let B of L._zod.deferred)B();return L}return Object.defineProperty(H,"init",{value:X}),Object.defineProperty(H,Symbol.hasInstance,{value:(w)=>{if(Y?.Parent&&w instanceof Y.Parent)return!0;return w?._zod?.traits?.has(W)}}),Object.defineProperty(H,"name",{value:W}),H}var X2=Symbol("zod_brand");class a extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class MW extends Error{constructor(W){super(`Encountered unidirectional transform during encode: ${W}`);this.name="ZodEncodeError"}}var vW={};function r(W){if(W)Object.assign(vW,W);return vW}var D={};QY(D,{unwrapMessage:()=>zW,uint8ArrayToHex:()=>s4,uint8ArrayToBase64url:()=>e4,uint8ArrayToBase64:()=>AY,stringifyPrimitive:()=>cW,slugify:()=>HQ,shallowClone:()=>XY,safeExtend:()=>r4,required:()=>n4,randomString:()=>c4,propertyKeyTypes:()=>AQ,promiseAllObject:()=>x4,primitiveTypes:()=>GY,prefixIssues:()=>QW,pick:()=>f4,partial:()=>d4,parsedType:()=>LQ,optionalKeys:()=>qQ,omit:()=>o4,objectClone:()=>v4,numKeys:()=>u4,nullish:()=>IW,normalizeParams:()=>U,mergeDefs:()=>s,merge:()=>p4,jsonStringifyReplacer:()=>AW,joinValues:()=>gW,issue:()=>KW,isPlainObject:()=>XW,isObject:()=>HW,hexToUint8Array:()=>a4,getSizableOrigin:()=>HY,getParsedType:()=>y4,getLengthableOrigin:()=>OW,getEnumValues:()=>UW,getElementAtPath:()=>h4,floatSafeRemainder:()=>JQ,finalizeIssue:()=>t,extend:()=>l4,escapeRegex:()=>WW,esc:()=>hW,defineLazy:()=>F,createTransparentProxy:()=>m4,cloneDef:()=>g4,clone:()=>i,cleanRegex:()=>VW,cleanEnum:()=>i4,captureStackTrace:()=>xW,cached:()=>qW,base64urlToUint8Array:()=>t4,base64ToUint8Array:()=>wY,assignProp:()=>YW,assertNotEqual:()=>Z4,assertNever:()=>j4,assertIs:()=>C4,assertEqual:()=>_4,assert:()=>k4,allowsEval:()=>wQ,aborted:()=>GW,NUMBER_FORMAT_RANGES:()=>KQ,Class:()=>qY,BIGINT_FORMAT_RANGES:()=>JY});function _4(W){return W}function Z4(W){return W}function C4(W){}function j4(W){throw Error("Unexpected value in exhaustive check")}function k4(W){}function UW(W){let Q=Object.values(W).filter((X)=>typeof X==="number");return Object.entries(W).filter(([X,G])=>Q.indexOf(+X)===-1).map(([X,G])=>G)}function gW(W,Q="|"){return W.map((Y)=>cW(Y)).join(Q)}function AW(W,Q){if(typeof Q==="bigint")return Q.toString();return Q}function qW(W){return{get value(){{let Y=W();return Object.defineProperty(this,"value",{value:Y}),Y}throw Error("cached value already set")}}}function IW(W){return W===null||W===void 0}function VW(W){let Q=W.startsWith("^")?1:0,Y=W.endsWith("$")?W.length-1:W.length;return W.slice(Q,Y)}function JQ(W,Q){let Y=(W.toString().split(".")[1]||"").length,X=Q.toString(),G=(X.split(".")[1]||"").length;if(G===0&&/\d?e-\d?/.test(X)){let q=X.match(/\d?e-(\d?)/);if(q?.[1])G=Number.parseInt(q[1])}let J=Y>G?Y:G,H=Number.parseInt(W.toFixed(J).replace(".","")),w=Number.parseInt(Q.toFixed(J).replace(".",""));return H%w/10**J}var YY=Symbol("evaluating");function F(W,Q,Y){let X=void 0;Object.defineProperty(W,Q,{get(){if(X===YY)return;if(X===void 0)X=YY,X=Y();return X},set(G){Object.defineProperty(W,Q,{value:G})},configurable:!0})}function v4(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 g4(W){return s(W._zod.def)}function h4(W,Q){if(!Q)return W;return Q.reduce((Y,X)=>Y?.[X],W)}function x4(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 c4(W=10){let Y="";for(let X=0;X<W;X++)Y+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return Y}function hW(W){return JSON.stringify(W)}function HQ(W){return W.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var xW="captureStackTrace"in Error?Error.captureStackTrace:(...W)=>{};function HW(W){return typeof W==="object"&&W!==null&&!Array.isArray(W)}var wQ=qW(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(W){return!1}});function XW(W){if(HW(W)===!1)return!1;let Q=W.constructor;if(Q===void 0)return!0;if(typeof Q!=="function")return!0;let Y=Q.prototype;if(HW(Y)===!1)return!1;if(Object.prototype.hasOwnProperty.call(Y,"isPrototypeOf")===!1)return!1;return!0}function XY(W){if(XW(W))return{...W};if(Array.isArray(W))return[...W];return W}function u4(W){let Q=0;for(let Y in W)if(Object.prototype.hasOwnProperty.call(W,Y))Q++;return Q}var y4=(W)=>{let Q=typeof W;switch(Q){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(W)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(W))return"array";if(W===null)return"null";if(W.then&&typeof W.then==="function"&&W.catch&&typeof W.catch==="function")return"promise";if(typeof Map<"u"&&W instanceof Map)return"map";if(typeof Set<"u"&&W instanceof Set)return"set";if(typeof Date<"u"&&W instanceof Date)return"date";if(typeof File<"u"&&W instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${Q}`)}},AQ=new Set(["string","number","symbol"]),GY=new Set(["string","number","bigint","boolean","symbol","undefined"]);function WW(W){return W.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function i(W,Q,Y){let X=new W._zod.constr(Q??W._zod.def);if(!Q||Y?.parent)X._zod.parent=W;return X}function U(W){let Q=W;if(!Q)return{};if(typeof Q==="string")return{error:()=>Q};if(Q?.message!==void 0){if(Q?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");Q.error=Q.message}if(delete Q.message,typeof Q.error==="string")return{...Q,error:()=>Q.error};return Q}function m4(W){let Q;return new Proxy({},{get(Y,X,G){return Q??(Q=W()),Reflect.get(Q,X,G)},set(Y,X,G,J){return Q??(Q=W()),Reflect.set(Q,X,G,J)},has(Y,X){return Q??(Q=W()),Reflect.has(Q,X)},deleteProperty(Y,X){return Q??(Q=W()),Reflect.deleteProperty(Q,X)},ownKeys(Y){return Q??(Q=W()),Reflect.ownKeys(Q)},getOwnPropertyDescriptor(Y,X){return Q??(Q=W()),Reflect.getOwnPropertyDescriptor(Q,X)},defineProperty(Y,X,G){return Q??(Q=W()),Reflect.defineProperty(Q,X,G)}})}function cW(W){if(typeof W==="bigint")return W.toString()+"n";if(typeof W==="string")return`"${W}"`;return`${W}`}function qQ(W){return Object.keys(W).filter((Q)=>{return W[Q]._zod.optin==="optional"&&W[Q]._zod.optout==="optional"})}var KQ={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},JY={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function f4(W,Q){let Y=W._zod.def,X=Y.checks;if(X&&X.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let J=s(W._zod.def,{get shape(){let H={};for(let w in Q){if(!(w in Y.shape))throw Error(`Unrecognized key: "${w}"`);if(!Q[w])continue;H[w]=Y.shape[w]}return YW(this,"shape",H),H},checks:[]});return i(W,J)}function o4(W,Q){let Y=W._zod.def,X=Y.checks;if(X&&X.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let J=s(W._zod.def,{get shape(){let H={...W._zod.def.shape};for(let w in Q){if(!(w in Y.shape))throw Error(`Unrecognized key: "${w}"`);if(!Q[w])continue;delete H[w]}return YW(this,"shape",H),H},checks:[]});return i(W,J)}function l4(W,Q){if(!XW(Q))throw Error("Invalid input to extend: expected a plain object");let Y=W._zod.def.checks;if(Y&&Y.length>0){let J=W._zod.def.shape;for(let H in Q)if(Object.getOwnPropertyDescriptor(J,H)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let G=s(W._zod.def,{get shape(){let J={...W._zod.def.shape,...Q};return YW(this,"shape",J),J}});return i(W,G)}function r4(W,Q){if(!XW(Q))throw Error("Invalid input to safeExtend: expected a plain object");let Y=s(W._zod.def,{get shape(){let X={...W._zod.def.shape,...Q};return YW(this,"shape",X),X}});return i(W,Y)}function p4(W,Q){let Y=s(W._zod.def,{get shape(){let X={...W._zod.def.shape,...Q._zod.def.shape};return YW(this,"shape",X),X},get catchall(){return Q._zod.def.catchall},checks:[]});return i(W,Y)}function d4(W,Q,Y){let G=Q._zod.def.checks;if(G&&G.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let H=s(Q._zod.def,{get shape(){let w=Q._zod.def.shape,q={...w};if(Y)for(let L in Y){if(!(L in w))throw Error(`Unrecognized key: "${L}"`);if(!Y[L])continue;q[L]=W?new W({type:"optional",innerType:w[L]}):w[L]}else for(let L in w)q[L]=W?new W({type:"optional",innerType:w[L]}):w[L];return YW(this,"shape",q),q},checks:[]});return i(Q,H)}function n4(W,Q,Y){let X=s(Q._zod.def,{get shape(){let G=Q._zod.def.shape,J={...G};if(Y)for(let H in Y){if(!(H in J))throw Error(`Unrecognized key: "${H}"`);if(!Y[H])continue;J[H]=new W({type:"nonoptional",innerType:G[H]})}else for(let H in G)J[H]=new W({type:"nonoptional",innerType:G[H]});return YW(this,"shape",J),J}});return i(Q,X)}function GW(W,Q=0){if(W.aborted===!0)return!0;for(let Y=Q;Y<W.issues.length;Y++)if(W.issues[Y]?.continue!==!0)return!0;return!1}function QW(W,Q){return Q.map((Y)=>{var X;return(X=Y).path??(X.path=[]),Y.path.unshift(W),Y})}function zW(W){return typeof W==="string"?W:W?.message}function t(W,Q,Y){let X={...W,path:W.path??[]};if(!W.message){let G=zW(W.inst?._zod.def?.error?.(W))??zW(Q?.error?.(W))??zW(Y.customError?.(W))??zW(Y.localeError?.(W))??"Invalid input";X.message=G}if(delete X.inst,delete X.continue,!Q?.reportInput)delete X.input;return X}function HY(W){if(W instanceof Set)return"set";if(W instanceof Map)return"map";if(W instanceof File)return"file";return"unknown"}function OW(W){if(Array.isArray(W))return"array";if(typeof W==="string")return"string";return"unknown"}function LQ(W){let Q=typeof W;switch(Q){case"number":return Number.isNaN(W)?"nan":"number";case"object":{if(W===null)return"null";if(Array.isArray(W))return"array";let Y=W;if(Y&&Object.getPrototypeOf(Y)!==Object.prototype&&"constructor"in Y&&Y.constructor)return Y.constructor.name}}return Q}function KW(...W){let[Q,Y,X]=W;if(typeof Q==="string")return{message:Q,code:"custom",input:Y,inst:X};return{...Q}}function i4(W){return Object.entries(W).filter(([Q,Y])=>{return Number.isNaN(Number.parseInt(Q,10))}).map((Q)=>Q[1])}function wY(W){let Q=atob(W),Y=new Uint8Array(Q.length);for(let X=0;X<Q.length;X++)Y[X]=Q.charCodeAt(X);return Y}function AY(W){let Q="";for(let Y=0;Y<W.length;Y++)Q+=String.fromCharCode(W[Y]);return btoa(Q)}function t4(W){let Q=W.replace(/-/g,"+").replace(/_/g,"/"),Y="=".repeat((4-Q.length%4)%4);return wY(Q+Y)}function e4(W){return AY(W).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function a4(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 s4(W){return Array.from(W).map((Q)=>Q.toString(16).padStart(2,"0")).join("")}class qY{constructor(...W){}}var KY=(W,Q)=>{W.name="$ZodError",Object.defineProperty(W,"_zod",{value:W._zod,enumerable:!1}),Object.defineProperty(W,"issues",{value:Q,enumerable:!1}),W.message=JSON.stringify(Q,AW,2),Object.defineProperty(W,"toString",{value:()=>W.message,enumerable:!1})},uW=K("$ZodError",KY),BQ=K("$ZodError",KY,{Parent:Error});function LY(W,Q=(Y)=>Y.message){let Y={},X=[];for(let G of W.issues)if(G.path.length>0)Y[G.path[0]]=Y[G.path[0]]||[],Y[G.path[0]].push(Q(G));else X.push(Q(G));return{formErrors:X,fieldErrors:Y}}function BY(W,Q=(Y)=>Y.message){let Y={_errors:[]},X=(G)=>{for(let J of G.issues)if(J.code==="invalid_union"&&J.errors.length)J.errors.map((H)=>X({issues:H}));else if(J.code==="invalid_key")X({issues:J.issues});else if(J.code==="invalid_element")X({issues:J.issues});else if(J.path.length===0)Y._errors.push(Q(J));else{let H=Y,w=0;while(w<J.path.length){let q=J.path[w];if(w!==J.path.length-1)H[q]=H[q]||{_errors:[]};else H[q]=H[q]||{_errors:[]},H[q]._errors.push(Q(J));H=H[q],w++}}};return X(W),Y}var yW=(W)=>(Q,Y,X,G)=>{let J=X?Object.assign(X,{async:!1}):{async:!1},H=Q._zod.run({value:Y,issues:[]},J);if(H instanceof Promise)throw new a;if(H.issues.length){let w=new(G?.Err??W)(H.issues.map((q)=>t(q,J,r())));throw xW(w,G?.callee),w}return H.value};var mW=(W)=>async(Q,Y,X,G)=>{let J=X?Object.assign(X,{async:!0}):{async:!0},H=Q._zod.run({value:Y,issues:[]},J);if(H instanceof Promise)H=await H;if(H.issues.length){let w=new(G?.Err??W)(H.issues.map((q)=>t(q,J,r())));throw xW(w,G?.callee),w}return H.value};var DW=(W)=>(Q,Y,X)=>{let G=X?{...X,async:!1}:{async:!1},J=Q._zod.run({value:Y,issues:[]},G);if(J instanceof Promise)throw new a;return J.issues.length?{success:!1,error:new(W??uW)(J.issues.map((H)=>t(H,G,r())))}:{success:!0,data:J.value}},NY=DW(BQ),FW=(W)=>async(Q,Y,X)=>{let G=X?Object.assign(X,{async:!0}):{async:!0},J=Q._zod.run({value:Y,issues:[]},G);if(J instanceof Promise)J=await J;return J.issues.length?{success:!1,error:new W(J.issues.map((H)=>t(H,G,r())))}:{success:!0,data:J.value}},MY=FW(BQ),zY=(W)=>(Q,Y,X)=>{let G=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return yW(W)(Q,Y,G)};var UY=(W)=>(Q,Y,X)=>{return yW(W)(Q,Y,X)};var IY=(W)=>async(Q,Y,X)=>{let G=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return mW(W)(Q,Y,G)};var VY=(W)=>async(Q,Y,X)=>{return mW(W)(Q,Y,X)};var OY=(W)=>(Q,Y,X)=>{let G=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return DW(W)(Q,Y,G)};var DY=(W)=>(Q,Y,X)=>{return DW(W)(Q,Y,X)};var FY=(W)=>async(Q,Y,X)=>{let G=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return FW(W)(Q,Y,G)};var $Y=(W)=>async(Q,Y,X)=>{return FW(W)(Q,Y,X)};var PY=/^[cC][^\s-]{8,}$/,EY=/^[0-9a-z]+$/,RY=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,SY=/^[0-9a-vA-V]{20}$/,bY=/^[A-Za-z0-9]{27}$/,TY=/^[a-zA-Z0-9_-]{21}$/,_Y=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var ZY=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,NQ=(W)=>{if(!W)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${W}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var CY=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Q6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function jY(){return new RegExp(Q6,"u")}var kY=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,vY=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var gY=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,hY=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,xY=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,MQ=/^[A-Za-z0-9_-]*$/;var cY=/^\+[1-9]\d{6,14}$/,uY="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",yY=new RegExp(`^${uY}$`);function mY(W){return typeof W.precision==="number"?W.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":W.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${W.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function fY(W){return new RegExp(`^${mY(W)}$`)}function oY(W){let Q=mY({precision:W.precision}),Y=["Z"];if(W.local)Y.push("");if(W.offset)Y.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let X=`${Q}(?:${Y.join("|")})`;return new RegExp(`^${uY}T(?:${X})$`)}var lY=(W)=>{let Q=W?`[\\s\\S]{${W?.minimum??0},${W?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${Q}$`)};var rY=/^-?\d+$/,fW=/^-?\d+(?:\.\d+)?$/,pY=/^(?:true|false)$/i,dY=/^null$/i;var nY=/^[^A-Z]*$/,iY=/^[^a-z]*$/;var g=K("$ZodCheck",(W,Q)=>{var Y;W._zod??(W._zod={}),W._zod.def=Q,(Y=W._zod).onattach??(Y.onattach=[])}),tY={number:"number",bigint:"bigint",object:"date"},zQ=K("$ZodCheckLessThan",(W,Q)=>{g.init(W,Q);let Y=tY[typeof Q.value];W._zod.onattach.push((X)=>{let G=X._zod.bag,J=(Q.inclusive?G.maximum:G.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(Q.value<J)if(Q.inclusive)G.maximum=Q.value;else G.exclusiveMaximum=Q.value}),W._zod.check=(X)=>{if(Q.inclusive?X.value<=Q.value:X.value<Q.value)return;X.issues.push({origin:Y,code:"too_big",maximum:typeof Q.value==="object"?Q.value.getTime():Q.value,input:X.value,inclusive:Q.inclusive,inst:W,continue:!Q.abort})}}),UQ=K("$ZodCheckGreaterThan",(W,Q)=>{g.init(W,Q);let Y=tY[typeof Q.value];W._zod.onattach.push((X)=>{let G=X._zod.bag,J=(Q.inclusive?G.minimum:G.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(Q.value>J)if(Q.inclusive)G.minimum=Q.value;else G.exclusiveMinimum=Q.value}),W._zod.check=(X)=>{if(Q.inclusive?X.value>=Q.value:X.value>Q.value)return;X.issues.push({origin:Y,code:"too_small",minimum:typeof Q.value==="object"?Q.value.getTime():Q.value,input:X.value,inclusive:Q.inclusive,inst:W,continue:!Q.abort})}}),eY=K("$ZodCheckMultipleOf",(W,Q)=>{g.init(W,Q),W._zod.onattach.push((Y)=>{var X;(X=Y._zod.bag).multipleOf??(X.multipleOf=Q.value)}),W._zod.check=(Y)=>{if(typeof Y.value!==typeof Q.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof Y.value==="bigint"?Y.value%Q.value===BigInt(0):JQ(Y.value,Q.value)===0)return;Y.issues.push({origin:typeof Y.value,code:"not_multiple_of",divisor:Q.value,input:Y.value,inst:W,continue:!Q.abort})}}),aY=K("$ZodCheckNumberFormat",(W,Q)=>{g.init(W,Q),Q.format=Q.format||"float64";let Y=Q.format?.includes("int"),X=Y?"int":"number",[G,J]=KQ[Q.format];W._zod.onattach.push((H)=>{let w=H._zod.bag;if(w.format=Q.format,w.minimum=G,w.maximum=J,Y)w.pattern=rY}),W._zod.check=(H)=>{let w=H.value;if(Y){if(!Number.isInteger(w)){H.issues.push({expected:X,format:Q.format,code:"invalid_type",continue:!1,input:w,inst:W});return}if(!Number.isSafeInteger(w)){if(w>0)H.issues.push({input:w,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:W,origin:X,inclusive:!0,continue:!Q.abort});else H.issues.push({input:w,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:W,origin:X,inclusive:!0,continue:!Q.abort});return}}if(w<G)H.issues.push({origin:"number",input:w,code:"too_small",minimum:G,inclusive:!0,inst:W,continue:!Q.abort});if(w>J)H.issues.push({origin:"number",input:w,code:"too_big",maximum:J,inclusive:!0,inst:W,continue:!Q.abort})}});var sY=K("$ZodCheckMaxLength",(W,Q)=>{var Y;g.init(W,Q),(Y=W._zod.def).when??(Y.when=(X)=>{let G=X.value;return!IW(G)&&G.length!==void 0}),W._zod.onattach.push((X)=>{let G=X._zod.bag.maximum??Number.POSITIVE_INFINITY;if(Q.maximum<G)X._zod.bag.maximum=Q.maximum}),W._zod.check=(X)=>{let G=X.value;if(G.length<=Q.maximum)return;let H=OW(G);X.issues.push({origin:H,code:"too_big",maximum:Q.maximum,inclusive:!0,input:G,inst:W,continue:!Q.abort})}}),W0=K("$ZodCheckMinLength",(W,Q)=>{var Y;g.init(W,Q),(Y=W._zod.def).when??(Y.when=(X)=>{let G=X.value;return!IW(G)&&G.length!==void 0}),W._zod.onattach.push((X)=>{let G=X._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(Q.minimum>G)X._zod.bag.minimum=Q.minimum}),W._zod.check=(X)=>{let G=X.value;if(G.length>=Q.minimum)return;let H=OW(G);X.issues.push({origin:H,code:"too_small",minimum:Q.minimum,inclusive:!0,input:G,inst:W,continue:!Q.abort})}}),Q0=K("$ZodCheckLengthEquals",(W,Q)=>{var Y;g.init(W,Q),(Y=W._zod.def).when??(Y.when=(X)=>{let G=X.value;return!IW(G)&&G.length!==void 0}),W._zod.onattach.push((X)=>{let G=X._zod.bag;G.minimum=Q.length,G.maximum=Q.length,G.length=Q.length}),W._zod.check=(X)=>{let G=X.value,J=G.length;if(J===Q.length)return;let H=OW(G),w=J>Q.length;X.issues.push({origin:H,...w?{code:"too_big",maximum:Q.length}:{code:"too_small",minimum:Q.length},inclusive:!0,exact:!0,input:X.value,inst:W,continue:!Q.abort})}}),$W=K("$ZodCheckStringFormat",(W,Q)=>{var Y,X;if(g.init(W,Q),W._zod.onattach.push((G)=>{let J=G._zod.bag;if(J.format=Q.format,Q.pattern)J.patterns??(J.patterns=new Set),J.patterns.add(Q.pattern)}),Q.pattern)(Y=W._zod).check??(Y.check=(G)=>{if(Q.pattern.lastIndex=0,Q.pattern.test(G.value))return;G.issues.push({origin:"string",code:"invalid_format",format:Q.format,input:G.value,...Q.pattern?{pattern:Q.pattern.toString()}:{},inst:W,continue:!Q.abort})});else(X=W._zod).check??(X.check=()=>{})}),Y0=K("$ZodCheckRegex",(W,Q)=>{$W.init(W,Q),W._zod.check=(Y)=>{if(Q.pattern.lastIndex=0,Q.pattern.test(Y.value))return;Y.issues.push({origin:"string",code:"invalid_format",format:"regex",input:Y.value,pattern:Q.pattern.toString(),inst:W,continue:!Q.abort})}}),X0=K("$ZodCheckLowerCase",(W,Q)=>{Q.pattern??(Q.pattern=nY),$W.init(W,Q)}),G0=K("$ZodCheckUpperCase",(W,Q)=>{Q.pattern??(Q.pattern=iY),$W.init(W,Q)}),J0=K("$ZodCheckIncludes",(W,Q)=>{g.init(W,Q);let Y=WW(Q.includes),X=new RegExp(typeof Q.position==="number"?`^.{${Q.position}}${Y}`:Y);Q.pattern=X,W._zod.onattach.push((G)=>{let J=G._zod.bag;J.patterns??(J.patterns=new Set),J.patterns.add(X)}),W._zod.check=(G)=>{if(G.value.includes(Q.includes,Q.position))return;G.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:Q.includes,input:G.value,inst:W,continue:!Q.abort})}}),H0=K("$ZodCheckStartsWith",(W,Q)=>{g.init(W,Q);let Y=new RegExp(`^${WW(Q.prefix)}.*`);Q.pattern??(Q.pattern=Y),W._zod.onattach.push((X)=>{let G=X._zod.bag;G.patterns??(G.patterns=new Set),G.patterns.add(Y)}),W._zod.check=(X)=>{if(X.value.startsWith(Q.prefix))return;X.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:Q.prefix,input:X.value,inst:W,continue:!Q.abort})}}),w0=K("$ZodCheckEndsWith",(W,Q)=>{g.init(W,Q);let Y=new RegExp(`.*${WW(Q.suffix)}$`);Q.pattern??(Q.pattern=Y),W._zod.onattach.push((X)=>{let G=X._zod.bag;G.patterns??(G.patterns=new Set),G.patterns.add(Y)}),W._zod.check=(X)=>{if(X.value.endsWith(Q.suffix))return;X.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:Q.suffix,input:X.value,inst:W,continue:!Q.abort})}});var A0=K("$ZodCheckOverwrite",(W,Q)=>{g.init(W,Q),W._zod.check=(Y)=>{Y.value=Q.tx(Y.value)}});class IQ{constructor(W=[]){if(this.content=[],this.indent=0,this)this.args=W}indented(W){this.indent+=1,W(this),this.indent-=1}write(W){if(typeof W==="function"){W(this,{execution:"sync"}),W(this,{execution:"async"});return}let Y=W.split(`
|
|
3
3
|
`).filter((J)=>J),X=Math.min(...Y.map((J)=>J.length-J.trimStart().length)),G=Y.map((J)=>J.slice(X)).map((J)=>" ".repeat(this.indent*2)+J);for(let J of G)this.content.push(J)}compile(){let W=Function,Q=this?.args,X=[...(this?.content??[""]).map((G)=>` ${G}`)];return new W(...Q,X.join(`
|
|
4
4
|
`))}}var K0={major:4,minor:3,patch:6};var E=K("$ZodType",(W,Q)=>{var Y;W??(W={}),W._zod.def=Q,W._zod.bag=W._zod.bag||{},W._zod.version=K0;let X=[...W._zod.def.checks??[]];if(W._zod.traits.has("$ZodCheck"))X.unshift(W);for(let G of X)for(let J of G._zod.onattach)J(W);if(X.length===0)(Y=W._zod).deferred??(Y.deferred=[]),W._zod.deferred?.push(()=>{W._zod.run=W._zod.parse});else{let G=(H,w,q)=>{let L=GW(H),B;for(let z of w){if(z._zod.def.when){if(!z._zod.def.when(H))continue}else if(L)continue;let I=H.issues.length,V=z._zod.check(H);if(V instanceof Promise&&q?.async===!1)throw new a;if(B||V instanceof Promise)B=(B??Promise.resolve()).then(async()=>{if(await V,H.issues.length===I)return;if(!L)L=GW(H,I)});else{if(H.issues.length===I)continue;if(!L)L=GW(H,I)}}if(B)return B.then(()=>{return H});return H},J=(H,w,q)=>{if(GW(H))return H.aborted=!0,H;let L=G(w,X,q);if(L instanceof Promise){if(q.async===!1)throw new a;return L.then((B)=>W._zod.parse(B,q))}return W._zod.parse(L,q)};W._zod.run=(H,w)=>{if(w.skipChecks)return W._zod.parse(H,w);if(w.direction==="backward"){let L=W._zod.parse({value:H.value,issues:[]},{...w,skipChecks:!0});if(L instanceof Promise)return L.then((B)=>{return J(B,H,w)});return J(L,H,w)}let q=W._zod.parse(H,w);if(q instanceof Promise){if(w.async===!1)throw new a;return q.then((L)=>G(L,X,w))}return G(q,X,w)}}F(W,"~standard",()=>({validate:(G)=>{try{let J=NY(W,G);return J.success?{value:J.data}:{issues:J.error?.issues}}catch(J){return MY(W,G).then((H)=>H.success?{value:H.data}:{issues:H.error?.issues})}},vendor:"zod",version:1}))}),pW=K("$ZodString",(W,Q)=>{E.init(W,Q),W._zod.pattern=[...W?._zod.bag?.patterns??[]].pop()??lY(W._zod.bag),W._zod.parse=(Y,X)=>{if(Q.coerce)try{Y.value=String(Y.value)}catch(G){}if(typeof Y.value==="string")return Y;return Y.issues.push({expected:"string",code:"invalid_type",input:Y.value,inst:W}),Y}}),R=K("$ZodStringFormat",(W,Q)=>{$W.init(W,Q),pW.init(W,Q)}),O0=K("$ZodGUID",(W,Q)=>{Q.pattern??(Q.pattern=ZY),R.init(W,Q)}),D0=K("$ZodUUID",(W,Q)=>{if(Q.version){let X={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[Q.version];if(X===void 0)throw Error(`Invalid UUID version: "${Q.version}"`);Q.pattern??(Q.pattern=NQ(X))}else Q.pattern??(Q.pattern=NQ());R.init(W,Q)}),F0=K("$ZodEmail",(W,Q)=>{Q.pattern??(Q.pattern=CY),R.init(W,Q)}),$0=K("$ZodURL",(W,Q)=>{R.init(W,Q),W._zod.check=(Y)=>{try{let X=Y.value.trim(),G=new URL(X);if(Q.hostname){if(Q.hostname.lastIndex=0,!Q.hostname.test(G.hostname))Y.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Q.hostname.source,input:Y.value,inst:W,continue:!Q.abort})}if(Q.protocol){if(Q.protocol.lastIndex=0,!Q.protocol.test(G.protocol.endsWith(":")?G.protocol.slice(0,-1):G.protocol))Y.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:Q.protocol.source,input:Y.value,inst:W,continue:!Q.abort})}if(Q.normalize)Y.value=G.href;else Y.value=X;return}catch(X){Y.issues.push({code:"invalid_format",format:"url",input:Y.value,inst:W,continue:!Q.abort})}}}),P0=K("$ZodEmoji",(W,Q)=>{Q.pattern??(Q.pattern=jY()),R.init(W,Q)}),E0=K("$ZodNanoID",(W,Q)=>{Q.pattern??(Q.pattern=TY),R.init(W,Q)}),R0=K("$ZodCUID",(W,Q)=>{Q.pattern??(Q.pattern=PY),R.init(W,Q)}),S0=K("$ZodCUID2",(W,Q)=>{Q.pattern??(Q.pattern=EY),R.init(W,Q)}),b0=K("$ZodULID",(W,Q)=>{Q.pattern??(Q.pattern=RY),R.init(W,Q)}),T0=K("$ZodXID",(W,Q)=>{Q.pattern??(Q.pattern=SY),R.init(W,Q)}),_0=K("$ZodKSUID",(W,Q)=>{Q.pattern??(Q.pattern=bY),R.init(W,Q)}),Z0=K("$ZodISODateTime",(W,Q)=>{Q.pattern??(Q.pattern=oY(Q)),R.init(W,Q)}),C0=K("$ZodISODate",(W,Q)=>{Q.pattern??(Q.pattern=yY),R.init(W,Q)}),j0=K("$ZodISOTime",(W,Q)=>{Q.pattern??(Q.pattern=fY(Q)),R.init(W,Q)}),k0=K("$ZodISODuration",(W,Q)=>{Q.pattern??(Q.pattern=_Y),R.init(W,Q)}),v0=K("$ZodIPv4",(W,Q)=>{Q.pattern??(Q.pattern=kY),R.init(W,Q),W._zod.bag.format="ipv4"}),g0=K("$ZodIPv6",(W,Q)=>{Q.pattern??(Q.pattern=vY),R.init(W,Q),W._zod.bag.format="ipv6",W._zod.check=(Y)=>{try{new URL(`http://[${Y.value}]`)}catch{Y.issues.push({code:"invalid_format",format:"ipv6",input:Y.value,inst:W,continue:!Q.abort})}}});var h0=K("$ZodCIDRv4",(W,Q)=>{Q.pattern??(Q.pattern=gY),R.init(W,Q)}),x0=K("$ZodCIDRv6",(W,Q)=>{Q.pattern??(Q.pattern=hY),R.init(W,Q),W._zod.check=(Y)=>{let X=Y.value.split("/");try{if(X.length!==2)throw Error();let[G,J]=X;if(!J)throw Error();let H=Number(J);if(`${H}`!==J)throw Error();if(H<0||H>128)throw Error();new URL(`http://[${G}]`)}catch{Y.issues.push({code:"invalid_format",format:"cidrv6",input:Y.value,inst:W,continue:!Q.abort})}}});function c0(W){if(W==="")return!0;if(W.length%4!==0)return!1;try{return atob(W),!0}catch{return!1}}var u0=K("$ZodBase64",(W,Q)=>{Q.pattern??(Q.pattern=xY),R.init(W,Q),W._zod.bag.contentEncoding="base64",W._zod.check=(Y)=>{if(c0(Y.value))return;Y.issues.push({code:"invalid_format",format:"base64",input:Y.value,inst:W,continue:!Q.abort})}});function Y6(W){if(!MQ.test(W))return!1;let Q=W.replace(/[-_]/g,(X)=>X==="-"?"+":"/"),Y=Q.padEnd(Math.ceil(Q.length/4)*4,"=");return c0(Y)}var y0=K("$ZodBase64URL",(W,Q)=>{Q.pattern??(Q.pattern=MQ),R.init(W,Q),W._zod.bag.contentEncoding="base64url",W._zod.check=(Y)=>{if(Y6(Y.value))return;Y.issues.push({code:"invalid_format",format:"base64url",input:Y.value,inst:W,continue:!Q.abort})}}),m0=K("$ZodE164",(W,Q)=>{Q.pattern??(Q.pattern=cY),R.init(W,Q)});function X6(W,Q=null){try{let Y=W.split(".");if(Y.length!==3)return!1;let[X]=Y;if(!X)return!1;let G=JSON.parse(atob(X));if("typ"in G&&G?.typ!=="JWT")return!1;if(!G.alg)return!1;if(Q&&(!("alg"in G)||G.alg!==Q))return!1;return!0}catch{return!1}}var f0=K("$ZodJWT",(W,Q)=>{R.init(W,Q),W._zod.check=(Y)=>{if(X6(Y.value,Q.alg))return;Y.issues.push({code:"invalid_format",format:"jwt",input:Y.value,inst:W,continue:!Q.abort})}});var OQ=K("$ZodNumber",(W,Q)=>{E.init(W,Q),W._zod.pattern=W._zod.bag.pattern??fW,W._zod.parse=(Y,X)=>{if(Q.coerce)try{Y.value=Number(Y.value)}catch(H){}let G=Y.value;if(typeof G==="number"&&!Number.isNaN(G)&&Number.isFinite(G))return Y;let J=typeof G==="number"?Number.isNaN(G)?"NaN":!Number.isFinite(G)?"Infinity":void 0:void 0;return Y.issues.push({expected:"number",code:"invalid_type",input:G,inst:W,...J?{received:J}:{}}),Y}}),o0=K("$ZodNumberFormat",(W,Q)=>{aY.init(W,Q),OQ.init(W,Q)}),l0=K("$ZodBoolean",(W,Q)=>{E.init(W,Q),W._zod.pattern=pY,W._zod.parse=(Y,X)=>{if(Q.coerce)try{Y.value=Boolean(Y.value)}catch(J){}let G=Y.value;if(typeof G==="boolean")return Y;return Y.issues.push({expected:"boolean",code:"invalid_type",input:G,inst:W}),Y}});var r0=K("$ZodNull",(W,Q)=>{E.init(W,Q),W._zod.pattern=dY,W._zod.values=new Set([null]),W._zod.parse=(Y,X)=>{let G=Y.value;if(G===null)return Y;return Y.issues.push({expected:"null",code:"invalid_type",input:G,inst:W}),Y}});var p0=K("$ZodUnknown",(W,Q)=>{E.init(W,Q),W._zod.parse=(Y)=>Y}),d0=K("$ZodNever",(W,Q)=>{E.init(W,Q),W._zod.parse=(Y,X)=>{return Y.issues.push({expected:"never",code:"invalid_type",input:Y.value,inst:W}),Y}});function L0(W,Q,Y){if(W.issues.length)Q.issues.push(...QW(Y,W.issues));Q.value[Y]=W.value}var n0=K("$ZodArray",(W,Q)=>{E.init(W,Q),W._zod.parse=(Y,X)=>{let G=Y.value;if(!Array.isArray(G))return Y.issues.push({expected:"array",code:"invalid_type",input:G,inst:W}),Y;Y.value=Array(G.length);let J=[];for(let H=0;H<G.length;H++){let w=G[H],q=Q.element._zod.run({value:w,issues:[]},X);if(q instanceof Promise)J.push(q.then((L)=>L0(L,Y,H)));else L0(q,Y,H)}if(J.length)return Promise.all(J).then(()=>Y);return Y}});function rW(W,Q,Y,X,G){if(W.issues.length){if(G&&!(Y in X))return;Q.issues.push(...QW(Y,W.issues))}if(W.value===void 0){if(Y in X)Q.value[Y]=void 0}else Q.value[Y]=W.value}function i0(W){let Q=Object.keys(W.shape);for(let X of Q)if(!W.shape?.[X]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${X}": expected a Zod schema`);let Y=qQ(W.shape);return{...W,keys:Q,keySet:new Set(Q),numKeys:Q.length,optionalKeys:new Set(Y)}}function t0(W,Q,Y,X,G,J){let H=[],w=G.keySet,q=G.catchall._zod,L=q.def.type,B=q.optout==="optional";for(let z in Q){if(w.has(z))continue;if(L==="never"){H.push(z);continue}let I=q.run({value:Q[z],issues:[]},X);if(I instanceof Promise)W.push(I.then((V)=>rW(V,Y,z,Q,B)));else rW(I,Y,z,Q,B)}if(H.length)Y.issues.push({code:"unrecognized_keys",keys:H,input:Q,inst:J});if(!W.length)return Y;return Promise.all(W).then(()=>{return Y})}var G6=K("$ZodObject",(W,Q)=>{if(E.init(W,Q),!Object.getOwnPropertyDescriptor(Q,"shape")?.get){let w=Q.shape;Object.defineProperty(Q,"shape",{get:()=>{let q={...w};return Object.defineProperty(Q,"shape",{value:q}),q}})}let X=qW(()=>i0(Q));F(W._zod,"propValues",()=>{let w=Q.shape,q={};for(let L in w){let B=w[L]._zod;if(B.values){q[L]??(q[L]=new Set);for(let z of B.values)q[L].add(z)}}return q});let G=HW,J=Q.catchall,H;W._zod.parse=(w,q)=>{H??(H=X.value);let L=w.value;if(!G(L))return w.issues.push({expected:"object",code:"invalid_type",input:L,inst:W}),w;w.value={};let B=[],z=H.shape;for(let I of H.keys){let V=z[I],c=V._zod.optout==="optional",v=V._zod.run({value:L[I],issues:[]},q);if(v instanceof Promise)B.push(v.then((kW)=>rW(kW,w,I,L,c)));else rW(v,w,I,L,c)}if(!J)return B.length?Promise.all(B).then(()=>w):w;return t0(B,L,w,q,X.value,W)}}),e0=K("$ZodObjectJIT",(W,Q)=>{G6.init(W,Q);let Y=W._zod.parse,X=qW(()=>i0(Q)),G=(I)=>{let V=new IQ(["shape","payload","ctx"]),c=X.value,v=(e)=>{let m=hW(e);return`shape[${m}]._zod.run({ value: input[${m}], issues: [] }, ctx)`};V.write("const input = payload.value;");let kW=Object.create(null),R4=0;for(let e of c.keys)kW[e]=`key_${R4++}`;V.write("const newResult = {};");for(let e of c.keys){let m=kW[e],n=hW(e),b4=I[e]?._zod?.optout==="optional";if(V.write(`const ${m} = ${v(e)};`),b4)V.write(`
|
package/dist/compat-worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @mcpcloud/runtime v0.1.
|
|
1
|
+
/*! @mcpcloud/runtime v0.1.2 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
|
|
2
2
|
var XP=Object.create;var{getPrototypeOf:JP,defineProperty:C9,getOwnPropertyNames:vP}=Object;var zP=Object.prototype.hasOwnProperty;var _9=($,U,W)=>{W=$!=null?XP(JP($)):{};let J=U||!$||!$.__esModule?C9(W,"default",{value:$,enumerable:!0}):W;for(let X of vP($))if(!zP.call(J,X))C9(J,X,{get:()=>$[X],enumerable:!0});return J};var q=($,U)=>()=>(U||$((U={exports:{}}).exports,U),U.exports);var x4=($,U)=>{for(var W in U)C9($,W,{get:U[W],enumerable:!0,configurable:!0,set:(J)=>U[W]=()=>J})};var vW=q((wI)=>{Object.defineProperty(wI,"__esModule",{value:!0});wI.regexpCode=wI.getEsmExportName=wI.getProperty=wI.safeStringify=wI.stringify=wI.strConcat=wI.addCodeArg=wI.str=wI._=wI.nil=wI._Code=wI.Name=wI.IDENTIFIER=wI._CodeOrName=void 0;class hJ{}wI._CodeOrName=hJ;wI.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class H0 extends hJ{constructor($){super();if(!wI.IDENTIFIER.test($))throw Error("CodeGen: name must be a valid identifier");this.str=$}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}wI.Name=H0;class m4 extends hJ{constructor($){super();this._items=typeof $==="string"?[$]:$}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let $=this._items[0];return $===""||$==='""'}get str(){var $;return($=this._str)!==null&&$!==void 0?$:this._str=this._items.reduce((U,W)=>`${U}${W}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((U,W)=>{if(W instanceof H0)U[W.str]=(U[W.str]||0)+1;return U},{})}}wI._Code=m4;wI.nil=new m4("");function bI($,...U){let W=[$[0]],J=0;while(J<U.length)u8(W,U[J]),W.push($[++J]);return new m4(W)}wI._=bI;var g8=new m4("+");function BI($,...U){let W=[JW($[0])],J=0;while(J<U.length)W.push(g8),u8(W,U[J]),W.push(g8,JW($[++J]));return RT(W),new m4(W)}wI.str=BI;function u8($,U){if(U instanceof m4)$.push(...U._items);else if(U instanceof H0)$.push(U);else $.push(TT(U))}wI.addCodeArg=u8;function RT($){let U=1;while(U<$.length-1){if($[U]===g8){let W=kT($[U-1],$[U+1]);if(W!==void 0){$.splice(U-1,3,W);continue}$[U++]="+"}U++}}function kT($,U){if(U==='""')return $;if($==='""')return U;if(typeof $=="string"){if(U instanceof H0||$[$.length-1]!=='"')return;if(typeof U!="string")return`${$.slice(0,-1)}${U}"`;if(U[0]==='"')return $.slice(0,-1)+U.slice(1);return}if(typeof U=="string"&&U[0]==='"'&&!($ instanceof H0))return`"${$}${U.slice(1)}`;return}function ZT($,U){return U.emptyStr()?$:$.emptyStr()?U:BI`${$}${U}`}wI.strConcat=ZT;function TT($){return typeof $=="number"||typeof $=="boolean"||$===null?$:JW(Array.isArray($)?$.join(","):$)}function CT($){return new m4(JW($))}wI.stringify=CT;function JW($){return JSON.stringify($).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}wI.safeStringify=JW;function _T($){return typeof $=="string"&&wI.IDENTIFIER.test($)?new m4(`.${$}`):bI`[${$}]`}wI.getProperty=_T;function gT($){if(typeof $=="string"&&wI.IDENTIFIER.test($))return new m4(`${$}`);throw Error(`CodeGen: invalid export name: ${$}, use explicit $id name mapping`)}wI.getEsmExportName=gT;function uT($){return new m4($.toString())}wI.regexpCode=uT});var h8=q((KI)=>{Object.defineProperty(KI,"__esModule",{value:!0});KI.ValueScope=KI.ValueScopeName=KI.Scope=KI.varKinds=KI.UsedValueState=void 0;var D4=vW();class LI extends Error{constructor($){super(`CodeGen: "code" for ${$} not defined`);this.value=$.value}}var mJ;(function($){$[$.Started=0]="Started",$[$.Completed=1]="Completed"})(mJ||(KI.UsedValueState=mJ={}));KI.varKinds={const:new D4.Name("const"),let:new D4.Name("let"),var:new D4.Name("var")};class y8{constructor({prefixes:$,parent:U}={}){this._names={},this._prefixes=$,this._parent=U}toName($){return $ instanceof D4.Name?$:this.name($)}name($){return new D4.Name(this._newName($))}_newName($){let U=this._names[$]||this._nameGroup($);return`${$}${U.index++}`}_nameGroup($){var U,W;if(((W=(U=this._parent)===null||U===void 0?void 0:U._prefixes)===null||W===void 0?void 0:W.has($))||this._prefixes&&!this._prefixes.has($))throw Error(`CodeGen: prefix "${$}" is not allowed in this scope`);return this._names[$]={prefix:$,index:0}}}KI.Scope=y8;class f8 extends D4.Name{constructor($,U){super(U);this.prefix=$}setValue($,{property:U,itemIndex:W}){this.value=$,this.scopePath=D4._`.${new D4.Name(U)}[${W}]`}}KI.ValueScopeName=f8;var dT=D4._`\n`;class II extends y8{constructor($){super($);this._values={},this._scope=$.scope,this.opts={...$,_n:$.lines?dT:D4.nil}}get(){return this._scope}name($){return new f8($,this._newName($))}value($,U){var W;if(U.ref===void 0)throw Error("CodeGen: ref must be passed in value");let J=this.toName($),{prefix:X}=J,v=(W=U.key)!==null&&W!==void 0?W:U.ref,z=this._values[X];if(z){let Y=z.get(v);if(Y)return Y}else z=this._values[X]=new Map;z.set(v,J);let Q=this._scope[X]||(this._scope[X]=[]),G=Q.length;return Q[G]=U.ref,J.setValue(U,{property:X,itemIndex:G}),J}getValue($,U){let W=this._values[$];if(!W)return;return W.get(U)}scopeRefs($,U=this._values){return this._reduceValues(U,(W)=>{if(W.scopePath===void 0)throw Error(`CodeGen: name "${W}" has no value`);return D4._`${$}${W.scopePath}`})}scopeCode($=this._values,U,W){return this._reduceValues($,(J)=>{if(J.value===void 0)throw Error(`CodeGen: name "${J}" has no value`);return J.value.code},U,W)}_reduceValues($,U,W={},J){let X=D4.nil;for(let v in $){let z=$[v];if(!z)continue;let Q=W[v]=W[v]||new Map;z.forEach((G)=>{if(Q.has(G))return;Q.set(G,mJ.Started);let Y=U(G);if(Y){let D=this.opts.es5?KI.varKinds.var:KI.varKinds.const;X=D4._`${X}${D} ${G} = ${Y};${this.opts._n}`}else if(Y=J===null||J===void 0?void 0:J(G))X=D4._`${X}${Y}${this.opts._n}`;else throw new LI(G);Q.set(G,mJ.Completed)})}return X}}KI.ValueScope=II});var s=q((H4)=>{Object.defineProperty(H4,"__esModule",{value:!0});H4.or=H4.and=H4.not=H4.CodeGen=H4.operators=H4.varKinds=H4.ValueScopeName=H4.ValueScope=H4.Scope=H4.Name=H4.regexpCode=H4.stringify=H4.getProperty=H4.nil=H4.strConcat=H4.str=H4._=void 0;var z$=vW(),i4=h8(),c6=vW();Object.defineProperty(H4,"_",{enumerable:!0,get:function(){return c6._}});Object.defineProperty(H4,"str",{enumerable:!0,get:function(){return c6.str}});Object.defineProperty(H4,"strConcat",{enumerable:!0,get:function(){return c6.strConcat}});Object.defineProperty(H4,"nil",{enumerable:!0,get:function(){return c6.nil}});Object.defineProperty(H4,"getProperty",{enumerable:!0,get:function(){return c6.getProperty}});Object.defineProperty(H4,"stringify",{enumerable:!0,get:function(){return c6.stringify}});Object.defineProperty(H4,"regexpCode",{enumerable:!0,get:function(){return c6.regexpCode}});Object.defineProperty(H4,"Name",{enumerable:!0,get:function(){return c6.Name}});var oJ=h8();Object.defineProperty(H4,"Scope",{enumerable:!0,get:function(){return oJ.Scope}});Object.defineProperty(H4,"ValueScope",{enumerable:!0,get:function(){return oJ.ValueScope}});Object.defineProperty(H4,"ValueScopeName",{enumerable:!0,get:function(){return oJ.ValueScopeName}});Object.defineProperty(H4,"varKinds",{enumerable:!0,get:function(){return oJ.varKinds}});H4.operators={GT:new z$._Code(">"),GTE:new z$._Code(">="),LT:new z$._Code("<"),LTE:new z$._Code("<="),EQ:new z$._Code("==="),NEQ:new z$._Code("!=="),NOT:new z$._Code("!"),OR:new z$._Code("||"),AND:new z$._Code("&&"),ADD:new z$._Code("+")};class p6{optimizeNodes(){return this}optimizeNames($,U){return this}}class OI extends p6{constructor($,U,W){super();this.varKind=$,this.name=U,this.rhs=W}render({es5:$,_n:U}){let W=$?i4.varKinds.var:this.varKind,J=this.rhs===void 0?"":` = ${this.rhs}`;return`${W} ${this.name}${J};`+U}optimizeNames($,U){if(!$[this.name.str])return;if(this.rhs)this.rhs=B0(this.rhs,$,U);return this}get names(){return this.rhs instanceof z$._CodeOrName?this.rhs.names:{}}}class i8 extends p6{constructor($,U,W){super();this.lhs=$,this.rhs=U,this.sideEffects=W}render({_n:$}){return`${this.lhs} = ${this.rhs};`+$}optimizeNames($,U){if(this.lhs instanceof z$.Name&&!$[this.lhs.str]&&!this.sideEffects)return;return this.rhs=B0(this.rhs,$,U),this}get names(){let $=this.lhs instanceof z$.Name?{}:{...this.lhs.names};return pJ($,this.rhs)}}class qI extends i8{constructor($,U,W,J){super($,W,J);this.op=U}render({_n:$}){return`${this.lhs} ${this.op}= ${this.rhs};`+$}}class VI extends p6{constructor($){super();this.label=$,this.names={}}render({_n:$}){return`${this.label}:`+$}}class FI extends p6{constructor($){super();this.label=$,this.names={}}render({_n:$}){return`break${this.label?` ${this.label}`:""};`+$}}class jI extends p6{constructor($){super();this.error=$}render({_n:$}){return`throw ${this.error};`+$}get names(){return this.error.names}}class MI extends p6{constructor($){super();this.code=$}render({_n:$}){return`${this.code};`+$}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames($,U){return this.code=B0(this.code,$,U),this}get names(){return this.code instanceof z$._CodeOrName?this.code.names:{}}}class dJ extends p6{constructor($=[]){super();this.nodes=$}render($){return this.nodes.reduce((U,W)=>U+W.render($),"")}optimizeNodes(){let{nodes:$}=this,U=$.length;while(U--){let W=$[U].optimizeNodes();if(Array.isArray(W))$.splice(U,1,...W);else if(W)$[U]=W;else $.splice(U,1)}return $.length>0?this:void 0}optimizeNames($,U){let{nodes:W}=this,J=W.length;while(J--){let X=W[J];if(X.optimizeNames($,U))continue;sT($,X.names),W.splice(J,1)}return W.length>0?this:void 0}get names(){return this.nodes.reduce(($,U)=>M1($,U.names),{})}}class o6 extends dJ{render($){return"{"+$._n+super.render($)+"}"+$._n}}class EI extends dJ{}class zW extends o6{}zW.kind="else";class F6 extends o6{constructor($,U){super(U);this.condition=$}render($){let U=`if(${this.condition})`+super.render($);if(this.else)U+="else "+this.else.render($);return U}optimizeNodes(){super.optimizeNodes();let $=this.condition;if($===!0)return this.nodes;let U=this.else;if(U){let W=U.optimizeNodes();U=this.else=Array.isArray(W)?new zW(W):W}if(U){if($===!1)return U instanceof F6?U:U.nodes;if(this.nodes.length)return this;return new F6(ZI($),U instanceof F6?[U]:U.nodes)}if($===!1||!this.nodes.length)return;return this}optimizeNames($,U){var W;if(this.else=(W=this.else)===null||W===void 0?void 0:W.optimizeNames($,U),!(super.optimizeNames($,U)||this.else))return;return this.condition=B0(this.condition,$,U),this}get names(){let $=super.names;if(pJ($,this.condition),this.else)M1($,this.else.names);return $}}F6.kind="if";class b0 extends o6{}b0.kind="for";class SI extends b0{constructor($){super();this.iteration=$}render($){return`for(${this.iteration})`+super.render($)}optimizeNames($,U){if(!super.optimizeNames($,U))return;return this.iteration=B0(this.iteration,$,U),this}get names(){return M1(super.names,this.iteration.names)}}class PI extends b0{constructor($,U,W,J){super();this.varKind=$,this.name=U,this.from=W,this.to=J}render($){let U=$.es5?i4.varKinds.var:this.varKind,{name:W,from:J,to:X}=this;return`for(${U} ${W}=${J}; ${W}<${X}; ${W}++)`+super.render($)}get names(){let $=pJ(super.names,this.from);return pJ($,this.to)}}class l8 extends b0{constructor($,U,W,J){super();this.loop=$,this.varKind=U,this.name=W,this.iterable=J}render($){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render($)}optimizeNames($,U){if(!super.optimizeNames($,U))return;return this.iterable=B0(this.iterable,$,U),this}get names(){return M1(super.names,this.iterable.names)}}class iJ extends o6{constructor($,U,W){super();this.name=$,this.args=U,this.async=W}render($){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render($)}}iJ.kind="func";class nJ extends dJ{render($){return"return "+super.render($)}}nJ.kind="return";class RI extends o6{render($){let U="try"+super.render($);if(this.catch)U+=this.catch.render($);if(this.finally)U+=this.finally.render($);return U}optimizeNodes(){var $,U;return super.optimizeNodes(),($=this.catch)===null||$===void 0||$.optimizeNodes(),(U=this.finally)===null||U===void 0||U.optimizeNodes(),this}optimizeNames($,U){var W,J;return super.optimizeNames($,U),(W=this.catch)===null||W===void 0||W.optimizeNames($,U),(J=this.finally)===null||J===void 0||J.optimizeNames($,U),this}get names(){let $=super.names;if(this.catch)M1($,this.catch.names);if(this.finally)M1($,this.finally.names);return $}}class rJ extends o6{constructor($){super();this.error=$}render($){return`catch(${this.error})`+super.render($)}}rJ.kind="catch";class cJ extends o6{render($){return"finally"+super.render($)}}cJ.kind="finally";class kI{constructor($,U={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...U,_n:U.lines?`
|
|
3
3
|
`:""},this._extScope=$,this._scope=new i4.Scope({parent:$}),this._nodes=[new EI]}toString(){return this._root.render(this.opts)}name($){return this._scope.name($)}scopeName($){return this._extScope.name($)}scopeValue($,U){let W=this._extScope.value($,U);return(this._values[W.prefix]||(this._values[W.prefix]=new Set)).add(W),W}getScopeValue($,U){return this._extScope.getValue($,U)}scopeRefs($){return this._extScope.scopeRefs($,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def($,U,W,J){let X=this._scope.toName(U);if(W!==void 0&&J)this._constants[X.str]=W;return this._leafNode(new OI($,X,W)),X}const($,U,W){return this._def(i4.varKinds.const,$,U,W)}let($,U,W){return this._def(i4.varKinds.let,$,U,W)}var($,U,W){return this._def(i4.varKinds.var,$,U,W)}assign($,U,W){return this._leafNode(new i8($,U,W))}add($,U){return this._leafNode(new qI($,H4.operators.ADD,U))}code($){if(typeof $=="function")$();else if($!==z$.nil)this._leafNode(new MI($));return this}object(...$){let U=["{"];for(let[W,J]of $){if(U.length>1)U.push(",");if(U.push(W),W!==J||this.opts.es5)U.push(":"),(0,z$.addCodeArg)(U,J)}return U.push("}"),new z$._Code(U)}if($,U,W){if(this._blockNode(new F6($)),U&&W)this.code(U).else().code(W).endIf();else if(U)this.code(U).endIf();else if(W)throw Error('CodeGen: "else" body without "then" body');return this}elseIf($){return this._elseNode(new F6($))}else(){return this._elseNode(new zW)}endIf(){return this._endBlockNode(F6,zW)}_for($,U){if(this._blockNode($),U)this.code(U).endFor();return this}for($,U){return this._for(new SI($),U)}forRange($,U,W,J,X=this.opts.es5?i4.varKinds.var:i4.varKinds.let){let v=this._scope.toName($);return this._for(new PI(X,v,U,W),()=>J(v))}forOf($,U,W,J=i4.varKinds.const){let X=this._scope.toName($);if(this.opts.es5){let v=U instanceof z$.Name?U:this.var("_arr",U);return this.forRange("_i",0,z$._`${v}.length`,(z)=>{this.var(X,z$._`${v}[${z}]`),W(X)})}return this._for(new l8("of",J,X,U),()=>W(X))}forIn($,U,W,J=this.opts.es5?i4.varKinds.var:i4.varKinds.const){if(this.opts.ownProperties)return this.forOf($,z$._`Object.keys(${U})`,W);let X=this._scope.toName($);return this._for(new l8("in",J,X,U),()=>W(X))}endFor(){return this._endBlockNode(b0)}label($){return this._leafNode(new VI($))}break($){return this._leafNode(new FI($))}return($){let U=new nJ;if(this._blockNode(U),this.code($),U.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(nJ)}try($,U,W){if(!U&&!W)throw Error('CodeGen: "try" without "catch" and "finally"');let J=new RI;if(this._blockNode(J),this.code($),U){let X=this.name("e");this._currNode=J.catch=new rJ(X),U(X)}if(W)this._currNode=J.finally=new cJ,this.code(W);return this._endBlockNode(rJ,cJ)}throw($){return this._leafNode(new jI($))}block($,U){if(this._blockStarts.push(this._nodes.length),$)this.code($).endBlock(U);return this}endBlock($){let U=this._blockStarts.pop();if(U===void 0)throw Error("CodeGen: not in self-balancing block");let W=this._nodes.length-U;if(W<0||$!==void 0&&W!==$)throw Error(`CodeGen: wrong number of nodes: ${W} vs ${$} expected`);return this._nodes.length=U,this}func($,U=z$.nil,W,J){if(this._blockNode(new iJ($,U,W)),J)this.code(J).endFunc();return this}endFunc(){return this._endBlockNode(iJ)}optimize($=1){while($-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode($){return this._currNode.nodes.push($),this}_blockNode($){this._currNode.nodes.push($),this._nodes.push($)}_endBlockNode($,U){let W=this._currNode;if(W instanceof $||U&&W instanceof U)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${U?`${$.kind}/${U.kind}`:$.kind}"`)}_elseNode($){let U=this._currNode;if(!(U instanceof F6))throw Error('CodeGen: "else" without "if"');return this._currNode=U.else=$,this}get _root(){return this._nodes[0]}get _currNode(){let $=this._nodes;return $[$.length-1]}set _currNode($){let U=this._nodes;U[U.length-1]=$}}H4.CodeGen=kI;function M1($,U){for(let W in U)$[W]=($[W]||0)+(U[W]||0);return $}function pJ($,U){return U instanceof z$._CodeOrName?M1($,U.names):$}function B0($,U,W){if($ instanceof z$.Name)return J($);if(!X($))return $;return new z$._Code($._items.reduce((v,z)=>{if(z instanceof z$.Name)z=J(z);if(z instanceof z$._Code)v.push(...z._items);else v.push(z);return v},[]));function J(v){let z=W[v.str];if(z===void 0||U[v.str]!==1)return v;return delete U[v.str],z}function X(v){return v instanceof z$._Code&&v._items.some((z)=>z instanceof z$.Name&&U[z.str]===1&&W[z.str]!==void 0)}}function sT($,U){for(let W in U)$[W]=($[W]||0)-(U[W]||0)}function ZI($){return typeof $=="boolean"||typeof $=="number"||$===null?!$:z$._`!${m8($)}`}H4.not=ZI;var $C=TI(H4.operators.AND);function UC(...$){return $.reduce($C)}H4.and=UC;var WC=TI(H4.operators.OR);function XC(...$){return $.reduce(WC)}H4.or=XC;function TI($){return(U,W)=>U===z$.nil?W:W===z$.nil?U:z$._`${m8(U)} ${$} ${m8(W)}`}function m8($){return $ instanceof z$.Name?$:z$._`(${$})`}});var Y$=q((lI)=>{Object.defineProperty(lI,"__esModule",{value:!0});lI.checkStrictMode=lI.getErrorPath=lI.Type=lI.useFunc=lI.setEvaluated=lI.evaluatedPropsToName=lI.mergeEvaluated=lI.eachItem=lI.unescapeJsonPointer=lI.escapeJsonPointer=lI.escapeFragment=lI.unescapeFragment=lI.schemaRefOrVal=lI.schemaHasRulesButRef=lI.schemaHasRules=lI.checkUnknownRules=lI.alwaysValidSchema=lI.toHash=void 0;var O$=s(),QC=vW();function GC($){let U={};for(let W of $)U[W]=!0;return U}lI.toHash=GC;function YC($,U){if(typeof U=="boolean")return U;if(Object.keys(U).length===0)return!0;return uI($,U),!xI(U,$.self.RULES.all)}lI.alwaysValidSchema=YC;function uI($,U=$.schema){let{opts:W,self:J}=$;if(!W.strictSchema)return;if(typeof U==="boolean")return;let X=J.RULES.keywords;for(let v in U)if(!X[v])hI($,`unknown keyword: "${v}"`)}lI.checkUnknownRules=uI;function xI($,U){if(typeof $=="boolean")return!$;for(let W in $)if(U[W])return!0;return!1}lI.schemaHasRules=xI;function DC($,U){if(typeof $=="boolean")return!$;for(let W in $)if(W!=="$ref"&&U.all[W])return!0;return!1}lI.schemaHasRulesButRef=DC;function HC({topSchemaRef:$,schemaPath:U},W,J,X){if(!X){if(typeof W=="number"||typeof W=="boolean")return W;if(typeof W=="string")return O$._`${W}`}return O$._`${$}${U}${(0,O$.getProperty)(J)}`}lI.schemaRefOrVal=HC;function bC($){return yI(decodeURIComponent($))}lI.unescapeFragment=bC;function BC($){return encodeURIComponent(r8($))}lI.escapeFragment=BC;function r8($){if(typeof $=="number")return`${$}`;return $.replace(/~/g,"~0").replace(/\//g,"~1")}lI.escapeJsonPointer=r8;function yI($){return $.replace(/~1/g,"/").replace(/~0/g,"~")}lI.unescapeJsonPointer=yI;function wC($,U){if(Array.isArray($))for(let W of $)U(W);else U($)}lI.eachItem=wC;function _I({mergeNames:$,mergeToName:U,mergeValues:W,resultToName:J}){return(X,v,z,Q)=>{let G=z===void 0?v:z instanceof O$.Name?(v instanceof O$.Name?$(X,v,z):U(X,v,z),z):v instanceof O$.Name?(U(X,z,v),v):W(v,z);return Q===O$.Name&&!(G instanceof O$.Name)?J(X,G):G}}lI.mergeEvaluated={props:_I({mergeNames:($,U,W)=>$.if(O$._`${W} !== true && ${U} !== undefined`,()=>{$.if(O$._`${U} === true`,()=>$.assign(W,!0),()=>$.assign(W,O$._`${W} || {}`).code(O$._`Object.assign(${W}, ${U})`))}),mergeToName:($,U,W)=>$.if(O$._`${W} !== true`,()=>{if(U===!0)$.assign(W,!0);else $.assign(W,O$._`${W} || {}`),c8($,W,U)}),mergeValues:($,U)=>$===!0?!0:{...$,...U},resultToName:fI}),items:_I({mergeNames:($,U,W)=>$.if(O$._`${W} !== true && ${U} !== undefined`,()=>$.assign(W,O$._`${U} === true ? true : ${W} > ${U} ? ${W} : ${U}`)),mergeToName:($,U,W)=>$.if(O$._`${W} !== true`,()=>$.assign(W,U===!0?!0:O$._`${W} > ${U} ? ${W} : ${U}`)),mergeValues:($,U)=>$===!0?!0:Math.max($,U),resultToName:($,U)=>$.var("items",U)})};function fI($,U){if(U===!0)return $.var("props",!0);let W=$.var("props",O$._`{}`);if(U!==void 0)c8($,W,U);return W}lI.evaluatedPropsToName=fI;function c8($,U,W){Object.keys(W).forEach((J)=>$.assign(O$._`${U}${(0,O$.getProperty)(J)}`,!0))}lI.setEvaluated=c8;var gI={};function AC($,U){return $.scopeValue("func",{ref:U,code:gI[U.code]||(gI[U.code]=new QC._Code(U.code))})}lI.useFunc=AC;var n8;(function($){$[$.Num=0]="Num",$[$.Str=1]="Str"})(n8||(lI.Type=n8={}));function LC($,U,W){if($ instanceof O$.Name){let J=U===n8.Num;return W?J?O$._`"[" + ${$} + "]"`:O$._`"['" + ${$} + "']"`:J?O$._`"/" + ${$}`:O$._`"/" + ${$}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return W?(0,O$.getProperty)($).toString():"/"+r8($)}lI.getErrorPath=LC;function hI($,U,W=$.opts.strictSchema){if(!W)return;if(U=`strict mode: ${U}`,W===!0)throw Error(U);$.self.logger.warn(U)}lI.checkStrictMode=hI});var j6=q((iI)=>{Object.defineProperty(iI,"__esModule",{value:!0});var o$=s(),_C={data:new o$.Name("data"),valCxt:new o$.Name("valCxt"),instancePath:new o$.Name("instancePath"),parentData:new o$.Name("parentData"),parentDataProperty:new o$.Name("parentDataProperty"),rootData:new o$.Name("rootData"),dynamicAnchors:new o$.Name("dynamicAnchors"),vErrors:new o$.Name("vErrors"),errors:new o$.Name("errors"),this:new o$.Name("this"),self:new o$.Name("self"),scope:new o$.Name("scope"),json:new o$.Name("json"),jsonPos:new o$.Name("jsonPos"),jsonLen:new o$.Name("jsonLen"),jsonPart:new o$.Name("jsonPart")};iI.default=_C});var QW=q((pI)=>{Object.defineProperty(pI,"__esModule",{value:!0});pI.extendErrors=pI.resetErrorsCount=pI.reportExtraError=pI.reportError=pI.keyword$DataError=pI.keywordError=void 0;var D$=s(),aJ=Y$(),U4=j6();pI.keywordError={message:({keyword:$})=>D$.str`must pass "${$}" keyword validation`};pI.keyword$DataError={message:({keyword:$,schemaType:U})=>U?D$.str`"${$}" keyword must be ${U} ($data)`:D$.str`"${$}" keyword is invalid ($data)`};function uC($,U=pI.keywordError,W,J){let{it:X}=$,{gen:v,compositeRule:z,allErrors:Q}=X,G=cI($,U,W);if(J!==null&&J!==void 0?J:z||Q)nI(v,G);else rI(X,D$._`[${G}]`)}pI.reportError=uC;function xC($,U=pI.keywordError,W){let{it:J}=$,{gen:X,compositeRule:v,allErrors:z}=J,Q=cI($,U,W);if(nI(X,Q),!(v||z))rI(J,U4.default.vErrors)}pI.reportExtraError=xC;function yC($,U){$.assign(U4.default.errors,U),$.if(D$._`${U4.default.vErrors} !== null`,()=>$.if(U,()=>$.assign(D$._`${U4.default.vErrors}.length`,U),()=>$.assign(U4.default.vErrors,null)))}pI.resetErrorsCount=yC;function fC({gen:$,keyword:U,schemaValue:W,data:J,errsCount:X,it:v}){if(X===void 0)throw Error("ajv implementation error");let z=$.name("err");$.forRange("i",X,U4.default.errors,(Q)=>{if($.const(z,D$._`${U4.default.vErrors}[${Q}]`),$.if(D$._`${z}.instancePath === undefined`,()=>$.assign(D$._`${z}.instancePath`,(0,D$.strConcat)(U4.default.instancePath,v.errorPath))),$.assign(D$._`${z}.schemaPath`,D$.str`${v.errSchemaPath}/${U}`),v.opts.verbose)$.assign(D$._`${z}.schema`,W),$.assign(D$._`${z}.data`,J)})}pI.extendErrors=fC;function nI($,U){let W=$.const("err",U);$.if(D$._`${U4.default.vErrors} === null`,()=>$.assign(U4.default.vErrors,D$._`[${W}]`),D$._`${U4.default.vErrors}.push(${W})`),$.code(D$._`${U4.default.errors}++`)}function rI($,U){let{gen:W,validateName:J,schemaEnv:X}=$;if(X.$async)W.throw(D$._`new ${$.ValidationError}(${U})`);else W.assign(D$._`${J}.errors`,U),W.return(!1)}var E1={keyword:new D$.Name("keyword"),schemaPath:new D$.Name("schemaPath"),params:new D$.Name("params"),propertyName:new D$.Name("propertyName"),message:new D$.Name("message"),schema:new D$.Name("schema"),parentSchema:new D$.Name("parentSchema")};function cI($,U,W){let{createErrors:J}=$.it;if(J===!1)return D$._`{}`;return hC($,U,W)}function hC($,U,W={}){let{gen:J,it:X}=$,v=[lC(X,W),mC($,W)];return iC($,U,v),J.object(...v)}function lC({errorPath:$},{instancePath:U}){let W=U?D$.str`${$}${(0,aJ.getErrorPath)(U,aJ.Type.Str)}`:$;return[U4.default.instancePath,(0,D$.strConcat)(U4.default.instancePath,W)]}function mC({keyword:$,it:{errSchemaPath:U}},{schemaPath:W,parentSchema:J}){let X=J?U:D$.str`${U}/${$}`;if(W)X=D$.str`${X}${(0,aJ.getErrorPath)(W,aJ.Type.Str)}`;return[E1.schemaPath,X]}function iC($,{params:U,message:W},J){let{keyword:X,data:v,schemaValue:z,it:Q}=$,{opts:G,propertyName:Y,topSchemaRef:D,schemaPath:H}=Q;if(J.push([E1.keyword,X],[E1.params,typeof U=="function"?U($):U||D$._`{}`]),G.messages)J.push([E1.message,typeof W=="function"?W($):W]);if(G.verbose)J.push([E1.schema,z],[E1.parentSchema,D$._`${D}${H}`],[U4.default.data,v]);if(Y)J.push([E1.propertyName,Y])}});var eI=q((tI)=>{Object.defineProperty(tI,"__esModule",{value:!0});tI.boolOrEmptySchema=tI.topBoolOrEmptySchema=void 0;var oC=QW(),dC=s(),tC=j6(),aC={message:"boolean schema is false"};function eC($){let{gen:U,schema:W,validateName:J}=$;if(W===!1)dI($,!1);else if(typeof W=="object"&&W.$async===!0)U.return(tC.default.data);else U.assign(dC._`${J}.errors`,null),U.return(!0)}tI.topBoolOrEmptySchema=eC;function sC($,U){let{gen:W,schema:J}=$;if(J===!1)W.var(U,!1),dI($);else W.var(U,!0)}tI.boolOrEmptySchema=sC;function dI($,U){let{gen:W,data:J}=$,X={gen:W,keyword:"false schema",data:J,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:$};(0,oC.reportError)(X,aC,void 0,U)}});var o8=q((sI)=>{Object.defineProperty(sI,"__esModule",{value:!0});sI.getRules=sI.isJSONType=void 0;var U2=["string","number","integer","boolean","null","object","array"],W2=new Set(U2);function X2($){return typeof $=="string"&&W2.has($)}sI.isJSONType=X2;function J2(){let $={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...$,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},$.number,$.string,$.array,$.object],post:{rules:[]},all:{},keywords:{}}}sI.getRules=J2});var d8=q((XK)=>{Object.defineProperty(XK,"__esModule",{value:!0});XK.shouldUseRule=XK.shouldUseGroup=XK.schemaHasRulesForType=void 0;function z2({schema:$,self:U},W){let J=U.RULES.types[W];return J&&J!==!0&&UK($,J)}XK.schemaHasRulesForType=z2;function UK($,U){return U.rules.some((W)=>WK($,W))}XK.shouldUseGroup=UK;function WK($,U){var W;return $[U.keyword]!==void 0||((W=U.definition.implements)===null||W===void 0?void 0:W.some((J)=>$[J]!==void 0))}XK.shouldUseRule=WK});var GW=q((GK)=>{Object.defineProperty(GK,"__esModule",{value:!0});GK.reportTypeError=GK.checkDataTypes=GK.checkDataType=GK.coerceAndCheckDataType=GK.getJSONTypes=GK.getSchemaTypes=GK.DataType=void 0;var Y2=o8(),D2=d8(),H2=QW(),a=s(),vK=Y$(),w0;(function($){$[$.Correct=0]="Correct",$[$.Wrong=1]="Wrong"})(w0||(GK.DataType=w0={}));function b2($){let U=zK($.type);if(U.includes("null")){if($.nullable===!1)throw Error("type: null contradicts nullable: false")}else{if(!U.length&&$.nullable!==void 0)throw Error('"nullable" cannot be used without "type"');if($.nullable===!0)U.push("null")}return U}GK.getSchemaTypes=b2;function zK($){let U=Array.isArray($)?$:$?[$]:[];if(U.every(Y2.isJSONType))return U;throw Error("type must be JSONType or JSONType[]: "+U.join(","))}GK.getJSONTypes=zK;function B2($,U){let{gen:W,data:J,opts:X}=$,v=w2(U,X.coerceTypes),z=U.length>0&&!(v.length===0&&U.length===1&&(0,D2.schemaHasRulesForType)($,U[0]));if(z){let Q=a8(U,J,X.strictNumbers,w0.Wrong);W.if(Q,()=>{if(v.length)A2($,U,v);else e8($)})}return z}GK.coerceAndCheckDataType=B2;var QK=new Set(["string","number","integer","boolean","null"]);function w2($,U){return U?$.filter((W)=>QK.has(W)||U==="array"&&W==="array"):[]}function A2($,U,W){let{gen:J,data:X,opts:v}=$,z=J.let("dataType",a._`typeof ${X}`),Q=J.let("coerced",a._`undefined`);if(v.coerceTypes==="array")J.if(a._`${z} == 'object' && Array.isArray(${X}) && ${X}.length == 1`,()=>J.assign(X,a._`${X}[0]`).assign(z,a._`typeof ${X}`).if(a8(U,X,v.strictNumbers),()=>J.assign(Q,X)));J.if(a._`${Q} !== undefined`);for(let Y of W)if(QK.has(Y)||Y==="array"&&v.coerceTypes==="array")G(Y);J.else(),e8($),J.endIf(),J.if(a._`${Q} !== undefined`,()=>{J.assign(X,Q),L2($,Q)});function G(Y){switch(Y){case"string":J.elseIf(a._`${z} == "number" || ${z} == "boolean"`).assign(Q,a._`"" + ${X}`).elseIf(a._`${X} === null`).assign(Q,a._`""`);return;case"number":J.elseIf(a._`${z} == "boolean" || ${X} === null
|
|
4
4
|
|| (${z} == "string" && ${X} && ${X} == +${X})`).assign(Q,a._`+${X}`);return;case"integer":J.elseIf(a._`${z} === "boolean" || ${X} === null
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* container-host subpath entry (`@mcpcloud/runtime/container-host`) — the generic
|
|
3
|
+
* runtime-host that boots a dedicated-container deployment from a fetched bundle.
|
|
4
|
+
* Imports node builtins (fs/path/url), so it lives behind its own subpath.
|
|
5
|
+
*/
|
|
6
|
+
export { fetchAndVerifyBundle, materializeBundle, resolveBootConfig, serveFromBundle, BOOT_ARTIFACT_SCHEMA_VERSION, } from './adapters/container-host';
|
|
7
|
+
export type { ContainerHostBootConfig, ServeFromBundleOptions, } from './adapters/container-host';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @mcpcloud/runtime v0.1.2 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
|
|
2
|
+
import{mkdirSync as O,mkdtempSync as P,writeFileSync as _}from"node:fs";import{tmpdir as E}from"node:os";import{dirname as H,join as F}from"node:path";import{pathToFileURL as A}from"node:url";import{createServer as j}from"node:http";import{Readable as x}from"node:stream";function z(G,K){let J=new URL(G.url??"/",K),Q=new Headers;for(let[Z,$]of Object.entries(G.headers))if(Array.isArray($))for(let C of $)Q.append(Z,C);else if(typeof $==="string")Q.set(Z,$);let X=G.method??"GET",Y=X==="GET"||X==="HEAD"?void 0:x.toWeb(G);return new Request(J,{method:X,headers:Q,body:Y,...Y?{duplex:"half"}:{}})}async function I(G,K){if(K.statusCode=G.status,G.headers.forEach((Q,X)=>{K.setHeader(X,Q)}),!G.body){K.end();return}let J=G.body.getReader();for(;;){let{done:Q,value:X}=await J.read();if(Q)break;K.write(X)}K.end()}function M(G,K={}){let J=K.port??Number(process.env.PORT??8080),Q=K.hostname??"0.0.0.0",X=j((Y,Z)=>{let $=`http://${Y.headers.host??`${Q}:${J}`}`;G.handleRequest(z(Y,$),K.env).then((C)=>I(C,Z)).catch(()=>{Z.statusCode=500,Z.end(JSON.stringify({error:"internal_error"}))})});return X.listen(J,Q),X}var L=1;function N(G=process.env){let K=G.BUNDLE_URL?.trim(),J=G.BUNDLE_SHA256?.trim();if(!K)throw Error("BUNDLE_URL is not set; the runtime host has no code to run.");if(!J)throw Error("BUNDLE_SHA256 is not set; refusing to boot unverified code.");let Q=Number(G.PORT??8080);if(!Number.isInteger(Q)||Q<=0)throw Error(`Invalid PORT: ${String(G.PORT)}`);return{bundleUrl:K,bundleSha256:J,port:Q}}async function B(G){let K=G.buffer.slice(G.byteOffset,G.byteOffset+G.byteLength),J=await crypto.subtle.digest("SHA-256",K);return Array.from(new Uint8Array(J)).map((Q)=>Q.toString(16).padStart(2,"0")).join("")}function D(G){let K=JSON.parse(new TextDecoder().decode(G));if(!K||typeof K!=="object")throw Error("Boot artifact must be a JSON object.");let J=K;if(J.schemaVersion!==L)throw Error(`Unsupported boot artifact schemaVersion: ${String(J.schemaVersion)}.`);if(typeof J.runtimeVersion!=="string"||typeof J.mainEntry!=="string"||!Array.isArray(J.files))throw Error("Boot artifact is malformed.");let Q=J.files.map((X)=>{if(!X||typeof X!=="object"||typeof X.path!=="string"||typeof X.content!=="string")throw Error("Boot artifact files must be { path, content }.");let Y=X;return{path:Y.path,content:Y.content}});return{schemaVersion:L,runtimeVersion:J.runtimeVersion,mainEntry:J.mainEntry,files:Q}}async function V(G,K=fetch){let J=await K(G.bundleUrl);if(!J.ok)throw Error(`Bundle fetch failed (HTTP ${J.status}).`);let Q=new Uint8Array(await J.arrayBuffer()),X=await B(Q);if(X!==G.bundleSha256.toLowerCase())throw Error(`Bundle sha256 mismatch (expected ${G.bundleSha256}, got ${X}).`);return D(Q)}function W(G,K){for(let J of G.files){let Q=F(K,J.path);O(H(Q),{recursive:!0}),_(Q,J.content)}return{entryPath:F(K,G.mainEntry)}}async function U(G={}){let K=G.bootConfig??N(),J=await V(K,G.fetchImpl),Q=G.workDir??P(F(E(),"mcpcloud-server-")),{entryPath:X}=W(J,Q),Y=await import(A(X).href),Z=Y.server??Y.default;if(!Z)throw Error(`Boot module ${J.mainEntry} does not export a \`server\`.`);let $={port:K.port,...G.hostname?{hostname:G.hostname}:{},...G.env?{env:G.env}:{}};return M(Z,$)}export{U as serveFromBundle,N as resolveBootConfig,W as materializeBundle,V as fetchAndVerifyBundle,L as BOOT_ARTIFACT_SCHEMA_VERSION};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @mcpcloud/runtime v0.1.
|
|
1
|
+
/*! @mcpcloud/runtime v0.1.2 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
|
|
2
2
|
var qq=Object.create;var{getPrototypeOf:Aq,defineProperty:vX,getOwnPropertyNames:Mq}=Object;var jq=Object.prototype.hasOwnProperty;var S5=($,U,v)=>{v=$!=null?qq(Aq($)):{};let D=U||!$||!$.__esModule?vX(v,"default",{value:$,enumerable:!0}):v;for(let J of Mq($))if(!jq.call(D,J))vX(D,J,{get:()=>$[J],enumerable:!0});return D};var T=($,U)=>()=>(U||$((U={exports:{}}).exports,U),U.exports);var q4=($,U)=>{for(var v in U)vX($,v,{get:U[v],enumerable:!0,configurable:!0,set:(D)=>U[v]=()=>D})};var U0=T((gL)=>{Object.defineProperty(gL,"__esModule",{value:!0});gL.regexpCode=gL.getEsmExportName=gL.getProperty=gL.safeStringify=gL.stringify=gL.strConcat=gL.addCodeArg=gL.str=gL._=gL.nil=gL._Code=gL.Name=gL.IDENTIFIER=gL._CodeOrName=void 0;class LW{}gL._CodeOrName=LW;gL.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class bU extends LW{constructor($){super();if(!gL.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}}}gL.Name=bU;class R4 extends LW{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,v)=>`${U}${v}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((U,v)=>{if(v instanceof bU)U[v.str]=(U[v.str]||0)+1;return U},{})}}gL._Code=R4;gL.nil=new R4("");function ZL($,...U){let v=[$[0]],D=0;while(D<U.length)NH(v,U[D]),v.push($[++D]);return new R4(v)}gL._=ZL;var OH=new R4("+");function TL($,...U){let v=[$0($[0])],D=0;while(D<U.length)v.push(OH),NH(v,U[D]),v.push(OH,$0($[++D]));return jR(v),new R4(v)}gL.str=TL;function NH($,U){if(U instanceof R4)$.push(...U._items);else if(U instanceof bU)$.push(U);else $.push(PR(U))}gL.addCodeArg=NH;function jR($){let U=1;while(U<$.length-1){if($[U]===OH){let v=ER($[U-1],$[U+1]);if(v!==void 0){$.splice(U-1,3,v);continue}$[U++]="+"}U++}}function ER($,U){if(U==='""')return $;if($==='""')return U;if(typeof $=="string"){if(U instanceof bU||$[$.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 bU))return`"${$}${U.slice(1)}`;return}function SR($,U){return U.emptyStr()?$:$.emptyStr()?U:TL`${$}${U}`}gL.strConcat=SR;function PR($){return typeof $=="number"||typeof $=="boolean"||$===null?$:$0(Array.isArray($)?$.join(","):$)}function RR($){return new R4($0($))}gL.stringify=RR;function $0($){return JSON.stringify($).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}gL.safeStringify=$0;function _R($){return typeof $=="string"&&gL.IDENTIFIER.test($)?new R4(`.${$}`):ZL`[${$}]`}gL.getProperty=_R;function kR($){if(typeof $=="string"&&gL.IDENTIFIER.test($))return new R4(`${$}`);throw Error(`CodeGen: invalid export name: ${$}, use explicit $id name mapping`)}gL.getEsmExportName=kR;function CR($){return new R4($.toString())}gL.regexpCode=CR});var VH=T((fL)=>{Object.defineProperty(fL,"__esModule",{value:!0});fL.ValueScope=fL.ValueScopeName=fL.Scope=fL.varKinds=fL.UsedValueState=void 0;var D4=U0();class uL extends Error{constructor($){super(`CodeGen: "code" for ${$} not defined`);this.value=$.value}}var IW;(function($){$[$.Started=0]="Started",$[$.Completed=1]="Completed"})(IW||(fL.UsedValueState=IW={}));fL.varKinds={const:new D4.Name("const"),let:new D4.Name("let"),var:new D4.Name("var")};class KH{constructor({prefixes:$,parent:U}={}){this._names={},this._prefixes=$,this._parent=U}toName($){return $ instanceof D4.Name?$:this.name($)}name($){return new D4.Name(this._newName($))}_newName($){let U=this._names[$]||this._nameGroup($);return`${$}${U.index++}`}_nameGroup($){var U,v;if(((v=(U=this._parent)===null||U===void 0?void 0:U._prefixes)===null||v===void 0?void 0:v.has($))||this._prefixes&&!this._prefixes.has($))throw Error(`CodeGen: prefix "${$}" is not allowed in this scope`);return this._names[$]={prefix:$,index:0}}}fL.Scope=KH;class IH extends D4.Name{constructor($,U){super(U);this.prefix=$}setValue($,{property:U,itemIndex:v}){this.value=$,this.scopePath=D4._`.${new D4.Name(U)}[${v}]`}}fL.ValueScopeName=IH;var rR=D4._`\n`;class yL extends KH{constructor($){super($);this._values={},this._scope=$.scope,this.opts={...$,_n:$.lines?rR:D4.nil}}get(){return this._scope}name($){return new IH($,this._newName($))}value($,U){var v;if(U.ref===void 0)throw Error("CodeGen: ref must be passed in value");let D=this.toName($),{prefix:J}=D,W=(v=U.key)!==null&&v!==void 0?v:U.ref,X=this._values[J];if(X){let z=X.get(W);if(z)return z}else X=this._values[J]=new Map;X.set(W,D);let G=this._scope[J]||(this._scope[J]=[]),Q=G.length;return G[Q]=U.ref,D.setValue(U,{property:J,itemIndex:Q}),D}getValue($,U){let v=this._values[$];if(!v)return;return v.get(U)}scopeRefs($,U=this._values){return this._reduceValues(U,(v)=>{if(v.scopePath===void 0)throw Error(`CodeGen: name "${v}" has no value`);return D4._`${$}${v.scopePath}`})}scopeCode($=this._values,U,v){return this._reduceValues($,(D)=>{if(D.value===void 0)throw Error(`CodeGen: name "${D}" has no value`);return D.value.code},U,v)}_reduceValues($,U,v={},D){let J=D4.nil;for(let W in $){let X=$[W];if(!X)continue;let G=v[W]=v[W]||new Map;X.forEach((Q)=>{if(G.has(Q))return;G.set(Q,IW.Started);let z=U(Q);if(z){let Y=this.opts.es5?fL.varKinds.var:fL.varKinds.const;J=D4._`${J}${Y} ${Q} = ${z};${this.opts._n}`}else if(z=D===null||D===void 0?void 0:D(Q))J=D4._`${J}${z}${this.opts._n}`;else throw new uL(Q);G.set(Q,IW.Completed)})}return J}}fL.ValueScope=yL});var e=T((W4)=>{Object.defineProperty(W4,"__esModule",{value:!0});W4.or=W4.and=W4.not=W4.CodeGen=W4.operators=W4.varKinds=W4.ValueScopeName=W4.ValueScope=W4.Scope=W4.Name=W4.regexpCode=W4.stringify=W4.getProperty=W4.nil=W4.strConcat=W4.str=W4._=void 0;var D$=U0(),_4=VH(),Z6=U0();Object.defineProperty(W4,"_",{enumerable:!0,get:function(){return Z6._}});Object.defineProperty(W4,"str",{enumerable:!0,get:function(){return Z6.str}});Object.defineProperty(W4,"strConcat",{enumerable:!0,get:function(){return Z6.strConcat}});Object.defineProperty(W4,"nil",{enumerable:!0,get:function(){return Z6.nil}});Object.defineProperty(W4,"getProperty",{enumerable:!0,get:function(){return Z6.getProperty}});Object.defineProperty(W4,"stringify",{enumerable:!0,get:function(){return Z6.stringify}});Object.defineProperty(W4,"regexpCode",{enumerable:!0,get:function(){return Z6.regexpCode}});Object.defineProperty(W4,"Name",{enumerable:!0,get:function(){return Z6.Name}});var jW=VH();Object.defineProperty(W4,"Scope",{enumerable:!0,get:function(){return jW.Scope}});Object.defineProperty(W4,"ValueScope",{enumerable:!0,get:function(){return jW.ValueScope}});Object.defineProperty(W4,"ValueScopeName",{enumerable:!0,get:function(){return jW.ValueScopeName}});Object.defineProperty(W4,"varKinds",{enumerable:!0,get:function(){return jW.varKinds}});W4.operators={GT:new D$._Code(">"),GTE:new D$._Code(">="),LT:new D$._Code("<"),LTE:new D$._Code("<="),EQ:new D$._Code("==="),NEQ:new D$._Code("!=="),NOT:new D$._Code("!"),OR:new D$._Code("||"),AND:new D$._Code("&&"),ADD:new D$._Code("+")};class T6{optimizeNodes(){return this}optimizeNames($,U){return this}}class lL extends T6{constructor($,U,v){super();this.varKind=$,this.name=U,this.rhs=v}render({es5:$,_n:U}){let v=$?_4.varKinds.var:this.varKind,D=this.rhs===void 0?"":` = ${this.rhs}`;return`${v} ${this.name}${D};`+U}optimizeNames($,U){if(!$[this.name.str])return;if(this.rhs)this.rhs=OU(this.rhs,$,U);return this}get names(){return this.rhs instanceof D$._CodeOrName?this.rhs.names:{}}}class AH extends T6{constructor($,U,v){super();this.lhs=$,this.rhs=U,this.sideEffects=v}render({_n:$}){return`${this.lhs} = ${this.rhs};`+$}optimizeNames($,U){if(this.lhs instanceof D$.Name&&!$[this.lhs.str]&&!this.sideEffects)return;return this.rhs=OU(this.rhs,$,U),this}get names(){let $=this.lhs instanceof D$.Name?{}:{...this.lhs.names};return MW($,this.rhs)}}class mL extends AH{constructor($,U,v,D){super($,v,D);this.op=U}render({_n:$}){return`${this.lhs} ${this.op}= ${this.rhs};`+$}}class cL extends T6{constructor($){super();this.label=$,this.names={}}render({_n:$}){return`${this.label}:`+$}}class iL extends T6{constructor($){super();this.label=$,this.names={}}render({_n:$}){return`break${this.label?` ${this.label}`:""};`+$}}class rL extends T6{constructor($){super();this.error=$}render({_n:$}){return`throw ${this.error};`+$}get names(){return this.error.names}}class nL extends T6{constructor($){super();this.code=$}render({_n:$}){return`${this.code};`+$}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames($,U){return this.code=OU(this.code,$,U),this}get names(){return this.code instanceof D$._CodeOrName?this.code.names:{}}}class EW extends T6{constructor($=[]){super();this.nodes=$}render($){return this.nodes.reduce((U,v)=>U+v.render($),"")}optimizeNodes(){let{nodes:$}=this,U=$.length;while(U--){let v=$[U].optimizeNodes();if(Array.isArray(v))$.splice(U,1,...v);else if(v)$[U]=v;else $.splice(U,1)}return $.length>0?this:void 0}optimizeNames($,U){let{nodes:v}=this,D=v.length;while(D--){let J=v[D];if(J.optimizeNames($,U))continue;dR($,J.names),v.splice(D,1)}return v.length>0?this:void 0}get names(){return this.nodes.reduce(($,U)=>Q1($,U.names),{})}}class g6 extends EW{render($){return"{"+$._n+super.render($)+"}"+$._n}}class oL extends EW{}class v0 extends g6{}v0.kind="else";class G6 extends g6{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 v=U.optimizeNodes();U=this.else=Array.isArray(v)?new v0(v):v}if(U){if($===!1)return U instanceof G6?U:U.nodes;if(this.nodes.length)return this;return new G6(eL($),U instanceof G6?[U]:U.nodes)}if($===!1||!this.nodes.length)return;return this}optimizeNames($,U){var v;if(this.else=(v=this.else)===null||v===void 0?void 0:v.optimizeNames($,U),!(super.optimizeNames($,U)||this.else))return;return this.condition=OU(this.condition,$,U),this}get names(){let $=super.names;if(MW($,this.condition),this.else)Q1($,this.else.names);return $}}G6.kind="if";class BU extends g6{}BU.kind="for";class pL extends BU{constructor($){super();this.iteration=$}render($){return`for(${this.iteration})`+super.render($)}optimizeNames($,U){if(!super.optimizeNames($,U))return;return this.iteration=OU(this.iteration,$,U),this}get names(){return Q1(super.names,this.iteration.names)}}class dL extends BU{constructor($,U,v,D){super();this.varKind=$,this.name=U,this.from=v,this.to=D}render($){let U=$.es5?_4.varKinds.var:this.varKind,{name:v,from:D,to:J}=this;return`for(${U} ${v}=${D}; ${v}<${J}; ${v}++)`+super.render($)}get names(){let $=MW(super.names,this.from);return MW($,this.to)}}class FH extends BU{constructor($,U,v,D){super();this.loop=$,this.varKind=U,this.name=v,this.iterable=D}render($){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render($)}optimizeNames($,U){if(!super.optimizeNames($,U))return;return this.iterable=OU(this.iterable,$,U),this}get names(){return Q1(super.names,this.iterable.names)}}class VW extends g6{constructor($,U,v){super();this.name=$,this.args=U,this.async=v}render($){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render($)}}VW.kind="func";class FW extends EW{render($){return"return "+super.render($)}}FW.kind="return";class tL extends g6{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 v,D;return super.optimizeNames($,U),(v=this.catch)===null||v===void 0||v.optimizeNames($,U),(D=this.finally)===null||D===void 0||D.optimizeNames($,U),this}get names(){let $=super.names;if(this.catch)Q1($,this.catch.names);if(this.finally)Q1($,this.finally.names);return $}}class qW extends g6{constructor($){super();this.error=$}render($){return`catch(${this.error})`+super.render($)}}qW.kind="catch";class AW extends g6{render($){return"finally"+super.render($)}}AW.kind="finally";class aL{constructor($,U={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...U,_n:U.lines?`
|
|
3
3
|
`:""},this._extScope=$,this._scope=new _4.Scope({parent:$}),this._nodes=[new oL]}toString(){return this._root.render(this.opts)}name($){return this._scope.name($)}scopeName($){return this._extScope.name($)}scopeValue($,U){let v=this._extScope.value($,U);return(this._values[v.prefix]||(this._values[v.prefix]=new Set)).add(v),v}getScopeValue($,U){return this._extScope.getValue($,U)}scopeRefs($){return this._extScope.scopeRefs($,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def($,U,v,D){let J=this._scope.toName(U);if(v!==void 0&&D)this._constants[J.str]=v;return this._leafNode(new lL($,J,v)),J}const($,U,v){return this._def(_4.varKinds.const,$,U,v)}let($,U,v){return this._def(_4.varKinds.let,$,U,v)}var($,U,v){return this._def(_4.varKinds.var,$,U,v)}assign($,U,v){return this._leafNode(new AH($,U,v))}add($,U){return this._leafNode(new mL($,W4.operators.ADD,U))}code($){if(typeof $=="function")$();else if($!==D$.nil)this._leafNode(new nL($));return this}object(...$){let U=["{"];for(let[v,D]of $){if(U.length>1)U.push(",");if(U.push(v),v!==D||this.opts.es5)U.push(":"),(0,D$.addCodeArg)(U,D)}return U.push("}"),new D$._Code(U)}if($,U,v){if(this._blockNode(new G6($)),U&&v)this.code(U).else().code(v).endIf();else if(U)this.code(U).endIf();else if(v)throw Error('CodeGen: "else" body without "then" body');return this}elseIf($){return this._elseNode(new G6($))}else(){return this._elseNode(new v0)}endIf(){return this._endBlockNode(G6,v0)}_for($,U){if(this._blockNode($),U)this.code(U).endFor();return this}for($,U){return this._for(new pL($),U)}forRange($,U,v,D,J=this.opts.es5?_4.varKinds.var:_4.varKinds.let){let W=this._scope.toName($);return this._for(new dL(J,W,U,v),()=>D(W))}forOf($,U,v,D=_4.varKinds.const){let J=this._scope.toName($);if(this.opts.es5){let W=U instanceof D$.Name?U:this.var("_arr",U);return this.forRange("_i",0,D$._`${W}.length`,(X)=>{this.var(J,D$._`${W}[${X}]`),v(J)})}return this._for(new FH("of",D,J,U),()=>v(J))}forIn($,U,v,D=this.opts.es5?_4.varKinds.var:_4.varKinds.const){if(this.opts.ownProperties)return this.forOf($,D$._`Object.keys(${U})`,v);let J=this._scope.toName($);return this._for(new FH("in",D,J,U),()=>v(J))}endFor(){return this._endBlockNode(BU)}label($){return this._leafNode(new cL($))}break($){return this._leafNode(new iL($))}return($){let U=new FW;if(this._blockNode(U),this.code($),U.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(FW)}try($,U,v){if(!U&&!v)throw Error('CodeGen: "try" without "catch" and "finally"');let D=new tL;if(this._blockNode(D),this.code($),U){let J=this.name("e");this._currNode=D.catch=new qW(J),U(J)}if(v)this._currNode=D.finally=new AW,this.code(v);return this._endBlockNode(qW,AW)}throw($){return this._leafNode(new rL($))}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 v=this._nodes.length-U;if(v<0||$!==void 0&&v!==$)throw Error(`CodeGen: wrong number of nodes: ${v} vs ${$} expected`);return this._nodes.length=U,this}func($,U=D$.nil,v,D){if(this._blockNode(new VW($,U,v)),D)this.code(D).endFunc();return this}endFunc(){return this._endBlockNode(VW)}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 v=this._currNode;if(v instanceof $||U&&v 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 G6))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]=$}}W4.CodeGen=aL;function Q1($,U){for(let v in U)$[v]=($[v]||0)+(U[v]||0);return $}function MW($,U){return U instanceof D$._CodeOrName?Q1($,U.names):$}function OU($,U,v){if($ instanceof D$.Name)return D($);if(!J($))return $;return new D$._Code($._items.reduce((W,X)=>{if(X instanceof D$.Name)X=D(X);if(X instanceof D$._Code)W.push(...X._items);else W.push(X);return W},[]));function D(W){let X=v[W.str];if(X===void 0||U[W.str]!==1)return W;return delete U[W.str],X}function J(W){return W instanceof D$._Code&&W._items.some((X)=>X instanceof D$.Name&&U[X.str]===1&&v[X.str]!==void 0)}}function dR($,U){for(let v in U)$[v]=($[v]||0)-(U[v]||0)}function eL($){return typeof $=="boolean"||typeof $=="number"||$===null?!$:D$._`!${qH($)}`}W4.not=eL;var tR=sL(W4.operators.AND);function aR(...$){return $.reduce(tR)}W4.and=aR;var eR=sL(W4.operators.OR);function sR(...$){return $.reduce(eR)}W4.or=sR;function sL($){return(U,v)=>U===D$.nil?v:v===D$.nil?U:D$._`${qH(U)} ${$} ${qH(v)}`}function qH($){return $ instanceof D$.Name?$:D$._`(${$})`}});var X$=T((QK)=>{Object.defineProperty(QK,"__esModule",{value:!0});QK.checkStrictMode=QK.getErrorPath=QK.Type=QK.useFunc=QK.setEvaluated=QK.evaluatedPropsToName=QK.mergeEvaluated=QK.eachItem=QK.unescapeJsonPointer=QK.escapeJsonPointer=QK.escapeFragment=QK.unescapeFragment=QK.schemaRefOrVal=QK.schemaHasRulesButRef=QK.schemaHasRules=QK.checkUnknownRules=QK.alwaysValidSchema=QK.toHash=void 0;var L$=e(),J_=U0();function D_($){let U={};for(let v of $)U[v]=!0;return U}QK.toHash=D_;function W_($,U){if(typeof U=="boolean")return U;if(Object.keys(U).length===0)return!0;return JK($,U),!DK(U,$.self.RULES.all)}QK.alwaysValidSchema=W_;function JK($,U=$.schema){let{opts:v,self:D}=$;if(!v.strictSchema)return;if(typeof U==="boolean")return;let J=D.RULES.keywords;for(let W in U)if(!J[W])GK($,`unknown keyword: "${W}"`)}QK.checkUnknownRules=JK;function DK($,U){if(typeof $=="boolean")return!$;for(let v in $)if(U[v])return!0;return!1}QK.schemaHasRules=DK;function X_($,U){if(typeof $=="boolean")return!$;for(let v in $)if(v!=="$ref"&&U.all[v])return!0;return!1}QK.schemaHasRulesButRef=X_;function G_({topSchemaRef:$,schemaPath:U},v,D,J){if(!J){if(typeof v=="number"||typeof v=="boolean")return v;if(typeof v=="string")return L$._`${v}`}return L$._`${$}${U}${(0,L$.getProperty)(D)}`}QK.schemaRefOrVal=G_;function Q_($){return WK(decodeURIComponent($))}QK.unescapeFragment=Q_;function z_($){return encodeURIComponent(jH($))}QK.escapeFragment=z_;function jH($){if(typeof $=="number")return`${$}`;return $.replace(/~/g,"~0").replace(/\//g,"~1")}QK.escapeJsonPointer=jH;function WK($){return $.replace(/~1/g,"/").replace(/~0/g,"~")}QK.unescapeJsonPointer=WK;function Y_($,U){if(Array.isArray($))for(let v of $)U(v);else U($)}QK.eachItem=Y_;function UK({mergeNames:$,mergeToName:U,mergeValues:v,resultToName:D}){return(J,W,X,G)=>{let Q=X===void 0?W:X instanceof L$.Name?(W instanceof L$.Name?$(J,W,X):U(J,W,X),X):W instanceof L$.Name?(U(J,X,W),W):v(W,X);return G===L$.Name&&!(Q instanceof L$.Name)?D(J,Q):Q}}QK.mergeEvaluated={props:UK({mergeNames:($,U,v)=>$.if(L$._`${v} !== true && ${U} !== undefined`,()=>{$.if(L$._`${U} === true`,()=>$.assign(v,!0),()=>$.assign(v,L$._`${v} || {}`).code(L$._`Object.assign(${v}, ${U})`))}),mergeToName:($,U,v)=>$.if(L$._`${v} !== true`,()=>{if(U===!0)$.assign(v,!0);else $.assign(v,L$._`${v} || {}`),EH($,v,U)}),mergeValues:($,U)=>$===!0?!0:{...$,...U},resultToName:XK}),items:UK({mergeNames:($,U,v)=>$.if(L$._`${v} !== true && ${U} !== undefined`,()=>$.assign(v,L$._`${U} === true ? true : ${v} > ${U} ? ${v} : ${U}`)),mergeToName:($,U,v)=>$.if(L$._`${v} !== true`,()=>$.assign(v,U===!0?!0:L$._`${v} > ${U} ? ${v} : ${U}`)),mergeValues:($,U)=>$===!0?!0:Math.max($,U),resultToName:($,U)=>$.var("items",U)})};function XK($,U){if(U===!0)return $.var("props",!0);let v=$.var("props",L$._`{}`);if(U!==void 0)EH($,v,U);return v}QK.evaluatedPropsToName=XK;function EH($,U,v){Object.keys(v).forEach((D)=>$.assign(L$._`${U}${(0,L$.getProperty)(D)}`,!0))}QK.setEvaluated=EH;var vK={};function H_($,U){return $.scopeValue("func",{ref:U,code:vK[U.code]||(vK[U.code]=new J_._Code(U.code))})}QK.useFunc=H_;var MH;(function($){$[$.Num=0]="Num",$[$.Str=1]="Str"})(MH||(QK.Type=MH={}));function w_($,U,v){if($ instanceof L$.Name){let D=U===MH.Num;return v?D?L$._`"[" + ${$} + "]"`:L$._`"['" + ${$} + "']"`:D?L$._`"/" + ${$}`:L$._`"/" + ${$}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return v?(0,L$.getProperty)($).toString():"/"+jH($)}QK.getErrorPath=w_;function GK($,U,v=$.opts.strictSchema){if(!v)return;if(U=`strict mode: ${U}`,v===!0)throw Error(U);$.self.logger.warn(U)}QK.checkStrictMode=GK});var Q6=T((YK)=>{Object.defineProperty(YK,"__esModule",{value:!0});var c$=e(),__={data:new c$.Name("data"),valCxt:new c$.Name("valCxt"),instancePath:new c$.Name("instancePath"),parentData:new c$.Name("parentData"),parentDataProperty:new c$.Name("parentDataProperty"),rootData:new c$.Name("rootData"),dynamicAnchors:new c$.Name("dynamicAnchors"),vErrors:new c$.Name("vErrors"),errors:new c$.Name("errors"),this:new c$.Name("this"),self:new c$.Name("self"),scope:new c$.Name("scope"),json:new c$.Name("json"),jsonPos:new c$.Name("jsonPos"),jsonLen:new c$.Name("jsonLen"),jsonPart:new c$.Name("jsonPart")};YK.default=__});var J0=T((BK)=>{Object.defineProperty(BK,"__esModule",{value:!0});BK.extendErrors=BK.resetErrorsCount=BK.reportExtraError=BK.reportError=BK.keyword$DataError=BK.keywordError=void 0;var G$=e(),PW=X$(),e$=Q6();BK.keywordError={message:({keyword:$})=>G$.str`must pass "${$}" keyword validation`};BK.keyword$DataError={message:({keyword:$,schemaType:U})=>U?G$.str`"${$}" keyword must be ${U} ($data)`:G$.str`"${$}" keyword is invalid ($data)`};function C_($,U=BK.keywordError,v,D){let{it:J}=$,{gen:W,compositeRule:X,allErrors:G}=J,Q=bK($,U,v);if(D!==null&&D!==void 0?D:X||G)HK(W,Q);else wK(J,G$._`[${Q}]`)}BK.reportError=C_;function Z_($,U=BK.keywordError,v){let{it:D}=$,{gen:J,compositeRule:W,allErrors:X}=D,G=bK($,U,v);if(HK(J,G),!(W||X))wK(D,e$.default.vErrors)}BK.reportExtraError=Z_;function T_($,U){$.assign(e$.default.errors,U),$.if(G$._`${e$.default.vErrors} !== null`,()=>$.if(U,()=>$.assign(G$._`${e$.default.vErrors}.length`,U),()=>$.assign(e$.default.vErrors,null)))}BK.resetErrorsCount=T_;function g_({gen:$,keyword:U,schemaValue:v,data:D,errsCount:J,it:W}){if(J===void 0)throw Error("ajv implementation error");let X=$.name("err");$.forRange("i",J,e$.default.errors,(G)=>{if($.const(X,G$._`${e$.default.vErrors}[${G}]`),$.if(G$._`${X}.instancePath === undefined`,()=>$.assign(G$._`${X}.instancePath`,(0,G$.strConcat)(e$.default.instancePath,W.errorPath))),$.assign(G$._`${X}.schemaPath`,G$.str`${W.errSchemaPath}/${U}`),W.opts.verbose)$.assign(G$._`${X}.schema`,v),$.assign(G$._`${X}.data`,D)})}BK.extendErrors=g_;function HK($,U){let v=$.const("err",U);$.if(G$._`${e$.default.vErrors} === null`,()=>$.assign(e$.default.vErrors,G$._`[${v}]`),G$._`${e$.default.vErrors}.push(${v})`),$.code(G$._`${e$.default.errors}++`)}function wK($,U){let{gen:v,validateName:D,schemaEnv:J}=$;if(J.$async)v.throw(G$._`new ${$.ValidationError}(${U})`);else v.assign(G$._`${D}.errors`,U),v.return(!1)}var z1={keyword:new G$.Name("keyword"),schemaPath:new G$.Name("schemaPath"),params:new G$.Name("params"),propertyName:new G$.Name("propertyName"),message:new G$.Name("message"),schema:new G$.Name("schema"),parentSchema:new G$.Name("parentSchema")};function bK($,U,v){let{createErrors:D}=$.it;if(D===!1)return G$._`{}`;return x_($,U,v)}function x_($,U,v={}){let{gen:D,it:J}=$,W=[u_(J,v),y_($,v)];return f_($,U,W),D.object(...W)}function u_({errorPath:$},{instancePath:U}){let v=U?G$.str`${$}${(0,PW.getErrorPath)(U,PW.Type.Str)}`:$;return[e$.default.instancePath,(0,G$.strConcat)(e$.default.instancePath,v)]}function y_({keyword:$,it:{errSchemaPath:U}},{schemaPath:v,parentSchema:D}){let J=D?U:G$.str`${U}/${$}`;if(v)J=G$.str`${J}${(0,PW.getErrorPath)(v,PW.Type.Str)}`;return[z1.schemaPath,J]}function f_($,{params:U,message:v},D){let{keyword:J,data:W,schemaValue:X,it:G}=$,{opts:Q,propertyName:z,topSchemaRef:Y,schemaPath:H}=G;if(D.push([z1.keyword,J],[z1.params,typeof U=="function"?U($):U||G$._`{}`]),Q.messages)D.push([z1.message,typeof v=="function"?v($):v]);if(Q.verbose)D.push([z1.schema,X],[z1.parentSchema,G$._`${Y}${H}`],[e$.default.data,W]);if(z)D.push([z1.propertyName,z])}});var IK=T((LK)=>{Object.defineProperty(LK,"__esModule",{value:!0});LK.boolOrEmptySchema=LK.topBoolOrEmptySchema=void 0;var i_=J0(),r_=e(),n_=Q6(),o_={message:"boolean schema is false"};function p_($){let{gen:U,schema:v,validateName:D}=$;if(v===!1)NK($,!1);else if(typeof v=="object"&&v.$async===!0)U.return(n_.default.data);else U.assign(r_._`${D}.errors`,null),U.return(!0)}LK.topBoolOrEmptySchema=p_;function d_($,U){let{gen:v,schema:D}=$;if(D===!1)v.var(U,!1),NK($);else v.var(U,!0)}LK.boolOrEmptySchema=d_;function NK($,U){let{gen:v,data:D}=$,J={gen:v,keyword:"false schema",data:D,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:$};(0,i_.reportError)(J,o_,void 0,U)}});var PH=T((VK)=>{Object.defineProperty(VK,"__esModule",{value:!0});VK.getRules=VK.isJSONType=void 0;var a_=["string","number","integer","boolean","null","object","array"],e_=new Set(a_);function s_($){return typeof $=="string"&&e_.has($)}VK.isJSONType=s_;function $k(){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:{}}}VK.getRules=$k});var RH=T((MK)=>{Object.defineProperty(MK,"__esModule",{value:!0});MK.shouldUseRule=MK.shouldUseGroup=MK.schemaHasRulesForType=void 0;function vk({schema:$,self:U},v){let D=U.RULES.types[v];return D&&D!==!0&&qK($,D)}MK.schemaHasRulesForType=vk;function qK($,U){return U.rules.some((v)=>AK($,v))}MK.shouldUseGroup=qK;function AK($,U){var v;return $[U.keyword]!==void 0||((v=U.definition.implements)===null||v===void 0?void 0:v.some((D)=>$[D]!==void 0))}MK.shouldUseRule=AK});var D0=T((RK)=>{Object.defineProperty(RK,"__esModule",{value:!0});RK.reportTypeError=RK.checkDataTypes=RK.checkDataType=RK.coerceAndCheckDataType=RK.getJSONTypes=RK.getSchemaTypes=RK.DataType=void 0;var Wk=PH(),Xk=RH(),Gk=J0(),a=e(),EK=X$(),NU;(function($){$[$.Correct=0]="Correct",$[$.Wrong=1]="Wrong"})(NU||(RK.DataType=NU={}));function Qk($){let U=SK($.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}RK.getSchemaTypes=Qk;function SK($){let U=Array.isArray($)?$:$?[$]:[];if(U.every(Wk.isJSONType))return U;throw Error("type must be JSONType or JSONType[]: "+U.join(","))}RK.getJSONTypes=SK;function zk($,U){let{gen:v,data:D,opts:J}=$,W=Yk(U,J.coerceTypes),X=U.length>0&&!(W.length===0&&U.length===1&&(0,Xk.schemaHasRulesForType)($,U[0]));if(X){let G=kH(U,D,J.strictNumbers,NU.Wrong);v.if(G,()=>{if(W.length)Hk($,U,W);else CH($)})}return X}RK.coerceAndCheckDataType=zk;var PK=new Set(["string","number","integer","boolean","null"]);function Yk($,U){return U?$.filter((v)=>PK.has(v)||U==="array"&&v==="array"):[]}function Hk($,U,v){let{gen:D,data:J,opts:W}=$,X=D.let("dataType",a._`typeof ${J}`),G=D.let("coerced",a._`undefined`);if(W.coerceTypes==="array")D.if(a._`${X} == 'object' && Array.isArray(${J}) && ${J}.length == 1`,()=>D.assign(J,a._`${J}[0]`).assign(X,a._`typeof ${J}`).if(kH(U,J,W.strictNumbers),()=>D.assign(G,J)));D.if(a._`${G} !== undefined`);for(let z of v)if(PK.has(z)||z==="array"&&W.coerceTypes==="array")Q(z);D.else(),CH($),D.endIf(),D.if(a._`${G} !== undefined`,()=>{D.assign(J,G),wk($,G)});function Q(z){switch(z){case"string":D.elseIf(a._`${X} == "number" || ${X} == "boolean"`).assign(G,a._`"" + ${J}`).elseIf(a._`${J} === null`).assign(G,a._`""`);return;case"number":D.elseIf(a._`${X} == "boolean" || ${J} === null
|
|
4
4
|
|| (${X} == "string" && ${J} && ${J} == +${J})`).assign(G,a._`+${J}`);return;case"integer":D.elseIf(a._`${X} === "boolean" || ${J} === null
|
package/dist/node.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @mcpcloud/runtime v0.1.
|
|
1
|
+
/*! @mcpcloud/runtime v0.1.2 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
|
|
2
2
|
import{createServer as E}from"node:http";import{Readable as F}from"node:stream";function G(x,f){let k=new URL(x.url??"/",f),O=new Headers;for(let[z,A]of Object.entries(x.headers))if(Array.isArray(A))for(let D of A)O.append(z,D);else if(typeof A==="string")O.set(z,A);let j=x.method??"GET",C=j==="GET"||j==="HEAD"?void 0:F.toWeb(x);return new Request(k,{method:j,headers:O,body:C,...C?{duplex:"half"}:{}})}async function I(x,f){if(f.statusCode=x.status,x.headers.forEach((O,j)=>{f.setHeader(j,O)}),!x.body){f.end();return}let k=x.body.getReader();for(;;){let{done:O,value:j}=await k.read();if(O)break;f.write(j)}f.end()}function J(x,f={}){let k=f.port??Number(process.env.PORT??8080),O=f.hostname??"0.0.0.0",j=E((C,z)=>{let A=`http://${C.headers.host??`${O}:${k}`}`;x.handleRequest(G(C,A),f.env).then((D)=>I(D,z)).catch(()=>{z.statusCode=500,z.end(JSON.stringify({error:"internal_error"}))})});return j.listen(k,O),j}export{J as serve};
|
package/dist/stdio.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @mcpcloud/runtime v0.1.
|
|
1
|
+
/*! @mcpcloud/runtime v0.1.2 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
|
|
2
2
|
var T4=Object.defineProperty;var YY=(W,Q)=>{for(var Y in Q)T4(W,Y,{get:Q[Y],enumerable:!0,configurable:!0,set:(X)=>Q[Y]=()=>X})};import E4 from"node:process";var X2=Object.freeze({status:"aborted"});function K(W,Q,Y){function X(w,q){if(!w._zod)Object.defineProperty(w,"_zod",{value:{def:q,constr:H,traits:new Set},enumerable:!1});if(w._zod.traits.has(W))return;w._zod.traits.add(W),Q(w,q);let L=H.prototype,B=Object.keys(L);for(let z=0;z<B.length;z++){let I=B[z];if(!(I in w))w[I]=L[I].bind(w)}}let G=Y?.Parent??Object;class J extends G{}Object.defineProperty(J,"name",{value:W});function H(w){var q;let L=Y?.Parent?new J:this;X(L,w),(q=L._zod).deferred??(q.deferred=[]);for(let B of L._zod.deferred)B();return L}return Object.defineProperty(H,"init",{value:X}),Object.defineProperty(H,Symbol.hasInstance,{value:(w)=>{if(Y?.Parent&&w instanceof Y.Parent)return!0;return w?._zod?.traits?.has(W)}}),Object.defineProperty(H,"name",{value:W}),H}var G2=Symbol("zod_brand");class a extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class MW extends Error{constructor(W){super(`Encountered unidirectional transform during encode: ${W}`);this.name="ZodEncodeError"}}var vW={};function r(W){if(W)Object.assign(vW,W);return vW}var D={};YY(D,{unwrapMessage:()=>zW,uint8ArrayToHex:()=>s4,uint8ArrayToBase64url:()=>e4,uint8ArrayToBase64:()=>qY,stringifyPrimitive:()=>cW,slugify:()=>wQ,shallowClone:()=>GY,safeExtend:()=>r4,required:()=>n4,randomString:()=>c4,propertyKeyTypes:()=>qQ,promiseAllObject:()=>x4,primitiveTypes:()=>JY,prefixIssues:()=>QW,pick:()=>f4,partial:()=>d4,parsedType:()=>BQ,optionalKeys:()=>KQ,omit:()=>o4,objectClone:()=>v4,numKeys:()=>u4,nullish:()=>IW,normalizeParams:()=>U,mergeDefs:()=>s,merge:()=>p4,jsonStringifyReplacer:()=>AW,joinValues:()=>gW,issue:()=>KW,isPlainObject:()=>XW,isObject:()=>HW,hexToUint8Array:()=>a4,getSizableOrigin:()=>wY,getParsedType:()=>y4,getLengthableOrigin:()=>OW,getEnumValues:()=>UW,getElementAtPath:()=>h4,floatSafeRemainder:()=>HQ,finalizeIssue:()=>t,extend:()=>l4,escapeRegex:()=>WW,esc:()=>hW,defineLazy:()=>F,createTransparentProxy:()=>m4,cloneDef:()=>g4,clone:()=>i,cleanRegex:()=>VW,cleanEnum:()=>i4,captureStackTrace:()=>xW,cached:()=>qW,base64urlToUint8Array:()=>t4,base64ToUint8Array:()=>AY,assignProp:()=>YW,assertNotEqual:()=>Z4,assertNever:()=>j4,assertIs:()=>C4,assertEqual:()=>_4,assert:()=>k4,allowsEval:()=>AQ,aborted:()=>GW,NUMBER_FORMAT_RANGES:()=>LQ,Class:()=>KY,BIGINT_FORMAT_RANGES:()=>HY});function _4(W){return W}function Z4(W){return W}function C4(W){}function j4(W){throw Error("Unexpected value in exhaustive check")}function k4(W){}function UW(W){let Q=Object.values(W).filter((X)=>typeof X==="number");return Object.entries(W).filter(([X,G])=>Q.indexOf(+X)===-1).map(([X,G])=>G)}function gW(W,Q="|"){return W.map((Y)=>cW(Y)).join(Q)}function AW(W,Q){if(typeof Q==="bigint")return Q.toString();return Q}function qW(W){return{get value(){{let Y=W();return Object.defineProperty(this,"value",{value:Y}),Y}throw Error("cached value already set")}}}function IW(W){return W===null||W===void 0}function VW(W){let Q=W.startsWith("^")?1:0,Y=W.endsWith("$")?W.length-1:W.length;return W.slice(Q,Y)}function HQ(W,Q){let Y=(W.toString().split(".")[1]||"").length,X=Q.toString(),G=(X.split(".")[1]||"").length;if(G===0&&/\d?e-\d?/.test(X)){let q=X.match(/\d?e-(\d?)/);if(q?.[1])G=Number.parseInt(q[1])}let J=Y>G?Y:G,H=Number.parseInt(W.toFixed(J).replace(".","")),w=Number.parseInt(Q.toFixed(J).replace(".",""));return H%w/10**J}var XY=Symbol("evaluating");function F(W,Q,Y){let X=void 0;Object.defineProperty(W,Q,{get(){if(X===XY)return;if(X===void 0)X=XY,X=Y();return X},set(G){Object.defineProperty(W,Q,{value:G})},configurable:!0})}function v4(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 g4(W){return s(W._zod.def)}function h4(W,Q){if(!Q)return W;return Q.reduce((Y,X)=>Y?.[X],W)}function x4(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 c4(W=10){let Y="";for(let X=0;X<W;X++)Y+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return Y}function hW(W){return JSON.stringify(W)}function wQ(W){return W.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var xW="captureStackTrace"in Error?Error.captureStackTrace:(...W)=>{};function HW(W){return typeof W==="object"&&W!==null&&!Array.isArray(W)}var AQ=qW(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(W){return!1}});function XW(W){if(HW(W)===!1)return!1;let Q=W.constructor;if(Q===void 0)return!0;if(typeof Q!=="function")return!0;let Y=Q.prototype;if(HW(Y)===!1)return!1;if(Object.prototype.hasOwnProperty.call(Y,"isPrototypeOf")===!1)return!1;return!0}function GY(W){if(XW(W))return{...W};if(Array.isArray(W))return[...W];return W}function u4(W){let Q=0;for(let Y in W)if(Object.prototype.hasOwnProperty.call(W,Y))Q++;return Q}var y4=(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}`)}},qQ=new Set(["string","number","symbol"]),JY=new Set(["string","number","bigint","boolean","symbol","undefined"]);function WW(W){return W.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function i(W,Q,Y){let X=new W._zod.constr(Q??W._zod.def);if(!Q||Y?.parent)X._zod.parent=W;return X}function U(W){let Q=W;if(!Q)return{};if(typeof Q==="string")return{error:()=>Q};if(Q?.message!==void 0){if(Q?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");Q.error=Q.message}if(delete Q.message,typeof Q.error==="string")return{...Q,error:()=>Q.error};return Q}function m4(W){let Q;return new Proxy({},{get(Y,X,G){return Q??(Q=W()),Reflect.get(Q,X,G)},set(Y,X,G,J){return Q??(Q=W()),Reflect.set(Q,X,G,J)},has(Y,X){return Q??(Q=W()),Reflect.has(Q,X)},deleteProperty(Y,X){return Q??(Q=W()),Reflect.deleteProperty(Q,X)},ownKeys(Y){return Q??(Q=W()),Reflect.ownKeys(Q)},getOwnPropertyDescriptor(Y,X){return Q??(Q=W()),Reflect.getOwnPropertyDescriptor(Q,X)},defineProperty(Y,X,G){return Q??(Q=W()),Reflect.defineProperty(Q,X,G)}})}function cW(W){if(typeof W==="bigint")return W.toString()+"n";if(typeof W==="string")return`"${W}"`;return`${W}`}function KQ(W){return Object.keys(W).filter((Q)=>{return W[Q]._zod.optin==="optional"&&W[Q]._zod.optout==="optional"})}var LQ={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]},HY={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function f4(W,Q){let Y=W._zod.def,X=Y.checks;if(X&&X.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let J=s(W._zod.def,{get shape(){let H={};for(let w in Q){if(!(w in Y.shape))throw Error(`Unrecognized key: "${w}"`);if(!Q[w])continue;H[w]=Y.shape[w]}return YW(this,"shape",H),H},checks:[]});return i(W,J)}function o4(W,Q){let Y=W._zod.def,X=Y.checks;if(X&&X.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let J=s(W._zod.def,{get shape(){let H={...W._zod.def.shape};for(let w in Q){if(!(w in Y.shape))throw Error(`Unrecognized key: "${w}"`);if(!Q[w])continue;delete H[w]}return YW(this,"shape",H),H},checks:[]});return i(W,J)}function l4(W,Q){if(!XW(Q))throw Error("Invalid input to extend: expected a plain object");let Y=W._zod.def.checks;if(Y&&Y.length>0){let J=W._zod.def.shape;for(let H in Q)if(Object.getOwnPropertyDescriptor(J,H)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let G=s(W._zod.def,{get shape(){let J={...W._zod.def.shape,...Q};return YW(this,"shape",J),J}});return i(W,G)}function r4(W,Q){if(!XW(Q))throw Error("Invalid input to safeExtend: expected a plain object");let Y=s(W._zod.def,{get shape(){let X={...W._zod.def.shape,...Q};return YW(this,"shape",X),X}});return i(W,Y)}function p4(W,Q){let Y=s(W._zod.def,{get shape(){let X={...W._zod.def.shape,...Q._zod.def.shape};return YW(this,"shape",X),X},get catchall(){return Q._zod.def.catchall},checks:[]});return i(W,Y)}function d4(W,Q,Y){let G=Q._zod.def.checks;if(G&&G.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let H=s(Q._zod.def,{get shape(){let w=Q._zod.def.shape,q={...w};if(Y)for(let L in Y){if(!(L in w))throw Error(`Unrecognized key: "${L}"`);if(!Y[L])continue;q[L]=W?new W({type:"optional",innerType:w[L]}):w[L]}else for(let L in w)q[L]=W?new W({type:"optional",innerType:w[L]}):w[L];return YW(this,"shape",q),q},checks:[]});return i(Q,H)}function n4(W,Q,Y){let X=s(Q._zod.def,{get shape(){let G=Q._zod.def.shape,J={...G};if(Y)for(let H in Y){if(!(H in J))throw Error(`Unrecognized key: "${H}"`);if(!Y[H])continue;J[H]=new W({type:"nonoptional",innerType:G[H]})}else for(let H in G)J[H]=new W({type:"nonoptional",innerType:G[H]});return YW(this,"shape",J),J}});return i(Q,X)}function GW(W,Q=0){if(W.aborted===!0)return!0;for(let Y=Q;Y<W.issues.length;Y++)if(W.issues[Y]?.continue!==!0)return!0;return!1}function QW(W,Q){return Q.map((Y)=>{var X;return(X=Y).path??(X.path=[]),Y.path.unshift(W),Y})}function zW(W){return typeof W==="string"?W:W?.message}function t(W,Q,Y){let X={...W,path:W.path??[]};if(!W.message){let G=zW(W.inst?._zod.def?.error?.(W))??zW(Q?.error?.(W))??zW(Y.customError?.(W))??zW(Y.localeError?.(W))??"Invalid input";X.message=G}if(delete X.inst,delete X.continue,!Q?.reportInput)delete X.input;return X}function wY(W){if(W instanceof Set)return"set";if(W instanceof Map)return"map";if(W instanceof File)return"file";return"unknown"}function OW(W){if(Array.isArray(W))return"array";if(typeof W==="string")return"string";return"unknown"}function BQ(W){let Q=typeof W;switch(Q){case"number":return Number.isNaN(W)?"nan":"number";case"object":{if(W===null)return"null";if(Array.isArray(W))return"array";let Y=W;if(Y&&Object.getPrototypeOf(Y)!==Object.prototype&&"constructor"in Y&&Y.constructor)return Y.constructor.name}}return Q}function KW(...W){let[Q,Y,X]=W;if(typeof Q==="string")return{message:Q,code:"custom",input:Y,inst:X};return{...Q}}function i4(W){return Object.entries(W).filter(([Q,Y])=>{return Number.isNaN(Number.parseInt(Q,10))}).map((Q)=>Q[1])}function AY(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 qY(W){let Q="";for(let Y=0;Y<W.length;Y++)Q+=String.fromCharCode(W[Y]);return btoa(Q)}function t4(W){let Q=W.replace(/-/g,"+").replace(/_/g,"/"),Y="=".repeat((4-Q.length%4)%4);return AY(Q+Y)}function e4(W){return qY(W).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function a4(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 s4(W){return Array.from(W).map((Q)=>Q.toString(16).padStart(2,"0")).join("")}class KY{constructor(...W){}}var LY=(W,Q)=>{W.name="$ZodError",Object.defineProperty(W,"_zod",{value:W._zod,enumerable:!1}),Object.defineProperty(W,"issues",{value:Q,enumerable:!1}),W.message=JSON.stringify(Q,AW,2),Object.defineProperty(W,"toString",{value:()=>W.message,enumerable:!1})},uW=K("$ZodError",LY),NQ=K("$ZodError",LY,{Parent:Error});function BY(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 NY(W,Q=(Y)=>Y.message){let Y={_errors:[]},X=(G)=>{for(let J of G.issues)if(J.code==="invalid_union"&&J.errors.length)J.errors.map((H)=>X({issues:H}));else if(J.code==="invalid_key")X({issues:J.issues});else if(J.code==="invalid_element")X({issues:J.issues});else if(J.path.length===0)Y._errors.push(Q(J));else{let H=Y,w=0;while(w<J.path.length){let q=J.path[w];if(w!==J.path.length-1)H[q]=H[q]||{_errors:[]};else H[q]=H[q]||{_errors:[]},H[q]._errors.push(Q(J));H=H[q],w++}}};return X(W),Y}var yW=(W)=>(Q,Y,X,G)=>{let J=X?Object.assign(X,{async:!1}):{async:!1},H=Q._zod.run({value:Y,issues:[]},J);if(H instanceof Promise)throw new a;if(H.issues.length){let w=new(G?.Err??W)(H.issues.map((q)=>t(q,J,r())));throw xW(w,G?.callee),w}return H.value};var mW=(W)=>async(Q,Y,X,G)=>{let J=X?Object.assign(X,{async:!0}):{async:!0},H=Q._zod.run({value:Y,issues:[]},J);if(H instanceof Promise)H=await H;if(H.issues.length){let w=new(G?.Err??W)(H.issues.map((q)=>t(q,J,r())));throw xW(w,G?.callee),w}return H.value};var DW=(W)=>(Q,Y,X)=>{let G=X?{...X,async:!1}:{async:!1},J=Q._zod.run({value:Y,issues:[]},G);if(J instanceof Promise)throw new a;return J.issues.length?{success:!1,error:new(W??uW)(J.issues.map((H)=>t(H,G,r())))}:{success:!0,data:J.value}},MY=DW(NQ),FW=(W)=>async(Q,Y,X)=>{let G=X?Object.assign(X,{async:!0}):{async:!0},J=Q._zod.run({value:Y,issues:[]},G);if(J instanceof Promise)J=await J;return J.issues.length?{success:!1,error:new W(J.issues.map((H)=>t(H,G,r())))}:{success:!0,data:J.value}},zY=FW(NQ),UY=(W)=>(Q,Y,X)=>{let G=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return yW(W)(Q,Y,G)};var IY=(W)=>(Q,Y,X)=>{return yW(W)(Q,Y,X)};var VY=(W)=>async(Q,Y,X)=>{let G=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return mW(W)(Q,Y,G)};var OY=(W)=>async(Q,Y,X)=>{return mW(W)(Q,Y,X)};var DY=(W)=>(Q,Y,X)=>{let G=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return DW(W)(Q,Y,G)};var FY=(W)=>(Q,Y,X)=>{return DW(W)(Q,Y,X)};var $Y=(W)=>async(Q,Y,X)=>{let G=X?Object.assign(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 EY=/^[cC][^\s-]{8,}$/,RY=/^[0-9a-z]+$/,SY=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,bY=/^[0-9a-vA-V]{20}$/,TY=/^[A-Za-z0-9]{27}$/,_Y=/^[a-zA-Z0-9_-]{21}$/,ZY=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var CY=/^([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})$/,MQ=(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 jY=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Q6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function kY(){return new RegExp(Q6,"u")}var vY=/^(?:(?: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])$/,gY=/^(([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 hY=/^((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])$/,xY=/^(([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])$/,cY=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,zQ=/^[A-Za-z0-9_-]*$/;var uY=/^\+[1-9]\d{6,14}$/,yY="(?:(?:\\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])))",mY=new RegExp(`^${yY}$`);function fY(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 oY(W){return new RegExp(`^${fY(W)}$`)}function lY(W){let Q=fY({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(`^${yY}T(?:${X})$`)}var rY=(W)=>{let Q=W?`[\\s\\S]{${W?.minimum??0},${W?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${Q}$`)};var pY=/^-?\d+$/,fW=/^-?\d+(?:\.\d+)?$/,dY=/^(?:true|false)$/i,nY=/^null$/i;var iY=/^[^A-Z]*$/,tY=/^[^a-z]*$/;var g=K("$ZodCheck",(W,Q)=>{var Y;W._zod??(W._zod={}),W._zod.def=Q,(Y=W._zod).onattach??(Y.onattach=[])}),eY={number:"number",bigint:"bigint",object:"date"},UQ=K("$ZodCheckLessThan",(W,Q)=>{g.init(W,Q);let Y=eY[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)=>{g.init(W,Q);let Y=eY[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})}}),aY=K("$ZodCheckMultipleOf",(W,Q)=>{g.init(W,Q),W._zod.onattach.push((Y)=>{var X;(X=Y._zod.bag).multipleOf??(X.multipleOf=Q.value)}),W._zod.check=(Y)=>{if(typeof Y.value!==typeof Q.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof Y.value==="bigint"?Y.value%Q.value===BigInt(0):HQ(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})}}),sY=K("$ZodCheckNumberFormat",(W,Q)=>{g.init(W,Q),Q.format=Q.format||"float64";let Y=Q.format?.includes("int"),X=Y?"int":"number",[G,J]=LQ[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=pY}),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 W0=K("$ZodCheckMaxLength",(W,Q)=>{var Y;g.init(W,Q),(Y=W._zod.def).when??(Y.when=(X)=>{let G=X.value;return!IW(G)&&G.length!==void 0}),W._zod.onattach.push((X)=>{let G=X._zod.bag.maximum??Number.POSITIVE_INFINITY;if(Q.maximum<G)X._zod.bag.maximum=Q.maximum}),W._zod.check=(X)=>{let G=X.value;if(G.length<=Q.maximum)return;let H=OW(G);X.issues.push({origin:H,code:"too_big",maximum:Q.maximum,inclusive:!0,input:G,inst:W,continue:!Q.abort})}}),Q0=K("$ZodCheckMinLength",(W,Q)=>{var Y;g.init(W,Q),(Y=W._zod.def).when??(Y.when=(X)=>{let G=X.value;return!IW(G)&&G.length!==void 0}),W._zod.onattach.push((X)=>{let G=X._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(Q.minimum>G)X._zod.bag.minimum=Q.minimum}),W._zod.check=(X)=>{let G=X.value;if(G.length>=Q.minimum)return;let H=OW(G);X.issues.push({origin:H,code:"too_small",minimum:Q.minimum,inclusive:!0,input:G,inst:W,continue:!Q.abort})}}),Y0=K("$ZodCheckLengthEquals",(W,Q)=>{var Y;g.init(W,Q),(Y=W._zod.def).when??(Y.when=(X)=>{let G=X.value;return!IW(G)&&G.length!==void 0}),W._zod.onattach.push((X)=>{let G=X._zod.bag;G.minimum=Q.length,G.maximum=Q.length,G.length=Q.length}),W._zod.check=(X)=>{let G=X.value,J=G.length;if(J===Q.length)return;let H=OW(G),w=J>Q.length;X.issues.push({origin:H,...w?{code:"too_big",maximum:Q.length}:{code:"too_small",minimum:Q.length},inclusive:!0,exact:!0,input:X.value,inst:W,continue:!Q.abort})}}),$W=K("$ZodCheckStringFormat",(W,Q)=>{var Y,X;if(g.init(W,Q),W._zod.onattach.push((G)=>{let J=G._zod.bag;if(J.format=Q.format,Q.pattern)J.patterns??(J.patterns=new Set),J.patterns.add(Q.pattern)}),Q.pattern)(Y=W._zod).check??(Y.check=(G)=>{if(Q.pattern.lastIndex=0,Q.pattern.test(G.value))return;G.issues.push({origin:"string",code:"invalid_format",format:Q.format,input:G.value,...Q.pattern?{pattern:Q.pattern.toString()}:{},inst:W,continue:!Q.abort})});else(X=W._zod).check??(X.check=()=>{})}),X0=K("$ZodCheckRegex",(W,Q)=>{$W.init(W,Q),W._zod.check=(Y)=>{if(Q.pattern.lastIndex=0,Q.pattern.test(Y.value))return;Y.issues.push({origin:"string",code:"invalid_format",format:"regex",input:Y.value,pattern:Q.pattern.toString(),inst:W,continue:!Q.abort})}}),G0=K("$ZodCheckLowerCase",(W,Q)=>{Q.pattern??(Q.pattern=iY),$W.init(W,Q)}),J0=K("$ZodCheckUpperCase",(W,Q)=>{Q.pattern??(Q.pattern=tY),$W.init(W,Q)}),H0=K("$ZodCheckIncludes",(W,Q)=>{g.init(W,Q);let Y=WW(Q.includes),X=new RegExp(typeof Q.position==="number"?`^.{${Q.position}}${Y}`:Y);Q.pattern=X,W._zod.onattach.push((G)=>{let J=G._zod.bag;J.patterns??(J.patterns=new Set),J.patterns.add(X)}),W._zod.check=(G)=>{if(G.value.includes(Q.includes,Q.position))return;G.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:Q.includes,input:G.value,inst:W,continue:!Q.abort})}}),w0=K("$ZodCheckStartsWith",(W,Q)=>{g.init(W,Q);let Y=new RegExp(`^${WW(Q.prefix)}.*`);Q.pattern??(Q.pattern=Y),W._zod.onattach.push((X)=>{let G=X._zod.bag;G.patterns??(G.patterns=new Set),G.patterns.add(Y)}),W._zod.check=(X)=>{if(X.value.startsWith(Q.prefix))return;X.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:Q.prefix,input:X.value,inst:W,continue:!Q.abort})}}),A0=K("$ZodCheckEndsWith",(W,Q)=>{g.init(W,Q);let Y=new RegExp(`.*${WW(Q.suffix)}$`);Q.pattern??(Q.pattern=Y),W._zod.onattach.push((X)=>{let G=X._zod.bag;G.patterns??(G.patterns=new Set),G.patterns.add(Y)}),W._zod.check=(X)=>{if(X.value.endsWith(Q.suffix))return;X.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:Q.suffix,input:X.value,inst:W,continue:!Q.abort})}});var q0=K("$ZodCheckOverwrite",(W,Q)=>{g.init(W,Q),W._zod.check=(Y)=>{Y.value=Q.tx(Y.value)}});class VQ{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 L0={major:4,minor:3,patch:6};var E=K("$ZodType",(W,Q)=>{var Y;W??(W={}),W._zod.def=Q,W._zod.bag=W._zod.bag||{},W._zod.version=L0;let X=[...W._zod.def.checks??[]];if(W._zod.traits.has("$ZodCheck"))X.unshift(W);for(let G of X)for(let J of G._zod.onattach)J(W);if(X.length===0)(Y=W._zod).deferred??(Y.deferred=[]),W._zod.deferred?.push(()=>{W._zod.run=W._zod.parse});else{let G=(H,w,q)=>{let L=GW(H),B;for(let z of w){if(z._zod.def.when){if(!z._zod.def.when(H))continue}else if(L)continue;let I=H.issues.length,V=z._zod.check(H);if(V instanceof Promise&&q?.async===!1)throw new a;if(B||V instanceof Promise)B=(B??Promise.resolve()).then(async()=>{if(await V,H.issues.length===I)return;if(!L)L=GW(H,I)});else{if(H.issues.length===I)continue;if(!L)L=GW(H,I)}}if(B)return B.then(()=>{return H});return H},J=(H,w,q)=>{if(GW(H))return H.aborted=!0,H;let L=G(w,X,q);if(L instanceof Promise){if(q.async===!1)throw new a;return L.then((B)=>W._zod.parse(B,q))}return W._zod.parse(L,q)};W._zod.run=(H,w)=>{if(w.skipChecks)return W._zod.parse(H,w);if(w.direction==="backward"){let L=W._zod.parse({value:H.value,issues:[]},{...w,skipChecks:!0});if(L instanceof Promise)return L.then((B)=>{return J(B,H,w)});return J(L,H,w)}let q=W._zod.parse(H,w);if(q instanceof Promise){if(w.async===!1)throw new a;return q.then((L)=>G(L,X,w))}return G(q,X,w)}}F(W,"~standard",()=>({validate:(G)=>{try{let J=MY(W,G);return J.success?{value:J.data}:{issues:J.error?.issues}}catch(J){return zY(W,G).then((H)=>H.success?{value:H.data}:{issues:H.error?.issues})}},vendor:"zod",version:1}))}),pW=K("$ZodString",(W,Q)=>{E.init(W,Q),W._zod.pattern=[...W?._zod.bag?.patterns??[]].pop()??rY(W._zod.bag),W._zod.parse=(Y,X)=>{if(Q.coerce)try{Y.value=String(Y.value)}catch(G){}if(typeof Y.value==="string")return Y;return Y.issues.push({expected:"string",code:"invalid_type",input:Y.value,inst:W}),Y}}),R=K("$ZodStringFormat",(W,Q)=>{$W.init(W,Q),pW.init(W,Q)}),D0=K("$ZodGUID",(W,Q)=>{Q.pattern??(Q.pattern=CY),R.init(W,Q)}),F0=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=MQ(X))}else Q.pattern??(Q.pattern=MQ());R.init(W,Q)}),$0=K("$ZodEmail",(W,Q)=>{Q.pattern??(Q.pattern=jY),R.init(W,Q)}),P0=K("$ZodURL",(W,Q)=>{R.init(W,Q),W._zod.check=(Y)=>{try{let X=Y.value.trim(),G=new URL(X);if(Q.hostname){if(Q.hostname.lastIndex=0,!Q.hostname.test(G.hostname))Y.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Q.hostname.source,input:Y.value,inst:W,continue:!Q.abort})}if(Q.protocol){if(Q.protocol.lastIndex=0,!Q.protocol.test(G.protocol.endsWith(":")?G.protocol.slice(0,-1):G.protocol))Y.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:Q.protocol.source,input:Y.value,inst:W,continue:!Q.abort})}if(Q.normalize)Y.value=G.href;else Y.value=X;return}catch(X){Y.issues.push({code:"invalid_format",format:"url",input:Y.value,inst:W,continue:!Q.abort})}}}),E0=K("$ZodEmoji",(W,Q)=>{Q.pattern??(Q.pattern=kY()),R.init(W,Q)}),R0=K("$ZodNanoID",(W,Q)=>{Q.pattern??(Q.pattern=_Y),R.init(W,Q)}),S0=K("$ZodCUID",(W,Q)=>{Q.pattern??(Q.pattern=EY),R.init(W,Q)}),b0=K("$ZodCUID2",(W,Q)=>{Q.pattern??(Q.pattern=RY),R.init(W,Q)}),T0=K("$ZodULID",(W,Q)=>{Q.pattern??(Q.pattern=SY),R.init(W,Q)}),_0=K("$ZodXID",(W,Q)=>{Q.pattern??(Q.pattern=bY),R.init(W,Q)}),Z0=K("$ZodKSUID",(W,Q)=>{Q.pattern??(Q.pattern=TY),R.init(W,Q)}),C0=K("$ZodISODateTime",(W,Q)=>{Q.pattern??(Q.pattern=lY(Q)),R.init(W,Q)}),j0=K("$ZodISODate",(W,Q)=>{Q.pattern??(Q.pattern=mY),R.init(W,Q)}),k0=K("$ZodISOTime",(W,Q)=>{Q.pattern??(Q.pattern=oY(Q)),R.init(W,Q)}),v0=K("$ZodISODuration",(W,Q)=>{Q.pattern??(Q.pattern=ZY),R.init(W,Q)}),g0=K("$ZodIPv4",(W,Q)=>{Q.pattern??(Q.pattern=vY),R.init(W,Q),W._zod.bag.format="ipv4"}),h0=K("$ZodIPv6",(W,Q)=>{Q.pattern??(Q.pattern=gY),R.init(W,Q),W._zod.bag.format="ipv6",W._zod.check=(Y)=>{try{new URL(`http://[${Y.value}]`)}catch{Y.issues.push({code:"invalid_format",format:"ipv6",input:Y.value,inst:W,continue:!Q.abort})}}});var x0=K("$ZodCIDRv4",(W,Q)=>{Q.pattern??(Q.pattern=hY),R.init(W,Q)}),c0=K("$ZodCIDRv6",(W,Q)=>{Q.pattern??(Q.pattern=xY),R.init(W,Q),W._zod.check=(Y)=>{let X=Y.value.split("/");try{if(X.length!==2)throw Error();let[G,J]=X;if(!J)throw Error();let H=Number(J);if(`${H}`!==J)throw Error();if(H<0||H>128)throw Error();new URL(`http://[${G}]`)}catch{Y.issues.push({code:"invalid_format",format:"cidrv6",input:Y.value,inst:W,continue:!Q.abort})}}});function u0(W){if(W==="")return!0;if(W.length%4!==0)return!1;try{return atob(W),!0}catch{return!1}}var y0=K("$ZodBase64",(W,Q)=>{Q.pattern??(Q.pattern=cY),R.init(W,Q),W._zod.bag.contentEncoding="base64",W._zod.check=(Y)=>{if(u0(Y.value))return;Y.issues.push({code:"invalid_format",format:"base64",input:Y.value,inst:W,continue:!Q.abort})}});function Y6(W){if(!zQ.test(W))return!1;let Q=W.replace(/[-_]/g,(X)=>X==="-"?"+":"/"),Y=Q.padEnd(Math.ceil(Q.length/4)*4,"=");return u0(Y)}var m0=K("$ZodBase64URL",(W,Q)=>{Q.pattern??(Q.pattern=zQ),R.init(W,Q),W._zod.bag.contentEncoding="base64url",W._zod.check=(Y)=>{if(Y6(Y.value))return;Y.issues.push({code:"invalid_format",format:"base64url",input:Y.value,inst:W,continue:!Q.abort})}}),f0=K("$ZodE164",(W,Q)=>{Q.pattern??(Q.pattern=uY),R.init(W,Q)});function X6(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 o0=K("$ZodJWT",(W,Q)=>{R.init(W,Q),W._zod.check=(Y)=>{if(X6(Y.value,Q.alg))return;Y.issues.push({code:"invalid_format",format:"jwt",input:Y.value,inst:W,continue:!Q.abort})}});var DQ=K("$ZodNumber",(W,Q)=>{E.init(W,Q),W._zod.pattern=W._zod.bag.pattern??fW,W._zod.parse=(Y,X)=>{if(Q.coerce)try{Y.value=Number(Y.value)}catch(H){}let G=Y.value;if(typeof G==="number"&&!Number.isNaN(G)&&Number.isFinite(G))return Y;let J=typeof G==="number"?Number.isNaN(G)?"NaN":!Number.isFinite(G)?"Infinity":void 0:void 0;return Y.issues.push({expected:"number",code:"invalid_type",input:G,inst:W,...J?{received:J}:{}}),Y}}),l0=K("$ZodNumberFormat",(W,Q)=>{sY.init(W,Q),DQ.init(W,Q)}),r0=K("$ZodBoolean",(W,Q)=>{E.init(W,Q),W._zod.pattern=dY,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 p0=K("$ZodNull",(W,Q)=>{E.init(W,Q),W._zod.pattern=nY,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 d0=K("$ZodUnknown",(W,Q)=>{E.init(W,Q),W._zod.parse=(Y)=>Y}),n0=K("$ZodNever",(W,Q)=>{E.init(W,Q),W._zod.parse=(Y,X)=>{return Y.issues.push({expected:"never",code:"invalid_type",input:Y.value,inst:W}),Y}});function B0(W,Q,Y){if(W.issues.length)Q.issues.push(...QW(Y,W.issues));Q.value[Y]=W.value}var i0=K("$ZodArray",(W,Q)=>{E.init(W,Q),W._zod.parse=(Y,X)=>{let G=Y.value;if(!Array.isArray(G))return Y.issues.push({expected:"array",code:"invalid_type",input:G,inst:W}),Y;Y.value=Array(G.length);let J=[];for(let H=0;H<G.length;H++){let w=G[H],q=Q.element._zod.run({value:w,issues:[]},X);if(q instanceof Promise)J.push(q.then((L)=>B0(L,Y,H)));else B0(q,Y,H)}if(J.length)return Promise.all(J).then(()=>Y);return Y}});function rW(W,Q,Y,X,G){if(W.issues.length){if(G&&!(Y in X))return;Q.issues.push(...QW(Y,W.issues))}if(W.value===void 0){if(Y in X)Q.value[Y]=void 0}else Q.value[Y]=W.value}function t0(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=KQ(W.shape);return{...W,keys:Q,keySet:new Set(Q),numKeys:Q.length,optionalKeys:new Set(Y)}}function e0(W,Q,Y,X,G,J){let H=[],w=G.keySet,q=G.catchall._zod,L=q.def.type,B=q.optout==="optional";for(let z in Q){if(w.has(z))continue;if(L==="never"){H.push(z);continue}let I=q.run({value:Q[z],issues:[]},X);if(I instanceof Promise)W.push(I.then((V)=>rW(V,Y,z,Q,B)));else rW(I,Y,z,Q,B)}if(H.length)Y.issues.push({code:"unrecognized_keys",keys:H,input:Q,inst:J});if(!W.length)return Y;return Promise.all(W).then(()=>{return Y})}var G6=K("$ZodObject",(W,Q)=>{if(E.init(W,Q),!Object.getOwnPropertyDescriptor(Q,"shape")?.get){let w=Q.shape;Object.defineProperty(Q,"shape",{get:()=>{let q={...w};return Object.defineProperty(Q,"shape",{value:q}),q}})}let X=qW(()=>t0(Q));F(W._zod,"propValues",()=>{let w=Q.shape,q={};for(let L in w){let B=w[L]._zod;if(B.values){q[L]??(q[L]=new Set);for(let z of B.values)q[L].add(z)}}return q});let G=HW,J=Q.catchall,H;W._zod.parse=(w,q)=>{H??(H=X.value);let L=w.value;if(!G(L))return w.issues.push({expected:"object",code:"invalid_type",input:L,inst:W}),w;w.value={};let B=[],z=H.shape;for(let I of H.keys){let V=z[I],c=V._zod.optout==="optional",v=V._zod.run({value:L[I],issues:[]},q);if(v instanceof Promise)B.push(v.then((kW)=>rW(kW,w,I,L,c)));else rW(v,w,I,L,c)}if(!J)return B.length?Promise.all(B).then(()=>w):w;return e0(B,L,w,q,X.value,W)}}),a0=K("$ZodObjectJIT",(W,Q)=>{G6.init(W,Q);let Y=W._zod.parse,X=qW(()=>t0(Q)),G=(I)=>{let V=new VQ(["shape","payload","ctx"]),c=X.value,v=(e)=>{let m=hW(e);return`shape[${m}]._zod.run({ value: input[${m}], issues: [] }, ctx)`};V.write("const input = payload.value;");let kW=Object.create(null),R4=0;for(let e of c.keys)kW[e]=`key_${R4++}`;V.write("const newResult = {};");for(let e of c.keys){let m=kW[e],n=hW(e),b4=I[e]?._zod?.optout==="optional";if(V.write(`const ${m} = ${v(e)};`),b4)V.write(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcpcloud/runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.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",
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"./node": {
|
|
17
17
|
"types": "./dist/node.d.ts",
|
|
18
18
|
"default": "./dist/node.js"
|
|
19
|
+
},
|
|
20
|
+
"./container-host": {
|
|
21
|
+
"types": "./dist/container-host.d.ts",
|
|
22
|
+
"default": "./dist/container-host.js"
|
|
19
23
|
}
|
|
20
24
|
},
|
|
21
25
|
"files": [
|
|
@@ -42,4 +46,4 @@
|
|
|
42
46
|
"access": "public"
|
|
43
47
|
},
|
|
44
48
|
"homepage": "https://mcpcloud.sh"
|
|
45
|
-
}
|
|
49
|
+
}
|