@linzumi/cli 1.0.275 → 1.0.277
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 +10 -9
- package/dist/cloud-supervisor.mjs +295 -0
- package/dist/hosted-coding-account-worker.js +25 -0
- package/dist/index.js +2084 -3
- package/dist/mcp-server.mjs +174 -168
- package/dist/{impl-res/native → native}/darwin/manifest.json +5 -2
- package/dist/remote-codex-harness-worker.js +757 -0
- package/dist/tcp-tunnel-cli.mjs +25 -69
- package/dist/topics-cli.mjs +137 -13
- package/package.json +10 -17
- package/scripts/build.mjs +33 -356
- package/scripts/bump-cli-version.mjs +35 -36
- package/scripts/check-package-size-budget.mjs +13 -61
- package/scripts/vm-provision-proof.mjs +1 -2
- package/dist/impl-res/cloud-supervisor.mjs +0 -281
- package/dist/impl-res/index.js +0 -1546
- package/dist/impl-res/mcp-server.mjs +0 -461
- package/dist/impl-ts/assets/linzumi-logo.svg +0 -1
- package/dist/impl-ts/cloud-supervisor.mjs +0 -281
- package/dist/impl-ts/crossHarnessFailover.mjs +0 -14
- package/dist/impl-ts/index.js +0 -2617
- package/dist/impl-ts/mcp-server.mjs +0 -455
- package/dist/impl-ts/native/darwin/manifest.json +0 -21
- package/dist/impl-ts/native/darwin/preview-process-identity +0 -0
- package/dist/impl-ts/tcp-tunnel-cli.mjs +0 -93
- package/scripts/build-differential-entry-impl-res.mjs +0 -64
- package/scripts/build-differential-entry.mjs +0 -180
- package/scripts/build-onboarding-demo-evidence.mjs +0 -186
- package/scripts/build-tui-demo-evidence.mjs +0 -107
- package/scripts/diagnose-claude-probe.ts +0 -198
- package/scripts/differentialMutations.mjs +0 -114
- package/scripts/f5_live_cross_harness_failover_e2e.mjs +0 -239
- package/scripts/golden-chaos-harness.mjs +0 -1420
- package/scripts/golden-lifecycle-e2e.mjs +0 -969
- package/scripts/normalize-agent-replay-fixture.ts +0 -281
- package/scripts/promote-gstack-claude-smoke-fixture.ts +0 -891
- package/scripts/record-agent-replay-fixtures.ts +0 -610
- package/scripts/replay-agent-backend-browser.ts +0 -198
- package/scripts/replay-agent-backend.ts +0 -1961
- package/scripts/replay-agent-fixture.ts +0 -326
- package/scripts/typecheck.mjs +0 -42
- package/scripts/vm-smoke.mjs +0 -241
- /package/dist/{impl-res/assets → assets}/linzumi-logo.svg +0 -0
- /package/dist/{impl-res/crossHarnessFailover.mjs → crossHarnessFailover.mjs} +0 -0
- /package/dist/{impl-res/native → native}/darwin/preview-process-identity +0 -0
package/dist/topics-cli.mjs
CHANGED
|
@@ -1,13 +1,135 @@
|
|
|
1
1
|
import { createRequire as __linzumiBundleCreateRequire } from 'node:module';
|
|
2
2
|
const require = __linzumiBundleCreateRequire(import.meta.url);
|
|
3
|
-
|
|
3
|
+
var Cl=Object.create;var Qn=Object.defineProperty;var Fl=Object.getOwnPropertyDescriptor;var Nl=Object.getOwnPropertyNames;var Il=Object.getPrototypeOf,$l=Object.prototype.hasOwnProperty;var Xe=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Se=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Pl=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Nl(t))!$l.call(e,i)&&i!==r&&Qn(e,i,{get:()=>t[i],enumerable:!(n=Fl(t,i))||n.enumerable});return e};var Rl=(e,t,r)=>(r=e!=null?Cl(Il(e)):{},Pl(t||!e||!e.__esModule?Qn(r,"default",{value:e,enumerable:!0}):r,e));var oi=Se((Rs,ii)=>{var Ye=Xe("constants"),jl=process.cwd,hr=null,Ul=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return hr||(hr=jl.call(process)),hr};try{process.cwd()}catch{}typeof process.chdir=="function"&&(Zr=process.chdir,process.chdir=function(e){hr=null,Zr.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,Zr));var Zr;ii.exports=Ll;function Ll(e){Ye.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||r(e),e.chown=o(e.chown),e.fchown=o(e.fchown),e.lchown=o(e.lchown),e.chmod=n(e.chmod),e.fchmod=n(e.fchmod),e.lchmod=n(e.lchmod),e.chownSync=l(e.chownSync),e.fchownSync=l(e.fchownSync),e.lchownSync=l(e.lchownSync),e.chmodSync=i(e.chmodSync),e.fchmodSync=i(e.fchmodSync),e.lchmodSync=i(e.lchmodSync),e.stat=a(e.stat),e.fstat=a(e.fstat),e.lstat=a(e.lstat),e.statSync=s(e.statSync),e.fstatSync=s(e.fstatSync),e.lstatSync=s(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(u,m,c){c&&process.nextTick(c)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(u,m,c,d){d&&process.nextTick(d)},e.lchownSync=function(){}),Ul==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:(function(u){function m(c,d,p){var h=Date.now(),_=0;u(c,d,function y(g){if(g&&(g.code==="EACCES"||g.code==="EPERM"||g.code==="EBUSY")&&Date.now()-h<6e4){setTimeout(function(){e.stat(d,function(S,T){S&&S.code==="ENOENT"?u(c,d,y):p(g)})},_),_<100&&(_+=10);return}p&&p(g)})}return Object.setPrototypeOf&&Object.setPrototypeOf(m,u),m})(e.rename)),e.read=typeof e.read!="function"?e.read:(function(u){function m(c,d,p,h,_,y){var g;if(y&&typeof y=="function"){var S=0;g=function(T,C,N){if(T&&T.code==="EAGAIN"&&S<10)return S++,u.call(e,c,d,p,h,_,g);y.apply(this,arguments)}}return u.call(e,c,d,p,h,_,g)}return Object.setPrototypeOf&&Object.setPrototypeOf(m,u),m})(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:(function(u){return function(m,c,d,p,h){for(var _=0;;)try{return u.call(e,m,c,d,p,h)}catch(y){if(y.code==="EAGAIN"&&_<10){_++;continue}throw y}}})(e.readSync);function t(u){u.lchmod=function(m,c,d){u.open(m,Ye.O_WRONLY|Ye.O_SYMLINK,c,function(p,h){if(p){d&&d(p);return}u.fchmod(h,c,function(_){u.close(h,function(y){d&&d(_||y)})})})},u.lchmodSync=function(m,c){var d=u.openSync(m,Ye.O_WRONLY|Ye.O_SYMLINK,c),p=!0,h;try{h=u.fchmodSync(d,c),p=!1}finally{if(p)try{u.closeSync(d)}catch{}else u.closeSync(d)}return h}}function r(u){Ye.hasOwnProperty("O_SYMLINK")&&u.futimes?(u.lutimes=function(m,c,d,p){u.open(m,Ye.O_SYMLINK,function(h,_){if(h){p&&p(h);return}u.futimes(_,c,d,function(y){u.close(_,function(g){p&&p(y||g)})})})},u.lutimesSync=function(m,c,d){var p=u.openSync(m,Ye.O_SYMLINK),h,_=!0;try{h=u.futimesSync(p,c,d),_=!1}finally{if(_)try{u.closeSync(p)}catch{}else u.closeSync(p)}return h}):u.futimes&&(u.lutimes=function(m,c,d,p){p&&process.nextTick(p)},u.lutimesSync=function(){})}function n(u){return u&&function(m,c,d){return u.call(e,m,c,function(p){f(p)&&(p=null),d&&d.apply(this,arguments)})}}function i(u){return u&&function(m,c){try{return u.call(e,m,c)}catch(d){if(!f(d))throw d}}}function o(u){return u&&function(m,c,d,p){return u.call(e,m,c,d,function(h){f(h)&&(h=null),p&&p.apply(this,arguments)})}}function l(u){return u&&function(m,c,d){try{return u.call(e,m,c,d)}catch(p){if(!f(p))throw p}}}function a(u){return u&&function(m,c,d){typeof c=="function"&&(d=c,c=null);function p(h,_){_&&(_.uid<0&&(_.uid+=4294967296),_.gid<0&&(_.gid+=4294967296)),d&&d.apply(this,arguments)}return c?u.call(e,m,c,p):u.call(e,m,p)}}function s(u){return u&&function(m,c){var d=c?u.call(e,m,c):u.call(e,m);return d&&(d.uid<0&&(d.uid+=4294967296),d.gid<0&&(d.gid+=4294967296)),d}}function f(u){if(!u||u.code==="ENOSYS")return!0;var m=!process.getuid||process.getuid()!==0;return!!(m&&(u.code==="EINVAL"||u.code==="EPERM"))}}});var ai=Se((Ms,ui)=>{var li=Xe("stream").Stream;ui.exports=zl;function zl(e){return{ReadStream:t,WriteStream:r};function t(n,i){if(!(this instanceof t))return new t(n,i);li.call(this);var o=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,i=i||{};for(var l=Object.keys(i),a=0,s=l.length;a<s;a++){var f=l[a];this[f]=i[f]}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,m){if(u){o.emit("error",u),o.readable=!1;return}o.fd=m,o.emit("open",m),o._read()})}function r(n,i){if(!(this instanceof r))return new r(n,i);li.call(this),this.path=n,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),l=0,a=o.length;l<a;l++){var s=o[l];this[s]=i[s]}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 di=Se((Ds,si)=>{"use strict";si.exports=Jl;var ql=Object.getPrototypeOf||function(e){return e.__proto__};function Jl(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:ql(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}});var tn=Se((js,en)=>{var V=Xe("fs"),Wl=oi(),Bl=ai(),Vl=di(),_r=Xe("util"),le,gr;typeof Symbol=="function"&&typeof Symbol.for=="function"?(le=Symbol.for("graceful-fs.queue"),gr=Symbol.for("graceful-fs.previous")):(le="___graceful-fs.queue",gr="___graceful-fs.previous");function Hl(){}function mi(e,t){Object.defineProperty(e,le,{get:function(){return t}})}var ct=Hl;_r.debuglog?ct=_r.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(ct=function(){var e=_r.format.apply(_r,arguments);e="GFS4: "+e.split(/\n/).join(`
|
|
4
|
+
GFS4: `),console.error(e)});V[le]||(fi=global[le]||[],mi(V,fi),V.close=(function(e){function t(r,n){return e.call(V,r,function(i){i||ci(),typeof n=="function"&&n.apply(this,arguments)})}return Object.defineProperty(t,gr,{value:e}),t})(V.close),V.closeSync=(function(e){function t(r){e.apply(V,arguments),ci()}return Object.defineProperty(t,gr,{value:e}),t})(V.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ct(V[le]),Xe("assert").equal(V[le].length,0)}));var fi;global[le]||mi(global,V[le]);en.exports=Yr(Vl(V));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!V.__patched&&(en.exports=Yr(V),V.__patched=!0);function Yr(e){Wl(e),e.gracefulify=Yr,e.createReadStream=C,e.createWriteStream=N;var t=e.readFile;e.readFile=r;function r(x,b,F){return typeof b=="function"&&(F=b,b=null),J(x,b,F);function J(L,E,v,G){return t(L,E,function(w){w&&(w.code==="EMFILE"||w.code==="ENFILE")?Et([J,[L,E,v],w,G||Date.now(),Date.now()]):typeof v=="function"&&v.apply(this,arguments)})}}var n=e.writeFile;e.writeFile=i;function i(x,b,F,J){return typeof F=="function"&&(J=F,F=null),L(x,b,F,J);function L(E,v,G,w,O){return n(E,v,G,function(k){k&&(k.code==="EMFILE"||k.code==="ENFILE")?Et([L,[E,v,G,w],k,O||Date.now(),Date.now()]):typeof w=="function"&&w.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=l);function l(x,b,F,J){return typeof F=="function"&&(J=F,F=null),L(x,b,F,J);function L(E,v,G,w,O){return o(E,v,G,function(k){k&&(k.code==="EMFILE"||k.code==="ENFILE")?Et([L,[E,v,G,w],k,O||Date.now(),Date.now()]):typeof w=="function"&&w.apply(this,arguments)})}}var a=e.copyFile;a&&(e.copyFile=s);function s(x,b,F,J){return typeof F=="function"&&(J=F,F=0),L(x,b,F,J);function L(E,v,G,w,O){return a(E,v,G,function(k){k&&(k.code==="EMFILE"||k.code==="ENFILE")?Et([L,[E,v,G,w],k,O||Date.now(),Date.now()]):typeof w=="function"&&w.apply(this,arguments)})}}var f=e.readdir;e.readdir=m;var u=/^v[0-5]\./;function m(x,b,F){typeof b=="function"&&(F=b,b=null);var J=u.test(process.version)?function(v,G,w,O){return f(v,L(v,G,w,O))}:function(v,G,w,O){return f(v,G,L(v,G,w,O))};return J(x,b,F);function L(E,v,G,w){return function(O,k){O&&(O.code==="EMFILE"||O.code==="ENFILE")?Et([J,[E,v,G],O,w||Date.now(),Date.now()]):(k&&k.sort&&k.sort(),typeof G=="function"&&G.call(this,O,k))}}}if(process.version.substr(0,4)==="v0.8"){var c=Bl(e);y=c.ReadStream,S=c.WriteStream}var d=e.ReadStream;d&&(y.prototype=Object.create(d.prototype),y.prototype.open=g);var p=e.WriteStream;p&&(S.prototype=Object.create(p.prototype),S.prototype.open=T),Object.defineProperty(e,"ReadStream",{get:function(){return y},set:function(x){y=x},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return S},set:function(x){S=x},enumerable:!0,configurable:!0});var h=y;Object.defineProperty(e,"FileReadStream",{get:function(){return h},set:function(x){h=x},enumerable:!0,configurable:!0});var _=S;Object.defineProperty(e,"FileWriteStream",{get:function(){return _},set:function(x){_=x},enumerable:!0,configurable:!0});function y(x,b){return this instanceof y?(d.apply(this,arguments),this):y.apply(Object.create(y.prototype),arguments)}function g(){var x=this;K(x.path,x.flags,x.mode,function(b,F){b?(x.autoClose&&x.destroy(),x.emit("error",b)):(x.fd=F,x.emit("open",F),x.read())})}function S(x,b){return this instanceof S?(p.apply(this,arguments),this):S.apply(Object.create(S.prototype),arguments)}function T(){var x=this;K(x.path,x.flags,x.mode,function(b,F){b?(x.destroy(),x.emit("error",b)):(x.fd=F,x.emit("open",F))})}function C(x,b){return new e.ReadStream(x,b)}function N(x,b){return new e.WriteStream(x,b)}var H=e.open;e.open=K;function K(x,b,F,J){return typeof F=="function"&&(J=F,F=null),L(x,b,F,J);function L(E,v,G,w,O){return H(E,v,G,function(k,R){k&&(k.code==="EMFILE"||k.code==="ENFILE")?Et([L,[E,v,G,w],k,O||Date.now(),Date.now()]):typeof w=="function"&&w.apply(this,arguments)})}}return e}function Et(e){ct("ENQUEUE",e[0].name,e[1]),V[le].push(e),Qr()}var yr;function ci(){for(var e=Date.now(),t=0;t<V[le].length;++t)V[le][t].length>2&&(V[le][t][3]=e,V[le][t][4]=e);Qr()}function Qr(){if(clearTimeout(yr),yr=void 0,V[le].length!==0){var e=V[le].shift(),t=e[0],r=e[1],n=e[2],i=e[3],o=e[4];if(i===void 0)ct("RETRY",t.name,r),t.apply(null,r);else if(Date.now()-i>=6e4){ct("TIMEOUT",t.name,r);var l=r.pop();typeof l=="function"&&l.call(null,n)}else{var a=Date.now()-o,s=Math.max(o-i,1),f=Math.min(s*1.2,100);a>=f?(ct("RETRY",t.name,r),t.apply(null,r.concat([i]))):V[le].push(e)}yr===void 0&&(yr=setTimeout(Qr,0))}}});var hi=Se((Us,pi)=>{function Oe(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))}pi.exports=Oe;Oe.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};Oe.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};Oe.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 r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),r=this._timeouts.shift();else return!1;var n=this,i=setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref&&n._timeout.unref()),n._fn(n._attempts)},r);return this._options.unref&&i.unref(),!0};Oe.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};Oe.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};Oe.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};Oe.prototype.start=Oe.prototype.try;Oe.prototype.errors=function(){return this._errors};Oe.prototype.attempts=function(){return this._attempts};Oe.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,r=0,n=0;n<this._errors.length;n++){var i=this._errors[n],o=i.message,l=(e[o]||0)+1;e[o]=l,l>=r&&(t=i,r=l)}return t}});var _i=Se(mt=>{var Kl=hi();mt.operation=function(e){var t=mt.timeouts(e);return new Kl(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};mt.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 r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var n=[],i=0;i<t.retries;i++)n.push(this.createTimeout(i,t));return e&&e.forever&&!n.length&&n.push(this.createTimeout(i,t)),n.sort(function(o,l){return o-l}),n};mt.createTimeout=function(e,t){var r=t.randomize?Math.random()+1:1,n=Math.round(r*t.minTimeout*Math.pow(t.factor,e));return n=Math.min(n,t.maxTimeout),n};mt.wrap=function(e,t,r){if(t instanceof Array&&(r=t,t=null),!r){r=[];for(var n in e)typeof e[n]=="function"&&r.push(n)}for(var i=0;i<r.length;i++){var o=r[i],l=e[o];e[o]=function(s){var f=mt.operation(t),u=Array.prototype.slice.call(arguments,1),m=u.pop();u.push(function(c){f.retry(c)||(c&&(arguments[0]=f.mainError()),m.apply(this,arguments))}),f.attempt(function(){s.apply(e,u)})}.bind(e,l),e[o].options=t}}});var gi=Se((zs,yi)=>{yi.exports=_i()});var Si=Se((qs,Sr)=>{Sr.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&Sr.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Sr.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var wi=Se((Js,Gt)=>{var W=global.process,pt=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"};pt(W)?(Ti=Xe("assert"),kt=Si(),Ai=/^win/i.test(W.platform),Bt=Xe("events"),typeof Bt!="function"&&(Bt=Bt.EventEmitter),W.__signal_exit_emitter__?re=W.__signal_exit_emitter__:(re=W.__signal_exit_emitter__=new Bt,re.count=0,re.emitted={}),re.infinite||(re.setMaxListeners(1/0),re.infinite=!0),Gt.exports=function(e,t){if(!pt(global.process))return function(){};Ti.equal(typeof e,"function","a callback must be provided for exit handler"),bt===!1&&rn();var r="exit";t&&t.alwaysLast&&(r="afterexit");var n=function(){re.removeListener(r,e),re.listeners("exit").length===0&&re.listeners("afterexit").length===0&&Tr()};return re.on(r,e),n},Tr=function(){!bt||!pt(global.process)||(bt=!1,kt.forEach(function(t){try{W.removeListener(t,Ar[t])}catch{}}),W.emit=vr,W.reallyExit=nn,re.count-=1)},Gt.exports.unload=Tr,ht=function(t,r,n){re.emitted[t]||(re.emitted[t]=!0,re.emit(t,r,n))},Ar={},kt.forEach(function(e){Ar[e]=function(){if(pt(global.process)){var r=W.listeners(e);r.length===re.count&&(Tr(),ht("exit",null,e),ht("afterexit",null,e),Ai&&e==="SIGHUP"&&(e="SIGINT"),W.kill(W.pid,e))}}}),Gt.exports.signals=function(){return kt},bt=!1,rn=function(){bt||!pt(global.process)||(bt=!0,re.count+=1,kt=kt.filter(function(t){try{return W.on(t,Ar[t]),!0}catch{return!1}}),W.emit=Oi,W.reallyExit=vi)},Gt.exports.load=rn,nn=W.reallyExit,vi=function(t){pt(global.process)&&(W.exitCode=t||0,ht("exit",W.exitCode,null),ht("afterexit",W.exitCode,null),nn.call(W,W.exitCode))},vr=W.emit,Oi=function(t,r){if(t==="exit"&&pt(global.process)){r!==void 0&&(W.exitCode=r);var n=vr.apply(this,arguments);return ht("exit",W.exitCode,null),ht("afterexit",W.exitCode,null),n}else return vr.apply(this,arguments)}):Gt.exports=function(){return function(){}};var Ti,kt,Ai,Bt,re,Tr,ht,Ar,bt,rn,nn,vi,vr,Oi});var Gi=Se((Ws,Vt)=>{"use strict";var Xl=Xe("path"),un=tn(),Zl=gi(),Yl=wi(),Ue={};function Ct(e,t){return t.lockfilePath||`${e}.lock`}function an(e,t,r){if(!t.realpath)return r(null,Xl.resolve(e));t.fs.realpath(e,r)}function on(e,t,r){t.fs.mkdir(Ct(e,t),n=>{if(!n)return r();if(n.code!=="EEXIST")return r(n);if(t.stale<=0)return r(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));t.fs.stat(Ct(e,t),(i,o)=>{if(i)return i.code==="ENOENT"?on(e,{...t,stale:0},r):r(i);if(!Ei(o,t))return r(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));ki(e,t,l=>{if(l)return r(l);on(e,{...t,stale:0},r)})})})}function Ei(e,t){return e.mtime.getTime()<Date.now()-t.stale}function ki(e,t,r){t.fs.rmdir(Ct(e,t),n=>{if(n&&n.code!=="ENOENT")return r(n);r()})}function ln(e,t){let r=Ue[e];r.updateTimeout||(r.updateDelay=r.updateDelay||t.update,r.updateTimeout=setTimeout(()=>{let n=Date.now()/1e3;r.updateTimeout=null,t.fs.utimes(Ct(e,t),n,n,i=>{if(!r.released){if(r.lastUpdate<=Date.now()-t.stale&&r.lastUpdate>Date.now()-t.stale*2){let o=Object.assign(new Error(r.updateError||"Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"});return xi(e,r,o)}if(i)return i.code==="ENOENT"?xi(e,r,Object.assign(i,{code:"ECOMPROMISED"})):(r.updateError=i,r.updateDelay=1e3,ln(e,t));r.lastUpdate=Date.now(),r.updateError=null,r.updateDelay=null,ln(e,t)}})},r.updateDelay),r.updateTimeout.unref&&r.updateTimeout.unref())}function xi(e,t,r){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),Ue[e]===t&&delete Ue[e],t.options.onCompromised(r)}function Ql(e,t,r){t={stale:1e4,update:null,realpath:!0,retries:0,fs:un,onCompromised:n=>{throw n},...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),an(e,t,(n,i)=>{if(n)return r(n);let o=Zl.operation(t.retries);o.attempt(()=>{on(i,t,l=>{if(o.retry(l))return;if(l)return r(o.mainError());let a=Ue[i]={options:t,lastUpdate:Date.now()};ln(i,t),r(null,s=>{if(a.released)return s&&s(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));bi(i,{...t,realpath:!1},s)})})})})}function bi(e,t,r){t={fs:un,realpath:!0,...t},an(e,t,(n,i)=>{if(n)return r(n);let o=Ue[i];if(!o)return r(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));o.updateTimeout&&clearTimeout(o.updateTimeout),o.released=!0,delete Ue[i],ki(i,t,r)})}function eu(e,t,r){t={stale:1e4,realpath:!0,fs:un,...t},t.stale=Math.max(t.stale||0,2e3),an(e,t,(n,i)=>{if(n)return r(n);t.fs.stat(Ct(i,t),(o,l)=>o?o.code==="ENOENT"?r(null,!1):r(o):r(null,!Ei(l,t)))})}function tu(){return Ue}Yl(()=>{for(let e in Ue){let t=Ue[e].options;try{t.fs.rmdirSync(Ct(e,t))}catch{}}});Vt.exports.lock=Ql;Vt.exports.unlock=bi;Vt.exports.check=eu;Vt.exports.getLocks=tu});var Fi=Se((Bs,Ci)=>{"use strict";var ru=tn();function nu(e){let t=["mkdir","realpath","stat","rmdir","utimes"],r={...e};return t.forEach(n=>{r[n]=(...i)=>{let o=i.pop(),l;try{l=e[`${n}Sync`](...i)}catch(a){return o(a)}o(null,l)}}),r}function iu(e){return(...t)=>new Promise((r,n)=>{t.push((i,o)=>{i?n(i):r(o)}),e(...t)})}function ou(e){return(...t)=>{let r,n;if(t.push((i,o)=>{r=i,n=o}),e(...t),r)throw r;return n}}function lu(e){if(e={...e},e.fs=nu(e.fs||ru),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}Ci.exports={toPromise:iu,toSync:ou,toSyncOptions:lu}});var Ii=Se((Vs,Qe)=>{"use strict";var Ft=Gi(),{toPromise:Or,toSync:wr,toSyncOptions:sn}=Fi();async function Ni(e,t){let r=await Or(Ft.lock)(e,t);return Or(r)}function uu(e,t){let r=wr(Ft.lock)(e,sn(t));return wr(r)}function au(e,t){return Or(Ft.unlock)(e,t)}function su(e,t){return wr(Ft.unlock)(e,sn(t))}function du(e,t){return Or(Ft.check)(e,t)}function fu(e,t){return wr(Ft.check)(e,sn(t))}Qe.exports=Ni;Qe.exports.lock=Ni;Qe.exports.unlock=au;Qe.exports.lockSync=uu;Qe.exports.unlockSync=su;Qe.exports.check=du;Qe.exports.checkSync=fu});import*as vl from"node:crypto";function Te(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 Ze(e){if(e!=null)return Te(e)}function D(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}}function Hr(e,t,r){return e.reduce(r,t)}function De(e,t){let r=e.length,n=new Array(r),i=0;for(let o=0;o<r;++o){let l=e[o],a=t(l);a!==void 0&&(n[i]=D(a),i=i+1|0)}return n.length=i,n}function Ce(e){if(e.RE_EXN_ID==="JsExn")return Te(e._1)}var pr=(e=>t=>t&&typeof t[e]=="string"?t[e]:void 0),Is=pr("stack"),Ae=pr("message"),$s=pr("name"),Ps=pr("fileName");import*as I from"node:fs";import*as xr from"node:crypto";function ve(e,t){if(e!==void 0)return Te(t(D(e)))}function q(e,t){if(e!==void 0)return t(D(e))}function $(e,t){return e!==void 0?D(e):t}function Kr(e,t){return e!==void 0?e:t}function ri(e){return e===void 0}function Xr(e,t){let r=e.indexOf(t);if(r!==-1)return r}var hu=Rl(Ii(),1);var $i=(function(e,t){for(var r in e)t(r)});function Nt(e,t){if(e===t)return!0;let r=typeof e;if(r==="string"||r==="number"||r==="bigint"||r==="boolean"||r==="undefined"||e===null)return!1;let n=typeof t;if(r==="function"||n==="function")throw{RE_EXN_ID:"Invalid_argument",_1:"equal: functional value",Error:new Error};if(n==="number"||n==="bigint"||n==="undefined"||t===null)return!1;let i=e.TAG,o=t.TAG;if(i!==o)return!1;let l=e.length|0,a=t.length|0;if(l===a)if(Array.isArray(e)){let s=0;for(;;){let f=s;if(f===l)return!0;if(!Nt(e[f],t[f]))return!1;s=f+1|0}}else{if(e instanceof Date&&t instanceof Date)return!(e>t||e<t);{let s={contents:!0},f=m=>{if(!Object.prototype.hasOwnProperty.call(t,m)){s.contents=!1;return}},u=m=>{if(!Object.prototype.hasOwnProperty.call(e,m)||!Nt(t[m],e[m])){s.contents=!1;return}};return $i(e,f),s.contents&&$i(t,u),s.contents}}else return!1}import*as Di from"node:child_process";function pu(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function j(e){return pu(e)?e:{RE_EXN_ID:"JsExn",_1:e}}var fn={};function Mi(e){let t=fn[e];if(t!==void 0){let r=t+1|0;return fn[e]=r,e+("/"+r)}return fn[e]=1,e}function ze(e){let t=Ce(e);if(t===void 0)return{code:void 0,message:"unknown error"};let r=D(t);return{code:Ze(r.code),message:$(Ae(r),"unknown error")}}function ji(e,t){return Nt(e.code,t)}function et(e){try{return{TAG:"Ok",_0:I.readFileSync(e,"utf8")}}catch(t){let r=j(t);return{TAG:"Error",_0:ze(r)}}}function Ht(e,t,r){try{return{TAG:"Ok",_0:(I.writeFileSync(e,t,r),void 0)}}catch(n){let i=j(n);return{TAG:"Error",_0:ze(i)}}}function Kt(e){try{return{TAG:"Ok",_0:(I.mkdirSync(e,{recursive:!0}),void 0)}}catch(t){let r=j(t);return{TAG:"Error",_0:ze(r)}}}function cn(e,t){try{return{TAG:"Ok",_0:(I.chmodSync(e,t),void 0)}}catch(r){let n=j(r);return{TAG:"Error",_0:ze(n)}}}function Ui(e,t){try{return{TAG:"Ok",_0:(I.linkSync(e,t),void 0)}}catch(r){let n=j(r);return{TAG:"Error",_0:ze(n)}}}function Li(e){try{return{TAG:"Ok",_0:(I.unlinkSync(e),void 0)}}catch(t){let r=j(t);return{TAG:"Error",_0:ze(r)}}}function zi(e,t){try{return{TAG:"Ok",_0:(I.renameSync(e,t),void 0)}}catch(r){let n=j(r);return{TAG:"Error",_0:ze(n)}}}function qi(e){try{return{TAG:"Ok",_0:(I.rmSync(e,{force:!0}),void 0)}}catch(t){let r=j(t);return{TAG:"Error",_0:ze(r)}}}function Ji(e){return xr.createHash("sha256").update(e).digest("hex")}function Wi(e){try{return xr.randomBytes(e).toString("hex")}catch{return""}}function Bi(e,t,r,n){try{return{TAG:"Ok",_0:Di.execFileSync(e,t,{encoding:"utf8",timeout:r,maxBuffer:n})}}catch(i){let o=j(i);return{TAG:"Error",_0:ze(o)}}}function tt(e){try{return process.stderr.write(e)}catch{return!1}}function Xt(e,t){return e[t]}function It(e){try{return Te(new URL(e))}catch{return}}function Vi(e){return e.keys().toArray()}function qe(e,t){try{return{TAG:"Ok",_0:new URL(e,t)}}catch(r){let n=j(r),i=Ce(n);return{TAG:"Error",_0:i!==void 0?$(Ae(D(i)),"unknown error"):"unknown error"}}}function X(e,t){return e.TAG==="Ok"?{TAG:"Ok",_0:t(e._0)}:e}function P(e,t){return e.TAG==="Ok"?t(e._0):e}function U(e,t){return e.TAG==="Ok"?e:{TAG:"Error",_0:t(e._0)}}var _u="--api-url must be ws://, wss://, http://, or https://";function ce(e){let t=It(e);if(t===void 0)return{TAG:"Error",_0:"invalid URL: "+e};let r=D(t),n=r.protocol,i;switch(n){case"http:":case"https:":i={TAG:"Ok",_0:void 0};break;case"ws:":r.protocol="http:",i={TAG:"Ok",_0:void 0};break;case"wss:":r.protocol="https:",i={TAG:"Ok",_0:void 0};break;default:i={TAG:"Error",_0:_u}}return X(i,()=>{r.pathname="",r.search="",r.hash="";let o=r.toString();return o.endsWith("/")?o.slice(0,o.length-1|0):o})}var Zt="wss://serve.linzumi.com";import*as pl from"node:os";var Zi={},Mr=[],Su=(e=>({...e}));function Ut(e){let t=0;for(;;){let r=t,n=e[r];if(n===void 0)return'"'+e+'"';switch(n){case'"':case`
|
|
5
|
+
`:return JSON.stringify(e);default:t=r+1|0;continue}}}function Tu(e){return e===""?[]:JSON.parse(e.split('"]["').join('","'))}function Au(e){return"["+Ut(e)+"]"}function vu(e){let t=e.length;return t!==1?t!==0?e.map(Au).join(""):"":"["+Ut(e[0])+"]"}var Sn="sury",Tn=Symbol(Sn),An=Symbol(Sn+":item"),Rt="string",ot="number",Ou="bigint",wu="boolean",xu="symbol",Mt="null",Ie="undefined",_n="nan";var vn="instance",yt="array",ie="object",lt="union",yn="never",or="unknown",Eu="ref",On=Mi("Sury.Exn"),$e="const";function ku(e){return e.type===Ie?!0:e.type===lt?Ie in e.has:!1}function bu(e,t){return(e&t)!==0}var Y={[or]:1,[Rt]:2,[ot]:4,[wu]:8,[Ie]:16,[Mt]:32,[ie]:64,[yt]:128,[lt]:256,[Eu]:512,[Ou]:1024,[_n]:2048,function:4096,[vn]:8192,[yn]:32768,[xu]:16384};function br(e){let t=Y[typeof e];if(t&16)return Ie;if(!(t&64))return t&2?'"'+e+'"':t&1024?e+"n":t&4096?"Function":e.toString();if(e===null)return Mt;if(Array.isArray(e)){let i="[";for(let o=0,l=e.length;o<l;++o)o!==0&&(i=i+", "),i=i+br(e[o]);return i+"]"}if(e.constructor!==Object)return Object.prototype.toString.call(e);let r=Object.keys(e),n="{ ";for(let i=0,o=r.length;i<o;++i){let l=r[i],a=e[l];n=n+l+": "+br(a)+"; "}return n+"}"}function Z(e){let t=e.type,r=e.to,n=e.const,i=e.name;if(i!==void 0)return i;if(n!==void 0)return br(n);let o=e.format,l=e.anyOf;if(l!==void 0)return l.map(Z).join(" | ");if(o!==void 0){if(o!=="compactColumns")return o;let a=e.additionalItems;if(r===void 0)return a!==void 0&&a!=="strip"&&a!=="strict"?Z(a)+"[]":"unknown[][]";let s=r.properties;return s===void 0?"unknown[][]":"["+Object.keys(s).map(u=>{let m=s[u];return Z(m)+"[]"}).join(", ")+"]"}switch(t){case"nan":return"NaN";case"object":let a=e.additionalItems,s=e.properties,f=Object.keys(s);return f.length===0?typeof a===ie?"{ [key: string]: "+Z(a)+"; }":"{}":"{ "+f.map(u=>u+": "+Z(s[u])+";").join(" ")+" }";default:if(e.b)return t;switch(t){case"instance":return e.class.name;case"array":let u=e.additionalItems,m=e.items;if(typeof u!==ie)return"["+m.map(Z).join(", ")+"]";let c=Z(u);return(u.type===lt?"("+c+")":c)+"[]";default:return t}}}var gt=class extends Error{constructor(t){super();for(let r in t)this[r]=t[r]}},ke=Object.defineProperty,lr=gt.prototype;ke(lr,"message",{get(){return Qi(this)}});ke(lr,"name",{value:"SuryError"});ke(lr,"s",{value:Tn});ke(lr,"_1",{get(){return this}});ke(lr,"RE_EXN_ID",{value:On});var Yi=1,wn=function(){},xn=Object.create(null);ke(xn,"with",{get(){return(e,...t)=>e(this,...t)}});wn.prototype=xn;function Dr(e){if(e&&e.s===Tn)return e;throw e}function Qi(e){let t=e.path;return(t===""?"":"Failed at "+t+": ")+e.reason}var Yt={m:Qi,d:void 0,a:"strip",f:0},nt={};var Gr="value",$t="r";function me(e,t){let r=new wn;return r.type=e,r.seq=Yi++,t&&(nt[Gr]=r,ke(r,$t,nt)),r}function eo(e){return e}var mn={};function Lt(e,t,r){if(mn[e])return mn[e];let n=me(t,!0);return r(n),mn[e]=n,n}var ne=me(or,!0);ne.decoder=eo;var Dt=(e=>{let t=new wn;for(let r in e)t[r]=e[r];return t.seq=Yi++,t});function ut(e,t){let r=Dt(e),n=r;for(;n.to;){let i=Dt(n.to);n.to=i,n=i}return t(n),r}function St(e,t){let r=e.g.e,n=r.length;return r[n]=t,"e["+n+"]"}function ur(e,t){let r=Y[t.type],n=t.const;return r&16?"void 0":r&2?Ut(n):r&1024?n+"n":r&28672?St(e,t.const):n}function Tt(e,t){let r='"'+t+'"',n=e[r];if(n!==void 0)return n;let i=Ut(t);return e[r]=i,i}function pe(){return this.i}function Gu(){return this.b.v()}function Cu(){return this.prev.v()}function we(e){let t=e.v+1;return e.v=t,"v"+t}function Cr(e,t){e.hd=e.hd===""?t:e.hd+","+t}function Fu(){let e=this,t=we(e.g);return e.cp="let "+t+"="+e.i+";",e.i=t,e.v=pe,t}function gn(){let e=this,t=e.p;if(t.fz)return e.v=pe,e.i;let r=we(e.g);return Cr(t,r+"="+e.i),e.v=pe,e.i=r,r}function Fr(){let e=this;if(e.fz)return e.v=pe,e.i="("+e.i+")",e.i;let t=we(e.g);if(e.prev!==void 0){let n=e.i;n===""?e.cp="let "+t+";"+e.cp:e.cp=e.cp+("let "+t+"="+n+";")}else{let n=e.i;n===""?Cr(e,t):Cr(e,t+"="+n)}return e.v=pe,e.i=t,t}function Nu(e,t,r,n){return{v:pe,i:"i",s:e,e:t,f:0,cp:"",hd:"",path:"",g:{v:-1,o:r,e:[],d:n}}}function ar(e,t,r){let n=e.path,i="Can't decode "+Z(t)+" to "+Z(r)+". Use S.to to define a custom decoder",o={code:"unsupported_decode",path:n,reason:i,from:t,to:r};throw new gt(o)}function Qt(e,t,r){return St(e,n=>{let i=t(n);throw new gt(i)})+"("+r+")"}function to(e,t,r,n,i,o,l){let a=l!==void 0?l:"Expected "+Z(e)+", received "+(i?br(n):Z(t));if(o!==void 0){let f={};for(let u=0,m=o.length;u<m;++u){let c=o[u],d=c.reason.split(`
|
|
6
|
+
`).join(`
|
|
7
|
+
`),p=c.path,_=`
|
|
8
|
+
- `+(p===""?"":"At "+p+": ")+d;f[_]||(f[_]=1,a=a+_)}}let s={code:"invalid_input",path:r,reason:a,expected:e,received:t,unionErrors:o};return i&&(s.input=n),s}function En(e,t,r,n){return i=>{let o=t!==void 0?t:"",l=n!==void 0?n:!0,a=e!==void 0?e:i.e,s=i.prev,f=s!==void 0?s.s:i.s,u=o===""?i.path:i.path+o;return m=>to(a,f,u,m,l,void 0,r)}}function ue(e){let t=e.e.errorMessage,r;if(t!==void 0){let n=t.type;r=n!==void 0?n:t._}else r=void 0;return En(void 0,void 0,r,void 0)(e)}function Iu(e,t){let r=t!==void 0?t:e.e;return Qt(e,En(r,void 0,void 0,void 0)(e),e.v())}function $u(e,t){let r=e.vc,n=r.length;if(n===1){let l=r[0];return l.c(t)+"||"+Qt(e,l.f(e),t)+";"}let i="",o=0;for(;o<n;){let l=r[o],a=l.f,s=l.c(t);for(o=o+1|0;o<n&&r[o].f===a;)s=s+"&&"+r[o].c(t),o=o+1|0;i=i+(s+"||"+Qt(e,a(e),t)+";")}return i}function ro(e){return e.t===!0?e.prev.t!==!0?e.cp==="":!1:!0}function Ne(e,t){let r=e,n="";for(;r!==void 0;){let i=r;r=i.prev;let o="";if(i.vc)if(t!==void 0&&ro(i)){let a=r.v(),s=i.vc,f="";for(let u=0,m=s.length;u<m;++u){let c=s[u],d=c.c(a);c.f===ue?f=f?f+"&&"+d:d:i.e.noValidation!==!0&&(o=o+(d+"||"+Qt(i,c.f(i),a)+";"))}f&&(t.contents?t.contents=f+"&&"+t.contents:t.contents=f)}else i.e.noValidation!==!0&&(o=$u(i,r.v()));i.hd!==""&&(o=o+("let "+i.hd+";")),i.fz=!0,o=i.cp+o,n=o+n}return n}function Pe(e,t,r,n){let i=n!==void 0?n:e.e;return{v:Fr,i:t,s:r,e:i,prev:e,f:0,d:e.d,cp:"",hd:"",t:!0,path:e.path,g:e.g}}function B(e,t,r,n){let i=t!==void 0?t:e.s,o=n!==void 0?n:e.e,l=e.v!==pe,a={v:l?Cu:pe,i:e.i,s:i,e:o,prev:e,f:e.f,d:e.d,cp:"",hd:"",vc:r,t:e.t,path:e.path,g:e.g};if(l){let s=e.v.bind(e);e.v=()=>{let f=s();return a.i=f,a.v=pe,f}}return a}function kn(e,t){let r=e.vc;r!==void 0?r.push(t):e.vc=[t]}function er(e,t){let r=t.e.inputRefiner,n;if(r!==void 0){let a=r(t);if(a.length!==0)if(t.prev!==void 0){for(let f=0,u=a.length;f<u;++f)kn(t,a[f]);n=void 0}else n=a;else n=void 0}else n=void 0;let i=e.e.refiner,o;if(i!==void 0){let a=i(e);o=a.length!==0?a:void 0}else o=void 0;let l=n!==void 0?o!==void 0?B(e,void 0,n.concat(o),void 0):B(e,void 0,n,void 0):o!==void 0?B(e,void 0,o,void 0):e;return l.io=!0,l}function no(e,t,r){if(!t.vc)return;let i="["+Tt(e.g,r)+"]";t.vc.forEach(o=>kn(e,{c:l=>o.c(l+i),f:o.f})),t.vc=void 0}function io(e,t){let r=e.s.additionalItems,n;n=r!==void 0&&r!=="strip"&&r!=="strict"?r:ne;let i=e.e.additionalItems,o;return o=i!==void 0&&i!=="strip"&&i!=="strict"?i:ne,{p:e,v:Fu,i:e.v()+"["+t+"]",s:n,e:o,f:e.f,cp:"",hd:"",path:"",g:e.g}}function _t(e,t,r){return Pe(e,ur(e,t),t,r)}function oo(e,t){let r=Pe(e,t,e.s,void 0);return r.f=1,r}function it(e,t,r){e.s.type===yt?e.s.items.push(r.s):(r.o||e.s.required.push(t),e.s.properties[t]=r.s),r.f&1&&r.v(),e.cp=e.cp+Ne(r,void 0),e.d[t]=r}function lo(e,t,r){return e.v()+"["+t+"]="+r.i}function We(e){let t=e.v!==pe,r={b:e,v:t?Gu:pe,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 n=e.v.bind(e);e.v=()=>{let i=n();return r.i=i,r.v=pe,i}}return r}function Pu(e,t){throw new gt({code:"invalid_operation",path:e.path,reason:t})}function uo(e,t,r,n){if(e.path===""&&r===void 0)return Ne(e,void 0);{let i=s=>{let f=t.path,u=f===""?"":Ut(f)+"+";return s+".path="+u+(r!==void 0?`'["'+`+r+`+'"]'+`:"")+s+".path"},o=Ne(e,void 0);if(o===""&&!(e.f&1))return o+(n!==void 0?n():"");let l=we(e.g),a=i(l)+";throw "+l;return e.f&1&&(e.i=e.i+".catch("+l+"=>{"+a+"})"),"try{"+o+(n!==void 0?n():"")+"}catch("+l+"){"+a+"}"}}function ao(e){return e}ao.embedded=Mr;function pn(e){return e+"<=2147483647&&"+e+">=-2147483648&&"+e+"%1===0"}function tr(e){return t=>"typeof "+t+'==="'+e+'"'}function Pt(e){return"Number.isNaN("+e+")"}function Nr(e){return"Array.isArray("+e+")"}function so(e){return tr(ie)(e)+"&&"+e}function Ru(e,t){return r=>r+" instanceof "+St(e,t)}function Mu(e){let t=Y[e.s.type];if(t&1){let i=[{c:tr(ot),f:ue}],o=e.e.format,l=0;return o==="int32"?i.push({c:pn,f:ue}):l=1,l===1&&(e.g.o&2||i.push({c:a=>"!"+Pt(a),f:ue})),B(e,e.e,i,void 0)}if(!(t&2))return t&4?e.s.format!==e.e.format&&e.e.format==="int32"?B(e,e.e,[{c:pn,f:ue}],void 0):e:ar(e,e.s,e.e);let r=we(e.g),n=Pe(e,r,e.e,void 0);return n.v=pe,n.cp="let "+r+"=+"+e.v()+";",n.vc=[{c:i=>{let o=e.e.format;return o!==void 0&&o==="int32"?pn(r):"!"+Pt(r)},f:ue}],n}function fo(){return Lt(ot,ot,e=>{e.decoder=Mu})}function Du(e){return Pe(e,'""+'+e.i,bn(),void 0)}function ju(e){let t=Y[e.s.type];if(t&1)return B(e,e.e,[{c:tr(Rt),f:ue}],void 0);if(!(t&3132&&$e in e.s))return t&1036?Du(e):t&2?e:ar(e,e.s,e.e);let r=""+e.s.const,n=me(Rt,!1);return n.const=r,Pe(e,'"'+r+'"',n,void 0)}function bn(){return Lt(Rt,Rt,e=>{e.decoder=ju})}function co(e,t){e[Y[t]&768?or:t]=!0}var Uu="JSON";function jt(e){let t=e.e;if(t.noValidation&&!e.u)return _t(e,t,void 0);if($e in e.s)return e.s.const===t.const?e:_t(e,t,void 0);let r=Y[t.type];if(!(Y[e.s.type]&2&&r&3132))return r&2048?B(e,t,[{c:Pt,f:ue}],void 0):B(e,t,[{c:o=>o+"==="+ur(e,t),f:ue}],void 0);let n=me(Rt,!1);n.const=""+t.const;let i=_t(e,n,n);return i.vc=[{c:o=>o+'==="'+n.const+'"',f:ue}],_t(i,t,t)}function jr(){return Lt(Ie,Ie,e=>{e.const=void 0,e.decoder=jt})}function Lu(){return Lt(Mt,Mt,e=>{e.const=null,e.decoder=jt})}function mo(){return Lt(_n,_n,e=>{e.const=NaN,e.decoder=jt})}function Gn(e){if(e===null)return Lu();let t=typeof e;if(t===Ie)return jr();if(t===ot&&Number.isNaN(e))return mo();if(t===ie){let n=me(vn,!0);return n.class=e.constructor,n.const=e,n.decoder=jt,n}let r=me(t,!0);return r.const=e,r.decoder=jt,r}function xe(e){let t=e,r,n=0;for(;!t.io||t.e.to;){let i=r;r=void 0;let o=t;if(n=n+1|0,n>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 l=o.v(),a=We(o),s=xe(a),f=Ne(s,void 0);t=a.i!==s.i||f!==""?Pe(o,l+".then("+l+"=>{"+f+"return "+s.i+"})",s.s,s.e):B(o,s.s,void 0,s.e),t.f=t.f|1,t.io=!0}else if(o.io){let l=o.e.to,s=o.e.parser;t=s!==void 0?s(o):B(t,void 0,void 0,l)}else{let l=o.s.encoder;l&&l!==i&&o.s!==o.e&&o.e.type!==or&&(t=l(o,o.e)),o!==t?r=l:(t=o.e.decoder(o),t.io||(t=er(t,t)))}}return t}function at(e){for(;;){let t=e,r=t.to;if(r===void 0)return t;e=r}}function Je(e){if($t in e)return e[$t];let t,r=e;for(;r;){let i=Dt(r),o=i.to,l=t;l!==void 0?i.to=l:delete i.to;let a=i.parser,s=i.serializer;s!==void 0?i.parser=s:delete i.parser,a!==void 0?i.serializer=a:delete i.serializer;let f=i.refiner,u=i.inputRefiner;u!==void 0?i.refiner=u:delete i.refiner,f!==void 0?i.inputRefiner=f:delete i.inputRefiner;let m=i.fromDefault,c=i.default;c!==void 0?i.fromDefault=c:delete i.fromDefault,m!==void 0?i.default=m:delete i.default;let d=i.items;d!==void 0&&(i.items=d.map(Je));let p=i.properties;if(p!==void 0){let y={},g=Object.keys(p);for(let S=0,T=g.length;S<T;++S){let C=g[S];y[C]=Je(p[C])}i.properties=y}typeof i.additionalItems===ie&&(i.additionalItems=Je(i.additionalItems));let h=i.anyOf;if(h!==void 0){let y={},g=[];for(let S=0,T=h.length;S<T;++S){let C=h[S],N=Je(C);g.push(N),co(y,N.type)}i.has=y,i.anyOf=g}let _=i.$defs;if(_!==void 0){let y={};for(let g=0,S=Object.keys(_).length;g<S;++g){let T=Object.keys(_)[g];y[T]=Je(_[T])}i.$defs=y}t=i,r=o}let n=t;return nt[Gr]=n,ke(e,$t,nt),nt[Gr]=e,ke(n,$t,nt),n}function po(e){try{return xe(e)}catch(t){let r=Dr(t),n=e.p;throw r.path=(n!==void 0?n.path:"")+(e.path+"[]"+r.path),r}}function zu(e,t,r,n){let i=Nu($e in e?ne:e,t,r,n),o=xe(i),l=Ne(o,void 0),a=bu(o.f,1);t.isAsync=a;let s=o.t===!0;if(t.hasTransform=s,l===""&&(o===i||o.i===i.i)&&!(r&1))return ao;let f=o.i;r&1&&!a&&!n&&(f="Promise.resolve("+f+")");let u="i=>{"+l+"return "+f+"}",m=i.g.e,c=new Function("e","s","return "+u)(m,Tn);return c.embedded=i.g.e,c}function Ir(e,t){let r=arguments,n=0,i,o="",l=0,a;for(;i===void 0;){let f=r[n];if(f)if(typeof f===ot){let u=f|Yt.f;i=u,o=o+"-"+u}else{let u=f.seq;u>l&&(l=u,a=f),o=o+u+"-",n=n+1|0}else{let u=Yt.f;i=u,o=o+"-"+u}}let s=a;if(s!==void 0){let f=o;if(f in s)return s[f];let u=r[n-1|0];for(let c=n-2|0;c>=0;--c){let d=u;u=ut(r[c],p=>{p.to=d})}let m=zu(u,u,i,0);return nt[Gr]=m,ke(s,f,nt),m}throw new Error("[Sury] No schema provided for decoder.")}var At="BS_PRIVATE_NESTED_SOME_NONE";function qu(e){let t=B(e,void 0,void 0,Cn());return t.cp=Iu(e,void 0)+";",t}function Cn(){return Lt(yn,yn,e=>{e.decoder=qu})}function Ju(e){let t=e.e.to;return Pe(e,"{"+At+":"+at(e.e).properties[At].const+"}",t,t)}function rr(e,t){return{v:Fr,i:"",s:t.type===yt?{type:yt,decoder:Nn,additionalItems:"strict",items:[]}:{type:ie,decoder:sr,additionalItems:"strict",required:[],properties:{}},e:e.e,prev:e,f:0,d:{},cp:"",hd:"",t:!0,path:e.path,g:e.g}}function Fn(e){return $n(e,jr())}function sr(e){let t=e.u,r=e.e,n=Y[e.s.type],i;if(n&65){let u=n&64,m;if(u)m=e.s;else{let d=me(ie,!1);d.properties=Zi,d.additionalItems=ne,m=d}let c=[];u||(c.push({c:so,f:ue}),r.additionalItems!=="strip"&&c.push({c:d=>"!"+Nr(d),f:ue})),i=c.length!==0?B(e,m,c,void 0):B(e,m,void 0,void 0)}else i=ar(e,e.s,r);let o=r.additionalItems,l;l=o==="strip"||o==="strict"?void 0:o;let a=i.s.additionalItems,s;s=a!=="strip"&&a!=="strict";let f;if(l!==void 0)if(l===ne)f=i;else if(s){let u=i.v(),m=we(i.g),c=io(i,m),d=po(c),p=d.t,h=p?Pe(i,"{}",r,void 0):B(i,r,void 0,void 0),_=uo(d,i,m,p?()=>lo(h,m,d):void 0);if((p||_!=="")&&(h.cp=h.cp+("for(let "+m+" in "+u+"){"+_+"}")),d.f&1){let y=we(h.g),g=we(h.g),S=we(h.g),T=we(h.g),C=h.v();f=oo(h,"new Promise(("+y+","+g+")=>{let "+T+"=Object.keys("+C+").length;for(let "+m+" in "+C+"){"+C+"["+m+"].then("+S+"=>{"+C+"["+m+"]="+S+";if("+T+"--===1){"+y+"("+C+")}},"+g+")}})")}else f=h}else{let u=rr(i,r),m=Object.keys(i.s.properties);for(let c=0,d=m.length;c<d;++c){let p=m[c],h=$r(i,p);h.e=l,h.io=!1,h.u=t,it(u,p,xe(h))}f=nr(u)}else{let u=r.properties,m=Object.keys(u),c=m.length,d=rr(i,r),p=r.additionalItems,h;h=p==="strip"||p==="strict"?p==="strip"?s||Object.keys(i.s.properties).length!==c:!1:!0;let _=i.s.additionalItems,y;y=_==="strip"||_==="strict"?!1:_.name===Uu;for(let S=0;S<c;++S){let T=m[S],C=u[T],N=$r(i,T);N.e=C,N.io=!1,N.u=t,y&&C.type===lt&&C.has[Ie]&&(N.i="("+N.i+"??null)");let H=xe(N);t&&$e in C&&no(i,H,T),it(d,T,H),h||(h=H.t)}let g=!1;if(r.additionalItems==="strict"){let S=i.s.additionalItems,T;T=S!=="strip"&&S!=="strict",g=T}if(g){let S=we(d.g);if(Cr(i,S),d.cp=d.cp+("for("+S+" in "+i.v()+"){if("),m.length!==0)for(let T=0,C=m.length;T<C;++T){let N=m[T];T!==0&&(d.cp=d.cp+"&&"),d.cp=d.cp+(S+"!=="+Tt(i.g,N))}else d.cp=d.cp+"true";d.cp=d.cp+("){"+Qt(i,T=>({code:"unrecognized_keys",path:d.path,reason:'Unrecognized key "'+T+'"',keys:[T]}),S)+"}}")}if(h)f=nr(d);else{let S=B(i,void 0,void 0,void 0);S.cp=d.cp,S.d=d.d,f=S}}return er(f,i)}function Wu(){let e=Gn(0),t={};return t[At]=e,{type:ie,serializer:r=>{let n=r.e.to;return _t(r,n,n)},decoder:sr,additionalItems:"strip",required:[At],properties:t}}function Nn(e){let t=e.u,r=e.e,n=Y[e.s.type],i=r.items,o=i.length,l;if(n&129){let u=n&128,m=u?e.s:In(ne),c=[];u||c.push({c:Nr,f:ue});let d=m.additionalItems,p;if(p=d==="strip"||d==="strict"?m.items.length===o:!1,!p){let h=r.additionalItems;(h==="strip"||h==="strict")&&(h==="strip"?c.push({c:_=>_+".length>="+o,f:ue}):c.push({c:_=>_+".length==="+o,f:ue}))}l=c.length!==0?B(e,m,c,void 0):B(e,m,void 0,void 0)}else l=ar(e,e.s,r);let a=r.additionalItems,s,f=0;if(a==="strip"||a==="strict")f=1;else if(a===ne)s=l;else{let u=l.v(),m=we(l.g),c=io(l,m),d=po(c),p=d.t,h=p?Pe(l,"new Array("+u+".length)",r,void 0):B(l,r,void 0,void 0),_=uo(d,l,m,p?()=>lo(h,m,d):void 0);(p||_!=="")&&(h.cp=h.cp+("for(let "+m+"="+o+";"+m+"<"+u+".length;++"+m+"){"+_+"}")),s=d.f&1?oo(h,"Promise.all("+h.i+")"):h}if(f===1){let u=rr(l,r),m=r.additionalItems,c;if(m==="strip"||m==="strict")if(m==="strip"){let d=l.s.additionalItems;c=d==="strip"||d==="strict"?l.s.items.length!==o:!0}else c=!1;else c=!0;for(let d=0;d<o;++d){let p=i[d],h=d.toString(),_=$r(l,h);_.e=p,_.io=!1,_.u=t;let y=xe(_);t&&$e in p&&no(l,y,h),it(u,h,y),c||(c=y.t)}if(c)s=nr(u);else{let d=B(l,void 0,void 0,void 0);d.cp=u.cp,d.d=u.d,s=d}}return er(s,l)}function Bu(e,t){let r=e.s.anyOf;return t.type===lt&&_o(t)===void 0&&ho(t.anyOf,r)||!Ku(r,t)?e:Hu(e,t)}function Vu(e){let t=e.e,r=t.anyOf,n=Y[e.s.type],i=_o(t);if(e.s===t&&i===void 0&&r.every(Er)||n&256&&ho(r,e.s.anyOf)&&i===void 0||e.io&&e.e===e.s)return e;(n&256||e.s.encoder===void 0&&n&512)&&(e.s=ne);let o="";if(!(n&769)){let E=hn(e.s),v=!1,G=!1,w=r.length,O=0;for(;o===""&&O<w;){let k=r[O];hn(k)===E?o=E:k.type===Mt?v=!0:k.type===Ie&&(G=!0),O=O+1|0}o===""&&(n&16&&v?o=Mt:n&32&&G&&(o=Ie))}let l=o,a=e.i,s=E=>St(e,function(){let v=arguments,G=to(t,ne,e.path,v[0],!0,v.length>1?Array.from(v).slice(1):void 0,void 0);throw new gt(G)})+"("+e.v()+E+")",f=B(e,void 0,void 0,void 0),u=[],m={contents:""},c=(E,v)=>{let G=E[0],w=E[1],O="",k="",R=!1,Q={contents:""},oe="",ge={},fe=2,M=E.length-1|0;for(;fe<=M;){let ee=We(w);ee.u=!0,ee.t=w.t,ee.io=!1,ee.e=E[fe];let te=fe===M,he=fe===2,dt=he&&te,wt=!dt,be=!1,Me="",He={contents:""};try{let z=xe(ee);if(u.push(z.s),Me=Ne(z,He),z.t){f.t=!0,z.f&1&&(f.f=f.f|1);let Ge=G.v();z.i!==Ge&&(Me=Me+(Ge+"="+z.i))}}catch(z){let Ge=St(ee,Dr(z));oe=oe+","+Ge,v&&dt?(m.contents=Ge,be=!0):te?(wt=!1,Me=v?"throw "+Ge:s(oe)):be=!0}let Ke=He.contents,ft=Me;if(!be&&Ke)if(ft){let z=ge[Ke];z!==void 0?typeof z=="string"?ge[Ke]=[z,ft]:z.push(ft):ge[Ke]=ft}else Q.contents=Q.contents?Q.contents+"||"+Ke:Ke;if(!be&&(!Ke||te)){let z=Object.keys(ge);for(let Ge=0,kl=z.length;Ge<kl;++Ge){let Zn=z[Ge];O=O+(R?"else if":"if")+("("+Zn+"){");let Wt=ge[Zn];if(typeof Wt=="string")O=O+Wt+"}";else{let Vr="";for(let mr=0,bl=Wt.length;mr<bl;++mr){let Gl=Wt[mr],Yn="e"+mr;O=O+("try{"+Gl+"}catch("+Yn+"){"),Vr=Vr+","+Yn}O=O+s(Vr)+"}".repeat(Wt.length)+"}"}R=!0}ge={}}if(!be&&!Ke)if(ft)if(Q.contents&&(O=O+(R?"else if":"if")+("(!("+Q.contents+")){"),k="}"+k,Q.contents="",R=!1),te&&(v||!wt||he))O=O+((R?"else{":"")+ft),k=(R?"}":"")+k;else{let z="e"+(fe-2|0);O=O+((R?"else{":"")+"try{"+ft+"}catch("+z+"){"),k=(R?"}":"")+"}"+k,oe=oe+","+z,R=!1}else Q.contents="",fe=M,wt=!1;if(te){if(Q.contents)O||oe?O=O+(R?"else if":"if")+("(!("+Q.contents+")){"+s(oe)+"}"):kn(w,{c:z=>"("+Q.contents+")",f:ue});else if(wt){let z=s(oe);O=O+(R?"else{"+z+"}":z)}}fe=fe+1}return O+k},d="",p="",h="",_=!1,y=r.length-1|0,g={},S=[],T=t.refiner,C=t.inputRefiner,N={contents:void 0},H={contents:void 0},K=(E,v,G)=>{if(v===void 0)return E;let w=O=>{let k=G.contents;if(k!==void 0)return k;let R=v(O);return G.contents=R,R};return E!==void 0?O=>{let k=E(O),R=w(O);for(let Q=0,oe=R.length;Q<oe;++Q)k.push(R[Q]);return k}:w},x=E=>{let v=K(E.refiner,T,N);v!==void 0&&(E.refiner=v);let G=K(E.inputRefiner,C,H);if(G!==void 0){E.inputRefiner=G;return}},b;if($e in e.s){let E=[],v=[];for(let G=0;G<=y;++G){let w=r[G];$e in w&&w.const===e.s.const?E.push(w):v.push(w)}b=E.concat(v)}else b=r;for(let E=0;E<=y;++E){let v=i!==void 0?ut(b[E],k=>{x(k),k.to=i}):b[E],G=v.type,w=Y[G],O=hn(v);if((l===""||l===O)&&!(w&16&&"fromDefault"in t)){let k=g[O];if(k!==void 0)w&64&&At in v.properties?k.splice(k.length-1|0,0,v):w&2096||k.push(v);else{let R=We(e),Q;if(w&37633)Q=ne;else{let M=me(v.type,!1);M.encoder=v.encoder,w&8192?M.class=v.class:w&64?(M.properties=Zi,M.additionalItems=ne):w&128?(M.additionalItems=ne,M.items=Mr):w&2096&&(M.const=v.const),M.decoder=ee=>Y[ee.s.type]&1?B(ee,ee.e,[{c:te=>{let he=Y[v.type];if(he&64)return so(te)+"&&!"+Nr(te);if(he&128)return Nr(te);if(he&8192)return Ru(ee,v.class)(te);if(!(he&4))return he&2048?Pt(te):he&48?te+"==="+ur(ee,v):he&17418?tr(v.type)(te):"";let dt=tr(ot)(te);return ee.g.o&2?dt:dt+"&&!"+Pt(te)},f:ue}],void 0):v.decoder(ee),Q=M}R.e=Q;let oe;try{oe=xe(R)}catch{R.vc=void 0,oe=R}Hi(w,g)?S.unshift(O):S.push(O),g[O]=[R,oe,v];let ge=!0,fe=oe;for(;fe!==void 0&≥){let M=fe;fe=M.prev,ge=!(M.vc&&ro(M))}if(ge){for(let M=0,ee=S.length;M<ee;++M){let te=S[M];if(!_){let he=g[te],dt=he[1],wt=c(he,!0),be=Ne(dt,void 0)+wt,Me=m.contents;if(Me)if(m.contents="",be){let He="e"+(E+M|0);d=d+("try{"+be+"throw "+Me+"}catch("+He+"){"),p="}"+p,h=h+","+He}else h=h+","+Me;else if(be){let He="e"+(E+M|0);d=d+("try{"+be+"}catch("+He+"){"),p="}"+p,h=h+","+He}else _=!0}}g={},S=[]}}}}let F=g,J=S;if(!_){let E=!1,v="";for(let O=0,k=J.length;O<k;++O){let R=F[J[O]],Q=R[1],oe=R[2],ge=c(R,!1),fe={contents:""},M=Ne(Q,fe)+ge,ee=fe.contents;M||Hi(Y[oe.type],F)?(d=d+(E?"else if":"if")+("("+ee+"){"+M+"}"),E=!0):v=v?v+"||"+ee:ee}let G=s(h),w;v?w=(E?"else if":"if")+("(!("+v+")){"+G+"}"):w=E?"else{"+G+"}":p===""?G+";":G,d=d+w}f.cp=f.cp+d+p,e.i!==f.i&&(f.i=e.i);let L=f.f&1?(f.i="Promise.resolve("+f.i+")",f.v=Fr,f):f.v===pe&&e.cp===""&&f.cp===""&&a==="i"?(e.hd="",e.v=Fr,e.i=a,e):f;return L.s=u.length?ir(u):Cn(),L.e=i!==void 0?(L.io=!0,at(i)):t,L}function ho(e,t){return t.every((r,n)=>{let i=e[n];return i!==void 0&&!(Y[r.type]&9152)&&r.type===i.type&&r.const===i.const?r.to===void 0:!1})}function Hu(e,t){return B(e,ne,void 0,ut(e.s,r=>{r.to=t}))}function Ku(e,t){return!(Y[at(t).type]&512)&&!(t.type===lt&&t.anyOf.some(r=>Y[r.type]&512))?!e.some(r=>r.to!==void 0||r.parser!==void 0?!0:Y[r.type]&512):!1}function _o(e){if(e.parser!==void 0)return;let r=e.to;if(r!==void 0)return r}function $r(e,t){let r=e.d,n;if(r!==void 0)n=r;else{let u={};e.d=u,n=u}let i=n[t];if(i!==void 0)return We(i);let o=e.s.type===ie?e.s.properties[t]:e.s.items[t],l;if(o!==void 0)l=o;else{let u=e.s.additionalItems;l=u==="strip"||u==="strict"?ar(e,e.s,e.e):e.s.type===ie&&u.type!==or&&!(Y[u.type]&512)&&!ku(u)?Fn(u):u}let s="["+Tt(e.g,t)+"]",f={p:e,v:gn,i:$e in l?ur(e,l):e.v()+s,s:l,e:l,f:0,cp:"",hd:"",path:e.path+s,g:e.g};return n[t]=f,f}function nr(e){let t=e.s.type===yt,r="",n="",i,o=Object.keys(e.d);for(let f=0,u=o.length;f<u;++f){let m=o[f],c=e.d[m];if(c.f&1&&(n=n+c.i+","),c.o){let d=i;i=p=>(d!==void 0?d(p):"")+("if("+c.v()+"!==void 0){"+p+"["+Tt(e.g,m)+"]="+c.i+"}")}else r=r+(t?c.i:Tt(e.g,m)+":"+c.i)+","}if(e.i=t?"["+r+"]":"{"+r+"}",n){let f=We(e);f.io=!0;let u=xe(f),m=Ne(u,void 0);return m===""&&n===u.i+","?e.i=u.i:e.i="Promise.all(["+n+"]).then((["+n+"])=>{"+m+"return "+u.i+"})",e.f=e.f|1,e.s=u.s,e.e=u.e,e.io=!0,e}let l=i;if(l===void 0)return e;let a=l(e.v()),s=B(e,void 0,void 0,void 0);return s.cp=s.cp+a,s}function ir(e){let t=e.length;if(t===1)return e[0];if(t!==0){let r={},n=new Set;for(let o=0,l=e.length;o<l;++o){let a=e[o];a.type===lt&&a.to===void 0?(a.anyOf.forEach(s=>{n.add(s)}),Object.assign(r,a.has)):(n.add(a),co(r,a.type))}let i=me(lt,!1);return i.anyOf=Array.from(n),i.decoder=Vu,i.encoder=Bu,i.has=r,i}throw new Error("[Sury] S.union requires at least one item")}function Hi(e,t){return e&8320&&ie in t?!0:e&2048?ot in t:!1}function hn(e){return Y[e.type]&8192?e.class.name:e.type}function Er(e){for(;;){let t=e,r=!1,n=!1,i=!1;if(t.to===void 0&&t.parser===void 0&&!(Y[t.type]&512)){let l=t.anyOf;i=l!==void 0?l.every(Er):!0}if(i){let l=t.items;n=l!==void 0?l.every(Er):!0}if(n){let l=t.properties;r=l!==void 0?Object.values(l).every(Er):!0}if(!r)return!1;let o=t.additionalItems;if(o===void 0||o==="strip"||o==="strict")return!0;e=o}}function In(e){let t=me(yt,e[$t]===e);return t.additionalItems=e,t.items=Mr,t.decoder=Nn,t}function $n(e,t){let r=t!==void 0?t:jr(),n=at(e);switch(n.type){case"undefined":return ir([r,Ki(e)]);case"union":let o=n.has,l=n.anyOf;return ut(e,a=>{let s=Su(o),f=[];for(let u=0,m=l.length;u<m;++u){let c=l[u],d=at(c),p=d.type,h;if(p==="undefined")s[r.type]=!0,f.push(r),h=Ki(c);else{let _=d.properties;if(_!==void 0){let y=_[At];h=y!==void 0?ut(c,g=>{let S={},T={...y};T.const=y.const+1,S[At]=T,g.properties=S}):c}else h=c}f.push(h)}f.length===l.length&&(s[r.type]=!0,f.push(r)),a.anyOf=f,a.has=s});default:return ir([e,r])}}function Ki(e){return ut(e,t=>{t.to=Wu(),t.parser=Ju})}ke(xn,"~standard",{get:function(){let e=this;return{version:1,vendor:Sn,validate:t=>{try{return{value:Ir(ne,e)(t)}}catch(r){let n=Dr(r);return{issues:[{message:n.reason,path:n.path===""?void 0:Tu(n.path)}]}}}}}});function yo(e,t){return Ir(ne,t)(e)}function Xu(e,t){return ut(e,r=>{let n=t(r),i=r.refiner;i!==void 0?r.refiner=o=>{let l=i(o),a=n(o);for(let s=0,f=a.length;s<f;++s)l.push(a[s]);return l}:r.refiner=n})}function go(e,t,r,n){let i=r!==void 0?r:"Refinement failed",o=n!==void 0?vu(n):"";return Xu(e,l=>(a=>{let s=St(a,t);return[{c:f=>s+"("+f+")",f:En(void 0,o,i,void 0)}]}))}function So(e,t){return ut(e,r=>{let n=r.anyOf;if(n!==void 0){let o=[],l=[];for(let c=0,d=n.length;c<d;++c){let p=n[c],h=at(p);h.type!=="undefined"&&(o.push(h),l.push(p))}let a=o.length,s;if(a!==1)if(a!==0)s=ir(o);else{let c="Can't set default for "+Z(r);throw new Error("[Sury] "+c)}else s=o[0];let f=l.length!==1?ir(l):l[0];if(t.TAG==="Value"){let c=t._0;try{Ir(ne,s)(c)}catch(d){let p=Dr(d),h="Invalid default for "+Z(r)+": "+p.message;throw new Error("[Sury] "+h)}try{r.default=Ir(Je(f),void 0)(c)}catch{}}r.parser=c=>{let d=c.e.to,p=c.v(),h;return h=t.TAG==="Value"?ur(c,Gn(t._0)):St(c,t._0)+"()",Pe(c,p+"===void 0?"+h+":"+p,d,d)};let u=Dt(s),m=u.decoder;u.serializer=c=>{let d=Je(f);return B(m(c),d,void 0,d)},u.decoder=eo,r.to=u;return}let i="Can't set default for "+Z(r);throw new Error("[Sury] "+i)})}function Zu(e){return e[An]}function Pr(e,t,r){let n=Dt(at(e));return n.from=t,r!==void 0&&(n.fromFlattened=r),new Proxy(n,{get:(i,o)=>{if(o===An)return i;let l=i.items,a=i.properties,s=a!==void 0?a[o]:l!==void 0?l[o]:void 0;if(s===void 0){let f='Cannot read property "'+o+'" of '+Z(i);throw new Error("[Sury] "+f)}return Pr(s,i.from.concat(o),i.fromFlattened)}})}function To(e,t,r){let n=rr(e,t);n.io=!0;let i=t.items;if(i!==void 0)for(let o=0,l=i.length;o<l;++o){let a=o.toString();it(n,a,r(a,i[o]))}else{let o=t.properties;if(o!==void 0){let l=Object.keys(o);for(let a=0,s=l.length;a<s;++a){let f=l[a];it(n,f,r(f,o[f]))}}else{let l="Don't know where the value is coming from: "+Z(t);throw new Error("[Sury] "+l)}}return nr(n)}function Ao(e,t){let r=t.from,n=t.fromFlattened,i=n!==void 0?We(Xi(e.fv[n],t.from,0)):r!==void 0?We(Xi(e,r,0)):$e in t?_t(e,t,void 0):To(e,t,(o,l)=>Ao(e,l));return i.prev=void 0,i.e=t,i}function vo(e,t){let r=t.e,n=r.from;if(n!==void 0){let l=r.fromFlattened,a;if(l!==void 0){e.flattened===void 0&&(e.flattened=[]);let s=e.flattened[l];if(s!==void 0)a=s;else{let f={};e.flattened[l]=f,a=f}}else a=e;for(let s=0,f=n.length;s<f;++s){let u=n[s],m=a.properties,c;if(m!==void 0)c=m;else{let h={};a.properties=h,c=h}let d=c[u],p;if(d!==void 0)p=d;else{let h={};c[u]=h,p=h}a=p}a.val=t;return}let i=t.d;if(i===void 0)return;let o=Object.keys(i);for(let l=0,a=o.length;l<a;++l)vo(e,i[o[l]])}function kr(e,t,r,n){let i=0;if(t!==void 0){let o=t.val;if(o!==void 0){let l=We(o);return l.t=!0,l.s=r,l.e=r,xe(l)}i=1}else i=1;if(i===1){if($e in r){let m=_t(e,r,r);return m.prev=void 0,m.p=e,m.v=gn,m.io=!0,xe(m)}let o=t===void 0?at(r):r,l=rr(e,o);l.e=o,l.io=!0,l.prev=void 0,l.p=e,l.v=gn;let a=o.flattened,s=o.items,f=0,u=0;if(s!==void 0&&(t!==void 0||typeof o.additionalItems!==ie))for(let m=0,c=s.length;m<c;++m){let d=m.toString(),p;if(t!==void 0){let _=t.properties;p=_!==void 0?_[d]:void 0}else p=void 0;let h=Tt(e.g,d);it(l,d,kr(e,p,s[m],n+("["+h+"]")))}else u=3;if(u===3){let m=o.properties;if(m!==void 0&&(t!==void 0||typeof o.additionalItems!==ie)){if(a!==void 0&&t!==void 0){let d=t.flattened;d!==void 0&&d.forEach((p,h)=>{let y=kr(e,p,Je(a[h]),n).d,g=Object.keys(y);for(let S=0,T=g.length;S<T;++S){let C=g[S];it(l,C,y[C])}})}let c=Object.keys(m);for(let d=0,p=c.length;d<p;++d){let h=c[d];if(!(h in l.d)){let _;if(t!==void 0){let g=t.properties;_=g!==void 0?g[h]:void 0}else _=void 0;let y=Tt(e.g,h);it(l,h,kr(e,_,m[h],n+("["+y+"]")))}}}else f=2}if(f===2){let m=r.from,c=m!==void 0?n+m.map(p=>'["'+p+'"]').join(""):n,d=c===""?"":" at "+c;Pu(e,"Missing input for "+Z(r)+d)}return nr(l)}}function Xi(e,t,r){for(;;){let n=r,i=e,o=t[n];if(o===void 0)return i;r=n+1|0,e=i.d[o]}}function Rr(e,t){if(typeof e!==ie||e===null)return Gn(e);let r=t(e);if(r!==void 0)return r;if(Array.isArray(e)){for(let s=0,f=e.length;s<f;++s){let u=Rr(e[s],t);e[s]=u}let a=me(yt,!1);return a.items=e,a.additionalItems="strict",a.decoder=Nn,a}let n=e.constructor;if(n&&n!==Object){let a=me(vn,!0);return a.class=n,a.const=e,a.decoder=jt,a}let i=Object.keys(e),o=i.length;for(let a=0;a<o;++a){let s=i[a],f=Rr(e[s],t);e[s]=f}let l=me(ie,!1);return l.required=i,l.properties=e,l.additionalItems=Yt.a,l.decoder=sr,l}function Yu(e){let t={};vo(t,e);let r=e.e.to,n=kr(e,t,r,"");return n.t=!0,n.prev=e,n}function Oo(e){return Rr(e,t=>{if(t["~standard"])return t})}function wo(e){let t=this,r="~"+e,n=t[r];if(n!==void 0)return D(n);let i={},o=[],l=me(ie,!1);l.required=o,l.properties=i,l.additionalItems=Yt.a,l.decoder=sr;let a=t.f(e,l)[An],s=(d,p)=>{let h=Ut(d);if(d in i)throw new Error("[Sury] "+("The field "+h+" defined twice"));return o.push(d),i[d]=p,Pr(p,a.from.concat(d),a.fromFlattened)},c={field:s,f:s,fieldOr:(d,p,h)=>{let _=$n(p,void 0);return s(d,So(_,{TAG:"Value",_0:h}))},tag:(d,p)=>{s(d,Oo(p))},nested:wo,flatten:d=>{if(d.type==="object"){let _=d.to,y=d.properties;if(_){let T="Unsupported nested flatten for transformed object schema "+Z(d);throw new Error("[Sury] "+T)}let g=Object.keys(y),S={};for(let T=0,C=g.length;T<C;++T){let N=g[T];S[N]=s(N,y[N])}return S}let h="Can't flatten "+Z(d)+" schema";throw new Error("[Sury] "+h)}};return t[r]=c,c}function Qu(e){let t=Dt(Rr(e,Zu));return t.serializer=Yu,t}function ea(e){let t=e.e.flattened;if(t!==void 0){let i=[];for(let o=0,l=t.length;o<l;++o){let a=t[o],s=a.to,f;if(s!==void 0){let u=We(e);u.e=a,u.io=!0,f=xe(u)}else{let u=To(e,a,(m,c)=>$r(e,m));u.e=a,u.prev=void 0,f=er(u,u)}i.push(f),e.cp=e.cp+Ne(f,void 0)}e.fv=i}let r=e.e.to,n=Ao(e,r);return n.t=!0,n.prev=e,er(n,e)}function xo(e){let t,r={},n=u=>{if(u.type==="object"){let d=u.properties,p=Object.keys(d);for(let _=0,y=p.length;_<y;++_){let g=p[_],S=d[g],T=r[g];if(T!==void 0){if(T!==S)throw new Error("[Sury] "+('The field "'+g+'" defined twice with incompatible schemas'))}else r[g]=S}let h=t||(t=[]);return Pr(u,Mr,h.push(u)-1|0)}let c="The '"+Z(u)+"' schema can't be flattened";throw new Error("[Sury] "+c)},i=(u,m)=>{if(u in r)throw new Error("[Sury] "+('The field "'+u+'" defined twice with incompatible schemas'));return r[u]=m,Pr(m,[u],void 0)},s=e({field:i,f:i,fieldOr:(u,m,c)=>{let d=$n(m,void 0);return i(u,So(d,{TAG:"Value",_0:c}))},tag:(u,m)=>{i(u,Oo(m))},nested:wo,flatten:n}),f=me(ie,!1);return f.required=Object.keys(r),f.properties=r,f.additionalItems=Yt.a,f.decoder=sr,f.parser=ea,f.to=Qu(s),t!==void 0&&(f.flattened=t),f}var st=bn();var Eo=fo();var ko=On;var bo=In;var dr=Fn;var Be=go;var Go=yo;var Ur=xo;function ra(e){return{path:e.path,summary:e.message}}function A(e){return{path:"",summary:e}}function Pn(e,t){try{return{TAG:"Ok",_0:Go(e,t)}}catch(r){let n=j(r);if(n.RE_EXN_ID===ko)return{TAG:"Error",_0:ra(n._1)};throw n}}import*as Lr from"node:fs";import*as $o from"node:os";import*as zr from"node:path";function Po(){return zr.join($o.homedir(),".linzumi","auth.json")}var Fo="Kandan auth cache must contain a JSON object",na="Kandan auth cache local_codex_runner must be an object",ia="Kandan auth cache personal_agent_delegation must be an object";function No(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e.access_token,r=e.issued_at;if(t===void 0||typeof t!="string"||r===void 0||typeof r!="string")return;let n=e.expires_at,i;return i=typeof n=="string"?n:void 0,{accessToken:t,issuedAt:r,expiresAt:i}}function Ro(e){let t;try{t=JSON.parse(e)}catch{t=void 0}if(t===void 0)return{TAG:"Error",_0:A(Fo)};if(typeof t!="object"||t===null||Array.isArray(t))return{TAG:"Error",_0:A(Fo)};let r=t.local_codex_runner,n=t.personal_agent_delegation,i=r!==void 0?typeof r=="object"&&r!==null&&!Array.isArray(r):!0,o=n!==void 0?typeof n=="object"&&n!==null&&!Array.isArray(n):!0;if(!i)return{TAG:"Error",_0:A(na)};if(!o)return{TAG:"Error",_0:A(ia)};let l;return l=typeof r=="object"&&r!==null&&!Array.isArray(r)?Object.fromEntries(De(Object.entries(r),a=>{let s=a[0];return ve(No(a[1]),f=>[s,f])})):void 0,{TAG:"Ok",_0:{serverTokens:l,personalAgentDelegation:q(n,No)}}}function oa(e){return Lr.existsSync(e)?P(U(et(e),t=>A(t.message)),t=>X(Ro(t),r=>r)):{TAG:"Ok",_0:void 0}}function la(e,t){return e!==void 0?new Date(e).getTime()<=t:!1}function Mo(e,t,r){return Lr.existsSync(t)?P(oa(t),n=>X(U(ce(e),A),i=>q(q(q(n,o=>o.serverTokens),o=>o[i]),o=>{if(!(o.accessToken.trim()===""||la(o.expiresAt,r)))return{accessToken:o.accessToken,expiresAt:o.expiresAt}}))):{TAG:"Ok",_0:void 0}}function Io(e){let t={};t.access_token=e.accessToken,t.issued_at=e.issuedAt;let r=e.expiresAt;return r!==void 0&&(t.expires_at=r),t}function ua(e){let t={};t.version=1;let r=e.serverTokens;r!==void 0&&(t.local_codex_runner=Object.fromEntries(Object.entries(r).map(i=>[i[0],Io(i[1])])));let n=e.personalAgentDelegation;return n!==void 0&&(t.personal_agent_delegation=Io(n)),t}function Do(e,t,r,n,i){return P(U(ce(e),A),o=>{let l=Lr.existsSync(n)?P(U(et(n),a=>A(a.message)),Ro):{TAG:"Ok",_0:{serverTokens:void 0,personalAgentDelegation:void 0}};return P(l,a=>{let s=i.toISOString(),f=ve(r,y=>new Date(i.getTime()+y*1e3).toISOString()),u={accessToken:t,issuedAt:s,expiresAt:f},m=a.serverTokens,c=m!==void 0?Object.fromEntries(Object.entries(m)):{};c[o]=u;let d=ua({serverTokens:c,personalAgentDelegation:a.personalAgentDelegation}),p=JSON.stringify(d,void 0,2)+`
|
|
9
|
+
`,h=n+".tmp."+process.pid.toString()+"."+Wi(6),_=y=>A(y.message);return P(U(Kt(zr.dirname(n)),_),()=>{let y=P(Ht(h,p,{encoding:"utf8",mode:384}),()=>zi(h,n));return y.TAG==="Ok"?{TAG:"Ok",_0:{accessToken:t,expiresAt:f}}:(qi(h),{TAG:"Error",_0:A(y._0.message)})})})})}function Uo(e){return e._0}var Of=new RegExp("^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$"),wf=new RegExp("^[0-9.]+$");function Rn(e){if(typeof e!="string")return;let t=e.trim();if(t!=="")return t}function Mn(e){return isFinite(e)?Math.trunc(e)===e:!1}function fa(e){if(typeof e=="number"&&e%1===0)return e}function ca(e){let t=e.replaceAll("-","+").replaceAll("_","/");switch(t.length&3){case 2:return t+"==";case 3:return t+"=";default:return t}}function ma(e){let t=e.split(".")[1];if(t===void 0)return;let r=Buffer.from(ca(t),"base64").toString("utf8"),n;try{n=JSON.parse(r)}catch{n=void 0}if(typeof n=="object"&&n!==null&&!Array.isArray(n))return n}function jn(e){let t=q(ma(e),r=>fa(r.exp));if(t===void 0)return{TAG:"Ok",_0:void 0};if(t<=0)return{TAG:"Ok",_0:void 0};try{return{TAG:"Ok",_0:new Date(t*1e3).toISOString()}}catch(r){let n=j(r),i=Ce(n);return{TAG:"Error",_0:A(i!==void 0?$(Ae(D(i)),"unknown error"):"unknown error")}}}import*as Wo from"node:http";import*as Bo from"node:crypto";function zt(e){let t=Ce(e);return t!==void 0?$(Ae(D(t)),"unknown error"):"unknown error"}async function vt(e,t){try{return{TAG:"Ok",_0:await fetch(e,t)}}catch(r){let n=j(r);return{TAG:"Error",_0:{message:zt(n)}}}}async function ha(e){try{return{TAG:"Ok",_0:await e.text()}}catch(t){let r=j(t);return{TAG:"Error",_0:{message:zt(r)}}}}async function Ot(e){let t=await ha(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};try{return{TAG:"Ok",_0:JSON.parse(t._0)}}catch(r){let n=j(r);return{TAG:"Error",_0:{message:zt(n)}}}}import*as Vo from"node:child_process";function qr(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e.error;if(typeof t=="string")return t}function Lo(e,t){if(e===void 0)return t!==void 0?"local runner device authorization failed (HTTP "+t.toString()+", no reason returned by the server)":"local runner device authorization failed (no reason returned by the server)";switch(e){case"access_denied":return"local runner device authorization was denied";case"approving_user_not_found":return"local runner device authorization failed: the approving Linzumi account could not be found";case"device_session_consumed":return"local runner device authorization was already used";case"device_session_expired":return"local runner device authorization expired";case"device_session_not_pending":return"local runner device authorization was already decided (approved or denied) on the server";case"invalid_device_code":return"local runner device authorization code was rejected";case"invalid_user_code":return"local runner device authorization code was not recognized by the server";case"rate_limited":return"local runner device authorization was rate limited by the server; wait a minute and retry";default:return"local runner device authorization failed (server said: "+e+")"}}function qt(e,t){let r=e[t];if(r!==void 0&&typeof r=="string"&&r.trim()!=="")return r}async function zo(e,t,r,n,i){let o=qe("/api/v2/local-codex-runner/device/start",e);if(o.TAG!=="Ok")return{TAG:"Error",_0:A(o._0)};let l={},a=(_,y)=>{if(y!==void 0){l[_]=y;return}};a("workspace",t),a("channel",r),a("onboarding",n),i!==void 0&&(a("runner_id",i.commanderId),a("machine_fingerprint",i.machineFingerprint),a("hostname",i.hostname));let s={};s["content-type"]="application/json";let f=await vt(o._0.toString(),{method:"POST",headers:s,body:JSON.stringify(l)});if(f.TAG!=="Ok")return{TAG:"Error",_0:A(f._0.message)};let u=f._0,m=u.status,c=await Ot(u);if(c.TAG!=="Ok")return{TAG:"Error",_0:A(c._0.message)};let d=c._0;if(m>=200&&m<300){if(Array.isArray(d))return{TAG:"Error",_0:A("local runner device authorization response was incomplete")};if(d!==null)switch(typeof d){case"object":let _=qt(d,"device_code"),y=qt(d,"user_code"),g=qt(d,"verification_uri");if(_===void 0)return{TAG:"Error",_0:A("local runner device authorization response was incomplete")};if(y===void 0)return{TAG:"Error",_0:A("local runner device authorization response was incomplete")};if(g===void 0)return{TAG:"Error",_0:A("local runner device authorization response was incomplete")};let S=d.expires_in,T;return T=typeof S=="number"?S:void 0,{TAG:"Ok",_0:{deviceCode:_,userCode:y,verificationUri:g,expiresInSeconds:T}}}}let h=qr(d);return{TAG:"Error",_0:A(h!==void 0?"local runner device authorization failed to start (server said: "+h+")":"local runner device authorization failed to start (HTTP "+m.toString()+")")}}async function _a(e,t,r){let n=new AbortController,i=setTimeout(()=>{n.abort()},r+1e4|0),o={};o.device_code=t,o.wait_ms=r;let l={};l["content-type"]="application/json";let a=qe("/api/v2/local-codex-runner/device/token",e),s;if(s=a.TAG==="Ok"?await vt(a._0.toString(),{method:"POST",headers:l,body:JSON.stringify(o),signal:Te(n.signal)}):{TAG:"Error",_0:{message:a._0}},s.TAG==="Ok"){let f=s._0,u=f.status,m=await Ot(f);if(clearTimeout(i),m.TAG!=="Ok")return n.signal.aborted?"Continue":{TAG:"Done",_0:{TAG:"Transient",reason:"non-JSON device/token response ("+m._0.message+")",httpStatus:u}};let c=m._0,d=u>=200&&u<300,p=qr(c),h=0;if(u!==202||p===void 0)h=1;else{if(p==="authorization_pending")return"Continue";h=1}if(h===1){let _=0;if(d){if(Array.isArray(c))return{TAG:"Done",_0:{TAG:"Rejected",reason:"device token response did not include access_token",httpStatus:u}};if(c===null)_=2;else switch(typeof c){case"object":let y=qt(c,"access_token");if(y===void 0)return{TAG:"Done",_0:{TAG:"Rejected",reason:"device token response did not include access_token",httpStatus:u}};let g=c.expires_in,S;return S=typeof g=="number"?g:void 0,{TAG:"Done",_0:{TAG:"Token",_0:{accessToken:y,expiresInSeconds:S}}};default:_=2}}else _=2;if(_===2){let y=0;if(p!==void 0)switch(p){case"access_denied":return{TAG:"Done",_0:"Denied"};case"device_session_consumed":return{TAG:"Done",_0:"Consumed"};case"device_session_expired":return{TAG:"Done",_0:"CodeExpired"};default:y=3}else y=3;if(y===3)return u>=500||u===429?{TAG:"Done",_0:{TAG:"Transient",reason:p!==void 0?p:"HTTP "+u.toString(),httpStatus:u}}:{TAG:"Done",_0:{TAG:"Rejected",reason:p,httpStatus:u}}}}}else return clearTimeout(i),n.signal.aborted?"Continue":{TAG:"Done",_0:{TAG:"Transient",reason:s._0.message,httpStatus:void 0}}}async function qo(e,t,r){let n=r!==void 0&&r>=0?r:600,i=Date.now()+n*1e3,o=async()=>{if(Date.now()>=i)return"CodeExpired";let l=Math.max(0,Math.min(3e4,i-Date.now())),a=await _a(e,t,l);return typeof a!="object"?await o():a._0};return await o()}function Ho(e,t){if(e!==void 0&&isFinite(e)&&e>0)return e;let r=ve(Xt(t,"LINZUMI_OAUTH_CALLBACK_TIMEOUT_MS"),i=>i.trim());if(r===void 0||r==="")return 3e5;let n=Number.parseInt(r,10);return isFinite(n)&&n>0?n:3e5}function ya(e){let t=e.split(".").map(o=>Number.parseInt(o,10));if(t.length!==4||t.some(o=>!Number.isInteger(o)||o<0?!0:o>255))return e==="localhost";let n=t[0],i=t[1];return n!==void 0&&i!==void 0?n===10||n===127||n===172&&i>=16&&i<=31||n===192&&i===168||n===169&&i===254?!0:n===100&&i>=64?i<=127:!1:!1}function ga(e){try{return{TAG:"Ok",_0:new URL(e)}}catch(t){let r=j(t);return{TAG:"Error",_0:zt(r)}}}function Sa(e,t){let r=ve(t,o=>o.trim());if(r!==void 0&&r!=="")return{TAG:"Ok",_0:r};let n=ga(e);if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0.hostname.trim();return ya(i)&&i!=="localhost"?{TAG:"Ok",_0:i}:{TAG:"Ok",_0:"127.0.0.1"}}function Ta(e,t,r,n,i,o,l){return X(qe("/api/v2/local-codex-runner/oauth/authorize",e),a=>{let s=a.searchParams;return s.set("redirect_uri",t),s.set("state",r),n!==void 0&&s.set("workspace",n),i!==void 0&&s.set("channel",i),o!==void 0&&s.set("onboarding",o),l!==void 0&&s.set("purpose","persisted_documents_publish"),a.toString()})}async function Aa(e,t,r){let n=qe("/api/v2/local-codex-runner/oauth/token",e);if(n.TAG!=="Ok")return{TAG:"Error",_0:A(n._0)};let i={};i.code=t,i.redirect_uri=r;let o={};o["content-type"]="application/json";let l=await vt(n._0.toString(),{method:"POST",headers:o,body:JSON.stringify(i)});if(l.TAG!=="Ok")return{TAG:"Error",_0:A(l._0.message)};let a=l._0,s=a.status,f=await Ot(a);if(f.TAG!=="Ok")return{TAG:"Error",_0:A(f._0.message)};let u=f._0;if(s>=200&&s<300){if(Array.isArray(u))return{TAG:"Error",_0:A("local runner OAuth token response did not include access_token")};if(u!==null)switch(typeof u){case"object":let d=qt(u,"access_token");if(d===void 0)return{TAG:"Error",_0:A("local runner OAuth token response did not include access_token")};let p=u.expires_in,h;return h=typeof p=="number"?p:void 0,{TAG:"Ok",_0:{accessToken:d,expiresInSeconds:h}}}}let c=qr(u);return c!==void 0?c==="admin_role_required"?{TAG:"Error",_0:A("This token requires a Linzumi admin account. Approve the request while signed in as an admin.")}:{TAG:"Error",_0:A("local runner OAuth token exchange failed: "+c)}:{TAG:"Error",_0:A("local runner OAuth token exchange failed")}}function Ln(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")}var va='<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path fill="currentColor" d="M206.7,82.37l2.55-6.45,2.01-3.63c.67-1.21,1.07-1.88,2.55-3.63,1.34-1.61,3.36-4.43,5.64-6.58,2.42-2.24,5.06-4.3,7.93-6.18,3.92-2.53,8.17-4.52,12.63-5.91,1.79-.63,4.03-1.16,6.72-1.61,6.1-.88,12.29-.92,18.4-.13,2.69.45,5.06,1.03,7.12,1.75,2.15.67,3.49,1.07,5.64,2.15,4.55,2.16,8.87,4.77,12.9,7.79,1.61,1.34,2.42,2.15,4.16,4.16l5.91,7.66c1.34,2.01,1.34,2.28,2.15,4.03l2.55,6.58c.67,1.34-.13,1.34,1.07.94,1.21-.27,4.3-2.01,6.45-2.82,4.7-1.83,9.62-3,14.64-3.49,2.42-.27,3.76-.54,7.12-.27s9.27,1.21,12.76,2.15c3.63.94,6.58,2.55,8.73,3.49,2.15,1.07,2.55,1.48,4.16,2.55,3.49,2.51,6.77,5.29,9.81,8.33,1.52,1.7,3.04,3.58,4.57,5.64,2.74,4.49,4.86,9.32,6.31,14.37.67,2.28,1.07,3.49,1.34,6.72.27,3.22,0,10.48.4,12.76.27,2.28.27.67,1.61.94,1.48.27,4.3,0,6.72.4,2.42.27,4.97.85,7.66,1.75,6.76,2.32,13.01,5.92,18.4,10.61,2.28,1.75,2.96,2.69,4.3,4.3,3.51,3.93,6.32,8.43,8.33,13.3,1.07,2.15,1.21,2.28,1.88,5.1.54,2.96,1.61,8.19,1.61,12.36s-.81,9.67-1.34,12.76c-.67,3.22-1.07,4.03-2.15,6.18-2.16,4.54-4.81,8.82-7.93,12.76-1.25,1.61-2.6,3-4.03,4.16-1.48,1.34-2.69,2.42-4.7,3.76-3.79,2.34-7.74,4.4-11.82,6.18l-6.58,2.15c-2.06.45-4.12.72-6.18.81l-7.25.13c-2.28,0-2.82.27-6.58-.4-3.76-.81-11.69-2.82-15.99-4.3-4.16-1.34-6.31-2.69-9.67-4.43-3.49-1.75-10.48-6.18-12.9-7.39-8.26-4.54-16.78-8.58-25.52-12.09-4.3-1.75-9.27-3.22-11.82-4.03-2.55-.81-5.24-1.61-7.66-2.15-8.39-2.25-16.99-3.6-25.66-4.03-3.9-.27-4.84-.27-8.19-.13-3.67-.09-7.79.04-12.36.4-7.9.79-15.75,2.04-23.51,3.76-8.37,2.26-16.62,4.95-24.72,8.06-3.22,1.34-2.82.81-9.13,4.16-6.31,3.36-22.03,12.22-28.75,15.58-6.72,3.36-8.73,3.49-11.82,4.43-3.09,1.07-4.3,1.21-6.58,1.61-7.3,1.09-14.71,1.18-22.03.27-2.55-.54-5.78-1.61-7.79-2.28-2.01-.54-2.15-.67-4.03-1.75-2.02-1.07-5.64-3.22-7.79-4.7-3.24-2.15-6.14-4.77-8.6-7.79-1.34-1.52-2.69-3.36-4.03-5.51-1.52-2.51-2.96-5.24-4.3-8.19-2.03-5.46-3.03-11.24-2.96-17.06,0-2.96.13-6.72.67-9.67.54-2.87,1.34-5.6,2.42-8.19,4.24-10.52,12.04-19.22,22.03-24.58,5.19-2.98,10.88-4.98,16.79-5.91,2.55-.4,5.37-.13,6.72-.4,1.34-.27,1.34,1.34,1.61-.94.4-2.28,0-9.4.4-12.76.27-3.36.81-4.97,1.48-7.25,1.87-6.19,4.88-11.97,8.87-17.06,3.47-3.98,7.39-7.54,11.69-10.61,4.43-2.61,9.11-4.77,13.97-6.45,2.55-.67,6.99-1.34,9.13-1.75,2.15-.27,1.88-.13,3.63-.13,1.79-.09,4.03,0,6.72.27,2.69.18,5.73.72,9.13,1.61,3.49,1.07,9.27,4.03,11.28,4.7s.4.27,1.07-.94ZM512.27,255.7c0,141.39-114.62,256-256,256S.27,397.09.27,255.7,114.89-.3,256.27-.3s256,114.62,256,256ZM449.33,352.66c14.67-29.16,22.94-62.09,22.94-96.95,0-119.29-96.71-216-216-216S40.27,136.41,40.27,255.7c0,41.89,11.94,80.98,32.57,114.09,1.7,1.79,2.94.65,3.05-.57.27-1.61,2.75-20.85,4.43-27.27,1.87-7.6,4.52-14.98,7.93-22.03,1.75-3.49,3.76-7.93,6.18-11.82,8.77-13.95,19.75-26.38,32.51-36.81,7.24-5.32,14.87-10.08,22.84-14.24,9.74-4.78,20.09-8.22,30.76-10.21,4.03-.99,7.61-1.66,10.75-2.02,3.36-.54,5.78-.54,9.27-.94,3.49-.54,9.32-1.16,11.82-2.01,6.65-2.27,5.64-6.72,3.09-7.52-2.55-.81-9.67-1.88-13.84-2.96-4.16-1.21-8.73-2.82-11.28-3.76-2.55-.94-2.28-.94-3.9-2.02l-5.91-4.03c-.94-.94-1.34-.94.54-2.02l10.21-5.51c2.01-1.07,1.75-.67,3.09-.13,1.34.67,4.3,2.42,6.72,3.36,7.2,2.69,14.96,3.52,22.57,2.42,1.34-.27,1.34-.54,1.61-1.21.27-.67.81-.94-.13-2.69-.94-1.88-4.43-6.58-5.64-8.46l-1.21-2.28c-.27-.45-1.07-1.07,1.21-1.75,2.42-.54,10.48-2.58,12.9-2.82.86-.09.67,0,1.75,1.07,1.07,1.07,3.09,3.63,4.84,5.24,1.88,1.61,4.43,3.22,6.18,4.3,2.8,1.71,5.99,2.68,9.27,2.82,1.88,0,4.97-.13,7.12-.67,2.15-.4,3.63-.94,5.64-2.02,2.01-1.07,4.7-2.69,6.72-4.43,2.01-1.75,3.49-5.1,5.64-6.04,2.15-.81,4.97.54,7.12.94,2.28.4,4.97,1.21,6.18,1.61,1.21.4,2.01.4.67,2.28l-8.06,10.34c-1.34,1.88.13,5.51,1.21,5.64l5.64.27c2.28-.13,4.43.13,7.66-.67,3.36-.81,9.27-2.96,11.82-3.9,2.69-.94,3.22-1.34,4.16-2.01.81-.54,1.39-1.03,1.75-1.48.45-.27.67-1.07,2.82,0s9.4,4.97,11.28,6.18c2.01,1.21,1.07.94,0,1.75l-5.51,3.9c-1.48.94-1.07.94-3.22,1.88-2.15,1.07-6.58,2.96-9.67,4.03s-4.03,1.75-8.73,2.69c-4.7.81-14.51,1.75-19.48,2.55-4.97.81-7.93,1.34-10.34,2.01-2.28.67-2.15.94-3.49,1.88-1.48,1.07-2.69,1.61-4.97,3.9-2.28,2.28-5.91,6.85-8.73,9.81-2.82,2.96-6.45,6.04-8.33,7.79-2.02,1.61-1.61,1.34-3.36,2.42l-6.99,4.03-4.03,2.02-6.72,2.15c-2.42.67-3.9,1.21-7.66,2.01l-14.91,2.82c-3.63.81-4.3,1.07-7.12,2.01-2.96,1.07-6.22,2.46-9.81,4.16-3.22,1.43-6.81,3.45-10.75,6.04-13.6,9.14-24.61,21.63-31.97,36.27-2.01,3.76-2.96,6.58-3.9,9.27-1.07,2.69-1.61,4.03-2.28,6.58-.67,2.69-1.48,5.24-2.15,9.27-.54,4.16-1.48,11.15-1.75,15.45-.27,4.16-.27,6.04,0,10.21l1.88,14.91c.67,3.76,1.48,5.91,2.15,8.19l1.88,5.64c.99,2.6,2.42,5.78,4.3,9.54,2.15,3.76,5.37,9.13,8.06,13.03,10.08,14.51,23.81,26.36,40.17,33.05,22.55,9.22,43.32,10.46,61.89,10.46,3.25,0,6.49-.09,9.71-.23,3.07-.42,2.74-6.09,10.48-9.42,5.26-2.26,13.7-2.42,14.91-2.55,1.07-.13-5.24-4.57-7.79-6.45-2.55-1.88-4.97-4.3-6.72-5.91-1.75-1.75-2.42-2.28-3.9-4.16-1.61-1.88-3.9-5.51-5.24-7.12-1.34-1.61-1.48-2.28-2.55-2.55-.98-.27-2.37-.09-4.16.54-1.88.4-5.37,1.21-7.12,1.88-1.75.67-2.02.81-3.09,2.01-1.07,1.07-2.69,3.76-3.63,4.7-.81.94-.67.67-1.48.94-.81.27-2.42.67-3.63.54-1.34-.18-2.55-.58-3.63-1.21-.81-.81-1.48-2.42-1.88-3.22-.4-.94-.54-1.21-.54-2.15l.4-3.49c.18-1.52.72-3.27,1.61-5.24.94-1.75,1.88-3.49,4.16-5.64,2.15-2.02,7.52-5.51,9.13-6.85,1.61-1.34,1.21-2.15.54-3.63-2.69-5.16-6.33-9.77-10.75-13.57-2.42-1.88-5.51-3.22-7.79-4.3-2.15-1.21-2.01-1.21-5.78-2.42-3.76-1.07-13.16-3.63-16.79-4.84-3.63-1.07-2.82-.94-5.1-2.01l-8.19-4.3c-1.75-.94-1.34-.54-2.69-1.61l-5.51-4.57c-2.18-1.93-3.77-4.45-4.57-7.25-.45-1.52-.45-2.87,0-4.03.4-1.34,0-1.21,2.01-3.63,2.15-2.42,7.25-7.93,10.21-10.75,3.09-2.82,4.97-4.03,7.79-6.04,5.43-3.82,11.09-7.32,16.93-10.48,2.42-1.21,5.37-2.02,7.12-2.69,1.61-.81,2.64-1.43,3.09-1.88.54-.4.67.54.4-.94-.4-1.48-1.88-4.97-2.28-7.66-.4-2.82-.4-6.18,0-8.73.36-2.42,1.03-4.66,2.01-6.72,1.16-2.24,2.46-4.3,3.9-6.18,1.34-1.7,2.91-3.04,4.7-4.03,1.75-1.07,4.3-2.01,6.18-2.42,1.61-.45,3.13-.58,4.57-.4l4.57.27c1.34.18,2.55.49,3.63.94,1.07.54,2.55,1.48,3.09,2.01.4.67.67.13-.27,1.61-1.07,1.48-4.16,4.57-5.78,7.12-1.61,2.69-2.96,5.6-4.03,8.73-.94,3.22-1.88,8.73-2.01,10.75-.27,2.15,4.7,1.75,5.1.54.54-1.07.27-2.55,1.07-5.1.81-2.42,2.42-7.25,3.9-9.81,1.34-2.55,2.82-3.76,4.57-5.51,1.79-1.88,3.67-3.45,5.64-4.7,1.88-1.21,3.22-1.75,5.64-2.28,2.42-.4,6.18-.67,8.73-.67,2.42,0,3.9.13,6.18.94,2.15.81,5.24,2.69,7.12,4.03,1.79,1.52,3.22,3.09,4.3,4.7,1.21,1.61,1.88,2.96,2.55,5.1.67,2.15,1.34,5.1,1.34,7.66,0,2.69-.54,6.04-1.21,8.19-.63,2.24-1.43,4.03-2.42,5.37-.67,1.34-.94,1.61-2.15,2.82-1.21,1.34-3.22,3.22-4.97,4.57-1.75,1.21-4.43,2.28-5.51,3.22-.94.81-.4,2.51.4,2.42.94.13,1.75.4,4.57-.13,2.82-.4,8.33-2.15,12.22-2.82,11.99-2.63,24.41-2.63,36.4,0,3.22.54,4.16,1.07,6.31,1.75l6.04,2.28c2.42,1.07,5.51,2.42,8.19,4.16,8.15,5.36,15.14,12.3,20.55,20.42,1.61,2.42,2.87,4.66,3.76,6.72,1.85,4.51,3.42,9.13,4.7,13.84.67,2.82,1.21,4.43,1.61,8.19.4,3.76.4,11.82.54,14.37.27,2.55-.13,2.28,1.75,1.34,1.75-.94,20.09-7.74,30.63-31.57,9.16-20.71,1.9-47.26-2.28-55.34-1.75-3.22-4.16-6.99-6.31-9.81-4.44-5.14-9.6-9.62-15.31-13.3-2.96-1.7-5.55-3.09-7.79-4.16-4.33-1.6-8.77-2.86-13.3-3.76l-6.18-.4h-14.37c-2.69-.27-3.1-3.18-.54-4.3,3.64-1.58,9.88-2.63,18.54-2.42,8.78.21,14.91,1.88,17.33,2.55,13.98,3.94,30.19,16.65,38.55,30.76,6.61,11.16,9.81,29.96,9.81,29.96.37,1.75,2.18,1.66,3.08.35ZM232.78,345.3c-3.91,0-7.08,3.17-7.08,7.08s3.17,7.08,7.08,7.08,7.08-3.17,7.08-7.08-3.17-7.08-7.08-7.08Z"/></svg>';function Oa(e){let t=e.status>=200&&e.status<300,r=t?"badge badge--success":"badge badge--notice",n=t?'<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false" class="mark"><path fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" d="M5 12.5l4.2 4.2L19 7"/></svg>':'<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false" class="mark"><path fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" d="M12 7v6M12 17h.01"/></svg>',i=t?"--success-soft":"--notice-soft";return`<!doctype html>
|
|
10
|
+
<html lang="en">
|
|
11
|
+
<head>
|
|
12
|
+
<meta charset="utf-8" />
|
|
13
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
14
|
+
<title>`+Ln(e.title)+`</title>
|
|
15
|
+
<style>
|
|
16
|
+
:root {
|
|
17
|
+
color-scheme: light dark;
|
|
18
|
+
/* Linzumi brand tokens (light) \u2014 kandan/server_v2/web/src/ui/theme/tokens.css */
|
|
19
|
+
--page-bg: #f5f2ee;
|
|
20
|
+
--surface: #fcfaf7;
|
|
21
|
+
--foreground: #1e1b18;
|
|
22
|
+
--muted: #5c5550;
|
|
23
|
+
--divider: rgba(138, 148, 144, 0.16);
|
|
24
|
+
--accent: #c4897a;
|
|
25
|
+
--success: #5a9a6a;
|
|
26
|
+
--success-soft: rgba(90, 154, 106, 0.1);
|
|
27
|
+
--notice-soft: rgba(196, 137, 122, 0.1);
|
|
28
|
+
--shadow: 0 12px 40px rgba(106, 138, 122, 0.12), 0 4px 12px rgba(106, 138, 122, 0.06);
|
|
29
|
+
}
|
|
30
|
+
@media (prefers-color-scheme: dark) {
|
|
31
|
+
:root {
|
|
32
|
+
/* Linzumi brand tokens (dark) */
|
|
33
|
+
--page-bg: #171b19;
|
|
34
|
+
--surface: #202522;
|
|
35
|
+
--foreground: rgba(245, 241, 232, 0.95);
|
|
36
|
+
--muted: rgba(245, 241, 232, 0.68);
|
|
37
|
+
--divider: rgba(245, 241, 232, 0.1);
|
|
38
|
+
--accent: #c8a0b0;
|
|
39
|
+
--success: #72c488;
|
|
40
|
+
--success-soft: rgba(114, 196, 136, 0.14);
|
|
41
|
+
--notice-soft: rgba(200, 160, 176, 0.14);
|
|
42
|
+
--shadow: 0 18px 50px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.35);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
* { box-sizing: border-box; }
|
|
46
|
+
body {
|
|
47
|
+
margin: 0;
|
|
48
|
+
min-height: 100vh;
|
|
49
|
+
display: grid;
|
|
50
|
+
place-items: center;
|
|
51
|
+
padding: 24px;
|
|
52
|
+
background:
|
|
53
|
+
radial-gradient(1200px 600px at 50% -10%, var(`+i+`), transparent 60%),
|
|
54
|
+
var(--page-bg);
|
|
55
|
+
color: var(--foreground);
|
|
56
|
+
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
57
|
+
-webkit-font-smoothing: antialiased;
|
|
58
|
+
}
|
|
59
|
+
main {
|
|
60
|
+
width: min(520px, 100%);
|
|
61
|
+
border: 1px solid var(--divider);
|
|
62
|
+
border-radius: 16px;
|
|
63
|
+
background: var(--surface);
|
|
64
|
+
padding: 40px 36px;
|
|
65
|
+
box-shadow: var(--shadow);
|
|
66
|
+
text-align: center;
|
|
67
|
+
}
|
|
68
|
+
.logo {
|
|
69
|
+
width: 44px;
|
|
70
|
+
height: 44px;
|
|
71
|
+
margin: 28px auto 0;
|
|
72
|
+
color: var(--accent);
|
|
73
|
+
}
|
|
74
|
+
.logo svg { display: block; width: 100%; height: 100%; }
|
|
75
|
+
.badge {
|
|
76
|
+
width: 64px;
|
|
77
|
+
height: 64px;
|
|
78
|
+
margin: 0 auto 22px;
|
|
79
|
+
display: grid;
|
|
80
|
+
place-items: center;
|
|
81
|
+
border-radius: 999px;
|
|
82
|
+
}
|
|
83
|
+
.badge--success { background: var(--success-soft); color: var(--success); }
|
|
84
|
+
.badge--notice { background: var(--notice-soft); color: var(--accent); }
|
|
85
|
+
.mark { width: 32px; height: 32px; }
|
|
86
|
+
h1 {
|
|
87
|
+
margin: 0 0 12px;
|
|
88
|
+
font-size: 23px;
|
|
89
|
+
font-weight: 600;
|
|
90
|
+
line-height: 1.3;
|
|
91
|
+
letter-spacing: -0.01em;
|
|
92
|
+
color: var(--foreground);
|
|
93
|
+
}
|
|
94
|
+
p {
|
|
95
|
+
margin: 0;
|
|
96
|
+
color: var(--muted);
|
|
97
|
+
font-size: 15px;
|
|
98
|
+
line-height: 1.6;
|
|
99
|
+
}
|
|
100
|
+
</style>
|
|
101
|
+
</head>
|
|
102
|
+
<body>
|
|
103
|
+
<main>
|
|
104
|
+
<div class="`+r+'">'+n+`</div>
|
|
105
|
+
<h1>`+Ln(e.title)+`</h1>
|
|
106
|
+
<p>`+Ln(e.body)+`</p>
|
|
107
|
+
<div class="logo">`+va+`</div>
|
|
108
|
+
</main>
|
|
109
|
+
</body>
|
|
110
|
+
</html>`}function fr(e,t){let r={};r["content-type"]="text/html; charset=utf-8",e.writeHead(t.status,r),e.end(Oa(t))}var wa=new RegExp('[&^|<>()%"]',"g");function xa(e){let t=It(e);if(t===void 0)return e;let r=D(t),n=r.searchParams;return Vi(n).includes("state")?(n.set("state","<SENSITIVE_DATA>"),r.toString()):e}function Ea(e,t){switch(e){case"darwin":return["open",[t]];case"win32":return["cmd",["/c","start","",t.replace(wa,"^$&")]];default:return["xdg-open",[t]]}}function Ko(e,t,r){let n=Ea(t,r),i=n[1],o=n[0];return new Promise((l,a)=>{let s=(u,m)=>{let c={};return c.command=o,c.args=i.map(d=>xa(d)),u!==void 0&&(c.pid=u),m!==void 0&&(c.message=m),c.purpose="oauth.open_browser",c};e("process.spawn",s(void 0,void 0));let f=Vo.spawn(o,i,{stdio:["ignore","ignore","ignore"],detached:!0});e("process.spawned",s(Ze(f.pid),void 0)),f.on("error",u=>{e("process.spawn_failed",s(Ze(f.pid),u.message)),l()}),f.on("spawn",()=>{f.unref(),l()})})}function ka(e,t,r){return new Promise((n,i)=>{let o={contents:void 0},l=new Promise((c,d)=>{o.contents=c}),a={contents:!1},s=c=>{if(a.contents)return!1;a.contents=!0;let d=o.contents;return d!==void 0&&d(c),!0},f={contents:"http://"+e+"/callback"},u=async(c,d)=>{let p=$(Ze(c.url),"/"),h=qe(p,"http://"+e);if(h.TAG==="Ok"){let _=h._0.searchParams,y=_.get("code"),g=_.get("state"),S=_.get("error"),T=0;if(S==null)T=1;else{if(S.trim()!=="")return s({TAG:"Error",_0:A("local runner OAuth failed: "+S)}),fr(d,{title:"Not authorized",body:"You denied the request. Close this tab and rerun the bootstrap command when you're ready.",status:403});T=1}if(T===1){let C=0;if(y==null||g==null)C=2;else{if(y.trim()!==""&&g.trim()!==""){let N=await r({code:y,state:g,redirectUri:f.contents});if(N.TAG==="Ok"){let H=s({TAG:"Ok",_0:N._0});return fr(d,{title:H?"Computer authorized":"Already authorized",body:"This computer has been authorized for agentic use in Linzumi. Feel free to close this tab and let the terminal finish setup.",status:200})}return s({TAG:"Error",_0:N._0}),fr(d,{title:"Authorization could not be completed",body:"We received the authorization but could not finish setup. Return to your terminal for details and rerun the bootstrap command.",status:400})}C=2}if(C===2)return fr(d,{title:"Authorization callback was incomplete",body:"We didn't receive the authorization code. Return to your terminal and try again.",status:400})}}else return s({TAG:"Error",_0:A(h._0)}),fr(d,{title:"Authorization callback failed",body:"Return to your terminal and rerun the bootstrap command.",status:500})},m=Wo.createServer((c,d)=>{u(c,d)});m.once("error",c=>n({TAG:"Error",_0:A(c.message)})),m.listen(0,e,()=>{let c=m.address(),d;if(c==null||typeof c!="object"||c===null||Array.isArray(c))d=void 0;else{let h=c.port;d=typeof h=="number"?h:void 0}if(d===void 0)return n({TAG:"Error",_0:A("local runner OAuth callback server did not bind to a TCP port")});f.contents="http://"+e+":"+d.toString()+"/callback";let p;if(c==null||typeof c!="object"||c===null||Array.isArray(c))p="";else{let h=c.address;p=typeof h=="string"?h:""}n({TAG:"Ok",_0:{redirectUri:f.contents,boundAddress:p,waitForToken:h=>{let _=Ho(h,t),y=setTimeout(()=>{s({TAG:"Error",_0:A("Authorization timed out before the browser callback completed. Rerun the connect command and finish authorizing in the browser.")}),m.close()},_);return y.unref(),l.then(g=>{clearTimeout(y)}),l},close:()=>{m.close()}}})})})}async function Xo(e,t,r,n,i,o,l,a,s,f){let u=U(ce(e),A);if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let m=u._0,c=U(Sa(e,o),A);if(c.TAG!=="Ok")return{TAG:"Error",_0:c._0};let d=Bo.randomBytes(18).toString("base64url"),p=await ka(c._0,l,y=>y.state===d?Aa(m,y.code,y.redirectUri):Promise.resolve({TAG:"Error",_0:A("local runner OAuth state mismatch")}));if(p.TAG!=="Ok")return{TAG:"Error",_0:p._0};let h=p._0,_=U(Ta(m,h.redirectUri,d,t,r,n,i),A);if(_.TAG==="Ok"){let y=_._0;a(`Authorize the local Codex runner:
|
|
111
|
+
`+y+`
|
|
112
|
+
`);let g;try{await s(y),g=await h.waitForToken(Ho(f,l))}catch(S){let T=j(S);g={TAG:"Error",_0:A(zt(T))}}return h.close(),g}return h.close(),{TAG:"Error",_0:_._0}}import*as Br from"node:fs";import*as Wn from"node:os";import*as de from"node:path";import*as Bn from"node:crypto";var Ga=new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$","i"),Ca=new RegExp("^[a-zA-Z0-9_.-]+$");function zn(e){return Ga.test(e)}function Wr(e){return Ca.test(e)}var Fa=Be(st,e=>e.trim()!=="","allowedCwds entries must be non-empty strings",void 0);function Qo(e){return{version:1,machineId:e.f("machineId",dr(Be(st,zn,"invalid machine id",void 0))),runnerId:e.f("runnerId",dr(Be(st,Wr,"invalid runner id",void 0))),allowedCwds:e.f("allowedCwds",bo(Fa))}}var Na=Ur(Qo),Ia=Ur(e=>(e.tag("version",1),Qo(e)));function qn(e){let t=new Set;return De(e,r=>{let n=r.trim();if(!(n===""||t.has(n)))return t.add(n),n})}function el(e){return{version:e.version,machineId:e.machineId,runnerId:e.runnerId,allowedCwds:qn(e.allowedCwds)}}function Jn(e){return X(Pn(e,Ia),el)}function tl(e){return X(Pn(e,Na),el)}var Jr=dr(Be(st,e=>e.trim()!=="","must be a non-empty string",void 0)),Zo=dr(Be(Eo,e=>Mn(e)?e>0:!1,"must be a positive integer",void 0));function $a(e){return!Number.isNaN(new Date(e).getTime())}var Yo=Be(st,$a,"must be a parseable date",void 0),xf=Ur(e=>({email:e.f("email",Be(st,t=>t.trim()!=="","must be a non-empty string",void 0)),serviceUrl:e.f("service_url",Be(st,t=>t.trim()!=="","must be a non-empty string",void 0)),accessToken:e.f("access_token",Jr),refreshToken:e.f("refresh_token",Jr),expiresInSeconds:e.f("expires_in_seconds",Zo),userId:e.f("user_id",Zo),workspaceSlug:e.f("workspace_slug",Jr),launchUrl:e.f("launch_url",Jr),createdAt:e.f("created_at",Yo),updatedAt:e.f("updated_at",Yo)}));var Re="prod";function rl(e){let t=e!==void 0?e:process.env,r=Xt(t,"HOME");return r!==void 0&&r.trim()!==""?r:Wn.homedir()}function Ra(e,t){let r=e!==void 0?e:process.env;return t==="~"?rl(r):t.startsWith("~/")?de.resolve(rl(r),t.slice(2)):t}function ol(e){let t=Xt(e,"LINZUMI_CONFIG_FILE");return t!==void 0&&t.trim()!==""?de.resolve(Ra(e,t)):de.resolve(Wn.homedir(),".linzumi","config.json")}function cr(e){let t=ce(e),r=ce(Zt);if(t.TAG!=="Ok")return{TAG:"Error",_0:A(t._0)};let n=t._0;return r.TAG==="Ok"?{TAG:"Ok",_0:n===r._0?Re:n}:{TAG:"Error",_0:A(r._0)}}function Ma(e){return X(cr(e),t=>t===Re?Re:Buffer.from(t).toString("base64url"))}function Da(e,t,r){let n=de.dirname(e),i=de.basename(e);return t!==void 0?P(cr(t),o=>o===Re?{TAG:"Ok",_0:de.join(n,i+"."+r)}:X(Ma(t),l=>de.join(n,i+"."+l+"."+r))):{TAG:"Ok",_0:de.join(n,i+"."+r)}}function ll(e){if(Br.existsSync(e))return P(U(et(e),r=>A(r.message)),r=>{let n;try{n=JSON.parse(r)}catch{n=void 0}return typeof n=="object"&&n!==null&&!Array.isArray(n)?Jn(n).TAG==="Ok"?{TAG:"Ok",_0:n}:{TAG:"Error",_0:A("invalid Linzumi config: "+e)}:{TAG:"Error",_0:A("invalid Linzumi config: "+e)}});let t={};return t.version=1,t.allowedCwds=[],{TAG:"Ok",_0:t}}function ja(){let e={};return e.allowedCwds=[],e}function nl(e,t){return P(ll(e),r=>{let n=t!==void 0?cr(t):{TAG:"Ok",_0:Re};return P(n,i=>{let o=i===Re?r:$(r[i],ja()),l=i===Re?Jn(o):tl(o);return U(l,a=>A("invalid Linzumi config section "+i+": "+e))})})}function Ua(e,t){let r=i=>A(i.message),n=Br.existsSync(e)?U(cn(e,384),r):{TAG:"Ok",_0:void 0};return P(P(n,()=>U(Ht(e,JSON.stringify(t,void 0,2)+`
|
|
113
|
+
`,{encoding:"utf8",mode:384}),r)),()=>U(cn(e,384),r))}function La(e){let t={},r=e.machineId;r!==void 0&&(t.machineId=r);let n=e.runnerId;return n!==void 0&&(t.runnerId=n),t.allowedCwds=qn(e.allowedCwds).map(i=>i),t}function za(e){let t=e.version===1,r=e.machineId,n=r!==void 0?zn(r):!0,i=e.runnerId,o=i!==void 0?Wr(i):!0,l=e.allowedCwds.every(a=>a.trim()!=="");return t&&n&&o&&l?{TAG:"Ok",_0:void 0}:{TAG:"Error",_0:A("invalid Linzumi config")}}function qa(e,t,r){return P(za(e),()=>{let n=r!==void 0?cr(r):{TAG:"Ok",_0:Re};return P(n,i=>P(ll(t),o=>{let l=Object.fromEntries(Object.entries(o)),a=La(e);return i===Re?(Object.entries(a).forEach(s=>{l[s[0]]=s[1]}),l.version=1):(l.version=1,l[i]=a),P(U(Kt(de.dirname(t)),s=>A(s.message)),()=>Ua(t,l))}))})}function il(e,t,r){return P(U(et(e),n=>A(n.message)),n=>{let i=n.trim();return t(i)?{TAG:"Ok",_0:i}:{TAG:"Error",_0:A("invalid Linzumi "+r+" seed: "+e)}})}function Ja(e,t,r,n){if(Br.existsSync(e))return il(e,r,n);let i=t();if(!r(i))return{TAG:"Error",_0:A("invalid generated Linzumi "+n+": "+i)};let o=de.dirname(e),l=de.basename(e),a=de.join(o,"."+l+"."+process.pid.toString()+"."+Bn.randomUUID()+".tmp"),s=f=>A(f.message);return P(P(U(Kt(o),s),()=>U(Ht(a,i+`
|
|
114
|
+
`,{encoding:"utf8",flag:"wx"}),s)),()=>{let f=Ui(a,e),u;if(f.TAG==="Ok")u={TAG:"Ok",_0:i};else{let m=f._0;u=ji(m,"EEXIST")?il(e,r,n):{TAG:"Error",_0:A(m.message)}}return Li(a),u})}function Wa(){return"runner-"+Bn.randomUUID()}function Ba(e,t,r,n,i,o,l,a){let s=t!==void 0?X(cr(t),f=>{if(f!==Re)return t}):{TAG:"Ok",_0:void 0};return P(s,f=>P(nl(e,f),u=>{let m=l(u);return m!==void 0?{TAG:"Ok",_0:m}:P(Da(e,f,r),c=>P(Ja(c,n,i,o),d=>P(nl(e,f),p=>{let h=l(p);return h!==void 0?{TAG:"Ok",_0:h}:X(qa(a(p,d),e,f),()=>d)})))}))}function ul(e,t,r){return Ba(e,t,"runner-id",r!==void 0?r:Wa,Wr,"runner id",i=>i.runnerId,(i,o)=>({version:i.version,machineId:i.machineId,runnerId:o,allowedCwds:i.allowedCwds}))}function Ha(e){if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e}async function al(e,t,r,n,i){let o=i!==void 0?i:[],l=U(ce(e),A);if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};let a=qe("/api/v2/local-codex-runner/oauth/validate",l._0);if(a.TAG!=="Ok")return{TAG:"Error",_0:A(a._0)};let s=a._0,f=s.searchParams;r!==void 0&&f.set("workspace",r),n!==void 0&&f.set("channel",n),o.forEach(p=>{f.append("required_scope",p)});let u={};u.authorization="Bearer "+t;let m=await vt(s.toString(),{method:"GET",headers:u});if(m.TAG!=="Ok")return{TAG:"Error",_0:A(m._0.message)};let c=m._0,d=c.status;if(d>404||d<401){if(d===200){let p=await Ot(c);return p.TAG!=="Ok"?{TAG:"Error",_0:A(p._0.message)}:q(Ha(p._0),_=>_.ok)===!0?{TAG:"Ok",_0:"Usable"}:{TAG:"Ok",_0:"Rejected"}}}else{if(d<402)return{TAG:"Ok",_0:"Rejected"};switch(d){case 402:break;case 403:return{TAG:"Ok",_0:"Rejected"};case 404:return{TAG:"Ok",_0:"NotFound"}}}return{TAG:"Error",_0:A("local runner auth validation failed with HTTP "+d.toString())}}var Xa=3600*1e3;function Za(e,t,r,n){return e<=3?"DecidePrompt":r!==void 0&&t-r<Xa?n?"DecideRefreshLine":"DecideSilent":"DecideSummary"}function sl(e){let t=Math.floor(e/6e4),r=Math.floor(t/60),n=t-r*60;return r>0?r.toString()+"h "+n.toString()+"m":n.toString()+"m"}function Ya(e){switch(e.TAG){case"Prompt":return(e.cycle===1?"":`The previous code expired; here is a fresh one (no restart needed - this prompt stays alive).
|
|
115
|
+
`)+`Authorize this computer:
|
|
116
|
+
Code: `+e.userCode+`
|
|
117
|
+
Open: `+e.verificationUri+`
|
|
118
|
+
`;case"Summary":return"Still waiting for authorization after "+sl(e.waitedMs)+" "+("("+e.cycle.toString()+` codes issued so far).
|
|
119
|
+
`)+(`Authorize this computer:
|
|
120
|
+
Code: `+e.userCode+`
|
|
121
|
+
Open: `+e.verificationUri+`
|
|
122
|
+
`);case"RefreshLine":return"\r\x1B[2KCode: "+e.userCode+" (waiting "+sl(e.waitedMs)+") - open "+e.verificationUri;case"TransientFailure":return"Device authorization poll hit a transient failure ("+e._0+`); retrying with the same code.
|
|
123
|
+
`;case"StartFailed":return"Could not mint a device authorization code ("+e.reason+"); retrying in "+Math.round(e.retryInMs/1e3).toString()+`s.
|
|
124
|
+
`}}function Qa(e){return new Promise((t,r)=>{setTimeout(()=>t(),e|0)})}function es(e){return{startDeviceAuthorization:t=>zo(t.httpBaseUrl,t.workspaceSlug,t.channelSlug,t.onboarding,t.identity),pollDeviceCodeForToken:t=>qo(t.httpBaseUrl,t.deviceCode,t.expiresInSeconds),now:()=>Date.now(),sleep:Qa,report:e,log:(t,r)=>{}}}var ts="local runner device authorization was denied - a signed-in user rejected this computer";async function dl(e,t,r,n,i,o,l,a){let s=o!==void 0?o:y=>{tt(y)},f=a!==void 0?a:es(y=>s(Ya(y))),u=l!==void 0?l:Nt(Ze(process.stderr.isTTY),!0),m=U(ce(e),A);if(m.TAG!=="Ok")return{TAG:"Error",_0:m._0};let c=m._0,d=f.now(),p={cycle:0,lastLoudPromptAtMs:void 0,startFailures:0},h=async y=>{let g=await f.pollDeviceCodeForToken({httpBaseUrl:c,deviceCode:y.deviceCode,expiresInSeconds:y.expiresInSeconds});if(typeof g!="object"||g.TAG!=="Transient")return g;let S=g.httpStatus,T=g.reason;f.report({TAG:"TransientFailure",_0:T});let C={};return C.cycle=p.cycle,C.reason=T,C.httpStatus=S!==void 0?S:null,f.log("device_wait.transient_poll_failure",C),await f.sleep(5e3),await h(y)},_=async()=>{let y=await f.startDeviceAuthorization({httpBaseUrl:c,workspaceSlug:t,channelSlug:r,onboarding:n,identity:i});if(y.TAG==="Ok"){let g=y._0;p.startFailures=0,p.cycle=p.cycle+1|0;let S=Za(p.cycle,f.now(),p.lastLoudPromptAtMs,u),T=0;switch(S){case"DecidePrompt":case"DecideSummary":T=1;break;case"DecideRefreshLine":f.report({TAG:"RefreshLine",userCode:g.userCode,verificationUri:g.verificationUri,waitedMs:f.now()-d});break;case"DecideSilent":break}if(T===1){p.lastLoudPromptAtMs=f.now();let H=f.now()-d,K;K=S==="DecidePrompt"?{TAG:"Prompt",cycle:p.cycle,userCode:g.userCode,verificationUri:g.verificationUri}:{TAG:"Summary",cycle:p.cycle,userCode:g.userCode,verificationUri:g.verificationUri,waitedMs:H},f.report(K)}let C={};C.cycle=p.cycle,C.verificationUri=g.verificationUri,f.log("device_wait.code_issued",C);let N=await h(g);if(typeof N!="object")switch(N){case"CodeExpired":let H={};return H.cycle=p.cycle,H.outcome="code_expired",f.log("device_wait.code_retired",H),await _();case"Denied":return{TAG:"Error",_0:A(ts)};case"Consumed":let K={};return K.cycle=p.cycle,K.outcome="consumed",f.log("device_wait.code_retired",K),await _()}else switch(N.TAG){case"Token":let H={};return H.cycle=p.cycle,H.waitedMs=f.now()-d,f.log("device_wait.authorized",H),{TAG:"Ok",_0:N._0};case"Rejected":let K=N.httpStatus,x=N.reason;f.report({TAG:"TransientFailure",_0:Lo(x,K)});let b={};return b.cycle=p.cycle,b.reason=x!==void 0?x:null,b.httpStatus=K,f.log("device_wait.code_rejected",b),await _();case"Transient":return await _()}}else{let g=y._0;p.startFailures=p.startFailures+1|0;let S=Math.min(6e4,5e3*Math.pow(2,p.startFailures-1|0));f.report({TAG:"StartFailed",reason:g.summary,retryInMs:S});let T={};return T.reason=g.summary,T.retryInMs=S,T.attempt=p.startFailures,f.log("device_wait.start_failed",T),await f.sleep(S),await _()}};return await _()}var ns="linzumi-machine-fingerprint:v1:";var fl={platform:void 0,execFile:void 0,readFile:void 0,username:void 0};function is(e,t){return Bi(e,t,5e3,1024*1024)}var os=new RegExp('"IOPlatformUUID"\\s*=\\s*"([0-9A-Fa-f-]{36})"'),ls=new RegExp("^[0-9a-f]{32}$"),us=["/etc/machine-id","/var/lib/dbus/machine-id"];function as(e){let t=e!==void 0?e:fl,r=$(t.platform,process.platform),n=$(t.execFile,is),i=$(t.readFile,et);switch(r){case"darwin":let o=n("ioreg",["-rd1","-c","IOPlatformExpertDevice"]);if(o.TAG!=="Ok")return;let l=os.exec(o._0);if(l==null)return;let a=l.slice(1)[0];if(a===void 0)return;let s=D(a);return s!==void 0?s.toLowerCase():void 0;case"linux":return Hr(us,void 0,(f,u)=>{if(f!==void 0)return f;let m=i(u);if(m.TAG!=="Ok")return;let c=m._0.trim().toLowerCase();if(ls.test(c))return c});default:return}}function cl(){return ve(as(fl),e=>"mfp-"+Ji(ns+e).slice(0,32))}function ds(e,t){return P(U(ce(e),A),r=>{let n=It(r);return n===void 0?{TAG:"Error",_0:A("invalid URL: "+r)}:{TAG:"Ok",_0:"Workspace '"+(t!==void 0?t:"undefined")+"' was not found on "+D(n).host+". Sign in to the web app to create it, then re-run connect."}})}function hl(e){let t=e.authFilePath;return t!==void 0?t:Po()}function _l(e,t){let r=hl(e);return X(Do(e.serviceUrl,t.accessToken,t.expiresInSeconds,r,new Date),n=>({accessToken:n.accessToken,expiresAt:n.expiresAt,authFilePath:r}))}function ml(e,t){if(t===void 0)return jn(e);let r=new Date(t).getTime();if(isFinite(r))return{TAG:"Ok",_0:t};let n=jn(e);if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0;return i!==void 0?{TAG:"Ok",_0:i}:{TAG:"Error",_0:A("invalid managed token expiry metadata and access token has no usable expiry")}}async function fs(e){let t=ol(process.env),r=ul(t,e.serviceUrl,void 0);if(r.TAG!=="Ok")return{TAG:"Error",_0:r._0};let n=r._0,i=cl(),o=pl.hostname(),l={commanderId:n,machineFingerprint:i,hostname:o},a=await dl(e.serviceUrl,e.workspaceSlug,e.channelSlug,e.onboarding,l,void 0,void 0,void 0);return a.TAG==="Ok"?_l(e,a._0):{TAG:"Error",_0:a._0}}async function cs(e){let t=e.authMode;if(typeof t!="object")return await fs(e);let r=ve(t.callbackHost,Uo),n=await Xo(e.serviceUrl,e.workspaceSlug,e.channelSlug,e.onboarding,void 0,r,process.env,i=>{tt(i)},i=>Ko((o,l)=>{if(o!=="process.spawn_failed"||typeof l!="object"||l===null||Array.isArray(l))return;let a=q(l.command,Rn),s=q(l.message,Rn);if(a!==void 0&&s!==void 0){tt("linzumi (rescript commander): could not open the authorization URL with "+a+" ("+s+`); open the URL above manually
|
|
125
|
+
`);return}},process.platform,i),void 0);return n.TAG==="Ok"?_l(e,n._0):{TAG:"Error",_0:n._0}}function ms(){return{readCachedToken:(e,t)=>Mo(e,t,Date.now()),validateToken:(e,t,r,n,i)=>al(e,t,r,n,i),acquireAndCacheAuth:cs}}async function ps(e,t,r){let n=await t.validateToken(e.serviceUrl,r,e.workspaceSlug,e.channelSlug,e.requiredScopes);if(n.TAG!=="Ok")return{TAG:"Ok",_0:void 0};switch(n._0){case"Usable":case"Rejected":return{TAG:"Ok",_0:void 0};case"NotFound":return P(ds(e.serviceUrl,e.workspaceSlug),i=>({TAG:"Error",_0:A(i)}))}}async function hs(e,t){let r=t!==void 0?t:ms(),n=ve(e.explicitToken,_=>_.trim()),i=n!==void 0&&n!==""?n:void 0;if(i!==void 0)return{TAG:"Ok",_0:{TAG:"ExplicitAuth",accessToken:i}};let o=hl(e),l=r.readCachedToken(e.serviceUrl,o);if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};let a=l._0,s;if(a!==void 0){let _=await r.validateToken(e.serviceUrl,a.accessToken,e.workspaceSlug,e.channelSlug,e.requiredScopes);if(_.TAG==="Ok")switch(_._0){case"Usable":s={TAG:"Ok",_0:a};break;case"Rejected":let y=e.reportRejectedCachedToken;y!==void 0&&y("UnusableRejected"),s={TAG:"Ok",_0:void 0};break;case"NotFound":let g=e.reportRejectedCachedToken;g!==void 0&&g("UnusableNotFound"),s={TAG:"Ok",_0:void 0};break}else s={TAG:"Error",_0:_._0}}else s={TAG:"Ok",_0:void 0};if(s.TAG!=="Ok")return{TAG:"Error",_0:s._0};let f=s._0;if(f!==void 0)return X(ml(f.accessToken,f.expiresAt),_=>({TAG:"CachedAuth",_0:{accessToken:f.accessToken,expiresAt:_,authFilePath:o}}));let u=await r.acquireAndCacheAuth(e);if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let m=u._0,c=ml(m.accessToken,m.expiresAt);if(c.TAG!=="Ok")return{TAG:"Error",_0:c._0};let d=c._0;if(e.workspaceSlug===void 0)return{TAG:"Ok",_0:{TAG:"AcquiredAuth",accessToken:m.accessToken,expiresAt:d,authFilePath:m.authFilePath,mode:e.authMode}};let h=await ps(e,r,m.accessToken);return h.TAG==="Ok"?{TAG:"Ok",_0:{TAG:"AcquiredAuth",accessToken:m.accessToken,expiresAt:d,authFilePath:m.authFilePath,mode:e.authMode}}:{TAG:"Error",_0:h._0}}function _s(e){switch(e.TAG){case"CachedAuth":return e._0.accessToken;case"ExplicitAuth":case"AcquiredAuth":return e.accessToken}}async function yl(e,t){return X(await hs(e,t),_s)}function Ss(e){let t=Ce(e);return t!==void 0?$(Ae(D(t)),"unknown error"):"unknown error"}function gl(e){let t;try{t={TAG:"Ok",_0:new URL(e)}}catch(o){let l=j(o);t={TAG:"Error",_0:Ss(l)}}if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0,n=r.protocol,i;switch(n){case"https:":case"wss:":i="https:";break;default:i="http:"}return r.protocol=i,r.pathname="/api/v2/graphql",r.search="",r.hash="",{TAG:"Ok",_0:r.toString()}}function As(e){return vl.createHash("sha256").update(e,"utf8").digest().subarray(0,8).toString("base64url")}function Xn(e,t){return{operationName:e,documentId:As(t),text:t}}var Ol=Xn("TopicsCliTopicLookup",`query TopicsCliTopicLookup($workspaceSlug: String!, $slug: String!) {
|
|
4
126
|
topic(workspaceSlug: $workspaceSlug, slug: $slug) {
|
|
5
127
|
id
|
|
6
128
|
slug
|
|
7
129
|
title
|
|
8
130
|
status
|
|
9
131
|
}
|
|
10
|
-
}`),
|
|
132
|
+
}`),wl=Xn("TopicsCliCreateTopic",`mutation TopicsCliCreateTopic($input: CreateTopicInput!) {
|
|
11
133
|
createTopic(input: $input) {
|
|
12
134
|
ok
|
|
13
135
|
error
|
|
@@ -16,7 +138,7 @@ import*as K from"node:crypto";function k(e){if(e===null||e.BS_PRIVATE_NESTED_SOM
|
|
|
16
138
|
slug
|
|
17
139
|
}
|
|
18
140
|
}
|
|
19
|
-
}`),
|
|
141
|
+
}`),xl=Xn("TopicsCliPostEntry",`mutation TopicsCliPostEntry($input: PostTopicEntryInput!) {
|
|
20
142
|
postTopicEntry(input: $input) {
|
|
21
143
|
ok
|
|
22
144
|
error
|
|
@@ -24,7 +146,7 @@ import*as K from"node:crypto";function k(e){if(e===null||e.BS_PRIVATE_NESTED_SOM
|
|
|
24
146
|
entrySeq
|
|
25
147
|
}
|
|
26
148
|
}
|
|
27
|
-
}`),
|
|
149
|
+
}`),Ff=[Ol,wl,xl],Kn=["plan","reasoning","command_execution","terminal_input","file_change","tool_call","approval_request","web_search","status","artifact","assistant_output"];function Vn(){return`Usage: linzumi topics post [options]
|
|
28
150
|
|
|
29
151
|
Post one entry into a long-lived topic (spec/topics-rules.md). The topic
|
|
30
152
|
auto-creates on first post, so producers never lose an entry to a missing
|
|
@@ -36,7 +158,7 @@ Required:
|
|
|
36
158
|
|
|
37
159
|
Options:
|
|
38
160
|
--kind <kind> Entry kind (default: status). One of:
|
|
39
|
-
`+
|
|
161
|
+
`+Kn.join(", ")+`.
|
|
40
162
|
--preview <text> Short preview line for collapsed rendering.
|
|
41
163
|
--body <text> Full entry body text.
|
|
42
164
|
--payload-json <json> JSON object payload (e.g. '{"severity":"error"}').
|
|
@@ -48,11 +170,13 @@ Options:
|
|
|
48
170
|
--linzumi-url <url> Server URL (defaults to the production server).
|
|
49
171
|
--token <token> Explicit access token (defaults to cached login).
|
|
50
172
|
-h, --help Show this help.
|
|
51
|
-
`}var
|
|
52
|
-
`)}else{let
|
|
53
|
-
`)}return 0}return
|
|
54
|
-
`),1}return
|
|
55
|
-
`),1}return
|
|
56
|
-
`),1}return
|
|
57
|
-
`),
|
|
58
|
-
`),1}
|
|
173
|
+
`}var vs=["workspace","topic","kind","preview","body","payload-json","dedupe-key","title","linzumi-url","api-url","token"],Os=["json","help","no-create"];function El(e){let t=[],r={},n,i=0;for(;ri(n)&&i<e.length;){let l=e[i];if(l==="-h"||l==="--help")r.help="FlagOn";else if(l.startsWith("--")){let a=Xr(l,"="),s=a!==void 0?l.slice(2,a):l.slice(2);if(Os.includes(s))a!==void 0?n="--"+s+" does not take a value":r[s]="FlagOn";else if(vs.includes(s))if(a!==void 0)r[s]={TAG:"FlagString",_0:l.slice(a+1|0)};else{let f=e[i+1|0],u=0;f!==void 0&&!f.startsWith("--")?(r[s]={TAG:"FlagString",_0:f},i=i+1|0):u=1,u===1&&(n="--"+s+" requires a value")}else n="unknown flag --"+s+" (see: linzumi topics --help)"}else t.push(l);i=i+1|0}let o=n;return o!==void 0?{TAG:"Error",_0:o}:{TAG:"Ok",_0:{subcommand:t[0],flags:r}}}function ye(e,t){let r=e[t];if(typeof r=="object")return r._0}function Hn(e,t){let r=e[t];return r!==void 0?typeof r!="object":!1}function ws(e){let t;try{t=JSON.parse(e)}catch{return{TAG:"Error",_0:"--payload-json must be valid JSON"}}return typeof t=="object"&&t!==null&&!Array.isArray(t)?{TAG:"Ok",_0:void 0}:{TAG:"Error",_0:"--payload-json must be a JSON object"}}function ae(e,t){if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e[t]}function Jt(e){if(typeof e=="string")return e}function Sl(e){if(typeof e=="boolean")return e}function xs(e){if(typeof e=="number")return e}function Es(e,t,r,n){let i=ae(n,"errors"),o=i!==void 0?Array.isArray(i)?i:[]:[];if(o.length!==0){let a=De(o,s=>q(ae(s,"extensions"),f=>Jt(ae(f,"code"))));return a.includes("PERSISTED_DOCUMENT_NOT_FOUND")?"DocumentNotFound":{TAG:"GraphqlErrors",_0:{messages:o.map(s=>$(Jt(ae(s,"message")),"unknown error")),codes:a}}}if(!e)return{TAG:"HttpFailure",_0:"HTTP "+t.toString()+" "+r};let l=ae(n,"data");return l!==void 0?{TAG:"Data",_0:l}:{TAG:"HttpFailure",_0:"empty response body"}}function Tl(e){if(typeof e!="object")return"topics request failed";switch(e.TAG){case"Data":return"topics request failed";case"GraphqlErrors":let t=e._0;if(t.codes.includes("FREE_FORM_GRAPHQL_FORBIDDEN"))return"this Linzumi server does not know this CLI version's topics documents yet (its persisted-document manifest predates them); nothing was changed - retry after the next server deploy";let r=t.messages;return r.some(i=>{let o=i.toLowerCase();return o.includes("cannot query field")||o.includes("unknown argument")||o.includes("unknown type")||o.includes("unknown field")?!0:o.includes("has invalid value $input")})?"this Linzumi server does not support topics yet (the topics server rollout has not reached it); nothing was changed":"topics request returned errors: "+r.join("; ");case"HttpFailure":return"topics request failed: "+e._0}}function ks(e,t,r){let n=async i=>{let o=Object.fromEntries([["content-type","application/json"],["authorization","Bearer "+t]]),l=await r(e,{method:"POST",headers:o,body:JSON.stringify(i)}),a;try{a=await l.json()}catch{a=null}return Es(l.ok,l.status,l.statusText,a)};return async(i,o)=>{let l=await n(Object.fromEntries([["documentId",i.documentId],["operationName",i.operationName],["variables",o]]));if(typeof l!="object"){let a=await n(Object.fromEntries([["query",i.text],["operationName",i.operationName],["variables",o]]));return typeof a!="object"||a.TAG!=="Data"?{TAG:"Error",_0:Tl(a)}:{TAG:"Ok",_0:a._0}}switch(l.TAG){case"Data":return{TAG:"Ok",_0:l._0};case"GraphqlErrors":case"HttpFailure":return{TAG:"Error",_0:Tl(l)}}}}function bs(e){return Object.fromEntries([["workspaceSlug",e.workspaceSlug],["slug",e.topicSlug]])}async function Al(e,t){let r=await e(Ol,bs(t));return r.TAG==="Ok"?{TAG:"Ok",_0:Jt(q(ae(r._0,"topic"),n=>ae(n,"id")))}:{TAG:"Error",_0:r._0}}async function Gs(e,t){if(!Kn.includes(t.kind))return{TAG:"Error",_0:'unknown entry kind "'+t.kind+'" (one of: '+Kn.join(", ")+")"};let r=t.payloadJson,n=r!==void 0?ws(r):{TAG:"Ok",_0:void 0};if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=await Al(e,t);if(i.TAG!=="Ok")return{TAG:"Error",_0:i._0};let o=i._0,l;if(o!==void 0)l={TAG:"Ok",_0:[o,!1]};else if(t.createMissing){let g=Object.fromEntries([["workspaceSlug",t.workspaceSlug],["slug",t.topicSlug]]),S=t.title;S!==void 0&&(g.title=S);let T=await e(wl,Object.fromEntries([["input",g]]));if(T.TAG==="Ok"){let C=ae(T._0,"createTopic"),N=$(Sl(q(C,b=>ae(b,"ok"))),!1),H=Jt(q(q(C,b=>ae(b,"topic")),b=>ae(b,"id"))),K=Jt(q(C,b=>ae(b,"error"))),x=0;if(N&&H!==void 0?l={TAG:"Ok",_0:[H,!0]}:x=1,x===1){let b;if(K!==void 0){let F=K.toLowerCase();b=F.includes("taken")||F.includes("slug")}else b=!1;if(b){let F=await Al(e,t),J=0;if(F.TAG==="Ok"){let L=F._0;L!==void 0?l={TAG:"Ok",_0:[L,!1]}:J=2}else J=2;J===2&&(l={TAG:"Error",_0:'could not create topic "'+t.topicSlug+'": '+$(K,"unknown error")})}else l={TAG:"Error",_0:'could not create topic "'+t.topicSlug+'": '+$(K,"unknown error")}}}else l={TAG:"Error",_0:T._0}}else l={TAG:"Error",_0:'topic "'+t.topicSlug+'" does not exist in workspace "'+t.workspaceSlug+'" (drop --no-create to auto-create it)'};if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};let a=l._0,s=Object.fromEntries([["topicId",a[0]],["kind",t.kind.toUpperCase()]]),f=t.preview;f!==void 0&&(s.previewText=f);let u=t.body;u!==void 0&&(s.body=u);let m=t.payloadJson;m!==void 0&&(s.payloadJson=m);let c=t.dedupeKey;c!==void 0&&(s.dedupeKey=c);let d=await e(xl,Object.fromEntries([["input",s]]));if(d.TAG!=="Ok")return{TAG:"Error",_0:d._0};let p=ae(d._0,"postTopicEntry"),h=$(Sl(q(p,g=>ae(g,"ok"))),!1),_=xs(q(q(p,g=>ae(g,"entry")),g=>ae(g,"entrySeq")));if(h&&_!==void 0)return{TAG:"Ok",_0:{topicSlug:t.topicSlug,entrySeq:_|0,created:a[1]}};let y=Jt(q(p,g=>ae(g,"error")));return{TAG:"Error",_0:'could not post to topic "'+t.topicSlug+'": '+$(y,"unknown error")}}async function Cs(e,t){let r=t.stdout,n=r!==void 0?r:a=>{process.stdout.write(a)},i=t.stderr,o=i!==void 0?i:a=>{process.stderr.write(a)},l=El(e);if(l.TAG==="Ok"){let a=l._0,s=a.flags,f=a.subcommand;if(Hn(s,"help"))return n(Vn()),0;if(f!==void 0){if(f==="post"){let u=ye(s,"workspace"),m=ye(s,"topic");if(u!==void 0){if(m!==void 0){let c=$(Kr(ye(s,"linzumi-url"),ye(s,"api-url")),t.defaultUrl),d,p=0,h;try{let _=ye(s,"token");h=await(_!==void 0?t.resolveToken({kandanUrl:c,explicitToken:_}):t.resolveToken({kandanUrl:c})),p=1}catch(_){let y=j(_);if(y.RE_EXN_ID==="JsExn")d={TAG:"Error",_0:$(Ae(y._1),"token resolution failed")};else throw y}if(p===1){let _=ks(t.graphqlEndpoint(c),h,$(t.fetchImpl,fetch));d=await Gs(_,{workspaceSlug:u,topicSlug:m,kind:$(ye(s,"kind"),"status"),preview:ye(s,"preview"),body:ye(s,"body"),payloadJson:ye(s,"payload-json"),dedupeKey:ye(s,"dedupe-key"),title:ye(s,"title"),createMissing:!Hn(s,"no-create")})}if(d.TAG==="Ok"){let _=d._0;if(Hn(s,"json")){let y=Object.fromEntries([["topicSlug",_.topicSlug],["entrySeq",_.entrySeq],["created",_.created]]);n(JSON.stringify(y)+`
|
|
174
|
+
`)}else{let y=_.created?" (topic auto-created)":"";n("posted entry #"+_.entrySeq.toString()+" to "+u+"/"+_.topicSlug+y+`
|
|
175
|
+
`)}return 0}return o(d._0+`
|
|
176
|
+
`),1}return o(`--workspace and --topic are required (see: linzumi topics --help)
|
|
177
|
+
`),1}return o(`--workspace and --topic are required (see: linzumi topics --help)
|
|
178
|
+
`),1}return o('unknown topics subcommand "'+f+`"
|
|
179
|
+
`),n(Vn()),1}return n(Vn()),1}return o(l._0+`
|
|
180
|
+
`),1}async function Nf(e){let t=El(e);if(t.TAG==="Ok"){let r=t._0.flags,n=$(Kr(ye(r,"linzumi-url"),ye(r,"api-url")),Zt),i=gl(n);if(i.TAG==="Ok"){let o=i._0;return await Cs(e,{resolveToken:async l=>{let a=await yl({serviceUrl:l.kandanUrl,explicitToken:l.explicitToken,workspaceSlug:void 0,channelSlug:void 0,requiredScopes:[],onboarding:void 0,authFilePath:void 0,authMode:{TAG:"BrowserMode",callbackHost:void 0},reportRejectedCachedToken:void 0},void 0);return a.TAG==="Ok"?a._0:await Promise.reject({RE_EXN_ID:"Failure",_1:a._0.summary})},defaultUrl:Zt,graphqlEndpoint:l=>o})}return tt(i._0+`
|
|
181
|
+
`),1}return tt(t._0+`
|
|
182
|
+
`),1}export{Os as booleanFlags,wl as createDocument,ks as createTransport,Xn as documentOf,Ff as documents,Tl as errorFromOutcome,Hn as flagOn,ye as flagString,Vn as helpText,Es as interpretGraphqlResponse,Sl as jsonBool,ae as jsonField,xs as jsonNumber,Jt as jsonString,Ol as lookupDocument,Al as lookupTopicId,bs as lookupVariables,El as parseTopicsArgs,As as persistedDocumentId,xl as postDocument,Gs as postTopicEntry,Nf as run,Cs as runTopicsCommand,Kn as topicEntryKinds,ws as validatePayloadJson,vs as valueFlags};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linzumi/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.277",
|
|
4
4
|
"description": "Linzumi CLI \u2014 point a Codex agent at the real code on your laptop, with your team watching and steering from shared threads.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -14,27 +14,20 @@
|
|
|
14
14
|
"!scripts/build-*-oracle.mjs"
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
|
-
"test:agent-source": "LINZUMI_CI_QUARANTINE=0 pnpm exec vitest run --config vitest.config.mjs test/channelSession.test.ts test/kandanQueue.test.ts test/llmProxySessionCredential.test.ts test/runnerBridge.test.ts test/threadCodexWorkerIpc.test.ts -t '(?:^| )(retains three busy accepted source snapshots without fusing or interrupting|keeps different accepted agent sources distinct through interrupt pickup|does not install an old mint after its credential is (replaced|stopped)|worker agent capability requires an exact true ready flag|starts an explicitly server-keyed OpenAI agent worker without local OpenAI credentials|applies the accepted OpenAI follow-up model on an existing worker|refuses explicit OpenAI worker creation with (passthrough|missing-token|blank-origin) binding|refuses a private agent turn without an owned relay before Codex|explicitly capable worker receives a private request through ordinary IPC|old worker receives no private agent source descriptor)$'",
|
|
18
17
|
"build": "rescript build ../linzumi-cli-rescript && node scripts/build.mjs",
|
|
19
|
-
"test:actual-commander-parity": "pnpm --dir ../linzumi-cli-rescript build && node --test --test-concurrency=1 ../linzumi-cli-rescript/src/parity/ActualCommanderParityConformance.res.mjs",
|
|
20
18
|
"bump-version": "node scripts/bump-cli-version.mjs",
|
|
21
|
-
"
|
|
22
|
-
"test": "npm run test:startup && node --import tsx --test ../linzumi-cli-rescript/src/parity/McpToolCallBoundaryTest.res.mjs && rescript build ../../kandan/server_v2/web/replay_harness && vitest run --config vitest.config.mjs",
|
|
19
|
+
"test": "pnpm --dir ../linzumi-cli-rescript test && npm run test:operational",
|
|
23
20
|
"typecheck": "rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.source.json",
|
|
24
|
-
"typecheck:all": "rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.json",
|
|
25
|
-
"typecheck:watch": "rescript build ../linzumi-cli-rescript && tsgo --noEmit -w -p tsconfig.source.json",
|
|
26
21
|
"prepack": "rescript build -q ../linzumi-cli-rescript && node scripts/build.mjs",
|
|
27
22
|
"pack:dry-run": "npm pack --dry-run",
|
|
28
|
-
"
|
|
29
|
-
"normalize:agent-fixture": "tsx scripts/normalize-agent-replay-fixture.ts",
|
|
23
|
+
"test:operational": "vitest run --config vitest.config.mjs",
|
|
30
24
|
"vendor:codex-app-server-protocol": "tsx scripts/vendor-codex-app-server-protocol.ts",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"test:startup": "npm run build && node --test --test-concurrency=1 ../linzumi-cli-rescript/src/parity/CommanderStartupRefusalConformance.res.mjs"
|
|
25
|
+
"test:startup": "npm run build && node --test --test-concurrency=1 ../linzumi-cli-rescript/src/parity/CommanderStartupRefusalConformance.res.mjs",
|
|
26
|
+
"typecheck:all": "rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.json",
|
|
27
|
+
"typecheck:watch": "rescript build ../linzumi-cli-rescript && tsgo --noEmit -w -p tsconfig.source.json",
|
|
28
|
+
"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",
|
|
29
|
+
"codex:history-table": "node scripts/codex_history_table.mjs",
|
|
30
|
+
"vendor:codex-app-server-protocol:check": "tsx scripts/vendor-codex-app-server-protocol.ts --check"
|
|
38
31
|
},
|
|
39
32
|
"keywords": [
|
|
40
33
|
"linzumi",
|
|
@@ -47,7 +40,7 @@
|
|
|
47
40
|
"access": "public"
|
|
48
41
|
},
|
|
49
42
|
"dependencies": {
|
|
50
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
43
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.283",
|
|
51
44
|
"@inquirer/prompts": "^7.8.6",
|
|
52
45
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
53
46
|
"@openai/codex": "0.153.2",
|