@mcpcloud/runtime 0.12.1 → 0.12.3

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/node.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @mcpcloud/runtime v0.12.1 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
1
+ /*! @mcpcloud/runtime v0.12.3 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
2
2
  var L9=Object.create;var{getPrototypeOf:O9,defineProperty:$8,getOwnPropertyNames:F9}=Object;var R9=Object.prototype.hasOwnProperty;function M9(Z){return this[Z]}var V9,_9,w9=(Z,$,W)=>{var Q=Z!=null&&typeof Z==="object";if(Q){var B=$?V9??=new WeakMap:_9??=new WeakMap,C=B.get(Z);if(C)return C}W=Z!=null?L9(O9(Z)):{};let H=$||!Z||!Z.__esModule?$8(W,"default",{value:Z,enumerable:!0}):W;for(let K of F9(Z))if(!R9.call(H,K))$8(H,K,{get:M9.bind(Z,K),enumerable:!0});if(Q)B.set(Z,H);return H};var P9=(Z,$)=>()=>($||Z(($={exports:{}}).exports,$),$.exports);var N9=(Z)=>Z;function E9(Z,$){this[Z]=N9.bind(null,$)}var S9=(Z,$)=>{for(var W in $)$8(Z,W,{get:$[W],enumerable:!0,configurable:!0,set:E9.bind($,W)})};var X8=(Z,$)=>()=>(Z&&($=Z(Z=0)),$);var k,W8,l,h,c;var i=X8(()=>{k={JS_EVAL_TYPE_GLOBAL:0,JS_EVAL_TYPE_MODULE:1,JS_EVAL_TYPE_DIRECT:2,JS_EVAL_TYPE_INDIRECT:3,JS_EVAL_TYPE_MASK:3,JS_EVAL_FLAG_STRICT:8,JS_EVAL_FLAG_STRIP:16,JS_EVAL_FLAG_COMPILE_ONLY:32,JS_EVAL_FLAG_BACKTRACE_BARRIER:64},W8={BaseObjects:1,Date:2,Eval:4,StringNormalize:8,RegExp:16,RegExpCompiler:32,JSON:64,Proxy:128,MapSet:256,TypedArrays:512,Promise:1024,BigInt:2048,BigFloat:4096,BigDecimal:8192,OperatorOverloading:16384,BignumExt:32768},l={Pending:0,Fulfilled:1,Rejected:2},h={JS_GPN_STRING_MASK:1,JS_GPN_SYMBOL_MASK:2,JS_GPN_PRIVATE_MASK:4,JS_GPN_ENUM_ONLY:16,JS_GPN_SET_ENUM:32,QTS_GPN_NUMBER_MASK:64,QTS_STANDARD_COMPLIANT_NUMBER:128},c={IsStrictlyEqual:0,IsSameValue:1,IsSameValueZero:2}});function m(...Z){B8&&console.log("quickjs-emscripten:",...Z)}function*X9(Z){return yield Z}function y9(Z){return X9(q8(Z))}function d8(Z,$){return(...W)=>{let Q=$.call(Z,J8,...W);return q8(Q)}}function k9(Z,$){let W=$.call(Z,J8);return q8(W)}function q8(Z){function $(W){return W.done?W.value:W.value instanceof Promise?W.value.then((Q)=>$(Z.next(Q)),(Q)=>$(Z.throw(Q))):$(Z.next(W.value))}return $(Z.next())}function z8(Z,$){let W;try{Z.dispose()}catch(Q){W=Q}if($&&W)throw Object.assign($,{message:`${$.message}
3
3
  Then, failed to dispose scope: ${W.message}`,disposeError:W}),$;if($||W)throw $||W}function h9(Z){let $=Z?Array.from(Z):[];function W(){return $.forEach((B)=>B.alive?B.dispose():void 0)}function Q(){return $.some((B)=>B.alive)}return Object.defineProperty($,G8,{configurable:!0,enumerable:!1,value:W}),Object.defineProperty($,"dispose",{configurable:!0,enumerable:!1,value:W}),Object.defineProperty($,"alive",{configurable:!0,enumerable:!1,get:Q}),$}function n(Z){return!!(Z&&(typeof Z=="object"||typeof Z=="function")&&("alive"in Z)&&typeof Z.alive=="boolean"&&("dispose"in Z)&&typeof Z.dispose=="function")}function m9(Z){if(!Z)return 0;let $=0;for(let[W,Q]of Object.entries(Z)){if(!(W in W8))throw new r8(W);Q&&($|=W8[W])}return $}function d9(Z){if(typeof Z=="number")return Z;if(Z===void 0)return 0;let{type:$,strict:W,strip:Q,compileOnly:B,backtraceBarrier:C}=Z,H=0;return $==="global"&&(H|=k.JS_EVAL_TYPE_GLOBAL),$==="module"&&(H|=k.JS_EVAL_TYPE_MODULE),W&&(H|=k.JS_EVAL_FLAG_STRICT),Q&&(H|=k.JS_EVAL_FLAG_STRIP),B&&(H|=k.JS_EVAL_FLAG_COMPILE_ONLY),C&&(H|=k.JS_EVAL_FLAG_BACKTRACE_BARRIER),H}function p9(Z){if(typeof Z=="number")return Z;if(Z===void 0)return 0;let{strings:$,symbols:W,quickjsPrivate:Q,onlyEnumerable:B,numbers:C,numbersAsStrings:H}=Z,K=0;return $&&(K|=h.JS_GPN_STRING_MASK),W&&(K|=h.JS_GPN_SYMBOL_MASK),Q&&(K|=h.JS_GPN_PRIVATE_MASK),B&&(K|=h.JS_GPN_ENUM_ONLY),C&&(K|=h.QTS_GPN_NUMBER_MASK),H&&(K|=h.QTS_STANDARD_COMPLIANT_NUMBER),K}function u9(...Z){let $=[];for(let W of Z)W!==void 0&&($=$.concat(W));return $}function K8(Z){return Z>>8}function H8(Z,$){$.interruptHandler&&Z.setInterruptHandler($.interruptHandler),$.maxStackSizeBytes!==void 0&&Z.setMaxStackSize($.maxStackSizeBytes),$.memoryLimitBytes!==void 0&&Z.setMemoryLimit($.memoryLimitBytes)}function j8(Z,$){$.moduleLoader&&Z.setModuleLoader($.moduleLoader),$.shouldInterrupt&&Z.setInterruptHandler($.shouldInterrupt),$.memoryLimitBytes!==void 0&&Z.setMemoryLimit($.memoryLimitBytes),$.maxStackSizeBytes!==void 0&&Z.setMaxStackSize($.maxStackSizeBytes)}var x9,b9=(Z,$)=>{for(var W in $)x9(Z,W,{get:$[W],enumerable:!0})},B8=!1,A9,Y8,n8,Q8,a8,s8,t8,T9,f9,r8,e8,Z9,$9,f,J8,b,G8,p8,w,v,u8,I,C8,v9,g9,g,c9,W9=class{constructor(Z){this.module=Z}toPointerArray(Z){let $=new Int32Array(Z.map((B)=>B.value)),W=$.length*$.BYTES_PER_ELEMENT,Q=this.module._malloc(W);return new Uint8Array(this.module.HEAPU8.buffer,Q,W).set(new Uint8Array($.buffer)),new w(Q,void 0,(B)=>this.module._free(B))}newTypedArray(Z,$){let W=new Z(Array($).fill(0)),Q=W.length*W.BYTES_PER_ELEMENT,B=this.module._malloc(Q),C=new Z(this.module.HEAPU8.buffer,B,$);return C.set(W),new w({typedArray:C,ptr:B},void 0,(H)=>this.module._free(H.ptr))}newMutablePointerArray(Z){return this.newTypedArray(Int32Array,Z)}newHeapCharPointer(Z){let $=this.module.lengthBytesUTF8(Z),W=$+1,Q=this.module._malloc(W);return this.module.stringToUTF8(Z,Q,W),new w({ptr:Q,strlen:$},void 0,(B)=>this.module._free(B.ptr))}newHeapBufferPointer(Z){let $=Z.byteLength,W=this.module._malloc($);return this.module.HEAPU8.set(Z,W),new w({pointer:W,numBytes:$},void 0,(Q)=>this.module._free(Q.pointer))}consumeHeapCharPointer(Z){let $=this.module.UTF8ToString(Z);return this.module._free(Z),$}},RZ,MZ,l9,l8=-2147483648,i8=2147483647,o=0,i9=class{constructor(){this.nextId=l8,this.freelist=[],this.groups=new Map}put(Z){let $=this.allocateId(),W=K8($),Q=this.groups.get(W);return Q||(Q=new Map,this.groups.set(W,Q)),Q.set($,Z),$}get(Z){if(Z===o)throw new f("no host reference id defined");let $=K8(Z),W=this.groups.get($);if(!W)throw new f(`host reference id ${Z} is not defined`);let Q=W.get(Z);if(!Q)throw new f(`host reference id ${Z} is not defined`);return Q}delete(Z){if(Z===o)throw new f("no host reference id defined");let $=K8(Z),W=this.groups.get($);if(!W)throw new f(`host reference id ${Z} is not defined`);W.delete(Z),W.size===0&&this.groups.delete($),this.freelist.push(Z)}allocateId(){if(this.freelist.length>0)return this.freelist.shift();if(this.nextId===o&&this.nextId++,this.nextId>i8)throw new $9(`HostRefMap: too many host refs created without disposing. Max simultaneous host refs: ${i8-l8}`);return this.nextId++}},o8,o9,n9,a9,s9=class{constructor(Z){this.freeHostRef=Z.freeHostRef,this.callFunction=Z.callFunction,this.shouldInterrupt=Z.shouldInterrupt,this.loadModuleSource=Z.loadModuleSource,this.normalizeModule=Z.normalizeModule}},U8=class{constructor(Z){this.contextCallbacks=new Map,this.runtimeCallbacks=new Map,this.suspendedCount=0,this.cToHostCallbacks=new s9({freeHostRef:($,W,Q)=>{let B=this.runtimeCallbacks.get(W);if(!B)throw Error(`QuickJSRuntime(rt = ${W}) not found when trying to free HostRef(id = ${Q})`);B.freeHostRef(W,Q)},callFunction:($,W,Q,B,C,H)=>this.handleAsyncify($,()=>{try{let K=this.contextCallbacks.get(W);if(!K)throw Error(`QuickJSContext(ctx = ${W}) not found for C function call "${H}"`);return K.callFunction(W,Q,B,C,H)}catch(K){return console.error("[C to host error: returning null]",K),0}}),shouldInterrupt:($,W)=>this.handleAsyncify($,()=>{try{let Q=this.runtimeCallbacks.get(W);if(!Q)throw Error(`QuickJSRuntime(rt = ${W}) not found for C interrupt`);return Q.shouldInterrupt(W)}catch(Q){return console.error("[C to host interrupt: returning error]",Q),1}}),loadModuleSource:($,W,Q,B)=>this.handleAsyncify($,()=>{try{let C=this.runtimeCallbacks.get(W);if(!C)throw Error(`QuickJSRuntime(rt = ${W}) not found for C module loader`);let H=C.loadModuleSource;if(!H)throw Error(`QuickJSRuntime(rt = ${W}) does not support module loading`);return H(W,Q,B)}catch(C){return console.error("[C to host module loader error: returning null]",C),0}}),normalizeModule:($,W,Q,B,C)=>this.handleAsyncify($,()=>{try{let H=this.runtimeCallbacks.get(W);if(!H)throw Error(`QuickJSRuntime(rt = ${W}) not found for C module loader`);let K=H.normalizeModule;if(!K)throw Error(`QuickJSRuntime(rt = ${W}) does not support module loading`);return K(W,Q,B,C)}catch(H){return console.error("[C to host module loader error: returning null]",H),0}})}),this.module=Z,this.module.callbacks=this.cToHostCallbacks}setRuntimeCallbacks(Z,$){this.runtimeCallbacks.set(Z,$)}deleteRuntime(Z){this.runtimeCallbacks.delete(Z)}setContextCallbacks(Z,$){this.contextCallbacks.set(Z,$)}deleteContext(Z){this.contextCallbacks.delete(Z)}handleAsyncify(Z,$){if(Z)return Z.handleSleep((Q)=>{try{let B=$();if(!(B instanceof Promise)){m("asyncify.handleSleep: not suspending:",B),Q(B);return}if(this.suspended)throw new s8(`Already suspended at: ${this.suspended.stack}
4
4
  Attempted to suspend at:`);this.suspended=new t8(`(${this.suspendedCount++})`),m("asyncify.handleSleep: suspending:",this.suspended),B.then((C)=>{this.suspended=void 0,m("asyncify.handleSleep: resolved:",C),Q(C)},(C)=>{m("asyncify.handleSleep: rejected:",C),console.error("QuickJS: cannot handle error in suspended function",C),this.suspended=void 0})}catch(B){throw m("asyncify.handleSleep: error:",B),this.suspended=void 0,B}});let W=$();if(W instanceof Promise)throw Error("Promise return value not supported in non-asyncify context.");return W}},z9=class{constructor(Z,$){this.module=Z,this.ffi=$,this.callbacks=new U8(Z)}newRuntime(Z={}){let $=new w(this.ffi.QTS_NewRuntime(),void 0,(Q)=>{this.ffi.QTS_FreeRuntime(Q),this.callbacks.deleteRuntime(Q)}),W=new a9({module:this.module,callbacks:this.callbacks,ffi:this.ffi,rt:$});return H8(W,Z),Z.moduleLoader&&W.setModuleLoader(Z.moduleLoader),W}newContext(Z={}){let $=this.newRuntime(),W=$.newContext({...Z,ownedLifetimes:u9($,Z.ownedLifetimes)});return $.context=W,W}evalCode(Z,$={}){return I.withScope((W)=>{let Q=W.manage(this.newContext());j8(Q.runtime,$);let B=Q.evalCode(Z,"eval.js");if($.memoryLimitBytes!==void 0&&Q.runtime.setMemoryLimit(-1),B.error)throw Q.dump(W.manage(B.error));return Q.dump(W.manage(B.value))})}getWasmMemory(){let Z=this.module.quickjsEmscriptenInit?.(()=>{})?.getWasmMemory?.();if(!Z)throw Error("Variant does not support getting WebAssembly.Memory");return Z}getFFI(){return this.ffi}};var K9=X8(()=>{i();i();x9=Object.defineProperty;A9={};b9(A9,{QuickJSAsyncifyError:()=>s8,QuickJSAsyncifySuspended:()=>t8,QuickJSEmptyGetOwnPropertyNames:()=>Z9,QuickJSEmscriptenModuleError:()=>f9,QuickJSHostRefInvalid:()=>f,QuickJSHostRefRangeExceeded:()=>$9,QuickJSMemoryLeakDetected:()=>T9,QuickJSNotImplemented:()=>a8,QuickJSPromisePending:()=>e8,QuickJSUnknownIntrinsic:()=>r8,QuickJSUnwrapError:()=>Y8,QuickJSUseAfterFree:()=>Q8,QuickJSWrongOwner:()=>n8});Y8=class extends Error{constructor(Z,$){let W=typeof Z=="object"&&Z&&"message"in Z?String(Z.message):String(Z);super(W);this.cause=Z,this.context=$,this.name="QuickJSUnwrapError"}},n8=class extends Error{constructor(){super(...arguments);this.name="QuickJSWrongOwner"}},Q8=class extends Error{constructor(){super(...arguments);this.name="QuickJSUseAfterFree"}},a8=class extends Error{constructor(){super(...arguments);this.name="QuickJSNotImplemented"}},s8=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifyError"}},t8=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifySuspended"}},T9=class extends Error{constructor(){super(...arguments);this.name="QuickJSMemoryLeakDetected"}},f9=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmscriptenModuleError"}},r8=class extends TypeError{constructor(){super(...arguments);this.name="QuickJSUnknownIntrinsic"}},e8=class extends Error{constructor(){super(...arguments);this.name="QuickJSPromisePending"}},Z9=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmptyGetOwnPropertyNames"}},$9=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefRangeExceeded"}},f=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefInvalid"}};J8=X9;J8.of=y9;b=class{[Symbol.dispose](){return this.dispose()}},G8=Symbol.dispose??Symbol.for("Symbol.dispose"),p8=b.prototype;p8[G8]||(p8[G8]=function(){return this.dispose()});w=class Z extends b{constructor($,W,Q,B){super();this._value=$,this.copier=W,this.disposer=Q,this._owner=B,this._alive=!0,this._constructorStack=B8?Error("Lifetime constructed").stack:void 0}get alive(){return this._alive}get value(){return this.assertAlive(),this._value}get owner(){return this._owner}get dupable(){return!!this.copier}dup(){if(this.assertAlive(),!this.copier)throw Error("Non-dupable lifetime");return new Z(this.copier(this._value),this.copier,this.disposer,this._owner)}consume($){this.assertAlive();let W=$(this);return this.dispose(),W}map($){return this.assertAlive(),$(this)}tap($){return $(this),this}dispose(){this.assertAlive(),this.disposer&&this.disposer(this._value),this._alive=!1}assertAlive(){if(!this.alive)throw this._constructorStack?new Q8(`Lifetime not alive
@@ -103,6 +103,12 @@ export interface InstallBindingsResult {
103
103
  exceededCap: () => boolean;
104
104
  /** True once a call was refused by the effect-class gate. */
105
105
  deniedByPolicy: () => boolean;
106
+ /**
107
+ * True once a host hook threw synchronously. Distinct from a tool failing:
108
+ * this is a defect in the HOST, and the caller may want to surface it
109
+ * differently from an upstream error the guest could reasonably retry.
110
+ */
111
+ hostThrew: () => boolean;
106
112
  }
107
113
  /**
108
114
  * Give the guest a `tool()` function.
package/dist/stdio.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @mcpcloud/runtime v0.12.1 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
1
+ /*! @mcpcloud/runtime v0.12.3 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
2
2
  var A3=Object.create;var{getPrototypeOf:j3,defineProperty:t1,getOwnPropertyNames:S3}=Object;var b3=Object.prototype.hasOwnProperty;function T3(W){return this[W]}var k3,v3,x3=(W,X,Y)=>{var Q=W!=null&&typeof W==="object";if(Q){var K=X?k3??=new WeakMap:v3??=new WeakMap,q=K.get(W);if(q)return q}Y=W!=null?A3(j3(W)):{};let J=X||!W||!W.__esModule?t1(Y,"default",{value:W,enumerable:!0}):Y;for(let G of S3(W))if(!b3.call(J,G))t1(J,G,{get:T3.bind(W,G),enumerable:!0});if(Q)K.set(W,J);return J};var g3=(W,X)=>()=>(X||W((X={exports:{}}).exports,X),X.exports);var h3=(W)=>W;function y3(W,X){this[W]=h3.bind(null,X)}var a1=(W,X)=>{for(var Y in X)t1(W,Y,{get:X[Y],enumerable:!0,configurable:!0,set:y3.bind(X,Y)})};var s1=(W,X)=>()=>(W&&(X=W(W=0)),X);var S0,a9,m1,b0,$1;var u1=s1(()=>{S0={JS_EVAL_TYPE_GLOBAL:0,JS_EVAL_TYPE_MODULE:1,JS_EVAL_TYPE_DIRECT:2,JS_EVAL_TYPE_INDIRECT:3,JS_EVAL_TYPE_MASK:3,JS_EVAL_FLAG_STRICT:8,JS_EVAL_FLAG_STRIP:16,JS_EVAL_FLAG_COMPILE_ONLY:32,JS_EVAL_FLAG_BACKTRACE_BARRIER:64},a9={BaseObjects:1,Date:2,Eval:4,StringNormalize:8,RegExp:16,RegExpCompiler:32,JSON:64,Proxy:128,MapSet:256,TypedArrays:512,Promise:1024,BigInt:2048,BigFloat:4096,BigDecimal:8192,OperatorOverloading:16384,BignumExt:32768},m1={Pending:0,Fulfilled:1,Rejected:2},b0={JS_GPN_STRING_MASK:1,JS_GPN_SYMBOL_MASK:2,JS_GPN_PRIVATE_MASK:4,JS_GPN_ENUM_ONLY:16,JS_GPN_SET_ENUM:32,QTS_GPN_NUMBER_MASK:64,QTS_STANDARD_COMPLIANT_NUMBER:128},$1={IsStrictlyEqual:0,IsSameValue:1,IsSameValueZero:2}});function H1(...W){Q4&&console.log("quickjs-emscripten:",...W)}function*L3(W){return yield W}function M7(W){return L3(G4(W))}function eW(W,X){return(...Y)=>{let Q=X.call(W,K4,...Y);return G4(Q)}}function F7(W,X){let Y=X.call(W,K4);return G4(Y)}function G4(W){function X(Y){return Y.done?Y.value:Y.value instanceof Promise?Y.value.then((Q)=>X(W.next(Q)),(Q)=>X(W.throw(Q))):X(W.next(Y.value))}return X(W.next())}function s9(W,X){let Y;try{W.dispose()}catch(Q){Y=Q}if(X&&Y)throw Object.assign(X,{message:`${X.message}
3
3
  Then, failed to dispose scope: ${Y.message}`,disposeError:Y}),X;if(X||Y)throw X||Y}function O7(W){let X=W?Array.from(W):[];function Y(){return X.forEach((K)=>K.alive?K.dispose():void 0)}function Q(){return X.some((K)=>K.alive)}return Object.defineProperty(X,Y4,{configurable:!0,enumerable:!1,value:Y}),Object.defineProperty(X,"dispose",{configurable:!0,enumerable:!1,value:Y}),Object.defineProperty(X,"alive",{configurable:!0,enumerable:!1,get:Q}),X}function l1(W){return!!(W&&(typeof W=="object"||typeof W=="function")&&("alive"in W)&&typeof W.alive=="boolean"&&("dispose"in W)&&typeof W.dispose=="function")}function Z7(W){if(!W)return 0;let X=0;for(let[Y,Q]of Object.entries(W)){if(!(Y in a9))throw new B3(Y);Q&&(X|=a9[Y])}return X}function R7(W){if(typeof W=="number")return W;if(W===void 0)return 0;let{type:X,strict:Y,strip:Q,compileOnly:K,backtraceBarrier:q}=W,J=0;return X==="global"&&(J|=S0.JS_EVAL_TYPE_GLOBAL),X==="module"&&(J|=S0.JS_EVAL_TYPE_MODULE),Y&&(J|=S0.JS_EVAL_FLAG_STRICT),Q&&(J|=S0.JS_EVAL_FLAG_STRIP),K&&(J|=S0.JS_EVAL_FLAG_COMPILE_ONLY),q&&(J|=S0.JS_EVAL_FLAG_BACKTRACE_BARRIER),J}function E7(W){if(typeof W=="number")return W;if(W===void 0)return 0;let{strings:X,symbols:Y,quickjsPrivate:Q,onlyEnumerable:K,numbers:q,numbersAsStrings:J}=W,G=0;return X&&(G|=b0.JS_GPN_STRING_MASK),Y&&(G|=b0.JS_GPN_SYMBOL_MASK),Q&&(G|=b0.JS_GPN_PRIVATE_MASK),K&&(G|=b0.JS_GPN_ENUM_ONLY),q&&(G|=b0.QTS_GPN_NUMBER_MASK),J&&(G|=b0.QTS_STANDARD_COMPLIANT_NUMBER),G}function I7(...W){let X=[];for(let Y of W)Y!==void 0&&(X=X.concat(Y));return X}function e9(W){return W>>8}function z4(W,X){X.interruptHandler&&W.setInterruptHandler(X.interruptHandler),X.maxStackSizeBytes!==void 0&&W.setMaxStackSize(X.maxStackSizeBytes),X.memoryLimitBytes!==void 0&&W.setMemoryLimit(X.memoryLimitBytes)}function B4(W,X){X.moduleLoader&&W.setModuleLoader(X.moduleLoader),X.shouldInterrupt&&W.setInterruptHandler(X.shouldInterrupt),X.memoryLimitBytes!==void 0&&W.setMemoryLimit(X.memoryLimitBytes),X.maxStackSizeBytes!==void 0&&W.setMaxStackSize(X.maxStackSizeBytes)}var H7,U7=(W,X)=>{for(var Y in X)H7(W,Y,{get:X[Y],enumerable:!0})},Q4=!1,L7,W4,G3,X4,q3,J3,z3,D7,w7,B3,$3,H3,U3,C0,K4,V0,Y4,W3,X0,T0,X3,D0,q4,V7,N7,m0,P7,D3=class{constructor(W){this.module=W}toPointerArray(W){let X=new Int32Array(W.map((K)=>K.value)),Y=X.length*X.BYTES_PER_ELEMENT,Q=this.module._malloc(Y);return new Uint8Array(this.module.HEAPU8.buffer,Q,Y).set(new Uint8Array(X.buffer)),new X0(Q,void 0,(K)=>this.module._free(K))}newTypedArray(W,X){let Y=new W(Array(X).fill(0)),Q=Y.length*Y.BYTES_PER_ELEMENT,K=this.module._malloc(Q),q=new W(this.module.HEAPU8.buffer,K,X);return q.set(Y),new X0({typedArray:q,ptr:K},void 0,(J)=>this.module._free(J.ptr))}newMutablePointerArray(W){return this.newTypedArray(Int32Array,W)}newHeapCharPointer(W){let X=this.module.lengthBytesUTF8(W),Y=X+1,Q=this.module._malloc(Y);return this.module.stringToUTF8(W,Q,Y),new X0({ptr:Q,strlen:X},void 0,(K)=>this.module._free(K.ptr))}newHeapBufferPointer(W){let X=W.byteLength,Y=this.module._malloc(X);return this.module.HEAPU8.set(W,Y),new X0({pointer:Y,numBytes:X},void 0,(Q)=>this.module._free(Q.pointer))}consumeHeapCharPointer(W){let X=this.module.UTF8ToString(W);return this.module._free(W),X}},ZG,RG,C7,Y3=-2147483648,Q3=2147483647,p1=0,_7=class{constructor(){this.nextId=Y3,this.freelist=[],this.groups=new Map}put(W){let X=this.allocateId(),Y=e9(X),Q=this.groups.get(Y);return Q||(Q=new Map,this.groups.set(Y,Q)),Q.set(X,W),X}get(W){if(W===p1)throw new C0("no host reference id defined");let X=e9(W),Y=this.groups.get(X);if(!Y)throw new C0(`host reference id ${W} is not defined`);let Q=Y.get(W);if(!Q)throw new C0(`host reference id ${W} is not defined`);return Q}delete(W){if(W===p1)throw new C0("no host reference id defined");let X=e9(W),Y=this.groups.get(X);if(!Y)throw new C0(`host reference id ${W} is not defined`);Y.delete(W),Y.size===0&&this.groups.delete(X),this.freelist.push(W)}allocateId(){if(this.freelist.length>0)return this.freelist.shift();if(this.nextId===p1&&this.nextId++,this.nextId>Q3)throw new U3(`HostRefMap: too many host refs created without disposing. Max simultaneous host refs: ${Q3-Y3}`);return this.nextId++}},K3,A7,j7,S7,b7=class{constructor(W){this.freeHostRef=W.freeHostRef,this.callFunction=W.callFunction,this.shouldInterrupt=W.shouldInterrupt,this.loadModuleSource=W.loadModuleSource,this.normalizeModule=W.normalizeModule}},J4=class{constructor(W){this.contextCallbacks=new Map,this.runtimeCallbacks=new Map,this.suspendedCount=0,this.cToHostCallbacks=new b7({freeHostRef:(X,Y,Q)=>{let K=this.runtimeCallbacks.get(Y);if(!K)throw Error(`QuickJSRuntime(rt = ${Y}) not found when trying to free HostRef(id = ${Q})`);K.freeHostRef(Y,Q)},callFunction:(X,Y,Q,K,q,J)=>this.handleAsyncify(X,()=>{try{let G=this.contextCallbacks.get(Y);if(!G)throw Error(`QuickJSContext(ctx = ${Y}) not found for C function call "${J}"`);return G.callFunction(Y,Q,K,q,J)}catch(G){return console.error("[C to host error: returning null]",G),0}}),shouldInterrupt:(X,Y)=>this.handleAsyncify(X,()=>{try{let Q=this.runtimeCallbacks.get(Y);if(!Q)throw Error(`QuickJSRuntime(rt = ${Y}) not found for C interrupt`);return Q.shouldInterrupt(Y)}catch(Q){return console.error("[C to host interrupt: returning error]",Q),1}}),loadModuleSource:(X,Y,Q,K)=>this.handleAsyncify(X,()=>{try{let q=this.runtimeCallbacks.get(Y);if(!q)throw Error(`QuickJSRuntime(rt = ${Y}) not found for C module loader`);let J=q.loadModuleSource;if(!J)throw Error(`QuickJSRuntime(rt = ${Y}) does not support module loading`);return J(Y,Q,K)}catch(q){return console.error("[C to host module loader error: returning null]",q),0}}),normalizeModule:(X,Y,Q,K,q)=>this.handleAsyncify(X,()=>{try{let J=this.runtimeCallbacks.get(Y);if(!J)throw Error(`QuickJSRuntime(rt = ${Y}) not found for C module loader`);let G=J.normalizeModule;if(!G)throw Error(`QuickJSRuntime(rt = ${Y}) does not support module loading`);return G(Y,Q,K,q)}catch(J){return console.error("[C to host module loader error: returning null]",J),0}})}),this.module=W,this.module.callbacks=this.cToHostCallbacks}setRuntimeCallbacks(W,X){this.runtimeCallbacks.set(W,X)}deleteRuntime(W){this.runtimeCallbacks.delete(W)}setContextCallbacks(W,X){this.contextCallbacks.set(W,X)}deleteContext(W){this.contextCallbacks.delete(W)}handleAsyncify(W,X){if(W)return W.handleSleep((Q)=>{try{let K=X();if(!(K instanceof Promise)){H1("asyncify.handleSleep: not suspending:",K),Q(K);return}if(this.suspended)throw new J3(`Already suspended at: ${this.suspended.stack}
4
4
  Attempted to suspend at:`);this.suspended=new z3(`(${this.suspendedCount++})`),H1("asyncify.handleSleep: suspending:",this.suspended),K.then((q)=>{this.suspended=void 0,H1("asyncify.handleSleep: resolved:",q),Q(q)},(q)=>{H1("asyncify.handleSleep: rejected:",q),console.error("QuickJS: cannot handle error in suspended function",q),this.suspended=void 0})}catch(K){throw H1("asyncify.handleSleep: error:",K),this.suspended=void 0,K}});let Y=X();if(Y instanceof Promise)throw Error("Promise return value not supported in non-asyncify context.");return Y}},w3=class{constructor(W,X){this.module=W,this.ffi=X,this.callbacks=new J4(W)}newRuntime(W={}){let X=new X0(this.ffi.QTS_NewRuntime(),void 0,(Q)=>{this.ffi.QTS_FreeRuntime(Q),this.callbacks.deleteRuntime(Q)}),Y=new S7({module:this.module,callbacks:this.callbacks,ffi:this.ffi,rt:X});return z4(Y,W),W.moduleLoader&&Y.setModuleLoader(W.moduleLoader),Y}newContext(W={}){let X=this.newRuntime(),Y=X.newContext({...W,ownedLifetimes:I7(X,W.ownedLifetimes)});return X.context=Y,Y}evalCode(W,X={}){return D0.withScope((Y)=>{let Q=Y.manage(this.newContext());B4(Q.runtime,X);let K=Q.evalCode(W,"eval.js");if(X.memoryLimitBytes!==void 0&&Q.runtime.setMemoryLimit(-1),K.error)throw Q.dump(Y.manage(K.error));return Q.dump(Y.manage(K.value))})}getWasmMemory(){let W=this.module.quickjsEmscriptenInit?.(()=>{})?.getWasmMemory?.();if(!W)throw Error("Variant does not support getting WebAssembly.Memory");return W}getFFI(){return this.ffi}};var M3=s1(()=>{u1();u1();H7=Object.defineProperty;L7={};U7(L7,{QuickJSAsyncifyError:()=>J3,QuickJSAsyncifySuspended:()=>z3,QuickJSEmptyGetOwnPropertyNames:()=>H3,QuickJSEmscriptenModuleError:()=>w7,QuickJSHostRefInvalid:()=>C0,QuickJSHostRefRangeExceeded:()=>U3,QuickJSMemoryLeakDetected:()=>D7,QuickJSNotImplemented:()=>q3,QuickJSPromisePending:()=>$3,QuickJSUnknownIntrinsic:()=>B3,QuickJSUnwrapError:()=>W4,QuickJSUseAfterFree:()=>X4,QuickJSWrongOwner:()=>G3});W4=class extends Error{constructor(W,X){let Y=typeof W=="object"&&W&&"message"in W?String(W.message):String(W);super(Y);this.cause=W,this.context=X,this.name="QuickJSUnwrapError"}},G3=class extends Error{constructor(){super(...arguments);this.name="QuickJSWrongOwner"}},X4=class extends Error{constructor(){super(...arguments);this.name="QuickJSUseAfterFree"}},q3=class extends Error{constructor(){super(...arguments);this.name="QuickJSNotImplemented"}},J3=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifyError"}},z3=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifySuspended"}},D7=class extends Error{constructor(){super(...arguments);this.name="QuickJSMemoryLeakDetected"}},w7=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmscriptenModuleError"}},B3=class extends TypeError{constructor(){super(...arguments);this.name="QuickJSUnknownIntrinsic"}},$3=class extends Error{constructor(){super(...arguments);this.name="QuickJSPromisePending"}},H3=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmptyGetOwnPropertyNames"}},U3=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefRangeExceeded"}},C0=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefInvalid"}};K4=L3;K4.of=M7;V0=class{[Symbol.dispose](){return this.dispose()}},Y4=Symbol.dispose??Symbol.for("Symbol.dispose"),W3=V0.prototype;W3[Y4]||(W3[Y4]=function(){return this.dispose()});X0=class W extends V0{constructor(X,Y,Q,K){super();this._value=X,this.copier=Y,this.disposer=Q,this._owner=K,this._alive=!0,this._constructorStack=Q4?Error("Lifetime constructed").stack:void 0}get alive(){return this._alive}get value(){return this.assertAlive(),this._value}get owner(){return this._owner}get dupable(){return!!this.copier}dup(){if(this.assertAlive(),!this.copier)throw Error("Non-dupable lifetime");return new W(this.copier(this._value),this.copier,this.disposer,this._owner)}consume(X){this.assertAlive();let Y=X(this);return this.dispose(),Y}map(X){return this.assertAlive(),X(this)}tap(X){return X(this),this}dispose(){this.assertAlive(),this.disposer&&this.disposer(this._value),this._alive=!1}assertAlive(){if(!this.alive)throw this._constructorStack?new X4(`Lifetime not alive
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpcloud/runtime",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
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",