@mcpcloud/runtime 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Catalog sessions (MS-17): make clients that connected before a tool-changing
3
+ * deploy fetch the new tool list, without a reconnect by hand.
4
+ *
5
+ * This runtime is stateless, so it cannot push
6
+ * `notifications/tools/list_changed`, and the `ttlMs` catalog hint only reaches
7
+ * 2026-07-28 clients — today every real client is on the 2025-era leg. What
8
+ * that era DOES give a server is the session lifecycle: a server may hand out
9
+ * `Mcp-Session-Id` at initialize, and once it answers a request carrying that id
10
+ * with 404, the client MUST start a new session (Streamable HTTP, 2025-06-18) —
11
+ * and a new session lists tools again.
12
+ *
13
+ * So the id is not a session at all: it is the catalog's fingerprint. No state
14
+ * is stored anywhere; a request is stale exactly when it presents an id this
15
+ * catalog would not have issued. Deploys that leave the catalog unchanged
16
+ * never trip it.
17
+ *
18
+ * The cost, and why it is a publisher opt-in (`MCP_CATALOG_SESSIONS`): the
19
+ * reference TS SDK client does not re-initialize on its own — it surfaces the
20
+ * 404 as an error — so the FIRST call after a tool-changing deploy may fail in
21
+ * a client that does not reconnect on "session not found".
22
+ *
23
+ * Only ids carrying {@link CATALOG_SESSION_PREFIX} are judged. A request with no
24
+ * id, or one some intermediary minted, passes exactly as before.
25
+ */
26
+ export declare const CATALOG_SESSION_PREFIX = "mcpc-";
27
+ /** Everything a client learns from the list methods; functions are dropped. */
28
+ export declare function catalogSessionId(catalog: unknown): string;
29
+ /** True when the request presents a catalog id this catalog did not issue. */
30
+ export declare function isStaleCatalogSession(request: Request, currentId: string): boolean;
31
+ /** Whether a POST body is (or, in a batch, contains) `initialize`. */
32
+ export declare function isInitializeRequest(request: Request): Promise<boolean>;
33
+ /**
34
+ * 404 for a catalog the server no longer serves. The message names the remedy
35
+ * for the clients that surface it instead of reconnecting on their own.
36
+ */
37
+ export declare function createCatalogSessionExpiredResponse(): Response;
38
+ /** Attach the catalog id to a successful initialize response. */
39
+ export declare function withCatalogSessionId(response: Response, id: string): Response;
@@ -1,4 +1,4 @@
1
- /*! @mcpcloud/runtime v0.18.0 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
1
+ /*! @mcpcloud/runtime v0.19.0 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
2
2
  var{create:Ih,defineProperty:$n,getOwnPropertyDescriptor:Oh,getOwnPropertyNames:Nh,getPrototypeOf:jh}=Object,qh=Object.prototype.hasOwnProperty,D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),fu=(e,t)=>{let r={};for(var o in e)$n(r,o,{get:e[o],enumerable:!0});if(t)$n(r,Symbol.toStringTag,{value:"Module"});return r},xh=(e,t,r,o)=>{if(t&&typeof t==="object"||typeof t==="function"){for(var n=Nh(t),s=0,a=n.length,i;s<a;s++)if(i=n[s],!qh.call(e,i)&&i!==r)$n(e,i,{get:((c)=>t[c]).bind(null,i),enumerable:!(o=Oh(t,i))||o.enumerable})}return e},Rn=(e,t,r)=>(r=e!=null?Ih(jh(e)):{},xh(t||!e||!e.__esModule?$n(r,"default",{value:e,enumerable:!0}):r,e));var Ah=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),gu=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),Mh=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),Lh=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function _u(e){return typeof e==="string"&&gu.has(e.replace(/#$/,""))}function Su(e,t){if(!("$schema"in e)||typeof e.$schema!=="string")return"2020-12";let r=e.$schema.replace(/#$/,"");if(Ah.has(r))return"2020-12";if(gu.has(r))return"2019-09";if(Mh.has(r)||Lh.has(r))return"draft-7";throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}var yu,Ga=Object.freeze({status:"aborted"});function M(e,t,r){function o(i,c){if(!i._zod)Object.defineProperty(i,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1});if(i._zod.traits.has(e))return;i._zod.traits.add(e),t(i,c);let l=a.prototype,m=Object.keys(l);for(let g=0;g<m.length;g++){let z=m[g];if(!(z in i))i[z]=l[z].bind(i)}}let n=r?.Parent??Object;class s extends n{}Object.defineProperty(s,"name",{value:e});function a(i){var c;let l=r?.Parent?new s:this;o(l,i),(c=l._zod).deferred??(c.deferred=[]);for(let m of l._zod.deferred)m();return l}return Object.defineProperty(a,"init",{value:o}),Object.defineProperty(a,Symbol.hasInstance,{value:(i)=>{if(r?.Parent&&i instanceof r.Parent)return!0;return i?._zod?.traits?.has(e)}}),Object.defineProperty(a,"name",{value:e}),a}var Zh=Symbol("zod_brand");class ut extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class uo extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(yu=globalThis).__zod_globalConfig??(yu.__zod_globalConfig={});var lr=globalThis.__zod_globalConfig;function Ke(e){if(e)Object.assign(lr,e);return lr}function Pn(e){let t=Object.values(e).filter((o)=>typeof o==="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function Ya(e,t="|"){return e.map((r)=>ti(r)).join(t)}function lo(e,t){if(typeof t==="bigint")return t.toString();return t}function mo(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw Error("cached value already set")}}}function En(e){return e===null||e===void 0}function Tn(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function bu(e,t){let r=e/t,o=Math.round(r),n=Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-o)<n)return 0;return r-o}var vu=Symbol("evaluating");function _e(e,t,r){let o=void 0;Object.defineProperty(e,t,{get(){if(o===vu)return;if(o===void 0)o=vu,o=r();return o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Vt(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function St(...e){let t={};for(let r of e){let o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function Xa(e){return JSON.stringify(e)}function zu(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Qa="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function dr(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var $u=mo(()=>{if(lr.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Ft(e){if(dr(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let r=t.prototype;if(dr(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function ei(e){if(Ft(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Ru=new Set(["string","number","symbol"]);function yt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function rt(e,t,r){let o=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)o._zod.parent=e;return o}function X(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function ti(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function wu(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Pu={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]};function Dh(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s=St(e._zod.def,{get shape(){let a={};for(let i in t){if(!(i in r.shape))throw Error(`Unrecognized key: "${i}"`);if(!t[i])continue;a[i]=r.shape[i]}return Vt(this,"shape",a),a},checks:[]});return rt(e,s)}function Uh(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=St(e._zod.def,{get shape(){let a={...e._zod.def.shape};for(let i in t){if(!(i in r.shape))throw Error(`Unrecognized key: "${i}"`);if(!t[i])continue;delete a[i]}return Vt(this,"shape",a),a},checks:[]});return rt(e,s)}function Vh(e,t){if(!Ft(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let s=e._zod.def.shape;for(let a in t)if(Object.getOwnPropertyDescriptor(s,a)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=St(e._zod.def,{get shape(){let s={...e._zod.def.shape,...t};return Vt(this,"shape",s),s}});return rt(e,n)}function Fh(e,t){if(!Ft(t))throw Error("Invalid input to safeExtend: expected a plain object");let r=St(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return Vt(this,"shape",o),o}});return rt(e,r)}function Hh(e,t){if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=St(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t._zod.def.shape};return Vt(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return rt(e,r)}function Jh(e,t,r){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let a=St(t._zod.def,{get shape(){let i=t._zod.def.shape,c={...i};if(r)for(let l in r){if(!(l in i))throw Error(`Unrecognized key: "${l}"`);if(!r[l])continue;c[l]=e?new e({type:"optional",innerType:i[l]}):i[l]}else for(let l in i)c[l]=e?new e({type:"optional",innerType:i[l]}):i[l];return Vt(this,"shape",c),c},checks:[]});return rt(t,a)}function Bh(e,t,r){let o=St(t._zod.def,{get shape(){let n=t._zod.def.shape,s={...n};if(r)for(let a in r){if(!(a in s))throw Error(`Unrecognized key: "${a}"`);if(!r[a])continue;s[a]=new e({type:"nonoptional",innerType:n[a]})}else for(let a in n)s[a]=new e({type:"nonoptional",innerType:n[a]});return Vt(this,"shape",s),s}});return rt(t,o)}function Ht(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Eu(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function vt(e,t){return t.map((r)=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function wn(e){return typeof e==="string"?e:e?.message}function ot(e,t,r){let o=e.message?e.message:wn(e.inst?._zod.def?.error?.(e))??wn(t?.error?.(e))??wn(r.customError?.(e))??wn(r.localeError?.(e))??"Invalid input",{inst:n,continue:s,input:a,...i}=e;if(i.path??(i.path=[]),i.message=o,t?.reportInput)i.input=a;return i}function kn(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Tu(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function Jt(...e){let[t,r,o]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:o};return{...t}}var ku=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,lo,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Cn=M("$ZodError",ku),ri=M("$ZodError",ku,{Parent:Error});function oi(e,t=(r)=>r.message){let r={},o=[];for(let n of e.issues)if(n.path.length>0)r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n));else o.push(t(n));return{formErrors:o,fieldErrors:r}}function ni(e,t=(r)=>r.message){let r={_errors:[]},o=(n,s=[])=>{for(let a of n.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map((i)=>o({issues:i},[...s,...a.path]));else if(a.code==="invalid_key")o({issues:a.issues},[...s,...a.path]);else if(a.code==="invalid_element")o({issues:a.issues},[...s,...a.path]);else{let i=[...s,...a.path];if(i.length===0)r._errors.push(t(a));else{let c=r,l=0;while(l<i.length){let m=i[l];if(l!==i.length-1)c[m]=c[m]||{_errors:[]};else c[m]=c[m]||{_errors:[]},c[m]._errors.push(t(a));c=c[m],l++}}}};return o(e),r}var In=(e)=>(t,r,o,n)=>{let s=o?{...o,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new ut;if(a.issues.length){let i=new(n?.Err??e)(a.issues.map((c)=>ot(c,s,Ke())));throw Qa(i,n?.callee),i}return a.value};var On=(e)=>async(t,r,o,n)=>{let s=o?{...o,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)a=await a;if(a.issues.length){let i=new(n?.Err??e)(a.issues.map((c)=>ot(c,s,Ke())));throw Qa(i,n?.callee),i}return a.value};var po=(e)=>(t,r,o)=>{let n=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},n);if(s instanceof Promise)throw new ut;return s.issues.length?{success:!1,error:new(e??Cn)(s.issues.map((a)=>ot(a,n,Ke())))}:{success:!0,data:s.value}},Cu=po(ri),ho=(e)=>async(t,r,o)=>{let n=o?{...o,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},n);if(s instanceof Promise)s=await s;return s.issues.length?{success:!1,error:new e(s.issues.map((a)=>ot(a,n,Ke())))}:{success:!0,data:s.value}},Iu=ho(ri),Ou=(e)=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return In(e)(t,r,n)};var Nu=(e)=>(t,r,o)=>In(e)(t,r,o);var ju=(e)=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return On(e)(t,r,n)};var qu=(e)=>async(t,r,o)=>On(e)(t,r,o);var xu=(e)=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return po(e)(t,r,n)};var Au=(e)=>(t,r,o)=>po(e)(t,r,o);var Mu=(e)=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return ho(e)(t,r,n)};var Lu=(e)=>async(t,r,o)=>ho(e)(t,r,o);var Zu=/^[cC][0-9a-z]{6,}$/,Du=/^[0-9a-z]+$/,Uu=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Vu=/^[0-9a-vA-V]{20}$/,Fu=/^[A-Za-z0-9]{27}$/,Hu=/^[a-zA-Z0-9_-]{21}$/,Ju=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Bu=/^([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})$/,si=(e)=>{if(!e)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}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var Ku=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Gh="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Gu(){return new RegExp(Gh,"u")}var Wu=/^(?:(?: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])$/,Yu=/^(([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 Xu=/^((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])$/,Qu=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,el=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ai=/^[A-Za-z0-9_-]*$/;var tl=/^https?$/,rl=/^\+[1-9]\d{6,14}$/,ol="(?:(?:\\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])))",nl=new RegExp(`^${ol}$`);function sl(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.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{${e.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function al(e){return new RegExp(`^${sl(e)}$`)}function il(e){let t=sl({precision:e.precision}),r=["Z"];if(e.local)r.push("");if(e.offset)r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let o=`${t}(?:${r.join("|")})`;return new RegExp(`^${ol}T(?:${o})$`)}var cl=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var ul=/^-?\d+$/,ii=/^-?\d+(?:\.\d+)?$/,ll=/^(?:true|false)$/i,dl=/^null$/i;var ml=/^[^A-Z]*$/,pl=/^[^a-z]*$/;var Me=M("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),hl={number:"number",bigint:"bigint",object:"date"},ci=M("$ZodCheckLessThan",(e,t)=>{Me.init(e,t);let r=hl[typeof t.value];e._zod.onattach.push((o)=>{let n=o._zod.bag,s=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<s)if(t.inclusive)n.maximum=t.value;else n.exclusiveMaximum=t.value}),e._zod.check=(o)=>{if(t.inclusive?o.value<=t.value:o.value<t.value)return;o.issues.push({origin:r,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ui=M("$ZodCheckGreaterThan",(e,t)=>{Me.init(e,t);let r=hl[typeof t.value];e._zod.onattach.push((o)=>{let n=o._zod.bag,s=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>s)if(t.inclusive)n.minimum=t.value;else n.exclusiveMinimum=t.value}),e._zod.check=(o)=>{if(t.inclusive?o.value>=t.value:o.value>t.value)return;o.issues.push({origin:r,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),fl=M("$ZodCheckMultipleOf",(e,t)=>{Me.init(e,t),e._zod.onattach.push((r)=>{var o;(o=r._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=(r)=>{if(typeof r.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof r.value==="bigint"?r.value%t.value===BigInt(0):bu(r.value,t.value)===0)return;r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),gl=M("$ZodCheckNumberFormat",(e,t)=>{Me.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),o=r?"int":"number",[n,s]=Pu[t.format];e._zod.onattach.push((a)=>{let i=a._zod.bag;if(i.format=t.format,i.minimum=n,i.maximum=s,r)i.pattern=ul}),e._zod.check=(a)=>{let i=a.value;if(r){if(!Number.isInteger(i)){a.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:i,inst:e});return}if(!Number.isSafeInteger(i)){if(i>0)a.issues.push({input:i,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});else a.issues.push({input:i,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}if(i<n)a.issues.push({origin:"number",input:i,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(i>s)a.issues.push({origin:"number",input:i,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var _l=M("$ZodCheckMaxLength",(e,t)=>{var r;Me.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!En(n)&&n.length!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<n)o._zod.bag.maximum=t.maximum}),e._zod.check=(o)=>{let n=o.value;if(n.length<=t.maximum)return;let a=kn(n);o.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Sl=M("$ZodCheckMinLength",(e,t)=>{var r;Me.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!En(n)&&n.length!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>n)o._zod.bag.minimum=t.minimum}),e._zod.check=(o)=>{let n=o.value;if(n.length>=t.minimum)return;let a=kn(n);o.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),yl=M("$ZodCheckLengthEquals",(e,t)=>{var r;Me.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!En(n)&&n.length!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=(o)=>{let n=o.value,s=n.length;if(s===t.length)return;let a=kn(n),i=s>t.length;o.issues.push({origin:a,...i?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),go=M("$ZodCheckStringFormat",(e,t)=>{var r,o;if(Me.init(e,t),e._zod.onattach.push((n)=>{let s=n._zod.bag;if(s.format=t.format,t.pattern)s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern)}),t.pattern)(r=e._zod).check??(r.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(o=e._zod).check??(o.check=()=>{})}),vl=M("$ZodCheckRegex",(e,t)=>{go.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),bl=M("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ml),go.init(e,t)}),zl=M("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=pl),go.init(e,t)}),$l=M("$ZodCheckIncludes",(e,t)=>{Me.init(e,t);let r=yt(t.includes),o=new RegExp(typeof t.position==="number"?`^.{${t.position}}${r}`:r);t.pattern=o,e._zod.onattach.push((n)=>{let s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(o)}),e._zod.check=(n)=>{if(n.value.includes(t.includes,t.position))return;n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Rl=M("$ZodCheckStartsWith",(e,t)=>{Me.init(e,t);let r=new RegExp(`^${yt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push((o)=>{let n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=(o)=>{if(o.value.startsWith(t.prefix))return;o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),wl=M("$ZodCheckEndsWith",(e,t)=>{Me.init(e,t);let r=new RegExp(`.*${yt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push((o)=>{let n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=(o)=>{if(o.value.endsWith(t.suffix))return;o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});var Pl=M("$ZodCheckOverwrite",(e,t)=>{Me.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class li{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
3
3
  `).filter((s)=>s),o=Math.min(...r.map((s)=>s.length-s.trimStart().length)),n=r.map((s)=>s.slice(o)).map((s)=>" ".repeat(this.indent*2)+s);for(let s of n)this.content.push(s)}compile(){let e=Function,t=this?.args,o=[...(this?.content??[""]).map((n)=>` ${n}`)];return new e(...t,o.join(`
4
4
  `))}}var Tl={major:4,minor:4,patch:3};var Se=M("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Tl;let o=[...e._zod.def.checks??[]];if(e._zod.traits.has("$ZodCheck"))o.unshift(e);for(let n of o)for(let s of n._zod.onattach)s(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(a,i,c)=>{let l=Ht(a),m;for(let g of i){if(g._zod.def.when){if(Eu(a))continue;if(!g._zod.def.when(a))continue}else if(l)continue;let z=a.issues.length,w=g._zod.check(a);if(w instanceof Promise&&c?.async===!1)throw new ut;if(m||w instanceof Promise)m=(m??Promise.resolve()).then(async()=>{if(await w,a.issues.length===z)return;if(!l)l=Ht(a,z)});else{if(a.issues.length===z)continue;if(!l)l=Ht(a,z)}}if(m)return m.then(()=>a);return a},s=(a,i,c)=>{if(Ht(a))return a.aborted=!0,a;let l=n(i,o,c);if(l instanceof Promise){if(c.async===!1)throw new ut;return l.then((m)=>e._zod.parse(m,c))}return e._zod.parse(l,c)};e._zod.run=(a,i)=>{if(i.skipChecks)return e._zod.parse(a,i);if(i.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...i,skipChecks:!0});if(l instanceof Promise)return l.then((m)=>s(m,a,i));return s(l,a,i)}let c=e._zod.parse(a,i);if(c instanceof Promise){if(i.async===!1)throw new ut;return c.then((l)=>n(l,o,i))}return n(c,o,i)}}_e(e,"~standard",()=>({validate:(n)=>{try{let s=Cu(e,n);return s.success?{value:s.data}:{issues:s.error?.issues}}catch(s){return Iu(e,n).then((a)=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),qn=M("$ZodString",(e,t)=>{Se.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??cl(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch(n){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),$e=M("$ZodStringFormat",(e,t)=>{go.init(e,t),qn.init(e,t)}),Al=M("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Bu),$e.init(e,t)}),Ml=M("$ZodUUID",(e,t)=>{if(t.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=si(o))}else t.pattern??(t.pattern=si());$e.init(e,t)}),Ll=M("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ku),$e.init(e,t)}),Zl=M("$ZodURL",(e,t)=>{$e.init(e,t),e._zod.check=(r)=>{try{let o=r.value.trim();if(!t.normalize&&t.protocol?.source===tl.source){if(!/^https?:\/\//i.test(o)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}}let n=new URL(o);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(n.hostname))r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})}if(t.normalize)r.value=n.href;else r.value=o;return}catch(o){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Dl=M("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Gu()),$e.init(e,t)}),Ul=M("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Hu),$e.init(e,t)}),Vl=M("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Zu),$e.init(e,t)}),Fl=M("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Du),$e.init(e,t)}),Hl=M("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Uu),$e.init(e,t)}),Jl=M("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Vu),$e.init(e,t)}),Bl=M("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Fu),$e.init(e,t)}),Kl=M("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=il(t)),$e.init(e,t)}),Gl=M("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=nl),$e.init(e,t)}),Wl=M("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=al(t)),$e.init(e,t)}),Yl=M("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ju),$e.init(e,t)}),Xl=M("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Wu),$e.init(e,t),e._zod.bag.format="ipv4"}),Ql=M("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Yu),$e.init(e,t),e._zod.bag.format="ipv6",e._zod.check=(r)=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}});var ed=M("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Xu),$e.init(e,t)}),td=M("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Qu),$e.init(e,t),e._zod.check=(r)=>{let o=r.value.split("/");try{if(o.length!==2)throw Error();let[n,s]=o;if(!s)throw Error();let a=Number(s);if(`${a}`!==s)throw Error();if(a<0||a>128)throw Error();new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function rd(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var od=M("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=el),$e.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=(r)=>{if(rd(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Wh(e){if(!ai.test(e))return!1;let t=e.replace(/[-_]/g,(o)=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return rd(r)}var nd=M("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ai),$e.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=(r)=>{if(Wh(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),sd=M("$ZodE164",(e,t)=>{t.pattern??(t.pattern=rl),$e.init(e,t)});function Yh(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[o]=r;if(!o)return!1;let n=JSON.parse(atob(o));if("typ"in n&&n?.typ!=="JWT")return!1;if(!n.alg)return!1;if(t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}var ad=M("$ZodJWT",(e,t)=>{$e.init(e,t),e._zod.check=(r)=>{if(Yh(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var mi=M("$ZodNumber",(e,t)=>{Se.init(e,t),e._zod.pattern=e._zod.bag.pattern??ii,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Number(r.value)}catch(a){}let n=r.value;if(typeof n==="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let s=typeof n==="number"?Number.isNaN(n)?"NaN":!Number.isFinite(n)?"Infinity":void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...s?{received:s}:{}}),r}}),id=M("$ZodNumberFormat",(e,t)=>{gl.init(e,t),mi.init(e,t)}),cd=M("$ZodBoolean",(e,t)=>{Se.init(e,t),e._zod.pattern=ll,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(s){}let n=r.value;if(typeof n==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}});var ud=M("$ZodNull",(e,t)=>{Se.init(e,t),e._zod.pattern=dl,e._zod.values=new Set([null]),e._zod.parse=(r,o)=>{let n=r.value;if(n===null)return r;return r.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),r}}),ld=M("$ZodAny",(e,t)=>{Se.init(e,t),e._zod.parse=(r)=>r}),dd=M("$ZodUnknown",(e,t)=>{Se.init(e,t),e._zod.parse=(r)=>r}),md=M("$ZodNever",(e,t)=>{Se.init(e,t),e._zod.parse=(r,o)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function kl(e,t,r){if(e.issues.length)t.issues.push(...vt(r,e.issues));t.value[r]=e.value}var pd=M("$ZodArray",(e,t)=>{Se.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!Array.isArray(n))return r.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),r;r.value=Array(n.length);let s=[];for(let a=0;a<n.length;a++){let i=n[a],c=t.element._zod.run({value:i,issues:[]},o);if(c instanceof Promise)s.push(c.then((l)=>kl(l,r,a)));else kl(c,r,a)}if(s.length)return Promise.all(s).then(()=>r);return r}});function jn(e,t,r,o,n,s){let a=r in o;if(e.issues.length){if(n&&s&&!a)return;t.issues.push(...vt(r,e.issues))}if(!a&&!n){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(a)t.value[r]=void 0}else t.value[r]=e.value}function hd(e){let t=Object.keys(e.shape);for(let o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${o}": expected a Zod schema`);let r=wu(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function fd(e,t,r,o,n,s){let a=[],i=n.keySet,c=n.catchall._zod,l=c.def.type,m=c.optin==="optional",g=c.optout==="optional";for(let z in t){if(z==="__proto__")continue;if(i.has(z))continue;if(l==="never"){a.push(z);continue}let w=c.run({value:t[z],issues:[]},o);if(w instanceof Promise)e.push(w.then((_)=>jn(_,r,z,t,m,g)));else jn(w,r,z,t,m,g)}if(a.length)r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s});if(!e.length)return r;return Promise.all(e).then(()=>r)}var Xh=M("$ZodObject",(e,t)=>{if(Se.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let i=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...i};return Object.defineProperty(t,"shape",{value:c}),c}})}let o=mo(()=>hd(t));_e(e._zod,"propValues",()=>{let i=t.shape,c={};for(let l in i){let m=i[l]._zod;if(m.values){c[l]??(c[l]=new Set);for(let g of m.values)c[l].add(g)}}return c});let n=dr,s=t.catchall,a;e._zod.parse=(i,c)=>{a??(a=o.value);let l=i.value;if(!n(l))return i.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),i;i.value={};let m=[],g=a.shape;for(let z of a.keys){let w=g[z],_=w._zod.optin==="optional",b=w._zod.optout==="optional",f=w._zod.run({value:l[z],issues:[]},c);if(f instanceof Promise)m.push(f.then((d)=>jn(d,i,z,l,_,b)));else jn(f,i,z,l,_,b)}if(!s)return m.length?Promise.all(m).then(()=>i):i;return fd(m,l,i,c,o.value,e)}}),gd=M("$ZodObjectJIT",(e,t)=>{Xh.init(e,t);let r=e._zod.parse,o=mo(()=>hd(t)),n=(z)=>{let w=new li(["shape","payload","ctx"]),_=o.value,b=(p)=>{let S=Xa(p);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};w.write("const input = payload.value;");let f=Object.create(null),d=0;for(let p of _.keys)f[p]=`key_${d++}`;w.write("const newResult = {};");for(let p of _.keys){let S=f[p],P=Xa(p),y=z[p],h=y?._zod?.optin==="optional",E=y?._zod?.optout==="optional";if(w.write(`const ${S} = ${b(p)};`),h&&E)w.write(`
@@ -1,4 +1,4 @@
1
- /*! @mcpcloud/runtime v0.18.0 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
1
+ /*! @mcpcloud/runtime v0.19.0 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
2
2
  var wk=Object.create;var{getPrototypeOf:Rk,defineProperty:Hd,getOwnPropertyNames:xk}=Object;var CS=Object.prototype.hasOwnProperty;function kk(e){return this[e]}var Ik,Pk,Ek=(e,t,n)=>{var o=e!=null&&typeof e==="object";if(o){var r=t?Ik??=new WeakMap:Pk??=new WeakMap,i=r.get(e);if(i)return i}n=e!=null?wk(Rk(e)):{};let a=t||!e||!e.__esModule||!CS.call(e,"default")?Hd(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let s of xk(e))if(!CS.call(a,s))Hd(a,s,{get:kk.bind(e,s),enumerable:!0})}if(o)r.set(e,a);return a};var U=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Tk=(e)=>e;function jk(e,t){this[e]=Tk.bind(null,t)}var tr=(e,t)=>{for(var n in t)Hd(e,n,{get:t[n],enumerable:!0,configurable:!0,set:jk.bind(t,n)})};var Va=U(function(uz){Object.defineProperty(uz,"__esModule",{value:!0});uz.regexpCode=uz.getEsmExportName=uz.getProperty=uz.safeStringify=uz.stringify=uz.strConcat=uz.addCodeArg=uz.str=uz._=uz.nil=uz._Code=uz.Name=uz.IDENTIFIER=uz._CodeOrName=void 0;class ld{}uz._CodeOrName=ld;uz.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class Uo extends ld{constructor(e){super();if(!uz.IDENTIFIER.test(e))throw Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}uz.Name=Uo;class Et extends ld{constructor(e){super();this._items=typeof e==="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((t,n)=>`${t}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((t,n)=>{if(n instanceof Uo)t[n.str]=(t[n.str]||0)+1;return t},{})}}uz._Code=Et;uz.nil=new Et("");function cz(e,...t){let n=[e[0]],o=0;while(o<t.length)Z_(n,t[o]),n.push(e[++o]);return new Et(n)}uz._=cz;var L_=new Et("+");function lz(e,...t){let n=[Za(e[0])],o=0;while(o<t.length)n.push(L_),Z_(n,t[o]),n.push(L_,Za(e[++o]));return UT(n),new Et(n)}uz.str=lz;function Z_(e,t){if(t instanceof Et)e.push(...t._items);else if(t instanceof Uo)e.push(t);else e.push(ZT(t))}uz.addCodeArg=Z_;function UT(e){let t=1;while(t<e.length-1){if(e[t]===L_){let n=DT(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]="+"}t++}}function DT(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string"){if(t instanceof Uo||e[e.length-1]!=='"')return;if(typeof t!="string")return`${e.slice(0,-1)}${t}"`;if(t[0]==='"')return e.slice(0,-1)+t.slice(1);return}if(typeof t=="string"&&t[0]==='"'&&!(e instanceof Uo))return`"${e}${t.slice(1)}`;return}function LT(e,t){return t.emptyStr()?e:e.emptyStr()?t:lz`${e}${t}`}uz.strConcat=LT;function ZT(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Za(Array.isArray(e)?e.join(","):e)}function VT(e){return new Et(Za(e))}uz.stringify=VT;function Za(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}uz.safeStringify=Za;function FT(e){return typeof e=="string"&&uz.IDENTIFIER.test(e)?new Et(`.${e}`):cz`[${e}]`}uz.getProperty=FT;function JT(e){if(typeof e=="string"&&uz.IDENTIFIER.test(e))return new Et(`${e}`);throw Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}uz.getEsmExportName=JT;function HT(e){return new Et(e.toString())}uz.regexpCode=HT});var H_=U(function(fz){Object.defineProperty(fz,"__esModule",{value:!0});fz.ValueScope=fz.ValueScopeName=fz.Scope=fz.varKinds=fz.UsedValueState=void 0;var ot=Va();class mz extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`);this.value=e.value}}var dd;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(dd||(fz.UsedValueState=dd={}));fz.varKinds={const:new ot.Name("const"),let:new ot.Name("let"),var:new ot.Name("var")};class F_{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof ot.Name?e:this.name(e)}name(e){return new ot.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){var t,n;if(((n=(t=this._parent)===null||t===void 0?void 0:t._prefixes)===null||n===void 0?void 0:n.has(e))||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}}fz.Scope=F_;class J_ extends ot.Name{constructor(e,t){super(t);this.prefix=e}setValue(e,{property:t,itemIndex:n}){this.value=e,this.scopePath=ot._`.${new ot.Name(t)}[${n}]`}}fz.ValueScopeName=J_;var i1=ot._`\n`;class pz extends F_{constructor(e){super(e);this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?i1:ot.nil}}get(){return this._scope}name(e){return new J_(e,this._newName(e))}value(e,t){var n;if(t.ref===void 0)throw Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:r}=o,i=(n=t.key)!==null&&n!==void 0?n:t.ref,a=this._values[r];if(a){let l=a.get(i);if(l)return l}else a=this._values[r]=new Map;a.set(i,o);let s=this._scope[r]||(this._scope[r]=[]),c=s.length;return s[c]=t.ref,o.setValue(t,{property:r,itemIndex:c}),o}getValue(e,t){let n=this._values[e];if(!n)return;return n.get(t)}scopeRefs(e,t=this._values){return this._reduceValues(t,(n)=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return ot._`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,(o)=>{if(o.value===void 0)throw Error(`CodeGen: name "${o}" has no value`);return o.value.code},t,n)}_reduceValues(e,t,n={},o){let r=ot.nil;for(let i in e){let a=e[i];if(!a)continue;let s=n[i]=n[i]||new Map;a.forEach((c)=>{if(s.has(c))return;s.set(c,dd.Started);let l=t(c);if(l){let d=this.opts.es5?fz.varKinds.var:fz.varKinds.const;r=ot._`${r}${d} ${c} = ${l};${this.opts._n}`}else if(l=o===null||o===void 0?void 0:o(c))r=ot._`${r}${l}${this.opts._n}`;else throw new mz(c);s.set(c,dd.Completed)})}return r}}fz.ValueScope=pz});var ce=U(function(it){Object.defineProperty(it,"__esModule",{value:!0});it.or=it.and=it.not=it.CodeGen=it.operators=it.varKinds=it.ValueScopeName=it.ValueScope=it.Scope=it.Name=it.regexpCode=it.stringify=it.getProperty=it.nil=it.strConcat=it.str=it._=void 0;var le=Va(),Tt=H_(),Vr=Va();Object.defineProperty(it,"_",{enumerable:!0,get:function(){return Vr._}});Object.defineProperty(it,"str",{enumerable:!0,get:function(){return Vr.str}});Object.defineProperty(it,"strConcat",{enumerable:!0,get:function(){return Vr.strConcat}});Object.defineProperty(it,"nil",{enumerable:!0,get:function(){return Vr.nil}});Object.defineProperty(it,"getProperty",{enumerable:!0,get:function(){return Vr.getProperty}});Object.defineProperty(it,"stringify",{enumerable:!0,get:function(){return Vr.stringify}});Object.defineProperty(it,"regexpCode",{enumerable:!0,get:function(){return Vr.regexpCode}});Object.defineProperty(it,"Name",{enumerable:!0,get:function(){return Vr.Name}});var vd=H_();Object.defineProperty(it,"Scope",{enumerable:!0,get:function(){return vd.Scope}});Object.defineProperty(it,"ValueScope",{enumerable:!0,get:function(){return vd.ValueScope}});Object.defineProperty(it,"ValueScopeName",{enumerable:!0,get:function(){return vd.ValueScopeName}});Object.defineProperty(it,"varKinds",{enumerable:!0,get:function(){return vd.varKinds}});it.operators={GT:new le._Code(">"),GTE:new le._Code(">="),LT:new le._Code("<"),LTE:new le._Code("<="),EQ:new le._Code("==="),NEQ:new le._Code("!=="),NOT:new le._Code("!"),OR:new le._Code("||"),AND:new le._Code("&&"),ADD:new le._Code("+")};class Fr{optimizeNodes(){return this}optimizeNames(e,t){return this}}class gz extends Fr{constructor(e,t,n){super();this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let n=e?Tt.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+t}optimizeNames(e,t){if(!e[this.name.str])return;if(this.rhs)this.rhs=Lo(this.rhs,e,t);return this}get names(){return this.rhs instanceof le._CodeOrName?this.rhs.names:{}}}class B_ extends Fr{constructor(e,t,n){super();this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,t){if(this.lhs instanceof le.Name&&!e[this.lhs.str]&&!this.sideEffects)return;return this.rhs=Lo(this.rhs,e,t),this}get names(){let e=this.lhs instanceof le.Name?{}:{...this.lhs.names};return gd(e,this.rhs)}}class vz extends B_{constructor(e,t,n,o){super(e,n,o);this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}}class _z extends Fr{constructor(e){super();this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}}class Sz extends Fr{constructor(e){super();this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}}class yz extends Fr{constructor(e){super();this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}}class bz extends Fr{constructor(e){super();this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=Lo(this.code,e,t),this}get names(){return this.code instanceof le._CodeOrName?this.code.names:{}}}class _d extends Fr{constructor(e=[]){super();this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,t=e.length;while(t--){let n=e[t].optimizeNodes();if(Array.isArray(n))e.splice(t,1,...n);else if(n)e[t]=n;else e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,o=n.length;while(o--){let r=n[o];if(r.optimizeNames(e,t))continue;l1(e,r.names),n.splice(o,1)}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>xn(e,t.names),{})}}class Jr extends _d{render(e){return"{"+e._n+super.render(e)+"}"+e._n}}class $z extends _d{}class Fa extends Jr{}Fa.kind="else";class dr extends Jr{constructor(e,t){super(t);this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);if(this.else)t+="else "+this.else.render(e);return t}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let t=this.else;if(t){let n=t.optimizeNodes();t=this.else=Array.isArray(n)?new Fa(n):n}if(t){if(e===!1)return t instanceof dr?t:t.nodes;if(this.nodes.length)return this;return new dr(kz(e),t instanceof dr?[t]:t.nodes)}if(e===!1||!this.nodes.length)return;return this}optimizeNames(e,t){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,t),!(super.optimizeNames(e,t)||this.else))return;return this.condition=Lo(this.condition,e,t),this}get names(){let e=super.names;if(gd(e,this.condition),this.else)xn(e,this.else.names);return e}}dr.kind="if";class Do extends Jr{}Do.kind="for";class zz extends Do{constructor(e){super();this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(!super.optimizeNames(e,t))return;return this.iteration=Lo(this.iteration,e,t),this}get names(){return xn(super.names,this.iteration.names)}}class wz extends Do{constructor(e,t,n,o){super();this.varKind=e,this.name=t,this.from=n,this.to=o}render(e){let t=e.es5?Tt.varKinds.var:this.varKind,{name:n,from:o,to:r}=this;return`for(${t} ${n}=${o}; ${n}<${r}; ${n}++)`+super.render(e)}get names(){let e=gd(super.names,this.from);return gd(e,this.to)}}class K_ extends Do{constructor(e,t,n,o){super();this.loop=e,this.varKind=t,this.name=n,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(!super.optimizeNames(e,t))return;return this.iterable=Lo(this.iterable,e,t),this}get names(){return xn(super.names,this.iterable.names)}}class md extends Jr{constructor(e,t,n){super();this.name=e,this.args=t,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}}md.kind="func";class pd extends _d{render(e){return"return "+super.render(e)}}pd.kind="return";class Rz extends Jr{render(e){let t="try"+super.render(e);if(this.catch)t+=this.catch.render(e);if(this.finally)t+=this.finally.render(e);return t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(t=this.finally)===null||t===void 0||t.optimizeNodes(),this}optimizeNames(e,t){var n,o;return super.optimizeNames(e,t),(n=this.catch)===null||n===void 0||n.optimizeNames(e,t),(o=this.finally)===null||o===void 0||o.optimizeNames(e,t),this}get names(){let e=super.names;if(this.catch)xn(e,this.catch.names);if(this.finally)xn(e,this.finally.names);return e}}class fd extends Jr{constructor(e){super();this.error=e}render(e){return`catch(${this.error})`+super.render(e)}}fd.kind="catch";class hd extends Jr{render(e){return"finally"+super.render(e)}}hd.kind="finally";class xz{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
3
3
  `:""},this._extScope=e,this._scope=new Tt.Scope({parent:e}),this._nodes=[new $z]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,o){let r=this._scope.toName(t);if(n!==void 0&&o)this._constants[r.str]=n;return this._leafNode(new gz(e,r,n)),r}const(e,t,n){return this._def(Tt.varKinds.const,e,t,n)}let(e,t,n){return this._def(Tt.varKinds.let,e,t,n)}var(e,t,n){return this._def(Tt.varKinds.var,e,t,n)}assign(e,t,n){return this._leafNode(new B_(e,t,n))}add(e,t){return this._leafNode(new vz(e,it.operators.ADD,t))}code(e){if(typeof e=="function")e();else if(e!==le.nil)this._leafNode(new bz(e));return this}object(...e){let t=["{"];for(let[n,o]of e){if(t.length>1)t.push(",");if(t.push(n),n!==o||this.opts.es5)t.push(":"),le.addCodeArg(t,o)}return t.push("}"),new le._Code(t)}if(e,t,n){if(this._blockNode(new dr(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new dr(e))}else(){return this._elseNode(new Fa)}endIf(){return this._endBlockNode(dr,Fa)}_for(e,t){if(this._blockNode(e),t)this.code(t).endFor();return this}for(e,t){return this._for(new zz(e),t)}forRange(e,t,n,o,r=this.opts.es5?Tt.varKinds.var:Tt.varKinds.let){let i=this._scope.toName(e);return this._for(new wz(r,i,t,n),()=>o(i))}forOf(e,t,n,o=Tt.varKinds.const){let r=this._scope.toName(e);if(this.opts.es5){let i=t instanceof le.Name?t:this.var("_arr",t);return this.forRange("_i",0,le._`${i}.length`,(a)=>{this.var(r,le._`${i}[${a}]`),n(r)})}return this._for(new K_("of",o,r,t),()=>n(r))}forIn(e,t,n,o=this.opts.es5?Tt.varKinds.var:Tt.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,le._`Object.keys(${t})`,n);let r=this._scope.toName(e);return this._for(new K_("in",o,r,t),()=>n(r))}endFor(){return this._endBlockNode(Do)}label(e){return this._leafNode(new _z(e))}break(e){return this._leafNode(new Sz(e))}return(e){let t=new pd;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(pd)}try(e,t,n){if(!t&&!n)throw Error('CodeGen: "try" without "catch" and "finally"');let o=new Rz;if(this._blockNode(o),this.code(e),t){let r=this.name("e");this._currNode=o.catch=new fd(r),t(r)}if(n)this._currNode=o.finally=new hd,this.code(n);return this._endBlockNode(fd,hd)}throw(e){return this._leafNode(new yz(e))}block(e,t){if(this._blockStarts.push(this._nodes.length),e)this.code(e).endBlock(t);return this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error("CodeGen: not in self-balancing block");let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,t=le.nil,n,o){if(this._blockNode(new md(e,t,n)),o)this.code(o).endFunc();return this}endFunc(){return this._endBlockNode(md)}optimize(e=1){while(e-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof dr))throw Error('CodeGen: "else" without "if"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}}it.CodeGen=xz;function xn(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function gd(e,t){return t instanceof le._CodeOrName?xn(e,t.names):e}function Lo(e,t,n){if(e instanceof le.Name)return o(e);if(!r(e))return e;return new le._Code(e._items.reduce((i,a)=>{if(a instanceof le.Name)a=o(a);if(a instanceof le._Code)i.push(...a._items);else i.push(a);return i},[]));function o(i){let a=n[i.str];if(a===void 0||t[i.str]!==1)return i;return delete t[i.str],a}function r(i){return i instanceof le._Code&&i._items.some((a)=>a instanceof le.Name&&t[a.str]===1&&n[a.str]!==void 0)}}function l1(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function kz(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:le._`!${G_(e)}`}it.not=kz;var u1=Iz(it.operators.AND);function d1(...e){return e.reduce(u1)}it.and=d1;var m1=Iz(it.operators.OR);function p1(...e){return e.reduce(m1)}it.or=p1;function Iz(e){return(t,n)=>t===le.nil?n:n===le.nil?t:le._`${G_(t)} ${e} ${G_(n)}`}function G_(e){return e instanceof le.Name?e:le._`(${e})`}});var de=U(function(Az){Object.defineProperty(Az,"__esModule",{value:!0});Az.checkStrictMode=Az.getErrorPath=Az.Type=Az.useFunc=Az.setEvaluated=Az.evaluatedPropsToName=Az.mergeEvaluated=Az.eachItem=Az.unescapeJsonPointer=Az.escapeJsonPointer=Az.escapeFragment=Az.unescapeFragment=Az.schemaRefOrVal=Az.schemaHasRulesButRef=Az.schemaHasRules=Az.checkUnknownRules=Az.alwaysValidSchema=Az.toHash=void 0;var ve=ce(),v1=Va();function _1(e){let t={};for(let n of e)t[n]=!0;return t}Az.toHash=_1;function S1(e,t){if(typeof t=="boolean")return t;if(Object.keys(t).length===0)return!0;return jz(e,t),!Oz(t,e.self.RULES.all)}Az.alwaysValidSchema=S1;function jz(e,t=e.schema){let{opts:n,self:o}=e;if(!n.strictSchema)return;if(typeof t==="boolean")return;let r=o.RULES.keywords;for(let i in t)if(!r[i])qz(e,`unknown keyword: "${i}"`)}Az.checkUnknownRules=jz;function Oz(e,t){if(typeof e=="boolean")return!e;for(let n in e)if(t[n])return!0;return!1}Az.schemaHasRules=Oz;function y1(e,t){if(typeof e=="boolean")return!e;for(let n in e)if(n!=="$ref"&&t.all[n])return!0;return!1}Az.schemaHasRulesButRef=y1;function b1({topSchemaRef:e,schemaPath:t},n,o,r){if(!r){if(typeof n=="number"||typeof n=="boolean")return n;if(typeof n=="string")return ve._`${n}`}return ve._`${e}${t}${ve.getProperty(o)}`}Az.schemaRefOrVal=b1;function $1(e){return Nz(decodeURIComponent(e))}Az.unescapeFragment=$1;function z1(e){return encodeURIComponent(Y_(e))}Az.escapeFragment=z1;function Y_(e){if(typeof e=="number")return`${e}`;return e.replace(/~/g,"~0").replace(/\//g,"~1")}Az.escapeJsonPointer=Y_;function Nz(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}Az.unescapeJsonPointer=Nz;function w1(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}Az.eachItem=w1;function Ez({mergeNames:e,mergeToName:t,mergeValues:n,resultToName:o}){return(r,i,a,s)=>{let c=a===void 0?i:a instanceof ve.Name?(i instanceof ve.Name?e(r,i,a):t(r,i,a),a):i instanceof ve.Name?(t(r,a,i),i):n(i,a);return s===ve.Name&&!(c instanceof ve.Name)?o(r,c):c}}Az.mergeEvaluated={props:Ez({mergeNames:(e,t,n)=>e.if(ve._`${n} !== true && ${t} !== undefined`,()=>{e.if(ve._`${t} === true`,()=>e.assign(n,!0),()=>e.assign(n,ve._`${n} || {}`).code(ve._`Object.assign(${n}, ${t})`))}),mergeToName:(e,t,n)=>e.if(ve._`${n} !== true`,()=>{if(t===!0)e.assign(n,!0);else e.assign(n,ve._`${n} || {}`),X_(e,n,t)}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Cz}),items:Ez({mergeNames:(e,t,n)=>e.if(ve._`${n} !== true && ${t} !== undefined`,()=>e.assign(n,ve._`${t} === true ? true : ${n} > ${t} ? ${n} : ${t}`)),mergeToName:(e,t,n)=>e.if(ve._`${n} !== true`,()=>e.assign(n,t===!0?!0:ve._`${n} > ${t} ? ${n} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Cz(e,t){if(t===!0)return e.var("props",!0);let n=e.var("props",ve._`{}`);if(t!==void 0)X_(e,n,t);return n}Az.evaluatedPropsToName=Cz;function X_(e,t,n){Object.keys(n).forEach((o)=>e.assign(ve._`${t}${ve.getProperty(o)}`,!0))}Az.setEvaluated=X_;var Tz={};function R1(e,t){return e.scopeValue("func",{ref:t,code:Tz[t.code]||(Tz[t.code]=new v1._Code(t.code))})}Az.useFunc=R1;var W_;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(W_||(Az.Type=W_={}));function x1(e,t,n){if(e instanceof ve.Name){let o=t===W_.Num;return n?o?ve._`"[" + ${e} + "]"`:ve._`"['" + ${e} + "']"`:o?ve._`"/" + ${e}`:ve._`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?ve.getProperty(e).toString():"/"+Y_(e)}Az.getErrorPath=x1;function qz(e,t,n=e.opts.strictSchema){if(!n)return;if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}Az.checkStrictMode=qz});var mr=U(function(Uz){Object.defineProperty(Uz,"__esModule",{value:!0});var De=ce(),F1={data:new De.Name("data"),valCxt:new De.Name("valCxt"),instancePath:new De.Name("instancePath"),parentData:new De.Name("parentData"),parentDataProperty:new De.Name("parentDataProperty"),rootData:new De.Name("rootData"),dynamicAnchors:new De.Name("dynamicAnchors"),vErrors:new De.Name("vErrors"),errors:new De.Name("errors"),this:new De.Name("this"),self:new De.Name("self"),scope:new De.Name("scope"),json:new De.Name("json"),jsonPos:new De.Name("jsonPos"),jsonLen:new De.Name("jsonLen"),jsonPart:new De.Name("jsonPart")};Uz.default=F1});var Ja=U(function(Vz){Object.defineProperty(Vz,"__esModule",{value:!0});Vz.extendErrors=Vz.resetErrorsCount=Vz.reportExtraError=Vz.reportError=Vz.keyword$DataError=Vz.keywordError=void 0;var me=ce(),yd=de(),Be=mr();Vz.keywordError={message:({keyword:e})=>me.str`must pass "${e}" keyword validation`};Vz.keyword$DataError={message:({keyword:e,schemaType:t})=>t?me.str`"${e}" keyword must be ${t} ($data)`:me.str`"${e}" keyword is invalid ($data)`};function H1(e,t=Vz.keywordError,n,o){let{it:r}=e,{gen:i,compositeRule:a,allErrors:s}=r,c=Zz(e,t,n);if(o!==null&&o!==void 0?o:a||s)Dz(i,c);else Lz(r,me._`[${c}]`)}Vz.reportError=H1;function K1(e,t=Vz.keywordError,n){let{it:o}=e,{gen:r,compositeRule:i,allErrors:a}=o,s=Zz(e,t,n);if(Dz(r,s),!(i||a))Lz(o,Be.default.vErrors)}Vz.reportExtraError=K1;function G1(e,t){e.assign(Be.default.errors,t),e.if(me._`${Be.default.vErrors} !== null`,()=>e.if(t,()=>e.assign(me._`${Be.default.vErrors}.length`,t),()=>e.assign(Be.default.vErrors,null)))}Vz.resetErrorsCount=G1;function B1({gen:e,keyword:t,schemaValue:n,data:o,errsCount:r,it:i}){if(r===void 0)throw Error("ajv implementation error");let a=e.name("err");e.forRange("i",r,Be.default.errors,(s)=>{if(e.const(a,me._`${Be.default.vErrors}[${s}]`),e.if(me._`${a}.instancePath === undefined`,()=>e.assign(me._`${a}.instancePath`,me.strConcat(Be.default.instancePath,i.errorPath))),e.assign(me._`${a}.schemaPath`,me.str`${i.errSchemaPath}/${t}`),i.opts.verbose)e.assign(me._`${a}.schema`,n),e.assign(me._`${a}.data`,o)})}Vz.extendErrors=B1;function Dz(e,t){let n=e.const("err",t);e.if(me._`${Be.default.vErrors} === null`,()=>e.assign(Be.default.vErrors,me._`[${n}]`),me._`${Be.default.vErrors}.push(${n})`),e.code(me._`${Be.default.errors}++`)}function Lz(e,t){let{gen:n,validateName:o,schemaEnv:r}=e;if(r.$async)n.throw(me._`new ${e.ValidationError}(${t})`);else n.assign(me._`${o}.errors`,t),n.return(!1)}var kn={keyword:new me.Name("keyword"),schemaPath:new me.Name("schemaPath"),params:new me.Name("params"),propertyName:new me.Name("propertyName"),message:new me.Name("message"),schema:new me.Name("schema"),parentSchema:new me.Name("parentSchema")};function Zz(e,t,n){let{createErrors:o}=e.it;if(o===!1)return me._`{}`;return W1(e,t,n)}function W1(e,t,n={}){let{gen:o,it:r}=e,i=[Y1(r,n),X1(e,n)];return Q1(e,t,i),o.object(...i)}function Y1({errorPath:e},{instancePath:t}){let n=t?me.str`${e}${yd.getErrorPath(t,yd.Type.Str)}`:e;return[Be.default.instancePath,me.strConcat(Be.default.instancePath,n)]}function X1({keyword:e,it:{errSchemaPath:t}},{schemaPath:n,parentSchema:o}){let r=o?t:me.str`${t}/${e}`;if(n)r=me.str`${r}${yd.getErrorPath(n,yd.Type.Str)}`;return[kn.schemaPath,r]}function Q1(e,{params:t,message:n},o){let{keyword:r,data:i,schemaValue:a,it:s}=e,{opts:c,propertyName:l,topSchemaRef:d,schemaPath:m}=s;if(o.push([kn.keyword,r],[kn.params,typeof t=="function"?t(e):t||me._`{}`]),c.messages)o.push([kn.message,typeof n=="function"?n(e):n]);if(c.verbose)o.push([kn.schema,a],[kn.parentSchema,me._`${d}${m}`],[Be.default.data,i]);if(l)o.push([kn.propertyName,l])}});var Gz=U(function(Hz){Object.defineProperty(Hz,"__esModule",{value:!0});Hz.boolOrEmptySchema=Hz.topBoolOrEmptySchema=void 0;var oj=Ja(),ij=ce(),aj=mr(),sj={message:"boolean schema is false"};function cj(e){let{gen:t,schema:n,validateName:o}=e;if(n===!1)Jz(e,!1);else if(typeof n=="object"&&n.$async===!0)t.return(aj.default.data);else t.assign(ij._`${o}.errors`,null),t.return(!0)}Hz.topBoolOrEmptySchema=cj;function lj(e,t){let{gen:n,schema:o}=e;if(o===!1)n.var(t,!1),Jz(e);else n.var(t,!0)}Hz.boolOrEmptySchema=lj;function Jz(e,t){let{gen:n,data:o}=e;oj.reportError({gen:n,keyword:"false schema",data:o,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e},sj,void 0,t)}});var eS=U(function(Bz){Object.defineProperty(Bz,"__esModule",{value:!0});Bz.getRules=Bz.isJSONType=void 0;var dj=["string","number","integer","boolean","null","object","array"],mj=new Set(dj);function pj(e){return typeof e=="string"&&mj.has(e)}Bz.isJSONType=pj;function fj(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Bz.getRules=fj});var tS=U(function(Qz){Object.defineProperty(Qz,"__esModule",{value:!0});Qz.shouldUseRule=Qz.shouldUseGroup=Qz.schemaHasRulesForType=void 0;function gj({schema:e,self:t},n){let o=t.RULES.types[n];return o&&o!==!0&&Yz(e,o)}Qz.schemaHasRulesForType=gj;function Yz(e,t){return t.rules.some((n)=>Xz(e,n))}Qz.shouldUseGroup=Yz;function Xz(e,t){var n;return e[t.keyword]!==void 0||((n=t.definition.implements)===null||n===void 0?void 0:n.some((o)=>e[o]!==void 0))}Qz.shouldUseRule=Xz});var Ha=U(function(ow){Object.defineProperty(ow,"__esModule",{value:!0});ow.reportTypeError=ow.checkDataTypes=ow.checkDataType=ow.coerceAndCheckDataType=ow.getJSONTypes=ow.getSchemaTypes=ow.DataType=void 0;var Sj=eS(),yj=tS(),bj=Ja(),ie=ce(),tw=de(),Zo;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Zo||(ow.DataType=Zo={}));function $j(e){let t=rw(e.type);if(t.includes("null")){if(e.nullable===!1)throw Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw Error('"nullable" cannot be used without "type"');if(e.nullable===!0)t.push("null")}return t}ow.getSchemaTypes=$j;function rw(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(Sj.isJSONType))return t;throw Error("type must be JSONType or JSONType[]: "+t.join(","))}ow.getJSONTypes=rw;function zj(e,t){let{gen:n,data:o,opts:r}=e,i=wj(t,r.coerceTypes),a=t.length>0&&!(i.length===0&&t.length===1&&yj.schemaHasRulesForType(e,t[0]));if(a){let s=nS(t,o,r.strictNumbers,Zo.Wrong);n.if(s,()=>{if(i.length)Rj(e,t,i);else oS(e)})}return a}ow.coerceAndCheckDataType=zj;var nw=new Set(["string","number","integer","boolean","null"]);function wj(e,t){return t?e.filter((n)=>nw.has(n)||t==="array"&&n==="array"):[]}function Rj(e,t,n){let{gen:o,data:r,opts:i}=e,a=o.let("dataType",ie._`typeof ${r}`),s=o.let("coerced",ie._`undefined`);if(i.coerceTypes==="array")o.if(ie._`${a} == 'object' && Array.isArray(${r}) && ${r}.length == 1`,()=>o.assign(r,ie._`${r}[0]`).assign(a,ie._`typeof ${r}`).if(nS(t,r,i.strictNumbers),()=>o.assign(s,r)));o.if(ie._`${s} !== undefined`);for(let l of n)if(nw.has(l)||l==="array"&&i.coerceTypes==="array")c(l);o.else(),oS(e),o.endIf(),o.if(ie._`${s} !== undefined`,()=>{o.assign(r,s),xj(e,s)});function c(l){switch(l){case"string":o.elseIf(ie._`${a} == "number" || ${a} == "boolean"`).assign(s,ie._`"" + ${r}`).elseIf(ie._`${r} === null`).assign(s,ie._`""`);return;case"number":o.elseIf(ie._`${a} == "boolean" || ${r} === null
4
4
  || (${a} == "string" && ${r} && ${r} == +${r})`).assign(s,ie._`+${r}`);return;case"integer":o.elseIf(ie._`${a} === "boolean" || ${r} === null
package/dist/config.d.ts CHANGED
@@ -20,6 +20,7 @@ export interface RuntimeEnv {
20
20
  MCP_OAUTH_TOOL_OVERRIDES?: string;
21
21
  /** 'true' forwards the calling client's identity upstream (client-identity.ts). */
22
22
  MCP_FORWARD_CLIENT_IDENTITY?: string;
23
+ MCP_CATALOG_SESSIONS?: string;
23
24
  MCP_MEMBER_KEY_MODE?: string;
24
25
  MCP_MEMBER_KEY_RUNTIME_URL?: string;
25
26
  MCP_MEMBER_KEY_CONNECT_URL?: string;
@@ -159,6 +160,11 @@ export interface RuntimeConfig {
159
160
  * Optional so a config built without it reads as off.
160
161
  */
161
162
  forwardClientIdentity?: boolean;
163
+ /**
164
+ * Issue catalog-keyed session ids so clients refetch tools after a deploy
165
+ * that changes them (MS-17). Optional so a config built without it is off.
166
+ */
167
+ catalogSessions?: boolean;
162
168
  }
163
169
  export declare function getProcessEnv(): RuntimeEnv;
164
170
  /**
@@ -1,4 +1,4 @@
1
- /*! @mcpcloud/runtime v0.18.0 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
1
+ /*! @mcpcloud/runtime v0.19.0 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
2
2
  var bt=Object.create;var{getPrototypeOf:Pt,defineProperty:re,getOwnPropertyNames:Ot}=Object;var Qe=Object.prototype.hasOwnProperty;function vt(e){return this[e]}var Mt,xt,Nt=(e,t,r)=>{var o=e!=null&&typeof e==="object";if(o){var l=t?Mt??=new WeakMap:xt??=new WeakMap,d=l.get(e);if(d)return d}r=e!=null?bt(Pt(e)):{};let f=t||!e||!e.__esModule||!Qe.call(e,"default")?re(r,"default",{value:e,enumerable:!0}):r;if(e&&typeof e==="object"||typeof e==="function"){for(let s of Ot(e))if(!Qe.call(f,s))re(f,s,{get:vt.bind(e,s),enumerable:!0})}if(o)l.set(e,f);return f};var Ct=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var kt=(e)=>e;function It(e,t){this[e]=kt.bind(null,t)}var Lt=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0,configurable:!0,set:It.bind(t,r)})};var ne=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(o){r=[o]}if(r)throw r[0];return t};var U,ie,j,K,F;var V=ne(()=>{U={JS_EVAL_TYPE_GLOBAL:0,JS_EVAL_TYPE_MODULE:1,JS_EVAL_TYPE_DIRECT:2,JS_EVAL_TYPE_INDIRECT:3,JS_EVAL_TYPE_MASK:3,JS_EVAL_FLAG_STRICT:8,JS_EVAL_FLAG_STRIP:16,JS_EVAL_FLAG_COMPILE_ONLY:32,JS_EVAL_FLAG_BACKTRACE_BARRIER:64},ie={BaseObjects:1,Date:2,Eval:4,StringNormalize:8,RegExp:16,RegExpCompiler:32,JSON:64,Proxy:128,MapSet:256,TypedArrays:512,Promise:1024,BigInt:2048,BigFloat:4096,BigDecimal:8192,OperatorOverloading:16384,BignumExt:32768},j={Pending:0,Fulfilled:1,Rejected:2},K={JS_GPN_STRING_MASK:1,JS_GPN_SYMBOL_MASK:2,JS_GPN_PRIVATE_MASK:4,JS_GPN_ENUM_ONLY:16,JS_GPN_SET_ENUM:32,QTS_GPN_NUMBER_MASK:64,QTS_STANDARD_COMPLIANT_NUMBER:128},F={IsStrictlyEqual:0,IsSameValue:1,IsSameValueZero:2}});function H(...e){ce&&console.log("quickjs-emscripten:",...e)}function*ot(e){return yield e}function Jt(e){return ot(de(e))}function $e(e,t){return(...r)=>{let o=t.call(e,he,...r);return de(o)}}function Dt(e,t){let r=t.call(e,he);return de(r)}function de(e){function t(r){return r.done?r.value:r.value instanceof Promise?r.value.then((o)=>t(e.next(o)),(o)=>t(e.throw(o))):t(e.next(r.value))}return t(e.next())}function se(e,t){let r;try{e.dispose()}catch(o){r=o}if(t&&r)throw Object.assign(t,{message:`${t.message}
3
3
  Then, failed to dispose scope: ${r.message}`,disposeError:r}),t;if(t||r)throw t||r}function Qt(e){let t=e?Array.from(e):[];function r(){return t.forEach((l)=>l.alive?l.dispose():void 0)}function o(){return t.some((l)=>l.alive)}return Object.defineProperty(t,le,{configurable:!0,enumerable:!1,value:r}),Object.defineProperty(t,"dispose",{configurable:!0,enumerable:!1,value:r}),Object.defineProperty(t,"alive",{configurable:!0,enumerable:!1,get:o}),t}function W(e){return!!(e&&(typeof e=="object"||typeof e=="function")&&("alive"in e)&&typeof e.alive=="boolean"&&("dispose"in e)&&typeof e.dispose=="function")}function Gt(e){if(!e)return 0;let t=0;for(let[r,o]of Object.entries(e)){if(!(r in ie))throw new rt(r);o&&(t|=ie[r])}return t}function Wt(e){if(typeof e=="number")return e;if(e===void 0)return 0;let{type:t,strict:r,strip:o,compileOnly:l,backtraceBarrier:d}=e,f=0;return t==="global"&&(f|=U.JS_EVAL_TYPE_GLOBAL),t==="module"&&(f|=U.JS_EVAL_TYPE_MODULE),r&&(f|=U.JS_EVAL_FLAG_STRICT),o&&(f|=U.JS_EVAL_FLAG_STRIP),l&&(f|=U.JS_EVAL_FLAG_COMPILE_ONLY),d&&(f|=U.JS_EVAL_FLAG_BACKTRACE_BARRIER),f}function qt(e){if(typeof e=="number")return e;if(e===void 0)return 0;let{strings:t,symbols:r,quickjsPrivate:o,onlyEnumerable:l,numbers:d,numbersAsStrings:f}=e,s=0;return t&&(s|=K.JS_GPN_STRING_MASK),r&&(s|=K.JS_GPN_SYMBOL_MASK),o&&(s|=K.JS_GPN_PRIVATE_MASK),l&&(s|=K.JS_GPN_ENUM_ONLY),d&&(s|=K.QTS_GPN_NUMBER_MASK),f&&(s|=K.QTS_STANDARD_COMPLIANT_NUMBER),s}function zt(...e){let t=[];for(let r of e)r!==void 0&&(t=t.concat(r));return t}function oe(e){return e>>8}function pe(e,t){t.interruptHandler&&e.setInterruptHandler(t.interruptHandler),t.maxStackSizeBytes!==void 0&&e.setMaxStackSize(t.maxStackSizeBytes),t.memoryLimitBytes!==void 0&&e.setMemoryLimit(t.memoryLimitBytes)}function _e(e,t){t.moduleLoader&&e.setModuleLoader(t.moduleLoader),t.shouldInterrupt&&e.setInterruptHandler(t.shouldInterrupt),t.memoryLimitBytes!==void 0&&e.setMemoryLimit(t.memoryLimitBytes),t.maxStackSizeBytes!==void 0&&e.setMaxStackSize(t.maxStackSizeBytes)}var Kt,Bt=(e,t)=>{for(var r in t)Kt(e,r,{get:t[r],enumerable:!0})},ce=!1,Yt,ae,Xe,ue,Ze,et,tt,Ft,Ht,rt,nt,it,st,I,he,N,le,Ve,A,B,Ge,M,fe,jt,$t,Y,Vt,at=class{constructor(e){this.module=e}toPointerArray(e){let t=new Int32Array(e.map((l)=>l.value)),r=t.length*t.BYTES_PER_ELEMENT,o=this.module._malloc(r);return new Uint8Array(this.module.HEAPU8.buffer,o,r).set(new Uint8Array(t.buffer)),new A(o,void 0,(l)=>this.module._free(l))}newTypedArray(e,t){let r=new e(Array(t).fill(0)),o=r.length*r.BYTES_PER_ELEMENT,l=this.module._malloc(o),d=new e(this.module.HEAPU8.buffer,l,t);return d.set(r),new A({typedArray:d,ptr:l},void 0,(f)=>this.module._free(f.ptr))}newMutablePointerArray(e){return this.newTypedArray(Int32Array,e)}newHeapCharPointer(e){let t=this.module.lengthBytesUTF8(e),r=t+1,o=this.module._malloc(r);return this.module.stringToUTF8(e,o,r),new A({ptr:o,strlen:t},void 0,(l)=>this.module._free(l.ptr))}newHeapBufferPointer(e){let t=e.byteLength,r=this.module._malloc(t);return this.module.HEAPU8.set(e,r),new A({pointer:r,numBytes:t},void 0,(o)=>this.module._free(o.pointer))}consumeHeapCharPointer(e){let t=this.module.UTF8ToString(e);return this.module._free(e),t}},Lr,Ur,Xt,We=-2147483648,qe=2147483647,G=0,Zt=class{constructor(){this.nextId=We,this.freelist=[],this.groups=new Map}put(e){let t=this.allocateId(),r=oe(t),o=this.groups.get(r);return o||(o=new Map,this.groups.set(r,o)),o.set(t,e),t}get(e){if(e===G)throw new I("no host reference id defined");let t=oe(e),r=this.groups.get(t);if(!r)throw new I(`host reference id ${e} is not defined`);let o=r.get(e);if(!o)throw new I(`host reference id ${e} is not defined`);return o}delete(e){if(e===G)throw new I("no host reference id defined");let t=oe(e),r=this.groups.get(t);if(!r)throw new I(`host reference id ${e} is not defined`);r.delete(e),r.size===0&&this.groups.delete(t),this.freelist.push(e)}allocateId(){if(this.freelist.length>0)return this.freelist.shift();if(this.nextId===G&&this.nextId++,this.nextId>qe)throw new st(`HostRefMap: too many host refs created without disposing. Max simultaneous host refs: ${qe-We}`);return this.nextId++}},ze,er,tr,rr,nr=class{constructor(e){this.freeHostRef=e.freeHostRef,this.callFunction=e.callFunction,this.shouldInterrupt=e.shouldInterrupt,this.loadModuleSource=e.loadModuleSource,this.normalizeModule=e.normalizeModule}},me=class{constructor(e){this.contextCallbacks=new Map,this.runtimeCallbacks=new Map,this.suspendedCount=0,this.cToHostCallbacks=new nr({freeHostRef:(t,r,o)=>{let l=this.runtimeCallbacks.get(r);if(!l)throw Error(`QuickJSRuntime(rt = ${r}) not found when trying to free HostRef(id = ${o})`);l.freeHostRef(r,o)},callFunction:(t,r,o,l,d,f)=>this.handleAsyncify(t,()=>{try{let s=this.contextCallbacks.get(r);if(!s)throw Error(`QuickJSContext(ctx = ${r}) not found for C function call "${f}"`);return s.callFunction(r,o,l,d,f)}catch(s){return console.error("[C to host error: returning null]",s),0}}),shouldInterrupt:(t,r)=>this.handleAsyncify(t,()=>{try{let o=this.runtimeCallbacks.get(r);if(!o)throw Error(`QuickJSRuntime(rt = ${r}) not found for C interrupt`);return o.shouldInterrupt(r)}catch(o){return console.error("[C to host interrupt: returning error]",o),1}}),loadModuleSource:(t,r,o,l)=>this.handleAsyncify(t,()=>{try{let d=this.runtimeCallbacks.get(r);if(!d)throw Error(`QuickJSRuntime(rt = ${r}) not found for C module loader`);let f=d.loadModuleSource;if(!f)throw Error(`QuickJSRuntime(rt = ${r}) does not support module loading`);return f(r,o,l)}catch(d){return console.error("[C to host module loader error: returning null]",d),0}}),normalizeModule:(t,r,o,l,d)=>this.handleAsyncify(t,()=>{try{let f=this.runtimeCallbacks.get(r);if(!f)throw Error(`QuickJSRuntime(rt = ${r}) not found for C module loader`);let s=f.normalizeModule;if(!s)throw Error(`QuickJSRuntime(rt = ${r}) does not support module loading`);return s(r,o,l,d)}catch(f){return console.error("[C to host module loader error: returning null]",f),0}})}),this.module=e,this.module.callbacks=this.cToHostCallbacks}setRuntimeCallbacks(e,t){this.runtimeCallbacks.set(e,t)}deleteRuntime(e){this.runtimeCallbacks.delete(e)}setContextCallbacks(e,t){this.contextCallbacks.set(e,t)}deleteContext(e){this.contextCallbacks.delete(e)}handleAsyncify(e,t){if(e)return e.handleSleep((o)=>{try{let l=t();if(!(l instanceof Promise)){H("asyncify.handleSleep: not suspending:",l),o(l);return}if(this.suspended)throw new et(`Already suspended at: ${this.suspended.stack}
4
4
  Attempted to suspend at:`);this.suspended=new tt(`(${this.suspendedCount++})`),H("asyncify.handleSleep: suspending:",this.suspended),l.then((d)=>{this.suspended=void 0,H("asyncify.handleSleep: resolved:",d),o(d)},(d)=>{H("asyncify.handleSleep: rejected:",d),console.error("QuickJS: cannot handle error in suspended function",d),this.suspended=void 0})}catch(l){throw H("asyncify.handleSleep: error:",l),this.suspended=void 0,l}});let r=t();if(r instanceof Promise)throw Error("Promise return value not supported in non-asyncify context.");return r}},ut=class{constructor(e,t){this.module=e,this.ffi=t,this.callbacks=new me(e)}newRuntime(e={}){let t=new A(this.ffi.QTS_NewRuntime(),void 0,(o)=>{this.ffi.QTS_FreeRuntime(o),this.callbacks.deleteRuntime(o)}),r=new rr({module:this.module,callbacks:this.callbacks,ffi:this.ffi,rt:t});return pe(r,e),e.moduleLoader&&r.setModuleLoader(e.moduleLoader),r}newContext(e={}){let t=this.newRuntime(),r=t.newContext({...e,ownedLifetimes:zt(t,e.ownedLifetimes)});return t.context=r,r}evalCode(e,t={}){return M.withScope((r)=>{let o=r.manage(this.newContext());_e(o.runtime,t);let l=o.evalCode(e,"eval.js");if(t.memoryLimitBytes!==void 0&&o.runtime.setMemoryLimit(-1),l.error)throw o.dump(r.manage(l.error));return o.dump(r.manage(l.value))})}getWasmMemory(){let e=this.module.quickjsEmscriptenInit?.(()=>{})?.getWasmMemory?.();if(!e)throw Error("Variant does not support getting WebAssembly.Memory");return e}getFFI(){return this.ffi}};var lt=ne(()=>{V();V();Kt=Object.defineProperty;Yt={};Bt(Yt,{QuickJSAsyncifyError:()=>et,QuickJSAsyncifySuspended:()=>tt,QuickJSEmptyGetOwnPropertyNames:()=>it,QuickJSEmscriptenModuleError:()=>Ht,QuickJSHostRefInvalid:()=>I,QuickJSHostRefRangeExceeded:()=>st,QuickJSMemoryLeakDetected:()=>Ft,QuickJSNotImplemented:()=>Ze,QuickJSPromisePending:()=>nt,QuickJSUnknownIntrinsic:()=>rt,QuickJSUnwrapError:()=>ae,QuickJSUseAfterFree:()=>ue,QuickJSWrongOwner:()=>Xe});ae=class extends Error{constructor(e,t){let r=typeof e=="object"&&e&&"message"in e?String(e.message):String(e);super(r);this.cause=e,this.context=t,this.name="QuickJSUnwrapError"}},Xe=class extends Error{constructor(){super(...arguments);this.name="QuickJSWrongOwner"}},ue=class extends Error{constructor(){super(...arguments);this.name="QuickJSUseAfterFree"}},Ze=class extends Error{constructor(){super(...arguments);this.name="QuickJSNotImplemented"}},et=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifyError"}},tt=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifySuspended"}},Ft=class extends Error{constructor(){super(...arguments);this.name="QuickJSMemoryLeakDetected"}},Ht=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmscriptenModuleError"}},rt=class extends TypeError{constructor(){super(...arguments);this.name="QuickJSUnknownIntrinsic"}},nt=class extends Error{constructor(){super(...arguments);this.name="QuickJSPromisePending"}},it=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmptyGetOwnPropertyNames"}},st=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefRangeExceeded"}},I=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefInvalid"}};he=ot;he.of=Jt;N=class{[Symbol.dispose](){return this.dispose()}},le=Symbol.dispose??Symbol.for("Symbol.dispose"),Ve=N.prototype;Ve[le]||(Ve[le]=function(){return this.dispose()});A=class e extends N{constructor(t,r,o,l){super();this._value=t,this.copier=r,this.disposer=o,this._owner=l,this._alive=!0,this._constructorStack=ce?Error("Lifetime constructed").stack:void 0}get alive(){return this._alive}get value(){return this.assertAlive(),this._value}get owner(){return this._owner}get dupable(){return!!this.copier}dup(){if(this.assertAlive(),!this.copier)throw Error("Non-dupable lifetime");return new e(this.copier(this._value),this.copier,this.disposer,this._owner)}consume(t){this.assertAlive();let r=t(this);return this.dispose(),r}map(t){return this.assertAlive(),t(this)}tap(t){return t(this),this}dispose(){this.assertAlive(),this.disposer&&this.disposer(this._value),this._alive=!1}assertAlive(){if(!this.alive)throw this._constructorStack?new ue(`Lifetime not alive
package/dist/http.d.ts CHANGED
@@ -29,7 +29,7 @@ export declare function parseRetryAfterSeconds(headerValue: string | null): numb
29
29
  * after the handler's one forced refresh has already failed — a shared-key
30
30
  * server's 401 is the operator's problem and no end user can act on it.
31
31
  */
32
- export declare function describeRefusedMemberCredential(status: number, config: Pick<RuntimeConfig, 'memberKey' | 'serverName'> | null | undefined): string | null;
32
+ export declare function describeRefusedMemberCredential(status: number, config: Pick<RuntimeConfig, 'memberKey' | 'serverName'> | null | undefined, payload?: unknown): string | null;
33
33
  export declare function mapUpstreamError(tool: ToolDefinition, status: number, payload: unknown, retryAfterSeconds?: number | null, config?: Pick<RuntimeConfig, 'memberKey' | 'serverName'> | null): UpstreamHttpError;
34
34
  export declare function normalizeUpstreamPayload(tool: ToolDefinition, response: Response, payload: unknown, config?: Pick<RuntimeConfig, 'memberKey' | 'serverName'> | null): unknown;
35
35
  export declare function formatToolResultText(tool: ToolDefinition, payload: unknown): string;