@linzumi/cli 1.0.311 → 1.0.312
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/README.md +1 -1
- package/dist/cloud-supervisor.mjs +7 -7
- package/dist/hosted-coding-account-worker.js +6 -6
- package/dist/index.js +357 -356
- package/dist/remote-codex-harness-worker.js +84 -84
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __linzumiBundleCreateRequire } from 'node:module';
|
|
2
2
|
const require = __linzumiBundleCreateRequire(import.meta.url);
|
|
3
|
-
var z2=Object.create;var ty=Object.defineProperty;var K2=Object.getOwnPropertyDescriptor;var H2=Object.getOwnPropertyNames;var J2=Object.getPrototypeOf,W2=Object.prototype.hasOwnProperty;var ut=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var N=(e,t)=>()=>(e&&(t=e(e=0)),t);var St=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),V2=(e,t)=>{for(var n in t)ty(e,n,{get:t[n],enumerable:!0})},Z2=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of H2(t))!W2.call(e,i)&&i!==n&&ty(e,i,{get:()=>t[i],enumerable:!(r=K2(t,i))||r.enumerable});return e};var ei=(e,t,n)=>(n=e!=null?z2(J2(e)):{},Z2(t||!e||!e.__esModule?ty(n,"default",{value:e,enumerable:!0}):n,e));var ny=N(()=>{});function _t(e){return e===void 0?{BS_PRIVATE_NESTED_SOME_NONE:0}:e!==null&&e.BS_PRIVATE_NESTED_SOME_NONE!==void 0?{BS_PRIVATE_NESTED_SOME_NONE:e.BS_PRIVATE_NESTED_SOME_NONE+1|0}:e}function as(e){if(e!=null)return _t(e)}function Fe(e){if(e===null||e.BS_PRIVATE_NESTED_SOME_NONE===void 0)return e;let t=e.BS_PRIVATE_NESTED_SOME_NONE;if(t!==0)return{BS_PRIVATE_NESTED_SOME_NONE:t-1|0}}var qe=N(()=>{});function $i(e,t){if(e!==void 0)return t(Fe(e))}function Wt(e,t,n){return e!==void 0?n(Fe(e)):t}function Ze(e,t){if(e!==void 0)return _t(t(Fe(e)))}function
|
|
4
|
-
GFS4: `),console.error(e)});Nt[pn]||(WC=global[pn]||[],ZC(Nt,WC),Nt.close=(function(e){function t(n,r){return e.call(Nt,n,function(i){i||VC(),typeof r=="function"&&r.apply(this,arguments)})}return Object.defineProperty(t,Af,{value:e}),t})(Nt.close),Nt.closeSync=(function(e){function t(n){e.apply(Nt,arguments),VC()}return Object.defineProperty(t,Af,{value:e}),t})(Nt.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ta(Nt[pn]),ut("assert").equal(Nt[pn].length,0)}));var WC;global[pn]||ZC(global,Nt[pn]);sy.exports=oy(sK(Nt));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!Nt.__patched&&(sy.exports=oy(Nt),Nt.__patched=!0);function oy(e){oK(e),e.gracefulify=oy,e.createReadStream=C,e.createWriteStream=O;var t=e.readFile;e.readFile=n;function n(k,E,x){return typeof E=="function"&&(x=E,E=null),I(k,E,x);function I(P,M,q,ee){return t(P,M,function(Q){Q&&(Q.code==="EMFILE"||Q.code==="ENFILE")?ds([I,[P,M,q],Q,ee||Date.now(),Date.now()]):typeof q=="function"&&q.apply(this,arguments)})}}var r=e.writeFile;e.writeFile=i;function i(k,E,x,I){return typeof x=="function"&&(I=x,x=null),P(k,E,x,I);function P(M,q,ee,Q,te){return r(M,q,ee,function(Y){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?ds([P,[M,q,ee,Q],Y,te||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=a);function a(k,E,x,I){return typeof x=="function"&&(I=x,x=null),P(k,E,x,I);function P(M,q,ee,Q,te){return o(M,q,ee,function(Y){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?ds([P,[M,q,ee,Q],Y,te||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}var s=e.copyFile;s&&(e.copyFile=d);function d(k,E,x,I){return typeof x=="function"&&(I=x,x=0),P(k,E,x,I);function P(M,q,ee,Q,te){return s(M,q,ee,function(Y){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?ds([P,[M,q,ee,Q],Y,te||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}var l=e.readdir;e.readdir=c;var u=/^v[0-5]\./;function c(k,E,x){typeof E=="function"&&(x=E,E=null);var I=u.test(process.version)?function(q,ee,Q,te){return l(q,P(q,ee,Q,te))}:function(q,ee,Q,te){return l(q,ee,P(q,ee,Q,te))};return I(k,E,x);function P(M,q,ee,Q){return function(te,Y){te&&(te.code==="EMFILE"||te.code==="ENFILE")?ds([I,[M,q,ee],te,Q||Date.now(),Date.now()]):(Y&&Y.sort&&Y.sort(),typeof ee=="function"&&ee.call(this,te,Y))}}}if(process.version.substr(0,4)==="v0.8"){var p=aK(e);g=p.ReadStream,v=p.WriteStream}var m=e.ReadStream;m&&(g.prototype=Object.create(m.prototype),g.prototype.open=S);var y=e.WriteStream;y&&(v.prototype=Object.create(y.prototype),v.prototype.open=T),Object.defineProperty(e,"ReadStream",{get:function(){return g},set:function(k){g=k},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return v},set:function(k){v=k},enumerable:!0,configurable:!0});var h=g;Object.defineProperty(e,"FileReadStream",{get:function(){return h},set:function(k){h=k},enumerable:!0,configurable:!0});var b=v;Object.defineProperty(e,"FileWriteStream",{get:function(){return b},set:function(k){b=k},enumerable:!0,configurable:!0});function g(k,E){return this instanceof g?(m.apply(this,arguments),this):g.apply(Object.create(g.prototype),arguments)}function S(){var k=this;w(k.path,k.flags,k.mode,function(E,x){E?(k.autoClose&&k.destroy(),k.emit("error",E)):(k.fd=x,k.emit("open",x),k.read())})}function v(k,E){return this instanceof v?(y.apply(this,arguments),this):v.apply(Object.create(v.prototype),arguments)}function T(){var k=this;w(k.path,k.flags,k.mode,function(E,x){E?(k.destroy(),k.emit("error",E)):(k.fd=x,k.emit("open",x))})}function C(k,E){return new e.ReadStream(k,E)}function O(k,E){return new e.WriteStream(k,E)}var _=e.open;e.open=w;function w(k,E,x,I){return typeof x=="function"&&(I=x,x=null),P(k,E,x,I);function P(M,q,ee,Q,te){return _(M,q,ee,function(Y,L){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?ds([P,[M,q,ee,Q],Y,te||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}return e}function ds(e){ta("ENQUEUE",e[0].name,e[1]),Nt[pn].push(e),ay()}var Tf;function VC(){for(var e=Date.now(),t=0;t<Nt[pn].length;++t)Nt[pn][t].length>2&&(Nt[pn][t][3]=e,Nt[pn][t][4]=e);ay()}function ay(){if(clearTimeout(Tf),Tf=void 0,Nt[pn].length!==0){var e=Nt[pn].shift(),t=e[0],n=e[1],r=e[2],i=e[3],o=e[4];if(i===void 0)ta("RETRY",t.name,n),t.apply(null,n);else if(Date.now()-i>=6e4){ta("TIMEOUT",t.name,n);var a=n.pop();typeof a=="function"&&a.call(null,r)}else{var s=Date.now()-o,d=Math.max(o-i,1),l=Math.min(d*1.2,100);s>=l?(ta("RETRY",t.name,n),t.apply(null,n.concat([i]))):Nt[pn].push(e)}Tf===void 0&&(Tf=setTimeout(ay,0))}}});var QC=St((C4e,YC)=>{function sr(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}YC.exports=sr;sr.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};sr.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};sr.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1;var r=this,i=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n);return this._options.unref&&i.unref(),!0};sr.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};sr.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};sr.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};sr.prototype.start=sr.prototype.try;sr.prototype.errors=function(){return this._errors};sr.prototype.attempts=function(){return this._attempts};sr.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],o=i.message,a=(e[o]||0)+1;e[o]=a,a>=n&&(t=i,n=a)}return t}});var XC=St(na=>{var lK=QC();na.operation=function(e){var t=na.timeouts(e);return new lK(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};na.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(o,a){return o-a}),r};na.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*t.minTimeout*Math.pow(t.factor,e));return r=Math.min(r,t.maxTimeout),r};na.wrap=function(e,t,n){if(t instanceof Array&&(n=t,t=null),!n){n=[];for(var r in e)typeof e[r]=="function"&&n.push(r)}for(var i=0;i<n.length;i++){var o=n[i],a=e[o];e[o]=function(d){var l=na.operation(t),u=Array.prototype.slice.call(arguments,1),c=u.pop();u.push(function(p){l.retry(p)||(p&&(arguments[0]=l.mainError()),c.apply(this,arguments))}),l.attempt(function(){d.apply(e,u)})}.bind(e,a),e[o].options=t}}});var t0=St((O4e,e0)=>{e0.exports=XC()});var n0=St((x4e,kf)=>{kf.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&kf.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&kf.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var s0=St((R4e,cs)=>{var It=global.process,ra=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};ra(It)?(r0=ut("assert"),ls=n0(),i0=/^win/i.test(It.platform),wl=ut("events"),typeof wl!="function"&&(wl=wl.EventEmitter),It.__signal_exit_emitter__?sn=It.__signal_exit_emitter__:(sn=It.__signal_exit_emitter__=new wl,sn.count=0,sn.emitted={}),sn.infinite||(sn.setMaxListeners(1/0),sn.infinite=!0),cs.exports=function(e,t){if(!ra(global.process))return function(){};r0.equal(typeof e,"function","a callback must be provided for exit handler"),us===!1&&ly();var n="exit";t&&t.alwaysLast&&(n="afterexit");var r=function(){sn.removeListener(n,e),sn.listeners("exit").length===0&&sn.listeners("afterexit").length===0&&Cf()};return sn.on(n,e),r},Cf=function(){!us||!ra(global.process)||(us=!1,ls.forEach(function(t){try{It.removeListener(t,Ef[t])}catch{}}),It.emit=Of,It.reallyExit=uy,sn.count-=1)},cs.exports.unload=Cf,ia=function(t,n,r){sn.emitted[t]||(sn.emitted[t]=!0,sn.emit(t,n,r))},Ef={},ls.forEach(function(e){Ef[e]=function(){if(ra(global.process)){var n=It.listeners(e);n.length===sn.count&&(Cf(),ia("exit",null,e),ia("afterexit",null,e),i0&&e==="SIGHUP"&&(e="SIGINT"),It.kill(It.pid,e))}}}),cs.exports.signals=function(){return ls},us=!1,ly=function(){us||!ra(global.process)||(us=!0,sn.count+=1,ls=ls.filter(function(t){try{return It.on(t,Ef[t]),!0}catch{return!1}}),It.emit=a0,It.reallyExit=o0)},cs.exports.load=ly,uy=It.reallyExit,o0=function(t){ra(global.process)&&(It.exitCode=t||0,ia("exit",It.exitCode,null),ia("afterexit",It.exitCode,null),uy.call(It,It.exitCode))},Of=It.emit,a0=function(t,n){if(t==="exit"&&ra(global.process)){n!==void 0&&(It.exitCode=n);var r=Of.apply(this,arguments);return ia("exit",It.exitCode,null),ia("afterexit",It.exitCode,null),r}else return Of.apply(this,arguments)}):cs.exports=function(){return function(){}};var r0,ls,i0,wl,sn,Cf,ia,Ef,us,ly,uy,o0,Of,a0});var f0=St((P4e,Tl)=>{"use strict";var uK=ut("path"),py=dy(),cK=t0(),fK=s0(),ji={};function fs(e,t){return t.lockfilePath||`${e}.lock`}function my(e,t,n){if(!t.realpath)return n(null,uK.resolve(e));t.fs.realpath(e,n)}function cy(e,t,n){t.fs.mkdir(fs(e,t),r=>{if(!r)return n();if(r.code!=="EEXIST")return n(r);if(t.stale<=0)return n(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));t.fs.stat(fs(e,t),(i,o)=>{if(i)return i.code==="ENOENT"?cy(e,{...t,stale:0},n):n(i);if(!l0(o,t))return n(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));u0(e,t,a=>{if(a)return n(a);cy(e,{...t,stale:0},n)})})})}function l0(e,t){return e.mtime.getTime()<Date.now()-t.stale}function u0(e,t,n){t.fs.rmdir(fs(e,t),r=>{if(r&&r.code!=="ENOENT")return n(r);n()})}function fy(e,t){let n=ji[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{let r=Date.now()/1e3;n.updateTimeout=null,t.fs.utimes(fs(e,t),r,r,i=>{if(!n.released){if(n.lastUpdate<=Date.now()-t.stale&&n.lastUpdate>Date.now()-t.stale*2){let o=Object.assign(new Error(n.updateError||"Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"});return d0(e,n,o)}if(i)return i.code==="ENOENT"?d0(e,n,Object.assign(i,{code:"ECOMPROMISED"})):(n.updateError=i,n.updateDelay=1e3,fy(e,t));n.lastUpdate=Date.now(),n.updateError=null,n.updateDelay=null,fy(e,t)}})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function d0(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),ji[e]===t&&delete ji[e],t.options.onCompromised(n)}function pK(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:py,onCompromised:r=>{throw r},...t},t.retries=t.retries||0,t.retries=typeof t.retries=="number"?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),my(e,t,(r,i)=>{if(r)return n(r);let o=cK.operation(t.retries);o.attempt(()=>{cy(i,t,a=>{if(o.retry(a))return;if(a)return n(o.mainError());let s=ji[i]={options:t,lastUpdate:Date.now()};fy(i,t),n(null,d=>{if(s.released)return d&&d(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));c0(i,{...t,realpath:!1},d)})})})})}function c0(e,t,n){t={fs:py,realpath:!0,...t},my(e,t,(r,i)=>{if(r)return n(r);let o=ji[i];if(!o)return n(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));o.updateTimeout&&clearTimeout(o.updateTimeout),o.released=!0,delete ji[i],u0(i,t,n)})}function mK(e,t,n){t={stale:1e4,realpath:!0,fs:py,...t},t.stale=Math.max(t.stale||0,2e3),my(e,t,(r,i)=>{if(r)return n(r);t.fs.stat(fs(i,t),(o,a)=>o?o.code==="ENOENT"?n(null,!1):n(o):n(null,!l0(a,t)))})}function hK(){return ji}fK(()=>{for(let e in ji){let t=ji[e].options;try{t.fs.rmdirSync(fs(e,t))}catch{}}});Tl.exports.lock=pK;Tl.exports.unlock=c0;Tl.exports.check=mK;Tl.exports.getLocks=hK});var m0=St((I4e,p0)=>{"use strict";var _K=dy();function yK(e){let t=["mkdir","realpath","stat","rmdir","utimes"],n={...e};return t.forEach(r=>{n[r]=(...i)=>{let o=i.pop(),a;try{a=e[`${r}Sync`](...i)}catch(s){return o(s)}o(null,a)}}),n}function gK(e){return(...t)=>new Promise((n,r)=>{t.push((i,o)=>{i?r(i):n(o)}),e(...t)})}function bK(e){return(...t)=>{let n,r;if(t.push((i,o)=>{n=i,r=o}),e(...t),n)throw n;return r}}function vK(e){if(e={...e},e.fs=yK(e.fs||_K),typeof e.retries=="number"&&e.retries>0||e.retries&&typeof e.retries.retries=="number"&&e.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return e}p0.exports={toPromise:gK,toSync:bK,toSyncOptions:vK}});var _0=St((M4e,po)=>{"use strict";var ps=f0(),{toPromise:xf,toSync:Rf,toSyncOptions:hy}=m0();async function h0(e,t){let n=await xf(ps.lock)(e,t);return xf(n)}function SK(e,t){let n=Rf(ps.lock)(e,hy(t));return Rf(n)}function wK(e,t){return xf(ps.unlock)(e,t)}function TK(e,t){return Rf(ps.unlock)(e,hy(t))}function AK(e,t){return xf(ps.check)(e,t)}function kK(e,t){return Rf(ps.check)(e,hy(t))}po.exports=h0;po.exports.lock=h0;po.exports.unlock=wK;po.exports.lockSync=SK;po.exports.unlockSync=TK;po.exports.check=AK;po.exports.checkSync=kK});var y0=N(()=>{});var ms=N(()=>{});var mo=N(()=>{});var Ue=N(()=>{y0();ms();mo()});function EK(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function Je(e){return EK(e)?e:{RE_EXN_ID:"JsExn",_1:e}}function yy(e){let t=_y[e];if(t!==void 0){let n=t+1|0;return _y[e]=n,e+("/"+n)}return _y[e]=1,e}var _y,it=N(()=>{_y={}});import*as b0 from"node:child_process";function jt(e){let t=ti(e);if(t===void 0)return{code:void 0,message:"unknown error"};let n=Fe(t);return{code:as(n.code),message:$e(ni(n),"unknown error")}}function v0(e,t,n,r){try{return{TAG:"Ok",_0:b0.execFileSync(e,t,{encoding:"utf8",timeout:n,maxBuffer:r})}}catch(i){let o=Je(i);return{TAG:"Error",_0:jt(o)}}}var OK,Ke=N(()=>{Ni();we();ss();OK=ei(_0(),1);Ue();qe();it()});function w0(e){let t=v0(e,["--version"],1e4,1048576);if(t.TAG!=="Ok")return;let n=S0.exec(t._0);if(n!=null)return ft(n.slice(1)[0],r=>r)}function T0(e,t){return e!==void 0&&t!==void 0?e===t?{TAG:"Match",version:e}:{TAG:"Mismatch",pathVersion:e,pinnedVersion:t}:{TAG:"Unverified",pathVersion:e,pinnedVersion:t}}var S0,A0=N(()=>{rt();Ke();we();Ue();S0=new RegExp("(\\d+\\.\\d+\\.\\d+)")});function RK(e,t){let n=T0(e,t);switch(n.TAG){case"Match":return{TAG:"Ok",_0:n.version};case"Mismatch":return{TAG:"Error",_0:"hosted_codex_runtime_refused reason=mismatch observed="+n.pathVersion+" expected="+n.pinnedVersion};case"Unverified":return{TAG:"Error",_0:"hosted_codex_runtime_refused reason=unverified observed=unverified expected="+t}}}function k0(e,t){return RK(w0(e),t)}var C0=N(()=>{we();A0()});var E0,gy=N(()=>{C0();E0=k0});var x0,O0=N(()=>{x0={name:"@linzumi/cli",version:"1.0.311",description:"Linzumi CLI \u2014 point a Codex agent at the real code on your laptop, with your team watching and steering from shared threads.",type:"module",bin:{linzumi:"bin/linzumi.js"},files:["README.md","bin","dist","scripts","!scripts/build-*-oracle.mjs","native/darwin/linzumi-terminal-pty-helper","native/darwin/terminal-pty-helper.manifest.json"],scripts:{build:"rescript build ../linzumi-cli-rescript && node scripts/build.mjs","bump-version":"node scripts/bump-cli-version.mjs",test:"pnpm --dir ../linzumi-cli-rescript test && npm run test:operational",typecheck:"rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.source.json",prepack:"rescript build -q ../linzumi-cli-rescript && node scripts/build.mjs","pack:dry-run":"npm pack --dry-run","test:operational":"vitest run --config vitest.config.mjs","vendor:codex-app-server-protocol":"tsx scripts/vendor-codex-app-server-protocol.ts","test:startup":"npm run build && node --test --test-concurrency=1 ../linzumi-cli-rescript/src/parity/CommanderStartupRefusalConformance.res.mjs","typecheck:all":"rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.json","typecheck:watch":"rescript build ../linzumi-cli-rescript && tsgo --noEmit -w -p tsconfig.source.json","test:agent-source":"LINZUMI_CI_QUARANTINE=0 pnpm exec vitest run --config vitest.config.mjs test/channelSession.test.ts test/kandanQueue.test.ts -t '(retains three busy accepted source snapshots without fusing or interrupting|keeps different accepted agent sources distinct through interrupt pickup)' && pnpm --dir ../linzumi-cli-rescript build && pnpm --dir ../linzumi-cli-rescript exec node --import tsx src/parity/AgentOpenaiModelProviderConformance.res.mjs && pnpm --dir ../linzumi-cli-rescript exec node --import tsx src/parity/WorkerMintCredentialConformance.res.mjs","codex:history-table":"node scripts/codex_history_table.mjs","vendor:codex-app-server-protocol:check":"tsx scripts/vendor-codex-app-server-protocol.ts --check"},keywords:["linzumi","kandan","codex","local-runner"],license:"MIT",publishConfig:{access:"public"},dependencies:{"@anthropic-ai/claude-agent-sdk":"0.3.283","@inquirer/prompts":"^7.8.6","@modelcontextprotocol/sdk":"^1.29.0","@openai/codex":"0.159.2",blessed:"^0.1.81","ghostty-web":"0.4.0","proper-lockfile":"3.2.0","stream-json":"1.9.1",undici:"^6.25.0",ws:"^8.18.0",zod:"^3.25.76"},engines:{node:">=20"},readmeFilename:"README.md",devDependencies:{"@types/blessed":"^0.1.27","@types/node":"^22.18.6","@types/proper-lockfile":"4.1.4","@typescript/native-preview":"7.0.0-dev.20260703.1",esbuild:"^0.27.2","fast-check":"^3.23.2",rescript:"12.3.0",tsx:"^4.21.0",typescript:"^5.9.3",vitest:"^1.6.1"}}});var by,If=N(()=>{"use strict";O0();by=x0.dependencies["@openai/codex"]});async function R0(e,t,n){let r;try{e(),r=!0}catch{r=!1}let i;try{await t(),i=!0}catch{i=!1}return r&&i?{TAG:"Ok",_0:void 0}:(n("hosted_auth_quota_cleanup_failed reason=owned_process_not_confirmed_reaped"),{TAG:"Error",_0:"cleanup_failed"})}function P0(e,t){let n=e.quotaWindow,r=e.credits;if(n===void 0&&r===void 0)return{status:"unavailable",reason:"empty_response"};let i=n!==void 0?[n.usedPercent,n.windowMinutes,n.resetsAtMs]:[void 0,void 0,void 0];return{status:"captured",quotaWindow:{usedPercent:i[0],windowMinutes:i[1],resetsAtMs:i[2],capturedAtMs:t,credits:r}}}var I0=N(()=>{});var M0,D0,$0=N(()=>{I0();M0=R0,D0=P0});function yt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function vy(e){let t=[["threadId",e.threadId],["turnId",e.turnId],["itemId",e.itemId],["processId",e.processId],["requestId",e.requestId]].filter(n=>n[1]!==void 0);return Object.fromEntries(t)}var Yt=N(()=>{"use strict"});var Mf=N(()=>{"use strict";Yt()});function G0(e){let t=ri(e.rateLimits)??ri(e.rate_limits)??ri(e.limits)??e,n=[t,...Object.values(t).flatMap(b=>{let g=ri(b);return g===void 0?[]:[g]})],r=n.reduce((b,g)=>{let S=ot(g.usedPercent)??ot(g.used_percent);return S===void 0?b:b===void 0?S:Math.max(b,S)},void 0),o=n.some(b=>ot(b.remaining)===0||ot(b.remainingRequests)===0||ot(b.remaining_requests)===0||ot(b.remainingTokens)===0||ot(b.remaining_tokens)===0||ot(b.retryAfterSeconds)!==void 0||ot(b.retry_after_seconds)!==void 0)?"rejected":r!==void 0&&r>=80?"allowed_warning":"allowed",a=ri(t.primary),s=ot(a?.usedPercent),d=ot(a?.windowDurationMins),l=ot(a?.resetsAt),u=ri(t.credits),c=L0(u?.hasCredits),p=L0(u?.unlimited),m=u?.balance,y=c===void 0||p===void 0?void 0:{hasCredits:c,unlimited:p,balance:typeof m=="string"?m:null},h=s===void 0&&d===void 0&&l===void 0?void 0:{...s===void 0?{}:{usedPercent:s},...d===void 0?{}:{windowMinutes:d},...l===void 0?{}:{resetsAtMs:l*1e3}};return{summary:$K(e)??"seen (no details)",status:o,utilizationPercent:r,...h===void 0?{}:{quotaWindow:h},...y===void 0?{}:{credits:y}}}function $K(e){let t=ri(e.rateLimits)??ri(e.rate_limits)??ri(e.limits)??e,n=N0(t,void 0),r=Object.entries(t).flatMap(([o,a])=>{let s=ri(a);return s===void 0?[]:[N0(s,o)]}),i=[n,...r].filter(o=>o!==void 0);return i.length===0?void 0:i.join(" | ")}function N0(e,t){let n=Er(e.limitName)??Er(e.limit_name)??Er(e.name)??Er(e.type)??t,r=Er(e.planType)??Er(e.plan_type)??Er(e.plan),i=ot(e.remaining)??ot(e.remainingRequests)??ot(e.remaining_requests)??ot(e.remainingTokens)??ot(e.remaining_tokens),o=ot(e.limit)??ot(e.requestLimit)??ot(e.request_limit)??ot(e.limitRequests)??ot(e.limit_requests)??ot(e.tokenLimit)??ot(e.token_limit)??ot(e.limitTokens)??ot(e.limit_tokens),a=Er(e.resetAt)??Er(e.reset_at)??Er(e.resetsAt)??Er(e.resets_at)??j0(e.resetsAt)??j0(e.resets_at)??Df(e.resetAfterSeconds)??Df(e.reset_after_seconds)??Df(e.retryAfterSeconds)??Df(e.retry_after_seconds),s=ot(e.usedPercent)??ot(e.used_percent),d=ot(e.windowDurationMins)??ot(e.window_duration_mins),l=[n,r].filter(m=>m!==void 0).join(" "),u=l===""?void 0:l,p=[i===void 0?void 0:o===void 0?`${i} remaining`:`${i}/${o} remaining`,s===void 0?void 0:`${s}% used`,d===void 0?void 0:`${d}m window`,a===void 0?void 0:`reset ${a}`].filter(m=>m!==void 0);return p.length===0?u===void 0?void 0:`${u} seen (no details)`:u===void 0?p.join(" "):`${u} ${p.join(" ")}`}function Df(e){let t=ot(e);return t===void 0?void 0:`${t}s`}function j0(e){let t=ot(e);return t===void 0?void 0:new Date(t*1e3).toISOString()}function ri(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function Er(e){return typeof e=="string"&&e.trim()!==""?e:void 0}function L0(e){return typeof e=="boolean"?e:void 0}function ot(e){if(typeof e=="number"&&Number.isSafeInteger(e))return e;if(typeof e!="string")return;let t=Number.parseInt(e,10);return Number.isSafeInteger(t)&&t.toString()===e.trim()?t:void 0}var F0=N(()=>{"use strict";Mf();Yt()});var Li=St((Z4e,B0)=>{"use strict";var q0=["nodebuffer","arraybuffer","fragments"],U0=typeof Blob<"u";U0&&q0.push("blob");B0.exports={BINARY_TYPES:q0,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:U0,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Cl=St((Y4e,$f)=>{"use strict";var{EMPTY_BUFFER:NK}=Li(),Sy=Buffer[Symbol.species];function jK(e,t){if(e.length===0)return NK;if(e.length===1)return e[0];let n=Buffer.allocUnsafe(t),r=0;for(let i=0;i<e.length;i++){let o=e[i];n.set(o,r),r+=o.length}return r<t?new Sy(n.buffer,n.byteOffset,r):n}function z0(e,t,n,r,i){for(let o=0;o<i;o++)n[r+o]=e[o]^t[o&3]}function K0(e,t){for(let n=0;n<e.length;n++)e[n]^=t[n&3]}function LK(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function wy(e){if(wy.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new Sy(e):ArrayBuffer.isView(e)?t=new Sy(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),wy.readOnly=!1),t}$f.exports={concat:jK,mask:z0,toArrayBuffer:LK,toBuffer:wy,unmask:K0};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=ut("bufferutil");$f.exports.mask=function(t,n,r,i,o){o<48?z0(t,n,r,i,o):e.mask(t,n,r,i,o)},$f.exports.unmask=function(t,n){t.length<32?K0(t,n):e.unmask(t,n)}}catch{}});var W0=St((Q4e,J0)=>{"use strict";var H0=Symbol("kDone"),Ty=Symbol("kRun"),Ay=class{constructor(t){this[H0]=()=>{this.pending--,this[Ty]()},this.concurrency=t||1/0,this.jobs=[],this.pending=0}add(t){this.jobs.push(t),this[Ty]()}[Ty](){if(this.pending!==this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[H0])}}};J0.exports=Ay});var Ol=St((X4e,Q0)=>{"use strict";var El=ut("zlib"),V0=Cl(),GK=W0(),{kStatusCode:Z0}=Li(),FK=Buffer[Symbol.species],qK=Buffer.from([0,0,255,255]),jf=Symbol("permessage-deflate"),Gi=Symbol("total-length"),_s=Symbol("callback"),_o=Symbol("buffers"),ys=Symbol("error"),Nf,ky=class{constructor(t,n,r){if(this._maxPayload=r|0,this._options=t||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!n,this._deflate=null,this._inflate=null,this.params=null,!Nf){let i=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Nf=new GK(i)}}static get extensionName(){return"permessage-deflate"}offer(){let t={};return this._options.serverNoContextTakeover&&(t.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(t.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(t.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?t.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(t.client_max_window_bits=!0),t}accept(t){return t=this.normalizeParams(t),this.params=this._isServer?this.acceptAsServer(t):this.acceptAsClient(t),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let t=this._deflate[_s];this._deflate.close(),this._deflate=null,t&&t(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(t){let n=this._options,r=t.find(i=>!(n.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(n.serverMaxWindowBits===!1||typeof n.serverMaxWindowBits=="number"&&n.serverMaxWindowBits>i.server_max_window_bits)||typeof n.clientMaxWindowBits=="number"&&!i.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return n.serverNoContextTakeover&&(r.server_no_context_takeover=!0),n.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof n.serverMaxWindowBits=="number"&&(r.server_max_window_bits=n.serverMaxWindowBits),typeof n.clientMaxWindowBits=="number"?r.client_max_window_bits=n.clientMaxWindowBits:(r.client_max_window_bits===!0||n.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(t){let n=t[0];if(this._options.clientNoContextTakeover===!1&&n.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!n.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(n.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&n.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return n}normalizeParams(t){return t.forEach(n=>{Object.keys(n).forEach(r=>{let i=n[r];if(i.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(i=i[0],r==="client_max_window_bits"){if(i!==!0){let o=+i;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=o}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else if(r==="server_max_window_bits"){let o=+i;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=o}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else throw new Error(`Unknown parameter "${r}"`);n[r]=i})}),t}decompress(t,n,r){Nf.add(i=>{this._decompress(t,n,(o,a)=>{i(),r(o,a)})})}compress(t,n,r){Nf.add(i=>{this._compress(t,n,(o,a)=>{i(),r(o,a)})})}_decompress(t,n,r){let i=this._isServer?"client":"server";if(!this._inflate){let o=`${i}_max_window_bits`,a=typeof this.params[o]!="number"?El.Z_DEFAULT_WINDOWBITS:this.params[o];this._inflate=El.createInflateRaw({...this._options.zlibInflateOptions,windowBits:a}),this._inflate[jf]=this,this._inflate[Gi]=0,this._inflate[_o]=[],this._inflate.on("error",BK),this._inflate.on("data",Y0)}this._inflate[_s]=r,this._inflate.write(t),n&&this._inflate.write(qK),this._inflate.flush(()=>{let o=this._inflate[ys];if(o){this._inflate.close(),this._inflate=null,r(o);return}let a=V0.concat(this._inflate[_o],this._inflate[Gi]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Gi]=0,this._inflate[_o]=[],n&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),r(null,a)})}_compress(t,n,r){let i=this._isServer?"server":"client";if(!this._deflate){let o=`${i}_max_window_bits`,a=typeof this.params[o]!="number"?El.Z_DEFAULT_WINDOWBITS:this.params[o];this._deflate=El.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:a}),this._deflate[Gi]=0,this._deflate[_o]=[],this._deflate.on("data",UK)}this._deflate[_s]=r,this._deflate.write(t),this._deflate.flush(El.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let o=V0.concat(this._deflate[_o],this._deflate[Gi]);n&&(o=new FK(o.buffer,o.byteOffset,o.length-4)),this._deflate[_s]=null,this._deflate[Gi]=0,this._deflate[_o]=[],n&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),r(null,o)})}};Q0.exports=ky;function UK(e){this[_o].push(e),this[Gi]+=e.length}function Y0(e){if(this[Gi]+=e.length,this[jf]._maxPayload<1||this[Gi]<=this[jf]._maxPayload){this[_o].push(e);return}this[ys]=new RangeError("Max payload size exceeded"),this[ys].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[ys][Z0]=1009,this.removeListener("data",Y0),this.reset()}function BK(e){if(this[jf]._inflate=null,this[ys]){this[_s](this[ys]);return}e[Z0]=1007,this[_s](e)}});var gs=St((eVe,Lf)=>{"use strict";var{isUtf8:X0}=ut("buffer"),{hasBlob:zK}=Li(),KK=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function HK(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function Cy(e){let t=e.length,n=0;for(;n<t;)if((e[n]&128)===0)n++;else if((e[n]&224)===192){if(n+1===t||(e[n+1]&192)!==128||(e[n]&254)===192)return!1;n+=2}else if((e[n]&240)===224){if(n+2>=t||(e[n+1]&192)!==128||(e[n+2]&192)!==128||e[n]===224&&(e[n+1]&224)===128||e[n]===237&&(e[n+1]&224)===160)return!1;n+=3}else if((e[n]&248)===240){if(n+3>=t||(e[n+1]&192)!==128||(e[n+2]&192)!==128||(e[n+3]&192)!==128||e[n]===240&&(e[n+1]&240)===128||e[n]===244&&e[n+1]>143||e[n]>244)return!1;n+=4}else return!1;return!0}function JK(e){return zK&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]==="Blob"||e[Symbol.toStringTag]==="File")}Lf.exports={isBlob:JK,isValidStatusCode:HK,isValidUTF8:Cy,tokenChars:KK};if(X0)Lf.exports.isValidUTF8=function(e){return e.length<24?Cy(e):X0(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=ut("utf-8-validate");Lf.exports.isValidUTF8=function(t){return t.length<32?Cy(t):e(t)}}catch{}});var Py=St((tVe,aE)=>{"use strict";var{Writable:WK}=ut("stream"),eE=Ol(),{BINARY_TYPES:VK,EMPTY_BUFFER:tE,kStatusCode:ZK,kWebSocket:YK}=Li(),{concat:Ey,toArrayBuffer:QK,unmask:XK}=Cl(),{isValidStatusCode:eH,isValidUTF8:nE}=gs(),Gf=Buffer[Symbol.species],dr=0,rE=1,iE=2,oE=3,Oy=4,xy=5,Ff=6,Ry=class extends WK{constructor(t={}){super(),this._allowSynchronousEvents=t.allowSynchronousEvents!==void 0?t.allowSynchronousEvents:!0,this._binaryType=t.binaryType||VK[0],this._extensions=t.extensions||{},this._isServer=!!t.isServer,this._maxPayload=t.maxPayload|0,this._skipUTF8Validation=!!t.skipUTF8Validation,this[YK]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=dr}_write(t,n,r){if(this._opcode===8&&this._state==dr)return r();this._bufferedBytes+=t.length,this._buffers.push(t),this.startLoop(r)}consume(t){if(this._bufferedBytes-=t,t===this._buffers[0].length)return this._buffers.shift();if(t<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new Gf(r.buffer,r.byteOffset+t,r.length-t),new Gf(r.buffer,r.byteOffset,t)}let n=Buffer.allocUnsafe(t);do{let r=this._buffers[0],i=n.length-t;t>=r.length?n.set(this._buffers.shift(),i):(n.set(new Uint8Array(r.buffer,r.byteOffset,t),i),this._buffers[0]=new Gf(r.buffer,r.byteOffset+t,r.length-t)),t-=r.length}while(t>0);return n}startLoop(t){this._loop=!0;do switch(this._state){case dr:this.getInfo(t);break;case rE:this.getPayloadLength16(t);break;case iE:this.getPayloadLength64(t);break;case oE:this.getMask();break;case Oy:this.getData(t);break;case xy:case Ff:this._loop=!1;return}while(this._loop);this._errored||t()}getInfo(t){if(this._bufferedBytes<2){this._loop=!1;return}let n=this.consume(2);if((n[0]&48)!==0){let i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");t(i);return}let r=(n[0]&64)===64;if(r&&!this._extensions[eE.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(i);return}if(this._fin=(n[0]&128)===128,this._opcode=n[0]&15,this._payloadLength=n[1]&127,this._opcode===0){if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");t(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(i);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");t(i);return}if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");t(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(n[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");t(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");t(i);return}this._payloadLength===126?this._state=rE:this._payloadLength===127?this._state=iE:this.haveLength(t)}getPayloadLength16(t){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(t)}getPayloadLength64(t){if(this._bufferedBytes<8){this._loop=!1;return}let n=this.consume(8),r=n.readUInt32BE(0);if(r>Math.pow(2,21)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");t(i);return}this._payloadLength=r*Math.pow(2,32)+n.readUInt32BE(4),this.haveLength(t)}haveLength(t){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let n=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(n);return}this._masked?this._state=oE:this._state=Oy}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Oy}getData(t){let n=tE;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}n=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&XK(n,this._mask)}if(this._opcode>7){this.controlMessage(n,t);return}if(this._compressed){this._state=xy,this.decompress(n,t);return}n.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(n)),this.dataMessage(t)}decompress(t,n){this._extensions[eE.extensionName].decompress(t,this._fin,(i,o)=>{if(i)return n(i);if(o.length){if(this._messageLength+=o.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let a=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");n(a);return}this._fragments.push(o)}this.dataMessage(n),this._state===dr&&this.startLoop(n)})}dataMessage(t){if(!this._fin){this._state=dr;return}let n=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=Ey(r,n):this._binaryType==="arraybuffer"?i=QK(Ey(r,n)):this._binaryType==="blob"?i=new Blob(r):i=r,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=dr):(this._state=Ff,setImmediate(()=>{this.emit("message",i,!0),this._state=dr,this.startLoop(t)}))}else{let i=Ey(r,n);if(!this._skipUTF8Validation&&!nE(i)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(o);return}this._state===xy||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=dr):(this._state=Ff,setImmediate(()=>{this.emit("message",i,!1),this._state=dr,this.startLoop(t)}))}}controlMessage(t,n){if(this._opcode===8){if(t.length===0)this._loop=!1,this.emit("conclude",1005,tE),this.end();else{let r=t.readUInt16BE(0);if(!eH(r)){let o=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");n(o);return}let i=new Gf(t.buffer,t.byteOffset+2,t.length-2);if(!this._skipUTF8Validation&&!nE(i)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(o);return}this._loop=!1,this.emit("conclude",r,i),this.end()}this._state=dr;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",t),this._state=dr):(this._state=Ff,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",t),this._state=dr,this.startLoop(n)}))}createError(t,n,r,i,o){this._loop=!1,this._errored=!0;let a=new t(r?`Invalid WebSocket frame: ${n}`:n);return Error.captureStackTrace(a,this.createError),a.code=o,a[ZK]=i,a}};aE.exports=Ry});var Dy=St((rVe,lE)=>{"use strict";var{Duplex:nVe}=ut("stream"),{randomFillSync:tH}=ut("crypto"),sE=Ol(),{EMPTY_BUFFER:nH,kWebSocket:rH,NOOP:iH}=Li(),{isBlob:bs,isValidStatusCode:oH}=gs(),{mask:dE,toBuffer:aa}=Cl(),lr=Symbol("kByteLength"),aH=Buffer.alloc(4),qf=8*1024,sa,vs=qf,Or=0,sH=1,dH=2,Iy=class e{constructor(t,n,r){this._extensions=n||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=t,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Or,this.onerror=iH,this[rH]=void 0}static frame(t,n){let r,i=!1,o=2,a=!1;n.mask&&(r=n.maskBuffer||aH,n.generateMask?n.generateMask(r):(vs===qf&&(sa===void 0&&(sa=Buffer.alloc(qf)),tH(sa,0,qf),vs=0),r[0]=sa[vs++],r[1]=sa[vs++],r[2]=sa[vs++],r[3]=sa[vs++]),a=(r[0]|r[1]|r[2]|r[3])===0,o=6);let s;typeof t=="string"?(!n.mask||a)&&n[lr]!==void 0?s=n[lr]:(t=Buffer.from(t),s=t.length):(s=t.length,i=n.mask&&n.readOnly&&!a);let d=s;s>=65536?(o+=8,d=127):s>125&&(o+=2,d=126);let l=Buffer.allocUnsafe(i?s+o:o);return l[0]=n.fin?n.opcode|128:n.opcode,n.rsv1&&(l[0]|=64),l[1]=d,d===126?l.writeUInt16BE(s,2):d===127&&(l[2]=l[3]=0,l.writeUIntBE(s,4,6)),n.mask?(l[1]|=128,l[o-4]=r[0],l[o-3]=r[1],l[o-2]=r[2],l[o-1]=r[3],a?[l,t]:i?(dE(t,r,l,o,s),[l]):(dE(t,r,t,0,s),[l,t])):[l,t]}close(t,n,r,i){let o;if(t===void 0)o=nH;else{if(typeof t!="number"||!oH(t))throw new TypeError("First argument must be a valid error code number");if(n===void 0||!n.length)o=Buffer.allocUnsafe(2),o.writeUInt16BE(t,0);else{let s=Buffer.byteLength(n);if(s>123)throw new RangeError("The message must not be greater than 123 bytes");o=Buffer.allocUnsafe(2+s),o.writeUInt16BE(t,0),typeof n=="string"?o.write(n,2):o.set(n,2)}}let a={[lr]:o.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Or?this.enqueue([this.dispatch,o,!1,a,i]):this.sendFrame(e.frame(o,a),i)}ping(t,n,r){let i,o;if(typeof t=="string"?(i=Buffer.byteLength(t),o=!1):bs(t)?(i=t.size,o=!1):(t=aa(t),i=t.length,o=aa.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[lr]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:o,rsv1:!1};bs(t)?this._state!==Or?this.enqueue([this.getBlobData,t,!1,a,r]):this.getBlobData(t,!1,a,r):this._state!==Or?this.enqueue([this.dispatch,t,!1,a,r]):this.sendFrame(e.frame(t,a),r)}pong(t,n,r){let i,o;if(typeof t=="string"?(i=Buffer.byteLength(t),o=!1):bs(t)?(i=t.size,o=!1):(t=aa(t),i=t.length,o=aa.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[lr]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:o,rsv1:!1};bs(t)?this._state!==Or?this.enqueue([this.getBlobData,t,!1,a,r]):this.getBlobData(t,!1,a,r):this._state!==Or?this.enqueue([this.dispatch,t,!1,a,r]):this.sendFrame(e.frame(t,a),r)}send(t,n,r){let i=this._extensions[sE.extensionName],o=n.binary?2:1,a=n.compress,s,d;typeof t=="string"?(s=Buffer.byteLength(t),d=!1):bs(t)?(s=t.size,d=!1):(t=aa(t),s=t.length,d=aa.readOnly),this._firstFragment?(this._firstFragment=!1,a&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(a=s>=i._threshold),this._compress=a):(a=!1,o=0),n.fin&&(this._firstFragment=!0);let l={[lr]:s,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:o,readOnly:d,rsv1:a};bs(t)?this._state!==Or?this.enqueue([this.getBlobData,t,this._compress,l,r]):this.getBlobData(t,this._compress,l,r):this._state!==Or?this.enqueue([this.dispatch,t,this._compress,l,r]):this.dispatch(t,this._compress,l,r)}getBlobData(t,n,r,i){this._bufferedBytes+=r[lr],this._state=dH,t.arrayBuffer().then(o=>{if(this._socket.destroyed){let s=new Error("The socket was closed while the blob was being read");process.nextTick(My,this,s,i);return}this._bufferedBytes-=r[lr];let a=aa(o);n?this.dispatch(a,n,r,i):(this._state=Or,this.sendFrame(e.frame(a,r),i),this.dequeue())}).catch(o=>{process.nextTick(lH,this,o,i)})}dispatch(t,n,r,i){if(!n){this.sendFrame(e.frame(t,r),i);return}let o=this._extensions[sE.extensionName];this._bufferedBytes+=r[lr],this._state=sH,o.compress(t,r.fin,(a,s)=>{if(this._socket.destroyed){let d=new Error("The socket was closed while data was being compressed");My(this,d,i);return}this._bufferedBytes-=r[lr],this._state=Or,r.readOnly=!1,this.sendFrame(e.frame(s,r),i),this.dequeue()})}dequeue(){for(;this._state===Or&&this._queue.length;){let t=this._queue.shift();this._bufferedBytes-=t[3][lr],Reflect.apply(t[0],this,t.slice(1))}}enqueue(t){this._bufferedBytes+=t[3][lr],this._queue.push(t)}sendFrame(t,n){t.length===2?(this._socket.cork(),this._socket.write(t[0]),this._socket.write(t[1],n),this._socket.uncork()):this._socket.write(t[0],n)}};lE.exports=Iy;function My(e,t,n){typeof n=="function"&&n(t);for(let r=0;r<e._queue.length;r++){let i=e._queue[r],o=i[i.length-1];typeof o=="function"&&o(t)}}function lH(e,t,n){My(e,t,n),e.onerror(t)}});var gE=St((iVe,yE)=>{"use strict";var{kForOnEventAttribute:xl,kListener:$y}=Li(),uE=Symbol("kCode"),cE=Symbol("kData"),fE=Symbol("kError"),pE=Symbol("kMessage"),mE=Symbol("kReason"),Ss=Symbol("kTarget"),hE=Symbol("kType"),_E=Symbol("kWasClean"),Fi=class{constructor(t){this[Ss]=null,this[hE]=t}get target(){return this[Ss]}get type(){return this[hE]}};Object.defineProperty(Fi.prototype,"target",{enumerable:!0});Object.defineProperty(Fi.prototype,"type",{enumerable:!0});var da=class extends Fi{constructor(t,n={}){super(t),this[uE]=n.code===void 0?0:n.code,this[mE]=n.reason===void 0?"":n.reason,this[_E]=n.wasClean===void 0?!1:n.wasClean}get code(){return this[uE]}get reason(){return this[mE]}get wasClean(){return this[_E]}};Object.defineProperty(da.prototype,"code",{enumerable:!0});Object.defineProperty(da.prototype,"reason",{enumerable:!0});Object.defineProperty(da.prototype,"wasClean",{enumerable:!0});var ws=class extends Fi{constructor(t,n={}){super(t),this[fE]=n.error===void 0?null:n.error,this[pE]=n.message===void 0?"":n.message}get error(){return this[fE]}get message(){return this[pE]}};Object.defineProperty(ws.prototype,"error",{enumerable:!0});Object.defineProperty(ws.prototype,"message",{enumerable:!0});var Rl=class extends Fi{constructor(t,n={}){super(t),this[cE]=n.data===void 0?null:n.data}get data(){return this[cE]}};Object.defineProperty(Rl.prototype,"data",{enumerable:!0});var uH={addEventListener(e,t,n={}){for(let i of this.listeners(e))if(!n[xl]&&i[$y]===t&&!i[xl])return;let r;if(e==="message")r=function(o,a){let s=new Rl("message",{data:a?o:o.toString()});s[Ss]=this,Uf(t,this,s)};else if(e==="close")r=function(o,a){let s=new da("close",{code:o,reason:a.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});s[Ss]=this,Uf(t,this,s)};else if(e==="error")r=function(o){let a=new ws("error",{error:o,message:o.message});a[Ss]=this,Uf(t,this,a)};else if(e==="open")r=function(){let o=new Fi("open");o[Ss]=this,Uf(t,this,o)};else return;r[xl]=!!n[xl],r[$y]=t,n.once?this.once(e,r):this.on(e,r)},removeEventListener(e,t){for(let n of this.listeners(e))if(n[$y]===t&&!n[xl]){this.removeListener(e,n);break}}};yE.exports={CloseEvent:da,ErrorEvent:ws,Event:Fi,EventTarget:uH,MessageEvent:Rl};function Uf(e,t,n){typeof e=="object"&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}});var Ny=St((oVe,bE)=>{"use strict";var{tokenChars:Pl}=gs();function ii(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}function cH(e){let t=Object.create(null),n=Object.create(null),r=!1,i=!1,o=!1,a,s,d=-1,l=-1,u=-1,c=0;for(;c<e.length;c++)if(l=e.charCodeAt(c),a===void 0)if(u===-1&&Pl[l]===1)d===-1&&(d=c);else if(c!==0&&(l===32||l===9))u===-1&&d!==-1&&(u=c);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${c}`);u===-1&&(u=c);let m=e.slice(d,u);l===44?(ii(t,m,n),n=Object.create(null)):a=m,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);else if(s===void 0)if(u===-1&&Pl[l]===1)d===-1&&(d=c);else if(l===32||l===9)u===-1&&d!==-1&&(u=c);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${c}`);u===-1&&(u=c),ii(n,e.slice(d,u),!0),l===44&&(ii(t,a,n),n=Object.create(null),a=void 0),d=u=-1}else if(l===61&&d!==-1&&u===-1)s=e.slice(d,c),d=u=-1;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(i){if(Pl[l]!==1)throw new SyntaxError(`Unexpected character at index ${c}`);d===-1?d=c:r||(r=!0),i=!1}else if(o)if(Pl[l]===1)d===-1&&(d=c);else if(l===34&&d!==-1)o=!1,u=c;else if(l===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(l===34&&e.charCodeAt(c-1)===61)o=!0;else if(u===-1&&Pl[l]===1)d===-1&&(d=c);else if(d!==-1&&(l===32||l===9))u===-1&&(u=c);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${c}`);u===-1&&(u=c);let m=e.slice(d,u);r&&(m=m.replace(/\\/g,""),r=!1),ii(n,s,m),l===44&&(ii(t,a,n),n=Object.create(null),a=void 0),s=void 0,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);if(d===-1||o||l===32||l===9)throw new SyntaxError("Unexpected end of input");u===-1&&(u=c);let p=e.slice(d,u);return a===void 0?ii(t,p,n):(s===void 0?ii(n,p,!0):r?ii(n,s,p.replace(/\\/g,"")):ii(n,s,p),ii(t,a,n)),t}function fH(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(r=>[t].concat(Object.keys(r).map(i=>{let o=r[i];return Array.isArray(o)||(o=[o]),o.map(a=>a===!0?i:`${i}=${a}`).join("; ")})).join("; ")).join(", ")}).join(", ")}bE.exports={format:fH,parse:cH}});var Hf=St((dVe,PE)=>{"use strict";var pH=ut("events"),mH=ut("https"),hH=ut("http"),wE=ut("net"),_H=ut("tls"),{randomBytes:yH,createHash:gH}=ut("crypto"),{Duplex:aVe,Readable:sVe}=ut("stream"),{URL:jy}=ut("url"),yo=Ol(),bH=Py(),vH=Dy(),{isBlob:SH}=gs(),{BINARY_TYPES:vE,EMPTY_BUFFER:Bf,GUID:wH,kForOnEventAttribute:Ly,kListener:TH,kStatusCode:AH,kWebSocket:dn,NOOP:TE}=Li(),{EventTarget:{addEventListener:kH,removeEventListener:CH}}=gE(),{format:EH,parse:OH}=Ny(),{toBuffer:xH}=Cl(),RH=30*1e3,AE=Symbol("kAborted"),Gy=[8,13],qi=["CONNECTING","OPEN","CLOSING","CLOSED"],PH=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,Mt=class e extends pH{constructor(t,n,r){super(),this._binaryType=vE[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Bf,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,n===void 0?n=[]:Array.isArray(n)||(typeof n=="object"&&n!==null?(r=n,n=[]):n=[n]),kE(this,t,n,r)):(this._autoPong=r.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(t){vE.includes(t)&&(this._binaryType=t,this._receiver&&(this._receiver._binaryType=t))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(t,n,r){let i=new bH({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),o=new vH(t,this._extensions,r.generateMask);this._receiver=i,this._sender=o,this._socket=t,i[dn]=this,o[dn]=this,t[dn]=this,i.on("conclude",DH),i.on("drain",$H),i.on("error",NH),i.on("message",jH),i.on("ping",LH),i.on("pong",GH),o.onerror=FH,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on("close",OE),t.on("data",Kf),t.on("end",xE),t.on("error",RE),this._readyState=e.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[yo.extensionName]&&this._extensions[yo.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){Wn(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,n,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),EE(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,n,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(r=t,t=n=void 0):typeof n=="function"&&(r=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Fy(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(t||Bf,n,r)}pong(t,n,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(r=t,t=n=void 0):typeof n=="function"&&(r=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Fy(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.pong(t||Bf,n,r)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof n=="function"&&(r=n,n={}),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Fy(this,t,r);return}let i={binary:typeof t!="string",mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[yo.extensionName]||(i.compress=!1),this._sender.send(t||Bf,i,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){Wn(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(Mt,"CONNECTING",{enumerable:!0,value:qi.indexOf("CONNECTING")});Object.defineProperty(Mt.prototype,"CONNECTING",{enumerable:!0,value:qi.indexOf("CONNECTING")});Object.defineProperty(Mt,"OPEN",{enumerable:!0,value:qi.indexOf("OPEN")});Object.defineProperty(Mt.prototype,"OPEN",{enumerable:!0,value:qi.indexOf("OPEN")});Object.defineProperty(Mt,"CLOSING",{enumerable:!0,value:qi.indexOf("CLOSING")});Object.defineProperty(Mt.prototype,"CLOSING",{enumerable:!0,value:qi.indexOf("CLOSING")});Object.defineProperty(Mt,"CLOSED",{enumerable:!0,value:qi.indexOf("CLOSED")});Object.defineProperty(Mt.prototype,"CLOSED",{enumerable:!0,value:qi.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(Mt.prototype,e,{enumerable:!0})});["open","error","close","message"].forEach(e=>{Object.defineProperty(Mt.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[Ly])return t[TH];return null},set(t){for(let n of this.listeners(e))if(n[Ly]){this.removeListener(e,n);break}typeof t=="function"&&this.addEventListener(e,t,{[Ly]:!0})}})});Mt.prototype.addEventListener=kH;Mt.prototype.removeEventListener=CH;PE.exports=Mt;function kE(e,t,n,r){let i={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:Gy[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=i.autoPong,!Gy.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${Gy.join(", ")})`);let o;if(t instanceof jy)o=t;else try{o=new jy(t)}catch{throw new SyntaxError(`Invalid URL: ${t}`)}o.protocol==="http:"?o.protocol="ws:":o.protocol==="https:"&&(o.protocol="wss:"),e._url=o.href;let a=o.protocol==="wss:",s=o.protocol==="ws+unix:",d;if(o.protocol!=="ws:"&&!a&&!s?d=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:s&&!o.pathname?d="The URL's pathname is empty":o.hash&&(d="The URL contains a fragment identifier"),d){let h=new SyntaxError(d);if(e._redirects===0)throw h;zf(e,h);return}let l=a?443:80,u=yH(16).toString("base64"),c=a?mH.request:hH.request,p=new Set,m;if(i.createConnection=i.createConnection||(a?MH:IH),i.defaultPort=i.defaultPort||l,i.port=o.port||l,i.host=o.hostname.startsWith("[")?o.hostname.slice(1,-1):o.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},i.path=o.pathname+o.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(m=new yo(i.perMessageDeflate!==!0?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=EH({[yo.extensionName]:m.offer()})),n.length){for(let h of n){if(typeof h!="string"||!PH.test(h)||p.has(h))throw new SyntaxError("An invalid or duplicated subprotocol was specified");p.add(h)}i.headers["Sec-WebSocket-Protocol"]=n.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(o.username||o.password)&&(i.auth=`${o.username}:${o.password}`),s){let h=i.path.split(":");i.socketPath=h[0],i.path=h[1]}let y;if(i.followRedirects){if(e._redirects===0){e._originalIpc=s,e._originalSecure=a,e._originalHostOrSocketPath=s?i.socketPath:o.host;let h=r&&r.headers;if(r={...r,headers:{}},h)for(let[b,g]of Object.entries(h))r.headers[b.toLowerCase()]=g}else if(e.listenerCount("redirect")===0){let h=s?e._originalIpc?i.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:o.host===e._originalHostOrSocketPath;(!h||e._originalSecure&&!a)&&(delete i.headers.authorization,delete i.headers.cookie,h||delete i.headers.host,i.auth=void 0)}i.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),y=e._req=c(i),e._redirects&&e.emit("redirect",e.url,y)}else y=e._req=c(i);i.timeout&&y.on("timeout",()=>{Wn(e,y,"Opening handshake has timed out")}),y.on("error",h=>{y===null||y[AE]||(y=e._req=null,zf(e,h))}),y.on("response",h=>{let b=h.headers.location,g=h.statusCode;if(b&&i.followRedirects&&g>=300&&g<400){if(++e._redirects>i.maxRedirects){Wn(e,y,"Maximum redirects exceeded");return}y.abort();let S;try{S=new jy(b,t)}catch{let T=new SyntaxError(`Invalid URL: ${b}`);zf(e,T);return}kE(e,S,n,r)}else e.emit("unexpected-response",y,h)||Wn(e,y,`Unexpected server response: ${h.statusCode}`)}),y.on("upgrade",(h,b,g)=>{if(e.emit("upgrade",h),e.readyState!==Mt.CONNECTING)return;y=e._req=null;let S=h.headers.upgrade;if(S===void 0||S.toLowerCase()!=="websocket"){Wn(e,b,"Invalid Upgrade header");return}let v=gH("sha1").update(u+wH).digest("base64");if(h.headers["sec-websocket-accept"]!==v){Wn(e,b,"Invalid Sec-WebSocket-Accept header");return}let T=h.headers["sec-websocket-protocol"],C;if(T!==void 0?p.size?p.has(T)||(C="Server sent an invalid subprotocol"):C="Server sent a subprotocol but none was requested":p.size&&(C="Server sent no subprotocol"),C){Wn(e,b,C);return}T&&(e._protocol=T);let O=h.headers["sec-websocket-extensions"];if(O!==void 0){if(!m){Wn(e,b,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let _;try{_=OH(O)}catch{Wn(e,b,"Invalid Sec-WebSocket-Extensions header");return}let w=Object.keys(_);if(w.length!==1||w[0]!==yo.extensionName){Wn(e,b,"Server indicated an extension that was not requested");return}try{m.accept(_[yo.extensionName])}catch{Wn(e,b,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[yo.extensionName]=m}e.setSocket(b,g,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(y,e):y.end()}function zf(e,t){e._readyState=Mt.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}function IH(e){return e.path=e.socketPath,wE.connect(e)}function MH(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=wE.isIP(e.host)?"":e.host),_H.connect(e)}function Wn(e,t,n){e._readyState=Mt.CLOSING;let r=new Error(n);Error.captureStackTrace(r,Wn),t.setHeader?(t[AE]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(zf,e,r)):(t.destroy(r),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function Fy(e,t,n){if(t){let r=SH(t)?t.size:xH(t).length;e._socket?e._sender._bufferedBytes+=r:e._bufferedAmount+=r}if(n){let r=new Error(`WebSocket is not open: readyState ${e.readyState} (${qi[e.readyState]})`);process.nextTick(n,r)}}function DH(e,t){let n=this[dn];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,n._socket[dn]!==void 0&&(n._socket.removeListener("data",Kf),process.nextTick(CE,n._socket),e===1005?n.close():n.close(e,t))}function $H(){let e=this[dn];e.isPaused||e._socket.resume()}function NH(e){let t=this[dn];t._socket[dn]!==void 0&&(t._socket.removeListener("data",Kf),process.nextTick(CE,t._socket),t.close(e[AH])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}function SE(){this[dn].emitClose()}function jH(e,t){this[dn].emit("message",e,t)}function LH(e){let t=this[dn];t._autoPong&&t.pong(e,!this._isServer,TE),t.emit("ping",e)}function GH(e){this[dn].emit("pong",e)}function CE(e){e.resume()}function FH(e){let t=this[dn];t.readyState!==Mt.CLOSED&&(t.readyState===Mt.OPEN&&(t._readyState=Mt.CLOSING,EE(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}function EE(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),RH)}function OE(){let e=this[dn];this.removeListener("close",OE),this.removeListener("data",Kf),this.removeListener("end",xE),e._readyState=Mt.CLOSING;let t;!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&(t=e._socket.read())!==null&&e._receiver.write(t),e._receiver.end(),this[dn]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",SE),e._receiver.on("finish",SE))}function Kf(e){this[dn]._receiver.write(e)||this.pause()}function xE(){let e=this[dn];e._readyState=Mt.CLOSING,e._receiver.end(),this.end()}function RE(){let e=this[dn];this.removeListener("error",RE),this.on("error",TE),e&&(e._readyState=Mt.CLOSING,this.destroy())}});var $E=St((uVe,DE)=>{"use strict";var lVe=Hf(),{Duplex:qH}=ut("stream");function IE(e){e.emit("close")}function UH(){!this.destroyed&&this._writableState.finished&&this.destroy()}function ME(e){this.removeListener("error",ME),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e)}function BH(e,t){let n=!0,r=new qH({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",function(o,a){let s=!a&&r._readableState.objectMode?o.toString():o;r.push(s)||e.pause()}),e.once("error",function(o){r.destroyed||(n=!1,r.destroy(o))}),e.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(i,o){if(e.readyState===e.CLOSED){o(i),process.nextTick(IE,r);return}let a=!1;e.once("error",function(d){a=!0,o(d)}),e.once("close",function(){a||o(i),process.nextTick(IE,r)}),n&&e.terminate()},r._final=function(i){if(e.readyState===e.CONNECTING){e.once("open",function(){r._final(i)});return}e._socket!==null&&(e._socket._writableState.finished?(i(),r._readableState.endEmitted&&r.destroy()):(e._socket.once("finish",function(){i()}),e.close()))},r._read=function(){e.isPaused&&e.resume()},r._write=function(i,o,a){if(e.readyState===e.CONNECTING){e.once("open",function(){r._write(i,o,a)});return}e.send(i,a)},r.on("end",UH),r.on("error",ME),r}DE.exports=BH});var jE=St((cVe,NE)=>{"use strict";var{tokenChars:zH}=gs();function KH(e){let t=new Set,n=-1,r=-1,i=0;for(i;i<e.length;i++){let a=e.charCodeAt(i);if(r===-1&&zH[a]===1)n===-1&&(n=i);else if(i!==0&&(a===32||a===9))r===-1&&n!==-1&&(r=i);else if(a===44){if(n===-1)throw new SyntaxError(`Unexpected character at index ${i}`);r===-1&&(r=i);let s=e.slice(n,r);if(t.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);t.add(s),n=r=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(n===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let o=e.slice(n,i);if(t.has(o))throw new SyntaxError(`The "${o}" subprotocol is duplicated`);return t.add(o),t}NE.exports={parse:KH}});var zE=St((pVe,BE)=>{"use strict";var HH=ut("events"),Jf=ut("http"),{Duplex:fVe}=ut("stream"),{createHash:JH}=ut("crypto"),LE=Ny(),la=Ol(),WH=jE(),VH=Hf(),{GUID:ZH,kWebSocket:YH}=Li(),QH=/^[+/0-9A-Za-z]{22}==$/,GE=0,FE=1,UE=2,qy=class extends HH{constructor(t,n){if(super(),t={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:VH,...t},t.port==null&&!t.server&&!t.noServer||t.port!=null&&(t.server||t.noServer)||t.server&&t.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(t.port!=null?(this._server=Jf.createServer((r,i)=>{let o=Jf.STATUS_CODES[426];i.writeHead(426,{"Content-Length":o.length,"Content-Type":"text/plain"}),i.end(o)}),this._server.listen(t.port,t.host,t.backlog,n)):t.server&&(this._server=t.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=XH(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,o,a)=>{this.handleUpgrade(i,o,a,r)}})}t.perMessageDeflate===!0&&(t.perMessageDeflate={}),t.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=t,this._state=GE}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(t){if(this._state===UE){t&&this.once("close",()=>{t(new Error("The server is not running"))}),process.nextTick(Il,this);return}if(t&&this.once("close",t),this._state!==FE)if(this._state=FE,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(Il,this):process.nextTick(Il,this);else{let n=this._server;this._removeListeners(),this._removeListeners=this._server=null,n.close(()=>{Il(this)})}}shouldHandle(t){if(this.options.path){let n=t.url.indexOf("?");if((n!==-1?t.url.slice(0,n):t.url)!==this.options.path)return!1}return!0}handleUpgrade(t,n,r,i){n.on("error",qE);let o=t.headers["sec-websocket-key"],a=t.headers.upgrade,s=+t.headers["sec-websocket-version"];if(t.method!=="GET"){ua(this,t,n,405,"Invalid HTTP method");return}if(a===void 0||a.toLowerCase()!=="websocket"){ua(this,t,n,400,"Invalid Upgrade header");return}if(o===void 0||!QH.test(o)){ua(this,t,n,400,"Missing or invalid Sec-WebSocket-Key header");return}if(s!==13&&s!==8){ua(this,t,n,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(t)){Ml(n,400);return}let d=t.headers["sec-websocket-protocol"],l=new Set;if(d!==void 0)try{l=WH.parse(d)}catch{ua(this,t,n,400,"Invalid Sec-WebSocket-Protocol header");return}let u=t.headers["sec-websocket-extensions"],c={};if(this.options.perMessageDeflate&&u!==void 0){let p=new la(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let m=LE.parse(u);m[la.extensionName]&&(p.accept(m[la.extensionName]),c[la.extensionName]=p)}catch{ua(this,t,n,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let p={origin:t.headers[`${s===8?"sec-websocket-origin":"origin"}`],secure:!!(t.socket.authorized||t.socket.encrypted),req:t};if(this.options.verifyClient.length===2){this.options.verifyClient(p,(m,y,h,b)=>{if(!m)return Ml(n,y||401,h,b);this.completeUpgrade(c,o,l,t,n,r,i)});return}if(!this.options.verifyClient(p))return Ml(n,401)}this.completeUpgrade(c,o,l,t,n,r,i)}completeUpgrade(t,n,r,i,o,a,s){if(!o.readable||!o.writable)return o.destroy();if(o[YH])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>GE)return Ml(o,503);let l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${JH("sha1").update(n+ZH).digest("base64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(r.size){let c=this.options.handleProtocols?this.options.handleProtocols(r,i):r.values().next().value;c&&(l.push(`Sec-WebSocket-Protocol: ${c}`),u._protocol=c)}if(t[la.extensionName]){let c=t[la.extensionName].params,p=LE.format({[la.extensionName]:[c]});l.push(`Sec-WebSocket-Extensions: ${p}`),u._extensions=t}this.emit("headers",l,i),o.write(l.concat(`\r
|
|
3
|
+
var z2=Object.create;var ty=Object.defineProperty;var K2=Object.getOwnPropertyDescriptor;var H2=Object.getOwnPropertyNames;var J2=Object.getPrototypeOf,W2=Object.prototype.hasOwnProperty;var ut=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var N=(e,t)=>()=>(e&&(t=e(e=0)),t);var St=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),V2=(e,t)=>{for(var n in t)ty(e,n,{get:t[n],enumerable:!0})},Z2=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of H2(t))!W2.call(e,i)&&i!==n&&ty(e,i,{get:()=>t[i],enumerable:!(r=K2(t,i))||r.enumerable});return e};var ei=(e,t,n)=>(n=e!=null?z2(J2(e)):{},Z2(t||!e||!e.__esModule?ty(n,"default",{value:e,enumerable:!0}):n,e));var ny=N(()=>{});function _t(e){return e===void 0?{BS_PRIVATE_NESTED_SOME_NONE:0}:e!==null&&e.BS_PRIVATE_NESTED_SOME_NONE!==void 0?{BS_PRIVATE_NESTED_SOME_NONE:e.BS_PRIVATE_NESTED_SOME_NONE+1|0}:e}function as(e){if(e!=null)return _t(e)}function Fe(e){if(e===null||e.BS_PRIVATE_NESTED_SOME_NONE===void 0)return e;let t=e.BS_PRIVATE_NESTED_SOME_NONE;if(t!==0)return{BS_PRIVATE_NESTED_SOME_NONE:t-1|0}}var qe=N(()=>{});function $i(e,t){if(e!==void 0)return t(Fe(e))}function Wt(e,t,n){return e!==void 0?n(Fe(e)):t}function Ze(e,t){if(e!==void 0)return _t(t(Fe(e)))}function ct(e,t){if(e!==void 0)return t(Fe(e))}function $e(e,t){return e!==void 0?Fe(e):t}var we=N(()=>{ny();qe()});var bf=N(()=>{});function Et(e,t,n){return e.reduce(n,t)}var rt=N(()=>{bf();qe()});function ti(e){if(e.RE_EXN_ID==="JsExn")return _t(e._1)}var vf,Q2,ni,v4e,S4e,Ni=N(()=>{qe();vf=(e=>t=>t&&typeof t[e]=="string"?t[e]:void 0),Q2=vf("stack"),ni=vf("message"),v4e=vf("name"),S4e=vf("fileName")});var ss=N(()=>{});var UC=St((w4e,qC)=>{var fo=ut("constants"),X2=process.cwd,Sf=null,eK=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return Sf||(Sf=X2.call(process)),Sf};try{process.cwd()}catch{}typeof process.chdir=="function"&&(iy=process.chdir,process.chdir=function(e){Sf=null,iy.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,iy));var iy;qC.exports=tK;function tK(e){fo.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||n(e),e.chown=o(e.chown),e.fchown=o(e.fchown),e.lchown=o(e.lchown),e.chmod=r(e.chmod),e.fchmod=r(e.fchmod),e.lchmod=r(e.lchmod),e.chownSync=a(e.chownSync),e.fchownSync=a(e.fchownSync),e.lchownSync=a(e.lchownSync),e.chmodSync=i(e.chmodSync),e.fchmodSync=i(e.fchmodSync),e.lchmodSync=i(e.lchmodSync),e.stat=s(e.stat),e.fstat=s(e.fstat),e.lstat=s(e.lstat),e.statSync=d(e.statSync),e.fstatSync=d(e.fstatSync),e.lstatSync=d(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(u,c,p){p&&process.nextTick(p)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(u,c,p,m){m&&process.nextTick(m)},e.lchownSync=function(){}),eK==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:(function(u){function c(p,m,y){var h=Date.now(),b=0;u(p,m,function g(S){if(S&&(S.code==="EACCES"||S.code==="EPERM"||S.code==="EBUSY")&&Date.now()-h<6e4){setTimeout(function(){e.stat(m,function(v,T){v&&v.code==="ENOENT"?u(p,m,g):y(S)})},b),b<100&&(b+=10);return}y&&y(S)})}return Object.setPrototypeOf&&Object.setPrototypeOf(c,u),c})(e.rename)),e.read=typeof e.read!="function"?e.read:(function(u){function c(p,m,y,h,b,g){var S;if(g&&typeof g=="function"){var v=0;S=function(T,C,O){if(T&&T.code==="EAGAIN"&&v<10)return v++,u.call(e,p,m,y,h,b,S);g.apply(this,arguments)}}return u.call(e,p,m,y,h,b,S)}return Object.setPrototypeOf&&Object.setPrototypeOf(c,u),c})(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:(function(u){return function(c,p,m,y,h){for(var b=0;;)try{return u.call(e,c,p,m,y,h)}catch(g){if(g.code==="EAGAIN"&&b<10){b++;continue}throw g}}})(e.readSync);function t(u){u.lchmod=function(c,p,m){u.open(c,fo.O_WRONLY|fo.O_SYMLINK,p,function(y,h){if(y){m&&m(y);return}u.fchmod(h,p,function(b){u.close(h,function(g){m&&m(b||g)})})})},u.lchmodSync=function(c,p){var m=u.openSync(c,fo.O_WRONLY|fo.O_SYMLINK,p),y=!0,h;try{h=u.fchmodSync(m,p),y=!1}finally{if(y)try{u.closeSync(m)}catch{}else u.closeSync(m)}return h}}function n(u){fo.hasOwnProperty("O_SYMLINK")&&u.futimes?(u.lutimes=function(c,p,m,y){u.open(c,fo.O_SYMLINK,function(h,b){if(h){y&&y(h);return}u.futimes(b,p,m,function(g){u.close(b,function(S){y&&y(g||S)})})})},u.lutimesSync=function(c,p,m){var y=u.openSync(c,fo.O_SYMLINK),h,b=!0;try{h=u.futimesSync(y,p,m),b=!1}finally{if(b)try{u.closeSync(y)}catch{}else u.closeSync(y)}return h}):u.futimes&&(u.lutimes=function(c,p,m,y){y&&process.nextTick(y)},u.lutimesSync=function(){})}function r(u){return u&&function(c,p,m){return u.call(e,c,p,function(y){l(y)&&(y=null),m&&m.apply(this,arguments)})}}function i(u){return u&&function(c,p){try{return u.call(e,c,p)}catch(m){if(!l(m))throw m}}}function o(u){return u&&function(c,p,m,y){return u.call(e,c,p,m,function(h){l(h)&&(h=null),y&&y.apply(this,arguments)})}}function a(u){return u&&function(c,p,m){try{return u.call(e,c,p,m)}catch(y){if(!l(y))throw y}}}function s(u){return u&&function(c,p,m){typeof p=="function"&&(m=p,p=null);function y(h,b){b&&(b.uid<0&&(b.uid+=4294967296),b.gid<0&&(b.gid+=4294967296)),m&&m.apply(this,arguments)}return p?u.call(e,c,p,y):u.call(e,c,y)}}function d(u){return u&&function(c,p){var m=p?u.call(e,c,p):u.call(e,c);return m&&(m.uid<0&&(m.uid+=4294967296),m.gid<0&&(m.gid+=4294967296)),m}}function l(u){if(!u||u.code==="ENOSYS")return!0;var c=!process.getuid||process.getuid()!==0;return!!(c&&(u.code==="EINVAL"||u.code==="EPERM"))}}});var KC=St((T4e,zC)=>{var BC=ut("stream").Stream;zC.exports=nK;function nK(e){return{ReadStream:t,WriteStream:n};function t(r,i){if(!(this instanceof t))return new t(r,i);BC.call(this);var o=this;this.path=r,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,i=i||{};for(var a=Object.keys(i),s=0,d=a.length;s<d;s++){var l=a[s];this[l]=i[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){o._read()});return}e.open(this.path,this.flags,this.mode,function(u,c){if(u){o.emit("error",u),o.readable=!1;return}o.fd=c,o.emit("open",c),o._read()})}function n(r,i){if(!(this instanceof n))return new n(r,i);BC.call(this),this.path=r,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};for(var o=Object.keys(i),a=0,s=o.length;a<s;a++){var d=o[a];this[d]=i[d]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var JC=St((A4e,HC)=>{"use strict";HC.exports=iK;var rK=Object.getPrototypeOf||function(e){return e.__proto__};function iK(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:rK(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}});var dy=St((k4e,sy)=>{var Nt=ut("fs"),oK=UC(),aK=KC(),sK=JC(),wf=ut("util"),pn,Af;typeof Symbol=="function"&&typeof Symbol.for=="function"?(pn=Symbol.for("graceful-fs.queue"),Af=Symbol.for("graceful-fs.previous")):(pn="___graceful-fs.queue",Af="___graceful-fs.previous");function dK(){}function ZC(e,t){Object.defineProperty(e,pn,{get:function(){return t}})}var ta=dK;wf.debuglog?ta=wf.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(ta=function(){var e=wf.format.apply(wf,arguments);e="GFS4: "+e.split(/\n/).join(`
|
|
4
|
+
GFS4: `),console.error(e)});Nt[pn]||(WC=global[pn]||[],ZC(Nt,WC),Nt.close=(function(e){function t(n,r){return e.call(Nt,n,function(i){i||VC(),typeof r=="function"&&r.apply(this,arguments)})}return Object.defineProperty(t,Af,{value:e}),t})(Nt.close),Nt.closeSync=(function(e){function t(n){e.apply(Nt,arguments),VC()}return Object.defineProperty(t,Af,{value:e}),t})(Nt.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ta(Nt[pn]),ut("assert").equal(Nt[pn].length,0)}));var WC;global[pn]||ZC(global,Nt[pn]);sy.exports=oy(sK(Nt));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!Nt.__patched&&(sy.exports=oy(Nt),Nt.__patched=!0);function oy(e){oK(e),e.gracefulify=oy,e.createReadStream=C,e.createWriteStream=O;var t=e.readFile;e.readFile=n;function n(k,E,x){return typeof E=="function"&&(x=E,E=null),I(k,E,x);function I(P,M,q,ee){return t(P,M,function(Q){Q&&(Q.code==="EMFILE"||Q.code==="ENFILE")?ds([I,[P,M,q],Q,ee||Date.now(),Date.now()]):typeof q=="function"&&q.apply(this,arguments)})}}var r=e.writeFile;e.writeFile=i;function i(k,E,x,I){return typeof x=="function"&&(I=x,x=null),P(k,E,x,I);function P(M,q,ee,Q,te){return r(M,q,ee,function(Y){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?ds([P,[M,q,ee,Q],Y,te||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=a);function a(k,E,x,I){return typeof x=="function"&&(I=x,x=null),P(k,E,x,I);function P(M,q,ee,Q,te){return o(M,q,ee,function(Y){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?ds([P,[M,q,ee,Q],Y,te||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}var s=e.copyFile;s&&(e.copyFile=d);function d(k,E,x,I){return typeof x=="function"&&(I=x,x=0),P(k,E,x,I);function P(M,q,ee,Q,te){return s(M,q,ee,function(Y){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?ds([P,[M,q,ee,Q],Y,te||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}var l=e.readdir;e.readdir=c;var u=/^v[0-5]\./;function c(k,E,x){typeof E=="function"&&(x=E,E=null);var I=u.test(process.version)?function(q,ee,Q,te){return l(q,P(q,ee,Q,te))}:function(q,ee,Q,te){return l(q,ee,P(q,ee,Q,te))};return I(k,E,x);function P(M,q,ee,Q){return function(te,Y){te&&(te.code==="EMFILE"||te.code==="ENFILE")?ds([I,[M,q,ee],te,Q||Date.now(),Date.now()]):(Y&&Y.sort&&Y.sort(),typeof ee=="function"&&ee.call(this,te,Y))}}}if(process.version.substr(0,4)==="v0.8"){var p=aK(e);g=p.ReadStream,v=p.WriteStream}var m=e.ReadStream;m&&(g.prototype=Object.create(m.prototype),g.prototype.open=S);var y=e.WriteStream;y&&(v.prototype=Object.create(y.prototype),v.prototype.open=T),Object.defineProperty(e,"ReadStream",{get:function(){return g},set:function(k){g=k},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return v},set:function(k){v=k},enumerable:!0,configurable:!0});var h=g;Object.defineProperty(e,"FileReadStream",{get:function(){return h},set:function(k){h=k},enumerable:!0,configurable:!0});var b=v;Object.defineProperty(e,"FileWriteStream",{get:function(){return b},set:function(k){b=k},enumerable:!0,configurable:!0});function g(k,E){return this instanceof g?(m.apply(this,arguments),this):g.apply(Object.create(g.prototype),arguments)}function S(){var k=this;w(k.path,k.flags,k.mode,function(E,x){E?(k.autoClose&&k.destroy(),k.emit("error",E)):(k.fd=x,k.emit("open",x),k.read())})}function v(k,E){return this instanceof v?(y.apply(this,arguments),this):v.apply(Object.create(v.prototype),arguments)}function T(){var k=this;w(k.path,k.flags,k.mode,function(E,x){E?(k.destroy(),k.emit("error",E)):(k.fd=x,k.emit("open",x))})}function C(k,E){return new e.ReadStream(k,E)}function O(k,E){return new e.WriteStream(k,E)}var _=e.open;e.open=w;function w(k,E,x,I){return typeof x=="function"&&(I=x,x=null),P(k,E,x,I);function P(M,q,ee,Q,te){return _(M,q,ee,function(Y,L){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?ds([P,[M,q,ee,Q],Y,te||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}return e}function ds(e){ta("ENQUEUE",e[0].name,e[1]),Nt[pn].push(e),ay()}var Tf;function VC(){for(var e=Date.now(),t=0;t<Nt[pn].length;++t)Nt[pn][t].length>2&&(Nt[pn][t][3]=e,Nt[pn][t][4]=e);ay()}function ay(){if(clearTimeout(Tf),Tf=void 0,Nt[pn].length!==0){var e=Nt[pn].shift(),t=e[0],n=e[1],r=e[2],i=e[3],o=e[4];if(i===void 0)ta("RETRY",t.name,n),t.apply(null,n);else if(Date.now()-i>=6e4){ta("TIMEOUT",t.name,n);var a=n.pop();typeof a=="function"&&a.call(null,r)}else{var s=Date.now()-o,d=Math.max(o-i,1),l=Math.min(d*1.2,100);s>=l?(ta("RETRY",t.name,n),t.apply(null,n.concat([i]))):Nt[pn].push(e)}Tf===void 0&&(Tf=setTimeout(ay,0))}}});var QC=St((C4e,YC)=>{function sr(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}YC.exports=sr;sr.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};sr.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};sr.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1;var r=this,i=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n);return this._options.unref&&i.unref(),!0};sr.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};sr.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};sr.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};sr.prototype.start=sr.prototype.try;sr.prototype.errors=function(){return this._errors};sr.prototype.attempts=function(){return this._attempts};sr.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],o=i.message,a=(e[o]||0)+1;e[o]=a,a>=n&&(t=i,n=a)}return t}});var XC=St(na=>{var lK=QC();na.operation=function(e){var t=na.timeouts(e);return new lK(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};na.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(o,a){return o-a}),r};na.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*t.minTimeout*Math.pow(t.factor,e));return r=Math.min(r,t.maxTimeout),r};na.wrap=function(e,t,n){if(t instanceof Array&&(n=t,t=null),!n){n=[];for(var r in e)typeof e[r]=="function"&&n.push(r)}for(var i=0;i<n.length;i++){var o=n[i],a=e[o];e[o]=function(d){var l=na.operation(t),u=Array.prototype.slice.call(arguments,1),c=u.pop();u.push(function(p){l.retry(p)||(p&&(arguments[0]=l.mainError()),c.apply(this,arguments))}),l.attempt(function(){d.apply(e,u)})}.bind(e,a),e[o].options=t}}});var t0=St((O4e,e0)=>{e0.exports=XC()});var n0=St((x4e,kf)=>{kf.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&kf.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&kf.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var s0=St((R4e,cs)=>{var It=global.process,ra=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};ra(It)?(r0=ut("assert"),ls=n0(),i0=/^win/i.test(It.platform),wl=ut("events"),typeof wl!="function"&&(wl=wl.EventEmitter),It.__signal_exit_emitter__?sn=It.__signal_exit_emitter__:(sn=It.__signal_exit_emitter__=new wl,sn.count=0,sn.emitted={}),sn.infinite||(sn.setMaxListeners(1/0),sn.infinite=!0),cs.exports=function(e,t){if(!ra(global.process))return function(){};r0.equal(typeof e,"function","a callback must be provided for exit handler"),us===!1&&ly();var n="exit";t&&t.alwaysLast&&(n="afterexit");var r=function(){sn.removeListener(n,e),sn.listeners("exit").length===0&&sn.listeners("afterexit").length===0&&Cf()};return sn.on(n,e),r},Cf=function(){!us||!ra(global.process)||(us=!1,ls.forEach(function(t){try{It.removeListener(t,Ef[t])}catch{}}),It.emit=Of,It.reallyExit=uy,sn.count-=1)},cs.exports.unload=Cf,ia=function(t,n,r){sn.emitted[t]||(sn.emitted[t]=!0,sn.emit(t,n,r))},Ef={},ls.forEach(function(e){Ef[e]=function(){if(ra(global.process)){var n=It.listeners(e);n.length===sn.count&&(Cf(),ia("exit",null,e),ia("afterexit",null,e),i0&&e==="SIGHUP"&&(e="SIGINT"),It.kill(It.pid,e))}}}),cs.exports.signals=function(){return ls},us=!1,ly=function(){us||!ra(global.process)||(us=!0,sn.count+=1,ls=ls.filter(function(t){try{return It.on(t,Ef[t]),!0}catch{return!1}}),It.emit=a0,It.reallyExit=o0)},cs.exports.load=ly,uy=It.reallyExit,o0=function(t){ra(global.process)&&(It.exitCode=t||0,ia("exit",It.exitCode,null),ia("afterexit",It.exitCode,null),uy.call(It,It.exitCode))},Of=It.emit,a0=function(t,n){if(t==="exit"&&ra(global.process)){n!==void 0&&(It.exitCode=n);var r=Of.apply(this,arguments);return ia("exit",It.exitCode,null),ia("afterexit",It.exitCode,null),r}else return Of.apply(this,arguments)}):cs.exports=function(){return function(){}};var r0,ls,i0,wl,sn,Cf,ia,Ef,us,ly,uy,o0,Of,a0});var f0=St((P4e,Tl)=>{"use strict";var uK=ut("path"),py=dy(),cK=t0(),fK=s0(),ji={};function fs(e,t){return t.lockfilePath||`${e}.lock`}function my(e,t,n){if(!t.realpath)return n(null,uK.resolve(e));t.fs.realpath(e,n)}function cy(e,t,n){t.fs.mkdir(fs(e,t),r=>{if(!r)return n();if(r.code!=="EEXIST")return n(r);if(t.stale<=0)return n(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));t.fs.stat(fs(e,t),(i,o)=>{if(i)return i.code==="ENOENT"?cy(e,{...t,stale:0},n):n(i);if(!l0(o,t))return n(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));u0(e,t,a=>{if(a)return n(a);cy(e,{...t,stale:0},n)})})})}function l0(e,t){return e.mtime.getTime()<Date.now()-t.stale}function u0(e,t,n){t.fs.rmdir(fs(e,t),r=>{if(r&&r.code!=="ENOENT")return n(r);n()})}function fy(e,t){let n=ji[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{let r=Date.now()/1e3;n.updateTimeout=null,t.fs.utimes(fs(e,t),r,r,i=>{if(!n.released){if(n.lastUpdate<=Date.now()-t.stale&&n.lastUpdate>Date.now()-t.stale*2){let o=Object.assign(new Error(n.updateError||"Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"});return d0(e,n,o)}if(i)return i.code==="ENOENT"?d0(e,n,Object.assign(i,{code:"ECOMPROMISED"})):(n.updateError=i,n.updateDelay=1e3,fy(e,t));n.lastUpdate=Date.now(),n.updateError=null,n.updateDelay=null,fy(e,t)}})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function d0(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),ji[e]===t&&delete ji[e],t.options.onCompromised(n)}function pK(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:py,onCompromised:r=>{throw r},...t},t.retries=t.retries||0,t.retries=typeof t.retries=="number"?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),my(e,t,(r,i)=>{if(r)return n(r);let o=cK.operation(t.retries);o.attempt(()=>{cy(i,t,a=>{if(o.retry(a))return;if(a)return n(o.mainError());let s=ji[i]={options:t,lastUpdate:Date.now()};fy(i,t),n(null,d=>{if(s.released)return d&&d(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));c0(i,{...t,realpath:!1},d)})})})})}function c0(e,t,n){t={fs:py,realpath:!0,...t},my(e,t,(r,i)=>{if(r)return n(r);let o=ji[i];if(!o)return n(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));o.updateTimeout&&clearTimeout(o.updateTimeout),o.released=!0,delete ji[i],u0(i,t,n)})}function mK(e,t,n){t={stale:1e4,realpath:!0,fs:py,...t},t.stale=Math.max(t.stale||0,2e3),my(e,t,(r,i)=>{if(r)return n(r);t.fs.stat(fs(i,t),(o,a)=>o?o.code==="ENOENT"?n(null,!1):n(o):n(null,!l0(a,t)))})}function hK(){return ji}fK(()=>{for(let e in ji){let t=ji[e].options;try{t.fs.rmdirSync(fs(e,t))}catch{}}});Tl.exports.lock=pK;Tl.exports.unlock=c0;Tl.exports.check=mK;Tl.exports.getLocks=hK});var m0=St((I4e,p0)=>{"use strict";var _K=dy();function yK(e){let t=["mkdir","realpath","stat","rmdir","utimes"],n={...e};return t.forEach(r=>{n[r]=(...i)=>{let o=i.pop(),a;try{a=e[`${r}Sync`](...i)}catch(s){return o(s)}o(null,a)}}),n}function gK(e){return(...t)=>new Promise((n,r)=>{t.push((i,o)=>{i?r(i):n(o)}),e(...t)})}function bK(e){return(...t)=>{let n,r;if(t.push((i,o)=>{n=i,r=o}),e(...t),n)throw n;return r}}function vK(e){if(e={...e},e.fs=yK(e.fs||_K),typeof e.retries=="number"&&e.retries>0||e.retries&&typeof e.retries.retries=="number"&&e.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return e}p0.exports={toPromise:gK,toSync:bK,toSyncOptions:vK}});var _0=St((M4e,po)=>{"use strict";var ps=f0(),{toPromise:xf,toSync:Rf,toSyncOptions:hy}=m0();async function h0(e,t){let n=await xf(ps.lock)(e,t);return xf(n)}function SK(e,t){let n=Rf(ps.lock)(e,hy(t));return Rf(n)}function wK(e,t){return xf(ps.unlock)(e,t)}function TK(e,t){return Rf(ps.unlock)(e,hy(t))}function AK(e,t){return xf(ps.check)(e,t)}function kK(e,t){return Rf(ps.check)(e,hy(t))}po.exports=h0;po.exports.lock=h0;po.exports.unlock=wK;po.exports.lockSync=SK;po.exports.unlockSync=TK;po.exports.check=AK;po.exports.checkSync=kK});var y0=N(()=>{});var ms=N(()=>{});var mo=N(()=>{});var Ue=N(()=>{y0();ms();mo()});function EK(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function Je(e){return EK(e)?e:{RE_EXN_ID:"JsExn",_1:e}}function yy(e){let t=_y[e];if(t!==void 0){let n=t+1|0;return _y[e]=n,e+("/"+n)}return _y[e]=1,e}var _y,it=N(()=>{_y={}});import*as b0 from"node:child_process";function jt(e){let t=ti(e);if(t===void 0)return{code:void 0,message:"unknown error"};let n=Fe(t);return{code:as(n.code),message:$e(ni(n),"unknown error")}}function v0(e,t,n,r){try{return{TAG:"Ok",_0:b0.execFileSync(e,t,{encoding:"utf8",timeout:n,maxBuffer:r})}}catch(i){let o=Je(i);return{TAG:"Error",_0:jt(o)}}}var OK,Ke=N(()=>{Ni();we();ss();OK=ei(_0(),1);Ue();qe();it()});function w0(e){let t=v0(e,["--version"],1e4,1048576);if(t.TAG!=="Ok")return;let n=S0.exec(t._0);if(n!=null)return ct(n.slice(1)[0],r=>r)}function T0(e,t){return e!==void 0&&t!==void 0?e===t?{TAG:"Match",version:e}:{TAG:"Mismatch",pathVersion:e,pinnedVersion:t}:{TAG:"Unverified",pathVersion:e,pinnedVersion:t}}var S0,A0=N(()=>{rt();Ke();we();Ue();S0=new RegExp("(\\d+\\.\\d+\\.\\d+)")});function RK(e,t){let n=T0(e,t);switch(n.TAG){case"Match":return{TAG:"Ok",_0:n.version};case"Mismatch":return{TAG:"Error",_0:"hosted_codex_runtime_refused reason=mismatch observed="+n.pathVersion+" expected="+n.pinnedVersion};case"Unverified":return{TAG:"Error",_0:"hosted_codex_runtime_refused reason=unverified observed=unverified expected="+t}}}function k0(e,t){return RK(w0(e),t)}var C0=N(()=>{we();A0()});var E0,gy=N(()=>{C0();E0=k0});var x0,O0=N(()=>{x0={name:"@linzumi/cli",version:"1.0.312",description:"Linzumi CLI \u2014 point a Codex agent at the real code on your laptop, with your team watching and steering from shared threads.",type:"module",bin:{linzumi:"bin/linzumi.js"},files:["README.md","bin","dist","scripts","!scripts/build-*-oracle.mjs","native/darwin/linzumi-terminal-pty-helper","native/darwin/terminal-pty-helper.manifest.json"],scripts:{build:"rescript build ../linzumi-cli-rescript && node scripts/build.mjs","bump-version":"node scripts/bump-cli-version.mjs",test:"pnpm --dir ../linzumi-cli-rescript test && npm run test:operational",typecheck:"rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.source.json",prepack:"rescript build -q ../linzumi-cli-rescript && node scripts/build.mjs","pack:dry-run":"npm pack --dry-run","test:operational":"vitest run --config vitest.config.mjs","vendor:codex-app-server-protocol":"tsx scripts/vendor-codex-app-server-protocol.ts","test:startup":"npm run build && node --test --test-concurrency=1 ../linzumi-cli-rescript/src/parity/CommanderStartupRefusalConformance.res.mjs","typecheck:all":"rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.json","typecheck:watch":"rescript build ../linzumi-cli-rescript && tsgo --noEmit -w -p tsconfig.source.json","test:agent-source":"LINZUMI_CI_QUARANTINE=0 pnpm exec vitest run --config vitest.config.mjs test/channelSession.test.ts test/kandanQueue.test.ts -t '(retains three busy accepted source snapshots without fusing or interrupting|keeps different accepted agent sources distinct through interrupt pickup)' && pnpm --dir ../linzumi-cli-rescript build && pnpm --dir ../linzumi-cli-rescript exec node --import tsx src/parity/AgentOpenaiModelProviderConformance.res.mjs && pnpm --dir ../linzumi-cli-rescript exec node --import tsx src/parity/WorkerMintCredentialConformance.res.mjs","codex:history-table":"node scripts/codex_history_table.mjs","vendor:codex-app-server-protocol:check":"tsx scripts/vendor-codex-app-server-protocol.ts --check"},keywords:["linzumi","kandan","codex","local-runner"],license:"MIT",publishConfig:{access:"public"},dependencies:{"@anthropic-ai/claude-agent-sdk":"0.3.283","@inquirer/prompts":"^7.8.6","@modelcontextprotocol/sdk":"^1.29.0","@openai/codex":"0.159.2",blessed:"^0.1.81","ghostty-web":"0.4.0","proper-lockfile":"3.2.0","stream-json":"1.9.1",undici:"^6.25.0",ws:"^8.18.0",zod:"^3.25.76"},engines:{node:">=20"},readmeFilename:"README.md",devDependencies:{"@types/blessed":"^0.1.27","@types/node":"^22.18.6","@types/proper-lockfile":"4.1.4","@typescript/native-preview":"7.0.0-dev.20260703.1",esbuild:"^0.27.2","fast-check":"^3.23.2",rescript:"12.3.0",tsx:"^4.21.0",typescript:"^5.9.3",vitest:"^1.6.1"}}});var by,If=N(()=>{"use strict";O0();by=x0.dependencies["@openai/codex"]});async function R0(e,t,n){let r;try{e(),r=!0}catch{r=!1}let i;try{await t(),i=!0}catch{i=!1}return r&&i?{TAG:"Ok",_0:void 0}:(n("hosted_auth_quota_cleanup_failed reason=owned_process_not_confirmed_reaped"),{TAG:"Error",_0:"cleanup_failed"})}function P0(e,t){let n=e.quotaWindow,r=e.credits;if(n===void 0&&r===void 0)return{status:"unavailable",reason:"empty_response"};let i=n!==void 0?[n.usedPercent,n.windowMinutes,n.resetsAtMs]:[void 0,void 0,void 0];return{status:"captured",quotaWindow:{usedPercent:i[0],windowMinutes:i[1],resetsAtMs:i[2],capturedAtMs:t,credits:r}}}var I0=N(()=>{});var M0,D0,$0=N(()=>{I0();M0=R0,D0=P0});function yt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function vy(e){let t=[["threadId",e.threadId],["turnId",e.turnId],["itemId",e.itemId],["processId",e.processId],["requestId",e.requestId]].filter(n=>n[1]!==void 0);return Object.fromEntries(t)}var Yt=N(()=>{"use strict"});var Mf=N(()=>{"use strict";Yt()});function G0(e){let t=ri(e.rateLimits)??ri(e.rate_limits)??ri(e.limits)??e,n=[t,...Object.values(t).flatMap(b=>{let g=ri(b);return g===void 0?[]:[g]})],r=n.reduce((b,g)=>{let S=ot(g.usedPercent)??ot(g.used_percent);return S===void 0?b:b===void 0?S:Math.max(b,S)},void 0),o=n.some(b=>ot(b.remaining)===0||ot(b.remainingRequests)===0||ot(b.remaining_requests)===0||ot(b.remainingTokens)===0||ot(b.remaining_tokens)===0||ot(b.retryAfterSeconds)!==void 0||ot(b.retry_after_seconds)!==void 0)?"rejected":r!==void 0&&r>=80?"allowed_warning":"allowed",a=ri(t.primary),s=ot(a?.usedPercent),d=ot(a?.windowDurationMins),l=ot(a?.resetsAt),u=ri(t.credits),c=L0(u?.hasCredits),p=L0(u?.unlimited),m=u?.balance,y=c===void 0||p===void 0?void 0:{hasCredits:c,unlimited:p,balance:typeof m=="string"?m:null},h=s===void 0&&d===void 0&&l===void 0?void 0:{...s===void 0?{}:{usedPercent:s},...d===void 0?{}:{windowMinutes:d},...l===void 0?{}:{resetsAtMs:l*1e3}};return{summary:$K(e)??"seen (no details)",status:o,utilizationPercent:r,...h===void 0?{}:{quotaWindow:h},...y===void 0?{}:{credits:y}}}function $K(e){let t=ri(e.rateLimits)??ri(e.rate_limits)??ri(e.limits)??e,n=N0(t,void 0),r=Object.entries(t).flatMap(([o,a])=>{let s=ri(a);return s===void 0?[]:[N0(s,o)]}),i=[n,...r].filter(o=>o!==void 0);return i.length===0?void 0:i.join(" | ")}function N0(e,t){let n=Er(e.limitName)??Er(e.limit_name)??Er(e.name)??Er(e.type)??t,r=Er(e.planType)??Er(e.plan_type)??Er(e.plan),i=ot(e.remaining)??ot(e.remainingRequests)??ot(e.remaining_requests)??ot(e.remainingTokens)??ot(e.remaining_tokens),o=ot(e.limit)??ot(e.requestLimit)??ot(e.request_limit)??ot(e.limitRequests)??ot(e.limit_requests)??ot(e.tokenLimit)??ot(e.token_limit)??ot(e.limitTokens)??ot(e.limit_tokens),a=Er(e.resetAt)??Er(e.reset_at)??Er(e.resetsAt)??Er(e.resets_at)??j0(e.resetsAt)??j0(e.resets_at)??Df(e.resetAfterSeconds)??Df(e.reset_after_seconds)??Df(e.retryAfterSeconds)??Df(e.retry_after_seconds),s=ot(e.usedPercent)??ot(e.used_percent),d=ot(e.windowDurationMins)??ot(e.window_duration_mins),l=[n,r].filter(m=>m!==void 0).join(" "),u=l===""?void 0:l,p=[i===void 0?void 0:o===void 0?`${i} remaining`:`${i}/${o} remaining`,s===void 0?void 0:`${s}% used`,d===void 0?void 0:`${d}m window`,a===void 0?void 0:`reset ${a}`].filter(m=>m!==void 0);return p.length===0?u===void 0?void 0:`${u} seen (no details)`:u===void 0?p.join(" "):`${u} ${p.join(" ")}`}function Df(e){let t=ot(e);return t===void 0?void 0:`${t}s`}function j0(e){let t=ot(e);return t===void 0?void 0:new Date(t*1e3).toISOString()}function ri(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function Er(e){return typeof e=="string"&&e.trim()!==""?e:void 0}function L0(e){return typeof e=="boolean"?e:void 0}function ot(e){if(typeof e=="number"&&Number.isSafeInteger(e))return e;if(typeof e!="string")return;let t=Number.parseInt(e,10);return Number.isSafeInteger(t)&&t.toString()===e.trim()?t:void 0}var F0=N(()=>{"use strict";Mf();Yt()});var Li=St((Z4e,B0)=>{"use strict";var q0=["nodebuffer","arraybuffer","fragments"],U0=typeof Blob<"u";U0&&q0.push("blob");B0.exports={BINARY_TYPES:q0,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:U0,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Cl=St((Y4e,$f)=>{"use strict";var{EMPTY_BUFFER:NK}=Li(),Sy=Buffer[Symbol.species];function jK(e,t){if(e.length===0)return NK;if(e.length===1)return e[0];let n=Buffer.allocUnsafe(t),r=0;for(let i=0;i<e.length;i++){let o=e[i];n.set(o,r),r+=o.length}return r<t?new Sy(n.buffer,n.byteOffset,r):n}function z0(e,t,n,r,i){for(let o=0;o<i;o++)n[r+o]=e[o]^t[o&3]}function K0(e,t){for(let n=0;n<e.length;n++)e[n]^=t[n&3]}function LK(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function wy(e){if(wy.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new Sy(e):ArrayBuffer.isView(e)?t=new Sy(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),wy.readOnly=!1),t}$f.exports={concat:jK,mask:z0,toArrayBuffer:LK,toBuffer:wy,unmask:K0};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=ut("bufferutil");$f.exports.mask=function(t,n,r,i,o){o<48?z0(t,n,r,i,o):e.mask(t,n,r,i,o)},$f.exports.unmask=function(t,n){t.length<32?K0(t,n):e.unmask(t,n)}}catch{}});var W0=St((Q4e,J0)=>{"use strict";var H0=Symbol("kDone"),Ty=Symbol("kRun"),Ay=class{constructor(t){this[H0]=()=>{this.pending--,this[Ty]()},this.concurrency=t||1/0,this.jobs=[],this.pending=0}add(t){this.jobs.push(t),this[Ty]()}[Ty](){if(this.pending!==this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[H0])}}};J0.exports=Ay});var Ol=St((X4e,Q0)=>{"use strict";var El=ut("zlib"),V0=Cl(),GK=W0(),{kStatusCode:Z0}=Li(),FK=Buffer[Symbol.species],qK=Buffer.from([0,0,255,255]),jf=Symbol("permessage-deflate"),Gi=Symbol("total-length"),_s=Symbol("callback"),_o=Symbol("buffers"),ys=Symbol("error"),Nf,ky=class{constructor(t,n,r){if(this._maxPayload=r|0,this._options=t||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!n,this._deflate=null,this._inflate=null,this.params=null,!Nf){let i=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Nf=new GK(i)}}static get extensionName(){return"permessage-deflate"}offer(){let t={};return this._options.serverNoContextTakeover&&(t.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(t.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(t.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?t.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(t.client_max_window_bits=!0),t}accept(t){return t=this.normalizeParams(t),this.params=this._isServer?this.acceptAsServer(t):this.acceptAsClient(t),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let t=this._deflate[_s];this._deflate.close(),this._deflate=null,t&&t(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(t){let n=this._options,r=t.find(i=>!(n.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(n.serverMaxWindowBits===!1||typeof n.serverMaxWindowBits=="number"&&n.serverMaxWindowBits>i.server_max_window_bits)||typeof n.clientMaxWindowBits=="number"&&!i.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return n.serverNoContextTakeover&&(r.server_no_context_takeover=!0),n.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof n.serverMaxWindowBits=="number"&&(r.server_max_window_bits=n.serverMaxWindowBits),typeof n.clientMaxWindowBits=="number"?r.client_max_window_bits=n.clientMaxWindowBits:(r.client_max_window_bits===!0||n.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(t){let n=t[0];if(this._options.clientNoContextTakeover===!1&&n.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!n.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(n.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&n.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return n}normalizeParams(t){return t.forEach(n=>{Object.keys(n).forEach(r=>{let i=n[r];if(i.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(i=i[0],r==="client_max_window_bits"){if(i!==!0){let o=+i;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=o}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else if(r==="server_max_window_bits"){let o=+i;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=o}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else throw new Error(`Unknown parameter "${r}"`);n[r]=i})}),t}decompress(t,n,r){Nf.add(i=>{this._decompress(t,n,(o,a)=>{i(),r(o,a)})})}compress(t,n,r){Nf.add(i=>{this._compress(t,n,(o,a)=>{i(),r(o,a)})})}_decompress(t,n,r){let i=this._isServer?"client":"server";if(!this._inflate){let o=`${i}_max_window_bits`,a=typeof this.params[o]!="number"?El.Z_DEFAULT_WINDOWBITS:this.params[o];this._inflate=El.createInflateRaw({...this._options.zlibInflateOptions,windowBits:a}),this._inflate[jf]=this,this._inflate[Gi]=0,this._inflate[_o]=[],this._inflate.on("error",BK),this._inflate.on("data",Y0)}this._inflate[_s]=r,this._inflate.write(t),n&&this._inflate.write(qK),this._inflate.flush(()=>{let o=this._inflate[ys];if(o){this._inflate.close(),this._inflate=null,r(o);return}let a=V0.concat(this._inflate[_o],this._inflate[Gi]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Gi]=0,this._inflate[_o]=[],n&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),r(null,a)})}_compress(t,n,r){let i=this._isServer?"server":"client";if(!this._deflate){let o=`${i}_max_window_bits`,a=typeof this.params[o]!="number"?El.Z_DEFAULT_WINDOWBITS:this.params[o];this._deflate=El.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:a}),this._deflate[Gi]=0,this._deflate[_o]=[],this._deflate.on("data",UK)}this._deflate[_s]=r,this._deflate.write(t),this._deflate.flush(El.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let o=V0.concat(this._deflate[_o],this._deflate[Gi]);n&&(o=new FK(o.buffer,o.byteOffset,o.length-4)),this._deflate[_s]=null,this._deflate[Gi]=0,this._deflate[_o]=[],n&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),r(null,o)})}};Q0.exports=ky;function UK(e){this[_o].push(e),this[Gi]+=e.length}function Y0(e){if(this[Gi]+=e.length,this[jf]._maxPayload<1||this[Gi]<=this[jf]._maxPayload){this[_o].push(e);return}this[ys]=new RangeError("Max payload size exceeded"),this[ys].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[ys][Z0]=1009,this.removeListener("data",Y0),this.reset()}function BK(e){if(this[jf]._inflate=null,this[ys]){this[_s](this[ys]);return}e[Z0]=1007,this[_s](e)}});var gs=St((eVe,Lf)=>{"use strict";var{isUtf8:X0}=ut("buffer"),{hasBlob:zK}=Li(),KK=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function HK(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function Cy(e){let t=e.length,n=0;for(;n<t;)if((e[n]&128)===0)n++;else if((e[n]&224)===192){if(n+1===t||(e[n+1]&192)!==128||(e[n]&254)===192)return!1;n+=2}else if((e[n]&240)===224){if(n+2>=t||(e[n+1]&192)!==128||(e[n+2]&192)!==128||e[n]===224&&(e[n+1]&224)===128||e[n]===237&&(e[n+1]&224)===160)return!1;n+=3}else if((e[n]&248)===240){if(n+3>=t||(e[n+1]&192)!==128||(e[n+2]&192)!==128||(e[n+3]&192)!==128||e[n]===240&&(e[n+1]&240)===128||e[n]===244&&e[n+1]>143||e[n]>244)return!1;n+=4}else return!1;return!0}function JK(e){return zK&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]==="Blob"||e[Symbol.toStringTag]==="File")}Lf.exports={isBlob:JK,isValidStatusCode:HK,isValidUTF8:Cy,tokenChars:KK};if(X0)Lf.exports.isValidUTF8=function(e){return e.length<24?Cy(e):X0(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=ut("utf-8-validate");Lf.exports.isValidUTF8=function(t){return t.length<32?Cy(t):e(t)}}catch{}});var Py=St((tVe,aE)=>{"use strict";var{Writable:WK}=ut("stream"),eE=Ol(),{BINARY_TYPES:VK,EMPTY_BUFFER:tE,kStatusCode:ZK,kWebSocket:YK}=Li(),{concat:Ey,toArrayBuffer:QK,unmask:XK}=Cl(),{isValidStatusCode:eH,isValidUTF8:nE}=gs(),Gf=Buffer[Symbol.species],dr=0,rE=1,iE=2,oE=3,Oy=4,xy=5,Ff=6,Ry=class extends WK{constructor(t={}){super(),this._allowSynchronousEvents=t.allowSynchronousEvents!==void 0?t.allowSynchronousEvents:!0,this._binaryType=t.binaryType||VK[0],this._extensions=t.extensions||{},this._isServer=!!t.isServer,this._maxPayload=t.maxPayload|0,this._skipUTF8Validation=!!t.skipUTF8Validation,this[YK]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=dr}_write(t,n,r){if(this._opcode===8&&this._state==dr)return r();this._bufferedBytes+=t.length,this._buffers.push(t),this.startLoop(r)}consume(t){if(this._bufferedBytes-=t,t===this._buffers[0].length)return this._buffers.shift();if(t<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new Gf(r.buffer,r.byteOffset+t,r.length-t),new Gf(r.buffer,r.byteOffset,t)}let n=Buffer.allocUnsafe(t);do{let r=this._buffers[0],i=n.length-t;t>=r.length?n.set(this._buffers.shift(),i):(n.set(new Uint8Array(r.buffer,r.byteOffset,t),i),this._buffers[0]=new Gf(r.buffer,r.byteOffset+t,r.length-t)),t-=r.length}while(t>0);return n}startLoop(t){this._loop=!0;do switch(this._state){case dr:this.getInfo(t);break;case rE:this.getPayloadLength16(t);break;case iE:this.getPayloadLength64(t);break;case oE:this.getMask();break;case Oy:this.getData(t);break;case xy:case Ff:this._loop=!1;return}while(this._loop);this._errored||t()}getInfo(t){if(this._bufferedBytes<2){this._loop=!1;return}let n=this.consume(2);if((n[0]&48)!==0){let i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");t(i);return}let r=(n[0]&64)===64;if(r&&!this._extensions[eE.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(i);return}if(this._fin=(n[0]&128)===128,this._opcode=n[0]&15,this._payloadLength=n[1]&127,this._opcode===0){if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");t(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(i);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");t(i);return}if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");t(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(n[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");t(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");t(i);return}this._payloadLength===126?this._state=rE:this._payloadLength===127?this._state=iE:this.haveLength(t)}getPayloadLength16(t){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(t)}getPayloadLength64(t){if(this._bufferedBytes<8){this._loop=!1;return}let n=this.consume(8),r=n.readUInt32BE(0);if(r>Math.pow(2,21)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");t(i);return}this._payloadLength=r*Math.pow(2,32)+n.readUInt32BE(4),this.haveLength(t)}haveLength(t){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let n=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(n);return}this._masked?this._state=oE:this._state=Oy}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Oy}getData(t){let n=tE;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}n=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&XK(n,this._mask)}if(this._opcode>7){this.controlMessage(n,t);return}if(this._compressed){this._state=xy,this.decompress(n,t);return}n.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(n)),this.dataMessage(t)}decompress(t,n){this._extensions[eE.extensionName].decompress(t,this._fin,(i,o)=>{if(i)return n(i);if(o.length){if(this._messageLength+=o.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let a=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");n(a);return}this._fragments.push(o)}this.dataMessage(n),this._state===dr&&this.startLoop(n)})}dataMessage(t){if(!this._fin){this._state=dr;return}let n=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=Ey(r,n):this._binaryType==="arraybuffer"?i=QK(Ey(r,n)):this._binaryType==="blob"?i=new Blob(r):i=r,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=dr):(this._state=Ff,setImmediate(()=>{this.emit("message",i,!0),this._state=dr,this.startLoop(t)}))}else{let i=Ey(r,n);if(!this._skipUTF8Validation&&!nE(i)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(o);return}this._state===xy||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=dr):(this._state=Ff,setImmediate(()=>{this.emit("message",i,!1),this._state=dr,this.startLoop(t)}))}}controlMessage(t,n){if(this._opcode===8){if(t.length===0)this._loop=!1,this.emit("conclude",1005,tE),this.end();else{let r=t.readUInt16BE(0);if(!eH(r)){let o=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");n(o);return}let i=new Gf(t.buffer,t.byteOffset+2,t.length-2);if(!this._skipUTF8Validation&&!nE(i)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(o);return}this._loop=!1,this.emit("conclude",r,i),this.end()}this._state=dr;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",t),this._state=dr):(this._state=Ff,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",t),this._state=dr,this.startLoop(n)}))}createError(t,n,r,i,o){this._loop=!1,this._errored=!0;let a=new t(r?`Invalid WebSocket frame: ${n}`:n);return Error.captureStackTrace(a,this.createError),a.code=o,a[ZK]=i,a}};aE.exports=Ry});var Dy=St((rVe,lE)=>{"use strict";var{Duplex:nVe}=ut("stream"),{randomFillSync:tH}=ut("crypto"),sE=Ol(),{EMPTY_BUFFER:nH,kWebSocket:rH,NOOP:iH}=Li(),{isBlob:bs,isValidStatusCode:oH}=gs(),{mask:dE,toBuffer:aa}=Cl(),lr=Symbol("kByteLength"),aH=Buffer.alloc(4),qf=8*1024,sa,vs=qf,Or=0,sH=1,dH=2,Iy=class e{constructor(t,n,r){this._extensions=n||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=t,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Or,this.onerror=iH,this[rH]=void 0}static frame(t,n){let r,i=!1,o=2,a=!1;n.mask&&(r=n.maskBuffer||aH,n.generateMask?n.generateMask(r):(vs===qf&&(sa===void 0&&(sa=Buffer.alloc(qf)),tH(sa,0,qf),vs=0),r[0]=sa[vs++],r[1]=sa[vs++],r[2]=sa[vs++],r[3]=sa[vs++]),a=(r[0]|r[1]|r[2]|r[3])===0,o=6);let s;typeof t=="string"?(!n.mask||a)&&n[lr]!==void 0?s=n[lr]:(t=Buffer.from(t),s=t.length):(s=t.length,i=n.mask&&n.readOnly&&!a);let d=s;s>=65536?(o+=8,d=127):s>125&&(o+=2,d=126);let l=Buffer.allocUnsafe(i?s+o:o);return l[0]=n.fin?n.opcode|128:n.opcode,n.rsv1&&(l[0]|=64),l[1]=d,d===126?l.writeUInt16BE(s,2):d===127&&(l[2]=l[3]=0,l.writeUIntBE(s,4,6)),n.mask?(l[1]|=128,l[o-4]=r[0],l[o-3]=r[1],l[o-2]=r[2],l[o-1]=r[3],a?[l,t]:i?(dE(t,r,l,o,s),[l]):(dE(t,r,t,0,s),[l,t])):[l,t]}close(t,n,r,i){let o;if(t===void 0)o=nH;else{if(typeof t!="number"||!oH(t))throw new TypeError("First argument must be a valid error code number");if(n===void 0||!n.length)o=Buffer.allocUnsafe(2),o.writeUInt16BE(t,0);else{let s=Buffer.byteLength(n);if(s>123)throw new RangeError("The message must not be greater than 123 bytes");o=Buffer.allocUnsafe(2+s),o.writeUInt16BE(t,0),typeof n=="string"?o.write(n,2):o.set(n,2)}}let a={[lr]:o.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Or?this.enqueue([this.dispatch,o,!1,a,i]):this.sendFrame(e.frame(o,a),i)}ping(t,n,r){let i,o;if(typeof t=="string"?(i=Buffer.byteLength(t),o=!1):bs(t)?(i=t.size,o=!1):(t=aa(t),i=t.length,o=aa.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[lr]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:o,rsv1:!1};bs(t)?this._state!==Or?this.enqueue([this.getBlobData,t,!1,a,r]):this.getBlobData(t,!1,a,r):this._state!==Or?this.enqueue([this.dispatch,t,!1,a,r]):this.sendFrame(e.frame(t,a),r)}pong(t,n,r){let i,o;if(typeof t=="string"?(i=Buffer.byteLength(t),o=!1):bs(t)?(i=t.size,o=!1):(t=aa(t),i=t.length,o=aa.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[lr]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:o,rsv1:!1};bs(t)?this._state!==Or?this.enqueue([this.getBlobData,t,!1,a,r]):this.getBlobData(t,!1,a,r):this._state!==Or?this.enqueue([this.dispatch,t,!1,a,r]):this.sendFrame(e.frame(t,a),r)}send(t,n,r){let i=this._extensions[sE.extensionName],o=n.binary?2:1,a=n.compress,s,d;typeof t=="string"?(s=Buffer.byteLength(t),d=!1):bs(t)?(s=t.size,d=!1):(t=aa(t),s=t.length,d=aa.readOnly),this._firstFragment?(this._firstFragment=!1,a&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(a=s>=i._threshold),this._compress=a):(a=!1,o=0),n.fin&&(this._firstFragment=!0);let l={[lr]:s,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:o,readOnly:d,rsv1:a};bs(t)?this._state!==Or?this.enqueue([this.getBlobData,t,this._compress,l,r]):this.getBlobData(t,this._compress,l,r):this._state!==Or?this.enqueue([this.dispatch,t,this._compress,l,r]):this.dispatch(t,this._compress,l,r)}getBlobData(t,n,r,i){this._bufferedBytes+=r[lr],this._state=dH,t.arrayBuffer().then(o=>{if(this._socket.destroyed){let s=new Error("The socket was closed while the blob was being read");process.nextTick(My,this,s,i);return}this._bufferedBytes-=r[lr];let a=aa(o);n?this.dispatch(a,n,r,i):(this._state=Or,this.sendFrame(e.frame(a,r),i),this.dequeue())}).catch(o=>{process.nextTick(lH,this,o,i)})}dispatch(t,n,r,i){if(!n){this.sendFrame(e.frame(t,r),i);return}let o=this._extensions[sE.extensionName];this._bufferedBytes+=r[lr],this._state=sH,o.compress(t,r.fin,(a,s)=>{if(this._socket.destroyed){let d=new Error("The socket was closed while data was being compressed");My(this,d,i);return}this._bufferedBytes-=r[lr],this._state=Or,r.readOnly=!1,this.sendFrame(e.frame(s,r),i),this.dequeue()})}dequeue(){for(;this._state===Or&&this._queue.length;){let t=this._queue.shift();this._bufferedBytes-=t[3][lr],Reflect.apply(t[0],this,t.slice(1))}}enqueue(t){this._bufferedBytes+=t[3][lr],this._queue.push(t)}sendFrame(t,n){t.length===2?(this._socket.cork(),this._socket.write(t[0]),this._socket.write(t[1],n),this._socket.uncork()):this._socket.write(t[0],n)}};lE.exports=Iy;function My(e,t,n){typeof n=="function"&&n(t);for(let r=0;r<e._queue.length;r++){let i=e._queue[r],o=i[i.length-1];typeof o=="function"&&o(t)}}function lH(e,t,n){My(e,t,n),e.onerror(t)}});var gE=St((iVe,yE)=>{"use strict";var{kForOnEventAttribute:xl,kListener:$y}=Li(),uE=Symbol("kCode"),cE=Symbol("kData"),fE=Symbol("kError"),pE=Symbol("kMessage"),mE=Symbol("kReason"),Ss=Symbol("kTarget"),hE=Symbol("kType"),_E=Symbol("kWasClean"),Fi=class{constructor(t){this[Ss]=null,this[hE]=t}get target(){return this[Ss]}get type(){return this[hE]}};Object.defineProperty(Fi.prototype,"target",{enumerable:!0});Object.defineProperty(Fi.prototype,"type",{enumerable:!0});var da=class extends Fi{constructor(t,n={}){super(t),this[uE]=n.code===void 0?0:n.code,this[mE]=n.reason===void 0?"":n.reason,this[_E]=n.wasClean===void 0?!1:n.wasClean}get code(){return this[uE]}get reason(){return this[mE]}get wasClean(){return this[_E]}};Object.defineProperty(da.prototype,"code",{enumerable:!0});Object.defineProperty(da.prototype,"reason",{enumerable:!0});Object.defineProperty(da.prototype,"wasClean",{enumerable:!0});var ws=class extends Fi{constructor(t,n={}){super(t),this[fE]=n.error===void 0?null:n.error,this[pE]=n.message===void 0?"":n.message}get error(){return this[fE]}get message(){return this[pE]}};Object.defineProperty(ws.prototype,"error",{enumerable:!0});Object.defineProperty(ws.prototype,"message",{enumerable:!0});var Rl=class extends Fi{constructor(t,n={}){super(t),this[cE]=n.data===void 0?null:n.data}get data(){return this[cE]}};Object.defineProperty(Rl.prototype,"data",{enumerable:!0});var uH={addEventListener(e,t,n={}){for(let i of this.listeners(e))if(!n[xl]&&i[$y]===t&&!i[xl])return;let r;if(e==="message")r=function(o,a){let s=new Rl("message",{data:a?o:o.toString()});s[Ss]=this,Uf(t,this,s)};else if(e==="close")r=function(o,a){let s=new da("close",{code:o,reason:a.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});s[Ss]=this,Uf(t,this,s)};else if(e==="error")r=function(o){let a=new ws("error",{error:o,message:o.message});a[Ss]=this,Uf(t,this,a)};else if(e==="open")r=function(){let o=new Fi("open");o[Ss]=this,Uf(t,this,o)};else return;r[xl]=!!n[xl],r[$y]=t,n.once?this.once(e,r):this.on(e,r)},removeEventListener(e,t){for(let n of this.listeners(e))if(n[$y]===t&&!n[xl]){this.removeListener(e,n);break}}};yE.exports={CloseEvent:da,ErrorEvent:ws,Event:Fi,EventTarget:uH,MessageEvent:Rl};function Uf(e,t,n){typeof e=="object"&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}});var Ny=St((oVe,bE)=>{"use strict";var{tokenChars:Pl}=gs();function ii(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}function cH(e){let t=Object.create(null),n=Object.create(null),r=!1,i=!1,o=!1,a,s,d=-1,l=-1,u=-1,c=0;for(;c<e.length;c++)if(l=e.charCodeAt(c),a===void 0)if(u===-1&&Pl[l]===1)d===-1&&(d=c);else if(c!==0&&(l===32||l===9))u===-1&&d!==-1&&(u=c);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${c}`);u===-1&&(u=c);let m=e.slice(d,u);l===44?(ii(t,m,n),n=Object.create(null)):a=m,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);else if(s===void 0)if(u===-1&&Pl[l]===1)d===-1&&(d=c);else if(l===32||l===9)u===-1&&d!==-1&&(u=c);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${c}`);u===-1&&(u=c),ii(n,e.slice(d,u),!0),l===44&&(ii(t,a,n),n=Object.create(null),a=void 0),d=u=-1}else if(l===61&&d!==-1&&u===-1)s=e.slice(d,c),d=u=-1;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(i){if(Pl[l]!==1)throw new SyntaxError(`Unexpected character at index ${c}`);d===-1?d=c:r||(r=!0),i=!1}else if(o)if(Pl[l]===1)d===-1&&(d=c);else if(l===34&&d!==-1)o=!1,u=c;else if(l===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(l===34&&e.charCodeAt(c-1)===61)o=!0;else if(u===-1&&Pl[l]===1)d===-1&&(d=c);else if(d!==-1&&(l===32||l===9))u===-1&&(u=c);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${c}`);u===-1&&(u=c);let m=e.slice(d,u);r&&(m=m.replace(/\\/g,""),r=!1),ii(n,s,m),l===44&&(ii(t,a,n),n=Object.create(null),a=void 0),s=void 0,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);if(d===-1||o||l===32||l===9)throw new SyntaxError("Unexpected end of input");u===-1&&(u=c);let p=e.slice(d,u);return a===void 0?ii(t,p,n):(s===void 0?ii(n,p,!0):r?ii(n,s,p.replace(/\\/g,"")):ii(n,s,p),ii(t,a,n)),t}function fH(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(r=>[t].concat(Object.keys(r).map(i=>{let o=r[i];return Array.isArray(o)||(o=[o]),o.map(a=>a===!0?i:`${i}=${a}`).join("; ")})).join("; ")).join(", ")}).join(", ")}bE.exports={format:fH,parse:cH}});var Hf=St((dVe,PE)=>{"use strict";var pH=ut("events"),mH=ut("https"),hH=ut("http"),wE=ut("net"),_H=ut("tls"),{randomBytes:yH,createHash:gH}=ut("crypto"),{Duplex:aVe,Readable:sVe}=ut("stream"),{URL:jy}=ut("url"),yo=Ol(),bH=Py(),vH=Dy(),{isBlob:SH}=gs(),{BINARY_TYPES:vE,EMPTY_BUFFER:Bf,GUID:wH,kForOnEventAttribute:Ly,kListener:TH,kStatusCode:AH,kWebSocket:dn,NOOP:TE}=Li(),{EventTarget:{addEventListener:kH,removeEventListener:CH}}=gE(),{format:EH,parse:OH}=Ny(),{toBuffer:xH}=Cl(),RH=30*1e3,AE=Symbol("kAborted"),Gy=[8,13],qi=["CONNECTING","OPEN","CLOSING","CLOSED"],PH=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,Mt=class e extends pH{constructor(t,n,r){super(),this._binaryType=vE[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Bf,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,n===void 0?n=[]:Array.isArray(n)||(typeof n=="object"&&n!==null?(r=n,n=[]):n=[n]),kE(this,t,n,r)):(this._autoPong=r.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(t){vE.includes(t)&&(this._binaryType=t,this._receiver&&(this._receiver._binaryType=t))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(t,n,r){let i=new bH({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),o=new vH(t,this._extensions,r.generateMask);this._receiver=i,this._sender=o,this._socket=t,i[dn]=this,o[dn]=this,t[dn]=this,i.on("conclude",DH),i.on("drain",$H),i.on("error",NH),i.on("message",jH),i.on("ping",LH),i.on("pong",GH),o.onerror=FH,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on("close",OE),t.on("data",Kf),t.on("end",xE),t.on("error",RE),this._readyState=e.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[yo.extensionName]&&this._extensions[yo.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){Wn(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,n,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),EE(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,n,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(r=t,t=n=void 0):typeof n=="function"&&(r=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Fy(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(t||Bf,n,r)}pong(t,n,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(r=t,t=n=void 0):typeof n=="function"&&(r=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Fy(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.pong(t||Bf,n,r)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof n=="function"&&(r=n,n={}),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Fy(this,t,r);return}let i={binary:typeof t!="string",mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[yo.extensionName]||(i.compress=!1),this._sender.send(t||Bf,i,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){Wn(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(Mt,"CONNECTING",{enumerable:!0,value:qi.indexOf("CONNECTING")});Object.defineProperty(Mt.prototype,"CONNECTING",{enumerable:!0,value:qi.indexOf("CONNECTING")});Object.defineProperty(Mt,"OPEN",{enumerable:!0,value:qi.indexOf("OPEN")});Object.defineProperty(Mt.prototype,"OPEN",{enumerable:!0,value:qi.indexOf("OPEN")});Object.defineProperty(Mt,"CLOSING",{enumerable:!0,value:qi.indexOf("CLOSING")});Object.defineProperty(Mt.prototype,"CLOSING",{enumerable:!0,value:qi.indexOf("CLOSING")});Object.defineProperty(Mt,"CLOSED",{enumerable:!0,value:qi.indexOf("CLOSED")});Object.defineProperty(Mt.prototype,"CLOSED",{enumerable:!0,value:qi.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(Mt.prototype,e,{enumerable:!0})});["open","error","close","message"].forEach(e=>{Object.defineProperty(Mt.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[Ly])return t[TH];return null},set(t){for(let n of this.listeners(e))if(n[Ly]){this.removeListener(e,n);break}typeof t=="function"&&this.addEventListener(e,t,{[Ly]:!0})}})});Mt.prototype.addEventListener=kH;Mt.prototype.removeEventListener=CH;PE.exports=Mt;function kE(e,t,n,r){let i={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:Gy[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=i.autoPong,!Gy.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${Gy.join(", ")})`);let o;if(t instanceof jy)o=t;else try{o=new jy(t)}catch{throw new SyntaxError(`Invalid URL: ${t}`)}o.protocol==="http:"?o.protocol="ws:":o.protocol==="https:"&&(o.protocol="wss:"),e._url=o.href;let a=o.protocol==="wss:",s=o.protocol==="ws+unix:",d;if(o.protocol!=="ws:"&&!a&&!s?d=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:s&&!o.pathname?d="The URL's pathname is empty":o.hash&&(d="The URL contains a fragment identifier"),d){let h=new SyntaxError(d);if(e._redirects===0)throw h;zf(e,h);return}let l=a?443:80,u=yH(16).toString("base64"),c=a?mH.request:hH.request,p=new Set,m;if(i.createConnection=i.createConnection||(a?MH:IH),i.defaultPort=i.defaultPort||l,i.port=o.port||l,i.host=o.hostname.startsWith("[")?o.hostname.slice(1,-1):o.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},i.path=o.pathname+o.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(m=new yo(i.perMessageDeflate!==!0?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=EH({[yo.extensionName]:m.offer()})),n.length){for(let h of n){if(typeof h!="string"||!PH.test(h)||p.has(h))throw new SyntaxError("An invalid or duplicated subprotocol was specified");p.add(h)}i.headers["Sec-WebSocket-Protocol"]=n.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(o.username||o.password)&&(i.auth=`${o.username}:${o.password}`),s){let h=i.path.split(":");i.socketPath=h[0],i.path=h[1]}let y;if(i.followRedirects){if(e._redirects===0){e._originalIpc=s,e._originalSecure=a,e._originalHostOrSocketPath=s?i.socketPath:o.host;let h=r&&r.headers;if(r={...r,headers:{}},h)for(let[b,g]of Object.entries(h))r.headers[b.toLowerCase()]=g}else if(e.listenerCount("redirect")===0){let h=s?e._originalIpc?i.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:o.host===e._originalHostOrSocketPath;(!h||e._originalSecure&&!a)&&(delete i.headers.authorization,delete i.headers.cookie,h||delete i.headers.host,i.auth=void 0)}i.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),y=e._req=c(i),e._redirects&&e.emit("redirect",e.url,y)}else y=e._req=c(i);i.timeout&&y.on("timeout",()=>{Wn(e,y,"Opening handshake has timed out")}),y.on("error",h=>{y===null||y[AE]||(y=e._req=null,zf(e,h))}),y.on("response",h=>{let b=h.headers.location,g=h.statusCode;if(b&&i.followRedirects&&g>=300&&g<400){if(++e._redirects>i.maxRedirects){Wn(e,y,"Maximum redirects exceeded");return}y.abort();let S;try{S=new jy(b,t)}catch{let T=new SyntaxError(`Invalid URL: ${b}`);zf(e,T);return}kE(e,S,n,r)}else e.emit("unexpected-response",y,h)||Wn(e,y,`Unexpected server response: ${h.statusCode}`)}),y.on("upgrade",(h,b,g)=>{if(e.emit("upgrade",h),e.readyState!==Mt.CONNECTING)return;y=e._req=null;let S=h.headers.upgrade;if(S===void 0||S.toLowerCase()!=="websocket"){Wn(e,b,"Invalid Upgrade header");return}let v=gH("sha1").update(u+wH).digest("base64");if(h.headers["sec-websocket-accept"]!==v){Wn(e,b,"Invalid Sec-WebSocket-Accept header");return}let T=h.headers["sec-websocket-protocol"],C;if(T!==void 0?p.size?p.has(T)||(C="Server sent an invalid subprotocol"):C="Server sent a subprotocol but none was requested":p.size&&(C="Server sent no subprotocol"),C){Wn(e,b,C);return}T&&(e._protocol=T);let O=h.headers["sec-websocket-extensions"];if(O!==void 0){if(!m){Wn(e,b,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let _;try{_=OH(O)}catch{Wn(e,b,"Invalid Sec-WebSocket-Extensions header");return}let w=Object.keys(_);if(w.length!==1||w[0]!==yo.extensionName){Wn(e,b,"Server indicated an extension that was not requested");return}try{m.accept(_[yo.extensionName])}catch{Wn(e,b,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[yo.extensionName]=m}e.setSocket(b,g,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(y,e):y.end()}function zf(e,t){e._readyState=Mt.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}function IH(e){return e.path=e.socketPath,wE.connect(e)}function MH(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=wE.isIP(e.host)?"":e.host),_H.connect(e)}function Wn(e,t,n){e._readyState=Mt.CLOSING;let r=new Error(n);Error.captureStackTrace(r,Wn),t.setHeader?(t[AE]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(zf,e,r)):(t.destroy(r),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function Fy(e,t,n){if(t){let r=SH(t)?t.size:xH(t).length;e._socket?e._sender._bufferedBytes+=r:e._bufferedAmount+=r}if(n){let r=new Error(`WebSocket is not open: readyState ${e.readyState} (${qi[e.readyState]})`);process.nextTick(n,r)}}function DH(e,t){let n=this[dn];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,n._socket[dn]!==void 0&&(n._socket.removeListener("data",Kf),process.nextTick(CE,n._socket),e===1005?n.close():n.close(e,t))}function $H(){let e=this[dn];e.isPaused||e._socket.resume()}function NH(e){let t=this[dn];t._socket[dn]!==void 0&&(t._socket.removeListener("data",Kf),process.nextTick(CE,t._socket),t.close(e[AH])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}function SE(){this[dn].emitClose()}function jH(e,t){this[dn].emit("message",e,t)}function LH(e){let t=this[dn];t._autoPong&&t.pong(e,!this._isServer,TE),t.emit("ping",e)}function GH(e){this[dn].emit("pong",e)}function CE(e){e.resume()}function FH(e){let t=this[dn];t.readyState!==Mt.CLOSED&&(t.readyState===Mt.OPEN&&(t._readyState=Mt.CLOSING,EE(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}function EE(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),RH)}function OE(){let e=this[dn];this.removeListener("close",OE),this.removeListener("data",Kf),this.removeListener("end",xE),e._readyState=Mt.CLOSING;let t;!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&(t=e._socket.read())!==null&&e._receiver.write(t),e._receiver.end(),this[dn]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",SE),e._receiver.on("finish",SE))}function Kf(e){this[dn]._receiver.write(e)||this.pause()}function xE(){let e=this[dn];e._readyState=Mt.CLOSING,e._receiver.end(),this.end()}function RE(){let e=this[dn];this.removeListener("error",RE),this.on("error",TE),e&&(e._readyState=Mt.CLOSING,this.destroy())}});var $E=St((uVe,DE)=>{"use strict";var lVe=Hf(),{Duplex:qH}=ut("stream");function IE(e){e.emit("close")}function UH(){!this.destroyed&&this._writableState.finished&&this.destroy()}function ME(e){this.removeListener("error",ME),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e)}function BH(e,t){let n=!0,r=new qH({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",function(o,a){let s=!a&&r._readableState.objectMode?o.toString():o;r.push(s)||e.pause()}),e.once("error",function(o){r.destroyed||(n=!1,r.destroy(o))}),e.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(i,o){if(e.readyState===e.CLOSED){o(i),process.nextTick(IE,r);return}let a=!1;e.once("error",function(d){a=!0,o(d)}),e.once("close",function(){a||o(i),process.nextTick(IE,r)}),n&&e.terminate()},r._final=function(i){if(e.readyState===e.CONNECTING){e.once("open",function(){r._final(i)});return}e._socket!==null&&(e._socket._writableState.finished?(i(),r._readableState.endEmitted&&r.destroy()):(e._socket.once("finish",function(){i()}),e.close()))},r._read=function(){e.isPaused&&e.resume()},r._write=function(i,o,a){if(e.readyState===e.CONNECTING){e.once("open",function(){r._write(i,o,a)});return}e.send(i,a)},r.on("end",UH),r.on("error",ME),r}DE.exports=BH});var jE=St((cVe,NE)=>{"use strict";var{tokenChars:zH}=gs();function KH(e){let t=new Set,n=-1,r=-1,i=0;for(i;i<e.length;i++){let a=e.charCodeAt(i);if(r===-1&&zH[a]===1)n===-1&&(n=i);else if(i!==0&&(a===32||a===9))r===-1&&n!==-1&&(r=i);else if(a===44){if(n===-1)throw new SyntaxError(`Unexpected character at index ${i}`);r===-1&&(r=i);let s=e.slice(n,r);if(t.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);t.add(s),n=r=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(n===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let o=e.slice(n,i);if(t.has(o))throw new SyntaxError(`The "${o}" subprotocol is duplicated`);return t.add(o),t}NE.exports={parse:KH}});var zE=St((pVe,BE)=>{"use strict";var HH=ut("events"),Jf=ut("http"),{Duplex:fVe}=ut("stream"),{createHash:JH}=ut("crypto"),LE=Ny(),la=Ol(),WH=jE(),VH=Hf(),{GUID:ZH,kWebSocket:YH}=Li(),QH=/^[+/0-9A-Za-z]{22}==$/,GE=0,FE=1,UE=2,qy=class extends HH{constructor(t,n){if(super(),t={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:VH,...t},t.port==null&&!t.server&&!t.noServer||t.port!=null&&(t.server||t.noServer)||t.server&&t.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(t.port!=null?(this._server=Jf.createServer((r,i)=>{let o=Jf.STATUS_CODES[426];i.writeHead(426,{"Content-Length":o.length,"Content-Type":"text/plain"}),i.end(o)}),this._server.listen(t.port,t.host,t.backlog,n)):t.server&&(this._server=t.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=XH(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,o,a)=>{this.handleUpgrade(i,o,a,r)}})}t.perMessageDeflate===!0&&(t.perMessageDeflate={}),t.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=t,this._state=GE}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(t){if(this._state===UE){t&&this.once("close",()=>{t(new Error("The server is not running"))}),process.nextTick(Il,this);return}if(t&&this.once("close",t),this._state!==FE)if(this._state=FE,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(Il,this):process.nextTick(Il,this);else{let n=this._server;this._removeListeners(),this._removeListeners=this._server=null,n.close(()=>{Il(this)})}}shouldHandle(t){if(this.options.path){let n=t.url.indexOf("?");if((n!==-1?t.url.slice(0,n):t.url)!==this.options.path)return!1}return!0}handleUpgrade(t,n,r,i){n.on("error",qE);let o=t.headers["sec-websocket-key"],a=t.headers.upgrade,s=+t.headers["sec-websocket-version"];if(t.method!=="GET"){ua(this,t,n,405,"Invalid HTTP method");return}if(a===void 0||a.toLowerCase()!=="websocket"){ua(this,t,n,400,"Invalid Upgrade header");return}if(o===void 0||!QH.test(o)){ua(this,t,n,400,"Missing or invalid Sec-WebSocket-Key header");return}if(s!==13&&s!==8){ua(this,t,n,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(t)){Ml(n,400);return}let d=t.headers["sec-websocket-protocol"],l=new Set;if(d!==void 0)try{l=WH.parse(d)}catch{ua(this,t,n,400,"Invalid Sec-WebSocket-Protocol header");return}let u=t.headers["sec-websocket-extensions"],c={};if(this.options.perMessageDeflate&&u!==void 0){let p=new la(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let m=LE.parse(u);m[la.extensionName]&&(p.accept(m[la.extensionName]),c[la.extensionName]=p)}catch{ua(this,t,n,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let p={origin:t.headers[`${s===8?"sec-websocket-origin":"origin"}`],secure:!!(t.socket.authorized||t.socket.encrypted),req:t};if(this.options.verifyClient.length===2){this.options.verifyClient(p,(m,y,h,b)=>{if(!m)return Ml(n,y||401,h,b);this.completeUpgrade(c,o,l,t,n,r,i)});return}if(!this.options.verifyClient(p))return Ml(n,401)}this.completeUpgrade(c,o,l,t,n,r,i)}completeUpgrade(t,n,r,i,o,a,s){if(!o.readable||!o.writable)return o.destroy();if(o[YH])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>GE)return Ml(o,503);let l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${JH("sha1").update(n+ZH).digest("base64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(r.size){let c=this.options.handleProtocols?this.options.handleProtocols(r,i):r.values().next().value;c&&(l.push(`Sec-WebSocket-Protocol: ${c}`),u._protocol=c)}if(t[la.extensionName]){let c=t[la.extensionName].params,p=LE.format({[la.extensionName]:[c]});l.push(`Sec-WebSocket-Extensions: ${p}`),u._extensions=t}this.emit("headers",l,i),o.write(l.concat(`\r
|
|
5
5
|
`).join(`\r
|
|
6
6
|
`)),o.removeListener("error",qE),u.setSocket(o,a,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(u),u.on("close",()=>{this.clients.delete(u),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Il,this)})),s(u,i)}};BE.exports=qy;function XH(e,t){for(let n of Object.keys(t))e.on(n,t[n]);return function(){for(let r of Object.keys(t))e.removeListener(r,t[r])}}function Il(e){e._state=UE,e.emit("close")}function qE(){this.destroy()}function Ml(e,t,n,r){n=n||Jf.STATUS_CODES[t],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(n),...r},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${Jf.STATUS_CODES[t]}\r
|
|
7
7
|
`+Object.keys(r).map(i=>`${i}: ${r[i]}`).join(`\r
|
|
@@ -129,14 +129,14 @@ const watchdog = setInterval(() => {
|
|
|
129
129
|
}, config.pollIntervalMs);
|
|
130
130
|
`.trim()}function kO(e,t){return{command:e,args:["-e",cW(),uW(t)]}}var CO=N(()=>{"use strict";Gl()});var EO=N(()=>{"use strict"});import{spawn as mW}from"node:child_process";import{randomUUID as hW}from"node:crypto";import{createServer as _W}from"node:net";function bW(e){let t=e;if(typeof t.ping=="function"&&t.readyState===WebSocket.OPEN)try{t.ping()}catch{}}async function SW(){return new Promise((e,t)=>{let n=_W();n.on("error",r=>t(r)),n.listen(0,"127.0.0.1",()=>{let r=n.address();if(typeof r=="object"&&r!==null){let i=r.port;n.close(o=>{o!==void 0?t(o):e(i)})}else n.close(),t(new Error("failed to allocate loopback port"))})})}async function ug(e,t,n={}){return IO(e,t,n,1)}async function IO(e,t,n,r){let o=`ws://127.0.0.1:${await SW()}`,a=fg(o,n);r===1&&$W();let s="",d=AW(),l=kO(process.execPath,{command:e,args:a,pollIntervalMs:yW,protectedPidsDir:SO()});Ot("process.spawn",{command:e,args:a,cwd:t,purpose:"codex.app_server"});let u=mW(l.command,[...l.args],{cwd:t,env:kW(n.env,n.inheritEnv??!0,t),stdio:d,detached:!0});OO(u,"stdout"),OO(u,"stderr",h=>{s=wW(`${s}${h}`)});let c=TO({stop:()=>xO(u),pid:u.pid,ownProcessGroup:!0,kind:"codex.app_server"});u.once("exit",()=>c.unregister());let p=()=>{c.unregister(),xO(u)},m,y=()=>(c.unregister(),m??=EW(u),m);Ot("process.spawned",{command:e,args:a,cwd:t,pid:u.pid,purpose:"codex.app_server"}),u.once("exit",(h,b)=>{Ot("process.exit",{command:e,args:a,cwd:t,pid:u.pid,code:h,signal:b,purpose:"codex.app_server"})});try{await ZW(o,u)}catch(h){if(p(),TW(h,s,r))return Ot("process.spawn.retry",{command:e,cwd:t,attempt:r,reason:"loopback_bind_in_use",purpose:"codex.app_server"}),IO(e,t,n,r+1);throw h}return{url:o,process:u,stop:p,stopAndWait:y}}function wW(e){return e.length>12e3?e.slice(e.length-12e3):e}function TW(e,t,n){let i=e instanceof Error?e.message:String(e);return n<3&&i.includes("codex app-server exited before readyz")&&t.includes("EADDRINUSE")&&t.includes("listen")}function AW(){return["ignore","pipe","pipe"]}function OO(e,t,n=void 0){let r=e[t];r!==null&&r.on("data",i=>{let o=i.toString();n?.(o),Ot("process.output",{pid:e.pid,purpose:"codex.app_server",stream:t,chars:o.length,output:o})})}function kW(e,t,n){let r=t?{...process.env}:{};for(let i of vW)delete r[i];if(e!==void 0)for(let[i,o]of Object.entries(e))o===void 0?delete r[i]:r[i]=o;return t&&(r=ng(r),r=rg(n,r,{log:(i,o)=>Ot(i,o)}),r=ng(r)),r}function xO(e,t=process.kill){if(e.pid!==void 0)try{let n=Ll(e.pid,"SIGINT",t);n.sparedPids.length>0&&Ot("process.group_signal_spared_listeners",{pid:e.pid,signal:"SIGINT",sparedPids:[...n.sparedPids],purpose:"codex.app_server"});return}catch(n){MO(e.pid,"SIGINT",n)}e.kill("SIGINT")}function CW(e){try{return process.kill(-e,0),!0}catch(t){return cg(t)!=="ESRCH"}}function EW(e,t={}){let n=e.pid;if(n===void 0)return Promise.reject(new Error("cannot reap owned Codex app-server without a process id"));let r=t.sigintGraceMs??5e3,i=t.sigkillWaitMs??5e3,o=t.killProcess??process.kill,a=t.listGroupPids??sg,s=t.processGroupExists??CW,d=t.protectedPids??ag;return new Promise((l,u)=>{let c=e.exitCode!==null||e.signalCode!==null,p=!1,m,y,h,b=()=>{m!==void 0&&clearTimeout(m),y!==void 0&&clearTimeout(y),h!==void 0&&clearTimeout(h)},g=_=>{if(!p)switch(p=!0,b(),e.off("exit",O),_){case"reaped":l();break;case"abandoned":u(new Error(`owned Codex app-server process group ${n} could not be confirmed reaped`));break}},S=()=>{let _=a(n);if(_===void 0)return;let w=d();return _.filter(k=>!w.has(k))},v=()=>{let _=S(),w=_===void 0?!s(n):_.length===0;return c&&w?(g("reaped"),!0):!1},T=()=>{p||h!==void 0||(h=setTimeout(()=>{h=void 0,v()||T()},10),h.unref?.())},C=_=>{try{let w=Ll(n,_,o,a,d());w.sparedPids.length>0&&Ot("process.group_signal_spared_listeners",{pid:n,signal:_,sparedPids:[...w.sparedPids],purpose:"codex.app_server"})}catch(w){if(cg(w)!=="ESRCH"){MO(n,_,w);try{e.kill(_)}catch{}}}},O=()=>{c=!0,v()||T()};e.once("exit",O),C("SIGINT"),!v()&&(m=setTimeout(()=>{p||(C("SIGKILL"),v()||T(),y=setTimeout(()=>g("abandoned"),i),y.unref?.())},r),m.unref?.())})}function MO(e,t,n){let r=cg(n),i=n instanceof Error?n.message:String(n);Ot(r==="EPERM"?"process.group_signal_denied":r==="ESRCH"?"process.group_signal_missing":"process.group_signal_failed",{pid:e,signal:t,code:r,message:i,fallback:"child_signal",purpose:"codex.app_server"}),r==="EPERM"&&process.stderr.write(`codex app-server process-group ${t} denied for pid ${e}; falling back to direct child ${t}
|
|
131
131
|
`)}function cg(e){if(e!==null&&typeof e=="object"&&"code"in e){let t=e.code;return typeof t=="string"?t:void 0}}function fg(e,t={}){return["app-server",...LW(t),"--listen",e]}function IW(e){return PW.find(t=>t===e)}function MW(e){let t=e?.trim();if(e===void 0||t===void 0||t==="")return{state:"unset"};if(!/^[0-9]+$/.test(t))return{state:"invalid",raw:e};let n=Number(t);return!Number.isSafeInteger(n)||n<pg||n>mg?{state:"invalid",raw:e}:{state:"applied",timeoutMs:n}}function $O(e=process.env){let t=MW(e[DO]);if(t.state==="unset")return t;let n=IW(e[RW]?.trim())??"env";return{...t,source:n}}function DW(e=process.env){let t=$O(e);return t.state==="applied"?t.timeoutMs:void 0}function $W(e=process.env,t=n=>{process.stderr.write(`${n}
|
|
132
|
-
`)}){let n=$O(e);if(n.state!=="unset"){if(n.state==="invalid"){let r=NW();t(`ERROR: ${DO}='${n.raw}' is invalid; stream-idle-timeout stays OFF. Accepted: ${r}.`),Ot("codex.stream_idle_timeout_config_invalid",{level:"error",raw:n.raw,source:n.source,acceptedFormat:r,minMs:pg,maxMs:mg});return}Ot("codex.stream_idle_timeout_config_applied",{level:"info",timeoutMs:n.timeoutMs,source:n.source})}}function NW(){return`a plain positive integer between ${pg} and ${mg} (milliseconds)`}function jO(){let e=NO;return["-c",`model_providers.${e}.name="OpenAI"`,"-c",`model_providers.${e}.wire_api="responses"`,"-c",`model_providers.${e}.requires_openai_auth=true`,"-c",`model_providers.${e}.supports_websockets=true`]}function jW(e){let t=NO;return[...jO(),"-c",`model_providers.${t}.stream_idle_timeout_ms=${e}`,"-c",`model_provider="${t}"`]}function LW(e,t=process.env){let n=DW(t);return[...OW,...e.nativeQuestionBridge==="durable"?xW:[],...bO(),...e.model===void 0?[]:["-c",`model=${JSON.stringify(e.model)}`],...e.reasoningEffort===void 0?[]:["-c",`model_reasoning_effort=${JSON.stringify(e.reasoningEffort)}`],...e.fast===!0?["-c",`service_tier=${JSON.stringify("fast")}`]:[],...(e.mcpServers??[]).flatMap(r=>ig(r,{neverEquivalentGranularApprovalPolicy:e.neverEquivalentGranularApprovalPolicy===!0})),...e.modelProvider===void 0?n===void 0?jO():jW(n):GW(e.modelProvider,n)]}function GW(e,t){return["-c",`model_providers.${e.id}.name=${JSON.stringify(e.name)}`,"-c",`model_providers.${e.id}.base_url=${JSON.stringify(e.baseUrl)}`,"-c",`model_providers.${e.id}.env_key=${JSON.stringify(e.envKey)}`,"-c",`model_providers.${e.id}.wire_api=${JSON.stringify(e.wireApi)}`,...Object.entries(e.httpHeaders??{}).flatMap(([n,r])=>["-c",`model_providers.${e.id}.http_headers.${n}=${JSON.stringify(r)}`]),...Object.entries(e.envHttpHeaders??{}).flatMap(([n,r])=>["-c",`model_providers.${e.id}.env_http_headers.${n}=${JSON.stringify(r)}`]),...t===void 0?[]:["-c",`model_providers.${e.id}.stream_idle_timeout_ms=${t}`],"-c",`model_provider=${JSON.stringify(e.id)}`]}async function rp(e,t=r=>new Uy.default(r),n=2e3){let r=await zW(e,t,n),i=hW(),o=new Map,a=new Set,s=new Set,d=[],l=new Set,u={nextId:1,closeError:void 0},c=h=>{let b=new Error(h);o.forEach(g=>g.reject(b)),o.clear()},p=setInterval(()=>bW(r),gW);p.unref?.();let m=h=>{if(clearInterval(p),c(h),u.closeError===void 0){u.closeError=new Error(h);for(let b of l)PO(b,u.closeError);l.clear()}};return r.addEventListener("close",()=>m("codex app-server websocket closed")),r.addEventListener("error",()=>m("codex app-server websocket closed")),r.addEventListener("message",h=>{let b=String(h.data),g=BW(b);if(g===void 0){FW(b,i);return}if(Fl({direction:"codex_to_commander",captureKind:UW(g),message:g,rawText:b,connectionId:i}),"id"in g&&("result"in g||"error"in g)){let S=o.get(g.id);S!==void 0&&(o.delete(g.id),S.resolve(g));return}if("id"in g&&typeof g.method=="string"){HW(r,g,s,i);return}if(!("id"in g)&&typeof g.method=="string"){let S=g;a.size===0?d.push(S):a.forEach(v=>RO(v,S))}}),await WW(r,o,i),{request:(h,b)=>{let g=u.nextId;return u.nextId+=1,LO(r,o,b===void 0?{jsonrpc:"2.0",id:g,method:h}:{jsonrpc:"2.0",id:g,method:h,params:b},i)},notify:(h,b)=>{let g=b===void 0?{jsonrpc:"2.0",method:h}:{jsonrpc:"2.0",method:h,params:b};Fl({direction:"commander_to_codex",captureKind:"outgoing",message:g,rawText:JSON.stringify(g),connectionId:i}),r.send(JSON.stringify(g))},onNotification:h=>{a.add(h),d.splice(0).forEach(b=>RO(h,b))},onRequest:h=>{s.add(h)},onClose:h=>{if(u.closeError!==void 0){PO(h,u.closeError);return}l.add(h)},isClosed:()=>u.closeError!==void 0,close:()=>{clearInterval(p),r.close()}}}function Fl(e){Yy()&&Nl({provider:"codex-app-server",captureKind:e.captureKind,rawText:e.rawText,rawValue:{message:e.message},captureMetadata:{direction:e.direction,capturedAtMs:Date.now(),capturePid:process.pid,connectionId:e.connectionId,...qW(e.message),...e.extraMetadata??{}}})}function FW(e,t){Yy()&&Nl({provider:"codex-app-server",captureKind:"incoming",rawText:e,captureMetadata:{direction:"codex_to_commander",capturedAtMs:Date.now(),capturePid:process.pid,connectionId:t,malformed:!0}})}function qW(e){return!("params"in e)||!yt(e.params)?{}:vy(e.params)}function UW(e){return"id"in e&&("result"in e||"error"in e)?"response":"id"in e&&typeof e.method=="string"?"request":"notification"}function BW(e){let t=String(e);try{let n=JSON.parse(t);if(!yt(n))throw new Error("codex app-server sent non-object JSON-RPC message");return n}catch(n){Ot("codex.app_server_frame_malformed",{purpose:"codex.app_server",message:n instanceof Error?n.message:String(n),payload:Zy(t,512),payloadChars:t.length});return}}function RO(e,t){try{e(t)}catch(n){Ot("codex.notification_callback_failed",{purpose:"codex.app_server",method:t.method,message:n instanceof Error?n.message:String(n)})}}function PO(e,t){try{e(t)}catch(n){Ot("codex.close_callback_failed",{purpose:"codex.app_server",message:n instanceof Error?n.message:String(n)})}}async function zW(e,t,n=2e3){let r=Date.now()+n,i;for(;Date.now()<=r;){let o=t(e);try{return await VW(o,Math.max(1,r-Date.now())),o}catch(a){i=a instanceof Error?a:new Error(String(a)),KW(o)}}throw i??new Error("websocket open failed")}function KW(e){let t=()=>{e.removeEventListener("error",n),e.removeEventListener("close",r)},n=()=>t(),r=()=>t();e.addEventListener("error",n,{once:!0}),e.addEventListener("close",r,{once:!0});try{e.close()}catch(i){t(),console.warn(`codex_app_server_failed_open_close_threw error_name=${i instanceof Error?i.name:"NonErrorThrow"}`)}}async function HW(e,t,n,r){let i=o=>JW(e,o,t.method,r);try{if(n.size===0){i({jsonrpc:"2.0",id:t.id,error:{code:-32601,message:`unhandled Codex app-server request: ${t.method}`}});return}for(let o of n){let a=await o(t);if(a!==void 0){i({jsonrpc:"2.0",id:t.id,result:a});return}}i({jsonrpc:"2.0",id:t.id,error:{code:-32601,message:`unhandled Codex app-server request: ${t.method}`}})}catch(o){i({jsonrpc:"2.0",id:t.id,error:{code:-32e3,message:o instanceof Error?o.message:String(o)}})}}function JW(e,t,n,r){let i=JSON.stringify(t);Fl({direction:"commander_to_codex",captureKind:"response",message:t,rawText:i,connectionId:r,extraMetadata:{requestMethod:n}}),e.send(i)}async function WW(e,t,n){let r=await LO(e,t,{jsonrpc:"2.0",id:"initialize",method:"initialize",params:{clientInfo:{name:"kandan-local-codex-runner",version:"0.0.1"},capabilities:{experimentalApi:!0}}},n);if("error"in r)throw new Error(`codex initialize failed: ${r.error.message}`);let i={jsonrpc:"2.0",method:"initialized"};Fl({direction:"commander_to_codex",captureKind:"outgoing",message:i,rawText:JSON.stringify(i),connectionId:n}),e.send(JSON.stringify(i))}function LO(e,t,n,r){return e.readyState!==WebSocket.OPEN?Promise.reject(new Error("codex app-server websocket is not open")):new Promise((i,o)=>{t.set(n.id,{resolve:i,reject:o}),Fl({direction:"commander_to_codex",captureKind:"request",message:n,rawText:JSON.stringify(n),connectionId:r}),e.send(JSON.stringify(n))})}function VW(e,t){return new Promise((n,r)=>{let i,o=()=>{i!==void 0&&clearTimeout(i),e.removeEventListener("open",a),e.removeEventListener("error",s)},a=()=>{o(),n()},s=()=>{o(),r(new Error("websocket open failed"))};e.addEventListener("open",a,{once:!0}),e.addEventListener("error",s,{once:!0}),i=setTimeout(()=>{o(),r(new Error("websocket open timed out"))},t),i.unref?.()})}function ZW(e,t,n=1e4){let r=YW(e),i=Date.now()+n;return new Promise((o,a)=>{let s=!1,d,l=m=>{s||(s=!0,d!==void 0&&clearTimeout(d),t.off("exit",u),m==="ready"?o():a(m))},u=(m,y)=>{l(new Error(`codex app-server exited before readyz: ${m??y??"unknown"}`))},c=()=>{d=setTimeout(p,50)},p=async()=>{if(Date.now()>i){l(new Error("timed out waiting for codex app-server readyz"));return}try{(await fetch(r)).ok?l("ready"):c()}catch{c()}};t.once("exit",u),p()})}function YW(e){let t=new URL(e);return t.protocol=t.protocol==="wss:"?"https:":"http:",t.pathname="/readyz",t.search="",t.hash="",t.toString()}var yW,gW,vW,OW,xW,DO,RW,pg,mg,PW,NO,hg=N(()=>{"use strict";KE();Yt();Kt();go();bo();Zf();ep();tp();vO();Gl();AO();CO();EO();yW=2e3,gW=(()=>{let e=process.env.LINZUMI_CODEX_WS_KEEPALIVE_MS;if(e===void 0)return 2e4;let t=Number.parseInt(e,10);return Number.isInteger(t)&&t>0?t:2e4})();vW=["LINZUMI_MCP_ACCESS_TOKEN","LINZUMI_MCP_OWNER_USERNAME"];OW=["-c","features.apps=false"],xW=["-c","features.default_mode_request_user_input=true"],DO="LINZUMI_CODEX_STREAM_IDLE_TIMEOUT_MS",RW="LINZUMI_CODEX_STREAM_IDLE_TIMEOUT_SOURCE",pg=5e3,mg=6e5,PW=["flag","env","server_default"];NO="openai-linzumi"});function ip(e){let t=new URL(e);switch(t.protocol){case"ws:":t.protocol="http:";break;case"wss:":t.protocol="https:";break;case"http:":case"https:":break;default:throw new Error("--api-url must be ws://, wss://, http://, or https://")}return t.pathname="",t.search="",t.hash="",t.toString().replace(/\/$/,"")}var O3e,_g=N(()=>{"use strict";go();O3e=300*1e3});function ql(e){let t=e.fetchImpl??fetch,n=ip(e.kandanUrl),r=e.authMode==="personal-agent-delegation"?"/api/v2/personal-agent-mcp":"/api/v2/local-runner-mcp",i=e.operatingMode??"text",o=async(a,s,d,l={})=>{let u=new URL(s,n),c={...d,operating_mode:i},p={method:a,headers:{authorization:`Bearer ${e.accessToken}`,...e.topicWakeTurnCapability===void 0?{}:{"x-linzumi-agent-turn":e.topicWakeTurnCapability}},...l.signal===void 0?{}:{signal:l.signal}};if(a==="GET")for(let[S,v]of Object.entries(c))v!=null&&u.searchParams.set(S,String(v));else p.headers={...p.headers,"content-type":"application/json"},p.body=JSON.stringify(c);let m=await t(u,p),y=await m.json(),h=yt(y)?y:void 0;if(h===void 0)throw new Error(`Linzumi MCP API returned non-object JSON from ${s}`);if(m.ok&&h.ok===!0)return h;let b=typeof h.error=="string"?h.error:`HTTP ${m.status}`,g=typeof h.detail=="string"?h.detail:void 0;throw new Error(`Linzumi MCP API ${s} failed: ${b}${g===void 0?"":` detail=${g}`}`)};return{validateAuth:()=>o("GET",`${r}/validate`,{}),issueOnboardingDiscoveryToken:a=>o("POST",`${r}/onboarding-discovery-token`,a),getMessage:a=>o("GET",`${r}/message`,a),getThread:a=>o("GET",`${r}/thread`,a),getThreadTranscript:a=>o("GET",`${r}/thread-transcript`,a),getChannel:a=>o("GET",`${r}/channel`,a),searchWorkspace:a=>o("GET",`${r}/search`,a),askWorkspace:a=>o("POST",`${r}/ask`,a),aboutMe:a=>o("GET",`${r}/about-me`,a),webSearch:a=>o("GET",`${r}/web-search`,a),fetchUrl:a=>o("GET",`${r}/fetch-url`,a),listUiTargets:a=>o("GET",`${r}/ui-targets`,a),openUi:a=>o("POST",`${r}/open-ui`,a),getCodingJobMetadata:a=>o("GET",`${r}/coding-job-metadata`,a),listProjects:a=>o("GET",`${r}/projects`,a),getProjectTasks:a=>o("GET",`${r}/project-tasks`,a),createProjectTask:a=>o("POST",`${r}/project-tasks/create`,a),updateProjectTask:a=>o("POST",`${r}/project-tasks/update`,a),deleteProjectTask:a=>o("POST",`${r}/project-tasks/delete`,a),addProjectTaskDependency:a=>o("POST",`${r}/project-tasks/add-dependency`,a),removeProjectTaskDependency:a=>o("POST",`${r}/project-tasks/remove-dependency`,a),getCallTranscript:a=>o("GET",`${r}/call-transcript`,a),renameCodingJob:a=>o("POST",`${r}/coding-job-title`,a),upsertCodingJobPlan:(a,s)=>o("POST",`${r}/coding-job-plan`,a,s),replaceCodingJobPlanSteps:a=>o("POST",`${r}/coding-job-plan/steps`,a),updateCodingJobPlanStep:a=>o("POST",`${r}/coding-job-plan/step`,a),linkCodingJobPullRequest:a=>o("POST",`${r}/coding-job-primary-pr`,a),listVaultSecrets:a=>o("GET",`${r}/vault-secrets`,a),noteProjectDirectory:a=>o("POST",`${r}/discovered-project`,a),noteAgentConversation:a=>o("POST",`${r}/discovered-conversation`,a),noteOnboardingDiscoveryStatus:a=>o("POST",`${r}/discovery-status`,a),sendChannelMessage:a=>o("POST",`${r}/channel-message`,a),editMessage:a=>o("POST",`${r}/message/edit`,a),agentReply:a=>o("POST",`${r}/agent-reply`,a),scheduleWake:a=>o("POST",`${r}/scheduled-wakes`,a),cancelWake:a=>o("POST",`${r}/scheduled-wakes/cancel`,a),declineDocumentAction:a=>o("POST",`${r}/agent/decline-document-action`,a),completeTopicWakeNoAction:a=>o("POST",`${r}/agent/complete-topic-wake-no-action`,a),recordTopicWakeToolAttempt:()=>o("POST",`${r}/agent/topic-wake-tool-attempt`,{}),agentTurnProgress:a=>o("POST",`${r}/agent-turn-progress`,a),agentDocumentTool:a=>o("POST",`${r}/agent/document-tool`,a),agentTopicTool:a=>o("POST",`${r}/agent/topic-tool`,a),agentListCodingJobs:a=>o("GET",`${r}/agent/coding-jobs`,a),agentStartCodingJob:a=>o("POST",`${r}/agent/start-coding-job`,a),agentSpawnChildJob:a=>o("POST",`${r}/agent/spawn-child-job`,a),agentArchiveChildJob:a=>o("POST",`${r}/agent/archive-child-job`,a),agentUnarchiveChildJob:a=>o("POST",`${r}/agent/unarchive-child-job`,a),agentInterruptCodingJob:a=>o("POST",`${r}/agent/interrupt-coding-job`,a),agentSendCodingJobMessage:a=>o("POST",`${r}/agent/send-coding-job-message`,a),agentDiscoverCodingJobs:a=>o("GET",`${r}/agent/discover-coding-jobs`,a),agentReadCodingJobThread:a=>o("GET",`${r}/agent/coding-job-thread`,a),agentResolveJobApproval:a=>o("POST",`${r}/agent/resolve-job-approval`,a),agentListPermissionRequests:a=>o("GET",`${r}/agent/permission-requests`,a),agentResolvePermissionRequest:a=>o("POST",`${r}/agent/resolve-permission-request`,a),agentSetJobPermissionMode:a=>o("POST",`${r}/agent/set-job-permission-mode`,a),agentArchiveCodingJob:a=>o("POST",`${r}/agent/archive-coding-job`,a),agentUnarchiveCodingJob:a=>o("POST",`${r}/agent/unarchive-coding-job`,a),agentSetThreadStatus:a=>o("POST",`${r}/agent/set-thread-status`,a),agentCreateChannel:a=>o("POST",`${r}/agent/create-channel`,a),agentRenameChannel:a=>o("POST",`${r}/agent/rename-channel`,a),agentArchiveChannel:a=>o("POST",`${r}/agent/archive-channel`,a),agentUnarchiveChannel:a=>o("POST",`${r}/agent/unarchive-channel`,a),agentAddReaction:a=>o("POST",`${r}/agent/add-reaction`,a),agentRemoveReaction:a=>o("POST",`${r}/agent/remove-reaction`,a),agentPinMessage:a=>o("POST",`${r}/agent/pin-message`,a),agentUnpinMessage:a=>o("POST",`${r}/agent/unpin-message`,a),prepareMessageUploads:a=>o("POST",`${r}/message-uploads/prepare`,a),attachMessageFiles:a=>o("POST",`${r}/message-files/attach`,a),prepareCustomEmoji:a=>o("POST",`${r}/custom-emoji/prepare`,a),renameCustomEmoji:a=>o("POST",`${r}/custom-emoji/rename`,a),sendThreadReply:a=>o("POST",`${r}/thread-reply`,a),sendDm:a=>o("POST",`${r}/dm`,a),dmOwner:a=>o("POST",`${r}/dm-owner`,a),getVaultValues:a=>o("POST",`${r}/vault-values`,a)}}var GO=N(()=>{"use strict";_g();Yt()});function FO(e){if(typeof e!="object"||e===null||Array.isArray(e))return{TAG:"Error",_0:"topic_quiet_auth_file_invalid"};let t=e.topicWakeTurnCapability;if(t===void 0)return{TAG:"Ok",_0:"none"};if(t===null||Array.isArray(t))return{TAG:"Error",_0:"topic_quiet_capability_invalid"};switch(typeof t){case"string":return t.trim()!==""&&Buffer.byteLength(t,"utf8")<=4096?{TAG:"Ok",_0:"available"}:{TAG:"Error",_0:"topic_quiet_capability_invalid"};case"object":let n=t.custody,r=0;if(typeof n=="string"){if(n==="claimed")return{TAG:"Ok",_0:"claimed"};r=1}else r=1;if(r===1){let i=t.custody,o=0;if(typeof i=="string"){if(i==="attempt_pending")return{TAG:"Ok",_0:"attempt_pending"};o=2}else o=2;if(o===2){let a=t.custody,s=0;if(typeof a=="string"){if(a==="attempt_acknowledged")return{TAG:"Ok",_0:"attempt_acknowledged"};s=3}else s=3;if(s===3){let d=t.custody,l=0;if(typeof d=="string"){if(d==="attempt_failed")return{TAG:"Ok",_0:"attempt_failed"};l=4}else l=4;if(l===4)return t.custody==="quiet_acknowledged"?{TAG:"Ok",_0:"quiet_acknowledged"}:{TAG:"Error",_0:"topic_quiet_capability_invalid"}}}}break;default:return{TAG:"Error",_0:"topic_quiet_capability_invalid"}}}function qO(e,t){return e==="quiet_acknowledged"?!0:t?!1:e!=="attempt_pending"&&e!=="attempt_failed"}var UO=N(()=>{});var BO,zO,op=N(()=>{UO();BO=FO,zO=qO});import{existsSync as e4,closeSync as H3e,fsyncSync as J3e,lstatSync as W3e,mkdirSync as V3e,openSync as Z3e,readFileSync as KO,renameSync as Y3e,rmSync as Q3e,writeFileSync as X3e}from"node:fs";import{homedir as t4}from"node:os";import{dirname as n6e,join as n4}from"node:path";function HO(e){let t=BO(JSON.parse(KO(e,"utf8")));switch(t.TAG){case"Ok":return t._0;case"Error":throw new Error(t._0)}}function r4(){return n4(t4(),".linzumi","auth.json")}function Ul(e,t=r4()){if(!e4(t))return;let n=i4(KO(t,"utf8")),r=ip(e),i=n.local_codex_runner?.[r];if(!(i===void 0||i.access_token.trim()==="")&&!(i.expires_at!==void 0&&Date.parse(i.expires_at)<=Date.now()))return{accessToken:i.access_token,kandanBaseUrl:r,issuedAt:i.issued_at,expiresAt:i.expires_at}}function i4(e){let t=JSON.parse(e);if(typeof t!="object"||t===null||Array.isArray(t))throw new Error("Kandan auth cache must contain a JSON object");let n=t,r=n.local_codex_runner,i=n.personal_agent_delegation;if(r!==void 0&&(typeof r!="object"||r===null||Array.isArray(r)))throw new Error("Kandan auth cache local_codex_runner must be an object");if(i!==void 0&&(typeof i!="object"||i===null||Array.isArray(i)))throw new Error("Kandan auth cache personal_agent_delegation must be an object");return{version:1,local_codex_runner:a4(r),personal_agent_delegation:o4(i)}}function o4(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e.access_token,n=e.issued_at,r=e.expires_at;if(!(typeof t!="string"||typeof n!="string"))return{access_token:t,issued_at:n,expires_at:typeof r=="string"?r:void 0}}function a4(e){if(!(typeof e!="object"||e===null||Array.isArray(e)))return Object.fromEntries(Object.entries(e).flatMap(([t,n])=>{if(typeof n!="object"||n===null||Array.isArray(n))return[];let r=n.access_token,i=n.issued_at,o=n.expires_at;return typeof r!="string"||typeof i!="string"?[]:[[t,{access_token:r,issued_at:i,expires_at:typeof o=="string"?o:void 0}]]}))}var JO=N(()=>{"use strict";_g();op()});function yg(e,t){return t.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i)==null?{TAG:"Error",_0:"progress_provider_turn_id_invalid"}:e!==void 0?e===t?{TAG:"Ok",_0:e}:{TAG:"Error",_0:"progress_provider_turn_rebind_refused"}:{TAG:"Ok",_0:t}}function WO(e,t,n){if(typeof n!="object"||n===null||Array.isArray(n))return{TAG:"Error",_0:"progress_provider_identity_missing"};let r=n.threadId;if(typeof r!="string")return{TAG:"Error",_0:"progress_provider_identity_missing"};let i=n.turnId;return typeof i=="string"?r===e?yg(t,i):{TAG:"Error",_0:"progress_provider_thread_mismatch"}:{TAG:"Error",_0:"progress_provider_identity_missing"}}function VO(e,t){return e>=0&&t>=0&&t<=(65536-e|0)?{TAG:"Ok",_0:e+t|0}:{TAG:"Error",_0:"progress_pre_response_budget_exhausted"}}var ZO=N(()=>{});var YO,QO,XO,ex=N(()=>{ZO();YO=yg,QO=WO,XO=VO});var gg=N(()=>{Ni();we();qe()});var nx,rx,bg,vg=N(()=>{nx=[["codexThreadId","harness_session_id"],["codex_thread_id","harness_session_id"],["kandanThreadId","thread_id"],["kandan_preview_ticket","linzumi_preview_ticket"],["kandan_thread_id","thread_id"],["linzumiThreadId","thread_id"],["linzumi_thread_id","thread_id"],["local_codex_runner","commander"],["runnerId","commander_id"],["runner_config","commander_config"],["runner_id","commander_id"]],rx=[["commander","local_codex_runner"],["commander_config","runner_config"],["commander_id","runner_id"],["harness_session_id","codex_thread_id"],["linzumi_preview_ticket","kandan_preview_ticket"],["thread_id","kandan_thread_id"]],bg=[["engine_boot_reconnect","harness_boot_reconnect"],["engine_for_runner_event_type","harness_for_commander_event_type"],["engine_rejected_steer","harness_rejected_steer"],["engine_unavailable","harness_unavailable"],["join_engine","join_harness"],["kandan-local-codex-runner","linzumi-commander"],["local_codex_runner","commander"],["original_engine","original_harness"],["resume_engine","resume_harness"]]});function Sg(e){let t={};return e.forEach(n=>{t[n[0]]=n[1]}),t}function d4(e){let t={};return e.forEach(n=>{t[n[1]]=n[0]}),t}function ox(e){let t=e.slice();return e.forEach(n=>{let r=l4[n];r!==void 0&&!t.includes(r)&&t.push(r);let i=u4[n];if(i!==void 0&&!t.includes(i)){t.push(i);return}}),t}var l4,u4,s6e,d6e,ap=N(()=>{vg();l4=Sg(nx),u4=Sg(rx),s6e=Sg(bg),d6e=d4(bg)});var u6e,c6e,f6e,p6e,Bl=N(()=>{Ke();ss();qe();ap();u6e=ox(["access_token","authorization","code","cookie","kandan_preview_ticket","refresh_token","token"]),c6e=new RegExp("^(authorization|cookie|set-cookie|password|login[_-]?url|turnCapability|topicWakeTurnCapability|topic_wake_turn_capability|x-linzumi-agent-turn|mcpAuthFileContents|LINZUMI_CLOUD_MCP_AUTH_JSON)$","i"),f6e=new RegExp("(^|[_-])(access[_-]?token|api[_-]?key|auth[_-]?token|oauth[_-]?code|refresh[_-]?token|secret|token)$","i"),p6e=new RegExp("\\beyJ[A-Za-z0-9_-]*\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\b","g")});var lx=N(()=>{Ke();gg();it();Bl()});var ux=N(()=>{lx()});var ct=N(()=>{rt()});var cr=N(()=>{});function p4(e){try{let t=JSON.stringify(e);if(t===void 0)return null;try{return JSON.parse(t)}catch{return null}}catch{return null}}var zl,As=N(()=>{rt();Ke();we();qe();it();zl=p4});var cx,vo=N(()=>{we();Ue();ct();As();cx=zl({version:1,kind:"successful_no_answer"})});var Jl=N(()=>{cr();Ke();we();Ue();ct();As();vo()});var ai=N(()=>{Ke()});function up(e){try{let t=JSON.stringify(e);if(t===void 0)return{TAG:"Error",_0:"authored JSON serialization failed"};try{return{TAG:"Ok",_0:JSON.parse(t)}}catch(n){let r=Je(n);return{TAG:"Error",_0:"authored JSON parse failed: "+jt(r).message}}}catch(t){let n=Je(t);return{TAG:"Error",_0:"authored JSON serialization failed: "+jt(n).message}}}var g6e,ks=N(()=>{Ke();we();Ue();ct();it();vo();g6e=up({})});var cp=N(()=>{cr();Ke();we();Ue();ks()});var px=St((b6e,fx)=>{"use strict";var{Transform:h4}=ut("stream"),{StringDecoder:_4}=ut("string_decoder"),Ag=class extends h4{constructor(t){super(Object.assign({},t,{writableObjectMode:!1})),this._buffer=""}_transform(t,n,r){typeof t=="string"?this._transform=this._transformString:(this._stringDecoder=new _4,this._transform=this._transformBuffer),this._transform(t,n,r)}_transformBuffer(t,n,r){this._buffer+=this._stringDecoder.write(t),this._processBuffer(r)}_transformString(t,n,r){this._buffer+=t.toString(),this._processBuffer(r)}_processBuffer(t){this._buffer&&(this.push(this._buffer,"utf8"),this._buffer=""),t(null)}_flushInput(){this._stringDecoder&&(this._buffer+=this._stringDecoder.end())}_flush(t){this._flushInput(),this._processBuffer(t)}};fx.exports=Ag});var Vl=St((v6e,mx)=>{"use strict";var y4=px(),Ne={value1:/^(?:[\"\{\[\]\-\d]|true\b|false\b|null\b|\s{1,256})/,string:/^(?:[^\x00-\x1f\"\\]{1,256}|\\[bfnrt\"\\\/]|\\u[\da-fA-F]{4}|\")/,key1:/^(?:[\"\}]|\s{1,256})/,colon:/^(?:\:|\s{1,256})/,comma:/^(?:[\,\]\}]|\s{1,256})/,ws:/^\s{1,256}/,numberStart:/^\d/,numberDigit:/^\d{0,256}/,numberFraction:/^[\.eE]/,numberExponent:/^[eE]/,numberExpSign:/^[-+]/},g4=16,ln=!0;try{new RegExp(".","y"),ln=!1}catch{}!ln&&Object.keys(Ne).forEach(e=>{let t=Ne[e].source.slice(1);t.slice(0,3)==="(?:"&&t.slice(-1)===")"&&(t=t.slice(3,-1)),Ne[e]=new RegExp(t,"y")});Ne.numberFracStart=Ne.numberExpStart=Ne.numberStart;Ne.numberFracDigit=Ne.numberExpDigit=Ne.numberDigit;var b4={true:!0,false:!1,null:null},si={object:"objectStop",array:"arrayStop","":"done"},v4=e=>String.fromCharCode(parseInt(e.slice(2),16)),S4={b:"\b",f:"\f",n:`
|
|
133
|
-
`,r:"\r",t:" ",'"':'"',"\\":"\\","/":"/"},ma=class e extends y4{static make(t){return new e(t)}constructor(t){super(Object.assign({},t,{readableObjectMode:!0})),this._packKeys=this._packStrings=this._packNumbers=this._streamKeys=this._streamStrings=this._streamNumbers=!0,t&&("packValues"in t&&(this._packKeys=this._packStrings=this._packNumbers=t.packValues),"packKeys"in t&&(this._packKeys=t.packKeys),"packStrings"in t&&(this._packStrings=t.packStrings),"packNumbers"in t&&(this._packNumbers=t.packNumbers),"streamValues"in t&&(this._streamKeys=this._streamStrings=this._streamNumbers=t.streamValues),"streamKeys"in t&&(this._streamKeys=t.streamKeys),"streamStrings"in t&&(this._streamStrings=t.streamStrings),"streamNumbers"in t&&(this._streamNumbers=t.streamNumbers),this._jsonStreaming=t.jsonStreaming),!this._packKeys&&(this._streamKeys=!0),!this._packStrings&&(this._streamStrings=!0),!this._packNumbers&&(this._streamNumbers=!0),this._done=!1,this._expect=this._jsonStreaming?"done":"value",this._stack=[],this._parent="",this._open_number=!1,this._accumulator=""}_flush(t){this._done=!0,super._flush(n=>{if(n)return t(n);this._open_number&&(this._streamNumbers&&this.push({name:"endNumber"}),this._open_number=!1,this._packNumbers&&(this.push({name:"numberValue",value:this._accumulator}),this._accumulator="")),t(null)})}_processBuffer(t){let n,r,i=0;e:for(;;)switch(this._expect){case"value1":case"value":if(Ne.value1.lastIndex=i,n=Ne.value1.exec(this._buffer),!n){if(this._done||i+g4<this._buffer.length)return i<this._buffer.length?t(new Error("Parser cannot parse input: expected a value")):t(new Error("Parser has expected a value"));break e}switch(r=n[0],r){case'"':this._streamStrings&&this.push({name:"startString"}),this._expect="string";break;case"{":this.push({name:"startObject"}),this._stack.push(this._parent),this._parent="object",this._expect="key1";break;case"[":this.push({name:"startArray"}),this._stack.push(this._parent),this._parent="array",this._expect="value1";break;case"]":if(this._expect!=="value1")return t(new Error("Parser cannot parse input: unexpected token ']'"));this._open_number&&(this._streamNumbers&&this.push({name:"endNumber"}),this._open_number=!1,this._packNumbers&&(this.push({name:"numberValue",value:this._accumulator}),this._accumulator="")),this.push({name:"endArray"}),this._parent=this._stack.pop(),this._expect=si[this._parent];break;case"-":this._open_number=!0,this._streamNumbers&&(this.push({name:"startNumber"}),this.push({name:"numberChunk",value:"-"})),this._packNumbers&&(this._accumulator="-"),this._expect="numberStart";break;case"0":this._open_number=!0,this._streamNumbers&&(this.push({name:"startNumber"}),this.push({name:"numberChunk",value:"0"})),this._packNumbers&&(this._accumulator="0"),this._expect="numberFraction";break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":this._open_number=!0,this._streamNumbers&&(this.push({name:"startNumber"}),this.push({name:"numberChunk",value:r})),this._packNumbers&&(this._accumulator=r),this._expect="numberDigit";break;case"true":case"false":case"null":if(this._buffer.length-i===r.length&&!this._done)break e;this.push({name:r+"Value",value:b4[r]}),this._expect=si[this._parent];break}ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"keyVal":case"string":if(Ne.string.lastIndex=i,n=Ne.string.exec(this._buffer),!n){if(i<this._buffer.length&&(this._done||this._buffer.length-i>=6))return t(new Error("Parser cannot parse input: escaped characters"));if(this._done)return t(new Error("Parser has expected a string value"));break e}if(r=n[0],r==='"')this._expect==="keyVal"?(this._streamKeys&&this.push({name:"endKey"}),this._packKeys&&(this.push({name:"keyValue",value:this._accumulator}),this._accumulator=""),this._expect="colon"):(this._streamStrings&&this.push({name:"endString"}),this._packStrings&&(this.push({name:"stringValue",value:this._accumulator}),this._accumulator=""),this._expect=si[this._parent]);else if(r.length>1&&r.charAt(0)==="\\"){let o=r.length==2?S4[r.charAt(1)]:v4(r);(this._expect==="keyVal"?this._streamKeys:this._streamStrings)&&this.push({name:"stringChunk",value:o}),(this._expect==="keyVal"?this._packKeys:this._packStrings)&&(this._accumulator+=o)}else(this._expect==="keyVal"?this._streamKeys:this._streamStrings)&&this.push({name:"stringChunk",value:r}),(this._expect==="keyVal"?this._packKeys:this._packStrings)&&(this._accumulator+=r);ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"key1":case"key":if(Ne.key1.lastIndex=i,n=Ne.key1.exec(this._buffer),!n){if(i<this._buffer.length||this._done)return t(new Error("Parser cannot parse input: expected an object key"));break e}if(r=n[0],r==='"')this._streamKeys&&this.push({name:"startKey"}),this._expect="keyVal";else if(r==="}"){if(this._expect!=="key1")return t(new Error("Parser cannot parse input: unexpected token '}'"));this.push({name:"endObject"}),this._parent=this._stack.pop(),this._expect=si[this._parent]}ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"colon":if(Ne.colon.lastIndex=i,n=Ne.colon.exec(this._buffer),!n){if(i<this._buffer.length||this._done)return t(new Error("Parser cannot parse input: expected ':'"));break e}r=n[0],r===":"&&(this._expect="value"),ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"arrayStop":case"objectStop":if(Ne.comma.lastIndex=i,n=Ne.comma.exec(this._buffer),!n){if(i<this._buffer.length||this._done)return t(new Error("Parser cannot parse input: expected ','"));break e}if(this._open_number&&(this._streamNumbers&&this.push({name:"endNumber"}),this._open_number=!1,this._packNumbers&&(this.push({name:"numberValue",value:this._accumulator}),this._accumulator="")),r=n[0],r===",")this._expect=this._expect==="arrayStop"?"value":"key";else if(r==="}"||r==="]"){if(r==="}"?this._expect==="arrayStop":this._expect!=="arrayStop")return t(new Error("Parser cannot parse input: expected '"+(this._expect==="arrayStop"?"]":"}")+"'"));this.push({name:r==="}"?"endObject":"endArray"}),this._parent=this._stack.pop(),this._expect=si[this._parent]}ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"numberStart":if(Ne.numberStart.lastIndex=i,n=Ne.numberStart.exec(this._buffer),!n){if(i<this._buffer.length||this._done)return t(new Error("Parser cannot parse input: expected a starting digit"));break e}r=n[0],this._streamNumbers&&this.push({name:"numberChunk",value:r}),this._packNumbers&&(this._accumulator+=r),this._expect=r==="0"?"numberFraction":"numberDigit",ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"numberDigit":if(Ne.numberDigit.lastIndex=i,n=Ne.numberDigit.exec(this._buffer),!n){if(i<this._buffer.length||this._done)return t(new Error("Parser cannot parse input: expected a digit"));break e}if(r=n[0],r)this._streamNumbers&&this.push({name:"numberChunk",value:r}),this._packNumbers&&(this._accumulator+=r),ln?this._buffer=this._buffer.slice(r.length):i+=r.length;else{if(i<this._buffer.length){this._expect="numberFraction";break}if(this._done){this._expect=si[this._parent];break}break e}break;case"numberFraction":if(Ne.numberFraction.lastIndex=i,n=Ne.numberFraction.exec(this._buffer),!n){if(i<this._buffer.length||this._done){this._expect=si[this._parent];break}break e}r=n[0],this._streamNumbers&&this.push({name:"numberChunk",value:r}),this._packNumbers&&(this._accumulator+=r),this._expect=r==="."?"numberFracStart":"numberExpSign",ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"numberFracStart":if(Ne.numberFracStart.lastIndex=i,n=Ne.numberFracStart.exec(this._buffer),!n){if(i<this._buffer.length||this._done)return t(new Error("Parser cannot parse input: expected a fractional part of a number"));break e}r=n[0],this._streamNumbers&&this.push({name:"numberChunk",value:r}),this._packNumbers&&(this._accumulator+=r),this._expect="numberFracDigit",ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"numberFracDigit":if(Ne.numberFracDigit.lastIndex=i,n=Ne.numberFracDigit.exec(this._buffer),r=n[0],r)this._streamNumbers&&this.push({name:"numberChunk",value:r}),this._packNumbers&&(this._accumulator+=r),ln?this._buffer=this._buffer.slice(r.length):i+=r.length;else{if(i<this._buffer.length){this._expect="numberExponent";break}if(this._done){this._expect=si[this._parent];break}break e}break;case"numberExponent":if(Ne.numberExponent.lastIndex=i,n=Ne.numberExponent.exec(this._buffer),!n){if(i<this._buffer.length){this._expect=si[this._parent];break}if(this._done){this._expect="done";break}break e}r=n[0],this._streamNumbers&&this.push({name:"numberChunk",value:r}),this._packNumbers&&(this._accumulator+=r),this._expect="numberExpSign",ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"numberExpSign":if(Ne.numberExpSign.lastIndex=i,n=Ne.numberExpSign.exec(this._buffer),!n){if(i<this._buffer.length){this._expect="numberExpStart";break}if(this._done)return t(new Error("Parser has expected an exponent value of a number"));break e}r=n[0],this._streamNumbers&&this.push({name:"numberChunk",value:r}),this._packNumbers&&(this._accumulator+=r),this._expect="numberExpStart",ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"numberExpStart":if(Ne.numberExpStart.lastIndex=i,n=Ne.numberExpStart.exec(this._buffer),!n){if(i<this._buffer.length||this._done)return t(new Error("Parser cannot parse input: expected an exponent part of a number"));break e}r=n[0],this._streamNumbers&&this.push({name:"numberChunk",value:r}),this._packNumbers&&(this._accumulator+=r),this._expect="numberExpDigit",ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"numberExpDigit":if(Ne.numberExpDigit.lastIndex=i,n=Ne.numberExpDigit.exec(this._buffer),r=n[0],r)this._streamNumbers&&this.push({name:"numberChunk",value:r}),this._packNumbers&&(this._accumulator+=r),ln?this._buffer=this._buffer.slice(r.length):i+=r.length;else{if(i<this._buffer.length||this._done){this._expect=si[this._parent];break}break e}break;case"done":if(Ne.ws.lastIndex=i,n=Ne.ws.exec(this._buffer),!n){if(i<this._buffer.length){if(this._jsonStreaming){this._expect="value";break}return t(new Error("Parser cannot parse input: unexpected characters"))}break e}r=n[0],this._open_number&&(this._streamNumbers&&this.push({name:"endNumber"}),this._open_number=!1,this._packNumbers&&(this.push({name:"numberValue",value:this._accumulator}),this._accumulator="")),ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break}!ln&&(this._buffer=this._buffer.slice(i)),t(null)}};ma.parser=ma.make;ma.make.Constructor=ma;mx.exports=ma});var w4,kg=N(()=>{Ke();it();w4=ei(Vl(),1)});var pp=N(()=>{Ke();we();Ue();ct();ai();vo();cp();kg();ks()});var Rr=N(()=>{Ke();Ue();ct();Jl();pp()});var Og=N(()=>{Rr()});var gx=N(()=>{});var bx=N(()=>{rt();bf();qe()});function Ns(e){let t=0;for(;;){let n=t,r=e[n];if(r===void 0)return'"'+e+'"';switch(r){case'"':case`
|
|
132
|
+
`)}){let n=$O(e);if(n.state!=="unset"){if(n.state==="invalid"){let r=NW();t(`ERROR: ${DO}='${n.raw}' is invalid; stream-idle-timeout stays OFF. Accepted: ${r}.`),Ot("codex.stream_idle_timeout_config_invalid",{level:"error",raw:n.raw,source:n.source,acceptedFormat:r,minMs:pg,maxMs:mg});return}Ot("codex.stream_idle_timeout_config_applied",{level:"info",timeoutMs:n.timeoutMs,source:n.source})}}function NW(){return`a plain positive integer between ${pg} and ${mg} (milliseconds)`}function jO(){let e=NO;return["-c",`model_providers.${e}.name="OpenAI"`,"-c",`model_providers.${e}.wire_api="responses"`,"-c",`model_providers.${e}.requires_openai_auth=true`,"-c",`model_providers.${e}.supports_websockets=true`]}function jW(e){let t=NO;return[...jO(),"-c",`model_providers.${t}.stream_idle_timeout_ms=${e}`,"-c",`model_provider="${t}"`]}function LW(e,t=process.env){let n=DW(t);return[...OW,...e.nativeQuestionBridge==="durable"?xW:[],...bO(),...e.model===void 0?[]:["-c",`model=${JSON.stringify(e.model)}`],...e.reasoningEffort===void 0?[]:["-c",`model_reasoning_effort=${JSON.stringify(e.reasoningEffort)}`],...e.fast===!0?["-c",`service_tier=${JSON.stringify("fast")}`]:[],...(e.mcpServers??[]).flatMap(r=>ig(r,{neverEquivalentGranularApprovalPolicy:e.neverEquivalentGranularApprovalPolicy===!0})),...e.modelProvider===void 0?n===void 0?jO():jW(n):GW(e.modelProvider,n)]}function GW(e,t){return["-c",`model_providers.${e.id}.name=${JSON.stringify(e.name)}`,"-c",`model_providers.${e.id}.base_url=${JSON.stringify(e.baseUrl)}`,"-c",`model_providers.${e.id}.env_key=${JSON.stringify(e.envKey)}`,"-c",`model_providers.${e.id}.wire_api=${JSON.stringify(e.wireApi)}`,...Object.entries(e.httpHeaders??{}).flatMap(([n,r])=>["-c",`model_providers.${e.id}.http_headers.${n}=${JSON.stringify(r)}`]),...Object.entries(e.envHttpHeaders??{}).flatMap(([n,r])=>["-c",`model_providers.${e.id}.env_http_headers.${n}=${JSON.stringify(r)}`]),...t===void 0?[]:["-c",`model_providers.${e.id}.stream_idle_timeout_ms=${t}`],"-c",`model_provider=${JSON.stringify(e.id)}`]}async function rp(e,t=r=>new Uy.default(r),n=2e3){let r=await zW(e,t,n),i=hW(),o=new Map,a=new Set,s=new Set,d=[],l=new Set,u={nextId:1,closeError:void 0},c=h=>{let b=new Error(h);o.forEach(g=>g.reject(b)),o.clear()},p=setInterval(()=>bW(r),gW);p.unref?.();let m=h=>{if(clearInterval(p),c(h),u.closeError===void 0){u.closeError=new Error(h);for(let b of l)PO(b,u.closeError);l.clear()}};return r.addEventListener("close",()=>m("codex app-server websocket closed")),r.addEventListener("error",()=>m("codex app-server websocket closed")),r.addEventListener("message",h=>{let b=String(h.data),g=BW(b);if(g===void 0){FW(b,i);return}if(Fl({direction:"codex_to_commander",captureKind:UW(g),message:g,rawText:b,connectionId:i}),"id"in g&&("result"in g||"error"in g)){let S=o.get(g.id);S!==void 0&&(o.delete(g.id),S.resolve(g));return}if("id"in g&&typeof g.method=="string"){HW(r,g,s,i);return}if(!("id"in g)&&typeof g.method=="string"){let S=g;a.size===0?d.push(S):a.forEach(v=>RO(v,S))}}),await WW(r,o,i),{request:(h,b)=>{let g=u.nextId;return u.nextId+=1,LO(r,o,b===void 0?{jsonrpc:"2.0",id:g,method:h}:{jsonrpc:"2.0",id:g,method:h,params:b},i)},notify:(h,b)=>{let g=b===void 0?{jsonrpc:"2.0",method:h}:{jsonrpc:"2.0",method:h,params:b};Fl({direction:"commander_to_codex",captureKind:"outgoing",message:g,rawText:JSON.stringify(g),connectionId:i}),r.send(JSON.stringify(g))},onNotification:h=>{a.add(h),d.splice(0).forEach(b=>RO(h,b))},onRequest:h=>{s.add(h)},onClose:h=>{if(u.closeError!==void 0){PO(h,u.closeError);return}l.add(h)},isClosed:()=>u.closeError!==void 0,close:()=>{clearInterval(p),r.close()}}}function Fl(e){Yy()&&Nl({provider:"codex-app-server",captureKind:e.captureKind,rawText:e.rawText,rawValue:{message:e.message},captureMetadata:{direction:e.direction,capturedAtMs:Date.now(),capturePid:process.pid,connectionId:e.connectionId,...qW(e.message),...e.extraMetadata??{}}})}function FW(e,t){Yy()&&Nl({provider:"codex-app-server",captureKind:"incoming",rawText:e,captureMetadata:{direction:"codex_to_commander",capturedAtMs:Date.now(),capturePid:process.pid,connectionId:t,malformed:!0}})}function qW(e){return!("params"in e)||!yt(e.params)?{}:vy(e.params)}function UW(e){return"id"in e&&("result"in e||"error"in e)?"response":"id"in e&&typeof e.method=="string"?"request":"notification"}function BW(e){let t=String(e);try{let n=JSON.parse(t);if(!yt(n))throw new Error("codex app-server sent non-object JSON-RPC message");return n}catch(n){Ot("codex.app_server_frame_malformed",{purpose:"codex.app_server",message:n instanceof Error?n.message:String(n),payload:Zy(t,512),payloadChars:t.length});return}}function RO(e,t){try{e(t)}catch(n){Ot("codex.notification_callback_failed",{purpose:"codex.app_server",method:t.method,message:n instanceof Error?n.message:String(n)})}}function PO(e,t){try{e(t)}catch(n){Ot("codex.close_callback_failed",{purpose:"codex.app_server",message:n instanceof Error?n.message:String(n)})}}async function zW(e,t,n=2e3){let r=Date.now()+n,i;for(;Date.now()<=r;){let o=t(e);try{return await VW(o,Math.max(1,r-Date.now())),o}catch(a){i=a instanceof Error?a:new Error(String(a)),KW(o)}}throw i??new Error("websocket open failed")}function KW(e){let t=()=>{e.removeEventListener("error",n),e.removeEventListener("close",r)},n=()=>t(),r=()=>t();e.addEventListener("error",n,{once:!0}),e.addEventListener("close",r,{once:!0});try{e.close()}catch(i){t(),console.warn(`codex_app_server_failed_open_close_threw error_name=${i instanceof Error?i.name:"NonErrorThrow"}`)}}async function HW(e,t,n,r){let i=o=>JW(e,o,t.method,r);try{if(n.size===0){i({jsonrpc:"2.0",id:t.id,error:{code:-32601,message:`unhandled Codex app-server request: ${t.method}`}});return}for(let o of n){let a=await o(t);if(a!==void 0){i({jsonrpc:"2.0",id:t.id,result:a});return}}i({jsonrpc:"2.0",id:t.id,error:{code:-32601,message:`unhandled Codex app-server request: ${t.method}`}})}catch(o){i({jsonrpc:"2.0",id:t.id,error:{code:-32e3,message:o instanceof Error?o.message:String(o)}})}}function JW(e,t,n,r){let i=JSON.stringify(t);Fl({direction:"commander_to_codex",captureKind:"response",message:t,rawText:i,connectionId:r,extraMetadata:{requestMethod:n}}),e.send(i)}async function WW(e,t,n){let r=await LO(e,t,{jsonrpc:"2.0",id:"initialize",method:"initialize",params:{clientInfo:{name:"kandan-local-codex-runner",version:"0.0.1"},capabilities:{experimentalApi:!0}}},n);if("error"in r)throw new Error(`codex initialize failed: ${r.error.message}`);let i={jsonrpc:"2.0",method:"initialized"};Fl({direction:"commander_to_codex",captureKind:"outgoing",message:i,rawText:JSON.stringify(i),connectionId:n}),e.send(JSON.stringify(i))}function LO(e,t,n,r){return e.readyState!==WebSocket.OPEN?Promise.reject(new Error("codex app-server websocket is not open")):new Promise((i,o)=>{t.set(n.id,{resolve:i,reject:o}),Fl({direction:"commander_to_codex",captureKind:"request",message:n,rawText:JSON.stringify(n),connectionId:r}),e.send(JSON.stringify(n))})}function VW(e,t){return new Promise((n,r)=>{let i,o=()=>{i!==void 0&&clearTimeout(i),e.removeEventListener("open",a),e.removeEventListener("error",s)},a=()=>{o(),n()},s=()=>{o(),r(new Error("websocket open failed"))};e.addEventListener("open",a,{once:!0}),e.addEventListener("error",s,{once:!0}),i=setTimeout(()=>{o(),r(new Error("websocket open timed out"))},t),i.unref?.()})}function ZW(e,t,n=1e4){let r=YW(e),i=Date.now()+n;return new Promise((o,a)=>{let s=!1,d,l=m=>{s||(s=!0,d!==void 0&&clearTimeout(d),t.off("exit",u),m==="ready"?o():a(m))},u=(m,y)=>{l(new Error(`codex app-server exited before readyz: ${m??y??"unknown"}`))},c=()=>{d=setTimeout(p,50)},p=async()=>{if(Date.now()>i){l(new Error("timed out waiting for codex app-server readyz"));return}try{(await fetch(r)).ok?l("ready"):c()}catch{c()}};t.once("exit",u),p()})}function YW(e){let t=new URL(e);return t.protocol=t.protocol==="wss:"?"https:":"http:",t.pathname="/readyz",t.search="",t.hash="",t.toString()}var yW,gW,vW,OW,xW,DO,RW,pg,mg,PW,NO,hg=N(()=>{"use strict";KE();Yt();Kt();go();bo();Zf();ep();tp();vO();Gl();AO();CO();EO();yW=2e3,gW=(()=>{let e=process.env.LINZUMI_CODEX_WS_KEEPALIVE_MS;if(e===void 0)return 2e4;let t=Number.parseInt(e,10);return Number.isInteger(t)&&t>0?t:2e4})();vW=["LINZUMI_MCP_ACCESS_TOKEN","LINZUMI_MCP_OWNER_USERNAME"];OW=["-c","features.apps=false"],xW=["-c","features.default_mode_request_user_input=true"],DO="LINZUMI_CODEX_STREAM_IDLE_TIMEOUT_MS",RW="LINZUMI_CODEX_STREAM_IDLE_TIMEOUT_SOURCE",pg=5e3,mg=6e5,PW=["flag","env","server_default"];NO="openai-linzumi"});function ip(e){let t=new URL(e);switch(t.protocol){case"ws:":t.protocol="http:";break;case"wss:":t.protocol="https:";break;case"http:":case"https:":break;default:throw new Error("--api-url must be ws://, wss://, http://, or https://")}return t.pathname="",t.search="",t.hash="",t.toString().replace(/\/$/,"")}var O3e,_g=N(()=>{"use strict";go();O3e=300*1e3});function ql(e){let t=e.fetchImpl??fetch,n=ip(e.kandanUrl),r=e.authMode==="personal-agent-delegation"?"/api/v2/personal-agent-mcp":"/api/v2/local-runner-mcp",i=e.operatingMode??"text",o=async(a,s,d,l={})=>{let u=new URL(s,n),c={...d,operating_mode:i},p={method:a,headers:{authorization:`Bearer ${e.accessToken}`,...e.topicWakeTurnCapability===void 0?{}:{"x-linzumi-agent-turn":e.topicWakeTurnCapability}},...l.signal===void 0?{}:{signal:l.signal}};if(a==="GET")for(let[S,v]of Object.entries(c))v!=null&&u.searchParams.set(S,String(v));else p.headers={...p.headers,"content-type":"application/json"},p.body=JSON.stringify(c);let m=await t(u,p),y=await m.json(),h=yt(y)?y:void 0;if(h===void 0)throw new Error(`Linzumi MCP API returned non-object JSON from ${s}`);if(m.ok&&h.ok===!0)return h;let b=typeof h.error=="string"?h.error:`HTTP ${m.status}`,g=typeof h.detail=="string"?h.detail:void 0;throw new Error(`Linzumi MCP API ${s} failed: ${b}${g===void 0?"":` detail=${g}`}`)};return{validateAuth:()=>o("GET",`${r}/validate`,{}),issueOnboardingDiscoveryToken:a=>o("POST",`${r}/onboarding-discovery-token`,a),getMessage:a=>o("GET",`${r}/message`,a),getThread:a=>o("GET",`${r}/thread`,a),getThreadTranscript:a=>o("GET",`${r}/thread-transcript`,a),getChannel:a=>o("GET",`${r}/channel`,a),searchWorkspace:a=>o("GET",`${r}/search`,a),askWorkspace:a=>o("POST",`${r}/ask`,a),aboutMe:a=>o("GET",`${r}/about-me`,a),webSearch:a=>o("GET",`${r}/web-search`,a),fetchUrl:a=>o("GET",`${r}/fetch-url`,a),listUiTargets:a=>o("GET",`${r}/ui-targets`,a),openUi:a=>o("POST",`${r}/open-ui`,a),getCodingJobMetadata:a=>o("GET",`${r}/coding-job-metadata`,a),listProjects:a=>o("GET",`${r}/projects`,a),getProjectTasks:a=>o("GET",`${r}/project-tasks`,a),createProjectTask:a=>o("POST",`${r}/project-tasks/create`,a),updateProjectTask:a=>o("POST",`${r}/project-tasks/update`,a),deleteProjectTask:a=>o("POST",`${r}/project-tasks/delete`,a),addProjectTaskDependency:a=>o("POST",`${r}/project-tasks/add-dependency`,a),removeProjectTaskDependency:a=>o("POST",`${r}/project-tasks/remove-dependency`,a),getCallTranscript:a=>o("GET",`${r}/call-transcript`,a),renameCodingJob:a=>o("POST",`${r}/coding-job-title`,a),upsertCodingJobPlan:(a,s)=>o("POST",`${r}/coding-job-plan`,a,s),replaceCodingJobPlanSteps:a=>o("POST",`${r}/coding-job-plan/steps`,a),updateCodingJobPlanStep:a=>o("POST",`${r}/coding-job-plan/step`,a),linkCodingJobPullRequest:a=>o("POST",`${r}/coding-job-primary-pr`,a),listVaultSecrets:a=>o("GET",`${r}/vault-secrets`,a),noteProjectDirectory:a=>o("POST",`${r}/discovered-project`,a),noteAgentConversation:a=>o("POST",`${r}/discovered-conversation`,a),noteOnboardingDiscoveryStatus:a=>o("POST",`${r}/discovery-status`,a),sendChannelMessage:a=>o("POST",`${r}/channel-message`,a),editMessage:a=>o("POST",`${r}/message/edit`,a),agentReply:a=>o("POST",`${r}/agent-reply`,a),scheduleWake:a=>o("POST",`${r}/scheduled-wakes`,a),cancelWake:a=>o("POST",`${r}/scheduled-wakes/cancel`,a),declineDocumentAction:a=>o("POST",`${r}/agent/decline-document-action`,a),completeTopicWakeNoAction:a=>o("POST",`${r}/agent/complete-topic-wake-no-action`,a),recordTopicWakeToolAttempt:()=>o("POST",`${r}/agent/topic-wake-tool-attempt`,{}),agentTurnProgress:a=>o("POST",`${r}/agent-turn-progress`,a),agentDocumentTool:a=>o("POST",`${r}/agent/document-tool`,a),agentTopicTool:a=>o("POST",`${r}/agent/topic-tool`,a),agentListCodingJobs:a=>o("GET",`${r}/agent/coding-jobs`,a),agentStartCodingJob:a=>o("POST",`${r}/agent/start-coding-job`,a),agentSpawnChildJob:a=>o("POST",`${r}/agent/spawn-child-job`,a),agentArchiveChildJob:a=>o("POST",`${r}/agent/archive-child-job`,a),agentUnarchiveChildJob:a=>o("POST",`${r}/agent/unarchive-child-job`,a),agentInterruptCodingJob:a=>o("POST",`${r}/agent/interrupt-coding-job`,a),agentSendCodingJobMessage:a=>o("POST",`${r}/agent/send-coding-job-message`,a),agentDiscoverCodingJobs:a=>o("GET",`${r}/agent/discover-coding-jobs`,a),agentReadCodingJobThread:a=>o("GET",`${r}/agent/coding-job-thread`,a),agentResolveJobApproval:a=>o("POST",`${r}/agent/resolve-job-approval`,a),agentListPermissionRequests:a=>o("GET",`${r}/agent/permission-requests`,a),agentResolvePermissionRequest:a=>o("POST",`${r}/agent/resolve-permission-request`,a),agentSetJobPermissionMode:a=>o("POST",`${r}/agent/set-job-permission-mode`,a),agentArchiveCodingJob:a=>o("POST",`${r}/agent/archive-coding-job`,a),agentUnarchiveCodingJob:a=>o("POST",`${r}/agent/unarchive-coding-job`,a),agentSetThreadStatus:a=>o("POST",`${r}/agent/set-thread-status`,a),agentCreateChannel:a=>o("POST",`${r}/agent/create-channel`,a),agentRenameChannel:a=>o("POST",`${r}/agent/rename-channel`,a),agentArchiveChannel:a=>o("POST",`${r}/agent/archive-channel`,a),agentUnarchiveChannel:a=>o("POST",`${r}/agent/unarchive-channel`,a),agentAddReaction:a=>o("POST",`${r}/agent/add-reaction`,a),agentRemoveReaction:a=>o("POST",`${r}/agent/remove-reaction`,a),agentPinMessage:a=>o("POST",`${r}/agent/pin-message`,a),agentUnpinMessage:a=>o("POST",`${r}/agent/unpin-message`,a),prepareMessageUploads:a=>o("POST",`${r}/message-uploads/prepare`,a),attachMessageFiles:a=>o("POST",`${r}/message-files/attach`,a),prepareCustomEmoji:a=>o("POST",`${r}/custom-emoji/prepare`,a),renameCustomEmoji:a=>o("POST",`${r}/custom-emoji/rename`,a),sendThreadReply:a=>o("POST",`${r}/thread-reply`,a),sendDm:a=>o("POST",`${r}/dm`,a),dmOwner:a=>o("POST",`${r}/dm-owner`,a),getVaultValues:a=>o("POST",`${r}/vault-values`,a)}}var GO=N(()=>{"use strict";_g();Yt()});function FO(e){if(typeof e!="object"||e===null||Array.isArray(e))return{TAG:"Error",_0:"topic_quiet_auth_file_invalid"};let t=e.topicWakeTurnCapability;if(t===void 0)return{TAG:"Ok",_0:"none"};if(t===null||Array.isArray(t))return{TAG:"Error",_0:"topic_quiet_capability_invalid"};switch(typeof t){case"string":return t.trim()!==""&&Buffer.byteLength(t,"utf8")<=4096?{TAG:"Ok",_0:"available"}:{TAG:"Error",_0:"topic_quiet_capability_invalid"};case"object":let n=t.custody,r=0;if(typeof n=="string"){if(n==="claimed")return{TAG:"Ok",_0:"claimed"};r=1}else r=1;if(r===1){let i=t.custody,o=0;if(typeof i=="string"){if(i==="attempt_pending")return{TAG:"Ok",_0:"attempt_pending"};o=2}else o=2;if(o===2){let a=t.custody,s=0;if(typeof a=="string"){if(a==="attempt_acknowledged")return{TAG:"Ok",_0:"attempt_acknowledged"};s=3}else s=3;if(s===3){let d=t.custody,l=0;if(typeof d=="string"){if(d==="attempt_failed")return{TAG:"Ok",_0:"attempt_failed"};l=4}else l=4;if(l===4)return t.custody==="quiet_acknowledged"?{TAG:"Ok",_0:"quiet_acknowledged"}:{TAG:"Error",_0:"topic_quiet_capability_invalid"}}}}break;default:return{TAG:"Error",_0:"topic_quiet_capability_invalid"}}}function qO(e,t){return e==="quiet_acknowledged"?!0:t?!1:e!=="attempt_pending"&&e!=="attempt_failed"}var UO=N(()=>{});var BO,zO,op=N(()=>{UO();BO=FO,zO=qO});import{existsSync as e4,closeSync as H3e,fsyncSync as J3e,lstatSync as W3e,mkdirSync as V3e,openSync as Z3e,readFileSync as KO,renameSync as Y3e,rmSync as Q3e,writeFileSync as X3e}from"node:fs";import{homedir as t4}from"node:os";import{dirname as n6e,join as n4}from"node:path";function HO(e){let t=BO(JSON.parse(KO(e,"utf8")));switch(t.TAG){case"Ok":return t._0;case"Error":throw new Error(t._0)}}function r4(){return n4(t4(),".linzumi","auth.json")}function Ul(e,t=r4()){if(!e4(t))return;let n=i4(KO(t,"utf8")),r=ip(e),i=n.local_codex_runner?.[r];if(!(i===void 0||i.access_token.trim()==="")&&!(i.expires_at!==void 0&&Date.parse(i.expires_at)<=Date.now()))return{accessToken:i.access_token,kandanBaseUrl:r,issuedAt:i.issued_at,expiresAt:i.expires_at}}function i4(e){let t=JSON.parse(e);if(typeof t!="object"||t===null||Array.isArray(t))throw new Error("Kandan auth cache must contain a JSON object");let n=t,r=n.local_codex_runner,i=n.personal_agent_delegation;if(r!==void 0&&(typeof r!="object"||r===null||Array.isArray(r)))throw new Error("Kandan auth cache local_codex_runner must be an object");if(i!==void 0&&(typeof i!="object"||i===null||Array.isArray(i)))throw new Error("Kandan auth cache personal_agent_delegation must be an object");return{version:1,local_codex_runner:a4(r),personal_agent_delegation:o4(i)}}function o4(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e.access_token,n=e.issued_at,r=e.expires_at;if(!(typeof t!="string"||typeof n!="string"))return{access_token:t,issued_at:n,expires_at:typeof r=="string"?r:void 0}}function a4(e){if(!(typeof e!="object"||e===null||Array.isArray(e)))return Object.fromEntries(Object.entries(e).flatMap(([t,n])=>{if(typeof n!="object"||n===null||Array.isArray(n))return[];let r=n.access_token,i=n.issued_at,o=n.expires_at;return typeof r!="string"||typeof i!="string"?[]:[[t,{access_token:r,issued_at:i,expires_at:typeof o=="string"?o:void 0}]]}))}var JO=N(()=>{"use strict";_g();op()});function yg(e,t){return t.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i)==null?{TAG:"Error",_0:"progress_provider_turn_id_invalid"}:e!==void 0?e===t?{TAG:"Ok",_0:e}:{TAG:"Error",_0:"progress_provider_turn_rebind_refused"}:{TAG:"Ok",_0:t}}function WO(e,t,n){if(typeof n!="object"||n===null||Array.isArray(n))return{TAG:"Error",_0:"progress_provider_identity_missing"};let r=n.threadId;if(typeof r!="string")return{TAG:"Error",_0:"progress_provider_identity_missing"};let i=n.turnId;return typeof i=="string"?r===e?yg(t,i):{TAG:"Error",_0:"progress_provider_thread_mismatch"}:{TAG:"Error",_0:"progress_provider_identity_missing"}}function VO(e,t){return e>=0&&t>=0&&t<=(65536-e|0)?{TAG:"Ok",_0:e+t|0}:{TAG:"Error",_0:"progress_pre_response_budget_exhausted"}}var ZO=N(()=>{});var YO,QO,XO,ex=N(()=>{ZO();YO=yg,QO=WO,XO=VO});var gg=N(()=>{Ni();we();qe()});var nx,rx,bg,vg=N(()=>{nx=[["codexThreadId","harness_session_id"],["codex_thread_id","harness_session_id"],["kandanThreadId","thread_id"],["kandan_preview_ticket","linzumi_preview_ticket"],["kandan_thread_id","thread_id"],["linzumiThreadId","thread_id"],["linzumi_thread_id","thread_id"],["local_codex_runner","commander"],["runnerId","commander_id"],["runner_config","commander_config"],["runner_id","commander_id"]],rx=[["commander","local_codex_runner"],["commander_config","runner_config"],["commander_id","runner_id"],["harness_session_id","codex_thread_id"],["linzumi_preview_ticket","kandan_preview_ticket"],["thread_id","kandan_thread_id"]],bg=[["engine_boot_reconnect","harness_boot_reconnect"],["engine_for_runner_event_type","harness_for_commander_event_type"],["engine_rejected_steer","harness_rejected_steer"],["engine_unavailable","harness_unavailable"],["join_engine","join_harness"],["kandan-local-codex-runner","linzumi-commander"],["local_codex_runner","commander"],["original_engine","original_harness"],["resume_engine","resume_harness"]]});function Sg(e){let t={};return e.forEach(n=>{t[n[0]]=n[1]}),t}function d4(e){let t={};return e.forEach(n=>{t[n[1]]=n[0]}),t}function ox(e){let t=e.slice();return e.forEach(n=>{let r=l4[n];r!==void 0&&!t.includes(r)&&t.push(r);let i=u4[n];if(i!==void 0&&!t.includes(i)){t.push(i);return}}),t}var l4,u4,s6e,d6e,ap=N(()=>{vg();l4=Sg(nx),u4=Sg(rx),s6e=Sg(bg),d6e=d4(bg)});var u6e,c6e,f6e,p6e,Bl=N(()=>{Ke();ss();qe();ap();u6e=ox(["access_token","authorization","code","cookie","kandan_preview_ticket","refresh_token","token"]),c6e=new RegExp("^(authorization|cookie|set-cookie|password|login[_-]?url|turnCapability|topicWakeTurnCapability|topic_wake_turn_capability|x-linzumi-agent-turn|mcpAuthFileContents|LINZUMI_CLOUD_MCP_AUTH_JSON)$","i"),f6e=new RegExp("(^|[_-])(access[_-]?token|api[_-]?key|auth[_-]?token|oauth[_-]?code|refresh[_-]?token|secret|token)$","i"),p6e=new RegExp("\\beyJ[A-Za-z0-9_-]*\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\b","g")});var lx=N(()=>{Ke();gg();it();Bl()});var ux=N(()=>{lx()});var ft=N(()=>{rt()});var cr=N(()=>{});function p4(e){try{let t=JSON.stringify(e);if(t===void 0)return null;try{return JSON.parse(t)}catch{return null}}catch{return null}}var zl,As=N(()=>{rt();Ke();we();qe();it();zl=p4});var cx,vo=N(()=>{we();Ue();ft();As();cx=zl({version:1,kind:"successful_no_answer"})});var Jl=N(()=>{cr();Ke();we();Ue();ft();As();vo()});var ai=N(()=>{Ke()});function up(e){try{let t=JSON.stringify(e);if(t===void 0)return{TAG:"Error",_0:"authored JSON serialization failed"};try{return{TAG:"Ok",_0:JSON.parse(t)}}catch(n){let r=Je(n);return{TAG:"Error",_0:"authored JSON parse failed: "+jt(r).message}}}catch(t){let n=Je(t);return{TAG:"Error",_0:"authored JSON serialization failed: "+jt(n).message}}}var g6e,ks=N(()=>{Ke();we();Ue();ft();it();vo();g6e=up({})});var cp=N(()=>{cr();Ke();we();Ue();ks()});var px=St((b6e,fx)=>{"use strict";var{Transform:h4}=ut("stream"),{StringDecoder:_4}=ut("string_decoder"),Ag=class extends h4{constructor(t){super(Object.assign({},t,{writableObjectMode:!1})),this._buffer=""}_transform(t,n,r){typeof t=="string"?this._transform=this._transformString:(this._stringDecoder=new _4,this._transform=this._transformBuffer),this._transform(t,n,r)}_transformBuffer(t,n,r){this._buffer+=this._stringDecoder.write(t),this._processBuffer(r)}_transformString(t,n,r){this._buffer+=t.toString(),this._processBuffer(r)}_processBuffer(t){this._buffer&&(this.push(this._buffer,"utf8"),this._buffer=""),t(null)}_flushInput(){this._stringDecoder&&(this._buffer+=this._stringDecoder.end())}_flush(t){this._flushInput(),this._processBuffer(t)}};fx.exports=Ag});var Vl=St((v6e,mx)=>{"use strict";var y4=px(),Ne={value1:/^(?:[\"\{\[\]\-\d]|true\b|false\b|null\b|\s{1,256})/,string:/^(?:[^\x00-\x1f\"\\]{1,256}|\\[bfnrt\"\\\/]|\\u[\da-fA-F]{4}|\")/,key1:/^(?:[\"\}]|\s{1,256})/,colon:/^(?:\:|\s{1,256})/,comma:/^(?:[\,\]\}]|\s{1,256})/,ws:/^\s{1,256}/,numberStart:/^\d/,numberDigit:/^\d{0,256}/,numberFraction:/^[\.eE]/,numberExponent:/^[eE]/,numberExpSign:/^[-+]/},g4=16,ln=!0;try{new RegExp(".","y"),ln=!1}catch{}!ln&&Object.keys(Ne).forEach(e=>{let t=Ne[e].source.slice(1);t.slice(0,3)==="(?:"&&t.slice(-1)===")"&&(t=t.slice(3,-1)),Ne[e]=new RegExp(t,"y")});Ne.numberFracStart=Ne.numberExpStart=Ne.numberStart;Ne.numberFracDigit=Ne.numberExpDigit=Ne.numberDigit;var b4={true:!0,false:!1,null:null},si={object:"objectStop",array:"arrayStop","":"done"},v4=e=>String.fromCharCode(parseInt(e.slice(2),16)),S4={b:"\b",f:"\f",n:`
|
|
133
|
+
`,r:"\r",t:" ",'"':'"',"\\":"\\","/":"/"},ma=class e extends y4{static make(t){return new e(t)}constructor(t){super(Object.assign({},t,{readableObjectMode:!0})),this._packKeys=this._packStrings=this._packNumbers=this._streamKeys=this._streamStrings=this._streamNumbers=!0,t&&("packValues"in t&&(this._packKeys=this._packStrings=this._packNumbers=t.packValues),"packKeys"in t&&(this._packKeys=t.packKeys),"packStrings"in t&&(this._packStrings=t.packStrings),"packNumbers"in t&&(this._packNumbers=t.packNumbers),"streamValues"in t&&(this._streamKeys=this._streamStrings=this._streamNumbers=t.streamValues),"streamKeys"in t&&(this._streamKeys=t.streamKeys),"streamStrings"in t&&(this._streamStrings=t.streamStrings),"streamNumbers"in t&&(this._streamNumbers=t.streamNumbers),this._jsonStreaming=t.jsonStreaming),!this._packKeys&&(this._streamKeys=!0),!this._packStrings&&(this._streamStrings=!0),!this._packNumbers&&(this._streamNumbers=!0),this._done=!1,this._expect=this._jsonStreaming?"done":"value",this._stack=[],this._parent="",this._open_number=!1,this._accumulator=""}_flush(t){this._done=!0,super._flush(n=>{if(n)return t(n);this._open_number&&(this._streamNumbers&&this.push({name:"endNumber"}),this._open_number=!1,this._packNumbers&&(this.push({name:"numberValue",value:this._accumulator}),this._accumulator="")),t(null)})}_processBuffer(t){let n,r,i=0;e:for(;;)switch(this._expect){case"value1":case"value":if(Ne.value1.lastIndex=i,n=Ne.value1.exec(this._buffer),!n){if(this._done||i+g4<this._buffer.length)return i<this._buffer.length?t(new Error("Parser cannot parse input: expected a value")):t(new Error("Parser has expected a value"));break e}switch(r=n[0],r){case'"':this._streamStrings&&this.push({name:"startString"}),this._expect="string";break;case"{":this.push({name:"startObject"}),this._stack.push(this._parent),this._parent="object",this._expect="key1";break;case"[":this.push({name:"startArray"}),this._stack.push(this._parent),this._parent="array",this._expect="value1";break;case"]":if(this._expect!=="value1")return t(new Error("Parser cannot parse input: unexpected token ']'"));this._open_number&&(this._streamNumbers&&this.push({name:"endNumber"}),this._open_number=!1,this._packNumbers&&(this.push({name:"numberValue",value:this._accumulator}),this._accumulator="")),this.push({name:"endArray"}),this._parent=this._stack.pop(),this._expect=si[this._parent];break;case"-":this._open_number=!0,this._streamNumbers&&(this.push({name:"startNumber"}),this.push({name:"numberChunk",value:"-"})),this._packNumbers&&(this._accumulator="-"),this._expect="numberStart";break;case"0":this._open_number=!0,this._streamNumbers&&(this.push({name:"startNumber"}),this.push({name:"numberChunk",value:"0"})),this._packNumbers&&(this._accumulator="0"),this._expect="numberFraction";break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":this._open_number=!0,this._streamNumbers&&(this.push({name:"startNumber"}),this.push({name:"numberChunk",value:r})),this._packNumbers&&(this._accumulator=r),this._expect="numberDigit";break;case"true":case"false":case"null":if(this._buffer.length-i===r.length&&!this._done)break e;this.push({name:r+"Value",value:b4[r]}),this._expect=si[this._parent];break}ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"keyVal":case"string":if(Ne.string.lastIndex=i,n=Ne.string.exec(this._buffer),!n){if(i<this._buffer.length&&(this._done||this._buffer.length-i>=6))return t(new Error("Parser cannot parse input: escaped characters"));if(this._done)return t(new Error("Parser has expected a string value"));break e}if(r=n[0],r==='"')this._expect==="keyVal"?(this._streamKeys&&this.push({name:"endKey"}),this._packKeys&&(this.push({name:"keyValue",value:this._accumulator}),this._accumulator=""),this._expect="colon"):(this._streamStrings&&this.push({name:"endString"}),this._packStrings&&(this.push({name:"stringValue",value:this._accumulator}),this._accumulator=""),this._expect=si[this._parent]);else if(r.length>1&&r.charAt(0)==="\\"){let o=r.length==2?S4[r.charAt(1)]:v4(r);(this._expect==="keyVal"?this._streamKeys:this._streamStrings)&&this.push({name:"stringChunk",value:o}),(this._expect==="keyVal"?this._packKeys:this._packStrings)&&(this._accumulator+=o)}else(this._expect==="keyVal"?this._streamKeys:this._streamStrings)&&this.push({name:"stringChunk",value:r}),(this._expect==="keyVal"?this._packKeys:this._packStrings)&&(this._accumulator+=r);ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"key1":case"key":if(Ne.key1.lastIndex=i,n=Ne.key1.exec(this._buffer),!n){if(i<this._buffer.length||this._done)return t(new Error("Parser cannot parse input: expected an object key"));break e}if(r=n[0],r==='"')this._streamKeys&&this.push({name:"startKey"}),this._expect="keyVal";else if(r==="}"){if(this._expect!=="key1")return t(new Error("Parser cannot parse input: unexpected token '}'"));this.push({name:"endObject"}),this._parent=this._stack.pop(),this._expect=si[this._parent]}ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"colon":if(Ne.colon.lastIndex=i,n=Ne.colon.exec(this._buffer),!n){if(i<this._buffer.length||this._done)return t(new Error("Parser cannot parse input: expected ':'"));break e}r=n[0],r===":"&&(this._expect="value"),ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"arrayStop":case"objectStop":if(Ne.comma.lastIndex=i,n=Ne.comma.exec(this._buffer),!n){if(i<this._buffer.length||this._done)return t(new Error("Parser cannot parse input: expected ','"));break e}if(this._open_number&&(this._streamNumbers&&this.push({name:"endNumber"}),this._open_number=!1,this._packNumbers&&(this.push({name:"numberValue",value:this._accumulator}),this._accumulator="")),r=n[0],r===",")this._expect=this._expect==="arrayStop"?"value":"key";else if(r==="}"||r==="]"){if(r==="}"?this._expect==="arrayStop":this._expect!=="arrayStop")return t(new Error("Parser cannot parse input: expected '"+(this._expect==="arrayStop"?"]":"}")+"'"));this.push({name:r==="}"?"endObject":"endArray"}),this._parent=this._stack.pop(),this._expect=si[this._parent]}ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"numberStart":if(Ne.numberStart.lastIndex=i,n=Ne.numberStart.exec(this._buffer),!n){if(i<this._buffer.length||this._done)return t(new Error("Parser cannot parse input: expected a starting digit"));break e}r=n[0],this._streamNumbers&&this.push({name:"numberChunk",value:r}),this._packNumbers&&(this._accumulator+=r),this._expect=r==="0"?"numberFraction":"numberDigit",ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"numberDigit":if(Ne.numberDigit.lastIndex=i,n=Ne.numberDigit.exec(this._buffer),!n){if(i<this._buffer.length||this._done)return t(new Error("Parser cannot parse input: expected a digit"));break e}if(r=n[0],r)this._streamNumbers&&this.push({name:"numberChunk",value:r}),this._packNumbers&&(this._accumulator+=r),ln?this._buffer=this._buffer.slice(r.length):i+=r.length;else{if(i<this._buffer.length){this._expect="numberFraction";break}if(this._done){this._expect=si[this._parent];break}break e}break;case"numberFraction":if(Ne.numberFraction.lastIndex=i,n=Ne.numberFraction.exec(this._buffer),!n){if(i<this._buffer.length||this._done){this._expect=si[this._parent];break}break e}r=n[0],this._streamNumbers&&this.push({name:"numberChunk",value:r}),this._packNumbers&&(this._accumulator+=r),this._expect=r==="."?"numberFracStart":"numberExpSign",ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"numberFracStart":if(Ne.numberFracStart.lastIndex=i,n=Ne.numberFracStart.exec(this._buffer),!n){if(i<this._buffer.length||this._done)return t(new Error("Parser cannot parse input: expected a fractional part of a number"));break e}r=n[0],this._streamNumbers&&this.push({name:"numberChunk",value:r}),this._packNumbers&&(this._accumulator+=r),this._expect="numberFracDigit",ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"numberFracDigit":if(Ne.numberFracDigit.lastIndex=i,n=Ne.numberFracDigit.exec(this._buffer),r=n[0],r)this._streamNumbers&&this.push({name:"numberChunk",value:r}),this._packNumbers&&(this._accumulator+=r),ln?this._buffer=this._buffer.slice(r.length):i+=r.length;else{if(i<this._buffer.length){this._expect="numberExponent";break}if(this._done){this._expect=si[this._parent];break}break e}break;case"numberExponent":if(Ne.numberExponent.lastIndex=i,n=Ne.numberExponent.exec(this._buffer),!n){if(i<this._buffer.length){this._expect=si[this._parent];break}if(this._done){this._expect="done";break}break e}r=n[0],this._streamNumbers&&this.push({name:"numberChunk",value:r}),this._packNumbers&&(this._accumulator+=r),this._expect="numberExpSign",ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"numberExpSign":if(Ne.numberExpSign.lastIndex=i,n=Ne.numberExpSign.exec(this._buffer),!n){if(i<this._buffer.length){this._expect="numberExpStart";break}if(this._done)return t(new Error("Parser has expected an exponent value of a number"));break e}r=n[0],this._streamNumbers&&this.push({name:"numberChunk",value:r}),this._packNumbers&&(this._accumulator+=r),this._expect="numberExpStart",ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"numberExpStart":if(Ne.numberExpStart.lastIndex=i,n=Ne.numberExpStart.exec(this._buffer),!n){if(i<this._buffer.length||this._done)return t(new Error("Parser cannot parse input: expected an exponent part of a number"));break e}r=n[0],this._streamNumbers&&this.push({name:"numberChunk",value:r}),this._packNumbers&&(this._accumulator+=r),this._expect="numberExpDigit",ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break;case"numberExpDigit":if(Ne.numberExpDigit.lastIndex=i,n=Ne.numberExpDigit.exec(this._buffer),r=n[0],r)this._streamNumbers&&this.push({name:"numberChunk",value:r}),this._packNumbers&&(this._accumulator+=r),ln?this._buffer=this._buffer.slice(r.length):i+=r.length;else{if(i<this._buffer.length||this._done){this._expect=si[this._parent];break}break e}break;case"done":if(Ne.ws.lastIndex=i,n=Ne.ws.exec(this._buffer),!n){if(i<this._buffer.length){if(this._jsonStreaming){this._expect="value";break}return t(new Error("Parser cannot parse input: unexpected characters"))}break e}r=n[0],this._open_number&&(this._streamNumbers&&this.push({name:"endNumber"}),this._open_number=!1,this._packNumbers&&(this.push({name:"numberValue",value:this._accumulator}),this._accumulator="")),ln?this._buffer=this._buffer.slice(r.length):i+=r.length;break}!ln&&(this._buffer=this._buffer.slice(i)),t(null)}};ma.parser=ma.make;ma.make.Constructor=ma;mx.exports=ma});var w4,kg=N(()=>{Ke();it();w4=ei(Vl(),1)});var pp=N(()=>{Ke();we();Ue();ft();ai();vo();cp();kg();ks()});var Rr=N(()=>{Ke();Ue();ft();Jl();pp()});var Og=N(()=>{Rr()});var gx=N(()=>{});var bx=N(()=>{rt();bf();qe()});function Ns(e){let t=0;for(;;){let n=t,r=e[n];if(r===void 0)return'"'+e+'"';switch(r){case'"':case`
|
|
134
134
|
`:return JSON.stringify(e);default:t=n+1|0;continue}}}function M4(e){return e===""?[]:JSON.parse(e.split('"]["').join('","'))}function D4(e){return"["+Ns(e)+"]"}function $4(e){let t=e.length;return t!==1?t!==0?e.map(D4).join(""):"":"["+Ns(e[0])+"]"}function L4(e){return e.type===fr?!0:e.type===Pr?fr in e.has:!1}function G4(e,t){return(e&t)!==0}function bp(e){let t=Rt[typeof e];if(t&16)return fr;if(!(t&64))return t&2?'"'+e+'"':t&1024?e+"n":t&4096?"Function":e.toString();if(e===null)return Rs;if(Array.isArray(e)){let i="[";for(let o=0,a=e.length;o<a;++o)o!==0&&(i=i+", "),i=i+bp(e[o]);return i+"]"}if(e.constructor!==Object)return Object.prototype.toString.call(e);let n=Object.keys(e),r="{ ";for(let i=0,o=n.length;i<o;++i){let a=n[i],s=e[a];r=r+a+": "+bp(s)+"; "}return r+"}"}function Vt(e){let t=e.type,n=e.to,r=e.const,i=e.name;if(i!==void 0)return i;if(r!==void 0)return bp(r);let o=e.format,a=e.anyOf;if(a!==void 0)return a.map(Vt).join(" | ");if(o!==void 0){if(o!=="compactColumns")return o;let s=e.additionalItems;if(n===void 0)return s!==void 0&&s!=="strip"&&s!=="strict"?Vt(s)+"[]":"unknown[][]";let d=n.properties;return d===void 0?"unknown[][]":"["+Object.keys(d).map(u=>{let c=d[u];return Vt(c)+"[]"}).join(", ")+"]"}switch(t){case"nan":return"NaN";case"object":let s=e.additionalItems,d=e.properties,l=Object.keys(d);return l.length===0?typeof s===tn?"{ [key: string]: "+Vt(s)+"; }":"{}":"{ "+l.map(u=>u+": "+Vt(d[u])+";").join(" ")+" }";default:if(e.b)return t;switch(t){case"instance":return e.class.name;case"array":let u=e.additionalItems,c=e.items;if(typeof u!==tn)return"["+c.map(Vt).join(", ")+"]";let p=Vt(u);return(u.type===Pr?"("+p+")":p)+"[]";default:return t}}}function Cp(e){if(e&&e.s===Gg)return e;throw e}function Ex(e){let t=e.path;return(t===""?"":"Failed at "+t+": ")+e.reason}function Qt(e,t){let n=new Bg;return n.type=e,n.seq=Cx++,t&&(li[Ps]=n,Zn(n,_a,li)),n}function Ox(e){return e}function ko(e,t,n){if(xg[e])return xg[e];let r=Qt(t,!0);return n(r),xg[e]=r,r}function To(e,t){let n=Ir(e),r=n;for(;r.to;){let i=Ir(r.to);r.to=i,r=i}return t(r),n}function ui(e,t){let n=e.g.e,r=n.length;return n[r]=t,"e["+r+"]"}function ru(e,t){let n=Rt[t.type],r=t.const;return n&16?"void 0":n&2?Ns(r):n&1024?r+"n":n&28672?ui(e,t.const):r}function ga(e,t){let n='"'+t+'"',r=e[n];if(r!==void 0)return r;let i=Ns(t);return e[n]=i,i}function Cn(){return this.i}function F4(){return this.b.v()}function q4(){return this.prev.v()}function Fn(e){let t=e.v+1;return e.v=t,"v"+t}function vp(e,t){e.hd=e.hd===""?t:e.hd+","+t}function U4(){let e=this,t=Fn(e.g);return e.cp="let "+t+"="+e.i+";",e.i=t,e.v=Cn,t}function $g(){let e=this,t=e.p;if(t.fz)return e.v=Cn,e.i;let n=Fn(e.g);return vp(t,n+"="+e.i),e.v=Cn,e.i=n,n}function Sp(){let e=this;if(e.fz)return e.v=Cn,e.i="("+e.i+")",e.i;let t=Fn(e.g);if(e.prev!==void 0){let r=e.i;r===""?e.cp="let "+t+";"+e.cp:e.cp=e.cp+("let "+t+"="+r+";")}else{let r=e.i;r===""?vp(e,t):vp(e,t+"="+r)}return e.v=Cn,e.i=t,t}function B4(e,t,n,r){return{v:Cn,i:"i",s:e,e:t,f:0,cp:"",hd:"",path:"",g:{v:-1,o:n,e:[],d:r}}}function va(e,t,n){let r=e.path,i="Can't decode "+Vt(t)+" to "+Vt(n)+". Use S.to to define a custom decoder",o={code:"unsupported_decode",path:r,reason:i,from:t,to:n};throw new ya(o)}function Yl(e,t,n){return ui(e,r=>{let i=t(r);throw new ya(i)})+"("+n+")"}function xx(e,t,n,r,i,o,a){let s=a!==void 0?a:"Expected "+Vt(e)+", received "+(i?bp(r):Vt(t));if(o!==void 0){let l={};for(let u=0,c=o.length;u<c;++u){let p=o[u],m=p.reason.split(`
|
|
135
135
|
`).join(`
|
|
136
136
|
`),y=p.path,b=`
|
|
137
137
|
- `+(y===""?"":"At "+y+": ")+m;l[b]||(l[b]=1,s=s+b)}}let d={code:"invalid_input",path:n,reason:s,expected:e,received:t,unionErrors:o};return i&&(d.input=r),d}function Kg(e,t,n,r){return i=>{let o=t!==void 0?t:"",a=r!==void 0?r:!0,s=e!==void 0?e:i.e,d=i.prev,l=d!==void 0?d.s:i.s,u=o===""?i.path:i.path+o;return c=>xx(s,l,u,c,a,void 0,n)}}function un(e){let t=e.e.errorMessage,n;if(t!==void 0){let r=t.type;n=r!==void 0?r:t._}else n=void 0;return Kg(void 0,void 0,n,void 0)(e)}function Rx(e,t){let n=t!==void 0?t:e.e;return Yl(e,Kg(n,void 0,void 0,void 0)(e),e.v())}function z4(e,t){let n=e.vc,r=n.length;if(r===1){let a=n[0];return a.c(t)+"||"+Yl(e,a.f(e),t)+";"}let i="",o=0;for(;o<r;){let a=n[o],s=a.f,d=a.c(t);for(o=o+1|0;o<r&&n[o].f===s;)d=d+"&&"+n[o].c(t),o=o+1|0;i=i+(d+"||"+Yl(e,s(e),t)+";")}return i}function Px(e){return e.t===!0?e.prev.t!==!0?e.cp==="":!1:!0}function ci(e,t){let n=e,r="";for(;n!==void 0;){let i=n;n=i.prev;let o="";if(i.vc)if(t!==void 0&&Px(i)){let s=n.v(),d=i.vc,l="";for(let u=0,c=d.length;u<c;++u){let p=d[u],m=p.c(s);p.f===un?l=l?l+"&&"+m:m:i.e.noValidation!==!0&&(o=o+(m+"||"+Yl(i,p.f(i),s)+";"))}l&&(t.contents?t.contents=l+"&&"+t.contents:t.contents=l)}else i.e.noValidation!==!0&&(o=z4(i,n.v()));i.hd!==""&&(o=o+("let "+i.hd+";")),i.fz=!0,o=i.cp+o,r=o+r}return r}function pr(e,t,n,r){let i=r!==void 0?r:e.e;return{v:Sp,i:t,s:n,e:i,prev:e,f:0,d:e.d,cp:"",hd:"",t:!0,path:e.path,g:e.g}}function Xe(e,t,n,r){let i=t!==void 0?t:e.s,o=r!==void 0?r:e.e,a=e.v!==Cn,s={v:a?q4:Cn,i:e.i,s:i,e:o,prev:e,f:e.f,d:e.d,cp:"",hd:"",vc:n,t:e.t,path:e.path,g:e.g};if(a){let d=e.v.bind(e);e.v=()=>{let l=d();return s.i=l,s.v=Cn,l}}return s}function Hg(e,t){let n=e.vc;n!==void 0?n.push(t):e.vc=[t]}function Ql(e,t){let n=t.e.inputRefiner,r;if(n!==void 0){let s=n(t);if(s.length!==0)if(t.prev!==void 0){for(let l=0,u=s.length;l<u;++l)Hg(t,s[l]);r=void 0}else r=s;else r=void 0}else r=void 0;let i=e.e.refiner,o;if(i!==void 0){let s=i(e);o=s.length!==0?s:void 0}else o=void 0;let a=r!==void 0?o!==void 0?Xe(e,void 0,r.concat(o),void 0):Xe(e,void 0,r,void 0):o!==void 0?Xe(e,void 0,o,void 0):e;return a.io=!0,a}function Ix(e,t,n){if(!t.vc)return;let i="["+ga(e.g,n)+"]";t.vc.forEach(o=>Hg(e,{c:a=>o.c(a+i),f:o.f})),t.vc=void 0}function Mx(e,t){let n=e.s.additionalItems,r;r=n!==void 0&&n!=="strip"&&n!=="strict"?n:xt;let i=e.e.additionalItems,o;return o=i!==void 0&&i!=="strip"&&i!=="strict"?i:xt,{p:e,v:U4,i:e.v()+"["+t+"]",s:r,e:o,f:e.f,cp:"",hd:"",path:"",g:e.g}}function So(e,t,n){return pr(e,ru(e,t),t,n)}function Dx(e,t){let n=pr(e,t,e.s,void 0);return n.f=1,n}function fi(e,t,n){e.s.type===Ki?e.s.items.push(n.s):(n.o||e.s.required.push(t),e.s.properties[t]=n.s),n.f&1&&n.v(),e.cp=e.cp+ci(n,void 0),e.d[t]=n}function $x(e,t,n){return e.v()+"["+t+"]="+n.i}function Hi(e){let t=e.v!==Cn,n={b:e,v:t?F4:Cn,i:e.i,s:e.s,io:e.io,e:e.e,f:0,d:e.d,cp:"",hd:"",u:!1,t:!1,path:e.path,g:e.g};if(t){let r=e.v.bind(e);e.v=()=>{let i=r();return n.i=i,n.v=Cn,i}}return n}function K4(e,t){throw new ya({code:"invalid_operation",path:e.path,reason:t})}function Jg(e,t,n,r){if(e.path===""&&n===void 0)return ci(e,void 0);{let i=d=>{let l=t.path,u=l===""?"":Ns(l)+"+";return d+".path="+u+(n!==void 0?`'["'+`+n+`+'"]'+`:"")+d+".path"},o=ci(e,void 0);if(o===""&&!(e.f&1))return o+(r!==void 0?r():"");let a=Fn(e.g),s=i(a)+";throw "+a;return e.f&1&&(e.i=e.i+".catch("+a+"=>{"+s+"})"),"try{"+o+(r!==void 0?r():"")+"}catch("+a+"){"+s+"}"}}function Nx(e){return e}function Rg(e){return e+"<=2147483647&&"+e+">=-2147483648&&"+e+"%1===0"}function Is(e){return t=>"typeof "+t+'==="'+e+'"'}function Os(e){return"Number.isNaN("+e+")"}function wp(e){return"Array.isArray("+e+")"}function jx(e){return Is(tn)(e)+"&&"+e}function H4(e,t){return n=>n+" instanceof "+ui(e,t)}function J4(e){let t=Rt[e.s.type];if(t&1){let i=[{c:Is(wo),f:un}],o=e.e.format,a=0;return o==="int32"?i.push({c:Rg,f:un}):a=1,a===1&&(e.g.o&2||i.push({c:s=>"!"+Os(s),f:un})),Xe(e,e.e,i,void 0)}if(!(t&2))return t&4?e.s.format!==e.e.format&&e.e.format==="int32"?Xe(e,e.e,[{c:Rg,f:un}],void 0):e:va(e,e.s,e.e);let n=Fn(e.g),r=pr(e,n,e.e,void 0);return r.v=Cn,r.cp="let "+n+"=+"+e.v()+";",r.vc=[{c:i=>{let o=e.e.format;return o!==void 0&&o==="int32"?Rg(n):"!"+Os(n)},f:un}],r}function Wg(){return ko(wo,wo,e=>{e.decoder=J4})}function W4(e){return pr(e,'""+'+e.i,js(),void 0)}function V4(e){let t=Rt[e.s.type];if(t&1)return Xe(e,e.e,[{c:Is(xs),f:un}],void 0);if(!(t&3132&&pi in e.s))return t&1036?W4(e):t&2?e:va(e,e.s,e.e);let n=""+e.s.const,r=Qt(xs,!1);return r.const=n,pr(e,'"'+n+'"',r,void 0)}function js(){return ko(xs,xs,e=>{e.decoder=V4})}function Z4(e){let t=Rt[e.s.type];if(t&1)return Xe(e,e.e,[{c:Is(gp),f:un}],void 0);if(!(t&2))return t&8?e:va(e,e.s,e.e);let n=Fn(e.g),r=pr(e,n,e.e,void 0);r.v=Cn;let i=e.v();return r.cp="let "+n+";("+r.i+"="+i+'==="true")||'+i+'==="false"||'+Rx(e,void 0)+";",r}function Vg(){return ko(gp,gp,e=>{e.decoder=Z4})}function Lx(e,t){e[Rt[t]&768?tu:t]=!0}function Ms(e){let t=e.e;if(t.noValidation&&!e.u)return So(e,t,void 0);if(pi in e.s)return e.s.const===t.const?e:So(e,t,void 0);let n=Rt[t.type];if(!(Rt[e.s.type]&2&&n&3132))return n&2048?Xe(e,t,[{c:Os,f:un}],void 0):Xe(e,t,[{c:o=>o+"==="+ru(e,t),f:un}],void 0);let r=Qt(xs,!1);r.const=""+t.const;let i=So(e,r,r);return i.vc=[{c:o=>o+'==="'+r.const+'"',f:un}],So(i,t,t)}function Co(){return ko(fr,fr,e=>{e.const=void 0,e.decoder=Ms})}function iu(){return ko(Rs,Rs,e=>{e.const=null,e.decoder=Ms})}function Gx(){return ko(Ig,Ig,e=>{e.const=NaN,e.decoder=Ms})}function Zg(e){if(e===null)return iu();let t=typeof e;if(t===fr)return Co();if(t===wo&&Number.isNaN(e))return Gx();if(t===tn){let r=Qt(qg,!0);return r.class=e.constructor,r.const=e,r.decoder=Ms,r}let n=Qt(t,!0);return n.const=e,n.decoder=Ms,n}function Gt(e){let t=e,n,r=0;for(;!t.io||t.e.to;){let i=n;n=void 0;let o=t;if(r=r+1|0,r>50)throw new Error("Loop count exceeded 100");if(o.e.$defs&&(o.g.d?Object.assign(o.g.d,o.e.$defs):o.g.d=o.e.$defs),o.f&1){let a=o.v(),s=Hi(o),d=Gt(s),l=ci(d,void 0);t=s.i!==d.i||l!==""?pr(o,a+".then("+a+"=>{"+l+"return "+d.i+"})",d.s,d.e):Xe(o,d.s,void 0,d.e),t.f=t.f|1,t.io=!0}else if(o.io){let a=o.e.to,d=o.e.parser;t=d!==void 0?d(o):Xe(t,void 0,void 0,a)}else{let a=o.s.encoder;a&&a!==i&&o.s!==o.e&&o.e.type!==tu&&(t=a(o,o.e)),o!==t?n=a:(t=o.e.decoder(o),t.io||(t=Ql(t,t)))}}return t}function Ao(e){for(;;){let t=e,n=t.to;if(n===void 0)return t;e=n}}function zi(e){if(_a in e)return e[_a];let t,n=e;for(;n;){let i=Ir(n),o=i.to,a=t;a!==void 0?i.to=a:delete i.to;let s=i.parser,d=i.serializer;d!==void 0?i.parser=d:delete i.parser,s!==void 0?i.serializer=s:delete i.serializer;let l=i.refiner,u=i.inputRefiner;u!==void 0?i.refiner=u:delete i.refiner,l!==void 0?i.inputRefiner=l:delete i.inputRefiner;let c=i.fromDefault,p=i.default;p!==void 0?i.fromDefault=p:delete i.fromDefault,c!==void 0?i.default=c:delete i.default;let m=i.items;m!==void 0&&(i.items=m.map(zi));let y=i.properties;if(y!==void 0){let g={},S=Object.keys(y);for(let v=0,T=S.length;v<T;++v){let C=S[v];g[C]=zi(y[C])}i.properties=g}typeof i.additionalItems===tn&&(i.additionalItems=zi(i.additionalItems));let h=i.anyOf;if(h!==void 0){let g={},S=[];for(let v=0,T=h.length;v<T;++v){let C=h[v],O=zi(C);S.push(O),Lx(g,O.type)}i.has=g,i.anyOf=S}let b=i.$defs;if(b!==void 0){let g={};for(let S=0,v=Object.keys(b).length;S<v;++S){let T=Object.keys(b)[S];g[T]=zi(b[T])}i.$defs=g}t=i,n=o}let r=t;return li[Ps]=r,Zn(e,_a,li),li[Ps]=e,Zn(r,_a,li),r}function Fx(e){try{return Gt(e)}catch(t){let n=Cp(t),r=e.p;throw n.path=(r!==void 0?r.path:"")+(e.path+"[]"+n.path),n}}function qx(e,t,n,r){let i=B4(pi in e?xt:e,t,n,r),o=Gt(i),a=ci(o,void 0),s=G4(o.f,1);t.isAsync=s;let d=o.t===!0;if(t.hasTransform=d,a===""&&(o===i||o.i===i.i)&&!(n&1))return Nx;let l=o.i;n&1&&!s&&!r&&(l="Promise.resolve("+l+")");let u="i=>{"+a+"return "+l+"}",c=i.g.e,p=new Function("e","s","return "+u)(c,Gg);return p.embedded=i.g.e,p}function Tp(e,t){let n=arguments,r=0,i,o="",a=0,s;for(;i===void 0;){let l=n[r];if(l)if(typeof l===wo){let u=l|Zl.f;i=u,o=o+"-"+u}else{let u=l.seq;u>a&&(a=u,s=l),o=o+u+"-",r=r+1|0}else{let u=Zl.f;i=u,o=o+"-"+u}}let d=s;if(d!==void 0){let l=o;if(l in d)return d[l];let u=n[r-1|0];for(let p=r-2|0;p>=0;--p){let m=u;u=To(n[p],y=>{y.to=m})}let c=qx(u,u,i,0);return li[Ps]=c,Zn(d,l,li),c}throw new Error("[Sury] No schema provided for decoder.")}function Y4(e){let t=Xe(e,void 0,void 0,Yg());return t.cp=Rx(e,void 0)+";",t}function Yg(){return ko(Mg,Mg,e=>{e.decoder=Y4})}function Q4(e){let t=e.e.to;return pr(e,"{"+ba+":"+Ao(e.e).properties[ba].const+"}",t,t)}function Ds(e,t){return{v:Sp,i:"",s:t.type===Ki?{type:Ki,decoder:ou,additionalItems:"strict",items:[]}:{type:tn,decoder:Ls,additionalItems:"strict",required:[],properties:{}},e:e.e,prev:e,f:0,d:{},cp:"",hd:"",t:!0,path:e.path,g:e.g}}function Qg(e){return Ep(e,Co())}function Ls(e){let t=e.u,n=e.e,r=Rt[e.s.type],i;if(r&65){let u=r&64,c;if(u)c=e.s;else{let m=Qt(tn,!1);m.properties=jg,m.additionalItems=xt,c=m}let p=[];u||(p.push({c:jx,f:un}),n.additionalItems!=="strip"&&p.push({c:m=>"!"+wp(m),f:un})),i=p.length!==0?Xe(e,c,p,void 0):Xe(e,c,void 0,void 0)}else i=va(e,e.s,n);let o=n.additionalItems,a;a=o==="strip"||o==="strict"?void 0:o;let s=i.s.additionalItems,d;d=s!=="strip"&&s!=="strict";let l;if(a!==void 0)if(a===xt)l=i;else if(d){let u=i.v(),c=Fn(i.g),p=Mx(i,c),m=Fx(p),y=m.t,h=y?pr(i,"{}",n,void 0):Xe(i,n,void 0,void 0),b=Jg(m,i,c,y?()=>$x(h,c,m):void 0);if((y||b!=="")&&(h.cp=h.cp+("for(let "+c+" in "+u+"){"+b+"}")),m.f&1){let g=Fn(h.g),S=Fn(h.g),v=Fn(h.g),T=Fn(h.g),C=h.v();l=Dx(h,"new Promise(("+g+","+S+")=>{let "+T+"=Object.keys("+C+").length;for(let "+c+" in "+C+"){"+C+"["+c+"].then("+v+"=>{"+C+"["+c+"]="+v+";if("+T+"--===1){"+g+"("+C+")}},"+S+")}})")}else l=h}else{let u=Ds(i,n),c=Object.keys(i.s.properties);for(let p=0,m=c.length;p<m;++p){let y=c[p],h=Xl(i,y);h.e=a,h.io=!1,h.u=t,fi(u,y,Gt(h))}l=$s(u)}else{let u=n.properties,c=Object.keys(u),p=c.length,m=Ds(i,n),y=n.additionalItems,h;h=y==="strip"||y==="strict"?y==="strip"?d||Object.keys(i.s.properties).length!==p:!1:!0;let b=i.s.additionalItems,g;g=b==="strip"||b==="strict"?!1:b.name===ha;for(let v=0;v<p;++v){let T=c[v],C=u[T],O=Xl(i,T);O.e=C,O.io=!1,O.u=t,g&&C.type===Pr&&C.has[fr]&&(O.i="("+O.i+"??null)");let _=Gt(O);t&&pi in C&&Ix(i,_,T),fi(m,T,_),h||(h=_.t)}let S=!1;if(n.additionalItems==="strict"){let v=i.s.additionalItems,T;T=v!=="strip"&&v!=="strict",S=T}if(S){let v=Fn(m.g);if(vp(i,v),m.cp=m.cp+("for("+v+" in "+i.v()+"){if("),c.length!==0)for(let T=0,C=c.length;T<C;++T){let O=c[T];T!==0&&(m.cp=m.cp+"&&"),m.cp=m.cp+(v+"!=="+ga(i.g,O))}else m.cp=m.cp+"true";m.cp=m.cp+("){"+Yl(i,T=>({code:"unrecognized_keys",path:m.path,reason:'Unrecognized key "'+T+'"',keys:[T]}),v)+"}}")}if(h)l=$s(m);else{let v=Xe(i,void 0,void 0,void 0);v.cp=m.cp,v.d=m.d,l=v}}return Ql(l,i)}function X4(){let e=Zg(0),t={};return t[ba]=e,{type:tn,serializer:n=>{let r=n.e.to;return So(n,r,r)},decoder:Ls,additionalItems:"strip",required:[ba],properties:t}}function ou(e){let t=e.u,n=e.e,r=Rt[e.s.type],i=n.items,o=i.length,a;if(r&129){let u=r&128,c=u?e.s:au(xt),p=[];u||p.push({c:wp,f:un});let m=c.additionalItems,y;if(y=m==="strip"||m==="strict"?c.items.length===o:!1,!y){let h=n.additionalItems;(h==="strip"||h==="strict")&&(h==="strip"?p.push({c:b=>b+".length>="+o,f:un}):p.push({c:b=>b+".length==="+o,f:un}))}a=p.length!==0?Xe(e,c,p,void 0):Xe(e,c,void 0,void 0)}else a=va(e,e.s,n);let s=n.additionalItems,d,l=0;if(s==="strip"||s==="strict")l=1;else if(s===xt)d=a;else{let u=a.v(),c=Fn(a.g),p=Mx(a,c),m=Fx(p),y=m.t,h=y?pr(a,"new Array("+u+".length)",n,void 0):Xe(a,n,void 0,void 0),b=Jg(m,a,c,y?()=>$x(h,c,m):void 0);(y||b!=="")&&(h.cp=h.cp+("for(let "+c+"="+o+";"+c+"<"+u+".length;++"+c+"){"+b+"}")),d=m.f&1?Dx(h,"Promise.all("+h.i+")"):h}if(l===1){let u=Ds(a,n),c=n.additionalItems,p;if(c==="strip"||c==="strict")if(c==="strip"){let m=a.s.additionalItems;p=m==="strip"||m==="strict"?a.s.items.length!==o:!0}else p=!1;else p=!0;for(let m=0;m<o;++m){let y=i[m],h=m.toString(),b=Xl(a,h);b.e=y,b.io=!1,b.u=t;let g=Gt(b);t&&pi in y&&Ix(a,g,h),fi(u,h,g),p||(p=g.t)}if(p)d=$s(u);else{let m=Xe(a,void 0,void 0,void 0);m.cp=u.cp,m.d=u.d,d=m}}return Ql(d,a)}function eV(e,t){let n=e.s.anyOf;return t.type===Pr&&Kx(t)===void 0&&Bx(t.anyOf,n)||!tV(n,t)?e:zx(e,t)}function Ux(e){let t=e.e,n=t.anyOf,r=Rt[e.s.type],i=Kx(t);if(e.s===t&&i===void 0&&n.every(_p)||r&256&&Bx(n,e.s.anyOf)&&i===void 0||e.io&&e.e===e.s)return e;(r&256||e.s.encoder===void 0&&r&512)&&(e.s=xt);let o="";if(!(r&769)){let M=Pg(e.s),q=!1,ee=!1,Q=n.length,te=0;for(;o===""&&te<Q;){let Y=n[te];Pg(Y)===M?o=M:Y.type===Rs?q=!0:Y.type===fr&&(ee=!0),te=te+1|0}o===""&&(r&16&&q?o=Rs:r&32&&ee&&(o=fr))}let a=o,s=e.i,d=M=>ui(e,function(){let q=arguments,ee=xx(t,xt,e.path,q[0],!0,q.length>1?Array.from(q).slice(1):void 0,void 0);throw new ya(ee)})+"("+e.v()+M+")",l=Xe(e,void 0,void 0,void 0),u=[],c={contents:""},p=(M,q)=>{let ee=M[0],Q=M[1],te="",Y="",L=!1,$={contents:""},K="",G={},R=2,D=M.length-1|0;for(;R<=D;){let z=Hi(Q);z.u=!0,z.t=Q.t,z.io=!1,z.e=M[R];let V=R===D,X=R===2,le=X&&V,me=!le,Ee=!1,F="",U={contents:""};try{let oe=Gt(z);if(u.push(oe.s),F=ci(oe,U),oe.t){l.t=!0,oe.f&1&&(l.f=l.f|1);let Se=ee.v();oe.i!==Se&&(F=F+(Se+"="+oe.i))}}catch(oe){let Se=ui(z,Cp(oe));K=K+","+Se,q&&le?(c.contents=Se,Ee=!0):V?(me=!1,F=q?"throw "+Se:d(K)):Ee=!0}let H=U.contents,ne=F;if(!Ee&&H)if(ne){let oe=G[H];oe!==void 0?typeof oe=="string"?G[H]=[oe,ne]:oe.push(ne):G[H]=ne}else $.contents=$.contents?$.contents+"||"+H:H;if(!Ee&&(!H||V)){let oe=Object.keys(G);for(let Se=0,At=oe.length;Se<At;++Se){let en=oe[Se];te=te+(L?"else if":"if")+("("+en+"){");let kt=G[en];if(typeof kt=="string")te=te+kt+"}";else{let $t="";for(let jn=0,wn=kt.length;jn<wn;++jn){let Xo=kt[jn],Qr="e"+jn;te=te+("try{"+Xo+"}catch("+Qr+"){"),$t=$t+","+Qr}te=te+d($t)+"}".repeat(kt.length)+"}"}L=!0}G={}}if(!Ee&&!H)if(ne)if($.contents&&(te=te+(L?"else if":"if")+("(!("+$.contents+")){"),Y="}"+Y,$.contents="",L=!1),V&&(q||!me||X))te=te+((L?"else{":"")+ne),Y=(L?"}":"")+Y;else{let oe="e"+(R-2|0);te=te+((L?"else{":"")+"try{"+ne+"}catch("+oe+"){"),Y=(L?"}":"")+"}"+Y,K=K+","+oe,L=!1}else $.contents="",R=D,me=!1;if(V){if($.contents)te||K?te=te+(L?"else if":"if")+("(!("+$.contents+")){"+d(K)+"}"):Hg(Q,{c:oe=>"("+$.contents+")",f:un});else if(me){let oe=d(K);te=te+(L?"else{"+oe+"}":oe)}}R=R+1}return te+Y},m="",y="",h="",b=!1,g=n.length-1|0,S={},v=[],T=t.refiner,C=t.inputRefiner,O={contents:void 0},_={contents:void 0},w=(M,q,ee)=>{if(q===void 0)return M;let Q=te=>{let Y=ee.contents;if(Y!==void 0)return Y;let L=q(te);return ee.contents=L,L};return M!==void 0?te=>{let Y=M(te),L=Q(te);for(let $=0,K=L.length;$<K;++$)Y.push(L[$]);return Y}:Q},k=M=>{let q=w(M.refiner,T,O);q!==void 0&&(M.refiner=q);let ee=w(M.inputRefiner,C,_);if(ee!==void 0){M.inputRefiner=ee;return}},E;if(pi in e.s){let M=[],q=[];for(let ee=0;ee<=g;++ee){let Q=n[ee];pi in Q&&Q.const===e.s.const?M.push(Q):q.push(Q)}E=M.concat(q)}else E=n;for(let M=0;M<=g;++M){let q=i!==void 0?To(E[M],Y=>{k(Y),Y.to=i}):E[M],ee=q.type,Q=Rt[ee],te=Pg(q);if((a===""||a===te)&&!(Q&16&&"fromDefault"in t)){let Y=S[te];if(Y!==void 0)Q&64&&ba in q.properties?Y.splice(Y.length-1|0,0,q):Q&2096||Y.push(q);else{let L=Hi(e),$;if(Q&37633)$=xt;else{let D=Qt(q.type,!1);D.encoder=q.encoder,Q&8192?D.class=q.class:Q&64?(D.properties=jg,D.additionalItems=xt):Q&128?(D.additionalItems=xt,D.items=kp):Q&2096&&(D.const=q.const),D.decoder=z=>Rt[z.s.type]&1?Xe(z,z.e,[{c:V=>{let X=Rt[q.type];if(X&64)return jx(V)+"&&!"+wp(V);if(X&128)return wp(V);if(X&8192)return H4(z,q.class)(V);if(!(X&4))return X&2048?Os(V):X&48?V+"==="+ru(z,q):X&17418?Is(q.type)(V):"";let le=Is(wo)(V);return z.g.o&2?le:le+"&&!"+Os(V)},f:un}],void 0):q.decoder(z),$=D}L.e=$;let K;try{K=Gt(L)}catch{L.vc=void 0,K=L}Sx(Q,S)?v.unshift(te):v.push(te),S[te]=[L,K,q];let G=!0,R=K;for(;R!==void 0&&G;){let D=R;R=D.prev,G=!(D.vc&&Px(D))}if(G){for(let D=0,z=v.length;D<z;++D){let V=v[D];if(!b){let X=S[V],le=X[1],me=p(X,!0),Ee=ci(le,void 0)+me,F=c.contents;if(F)if(c.contents="",Ee){let U="e"+(M+D|0);m=m+("try{"+Ee+"throw "+F+"}catch("+U+"){"),y="}"+y,h=h+","+U}else h=h+","+F;else if(Ee){let U="e"+(M+D|0);m=m+("try{"+Ee+"}catch("+U+"){"),y="}"+y,h=h+","+U}else b=!0}}S={},v=[]}}}}let x=S,I=v;if(!b){let M=!1,q="";for(let te=0,Y=I.length;te<Y;++te){let L=x[I[te]],$=L[1],K=L[2],G=p(L,!1),R={contents:""},D=ci($,R)+G,z=R.contents;D||Sx(Rt[K.type],x)?(m=m+(M?"else if":"if")+("("+z+"){"+D+"}"),M=!0):q=q?q+"||"+z:z}let ee=d(h),Q;q?Q=(M?"else if":"if")+("(!("+q+")){"+ee+"}"):Q=M?"else{"+ee+"}":y===""?ee+";":ee,m=m+Q}l.cp=l.cp+m+y,e.i!==l.i&&(l.i=e.i);let P=l.f&1?(l.i="Promise.resolve("+l.i+")",l.v=Sp,l):l.v===Cn&&e.cp===""&&l.cp===""&&s==="i"?(e.hd="",e.v=Sp,e.i=s,e):l;return P.s=u.length?Ji(u):Yg(),P.e=i!==void 0?(P.io=!0,Ao(i)):t,P}function Bx(e,t){return t.every((n,r)=>{let i=e[r];return i!==void 0&&!(Rt[n.type]&9152)&&n.type===i.type&&n.const===i.const?n.to===void 0:!1})}function zx(e,t){return Xe(e,xt,void 0,To(e.s,n=>{n.to=t}))}function tV(e,t){return!(Rt[Ao(t).type]&512)&&!(t.type===Pr&&t.anyOf.some(n=>Rt[n.type]&512))?!e.some(n=>n.to!==void 0||n.parser!==void 0?!0:Rt[n.type]&512):!1}function Kx(e){if(e.parser!==void 0)return;let n=e.to;if(n!==void 0)return n}function Xl(e,t){let n=e.d,r;if(n!==void 0)r=n;else{let u={};e.d=u,r=u}let i=r[t];if(i!==void 0)return Hi(i);let o=e.s.type===tn?e.s.properties[t]:e.s.items[t],a;if(o!==void 0)a=o;else{let u=e.s.additionalItems;a=u==="strip"||u==="strict"?va(e,e.s,e.e):e.s.type===tn&&u.type!==tu&&!(Rt[u.type]&512)&&!L4(u)?Qg(u):u}let d="["+ga(e.g,t)+"]",l={p:e,v:$g,i:pi in a?ru(e,a):e.v()+d,s:a,e:a,f:0,cp:"",hd:"",path:e.path+d,g:e.g};return r[t]=l,l}function $s(e){let t=e.s.type===Ki,n="",r="",i,o=Object.keys(e.d);for(let l=0,u=o.length;l<u;++l){let c=o[l],p=e.d[c];if(p.f&1&&(r=r+p.i+","),p.o){let m=i;i=y=>(m!==void 0?m(y):"")+("if("+p.v()+"!==void 0){"+y+"["+ga(e.g,c)+"]="+p.i+"}")}else n=n+(t?p.i:ga(e.g,c)+":"+p.i)+","}if(e.i=t?"["+n+"]":"{"+n+"}",r){let l=Hi(e);l.io=!0;let u=Gt(l),c=ci(u,void 0);return c===""&&r===u.i+","?e.i=u.i:e.i="Promise.all(["+r+"]).then((["+r+"])=>{"+c+"return "+u.i+"})",e.f=e.f|1,e.s=u.s,e.e=u.e,e.io=!0,e}let a=i;if(a===void 0)return e;let s=a(e.v()),d=Xe(e,void 0,void 0,void 0);return d.cp=d.cp+s,d}function Ji(e){let t=e.length;if(t===1)return e[0];if(t!==0){let n={},r=new Set;for(let o=0,a=e.length;o<a;++o){let s=e[o];s.type===Pr&&s.to===void 0?(s.anyOf.forEach(d=>{r.add(d)}),Object.assign(n,s.has)):(r.add(s),Lx(n,s.type))}let i=Qt(Pr,!1);return i.anyOf=Array.from(r),i.decoder=Ux,i.encoder=eV,i.has=n,i}throw new Error("[Sury] S.union requires at least one item")}function Sx(e,t){return e&8320&&tn in t?!0:e&2048?wo in t:!1}function Pg(e){return Rt[e.type]&8192?e.class.name:e.type}function _p(e){for(;;){let t=e,n=!1,r=!1,i=!1;if(t.to===void 0&&t.parser===void 0&&!(Rt[t.type]&512)){let a=t.anyOf;i=a!==void 0?a.every(_p):!0}if(i){let a=t.items;r=a!==void 0?a.every(_p):!0}if(r){let a=t.properties;n=a!==void 0?Object.values(a).every(_p):!0}if(!n)return!1;let o=t.additionalItems;if(o===void 0||o==="strip"||o==="strict")return!0;e=o}}function au(e){let t=Qt(Ki,e[_a]===e);return t.additionalItems=e,t.items=kp,t.decoder=ou,t}function Ep(e,t){let n=t!==void 0?t:Co(),r=Ao(e);switch(r.type){case"undefined":return Ji([n,wx(e)]);case"union":let o=r.has,a=r.anyOf;return To(e,s=>{let d=I4(o),l=[];for(let u=0,c=a.length;u<c;++u){let p=a[u],m=Ao(p),y=m.type,h;if(y==="undefined")d[n.type]=!0,l.push(n),h=wx(p);else{let b=m.properties;if(b!==void 0){let g=b[ba];h=g!==void 0?To(p,S=>{let v={},T={...g};T.const=g.const+1,v[ba]=T,S.properties=v}):p}else h=p}l.push(h)}l.length===a.length&&(d[n.type]=!0,l.push(n)),s.anyOf=l,s.has=d});default:return Ji([e,n])}}function wx(e){return To(e,t=>{t.to=X4(),t.parser=Q4})}function Op(e){let t=Qt(tn,e[_a]===e);return t.properties=jg,t.additionalItems=e,t.decoder=Ls,t}function Tx(e){let t=e.e,n=t.$ref,r=e.g.d,i=n.slice(8),o=r[i],a=e.g.o,s=e.s.seq===t.seq?o:e.s,d=s.seq+"-"+o.seq+"--"+a,l="",u=o[d];if(u!==void 0){let h=Fe(u);l=h===0?ui(e,o)+('["'+d+'"]'):ui(e,h)}else{let h=$e(o.hasTransform,!1),b=$e(o.isAsync,!1),g=!0,S=0;for(;g;){g=!1,o.hasTransform===void 0&&(o.hasTransform=h),o.isAsync===void 0&&(o.isAsync=b),vx[Ps]=0,Zn(o,d,vx);let v=qx(s,o,a,r);li[Ps]=v,Zn(o,d,li),S=v;let T=o.hasTransform,C=o.isAsync;(T!==h||C!==b)&&(h=T,b=C,delete o[d],g=!0)}l=ui(e,S)}let c=o.hasTransform===!0,p=o.isAsync,m="",y;if(c||p){let h=Fn(e.g);m="let "+h+";";let b=pr(e,h,t,t);b.v=Cn,b.cp=h+"="+l+"("+e.i+");",p&&(b.f=b.f|1),y=b}else{let h=Xe(e,t,void 0,t);h.cp=l+"("+e.i+");",y=h}return y.prev=void 0,y.cp=m+Jg(y,e,void 0,void 0),y.fz=void 0,y.prev=e,y}function Hx(e,t){return Tp(xt,t)(e)}function rV(e,t){return To(e,n=>{let r=t(n),i=n.refiner;i!==void 0?n.refiner=o=>{let a=i(o),s=r(o);for(let d=0,l=s.length;d<l;++d)a.push(s[d]);return a}:n.refiner=r})}function Jx(e,t,n,r){let i=n!==void 0?n:"Refinement failed",o=r!==void 0?$4(r):"";return rV(e,a=>(s=>{let d=ui(s,t);return[{c:l=>d+"("+l+")",f:Kg(void 0,o,i,void 0)}]}))}function Xg(){let e=Ir(iu());return e.to=Co(),e}function Wx(e,t){return To(e,n=>{let r=n.anyOf;if(r!==void 0){let o=[],a=[];for(let p=0,m=r.length;p<m;++p){let y=r[p],h=Ao(y);h.type!=="undefined"&&(o.push(h),a.push(y))}let s=o.length,d;if(s!==1)if(s!==0)d=Ji(o);else{let p="Can't set default for "+Vt(n);throw new Error("[Sury] "+p)}else d=o[0];let l=a.length!==1?Ji(a):a[0];if(t.TAG==="Value"){let p=t._0;try{Tp(xt,d)(p)}catch(m){let y=Cp(m),h="Invalid default for "+Vt(n)+": "+y.message;throw new Error("[Sury] "+h)}try{n.default=Tp(zi(l),void 0)(p)}catch{}}n.parser=p=>{let m=p.e.to,y=p.v(),h;return h=t.TAG==="Value"?ru(p,Zg(t._0)):ui(p,t._0)+"()",pr(p,y+"===void 0?"+h+":"+y,m,m)};let u=Ir(d),c=u.decoder;u.serializer=p=>{let m=zi(l);return Xe(c(p),m,void 0,m)},u.decoder=Ox,n.to=u;return}let i="Can't set default for "+Vt(n);throw new Error("[Sury] "+i)})}function Ng(e,t){let n=Rt[t.type];if(n&46)return Gt(Xe(e,xt,void 0,t));if(n&2064){let i=Ir(iu());return i.to=t,Gt(Xe(e,xt,void 0,i))}if(n&128){let i=au(xt),o=Gt(Xe(e,xt,void 0,i));return o.s.additionalItems=Gn(),o.e=t,o.io=!1,o}if(n&64){let i=Op(xt),o=Gt(Xe(e,xt,void 0,i));return o.s.additionalItems=Gn(),o.e=t,o.io=!1,o}if(n&768)return e;let r=Ir(js());return r.to=t,Gt(Xe(e,xt,void 0,r))}function Es(e){let t=Rt[e.type],n=!0;if(!(t&46||e.$ref===Gn().$ref||t&256&&e.anyOf.every(Es))){let i=!1;if(t&128){let o=e.additionalItems,a;a=o==="strip"||o==="strict"?!0:Es(o),i=a}n=i&&e.items.every(Es)}if(n)return!0;let r=!1;if(t&64){let i=e.additionalItems,o;o=i==="strip"||i==="strict"?!0:Es(i),r=o}return r?Object.values(e.properties).every(Es):!1}function Ax(e){let t=Rt[e.s.type];if(Es(e.s))return e;if(t&2064)return So(e,iu(),void 0);if(t&128){let n=Qt(Ki,!1);n.items=e.s.items.map(o=>Gn()),n.decoder=ou;let r=e.s.additionalItems,i;return i=r==="strip"||r==="strict"?r:Gn(),n.additionalItems=i,n.to=e.e.to,Gt(Xe(e,void 0,void 0,n))}if(t&64){let n=e.s.additionalItems;if(!(n==="strip"||n==="strict")){let o=Op(Gn());return o.to=e.e.to,Gt(Xe(e,void 0,void 0,o))}let r=Ds(e,e.s);r.e=Gn(),e.e.to&&(r.e=Ir(r.e),r.e.to=e.e.to);let i=Object.keys(e.s.properties);for(let o=0,a=i.length;o<a;++o){let s=i[o],d=Xl(e,s);if(d.io=!1,d.s.type===Pr&&d.s.has[fr]){d.e=Ji([Co(),Gn()]);let l=Gt(d);l.o=!0,fi(r,s,l)}else d.e=Gn(),fi(r,s,Gt(d))}return $s(r)}if(t&512)return Tx(e);if(t&256&&!(fr in e.s.has))return Gt(zx(e,e.e));if(t&1)return e.e.to&&!e.e.parser?(e.s=Gn(),Ng(e,e.e)):e.e.noValidation?(e.s=Gn(),e):Tx(e);try{let n=Ir(js());return n.to=e.e,e.e=n,Gt(e)}catch{return va(e,e.s,Gn())}}function Gn(){return ko(ha,Dg,e=>{let t=Qt(Dg,!0);t.$ref=nV+ha,t.name=ha,t.decoder=Ax,t.encoder=Ng,e.$ref=t.$ref,e.name=ha,e.decoder=Ax,e.encoder=Ng;let n=[js(),Vg(),Wg(),iu(),Op(t),au(t)],r={};n.forEach(a=>{r[a.type]=!0});let i=Qt(Pr,!0);i.anyOf=n,i.has=r,i.decoder=Ux,i.name=ha,i.type=Pr;let o={};o[ha]=i,e.$defs=o})}function iV(e){return e[Fg]}function eu(e,t,n){let r=Ir(Ao(e));return r.from=t,n!==void 0&&(r.fromFlattened=n),new Proxy(r,{get:(i,o)=>{if(o===Fg)return i;let a=i.items,s=i.properties,d=s!==void 0?s[o]:a!==void 0?a[o]:void 0;if(d===void 0){let l='Cannot read property "'+o+'" of '+Vt(i);throw new Error("[Sury] "+l)}return eu(d,i.from.concat(o),i.fromFlattened)}})}function Vx(e,t,n){let r=Ds(e,t);r.io=!0;let i=t.items;if(i!==void 0)for(let o=0,a=i.length;o<a;++o){let s=o.toString();fi(r,s,n(s,i[o]))}else{let o=t.properties;if(o!==void 0){let a=Object.keys(o);for(let s=0,d=a.length;s<d;++s){let l=a[s];fi(r,l,n(l,o[l]))}}else{let a="Don't know where the value is coming from: "+Vt(t);throw new Error("[Sury] "+a)}}return $s(r)}function Zx(e,t){let n=t.from,r=t.fromFlattened,i=r!==void 0?Hi(kx(e.fv[r],t.from,0)):n!==void 0?Hi(kx(e,n,0)):pi in t?So(e,t,void 0):Vx(e,t,(o,a)=>Zx(e,a));return i.prev=void 0,i.e=t,i}function Yx(e,t){let n=t.e,r=n.from;if(r!==void 0){let a=n.fromFlattened,s;if(a!==void 0){e.flattened===void 0&&(e.flattened=[]);let d=e.flattened[a];if(d!==void 0)s=d;else{let l={};e.flattened[a]=l,s=l}}else s=e;for(let d=0,l=r.length;d<l;++d){let u=r[d],c=s.properties,p;if(c!==void 0)p=c;else{let h={};s.properties=h,p=h}let m=p[u],y;if(m!==void 0)y=m;else{let h={};p[u]=h,y=h}s=y}s.val=t;return}let i=t.d;if(i===void 0)return;let o=Object.keys(i);for(let a=0,s=o.length;a<s;++a)Yx(e,i[o[a]])}function yp(e,t,n,r){let i=0;if(t!==void 0){let o=t.val;if(o!==void 0){let a=Hi(o);return a.t=!0,a.s=n,a.e=n,Gt(a)}i=1}else i=1;if(i===1){if(pi in n){let c=So(e,n,n);return c.prev=void 0,c.p=e,c.v=$g,c.io=!0,Gt(c)}let o=t===void 0?Ao(n):n,a=Ds(e,o);a.e=o,a.io=!0,a.prev=void 0,a.p=e,a.v=$g;let s=o.flattened,d=o.items,l=0,u=0;if(d!==void 0&&(t!==void 0||typeof o.additionalItems!==tn))for(let c=0,p=d.length;c<p;++c){let m=c.toString(),y;if(t!==void 0){let b=t.properties;y=b!==void 0?b[m]:void 0}else y=void 0;let h=ga(e.g,m);fi(a,m,yp(e,y,d[c],r+("["+h+"]")))}else u=3;if(u===3){let c=o.properties;if(c!==void 0&&(t!==void 0||typeof o.additionalItems!==tn)){if(s!==void 0&&t!==void 0){let m=t.flattened;m!==void 0&&m.forEach((y,h)=>{let g=yp(e,y,zi(s[h]),r).d,S=Object.keys(g);for(let v=0,T=S.length;v<T;++v){let C=S[v];fi(a,C,g[C])}})}let p=Object.keys(c);for(let m=0,y=p.length;m<y;++m){let h=p[m];if(!(h in a.d)){let b;if(t!==void 0){let S=t.properties;b=S!==void 0?S[h]:void 0}else b=void 0;let g=ga(e.g,h);fi(a,h,yp(e,b,c[h],r+("["+g+"]")))}}}else l=2}if(l===2){let c=n.from,p=c!==void 0?r+c.map(y=>'["'+y+'"]').join(""):r,m=p===""?"":" at "+p;K4(e,"Missing input for "+Vt(n)+m)}return $s(a)}}function kx(e,t,n){for(;;){let r=n,i=e,o=t[r];if(o===void 0)return i;n=r+1|0,e=i.d[o]}}function Ap(e,t){if(typeof e!==tn||e===null)return Zg(e);let n=t(e);if(n!==void 0)return n;if(Array.isArray(e)){for(let d=0,l=e.length;d<l;++d){let u=Ap(e[d],t);e[d]=u}let s=Qt(Ki,!1);return s.items=e,s.additionalItems="strict",s.decoder=ou,s}let r=e.constructor;if(r&&r!==Object){let s=Qt(qg,!0);return s.class=r,s.const=e,s.decoder=Ms,s}let i=Object.keys(e),o=i.length;for(let s=0;s<o;++s){let d=i[s],l=Ap(e[d],t);e[d]=l}let a=Qt(tn,!1);return a.required=i,a.properties=e,a.additionalItems=Zl.a,a.decoder=Ls,a}function oV(e){let t={};Yx(t,e);let n=e.e.to,r=yp(e,t,n,"");return r.t=!0,r.prev=e,r}function su(e){return Ap(e,t=>{if(t["~standard"])return t})}function Qx(e){let t=this,n="~"+e,r=t[n];if(r!==void 0)return Fe(r);let i={},o=[],a=Qt(tn,!1);a.required=o,a.properties=i,a.additionalItems=Zl.a,a.decoder=Ls;let s=t.f(e,a)[Fg],d=(m,y)=>{let h=Ns(m);if(m in i)throw new Error("[Sury] "+("The field "+h+" defined twice"));return o.push(m),i[m]=y,eu(y,s.from.concat(m),s.fromFlattened)},p={field:d,f:d,fieldOr:(m,y,h)=>{let b=Ep(y,void 0);return d(m,Wx(b,{TAG:"Value",_0:h}))},tag:(m,y)=>{d(m,su(y))},nested:Qx,flatten:m=>{if(m.type==="object"){let b=m.to,g=m.properties;if(b){let T="Unsupported nested flatten for transformed object schema "+Vt(m);throw new Error("[Sury] "+T)}let S=Object.keys(g),v={};for(let T=0,C=S.length;T<C;++T){let O=S[T];v[O]=d(O,g[O])}return v}let h="Can't flatten "+Vt(m)+" schema";throw new Error("[Sury] "+h)}};return t[n]=p,p}function Xx(e){let t=Ir(Ap(e,iV));return t.serializer=oV,t}function eR(e){let t=e.e.flattened;if(t!==void 0){let i=[];for(let o=0,a=t.length;o<a;++o){let s=t[o],d=s.to,l;if(d!==void 0){let u=Hi(e);u.e=s,u.io=!0,l=Gt(u)}else{let u=Vx(e,s,(c,p)=>Xl(e,c));u.e=s,u.prev=void 0,l=Ql(u,u)}i.push(l),e.cp=e.cp+ci(l,void 0)}e.fv=i}let n=e.e.to,r=Zx(e,n);return r.t=!0,r.prev=e,Ql(r,e)}function tR(e){let t,n={},r=u=>{if(u.type==="object"){let m=u.properties,y=Object.keys(m);for(let b=0,g=y.length;b<g;++b){let S=y[b],v=m[S],T=n[S];if(T!==void 0){if(T!==v)throw new Error("[Sury] "+('The field "'+S+'" defined twice with incompatible schemas'))}else n[S]=v}let h=t||(t=[]);return eu(u,kp,h.push(u)-1|0)}let p="The '"+Vt(u)+"' schema can't be flattened";throw new Error("[Sury] "+p)},i=(u,c)=>{if(u in n)throw new Error("[Sury] "+('The field "'+u+'" defined twice with incompatible schemas'));return n[u]=c,eu(c,[u],void 0)},d=e({field:i,f:i,fieldOr:(u,c,p)=>{let m=Ep(c,void 0);return i(u,Wx(m,{TAG:"Value",_0:p}))},tag:(u,c)=>{i(u,su(c))},nested:Qx,flatten:r}),l=Qt(tn,!1);return l.required=Object.keys(n),l.properties=n,l.additionalItems=Zl.a,l.decoder=Ls,l.parser=eR,l.to=Xx(d),t!==void 0&&(l.flattened=t),l}function nR(e){let t=[],n=(s,d)=>{let l=s.toString();if(t[s])throw new Error("[Sury] "+("The item ["+l+"] is defined multiple times"));return t[s]=d,eu(d,[s.toString()],void 0)},o=e({item:n,tag:(s,d)=>{n(s,su(d))}});for(let s=0,d=t.length;s<d;++s)t[s]||(t[s]=Co());let a=Qt(Ki,!1);return a.items=t,a.additionalItems="strict",a.decoder=ou,a.parser=eR,a.to=Xx(o),a}function aV(e){return e}function dV(e){return su(e(sV))}function iR(e){return Ji(e.map(rR))}function oR(e){return Ep(e,Xg())}function aR(e){return Ji([e,Co(),Xg()])}var jg,kp,I4,Lg,Gg,Fg,xs,wo,N4,gp,j4,Rs,fr,Ig,qg,Ki,tn,Pr,Mg,tu,Dg,Ug,pi,Rt,ya,Zn,nu,Cx,Bg,zg,Zl,li,vx,Ps,_a,xg,xt,Ir,ha,ba,nV,sV,rR,sR,dR,lR,uR,cR=N(()=>{gx();bx();we();qe();it();jg={},kp=[],I4=(e=>({...e}));Lg="sury",Gg=Symbol(Lg),Fg=Symbol(Lg+":item"),xs="string",wo="number",N4="bigint",gp="boolean",j4="symbol",Rs="null",fr="undefined",Ig="nan",qg="instance",Ki="array",tn="object",Pr="union",Mg="never",tu="unknown",Dg="ref",Ug=yy("Sury.Exn"),pi="const";Rt={[tu]:1,[xs]:2,[wo]:4,[gp]:8,[fr]:16,[Rs]:32,[tn]:64,[Ki]:128,[Pr]:256,[Dg]:512,[N4]:1024,[Ig]:2048,function:4096,[qg]:8192,[Mg]:32768,[j4]:16384};ya=class extends Error{constructor(t){super();for(let n in t)this[n]=t[n]}},Zn=Object.defineProperty,nu=ya.prototype;Zn(nu,"message",{get(){return Ex(this)}});Zn(nu,"name",{value:"SuryError"});Zn(nu,"s",{value:Gg});Zn(nu,"_1",{get(){return this}});Zn(nu,"RE_EXN_ID",{value:Ug});Cx=1,Bg=function(){},zg=Object.create(null);Zn(zg,"with",{get(){return(e,...t)=>e(this,...t)}});Bg.prototype=zg;Zl={m:Ex,d:void 0,a:"strip",f:0},li={},vx={configurable:!0},Ps="value",_a="r";xg={};xt=Qt(tu,!0);xt.decoder=Ox;Ir=(e=>{let t=new Bg;for(let n in e)t[n]=e[n];return t.seq=Cx++,t});Nx.embedded=kp;ha="JSON";ba="BS_PRIVATE_NESTED_SOME_NONE";Zn(zg,"~standard",{get:function(){let e=this;return{version:1,vendor:Lg,validate:t=>{try{return{value:Tp(xt,e)(t)}}catch(n){let r=Cp(n);return{issues:[{message:r.reason,path:r.path===""?void 0:M4(r.path)}]}}}}}});nV="#/$defs/";sV={m:aV};rR=su;sR=rR,dR=Op,lR=Ji,uR=dV});var Oe,fR,Mr,Gs,pR,qn,xp,mR,Ye,eb,hR,Wi,Rp,Sa,_R,mi,mn,yR,Eo=N(()=>{cR();Oe=js(),fR=Vg(),Mr=Wg(),Gs=Gn(),pR=Ug,qn=sR,xp=au,mR=dR,Ye=Qg,eb=oR,hR=aR,Wi=lR,Rp=iR,Sa=Jx,_R=Hx,mi=uR,mn=tR,yR=nR});function hi(e,t){return e.TAG==="Ok"?t(e._0):e}var Ft=N(()=>{ny()});function uV(e){return{path:e.path,summary:e.message}}function Fs(e,t){try{return{TAG:"Ok",_0:_R(e,t)}}catch(n){let r=Je(n);if(r.RE_EXN_ID===pR)return{TAG:"Error",_0:uV(r._1)};throw r}}var qs=N(()=>{Eo();it()});function tb(e,t){if(e===void 0)return;let n=Fs(e,pV);return n.TAG==="Ok"?n._0:(console.warn("message_author branch=invalid_read seq="+t.toString()+" reason="+n._0.summary),{kind:"unavailable",author_kind:"unknown",reason:"invalid_source"})}function nb(e){switch(e.kind){case"agent":return":agent/"+e.agent_id+"/"+e.via_user_id+" ("+JSON.stringify(e.display_name)+")";case"human":return":human/"+e.user_id+" ("+JSON.stringify(e.display_name)+")";case"service":return":service/"+e.user_id+" ("+JSON.stringify(e.display_name)+")";case"external":return":external/"+e.user_id+" ("+JSON.stringify(e.display_name)+")";case"system":return":system";case"unavailable":return":unavailable/"+e.author_kind+"/"+e.reason}}function bR(e,t){return e!==void 0?"Linzumi message author="+nb(e)+`:
|
|
138
138
|
|
|
139
|
-
`+t:t}var lu,gR,Pp,fV,pV,rb=N(()=>{Eo();Ft();qs();lu=Sa(Oe,e=>e.trim()!=="","empty author field",void 0),gR=Sa(lu,e=>new RegExp("^[A-Za-z0-9+/]+={0,2}$").test(e),"expected unbroken base64 entity reference",void 0),Pp=Sa(gR,e=>{let t=Buffer.from(e,"base64").toString("utf8");return new RegExp("^1:User:[1-9][0-9]*$").test(t)},"expected encoded User identity",void 0),fV=Sa(gR,e=>{let t=Buffer.from(e,"base64").toString("utf8");return new RegExp("^1:CodingJob:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$").test(t)},"expected encoded CodingJob identity",void 0),pV=Wi([mn(e=>(e.tag("kind","agent"),{kind:"agent",agent_id:e.f("agent_id",fV),via_user_id:e.f("via_user_id",Pp),display_name:e.f("display_name",lu)})),mn(e=>(e.tag("kind","human"),{kind:"human",user_id:e.f("user_id",Pp),display_name:e.f("display_name",lu)})),mn(e=>(e.tag("kind","service"),{kind:"service",user_id:e.f("user_id",Pp),display_name:e.f("display_name",lu)})),mn(e=>(e.tag("kind","external"),{kind:"external",user_id:e.f("user_id",Pp),display_name:e.f("display_name",lu)})),mn(e=>(e.tag("kind","system"),{kind:"system"})),mn(e=>(e.tag("kind","unavailable"),{kind:"unavailable",author_kind:e.f("author_kind",Sa(Oe,t=>["agent","system","unknown"].includes(t),"unknown unavailable author kind",void 0)),reason:e.f("reason",Sa(Oe,t=>["not_visible","invalid_source"].includes(t),"unknown unavailable author reason",void 0))}))])});var Ip,SR,Us=N(()=>{rb();Ip=tb,SR=bR});var uu=N(()=>{we();qe()});var Ta=N(()=>{bf();qe()});var $p=N(()=>{Ta();Ke();we();Ft();Ue();qe();
|
|
139
|
+
`+t:t}var lu,gR,Pp,fV,pV,rb=N(()=>{Eo();Ft();qs();lu=Sa(Oe,e=>e.trim()!=="","empty author field",void 0),gR=Sa(lu,e=>new RegExp("^[A-Za-z0-9+/]+={0,2}$").test(e),"expected unbroken base64 entity reference",void 0),Pp=Sa(gR,e=>{let t=Buffer.from(e,"base64").toString("utf8");return new RegExp("^1:User:[1-9][0-9]*$").test(t)},"expected encoded User identity",void 0),fV=Sa(gR,e=>{let t=Buffer.from(e,"base64").toString("utf8");return new RegExp("^1:CodingJob:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$").test(t)},"expected encoded CodingJob identity",void 0),pV=Wi([mn(e=>(e.tag("kind","agent"),{kind:"agent",agent_id:e.f("agent_id",fV),via_user_id:e.f("via_user_id",Pp),display_name:e.f("display_name",lu)})),mn(e=>(e.tag("kind","human"),{kind:"human",user_id:e.f("user_id",Pp),display_name:e.f("display_name",lu)})),mn(e=>(e.tag("kind","service"),{kind:"service",user_id:e.f("user_id",Pp),display_name:e.f("display_name",lu)})),mn(e=>(e.tag("kind","external"),{kind:"external",user_id:e.f("user_id",Pp),display_name:e.f("display_name",lu)})),mn(e=>(e.tag("kind","system"),{kind:"system"})),mn(e=>(e.tag("kind","unavailable"),{kind:"unavailable",author_kind:e.f("author_kind",Sa(Oe,t=>["agent","system","unknown"].includes(t),"unknown unavailable author kind",void 0)),reason:e.f("reason",Sa(Oe,t=>["not_visible","invalid_source"].includes(t),"unknown unavailable author reason",void 0))}))])});var Ip,SR,Us=N(()=>{rb();Ip=tb,SR=bR});var uu=N(()=>{we();qe()});var Ta=N(()=>{bf();qe()});var $p=N(()=>{Ta();Ke();we();Ft();Ue();qe();ft();it()});function fu(e){switch(e){case"LoggedIn":return"logged_in";case"NotLoggedIn":return"not_logged_in";case"BinaryMissing":return"binary_missing";case"ProbeFailed":return"probe_failed"}}var ob=N(()=>{});var _V,yV,gV,bV,J9e,Np=N(()=>{Eo();Ft();qs();ft();_V=Wi([qn("openai"),qn("wafer")]),yV=mi(e=>({sourceSeq:e.m(Mr),provider:e.m(_V),model:e.m(Oe)})),gV=Wi([qn("catalog_unavailable"),qn("offered"),qn("delisted"),qn("unverified")]),bV=mi(e=>({selection:e.m(yV),baseUrl:e.m(Oe),token:e.m(Oe),catalogStatus:e.m(Ye(gV))})),J9e=mi(e=>({source:e.m(bV),turn:e.m(mR(Gs))}))});var kR=N(()=>{we();Ue();ft();$p();ob();Np()});var CR=N(()=>{we();Ft();uu();Ue();ft();kR()});var pu=N(()=>{rt()});var t5e,n5e,r5e,ER=N(()=>{pu();rt();Ke();we();Ft();ft();it();t5e=1800*1e3,n5e=new RegExp("[^A-Za-z0-9._-]+","g"),r5e=new RegExp("^[-.]+|[-.]+$","g")});var xR=N(()=>{rt();Ke();we();Ft();ft();ER()});var RR=N(()=>{cr();we();Ft();gg();Ue();qe();ft();it();CR();xR()});var lb=N(()=>{RR()});var PR=N(()=>{"use strict";Us();lb();op();Kt();Yt()});var IR=N(()=>{});function OV(e){switch(e){case"HumanReview":return"human_review";case"AutomaticReview":return"automatic_review";case"AcceptEdits":return"accept_edits";case"DenyRequests":return"deny_requests";case"DangerousBypass":return"dangerous_bypass"}}var q5e,MR=N(()=>{q5e=["HumanReview","AutomaticReview","AcceptEdits","DenyRequests","DangerousBypass"].map(OV)});var X5e,ub=N(()=>{rt();we();Ft();Ue();qe();IR();MR();X5e=Object.fromEntries([["granular",Object.fromEntries([["sandbox_approval",!1],["rules",!1],["skill_approval",!1],["request_permissions",!1],["mcp_elicitations",!0]])]])});var $R=N(()=>{Ta();Ke();we();Ft();Ue();qe();ub();it();Np()});var Hs=N(()=>{});var NR=N(()=>{cr();Hs();Ke();we();Ue();qe();ft()});function jR(e){return JSON.stringify(e)}var MV,DV,i8e,o8e,a8e,s8e,LR=N(()=>{pu();cr();Ke();qe();NR();MV="file",DV=["mcp_oauth_credentials_store","cli_auth_credentials_store"],i8e=DV.flatMap(e=>["-c",e+'="'+MV+'"']);o8e=["-c","model_providers.openai-linzumi.name="+jR("OpenAI"),"-c","model_providers.openai-linzumi.wire_api="+jR("responses"),"-c","model_providers.openai-linzumi.requires_openai_auth=true","-c","model_providers.openai-linzumi.supports_websockets=true"],a8e=new RegExp("\\bsession\\b.+\\bis archived\\b","i"),s8e=new RegExp("^thread not found(?:\\s*:|\\b)","i")});var FR=N(()=>{rt();we();Ft();qe();ft();$R();LR();rb()});var qR=N(()=>{FR()});var fb=N(()=>{});var pb=N(()=>{});var Fp=N(()=>{we();ft();Jl();fb();pb()});var zR=N(()=>{Fp()});var hb=N(()=>{"use strict"});function UV(e){let t=new Map;return{report:r=>{let i=r.key??r.message,o=r.audience??"user",a=e.nowMs(),s=t.get(i),d=s===void 0?{key:i,severity:r.severity,message:r.message,audience:o,count:1,firstAtMs:a,lastAtMs:a}:{...s,severity:r.severity,message:r.message,audience:o,count:s.count+1,lastAtMs:a};t.delete(i),t.set(i,d);for(let l of t.keys()){if(t.size<=qV)break;t.delete(l)}return e.writeAuditEvent(KR,{severity:d.severity,audience:d.audience,key:d.key,message:d.message,count:d.count}),e.tuiActive()?(d.audience==="user"&&e.reportConsoleEvent(KR,{severity:d.severity,key:d.key,message:d.message,count:d.count}),d):(d.count===1&&e.writeStderr(`${BV(d.severity)}${d.message}
|
|
140
140
|
`),d)},notices:()=>Array.from(t.values()),reset:()=>t.clear()}}function BV(e){switch(e){case"warning":return"WARNING: ";case"error":return"ERROR: ";case"info":return""}}function _b(e){return zV.report(e)}var qV,KR,HR,zV,yb=N(()=>{"use strict";go();qV=50,KR="runner.notice";HR={tuiActive:()=>!1,reportConsoleEvent:()=>{}},zV=UV({tuiActive:()=>HR.tuiActive(),writeAuditEvent:(e,t)=>Ot(e,t),reportConsoleEvent:(e,t)=>HR.reportConsoleEvent(e,t),writeStderr:e=>{process.stderr.write(e)},nowMs:Date.now})});var JR=N(()=>{"use strict";Kt();Yt()});var WR=N(()=>{"use strict"});function Up(e){return`<linzumi_context>
|
|
141
141
|
<linzumi_thread_id>${qp(e.threadId)}</linzumi_thread_id>
|
|
142
142
|
<linzumi_creator_user_id>${qp(e.creatorUserId)}</linzumi_creator_user_id>
|
|
@@ -146,7 +146,7 @@ const watchdog = setInterval(() => {
|
|
|
146
146
|
|
|
147
147
|
<linzumi_pr_footer_instruction>
|
|
148
148
|
For any GitHub pull request you open from this session, include this Markdown footer link in the PR description: [Continue this on Linzumi](${e.conversationUrl})
|
|
149
|
-
</linzumi_pr_footer_instruction>`}function qp(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")}var hu=N(()=>{"use strict";Kt()});var VR=N(()=>{"use strict";Us();WR();hu()});var ZR=N(()=>{"use strict";bo();Yt();Kt()});var KV,gb,Js=N(()=>{Eo();KV=["deterministic","transient_upstream","transient_local","rate_limited","needs_approval","needs_decision","route_outage"],gb=Rp(KV)});var gu=N(()=>{pu();rt();Ke();we();Ft();uu();qe();mo();it();Rr()});var K8e,Zi=N(()=>{rt();Ke();we();ss();ms();Ue();ct();it();gu();ai();Rr();K8e=new RegExp('^\\{"t":"([^"]+)"')});function Yi(e,t){return e.catch(n=>t(Je(n)))}var Qi=N(()=>{it()});function vb(e,t){return{message:t,budgetExempt:!1,preserveForRestart:e!==void 0?e:!1}}function iP(e,t){let n=t-e.maxLivePressureAgeMs;return e.activeAckStartedAtMs.some(r=>r<=n)}function Vs(e){return e.replace(QV,"?").slice(0,128)}function XV(e,t,n,r,i,o,a,s,d,l){let u=a!==void 0?a:!1,c=e.now(),p=Vs(t).slice(0,64),m=Vs(r),y=o!==void 0?o-i:u?c-i:0,h=o!==void 0?c-o:0,b={correlationId:p,pushClass:n,pushEvent:m,queueWaitMs:y,ackWaitMs:h,outcome:s,activeWindowOccupancy:d};try{return l!==void 0?l(b):e.onPushTiming(b)}catch{try{console.warn("commander_push.timing_sink_failed correlation_id="+p+" push_event="+m+" branch="+s);return}catch{return}}}function bu(e,t,n,r,i){let o=t.timingEmitted.contents,a=t.timing;if(!(o||a===void 0))return t.timingEmitted.contents=!0,XV(e,a.correlationId,a.pushClass,a.pushEvent,t.enqueuedAtMs,n,!0,r,i,t.onPushTiming)}function oP(e,t){return Et(e.activeAckStartedAtMs,0,(n,r)=>Math.max(n,t-r))}function e3(e,t,n,r,i){e.pressureShedCount.contents=e.pressureShedCount.contents+1|0;let o=i!==void 0?i.TAG==="ItemStream"?["item",Vs(i.itemKey),Ze(i.turnId,Vs)]:["turn",void 0,Vs(i._0)]:["none",void 0,void 0],a;return a=t==="AckPressure"?"ack_pressure":"queue_age",{event:"commander_push.pressure_shed",branch:a,shedCount:e.pressureShedCount.contents,ageMs:n,budgetMs:e.maxLivePressureAgeMs,threadKey:Vs(r),streamKind:o[0],itemKey:o[1],turnId:o[2]}}function aP(e,t,n,r,i,o){let a=o(),s=e3(e,t,n,r,i);try{e.onPressureShed(s)}catch{let l=s.branch,u=s.shedCount,c=s.ageMs,p=s.budgetMs,m=s.threadKey,y=s.streamKind,h=s.itemKey,b=s.turnId,g={event:"commander_push.pressure_shed_fallback",branch:l,shedCount:u,ageMs:c,budgetMs:p,threadKey:m,streamKind:y,itemKey:h,turnId:b};try{e.onPressureShedFallback(g)}catch{}}return a}function tP(e){let t=e.now(),n=t-e.maxLivePressureAgeMs,r=iP(e,t),i=[];e.live.activeThreads.forEach(o=>{let a=e.live.pendingByThread.get(o);if(a===void 0)return;let s=a.filter(l=>{let u=l.enqueuedAtMs<=n;if(!r&&!u)return!0;let c=r?"AckPressure":"QueueAge",p;return p=c==="AckPressure"?oP(e,t):t-l.enqueuedAtMs,aP(e,c,p,l.threadKey,l.streamIdentity,()=>{$i(l.supersede,m=>m()),bu(e,l,void 0,"pressure_shed",e.inFlight.contents)}),!1});s.length!==0?(e.live.pendingByThread.set(o,s),i.push(o)):e.live.pendingByThread.delete(o)}),e.live.activeThreads.splice(0,e.live.activeThreads.length,...i)}function sP(e){let t=e.activeThreads.shift();if(t===void 0)return{TAG:"Ok",_0:void 0};let n=e.pendingByThread.get(t);if(n===void 0)return{TAG:"Error",_0:"Commander push admission lost an active thread"};let r=n.shift();return r!==void 0?(n.length!==0?e.activeThreads.push(t):e.pendingByThread.delete(t),{TAG:"Ok",_0:r}):(e.pendingByThread.delete(t),{TAG:"Error",_0:"Commander push admission thread queue was empty"})}function t3(e){for(;;){let t=sP(e.live);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let n=t._0;if(n===void 0)return{TAG:"Ok",_0:void 0};let r=e.now(),i=iP(e,r),o=n.enqueuedAtMs+e.maxLivePressureAgeMs<=r;if(!i&&!o)return{TAG:"Ok",_0:n};let a=i?"AckPressure":"QueueAge",s;s=a==="AckPressure"?oP(e,r):r-n.enqueuedAtMs,aP(e,a,s,n.threadKey,n.streamIdentity,()=>{$i(n.supersede,d=>d()),bu(e,n,void 0,"pressure_shed",e.inFlight.contents)})}}function n3(e){for(;;){let t=e.priority.activeThreads.length!==0,n=e.live.activeThreads.length!==0,r=e.maxInFlight===1?!0:e.liveInFlight.contents<(e.maxInFlight-1|0),i=n&&r,o=e.consecutivePriority.contents<8,a=0;if(t)a=i&&!o?1:2;else if(i)a=1;else return e.consecutivePriority.contents=0,{TAG:"Ok",_0:void 0};switch(a){case 1:e.consecutivePriority.contents=0;let s=t3(e);if(s.TAG!=="Ok")return{TAG:"Error",_0:s._0};let d=s._0;if(d!==void 0)return{TAG:"Ok",_0:d};continue;case 2:return e.consecutivePriority.contents=e.consecutivePriority.contents+1|0,sP(e.priority)}}}function dP(e,t,n,r,i,o,a){let s=t!==void 0?t:2e3,d=n!==void 0?n:T=>performance.now(),l=r!==void 0?r:(T,C)=>{let O=setTimeout(C,T);return O.unref(),()=>{clearTimeout(O)}},u=i!==void 0?i:T=>{console.warn("commander_push.pressure_shed",T)},c=o!==void 0?o:T=>{console.warn("commander_push.pressure_shed_fallback",T)},p=a!==void 0?a:T=>{},m=e>0,y=s>0&&isFinite(s)&&Number.isSafeInteger(s);if(!m)return{TAG:"Error",_0:"Commander push admission maxInFlight must be a positive integer"};if(!y)return{TAG:"Error",_0:"Commander push admission maxLivePressureAgeMs must be positive and finite"};let h={maxInFlight:e,priority:{pendingByThread:new Map,activeThreads:[]},live:{pendingByThread:new Map,activeThreads:[]},inFlight:{contents:0},liveInFlight:{contents:0},consecutivePriority:{contents:0},pumpScheduled:{contents:!1},schedulePump:()=>{},armPressureCheck:T=>{},recomputePressureCheck:()=>{},maxLivePressureAgeMs:s,now:d,schedulePressureCheck:l,activeAckStartedAtMs:[],cancelPressureCheck:{contents:void 0},pressureCheckDeadlineMs:{contents:void 0},onPressureShed:u,onPressureShedFallback:c,pressureShedCount:{contents:0},onPushTiming:p},b=T=>{let C=h.pressureCheckDeadlineMs.contents;if(C!==void 0){if(C<=T)return;$i(h.cancelPressureCheck.contents,w=>w()),h.pressureCheckDeadlineMs.contents=T;let _=h.schedulePressureCheck(Math.max(1,T-h.now()),()=>{h.cancelPressureCheck.contents=void 0,h.pressureCheckDeadlineMs.contents=void 0,tP(h),h.schedulePump(),h.recomputePressureCheck()});h.cancelPressureCheck.contents=_;return}$i(h.cancelPressureCheck.contents,_=>_()),h.pressureCheckDeadlineMs.contents=T;let O=h.schedulePressureCheck(Math.max(1,T-h.now()),()=>{h.cancelPressureCheck.contents=void 0,h.pressureCheckDeadlineMs.contents=void 0,tP(h),h.schedulePump(),h.recomputePressureCheck()});h.cancelPressureCheck.contents=O},g=()=>{let T={contents:void 0};h.live.pendingByThread.forEach(O=>{O.forEach(_=>{let w=_.enqueuedAtMs+h.maxLivePressureAgeMs,k=T.contents;T.contents=k!==void 0?Math.min(k,w):w})});let C=T.contents;if(C!==void 0)return b(Et(h.activeAckStartedAtMs,C,(O,_)=>Math.min(O,_+h.maxLivePressureAgeMs)))},S=()=>{for(;;){if(h.pumpScheduled.contents=!1,h.inFlight.contents>=h.maxInFlight)return;let T=n3(h);if(T.TAG==="Ok"){let O=T._0;if(O===void 0)return;let _=h.now();h.inFlight.contents=h.inFlight.contents+1|0;let w=h.inFlight.contents;h.activeAckStartedAtMs.push(_),h.live.activeThreads.length!==0&&b(_+h.maxLivePressureAgeMs),O.replaceableLive&&(h.liveInFlight.contents=h.liveInFlight.contents+1|0),Yi(O.task(_,w),k=>{O.outcome.contents="failed";let E=ti(k),x=E!==void 0?$e(ni(Fe(E)),"unknown admission task error"):"unknown admission task error";return O.fail(vb(void 0,x)),Promise.resolve()}).finally(()=>{bu(h,O,_,O.outcome.contents,w),h.inFlight.contents=h.inFlight.contents-1|0;let k=h.activeAckStartedAtMs.indexOf(_);k!==-1&&h.activeAckStartedAtMs.splice(k,1),O.replaceableLive&&(h.liveInFlight.contents=h.liveInFlight.contents-1|0),h.schedulePump()});continue}let C=T._0;h.priority.pendingByThread.forEach(O=>{O.forEach(_=>{_.fail(vb(void 0,C)),bu(h,_,void 0,"failed",h.inFlight.contents)})}),h.live.pendingByThread.forEach(O=>{O.forEach(_=>{_.fail(vb(void 0,C)),bu(h,_,void 0,"failed",h.inFlight.contents)})}),h.priority.pendingByThread.clear(),h.live.pendingByThread.clear(),h.priority.activeThreads.splice(0,h.priority.activeThreads.length),h.live.activeThreads.splice(0,h.live.activeThreads.length);return}},v=()=>{if(!h.pumpScheduled.contents){h.pumpScheduled.contents=!0,queueMicrotask(S);return}};return h.schedulePump=v,h.armPressureCheck=b,h.recomputePressureCheck=g,{TAG:"Ok",_0:h}}function lP(e){let t=Ze(e[XR],r=>r.trim());if(t===void 0)return{TAG:"Ok",_0:16};if(t==="")return{TAG:"Ok",_0:16};let n=Number(t);return Number.isSafeInteger(n)&&n>=2?{TAG:"Ok",_0:n|0}:{TAG:"Error",_0:XR+" must be an integer of at least 2"}}function uP(e){let t=Ze(e[eP],r=>r.trim());if(t===void 0)return{TAG:"Ok",_0:2e3};if(t==="")return{TAG:"Ok",_0:2e3};let n=Number(t);return Number.isSafeInteger(n)&&n>0?{TAG:"Ok",_0:n|0}:{TAG:"Error",_0:eP+" must be a positive integer"}}function nP(e,t,n,r,i,o,a,s){return Object.fromEntries([["branch",e],["shed_count",t],["age_ms",n],["budget_ms",r],["thread_key",i],["stream_kind",o],["item_key",Wt(a,null,d=>d)],["turn_id",Wt(s,null,d=>d)]])}function o3(e,t){if(t.TAG==="PressureShed"){let r=t._0;return e(r.event,nP(r.branch,r.shedCount,r.ageMs,r.budgetMs,r.threadKey,r.streamKind,r.itemKey,r.turnId))}let n=t._0;e(n.event,nP(n.branch,n.shedCount,n.ageMs,n.budgetMs,n.threadKey,n.streamKind,n.itemKey,n.turnId))}function rP(e){let t=r3.contents;if(t!==void 0)return o3(t,e);i3.push(e)}var XR,eP,QV,r3,i3,H8e,Sb=N(()=>{rt();Ni();we();Ft();Qi();qe();XR="LINZUMI_COMMANDER_PUSH_MAX_INFLIGHT",eP="LINZUMI_COMMANDER_PUSH_PRESSURE_BUDGET_MS";QV=new RegExp("[^\\x20-\\x7E]","g");r3={contents:void 0},i3=[];H8e=hi(lP(process.env),e=>hi(uP(process.env),t=>dP(e,t,void 0,void 0,n=>rP({TAG:"PressureShed",_0:n}),n=>rP({TAG:"PressureShedFallback",_0:n}),void 0)))});var fP=N(()=>{cr();we();Ue()});var s3,ka=N(()=>{Ke();we();Ue();qe();it();s3=ei(Vl(),1)});var pP=N(()=>{we();qe()});var W8e,mP=N(()=>{pP();we();qe();ct();W8e=process.pid.toString()+":"+performance.timeOrigin.toString()});var Qs=N(()=>{rt()});var u3,_P=N(()=>{Ta();Hs();Ke();we();ss();Ue();qe();u3=ei(Vl(),1);Qs();kg()});var f3,yP=N(()=>{Ta();rt();Hs();Ke();we();Ft();qe();it();f3=ei(Vl(),1);ka()});var gP=N(()=>{pu();Ke();Ft();ct();it();ka()});var Jp=N(()=>{rt();Ke();we();Ft();ms();Ue();ct();it();ka();Zi();ai();_P();yP();Rr();Qs();gP();pp()});var kb=N(()=>{rt();Ke();we();Ue();Zi();ai();Jp();Rr();Qs()});var jZe,Zp=N(()=>{rt();Ke();we();Ft();Qi();ms();Ue();qe();ct();it();ka();gu();Zi();ai();vo();cp();mP();Rr();Qs();kb();jZe=1440*60*1e3});var xb=N(()=>{});var M3,D3,$3,LZe,AP=N(()=>{Eo();qs();Js();M3=mn(e=>({decision:e.f("decision",Oe),label:e.f("label",Oe),description:e.f("description",Ye(Oe))})),D3=mn(e=>({requestId:e.f("requestId",Oe),kind:e.f("kind",Oe),summary:e.f("summary",Oe),reason:e.f("reason",Ye(Oe)),port:e.f("port",Ye(Mr)),pid:e.f("pid",Ye(Mr)),command:e.f("command",Ye(Oe)),cwd:e.f("cwd",Ye(Oe)),processName:e.f("processName",Ye(Oe)),processIconKey:e.f("processIconKey",Ye(Oe)),processIconPath:e.f("processIconPath",Ye(Oe)),choices:e.f("choices",Ye(xp(M3))),allowedActorSlug:e.f("allowedActorSlug",Ye(Oe)),allowedActorUserId:e.f("allowedActorUserId",Ye(Mr))})),$3=Rp(["starting turn","streaming response","running terminal command","interrupt requested","retrying empty turn","model stream stalled - resuming automatically from the last streamed checkpoint","upstream outage detected - recovery paused, resuming automatically","compacting conversation history","awaiting approval"]),LZe=Wi([mn(e=>(e.tag("status","queued"),{TAG:"Queued",reason:e.f("reason",Ye(Oe))})),mn(e=>(e.tag("status","processed"),{TAG:"Processed",reason:e.f("reason",Ye(Oe))})),mn(e=>(e.tag("status","processing"),{TAG:"Processing",reason:e.f("reason",$3),approval:e.f("approval",Ye(D3))})),mn(e=>(e.tag("status","ignored"),{TAG:"Ignored",reason:e.f("reason",Oe)})),mn(e=>(e.tag("status","failed"),{TAG:"Failed",reason:e.f("reason",Oe),retryable:e.f("retryable",Ye(fR)),fate:e.f("fate",Ye(gb))})),mn(e=>(e.tag("status","recovering"),{TAG:"Recovering",reason:e.f("reason",Oe),fate:e.f("fate",Ye(gb))})),mn(e=>(e.tag("status","interrupted"),{TAG:"Interrupted",reason:e.f("reason",Oe)}))])});var kP=N(()=>{we()});var ed=N(()=>{we();Js();Zi();kP()});var CP=N(()=>{rt();we();qe();Bl()});var WZe,VZe,ZZe,wu=N(()=>{rt();we();Ue();ct();ub();ed();CP();WZe=new RegExp("^https?:\\/\\/","i"),VZe=new RegExp("^data:","i"),ZZe=new RegExp("^file:\\/\\/","i")});var Pb=N(()=>{rt();Ke();we();qe();ct();wu()});var RP=N(()=>{});var PP=N(()=>{rt();we();Ue()});var IP=N(()=>{Ue();As()});var V7e,Z7e,Y7e,Q7e,X7e,eYe,tYe,nYe,rYe,iYe,oYe,aYe,sYe,dYe,lYe,uYe,cYe,fYe,pYe,mYe,Ib=N(()=>{rt();Hs();we();ss();uu();xb();Ue();qe();Js();ct();As();RP();PP();wu();IP();ed();Pb();vo();V7e=new RegExp("<[^>]*>","g"),Z7e=new RegExp(`data:[^"' )]+`,"g"),Y7e=new RegExp("\\s+","g"),Q7e=new RegExp("(?:<!doctype\\s+html|<html(?:\\s|>))","i"),X7e=new RegExp("cloudflare|cf-ray|\\bblocked\\b|access denied|\\bchallenge\\b|attention required","i"),eYe=new RegExp("cloudflare|cf-ray","i"),tYe=new RegExp("\\bblocked\\b|access denied","i"),nYe=new RegExp("attention required","i"),rYe=new RegExp("@font-face","i"),iYe=new RegExp("unexpected status (401|403)\\b","i"),oYe=new RegExp("\\b(401|403)\\s+(?:unauthorized|forbidden)\\b","i"),aYe=new RegExp("^(?:model_request_rejected|invalid_request_error|invalid_request|request_rejected|content_policy_violation|content_filter|input_validation_error)$","i"),sYe=new RegExp("\\bmodel request was rejected\\b|\\bmodel_request_rejected\\b","i"),dYe=new RegExp("^provider_outage$","i"),lYe=new RegExp("rejecting requests|experiencing an outage|provider outage","i"),uYe=new RegExp("\\bapply_patch\\b[^]*\\bincompatible\\b|\\bin-flight tool future\\b[^]*\\bfail","i"),cYe=new RegExp("\\btools::router\\b[^]*\\bfatal\\b|\\bresponse\\.failed\\b","i"),fYe=new RegExp("(tool.*fatal|fatal.*tool|response[._]failed|tool_failure)","i"),pYe=new RegExp("upstream model stream stalled","i"),mYe=new RegExp("\\(HTTP (\\d{3})\\)")});var gYe,Mb=N(()=>{Ni();we();qe();it();wu();ed();Pb();Ib();gYe=10*6e4});var SYe,$P=N(()=>{rt();we();qe();mo();it();Mb();ed();SYe=10*6e4});var NP=N(()=>{});var wYe,jP=N(()=>{Eo();qs();wYe=yR(e=>({joinRef:e.item(0,eb(Oe)),ref:e.item(1,eb(Oe)),topic:e.item(2,Oe),event:e.item(3,Oe),payload:e.item(4,Gs)}))});var LP=N(()=>{});var DYe,GP,$Ye,NYe,jYe,LYe,Xp=N(()=>{cr();rt();Ni();Ke();we();Ft();Qi();Ue();qe();ct();NP();it();Bl();jP();ap();LP();DYe=new RegExp("/$"),GP="[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?<![\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]",$Ye=new RegExp(GP),NYe=new RegExp(GP,"g"),jYe=new RegExp("^npm install -g @linzumi\\/cli(@[0-9A-Za-z^~.-]{1,32})?$"),LYe=new RegExp("^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]{1,32})?$")});var FP=N(()=>{rt();we()});var h6,GYe,FYe,_6,y6,qYe,UYe,qP=N(()=>{Eo();we();qs();h6=mi(e=>({decision:e.m(Oe),label:e.m(Oe),description:e.m(Ye(Oe))})),GYe=mi(e=>({decision:e.m(Oe)})),FYe=mi(e=>({status:e.m(Oe),response:e.m(Gs)})),_6=qn("terminal"),y6=Wi([qn("interrupted"),qn("processed"),qn("failed"),qn("ignored"),qn("stop_failed")]),qYe=mi(e=>({disposition:e.m(_6),thread_id:e.m(Oe),seq:e.m(Mr),status:e.m(y6),reason:e.m(hR(Oe))})),UYe=mi(e=>({approval_request_id:e.m(Oe),approval_kind:e.m(Oe),approval_summary:e.m(Oe),approval_reason:e.m(Ye(Oe)),approval_port:e.m(Ye(Mr)),approval_pid:e.m(Ye(Mr)),approval_command:e.m(Ye(Oe)),approval_cwd:e.m(Ye(Oe)),approval_process_name:e.m(Ye(Oe)),approval_process_icon_key:e.m(Ye(Oe)),approval_process_icon_path:e.m(Ye(Oe)),approval_choices:e.m(Ye(xp(h6))),approval_allowed_actor_slug:e.m(Ye(Oe)),approval_allowed_actor_user_id:e.m(Ye(Mr))}))});var UP=N(()=>{Ta();rt();Hs();Ke();we();Ft();Ue();it();ka();gu();Zi();ai();Jp()});var RQe,$b=N(()=>{cr();rt();Ni();Ke();we();Ft();Qi();Zp();uu();xb();Ue();qe();mo();Js();ct();Jl();As();it();AP();Mb();Zi();$P();Sb();wu();Xp();ai();ed();Ib();vo();FP();cp();Rr();Qs();pp();ks();qP();Fp();UP();RQe=new RegExp("^item-\\d+$")});var PQe,IQe,HP=N(()=>{Ni();we();qe();it();PQe=10*6e4,IQe=30*6e4});var JP=N(()=>{we();Ft();Qi();Ue();qe();it()});var LQe,WP=N(()=>{cr();rt();Ke();we();Ft();Qi();Ue();mo();ct();vg();it();Bl();ap();LQe=100*1024*1024});var VP=N(()=>{Ta();cr();rt();Ke();we();Qi();Zp();Ue();ct();Jl();it();WP();Xp();fb();Rr();Fp()});var JXe,ZP=N(()=>{cr();rt();Ke();we();Ft();Qi();Zp();ms();Ue();qe();mo();ct();it();ka();gu();Zi();Xp();ai();Jp();HP();JP();vo();$b();Rr();VP();ks();kb();JXe=8*1024*1024});var G6,QXe,Nb=N(()=>{"use strict";Zf();By();go();Yt();G6=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/,QXe=new RegExp(G6.source,"g")});var YP=N(()=>{Ke();we();Ue();Js();it();Zi();Sb();fP();$b();ZP();Rr();ks();Nb();hb()});var QP=N(()=>{YP()});var XP=N(()=>{ai()});var Ket,eI=N(()=>{"use strict";Yt();Kt();Ket=1024*1024});var att,tI=N(()=>{"use strict";Yt();XP();Og();eI();att=1440*60*1e3});var nI=N(()=>{"use strict"});var jb=N(()=>{"use strict";nI();bo()});var z6,mtt,K6,htt,em=N(()=>{"use strict";z6=["deterministic","transient_upstream","transient_local","rate_limited","needs_approval","needs_decision","route_outage"],mtt=new Set(z6),K6={runner_updating:"transient_local",stillborn_worker:"transient_local",infra_turn_kill:"transient_local",resume_transient:"transient_local",start_stage_transient:"transient_local",resume_torn_tail:"transient_local",resurrection_interrupted:"transient_local",dead_letter_exhausted:"transient_local",dead_letter_withheld:"needs_decision",dead_letter_permanent:"deterministic",resume_cwd_not_allowed:"deterministic",cwd_stillbirth_circuit_open:"deterministic",engine_unavailable:"deterministic",provider_binding_rejected:"deterministic",project_untrusted:"deterministic",attachment_download_failed:"transient_local",claude_input_queue_closed:"transient_local",claude_dispatch_wedged:"transient_local"},htt=Object.keys(K6)});var rI=N(()=>{pb()});var Lb=N(()=>{"use strict";Kt();rI()});var iI=N(()=>{"use strict";bo();Kt();Yt()});var aI=N(()=>{"use strict";jb();bo();Kt();em();Lb();iI()});var Gb=N(()=>{"use strict";Us()});var sI=N(()=>{Np()});var dI=N(()=>{"use strict";Us();Kt();hu();Yt()});function uI(e){return Math.ceil(e.length/4)}function Fb(e){if(!yt(e))return;let t=Lt(e.ir_version),n=Tn(e.nodes);if(!(t===void 0||n===void 0))return{irVersion:t,threadTitle:ie(e.thread_title),nodes:n.flatMap(W6),hasMore:e.has_more===!0,cursor:Lt(e.cursor),budget:V6(e.budget)}}function W6(e){if(!yt(e))return[];let t=ie(e.kind),n=Lt(e.seq),r=ie(e.body)??"";return t===void 0||n===void 0?[]:[{kind:t,seq:n,at:ie(e.at),engine:ie(e.engine)??"none",body:r,structured:ge(e.structured),actor:ge(e.actor),messageAuthor:Ip(e.message_author,n),attachments:Tn(e.attachments)??[],sourceSeq:Lt(e.source_seq),streamKey:ie(e.stream_key)}]}function V6(e){if(!yt(e))return;let t=Lt(e.context_window),n=Lt(e.max_emission_tokens);if(!(t===void 0||n===void 0||n<=0))return{model:ie(e.model),contextWindow:t,maxEmissionTokens:n}}function Z6(e,t){let n=t>0?t:lI,r=e.filter(s=>s.kind!=="reasoning"),i=e.length-r.length,o=[],a=0;for(let s=r.length-1;s>=0;s-=1){let d=r[s];if(d===void 0)continue;let l=uI(cI(d,n));if(o.length>0&&a+l>n)break;a+=l,o.unshift(d)}return{tail:o,omittedNodeCount:r.length-o.length,redactedReasoningCount:i,artifacts:Y6(e)}}function Y6(e){let t=new Set,n=new Set,r=0;for(let i of e){if(i.kind==="error"&&(r+=1),i.kind==="file_change")for(let o of Q6(i.structured))t.add(o);if(i.kind==="command_execution"){let o=ie(i.structured?.command)?.trim();o!==void 0&&o!==""&&n.add(o.split(`
|
|
149
|
+
</linzumi_pr_footer_instruction>`}function qp(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")}var hu=N(()=>{"use strict";Kt()});var VR=N(()=>{"use strict";Us();WR();hu()});var ZR=N(()=>{"use strict";bo();Yt();Kt()});var KV,gb,Js=N(()=>{Eo();KV=["deterministic","transient_upstream","transient_local","rate_limited","needs_approval","needs_decision","route_outage"],gb=Rp(KV)});var gu=N(()=>{pu();rt();Ke();we();Ft();uu();qe();mo();it();Rr()});var K8e,Zi=N(()=>{rt();Ke();we();ss();ms();Ue();ft();it();gu();ai();Rr();K8e=new RegExp('^\\{"t":"([^"]+)"')});function Yi(e,t){return e.catch(n=>t(Je(n)))}var Qi=N(()=>{it()});function vb(e,t){return{message:t,budgetExempt:!1,preserveForRestart:e!==void 0?e:!1}}function iP(e,t){let n=t-e.maxLivePressureAgeMs;return e.activeAckStartedAtMs.some(r=>r<=n)}function Vs(e){return e.replace(QV,"?").slice(0,128)}function XV(e,t,n,r,i,o,a,s,d,l){let u=a!==void 0?a:!1,c=e.now(),p=Vs(t).slice(0,64),m=Vs(r),y=o!==void 0?o-i:u?c-i:0,h=o!==void 0?c-o:0,b={correlationId:p,pushClass:n,pushEvent:m,queueWaitMs:y,ackWaitMs:h,outcome:s,activeWindowOccupancy:d};try{return l!==void 0?l(b):e.onPushTiming(b)}catch{try{console.warn("commander_push.timing_sink_failed correlation_id="+p+" push_event="+m+" branch="+s);return}catch{return}}}function bu(e,t,n,r,i){let o=t.timingEmitted.contents,a=t.timing;if(!(o||a===void 0))return t.timingEmitted.contents=!0,XV(e,a.correlationId,a.pushClass,a.pushEvent,t.enqueuedAtMs,n,!0,r,i,t.onPushTiming)}function oP(e,t){return Et(e.activeAckStartedAtMs,0,(n,r)=>Math.max(n,t-r))}function e3(e,t,n,r,i){e.pressureShedCount.contents=e.pressureShedCount.contents+1|0;let o=i!==void 0?i.TAG==="ItemStream"?["item",Vs(i.itemKey),Ze(i.turnId,Vs)]:["turn",void 0,Vs(i._0)]:["none",void 0,void 0],a;return a=t==="AckPressure"?"ack_pressure":"queue_age",{event:"commander_push.pressure_shed",branch:a,shedCount:e.pressureShedCount.contents,ageMs:n,budgetMs:e.maxLivePressureAgeMs,threadKey:Vs(r),streamKind:o[0],itemKey:o[1],turnId:o[2]}}function aP(e,t,n,r,i,o){let a=o(),s=e3(e,t,n,r,i);try{e.onPressureShed(s)}catch{let l=s.branch,u=s.shedCount,c=s.ageMs,p=s.budgetMs,m=s.threadKey,y=s.streamKind,h=s.itemKey,b=s.turnId,g={event:"commander_push.pressure_shed_fallback",branch:l,shedCount:u,ageMs:c,budgetMs:p,threadKey:m,streamKind:y,itemKey:h,turnId:b};try{e.onPressureShedFallback(g)}catch{}}return a}function tP(e){let t=e.now(),n=t-e.maxLivePressureAgeMs,r=iP(e,t),i=[];e.live.activeThreads.forEach(o=>{let a=e.live.pendingByThread.get(o);if(a===void 0)return;let s=a.filter(l=>{let u=l.enqueuedAtMs<=n;if(!r&&!u)return!0;let c=r?"AckPressure":"QueueAge",p;return p=c==="AckPressure"?oP(e,t):t-l.enqueuedAtMs,aP(e,c,p,l.threadKey,l.streamIdentity,()=>{$i(l.supersede,m=>m()),bu(e,l,void 0,"pressure_shed",e.inFlight.contents)}),!1});s.length!==0?(e.live.pendingByThread.set(o,s),i.push(o)):e.live.pendingByThread.delete(o)}),e.live.activeThreads.splice(0,e.live.activeThreads.length,...i)}function sP(e){let t=e.activeThreads.shift();if(t===void 0)return{TAG:"Ok",_0:void 0};let n=e.pendingByThread.get(t);if(n===void 0)return{TAG:"Error",_0:"Commander push admission lost an active thread"};let r=n.shift();return r!==void 0?(n.length!==0?e.activeThreads.push(t):e.pendingByThread.delete(t),{TAG:"Ok",_0:r}):(e.pendingByThread.delete(t),{TAG:"Error",_0:"Commander push admission thread queue was empty"})}function t3(e){for(;;){let t=sP(e.live);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let n=t._0;if(n===void 0)return{TAG:"Ok",_0:void 0};let r=e.now(),i=iP(e,r),o=n.enqueuedAtMs+e.maxLivePressureAgeMs<=r;if(!i&&!o)return{TAG:"Ok",_0:n};let a=i?"AckPressure":"QueueAge",s;s=a==="AckPressure"?oP(e,r):r-n.enqueuedAtMs,aP(e,a,s,n.threadKey,n.streamIdentity,()=>{$i(n.supersede,d=>d()),bu(e,n,void 0,"pressure_shed",e.inFlight.contents)})}}function n3(e){for(;;){let t=e.priority.activeThreads.length!==0,n=e.live.activeThreads.length!==0,r=e.maxInFlight===1?!0:e.liveInFlight.contents<(e.maxInFlight-1|0),i=n&&r,o=e.consecutivePriority.contents<8,a=0;if(t)a=i&&!o?1:2;else if(i)a=1;else return e.consecutivePriority.contents=0,{TAG:"Ok",_0:void 0};switch(a){case 1:e.consecutivePriority.contents=0;let s=t3(e);if(s.TAG!=="Ok")return{TAG:"Error",_0:s._0};let d=s._0;if(d!==void 0)return{TAG:"Ok",_0:d};continue;case 2:return e.consecutivePriority.contents=e.consecutivePriority.contents+1|0,sP(e.priority)}}}function dP(e,t,n,r,i,o,a){let s=t!==void 0?t:2e3,d=n!==void 0?n:T=>performance.now(),l=r!==void 0?r:(T,C)=>{let O=setTimeout(C,T);return O.unref(),()=>{clearTimeout(O)}},u=i!==void 0?i:T=>{console.warn("commander_push.pressure_shed",T)},c=o!==void 0?o:T=>{console.warn("commander_push.pressure_shed_fallback",T)},p=a!==void 0?a:T=>{},m=e>0,y=s>0&&isFinite(s)&&Number.isSafeInteger(s);if(!m)return{TAG:"Error",_0:"Commander push admission maxInFlight must be a positive integer"};if(!y)return{TAG:"Error",_0:"Commander push admission maxLivePressureAgeMs must be positive and finite"};let h={maxInFlight:e,priority:{pendingByThread:new Map,activeThreads:[]},live:{pendingByThread:new Map,activeThreads:[]},inFlight:{contents:0},liveInFlight:{contents:0},consecutivePriority:{contents:0},pumpScheduled:{contents:!1},schedulePump:()=>{},armPressureCheck:T=>{},recomputePressureCheck:()=>{},maxLivePressureAgeMs:s,now:d,schedulePressureCheck:l,activeAckStartedAtMs:[],cancelPressureCheck:{contents:void 0},pressureCheckDeadlineMs:{contents:void 0},onPressureShed:u,onPressureShedFallback:c,pressureShedCount:{contents:0},onPushTiming:p},b=T=>{let C=h.pressureCheckDeadlineMs.contents;if(C!==void 0){if(C<=T)return;$i(h.cancelPressureCheck.contents,w=>w()),h.pressureCheckDeadlineMs.contents=T;let _=h.schedulePressureCheck(Math.max(1,T-h.now()),()=>{h.cancelPressureCheck.contents=void 0,h.pressureCheckDeadlineMs.contents=void 0,tP(h),h.schedulePump(),h.recomputePressureCheck()});h.cancelPressureCheck.contents=_;return}$i(h.cancelPressureCheck.contents,_=>_()),h.pressureCheckDeadlineMs.contents=T;let O=h.schedulePressureCheck(Math.max(1,T-h.now()),()=>{h.cancelPressureCheck.contents=void 0,h.pressureCheckDeadlineMs.contents=void 0,tP(h),h.schedulePump(),h.recomputePressureCheck()});h.cancelPressureCheck.contents=O},g=()=>{let T={contents:void 0};h.live.pendingByThread.forEach(O=>{O.forEach(_=>{let w=_.enqueuedAtMs+h.maxLivePressureAgeMs,k=T.contents;T.contents=k!==void 0?Math.min(k,w):w})});let C=T.contents;if(C!==void 0)return b(Et(h.activeAckStartedAtMs,C,(O,_)=>Math.min(O,_+h.maxLivePressureAgeMs)))},S=()=>{for(;;){if(h.pumpScheduled.contents=!1,h.inFlight.contents>=h.maxInFlight)return;let T=n3(h);if(T.TAG==="Ok"){let O=T._0;if(O===void 0)return;let _=h.now();h.inFlight.contents=h.inFlight.contents+1|0;let w=h.inFlight.contents;h.activeAckStartedAtMs.push(_),h.live.activeThreads.length!==0&&b(_+h.maxLivePressureAgeMs),O.replaceableLive&&(h.liveInFlight.contents=h.liveInFlight.contents+1|0),Yi(O.task(_,w),k=>{O.outcome.contents="failed";let E=ti(k),x=E!==void 0?$e(ni(Fe(E)),"unknown admission task error"):"unknown admission task error";return O.fail(vb(void 0,x)),Promise.resolve()}).finally(()=>{bu(h,O,_,O.outcome.contents,w),h.inFlight.contents=h.inFlight.contents-1|0;let k=h.activeAckStartedAtMs.indexOf(_);k!==-1&&h.activeAckStartedAtMs.splice(k,1),O.replaceableLive&&(h.liveInFlight.contents=h.liveInFlight.contents-1|0),h.schedulePump()});continue}let C=T._0;h.priority.pendingByThread.forEach(O=>{O.forEach(_=>{_.fail(vb(void 0,C)),bu(h,_,void 0,"failed",h.inFlight.contents)})}),h.live.pendingByThread.forEach(O=>{O.forEach(_=>{_.fail(vb(void 0,C)),bu(h,_,void 0,"failed",h.inFlight.contents)})}),h.priority.pendingByThread.clear(),h.live.pendingByThread.clear(),h.priority.activeThreads.splice(0,h.priority.activeThreads.length),h.live.activeThreads.splice(0,h.live.activeThreads.length);return}},v=()=>{if(!h.pumpScheduled.contents){h.pumpScheduled.contents=!0,queueMicrotask(S);return}};return h.schedulePump=v,h.armPressureCheck=b,h.recomputePressureCheck=g,{TAG:"Ok",_0:h}}function lP(e){let t=Ze(e[XR],r=>r.trim());if(t===void 0)return{TAG:"Ok",_0:16};if(t==="")return{TAG:"Ok",_0:16};let n=Number(t);return Number.isSafeInteger(n)&&n>=2?{TAG:"Ok",_0:n|0}:{TAG:"Error",_0:XR+" must be an integer of at least 2"}}function uP(e){let t=Ze(e[eP],r=>r.trim());if(t===void 0)return{TAG:"Ok",_0:2e3};if(t==="")return{TAG:"Ok",_0:2e3};let n=Number(t);return Number.isSafeInteger(n)&&n>0?{TAG:"Ok",_0:n|0}:{TAG:"Error",_0:eP+" must be a positive integer"}}function nP(e,t,n,r,i,o,a,s){return Object.fromEntries([["branch",e],["shed_count",t],["age_ms",n],["budget_ms",r],["thread_key",i],["stream_kind",o],["item_key",Wt(a,null,d=>d)],["turn_id",Wt(s,null,d=>d)]])}function o3(e,t){if(t.TAG==="PressureShed"){let r=t._0;return e(r.event,nP(r.branch,r.shedCount,r.ageMs,r.budgetMs,r.threadKey,r.streamKind,r.itemKey,r.turnId))}let n=t._0;e(n.event,nP(n.branch,n.shedCount,n.ageMs,n.budgetMs,n.threadKey,n.streamKind,n.itemKey,n.turnId))}function rP(e){let t=r3.contents;if(t!==void 0)return o3(t,e);i3.push(e)}var XR,eP,QV,r3,i3,H8e,Sb=N(()=>{rt();Ni();we();Ft();Qi();qe();XR="LINZUMI_COMMANDER_PUSH_MAX_INFLIGHT",eP="LINZUMI_COMMANDER_PUSH_PRESSURE_BUDGET_MS";QV=new RegExp("[^\\x20-\\x7E]","g");r3={contents:void 0},i3=[];H8e=hi(lP(process.env),e=>hi(uP(process.env),t=>dP(e,t,void 0,void 0,n=>rP({TAG:"PressureShed",_0:n}),n=>rP({TAG:"PressureShedFallback",_0:n}),void 0)))});var fP=N(()=>{cr();we();Ue()});var s3,ka=N(()=>{Ke();we();Ue();qe();it();s3=ei(Vl(),1)});var pP=N(()=>{we();qe()});var W8e,mP=N(()=>{pP();we();qe();ft();W8e=process.pid.toString()+":"+performance.timeOrigin.toString()});var Qs=N(()=>{rt()});var u3,_P=N(()=>{Ta();Hs();Ke();we();ss();Ue();qe();u3=ei(Vl(),1);Qs();kg()});var f3,yP=N(()=>{Ta();rt();Hs();Ke();we();Ft();qe();it();f3=ei(Vl(),1);ka()});var gP=N(()=>{pu();Ke();Ft();ft();it();ka()});var Jp=N(()=>{rt();Ke();we();Ft();ms();Ue();ft();it();ka();Zi();ai();_P();yP();Rr();Qs();gP();pp()});var kb=N(()=>{rt();Ke();we();Ue();Zi();ai();Jp();Rr();Qs()});var jZe,Zp=N(()=>{rt();Ke();we();Ft();Qi();ms();Ue();qe();ft();it();ka();gu();Zi();ai();vo();cp();mP();Rr();Qs();kb();jZe=1440*60*1e3});var xb=N(()=>{});var M3,D3,$3,LZe,AP=N(()=>{Eo();qs();Js();M3=mn(e=>({decision:e.f("decision",Oe),label:e.f("label",Oe),description:e.f("description",Ye(Oe))})),D3=mn(e=>({requestId:e.f("requestId",Oe),kind:e.f("kind",Oe),summary:e.f("summary",Oe),reason:e.f("reason",Ye(Oe)),port:e.f("port",Ye(Mr)),pid:e.f("pid",Ye(Mr)),command:e.f("command",Ye(Oe)),cwd:e.f("cwd",Ye(Oe)),processName:e.f("processName",Ye(Oe)),processIconKey:e.f("processIconKey",Ye(Oe)),processIconPath:e.f("processIconPath",Ye(Oe)),choices:e.f("choices",Ye(xp(M3))),allowedActorSlug:e.f("allowedActorSlug",Ye(Oe)),allowedActorUserId:e.f("allowedActorUserId",Ye(Mr))})),$3=Rp(["starting turn","streaming response","running terminal command","interrupt requested","retrying empty turn","model stream stalled - resuming automatically from the last streamed checkpoint","upstream outage detected - recovery paused, resuming automatically","compacting conversation history","awaiting approval"]),LZe=Wi([mn(e=>(e.tag("status","queued"),{TAG:"Queued",reason:e.f("reason",Ye(Oe))})),mn(e=>(e.tag("status","processed"),{TAG:"Processed",reason:e.f("reason",Ye(Oe))})),mn(e=>(e.tag("status","processing"),{TAG:"Processing",reason:e.f("reason",$3),approval:e.f("approval",Ye(D3))})),mn(e=>(e.tag("status","ignored"),{TAG:"Ignored",reason:e.f("reason",Oe)})),mn(e=>(e.tag("status","failed"),{TAG:"Failed",reason:e.f("reason",Oe),retryable:e.f("retryable",Ye(fR)),fate:e.f("fate",Ye(gb))})),mn(e=>(e.tag("status","recovering"),{TAG:"Recovering",reason:e.f("reason",Oe),fate:e.f("fate",Ye(gb))})),mn(e=>(e.tag("status","interrupted"),{TAG:"Interrupted",reason:e.f("reason",Oe)}))])});var kP=N(()=>{we()});var ed=N(()=>{we();Js();Zi();kP()});var CP=N(()=>{rt();we();qe();Bl()});var WZe,VZe,ZZe,wu=N(()=>{rt();we();Ue();ft();ub();ed();CP();WZe=new RegExp("^https?:\\/\\/","i"),VZe=new RegExp("^data:","i"),ZZe=new RegExp("^file:\\/\\/","i")});var Pb=N(()=>{rt();Ke();we();qe();ft();wu()});var RP=N(()=>{});var PP=N(()=>{rt();we();Ue()});var IP=N(()=>{Ue();As()});var V7e,Z7e,Y7e,Q7e,X7e,eYe,tYe,nYe,rYe,iYe,oYe,aYe,sYe,dYe,lYe,uYe,cYe,fYe,pYe,mYe,Ib=N(()=>{rt();Hs();we();ss();uu();xb();Ue();qe();Js();ft();As();RP();PP();wu();IP();ed();Pb();vo();V7e=new RegExp("<[^>]*>","g"),Z7e=new RegExp(`data:[^"' )]+`,"g"),Y7e=new RegExp("\\s+","g"),Q7e=new RegExp("(?:<!doctype\\s+html|<html(?:\\s|>))","i"),X7e=new RegExp("cloudflare|cf-ray|\\bblocked\\b|access denied|\\bchallenge\\b|attention required","i"),eYe=new RegExp("cloudflare|cf-ray","i"),tYe=new RegExp("\\bblocked\\b|access denied","i"),nYe=new RegExp("attention required","i"),rYe=new RegExp("@font-face","i"),iYe=new RegExp("unexpected status (401|403)\\b","i"),oYe=new RegExp("\\b(401|403)\\s+(?:unauthorized|forbidden)\\b","i"),aYe=new RegExp("^(?:model_request_rejected|invalid_request_error|invalid_request|request_rejected|content_policy_violation|content_filter|input_validation_error)$","i"),sYe=new RegExp("\\bmodel request was rejected\\b|\\bmodel_request_rejected\\b","i"),dYe=new RegExp("^provider_outage$","i"),lYe=new RegExp("rejecting requests|experiencing an outage|provider outage","i"),uYe=new RegExp("\\bapply_patch\\b[^]*\\bincompatible\\b|\\bin-flight tool future\\b[^]*\\bfail","i"),cYe=new RegExp("\\btools::router\\b[^]*\\bfatal\\b|\\bresponse\\.failed\\b","i"),fYe=new RegExp("(tool.*fatal|fatal.*tool|response[._]failed|tool_failure)","i"),pYe=new RegExp("upstream model stream stalled","i"),mYe=new RegExp("\\(HTTP (\\d{3})\\)")});var gYe,Mb=N(()=>{Ni();we();qe();it();wu();ed();Pb();Ib();gYe=10*6e4});var SYe,$P=N(()=>{rt();we();qe();mo();it();Mb();ed();SYe=10*6e4});var NP=N(()=>{});var wYe,jP=N(()=>{Eo();qs();wYe=yR(e=>({joinRef:e.item(0,eb(Oe)),ref:e.item(1,eb(Oe)),topic:e.item(2,Oe),event:e.item(3,Oe),payload:e.item(4,Gs)}))});var LP=N(()=>{});var DYe,GP,$Ye,NYe,jYe,LYe,Xp=N(()=>{cr();rt();Ni();Ke();we();Ft();Qi();Ue();qe();ft();NP();it();Bl();jP();ap();LP();DYe=new RegExp("/$"),GP="[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?<![\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]",$Ye=new RegExp(GP),NYe=new RegExp(GP,"g"),jYe=new RegExp("^npm install -g @linzumi\\/cli(@[0-9A-Za-z^~.-]{1,32})?$"),LYe=new RegExp("^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]{1,32})?$")});var FP=N(()=>{rt();we()});var h6,GYe,FYe,_6,y6,qYe,UYe,qP=N(()=>{Eo();we();qs();h6=mi(e=>({decision:e.m(Oe),label:e.m(Oe),description:e.m(Ye(Oe))})),GYe=mi(e=>({decision:e.m(Oe)})),FYe=mi(e=>({status:e.m(Oe),response:e.m(Gs)})),_6=qn("terminal"),y6=Wi([qn("interrupted"),qn("processed"),qn("failed"),qn("ignored"),qn("stop_failed")]),qYe=mi(e=>({disposition:e.m(_6),thread_id:e.m(Oe),seq:e.m(Mr),status:e.m(y6),reason:e.m(hR(Oe))})),UYe=mi(e=>({approval_request_id:e.m(Oe),approval_kind:e.m(Oe),approval_summary:e.m(Oe),approval_reason:e.m(Ye(Oe)),approval_port:e.m(Ye(Mr)),approval_pid:e.m(Ye(Mr)),approval_command:e.m(Ye(Oe)),approval_cwd:e.m(Ye(Oe)),approval_process_name:e.m(Ye(Oe)),approval_process_icon_key:e.m(Ye(Oe)),approval_process_icon_path:e.m(Ye(Oe)),approval_choices:e.m(Ye(xp(h6))),approval_allowed_actor_slug:e.m(Ye(Oe)),approval_allowed_actor_user_id:e.m(Ye(Mr))}))});var UP=N(()=>{Ta();rt();Hs();Ke();we();Ft();Ue();it();ka();gu();Zi();ai();Jp()});var RQe,$b=N(()=>{cr();rt();Ni();Ke();we();Ft();Qi();Zp();uu();xb();Ue();qe();mo();Js();ft();Jl();As();it();AP();Mb();Zi();$P();Sb();wu();Xp();ai();ed();Ib();vo();FP();cp();Rr();Qs();pp();ks();qP();Fp();UP();RQe=new RegExp("^item-\\d+$")});var PQe,IQe,HP=N(()=>{Ni();we();qe();it();PQe=10*6e4,IQe=30*6e4});var JP=N(()=>{we();Ft();Qi();Ue();qe();it()});var LQe,WP=N(()=>{cr();rt();Ke();we();Ft();Qi();Ue();mo();ft();vg();it();Bl();ap();LQe=100*1024*1024});var VP=N(()=>{Ta();cr();rt();Ke();we();Qi();Zp();Ue();ft();Jl();it();WP();Xp();fb();Rr();Fp()});var JXe,ZP=N(()=>{cr();rt();Ke();we();Ft();Qi();Zp();ms();Ue();qe();mo();ft();it();ka();gu();Zi();Xp();ai();Jp();HP();JP();vo();$b();Rr();VP();ks();kb();JXe=8*1024*1024});var G6,QXe,Nb=N(()=>{"use strict";Zf();By();go();Yt();G6=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/,QXe=new RegExp(G6.source,"g")});var YP=N(()=>{Ke();we();Ue();Js();it();Zi();Sb();fP();$b();ZP();Rr();ks();Nb();hb()});var QP=N(()=>{YP()});var XP=N(()=>{ai()});var Ket,eI=N(()=>{"use strict";Yt();Kt();Ket=1024*1024});var att,tI=N(()=>{"use strict";Yt();XP();Og();eI();att=1440*60*1e3});var nI=N(()=>{"use strict"});var jb=N(()=>{"use strict";nI();bo()});var z6,mtt,K6,htt,em=N(()=>{"use strict";z6=["deterministic","transient_upstream","transient_local","rate_limited","needs_approval","needs_decision","route_outage"],mtt=new Set(z6),K6={runner_updating:"transient_local",stillborn_worker:"transient_local",infra_turn_kill:"transient_local",resume_transient:"transient_local",start_stage_transient:"transient_local",resume_torn_tail:"transient_local",resurrection_interrupted:"transient_local",dead_letter_exhausted:"transient_local",dead_letter_withheld:"needs_decision",dead_letter_permanent:"deterministic",resume_cwd_not_allowed:"deterministic",cwd_stillbirth_circuit_open:"deterministic",engine_unavailable:"deterministic",provider_binding_rejected:"deterministic",project_untrusted:"deterministic",attachment_download_failed:"transient_local",claude_input_queue_closed:"transient_local",claude_dispatch_wedged:"transient_local"},htt=Object.keys(K6)});var rI=N(()=>{pb()});var Lb=N(()=>{"use strict";Kt();rI()});var iI=N(()=>{"use strict";bo();Kt();Yt()});var aI=N(()=>{"use strict";jb();bo();Kt();em();Lb();iI()});var Gb=N(()=>{"use strict";Us()});var sI=N(()=>{Np()});var dI=N(()=>{"use strict";Us();Kt();hu();Yt()});function uI(e){return Math.ceil(e.length/4)}function Fb(e){if(!yt(e))return;let t=Lt(e.ir_version),n=Tn(e.nodes);if(!(t===void 0||n===void 0))return{irVersion:t,threadTitle:ie(e.thread_title),nodes:n.flatMap(W6),hasMore:e.has_more===!0,cursor:Lt(e.cursor),budget:V6(e.budget)}}function W6(e){if(!yt(e))return[];let t=ie(e.kind),n=Lt(e.seq),r=ie(e.body)??"";return t===void 0||n===void 0?[]:[{kind:t,seq:n,at:ie(e.at),engine:ie(e.engine)??"none",body:r,structured:ge(e.structured),actor:ge(e.actor),messageAuthor:Ip(e.message_author,n),attachments:Tn(e.attachments)??[],sourceSeq:Lt(e.source_seq),streamKey:ie(e.stream_key)}]}function V6(e){if(!yt(e))return;let t=Lt(e.context_window),n=Lt(e.max_emission_tokens);if(!(t===void 0||n===void 0||n<=0))return{model:ie(e.model),contextWindow:t,maxEmissionTokens:n}}function Z6(e,t){let n=t>0?t:lI,r=e.filter(s=>s.kind!=="reasoning"),i=e.length-r.length,o=[],a=0;for(let s=r.length-1;s>=0;s-=1){let d=r[s];if(d===void 0)continue;let l=uI(cI(d,n));if(o.length>0&&a+l>n)break;a+=l,o.unshift(d)}return{tail:o,omittedNodeCount:r.length-o.length,redactedReasoningCount:i,artifacts:Y6(e)}}function Y6(e){let t=new Set,n=new Set,r=0;for(let i of e){if(i.kind==="error"&&(r+=1),i.kind==="file_change")for(let o of Q6(i.structured))t.add(o);if(i.kind==="command_execution"){let o=ie(i.structured?.command)?.trim();o!==void 0&&o!==""&&n.add(o.split(`
|
|
150
150
|
`,1)[0]??o)}}return{filesTouched:[...t].slice(0,100),commandsRun:[...n].slice(0,100),errorCount:r}}function Q6(e){if(e===void 0)return[];let t=ie(e.path),r=(Tn(e.paths)??Tn(e.files)??[]).flatMap(i=>{let o=ie(i);if(o!==void 0)return[o];let a=yt(i)?ie(i.path):void 0;return a===void 0?[]:[a]});return t===void 0?r:[t,...r]}function qb(e){let t=e.budget?.maxEmissionTokens??lI,n=Z6(e.nodes,t),r=i9({resumeFailure:e.resumeFailure,threadTitle:e.threadTitle,linzumiContext:e.linzumiContext,budgeted:n,transcriptEmpty:n.tail.length===0}),i=[yi(r,"commentary")],o=0;for(let s of n.tail)o+=1,i.push(...X6(s,t,o));let a=i.reduce((s,d)=>s+uI(JSON.stringify(d)),0);return{items:i,emittedNodeCount:n.tail.length,omittedNodeCount:n.omittedNodeCount,redactedReasoningCount:n.redactedReasoningCount,emittedTokenEstimate:a,maxEmissionTokens:t}}function X6(e,t,n){let r=cI(e,t);switch(e.kind){case"user_message":return[{type:"message",role:"user",content:[{type:"input_text",text:SR(e.messageAuthor,r9(e,r))}]}];case"assistant_message":return[yi(r,n9(e))];case"command_execution":return e9(e,r,n);case"tool_call":return t9(e,r,n);case"reasoning":return[];case"file_change":return[yi(`[file change]
|
|
151
151
|
${r}`,"commentary")];case"terminal_input":return[yi(`[terminal input]
|
|
152
152
|
${r}`,"commentary")];case"tool_result":return[yi(`[tool result]
|
|
@@ -155,7 +155,7 @@ ${s}`}]}function t9(e,t,n){let r=fI(e,n);return[{type:"function_call",name:o9(ie
|
|
|
155
155
|
[${e.attachments.length} attachment(s) in the original message]`}function cI(e,t){let n=Math.max(1e3,t*4),r=e.body;return r.length<=n?r:`[...truncated...]
|
|
156
156
|
${r.slice(r.length-n)}`}function i9(e){let t=e.resumeFailure.trim(),{artifacts:n}=e.budgeted,r=["Rebuilt Linzumi coding session","","This session was rebuilt after an interrupted durable engine session: the previous engine session for this Linzumi thread could not be resumed"+(t===""?".":` (${s9(t,400)}).`),e.transcriptEmpty?"The durable server-side transcript could not be fetched or is empty - ask the user for any missing context instead of guessing.":"You are continuing the SAME task in the SAME Linzumi thread. The transcript below is replayed from the durable server-side record. Re-derive any local state (files, branches, running processes) from the workspace itself; do not assume in-memory state survived.",...e.threadTitle===void 0||e.threadTitle.trim()===""?[]:["",`Thread: ${e.threadTitle.trim()}`],...e.linzumiContext===void 0?[]:["",Up(e.linzumiContext)]],i=[...e.budgeted.omittedNodeCount>0?[`${e.budgeted.omittedNodeCount} older transcript entries were omitted to fit the emission budget.`]:[],...e.budgeted.redactedReasoningCount>0?[`${e.budgeted.redactedReasoningCount} reasoning entries were redacted (provider-private; never replayed).`]:[],...n.filesTouched.length>0?[`Files touched: ${n.filesTouched.join(", ")}`]:[],...n.commandsRun.length>0?[`Commands run: ${n.commandsRun.join("; ")}`]:[],...n.errorCount>0?[`${n.errorCount} error entries in the full history.`]:[]];return[...r,...i.length===0?[]:["",...i]].join(`
|
|
157
157
|
`)}function fI(e,t){return`linzumi_replay_${e.seq}_${t}`}function o9(e){let t=e.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64);return t===""?"linzumi_replayed_tool":t}function a9(e){return e.split(`
|
|
158
|
-
`,1)[0]??e}function s9(e,t){return e.length<=t?e:`[...truncated...]${e.slice(e.length-t)}`}var lI,Ub=N(()=>{"use strict";Us();Kt();hu();Yt();lI=76800});var pI=N(()=>{"use strict";Kt()});var mI=N(()=>{"use strict";Kt();em()});var hI=N(()=>{"use strict"});var _I=N(()=>{we();Ue();ct()});var yI=N(()=>{_I()});var gI=N(()=>{"use strict";Gb();yI()});var tm,bI=N(()=>{tm={default:{maxLadderMs:9e5},wafer:{maxLadderMs:36e5}}});var Hnt,Jnt,vI=N(()=>{"use strict";bI();Hnt={maxRecoveryRungs:4,maxLadderMs:tm.default.maxLadderMs,maxRateLimitHoldMs:30*6e4},Jnt={default:tm.default,wafer:tm.wafer}});var SI=N(()=>{"use strict"});var Ynt,wI=N(()=>{"use strict";Yt();Ynt=10*6e4});var Bb=N(()=>{"use strict";go()});var zb=N(()=>{"use strict";Bb();Bb()});var TI=N(()=>{"use strict";zb()});function p9(e){let t=e.toLowerCase();switch(!0){case t.endsWith(".app"):return e.slice(0,-4);case t.endsWith(".exe"):return e.slice(0,-4);case t.endsWith(".cmd"):case t.endsWith(".bat"):return e.slice(0,-4);default:return e}}function m9(e){return p9(e.trim().replaceAll("\\","/").toLowerCase())}var f9,AI,prt,kI=N(()=>{"use strict";f9=[{appName:"Bun",iconKey:"bun",names:["bun","bunx"]},{appName:"Node.js",iconKey:"nodejs",names:["node","nodejs","node.exe"]},{appName:"npm",iconKey:"npm",names:["npm","npm-cli.js","npx"]},{appName:"pnpm",iconKey:"pnpm",names:["pnpm","pnpx"]},{appName:"Yarn",iconKey:"yarn",names:["yarn","yarnpkg","yarn.js"]},{appName:"Corepack",iconKey:"corepack",names:["corepack"]},{appName:"Deno",iconKey:"deno",names:["deno"]},{appName:"Vite",iconKey:"vite",names:["vite","vite-node"]},{appName:"Vitest",iconKey:"vitest",names:["vitest"]},{appName:"Next.js",iconKey:"nextjs",names:["next","next-server"]},{appName:"Nuxt",iconKey:"nuxt",names:["nuxt","nuxi"]},{appName:"Astro",iconKey:"astro",names:["astro"]},{appName:"SvelteKit",iconKey:"svelte",names:["svelte-kit","sveltekit"]},{appName:"Remix",iconKey:"remix",names:["remix"]},{appName:"Expo",iconKey:"expo",names:["expo","expo-cli"]},{appName:"React Native",iconKey:"react",names:["react-native"]},{appName:"Metro",iconKey:"metro",names:["metro","metro-inspector-proxy"]},{appName:"Webpack",iconKey:"webpack",names:["webpack","webpack-dev-server","webpack-cli"]},{appName:"Parcel",iconKey:"parcel",names:["parcel"]},{appName:"Rollup",iconKey:"rollup",names:["rollup"]},{appName:"esbuild",iconKey:"esbuild",names:["esbuild"]},{appName:"SWC",iconKey:"swc",names:["swc"]},{appName:"TypeScript",iconKey:"typescript",names:["tsc","tsserver","tsx","ts-node","typescript-language-server"]},{appName:"ESLint",iconKey:"eslint",names:["eslint","eslint_d"]},{appName:"Prettier",iconKey:"prettier",names:["prettier"]},{appName:"Biome",iconKey:"biome",names:["biome"]},{appName:"Storybook",iconKey:"storybook",names:["storybook","start-storybook"]},{appName:"Playwright",iconKey:"playwright",names:["playwright"]},{appName:"Cypress",iconKey:"cypress",names:["cypress"]},{appName:"Jest",iconKey:"jest",names:["jest"]},{appName:"Python",iconKey:"python",names:["python","python2","python3","python3.9","python3.10","python3.11","python3.12","python3.13","pypy","pypy3"]},{appName:"pip",iconKey:"python",names:["pip","pip2","pip3"]},{appName:"pipx",iconKey:"python",names:["pipx"]},{appName:"uv",iconKey:"python",names:["uv","uvx"]},{appName:"Poetry",iconKey:"poetry",names:["poetry"]},{appName:"Pipenv",iconKey:"python",names:["pipenv"]},{appName:"Conda",iconKey:"conda",names:["conda","mamba","micromamba"]},{appName:"Django",iconKey:"django",names:["django-admin","django-admin.py","manage.py"]},{appName:"Flask",iconKey:"flask",names:["flask"]},{appName:"Uvicorn",iconKey:"uvicorn",names:["uvicorn"]},{appName:"Gunicorn",iconKey:"gunicorn",names:["gunicorn"]},{appName:"Hypercorn",iconKey:"python",names:["hypercorn"]},{appName:"Celery",iconKey:"celery",names:["celery"]},{appName:"Jupyter",iconKey:"jupyter",names:["jupyter","jupyter-lab","jupyter-notebook","ipython"]},{appName:"Ruby",iconKey:"ruby",names:["ruby","erb","irb"]},{appName:"Bundler",iconKey:"ruby",names:["bundle","bundler"]},{appName:"Rails",iconKey:"rails",names:["rails","bin/rails"]},{appName:"Rack",iconKey:"ruby",names:["rackup"]},{appName:"Puma",iconKey:"puma",names:["puma"]},{appName:"Sidekiq",iconKey:"sidekiq",names:["sidekiq"]},{appName:"RSpec",iconKey:"ruby",names:["rspec"]},{appName:"Go",iconKey:"go",names:["go","gofmt","gopls","air"]},{appName:"Delve",iconKey:"go",names:["dlv"]},{appName:"Rust",iconKey:"rust",names:["rustc","rustup","cargo","rust-analyzer"]},{appName:"Java",iconKey:"java",names:["java","javac","jar","jshell","jwebserver"]},{appName:"Gradle",iconKey:"gradle",names:["gradle","gradlew"]},{appName:"Maven",iconKey:"maven",names:["mvn","mvnw"]},{appName:"Spring Boot",iconKey:"spring",names:["spring","spring-boot"]},{appName:"Kotlin",iconKey:"kotlin",names:["kotlin","kotlinc","kotlin-language-server"]},{appName:"Scala",iconKey:"scala",names:["scala","scalac","sbt","metals"]},{appName:"Clojure",iconKey:"clojure",names:["clojure","clj","lein","boot"]},{appName:"PHP",iconKey:"php",names:["php","php-fpm","php-cgi","composer"]},{appName:"Laravel",iconKey:"laravel",names:["artisan","laravel"]},{appName:"Symfony",iconKey:"symfony",names:["symfony"]},{appName:"Elixir",iconKey:"elixir",names:["elixir","iex","mix"]},{appName:"Erlang",iconKey:"erlang",names:["erl","beam.smp","beam","epmd","rebar3"]},{appName:"Phoenix",iconKey:"phoenix",names:["phx.server","phoenix"]},{appName:"PostgreSQL",iconKey:"postgresql",names:["postgres","postmaster","pg_ctl","psql","pg_isready"]},{appName:"Redis",iconKey:"redis",names:["redis-server","redis-cli","redis-sentinel"]},{appName:"MySQL",iconKey:"mysql",names:["mysql","mysqld","mysqladmin"]},{appName:"MariaDB",iconKey:"mariadb",names:["mariadb","mariadbd","mariadb-admin"]},{appName:"SQLite",iconKey:"sqlite",names:["sqlite3","sqlite"]},{appName:"MongoDB",iconKey:"mongodb",names:["mongod","mongosh","mongo"]},{appName:"Elasticsearch",iconKey:"elasticsearch",names:["elasticsearch"]},{appName:"OpenSearch",iconKey:"opensearch",names:["opensearch"]},{appName:"Solr",iconKey:"solr",names:["solr"]},{appName:"Kafka",iconKey:"kafka",names:["kafka-server-start","kafka-console-consumer","kafka-console-producer"]},{appName:"ZooKeeper",iconKey:"zookeeper",names:["zookeeper-server-start","zkserver"]},{appName:"RabbitMQ",iconKey:"rabbitmq",names:["rabbitmq-server","rabbitmqctl"]},{appName:"NATS",iconKey:"nats",names:["nats-server","nats"]},{appName:"Docker",iconKey:"docker",names:["docker","dockerd","docker-compose","docker-proxy","com.docker.backend"]},{appName:"Podman",iconKey:"podman",names:["podman","podman-compose"]},{appName:"Kubernetes",iconKey:"kubernetes",names:["kubectl","kube-apiserver","kubelet","minikube","kind"]},{appName:"Helm",iconKey:"helm",names:["helm"]},{appName:"Tilt",iconKey:"tilt",names:["tilt"]},{appName:"nginx",iconKey:"nginx",names:["nginx"]},{appName:"Caddy",iconKey:"caddy",names:["caddy"]},{appName:"Apache HTTP Server",iconKey:"apache",names:["httpd","apache2","apachectl"]},{appName:"HAProxy",iconKey:"haproxy",names:["haproxy"]},{appName:"Traefik",iconKey:"traefik",names:["traefik"]},{appName:"Envoy",iconKey:"envoy",names:["envoy"]},{appName:"Tailscale",iconKey:"tailscale",names:["tailscale","tailscaled"]},{appName:"Cloudflare Tunnel",iconKey:"cloudflare",names:["cloudflared"]},{appName:"ngrok",iconKey:"ngrok",names:["ngrok"]},{appName:"localtunnel",iconKey:"terminal",names:["lt","localtunnel"]},{appName:"SSH",iconKey:"ssh",names:["ssh","sshd","scp","sftp"]},{appName:"Git",iconKey:"git",names:["git","git-lfs","git-upload-pack","git-receive-pack"]},{appName:"GitHub CLI",iconKey:"github",names:["gh"]},{appName:"GitLab CLI",iconKey:"gitlab",names:["glab"]},{appName:"Subversion",iconKey:"subversion",names:["svn"]},{appName:"Mercurial",iconKey:"mercurial",names:["hg"]},{appName:"AWS CLI",iconKey:"aws",names:["aws","aws-vault","sam"]},{appName:"Azure CLI",iconKey:"azure",names:["az"]},{appName:"Google Cloud CLI",iconKey:"google-cloud",names:["gcloud","gsutil","bq"]},{appName:"Terraform",iconKey:"terraform",names:["terraform"]},{appName:"OpenTofu",iconKey:"opentofu",names:["tofu"]},{appName:"Ansible",iconKey:"ansible",names:["ansible","ansible-playbook"]},{appName:"Pulumi",iconKey:"pulumi",names:["pulumi"]},{appName:"Nomad",iconKey:"nomad",names:["nomad"]},{appName:"Vault",iconKey:"vault",names:["vault"]},{appName:"Consul",iconKey:"consul",names:["consul"]},{appName:"Make",iconKey:"make",names:["make","gmake"]},{appName:"CMake",iconKey:"cmake",names:["cmake","ctest","cpack"]},{appName:"Ninja",iconKey:"ninja",names:["ninja"]},{appName:"Bazel",iconKey:"bazel",names:["bazel","bazelisk"]},{appName:"Buck",iconKey:"buck",names:["buck","buck2"]},{appName:"Clang",iconKey:"clang",names:["clang","clang++","clangd"]},{appName:"GCC",iconKey:"gcc",names:["gcc","g++","cc","c++"]},{appName:"LLDB",iconKey:"terminal",names:["lldb"]},{appName:"GDB",iconKey:"terminal",names:["gdb"]},{appName:"Swift",iconKey:"swift",names:["swift","swiftc","sourcekit-lsp"]},{appName:"Xcode",iconKey:"xcode",names:["xcodebuild","xcrun","simctl"]},{appName:"Zig",iconKey:"zig",names:["zig"]},{appName:"Lua",iconKey:"lua",names:["lua","luajit","lua-language-server"]},{appName:"Perl",iconKey:"perl",names:["perl"]},{appName:"R",iconKey:"r",names:["r","rscript","rserver","rsession"]},{appName:"Julia",iconKey:"julia",names:["julia"]},{appName:"Haskell",iconKey:"haskell",names:["ghc","ghci","cabal","stack","haskell-language-server-wrapper"]},{appName:"OCaml",iconKey:"ocaml",names:["ocaml","ocamlc","dune","opam"]},{appName:"F#",iconKey:"fsharp",names:["fsharpi","fsautocomplete"]},{appName:".NET",iconKey:"dotnet",names:["dotnet","csharp-ls","omnisharp"]},{appName:"PowerShell",iconKey:"powershell",names:["pwsh","powershell"]},{appName:"Bash",iconKey:"terminal",names:["bash"]},{appName:"Zsh",iconKey:"terminal",names:["zsh"]},{appName:"fish",iconKey:"terminal",names:["fish"]},{appName:"tmux",iconKey:"terminal",names:["tmux"]},{appName:"GNU Screen",iconKey:"terminal",names:["screen"]},{appName:"direnv",iconKey:"terminal",names:["direnv"]},{appName:"Nix",iconKey:"nix",names:["nix","nix-shell","nix-daemon","nix-build","nix develop"]},{appName:"Homebrew",iconKey:"homebrew",names:["brew"]},{appName:"mise",iconKey:"terminal",names:["mise"]},{appName:"asdf",iconKey:"terminal",names:["asdf"]},{appName:"Volta",iconKey:"volta",names:["volta"]},{appName:"fnm",iconKey:"nodejs",names:["fnm"]},{appName:"nvm",iconKey:"nodejs",names:["nvm"]},{appName:"curl",iconKey:"terminal",names:["curl"]},{appName:"HTTPie",iconKey:"httpie",names:["http","https","httpie"]},{appName:"wget",iconKey:"terminal",names:["wget"]},{appName:"jq",iconKey:"terminal",names:["jq"]},{appName:"ripgrep",iconKey:"terminal",names:["rg","ripgrep"]},{appName:"fd",iconKey:"terminal",names:["fd"]},{appName:"fzf",iconKey:"terminal",names:["fzf"]},{appName:"bat",iconKey:"terminal",names:["bat"]},{appName:"eza",iconKey:"terminal",names:["eza","exa"]},{appName:"htop",iconKey:"terminal",names:["htop","top","btop"]},{appName:"Vim",iconKey:"vim",names:["vim","view","vimdiff"]},{appName:"Neovim",iconKey:"neovim",names:["nvim","nvim-qt"]},{appName:"Emacs",iconKey:"emacs",names:["emacs","emacsclient"]},{appName:"Visual Studio Code",iconKey:"vscode",names:["code","code-insiders","vscode","visual studio code","visual studio code - insiders"]},{appName:"code-server",iconKey:"vscode",names:["code-server"]},{appName:"Cursor",iconKey:"cursor",names:["cursor"]},{appName:"Zed",iconKey:"zed",names:["zed"]},{appName:"Sublime Text",iconKey:"sublime-text",names:["subl","sublime_text","sublime text"]},{appName:"Atom",iconKey:"atom",names:["atom"]},{appName:"IntelliJ IDEA",iconKey:"intellij-idea",names:["idea","idea.sh","intellij idea","idea64.exe"]},{appName:"WebStorm",iconKey:"webstorm",names:["webstorm","webstorm.sh"]},{appName:"PyCharm",iconKey:"pycharm",names:["pycharm","pycharm.sh"]},{appName:"RubyMine",iconKey:"rubymine",names:["rubymine","rubymine.sh"]},{appName:"GoLand",iconKey:"goland",names:["goland","goland.sh"]},{appName:"CLion",iconKey:"clion",names:["clion","clion.sh"]},{appName:"DataGrip",iconKey:"datagrip",names:["datagrip","datagrip.sh"]},{appName:"Rider",iconKey:"rider",names:["rider","rider.sh"]},{appName:"Android Studio",iconKey:"android-studio",names:["studio","studio.sh","android studio"]},{appName:"Xcode",iconKey:"xcode",names:["xcode","xcode.app"]},{appName:"Postman",iconKey:"postman",names:["postman"]},{appName:"Insomnia",iconKey:"insomnia",names:["insomnia"]},{appName:"Hoppscotch",iconKey:"hoppscotch",names:["hoppscotch"]},{appName:"TablePlus",iconKey:"tableplus",names:["tableplus"]},{appName:"DBeaver",iconKey:"dbeaver",names:["dbeaver"]},{appName:"RedisInsight",iconKey:"redis",names:["redisinsight"]},{appName:"Prisma",iconKey:"prisma",names:["prisma"]},{appName:"Drizzle Kit",iconKey:"drizzle",names:["drizzle-kit"]},{appName:"Supabase",iconKey:"supabase",names:["supabase"]},{appName:"Firebase",iconKey:"firebase",names:["firebase"]},{appName:"Vercel",iconKey:"vercel",names:["vercel"]},{appName:"Netlify",iconKey:"netlify",names:["netlify","ntl"]},{appName:"Fly.io",iconKey:"fly",names:["fly","flyctl"]},{appName:"Heroku",iconKey:"heroku",names:["heroku"]},{appName:"Stripe CLI",iconKey:"stripe",names:["stripe"]},{appName:"Twilio CLI",iconKey:"twilio",names:["twilio"]},{appName:"Mailpit",iconKey:"mail",names:["mailpit"]},{appName:"MailHog",iconKey:"mail",names:["mailhog"]},{appName:"OpenSSL",iconKey:"openssl",names:["openssl"]},{appName:"mkcert",iconKey:"certificate",names:["mkcert"]},{appName:"mkdocs",iconKey:"markdown",names:["mkdocs"]},{appName:"Hugo",iconKey:"hugo",names:["hugo"]},{appName:"Jekyll",iconKey:"jekyll",names:["jekyll"]},{appName:"Eleventy",iconKey:"eleventy",names:["eleventy","11ty"]},{appName:"Docusaurus",iconKey:"docusaurus",names:["docusaurus"]},{appName:"Trunk",iconKey:"rust",names:["trunk"]},{appName:"wasm-pack",iconKey:"webassembly",names:["wasm-pack"]},{appName:"wasmtime",iconKey:"webassembly",names:["wasmtime"]},{appName:"Language Server",iconKey:"language-server",names:["lua-language-server","yaml-language-server","vscode-json-language-server","docker-langserver","bash-language-server","marksman","taplo"]}],AI=new Map;for(let e of f9)for(let t of e.names)AI.set(m9(t),{appName:e.appName,iconKey:e.iconKey});prt=AI.size});var CI=N(()=>{"use strict"});async function RI(e){let t=[],n=new Set,r=new Set,i=[],o=null;for(let s=0;s<Kb;s+=1){let d=await e.request("model/list",{cursor:o,limit:h9,includeHidden:!1}),l=y9(d,"model/list"),u=Tn(l.data);if(u===void 0)throw Dr("model/list response did not include data");for(let m of u){let y=ge(m),h=ie(y?.model)?.trim(),b=ie(y?.displayName)?.trim(),g=Tn(y?.supportedReasoningEfforts),S=ie(y?.defaultReasoningEffort)?.trim();if(y===void 0||h===void 0||!Tu(h)||b===void 0||!Tu(b)||y.hidden!==!1||g===void 0||S===void 0||!Tu(S)||typeof y.isDefault!="boolean")throw Dr("model/list included invalid visible model metadata");if(n.has(h))throw Dr(`model/list repeated model ${h}`);let v=g.map(T=>{let C=ge(T),O=ie(C?.reasoningEffort)?.trim();if(O===void 0||!Tu(O))throw Dr(`model/list ${h} included invalid reasoning effort metadata`);return O});if(new Set(v).size!==v.length||!v.includes(S))throw Dr(`model/list ${h} included inconsistent reasoning effort metadata`);if(n.add(h),t.push({id:h,displayName:b,reasoningEfforts:v,defaultReasoningEffort:S}),y.isDefault&&i.push(h),t.length>EI)throw Dr(`model/list exceeded ${EI} visible models`)}let c=l.nextCursor;if(c===null)break;let p=ie(c)?.trim();if(p===void 0||!Tu(p))throw Dr("model/list included invalid pagination cursor");if(r.has(p))throw Dr(`model/list repeated pagination cursor ${p}`);if(r.add(p),o=p,s===Kb-1)throw Dr(`model/list exceeded ${Kb} pagination pages`)}if(t.length===0)return{type:"empty"};if(i.length!==1)throw Dr("model/list did not advertise exactly one valid default model");let[a]=i;if(a===void 0)throw Dr("model/list did not advertise exactly one valid default model");return{type:"ready",catalog:{defaultModel:a,models:t}}}function y9(e,t){if("error"in e)throw new Error(`${t} failed: ${e.error.message}`);let n=ge(e.result);if(n===void 0)throw new Error(`${t} response did not include an object result`);return n}function g9(){let e=process.env.LINZUMI_CODEX_START_REQUEST_TIMEOUT_MS?.trim();if(e===void 0||e==="")return OI;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:OI}function b9(e,t,n=g9()){return v9(e,t,n,(r,i)=>new Hb(r,i))}function v9(e,t,n,r){return n>0?new Promise((i,o)=>{let a=setTimeout(()=>{o(r(e,n))},n);a.unref?.(),t.then(s=>{clearTimeout(a),i(s)},s=>{clearTimeout(a),o(s)})}):t}function Au(e,t,n){return b9(t,e.request(t,n))}async function xI(e,t,n,r,i,o){o("kandan.reconnect_thread_unarchive_started",{codex_thread_id:t,discovered_by:r,message:i});try{let a=await Au(e,"thread/unarchive",{threadId:t});if("error"in a)throw new Error(`thread/unarchive failed: ${a.error.message}`);let s=await Au(e,"thread/resume",n);if("error"in s)throw new Error(`thread/resume after unarchive failed: ${s.error.message}`);return o("kandan.reconnect_thread_unarchive_resumed",{codex_thread_id:t,discovered_by:r}),{mode:"resumed"}}catch(a){let s=a instanceof Error?a.message:String(a);throw o("kandan.reconnect_thread_unarchive_failed",{codex_thread_id:t,discovered_by:r,archive_error:i,message:s}),new Error(r==="forced_inject_not_found"?`thread/inject_items failed: ${i}; archive recovery failed: ${s}`:s)}}async function PI(e){let{codex:t,codexThreadId:n,rehydration:r}=e,i={threadId:n,...e.resumeOverrides},o;if(r.forceRehydrate===!0)o="the server marked the durable engine session dead after an acknowledged-but-unexecuted turn";else{let s=await Au(t,"thread/resume",i);if(!("error"in s))return{mode:"resumed"};if(A9(s.error.message))throw r.log("linzumi.agent_thread_resume_failed_unrecoverable",{codex_thread_id:n,message:s.error.message,rehydrating:!1}),new Error(s.error.message);if(S9(s.error.message))return await xI(t,n,i,"resume_archived",s.error.message,r.log);if(e.rebuildWhen==="missing-rollout-only"&&!T9(s.error.message))throw r.log("linzumi.agent_thread_resume_failed_unrecoverable",{codex_thread_id:n,message:s.error.message,rehydrating:!1}),new Error(s.error.message);o=s.error.message}r.log(r.forceRehydrate===!0?"kandan.reconnect_thread_rehydrate_forced":"kandan.reconnect_thread_resume_failed",{codex_thread_id:n,message:o,forced:r.forceRehydrate===!0,rehydrating:!0});let a;try{let s;try{s=await r.buildRehydrationItems?.(o)}catch(u){r.log("kandan.reconnect_thread_rehydration_items_failed",{codex_thread_id:n,message:u instanceof Error?u.message:String(u)}),s=void 0}let d=s!==void 0&&s.length>0?[...s]:[{type:"agentMessage",text:await r.buildRehydrationText(o)}],l=await Au(t,"thread/inject_items",{threadId:n,items:d});if("error"in l){if(r.forceRehydrate===!0&&w9(l.error.message))return await xI(t,n,i,"forced_inject_not_found",l.error.message,r.log);a=`thread/inject_items failed: ${l.error.message}`}else{let u=await Au(t,"thread/resume",i);"error"in u&&(a=`rehydrated thread/resume failed: ${u.error.message}`)}}catch(s){a=s instanceof Error?s.message:String(s)}if(a!==void 0)throw r.log("kandan.reconnect_thread_rehydration_failed",{codex_thread_id:n,resume_failure:o,rehydration_failure:a}),new Error(`could not resume this thread's engine session (${o}) and rebuilding a fresh session from the thread transcript also failed (${a})`);return r.log("kandan.reconnect_thread_rehydrated",{codex_thread_id:n,resume_failure:o}),{mode:"rehydrated",resumeFailure:o}}var EI,h9,Kb,_9,mr,Dr,Tu,OI,Hb,S9,w9,T9,A9,Jb=N(()=>{"use strict";ux();Og();PR();lb();qR();zR();hb();ep();yb();JR();Mf();Vf();VR();bo();ZR();QP();tI();aI();Lb();Kt();Gb();sI();hu();tp();dI();Ub();pI();mI();hI();gI();Nb();em();vI();Yt();SI();Gl();wI();zb();TI();kI();CI();EI=100,h9=100,Kb=20,_9=255,mr=class extends Error{constructor(t){super(t),this.name="NativeModelCatalogInvalidResponseError"}},Dr=e=>new mr(e),Tu=e=>e!==""&&e.length<=_9;OI=12e4;Hb=class extends Error{constructor(t,n){super(`Codex ${t} did not reply within ${n}ms (start request timed out)`),this.name="CodexStartRequestTimeoutError"}};S9=e=>/\bsession\b.+\bis archived\b/i.test(e),w9=e=>/^thread not found(?:\s*:|\b)/i.test(e.trim()),T9=e=>/\bno rollout found\b/i.test(e)||/\bsession not found\b[\s\S]*\brollout\b/i.test(e),A9=e=>/\balready has an active writer\b/i.test(e)});var II=N(()=>{});var Dat,$at,Nat,jat,Lat,MI=N(()=>{II();rt();Ni();Ke();we();Ue();mo();it();$p();ob();Dat=fu("LoggedIn"),$at=fu("NotLoggedIn"),Nat=fu("BinaryMissing"),jat=fu("ProbeFailed"),Lat=new RegExp("[\\x00-\\x1f\\x7f-\\x9f]")});var DI=N(()=>{MI()});var $I=N(()=>{$p()});var NI=N(()=>{"use strict"});function jI(e){return typeof e!="string"||e===""?e:E9.reduce((t,n)=>n.source.startsWith("\\beyJ")?t.replace(n,"<redacted>"):t.replace(n,"$1<redacted>"),e)}var E9,Qat,Xat,LI=N(()=>{"use strict";E9=[/(--token[=\s]+)\S+/gi,/(bearer\s+)[^\s,;"'\]\}]+/gi,/((?:access[_-]?token|api[_-]?key|auth[_-]?token|authorization|secret|password|refresh[_-]?token|session[_-]?token|jwt|token)["']?\s*[:=]\s*["']?)[^\s,;"'\]\}]+/gi,/\beyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g];Qat=64*1024,Xat=16*1024});var GI=N(()=>{"use strict"});var FI=N(()=>{"use strict";Kt()});var Kz={};V2(Kz,{AbortError:()=>Lr,CommandMatcher:()=>rT,DirectConnectError:()=>_r,DirectConnectTransport:()=>sT,EXIT_REASONS:()=>ODe,FileIndex:()=>iT,HOOK_EVENTS:()=>Xa,InMemorySessionStore:()=>Uw,ORG_POLICY_LIMIT_PREFIXES:()=>y1e,SYSTEM_PROMPT_DYNAMIC_BOUNDARY:()=>xDe,USAGE_LIMIT_ERROR_PREFIXES:()=>_1e,USAGE_TRANSITION_PREFIXES:()=>b1e,USAGE_WARNING_PREFIXES:()=>g1e,createSdkMcpServer:()=>CDe,deleteSession:()=>CJe,filterEscalatingDefaultMode:()=>mKe,foldSessionSummary:()=>OF,forkSession:()=>MJe,getSessionInfo:()=>IJe,getSessionMessages:()=>RJe,getSubagentMessages:()=>jJe,importSessionToStore:()=>DJe,listSessions:()=>PJe,listSubagents:()=>NJe,parseDirectConnectUrl:()=>R1e,prewarm:()=>mJe,query:()=>cJe,renameSession:()=>AJe,resolveSettings:()=>xJe,startup:()=>pJe,tagSession:()=>kJe,tool:()=>kDe});import{createRequire as O9}from"node:module";import{randomUUID as Bv}from"crypto";import{createHash as $5}from"crypto";import{basename as JY,dirname as aM}from"path";import{realpathSync as dM}from"node:fs";import{cwd as nQ}from"node:process";import{readFileSync as mX,realpathSync as dj,statSync as _M}from"fs";import{homedir as fj}from"os";import{dirname as bM,resolve as _d,sep as no}from"path";import*as kS from"path";import{createReadStream as QX}from"fs";import{readdir as XX,readFile as eee}from"fs/promises";import{dirname as tee,join as Cj,relative as nee,sep as ree}from"path";import{createInterface as iee}from"readline";import{appendFile as rv,mkdir as DM,rename as $M,stat as oee,symlink as aee,unlink as iv}from"fs/promises";import{dirname as od,isAbsolute as see,join as No,resolve as Ej}from"path";import{homedir as vee}from"os";import{join as See,resolve as jM}from"path";import*as Re from"fs";import{appendFile as Iee,chmod as Mee,copyFile as Dee,link as $ee,lstat as ov,mkdir as Nee,open as am,readdir as jee,readFile as LM,readlink as Lee,realpath as Gee,rename as Fee,rmdir as qee,rm as Uee,stat as GM,symlink as Bee,unlink as zee}from"fs/promises";import*as Ve from"path";import{readFile as Ute}from"fs/promises";import{constants as Uie}from"fs";import{access as uw,readdir as Bie,readFile as zie,readlink as Kie}from"fs/promises";import{homedir as Hie}from"os";import{delimiter as Jie,join as wc,resolve as tL}from"path";import{readFile as oD}from"fs/promises";import{release as noe}from"os";import Ut from"node:path";import dL from"node:os";import cw from"node:process";import{isAbsolute as qoe}from"path";import{once as dD}from"events";import{constants as Uu,createWriteStream as NTe}from"fs";import{lstat as jTe,open as SL,readdir as Ju,realpath as wL,stat as LTe}from"fs/promises";import{basename as GTe,dirname as FTe,join as Fr}from"path";import{execFile as zTe}from"child_process";import{promisify as KTe}from"util";import{execFileSync as HTe}from"child_process";import{lstatSync as JTe}from"fs";import{join as WTe}from"path";import{basename as HD,dirname as JD,join as gOe}from"path";import{createHash as EOe}from"crypto";import{constants as NG}from"fs";import{isAbsolute as vxe,sep as VD}from"path";import{readdir as QA,stat as Ixe}from"fs/promises";import{basename as Mxe,dirname as Dxe,join as $xe}from"path";import{basename as Lxe,join as Ec}from"path";import{readFile as Gxe}from"fs/promises";import{dirname as Fxe,join as qxe}from"path";import{basename as QD,dirname as XD}from"path";import{constants as mm}from"fs";import{lstat as Xxe,open as eRe}from"fs/promises";import{dirname as tRe,join as nRe}from"path";import{randomUUID as hm}from"crypto";import{basename as bRe,join as $a}from"path";import{AsyncLocalStorage as vRe}from"async_hooks";import{constants as SRe}from"fs";import{appendFile as wRe,copyFile as TRe,lstat as ARe,mkdir as kRe,open as r1,readdir as i1,readFile as o1,stat as CRe,unlink as ERe,writeFile as pv}from"fs/promises";import{randomBytes as ORe}from"crypto";import{constants as nn}from"fs";import{lstat as O_,open as ef,rename as _F,stat as xRe,unlink as Bu,writeFile as RRe}from"fs/promises";import{basename as PRe,join as IRe}from"path";import{readdir as SPe,readFile as l1}from"fs/promises";import{isAbsolute as wF,join as gh,relative as TF,sep as bh}from"path";import{randomUUID as k1e}from"crypto";import{join as L1}from"path";import{resolve as I1e}from"path";import{join as Td}from"path";import{dirname as Y1e}from"path";import{open as r$e}from"fs/promises";import{join as f$e}from"path";import{homedir as nLe}from"os";import{dirname as rLe,join as qr,resolve as Un}from"path";import{join as Uq}from"path";import{isAbsolute as o$}from"path";import{posix as oU,win32 as aU}from"path";import{posix as hGe,win32 as _Ge}from"path";import{isIPv4 as bGe,isIPv6 as vGe}from"net";import{userInfo as QBe}from"os";import{execFile as M2e}from"child_process";import{accessSync as D2e,closeSync as $2e,constants as N2e,openSync as j2e,readSync as L2e}from"fs";import{execFile as hKe}from"child_process";import{randomUUID as _Ke}from"crypto";import{mkdir as zh,mkdtemp as yKe,readFile as gKe,rm as yz,writeFile as gz}from"fs/promises";import{createRequire as bKe}from"module";import{homedir as Nc,tmpdir as vKe}from"os";import{dirname as bN,isAbsolute as WT,join as qt,posix as bz,resolve as jc,sep as SKe,win32 as vz}from"path";import{fileURLToPath as wKe}from"url";import{setMaxListeners as TKe}from"events";import{spawn as EKe}from"child_process";import{existsSync as OKe}from"fs";import{createInterface as xKe}from"readline";import{StringDecoder as RKe}from"string_decoder";import{existsSync as WKe}from"fs";import{copyFile as qHe,readFile as UHe,rm as Rz,writeFile as Pz}from"fs/promises";import{homedir as CN}from"os";import{join as Fv}from"path";import{createHash as KHe}from"crypto";import{userInfo as HHe}from"os";import{realpathSync as XHe}from"fs";import{isAbsolute as eJe,relative as tJe,resolve as nJe,sep as rJe}from"path";import{randomUUID as Nz}from"crypto";import{constants as PN}from"fs";import{open as hJe,readdir as jz,rm as IN,stat as _Je}from"fs/promises";import{join as to}from"path";function I9(e){return this[e]}function N9(e,t){this[e]=$9.bind(null,t)}function j5(e){return N5.test(e)}function L5(e,t){let n=Buffer.from(t.replace(/-/g,""),"hex"),r=$5("sha1").update(n).update(Buffer.from(e,"utf8")).digest();r[6]=r[6]&15|80,r[8]=r[8]&63|128;let i=r.subarray(0,16).toString("hex");return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20,32)}`}function F5(){let e=process.env.CLAUDE_CODE_REMOTE_SESSION_ID?.trim();return e?L5(e,G5):null}function q5(){this.__data__=[],this.size=0}function B5(e,t){return e===t||e!==e&&t!==t}function z5(e,t){for(var n=e.length;n--;)if(Uc(e[n][0],t))return n;return-1}function J5(e){var t=this.__data__,n=Zh(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():H5.call(t,n,1),--this.size,!0}function V5(e){var t=this.__data__,n=Zh(t,e);return n<0?void 0:t[n][1]}function Y5(e){return Zh(this.__data__,e)>-1}function X5(e,t){var n=this.__data__,r=Zh(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function Jd(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function t8(){this.__data__=new Yh,this.size=0}function r8(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function o8(e){return this.__data__.get(e)}function s8(e){return this.__data__.has(e)}function _8(e){var t=m8.call(e,ku),n=e[ku];try{e[ku]=void 0;var r=!0}catch{}var i=h8.call(e);return r&&(t?e[ku]=n:delete e[ku]),i}function v8(e){return b8.call(e)}function A8(e){return e==null?e===void 0?T8:w8:BI&&BI in Object(e)?y8(e):S8(e)}function k8(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function R8(e){if(!Ur(e))return!1;var t=Ja(e);return t==E8||t==O8||t==C8||t==x8}function I8(e){return!!zI&&zI in e}function N8(e){if(e!=null){try{return $8.call(e)}catch{}try{return e+""}catch{}}return""}function z8(e){if(!Ur(e)||M8(e))return!1;var t=aA(e)?B8:L8;return t.test(Wa(e))}function H8(e,t){return e?.[t]}function W8(e,t){var n=J8(e,t);return K8(n)?n:void 0}function Y8(){this.__data__=oc?oc(null):{},this.size=0}function X8(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function iZ(e){var t=this.__data__;if(oc){var n=t[e];return n===tZ?void 0:n}return rZ.call(t,e)?t[e]:void 0}function dZ(e){var t=this.__data__;return oc?t[e]!==void 0:sZ.call(t,e)}function cZ(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=oc&&t===void 0?uZ:t,this}function Wd(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function pZ(){this.size=0,this.__data__={hash:new KI,map:new(ic||Yh),string:new KI}}function hZ(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function yZ(e,t){var n=e.__data__;return _Z(t)?n[typeof t=="string"?"string":"hash"]:n.map}function gZ(e){var t=Qh(this,e).delete(e);return this.size-=t?1:0,t}function vZ(e){return Qh(this,e).get(e)}function wZ(e){return Qh(this,e).has(e)}function AZ(e,t){var n=Qh(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function Vd(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function EZ(e,t){var n=this.__data__;if(n instanceof Yh){var r=n.__data__;if(!ic||r.length<CZ-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Xh(r)}return n.set(e,t),this.size=n.size,this}function Zd(e){var t=this.__data__=new Yh(e);this.size=t.size}function RZ(e){return this.__data__.set(e,xZ),this}function IZ(e){return this.__data__.has(e)}function Gm(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new Xh;++t<n;)this.add(e[t])}function $Z(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function jZ(e,t){return e.has(t)}function qZ(e,t,n,r,i,o){var a=n&GZ,s=e.length,d=t.length;if(s!=d&&!(a&&d>s))return!1;var l=o.get(e),u=o.get(t);if(l&&u)return l==t&&u==e;var c=-1,p=!0,m=n&FZ?new DZ:void 0;for(o.set(e,t),o.set(t,e);++c<s;){var y=e[c],h=t[c];if(r)var b=a?r(h,y,c,t,e,o):r(y,h,c,e,t,o);if(b!==void 0){if(b)continue;p=!1;break}if(m){if(!NZ(t,function(g,S){if(!LZ(m,S)&&(y===g||i(y,g,n,r,o)))return m.push(S)})){p=!1;break}}else if(!(y===h||i(y,h,n,r,o))){p=!1;break}}return o.delete(e),o.delete(t),p}function BZ(e){var t=-1,n=Array(e.size);return e.forEach(function(r,i){n[++t]=[i,r]}),n}function KZ(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}function a7(e,t,n,r,i,o,a){switch(n){case o7:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case i7:return!(e.byteLength!=t.byteLength||!o(new Fm(e),new Fm(t)));case VZ:case ZZ:case XZ:return Uc(+e,+t);case YZ:return e.name==t.name&&e.message==t.message;case e7:case n7:return e==t+"";case QZ:var s=zZ;case t7:var d=r&JZ;if(s||(s=HZ),e.size!=t.size&&!d)return!1;var l=a.get(e);if(l)return l==t;r|=WZ,a.set(e,t);var u=HN(s(e),s(t),r,i,o,a);return a.delete(e),u;case r7:if(Vb)return Vb.call(e)==Vb.call(t)}return!1}function d7(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function u7(e,t,n){var r=t(e);return rr(e)?r:sA(r,n(e))}function c7(e,t){for(var n=-1,r=e==null?0:e.length,i=0,o=[];++n<r;){var a=e[n];t(a,n,e)&&(o[i++]=a)}return o}function p7(){return[]}function y7(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function b7(e){return e!=null&&typeof e=="object"}function S7(e){return Ai(e)&&Ja(e)==v7}function C7(){return!1}function M7(e,t){var n=typeof e;return t=t??P7,!!t&&(n=="number"||n!="symbol"&&I7.test(e))&&e>-1&&e%1==0&&e<t}function $7(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=D7}function aY(e){return Ai(e)&&lA(e.length)&&!!Pt[Ja(e)]}function dY(e){return function(t){return e(t)}}function mY(e,t){var n=rr(e),r=!n&&ac(e),i=!n&&!r&&kd(e),o=!n&&!r&&!i&&cA(e),a=n||r||i||o,s=a?g7(e.length,String):[],d=s.length;for(var l in e)(t||pY.call(e,l))&&!(a&&(l=="length"||i&&(l=="offset"||l=="parent")||o&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||e_(l,d)))&&s.push(l);return s}function _Y(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||hY;return e===n}function yY(e,t){return function(n){return e(t(n))}}function wY(e){if(!fA(e))return bY(e);var t=[];for(var n in Object(e))SY.call(e,n)&&n!="constructor"&&t.push(n);return t}function AY(e){return e!=null&&lA(e.length)&&!aA(e)}function kY(e){return t_(e)?YN(e):TY(e)}function CY(e){return JN(e,Bc,dA)}function RY(e,t,n,r,i,o){var a=n&EY,s=zv(e),d=s.length,l=zv(t),u=l.length;if(d!=u&&!a)return!1;for(var c=d;c--;){var p=s[c];if(!(a?p in t:xY.call(t,p)))return!1}var m=o.get(e),y=o.get(t);if(m&&y)return m==t&&y==e;var h=!0;o.set(e,t),o.set(t,e);for(var b=a;++c<d;){p=s[c];var g=e[p],S=t[p];if(r)var v=a?r(S,g,p,t,e,o):r(g,S,p,e,t,o);if(!(v===void 0?g===S||i(g,S,n,r,o):v)){h=!1;break}b||(b=p=="constructor")}if(h&&!b){var T=e.constructor,C=t.constructor;T!=C&&"constructor"in e&&"constructor"in t&&!(typeof T=="function"&&T instanceof T&&typeof C=="function"&&C instanceof C)&&(h=!1)}return o.delete(e),o.delete(t),h}function zY(e,t,n,r,i,o){var a=rr(e),s=rr(t),d=a?iM:sc(e),l=s?iM:sc(t);d=d==rM?nm:d,l=l==rM?nm:l;var u=d==nm,c=l==nm,p=d==l;if(p&&kd(e)){if(!kd(t))return!1;a=!0,u=!1}if(p&&!u)return o||(o=new hd),a||cA(e)?HN(e,t,n,r,i,o):s7(e,t,d,n,r,i,o);if(!(n&UY)){var m=u&&oM.call(e,"__wrapped__"),y=c&&oM.call(t,"__wrapped__");if(m||y){var h=m?e.value():e,b=y?t.value():t;return o||(o=new hd),i(h,b,n,r,o)}}return p?(o||(o=new hd),PY(e,t,n,r,i,o)):!1}function XN(e,t,n,r,i){return e===t?!0:e==null||t==null||!Ai(e)&&!Ai(t)?e!==e&&t!==t:KY(e,t,n,r,XN,i)}function HY(e,t){return pA(e,t)}function dt(){return WY===!0}function wt(e){if(!e)return!1;if(typeof e=="boolean")return e;let t=String(e).toLowerCase().trim();return["1","true","yes","on"].includes(t)}function ej(e){if(e===void 0)return!1;if(typeof e=="boolean")return!e;let t=String(e).toLowerCase().trim();return["0","false","no","off"].includes(t)}function Bn(){let e=new Set;return{subscribe(t){let n=VY(t);return e.add(n),()=>{e.delete(n)}},emit(...t){let n;for(let r of e)try{r(...t)}catch(i){(n??=[]).push(i)}if(n)throw n.length===1?n[0]:AggregateError(n,"Signal listener(s) threw")},clear(){e.clear()}}}function Zv(){return{sent:new Set,rejected:new Set,declaredTools:void 0,noChannelTools:void 0,declaredToolsDecided:!1,nameOnlyAnnouncements:new Set,surfacedOnWire:new Set,definedByValue:new Set,inlineToolsRefusal:{rejectedHeader:void 0,announcementsByName:new Set},advisorHeld:void 0,wireShapeSeed:void 0,webSearchHistoryRejected:!1}}function YY(e,t){for(let n of t.sent)tQ(e,n);for(let n of t.rejected)tj(e,n);e.wireShapeSeed=t}function QY(e){let t=Zv();t.declaredTools=e.declaredTools,t.noChannelTools=e.noChannelTools,t.declaredToolsDecided=e.declaredToolsDecided,t.advisorHeld=e.advisorHeld,e.wireShapeSeed!==void 0&&YY(t,e.wireShapeSeed);let{rejectedHeader:n,announcementsByName:r}=e.inlineToolsRefusal;return n!==void 0&&XY(t,n),eQ(t,r),t.webSearchHistoryRejected=e.webSearchHistoryRejected,t}function XY(e,t){tj(e,t),e.inlineToolsRefusal.rejectedHeader=t}function eQ(e,t){for(let n of t)e.inlineToolsRefusal.announcementsByName.add(n),e.nameOnlyAnnouncements.add(n)}function tQ(e,t){e.rejected.has(t)||e.sent.add(t)}function tj(e,t){e.sent.delete(t),e.rejected.add(t)}function lM(e){return process.platform==="darwin"?e.normalize("NFC"):e}function nj(){let e="";if(typeof process<"u"&&typeof process.cwd=="function"&&typeof dM=="function")try{let t=nQ();try{e=lM(dM(t))}catch{e=lM(t)}}catch{}return e}function iQ(){if(uM===null)return null;let e=process.env.CLAUDE_CODE_SESSION_KIND;return e!==void 0&&String(e).trim()==="bg"?null:uM}function aQ(e,t,n){t=="__proto__"&&qm?qm(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function sQ(e){return function(t,n,r){for(var i=-1,o=Object(t),a=r(t),s=a.length;s--;){var d=a[e?s:++i];if(n(o[d],d,o)===!1)break}return t}}function uQ(e,t){return e&&rj(e,t,Bc)}function mQ(e,t,n,r){var i=n.length,o=i,a=!r;if(e==null)return!o;for(e=Object(e);i--;){var s=n[i];if(a&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<o;){s=n[i];var d=s[0],l=e[d],u=s[1];if(a&&s[2]){if(l===void 0&&!(d in e))return!1}else{var c=new hd;if(r)var p=r(l,u,d,e,t,c);if(!(p===void 0?pA(u,l,fQ|pQ,r,c):p))return!1}}return!0}function _Q(e){return e===e&&!Ur(e)}function yQ(e){for(var t=Bc(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,ij(i)]}return t}function bQ(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==void 0||e in Object(n))}}function vQ(e){var t=gQ(e);return t.length==1&&t[0][2]?oj(t[0][0],t[0][1]):function(n){return n===e||hQ(n,e,t)}}function TQ(e){return typeof e=="symbol"||Ai(e)&&Ja(e)==wQ}function CQ(e,t){if(rr(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||mA(e)?!0:kQ.test(e)||!AQ.test(e)||t!=null&&e in Object(t)}function _A(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw TypeError(EQ);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=e.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(_A.Cache||Xh),n}function xQ(e){var t=yA(e,function(r){return n.size===OQ&&n.clear(),r}),n=t.cache;return t}function $Q(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}function aj(e){if(typeof e=="string")return e;if(rr(e))return gA(e,aj)+"";if(mA(e))return fM?fM.call(e):"";var t=e+"";return t=="0"&&1/e==-NQ?"-0":t}function LQ(e){return e==null?"":jQ(e)}function FQ(e,t){return rr(e)?e:hA(e,t)?[e]:DQ(GQ(e))}function UQ(e){if(typeof e=="string"||mA(e))return e;var t=e+"";return t=="0"&&1/e==-qQ?"-0":t}function BQ(e,t){t=Yd(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[Fa(t[n++])];return n&&n==r?e:void 0}function zQ(e,t,n){var r=e==null?void 0:r_(e,t);return r===void 0?n:r}function HQ(e,t){return e!=null&&t in Object(e)}function WQ(e,t,n){t=Yd(t,e);for(var r=-1,i=t.length,o=!1;++r<i;){var a=Fa(t[r]);if(!(o=e!=null&&n(e,a)))break;e=e[a]}return o||++r!=i?o:(i=e==null?0:e.length,!!i&&lA(i)&&e_(a,i)&&(rr(e)||ac(e)))}function ZQ(e,t){return e!=null&&VQ(e,t,JQ)}function XQ(e,t){return hA(e)&&ij(t)?oj(Fa(e),t):function(n){var r=KQ(n,e);return r===void 0&&r===t?sj(n,e):pA(t,r,YQ|QQ)}}function tX(e){return e}function nX(e){return function(t){return t?.[e]}}function iX(e){return function(t){return r_(t,e)}}function aX(e){return hA(e)?rX(Fa(e)):oX(e)}function dX(e){return typeof e=="function"?e:e==null?bA:typeof e=="object"?rr(e)?eX(e[0],e[1]):SQ(e):sX(e)}function lX(e,t){var n={};return t=i_(t,3),cQ(e,function(r,i,o){n_(n,i,t(r,i,o))}),n}function uX(e,t){for(var n,r=-1,i=e.length;++r<i;){var o=t(e[r]);o!==void 0&&(n=n===void 0?o:n+o)}return n}function fX(e,t){return e&&e.length?cX(e,i_(t,2)):0}function rm(e){return Object.assign(Object.create(null),e)}function lj(e,t){return e}function Mn(e){return e}function zc(e){return e}function uj(e){return e}function _X(e){try{if(e!==null&&typeof e=="object"&&"telemetryMessage"in e&&typeof e.telemetryMessage=="string")return e.telemetryMessage}catch{}}function yX(e,t){return e instanceof Error&&e.message===t}function qa(e){return e instanceof Error?e:Error(String(e))}function bi(e){return e instanceof Error?e.message:String(e)}function tt(e){if(e&&typeof e=="object"&&"code"in e&&typeof e.code=="string")return e.code}function Cm(e){return gX(tt(e))}function gX(e){return e&&/^[A-Z][A-Z0-9_]{0,63}$/.test(e)?uj(e):void 0}function cj(e){if(typeof e=="string")return/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(e)?uj(e):Mn("nonconforming")}function Wr(e){return tt(e)==="ENOENT"}function yM(e){return tt(e)==="EISDIR"}function gM(e){return vX(tt(e))}function vX(e){return e!==void 0&&bX.has(e)}function Kc(e,t,n){return new Promise((r,i)=>{if(t?.aborted){n?.throwOnAbort||n?.abortError?i(n.abortError?.()??Error("aborted")):r();return}let o=setTimeout((s,d,l)=>{s?.removeEventListener("abort",d),l()},e,t,a,r);function a(){clearTimeout(o),n?.throwOnAbort||n?.abortError?i(n.abortError?.()??Error("aborted")):r()}t?.addEventListener("abort",a,{once:!0}),n?.unref&&o.unref()})}function SX(e,t){e(Error(t))}function Uo(e,t,n){let r,i=new Promise((o,a)=>{r=setTimeout(SX,t,a,n)});return Promise.race([e,i]).finally(()=>{r!==void 0&&clearTimeout(r)})}function TX(e,t,n=wX){let r=()=>{},i=new Promise(o=>{r=n(()=>o(void 0),t)});return Promise.race([e,i]).finally(r)}function on(e){return process.platform==="darwin"?e.normalize("NFC"):e}function io(e){return/^[\\/]{2}/.test(e)||s_(e)}function o_(e){return/(^|[\\/])\.\.([\\/]|$)/.test(e)}function vM(e){return/^[\\/]{2}[?.][\\/](?!unc[\\/])/i.test(e)?null:e.match(/^[\\/]{2}(?:[?.][\\/]unc[\\/])?([^\\/]+)/i)?.[1]?.replace(/[A-Z]/g,t=>t.toLowerCase())??null}function yd(e){return/(^|[\\/])\.{1,2}[. ]*([\\/]|$)/.test(e)}function a_(e){return/^[\\/]{2}[?.][\\/]/.test(e)}function Hc(e){if(!/\/\.(?:vol|file|nofollow|resolve)(?:\/|$)/i.test(e)||!e.startsWith("/"))return!1;let t=[];for(let n of e.split("/"))if(!(n===""||n===".")){if(n===".."){t.pop();continue}if(t.push(n),t.length===1&&/^\.(?:vol|file|nofollow|resolve)$/i.test(n))return!0}return!1}function AX(e){return/^[\\/](GLOBAL\?\?|GLOBALROOT|DosDevices|Device)[\\/]/i.test(e)}function kX(e,t){if(!io(e))return!1;if(a_(e)||s_(e)||yd(e))return!0;let n=vM(e);return n===null||n!==vM(t)}function pj(e){return e.length===2&&Yb(e[0])==="net"||e.length===3&&Yb(e[0])==="network"&&Yb(e[1])==="servers"}function Um(e){if(process.platform==="win32"||!e.startsWith("/"))return null;let t=[];for(let n of e.split("/"))if(!(n===""||n===".")){if(n===".."){t.pop();continue}if(t.push(n),pj(t))return Em(n)}return null}function Em(e){return e.replace(/[A-Z]/g,t=>t.toLowerCase())}function Yb(e){return e.replace(/[\u200c-\u200f\u202a-\u202e\u206a-\u206f\ufeff]/g,"").toUpperCase().toLowerCase()}function mj(e,t){if(Hc(e))return!0;if(Lo(e)){let n=Um(e);if(n===null||n!==Um(t))return!0}return CX(e,t)}function CX(e,t,n=process.platform,r=n==="darwin"&&(process.platform!=="darwin"||hj())){if(n!=="darwin"||!xX(e,n,r))return!1;let i=CS(t,n,r).complete[0]??null,{complete:o,partial:a}=CS(e,n,r);return o.length===0&&a.length===0||i===null?!0:o.some(s=>s!==i)||a.some(s=>!i.startsWith(s))}function hj(e=SM){let t=e===SM;if(t&&Qb.value!==void 0)return Qb.value;let n;try{let r=!1;try{r=e.readAutoMaster().split(`
|
|
158
|
+
`,1)[0]??e}function s9(e,t){return e.length<=t?e:`[...truncated...]${e.slice(e.length-t)}`}var lI,Ub=N(()=>{"use strict";Us();Kt();hu();Yt();lI=76800});var pI=N(()=>{"use strict";Kt()});var mI=N(()=>{"use strict";Kt();em()});var hI=N(()=>{"use strict"});var _I=N(()=>{we();Ue();ft()});var yI=N(()=>{_I()});var gI=N(()=>{"use strict";Gb();yI()});var tm,bI=N(()=>{tm={default:{maxLadderMs:9e5},wafer:{maxLadderMs:36e5}}});var Hnt,Jnt,vI=N(()=>{"use strict";bI();Hnt={maxRecoveryRungs:4,maxLadderMs:tm.default.maxLadderMs,maxRateLimitHoldMs:30*6e4},Jnt={default:tm.default,wafer:tm.wafer}});var SI=N(()=>{"use strict"});var Ynt,wI=N(()=>{"use strict";Yt();Ynt=10*6e4});var Bb=N(()=>{"use strict";go()});var zb=N(()=>{"use strict";Bb();Bb()});var TI=N(()=>{"use strict";zb()});function p9(e){let t=e.toLowerCase();switch(!0){case t.endsWith(".app"):return e.slice(0,-4);case t.endsWith(".exe"):return e.slice(0,-4);case t.endsWith(".cmd"):case t.endsWith(".bat"):return e.slice(0,-4);default:return e}}function m9(e){return p9(e.trim().replaceAll("\\","/").toLowerCase())}var f9,AI,prt,kI=N(()=>{"use strict";f9=[{appName:"Bun",iconKey:"bun",names:["bun","bunx"]},{appName:"Node.js",iconKey:"nodejs",names:["node","nodejs","node.exe"]},{appName:"npm",iconKey:"npm",names:["npm","npm-cli.js","npx"]},{appName:"pnpm",iconKey:"pnpm",names:["pnpm","pnpx"]},{appName:"Yarn",iconKey:"yarn",names:["yarn","yarnpkg","yarn.js"]},{appName:"Corepack",iconKey:"corepack",names:["corepack"]},{appName:"Deno",iconKey:"deno",names:["deno"]},{appName:"Vite",iconKey:"vite",names:["vite","vite-node"]},{appName:"Vitest",iconKey:"vitest",names:["vitest"]},{appName:"Next.js",iconKey:"nextjs",names:["next","next-server"]},{appName:"Nuxt",iconKey:"nuxt",names:["nuxt","nuxi"]},{appName:"Astro",iconKey:"astro",names:["astro"]},{appName:"SvelteKit",iconKey:"svelte",names:["svelte-kit","sveltekit"]},{appName:"Remix",iconKey:"remix",names:["remix"]},{appName:"Expo",iconKey:"expo",names:["expo","expo-cli"]},{appName:"React Native",iconKey:"react",names:["react-native"]},{appName:"Metro",iconKey:"metro",names:["metro","metro-inspector-proxy"]},{appName:"Webpack",iconKey:"webpack",names:["webpack","webpack-dev-server","webpack-cli"]},{appName:"Parcel",iconKey:"parcel",names:["parcel"]},{appName:"Rollup",iconKey:"rollup",names:["rollup"]},{appName:"esbuild",iconKey:"esbuild",names:["esbuild"]},{appName:"SWC",iconKey:"swc",names:["swc"]},{appName:"TypeScript",iconKey:"typescript",names:["tsc","tsserver","tsx","ts-node","typescript-language-server"]},{appName:"ESLint",iconKey:"eslint",names:["eslint","eslint_d"]},{appName:"Prettier",iconKey:"prettier",names:["prettier"]},{appName:"Biome",iconKey:"biome",names:["biome"]},{appName:"Storybook",iconKey:"storybook",names:["storybook","start-storybook"]},{appName:"Playwright",iconKey:"playwright",names:["playwright"]},{appName:"Cypress",iconKey:"cypress",names:["cypress"]},{appName:"Jest",iconKey:"jest",names:["jest"]},{appName:"Python",iconKey:"python",names:["python","python2","python3","python3.9","python3.10","python3.11","python3.12","python3.13","pypy","pypy3"]},{appName:"pip",iconKey:"python",names:["pip","pip2","pip3"]},{appName:"pipx",iconKey:"python",names:["pipx"]},{appName:"uv",iconKey:"python",names:["uv","uvx"]},{appName:"Poetry",iconKey:"poetry",names:["poetry"]},{appName:"Pipenv",iconKey:"python",names:["pipenv"]},{appName:"Conda",iconKey:"conda",names:["conda","mamba","micromamba"]},{appName:"Django",iconKey:"django",names:["django-admin","django-admin.py","manage.py"]},{appName:"Flask",iconKey:"flask",names:["flask"]},{appName:"Uvicorn",iconKey:"uvicorn",names:["uvicorn"]},{appName:"Gunicorn",iconKey:"gunicorn",names:["gunicorn"]},{appName:"Hypercorn",iconKey:"python",names:["hypercorn"]},{appName:"Celery",iconKey:"celery",names:["celery"]},{appName:"Jupyter",iconKey:"jupyter",names:["jupyter","jupyter-lab","jupyter-notebook","ipython"]},{appName:"Ruby",iconKey:"ruby",names:["ruby","erb","irb"]},{appName:"Bundler",iconKey:"ruby",names:["bundle","bundler"]},{appName:"Rails",iconKey:"rails",names:["rails","bin/rails"]},{appName:"Rack",iconKey:"ruby",names:["rackup"]},{appName:"Puma",iconKey:"puma",names:["puma"]},{appName:"Sidekiq",iconKey:"sidekiq",names:["sidekiq"]},{appName:"RSpec",iconKey:"ruby",names:["rspec"]},{appName:"Go",iconKey:"go",names:["go","gofmt","gopls","air"]},{appName:"Delve",iconKey:"go",names:["dlv"]},{appName:"Rust",iconKey:"rust",names:["rustc","rustup","cargo","rust-analyzer"]},{appName:"Java",iconKey:"java",names:["java","javac","jar","jshell","jwebserver"]},{appName:"Gradle",iconKey:"gradle",names:["gradle","gradlew"]},{appName:"Maven",iconKey:"maven",names:["mvn","mvnw"]},{appName:"Spring Boot",iconKey:"spring",names:["spring","spring-boot"]},{appName:"Kotlin",iconKey:"kotlin",names:["kotlin","kotlinc","kotlin-language-server"]},{appName:"Scala",iconKey:"scala",names:["scala","scalac","sbt","metals"]},{appName:"Clojure",iconKey:"clojure",names:["clojure","clj","lein","boot"]},{appName:"PHP",iconKey:"php",names:["php","php-fpm","php-cgi","composer"]},{appName:"Laravel",iconKey:"laravel",names:["artisan","laravel"]},{appName:"Symfony",iconKey:"symfony",names:["symfony"]},{appName:"Elixir",iconKey:"elixir",names:["elixir","iex","mix"]},{appName:"Erlang",iconKey:"erlang",names:["erl","beam.smp","beam","epmd","rebar3"]},{appName:"Phoenix",iconKey:"phoenix",names:["phx.server","phoenix"]},{appName:"PostgreSQL",iconKey:"postgresql",names:["postgres","postmaster","pg_ctl","psql","pg_isready"]},{appName:"Redis",iconKey:"redis",names:["redis-server","redis-cli","redis-sentinel"]},{appName:"MySQL",iconKey:"mysql",names:["mysql","mysqld","mysqladmin"]},{appName:"MariaDB",iconKey:"mariadb",names:["mariadb","mariadbd","mariadb-admin"]},{appName:"SQLite",iconKey:"sqlite",names:["sqlite3","sqlite"]},{appName:"MongoDB",iconKey:"mongodb",names:["mongod","mongosh","mongo"]},{appName:"Elasticsearch",iconKey:"elasticsearch",names:["elasticsearch"]},{appName:"OpenSearch",iconKey:"opensearch",names:["opensearch"]},{appName:"Solr",iconKey:"solr",names:["solr"]},{appName:"Kafka",iconKey:"kafka",names:["kafka-server-start","kafka-console-consumer","kafka-console-producer"]},{appName:"ZooKeeper",iconKey:"zookeeper",names:["zookeeper-server-start","zkserver"]},{appName:"RabbitMQ",iconKey:"rabbitmq",names:["rabbitmq-server","rabbitmqctl"]},{appName:"NATS",iconKey:"nats",names:["nats-server","nats"]},{appName:"Docker",iconKey:"docker",names:["docker","dockerd","docker-compose","docker-proxy","com.docker.backend"]},{appName:"Podman",iconKey:"podman",names:["podman","podman-compose"]},{appName:"Kubernetes",iconKey:"kubernetes",names:["kubectl","kube-apiserver","kubelet","minikube","kind"]},{appName:"Helm",iconKey:"helm",names:["helm"]},{appName:"Tilt",iconKey:"tilt",names:["tilt"]},{appName:"nginx",iconKey:"nginx",names:["nginx"]},{appName:"Caddy",iconKey:"caddy",names:["caddy"]},{appName:"Apache HTTP Server",iconKey:"apache",names:["httpd","apache2","apachectl"]},{appName:"HAProxy",iconKey:"haproxy",names:["haproxy"]},{appName:"Traefik",iconKey:"traefik",names:["traefik"]},{appName:"Envoy",iconKey:"envoy",names:["envoy"]},{appName:"Tailscale",iconKey:"tailscale",names:["tailscale","tailscaled"]},{appName:"Cloudflare Tunnel",iconKey:"cloudflare",names:["cloudflared"]},{appName:"ngrok",iconKey:"ngrok",names:["ngrok"]},{appName:"localtunnel",iconKey:"terminal",names:["lt","localtunnel"]},{appName:"SSH",iconKey:"ssh",names:["ssh","sshd","scp","sftp"]},{appName:"Git",iconKey:"git",names:["git","git-lfs","git-upload-pack","git-receive-pack"]},{appName:"GitHub CLI",iconKey:"github",names:["gh"]},{appName:"GitLab CLI",iconKey:"gitlab",names:["glab"]},{appName:"Subversion",iconKey:"subversion",names:["svn"]},{appName:"Mercurial",iconKey:"mercurial",names:["hg"]},{appName:"AWS CLI",iconKey:"aws",names:["aws","aws-vault","sam"]},{appName:"Azure CLI",iconKey:"azure",names:["az"]},{appName:"Google Cloud CLI",iconKey:"google-cloud",names:["gcloud","gsutil","bq"]},{appName:"Terraform",iconKey:"terraform",names:["terraform"]},{appName:"OpenTofu",iconKey:"opentofu",names:["tofu"]},{appName:"Ansible",iconKey:"ansible",names:["ansible","ansible-playbook"]},{appName:"Pulumi",iconKey:"pulumi",names:["pulumi"]},{appName:"Nomad",iconKey:"nomad",names:["nomad"]},{appName:"Vault",iconKey:"vault",names:["vault"]},{appName:"Consul",iconKey:"consul",names:["consul"]},{appName:"Make",iconKey:"make",names:["make","gmake"]},{appName:"CMake",iconKey:"cmake",names:["cmake","ctest","cpack"]},{appName:"Ninja",iconKey:"ninja",names:["ninja"]},{appName:"Bazel",iconKey:"bazel",names:["bazel","bazelisk"]},{appName:"Buck",iconKey:"buck",names:["buck","buck2"]},{appName:"Clang",iconKey:"clang",names:["clang","clang++","clangd"]},{appName:"GCC",iconKey:"gcc",names:["gcc","g++","cc","c++"]},{appName:"LLDB",iconKey:"terminal",names:["lldb"]},{appName:"GDB",iconKey:"terminal",names:["gdb"]},{appName:"Swift",iconKey:"swift",names:["swift","swiftc","sourcekit-lsp"]},{appName:"Xcode",iconKey:"xcode",names:["xcodebuild","xcrun","simctl"]},{appName:"Zig",iconKey:"zig",names:["zig"]},{appName:"Lua",iconKey:"lua",names:["lua","luajit","lua-language-server"]},{appName:"Perl",iconKey:"perl",names:["perl"]},{appName:"R",iconKey:"r",names:["r","rscript","rserver","rsession"]},{appName:"Julia",iconKey:"julia",names:["julia"]},{appName:"Haskell",iconKey:"haskell",names:["ghc","ghci","cabal","stack","haskell-language-server-wrapper"]},{appName:"OCaml",iconKey:"ocaml",names:["ocaml","ocamlc","dune","opam"]},{appName:"F#",iconKey:"fsharp",names:["fsharpi","fsautocomplete"]},{appName:".NET",iconKey:"dotnet",names:["dotnet","csharp-ls","omnisharp"]},{appName:"PowerShell",iconKey:"powershell",names:["pwsh","powershell"]},{appName:"Bash",iconKey:"terminal",names:["bash"]},{appName:"Zsh",iconKey:"terminal",names:["zsh"]},{appName:"fish",iconKey:"terminal",names:["fish"]},{appName:"tmux",iconKey:"terminal",names:["tmux"]},{appName:"GNU Screen",iconKey:"terminal",names:["screen"]},{appName:"direnv",iconKey:"terminal",names:["direnv"]},{appName:"Nix",iconKey:"nix",names:["nix","nix-shell","nix-daemon","nix-build","nix develop"]},{appName:"Homebrew",iconKey:"homebrew",names:["brew"]},{appName:"mise",iconKey:"terminal",names:["mise"]},{appName:"asdf",iconKey:"terminal",names:["asdf"]},{appName:"Volta",iconKey:"volta",names:["volta"]},{appName:"fnm",iconKey:"nodejs",names:["fnm"]},{appName:"nvm",iconKey:"nodejs",names:["nvm"]},{appName:"curl",iconKey:"terminal",names:["curl"]},{appName:"HTTPie",iconKey:"httpie",names:["http","https","httpie"]},{appName:"wget",iconKey:"terminal",names:["wget"]},{appName:"jq",iconKey:"terminal",names:["jq"]},{appName:"ripgrep",iconKey:"terminal",names:["rg","ripgrep"]},{appName:"fd",iconKey:"terminal",names:["fd"]},{appName:"fzf",iconKey:"terminal",names:["fzf"]},{appName:"bat",iconKey:"terminal",names:["bat"]},{appName:"eza",iconKey:"terminal",names:["eza","exa"]},{appName:"htop",iconKey:"terminal",names:["htop","top","btop"]},{appName:"Vim",iconKey:"vim",names:["vim","view","vimdiff"]},{appName:"Neovim",iconKey:"neovim",names:["nvim","nvim-qt"]},{appName:"Emacs",iconKey:"emacs",names:["emacs","emacsclient"]},{appName:"Visual Studio Code",iconKey:"vscode",names:["code","code-insiders","vscode","visual studio code","visual studio code - insiders"]},{appName:"code-server",iconKey:"vscode",names:["code-server"]},{appName:"Cursor",iconKey:"cursor",names:["cursor"]},{appName:"Zed",iconKey:"zed",names:["zed"]},{appName:"Sublime Text",iconKey:"sublime-text",names:["subl","sublime_text","sublime text"]},{appName:"Atom",iconKey:"atom",names:["atom"]},{appName:"IntelliJ IDEA",iconKey:"intellij-idea",names:["idea","idea.sh","intellij idea","idea64.exe"]},{appName:"WebStorm",iconKey:"webstorm",names:["webstorm","webstorm.sh"]},{appName:"PyCharm",iconKey:"pycharm",names:["pycharm","pycharm.sh"]},{appName:"RubyMine",iconKey:"rubymine",names:["rubymine","rubymine.sh"]},{appName:"GoLand",iconKey:"goland",names:["goland","goland.sh"]},{appName:"CLion",iconKey:"clion",names:["clion","clion.sh"]},{appName:"DataGrip",iconKey:"datagrip",names:["datagrip","datagrip.sh"]},{appName:"Rider",iconKey:"rider",names:["rider","rider.sh"]},{appName:"Android Studio",iconKey:"android-studio",names:["studio","studio.sh","android studio"]},{appName:"Xcode",iconKey:"xcode",names:["xcode","xcode.app"]},{appName:"Postman",iconKey:"postman",names:["postman"]},{appName:"Insomnia",iconKey:"insomnia",names:["insomnia"]},{appName:"Hoppscotch",iconKey:"hoppscotch",names:["hoppscotch"]},{appName:"TablePlus",iconKey:"tableplus",names:["tableplus"]},{appName:"DBeaver",iconKey:"dbeaver",names:["dbeaver"]},{appName:"RedisInsight",iconKey:"redis",names:["redisinsight"]},{appName:"Prisma",iconKey:"prisma",names:["prisma"]},{appName:"Drizzle Kit",iconKey:"drizzle",names:["drizzle-kit"]},{appName:"Supabase",iconKey:"supabase",names:["supabase"]},{appName:"Firebase",iconKey:"firebase",names:["firebase"]},{appName:"Vercel",iconKey:"vercel",names:["vercel"]},{appName:"Netlify",iconKey:"netlify",names:["netlify","ntl"]},{appName:"Fly.io",iconKey:"fly",names:["fly","flyctl"]},{appName:"Heroku",iconKey:"heroku",names:["heroku"]},{appName:"Stripe CLI",iconKey:"stripe",names:["stripe"]},{appName:"Twilio CLI",iconKey:"twilio",names:["twilio"]},{appName:"Mailpit",iconKey:"mail",names:["mailpit"]},{appName:"MailHog",iconKey:"mail",names:["mailhog"]},{appName:"OpenSSL",iconKey:"openssl",names:["openssl"]},{appName:"mkcert",iconKey:"certificate",names:["mkcert"]},{appName:"mkdocs",iconKey:"markdown",names:["mkdocs"]},{appName:"Hugo",iconKey:"hugo",names:["hugo"]},{appName:"Jekyll",iconKey:"jekyll",names:["jekyll"]},{appName:"Eleventy",iconKey:"eleventy",names:["eleventy","11ty"]},{appName:"Docusaurus",iconKey:"docusaurus",names:["docusaurus"]},{appName:"Trunk",iconKey:"rust",names:["trunk"]},{appName:"wasm-pack",iconKey:"webassembly",names:["wasm-pack"]},{appName:"wasmtime",iconKey:"webassembly",names:["wasmtime"]},{appName:"Language Server",iconKey:"language-server",names:["lua-language-server","yaml-language-server","vscode-json-language-server","docker-langserver","bash-language-server","marksman","taplo"]}],AI=new Map;for(let e of f9)for(let t of e.names)AI.set(m9(t),{appName:e.appName,iconKey:e.iconKey});prt=AI.size});var CI=N(()=>{"use strict"});async function RI(e){let t=[],n=new Set,r=new Set,i=[],o=null;for(let s=0;s<Kb;s+=1){let d=await e.request("model/list",{cursor:o,limit:h9,includeHidden:!1}),l=y9(d,"model/list"),u=Tn(l.data);if(u===void 0)throw Dr("model/list response did not include data");for(let m of u){let y=ge(m),h=ie(y?.model)?.trim(),b=ie(y?.displayName)?.trim(),g=Tn(y?.supportedReasoningEfforts),S=ie(y?.defaultReasoningEffort)?.trim();if(y===void 0||h===void 0||!Tu(h)||b===void 0||!Tu(b)||y.hidden!==!1||g===void 0||S===void 0||!Tu(S)||typeof y.isDefault!="boolean")throw Dr("model/list included invalid visible model metadata");if(n.has(h))throw Dr(`model/list repeated model ${h}`);let v=g.map(T=>{let C=ge(T),O=ie(C?.reasoningEffort)?.trim();if(O===void 0||!Tu(O))throw Dr(`model/list ${h} included invalid reasoning effort metadata`);return O});if(new Set(v).size!==v.length||!v.includes(S))throw Dr(`model/list ${h} included inconsistent reasoning effort metadata`);if(n.add(h),t.push({id:h,displayName:b,reasoningEfforts:v,defaultReasoningEffort:S}),y.isDefault&&i.push(h),t.length>EI)throw Dr(`model/list exceeded ${EI} visible models`)}let c=l.nextCursor;if(c===null)break;let p=ie(c)?.trim();if(p===void 0||!Tu(p))throw Dr("model/list included invalid pagination cursor");if(r.has(p))throw Dr(`model/list repeated pagination cursor ${p}`);if(r.add(p),o=p,s===Kb-1)throw Dr(`model/list exceeded ${Kb} pagination pages`)}if(t.length===0)return{type:"empty"};if(i.length!==1)throw Dr("model/list did not advertise exactly one valid default model");let[a]=i;if(a===void 0)throw Dr("model/list did not advertise exactly one valid default model");return{type:"ready",catalog:{defaultModel:a,models:t}}}function y9(e,t){if("error"in e)throw new Error(`${t} failed: ${e.error.message}`);let n=ge(e.result);if(n===void 0)throw new Error(`${t} response did not include an object result`);return n}function g9(){let e=process.env.LINZUMI_CODEX_START_REQUEST_TIMEOUT_MS?.trim();if(e===void 0||e==="")return OI;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:OI}function b9(e,t,n=g9()){return v9(e,t,n,(r,i)=>new Hb(r,i))}function v9(e,t,n,r){return n>0?new Promise((i,o)=>{let a=setTimeout(()=>{o(r(e,n))},n);a.unref?.(),t.then(s=>{clearTimeout(a),i(s)},s=>{clearTimeout(a),o(s)})}):t}function Au(e,t,n){return b9(t,e.request(t,n))}async function xI(e,t,n,r,i,o){o("kandan.reconnect_thread_unarchive_started",{codex_thread_id:t,discovered_by:r,message:i});try{let a=await Au(e,"thread/unarchive",{threadId:t});if("error"in a)throw new Error(`thread/unarchive failed: ${a.error.message}`);let s=await Au(e,"thread/resume",n);if("error"in s)throw new Error(`thread/resume after unarchive failed: ${s.error.message}`);return o("kandan.reconnect_thread_unarchive_resumed",{codex_thread_id:t,discovered_by:r}),{mode:"resumed"}}catch(a){let s=a instanceof Error?a.message:String(a);throw o("kandan.reconnect_thread_unarchive_failed",{codex_thread_id:t,discovered_by:r,archive_error:i,message:s}),new Error(r==="forced_inject_not_found"?`thread/inject_items failed: ${i}; archive recovery failed: ${s}`:s)}}async function PI(e){let{codex:t,codexThreadId:n,rehydration:r}=e,i={threadId:n,...e.resumeOverrides},o;if(r.forceRehydrate===!0)o="the server marked the durable engine session dead after an acknowledged-but-unexecuted turn";else{let s=await Au(t,"thread/resume",i);if(!("error"in s))return{mode:"resumed"};if(A9(s.error.message))throw r.log("linzumi.agent_thread_resume_failed_unrecoverable",{codex_thread_id:n,message:s.error.message,rehydrating:!1}),new Error(s.error.message);if(S9(s.error.message))return await xI(t,n,i,"resume_archived",s.error.message,r.log);if(e.rebuildWhen==="missing-rollout-only"&&!T9(s.error.message))throw r.log("linzumi.agent_thread_resume_failed_unrecoverable",{codex_thread_id:n,message:s.error.message,rehydrating:!1}),new Error(s.error.message);o=s.error.message}r.log(r.forceRehydrate===!0?"kandan.reconnect_thread_rehydrate_forced":"kandan.reconnect_thread_resume_failed",{codex_thread_id:n,message:o,forced:r.forceRehydrate===!0,rehydrating:!0});let a;try{let s;try{s=await r.buildRehydrationItems?.(o)}catch(u){r.log("kandan.reconnect_thread_rehydration_items_failed",{codex_thread_id:n,message:u instanceof Error?u.message:String(u)}),s=void 0}let d=s!==void 0&&s.length>0?[...s]:[{type:"agentMessage",text:await r.buildRehydrationText(o)}],l=await Au(t,"thread/inject_items",{threadId:n,items:d});if("error"in l){if(r.forceRehydrate===!0&&w9(l.error.message))return await xI(t,n,i,"forced_inject_not_found",l.error.message,r.log);a=`thread/inject_items failed: ${l.error.message}`}else{let u=await Au(t,"thread/resume",i);"error"in u&&(a=`rehydrated thread/resume failed: ${u.error.message}`)}}catch(s){a=s instanceof Error?s.message:String(s)}if(a!==void 0)throw r.log("kandan.reconnect_thread_rehydration_failed",{codex_thread_id:n,resume_failure:o,rehydration_failure:a}),new Error(`could not resume this thread's engine session (${o}) and rebuilding a fresh session from the thread transcript also failed (${a})`);return r.log("kandan.reconnect_thread_rehydrated",{codex_thread_id:n,resume_failure:o}),{mode:"rehydrated",resumeFailure:o}}var EI,h9,Kb,_9,mr,Dr,Tu,OI,Hb,S9,w9,T9,A9,Jb=N(()=>{"use strict";ux();Og();PR();lb();qR();zR();hb();ep();yb();JR();Mf();Vf();VR();bo();ZR();QP();tI();aI();Lb();Kt();Gb();sI();hu();tp();dI();Ub();pI();mI();hI();gI();Nb();em();vI();Yt();SI();Gl();wI();zb();TI();kI();CI();EI=100,h9=100,Kb=20,_9=255,mr=class extends Error{constructor(t){super(t),this.name="NativeModelCatalogInvalidResponseError"}},Dr=e=>new mr(e),Tu=e=>e!==""&&e.length<=_9;OI=12e4;Hb=class extends Error{constructor(t,n){super(`Codex ${t} did not reply within ${n}ms (start request timed out)`),this.name="CodexStartRequestTimeoutError"}};S9=e=>/\bsession\b.+\bis archived\b/i.test(e),w9=e=>/^thread not found(?:\s*:|\b)/i.test(e.trim()),T9=e=>/\bno rollout found\b/i.test(e)||/\bsession not found\b[\s\S]*\brollout\b/i.test(e),A9=e=>/\balready has an active writer\b/i.test(e)});var II=N(()=>{});var Dat,$at,Nat,jat,Lat,MI=N(()=>{II();rt();Ni();Ke();we();Ue();mo();it();$p();ob();Dat=fu("LoggedIn"),$at=fu("NotLoggedIn"),Nat=fu("BinaryMissing"),jat=fu("ProbeFailed"),Lat=new RegExp("[\\x00-\\x1f\\x7f-\\x9f]")});var DI=N(()=>{MI()});var $I=N(()=>{$p()});var NI=N(()=>{"use strict"});function jI(e){return typeof e!="string"||e===""?e:E9.reduce((t,n)=>n.source.startsWith("\\beyJ")?t.replace(n,"<redacted>"):t.replace(n,"$1<redacted>"),e)}var E9,Qat,Xat,LI=N(()=>{"use strict";E9=[/(--token[=\s]+)\S+/gi,/(bearer\s+)[^\s,;"'\]\}]+/gi,/((?:access[_-]?token|api[_-]?key|auth[_-]?token|authorization|secret|password|refresh[_-]?token|session[_-]?token|jwt|token)["']?\s*[:=]\s*["']?)[^\s,;"'\]\}]+/gi,/\beyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g];Qat=64*1024,Xat=16*1024});var GI=N(()=>{"use strict"});var FI=N(()=>{"use strict";Kt()});var Kz={};V2(Kz,{AbortError:()=>Lr,CommandMatcher:()=>rT,DirectConnectError:()=>_r,DirectConnectTransport:()=>sT,EXIT_REASONS:()=>ODe,FileIndex:()=>iT,HOOK_EVENTS:()=>Xa,InMemorySessionStore:()=>Uw,ORG_POLICY_LIMIT_PREFIXES:()=>y1e,SYSTEM_PROMPT_DYNAMIC_BOUNDARY:()=>xDe,USAGE_LIMIT_ERROR_PREFIXES:()=>_1e,USAGE_TRANSITION_PREFIXES:()=>b1e,USAGE_WARNING_PREFIXES:()=>g1e,createSdkMcpServer:()=>CDe,deleteSession:()=>CJe,filterEscalatingDefaultMode:()=>mKe,foldSessionSummary:()=>OF,forkSession:()=>MJe,getSessionInfo:()=>IJe,getSessionMessages:()=>RJe,getSubagentMessages:()=>jJe,importSessionToStore:()=>DJe,listSessions:()=>PJe,listSubagents:()=>NJe,parseDirectConnectUrl:()=>R1e,prewarm:()=>mJe,query:()=>cJe,renameSession:()=>AJe,resolveSettings:()=>xJe,startup:()=>pJe,tagSession:()=>kJe,tool:()=>kDe});import{createRequire as O9}from"node:module";import{randomUUID as Bv}from"crypto";import{createHash as $5}from"crypto";import{basename as JY,dirname as aM}from"path";import{realpathSync as dM}from"node:fs";import{cwd as nQ}from"node:process";import{readFileSync as mX,realpathSync as dj,statSync as _M}from"fs";import{homedir as fj}from"os";import{dirname as bM,resolve as _d,sep as no}from"path";import*as kS from"path";import{createReadStream as QX}from"fs";import{readdir as XX,readFile as eee}from"fs/promises";import{dirname as tee,join as Cj,relative as nee,sep as ree}from"path";import{createInterface as iee}from"readline";import{appendFile as rv,mkdir as DM,rename as $M,stat as oee,symlink as aee,unlink as iv}from"fs/promises";import{dirname as od,isAbsolute as see,join as No,resolve as Ej}from"path";import{homedir as vee}from"os";import{join as See,resolve as jM}from"path";import*as Re from"fs";import{appendFile as Iee,chmod as Mee,copyFile as Dee,link as $ee,lstat as ov,mkdir as Nee,open as am,readdir as jee,readFile as LM,readlink as Lee,realpath as Gee,rename as Fee,rmdir as qee,rm as Uee,stat as GM,symlink as Bee,unlink as zee}from"fs/promises";import*as Ve from"path";import{readFile as Ute}from"fs/promises";import{constants as Uie}from"fs";import{access as uw,readdir as Bie,readFile as zie,readlink as Kie}from"fs/promises";import{homedir as Hie}from"os";import{delimiter as Jie,join as wc,resolve as tL}from"path";import{readFile as oD}from"fs/promises";import{release as noe}from"os";import Ut from"node:path";import dL from"node:os";import cw from"node:process";import{isAbsolute as qoe}from"path";import{once as dD}from"events";import{constants as Uu,createWriteStream as NTe}from"fs";import{lstat as jTe,open as SL,readdir as Ju,realpath as wL,stat as LTe}from"fs/promises";import{basename as GTe,dirname as FTe,join as Fr}from"path";import{execFile as zTe}from"child_process";import{promisify as KTe}from"util";import{execFileSync as HTe}from"child_process";import{lstatSync as JTe}from"fs";import{join as WTe}from"path";import{basename as HD,dirname as JD,join as gOe}from"path";import{createHash as EOe}from"crypto";import{constants as NG}from"fs";import{isAbsolute as vxe,sep as VD}from"path";import{readdir as QA,stat as Ixe}from"fs/promises";import{basename as Mxe,dirname as Dxe,join as $xe}from"path";import{basename as Lxe,join as Ec}from"path";import{readFile as Gxe}from"fs/promises";import{dirname as Fxe,join as qxe}from"path";import{basename as QD,dirname as XD}from"path";import{constants as mm}from"fs";import{lstat as Xxe,open as eRe}from"fs/promises";import{dirname as tRe,join as nRe}from"path";import{randomUUID as hm}from"crypto";import{basename as bRe,join as $a}from"path";import{AsyncLocalStorage as vRe}from"async_hooks";import{constants as SRe}from"fs";import{appendFile as wRe,copyFile as TRe,lstat as ARe,mkdir as kRe,open as r1,readdir as i1,readFile as o1,stat as CRe,unlink as ERe,writeFile as pv}from"fs/promises";import{randomBytes as ORe}from"crypto";import{constants as nn}from"fs";import{lstat as O_,open as ef,rename as _F,stat as xRe,unlink as Bu,writeFile as RRe}from"fs/promises";import{basename as PRe,join as IRe}from"path";import{readdir as SPe,readFile as l1}from"fs/promises";import{isAbsolute as wF,join as gh,relative as TF,sep as bh}from"path";import{randomUUID as k1e}from"crypto";import{join as L1}from"path";import{resolve as I1e}from"path";import{join as Td}from"path";import{dirname as Y1e}from"path";import{open as r$e}from"fs/promises";import{join as f$e}from"path";import{homedir as nLe}from"os";import{dirname as rLe,join as qr,resolve as Un}from"path";import{join as Uq}from"path";import{isAbsolute as o$}from"path";import{posix as oU,win32 as aU}from"path";import{posix as hGe,win32 as _Ge}from"path";import{isIPv4 as bGe,isIPv6 as vGe}from"net";import{userInfo as QBe}from"os";import{execFile as M2e}from"child_process";import{accessSync as D2e,closeSync as $2e,constants as N2e,openSync as j2e,readSync as L2e}from"fs";import{execFile as hKe}from"child_process";import{randomUUID as _Ke}from"crypto";import{mkdir as zh,mkdtemp as yKe,readFile as gKe,rm as yz,writeFile as gz}from"fs/promises";import{createRequire as bKe}from"module";import{homedir as Nc,tmpdir as vKe}from"os";import{dirname as bN,isAbsolute as WT,join as qt,posix as bz,resolve as jc,sep as SKe,win32 as vz}from"path";import{fileURLToPath as wKe}from"url";import{setMaxListeners as TKe}from"events";import{spawn as EKe}from"child_process";import{existsSync as OKe}from"fs";import{createInterface as xKe}from"readline";import{StringDecoder as RKe}from"string_decoder";import{existsSync as WKe}from"fs";import{copyFile as qHe,readFile as UHe,rm as Rz,writeFile as Pz}from"fs/promises";import{homedir as CN}from"os";import{join as Fv}from"path";import{createHash as KHe}from"crypto";import{userInfo as HHe}from"os";import{realpathSync as XHe}from"fs";import{isAbsolute as eJe,relative as tJe,resolve as nJe,sep as rJe}from"path";import{randomUUID as Nz}from"crypto";import{constants as PN}from"fs";import{open as hJe,readdir as jz,rm as IN,stat as _Je}from"fs/promises";import{join as to}from"path";function I9(e){return this[e]}function N9(e,t){this[e]=$9.bind(null,t)}function j5(e){return N5.test(e)}function L5(e,t){let n=Buffer.from(t.replace(/-/g,""),"hex"),r=$5("sha1").update(n).update(Buffer.from(e,"utf8")).digest();r[6]=r[6]&15|80,r[8]=r[8]&63|128;let i=r.subarray(0,16).toString("hex");return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20,32)}`}function F5(){let e=process.env.CLAUDE_CODE_REMOTE_SESSION_ID?.trim();return e?L5(e,G5):null}function q5(){this.__data__=[],this.size=0}function B5(e,t){return e===t||e!==e&&t!==t}function z5(e,t){for(var n=e.length;n--;)if(Uc(e[n][0],t))return n;return-1}function J5(e){var t=this.__data__,n=Zh(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():H5.call(t,n,1),--this.size,!0}function V5(e){var t=this.__data__,n=Zh(t,e);return n<0?void 0:t[n][1]}function Y5(e){return Zh(this.__data__,e)>-1}function X5(e,t){var n=this.__data__,r=Zh(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function Jd(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function t8(){this.__data__=new Yh,this.size=0}function r8(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function o8(e){return this.__data__.get(e)}function s8(e){return this.__data__.has(e)}function _8(e){var t=m8.call(e,ku),n=e[ku];try{e[ku]=void 0;var r=!0}catch{}var i=h8.call(e);return r&&(t?e[ku]=n:delete e[ku]),i}function v8(e){return b8.call(e)}function A8(e){return e==null?e===void 0?T8:w8:BI&&BI in Object(e)?y8(e):S8(e)}function k8(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function R8(e){if(!Ur(e))return!1;var t=Ja(e);return t==E8||t==O8||t==C8||t==x8}function I8(e){return!!zI&&zI in e}function N8(e){if(e!=null){try{return $8.call(e)}catch{}try{return e+""}catch{}}return""}function z8(e){if(!Ur(e)||M8(e))return!1;var t=aA(e)?B8:L8;return t.test(Wa(e))}function H8(e,t){return e?.[t]}function W8(e,t){var n=J8(e,t);return K8(n)?n:void 0}function Y8(){this.__data__=oc?oc(null):{},this.size=0}function X8(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function iZ(e){var t=this.__data__;if(oc){var n=t[e];return n===tZ?void 0:n}return rZ.call(t,e)?t[e]:void 0}function dZ(e){var t=this.__data__;return oc?t[e]!==void 0:sZ.call(t,e)}function cZ(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=oc&&t===void 0?uZ:t,this}function Wd(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function pZ(){this.size=0,this.__data__={hash:new KI,map:new(ic||Yh),string:new KI}}function hZ(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function yZ(e,t){var n=e.__data__;return _Z(t)?n[typeof t=="string"?"string":"hash"]:n.map}function gZ(e){var t=Qh(this,e).delete(e);return this.size-=t?1:0,t}function vZ(e){return Qh(this,e).get(e)}function wZ(e){return Qh(this,e).has(e)}function AZ(e,t){var n=Qh(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function Vd(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function EZ(e,t){var n=this.__data__;if(n instanceof Yh){var r=n.__data__;if(!ic||r.length<CZ-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Xh(r)}return n.set(e,t),this.size=n.size,this}function Zd(e){var t=this.__data__=new Yh(e);this.size=t.size}function RZ(e){return this.__data__.set(e,xZ),this}function IZ(e){return this.__data__.has(e)}function Gm(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new Xh;++t<n;)this.add(e[t])}function $Z(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function jZ(e,t){return e.has(t)}function qZ(e,t,n,r,i,o){var a=n&GZ,s=e.length,d=t.length;if(s!=d&&!(a&&d>s))return!1;var l=o.get(e),u=o.get(t);if(l&&u)return l==t&&u==e;var c=-1,p=!0,m=n&FZ?new DZ:void 0;for(o.set(e,t),o.set(t,e);++c<s;){var y=e[c],h=t[c];if(r)var b=a?r(h,y,c,t,e,o):r(y,h,c,e,t,o);if(b!==void 0){if(b)continue;p=!1;break}if(m){if(!NZ(t,function(g,S){if(!LZ(m,S)&&(y===g||i(y,g,n,r,o)))return m.push(S)})){p=!1;break}}else if(!(y===h||i(y,h,n,r,o))){p=!1;break}}return o.delete(e),o.delete(t),p}function BZ(e){var t=-1,n=Array(e.size);return e.forEach(function(r,i){n[++t]=[i,r]}),n}function KZ(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}function a7(e,t,n,r,i,o,a){switch(n){case o7:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case i7:return!(e.byteLength!=t.byteLength||!o(new Fm(e),new Fm(t)));case VZ:case ZZ:case XZ:return Uc(+e,+t);case YZ:return e.name==t.name&&e.message==t.message;case e7:case n7:return e==t+"";case QZ:var s=zZ;case t7:var d=r&JZ;if(s||(s=HZ),e.size!=t.size&&!d)return!1;var l=a.get(e);if(l)return l==t;r|=WZ,a.set(e,t);var u=HN(s(e),s(t),r,i,o,a);return a.delete(e),u;case r7:if(Vb)return Vb.call(e)==Vb.call(t)}return!1}function d7(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function u7(e,t,n){var r=t(e);return rr(e)?r:sA(r,n(e))}function c7(e,t){for(var n=-1,r=e==null?0:e.length,i=0,o=[];++n<r;){var a=e[n];t(a,n,e)&&(o[i++]=a)}return o}function p7(){return[]}function y7(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function b7(e){return e!=null&&typeof e=="object"}function S7(e){return Ai(e)&&Ja(e)==v7}function C7(){return!1}function M7(e,t){var n=typeof e;return t=t??P7,!!t&&(n=="number"||n!="symbol"&&I7.test(e))&&e>-1&&e%1==0&&e<t}function $7(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=D7}function aY(e){return Ai(e)&&lA(e.length)&&!!Pt[Ja(e)]}function dY(e){return function(t){return e(t)}}function mY(e,t){var n=rr(e),r=!n&&ac(e),i=!n&&!r&&kd(e),o=!n&&!r&&!i&&cA(e),a=n||r||i||o,s=a?g7(e.length,String):[],d=s.length;for(var l in e)(t||pY.call(e,l))&&!(a&&(l=="length"||i&&(l=="offset"||l=="parent")||o&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||e_(l,d)))&&s.push(l);return s}function _Y(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||hY;return e===n}function yY(e,t){return function(n){return e(t(n))}}function wY(e){if(!fA(e))return bY(e);var t=[];for(var n in Object(e))SY.call(e,n)&&n!="constructor"&&t.push(n);return t}function AY(e){return e!=null&&lA(e.length)&&!aA(e)}function kY(e){return t_(e)?YN(e):TY(e)}function CY(e){return JN(e,Bc,dA)}function RY(e,t,n,r,i,o){var a=n&EY,s=zv(e),d=s.length,l=zv(t),u=l.length;if(d!=u&&!a)return!1;for(var c=d;c--;){var p=s[c];if(!(a?p in t:xY.call(t,p)))return!1}var m=o.get(e),y=o.get(t);if(m&&y)return m==t&&y==e;var h=!0;o.set(e,t),o.set(t,e);for(var b=a;++c<d;){p=s[c];var g=e[p],S=t[p];if(r)var v=a?r(S,g,p,t,e,o):r(g,S,p,e,t,o);if(!(v===void 0?g===S||i(g,S,n,r,o):v)){h=!1;break}b||(b=p=="constructor")}if(h&&!b){var T=e.constructor,C=t.constructor;T!=C&&"constructor"in e&&"constructor"in t&&!(typeof T=="function"&&T instanceof T&&typeof C=="function"&&C instanceof C)&&(h=!1)}return o.delete(e),o.delete(t),h}function zY(e,t,n,r,i,o){var a=rr(e),s=rr(t),d=a?iM:sc(e),l=s?iM:sc(t);d=d==rM?nm:d,l=l==rM?nm:l;var u=d==nm,c=l==nm,p=d==l;if(p&&kd(e)){if(!kd(t))return!1;a=!0,u=!1}if(p&&!u)return o||(o=new hd),a||cA(e)?HN(e,t,n,r,i,o):s7(e,t,d,n,r,i,o);if(!(n&UY)){var m=u&&oM.call(e,"__wrapped__"),y=c&&oM.call(t,"__wrapped__");if(m||y){var h=m?e.value():e,b=y?t.value():t;return o||(o=new hd),i(h,b,n,r,o)}}return p?(o||(o=new hd),PY(e,t,n,r,i,o)):!1}function XN(e,t,n,r,i){return e===t?!0:e==null||t==null||!Ai(e)&&!Ai(t)?e!==e&&t!==t:KY(e,t,n,r,XN,i)}function HY(e,t){return pA(e,t)}function dt(){return WY===!0}function wt(e){if(!e)return!1;if(typeof e=="boolean")return e;let t=String(e).toLowerCase().trim();return["1","true","yes","on"].includes(t)}function ej(e){if(e===void 0)return!1;if(typeof e=="boolean")return!e;let t=String(e).toLowerCase().trim();return["0","false","no","off"].includes(t)}function Bn(){let e=new Set;return{subscribe(t){let n=VY(t);return e.add(n),()=>{e.delete(n)}},emit(...t){let n;for(let r of e)try{r(...t)}catch(i){(n??=[]).push(i)}if(n)throw n.length===1?n[0]:AggregateError(n,"Signal listener(s) threw")},clear(){e.clear()}}}function Zv(){return{sent:new Set,rejected:new Set,declaredTools:void 0,noChannelTools:void 0,declaredToolsDecided:!1,nameOnlyAnnouncements:new Set,surfacedOnWire:new Set,definedByValue:new Set,inlineToolsRefusal:{rejectedHeader:void 0,announcementsByName:new Set},advisorHeld:void 0,wireShapeSeed:void 0,webSearchHistoryRejected:!1}}function YY(e,t){for(let n of t.sent)tQ(e,n);for(let n of t.rejected)tj(e,n);e.wireShapeSeed=t}function QY(e){let t=Zv();t.declaredTools=e.declaredTools,t.noChannelTools=e.noChannelTools,t.declaredToolsDecided=e.declaredToolsDecided,t.advisorHeld=e.advisorHeld,e.wireShapeSeed!==void 0&&YY(t,e.wireShapeSeed);let{rejectedHeader:n,announcementsByName:r}=e.inlineToolsRefusal;return n!==void 0&&XY(t,n),eQ(t,r),t.webSearchHistoryRejected=e.webSearchHistoryRejected,t}function XY(e,t){tj(e,t),e.inlineToolsRefusal.rejectedHeader=t}function eQ(e,t){for(let n of t)e.inlineToolsRefusal.announcementsByName.add(n),e.nameOnlyAnnouncements.add(n)}function tQ(e,t){e.rejected.has(t)||e.sent.add(t)}function tj(e,t){e.sent.delete(t),e.rejected.add(t)}function lM(e){return process.platform==="darwin"?e.normalize("NFC"):e}function nj(){let e="";if(typeof process<"u"&&typeof process.cwd=="function"&&typeof dM=="function")try{let t=nQ();try{e=lM(dM(t))}catch{e=lM(t)}}catch{}return e}function iQ(){if(uM===null)return null;let e=process.env.CLAUDE_CODE_SESSION_KIND;return e!==void 0&&String(e).trim()==="bg"?null:uM}function aQ(e,t,n){t=="__proto__"&&qm?qm(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function sQ(e){return function(t,n,r){for(var i=-1,o=Object(t),a=r(t),s=a.length;s--;){var d=a[e?s:++i];if(n(o[d],d,o)===!1)break}return t}}function uQ(e,t){return e&&rj(e,t,Bc)}function mQ(e,t,n,r){var i=n.length,o=i,a=!r;if(e==null)return!o;for(e=Object(e);i--;){var s=n[i];if(a&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<o;){s=n[i];var d=s[0],l=e[d],u=s[1];if(a&&s[2]){if(l===void 0&&!(d in e))return!1}else{var c=new hd;if(r)var p=r(l,u,d,e,t,c);if(!(p===void 0?pA(u,l,fQ|pQ,r,c):p))return!1}}return!0}function _Q(e){return e===e&&!Ur(e)}function yQ(e){for(var t=Bc(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,ij(i)]}return t}function bQ(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==void 0||e in Object(n))}}function vQ(e){var t=gQ(e);return t.length==1&&t[0][2]?oj(t[0][0],t[0][1]):function(n){return n===e||hQ(n,e,t)}}function TQ(e){return typeof e=="symbol"||Ai(e)&&Ja(e)==wQ}function CQ(e,t){if(rr(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||mA(e)?!0:kQ.test(e)||!AQ.test(e)||t!=null&&e in Object(t)}function _A(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw TypeError(EQ);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=e.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(_A.Cache||Xh),n}function xQ(e){var t=yA(e,function(r){return n.size===OQ&&n.clear(),r}),n=t.cache;return t}function $Q(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}function aj(e){if(typeof e=="string")return e;if(rr(e))return gA(e,aj)+"";if(mA(e))return fM?fM.call(e):"";var t=e+"";return t=="0"&&1/e==-NQ?"-0":t}function LQ(e){return e==null?"":jQ(e)}function FQ(e,t){return rr(e)?e:hA(e,t)?[e]:DQ(GQ(e))}function UQ(e){if(typeof e=="string"||mA(e))return e;var t=e+"";return t=="0"&&1/e==-qQ?"-0":t}function BQ(e,t){t=Yd(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[Fa(t[n++])];return n&&n==r?e:void 0}function zQ(e,t,n){var r=e==null?void 0:r_(e,t);return r===void 0?n:r}function HQ(e,t){return e!=null&&t in Object(e)}function WQ(e,t,n){t=Yd(t,e);for(var r=-1,i=t.length,o=!1;++r<i;){var a=Fa(t[r]);if(!(o=e!=null&&n(e,a)))break;e=e[a]}return o||++r!=i?o:(i=e==null?0:e.length,!!i&&lA(i)&&e_(a,i)&&(rr(e)||ac(e)))}function ZQ(e,t){return e!=null&&VQ(e,t,JQ)}function XQ(e,t){return hA(e)&&ij(t)?oj(Fa(e),t):function(n){var r=KQ(n,e);return r===void 0&&r===t?sj(n,e):pA(t,r,YQ|QQ)}}function tX(e){return e}function nX(e){return function(t){return t?.[e]}}function iX(e){return function(t){return r_(t,e)}}function aX(e){return hA(e)?rX(Fa(e)):oX(e)}function dX(e){return typeof e=="function"?e:e==null?bA:typeof e=="object"?rr(e)?eX(e[0],e[1]):SQ(e):sX(e)}function lX(e,t){var n={};return t=i_(t,3),cQ(e,function(r,i,o){n_(n,i,t(r,i,o))}),n}function uX(e,t){for(var n,r=-1,i=e.length;++r<i;){var o=t(e[r]);o!==void 0&&(n=n===void 0?o:n+o)}return n}function fX(e,t){return e&&e.length?cX(e,i_(t,2)):0}function rm(e){return Object.assign(Object.create(null),e)}function lj(e,t){return e}function Mn(e){return e}function zc(e){return e}function uj(e){return e}function _X(e){try{if(e!==null&&typeof e=="object"&&"telemetryMessage"in e&&typeof e.telemetryMessage=="string")return e.telemetryMessage}catch{}}function yX(e,t){return e instanceof Error&&e.message===t}function qa(e){return e instanceof Error?e:Error(String(e))}function bi(e){return e instanceof Error?e.message:String(e)}function tt(e){if(e&&typeof e=="object"&&"code"in e&&typeof e.code=="string")return e.code}function Cm(e){return gX(tt(e))}function gX(e){return e&&/^[A-Z][A-Z0-9_]{0,63}$/.test(e)?uj(e):void 0}function cj(e){if(typeof e=="string")return/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(e)?uj(e):Mn("nonconforming")}function Wr(e){return tt(e)==="ENOENT"}function yM(e){return tt(e)==="EISDIR"}function gM(e){return vX(tt(e))}function vX(e){return e!==void 0&&bX.has(e)}function Kc(e,t,n){return new Promise((r,i)=>{if(t?.aborted){n?.throwOnAbort||n?.abortError?i(n.abortError?.()??Error("aborted")):r();return}let o=setTimeout((s,d,l)=>{s?.removeEventListener("abort",d),l()},e,t,a,r);function a(){clearTimeout(o),n?.throwOnAbort||n?.abortError?i(n.abortError?.()??Error("aborted")):r()}t?.addEventListener("abort",a,{once:!0}),n?.unref&&o.unref()})}function SX(e,t){e(Error(t))}function Uo(e,t,n){let r,i=new Promise((o,a)=>{r=setTimeout(SX,t,a,n)});return Promise.race([e,i]).finally(()=>{r!==void 0&&clearTimeout(r)})}function TX(e,t,n=wX){let r=()=>{},i=new Promise(o=>{r=n(()=>o(void 0),t)});return Promise.race([e,i]).finally(r)}function on(e){return process.platform==="darwin"?e.normalize("NFC"):e}function io(e){return/^[\\/]{2}/.test(e)||s_(e)}function o_(e){return/(^|[\\/])\.\.([\\/]|$)/.test(e)}function vM(e){return/^[\\/]{2}[?.][\\/](?!unc[\\/])/i.test(e)?null:e.match(/^[\\/]{2}(?:[?.][\\/]unc[\\/])?([^\\/]+)/i)?.[1]?.replace(/[A-Z]/g,t=>t.toLowerCase())??null}function yd(e){return/(^|[\\/])\.{1,2}[. ]*([\\/]|$)/.test(e)}function a_(e){return/^[\\/]{2}[?.][\\/]/.test(e)}function Hc(e){if(!/\/\.(?:vol|file|nofollow|resolve)(?:\/|$)/i.test(e)||!e.startsWith("/"))return!1;let t=[];for(let n of e.split("/"))if(!(n===""||n===".")){if(n===".."){t.pop();continue}if(t.push(n),t.length===1&&/^\.(?:vol|file|nofollow|resolve)$/i.test(n))return!0}return!1}function AX(e){return/^[\\/](GLOBAL\?\?|GLOBALROOT|DosDevices|Device)[\\/]/i.test(e)}function kX(e,t){if(!io(e))return!1;if(a_(e)||s_(e)||yd(e))return!0;let n=vM(e);return n===null||n!==vM(t)}function pj(e){return e.length===2&&Yb(e[0])==="net"||e.length===3&&Yb(e[0])==="network"&&Yb(e[1])==="servers"}function Um(e){if(process.platform==="win32"||!e.startsWith("/"))return null;let t=[];for(let n of e.split("/"))if(!(n===""||n===".")){if(n===".."){t.pop();continue}if(t.push(n),pj(t))return Em(n)}return null}function Em(e){return e.replace(/[A-Z]/g,t=>t.toLowerCase())}function Yb(e){return e.replace(/[\u200c-\u200f\u202a-\u202e\u206a-\u206f\ufeff]/g,"").toUpperCase().toLowerCase()}function mj(e,t){if(Hc(e))return!0;if(Lo(e)){let n=Um(e);if(n===null||n!==Um(t))return!0}return CX(e,t)}function CX(e,t,n=process.platform,r=n==="darwin"&&(process.platform!=="darwin"||hj())){if(n!=="darwin"||!xX(e,n,r))return!1;let i=CS(t,n,r).complete[0]??null,{complete:o,partial:a}=CS(e,n,r);return o.length===0&&a.length===0||i===null?!0:o.some(s=>s!==i)||a.some(s=>!i.startsWith(s))}function hj(e=SM){let t=e===SM;if(t&&Qb.value!==void 0)return Qb.value;let n;try{let r=!1;try{r=e.readAutoMaster().split(`
|
|
159
159
|
`).some(i=>{let o=i.replace(/#.*$/,"").trim().split(/\s+/);return o.length>=2&&o[0].toLowerCase()==="/home"})}catch(i){if(!Wr(i))throw i}n=r||e.homeIsOwnMount()}catch{return!0}return t&&(Qb.value=n),n}function CS(e,t,n){let r=[],i=[];if(!e.startsWith("/"))return{complete:r,partial:i};let o=[];for(let a of e.split("/")){if(a===""||a===".")continue;if(a===".."){o.pop();continue}if(o.push(a),o.length>EX)continue;let s="/"+o.join("/"),d=(t==="darwin"?Sj(s):s).split("/").filter(u=>u!==""),l=d[0]?.toLowerCase();l==="network"?d.length===1?i.push("/network/"):d.length===2?i.push(`/network/${Em(d[1])}/`):d.length===3&&r.push(`/network/${Em(d[1])}/${Em(d[2])}`):n&&l==="home"&&d.length===2&&r.push(`/home/${d[1]}`)}return{complete:r,partial:i}}function Lo(e){return process.platform==="win32"?!1:Qd(e)}function Qd(e){return vA(e)!==null}function vA(e){if(!e.startsWith("/"))return null;if(e.length>yj)return wM(e);let t=im.get(e);return t===void 0&&(t=wM(e),im.size>=_j&&im.clear(),im.set(e,t)),t}function wM(e){let t=[];for(let n of e.split("/"))if(!(n===""||n===".")){if(n===".."){t.pop();continue}if(t.push(n),pj(t))return"/"+t.join("/")}return null}function gd(e){if(!e.startsWith("/"))return!1;let t=[];for(let n of e.split("/"))if(!(n===""||n===".")){if(n===".."){t.pop();continue}t.push(n)}return t.length===1&&t[0].toLowerCase()==="net"}function Za(e){if(!e.startsWith("/"))return!1;if(e.length>yj)return TM(e);let t=om.get(e);return t===void 0&&(t=TM(e),om.size>=_j&&om.clear(),om.set(e,t)),t}function TM(e){let t=[];for(let n of e.split("/"))if(!(n===""||n===".")){if(n===".."){t.pop();continue}if(t.push(n),t.length===1&&t[0].toLowerCase()==="network")return!0}return!1}function OX(e){return process.platform!=="darwin"?!1:Za(e)}function xX(e,t=process.platform,n=t==="darwin"&&(process.platform!=="darwin"||hj())){if(t!=="darwin")return!1;if(Za(e)||Hc(e))return!0;if(!e.startsWith("/"))return!1;let{complete:r,partial:i}=CS(e,t,n);if(i.length>0||r.some(a=>a.startsWith("/network/")))return!0;let o=r.filter(a=>a.startsWith("/home/"));if(o.length>0){let a=RX();if(o.some(s=>s!==a))return!0}return!1}function RX(){let e;try{e=fj()}catch{return null}let t=/^\/home\/([^/]+)/.exec(Sj(e));return t?`/home/${t[1]}`:null}function ES(e){return PX(e)||Za(e)}function PX(e){return SA(e)||Qd(e)||gd(e)||a_(e)||s_(e)||AX(e)||Hc(e)}function Cd(e){let t=/^[\\/]{2}wsl(?:\$|\.localhost)[\\/]([^\\/]*)/i.exec(e);return t!==null&&!/^\.{0,2}[. ]*$/.test(t[1]??"")}function SA(e){return io(e)&&!Cd(e)}function wA(e){return e.startsWith("\\\\?\\UNC\\")?"\\\\"+e.slice(8):e.startsWith("\\\\?\\")&&e.length>=7&&e[5]===":"?e.slice(4):e}function IX(e){if(/^\\\\\?\\volume\{/i.test(e))return AM(e);if(s_(e))return!0;let t=wA(e);return t!==e&&AM(t)?!0:io(t)&&!Cd(t)}function AM(e){return yd(e)||e.includes("/")}function MX(e){try{return wA(dj.native(e))}catch{return null}}function OS(e){return LX(e).real??null}function vj(e,t){let n=_d(t).toLowerCase(),r=bM(_d(e)).toLowerCase();if(r===n||CM(r,n)||EM(r,n,"lexical"))return!0;let i=OS(t)?.toLowerCase();if(i==null)return!1;let o=OS(bM(_d(e)))?.toLowerCase();return o==null?!0:o===i||CM(o,i)||EM(o,i,"canonical")}function CM(e,t){return e.startsWith(Bm(t)+no)?e.split(no).some(n=>$X.has(n)):!1}function Bm(e){return e.endsWith(no)?e.slice(0,-1):e}function EM(e,t,n){let r=fj(),i=(process.env.LOCALAPPDATA??"").trim();if(n==="lexical")return ev(OM(r,i,d=>_d(d).toLowerCase()),e,t);let o=r+"\0"+i;if(Xb?.key===o)return ev(Xb.aliasDirs,e,t);let a=!0,s=OM(r,i,d=>{if(!NX(d))return _d(d).toLowerCase();let l=OS(d)?.toLowerCase();return l??(a=!1,_d(d).toLowerCase())});return a&&(Xb={key:o,aliasDirs:s}),ev(s,e,t)}function OM(e,t,n){let r=[];if(e&&r.push(Bm(n(e))+no+["appdata","local","microsoft","windowsapps"].join(no)),t){let i=Bm(n(t))+no+["microsoft","windowsapps"].join(no);r.includes(i)||r.push(i)}return r}function NX(e){return process.platform==="win32"?/^[A-Za-z]:[\\/](?![\\/])/.test(e):e.startsWith("/")&&!io(e)}function ev(e,t,n){let r=Bm(n);for(let i of e)if((i===r||i.startsWith(r+no))&&(t===i||t.startsWith(i+no)))return!0;return!1}function Sj(e){let t=e.split("/");if(t.length<5||t[0]!==""||Eu(t[1]??"")!=="system"||Eu(t[2]??"")!=="volumes"||Eu(t[3]??"")!=="data")return e;let n=t.slice(4);for(let r of jX){let i=r.split("/");if(!(n.length<i.length)&&i.every((o,a)=>Eu(n[a]??"")===Eu(o)))return"/"+n.join("/")}return e}function Eu(e){return e.toUpperCase().toLowerCase()}function LX(e){let t=GX(()=>wA(dj.native(e)));return{real:t.value,code:t.code}}function wj(e){return e!=null&&typeof e=="object"&&"code"in e&&typeof e.code=="string"?e.code:void 0}function GX(e){try{return{value:FX(e)}}catch(t){return{code:wj(t)}}}function FX(e){return qX(e,()=>!0)}function qX(e,t){for(let n=0;;n++)try{return e()}catch(r){let i=wj(r);if(i===void 0||process.platform!=="win32"||!DX.has(i)||n>=gj-1||!t())throw r;kM??=new Int32Array(new SharedArrayBuffer(4)),Atomics.wait(kM,0,0,bj)}}function s_(e){return xM.test(e)||e.includes("??")&&xM.test(UX(e))}function UX(e){return kS.win32?kS.win32.normalize(e):e}function Ou(e,t){return`${e}\0${t}`}function tv(e){let{project:t}=e;if(t===null)throw new lc;return t}function HX(e){return Tj({kind:"root",host:e.host,id:e.id,parentId:e.parentId},e.project)}function nv(e,t){let n=t.originalCwd??e?.originalCwd,r=t.projectRoot??e?.projectRoot,i=t.cwd??e?.cwd;if(n===void 0&&r===void 0&&i===void 0)return null;if(n===void 0||r===void 0||i===void 0)throw new lc;return{originalCwd:on(n),projectRoot:on(r),cwd:on(i)}}function Tj(e,t){let n={project:t===null?null:nv(null,t)},r=Bn(),i=e.kind==="fork"?e.root.observers:new Yv,o=e.kind==="fork"?e.root.autonomousLoopPreamble:new TS,a=e.kind==="fork"?e.root.precompute:new mS,s={get originalCwd(){return tv(n).originalCwd},get projectRoot(){return tv(n).projectRoot},get cwd(){return tv(n).cwd}},d={host:e.kind==="fork"?e.root.host:e.host,get id(){return e.kind==="fork"?e.root.id:e.id},get parentId(){return e.kind==="fork"?e.root.parentId:e.parentId},get root(){return e.kind==="fork"?e.root:d},get project(){return n.project===null?null:s},observers:i,autonomousLoopPreamble:o,btwHistory:e.kind==="fork"?e.root.btwHistory:new AS,ccrRecap:e.kind==="fork"?e.root.ccrRecap:new bS,conversationLatches:e.kind==="fork"?e.root.conversationLatches:new Qv,costLedger:e.kind==="fork"?e.root.costLedger:new eS,engineStore:e.kind==="fork"?e.root.engineStore:new hS,fableConsentSlots:e.kind==="fork"?e.root.fableConsentSlots:new tS,hookRegistry:e.kind==="fork"?e.root.hookRegistry:new nS,identity:e.kind==="fork"?e.root.identity:new _S,invokedSkills:e.kind==="fork"?e.root.invokedSkills:new rS,mcpSessionWiring:e.kind==="fork"?e.root.mcpSessionWiring:new iS,modelSelection:e.kind==="fork"?e.root.modelSelection:new oS,promptAssembly:e.kind==="fork"?e.root.promptAssembly:new aS,promptSuggestion:e.kind==="fork"?e.root.promptSuggestion:new SS,pendingHint:e.kind==="fork"?e.root.pendingHint:new xS,pluginsSync:e.kind==="fork"?e.root.pluginsSync:new vS,precompute:a,requestJournal:e.kind==="fork"?e.root.requestJournal:new sS,sessionCron:e.kind==="fork"?e.root.sessionCron:new dS,sessionFlags:e.kind==="fork"?e.root.sessionFlags:new lS,sessionRefsGate:e.kind==="fork"?e.root.sessionRefsGate:new wS,sessionScratch:e.kind==="fork"?e.root.sessionScratch:new uS,surfaceCapabilities:e.kind==="fork"?e.root.surfaceCapabilities:new cS,toolProgressThrottle:e.kind==="fork"?e.root.toolProgressThrottle:new RS,turnBudget:e.kind==="fork"?e.root.turnBudget:new fS,userPresence:e.kind==="fork"?e.root.userPresence:new pS,workflowUsageConsent:e.kind==="fork"?e.root.workflowUsageConsent:new gS,outsideReadPrompt:e.kind==="fork"?e.root.outsideReadPrompt:new yS,writePermissionStash:e.kind==="fork"?e.root.writePermissionStash:new PS,subscribe(l){let u=r.subscribe(l);if(e.kind!=="fork")return u;let c=e.root,{id:p,parentId:m}=c,y=c.subscribe(()=>{c.id===p&&c.parentId===m||(p=c.id,m=c.parentId,l())});return()=>{u(),y()}},setCwd(l){d.update({project:{cwd:l}})},withProject(l){return Tj({kind:"fork",root:d.root},nv(n.project,l))},update(l){let u=l.project===void 0?n.project:l.project===null?null:nv(n.project,l.project),c=!1;if(l.id!==void 0||"parentId"in l){if(e.kind==="fork")throw Error("A withProject fork cannot re-identify the session \u2014 update the root session instead");l.id!==void 0&&l.id!==e.id&&(e.id=l.id,c=!0),"parentId"in l&&l.parentId!==e.parentId&&(e.parentId=l.parentId,c=!0)}(u?.originalCwd!==n.project?.originalCwd||u?.projectRoot!==n.project?.projectRoot||u?.cwd!==n.project?.cwd)&&(n.project=u,c=!0),c&&r.emit()}};return d}function RM(){return["userSettings","projectSettings","localSettings","flagSettings","policySettings"]}function IM(){return{rateTokens:null,rateLastRefillMs:null,featureOkLogged:!1,reportedDropReasons:new Set}}function MM(){}function JX(){return new zS({backgroundHousekeeping:new BS,launchOptions:new IS,settingsSource:new MS,extensionsConfig:new DS,modelStringsCache:new $S,diagnostics:new NS,telemetryHandles:new jS,credentialSlots:new LS,mcpProcessWiring:new GS,requestLatches:new FS,accountCreditLatches:new qS,proactivity:new US})}function WX(e=nj()){return HX({host:JX(),id:F5()??Bv(),project:{originalCwd:e,projectRoot:e,cwd:e}})}function Xd(){return TA()}function TA(){return kj()?.session??Aj}function d_(e){return e.of(Aj.host)}function VX(){let e=kj();return e?.session?void 0:e}function ZX(){return VX()?.sessionId??TA().id}function YX(){return TA().host.launchOptions.diskless()}function ce(e,t){return{code:"InvalidArgument",argument:e,...t!==void 0&&{reason:t}}}function lee(e){return e.code==="Failed"&&"telemetryCode"in e&&e.telemetryCode===dee}function cee({writeBatch:e,sizeOf:t,flushIntervalMs:n=1e3,maxBufferSize:r=100,maxBufferBytes:i=1/0,immediateMode:o=!1}){let a=[],s=0,d=null,l=null;function u(){d&&(clearTimeout(d),d=null)}function c(h){try{e(h)}catch{}}function p(){l&&(c(l),l=null),a.length!==0&&(c(a),a=[],s=0,u())}function m(){d||(d=setTimeout(p,n))}function y(){if(l){l.push(...a),a=[],s=0,u();return}let h=a;a=[],s=0,u(),l=h,setImmediate(()=>{let b=l;l=null,b&&c(b)})}return{write(h){if(o){c([h]);return}a.push(h),s+=t(h),m(),(a.length>=r||s>=i)&&y()},flush:p,dispose(){p()}}}function fee(e){return typeof e=="function"?e:Symbol.asyncDispose in e?()=>e[Symbol.asyncDispose]():()=>e[Symbol.dispose]()}function mee(){return d_(pee)}function Rj(e){return mee().cleanup.register(e)}function hee(e){let t=NM.lookup(e);if(t!==void 0)return t;let n=_ee(e);return NM.remember(e,n),n}function _ee(e){if(!e||e.trim()==="")return null;let t=e.split(",").map(o=>o.trim()).filter(Boolean);if(t.length===0)return null;let n=t.some(o=>o.startsWith("!")),r=t.some(o=>!o.startsWith("!"));if(n&&r)return null;let i=t.map(o=>o.replace(/^!/,"").toLowerCase());return{include:n?[]:i,exclude:n?i:[],isExclusive:n}}function yee(e){let t=[],n=e.match(/^MCP server ["']([^"']+)["']/);if(n&&n[1])t.push("mcp"),t.push(n[1].toLowerCase());else{let o=e.match(/^([^:[]+):/);o&&o[1]&&t.push(o[1].trim().toLowerCase())}let r=e.match(/^\[([^\]]+)]/);r&&r[1]&&t.push(r[1].trim().toLowerCase()),e.toLowerCase().includes("1p event:")&&t.push("1p");let i=e.match(/:\s*([^:]+?)(?:\s+(?:type|mode|status|event))?:/);if(i&&i[1]){let o=i[1].trim().toLowerCase();o.length<30&&!o.includes(" ")&&t.push(o)}return Array.from(new Set(t))}function gee(e,t){return t?e.length===0?!1:t.isExclusive?!e.some(n=>t.exclude.includes(n)):e.some(n=>t.include.includes(n)):!0}function bee(e,t){if(!t)return!0;let n=yee(e);return gee(n,t)}function kee(e){if(e.length<=32){if(wee.test(e)){let t=Number(e);return Number.isInteger(t)?t:NaN}if(Tee.test(e))return parseInt(e.replace(Aee,""),10)}}function Cee(e){let t=String(e).trim();return kee(t)??parseInt(t,10)}function uc(){return process.env.CLAUDE_CONFIG_DIR}function Pj(e){let t=e==="CLAUDE_CONFIG_DIR"?uc():process.env[e];if(t===void 0)return;let n=String(t).trim();return n||void 0}function Ij(e){return wt(process.env[e])}function Eee(e){return jM(ir())===jM(e)}function Mj(){return process.env.CLAUDE_CODE_PROJECT_DIR_NAME}function Dj(e){if(!(!e||!Oee.test(e)||xee.test(e)))return e}function Ree(){return`${uc()??""}\0${Mj()??""}`}function Hee(){return Kee}function Me(e,t,n){let r=[];try{let a=cn(r,hn`JSON.stringify(${AA(e)})`,0);return JSON.stringify(e,t,n)}catch(a){var i=a,o=1}finally{fn(r,i,o)}}function Jee(e){return JSON.parse(e)}function Bo(e,t){let n=[];try{let o=cn(n,hn`structuredClone(${AA(e)})`,0);return structuredClone(e,t)}catch(o){var r=o,i=1}finally{fn(n,r,i)}}function AA(e){return typeof e=="string"?e.length:e}function Vee(){return process.platform==="win32"?0:Re.constants.O_NOFOLLOW|Re.constants.O_NONBLOCK}function $j(){return process.platform==="win32"?"r":Re.constants.O_RDONLY|Re.constants.O_NONBLOCK|Re.constants.O_NOCTTY}function Zee(e,t){let n=s=>s.split(bd).filter(Boolean),r=Ve.resolve(e),i=Ve.resolve(t),o=n(r),a=n(i);return Ve.parse(r).root===Ve.parse(i).root&&o.length<a.length&&o.every((s,d)=>s===a[d])}function WS(e){let t="";for(let r of e.split(/([\\/]+)/)){if(r==="."||r==="..")break;t+=r}let n=t.replace(/(?<=[^\\/])[\\/]+$/,"");return n===""?e:n}function Yee(e){let t=Ve.join(e).replace(/(?<=[^\\/])[\\/]+$/,"");return io(t)&&!Cd(t)?t:WS(e)}function Qee(e){if(e.startsWith("\\\\"))return WS(e);let t=e.replace(/^\/+/,"/"),n=vA(t);return n!==null?n:WS(e)}function Om(e,t,n){let r=yd(e);return t.length===0||r||t.some(i=>i==="."||i==="..")?(n!==void 0&&(t.length>0||r)&&n(Ve.join(e,...t)),r?Xee(e):e):Ve.join(e,...t)}function ete(e){return o_(Ve.isAbsolute(e)?e:e.replace(/^(?:\.\.(?:[\\/]+|$))+/,""))}function tte(e,t=process.platform==="win32"){return e.includes("\uFFFD")||ete(e)||t&&(/^(?:[A-Za-z]:(?![\\/])|[\\/](?![\\/]))/.test(e)||/^[\\/]{2}\?[\\/]/.test(e)&&!/^[\\/]{2}\?[\\/](?:[A-Za-z]:[\\/]|UNC[\\/])/i.test(e)||e.split(/[\\/]/).some(n=>n!=="."&&n!==".."&&/[. ]$/.test(n)))}function qM(e,t,n=!1,r=!1,i=!1){if(t?.unreadableAncestry!=="unverified")return;let o=e!==void 0&&typeof e=="object"&&"errno"in e?e.errno:void 0;if(!(o==="ENOENT"||o==="ENOTDIR")&&!(o==="ENAMETOOLONG"&&!n&&!r&&!i))return Sd}function sm(e){return Za(e)}function dm(e,t){return t!==void 0&&t.some(n=>Za(n)&&!mj(e,n)&&(kA(e,n)||Lo(e)))}function UM(e,t){return t!==void 0&&t.some(n=>Za(n)&&kA(n,e))}function kA(e,t){let n=o=>o.length>1?o.replace(/\/+$/,""):o,[r,i]=[n(e),n(t)];return r===i||r.startsWith(i==="/"?i:i+"/")}function xm(e,t){return t===void 0||t.every(n=>mj(e,n))}function BM(e,t){return t===void 0||t.every(n=>kX(e,n))}function zM(e,t,n){let r=Lo(e)?vA(e):null;if(r===null||!xm(r,t))return;let i=Ve.join(e);return Lo(i)&&Um(i)===Um(r)?i:Om(e,[],n)}function nte(e){return e?.anchors!==void 0&&e.anchors.length>0?e.anchors:e?.anchor!==void 0?[e.anchor]:void 0}async function rte(e){return o_(e)||SA(e)||Qd(e)||gd(e)||await Lj(EA,e)!==void 0}async function Nj(e,t=EA){return o_(e)||SA(e)||Qd(e)||gd(e)||await Lj(t,e,{surfaceNetworkRaw:!0,unreadableAncestry:"unverified"})!==void 0}function jj(e,t,n){return ite(Gj(t,n),r=>r.kind==="lstat"?e.lstatSync(r.path):r.kind==="opendirNofollow"?(e.openDirNoFollowSync(r.path),"ok"):e.readlinkSync(r.path))}function Lj(e,t,n,r){return ote(Gj(t,n),r,async i=>i.kind==="lstat"?e.lstat(i.path):i.kind==="opendirNofollow"?(await e.openDirNoFollow(i.path),"ok"):e.readlink(i.path))}function ite(e,t){let n;for(;;){let r=e.next(n);if(r.done)return r.value;try{n=t(r.value)}catch(i){n={errno:tt(i)}}}}async function ote(e,t,n){let r;for(;;){let i=e.next(r);if(i.done)return i.value;if(t?.aborted===!0)return Sd;try{r=await n(i.value)}catch(o){r={errno:tt(o)}}}}function*Gj(e,t){let n=nte(t);if(sm(e)&&!dm(e,n))return e;if(io(e)&&!Cd(e)&&BM(e,n)||Lo(e)&&xm(e,n))return;let r=Ve.resolve(e),i=Ve.parse(r).root,o=i,a=r.slice(i.length).split(bd).filter(Boolean),s=0,d=!1,l=!1,u,c=64,p=()=>a.some(y=>yd(y)),m=()=>/[. ]$/.test(a[0]);for(;a.length>0&&s<c;){if(d&&yd(a[0]))return Sd;let y=Ve.join(o,a[0]);if(Lo(y)&&xm(y,n)||sm(y)&&!(dm(y,n)||UM(y,n)))return Om(y,a.slice(1),t?.onCollapsedLanding);if(Hc(y))return t?.surfaceNetworkRaw===!0||t?.unreadableAncestry==="unverified"?Sd:Om(y,a.slice(1),t?.onCollapsedLanding);let h=process.platform==="darwin"&&y!=="/dev/fd"&&kA(y,"/dev/fd");if(h&&Ve.dirname(y)==="/dev/fd"&&a.some((_,w)=>w>0&&(_===".."||_==="."))){for(a.shift();a[0]==="."&&a.length>1;)a.shift();o=y;continue}let b=h?{errno:"ENOENT"}:yield{kind:"lstat",path:y};if(b===void 0||typeof b=="string"||"errno"in b){if(process.platform!=="win32"&&typeof b=="object"&&"errno"in b&&b.errno!==void 0&&b.errno!=="ENOENT"&&b.errno!=="ENOTDIR"&&b.errno!=="ENAMETOOLONG"&&typeof(yield{kind:"opendirNofollow",path:y})=="string"){l=!0,a.shift(),o=y;continue}if(t?.launchAncestry&&!l&&typeof b=="object"&&"errno"in b&&(b.errno==="EPERM"||b.errno==="EACCES")&&Zee(y,t.launchAncestry)){d=!0,a.shift(),o=y;continue}return typeof b=="object"&&"errno"in b&&(b.errno==="ENOENT"||b.errno==="ENOTDIR")&&t?.onOutcome?.({kind:"absent",at:o,remaining:[...a]}),qM(b,t,s>0,p(),m())}let g=b;if(l=!0,!g.isSymbolicLink()){a.shift(),o=y;continue}s++;let S=y+"\0"+a.join("\0");if((u??=new Set).has(S))return;u.add(S);let v=yield{kind:"readlink",path:y};if(typeof v!="string")return qM(v,t,s>0,p(),m());let T=v;if(t?.literalLinkText==="opaque"&&tte(T))return FM;if(!Ve.isAbsolute(T)){let _=T.split(bd).filter(Boolean);if(t?.surfaceNetworkRaw===!0){let w=zM((o.endsWith(Ve.sep)?o:o+Ve.sep)+[..._,...a.slice(1)].join(Ve.sep),n,t?.onCollapsedLanding);if(w!==void 0)return w}a.shift(),t?.onHop?.({composed:Ve.resolve(o,T,...a),leaf:a.length===0,text:T}),a=[..._,...a];continue}let C=T;if(t?.surfaceNetworkRaw===!0&&a.length>1&&gd(C)){let _=zM([C,...a.slice(1)].join(Ve.sep),n,t?.onCollapsedLanding);if(_!==void 0)return _}if(io(C)&&!Cd(C)&&BM(C,n)||Lo(C)&&xm(C,n)||sm(C)&&!(dm(C,n)||a.length>1&&UM(C,n)))return a.shift(),Om(C,a,t?.onCollapsedLanding);if(t?.surfaceNetworkRaw===!0&&yd(C)&&(io(C)||Qd(C)||Za(C)||gd(C)))return a.shift(),a.length===0?C:C+Ve.sep+a.join(Ve.sep);a.shift(),t?.onHop?.({composed:a.length===0?C:Ve.resolve(C,...a),leaf:a.length===0,text:T});let O=Ve.parse(C).root||Ve.sep;o=O,l=!1,a=[...C.slice(O.length).split(bd).filter(Boolean),...a]}if(a.length>0&&t?.literalLinkText==="opaque")return FM;if(a.length>0)return Sd;if(s>0&&gd(o)||sm(o)&&!dm(o,n))return o;a.length===0&&t?.onOutcome?.({kind:"resolved",path:o})}function CA(e,t){if(io(t)&&!Cd(t)||Lo(t)||OX(t))return{resolvedPath:t,isSymlink:!1,isCanonical:!1};let n=jj(e,t);if(n===Sd)return{resolvedPath:t,isSymlink:!1,isCanonical:!1};if(n!==void 0)return{resolvedPath:n,isSymlink:!0,isCanonical:!1};try{let r=ste(e,t);return{resolvedPath:r,isSymlink:r!==t,isCanonical:!0}}catch{return{resolvedPath:t,isSymlink:!1,isCanonical:!1}}}function ate(e){let t=iQ();if(t===null)return null;try{let n=Ve.resolve(t),r=Ve.resolve(e.cwd()),i=Ve.parse(n).root;if(i!==Ve.parse(r).root)return null;let o=n.slice(i.length).split(bd).filter(Boolean),a=r.slice(i.length).split(bd).filter(Boolean),s=0;for(;s<o.length&&s<a.length&&o[s]===a[s];)s++;return s>0?Ve.join(i,...o.slice(0,s)):null}catch{return null}}function ste(e,t){try{return e.realpathSync(t)}catch(n){let r=tt(n);if(r!=="EPERM"&&r!=="EACCES")throw n;let i,o=ate(e);if(jj(e,t,{unreadableAncestry:"unverified",surfaceNetworkRaw:!0,launchAncestry:o,onOutcome:a=>{i=a}})!==void 0||i===void 0)throw n;if(i.kind==="absent")throw Object.assign(Error("ENOENT: no such file or directory"),{code:"ENOENT",syscall:"realpath",path:t});return on(i.path)}}function Xt(){return EA}async function Fj(e,t,n){let r=n!==void 0?n==="file":(await e.stat()).isFile(),i=[],o=0;for(;o<t;){let a=Buffer.allocUnsafe(Math.min(65536,t-o)),{bytesRead:s}=await e.read(a,0,a.length,r?o:null);if(s===0)break;i.push(a.subarray(0,s)),o+=s}return Buffer.concat(i,o)}function dte(e,t,n){return e.destroyed||e.writableEnded?!1:(e.write(t,n),!0)}function lte(e){dte(process.stderr,e)}function qj(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Uj(e,t,n=t+"s"){return e===1?t:n}function OA(e,t){if(t<=0)return"";if(e.length<=t)return e;let n=e.slice(0,t),r=n.charCodeAt(t-1);return Bj(r>=55296&&r<=56319?n.slice(0,-1):n)}function KM(e,t){if(t<=0)return"";if(e.length<=t)return e;let n=e.slice(-t),r=n.charCodeAt(0);return Bj(r>=56320&&r<=57343?n.slice(1):n)}function Bj(e){return typeof Buffer<"u"?Buffer.from(e,"utf16le").toString("utf16le"):ute(e)}function ute(e){let t=[];for(let n=0;n<e.length;n+=8192){let r=Math.min(n+8192,e.length),i=new Uint16Array(r-n);for(let o=n;o<r;o++)i[o-n]=e.charCodeAt(o);t.push(String.fromCharCode(...i))}return t.join("")}function zj(e){return Hm?Hm(e):!cte.test(e)}function Kj(e){return Hm&&Hm(e)?e:e.replace(fte,"")}function pte(e,t){let n=e.indexOf(t);return n===-1?e:e.slice(0,n)}function mte(e,t,n=0){let r=0,i=e.indexOf(t,n);for(;i!==-1;)r++,i=e.indexOf(t,i+1);return r}function hte(e){let t=/[\p{Cc}\p{Cf}\p{Default_Ignorable_Code_Point}\u2028\u2029]/gu;if(!t.test(e))return e;let n="";for(let{segment:r}of new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(e)){let i=new RegExp("\\p{Extended_Pictographic}|\\p{Regional_Indicator}|^[#*0-9]\\uFE0F?\\u20E3$","u").test(r),o=/^\u{1F3F4}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,6}\u{E007F}$/u.test(r);t.lastIndex=0,n+=r.replace(t,(a,s)=>{if(a===`
|
|
160
160
|
`||a===" ")return a;let d=a.codePointAt(0)??0;return i&&(a==="\uFE0F"||a==="\uFE0E"||a==="\u20E3"||a==="\u200D"&&s+a.length<r.length||o&&d>=917536&&d<=917631)?a:d===27?"\u241B":d<32?String.fromCodePoint(9216+d):d===127?"\u2421":`\\u{${d.toString(16).toUpperCase()}}`})}return n}function Hj(e){return hte(e).replace(/\n/g,"\u2424").replace(/\t/g,"\u2409")}function ZS(e,t){let n=/-----BEGIN[ A-Z0-9_-]{0,100}?PRIVATE KEY(?: BLOCK)?-----/gi,r=/-----END[ A-Z0-9_-]{0,100}?PRIVATE KEY(?: BLOCK)?-----/gi;n.lastIndex=t;let i=n.exec(e);if(!i)return null;r.lastIndex=i.index+i[0].length+gte;let o=r.exec(e);return o?{start:i.index,end:o.index+o[0].length}:null}function bte(e){return ZS(e,0)!==null}function vte(e){let t=ZS(e,0);if(!t)return e;let n="",r=0;for(;t;)n+=e.slice(r,t.start)+"[REDACTED]",r=t.end,t=ZS(e,r);return n+e.slice(r)}function wte(){return Jj.map(e=>({id:e.id,confidence:e.confidence,re:new RegExp(e.confidence!=="high"?e.source:Ste+(e.source.endsWith(WM)?e.source.slice(0,-WM.length)+VM:e.source+VM),(e.flags??"").replace("g","")+"g")}))}function av(e){return Jj.map(t=>({id:t.id,confidence:t.confidence,re:new RegExp(t.source,e?(t.flags??"").replace("g","")+"g":t.flags??"")}))}function YS(e,t){if(typeof t!="string")return"[REDACTED]";let n=t.length>=2&&(t[0]==='"'||t[0]==="'")&&t.at(-1)===t[0]?t[0]:"",r=e.lastIndexOf(t);return`${e.slice(0,r)}${n}[REDACTED]${n}${e.slice(r+t.length)}`}function Cte(e){return kte.redact(e)}function xte(e,t){let n=typeof t=="string"?t:e;return Ete.test(n)||Ote.test(n)?e:YS(e,t)}function Mte(e){return Object.hasOwn(XS,e)}function ZM(e){return IX(e)?null:Ej(e)}function YM(){}function QM(e,t,n,r){let i=No(t,"debug"),o=No(i,`${e.sessionId}.txt`),a;n===null?a=o:r!==null&&n===r?a=No(r,`${e.sessionId}.txt`):a=n;let s=!e.fromBackend&&a===o?"v5":"raw";return{target:a,arm:s,configHome:t,rotate:s==="raw"&&!(od(a)===i&&a.endsWith(".txt")),pointLatest:s==="raw"&&a!==o}}function sv(e){return Oj.userNamed(see(e)?e:Ej(e))}function $te(e){return e.code==="Failed"&&e.telemetryCode==="ENOENT"}function Nte(e,t=uee){return t?e:void 0}async function XM(e,t,n,r){let i={namespace:"log",sessionId:t,channel:"debug"},o=await xj.run(!0,()=>e.append(i,[{data:n}],r?{markLatest:!0}:void 0));return o.ok?"landed":r&&o.error.code==="InvalidArgument"&&o.error.argument==="opts.markLatest"?"refused":"dropped"}function Lte(){return d_(jte)}function Gte(e,t){return new ew({argv:process.argv,env:process.env,sessionId:()=>ZX(),configHomeDir:()=>ir(),onExit:n=>{process.on("exit",n)},registerCleanup:n=>{Rj(n)},writeToStderr:n=>{lte(n)},isAnt:t?.isAnt??!1,isTestEnvironment:t?.isTestEnvironment??!1,launchIdentity:t,storageV5:e.init.storageV5!==void 0&&e.init.configHome===ir()?e.init.storageV5:void 0,syncExitDrain:e.init.syncExitDrain,diskless:()=>YX(),defaultFile:()=>e.defaultFile})}function Fte(){let e=Lte(),t=e.instance;if(t)return t;let n=Gte(e);return e.setInstance(n),n}function Te(e,t={level:"debug"}){Fte().log(e,t)}function rw(){return zte}function ue(e,t){let n=rw(),r=iw({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===cc?void 0:cc].filter(i=>!!i)});e.common.issues.push(r)}function De(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,a)=>{let{message:s}=e;return o.code==="invalid_enum_value"?{message:s??a.defaultError}:typeof a.data>"u"?{message:s??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:s??n??a.defaultError}},description:i}}function Yj(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function sne(e){return new RegExp(`^${Yj(e)}$`)}function dne(e){let t=`${Zj}T${Yj(e)}`,n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function lne(e,t){return!!((t==="v4"||!t)&&ene.test(e)||(t==="v6"||!t)&&nne.test(e))}function une(e,t){if(!Zte.test(e))return!1;try{let[n]=e.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function cne(e,t){return!!((t==="v4"||!t)&&tne.test(e)||(t==="v6"||!t)&&rne.test(e))}function fne(e,t){let n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,o=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return o%a/10**i}function ad(e){if(e instanceof wr){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=Gr.create(ad(r))}return new wr({...e._def,shape:()=>t})}else return e instanceof zo?new zo({...e._def,type:ad(e.element)}):e instanceof Gr?Gr.create(ad(e.unwrap())):e instanceof so?so.create(ad(e.unwrap())):e instanceof ao?ao.create(e.items.map(t=>ad(t))):e}function aw(e,t){let n=Do(e),r=Do(t);if(e===t)return{valid:!0,data:e};if(n===_e.object&&r===_e.object){let i=et.objectKeys(t),o=et.objectKeys(e).filter(s=>i.indexOf(s)!==-1),a={...e,...t};for(let s of o){let d=aw(e[s],t[s]);if(!d.valid)return{valid:!1};a[s]=d.data}return{valid:!0,data:a}}else if(n===_e.array&&r===_e.array){if(e.length!==t.length)return{valid:!1};let i=[];for(let o=0;o<e.length;o++){let a=e[o],s=t[o],d=aw(a,s);if(!d.valid)return{valid:!1};i.push(d.data)}return{valid:!0,data:i}}else return n===_e.date&&r===_e.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}function Qj(e,t){return new Nd({values:e,typeName:se.ZodEnum,...De(t)})}function W(e){return mne.lazy(e)}function hne(e){let t=e?.trim();return t||void 0}function nl(e){return e===void 0?void 0:String(e)}function Sne(e){return typeof e=="boolean"?e?"1":"0":String(e)}function Xj(e){return tl(nl,el().optional().transform(t=>{if(t===void 0||e?.digitsOnly&&!/^[+-]?\d+$/.test(t.trim()))return;let n=Cee(t);if(Number.isFinite(n)&&!(e?.min!==void 0&&n<e.min)&&!(e?.max!==void 0&&n>e.max))return n}))}function RA(e,t){let n=0;for(let r of e)n+=+!!t(r);return n}function Wo(e){return[...new Set(e)]}function nL(){return"prod"}function Vie(){if(process.env.CLAUDE_CODE_CUSTOM_OAUTH_URL)return"-custom-oauth";switch(nL()){case"local":return"-local-oauth";case"staging":return"-staging-oauth";case"prod":return""}}function Qie(){let e=process.env.CLAUDE_LOCAL_OAUTH_API_BASE?.replace(/\/$/,"")??"http://localhost:8000",t=process.env.CLAUDE_LOCAL_OAUTH_APPS_BASE?.replace(/\/$/,"")??"http://localhost:4000",n=process.env.CLAUDE_LOCAL_OAUTH_CONSOLE_BASE?.replace(/\/$/,"")??"http://localhost:3000";return{BASE_API_URL:e,CONSOLE_AUTHORIZE_URL:`${n}/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`${t}/oauth/authorize`,CLAUDE_AI_ORIGIN:t,TOKEN_URL:`${e}/v1/oauth/token`,API_KEY_URL:`${e}/api/oauth/claude_cli/create_api_key`,ROLES_URL:`${e}/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`${n}/buy_credits?returnUrl=/oauth/code/success%3Fapp%3Dclaude-code`,CLAUDEAI_SUCCESS_URL:`${n}/oauth/code/success?app=claude-code`,MANUAL_REDIRECT_URL:`${n}/oauth/code/callback`,CLIENT_ID:"22422756-60c9-4084-8eb7-27705fd5cf9a",DESIGN_CLIENT_ID:"00000000-0000-4000-8000-000000000000",OAUTH_FILE_SUFFIX:"-local-oauth",PLUGINS_SCOPE_REGISTERED:!0,PROJECTS_SCOPES_REGISTERED:!0,MCP_PROXY_URL:"http://localhost:8205",MCP_PROXY_PATH:"/v1/toolbox/shttp/mcp/{server_id}"}}function eoe(){switch(nL()){case"local":return Qie();case"staging":return Yie??iD;case"prod":return iD}}function toe(){let e=eoe(),t=process.env.CLAUDE_CODE_CUSTOM_OAUTH_URL;if(t){let r=t.replace(/\/$/,"");if(!Xie.includes(r))throw Error("CLAUDE_CODE_CUSTOM_OAUTH_URL is not an approved endpoint.");e={...e,BASE_API_URL:r,CONSOLE_AUTHORIZE_URL:`${r}/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`${r}/oauth/authorize`,CLAUDE_AI_ORIGIN:r,TOKEN_URL:`${r}/v1/oauth/token`,API_KEY_URL:`${r}/api/oauth/claude_cli/create_api_key`,ROLES_URL:`${r}/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`${r}/oauth/code/success?app=claude-code`,CLAUDEAI_SUCCESS_URL:`${r}/oauth/code/success?app=claude-code`,MANUAL_REDIRECT_URL:`${r}/oauth/code/callback`,OAUTH_FILE_SUFFIX:"-custom-oauth",PLUGINS_SCOPE_REGISTERED:!1,PROJECTS_SCOPES_REGISTERED:!1}}let n=process.env.CLAUDE_CODE_OAUTH_CLIENT_ID;return n&&(e={...e,CLIENT_ID:n,PLUGINS_SCOPE_REGISTERED:!1,PROJECTS_SCOPES_REGISTERED:!1}),e}function PA(){return process.versions.bun!==void 0}function Ooe(e,{suffix:t="nodejs"}={}){if(typeof e!="string")throw TypeError(`Expected a string, got ${typeof e}`);return t&&(e+=`-${t}`),cw.platform==="darwin"?koe(e):cw.platform==="win32"?Coe(e):Eoe(e)}function xoe(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t}function Roe(e){return`</pasted_content id="${e}">
|
|
161
161
|
`}function Poe(e){if(e.length!==4)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(!(n>=48&&n<=57||n>=97&&n<=102))return!1}return!0}function Ioe(e){let t=[],n=0,r=0;for(;;){let i=e.indexOf('<pasted_content id="',r);if(i===-1)break;let o=i+20,a=e.slice(o,o+4);if(!Poe(a)||!e.startsWith(`">
|