@leviyuan/lodestar 0.21.8 → 0.21.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lodestar-agent.js +54 -59
- package/dist/lodestar-claude.js +60 -0
- package/dist/lodestar-setup.js +54 -59
- package/dist/lodestar-stop.js +3 -3
- package/dist/lodestar-update.js +52 -57
- package/dist/lodestar-version.js +14 -19
- package/dist/lodestar.js +251 -251
- package/docs/claude-agent-backend.md +10 -0
- package/docs/configuration.md +1 -0
- package/docs/models.md +26 -1
- package/docs/usage.md +1 -1
- package/package.json +8 -4
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{createRequire as A$}from"node:module";var E$=Object.create;var{getPrototypeOf:D$,defineProperty:j1,getOwnPropertyNames:f$}=Object;var _$=Object.prototype.hasOwnProperty;function x$($){return this[$]}var v$,y$,X0=($,J,Q)=>{var Y=$!=null&&typeof $==="object";if(Y){var X=J?v$??=new WeakMap:y$??=new WeakMap,Z=X.get($);if(Z)return Z}Q=$!=null?E$(D$($)):{};let W=J||!$||!$.__esModule?j1(Q,"default",{value:$,enumerable:!0}):Q;for(let K of f$($))if(!_$.call(W,K))j1(W,K,{get:x$.bind($,K),enumerable:!0});if(Y)X.set($,W);return W};var P=($,J)=>()=>(J||$((J={exports:{}}).exports,J),J.exports);var j=A$(import.meta.url);var C1=P((rJ,I1)=>{I1.exports=T1;T1.sync=k$;var R1=j("fs");function b$($,J){var Q=J.pathExt!==void 0?J.pathExt:process.env.PATHEXT;if(!Q)return!0;if(Q=Q.split(";"),Q.indexOf("")!==-1)return!0;for(var Y=0;Y<Q.length;Y++){var X=Q[Y].toLowerCase();if(X&&$.substr(-X.length).toLowerCase()===X)return!0}return!1}function U1($,J,Q){if(!$.isSymbolicLink()&&!$.isFile())return!1;return b$(J,Q)}function T1($,J,Q){R1.stat($,function(Y,X){Q(Y,Y?!1:U1(X,$,J))})}function k$($,J){return U1(R1.statSync($),$,J)}});var f1=P((sJ,D1)=>{D1.exports=w1;w1.sync=h$;var S1=j("fs");function w1($,J,Q){S1.stat($,function(Y,X){Q(Y,Y?!1:E1(X,J))})}function h$($,J){return E1(S1.statSync($),J)}function E1($,J){return $.isFile()&&g$($,J)}function g$($,J){var{mode:Q,uid:Y,gid:X}=$,Z=J.uid!==void 0?J.uid:process.getuid&&process.getuid(),W=J.gid!==void 0?J.gid:process.getgid&&process.getgid(),K=parseInt("100",8),H=parseInt("010",8),B=parseInt("001",8),z=K|H,V=Q&B||Q&H&&X===W||Q&K&&Y===Z||Q&z&&Z===0;return V}});var x1=P(($Q,_1)=>{var eJ=j("fs"),T0;if(process.platform==="win32"||global.TESTING_WINDOWS)T0=C1();else T0=f1();_1.exports=i0;i0.sync=u$;function i0($,J,Q){if(typeof J==="function")Q=J,J={};if(!Q){if(typeof Promise!=="function")throw TypeError("callback not provided");return new Promise(function(Y,X){i0($,J||{},function(Z,W){if(Z)X(Z);else Y(W)})})}T0($,J||{},function(Y,X){if(Y){if(Y.code==="EACCES"||J&&J.ignoreErrors)Y=null,X=!1}Q(Y,X)})}function u$($,J){try{return T0.sync($,J||{})}catch(Q){if(J&&J.ignoreErrors||Q.code==="EACCES")return!1;else throw Q}}});var g1=P((JQ,h1)=>{var Z0=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",v1=j("path"),c$=Z0?";":":",y1=x1(),A1=($)=>Object.assign(Error(`not found: ${$}`),{code:"ENOENT"}),b1=($,J)=>{let Q=J.colon||c$,Y=$.match(/\//)||Z0&&$.match(/\\/)?[""]:[...Z0?[process.cwd()]:[],...(J.path||process.env.PATH||"").split(Q)],X=Z0?J.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",Z=Z0?X.split(Q):[""];if(Z0){if($.indexOf(".")!==-1&&Z[0]!=="")Z.unshift("")}return{pathEnv:Y,pathExt:Z,pathExtExe:X}},k1=($,J,Q)=>{if(typeof J==="function")Q=J,J={};if(!J)J={};let{pathEnv:Y,pathExt:X,pathExtExe:Z}=b1($,J),W=[],K=(B)=>new Promise((z,V)=>{if(B===Y.length)return J.all&&W.length?z(W):V(A1($));let G=Y[B],F=/^".*"$/.test(G)?G.slice(1,-1):G,R=v1.join(F,$),T=!F&&/^\.[\\\/]/.test($)?$.slice(0,2)+R:R;z(H(T,B,0))}),H=(B,z,V)=>new Promise((G,F)=>{if(V===X.length)return G(K(z+1));let R=X[V];y1(B+R,{pathExt:Z},(T,S)=>{if(!T&&S)if(J.all)W.push(B+R);else return G(B+R);return G(H(B,z,V+1))})});return Q?K(0).then((B)=>Q(null,B),Q):K(0)},m$=($,J)=>{J=J||{};let{pathEnv:Q,pathExt:Y,pathExtExe:X}=b1($,J),Z=[];for(let W=0;W<Q.length;W++){let K=Q[W],H=/^".*"$/.test(K)?K.slice(1,-1):K,B=v1.join(H,$),z=!H&&/^\.[\\\/]/.test($)?$.slice(0,2)+B:B;for(let V=0;V<Y.length;V++){let G=z+Y[V];try{if(y1.sync(G,{pathExt:X}))if(J.all)Z.push(G);else return G}catch(F){}}}if(J.all&&Z.length)return Z;if(J.nothrow)return null;throw A1($)};h1.exports=k1;k1.sync=m$});var c1=P((QQ,d0)=>{var u1=($={})=>{let J=$.env||process.env;if(($.platform||process.platform)!=="win32")return"PATH";return Object.keys(J).reverse().find((Y)=>Y.toUpperCase()==="PATH")||"Path"};d0.exports=u1;d0.exports.default=u1});var i1=P((YQ,p1)=>{var m1=j("path"),l$=g1(),p$=c1();function l1($,J){let Q=$.options.env||process.env,Y=process.cwd(),X=$.options.cwd!=null,Z=X&&process.chdir!==void 0&&!process.chdir.disabled;if(Z)try{process.chdir($.options.cwd)}catch(K){}let W;try{W=l$.sync($.command,{path:Q[p$({env:Q})],pathExt:J?m1.delimiter:void 0})}catch(K){}finally{if(Z)process.chdir(Y)}if(W)W=m1.resolve(X?$.options.cwd:"",W);return W}function i$($){return l1($)||l1($,!0)}p1.exports=i$});var d1=P((a$,a0)=>{var n0=/([()\][%!^"`<>&|;, *?])/g;function d$($){return $=$.replace(n0,"^$1"),$}function n$($,J){if($=`${$}`,$=$.replace(/(?=(\\+?)?)\1"/g,"$1$1\\\""),$=$.replace(/(?=(\\+?)?)\1$/,"$1$1"),$=`"${$}"`,$=$.replace(n0,"^$1"),J)$=$.replace(n0,"^$1");return $}a$.command=d$;a$.argument=n$});var a1=P((XQ,n1)=>{n1.exports=/^#!(.*)/});var t1=P((ZQ,o1)=>{var r$=a1();o1.exports=($="")=>{let J=$.match(r$);if(!J)return null;let[Q,Y]=J[0].replace(/#! ?/,"").split(" "),X=Q.split("/").pop();if(X==="env")return Y;return Y?`${X} ${Y}`:X}});var s1=P((WQ,r1)=>{var o0=j("fs"),s$=t1();function e$($){let Q=Buffer.alloc(150),Y;try{Y=o0.openSync($,"r"),o0.readSync(Y,Q,0,150,0),o0.closeSync(Y)}catch(X){}return s$(Q.toString())}r1.exports=e$});var Q8=P((KQ,J8)=>{var $9=j("path"),e1=i1(),$8=d1(),J9=s1(),Q9=process.platform==="win32",Y9=/\.(?:com|exe)$/i,X9=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Z9($){$.file=e1($);let J=$.file&&J9($.file);if(J)return $.args.unshift($.file),$.command=J,e1($);return $.file}function W9($){if(!Q9)return $;let J=Z9($),Q=!Y9.test(J);if($.options.forceShell||Q){let Y=X9.test(J);$.command=$9.normalize($.command),$.command=$8.command($.command),$.args=$.args.map((Z)=>$8.argument(Z,Y));let X=[$.command].concat($.args).join(" ");$.args=["/d","/s","/c",`"${X}"`],$.command=process.env.comspec||"cmd.exe",$.options.windowsVerbatimArguments=!0}return $}function K9($,J,Q){if(J&&!Array.isArray(J))Q=J,J=null;J=J?J.slice(0):[],Q=Object.assign({},Q);let Y={command:$,args:J,options:Q,file:void 0,original:{command:$,args:J}};return Q.shell?Y:W9(Y)}J8.exports=K9});var Z8=P((VQ,X8)=>{var t0=process.platform==="win32";function r0($,J){return Object.assign(Error(`${J} ${$.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${J} ${$.command}`,path:$.command,spawnargs:$.args})}function V9($,J){if(!t0)return;let Q=$.emit;$.emit=function(Y,X){if(Y==="exit"){let Z=Y8(X,J);if(Z)return Q.call($,"error",Z)}return Q.apply($,arguments)}}function Y8($,J){if(t0&&$===1&&!J.file)return r0(J.original,"spawn");return null}function z9($,J){if(t0&&$===1&&!J.file)return r0(J.original,"spawnSync");return null}X8.exports={hookChildProcess:V9,verifyENOENT:Y8,verifyENOENTSync:z9,notFoundError:r0}});var $1=P((zQ,W0)=>{var W8=j("child_process"),s0=Q8(),e0=Z8();function K8($,J,Q){let Y=s0($,J,Q),X=W8.spawn(Y.command,Y.args,Y.options);return e0.hookChildProcess(X,Y),X}function G9($,J,Q){let Y=s0($,J,Q),X=W8.spawnSync(Y.command,Y.args,Y.options);return X.error=X.error||e0.verifyENOENTSync(X.status,Y),X}W0.exports=K8;W0.exports.spawn=K8;W0.exports.sync=G9;W0.exports._parse=s0;W0.exports._enoent=e0});var H8=P((GQ,G8)=>{var{homedir:V8}=j("node:os"),{join:O0}=j("node:path");function z8(){if(process.env.LODESTAR_DATA_DIR)return process.env.LODESTAR_DATA_DIR;if(process.env.XDG_DATA_HOME)return O0(process.env.XDG_DATA_HOME,"lodestar");if(process.platform==="win32")return O0(process.env.LOCALAPPDATA??O0(V8(),"AppData","Local"),"Lodestar");return O0(V8(),".local","share","lodestar")}function H9(){return O0(z8(),"managed-claude-plugin")}G8.exports={lodestarDataDir:z8,managedClaudePluginDir:H9}});var D8=P((eQ,E8)=>{var G0=1000,H0=G0*60,B0=H0*60,s=B0*24,b9=s*7,k9=s*365.25;E8.exports=function($,J){J=J||{};var Q=typeof $;if(Q==="string"&&$.length>0)return h9($);else if(Q==="number"&&isFinite($))return J.long?u9($):g9($);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify($))};function h9($){if($=String($),$.length>100)return;var J=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec($);if(!J)return;var Q=parseFloat(J[1]),Y=(J[2]||"ms").toLowerCase();switch(Y){case"years":case"year":case"yrs":case"yr":case"y":return Q*k9;case"weeks":case"week":case"w":return Q*b9;case"days":case"day":case"d":return Q*s;case"hours":case"hour":case"hrs":case"hr":case"h":return Q*B0;case"minutes":case"minute":case"mins":case"min":case"m":return Q*H0;case"seconds":case"second":case"secs":case"sec":case"s":return Q*G0;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return Q;default:return}}function g9($){var J=Math.abs($);if(J>=s)return Math.round($/s)+"d";if(J>=B0)return Math.round($/B0)+"h";if(J>=H0)return Math.round($/H0)+"m";if(J>=G0)return Math.round($/G0)+"s";return $+"ms"}function u9($){var J=Math.abs($);if(J>=s)return E0($,J,s,"day");if(J>=B0)return E0($,J,B0,"hour");if(J>=H0)return E0($,J,H0,"minute");if(J>=G0)return E0($,J,G0,"second");return $+" ms"}function E0($,J,Q,Y){var X=J>=Q*1.5;return Math.round($/Q)+" "+Y+(X?"s":"")}});var Z1=P(($Y,f8)=>{function c9($){Q.debug=Q,Q.default=Q,Q.coerce=H,Q.disable=W,Q.enable=X,Q.enabled=K,Q.humanize=D8(),Q.destroy=B,Object.keys($).forEach((z)=>{Q[z]=$[z]}),Q.names=[],Q.skips=[],Q.formatters={};function J(z){let V=0;for(let G=0;G<z.length;G++)V=(V<<5)-V+z.charCodeAt(G),V|=0;return Q.colors[Math.abs(V)%Q.colors.length]}Q.selectColor=J;function Q(z){let V,G=null,F,R;function T(...S){if(!T.enabled)return;let i=T,b=Number(new Date),a=b-(V||b);if(i.diff=a,i.prev=V,i.curr=b,V=b,S[0]=Q.coerce(S[0]),typeof S[0]!=="string")S.unshift("%O");let n=0;S[0]=S[0].replace(/%([a-zA-Z%])/g,(o,Y0)=>{if(o==="%%")return"%";n++;let L1=Q.formatters[Y0];if(typeof L1==="function"){let w$=S[n];o=L1.call(i,w$),S.splice(n,1),n--}return o}),Q.formatArgs.call(i,S),(i.log||Q.log).apply(i,S)}if(T.namespace=z,T.useColors=Q.useColors(),T.color=Q.selectColor(z),T.extend=Y,T.destroy=Q.destroy,Object.defineProperty(T,"enabled",{enumerable:!0,configurable:!1,get:()=>{if(G!==null)return G;if(F!==Q.namespaces)F=Q.namespaces,R=Q.enabled(z);return R},set:(S)=>{G=S}}),typeof Q.init==="function")Q.init(T);return T}function Y(z,V){let G=Q(this.namespace+(typeof V>"u"?":":V)+z);return G.log=this.log,G}function X(z){Q.save(z),Q.namespaces=z,Q.names=[],Q.skips=[];let V=(typeof z==="string"?z:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let G of V)if(G[0]==="-")Q.skips.push(G.slice(1));else Q.names.push(G)}function Z(z,V){let G=0,F=0,R=-1,T=0;while(G<z.length)if(F<V.length&&(V[F]===z[G]||V[F]==="*"))if(V[F]==="*")R=F,T=G,F++;else G++,F++;else if(R!==-1)F=R+1,T++,G=T;else return!1;while(F<V.length&&V[F]==="*")F++;return F===V.length}function W(){let z=[...Q.names,...Q.skips.map((V)=>"-"+V)].join(",");return Q.enable(""),z}function K(z){for(let V of Q.skips)if(Z(z,V))return!1;for(let V of Q.names)if(Z(z,V))return!0;return!1}function H(z){if(z instanceof Error)return z.stack||z.message;return z}function B(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return Q.enable(Q.load()),Q}f8.exports=c9});var x8=P((_8,D0)=>{_8.formatArgs=l9;_8.save=p9;_8.load=i9;_8.useColors=m9;_8.storage=d9();_8.destroy=(()=>{let $=!1;return()=>{if(!$)$=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}})();_8.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function m9(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let $;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&($=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt($[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function l9($){if($[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+$[0]+(this.useColors?"%c ":" ")+"+"+D0.exports.humanize(this.diff),!this.useColors)return;let J="color: "+this.color;$.splice(1,0,J,"color: inherit");let Q=0,Y=0;$[0].replace(/%[a-zA-Z%]/g,(X)=>{if(X==="%%")return;if(Q++,X==="%c")Y=Q}),$.splice(Y,0,J)}_8.log=console.debug||console.log||(()=>{});function p9($){try{if($)_8.storage.setItem("debug",$);else _8.storage.removeItem("debug")}catch(J){}}function i9(){let $;try{$=_8.storage.getItem("debug")||_8.storage.getItem("DEBUG")}catch(J){}if(!$&&typeof process<"u"&&"env"in process)$=process.env.DEBUG;return $}function d9(){try{return localStorage}catch($){}}D0.exports=Z1()(_8);var{formatters:n9}=D0.exports;n9.j=function($){try{return JSON.stringify($)}catch(J){return"[UnexpectedJSONParseError]: "+J.message}}});var b8=P((y8,_0)=>{var J4=j("tty"),f0=j("util");y8.init=V4;y8.log=Z4;y8.formatArgs=Y4;y8.save=W4;y8.load=K4;y8.useColors=Q4;y8.destroy=f0.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");y8.colors=[6,2,3,4,5,1];try{let $=(()=>{throw new Error("Cannot require module "+"supports-color");})();if($&&($.stderr||$).level>=2)y8.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221]}catch($){}y8.inspectOpts=Object.keys(process.env).filter(($)=>{return/^debug_/i.test($)}).reduce(($,J)=>{let Q=J.substring(6).toLowerCase().replace(/_([a-z])/g,(X,Z)=>{return Z.toUpperCase()}),Y=process.env[J];if(/^(yes|on|true|enabled)$/i.test(Y))Y=!0;else if(/^(no|off|false|disabled)$/i.test(Y))Y=!1;else if(Y==="null")Y=null;else Y=Number(Y);return $[Q]=Y,$},{});function Q4(){return"colors"in y8.inspectOpts?Boolean(y8.inspectOpts.colors):J4.isatty(process.stderr.fd)}function Y4($){let{namespace:J,useColors:Q}=this;if(Q){let Y=this.color,X="\x1B[3"+(Y<8?Y:"8;5;"+Y),Z=` ${X};1m${J} \x1B[0m`;$[0]=Z+$[0].split(`
|
|
3
|
+
`).join(`
|
|
4
|
+
`+Z),$.push(X+"m+"+_0.exports.humanize(this.diff)+"\x1B[0m")}else $[0]=X4()+J+" "+$[0]}function X4(){if(y8.inspectOpts.hideDate)return"";return new Date().toISOString()+" "}function Z4(...$){return process.stderr.write(f0.formatWithOptions(y8.inspectOpts,...$)+`
|
|
5
|
+
`)}function W4($){if($)process.env.DEBUG=$;else delete process.env.DEBUG}function K4(){return process.env.DEBUG}function V4($){$.inspectOpts={};let J=Object.keys(y8.inspectOpts);for(let Q=0;Q<J.length;Q++)$.inspectOpts[J[Q]]=y8.inspectOpts[J[Q]]}_0.exports=Z1()(y8);var{formatters:v8}=_0.exports;v8.o=function($){return this.inspectOpts.colors=this.useColors,f0.inspect($,this.inspectOpts).split(`
|
|
6
|
+
`).map((J)=>J.trim()).join(" ")};v8.O=function($){return this.inspectOpts.colors=this.useColors,f0.inspect($,this.inspectOpts)}});var x0=P((YY,W1)=>{if(typeof process>"u"||process.type==="renderer"||!1||process.__nwjs)W1.exports=x8();else W1.exports=b8()});var g8=P((E)=>{var O4=E&&E.__createBinding||(Object.create?function($,J,Q,Y){if(Y===void 0)Y=Q;var X=Object.getOwnPropertyDescriptor(J,Q);if(!X||("get"in X?!J.__esModule:X.writable||X.configurable))X={enumerable:!0,get:function(){return J[Q]}};Object.defineProperty($,Y,X)}:function($,J,Q,Y){if(Y===void 0)Y=Q;$[Y]=J[Q]}),N4=E&&E.__setModuleDefault||(Object.create?function($,J){Object.defineProperty($,"default",{enumerable:!0,value:J})}:function($,J){$.default=J}),k8=E&&E.__importStar||function($){if($&&$.__esModule)return $;var J={};if($!=null){for(var Q in $)if(Q!=="default"&&Object.prototype.hasOwnProperty.call($,Q))O4(J,$,Q)}return N4(J,$),J};Object.defineProperty(E,"__esModule",{value:!0});E.req=E.json=E.toBuffer=void 0;var P4=k8(j("http")),L4=k8(j("https"));async function h8($){let J=0,Q=[];for await(let Y of $)J+=Y.length,Q.push(Y);return Buffer.concat(Q,J)}E.toBuffer=h8;async function j4($){let Q=(await h8($)).toString("utf8");try{return JSON.parse(Q)}catch(Y){let X=Y;throw X.message+=` (input: ${Q})`,X}}E.json=j4;function R4($,J={}){let Y=((typeof $==="string"?$:$.href).startsWith("https:")?L4:P4).request($,J),X=new Promise((Z,W)=>{Y.once("response",Z).once("error",W).end()});return Y.then=X.then.bind(X),Y}E.req=R4});var K1=P((_)=>{var c8=_&&_.__createBinding||(Object.create?function($,J,Q,Y){if(Y===void 0)Y=Q;var X=Object.getOwnPropertyDescriptor(J,Q);if(!X||("get"in X?!J.__esModule:X.writable||X.configurable))X={enumerable:!0,get:function(){return J[Q]}};Object.defineProperty($,Y,X)}:function($,J,Q,Y){if(Y===void 0)Y=Q;$[Y]=J[Q]}),U4=_&&_.__setModuleDefault||(Object.create?function($,J){Object.defineProperty($,"default",{enumerable:!0,value:J})}:function($,J){$.default=J}),m8=_&&_.__importStar||function($){if($&&$.__esModule)return $;var J={};if($!=null){for(var Q in $)if(Q!=="default"&&Object.prototype.hasOwnProperty.call($,Q))c8(J,$,Q)}return U4(J,$),J},T4=_&&_.__exportStar||function($,J){for(var Q in $)if(Q!=="default"&&!Object.prototype.hasOwnProperty.call(J,Q))c8(J,$,Q)};Object.defineProperty(_,"__esModule",{value:!0});_.Agent=void 0;var I4=m8(j("net")),u8=m8(j("http")),C4=j("https");T4(g8(),_);var h=Symbol("AgentBaseInternalState");class l8 extends u8.Agent{constructor($){super($);this[h]={}}isSecureEndpoint($){if($){if(typeof $.secureEndpoint==="boolean")return $.secureEndpoint;if(typeof $.protocol==="string")return $.protocol==="https:"}let{stack:J}=Error();if(typeof J!=="string")return!1;return J.split(`
|
|
7
|
+
`).some((Q)=>Q.indexOf("(https.js:")!==-1||Q.indexOf("node:https:")!==-1)}incrementSockets($){if(this.maxSockets===1/0&&this.maxTotalSockets===1/0)return null;if(!this.sockets[$])this.sockets[$]=[];let J=new I4.Socket({writable:!1});return this.sockets[$].push(J),this.totalSocketCount++,J}decrementSockets($,J){if(!this.sockets[$]||J===null)return;let Q=this.sockets[$],Y=Q.indexOf(J);if(Y!==-1){if(Q.splice(Y,1),this.totalSocketCount--,Q.length===0)delete this.sockets[$]}}getName($){if(this.isSecureEndpoint($))return C4.Agent.prototype.getName.call(this,$);return super.getName($)}createSocket($,J,Q){let Y={...J,secureEndpoint:this.isSecureEndpoint(J)},X=this.getName(Y),Z=this.incrementSockets(X);Promise.resolve().then(()=>this.connect($,Y)).then((W)=>{if(this.decrementSockets(X,Z),W instanceof u8.Agent)try{return W.addRequest($,Y)}catch(K){return Q(K)}this[h].currentSocket=W,super.createSocket($,J,Q)},(W)=>{this.decrementSockets(X,Z),Q(W)})}createConnection(){let $=this[h].currentSocket;if(this[h].currentSocket=void 0,!$)throw Error("No socket was returned in the `connect()` function");return $}get defaultPort(){return this[h].defaultPort??(this.protocol==="https:"?443:80)}set defaultPort($){if(this[h])this[h].defaultPort=$}get protocol(){return this[h].protocol??(this.isSecureEndpoint()?"https:":"http:")}set protocol($){if(this[h])this[h].protocol=$}}_.Agent=l8});var d8=P((v)=>{var S4=v&&v.__createBinding||(Object.create?function($,J,Q,Y){if(Y===void 0)Y=Q;var X=Object.getOwnPropertyDescriptor(J,Q);if(!X||("get"in X?!J.__esModule:X.writable||X.configurable))X={enumerable:!0,get:function(){return J[Q]}};Object.defineProperty($,Y,X)}:function($,J,Q,Y){if(Y===void 0)Y=Q;$[Y]=J[Q]}),w4=v&&v.__setModuleDefault||(Object.create?function($,J){Object.defineProperty($,"default",{enumerable:!0,value:J})}:function($,J){$.default=J}),i8=v&&v.__importStar||function($){if($&&$.__esModule)return $;var J={};if($!=null){for(var Q in $)if(Q!=="default"&&Object.prototype.hasOwnProperty.call($,Q))S4(J,$,Q)}return w4(J,$),J},E4=v&&v.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(v,"__esModule",{value:!0});v.HttpProxyAgent=void 0;var D4=i8(j("net")),f4=i8(j("tls")),_4=E4(x0()),x4=j("events"),v4=K1(),p8=j("url"),q0=(0,_4.default)("http-proxy-agent");class V1 extends v4.Agent{constructor($,J){super(J);this.proxy=typeof $==="string"?new p8.URL($):$,this.proxyHeaders=J?.headers??{},q0("Creating new HttpProxyAgent instance: %o",this.proxy.href);let Q=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,""),Y=this.proxy.port?parseInt(this.proxy.port,10):this.proxy.protocol==="https:"?443:80;this.connectOpts={...J?y4(J,"headers"):null,host:Q,port:Y}}addRequest($,J){$._header=null,this.setRequestProps($,J),super.addRequest($,J)}setRequestProps($,J){let{proxy:Q}=this,Y=J.secureEndpoint?"https:":"http:",X=$.getHeader("host")||"localhost",Z=`${Y}//${X}`,W=new p8.URL($.path,Z);if(J.port!==80)W.port=String(J.port);$.path=String(W);let K=typeof this.proxyHeaders==="function"?this.proxyHeaders():{...this.proxyHeaders};if(Q.username||Q.password){let H=`${decodeURIComponent(Q.username)}:${decodeURIComponent(Q.password)}`;K["Proxy-Authorization"]=`Basic ${Buffer.from(H).toString("base64")}`}if(!K["Proxy-Connection"])K["Proxy-Connection"]=this.keepAlive?"Keep-Alive":"close";for(let H of Object.keys(K)){let B=K[H];if(B)$.setHeader(H,B)}}async connect($,J){if($._header=null,!$.path.includes("://"))this.setRequestProps($,J);let Q,Y;if(q0("Regenerating stored HTTP header string for request"),$._implicitHeader(),$.outputData&&$.outputData.length>0)q0("Patching connection write() output buffer with updated header"),Q=$.outputData[0].data,Y=Q.indexOf(`\r
|
|
8
|
+
\r
|
|
9
|
+
`)+4,$.outputData[0].data=$._header+Q.substring(Y),q0("Output buffer: %o",$.outputData[0].data);let X;if(this.proxy.protocol==="https:")q0("Creating `tls.Socket`: %o",this.connectOpts),X=f4.connect(this.connectOpts);else q0("Creating `net.Socket`: %o",this.connectOpts),X=D4.connect(this.connectOpts);return await(0,x4.once)(X,"connect"),X}}V1.protocols=["http","https"];v.HttpProxyAgent=V1;function y4($,...J){let Q={},Y;for(Y in $)if(!J.includes(Y))Q[Y]=$[Y];return Q}});var n8=P((M0)=>{var A4=M0&&M0.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(M0,"__esModule",{value:!0});M0.parseProxyResponse=void 0;var b4=A4(x0()),v0=(0,b4.default)("https-proxy-agent:parse-proxy-response");function k4($){return new Promise((J,Q)=>{let Y=0,X=[];function Z(){let z=$.read();if(z)B(z);else $.once("readable",Z)}function W(){$.removeListener("end",K),$.removeListener("error",H),$.removeListener("readable",Z)}function K(){W(),v0("onend"),Q(Error("Proxy connection ended before receiving CONNECT response"))}function H(z){W(),v0("onerror %o",z),Q(z)}function B(z){X.push(z),Y+=z.length;let V=Buffer.concat(X,Y),G=V.indexOf(`\r
|
|
10
|
+
\r
|
|
11
|
+
`);if(G===-1){v0("have not received end of HTTP headers yet..."),Z();return}let F=V.slice(0,G).toString("ascii").split(`\r
|
|
12
|
+
`),R=F.shift();if(!R)return $.destroy(),Q(Error("No header received from proxy CONNECT response"));let T=R.split(" "),S=+T[1],i=T.slice(2).join(" "),b={};for(let a of F){if(!a)continue;let n=a.indexOf(":");if(n===-1)return $.destroy(),Q(Error(`Invalid header from proxy CONNECT response: "${a}"`));let U0=a.slice(0,n).toLowerCase(),o=a.slice(n+1).trimStart(),Y0=b[U0];if(typeof Y0==="string")b[U0]=[Y0,o];else if(Array.isArray(Y0))Y0.push(o);else b[U0]=o}v0("got proxy server response: %o %o",R,b),W(),J({connect:{statusCode:S,statusText:i,headers:b},buffered:V})}$.on("error",H),$.on("end",K),Z()})}M0.parseProxyResponse=k4});var e8=P((y)=>{var h4=y&&y.__createBinding||(Object.create?function($,J,Q,Y){if(Y===void 0)Y=Q;var X=Object.getOwnPropertyDescriptor(J,Q);if(!X||("get"in X?!J.__esModule:X.writable||X.configurable))X={enumerable:!0,get:function(){return J[Q]}};Object.defineProperty($,Y,X)}:function($,J,Q,Y){if(Y===void 0)Y=Q;$[Y]=J[Q]}),g4=y&&y.__setModuleDefault||(Object.create?function($,J){Object.defineProperty($,"default",{enumerable:!0,value:J})}:function($,J){$.default=J}),r8=y&&y.__importStar||function($){if($&&$.__esModule)return $;var J={};if($!=null){for(var Q in $)if(Q!=="default"&&Object.prototype.hasOwnProperty.call($,Q))h4(J,$,Q)}return g4(J,$),J},s8=y&&y.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(y,"__esModule",{value:!0});y.HttpsProxyAgent=void 0;var y0=r8(j("net")),a8=r8(j("tls")),u4=s8(j("assert")),c4=s8(x0()),m4=K1(),l4=j("url"),p4=n8(),j0=(0,c4.default)("https-proxy-agent"),o8=($)=>{if($.servername===void 0&&$.host&&!y0.isIP($.host))return{...$,servername:$.host};return $};class z1 extends m4.Agent{constructor($,J){super(J);this.options={path:void 0},this.proxy=typeof $==="string"?new l4.URL($):$,this.proxyHeaders=J?.headers??{},j0("Creating new HttpsProxyAgent instance: %o",this.proxy.href);let Q=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,""),Y=this.proxy.port?parseInt(this.proxy.port,10):this.proxy.protocol==="https:"?443:80;this.connectOpts={ALPNProtocols:["http/1.1"],...J?t8(J,"headers"):null,host:Q,port:Y}}async connect($,J){let{proxy:Q}=this;if(!J.host)throw TypeError('No "host" provided');let Y;if(Q.protocol==="https:")j0("Creating `tls.Socket`: %o",this.connectOpts),Y=a8.connect(o8(this.connectOpts));else j0("Creating `net.Socket`: %o",this.connectOpts),Y=y0.connect(this.connectOpts);let X=typeof this.proxyHeaders==="function"?this.proxyHeaders():{...this.proxyHeaders},Z=y0.isIPv6(J.host)?`[${J.host}]`:J.host,W=`CONNECT ${Z}:${J.port} HTTP/1.1\r
|
|
13
|
+
`;if(Q.username||Q.password){let V=`${decodeURIComponent(Q.username)}:${decodeURIComponent(Q.password)}`;X["Proxy-Authorization"]=`Basic ${Buffer.from(V).toString("base64")}`}if(X.Host=`${Z}:${J.port}`,!X["Proxy-Connection"])X["Proxy-Connection"]=this.keepAlive?"Keep-Alive":"close";for(let V of Object.keys(X))W+=`${V}: ${X[V]}\r
|
|
14
|
+
`;let K=(0,p4.parseProxyResponse)(Y);Y.write(`${W}\r
|
|
15
|
+
`);let{connect:H,buffered:B}=await K;if($.emit("proxyConnect",H),this.emit("proxyConnect",H,$),H.statusCode===200){if($.once("socket",i4),J.secureEndpoint)return j0("Upgrading socket connection to TLS"),a8.connect({...t8(o8(J),"host","path","port"),socket:Y});return Y}Y.destroy();let z=new y0.Socket({writable:!1});return z.readable=!0,$.once("socket",(V)=>{j0("Replaying proxy buffer for failed request"),(0,u4.default)(V.listenerCount("data")>0),V.push(B),V.push(null)}),z}}z1.protocols=["http","https"];y.HttpsProxyAgent=z1;function i4($){$.resume()}function t8($,...J){let Q={},Y;for(Y in $)if(!J.includes(Y))Q[Y]=$[Y];return Q}});var R0=P((J$)=>{Object.defineProperty(J$,"__esModule",{value:!0});J$.AddressError=void 0;class $$ extends Error{constructor($,J){super($);this.name="AddressError",this.parseMessage=J}}J$.AddressError=$$});var A0=P((X$)=>{Object.defineProperty(X$,"__esModule",{value:!0});X$.isInSubnet=d4;X$.isHostInSubnet=G1;X$.isGloballyReachable=n4;X$.offsetBigInt=a4;X$.isCorrect=o4;X$.prefixLengthFromMask=t4;X$.assertByteArray=r4;X$.numberToPaddedHex=Y$;X$.stringToPaddedHex=s4;X$.testBit=e4;var $0=R0();function d4($){if(this.subnetMask<$.subnetMask)return!1;return G1.call(this,$)}function G1($){if(this.binaryZeroPad().length!==$.binaryZeroPad().length)return!1;return this.mask($.subnetMask)===$.mask()}function n4($){let J=null;for(let Q=0;Q<$.length;Q++){let Y=$[Q];if(Y.reachable!==null&&G1.call(this,Y.subnet)&&(J===null||Y.subnet.subnetMask>J.subnet.subnetMask))J=Y}return J===null?!0:J.reachable}function a4($,J,Q,Y){if(typeof J==="number"&&!Number.isSafeInteger(J))throw new $0.AddressError(`${Y} offset must be an integer`);if(typeof J!=="number"&&typeof J!=="bigint")throw new $0.AddressError(`${Y} offset must be an integer`);let X=$+BigInt(J);if(X<BigInt(0)||X>(BigInt(1)<<BigInt(Q))-BigInt(1))throw new $0.AddressError(`${Y} offset leaves the address space`);return X}function o4($){return function(){if(this.addressMinusSuffix!==this.correctForm())return!1;if(this.subnetMask===$&&!this.parsedSubnet)return!0;return this.parsedSubnet===String(this.subnetMask)}}function t4($,J){let Q=$.toString(2).padStart(J,"0");if(Q.length>J)throw new $0.AddressError("Invalid subnet mask.");let Y=Q.indexOf("0");if(Y===-1)return J;if(Q.slice(Y).includes("1"))throw new $0.AddressError("Invalid subnet mask.");return Y}function r4($,J,Q,Y){if($.length!==J)throw new $0.AddressError(`${Q} addresses require exactly ${J} bytes`);for(let X=0;X<$.length;X++)if(!Number.isInteger($[X])||$[X]<Y||$[X]>255)throw new $0.AddressError(`All bytes must be integers between ${Y} and 255`)}function Y$($){return $.toString(16).padStart(2,"0")}function s4($){return Y$(parseInt($,10))}function e4($,J){let{length:Q}=$;if(J>Q)return!1;let Y=Q-J;return $.substring(Y,Y+1)==="1"}});var H1=P((Z$)=>{Object.defineProperty(Z$,"__esModule",{value:!0});Z$.SPECIAL_PURPOSE=Z$.RE_SUBNET_STRING=Z$.RE_ADDRESS=Z$.GROUPS=Z$.BITS=void 0;Z$.BITS=32;Z$.GROUPS=4;Z$.RE_ADDRESS=/^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$/g;Z$.RE_SUBNET_STRING=/\/\d{1,2}$/;Z$.SPECIAL_PURPOSE=[["0.0.0.0/8","This network",!1],["0.0.0.0/32","This host on this network",!1],["10.0.0.0/8","Private-Use",!1],["100.64.0.0/10","Shared Address Space",!1],["127.0.0.0/8","Loopback",!1],["169.254.0.0/16","Link Local",!1],["172.16.0.0/12","Private-Use",!1],["192.0.0.0/24","IETF Protocol Assignments",!1],["192.0.0.0/29","IPv4 Service Continuity Prefix",!1],["192.0.0.8/32","IPv4 dummy address",!1],["192.0.0.9/32","Port Control Protocol Anycast",!0],["192.0.0.10/32","Traversal Using Relays around NAT Anycast",!0],["192.0.0.170/32","NAT64/DNS64 Discovery",!1],["192.0.0.171/32","NAT64/DNS64 Discovery",!1],["192.0.2.0/24","Documentation (TEST-NET-1)",!1],["192.31.196.0/24","AS112-v4",!0],["192.52.193.0/24","AMT",!0],["192.88.99.0/24","Deprecated (6to4 Relay Anycast)",null],["192.88.99.2/32","6a44-relay anycast address",!1],["192.168.0.0/16","Private-Use",!1],["192.175.48.0/24","Direct Delegation AS112 Service",!0],["198.18.0.0/15","Benchmarking",!1],["198.51.100.0/24","Documentation (TEST-NET-2)",!1],["203.0.113.0/24","Documentation (TEST-NET-3)",!1],["240.0.0.0/4","Reserved",!1],["255.255.255.255/32","Limited Broadcast",!1]]});var B1=P((u)=>{var M6=u&&u.__createBinding||(Object.create?function($,J,Q,Y){if(Y===void 0)Y=Q;var X=Object.getOwnPropertyDescriptor(J,Q);if(!X||("get"in X?!J.__esModule:X.writable||X.configurable))X={enumerable:!0,get:function(){return J[Q]}};Object.defineProperty($,Y,X)}:function($,J,Q,Y){if(Y===void 0)Y=Q;$[Y]=J[Q]}),F6=u&&u.__setModuleDefault||(Object.create?function($,J){Object.defineProperty($,"default",{enumerable:!0,value:J})}:function($,J){$.default=J}),K$=u&&u.__importStar||function($){if($&&$.__esModule)return $;var J={};if($!=null){for(var Q in $)if(Q!=="default"&&Object.prototype.hasOwnProperty.call($,Q))M6(J,$,Q)}return F6(J,$),J};Object.defineProperty(u,"__esModule",{value:!0});u.Address4=void 0;var x=K$(A0()),U=K$(H1()),g=R0(),O6=x.isCorrect(U.BITS);class O{constructor($){this.addressMinusSuffix="",this.groups=U.GROUPS,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=O6,this.isInSubnet=x.isInSubnet,this.isHostInSubnet=x.isHostInSubnet,this.address=$;let J=U.RE_SUBNET_STRING.exec($);if(J){if(this.parsedSubnet=J[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,this.subnetMask<0||this.subnetMask>U.BITS)throw new g.AddressError("Invalid subnet mask.");$=$.replace(U.RE_SUBNET_STRING,"")}let Q=U.GROUPS*4-1;if($.length>Q)throw new g.AddressError(`IPv4 addresses are at most ${Q} characters.`);this.addressMinusSuffix=$,this.parsedAddress=this.parse($)}static isValid($){try{return new O($),!0}catch{return!1}}parse($){let J=$.split(".");if(J.some((Q)=>/^0\d/.test(Q)))throw new g.AddressError("IPv4 addresses can't have leading zeroes.");if(!$.match(U.RE_ADDRESS))throw new g.AddressError("Invalid IPv4 address.");return J}correctForm(){return this.parsedAddress.map(($)=>parseInt($,10)).join(".")}static fromAddressAndMask($,J){let Q=x.prefixLengthFromMask(new O(J).bigInt(),U.BITS);return new O(`${$}/${Q}`)}static fromAddressAndWildcardMask($,J){let Q=new O(J).bigInt(),Y=(BigInt(1)<<BigInt(U.BITS))-BigInt(1),X=Q^Y,Z=x.prefixLengthFromMask(X,U.BITS);return new O(`${$}/${Z}`)}static fromWildcard($){let J=$.split(".");if(J.length!==U.GROUPS)throw new g.AddressError("Wildcard pattern must have 4 octets");let Q=-1;for(let W=0;W<J.length;W++)if(J[W]==="*"){if(Q===-1)Q=W}else if(Q!==-1)throw new g.AddressError("Wildcard `*` must only appear in trailing octets (e.g. `192.168.0.*`)");let Y=Q===-1?0:J.length-Q,X=J.map((W)=>W==="*"?"0":W),Z=U.BITS-Y*8;return new O(`${X.join(".")}/${Z}`)}static fromHex($){let J=$.replace(/:/g,"");if(!/^[0-9a-fA-F]{8}$/.test(J))throw new g.AddressError("IPv4 hex must be exactly 8 hex digits");let Q=[];for(let Y=0;Y<8;Y+=2)Q.push(parseInt(J.slice(Y,Y+2),16));return new O(Q.join("."))}static fromInteger($){if(!Number.isInteger($)||$<0||$>4294967295)throw new g.AddressError("IPv4 integer must be in the range 0 to 2**32 - 1");return O.fromHex($.toString(16).padStart(8,"0"))}static fromArpa($){let Q=$.replace(/(\.in-addr\.arpa)?\.?$/i,"").split(".").reverse().join(".");return new O(Q)}toHex(){return this.parsedAddress.map(($)=>x.stringToPaddedHex($)).join(":")}toArray(){return this.parsedAddress.map(($)=>parseInt($,10))}toGroup6(){let $=[],J;for(J=0;J<U.GROUPS;J+=2)$.push(`${x.stringToPaddedHex(this.parsedAddress[J])}${x.stringToPaddedHex(this.parsedAddress[J+1])}`);return $.join(":")}bigInt(){return BigInt(`0x${this.parsedAddress.map(($)=>x.stringToPaddedHex($)).join("")}`)}_startAddress(){return BigInt(`0b${this.mask()+"0".repeat(U.BITS-this.subnetMask)}`)}startAddress(){return O.fromBigInt(this._startAddress())}startAddressExclusive(){let $=BigInt("1");return O.fromBigInt(this._startAddress()+$)}offset($){return O.fromBigInt(x.offsetBigInt(this.bigInt(),$,U.BITS,"IPv4")).withSubnetMask(this.subnetMask)}nextNetwork(){return O.fromBigInt(x.offsetBigInt(this._endAddress(),1,U.BITS,"IPv4")).withSubnetMask(this.subnetMask)}withSubnetMask($){return new O(`${this.correctForm()}/${$}`)}_endAddress(){return BigInt(`0b${this.mask()+"1".repeat(U.BITS-this.subnetMask)}`)}endAddress(){return O.fromBigInt(this._endAddress())}endAddressExclusive(){let $=BigInt("1");return O.fromBigInt(this._endAddress()-$)}subnetMaskAddress(){return O.fromBigInt(BigInt(`0b${"1".repeat(this.subnetMask)}${"0".repeat(U.BITS-this.subnetMask)}`))}wildcardMask(){return O.fromBigInt(BigInt(`0b${"0".repeat(this.subnetMask)}${"1".repeat(U.BITS-this.subnetMask)}`))}networkForm(){return`${this.startAddress().correctForm()}/${this.subnetMask}`}static fromBigInt($){if($<BigInt(0)||$>BigInt(4294967295))throw new g.AddressError("IPv4 BigInt must be in the range 0 to 2**32 - 1");return O.fromHex($.toString(16).padStart(8,"0"))}static fromByteArray($){return x.assertByteArray($,4,"IPv4",0),this.fromUnsignedByteArray($)}static fromUnsignedByteArray($){if($.length!==4)throw new g.AddressError("IPv4 addresses require exactly 4 bytes");let J=$.join(".");return new O(J)}mask($){if($===void 0)$=this.subnetMask;return this.getBitsBase2(0,$)}getBitsBase2($,J){return this.binaryZeroPad().slice($,J)}reverseForm($){if(!$)$={};let J=this.correctForm().split(".").reverse().join(".");if($.omitSuffix)return J;return`${J}.in-addr.arpa.`}isMulticast(){return this.isHostInSubnet(N6)}isPrivate(){return P6.some(($)=>this.isHostInSubnet($))}isLoopback(){return this.isHostInSubnet(L6)}isLinkLocal(){return this.isHostInSubnet(j6)}isUnspecified(){return this.isHostInSubnet(R6)}isBroadcast(){return this.isHostInSubnet(U6)}isCGNAT(){return this.isHostInSubnet(T6)}isDocumentation(){return I6.some(($)=>this.isHostInSubnet($))}isBenchmarking(){return this.isHostInSubnet(C6)}isReserved(){return this.isHostInSubnet(S6)}isGlobal(){return!this.isMulticast()&&x.isGloballyReachable.call(this,w6)}binaryZeroPad(){if(this._binaryZeroPad===void 0)this._binaryZeroPad=this.bigInt().toString(2).padStart(U.BITS,"0");return this._binaryZeroPad}groupForV6(){let $=this.parsedAddress;return this.correctForm().replace(U.RE_ADDRESS,`<span class="hover-group group-v4 group-6">${$.slice(0,2).join(".")}</span>.<span class="hover-group group-v4 group-7">${$.slice(2,4).join(".")}</span>`)}}u.Address4=O;var N6=new O("224.0.0.0/4"),P6=[new O("10.0.0.0/8"),new O("172.16.0.0/12"),new O("192.168.0.0/16")],L6=new O("127.0.0.0/8"),j6=new O("169.254.0.0/16"),R6=new O("0.0.0.0/32"),U6=new O("255.255.255.255/32"),T6=new O("100.64.0.0/10"),I6=[new O("192.0.2.0/24"),new O("198.51.100.0/24"),new O("203.0.113.0/24")],C6=new O("198.18.0.0/15"),S6=new O("240.0.0.0/4"),w6=U.SPECIAL_PURPOSE.map(([$,,J])=>({subnet:new O($),reachable:J}))});var q1=P((V$)=>{Object.defineProperty(V$,"__esModule",{value:!0});V$.SPECIAL_PURPOSE=V$.RE_URL_WITH_PORT=V$.RE_URL=V$.RE_ZONE_STRING=V$.RE_SUBNET_STRING=V$.RE_BAD_ADDRESS=V$.RE_BAD_CHARACTERS=V$.TYPES=V$.SCOPES=V$.GROUPS=V$.BITS=void 0;V$.BITS=128;V$.GROUPS=8;V$.SCOPES={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"};V$.TYPES={"ff01::1/128":"Multicast (All nodes on this interface)","ff01::2/128":"Multicast (All routers on this interface)","ff02::1/128":"Multicast (All nodes on this link)","ff02::2/128":"Multicast (All routers on this link)","ff05::2/128":"Multicast (All routers in this site)","ff02::5/128":"Multicast (OSPFv3 AllSPF routers)","ff02::6/128":"Multicast (OSPFv3 AllDR routers)","ff02::9/128":"Multicast (RIP routers)","ff02::a/128":"Multicast (EIGRP routers)","ff02::d/128":"Multicast (PIM routers)","ff02::16/128":"Multicast (MLDv2 reports)","ff01::fb/128":"Multicast (mDNSv6)","ff02::fb/128":"Multicast (mDNSv6)","ff05::fb/128":"Multicast (mDNSv6)","ff02::1:2/128":"Multicast (All DHCP servers and relay agents on this link)","ff05::1:2/128":"Multicast (All DHCP servers and relay agents in this site)","ff02::1:3/128":"Multicast (All DHCP servers on this link)","ff05::1:3/128":"Multicast (All DHCP servers in this site)","::/128":"Unspecified","::1/128":"Loopback","::ffff:0:0/96":"IPv4-mapped","ff00::/8":"Multicast","fe80::/10":"Link-local unicast","fc00::/7":"Unique local","2001::/32":"Teredo","2001:2::/48":"Benchmarking","2002::/16":"6to4","2001:db8::/32":"Documentation","3fff::/20":"Documentation","100::/64":"Discard-only","fec0::/10":"Site-local unicast (deprecated)","::/96":"IPv4-compatible (deprecated)","64:ff9b::/96":"NAT64 (well-known)","64:ff9b:1::/48":"NAT64 (local-use)"};V$.RE_BAD_CHARACTERS=/([^0-9a-f:/%])/gi;V$.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi;V$.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/;V$.RE_ZONE_STRING=/%.*$/;V$.RE_URL=/^(?:\[([0-9a-f:.]+)\]|([0-9a-f:.]+))(?:[/?#].*)?$/i;V$.RE_URL_WITH_PORT=/^\[([0-9a-f:.]+)\]:([0-9]{1,5})(?:[/?#].*)?$/i;V$.SPECIAL_PURPOSE=[["::1/128","Loopback Address",!1],["::/128","Unspecified Address",!1],["::ffff:0:0/96","IPv4-mapped Address",!1],["64:ff9b::/96","IPv4-IPv6 Translat.",!0],["64:ff9b:1::/48","IPv4-IPv6 Translat.",!1],["100::/64","Discard-Only Address Block",!1],["100:0:0:1::/64","Dummy IPv6 Prefix",!1],["2001::/23","IETF Protocol Assignments",!1],["2001::/32","TEREDO",!1],["2001:1::1/128","Port Control Protocol Anycast",!0],["2001:1::2/128","Traversal Using Relays around NAT Anycast",!0],["2001:1::3/128","DNS-SD Service Registration Protocol Anycast",!0],["2001:2::/48","Benchmarking",!1],["2001:3::/32","AMT",!0],["2001:4:112::/48","AS112-v6",!0],["2001:10::/28","Deprecated (previously ORCHID)",null],["2001:20::/28","ORCHIDv2",!0],["2001:30::/28","Drone Remote ID Protocol Entity Tags (DETs) Prefix",!0],["2001:db8::/32","Documentation",!1],["2002::/16","6to4",!1],["2620:4f:8000::/48","Direct Delegation AS112 Service",!0],["3fff::/20","Documentation",!1],["5f00::/16","Segment Routing (SRv6) SIDs",!1],["fc00::/7","Unique-Local",!1],["fe80::/10","Link-Local Unicast",!1]]});var M1=P((B$)=>{Object.defineProperty(B$,"__esModule",{value:!0});B$.escapeHtml=b0;B$.spanAllZeroes=G$;B$.spanAll=h6;B$.spanLeadingZeroes=g6;B$.simpleGroup=u6;function b0($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function G$($){return b0($).replace(/(0+)/g,'<span class="zero">$1</span>')}function h6($,J=0){return $.split("").map((Y,X)=>`<span class="digit value-${b0(Y)} position-${X+J}">${G$(Y)}</span>`).join("")}function H$($){return b0($).replace(/^(0+)/,'<span class="zero">$1</span>')}function g6($){return $.split(":").map((Q)=>H$(Q)).join(":")}function u6($,J=0){return $.split(":").map((Y,X)=>{if(/group-v4/.test(Y))return Y;return`<span class="hover-group group-${X+J}">${H$(Y)}</span>`})}});var q$=P((D)=>{var d6=D&&D.__createBinding||(Object.create?function($,J,Q,Y){if(Y===void 0)Y=Q;var X=Object.getOwnPropertyDescriptor(J,Q);if(!X||("get"in X?!J.__esModule:X.writable||X.configurable))X={enumerable:!0,get:function(){return J[Q]}};Object.defineProperty($,Y,X)}:function($,J,Q,Y){if(Y===void 0)Y=Q;$[Y]=J[Q]}),n6=D&&D.__setModuleDefault||(Object.create?function($,J){Object.defineProperty($,"default",{enumerable:!0,value:J})}:function($,J){$.default=J}),a6=D&&D.__importStar||function($){if($&&$.__esModule)return $;var J={};if($!=null){for(var Q in $)if(Q!=="default"&&Object.prototype.hasOwnProperty.call($,Q))d6(J,$,Q)}return n6(J,$),J};Object.defineProperty(D,"__esModule",{value:!0});D.ADDRESS_BOUNDARY=void 0;D.groupPossibilities=h0;D.padGroup=k0;D.simpleRegularExpression=t6;D.possibleElisions=r6;var o6=a6(q1());function h0($){return`(${$.join("|")})`}function k0($){if($.length<4)return`0{0,${4-$.length}}${$}`;return $}D.ADDRESS_BOUNDARY="[^A-Fa-f0-9:]";function t6($){let J=[];$.forEach((Y,X)=>{if(parseInt(Y,16)===0)J.push(X)});let Q=J.map((Y)=>$.map((X,Z)=>{if(Z===Y){let W=Z===0||Z===o6.GROUPS-1?":":"";return h0([k0(X),W])}return k0(X)}).join(":"));return Q.push($.map(k0).join(":")),h0(Q)}function r6($,J,Q){let Y=J?"":":",X=Q?"":":",Z=[];if(!J&&!Q)Z.push("::");if(J&&Q)Z.push("");if(Q&&!J||!Q&&J)Z.push(":");Z.push(`${Y}(:0{1,4}){1,${$-1}}`),Z.push(`(0{1,4}:){1,${$-1}}${X}`),Z.push(`(0{1,4}:){${$-1}}0{1,4}`);for(let W=1;W<$-1;W++)for(let K=1;K<$-W;K++)Z.push(`(0{1,4}:){${K}}:(0{1,4}:){${$-K-W-1}}0{1,4}`);return h0(Z)}});var N$=P((l)=>{var s6=l&&l.__createBinding||(Object.create?function($,J,Q,Y){if(Y===void 0)Y=Q;var X=Object.getOwnPropertyDescriptor(J,Q);if(!X||("get"in X?!J.__esModule:X.writable||X.configurable))X={enumerable:!0,get:function(){return J[Q]}};Object.defineProperty($,Y,X)}:function($,J,Q,Y){if(Y===void 0)Y=Q;$[Y]=J[Q]}),e6=l&&l.__setModuleDefault||(Object.create?function($,J){Object.defineProperty($,"default",{enumerable:!0,value:J})}:function($,J){$.default=J}),c0=l&&l.__importStar||function($){if($&&$.__esModule)return $;var J={};if($!=null){for(var Q in $)if(Q!=="default"&&Object.prototype.hasOwnProperty.call($,Q))s6(J,$,Q)}return e6(J,$),J};Object.defineProperty(l,"__esModule",{value:!0});l.Address6=void 0;var m=c0(A0()),F1=c0(H1()),M=c0(q1()),J0=c0(M1()),c=B1(),Q0=q$(),C=R0(),g0=A0(),$J=m.isCorrect(M.BITS);function u0($){if(!$)throw Error("Assertion failed.")}function JJ($){let J=/(\d+)(\d{3})/;while(J.test($))$=$.replace(J,"$1,$2");return $}function QJ($){return $=$.replace(/^(0{1,})([1-9]+)$/,'<span class="parse-error">$1</span>$2'),$=$.replace(/^(0{1,})(0)$/,'<span class="parse-error">$1</span>$2'),$}function YJ($,J){let Q=[],Y=[],X;for(X=0;X<$.length;X++)if(X<J[0])Q.push($[X]);else if(X>J[1])Y.push($[X]);return Q.concat(["compact"]).concat(Y)}function M$($){return parseInt($,16).toString(16).padStart(4,"0")}function F$($){return $&255}class q{constructor($,J){if(this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=m.isInSubnet,this.isHostInSubnet=m.isHostInSubnet,this.isCorrect=$J,J===void 0)this.groups=M.GROUPS;else this.groups=J;this.address=$;let Q=M.RE_SUBNET_STRING.exec($);if(Q){if(this.parsedSubnet=Q[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,Number.isNaN(this.subnetMask)||this.subnetMask<0||this.subnetMask>M.BITS)throw new C.AddressError("Invalid subnet mask.");$=$.replace(M.RE_SUBNET_STRING,"")}if(/\//.test($))throw new C.AddressError("Invalid subnet mask.");let Y=M.RE_ZONE_STRING.exec($);if(Y)this.zone=Y[0],$=$.replace(M.RE_ZONE_STRING,"");let X=this.groups*5+5;if($.length>X)throw new C.AddressError(`IPv6 addresses are at most ${X} characters.`);this.addressMinusSuffix=$,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid($){try{return new q($),!0}catch{return!1}}static fromBigInt($){if($<BigInt(0)||$>(BigInt(1)<<BigInt(M.BITS))-BigInt(1))throw new C.AddressError("IPv6 BigInt must be in the range 0 to 2**128 - 1");let J=$.toString(16).padStart(32,"0"),Q=[];for(let Y=0;Y<M.GROUPS;Y++)Q.push(J.slice(Y*4,(Y+1)*4));return new q(Q.join(":"))}static fromURL($){var J;let Q,Y=null,X,Z,W=$.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"");if(W.indexOf("[")!==-1&&W.indexOf("]:")!==-1){if(Z="failed to parse address with port",X=M.RE_URL_WITH_PORT.exec(W),X===null)return{error:Z,address:null,port:null};Q=X[1],Y=X[2]}else{if(Z="failed to parse address from URL",X=M.RE_URL.exec(W),X===null)return{error:Z,address:null,port:null};Q=(J=X[1])!==null&&J!==void 0?J:X[2]}if(Y){if(Y=parseInt(Y,10),Y<0||Y>65535)Y=null}else Y=null;let K;try{K=new q(Q)}catch{return{error:Z,address:null,port:null}}return{address:K,port:Y}}static fromAddressAndMask($,J){let Q=m.prefixLengthFromMask(new q(J).bigInt(),M.BITS);return new q(`${$}/${Q}`)}static fromAddressAndWildcardMask($,J){let Q=new q(J).bigInt(),Y=(BigInt(1)<<BigInt(M.BITS))-BigInt(1),X=Q^Y,Z=m.prefixLengthFromMask(X,M.BITS);return new q(`${$}/${Z}`)}static fromWildcard($){if($.includes("%")||$.includes("/"))throw new C.AddressError("Wildcard pattern must not include a zone or CIDR suffix");let J=$.split("::");if(J.length>2)throw new C.AddressError("Wildcard pattern cannot contain more than one '::'");let Q;if(J.length===2){let K=J[0]===""?[]:J[0].split(":"),H=J[1]===""?[]:J[1].split(":"),B=M.GROUPS-K.length-H.length;if(B<1)throw new C.AddressError("Wildcard pattern with '::' has too many groups");Q=[...K,...Array(B).fill("0"),...H]}else Q=$.split(":");if(Q.length!==M.GROUPS)throw new C.AddressError("Wildcard pattern must have 8 groups");let Y=-1;for(let K=0;K<Q.length;K++)if(Q[K]==="*"){if(Y===-1)Y=K}else if(Y!==-1)throw new C.AddressError("Wildcard `*` must only appear in trailing groups (e.g. `2001:db8:*:*:*:*:*:*`)");let X=Y===-1?0:Q.length-Y,Z=Q.map((K)=>K==="*"?"0":K),W=M.BITS-X*16;return new q(`${Z.join(":")}/${W}`)}static fromAddress4($){let J=new c.Address4($),Q=M.BITS-(F1.BITS-J.subnetMask);return new q(`::ffff:${J.correctForm()}/${Q}`)}static fromArpa($){let J=$.replace(/(\.ip6\.arpa)?\.?$/i,"");if(!/^[0-9a-f](\.[0-9a-f]){0,31}$/i.test(J))throw new C.AddressError("Invalid 'ip6.arpa' form.");let Q=J.split(".").reverse(),Y=Q.length*4,X=Q.join("").padEnd(32,"0"),Z=[];for(let W=0;W<M.GROUPS;W++)Z.push(X.slice(W*4,(W+1)*4));return new q(`${Z.join(":")}/${Y}`)}microsoftTranscription(){return`${this.correctForm().replace(/:/g,"-")}.ipv6-literal.net`}mask($=this.subnetMask){return this.getBitsBase2(0,$)}possibleSubnets($=128){let J=M.BITS-this.subnetMask,Q=Math.abs($-M.BITS),Y=J-Q;if(Y<0)return"0";return JJ((BigInt("2")**BigInt(Y)).toString(10))}_startAddress(){return BigInt(`0b${this.mask()+"0".repeat(M.BITS-this.subnetMask)}`)}startAddress(){return q.fromBigInt(this._startAddress())}startAddressExclusive(){let $=BigInt("1");return q.fromBigInt(this._startAddress()+$)}_endAddress(){return BigInt(`0b${this.mask()+"1".repeat(M.BITS-this.subnetMask)}`)}endAddress(){return q.fromBigInt(this._endAddress())}endAddressExclusive(){let $=BigInt("1");return q.fromBigInt(this._endAddress()-$)}offset($){return q.fromBigInt(m.offsetBigInt(this.bigInt(),$,M.BITS,"IPv6")).withSubnetMask(this.subnetMask)}nextNetwork(){return q.fromBigInt(m.offsetBigInt(this._endAddress(),1,M.BITS,"IPv6")).withSubnetMask(this.subnetMask)}withSubnetMask($){return new q(`${this.correctForm()}/${$}`)}subnetMaskAddress(){return q.fromBigInt(BigInt(`0b${"1".repeat(this.subnetMask)}${"0".repeat(M.BITS-this.subnetMask)}`))}wildcardMask(){return q.fromBigInt(BigInt(`0b${"0".repeat(this.subnetMask)}${"1".repeat(M.BITS-this.subnetMask)}`))}networkForm(){return`${this.startAddress().correctForm()}/${this.subnetMask}`}getScope(){let $=this.getType();if($==="Multicast"||$.startsWith("Multicast "))return M.SCOPES[parseInt(this.getBits(12,16).toString(10),10)]||"Unknown";if($==="Link-local unicast"||$==="Loopback")return"Link local";if($==="Unspecified")return"Unknown";return"Global"}getType(){for(let $=0;$<O$.length;$++){let J=O$[$];if(this.isHostInSubnet(J[0]))return J[1]}return"Global unicast"}getBits($,J){return BigInt(`0b${this.getBitsBase2($,J)}`)}getBitsBase2($,J){return this.binaryZeroPad().slice($,J)}getBitsBase16($,J){let Q=J-$;if(Q%4!==0)throw Error("Length of bits to retrieve must be divisible by four");return this.getBits($,J).toString(16).padStart(Q/4,"0")}getBitsPastSubnet(){return this.getBitsBase2(this.subnetMask,M.BITS)}reverseForm($){if(!$)$={};let J=Math.floor(this.subnetMask/4),Q=this.canonicalForm().replace(/:/g,"").split("").slice(0,J).reverse().join(".");if(J>0){if($.omitSuffix)return Q;return`${Q}.ip6.arpa.`}if($.omitSuffix)return"";return"ip6.arpa."}correctForm(){let $,J=[],Q=0,Y=[];for($=0;$<this.parsedAddress.length;$++){let W=parseInt(this.parsedAddress[$],16);if(W===0)Q++;if(W!==0&&Q>0){if(Q>1)Y.push([$-Q,$-1]);Q=0}}if(Q>1)Y.push([this.parsedAddress.length-Q,this.parsedAddress.length-1]);let X=Y.map((W)=>W[1]-W[0]+1);if(Y.length>0){let W=X.indexOf(Math.max(...X));J=YJ(this.parsedAddress,Y[W])}else J=this.parsedAddress;for($=0;$<J.length;$++)if(J[$]!=="compact")J[$]=parseInt(J[$],16).toString(16);let Z=J.join(":");return Z=Z.replace(/^compact$/,"::"),Z=Z.replace(/(^compact)|(compact$)/,":"),Z=Z.replace(/compact/,""),Z}binaryZeroPad(){if(this._binaryZeroPad===void 0)this._binaryZeroPad=this.bigInt().toString(2).padStart(M.BITS,"0");return this._binaryZeroPad}parse4in6($){if($.indexOf(".")===-1)return $;let J=$.split(":"),Q=J.slice(-1)[0],Y=Q.split(".");if(Y.length===F1.GROUPS&&Y.every((Z)=>/^\d{1,3}$/.test(Z))){if(Y.some((Z)=>/^0\d/.test(Z))){let Z=Y.map(QJ).join("."),W=J.slice(0,-1).map(J0.escapeHtml).join(":"),K=J.length>1?":":"";throw new C.AddressError("IPv4 addresses can't have leading zeroes.",`${W}${K}${Z}`)}}let X=Q.match(F1.RE_ADDRESS);if(X){this.parsedAddress4=X[0];let Z=this.subnetMask>=96?`/${this.subnetMask-96}`:"";this.address4=new c.Address4(`${this.parsedAddress4}${Z}`),this.v4=!0,J[J.length-1]=this.address4.toGroup6(),$=J.join(":")}return $}parse($){$=this.parse4in6($);let J=$.match(M.RE_BAD_CHARACTERS);if(J)throw new C.AddressError(`Bad character${J.length>1?"s":""} detected in address: ${J.join("")}`,$.replace(M.RE_BAD_CHARACTERS,'<span class="parse-error">$1</span>'));let Q=$.match(M.RE_BAD_ADDRESS);if(Q)throw new C.AddressError(`Address failed regex: ${Q.join("")}`,$.replace(M.RE_BAD_ADDRESS,'<span class="parse-error">$1</span>'));let Y=[],X=$.split("::");if(X.length===2){let Z=X[0].split(":"),W=X[1].split(":");if(Z.length===1&&Z[0]==="")Z=[];if(W.length===1&&W[0]==="")W=[];let K=this.groups-(Z.length+W.length);if(!K)throw new C.AddressError("Error parsing groups");this.elidedGroups=K,this.elisionBegin=Z.length,this.elisionEnd=Z.length+this.elidedGroups,Y=Y.concat(Z);for(let H=0;H<K;H++)Y.push("0");Y=Y.concat(W)}else if(X.length===1)Y=$.split(":"),this.elidedGroups=0;else throw new C.AddressError("Too many :: groups found");if(Y=Y.map((Z)=>parseInt(Z,16).toString(16)),Y.length!==this.groups)throw new C.AddressError("Incorrect number of groups found");return Y}canonicalForm(){return this.parsedAddress.map(M$).join(":")}decimal(){return this.parsedAddress.map(($)=>parseInt($,16).toString(10).padStart(5,"0")).join(":")}bigInt(){return BigInt(`0x${this.parsedAddress.map(M$).join("")}`)}to4(){let $=this.binaryZeroPad().split(""),J=BigInt(`0b${$.slice(96,128).join("")}`).toString(16).padStart(8,"0");if(this.subnetMask>=96){let Q=this.subnetMask-96,Y=[];for(let X=0;X<8;X+=2)Y.push(parseInt(J.slice(X,X+2),16));return new c.Address4(`${Y.join(".")}/${Q}`)}return c.Address4.fromHex(J)}to4in6(){let $=this.to4(),Q=new q(this.parsedAddress.slice(0,6).join(":"),6).correctForm(),Y="";if(!/:$/.test(Q))Y=":";return Q+Y+$.correctForm()}inspectTeredo(){let $=this.getBitsBase16(0,32),Q=(this.getBits(80,96)^BigInt("0xffff")).toString(),Y=c.Address4.fromHex(this.getBitsBase16(32,64)),X=this.getBits(96,128),Z=c.Address4.fromHex((X^BigInt("0xffffffff")).toString(16).padStart(8,"0")),W=this.getBitsBase2(64,80),K=(0,g0.testBit)(W,15),H=(0,g0.testBit)(W,14),B=(0,g0.testBit)(W,8),z=(0,g0.testBit)(W,9),V=BigInt(`0b${W.slice(2,6)+W.slice(8,16)}`).toString(10);return{prefix:`${$.slice(0,4)}:${$.slice(4,8)}`,server4:Y.address,client4:Z.address,flags:W,coneNat:K,microsoft:{reserved:H,universalLocal:z,groupIndividual:B,nonce:V},udpPort:Q}}inspect6to4(){let $=this.getBitsBase16(0,16),J=c.Address4.fromHex(this.getBitsBase16(16,48));return{prefix:$.slice(0,4),gateway:J.address}}to6to4(){if(!this.is4())return null;let $=["2002",this.getBitsBase16(96,112),this.getBitsBase16(112,128),"","/16"].join(":");return new q($)}static fromAddress4Nat64($,J="64:ff9b::/96"){let Q=new c.Address4($),Y=new q(J),X=Y.subnetMask;if(X!==32&&X!==40&&X!==48&&X!==56&&X!==64&&X!==96)throw new C.AddressError("NAT64 prefix length must be 32, 40, 48, 56, 64, or 96");let Z=Y.binaryZeroPad(),W=Q.binaryZeroPad(),K;if(X===96)K=Z.slice(0,96)+W;else{let z=64-X;K=[Z.slice(0,X),W.slice(0,z),"00000000",W.slice(z),"0".repeat(56-(32-z))].join("")}let H=BigInt(`0b${K}`).toString(16).padStart(32,"0"),B=[];for(let z=0;z<8;z++)B.push(H.slice(z*4,(z+1)*4));return new q(B.join(":"))}toAddress4Nat64($="64:ff9b::/96"){let J=new q($),Q=J.subnetMask;if(Q!==32&&Q!==40&&Q!==48&&Q!==56&&Q!==64&&Q!==96)throw new C.AddressError("NAT64 prefix length must be 32, 40, 48, 56, 64, or 96");if(!this.isHostInSubnet(J))return null;let Y=this.binaryZeroPad(),X;if(Q===96)X=Y.slice(96,128);else{let W=64-Q;X=Y.slice(Q,Q+W)+Y.slice(72,72+(32-W))}let Z=[];for(let W=0;W<4;W++)Z.push(parseInt(X.slice(W*8,(W+1)*8),2).toString());return new c.Address4(Z.join("."))}toByteArray(){let $=this.bigInt().toString(16).padStart(M.BITS/4,"0"),J=[];for(let Q=0,Y=$.length;Q<Y;Q+=2)J.push(parseInt($.substring(Q,Q+2),16));return J}toUnsignedByteArray(){return this.toByteArray().map(F$)}static fromByteArray($){return m.assertByteArray($,16,"IPv6",-128),this.fromUnsignedByteArray($.map(F$))}static fromUnsignedByteArray($){m.assertByteArray($,16,"IPv6",0);let J=BigInt("256"),Q=BigInt("0"),Y=BigInt("1");for(let X=$.length-1;X>=0;X--)Q+=Y*BigInt($[X].toString(10)),Y*=J;return q.fromBigInt(Q)}isCanonical(){return this.addressMinusSuffix===this.canonicalForm()}isLinkLocal(){let $=this.embeddedIPv4();if($)return $.isLinkLocal();return this.isHostInSubnet(KJ)}isMulticast(){let $=this.embeddedIPv4();if($)return $.isMulticast();let J=this.getType();return J==="Multicast"||J.startsWith("Multicast ")}is4(){return this.v4}isMapped4(){return this.isHostInSubnet(BJ)}embeddedIPv4(){if(this.isMapped4()||this.isHostInSubnet(qJ))return this.to4();return null}isTeredo(){return this.isHostInSubnet(XJ)}is6to4(){return this.isHostInSubnet(ZJ)}isLoopback(){let $=this.embeddedIPv4();if($)return $.isLoopback();return this.getType()==="Loopback"}isULA(){return this.isHostInSubnet(WJ)}isPrivate(){let $=this.embeddedIPv4();if($)return $.isPrivate();return this.isULA()||this.isHostInSubnet(MJ)}isCGNAT(){let $=this.embeddedIPv4();if($)return $.isCGNAT();return!1}isBroadcast(){let $=this.embeddedIPv4();if($)return $.isBroadcast();return!1}isUnspecified(){let $=this.embeddedIPv4();if($)return $.isUnspecified();return this.getType()==="Unspecified"}isDocumentation(){return VJ.some(($)=>this.isHostInSubnet($))}isBenchmarking(){let $=this.embeddedIPv4();if($)return $.isBenchmarking();return this.isHostInSubnet(zJ)}isGlobal(){let $=this.embeddedIPv4();if($)return $.isGlobal();return this.isHostInSubnet(GJ)&&m.isGloballyReachable.call(this,HJ)}href($){if($===void 0)$="";else $=`:${$}`;return`http://[${this.correctForm()}]${$}/`}link($){if(!$)$={};if($.className===void 0)$.className="";if($.prefix===void 0)$.prefix="/#address=";if($.v4===void 0)$.v4=!1;let J=this.correctForm;if($.v4)J=this.to4in6;let Q=J.call(this),Y=J0.escapeHtml(`${$.prefix}${Q}`),X=J0.escapeHtml(Q);if($.className){let Z=J0.escapeHtml($.className);return`<a href="${Y}" class="${Z}">${X}</a>`}return`<a href="${Y}">${X}</a>`}group(){if(this.elidedGroups===0)return J0.simpleGroup(this.addressMinusSuffix).join(":");u0(typeof this.elidedGroups==="number"),u0(typeof this.elisionBegin==="number");let $=[],[J,Q]=this.addressMinusSuffix.split("::");if(J.length)$.push(...J0.simpleGroup(J));else $.push("");let Y=["hover-group"];for(let X=this.elisionBegin;X<this.elisionBegin+this.elidedGroups;X++)Y.push(`group-${X}`);if($.push(`<span class="${Y.join(" ")}"></span>`),Q.length)$.push(...J0.simpleGroup(Q,this.elisionEnd));else $.push("");if(this.is4())u0(this.address4 instanceof c.Address4),$.pop(),$.push(this.address4.groupForV6());return $.join(":")}regularExpressionString($=!1){let J=[],Q=new q(this.correctForm());if(Q.elidedGroups===0)J.push((0,Q0.simpleRegularExpression)(Q.parsedAddress));else if(Q.elidedGroups===M.GROUPS)J.push((0,Q0.possibleElisions)(M.GROUPS));else{let Y=Q.address.split("::");if(Y[0].length)J.push((0,Q0.simpleRegularExpression)(Y[0].split(":")));if(u0(typeof Q.elidedGroups==="number"),J.push((0,Q0.possibleElisions)(Q.elidedGroups,Y[0].length!==0,Y[1].length!==0)),Y[1].length)J.push((0,Q0.simpleRegularExpression)(Y[1].split(":")));J=[J.join(":")]}if(!$)J=["(?=^|",Q0.ADDRESS_BOUNDARY,"|[^\\w\\:])(",...J,")(?=[^\\w\\:]|",Q0.ADDRESS_BOUNDARY,"|$)"];return J.join("")}regularExpression($=!1){return new RegExp(this.regularExpressionString($),"i")}}l.Address6=q;var O$=Object.keys(M.TYPES).map(($)=>[new q($),M.TYPES[$]]),XJ=new q("2001::/32"),ZJ=new q("2002::/16"),WJ=new q("fc00::/7"),KJ=new q("fe80::/10"),VJ=[new q("2001:db8::/32"),new q("3fff::/20")],zJ=new q("2001:2::/48"),GJ=new q("2000::/3"),HJ=M.SPECIAL_PURPOSE.map(([$,,J])=>({subnet:new q($),reachable:J})),BJ=new q("::ffff:0:0/96"),qJ=new q("64:ff9b::/96"),MJ=new q("64:ff9b:1::/48")});var P$=P((w)=>{var FJ=w&&w.__createBinding||(Object.create?function($,J,Q,Y){if(Y===void 0)Y=Q;var X=Object.getOwnPropertyDescriptor(J,Q);if(!X||("get"in X?!J.__esModule:X.writable||X.configurable))X={enumerable:!0,get:function(){return J[Q]}};Object.defineProperty($,Y,X)}:function($,J,Q,Y){if(Y===void 0)Y=Q;$[Y]=J[Q]}),OJ=w&&w.__setModuleDefault||(Object.create?function($,J){Object.defineProperty($,"default",{enumerable:!0,value:J})}:function($,J){$.default=J}),NJ=w&&w.__importStar||function($){if($&&$.__esModule)return $;var J={};if($!=null){for(var Q in $)if(Q!=="default"&&Object.prototype.hasOwnProperty.call($,Q))FJ(J,$,Q)}return OJ(J,$),J};Object.defineProperty(w,"__esModule",{value:!0});w.v6=w.AddressError=w.Address6=w.Address4=void 0;var PJ=B1();Object.defineProperty(w,"Address4",{enumerable:!0,get:function(){return PJ.Address4}});var LJ=N$();Object.defineProperty(w,"Address6",{enumerable:!0,get:function(){return LJ.Address6}});var jJ=R0();Object.defineProperty(w,"AddressError",{enumerable:!0,get:function(){return jJ.AddressError}});var RJ=NJ(M1());w.v6={helpers:RJ}});var S$=X0($1(),1);import{realpathSync as I$}from"node:fs";import{constants as iJ}from"node:os";import{fileURLToPath as dJ}from"node:url";import{createHash as w9}from"node:crypto";import{lstatSync as E9,mkdirSync as L8,readFileSync as D9,realpathSync as U8,rmSync as f9,symlinkSync as _9}from"node:fs";import{homedir as x9}from"node:os";import{dirname as v9,isAbsolute as S0,join as f,relative as T8,resolve as I8,sep as y9}from"node:path";var I0=X0(H8(),1);import{homedir as B9}from"node:os";import{join as N}from"node:path";var J1=B9(),q9=process.platform==="win32";function M9($,J,Q){if($)return $;if(J)return N(J,"lodestar");return Q}function F9(){if(q9)return N(process.env.APPDATA??N(J1,"AppData","Roaming"),"Lodestar");return N(J1,".config","lodestar")}var O9=M9(process.env.LODESTAR_CONFIG_DIR,process.env.XDG_CONFIG_HOME,F9()),L=I0.lodestarDataDir(),qQ=process.env.LODESTAR_CONFIG??N(O9,"config.toml"),MQ=N(L,"daemon.pid"),FQ=N(L,"daemon.log"),OQ=N(L,"session-chat-map.json"),NQ=N(L,"session-resume-map.json"),PQ=N(L,"session-turns-map.json"),LQ=N(L,"session-model-map.json"),jQ=N(L,"session-activity.json"),RQ=N(L,"claude-translation-context"),UQ=N(L,"claude-translation-traces"),TQ=N(L,"temp-session-leases.json"),IQ=N(L,"tasklist-map.json"),CQ=N(L,"agent-runs"),SQ=N(L,"agent-project-client.json"),wQ=N(L,"agent-session-ids.json"),EQ=I0.managedClaudePluginDir(),DQ=N(L,"dsh"),fQ=N(L,"codex-accounts"),_Q=N(L,"codex-accounts.json"),xQ=N(L,"codex-quota-blocks.json"),B8=N(J1,".claude-accounts"),q8=N(L,"claude-accounts.json"),M8=N(L,"agent-runtimes"),vQ=N(L,"context-window-cache.json"),yQ=N(L,"notify-callbacks.json"),AQ=N(L,"alive-on-shutdown.json"),bQ=N(L,"inbox"),kQ=N(L,"file-deliveries"),hQ=N(L,"file-delivery-groups.json"),gQ=N(L,"debug.sock"),uQ=N(L,"debug-context.json");import{chmodSync as N9,closeSync as Q1,fsyncSync as F8,mkdirSync as P9,openSync as O8,renameSync as L9,unlinkSync as j9,writeFileSync as R9}from"node:fs";import{randomUUID as U9}from"node:crypto";import{dirname as N8}from"node:path";var T9=384;var I9=448;function C9($){let J=N8($);P9(J,{recursive:!0,mode:I9})}function S9($,J,Q){C9($);let Y=`${$}.${process.pid}.${U9()}.tmp`,X=null;try{X=O8(Y,"wx",Q),R9(X,J),F8(X),Q1(X),X=null,L9(Y,$);try{N9($,Q)}catch{}if(process.platform!=="win32"){let Z=null;try{Z=O8(N8($),"r"),F8(Z)}catch{}finally{if(Z!==null)try{Q1(Z)}catch{}}}}catch(Z){if(X!==null)try{Q1(X)}catch{}try{j9(Y)}catch{}throw Z}}function P8($,J){S9($,J,T9)}function K0($,J){P8($,JSON.stringify(J,null,2)+`
|
|
16
|
+
`)}var I="default",N0=["projects","tasks","file-history","plans"],V0=new Map,d=new Set,z0=new Map;function r($){try{return E9($)}catch(J){if(J.code!=="ENOENT")throw J;return null}}function k($){let J=I8($);if(r(J))return U8(J);let Q=v9(J);return Q===J?J:f(k(Q),T8(Q,J))}function X1($,J){let Q=T8($,J);return!Q||!S0(Q)&&Q!==".."&&!Q.startsWith(`..${y9}`)}function A9($,J){return X1($,J)||X1(J,$)}function C8($){return w9("sha256").update($).digest("hex")}function j8($){if($!==void 0&&(!$||!S0($)))throw Error("CLAUDE_CONFIG_DIR 必须为非空绝对路径;未设置时才使用原生默认目录");return $}function t($){return{id:$.id,name:$.name,...$.configDir!==void 0?{configDir:$.configDir}:{},state:$.state,generation:$.generation,...$.identity?{identity:$.identity}:{}}}function A($){return $.normalize("NFC").toLowerCase()}function Y1($){return!$.trim()||["default","默认"].includes(A($.trim()))}function P0($){if(!$||$!==$.trim()||$.length>80||/[\x00-\x1f\x7f/\\<>:"|?*]/.test($)||[".","..","default","默认"].includes(A($))||/[. ]$/.test($)||/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test($))throw Error("Claude 备注名须为 1–80 个字符,不能包含路径分隔符、控制字符或系统保留名称");return $.normalize("NFC")}function C0($){return`claude-${C8(A($)).slice(0,32)}`}function w0($){return Object.assign(Error($),{code:"CLAUDE_SUBSCRIPTION_AUTH_MISSING"})}function R8($){if(!$.subscriptionType?.trim()||$.apiProvider!=="firstParty"||$.apiKeySource&&$.apiKeySource!=="none")throw w0("Claude 账号未通过原生第一方订阅认证;请先在该账号目录完成 claude auth login");if(!$.email?.trim())throw w0("Claude 原生认证未返回稳定账号身份,不能收录或复用该账号的额度缓存");return C8(JSON.stringify([$.email.trim().normalize("NFC").toLowerCase(),$.organization?.trim().normalize("NFC")??""]))}class S8{home;root;stateFile;nativeConfigDir;authenticationCandidates=new WeakMap;constructor($={}){this.home=$.home??x9(),this.root=$.accountsDir??($.home?f($.home,".claude-accounts"):B8),this.stateFile=$.stateFile??q8,this.nativeConfigDir=j8(($.env??process.env).CLAUDE_CONFIG_DIR)}configureNativeEnv($){this.nativeConfigDir=j8($.CLAUDE_CONFIG_DIR)}namespace(){return JSON.stringify([this.nativeConfigDir??null])}sharedConfigDir(){return I8(this.nativeConfigDir||f(this.home,".claude"))}read(){let $=r(this.stateFile);if(!$)return{version:1,accounts:[]};if(!$.isFile()||$.isSymbolicLink())throw Error("Claude 账号记录必须为独立文件");let J=JSON.parse(D9(this.stateFile,"utf8")),Q=(K)=>K===void 0||typeof K==="string"&&/^[a-f0-9]{64}$/.test(K),Y=(K)=>Number.isSafeInteger(K)&&Number(K)>=0;if(!J||J.version!==1||!Array.isArray(J.accounts)||J.sharedConfigDir!==void 0&&(typeof J.sharedConfigDir!=="string"||!S0(J.sharedConfigDir))||J.native&&(typeof J.native.namespace!=="string"||!Y(J.native.generation)||!Q(J.native.identity)))throw Error("Claude 账号记录格式无效");let X=new Set,Z=new Set,W=new Set;if(J.native?.namespace===this.namespace()&&J.native.identity)W.add(J.native.identity);for(let K of J.accounts){if(!K||typeof K.name!=="string")throw Error("Claude 账号记录缺少备注名");if(P0(K.name),K.id!==C0(K.name)||X.has(K.id)||Z.has(A(K.name))||K.configDir!==f(this.root,K.name)||typeof K.directoryKey!=="string"||!S0(K.directoryKey)||!["enrolling","ready"].includes(K.state)||!Y(K.generation)||!Q(K.identity)||!Array.isArray(K.linked)||K.linked.some((H)=>!N0.includes(H))||new Set(K.linked).size!==K.linked.length||K.identity&&W.has(K.identity))throw Error("Claude 账号记录重复或无效");if(K.state==="ready"&&N0.some((H)=>!K.linked.includes(H)))throw Error("Claude ready 账号缺少共享目录完成记录");if(K.identity)W.add(K.identity);X.add(K.id),Z.add(A(K.name))}return J}native($){let J=$.native,Q=J?.namespace===this.namespace();return{id:I,name:"默认",...this.nativeConfigDir!==void 0?{configDir:this.nativeConfigDir}:{},state:"ready",generation:Q?J.generation:J?J.generation+1:0,...Q&&J?.identity?{identity:J.identity}:{}}}revisionOf($){return JSON.stringify([$.id,$.configDir??null,$.generation,$.identity??null])}list(){let $=this.read();return[this.native($),...$.accounts.filter((J)=>J.state==="ready").map(t)]}get($){let J=this.read();if($===I)return this.native(J);let Q=J.accounts.find((Y)=>Y.id===$);if(!Q)throw Error(`Claude 账号不存在:${$}`);return t(Q)}find($=""){if(Y1($))return this.get(I);let J=A(P0($)),Q=this.read().accounts.find((Y)=>A(Y.name)===J);if(!Q)throw Error(`Claude 账号尚未收录:${$};发送 hi ${$} 校验并收录`);return t(Q)}candidate($){if(Y1($))return this.get(I);let J=P0($),Q=this.read(),Y=Q.accounts.find((Z)=>A(Z.name)===A(J)),X=Y?t(Y):{id:C0(J),name:J,configDir:f(this.root,J),state:"candidate",generation:0};return this.inspect(X,Q,Y),X}revision($){return this.revisionOf(this.get($))}nativeCliEnv($,J){if(Y1($))return this.env(I,J);let Q=P0($),Y=this.read().accounts.find((Z)=>A(Z.name)===A(Q)),X=Y?t(Y):{id:C0(Q),name:Q,configDir:f(this.root,Q),state:"candidate",generation:0};return this.candidateEnv(X,J)}candidateEnv($,J){let Q={...J};if($.id===I){if(this.nativeConfigDir===void 0)delete Q.CLAUDE_CONFIG_DIR;else Q.CLAUDE_CONFIG_DIR=this.nativeConfigDir;Q.CLAUDE_SECURESTORAGE_CONFIG_DIR=this.nativeConfigDir??""}else{if($.id!==C0(P0($.name))||$.configDir!==f(this.root,$.name))throw Error("Claude 候选账号目录与备注不匹配");Q.CLAUDE_CONFIG_DIR=$.configDir,Q.CLAUDE_SECURESTORAGE_CONFIG_DIR=$.configDir}return Q}env($,J){if($===I)return this.candidateEnv({id:$,name:"默认",state:"ready",generation:0},J);let Q=this.get($);if(Q.state!=="ready")throw Error(`Claude 账号 ${Q.name} 尚在收录,不能启动任务或查询`);return this.prepareShared($),this.candidateEnv(Q,J)}inspect($,J,Q){let Y=$.configDir,X=r(Y);if(!X)throw Error(`Claude 账号目录不存在:${Y};请先在该目录完成原生登录`);if(X.isSymbolicLink()||!X.isDirectory())throw Error("Claude 额外账号目录必须为独立目录,不能是软链接");let Z=k(Y),W=k(this.sharedConfigDir());if(A9(Z,W))throw Error("Claude 额外账号目录与默认共享目录相同或存在祖先重叠,拒绝收录");if(X1(Z,k(this.stateFile)))throw Error("Claude 账号状态文件不能放在额外账号目录内部");if(Q&&Q.directoryKey!==Z)throw Error("Claude 账号目录实际位置已变化,拒绝复用旧账号记录");if(J.sharedConfigDir&&J.sharedConfigDir!==W)throw Error("Claude 默认共享目录已变化,不能把已收录历史自动改指向其他目录");let K=r(f(Y,".credentials.json"));if(K&&(K.isSymbolicLink()||!K.isFile()))throw Error("Claude 额外账号凭据必须为独立文件,不能复用其他目录的凭据链接");for(let H of N0){let B=f(W,H),z=r(B);if(z&&(z.isSymbolicLink()||!z.isDirectory()))throw Error(`Claude 默认共享目录不是独立目录:${H}`);let V=f(Y,H),G=r(V);if(!G){if(Q?.state==="ready"||Q?.linked.includes(H))throw Error(`Claude 已共享目录缺失:${H}`);continue}if(G.isSymbolicLink()){let F;try{F=U8(V)}catch{throw Error(`Claude 共享链接已损坏:${H}`)}if(F!==B)throw Error(`Claude 共享链接指向其他位置:${H}`)}else if(!G.isDirectory()||Q?.state==="ready"||Q?.linked.includes(H))throw Error(`Claude 共享目录已被替换,拒绝清理:${H}`)}return{directory:Z,shared:W}}prepareShared($){if($===I)return;let J=this.read(),Q=J.accounts.find((Y)=>Y.id===$);if(!Q||Q.state!=="ready")throw Error("Claude 账号尚未完成收录,请显式发送 hi 备注重试");if(this.inspect(Q,J,Q),d.has(Q.directoryKey))throw Error(`Claude 账号 ${Q.name} 正在校验收录,请稍后重试`)}acquireUse($){this.prepareShared($);let J=k($===I?this.sharedConfigDir():this.get($).configDir);if(d.has(J))throw Error("Claude 账号正在收录,不能同时启动任务或额度查询");return this.useDirectory(J)}acquireCandidateUse($){let J=k($.id===I?this.sharedConfigDir():$.configDir??"");this.candidateEnv($,{});let Q=this.authenticationCandidates.get($);if(!Q||Q.directory!==J||!d.has(J))throw Error("Claude 候选认证租约只能在该账号正在执行的收录回调中取得");let Y=Symbol($.id),X=this.useDirectory(J);return Q.leases.add(Y),()=>{X(),Q.leases.delete(Y)}}useDirectory($){let J=Symbol($),Q=z0.get($)??new Set;return Q.add(J),z0.set($,Q),()=>{if(Q.delete(J),!Q.size&&z0.get($)===Q)z0.delete($)}}observeIdentity($,J,Q){let Y=this.read(),X=$===I?this.native(Y):Y.accounts.find((K)=>K.id===$);if(!X)throw Error("Claude 账号身份查询完成时记录已不存在");if(X.state!=="ready")throw Error("Claude 账号尚未完成收录,不能发布普通身份查询结果");if(Q!==void 0&&this.revisionOf(X)!==Q)throw Object.assign(Error("Claude 账号身份已更新,忽略旧代次查询结果"),{code:"CLAUDE_ACCOUNT_REVISION_CHANGED"});let Z=R8(J),W=this.duplicate(Y,$,Z);if(W){if(X.identity){if(delete X.identity,X.generation++,$===I)Y.native={namespace:this.namespace(),generation:X.generation};K0(this.stateFile,Y)}throw w0(`Claude 账号与已收录账号「${W}」是同一订阅身份,不能重复使用`)}if(X.identity!==Z){if(X.identity=Z,X.generation++,$===I)Y.native={namespace:this.namespace(),generation:X.generation,identity:Z};K0(this.stateFile,Y)}return this.revisionOf(X)}duplicate($,J,Q){if(J!==I&&this.native($).identity===Q)return"默认";return $.accounts.find((Y)=>Y.id!==J&&Y.identity===Q)?.name}enroll($,J){let Q=k(this.stateFile),X=(V0.get(Q)??Promise.resolve()).catch(()=>{}).then(()=>this.enrollExclusive($,J));return V0.set(Q,X),X.then(()=>{if(V0.get(Q)===X)V0.delete(Q)},()=>{if(V0.get(Q)===X)V0.delete(Q)}),X}async authenticateCandidate($,J){let Q={directory:k($.id===I?this.sharedConfigDir():$.configDir),leases:new Set};this.authenticationCandidates.set($,Q);try{let Y=await J($);if(Q.leases.size)throw Error("Claude 原生认证连接退出尚未确认,保留账号占用且不清理历史");return Y}finally{this.authenticationCandidates.delete($)}}async enrollExclusive($,J){let Q=this.candidate($);if(Q.id===I){let X=k(this.sharedConfigDir());if(d.has(X))throw Error("Claude 默认账号正在收录校验");d.add(X);try{let Z=this.revision(I),W=await this.authenticateCandidate(Q,J);return this.observeIdentity(I,W,Z),this.get(I)}finally{d.delete(X)}}let Y=k(Q.configDir);if(z0.get(Y)?.size||d.has(Y))throw Error(`Claude 账号 ${Q.name} 正在使用或收录,结束任务和查询后再试`);d.add(Y);try{let X=await this.authenticateCandidate(t(Q),J);if(z0.get(Y)?.size)throw Error("Claude 原生认证连接退出尚未确认,保留账号占用且不清理历史");let Z=R8(X),W=this.read(),K=W.accounts.find((G)=>G.id===Q.id),{directory:H,shared:B}=this.inspect(Q,W,K);if(H!==Y)throw Error("Claude 认证期间账号目录已被替换,拒绝清理历史");if(K?.state==="ready")return this.observeIdentity(K.id,X,this.revisionOf(Q)),this.get(K.id);let z=this.duplicate(W,Q.id,Z);if(z)throw w0(`Claude 账号与已收录账号「${z}」是同一订阅身份,未清理该目录的历史`);let V=K??{...Q,configDir:Q.configDir,state:"enrolling",directoryKey:H,linked:[]};if(V.identity!==Z)V.identity=Z,V.generation++;if(!K)W.accounts.push(V);W.sharedConfigDir=B,K0(this.stateFile,W),L8(B,{recursive:!0,mode:448});for(let G of N0)L8(f(B,G),{recursive:!0,mode:448});for(let G of N0){this.inspect(V,W,V);let F=f(V.configDir,G),R=r(F);if(!R?.isSymbolicLink()){if(R)f9(F,{recursive:!0});_9(f(B,G),F,process.platform==="win32"?"junction":"dir")}if(!V.linked.includes(G))V.linked.push(G);K0(this.stateFile,W)}return V.state="ready",K0(this.stateFile,W),t(V)}finally{d.delete(Y)}}}var w8=new S8;import{Agent as AJ}from"node:http";import{Agent as bJ}from"node:https";var kJ=X0(d8(),1),hJ=X0(e8(),1);var p=X0(P$(),1);import{execFile as UJ}from"node:child_process";import{readFile as TJ}from"node:fs/promises";import{homedir as IJ}from"node:os";import{join as L$}from"node:path";import{promisify as CJ}from"node:util";var SJ=CJ(UJ);function F0($,J){return $[J.toLowerCase()]?.trim()||$[J]?.trim()||void 0}function N1($){let J=$.hostname.replace(/^\[|\]$/g,"").toLowerCase();return J==="localhost"||J.endsWith(".localhost")||J==="::1"||/^127\.(?:\d{1,3}\.){2}\d{1,3}$/.test(J)||/^::ffff:(?:127\.|7f[0-9a-f]{2}:)/.test(J)}function O1($,J=""){let Q=$.hostname.replace(/^\[|\]$/g,"").toLowerCase(),Y=$.port||($.protocol==="https:"?"443":"80");return J.split(/[,;\s]+/).filter(Boolean).some((X)=>{let Z=X.toLowerCase();if(Z==="*")return!0;if(Z==="<local>")return!Q.includes(".")&&!Q.includes(":");if(Z.includes("/")){let H=Z.match(/^(\d{1,3}(?:\.\d{1,3}){0,2})\/(\d{1,2})$/),B=H?`${H[1]}${".0".repeat(4-H[1].split(".").length)}/${H[2]}`:Z;if(p.Address4.isValid(B))return p.Address4.isValid(Q)&&new p.Address4(Q).isInSubnet(new p.Address4(B));if(p.Address6.isValid(Z))return p.Address6.isValid(Q)&&new p.Address6(Q).isInSubnet(new p.Address6(Z));throw Error("network proxy: invalid IP range in bypass list")}let W=Z.match(/^(\[[^\]]+\]|[^:]+):(\d+)$/);if(W&&W[2]!==Y)return!1;let K=(W?W[1]:Z).replace(/^\[|\]$/g,"").replace(/^\*?\./,"");return Q===K||Q.endsWith(`.${K}`)})}function j$($,J){let Q;try{Q=new URL($)}catch{throw Error(`network proxy: ${J} contains an invalid proxy URL`)}if(!["http:","https:"].includes(Q.protocol))throw Error(`network proxy: ${J} must use an HTTP(S) proxy; SOCKS and PAC are not supported`);if(!Q.hostname||Q.search||Q.hash||Q.pathname&&Q.pathname!=="/")throw Error(`network proxy: ${J} must contain a proxy host and port without a path or query`);return Q.href}function R$($,J,Q={}){if(!["http:","https:"].includes($.protocol))throw Error(`network: unsupported URL protocol ${$.protocol}`);if(N1($)||O1($,F0(J,"NO_PROXY")))return;let Y=$.protocol==="https:"?"HTTPS_PROXY":"HTTP_PROXY",X=F0(J,Y)||F0(J,"ALL_PROXY");if(X)return j$(X,"environment");if(Q.unsupported)throw Error(`network proxy: ${Q.unsupported}`);let Z=($.protocol==="https:"?Q.https:Q.http)||Q.all;if(!Z||O1($,Q.bypass))return;return j$(Z,"system settings")}function p0($,J,Q="http"){if(typeof $!=="string"||!$.trim()||!Number.isInteger(Number(J))||Number(J)<1||Number(J)>65535)throw Error("network proxy: system proxy has an invalid host or port");let Y=$.includes(":")&&!$.startsWith("[")?`[${$}]`:$;return`${Q}://${Y}:${J}`}function wJ($){if($.AutoConfigURL)return{unsupported:"Windows PAC proxy is not supported; configure a manual HTTP(S) proxy or proxy environment variables"};if(!$.ProxyEnable)return $.AutoDetect?{unsupported:"Windows automatic proxy discovery is not supported; configure a manual HTTP(S) proxy or proxy environment variables"}:{};if(typeof $.ProxyServer!=="string"||!$.ProxyServer.trim())throw Error("network proxy: Windows proxy is enabled without a server");let J={bypass:String($.ProxyOverride??"")};for(let Q of $.ProxyServer.split(";").map((Y)=>Y.trim()).filter(Boolean)){let Y=Q.match(/^(http|https|socks)=(.+)$/i),X=Y?Y[2]:Q,Z=/^[a-z][\w+.-]*:\/\//i.test(X)?X:`http://${X}`;if(!Y)J.all=Z;else if(Y[1].toLowerCase()==="socks")J.all=`socks://${X.replace(/^socks\w*:\/\//,"")}`;else J[Y[1].toLowerCase()]=Z}return J}function EJ($){let J=(X)=>$.match(new RegExp(`^\\s*${X}\\s*:\\s*(.*?)\\s*$`,"m"))?.[1];if(J("ProxyAutoConfigEnable")==="1"||J("ProxyAutoDiscoveryEnable")==="1")return{unsupported:"macOS PAC/automatic proxy discovery is not supported; configure a manual HTTP(S) proxy or proxy environment variables"};let Q={};if(J("HTTPEnable")==="1")Q.http=p0(J("HTTPProxy"),J("HTTPPort"));if(J("HTTPSEnable")==="1")Q.https=p0(J("HTTPSProxy"),J("HTTPSPort"));if(J("SOCKSEnable")==="1")Q.all=p0(J("SOCKSProxy"),J("SOCKSPort"),"socks");if(!Q.http&&!Q.https&&!Q.all)return Q;let Y=$.match(/ExceptionsList\s*:\s*<array>\s*\{([^}]*)\}/)?.[1]??"";if(Q.bypass=[...Y.matchAll(/^\s*\d+\s*:\s*(.*?)\s*$/gm)].map((X)=>X[1]).join(","),J("ExcludeSimpleHostnames")==="1")Q.bypass+=",<local>";return Q}function m0($){if($===void 0)return"";if(!/^(['"]).*\1$/.test($))throw Error("network proxy: invalid GNOME proxy string");return $.slice(1,-1).replace(/\\([\\'"])/g,"$1")}function DJ($){let J=new Map($.split(`
|
|
17
|
+
`).filter(Boolean).map((X)=>{let Z=X.match(/^org\.gnome\.system\.proxy(\.\w+)?\s+([\w-]+)\s+(.*)$/);if(!Z)throw Error("network proxy: invalid GNOME proxy settings");return[`${Z[1]??""}/${Z[2]}`,Z[3]]})),Q=m0(J.get("/mode"));if(Q==="none")return{};if(Q==="auto")return{unsupported:"GNOME PAC proxy is not supported; configure a manual HTTP(S) proxy or proxy environment variables"};if(Q!=="manual")throw Error("network proxy: unknown GNOME proxy mode");let Y={};for(let X of["http","https","socks"]){let Z=m0(J.get(`.${X}/host`));if(!Z)continue;let W=new URL(p0(Z,J.get(`.${X}/port`),X==="socks"?"socks":"http"));if(X==="http"&&J.get(".http/use-authentication")==="true")W.username=m0(J.get(".http/authentication-user")),W.password=m0(J.get(".http/authentication-password"));Y[X==="socks"?"all":X]=W.href}if(J.get("/use-same-proxy")==="true"&&Y.http)Y.https=Y.http;return Y.bypass=[...(J.get("/ignore-hosts")??"").matchAll(/'((?:\\.|[^'])*)'/g)].map((X)=>X[1]).join(","),Y}function fJ($){let J=$.match(/^\[Proxy Settings\]\s*\n([\s\S]*?)(?=^\[|$(?![\s\S]))/m)?.[1];if(J===void 0)return;let Q=new Map(J.split(`
|
|
18
|
+
`).filter((Z)=>Z.includes("=")).map((Z)=>{let W=Z.indexOf("=");return[Z.slice(0,W).trim(),Z.slice(W+1).trim()]})),Y=Q.get("ProxyType")??"0";if(Y==="0"||Y==="4")return{};if(Y!=="1")return{unsupported:"KDE PAC/automatic proxy discovery is not supported; configure a manual HTTP(S) proxy or proxy environment variables"};if(Q.get("ReversedException")==="true")return{unsupported:"KDE reversed proxy exceptions are not supported"};let X={bypass:Q.get("NoProxyFor")};for(let Z of["http","https","socks"]){let W=Q.get(`${Z}Proxy`);if(!W)continue;let K=W.replace(/\s+(\d+)$/,":$1");X[Z==="socks"?"all":Z]=/^[a-z][\w+.-]*:\/\//i.test(K)?K:`${Z==="socks"?"socks":"http"}://${K}`}return X}async function l0($,J,Q=5000){let{stdout:Y}=await SJ($,J,{encoding:"utf8",timeout:Q,maxBuffer:262144,windowsHide:!0});return Y}var _J=String.raw`
|
|
19
|
+
$ErrorActionPreference = 'Stop'
|
|
20
|
+
[Console]::OutputEncoding = New-Object Text.UTF8Encoding($false)
|
|
21
|
+
Add-Type @'
|
|
22
|
+
using System;
|
|
23
|
+
using System.Runtime.InteropServices;
|
|
24
|
+
public static class LodestarProxy {
|
|
25
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
26
|
+
public struct Settings {
|
|
27
|
+
[MarshalAs(UnmanagedType.Bool)] public bool AutoDetect;
|
|
28
|
+
public IntPtr AutoConfigUrl, Proxy, Bypass;
|
|
29
|
+
}
|
|
30
|
+
[DllImport("winhttp.dll", SetLastError = true)]
|
|
31
|
+
[return: MarshalAs(UnmanagedType.Bool)]
|
|
32
|
+
public static extern bool WinHttpGetIEProxyConfigForCurrentUser(out Settings settings);
|
|
33
|
+
[DllImport("kernel32.dll")] public static extern IntPtr GlobalFree(IntPtr pointer);
|
|
34
|
+
}
|
|
35
|
+
'@
|
|
36
|
+
$settings = New-Object LodestarProxy+Settings
|
|
37
|
+
if (-not [LodestarProxy]::WinHttpGetIEProxyConfigForCurrentUser([ref]$settings)) {
|
|
38
|
+
$code = [Runtime.InteropServices.Marshal]::GetLastWin32Error()
|
|
39
|
+
if ($code -eq 2) { '{}'; exit 0 }
|
|
40
|
+
throw (New-Object ComponentModel.Win32Exception($code))
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
$proxy = [Runtime.InteropServices.Marshal]::PtrToStringUni($settings.Proxy)
|
|
44
|
+
@{
|
|
45
|
+
ProxyEnable = -not [string]::IsNullOrEmpty($proxy)
|
|
46
|
+
ProxyServer = $proxy
|
|
47
|
+
ProxyOverride = [Runtime.InteropServices.Marshal]::PtrToStringUni($settings.Bypass)
|
|
48
|
+
AutoConfigURL = [Runtime.InteropServices.Marshal]::PtrToStringUni($settings.AutoConfigUrl)
|
|
49
|
+
AutoDetect = $settings.AutoDetect
|
|
50
|
+
} | ConvertTo-Json -Compress
|
|
51
|
+
} finally {
|
|
52
|
+
foreach ($pointer in @($settings.Proxy, $settings.Bypass, $settings.AutoConfigUrl)) {
|
|
53
|
+
if ($pointer -ne [IntPtr]::Zero) { [void][LodestarProxy]::GlobalFree($pointer) }
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
`;async function xJ(){if(process.platform==="win32")return wJ(JSON.parse(await l0("powershell.exe",["-NoProfile","-NonInteractive","-Command",_J],15000)));if(process.platform==="darwin")return EJ(await l0("/usr/sbin/scutil",["--proxy"]));if(process.platform==="linux"){let $=L$(process.env.XDG_CONFIG_HOME||L$(IJ(),".config"),"kioslaverc");try{let Q=fJ(await TJ($,"utf8"));if(Q&&(!process.env.XDG_CURRENT_DESKTOP||/kde/i.test(process.env.XDG_CURRENT_DESKTOP)))return Q}catch(Q){if(Q?.code!=="ENOENT")throw Q}let J;try{J=await l0("gsettings",["list-schemas"])}catch(Q){if(Q?.code==="ENOENT")return{};throw Q}if(!J.split(/\r?\n/).includes("org.gnome.system.proxy"))return{};return DJ(await l0("gsettings",["list-recursively","org.gnome.system.proxy"]))}return{}}function vJ($=xJ,J=process.env,Q=Date.now){let Y;return async(X)=>{if(N1(X)||O1(X,F0(J,"NO_PROXY"))||F0(J,X.protocol==="https:"?"HTTPS_PROXY":"HTTP_PROXY")||F0(J,"ALL_PROXY"))return R$(X,J);if(!Y||Y.until<=Q()){let Z=$().catch((W)=>{if(Y?.value===Z)Y=void 0;if(W instanceof Error&&W.message.startsWith("network proxy:"))throw W;let K=W instanceof Error?W.code??W.name:"unknown error";throw Error(`network proxy: failed to read ${process.platform} system proxy settings (${K})`,{cause:W})});Y={until:Q()+30000,value:Z}}return R$(X,J,await Y.value)}}var yJ=vJ();var wY=new AJ({keepAlive:!0}),EY=new bJ({keepAlive:!0});import{existsSync as P1,readFileSync as cJ}from"node:fs";import{join as U$,isAbsolute as mJ}from"node:path";var gJ=X0($1(),1);function lJ($,J=M8){let Q=U$(J,$,"current.json");if(!P1(Q))return null;let Y=JSON.parse(cJ(Q,"utf8"));if(!Number.isFinite(Y.checkedAt)||Y.directory!==void 0&&!mJ(Y.directory))throw Error(`Invalid ${$} runtime state: ${Q}`);return Y}function pJ($){let J=lJ($);if(!J?.directory)throw Error(`${$} runtime 未安装,请运行 lodestar-update --agents-only`);if(!P1(J.directory))throw Error(`${$} runtime 安装目录不存在: ${J.directory};请运行 lodestar-update --agents-only`);return J.directory}function T$($,J){let Q=U$(pJ($),"node_modules",".bin",`${J}${process.platform==="win32"?".cmd":""}`);if(!P1(Q))throw Error(`${$} executable missing: ${Q}`);return Q}var C$=["用法:lodestar-claude <备注名|default> [Claude 原生参数...]"," lodestar-claude 工作号"," lodestar-claude 工作号 auth login"," lodestar-claude default --help","","使用 Lodestar 当前选中的 Claude 原生运行时,保留当前终端的 HOME、工作目录和其他环境。","额外账号使用 ~/.claude-accounts/备注名;首次登录无需先收录,命令本身不创建目录或清理历史。","default 保留当前终端 CLAUDE_CONFIG_DIR 的未设置状态或原始路径,不读取 Lodestar 的 [claude.env]。","仅供用户本机终端使用;受管 Agent 任务请使用 lodestar-agent。"].join(`
|
|
57
|
+
`);function nJ(){if(["LODESTAR_AGENT_ROLE","LODESTAR_AGENT_URL","LODESTAR_AGENT_CAPABILITY","LODESTAR_AGENT_SESSION","DSH_LODESTAR_AGENT_CONTEXT"].some(($)=>process.env[$]!==void 0))throw Error("lodestar-claude 仅供用户本机终端使用;受管 Agent 任务须通过 lodestar-agent 绑定当前会话,不能绕过 Claude 订阅调用限制")}async function aJ($=process.argv.slice(2)){if($[0]==="--help"||$[0]==="-h"){process.stdout.write(`${C$}
|
|
58
|
+
`);return}let[J,...Q]=$;if(!J?.trim())throw Error(C$);nJ();let Y=w8.nativeCliEnv(J,process.env),X=T$("claude","claude"),Z=await new Promise((W,K)=>{let H=S$.spawn(X,Q,{env:Y,stdio:"inherit",shell:!1}),z=["SIGINT","SIGTERM","SIGHUP"].map((G)=>{let F=()=>{try{H.kill(G)}catch(R){process.stderr.write(`lodestar-claude: 转发 ${G} 失败:${R instanceof Error?R.message:String(R)}
|
|
59
|
+
`)}};return process.on(G,F),{signal:G,forward:F}}),V=()=>{for(let{signal:G,forward:F}of z)process.off(G,F)};H.once("error",(G)=>{V(),K(G)}),H.once("close",(G,F)=>{V(),W({code:G,signal:F})})});if(Z.signal)process.exitCode=128+(iJ.signals[Z.signal]??0),process.kill(process.pid,Z.signal);else process.exitCode=Z.code??1}if(process.argv[1]&&I$(process.argv[1])===I$(dJ(import.meta.url)))aJ().catch(($)=>{process.stderr.write(`lodestar-claude: ${$ instanceof Error?$.message:String($)}
|
|
60
|
+
`),process.exitCode=1});export{aJ as main};
|