@urun-sh/openai 0.6.44 → 0.6.45

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.
Files changed (37) hide show
  1. package/dist/{chunk-J3KCHTSA.js → chunk-3QZYIRAL.js} +3 -3
  2. package/dist/{chunk-BA3NCMS5.js → chunk-5JTIJPFV.js} +1 -1
  3. package/dist/{chunk-MJSK6W3W.js → chunk-BMSZZYSZ.js} +1 -1
  4. package/dist/{chunk-Y774TOE7.js → chunk-GCQR62TJ.js} +1 -1
  5. package/dist/chunk-LNQW3VFC.js +66 -0
  6. package/dist/{chunk-FNAZ2XBE.js → chunk-NUPHEB3L.js} +1 -1
  7. package/dist/{chunk-G6AFKOVS.js → chunk-PXV7QBSD.js} +1 -1
  8. package/dist/{chunk-HB5KNEY5.js → chunk-Q3AIBMET.js} +1 -1
  9. package/dist/chunk-ZXQXOEVN.js +4 -0
  10. package/dist/{composite-DNNAm0PY.d.ts → composite-BXbbnmL2.d.ts} +9 -0
  11. package/dist/{composite-DM2sT1Sp.d.cts → composite-n3axzdCh.d.cts} +34 -0
  12. package/dist/gemini-live.cjs +2 -2
  13. package/dist/gemini-live.d.cts +11 -0
  14. package/dist/gemini-live.d.ts +2 -0
  15. package/dist/gemini-live.js +1 -1
  16. package/dist/hosted/bin.cjs +42 -42
  17. package/dist/hosted/bin.js +1 -1
  18. package/dist/hosted/index.cjs +43 -43
  19. package/dist/hosted/index.d.cts +1 -1
  20. package/dist/hosted/index.d.ts +1 -1
  21. package/dist/hosted/index.js +1 -1
  22. package/dist/index.cjs +1 -1
  23. package/dist/index.js +1 -1
  24. package/dist/pi-extension/index.cjs +7 -7
  25. package/dist/pi-extension/index.js +1 -1
  26. package/dist/pi-extension/standalone.cjs +54 -54
  27. package/dist/pooler/bin.cjs +2 -2
  28. package/dist/pooler/bin.js +1 -1
  29. package/dist/proxy/cli.cjs +52 -52
  30. package/dist/proxy/cli.js +1 -1
  31. package/dist/proxy/index.cjs +30 -30
  32. package/dist/proxy/index.d.cts +16 -3
  33. package/dist/proxy/index.d.ts +8 -3
  34. package/dist/proxy/index.js +1 -1
  35. package/package.json +1 -1
  36. package/dist/chunk-DMRZZTYI.js +0 -4
  37. package/dist/chunk-VQSCBUKT.js +0 -66
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var pn=Object.create;var ze=Object.defineProperty;var fn=Object.getOwnPropertyDescriptor;var hn=Object.getOwnPropertyNames;var gn=Object.getPrototypeOf,mn=Object.prototype.hasOwnProperty;var yn=(s,e,t)=>()=>{if(t)throw t[0];try{return s&&(e=s(s=0)),e}catch(n){throw t=[n],n}};var wn=(s,e)=>()=>{try{return e||s((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var vn=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of hn(e))!mn.call(s,r)&&r!==t&&ze(s,r,{get:()=>e[r],enumerable:!(n=fn(e,r))||n.enumerable});return s};var de=(s,e,t)=>(t=s!=null?pn(gn(s)):{},vn(e||!s||!s.__esModule?ze(t,"default",{value:s,enumerable:!0}):t,s));var b=yn(()=>{"use strict"});var Xe=wn(()=>{"use strict";b();var Qe;(function(s){(function(e){var t=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:p(),n=r(s);typeof t.Reflect<"u"&&(n=r(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=s);function r(g,v){return function(h,d){Object.defineProperty(g,h,{configurable:!0,writable:!0,value:d}),v&&v(h,d)}}function i(){try{return Function("return this;")()}catch{}}function l(){try{return(0,eval)("(function() { return this; })()")}catch{}}function p(){return i()||l()}})(function(e,t){var n=Object.prototype.hasOwnProperty,r=typeof Symbol=="function",i=r&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",l=r&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",p=typeof Object.create=="function",g={__proto__:[]}instanceof Array,v=!p&&!g,h={create:p?function(){return Ee(Object.create(null))}:g?function(){return Ee({__proto__:null})}:function(){return Ee({})},has:v?function(o,a){return n.call(o,a)}:function(o,a){return a in o},get:v?function(o,a){return n.call(o,a)?o[a]:void 0}:function(o,a){return o[a]}},d=Object.getPrototypeOf(Function),R=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:an(),L=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:ln(),_=typeof WeakMap=="function"?WeakMap:un(),k=r?Symbol.for("@reflect-metadata:registry"):void 0,C=rn(),O=sn(C);function P(o,a,u,c){if(E(u)){if(!He(o))throw new TypeError;if(!Fe(a))throw new TypeError;return X(o,a)}else{if(!He(o))throw new TypeError;if(!U(a))throw new TypeError;if(!U(c)&&!E(c)&&!ne(c))throw new TypeError;return ne(c)&&(c=void 0),u=Y(u),_e(o,a,u,c)}}e("decorate",P);function A(o,a){function u(c,S){if(!U(c))throw new TypeError;if(!E(S)&&!tn(S))throw new TypeError;Ue(o,a,c,S)}return u}e("metadata",A);function x(o,a,u,c){if(!U(u))throw new TypeError;return E(c)||(c=Y(c)),Ue(o,a,u,c)}e("defineMetadata",x);function j(o,a,u){if(!U(a))throw new TypeError;return E(u)||(u=Y(u)),Ce(o,a,u)}e("hasMetadata",j);function G(o,a,u){if(!U(a))throw new TypeError;return E(u)||(u=Y(u)),Se(o,a,u)}e("hasOwnMetadata",G);function V(o,a,u){if(!U(a))throw new TypeError;return E(u)||(u=Y(u)),$e(o,a,u)}e("getMetadata",V);function $(o,a,u){if(!U(a))throw new TypeError;return E(u)||(u=Y(u)),Le(o,a,u)}e("getOwnMetadata",$);function z(o,a){if(!U(o))throw new TypeError;return E(a)||(a=Y(a)),qe(o,a)}e("getMetadataKeys",z);function Q(o,a){if(!U(o))throw new TypeError;return E(a)||(a=Y(a)),De(o,a)}e("getOwnMetadataKeys",Q);function ue(o,a,u){if(!U(a))throw new TypeError;if(E(u)||(u=Y(u)),!U(a))throw new TypeError;E(u)||(u=Y(u));var c=oe(a,u,!1);return E(c)?!1:c.OrdinaryDeleteMetadata(o,a,u)}e("deleteMetadata",ue);function X(o,a){for(var u=o.length-1;u>=0;--u){var c=o[u],S=c(a);if(!E(S)&&!ne(S)){if(!Fe(S))throw new TypeError;a=S}}return a}function _e(o,a,u,c){for(var S=o.length-1;S>=0;--S){var q=o[S],H=q(a,u,c);if(!E(H)&&!ne(H)){if(!U(H))throw new TypeError;c=H}}return c}function Ce(o,a,u){var c=Se(o,a,u);if(c)return!0;var S=Re(a);return ne(S)?!1:Ce(o,S,u)}function Se(o,a,u){var c=oe(a,u,!1);return E(c)?!1:je(c.OrdinaryHasOwnMetadata(o,a,u))}function $e(o,a,u){var c=Se(o,a,u);if(c)return Le(o,a,u);var S=Re(a);if(!ne(S))return $e(o,S,u)}function Le(o,a,u){var c=oe(a,u,!1);if(!E(c))return c.OrdinaryGetOwnMetadata(o,a,u)}function Ue(o,a,u,c){var S=oe(u,c,!0);S.OrdinaryDefineOwnMetadata(o,a,u,c)}function qe(o,a){var u=De(o,a),c=Re(o);if(c===null)return u;var S=qe(c,a);if(S.length<=0)return u;if(u.length<=0)return S;for(var q=new L,H=[],T=0,f=u;T<f.length;T++){var m=f[T],y=q.has(m);y||(q.add(m),H.push(m))}for(var w=0,I=S;w<I.length;w++){var m=I[w],y=q.has(m);y||(q.add(m),H.push(m))}return H}function De(o,a){var u=oe(o,a,!1);return u?u.OrdinaryOwnMetadataKeys(o,a):[]}function Ge(o){if(o===null)return 1;switch(typeof o){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return o===null?1:6;default:return 6}}function E(o){return o===void 0}function ne(o){return o===null}function Qt(o){return typeof o=="symbol"}function U(o){return typeof o=="object"?o!==null:typeof o=="function"}function Xt(o,a){switch(Ge(o)){case 0:return o;case 1:return o;case 2:return o;case 3:return o;case 4:return o;case 5:return o}var u=a===3?"string":a===5?"number":"default",c=Ke(o,i);if(c!==void 0){var S=c.call(o,u);if(U(S))throw new TypeError;return S}return Zt(o,u==="default"?"number":u)}function Zt(o,a){if(a==="string"){var u=o.toString;if(re(u)){var c=u.call(o);if(!U(c))return c}var S=o.valueOf;if(re(S)){var c=S.call(o);if(!U(c))return c}}else{var S=o.valueOf;if(re(S)){var c=S.call(o);if(!U(c))return c}var q=o.toString;if(re(q)){var c=q.call(o);if(!U(c))return c}}throw new TypeError}function je(o){return!!o}function en(o){return""+o}function Y(o){var a=Xt(o,3);return Qt(a)?a:en(a)}function He(o){return Array.isArray?Array.isArray(o):o instanceof Object?o instanceof Array:Object.prototype.toString.call(o)==="[object Array]"}function re(o){return typeof o=="function"}function Fe(o){return typeof o=="function"}function tn(o){switch(Ge(o)){case 3:return!0;case 4:return!0;default:return!1}}function be(o,a){return o===a||o!==o&&a!==a}function Ke(o,a){var u=o[a];if(u!=null){if(!re(u))throw new TypeError;return u}}function Ve(o){var a=Ke(o,l);if(!re(a))throw new TypeError;var u=a.call(o);if(!U(u))throw new TypeError;return u}function Ye(o){return o.value}function Be(o){var a=o.next();return a.done?!1:a}function Je(o){var a=o.return;a&&a.call(o)}function Re(o){var a=Object.getPrototypeOf(o);if(typeof o!="function"||o===d||a!==d)return a;var u=o.prototype,c=u&&Object.getPrototypeOf(u);if(c==null||c===Object.prototype)return a;var S=c.constructor;return typeof S!="function"||S===o?a:S}function nn(){var o;!E(k)&&typeof t.Reflect<"u"&&!(k in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(o=on(t.Reflect));var a,u,c,S=new _,q={registerProvider:H,getProvider:f,setProvider:y};return q;function H(w){if(!Object.isExtensible(q))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case o===w:break;case E(a):a=w;break;case a===w:break;case E(u):u=w;break;case u===w:break;default:c===void 0&&(c=new L),c.add(w);break}}function T(w,I){if(!E(a)){if(a.isProviderFor(w,I))return a;if(!E(u)){if(u.isProviderFor(w,I))return a;if(!E(c))for(var M=Ve(c);;){var D=Be(M);if(!D)return;var K=Ye(D);if(K.isProviderFor(w,I))return Je(M),K}}}if(!E(o)&&o.isProviderFor(w,I))return o}function f(w,I){var M=S.get(w),D;return E(M)||(D=M.get(I)),E(D)&&(D=T(w,I),E(D)||(E(M)&&(M=new R,S.set(w,M)),M.set(I,D))),D}function m(w){if(E(w))throw new TypeError;return a===w||u===w||!E(c)&&c.has(w)}function y(w,I,M){if(!m(M))throw new Error("Metadata provider not registered.");var D=f(w,I);if(D!==M){if(!E(D))return!1;var K=S.get(w);E(K)&&(K=new R,S.set(w,K)),K.set(I,M)}return!0}}function rn(){var o;return!E(k)&&U(t.Reflect)&&Object.isExtensible(t.Reflect)&&(o=t.Reflect[k]),E(o)&&(o=nn()),!E(k)&&U(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,k,{enumerable:!1,configurable:!1,writable:!1,value:o}),o}function sn(o){var a=new _,u={isProviderFor:function(m,y){var w=a.get(m);return E(w)?!1:w.has(y)},OrdinaryDefineOwnMetadata:H,OrdinaryHasOwnMetadata:S,OrdinaryGetOwnMetadata:q,OrdinaryOwnMetadataKeys:T,OrdinaryDeleteMetadata:f};return C.registerProvider(u),u;function c(m,y,w){var I=a.get(m),M=!1;if(E(I)){if(!w)return;I=new R,a.set(m,I),M=!0}var D=I.get(y);if(E(D)){if(!w)return;if(D=new R,I.set(y,D),!o.setProvider(m,y,u))throw I.delete(y),M&&a.delete(m),new Error("Wrong provider for target.")}return D}function S(m,y,w){var I=c(y,w,!1);return E(I)?!1:je(I.has(m))}function q(m,y,w){var I=c(y,w,!1);if(!E(I))return I.get(m)}function H(m,y,w,I){var M=c(w,I,!0);M.set(m,y)}function T(m,y){var w=[],I=c(m,y,!1);if(E(I))return w;for(var M=I.keys(),D=Ve(M),K=0;;){var We=Be(D);if(!We)return w.length=K,w;var dn=Ye(We);try{w[K]=dn}catch(cn){try{Je(D)}finally{throw cn}}K++}}function f(m,y,w){var I=c(y,w,!1);if(E(I)||!I.delete(m))return!1;if(I.size===0){var M=a.get(y);E(M)||(M.delete(w),M.size===0&&a.delete(M))}return!0}}function on(o){var a=o.defineMetadata,u=o.hasOwnMetadata,c=o.getOwnMetadata,S=o.getOwnMetadataKeys,q=o.deleteMetadata,H=new _,T={isProviderFor:function(f,m){var y=H.get(f);return!E(y)&&y.has(m)?!0:S(f,m).length?(E(y)&&(y=new L,H.set(f,y)),y.add(m),!0):!1},OrdinaryDefineOwnMetadata:a,OrdinaryHasOwnMetadata:u,OrdinaryGetOwnMetadata:c,OrdinaryOwnMetadataKeys:S,OrdinaryDeleteMetadata:q};return T}function oe(o,a,u){var c=C.getProvider(o,a);if(!E(c))return c;if(u){if(C.setProvider(o,a,O))return O;throw new Error("Illegal state.")}}function an(){var o={},a=[],u=(function(){function T(f,m,y){this._index=0,this._keys=f,this._values=m,this._selector=y}return T.prototype["@@iterator"]=function(){return this},T.prototype[l]=function(){return this},T.prototype.next=function(){var f=this._index;if(f>=0&&f<this._keys.length){var m=this._selector(this._keys[f],this._values[f]);return f+1>=this._keys.length?(this._index=-1,this._keys=a,this._values=a):this._index++,{value:m,done:!1}}return{value:void 0,done:!0}},T.prototype.throw=function(f){throw this._index>=0&&(this._index=-1,this._keys=a,this._values=a),f},T.prototype.return=function(f){return this._index>=0&&(this._index=-1,this._keys=a,this._values=a),{value:f,done:!0}},T})(),c=(function(){function T(){this._keys=[],this._values=[],this._cacheKey=o,this._cacheIndex=-2}return Object.defineProperty(T.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),T.prototype.has=function(f){return this._find(f,!1)>=0},T.prototype.get=function(f){var m=this._find(f,!1);return m>=0?this._values[m]:void 0},T.prototype.set=function(f,m){var y=this._find(f,!0);return this._values[y]=m,this},T.prototype.delete=function(f){var m=this._find(f,!1);if(m>=0){for(var y=this._keys.length,w=m+1;w<y;w++)this._keys[w-1]=this._keys[w],this._values[w-1]=this._values[w];return this._keys.length--,this._values.length--,be(f,this._cacheKey)&&(this._cacheKey=o,this._cacheIndex=-2),!0}return!1},T.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=o,this._cacheIndex=-2},T.prototype.keys=function(){return new u(this._keys,this._values,S)},T.prototype.values=function(){return new u(this._keys,this._values,q)},T.prototype.entries=function(){return new u(this._keys,this._values,H)},T.prototype["@@iterator"]=function(){return this.entries()},T.prototype[l]=function(){return this.entries()},T.prototype._find=function(f,m){if(!be(this._cacheKey,f)){this._cacheIndex=-1;for(var y=0;y<this._keys.length;y++)if(be(this._keys[y],f)){this._cacheIndex=y;break}}return this._cacheIndex<0&&m&&(this._cacheIndex=this._keys.length,this._keys.push(f),this._values.push(void 0)),this._cacheIndex},T})();return c;function S(T,f){return T}function q(T,f){return f}function H(T,f){return[T,f]}}function ln(){var o=(function(){function a(){this._map=new R}return Object.defineProperty(a.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),a.prototype.has=function(u){return this._map.has(u)},a.prototype.add=function(u){return this._map.set(u,u),this},a.prototype.delete=function(u){return this._map.delete(u)},a.prototype.clear=function(){this._map.clear()},a.prototype.keys=function(){return this._map.keys()},a.prototype.values=function(){return this._map.keys()},a.prototype.entries=function(){return this._map.entries()},a.prototype["@@iterator"]=function(){return this.keys()},a.prototype[l]=function(){return this.keys()},a})();return o}function un(){var o=16,a=h.create(),u=c();return(function(){function f(){this._key=c()}return f.prototype.has=function(m){var y=S(m,!1);return y!==void 0?h.has(y,this._key):!1},f.prototype.get=function(m){var y=S(m,!1);return y!==void 0?h.get(y,this._key):void 0},f.prototype.set=function(m,y){var w=S(m,!0);return w[this._key]=y,this},f.prototype.delete=function(m){var y=S(m,!1);return y!==void 0?delete y[this._key]:!1},f.prototype.clear=function(){this._key=c()},f})();function c(){var f;do f="@@WeakMap@@"+T();while(h.has(a,f));return a[f]=!0,f}function S(f,m){if(!n.call(f,u)){if(!m)return;Object.defineProperty(f,u,{value:h.create()})}return f[u]}function q(f,m){for(var y=0;y<m;++y)f[y]=Math.random()*255|0;return f}function H(f){if(typeof Uint8Array=="function"){var m=new Uint8Array(f);return typeof crypto<"u"?crypto.getRandomValues(m):typeof msCrypto<"u"?msCrypto.getRandomValues(m):q(m,f),m}return q(new Array(f),f)}function T(){var f=H(o);f[6]=f[6]&79|64,f[8]=f[8]&191|128;for(var m="",y=0;y<o;++y){var w=f[y];(y===4||y===6||y===8)&&(m+="-"),w<16&&(m+="0"),m+=w.toString(16).toLowerCase()}return m}}function Ee(o){return o.__=void 0,delete o.__,o}})})(Qe||(Qe={}))});b();var li=de(Xe(),1),B=de(require("process"),1),zt=require("ioredis");b();var En=de(require("os"),1),kn=de(require("path"),1),Pn=require("url"),Tn=require("util");b();var Rn=require("crypto");b();b();b();b();b();var J=class extends Error{};var In=new Set(["EPIPE","EIO","EBADF","ENXIO"]);function Ze(s){let e=s?.code;return typeof e=="string"&&In.has(e)}function ce(s,e){try{return s.write(e),!0}catch(t){if(Ze(t))return!1;throw t}}function et(s){let e={stdout:!1,stderr:!1},t=[];for(let n of["stdout","stderr"]){let r=s.streams[n],i=l=>{Ze(l)&&(e[n]=!0);let p=l?.code;try{s.note(`${new Date().toISOString()} urun compat: process.${n} died (${String(p??(l instanceof Error?l.message:l))}) \u2014 the terminal is gone; launcher output continues in this log only
2
+ "use strict";var pn=Object.create;var ze=Object.defineProperty;var fn=Object.getOwnPropertyDescriptor;var hn=Object.getOwnPropertyNames;var gn=Object.getPrototypeOf,mn=Object.prototype.hasOwnProperty;var yn=(s,e,t)=>()=>{if(t)throw t[0];try{return s&&(e=s(s=0)),e}catch(n){throw t=[n],n}};var wn=(s,e)=>()=>{try{return e||s((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var vn=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of hn(e))!mn.call(s,r)&&r!==t&&ze(s,r,{get:()=>e[r],enumerable:!(n=fn(e,r))||n.enumerable});return s};var de=(s,e,t)=>(t=s!=null?pn(gn(s)):{},vn(e||!s||!s.__esModule?ze(t,"default",{value:s,enumerable:!0}):t,s));var b=yn(()=>{"use strict"});var Xe=wn(()=>{"use strict";b();var Qe;(function(s){(function(e){var t=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:p(),n=r(s);typeof t.Reflect<"u"&&(n=r(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=s);function r(g,v){return function(h,d){Object.defineProperty(g,h,{configurable:!0,writable:!0,value:d}),v&&v(h,d)}}function i(){try{return Function("return this;")()}catch{}}function l(){try{return(0,eval)("(function() { return this; })()")}catch{}}function p(){return i()||l()}})(function(e,t){var n=Object.prototype.hasOwnProperty,r=typeof Symbol=="function",i=r&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",l=r&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",p=typeof Object.create=="function",g={__proto__:[]}instanceof Array,v=!p&&!g,h={create:p?function(){return Ee(Object.create(null))}:g?function(){return Ee({__proto__:null})}:function(){return Ee({})},has:v?function(o,a){return n.call(o,a)}:function(o,a){return a in o},get:v?function(o,a){return n.call(o,a)?o[a]:void 0}:function(o,a){return o[a]}},d=Object.getPrototypeOf(Function),R=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:an(),L=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:ln(),_=typeof WeakMap=="function"?WeakMap:un(),k=r?Symbol.for("@reflect-metadata:registry"):void 0,C=rn(),O=sn(C);function P(o,a,u,c){if(E(u)){if(!He(o))throw new TypeError;if(!Fe(a))throw new TypeError;return X(o,a)}else{if(!He(o))throw new TypeError;if(!U(a))throw new TypeError;if(!U(c)&&!E(c)&&!ne(c))throw new TypeError;return ne(c)&&(c=void 0),u=Y(u),_e(o,a,u,c)}}e("decorate",P);function A(o,a){function u(c,S){if(!U(c))throw new TypeError;if(!E(S)&&!tn(S))throw new TypeError;Ue(o,a,c,S)}return u}e("metadata",A);function x(o,a,u,c){if(!U(u))throw new TypeError;return E(c)||(c=Y(c)),Ue(o,a,u,c)}e("defineMetadata",x);function j(o,a,u){if(!U(a))throw new TypeError;return E(u)||(u=Y(u)),Ce(o,a,u)}e("hasMetadata",j);function G(o,a,u){if(!U(a))throw new TypeError;return E(u)||(u=Y(u)),Se(o,a,u)}e("hasOwnMetadata",G);function V(o,a,u){if(!U(a))throw new TypeError;return E(u)||(u=Y(u)),$e(o,a,u)}e("getMetadata",V);function $(o,a,u){if(!U(a))throw new TypeError;return E(u)||(u=Y(u)),Le(o,a,u)}e("getOwnMetadata",$);function z(o,a){if(!U(o))throw new TypeError;return E(a)||(a=Y(a)),qe(o,a)}e("getMetadataKeys",z);function Q(o,a){if(!U(o))throw new TypeError;return E(a)||(a=Y(a)),De(o,a)}e("getOwnMetadataKeys",Q);function ue(o,a,u){if(!U(a))throw new TypeError;if(E(u)||(u=Y(u)),!U(a))throw new TypeError;E(u)||(u=Y(u));var c=oe(a,u,!1);return E(c)?!1:c.OrdinaryDeleteMetadata(o,a,u)}e("deleteMetadata",ue);function X(o,a){for(var u=o.length-1;u>=0;--u){var c=o[u],S=c(a);if(!E(S)&&!ne(S)){if(!Fe(S))throw new TypeError;a=S}}return a}function _e(o,a,u,c){for(var S=o.length-1;S>=0;--S){var q=o[S],H=q(a,u,c);if(!E(H)&&!ne(H)){if(!U(H))throw new TypeError;c=H}}return c}function Ce(o,a,u){var c=Se(o,a,u);if(c)return!0;var S=Re(a);return ne(S)?!1:Ce(o,S,u)}function Se(o,a,u){var c=oe(a,u,!1);return E(c)?!1:je(c.OrdinaryHasOwnMetadata(o,a,u))}function $e(o,a,u){var c=Se(o,a,u);if(c)return Le(o,a,u);var S=Re(a);if(!ne(S))return $e(o,S,u)}function Le(o,a,u){var c=oe(a,u,!1);if(!E(c))return c.OrdinaryGetOwnMetadata(o,a,u)}function Ue(o,a,u,c){var S=oe(u,c,!0);S.OrdinaryDefineOwnMetadata(o,a,u,c)}function qe(o,a){var u=De(o,a),c=Re(o);if(c===null)return u;var S=qe(c,a);if(S.length<=0)return u;if(u.length<=0)return S;for(var q=new L,H=[],T=0,f=u;T<f.length;T++){var m=f[T],y=q.has(m);y||(q.add(m),H.push(m))}for(var w=0,I=S;w<I.length;w++){var m=I[w],y=q.has(m);y||(q.add(m),H.push(m))}return H}function De(o,a){var u=oe(o,a,!1);return u?u.OrdinaryOwnMetadataKeys(o,a):[]}function Ge(o){if(o===null)return 1;switch(typeof o){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return o===null?1:6;default:return 6}}function E(o){return o===void 0}function ne(o){return o===null}function Qt(o){return typeof o=="symbol"}function U(o){return typeof o=="object"?o!==null:typeof o=="function"}function Xt(o,a){switch(Ge(o)){case 0:return o;case 1:return o;case 2:return o;case 3:return o;case 4:return o;case 5:return o}var u=a===3?"string":a===5?"number":"default",c=Ke(o,i);if(c!==void 0){var S=c.call(o,u);if(U(S))throw new TypeError;return S}return Zt(o,u==="default"?"number":u)}function Zt(o,a){if(a==="string"){var u=o.toString;if(re(u)){var c=u.call(o);if(!U(c))return c}var S=o.valueOf;if(re(S)){var c=S.call(o);if(!U(c))return c}}else{var S=o.valueOf;if(re(S)){var c=S.call(o);if(!U(c))return c}var q=o.toString;if(re(q)){var c=q.call(o);if(!U(c))return c}}throw new TypeError}function je(o){return!!o}function en(o){return""+o}function Y(o){var a=Xt(o,3);return Qt(a)?a:en(a)}function He(o){return Array.isArray?Array.isArray(o):o instanceof Object?o instanceof Array:Object.prototype.toString.call(o)==="[object Array]"}function re(o){return typeof o=="function"}function Fe(o){return typeof o=="function"}function tn(o){switch(Ge(o)){case 3:return!0;case 4:return!0;default:return!1}}function be(o,a){return o===a||o!==o&&a!==a}function Ke(o,a){var u=o[a];if(u!=null){if(!re(u))throw new TypeError;return u}}function Ve(o){var a=Ke(o,l);if(!re(a))throw new TypeError;var u=a.call(o);if(!U(u))throw new TypeError;return u}function Ye(o){return o.value}function Be(o){var a=o.next();return a.done?!1:a}function Je(o){var a=o.return;a&&a.call(o)}function Re(o){var a=Object.getPrototypeOf(o);if(typeof o!="function"||o===d||a!==d)return a;var u=o.prototype,c=u&&Object.getPrototypeOf(u);if(c==null||c===Object.prototype)return a;var S=c.constructor;return typeof S!="function"||S===o?a:S}function nn(){var o;!E(k)&&typeof t.Reflect<"u"&&!(k in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(o=on(t.Reflect));var a,u,c,S=new _,q={registerProvider:H,getProvider:f,setProvider:y};return q;function H(w){if(!Object.isExtensible(q))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case o===w:break;case E(a):a=w;break;case a===w:break;case E(u):u=w;break;case u===w:break;default:c===void 0&&(c=new L),c.add(w);break}}function T(w,I){if(!E(a)){if(a.isProviderFor(w,I))return a;if(!E(u)){if(u.isProviderFor(w,I))return a;if(!E(c))for(var M=Ve(c);;){var D=Be(M);if(!D)return;var K=Ye(D);if(K.isProviderFor(w,I))return Je(M),K}}}if(!E(o)&&o.isProviderFor(w,I))return o}function f(w,I){var M=S.get(w),D;return E(M)||(D=M.get(I)),E(D)&&(D=T(w,I),E(D)||(E(M)&&(M=new R,S.set(w,M)),M.set(I,D))),D}function m(w){if(E(w))throw new TypeError;return a===w||u===w||!E(c)&&c.has(w)}function y(w,I,M){if(!m(M))throw new Error("Metadata provider not registered.");var D=f(w,I);if(D!==M){if(!E(D))return!1;var K=S.get(w);E(K)&&(K=new R,S.set(w,K)),K.set(I,M)}return!0}}function rn(){var o;return!E(k)&&U(t.Reflect)&&Object.isExtensible(t.Reflect)&&(o=t.Reflect[k]),E(o)&&(o=nn()),!E(k)&&U(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,k,{enumerable:!1,configurable:!1,writable:!1,value:o}),o}function sn(o){var a=new _,u={isProviderFor:function(m,y){var w=a.get(m);return E(w)?!1:w.has(y)},OrdinaryDefineOwnMetadata:H,OrdinaryHasOwnMetadata:S,OrdinaryGetOwnMetadata:q,OrdinaryOwnMetadataKeys:T,OrdinaryDeleteMetadata:f};return C.registerProvider(u),u;function c(m,y,w){var I=a.get(m),M=!1;if(E(I)){if(!w)return;I=new R,a.set(m,I),M=!0}var D=I.get(y);if(E(D)){if(!w)return;if(D=new R,I.set(y,D),!o.setProvider(m,y,u))throw I.delete(y),M&&a.delete(m),new Error("Wrong provider for target.")}return D}function S(m,y,w){var I=c(y,w,!1);return E(I)?!1:je(I.has(m))}function q(m,y,w){var I=c(y,w,!1);if(!E(I))return I.get(m)}function H(m,y,w,I){var M=c(w,I,!0);M.set(m,y)}function T(m,y){var w=[],I=c(m,y,!1);if(E(I))return w;for(var M=I.keys(),D=Ve(M),K=0;;){var We=Be(D);if(!We)return w.length=K,w;var dn=Ye(We);try{w[K]=dn}catch(cn){try{Je(D)}finally{throw cn}}K++}}function f(m,y,w){var I=c(y,w,!1);if(E(I)||!I.delete(m))return!1;if(I.size===0){var M=a.get(y);E(M)||(M.delete(w),M.size===0&&a.delete(M))}return!0}}function on(o){var a=o.defineMetadata,u=o.hasOwnMetadata,c=o.getOwnMetadata,S=o.getOwnMetadataKeys,q=o.deleteMetadata,H=new _,T={isProviderFor:function(f,m){var y=H.get(f);return!E(y)&&y.has(m)?!0:S(f,m).length?(E(y)&&(y=new L,H.set(f,y)),y.add(m),!0):!1},OrdinaryDefineOwnMetadata:a,OrdinaryHasOwnMetadata:u,OrdinaryGetOwnMetadata:c,OrdinaryOwnMetadataKeys:S,OrdinaryDeleteMetadata:q};return T}function oe(o,a,u){var c=C.getProvider(o,a);if(!E(c))return c;if(u){if(C.setProvider(o,a,O))return O;throw new Error("Illegal state.")}}function an(){var o={},a=[],u=(function(){function T(f,m,y){this._index=0,this._keys=f,this._values=m,this._selector=y}return T.prototype["@@iterator"]=function(){return this},T.prototype[l]=function(){return this},T.prototype.next=function(){var f=this._index;if(f>=0&&f<this._keys.length){var m=this._selector(this._keys[f],this._values[f]);return f+1>=this._keys.length?(this._index=-1,this._keys=a,this._values=a):this._index++,{value:m,done:!1}}return{value:void 0,done:!0}},T.prototype.throw=function(f){throw this._index>=0&&(this._index=-1,this._keys=a,this._values=a),f},T.prototype.return=function(f){return this._index>=0&&(this._index=-1,this._keys=a,this._values=a),{value:f,done:!0}},T})(),c=(function(){function T(){this._keys=[],this._values=[],this._cacheKey=o,this._cacheIndex=-2}return Object.defineProperty(T.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),T.prototype.has=function(f){return this._find(f,!1)>=0},T.prototype.get=function(f){var m=this._find(f,!1);return m>=0?this._values[m]:void 0},T.prototype.set=function(f,m){var y=this._find(f,!0);return this._values[y]=m,this},T.prototype.delete=function(f){var m=this._find(f,!1);if(m>=0){for(var y=this._keys.length,w=m+1;w<y;w++)this._keys[w-1]=this._keys[w],this._values[w-1]=this._values[w];return this._keys.length--,this._values.length--,be(f,this._cacheKey)&&(this._cacheKey=o,this._cacheIndex=-2),!0}return!1},T.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=o,this._cacheIndex=-2},T.prototype.keys=function(){return new u(this._keys,this._values,S)},T.prototype.values=function(){return new u(this._keys,this._values,q)},T.prototype.entries=function(){return new u(this._keys,this._values,H)},T.prototype["@@iterator"]=function(){return this.entries()},T.prototype[l]=function(){return this.entries()},T.prototype._find=function(f,m){if(!be(this._cacheKey,f)){this._cacheIndex=-1;for(var y=0;y<this._keys.length;y++)if(be(this._keys[y],f)){this._cacheIndex=y;break}}return this._cacheIndex<0&&m&&(this._cacheIndex=this._keys.length,this._keys.push(f),this._values.push(void 0)),this._cacheIndex},T})();return c;function S(T,f){return T}function q(T,f){return f}function H(T,f){return[T,f]}}function ln(){var o=(function(){function a(){this._map=new R}return Object.defineProperty(a.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),a.prototype.has=function(u){return this._map.has(u)},a.prototype.add=function(u){return this._map.set(u,u),this},a.prototype.delete=function(u){return this._map.delete(u)},a.prototype.clear=function(){this._map.clear()},a.prototype.keys=function(){return this._map.keys()},a.prototype.values=function(){return this._map.keys()},a.prototype.entries=function(){return this._map.entries()},a.prototype["@@iterator"]=function(){return this.keys()},a.prototype[l]=function(){return this.keys()},a})();return o}function un(){var o=16,a=h.create(),u=c();return(function(){function f(){this._key=c()}return f.prototype.has=function(m){var y=S(m,!1);return y!==void 0?h.has(y,this._key):!1},f.prototype.get=function(m){var y=S(m,!1);return y!==void 0?h.get(y,this._key):void 0},f.prototype.set=function(m,y){var w=S(m,!0);return w[this._key]=y,this},f.prototype.delete=function(m){var y=S(m,!1);return y!==void 0?delete y[this._key]:!1},f.prototype.clear=function(){this._key=c()},f})();function c(){var f;do f="@@WeakMap@@"+T();while(h.has(a,f));return a[f]=!0,f}function S(f,m){if(!n.call(f,u)){if(!m)return;Object.defineProperty(f,u,{value:h.create()})}return f[u]}function q(f,m){for(var y=0;y<m;++y)f[y]=Math.random()*255|0;return f}function H(f){if(typeof Uint8Array=="function"){var m=new Uint8Array(f);return typeof crypto<"u"?crypto.getRandomValues(m):typeof msCrypto<"u"?msCrypto.getRandomValues(m):q(m,f),m}return q(new Array(f),f)}function T(){var f=H(o);f[6]=f[6]&79|64,f[8]=f[8]&191|128;for(var m="",y=0;y<o;++y){var w=f[y];(y===4||y===6||y===8)&&(m+="-"),w<16&&(m+="0"),m+=w.toString(16).toLowerCase()}return m}}function Ee(o){return o.__=void 0,delete o.__,o}})})(Qe||(Qe={}))});b();var li=de(Xe(),1),B=de(require("process"),1),zt=require("ioredis");b();var En=de(require("os"),1),kn=de(require("path"),1),Pn=require("url"),Tn=require("util");b();var Rn=require("crypto");b();b();b();b();b();var J=class extends Error{bindingLost;constructor(e,t){super(e),this.bindingLost=t?.bindingLost??!1}};var In=new Set(["EPIPE","EIO","EBADF","ENXIO"]);function Ze(s){let e=s?.code;return typeof e=="string"&&In.has(e)}function ce(s,e){try{return s.write(e),!0}catch(t){if(Ze(t))return!1;throw t}}function et(s){let e={stdout:!1,stderr:!1},t=[];for(let n of["stdout","stderr"]){let r=s.streams[n],i=l=>{Ze(l)&&(e[n]=!0);let p=l?.code;try{s.note(`${new Date().toISOString()} urun compat: process.${n} died (${String(p??(l instanceof Error?l.message:l))}) \u2014 the terminal is gone; launcher output continues in this log only
3
3
  `)}catch{}};r.on("error",i),t.push([r,i])}return{isDead:n=>e[n],uninstall:()=>{for(let[n,r]of t)n.off("error",r)}}}b();b();var ke=`
4
4
  local slot, retired, meta, idx = KEYS[1], KEYS[2], KEYS[3], KEYS[4]
5
5
  local key, gen, now = ARGV[1], tonumber(ARGV[2]), ARGV[3]
@@ -311,7 +311,7 @@ return 'ok'
311
311
 
312
312
  `),this.res.end()}stopKeepalive(){this.keepalive!==null&&clearInterval(this.keepalive),this.keepalive=null}};function Gt(s){return new Promise((e,t)=>{let n=0,r=[];s.on("data",i=>{if(n+=i.length,n>Dt){t(new Error(`request body exceeds ${Dt} bytes`)),s.destroy();return}r.push(i)}),s.on("end",()=>e(Buffer.concat(r).toString("utf8"))),s.on("error",t)})}function Ht(s){let e=s.keepaliveMs??sr,t=s.log??(()=>{}),n=(0,jt.createServer)((r,i)=>{(async()=>{let l=new URL(r.url??"/","http://pooler.internal");if(r.method==="GET"&&l.pathname===er){i.writeHead(200,{"content-type":"application/json"}),i.end(JSON.stringify({ok:!0,...s.pooler.stats()}));return}if(r.method==="GET"&&l.pathname===tr){let h=["# TYPE pooler_pool_queued gauge","# TYPE pooler_pool_inflight gauge","# TYPE pooler_pool_sessions gauge","# TYPE pooler_lane_demand_enqueued counter","# TYPE pooler_lane_demand_reaffirmed counter"];for(let d of s.pooler.stats().pools){let R=`pool="${d.pool}"`;h.push(`pooler_pool_queued{${R}} ${d.queued}`),h.push(`pooler_pool_inflight{${R}} ${d.inflight}`),h.push(`pooler_pool_sessions{${R}} ${d.sessions}`)}for(let d of s.lanePlane?.demandCounters()??[]){let R=`model="${d.model.replaceAll('"','\\"')}"`;h.push(`pooler_lane_demand_enqueued{${R}} ${d.enqueued}`),h.push(`pooler_lane_demand_reaffirmed{${R}} ${d.reaffirmed}`)}for(let d of s.lanePlane?.demandRefusals()??[])h.push(`pooler_lane_demand_refused{reason="${d.reason}"} ${d.count}`);i.writeHead(200,{"content-type":"text/plain; version=0.0.4"}),i.end(`${h.join(`
313
313
  `)}
314
- `);return}if(s.lanePlane&&r.method==="GET"&&l.pathname===rr){if(r.headers.authorization!==`Bearer ${s.token}`){F(i,401,"the pooler channel requires the in-cluster bearer token","unauthorized");return}i.writeHead(200,{"content-type":"application/json"}),i.end(JSON.stringify({pools:await s.lanePlane.status()}));return}if(s.lanePlane&&r.method==="POST"&&l.pathname===nr){if(r.headers.authorization!==`Bearer ${s.token}`){F(i,401,"the pooler channel requires the in-cluster bearer token","unauthorized");return}let h;try{h=JSON.parse(await Gt(r))}catch(O){F(i,400,O instanceof Error?O.message:String(O),"invalid_request");return}let d=h??{};if(typeof d.pool!="string"||d.pool===""){F(i,400,"pool is required","invalid_request");return}let R=d.hold_ms;if(R!==void 0&&(typeof R!="number"||!Number.isInteger(R)||R<0||R>Rt)){F(i,400,"hold_ms must be an integer in 0..120000","invalid_request");return}let L=typeof d.model=="string"&&d.model!==""?d.model:void 0,_=typeof d.app=="string"&&d.app!==""?d.app:void 0,k=typeof d.fn=="string"&&d.fn!==""?d.fn:void 0,C=d.shared_app===!0?!0:void 0;try{let O=await s.lanePlane.pick({pool:d.pool,app:_,fn:k,sharedApp:C,model:L,holdMs:R??0});if(O.length===0){let P=s.lanePlane.demandFailure(d.pool);F(i,503,P?`no capacity available for this model right now, retry shortly (the demand mint last failed: ${P})`:"no capacity available for this model right now, retry shortly","lane_capacity",2);return}i.writeHead(200,{"content-type":"application/json"}),i.end(JSON.stringify({lanes:O.map(P=>({lane_id:P.laneId,host:P.host}))}))}catch(O){if(O instanceof se){F(i,400,O.message,"lane_target");return}t(`[pooler] lane pick for ${d.pool} failed: ${O instanceof Error?O.message:String(O)}`),F(i,500,"the pooler lane plane failed this pick","pooler_error")}return}if(r.method!=="POST"||l.pathname!==Zn){F(i,404,`no route for ${r.method??""} ${l.pathname}`,"not_found");return}if(r.headers.authorization!==`Bearer ${s.token}`){F(i,401,"the pooler channel requires the in-cluster bearer token","unauthorized");return}let p;try{p=JSON.parse(await Gt(r))}catch(h){F(i,400,h instanceof Error?h.message:String(h),"invalid_request");return}let g=ir(p);if("reason"in g){F(i,400,g.reason,"invalid_request");return}let v=new Ne(i,g.value.streaming,e);v.head();try{await s.pooler.submit(g.value.request,v)}catch(h){t(`[pooler] request ${g.value.request.request_id} failed unexpectedly: ${h instanceof Error?h.message:String(h)}`),v.fail({status:500,code:"pooler_error",message:"the pooler failed to serve this request"})}})()});return{server:n,close:()=>new Promise(r=>n.close(()=>r()))}}b();var ve=require("@urun-sh/core");b();var or=3,ar="llm",lr=new Set(["paused","error"]);function Ft(s,e,t){let n=s.doc(ar),r=typeof n.onConnectionState=="function",i=typeof s.onPhase=="function";if(!r&&!i)throw new Error(`session for app "${e}" exposes neither a doc connection-state surface nor onPhase \u2014 session-gone detection requires @urun-sh/core Session (SessionDocument.onConnectionState / Session.onPhase); pooling a session with no native lifecycle signal would silently swallow requests dispatched after the platform closes it`);let l=null,p=!1,g=new Set,v=[],h=d=>{if(!l){l=d;for(let R of[...g])R(d);g.clear()}};return r&&v.push(n.onConnectionState(d=>{p&&(d.consecutiveFailures<or||h(new J(`the pooled session for app "${e}" is gone: its doc backhaul failed ${d.consecutiveFailures} consecutive times (last close ${d.lastCloseCode===null?"by provider liveness reap":`code ${d.lastCloseCode}`}${d.lastCloseReason?`, reason ${JSON.stringify(d.lastCloseReason)}`:""}) \u2014 the platform closed the session (idle timeout or a serve-side crash). The entry is evicted; retry to get a fresh session.`)))})),t?.armOnFirstSync===!0&&typeof n.onSynced=="function"?v.push(n.onSynced(()=>{p=!0})):i&&v.push(s.onPhase(d=>{if(d.name==="live"){p=!0;return}p&&lr.has(d.name)&&h(new J(`the pooled session for app "${e}" lost its compute binding (phase "${d.name}"). The entry is evicted; retry to get a fresh session. The named session itself is not over \u2014 it stays attachable by name.`))})),{gone:()=>l,onGone(d){return l?(d(l),()=>{}):(g.add(d),()=>g.delete(d))},dispose(){g.clear();for(let d of v.splice(0))d()}}}b();var Yt=require("@urun-sh/core");b();async function Kt(s,e,t){if(s.synced===!0||typeof s.onSynced!="function")return;let n;await new Promise((r,i)=>{let l=s.onSynced(()=>{clearTimeout(n),r()});n=setTimeout(()=>{l(),i(new Error(`[urun] llm doc plane never synced within ${e}ms \u2014 ${t} is withheld rather than raced into a possibly-lost pre-sync write (resumed-attach first-write-lost, prod-usw2 2026-09-23)`))},e)})}var Bt=require("@urun-sh/core/internal");var dr=new Set(["accepted","done","error"]);function cr(s){if(s===null||typeof s!="object")return{};let e=s,t={};for(let[n,r]of Object.entries(e)){let i=r===null||typeof r!="object"?null:r.toJSON;t[n]=typeof i=="function"?i.call(r):r}return t}function pr(s){if(s===null||typeof s!="object")return null;let e=s,t=e.status;return t!==void 0&&(typeof t!="string"||!dr.has(t))?null:{attempt:typeof e.attempt=="number"?e.attempt:0,...typeof t=="string"?{status:t}:{},...typeof e.error=="string"?{error:e.error}:{}}}function Vt(s){let e=cr(s.get()),t=Number(e[Ct]??0),n={},r=e[Oe];if(r!==null&&typeof r=="object")for(let[i,l]of Object.entries(r)){let p=pr(l);p!==null&&(n[i]=p)}return{freeSlots:Number.isFinite(t)?t:0,inflight:n,liveSeen:e[Me]===!0}}function fr(s){if(s===Yt.STREAM_END)return{t:"end"};if(s===null||typeof s!="object")return null;let e=s;return e.t==="delta"?{t:"delta",...typeof e.delta=="string"?{delta:e.delta}:{},...typeof e.reasoning=="string"?{reasoning:e.reasoning}:{},...e.tool_calls!==void 0?{tool_calls:e.tool_calls}:{}}:e.t==="response"||e.t==="error"?{t:e.t,body:e.body??s}:null}async function*hr(s,e){let t=s.stream(Nt(e)),n=!1;try{for await(let r of t.messages()){let i=fr(r);if(i!==null&&(yield i,i.t!=="delta")){n=!0;return}}}catch(r){throw new ee(e,r instanceof Error?r.message:String(r))}if(!n)throw new ee(e,"the reply stream ended without a terminal chunk (urun-stream-v1 is at-most-once across a reconnect)")}function Jt(s){let{session:e,sessionId:t,goneWatch:n}=s;if(typeof e.whenLive!="function")throw new Error(`pooler session ${t} exposes no whenLive \u2014 a request must never be pushed into a session whose admission is unproven (the cold-wake gate is a contract, not an option)`);if(typeof e.end!="function")throw new Error(`pooler session ${t} exposes no end \u2014 the pooler is the attached client and must be able to release it`);if(typeof e.cancel!="function")throw new Error(`pooler session ${t} exposes no cancel \u2014 the pooler's never-live eviction requires the admission-ticket cancel verb`);if(typeof e.phase!="object"||e.phase===null||typeof e.phase.name!="string")throw new Error(`pooler session ${t} exposes no phase surface \u2014 the servability probe reads core's own phase name live, and a wrapper must never fabricate one`);let r=()=>e.doc(Ot),i=!1;return"onPhase"in e&&typeof e.onPhase=="function"&&e.onPhase(l=>{l.name==="live"&&(i=!0)}),{sessionId:t,snapshot:()=>Vt(r()),onDocChange:l=>r().on("change",()=>l()),onGone:l=>n.onGone(l),gone:()=>n.gone(),phaseName:()=>(e.phase.name==="live"&&(i=!0),e.phase.name),everLive:()=>i||Vt(r()).liveSeen,markLiveSeen:async()=>{await Kt(r(),15e3,"the durable live-seen mark"),r().set({[Me]:!0})},whenLive:l=>e.whenLive(l),markInflight:(l,p)=>(r().set({[Oe]:{[l]:{attempt:p}}}),Promise.resolve()),push:l=>(r().set({[Mt]:{[l.request_id]:{...l.payload,request_id:l.request_id,consumer_id:l.consumer_id,stream:l.stream}}}),Promise.resolve()),clearRequest:l=>{try{(0,Bt.gcRequest)(r(),l)}catch{}return Promise.resolve()},reply:l=>hr(e,l),end:async()=>{await e.end(),n.dispose()},cancel:async()=>{await e.cancel(),n.dispose()},namedSessionId:()=>typeof e.namedSessionId=="function"?e.namedSessionId():void 0}}function Wt(s){return async(e,t)=>{let n=e.fn??Ut,r=(0,ve.App)(e.app,{baseUrl:s.baseUrl,orgId:s.orgId,getAccessToken:async()=>(await(0,ve.createClientToken)(s.apiKey,{baseUrl:s.baseUrl,expiresIn:300,allowedFunctions:[`${e.app}/${n}`],bindPrincipal:!0,...e.sharedApp?{sharedApp:!0}:{}})).token}),i=r[n];if(typeof i!="function")throw new Error(`app "${e.app}" has no function "${n}" \u2014 the pooler cannot dial a slot for it`);let l={concurrencyKey:t,...e.sharedApp?{sharedApp:!0}:{}},p=i.call(r,void 0,l);if(p===null||typeof p!="object")throw new Error(`app "${e.app}" function "${n}" returned no session`);let g=p;return Jt({session:g,sessionId:t,goneWatch:Ft(g,t,{armOnFirstSync:!0})})}}function br(){let s=null;s=et({streams:B.default,note:e=>{s?.isDead("stderr")!==!0&&ce(B.default.stderr,e)}})}async function Rr(){br();let s=qt(B.default.env),e=d=>{ce(B.default.stdout,`${d}
314
+ `);return}if(s.lanePlane&&r.method==="GET"&&l.pathname===rr){if(r.headers.authorization!==`Bearer ${s.token}`){F(i,401,"the pooler channel requires the in-cluster bearer token","unauthorized");return}i.writeHead(200,{"content-type":"application/json"}),i.end(JSON.stringify({pools:await s.lanePlane.status()}));return}if(s.lanePlane&&r.method==="POST"&&l.pathname===nr){if(r.headers.authorization!==`Bearer ${s.token}`){F(i,401,"the pooler channel requires the in-cluster bearer token","unauthorized");return}let h;try{h=JSON.parse(await Gt(r))}catch(O){F(i,400,O instanceof Error?O.message:String(O),"invalid_request");return}let d=h??{};if(typeof d.pool!="string"||d.pool===""){F(i,400,"pool is required","invalid_request");return}let R=d.hold_ms;if(R!==void 0&&(typeof R!="number"||!Number.isInteger(R)||R<0||R>Rt)){F(i,400,"hold_ms must be an integer in 0..120000","invalid_request");return}let L=typeof d.model=="string"&&d.model!==""?d.model:void 0,_=typeof d.app=="string"&&d.app!==""?d.app:void 0,k=typeof d.fn=="string"&&d.fn!==""?d.fn:void 0,C=d.shared_app===!0?!0:void 0;try{let O=await s.lanePlane.pick({pool:d.pool,app:_,fn:k,sharedApp:C,model:L,holdMs:R??0});if(O.length===0){let P=s.lanePlane.demandFailure(d.pool);F(i,503,P?`no capacity available for this model right now, retry shortly (the demand mint last failed: ${P})`:"no capacity available for this model right now, retry shortly","lane_capacity",2);return}i.writeHead(200,{"content-type":"application/json"}),i.end(JSON.stringify({lanes:O.map(P=>({lane_id:P.laneId,host:P.host}))}))}catch(O){if(O instanceof se){F(i,400,O.message,"lane_target");return}t(`[pooler] lane pick for ${d.pool} failed: ${O instanceof Error?O.message:String(O)}`),F(i,500,"the pooler lane plane failed this pick","pooler_error")}return}if(r.method!=="POST"||l.pathname!==Zn){F(i,404,`no route for ${r.method??""} ${l.pathname}`,"not_found");return}if(r.headers.authorization!==`Bearer ${s.token}`){F(i,401,"the pooler channel requires the in-cluster bearer token","unauthorized");return}let p;try{p=JSON.parse(await Gt(r))}catch(h){F(i,400,h instanceof Error?h.message:String(h),"invalid_request");return}let g=ir(p);if("reason"in g){F(i,400,g.reason,"invalid_request");return}let v=new Ne(i,g.value.streaming,e);v.head();try{await s.pooler.submit(g.value.request,v)}catch(h){t(`[pooler] request ${g.value.request.request_id} failed unexpectedly: ${h instanceof Error?h.message:String(h)}`),v.fail({status:500,code:"pooler_error",message:"the pooler failed to serve this request"})}})()});return{server:n,close:()=>new Promise(r=>n.close(()=>r()))}}b();var ve=require("@urun-sh/core");b();var or=3,ar="llm",lr=new Set(["paused","error"]);function Ft(s,e,t){let n=s.doc(ar),r=typeof n.onConnectionState=="function",i=typeof s.onPhase=="function";if(!r&&!i)throw new Error(`session for app "${e}" exposes neither a doc connection-state surface nor onPhase \u2014 session-gone detection requires @urun-sh/core Session (SessionDocument.onConnectionState / Session.onPhase); pooling a session with no native lifecycle signal would silently swallow requests dispatched after the platform closes it`);let l=null,p=!1,g=new Set,v=[],h=d=>{if(!l){l=d;for(let R of[...g])R(d);g.clear()}};return r&&v.push(n.onConnectionState(d=>{p&&(d.consecutiveFailures<or||h(new J(`the pooled session for app "${e}" is gone: its doc backhaul failed ${d.consecutiveFailures} consecutive times (last close ${d.lastCloseCode===null?"by provider liveness reap":`code ${d.lastCloseCode}`}${d.lastCloseReason?`, reason ${JSON.stringify(d.lastCloseReason)}`:""}) \u2014 the platform closed the session (idle timeout or a serve-side crash). The entry is evicted; retry to get a fresh session.`)))})),t?.armOnFirstSync===!0&&typeof n.onSynced=="function"?v.push(n.onSynced(()=>{p=!0})):i&&v.push(s.onPhase(d=>{if(d.name==="live"){p=!0;return}p&&lr.has(d.name)&&h(new J(`the pooled session for app "${e}" lost its compute binding (phase "${d.name}"). The entry is evicted; retry to get a fresh session. The named session itself is not over \u2014 it stays attachable by name.`,{bindingLost:!0}))})),{gone:()=>l,onGone(d){return l?(d(l),()=>{}):(g.add(d),()=>g.delete(d))},dispose(){g.clear();for(let d of v.splice(0))d()}}}b();var Yt=require("@urun-sh/core");b();async function Kt(s,e,t){if(s.synced===!0||typeof s.onSynced!="function")return;let n;await new Promise((r,i)=>{let l=s.onSynced(()=>{clearTimeout(n),r()});n=setTimeout(()=>{l(),i(new Error(`[urun] llm doc plane never synced within ${e}ms \u2014 ${t} is withheld rather than raced into a possibly-lost pre-sync write (resumed-attach first-write-lost, prod-usw2 2026-09-23)`))},e)})}var Bt=require("@urun-sh/core/internal");var dr=new Set(["accepted","done","error"]);function cr(s){if(s===null||typeof s!="object")return{};let e=s,t={};for(let[n,r]of Object.entries(e)){let i=r===null||typeof r!="object"?null:r.toJSON;t[n]=typeof i=="function"?i.call(r):r}return t}function pr(s){if(s===null||typeof s!="object")return null;let e=s,t=e.status;return t!==void 0&&(typeof t!="string"||!dr.has(t))?null:{attempt:typeof e.attempt=="number"?e.attempt:0,...typeof t=="string"?{status:t}:{},...typeof e.error=="string"?{error:e.error}:{}}}function Vt(s){let e=cr(s.get()),t=Number(e[Ct]??0),n={},r=e[Oe];if(r!==null&&typeof r=="object")for(let[i,l]of Object.entries(r)){let p=pr(l);p!==null&&(n[i]=p)}return{freeSlots:Number.isFinite(t)?t:0,inflight:n,liveSeen:e[Me]===!0}}function fr(s){if(s===Yt.STREAM_END)return{t:"end"};if(s===null||typeof s!="object")return null;let e=s;return e.t==="delta"?{t:"delta",...typeof e.delta=="string"?{delta:e.delta}:{},...typeof e.reasoning=="string"?{reasoning:e.reasoning}:{},...e.tool_calls!==void 0?{tool_calls:e.tool_calls}:{}}:e.t==="response"||e.t==="error"?{t:e.t,body:e.body??s}:null}async function*hr(s,e){let t=s.stream(Nt(e)),n=!1;try{for await(let r of t.messages()){let i=fr(r);if(i!==null&&(yield i,i.t!=="delta")){n=!0;return}}}catch(r){throw new ee(e,r instanceof Error?r.message:String(r))}if(!n)throw new ee(e,"the reply stream ended without a terminal chunk (urun-stream-v1 is at-most-once across a reconnect)")}function Jt(s){let{session:e,sessionId:t,goneWatch:n}=s;if(typeof e.whenLive!="function")throw new Error(`pooler session ${t} exposes no whenLive \u2014 a request must never be pushed into a session whose admission is unproven (the cold-wake gate is a contract, not an option)`);if(typeof e.end!="function")throw new Error(`pooler session ${t} exposes no end \u2014 the pooler is the attached client and must be able to release it`);if(typeof e.cancel!="function")throw new Error(`pooler session ${t} exposes no cancel \u2014 the pooler's never-live eviction requires the admission-ticket cancel verb`);if(typeof e.phase!="object"||e.phase===null||typeof e.phase.name!="string")throw new Error(`pooler session ${t} exposes no phase surface \u2014 the servability probe reads core's own phase name live, and a wrapper must never fabricate one`);let r=()=>e.doc(Ot),i=!1;return"onPhase"in e&&typeof e.onPhase=="function"&&e.onPhase(l=>{l.name==="live"&&(i=!0)}),{sessionId:t,snapshot:()=>Vt(r()),onDocChange:l=>r().on("change",()=>l()),onGone:l=>n.onGone(l),gone:()=>n.gone(),phaseName:()=>(e.phase.name==="live"&&(i=!0),e.phase.name),everLive:()=>i||Vt(r()).liveSeen,markLiveSeen:async()=>{await Kt(r(),15e3,"the durable live-seen mark"),r().set({[Me]:!0})},whenLive:l=>e.whenLive(l),markInflight:(l,p)=>(r().set({[Oe]:{[l]:{attempt:p}}}),Promise.resolve()),push:l=>(r().set({[Mt]:{[l.request_id]:{...l.payload,request_id:l.request_id,consumer_id:l.consumer_id,stream:l.stream}}}),Promise.resolve()),clearRequest:l=>{try{(0,Bt.gcRequest)(r(),l)}catch{}return Promise.resolve()},reply:l=>hr(e,l),end:async()=>{await e.end(),n.dispose()},cancel:async()=>{await e.cancel(),n.dispose()},namedSessionId:()=>typeof e.namedSessionId=="function"?e.namedSessionId():void 0}}function Wt(s){return async(e,t)=>{let n=e.fn??Ut,r=(0,ve.App)(e.app,{baseUrl:s.baseUrl,orgId:s.orgId,getAccessToken:async()=>(await(0,ve.createClientToken)(s.apiKey,{baseUrl:s.baseUrl,expiresIn:300,allowedFunctions:[`${e.app}/${n}`],bindPrincipal:!0,...e.sharedApp?{sharedApp:!0}:{}})).token}),i=r[n];if(typeof i!="function")throw new Error(`app "${e.app}" has no function "${n}" \u2014 the pooler cannot dial a slot for it`);let l={concurrencyKey:t,...e.sharedApp?{sharedApp:!0}:{}},p=i.call(r,void 0,l);if(p===null||typeof p!="object")throw new Error(`app "${e.app}" function "${n}" returned no session`);let g=p;return Jt({session:g,sessionId:t,goneWatch:Ft(g,t,{armOnFirstSync:!0})})}}function br(){let s=null;s=et({streams:B.default,note:e=>{s?.isDead("stderr")!==!0&&ce(B.default.stderr,e)}})}async function Rr(){br();let s=qt(B.default.env),e=d=>{ce(B.default.stdout,`${d}
315
315
  `)},t=new zt.Redis(s.valkeyUrl,{maxRetriesPerRequest:null}),n=new pe({eval:(d,R,L)=>t.eval(d,R.length,...R,...L)},"pooler"),r=Wt(s),i=new we({journal:new he,registry:n,queueDeadlineMs:6e4,silenceDeadlineMs:33e4,backlogThreshold:8,mint:(d,R,L)=>{let _=s.targets.find(k=>k.region===d&&k.model===R);return _===void 0?Promise.reject(new Error(`no pooler target for ${d}:${R} \u2014 refusing to mint`)):r(_,L)},limits:s.targets.map(({region:d,model:R,min:L,max:_})=>({region:d,model:R,min:L,max:_})),scaleUpWaitMs:5e3,mintCooldownMs:1e4,sessionIdleTtlMs:6e4,idleSweepMs:5e3,onEvent:d=>{Lt.has(d.kind)&&e(`[pooler] ${d.kind} ${JSON.stringify(d)}`)}});await i.warm();let l=s.laneRuntimeKey,p=s.laneDocHostUrl===void 0?void 0:Et({docHostUrl:s.laneDocHostUrl,redis:t,targets:s.targets,admission:kt({baseUrl:s.baseUrl,apiKey:s.apiKey}),...l?{mintRuntimeToken:d=>It(d,s.orgId,l,Te,Tt)}:{},catalogIdentity:async d=>{if(d===void 0)return null;let R=await t.hgetall(mt),L=[];for(let[P,A]of Object.entries(R))try{L.push({row:JSON.parse(A),field:P})}catch{}let _=P=>{let A=P.app_slug,x=P.function;return typeof A!="string"||A===""||typeof x!="string"||x===""?null:{app:A,fn:x,sharedApp:P.shared_org_id?!0:void 0}},k=L.find(P=>P.field===d);if(k){let P=_(k.row);if(P)return P}let C=d.includes(":")?d.slice(0,d.indexOf(":")):d,O=L.filter(P=>P.row.model_id===C).sort((P,A)=>P.field.localeCompare(A.field));for(let P of O){let A=_(P.row);if(A)return A}return null},onEvent:d=>{e(`[pooler] ${d.kind} ${JSON.stringify(d)}`)}}),{server:g,close:v}=Ht({pooler:i,token:s.token,lanePlane:p,log:e});await new Promise((d,R)=>{g.once("error",R),g.listen(s.port,s.bindHost,()=>d())}),e(`urun-pooler listening on http://${s.bindHost}:${s.port} (targets ${s.targets.map(d=>`${d.region}:${d.model} min=${d.min} max=${d.max}`).join(", ")})${p===void 0?"":" lanes=on"}`);let h=async d=>{e(`urun-pooler: ${d} \u2014 draining`),await v(),await i.close(),await p?.close(),await t.quit().catch(()=>{})};await new Promise(d=>{B.default.once("SIGINT",()=>{h("SIGINT").finally(d)}),B.default.once("SIGTERM",()=>{h("SIGTERM").finally(d)})})}Rr().then(()=>B.default.exit(0),s=>{ce(B.default.stderr,`urun-pooler failed: ${s instanceof Error?`${s.name}: ${s.message}`:String(s)}
316
316
  `),B.default.exit(1)});
317
317
  /*! Bundled license information:
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{a as Ce}from"../chunk-LM4E5YM2.js";import{a as te,b as ne,c as se,d as re}from"../chunk-Y774TOE7.js";import{a as X}from"../chunk-MJSK6W3W.js";import{c as W,v as N,w as z}from"../chunk-BA3NCMS5.js";import{a as Q,b as Z,d as ee}from"../chunk-XNRPTMSL.js";import{a as J}from"../chunk-7KRHHEKZ.js";import{j as q}from"../chunk-J3KCHTSA.js";import{b as Ge,c as p}from"../chunk-YSFSRI3D.js";p();var mn=Ge(Ce(),1);import b from"process";import{Redis as kt}from"ioredis";p();p();var D=`
2
+ import{a as Ce}from"../chunk-LM4E5YM2.js";import{a as te,b as ne,c as se,d as re}from"../chunk-GCQR62TJ.js";import{a as X}from"../chunk-BMSZZYSZ.js";import{c as W,v as N,w as z}from"../chunk-5JTIJPFV.js";import{a as Q,b as Z,d as ee}from"../chunk-XNRPTMSL.js";import{a as J}from"../chunk-7KRHHEKZ.js";import{j as q}from"../chunk-3QZYIRAL.js";import{b as Ge,c as p}from"../chunk-YSFSRI3D.js";p();var mn=Ge(Ce(),1);import b from"process";import{Redis as kt}from"ioredis";p();p();var D=`
3
3
  local slot, retired, meta, idx = KEYS[1], KEYS[2], KEYS[3], KEYS[4]
4
4
  local key, gen, now = ARGV[1], tonumber(ARGV[2]), ARGV[3]
5
5
  -- The session-as-routing-identity schema (docs/pooler-session-registry.md