diff --git a/copilot/compiled/https-proxy-agent/index.js b/copilot/compiled/https-proxy-agent/index.js new file mode 100644 index 000000000000..e43454fe4875 --- /dev/null +++ b/copilot/compiled/https-proxy-agent/index.js @@ -0,0 +1 @@ +(function(){var e={430:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const o=r(361);const s=n(r(234));const i=n(r(699));const c=s.default("agent-base");function isAgent(e){return Boolean(e)&&typeof e.addRequest==="function"}function isSecureEndpoint(){const{stack:e}=new Error;if(typeof e!=="string")return false;return e.split("\n").some((e=>e.indexOf("(https.js:")!==-1||e.indexOf("node:https:")!==-1))}function createAgent(e,t){return new createAgent.Agent(e,t)}(function(e){class Agent extends o.EventEmitter{constructor(e,t){super();let r=t;if(typeof e==="function"){this.callback=e}else if(e){r=e}this.timeout=null;if(r&&typeof r.timeout==="number"){this.timeout=r.timeout}this.maxFreeSockets=1;this.maxSockets=1;this.maxTotalSockets=Infinity;this.sockets={};this.freeSockets={};this.requests={};this.options={}}get defaultPort(){if(typeof this.explicitDefaultPort==="number"){return this.explicitDefaultPort}return isSecureEndpoint()?443:80}set defaultPort(e){this.explicitDefaultPort=e}get protocol(){if(typeof this.explicitProtocol==="string"){return this.explicitProtocol}return isSecureEndpoint()?"https:":"http:"}set protocol(e){this.explicitProtocol=e}callback(e,t,r){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(e,t){const r=Object.assign({},t);if(typeof r.secureEndpoint!=="boolean"){r.secureEndpoint=isSecureEndpoint()}if(r.host==null){r.host="localhost"}if(r.port==null){r.port=r.secureEndpoint?443:80}if(r.protocol==null){r.protocol=r.secureEndpoint?"https:":"http:"}if(r.host&&r.path){delete r.path}delete r.agent;delete r.hostname;delete r._defaultAgent;delete r.defaultPort;delete r.createConnection;e._last=true;e.shouldKeepAlive=false;let n=false;let o=null;const s=r.timeout||this.timeout;const onerror=t=>{if(e._hadError)return;e.emit("error",t);e._hadError=true};const ontimeout=()=>{o=null;n=true;const e=new Error(`A "socket" was not created for HTTP request before ${s}ms`);e.code="ETIMEOUT";onerror(e)};const callbackError=e=>{if(n)return;if(o!==null){clearTimeout(o);o=null}onerror(e)};const onsocket=t=>{if(n)return;if(o!=null){clearTimeout(o);o=null}if(isAgent(t)){c("Callback returned another Agent instance %o",t.constructor.name);t.addRequest(e,r);return}if(t){t.once("free",(()=>{this.freeSocket(t,r)}));e.onSocket(t);return}const s=new Error(`no Duplex stream was returned to agent-base for \`${e.method} ${e.path}\``);onerror(s)};if(typeof this.callback!=="function"){onerror(new Error("`callback` is not defined"));return}if(!this.promisifiedCallback){if(this.callback.length>=3){c("Converting legacy callback function to promise");this.promisifiedCallback=i.default(this.callback)}else{this.promisifiedCallback=this.callback}}if(typeof s==="number"&&s>0){o=setTimeout(ontimeout,s)}if("port"in r&&typeof r.port!=="number"){r.port=Number(r.port)}try{c("Resolving socket for %o request: %o",r.protocol,`${e.method} ${e.path}`);Promise.resolve(this.promisifiedCallback(e,r)).then(onsocket,callbackError)}catch(e){Promise.reject(e).catch(callbackError)}}freeSocket(e,t){c("Freeing socket %o %o",e.constructor.name,t);e.destroy()}destroy(){c("Destroying agent %o",this.constructor.name)}}e.Agent=Agent;e.prototype=e.Agent.prototype})(createAgent||(createAgent={}));e.exports=createAgent},699:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});function promisify(e){return function(t,r){return new Promise(((n,o)=>{e.call(this,t,r,((e,t)=>{if(e){o(e)}else{n(t)}}))}))}}t["default"]=promisify},741:function(e,t,r){t.formatArgs=formatArgs;t.save=save;t.load=load;t.useColors=useColors;t.storage=localstorage();t.destroy=(()=>{let e=false;return()=>{if(!e){e=true;console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}}})();t.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 useColors(){if(typeof window!=="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)){return true}if(typeof navigator!=="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)){return false}return typeof document!=="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!=="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!=="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator!=="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function formatArgs(t){t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff);if(!this.useColors){return}const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0;let o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{if(e==="%%"){return}n++;if(e==="%c"){o=n}}));t.splice(o,0,r)}t.log=console.debug||console.log||(()=>{});function save(e){try{if(e){t.storage.setItem("debug",e)}else{t.storage.removeItem("debug")}}catch(e){}}function load(){let e;try{e=t.storage.getItem("debug")}catch(e){}if(!e&&typeof process!=="undefined"&&"env"in process){e=process.env.DEBUG}return e}function localstorage(){try{return localStorage}catch(e){}}e.exports=r(993)(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},993:function(e,t,r){function setup(e){createDebug.debug=createDebug;createDebug.default=createDebug;createDebug.coerce=coerce;createDebug.disable=disable;createDebug.enable=enable;createDebug.enabled=enabled;createDebug.humanize=r(257);createDebug.destroy=destroy;Object.keys(e).forEach((t=>{createDebug[t]=e[t]}));createDebug.names=[];createDebug.skips=[];createDebug.formatters={};function selectColor(e){let t=0;for(let r=0;r{if(t==="%%"){return"%"}s++;const o=createDebug.formatters[n];if(typeof o==="function"){const n=e[s];t=o.call(r,n);e.splice(s,1);s--}return t}));createDebug.formatArgs.call(r,e);const i=r.log||createDebug.log;i.apply(r,e)}debug.namespace=e;debug.useColors=createDebug.useColors();debug.color=createDebug.selectColor(e);debug.extend=extend;debug.destroy=createDebug.destroy;Object.defineProperty(debug,"enabled",{enumerable:true,configurable:false,get:()=>{if(r!==null){return r}if(n!==createDebug.namespaces){n=createDebug.namespaces;o=createDebug.enabled(e)}return o},set:e=>{r=e}});if(typeof createDebug.init==="function"){createDebug.init(debug)}return debug}function extend(e,t){const r=createDebug(this.namespace+(typeof t==="undefined"?":":t)+e);r.log=this.log;return r}function enable(e){createDebug.save(e);createDebug.namespaces=e;createDebug.names=[];createDebug.skips=[];let t;const r=(typeof e==="string"?e:"").split(/[\s,]+/);const n=r.length;for(t=0;t"-"+e))].join(",");createDebug.enable("");return e}function enabled(e){if(e[e.length-1]==="*"){return true}let t;let r;for(t=0,r=createDebug.skips.length;t{}),"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");t.colors=[6,2,3,4,5,1];try{const e=r(575);if(e&&(e.stderr||e).level>=2){t.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(e){}t.inspectOpts=Object.keys(process.env).filter((e=>/^debug_/i.test(e))).reduce(((e,t)=>{const r=t.substring(6).toLowerCase().replace(/_([a-z])/g,((e,t)=>t.toUpperCase()));let n=process.env[t];if(/^(yes|on|true|enabled)$/i.test(n)){n=true}else if(/^(no|off|false|disabled)$/i.test(n)){n=false}else if(n==="null"){n=null}else{n=Number(n)}e[r]=n;return e}),{});function useColors(){return"colors"in t.inspectOpts?Boolean(t.inspectOpts.colors):n.isatty(process.stderr.fd)}function formatArgs(t){const{namespace:r,useColors:n}=this;if(n){const n=this.color;const o="[3"+(n<8?n:"8;5;"+n);const s=` ${o};1m${r} `;t[0]=s+t[0].split("\n").join("\n"+s);t.push(o+"m+"+e.exports.humanize(this.diff)+"")}else{t[0]=getDate()+r+" "+t[0]}}function getDate(){if(t.inspectOpts.hideDate){return""}return(new Date).toISOString()+" "}function log(...e){return process.stderr.write(o.format(...e)+"\n")}function save(e){if(e){process.env.DEBUG=e}else{delete process.env.DEBUG}}function load(){return process.env.DEBUG}function init(e){e.inspectOpts={};const r=Object.keys(t.inspectOpts);for(let n=0;ne.trim())).join(" ")};s.O=function(e){this.inspectOpts.colors=this.useColors;return o.inspect(e,this.inspectOpts)}},592:function(e){"use strict";e.exports=(e,t=process.argv)=>{const r=e.startsWith("-")?"":e.length===1?"-":"--";const n=t.indexOf(r+e);const o=t.indexOf("--");return n!==-1&&(o===-1||n{p("replaying proxy buffer for failed request");u.default(e.listenerCount("data")>0);e.push(b);e.push(null)}));return y}))}}t["default"]=HttpsProxyAgent;function resume(e){e.resume()}function isDefaultPort(e,t){return Boolean(!t&&e===80||t&&e===443)}function isHTTPS(e){return typeof e==="string"?/^https:?$/i.test(e):false}function omit(e,...t){const r={};let n;for(n in e){if(!t.includes(n)){r[n]=e[n]}}return r}},898:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const o=n(r(498));function createHttpsProxyAgent(e){return new o.default(e)}(function(e){e.HttpsProxyAgent=o.default;e.prototype=o.default.prototype})(createHttpsProxyAgent||(createHttpsProxyAgent={}));e.exports=createHttpsProxyAgent},820:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const o=n(r(234));const s=o.default("https-proxy-agent:parse-proxy-response");function parseProxyResponse(e){return new Promise(((t,r)=>{let n=0;const o=[];function read(){const t=e.read();if(t)ondata(t);else e.once("readable",read)}function cleanup(){e.removeListener("end",onend);e.removeListener("error",onerror);e.removeListener("close",onclose);e.removeListener("readable",read)}function onclose(e){s("onclose had error %o",e)}function onend(){s("onend")}function onerror(e){cleanup();s("onerror %o",e);r(e)}function ondata(e){o.push(e);n+=e.length;const r=Buffer.concat(o,n);const i=r.indexOf("\r\n\r\n");if(i===-1){s("have not received end of HTTP headers yet...");read();return}const c=r.toString("ascii",0,r.indexOf("\r\n"));const u=+c.split(" ")[1];s("got proxy server response: %o",c);t({statusCode:u,buffered:r})}e.on("error",onerror);e.on("close",onclose);e.on("end",onend);read()}))}t["default"]=parseProxyResponse},257:function(e){var t=1e3;var r=t*60;var n=r*60;var o=n*24;var s=o*7;var i=o*365.25;e.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0){return parse(e)}else if(r==="number"&&isFinite(e)){return t.long?fmtLong(e):fmtShort(e)}throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function parse(e){e=String(e);if(e.length>100){return}var c=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!c){return}var u=parseFloat(c[1]);var a=(c[2]||"ms").toLowerCase();switch(a){case"years":case"year":case"yrs":case"yr":case"y":return u*i;case"weeks":case"week":case"w":return u*s;case"days":case"day":case"d":return u*o;case"hours":case"hour":case"hrs":case"hr":case"h":return u*n;case"minutes":case"minute":case"mins":case"min":case"m":return u*r;case"seconds":case"second":case"secs":case"sec":case"s":return u*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return u;default:return undefined}}function fmtShort(e){var s=Math.abs(e);if(s>=o){return Math.round(e/o)+"d"}if(s>=n){return Math.round(e/n)+"h"}if(s>=r){return Math.round(e/r)+"m"}if(s>=t){return Math.round(e/t)+"s"}return e+"ms"}function fmtLong(e){var s=Math.abs(e);if(s>=o){return plural(e,s,o,"day")}if(s>=n){return plural(e,s,n,"hour")}if(s>=r){return plural(e,s,r,"minute")}if(s>=t){return plural(e,s,t,"second")}return e+" ms"}function plural(e,t,r,n){var o=t>=r*1.5;return Math.round(e/r)+" "+n+(o?"s":"")}},575:function(e,t,r){"use strict";const n=r(37);const o=r(224);const s=r(592);const{env:i}=process;let c;if(s("no-color")||s("no-colors")||s("color=false")||s("color=never")){c=0}else if(s("color")||s("colors")||s("color=true")||s("color=always")){c=1}if("FORCE_COLOR"in i){if(i.FORCE_COLOR==="true"){c=1}else if(i.FORCE_COLOR==="false"){c=0}else{c=i.FORCE_COLOR.length===0?1:Math.min(parseInt(i.FORCE_COLOR,10),3)}}function translateLevel(e){if(e===0){return false}return{level:e,hasBasic:true,has256:e>=2,has16m:e>=3}}function supportsColor(e,t){if(c===0){return 0}if(s("color=16m")||s("color=full")||s("color=truecolor")){return 3}if(s("color=256")){return 2}if(e&&!t&&c===undefined){return 0}const r=c||0;if(i.TERM==="dumb"){return r}if(process.platform==="win32"){const e=n.release().split(".");if(Number(e[0])>=10&&Number(e[2])>=10586){return Number(e[2])>=14931?3:2}return 1}if("CI"in i){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((e=>e in i))||i.CI_NAME==="codeship"){return 1}return r}if("TEAMCITY_VERSION"in i){return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(i.TEAMCITY_VERSION)?1:0}if(i.COLORTERM==="truecolor"){return 3}if("TERM_PROGRAM"in i){const e=parseInt((i.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(i.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(i.TERM)){return 2}if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(i.TERM)){return 1}if("COLORTERM"in i){return 1}return r}function getSupportLevel(e){const t=supportsColor(e,e&&e.isTTY);return translateLevel(t)}e.exports={supportsColor:getSupportLevel,stdout:translateLevel(supportsColor(true,o.isatty(1))),stderr:translateLevel(supportsColor(true,o.isatty(2)))}},491:function(e){"use strict";e.exports=require("assert")},361:function(e){"use strict";e.exports=require("events")},808:function(e){"use strict";e.exports=require("net")},37:function(e){"use strict";e.exports=require("os")},404:function(e){"use strict";e.exports=require("tls")},224:function(e){"use strict";e.exports=require("tty")},310:function(e){"use strict";e.exports=require("url")},837:function(e){"use strict";e.exports=require("util")}};var t={};function __nccwpck_require__(r){var n=t[r];if(n!==undefined){return n.exports}var o=t[r]={exports:{}};var s=true;try{e[r].call(o.exports,o,o.exports,__nccwpck_require__);s=false}finally{if(s)delete t[r]}return o.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r=__nccwpck_require__(898);module.exports=r})(); \ No newline at end of file diff --git a/copilot/compiled/https-proxy-agent/package.json b/copilot/compiled/https-proxy-agent/package.json new file mode 100644 index 000000000000..23eb562b7a38 --- /dev/null +++ b/copilot/compiled/https-proxy-agent/package.json @@ -0,0 +1 @@ +{"name":"https-proxy-agent","version":"5.0.1","author":"Nathan Rajlich (http://n8.io/)","license":"MIT","types":"dist/index"} diff --git a/copilot/compiled/socks-proxy-agent/index.js b/copilot/compiled/socks-proxy-agent/index.js new file mode 100644 index 000000000000..f6dbd15ac0e9 --- /dev/null +++ b/copilot/compiled/socks-proxy-agent/index.js @@ -0,0 +1 @@ +(function(){var e={430:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const r=n(361);const o=s(n(234));const i=s(n(699));const a=o.default("agent-base");function isAgent(e){return Boolean(e)&&typeof e.addRequest==="function"}function isSecureEndpoint(){const{stack:e}=new Error;if(typeof e!=="string")return false;return e.split("\n").some((e=>e.indexOf("(https.js:")!==-1||e.indexOf("node:https:")!==-1))}function createAgent(e,t){return new createAgent.Agent(e,t)}(function(e){class Agent extends r.EventEmitter{constructor(e,t){super();let n=t;if(typeof e==="function"){this.callback=e}else if(e){n=e}this.timeout=null;if(n&&typeof n.timeout==="number"){this.timeout=n.timeout}this.maxFreeSockets=1;this.maxSockets=1;this.maxTotalSockets=Infinity;this.sockets={};this.freeSockets={};this.requests={};this.options={}}get defaultPort(){if(typeof this.explicitDefaultPort==="number"){return this.explicitDefaultPort}return isSecureEndpoint()?443:80}set defaultPort(e){this.explicitDefaultPort=e}get protocol(){if(typeof this.explicitProtocol==="string"){return this.explicitProtocol}return isSecureEndpoint()?"https:":"http:"}set protocol(e){this.explicitProtocol=e}callback(e,t,n){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(e,t){const n=Object.assign({},t);if(typeof n.secureEndpoint!=="boolean"){n.secureEndpoint=isSecureEndpoint()}if(n.host==null){n.host="localhost"}if(n.port==null){n.port=n.secureEndpoint?443:80}if(n.protocol==null){n.protocol=n.secureEndpoint?"https:":"http:"}if(n.host&&n.path){delete n.path}delete n.agent;delete n.hostname;delete n._defaultAgent;delete n.defaultPort;delete n.createConnection;e._last=true;e.shouldKeepAlive=false;let s=false;let r=null;const o=n.timeout||this.timeout;const onerror=t=>{if(e._hadError)return;e.emit("error",t);e._hadError=true};const ontimeout=()=>{r=null;s=true;const e=new Error(`A "socket" was not created for HTTP request before ${o}ms`);e.code="ETIMEOUT";onerror(e)};const callbackError=e=>{if(s)return;if(r!==null){clearTimeout(r);r=null}onerror(e)};const onsocket=t=>{if(s)return;if(r!=null){clearTimeout(r);r=null}if(isAgent(t)){a("Callback returned another Agent instance %o",t.constructor.name);t.addRequest(e,n);return}if(t){t.once("free",(()=>{this.freeSocket(t,n)}));e.onSocket(t);return}const o=new Error(`no Duplex stream was returned to agent-base for \`${e.method} ${e.path}\``);onerror(o)};if(typeof this.callback!=="function"){onerror(new Error("`callback` is not defined"));return}if(!this.promisifiedCallback){if(this.callback.length>=3){a("Converting legacy callback function to promise");this.promisifiedCallback=i.default(this.callback)}else{this.promisifiedCallback=this.callback}}if(typeof o==="number"&&o>0){r=setTimeout(ontimeout,o)}if("port"in n&&typeof n.port!=="number"){n.port=Number(n.port)}try{a("Resolving socket for %o request: %o",n.protocol,`${e.method} ${e.path}`);Promise.resolve(this.promisifiedCallback(e,n)).then(onsocket,callbackError)}catch(e){Promise.reject(e).catch(callbackError)}}freeSocket(e,t){a("Freeing socket %o %o",e.constructor.name,t);e.destroy()}destroy(){a("Destroying agent %o",this.constructor.name)}}e.Agent=Agent;e.prototype=e.Agent.prototype})(createAgent||(createAgent={}));e.exports=createAgent},699:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});function promisify(e){return function(t,n){return new Promise(((s,r)=>{e.call(this,t,n,((e,t)=>{if(e){r(e)}else{s(t)}}))}))}}t["default"]=promisify},741:function(e,t,n){t.formatArgs=formatArgs;t.save=save;t.load=load;t.useColors=useColors;t.storage=localstorage();t.destroy=(()=>{let e=false;return()=>{if(!e){e=true;console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}}})();t.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 useColors(){if(typeof window!=="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)){return true}if(typeof navigator!=="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)){return false}return typeof document!=="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!=="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!=="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator!=="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function formatArgs(t){t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff);if(!this.useColors){return}const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let s=0;let r=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{if(e==="%%"){return}s++;if(e==="%c"){r=s}}));t.splice(r,0,n)}t.log=console.debug||console.log||(()=>{});function save(e){try{if(e){t.storage.setItem("debug",e)}else{t.storage.removeItem("debug")}}catch(e){}}function load(){let e;try{e=t.storage.getItem("debug")}catch(e){}if(!e&&typeof process!=="undefined"&&"env"in process){e=process.env.DEBUG}return e}function localstorage(){try{return localStorage}catch(e){}}e.exports=n(993)(t);const{formatters:s}=e.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},993:function(e,t,n){function setup(e){createDebug.debug=createDebug;createDebug.default=createDebug;createDebug.coerce=coerce;createDebug.disable=disable;createDebug.enable=enable;createDebug.enabled=enabled;createDebug.humanize=n(257);createDebug.destroy=destroy;Object.keys(e).forEach((t=>{createDebug[t]=e[t]}));createDebug.names=[];createDebug.skips=[];createDebug.formatters={};function selectColor(e){let t=0;for(let n=0;n{if(t==="%%"){return"%"}o++;const r=createDebug.formatters[s];if(typeof r==="function"){const s=e[o];t=r.call(n,s);e.splice(o,1);o--}return t}));createDebug.formatArgs.call(n,e);const i=n.log||createDebug.log;i.apply(n,e)}debug.namespace=e;debug.useColors=createDebug.useColors();debug.color=createDebug.selectColor(e);debug.extend=extend;debug.destroy=createDebug.destroy;Object.defineProperty(debug,"enabled",{enumerable:true,configurable:false,get:()=>{if(n!==null){return n}if(s!==createDebug.namespaces){s=createDebug.namespaces;r=createDebug.enabled(e)}return r},set:e=>{n=e}});if(typeof createDebug.init==="function"){createDebug.init(debug)}return debug}function extend(e,t){const n=createDebug(this.namespace+(typeof t==="undefined"?":":t)+e);n.log=this.log;return n}function enable(e){createDebug.save(e);createDebug.namespaces=e;createDebug.names=[];createDebug.skips=[];let t;const n=(typeof e==="string"?e:"").split(/[\s,]+/);const s=n.length;for(t=0;t"-"+e))].join(",");createDebug.enable("");return e}function enabled(e){if(e[e.length-1]==="*"){return true}let t;let n;for(t=0,n=createDebug.skips.length;t{}),"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");t.colors=[6,2,3,4,5,1];try{const e=n(575);if(e&&(e.stderr||e).level>=2){t.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(e){}t.inspectOpts=Object.keys(process.env).filter((e=>/^debug_/i.test(e))).reduce(((e,t)=>{const n=t.substring(6).toLowerCase().replace(/_([a-z])/g,((e,t)=>t.toUpperCase()));let s=process.env[t];if(/^(yes|on|true|enabled)$/i.test(s)){s=true}else if(/^(no|off|false|disabled)$/i.test(s)){s=false}else if(s==="null"){s=null}else{s=Number(s)}e[n]=s;return e}),{});function useColors(){return"colors"in t.inspectOpts?Boolean(t.inspectOpts.colors):s.isatty(process.stderr.fd)}function formatArgs(t){const{namespace:n,useColors:s}=this;if(s){const s=this.color;const r="[3"+(s<8?s:"8;5;"+s);const o=` ${r};1m${n} `;t[0]=o+t[0].split("\n").join("\n"+o);t.push(r+"m+"+e.exports.humanize(this.diff)+"")}else{t[0]=getDate()+n+" "+t[0]}}function getDate(){if(t.inspectOpts.hideDate){return""}return(new Date).toISOString()+" "}function log(...e){return process.stderr.write(r.format(...e)+"\n")}function save(e){if(e){process.env.DEBUG=e}else{delete process.env.DEBUG}}function load(){return process.env.DEBUG}function init(e){e.inspectOpts={};const n=Object.keys(t.inspectOpts);for(let s=0;se.trim())).join(" ")};o.O=function(e){this.inspectOpts.colors=this.useColors;return r.inspect(e,this.inspectOpts)}},592:function(e){"use strict";e.exports=(e,t=process.argv)=>{const n=e.startsWith("-")?"":e.length===1?"-":"--";const s=t.indexOf(n+e);const r=t.indexOf("--");return s!==-1&&(r===-1||s{s[n++]=parseInt(e,10)&255}))}else if(this.isV6Format(e)){const o=e.split(":",8);let i;for(i=0;i0;i--){e.push("0")}o.splice(...e)}s=t||r.alloc(n+16);for(i=0;i>8&255;s[n++]=e&255}}if(!s){throw Error(`Invalid ip address: ${e}`)}return s};s.toString=function(e,t,n){t=~~t;n=n||e.length-t;let s=[];if(n===4){for(let r=0;r32){t="ipv6"}else{t=_normalizeFamily(t)}let n=4;if(t==="ipv6"){n=16}const o=r.alloc(n);for(let t=0,n=o.length;t>n)&255}return s.toString(o)};s.mask=function(e,t){e=s.toBuffer(e);t=s.toBuffer(t);const n=r.alloc(Math.max(e.length,t.length));let o;if(e.length===t.length){for(o=0;oe.length){n=t;r=e}const o=n.length-r.length;for(let e=o;e{const n=_normalizeFamily(e.family);return n===t}));if(s.length===0){return undefined}return s[0].address}const r=Object.keys(n).map((r=>{const o=n[r].filter((n=>{n.family=_normalizeFamily(n.family);if(n.family!==t||s.isLoopback(n.address)){return false}if(!e){return true}return e==="public"?s.isPrivate(n.address):s.isPublic(n.address)}));return o.length?o[0].address:undefined})).filter(Boolean);return!r.length?s.loopback(t):r[0]};s.toLong=function(e){let t=0;e.split(".").forEach((e=>{t<<=8;t+=parseInt(e)}));return t>>>0};s.fromLong=function(e){return`${e>>>24}.${e>>16&255}.${e>>8&255}.${e&255}`}},257:function(e){var t=1e3;var n=t*60;var s=n*60;var r=s*24;var o=r*7;var i=r*365.25;e.exports=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0){return parse(e)}else if(n==="number"&&isFinite(e)){return t.long?fmtLong(e):fmtShort(e)}throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function parse(e){e=String(e);if(e.length>100){return}var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!a){return}var c=parseFloat(a[1]);var u=(a[2]||"ms").toLowerCase();switch(u){case"years":case"year":case"yrs":case"yr":case"y":return c*i;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*s;case"minutes":case"minute":case"mins":case"min":case"m":return c*n;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return undefined}}function fmtShort(e){var o=Math.abs(e);if(o>=r){return Math.round(e/r)+"d"}if(o>=s){return Math.round(e/s)+"h"}if(o>=n){return Math.round(e/n)+"m"}if(o>=t){return Math.round(e/t)+"s"}return e+"ms"}function fmtLong(e){var o=Math.abs(e);if(o>=r){return plural(e,o,r,"day")}if(o>=s){return plural(e,o,s,"hour")}if(o>=n){return plural(e,o,n,"minute")}if(o>=t){return plural(e,o,t,"second")}return e+" ms"}function plural(e,t,n,s){var r=t>=n*1.5;return Math.round(e/n)+" "+s+(r?"s":"")}},75:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});const s=n(496);const r=4096;const o="utf8";class SmartBuffer{constructor(e){this.length=0;this._encoding=o;this._writeOffset=0;this._readOffset=0;if(SmartBuffer.isSmartBufferOptions(e)){if(e.encoding){s.checkEncoding(e.encoding);this._encoding=e.encoding}if(e.size){if(s.isFiniteInteger(e.size)&&e.size>0){this._buff=Buffer.allocUnsafe(e.size)}else{throw new Error(s.ERRORS.INVALID_SMARTBUFFER_SIZE)}}else if(e.buff){if(Buffer.isBuffer(e.buff)){this._buff=e.buff;this.length=e.buff.length}else{throw new Error(s.ERRORS.INVALID_SMARTBUFFER_BUFFER)}}else{this._buff=Buffer.allocUnsafe(r)}}else{if(typeof e!=="undefined"){throw new Error(s.ERRORS.INVALID_SMARTBUFFER_OBJECT)}this._buff=Buffer.allocUnsafe(r)}}static fromSize(e,t){return new this({size:e,encoding:t})}static fromBuffer(e,t){return new this({buff:e,encoding:t})}static fromOptions(e){return new this(e)}static isSmartBufferOptions(e){const t=e;return t&&(t.encoding!==undefined||t.size!==undefined||t.buff!==undefined)}readInt8(e){return this._readNumberValue(Buffer.prototype.readInt8,1,e)}readInt16BE(e){return this._readNumberValue(Buffer.prototype.readInt16BE,2,e)}readInt16LE(e){return this._readNumberValue(Buffer.prototype.readInt16LE,2,e)}readInt32BE(e){return this._readNumberValue(Buffer.prototype.readInt32BE,4,e)}readInt32LE(e){return this._readNumberValue(Buffer.prototype.readInt32LE,4,e)}readBigInt64BE(e){s.bigIntAndBufferInt64Check("readBigInt64BE");return this._readNumberValue(Buffer.prototype.readBigInt64BE,8,e)}readBigInt64LE(e){s.bigIntAndBufferInt64Check("readBigInt64LE");return this._readNumberValue(Buffer.prototype.readBigInt64LE,8,e)}writeInt8(e,t){this._writeNumberValue(Buffer.prototype.writeInt8,1,e,t);return this}insertInt8(e,t){return this._insertNumberValue(Buffer.prototype.writeInt8,1,e,t)}writeInt16BE(e,t){return this._writeNumberValue(Buffer.prototype.writeInt16BE,2,e,t)}insertInt16BE(e,t){return this._insertNumberValue(Buffer.prototype.writeInt16BE,2,e,t)}writeInt16LE(e,t){return this._writeNumberValue(Buffer.prototype.writeInt16LE,2,e,t)}insertInt16LE(e,t){return this._insertNumberValue(Buffer.prototype.writeInt16LE,2,e,t)}writeInt32BE(e,t){return this._writeNumberValue(Buffer.prototype.writeInt32BE,4,e,t)}insertInt32BE(e,t){return this._insertNumberValue(Buffer.prototype.writeInt32BE,4,e,t)}writeInt32LE(e,t){return this._writeNumberValue(Buffer.prototype.writeInt32LE,4,e,t)}insertInt32LE(e,t){return this._insertNumberValue(Buffer.prototype.writeInt32LE,4,e,t)}writeBigInt64BE(e,t){s.bigIntAndBufferInt64Check("writeBigInt64BE");return this._writeNumberValue(Buffer.prototype.writeBigInt64BE,8,e,t)}insertBigInt64BE(e,t){s.bigIntAndBufferInt64Check("writeBigInt64BE");return this._insertNumberValue(Buffer.prototype.writeBigInt64BE,8,e,t)}writeBigInt64LE(e,t){s.bigIntAndBufferInt64Check("writeBigInt64LE");return this._writeNumberValue(Buffer.prototype.writeBigInt64LE,8,e,t)}insertBigInt64LE(e,t){s.bigIntAndBufferInt64Check("writeBigInt64LE");return this._insertNumberValue(Buffer.prototype.writeBigInt64LE,8,e,t)}readUInt8(e){return this._readNumberValue(Buffer.prototype.readUInt8,1,e)}readUInt16BE(e){return this._readNumberValue(Buffer.prototype.readUInt16BE,2,e)}readUInt16LE(e){return this._readNumberValue(Buffer.prototype.readUInt16LE,2,e)}readUInt32BE(e){return this._readNumberValue(Buffer.prototype.readUInt32BE,4,e)}readUInt32LE(e){return this._readNumberValue(Buffer.prototype.readUInt32LE,4,e)}readBigUInt64BE(e){s.bigIntAndBufferInt64Check("readBigUInt64BE");return this._readNumberValue(Buffer.prototype.readBigUInt64BE,8,e)}readBigUInt64LE(e){s.bigIntAndBufferInt64Check("readBigUInt64LE");return this._readNumberValue(Buffer.prototype.readBigUInt64LE,8,e)}writeUInt8(e,t){return this._writeNumberValue(Buffer.prototype.writeUInt8,1,e,t)}insertUInt8(e,t){return this._insertNumberValue(Buffer.prototype.writeUInt8,1,e,t)}writeUInt16BE(e,t){return this._writeNumberValue(Buffer.prototype.writeUInt16BE,2,e,t)}insertUInt16BE(e,t){return this._insertNumberValue(Buffer.prototype.writeUInt16BE,2,e,t)}writeUInt16LE(e,t){return this._writeNumberValue(Buffer.prototype.writeUInt16LE,2,e,t)}insertUInt16LE(e,t){return this._insertNumberValue(Buffer.prototype.writeUInt16LE,2,e,t)}writeUInt32BE(e,t){return this._writeNumberValue(Buffer.prototype.writeUInt32BE,4,e,t)}insertUInt32BE(e,t){return this._insertNumberValue(Buffer.prototype.writeUInt32BE,4,e,t)}writeUInt32LE(e,t){return this._writeNumberValue(Buffer.prototype.writeUInt32LE,4,e,t)}insertUInt32LE(e,t){return this._insertNumberValue(Buffer.prototype.writeUInt32LE,4,e,t)}writeBigUInt64BE(e,t){s.bigIntAndBufferInt64Check("writeBigUInt64BE");return this._writeNumberValue(Buffer.prototype.writeBigUInt64BE,8,e,t)}insertBigUInt64BE(e,t){s.bigIntAndBufferInt64Check("writeBigUInt64BE");return this._insertNumberValue(Buffer.prototype.writeBigUInt64BE,8,e,t)}writeBigUInt64LE(e,t){s.bigIntAndBufferInt64Check("writeBigUInt64LE");return this._writeNumberValue(Buffer.prototype.writeBigUInt64LE,8,e,t)}insertBigUInt64LE(e,t){s.bigIntAndBufferInt64Check("writeBigUInt64LE");return this._insertNumberValue(Buffer.prototype.writeBigUInt64LE,8,e,t)}readFloatBE(e){return this._readNumberValue(Buffer.prototype.readFloatBE,4,e)}readFloatLE(e){return this._readNumberValue(Buffer.prototype.readFloatLE,4,e)}writeFloatBE(e,t){return this._writeNumberValue(Buffer.prototype.writeFloatBE,4,e,t)}insertFloatBE(e,t){return this._insertNumberValue(Buffer.prototype.writeFloatBE,4,e,t)}writeFloatLE(e,t){return this._writeNumberValue(Buffer.prototype.writeFloatLE,4,e,t)}insertFloatLE(e,t){return this._insertNumberValue(Buffer.prototype.writeFloatLE,4,e,t)}readDoubleBE(e){return this._readNumberValue(Buffer.prototype.readDoubleBE,8,e)}readDoubleLE(e){return this._readNumberValue(Buffer.prototype.readDoubleLE,8,e)}writeDoubleBE(e,t){return this._writeNumberValue(Buffer.prototype.writeDoubleBE,8,e,t)}insertDoubleBE(e,t){return this._insertNumberValue(Buffer.prototype.writeDoubleBE,8,e,t)}writeDoubleLE(e,t){return this._writeNumberValue(Buffer.prototype.writeDoubleLE,8,e,t)}insertDoubleLE(e,t){return this._insertNumberValue(Buffer.prototype.writeDoubleLE,8,e,t)}readString(e,t){let n;if(typeof e==="number"){s.checkLengthValue(e);n=Math.min(e,this.length-this._readOffset)}else{t=e;n=this.length-this._readOffset}if(typeof t!=="undefined"){s.checkEncoding(t)}const r=this._buff.slice(this._readOffset,this._readOffset+n).toString(t||this._encoding);this._readOffset+=n;return r}insertString(e,t,n){s.checkOffsetValue(t);return this._handleString(e,true,t,n)}writeString(e,t,n){return this._handleString(e,false,t,n)}readStringNT(e){if(typeof e!=="undefined"){s.checkEncoding(e)}let t=this.length;for(let e=this._readOffset;ethis.length){throw new Error(s.ERRORS.INVALID_READ_BEYOND_BOUNDS)}}ensureInsertable(e,t){s.checkOffsetValue(t);this._ensureCapacity(this.length+e);if(tthis.length){this.length=t+e}else{this.length+=e}}_ensureWriteable(e,t){const n=typeof t==="number"?t:this._writeOffset;this._ensureCapacity(n+e);if(n+e>this.length){this.length=n+e}}_ensureCapacity(e){const t=this._buff.length;if(e>t){let n=this._buff;let s=t*3/2+1;if(st.length){throw new Error(r.INVALID_TARGET_OFFSET)}}t.checkTargetOffset=checkTargetOffset;function isInteger(e){return typeof e==="number"&&isFinite(e)&&Math.floor(e)===e}function bigIntAndBufferInt64Check(e){if(typeof BigInt==="undefined"){throw new Error("Platform does not support JS BigInt type.")}if(typeof s.Buffer.prototype[e]==="undefined"){throw new Error(`Platform does not support Buffer.prototype.${e}.`)}}t.bigIntAndBufferInt64Check=bigIntAndBufferInt64Check},878:function(e,t,n){"use strict";var s=this&&this.__awaiter||function(e,t,n,s){function adopt(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,r){function fulfilled(e){try{step(s.next(e))}catch(e){r(e)}}function rejected(e){try{step(s["throw"](e))}catch(e){r(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((s=s.apply(e,t||[])).next())}))};var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.SocksProxyAgent=void 0;const o=n(651);const i=n(430);const a=r(n(234));const c=r(n(523));const u=r(n(404));const f=(0,a.default)("socks-proxy-agent");function parseSocksProxy(e){var t;let n=0;let s=false;let r=5;const o=e.hostname;if(o==null){throw new TypeError('No "host"')}if(typeof e.port==="number"){n=e.port}else if(typeof e.port==="string"){n=parseInt(e.port,10)}if(n==null){n=1080}if(e.protocol!=null){switch(e.protocol.replace(":","")){case"socks4":s=true;case"socks4a":r=4;break;case"socks5":s=true;case"socks":case"socks5h":r=5;break;default:throw new TypeError(`A "socks" protocol must be specified! Got: ${String(e.protocol)}`)}}if(typeof e.type!=="undefined"){if(e.type===4||e.type===5){r=e.type}else{throw new TypeError(`"type" must be 4 or 5, got: ${String(e.type)}`)}}const i={host:o,port:n,type:r};let a=(t=e.userId)!==null&&t!==void 0?t:e.username;let c=e.password;if(e.auth!=null){const t=e.auth.split(":");a=t[0];c=t[1]}if(a!=null){Object.defineProperty(i,"userId",{value:a,enumerable:false})}if(c!=null){Object.defineProperty(i,"password",{value:c,enumerable:false})}return{lookup:s,proxy:i}}const normalizeProxyOptions=e=>{let t;if(typeof e==="string"){t=new URL(e)}else{t=e}if(t==null){throw new TypeError("a SOCKS proxy server `host` and `port` must be specified!")}return t};class SocksProxyAgent extends i.Agent{constructor(e,t){var n;const s=normalizeProxyOptions(e);super(s);const r=parseSocksProxy(s);this.shouldLookup=r.lookup;this.proxy=r.proxy;this.tlsConnectionOptions=s.tls!=null?s.tls:{};this.timeout=(n=t===null||t===void 0?void 0:t.timeout)!==null&&n!==void 0?n:null}callback(e,t){var n;return s(this,void 0,void 0,(function*(){const{shouldLookup:s,proxy:r,timeout:i}=this;let{host:a,port:l,lookup:h}=t;if(a==null){throw new Error("No `host` defined!")}if(s){a=yield new Promise(((e,t)=>{const n=h!==null&&h!==void 0?h:c.default.lookup;n(a,{},((n,s)=>{if(n){t(n)}else{e(s)}}))}))}const d={proxy:r,destination:{host:a,port:l},command:"connect",timeout:i!==null&&i!==void 0?i:undefined};const cleanup=t=>{e.destroy();p.destroy();if(t)t.destroy()};f("Creating socks proxy connection: %o",d);const{socket:p}=yield o.SocksClient.createConnection(d);f("Successfully created socks proxy connection");if(i!==null){p.setTimeout(i);p.on("timeout",(()=>cleanup()))}if(t.secureEndpoint){f("Upgrading socket connection to TLS");const e=(n=t.servername)!==null&&n!==void 0?n:t.host;const s=u.default.connect(Object.assign(Object.assign(Object.assign({},omit(t,"host","hostname","path","port")),{socket:p,servername:e}),this.tlsConnectionOptions));s.once("error",(e=>{f("socket TLS error",e.message);cleanup(s)}));return s}return p}))}}t.SocksProxyAgent=SocksProxyAgent;function omit(e,...t){const n={};let s;for(s in e){if(!t.includes(s)){n[s]=e[s]}}return n}},650:function(e,t,n){"use strict";var s=this&&this.__awaiter||function(e,t,n,s){function adopt(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,r){function fulfilled(e){try{step(s.next(e))}catch(e){r(e)}}function rejected(e){try{step(s["throw"](e))}catch(e){r(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:true});t.SocksClientError=t.SocksClient=void 0;const r=n(361);const o=n(808);const i=n(460);const a=n(75);const c=n(628);const u=n(833);const f=n(390);const l=n(453);Object.defineProperty(t,"SocksClientError",{enumerable:true,get:function(){return l.SocksClientError}});class SocksClient extends r.EventEmitter{constructor(e){super();this.options=Object.assign({},e);(0,u.validateSocksClientOptions)(e);this.setState(c.SocksClientState.Created)}static createConnection(e,t){return new Promise(((n,s)=>{try{(0,u.validateSocksClientOptions)(e,["connect"])}catch(e){if(typeof t==="function"){t(e);return n(e)}else{return s(e)}}const r=new SocksClient(e);r.connect(e.existing_socket);r.once("established",(e=>{r.removeAllListeners();if(typeof t==="function"){t(null,e);n(e)}else{n(e)}}));r.once("error",(e=>{r.removeAllListeners();if(typeof t==="function"){t(e);n(e)}else{s(e)}}))}))}static createConnectionChain(e,t){return new Promise(((n,r)=>s(this,void 0,void 0,(function*(){try{(0,u.validateSocksClientChainOptions)(e)}catch(e){if(typeof t==="function"){t(e);return n(e)}else{return r(e)}}let s;if(e.randomizeChain){(0,l.shuffleArray)(e.proxies)}try{for(let t=0;tthis.onDataReceivedHandler(e);this.onClose=()=>this.onCloseHandler();this.onError=e=>this.onErrorHandler(e);this.onConnect=()=>this.onConnectHandler();const t=setTimeout((()=>this.onEstablishedTimeout()),this.options.timeout||c.DEFAULT_TIMEOUT);if(t.unref&&typeof t.unref==="function"){t.unref()}if(e){this.socket=e}else{this.socket=new o.Socket}this.socket.once("close",this.onClose);this.socket.once("error",this.onError);this.socket.once("connect",this.onConnect);this.socket.on("data",this.onDataReceived);this.setState(c.SocksClientState.Connecting);this.receiveBuffer=new f.ReceiveBuffer;if(e){this.socket.emit("connect")}else{this.socket.connect(this.getSocketOptions());if(this.options.set_tcp_nodelay!==undefined&&this.options.set_tcp_nodelay!==null){this.socket.setNoDelay(!!this.options.set_tcp_nodelay)}}this.prependOnceListener("established",(e=>{setImmediate((()=>{if(this.receiveBuffer.length>0){const t=this.receiveBuffer.get(this.receiveBuffer.length);e.socket.emit("data",t)}e.socket.resume()}))}))}getSocketOptions(){return Object.assign(Object.assign({},this.options.socket_options),{host:this.options.proxy.host||this.options.proxy.ipaddress,port:this.options.proxy.port})}onEstablishedTimeout(){if(this.state!==c.SocksClientState.Established&&this.state!==c.SocksClientState.BoundWaitingForConnection){this.closeSocket(c.ERRORS.ProxyConnectionTimedOut)}}onConnectHandler(){this.setState(c.SocksClientState.Connected);if(this.options.proxy.type===4){this.sendSocks4InitialHandshake()}else{this.sendSocks5InitialHandshake()}this.setState(c.SocksClientState.SentInitialHandshake)}onDataReceivedHandler(e){this.receiveBuffer.append(e);this.processData()}processData(){while(this.state!==c.SocksClientState.Established&&this.state!==c.SocksClientState.Error&&this.receiveBuffer.length>=this.nextRequiredPacketBufferSize){if(this.state===c.SocksClientState.SentInitialHandshake){if(this.options.proxy.type===4){this.handleSocks4FinalHandshakeResponse()}else{this.handleInitialSocks5HandshakeResponse()}}else if(this.state===c.SocksClientState.SentAuthentication){this.handleInitialSocks5AuthenticationHandshakeResponse()}else if(this.state===c.SocksClientState.SentFinalHandshake){this.handleSocks5FinalHandshakeResponse()}else if(this.state===c.SocksClientState.BoundWaitingForConnection){if(this.options.proxy.type===4){this.handleSocks4IncomingConnectionResponse()}else{this.handleSocks5IncomingConnectionResponse()}}else{this.closeSocket(c.ERRORS.InternalError);break}}}onCloseHandler(){this.closeSocket(c.ERRORS.SocketClosed)}onErrorHandler(e){this.closeSocket(e.message)}removeInternalSocketHandlers(){this.socket.pause();this.socket.removeListener("data",this.onDataReceived);this.socket.removeListener("close",this.onClose);this.socket.removeListener("error",this.onError);this.socket.removeListener("connect",this.onConnect)}closeSocket(e){if(this.state!==c.SocksClientState.Error){this.setState(c.SocksClientState.Error);this.socket.destroy();this.removeInternalSocketHandlers();this.emit("error",new l.SocksClientError(e,this.options))}}sendSocks4InitialHandshake(){const e=this.options.proxy.userId||"";const t=new a.SmartBuffer;t.writeUInt8(4);t.writeUInt8(c.SocksCommand[this.options.command]);t.writeUInt16BE(this.options.destination.port);if(o.isIPv4(this.options.destination.host)){t.writeBuffer(i.toBuffer(this.options.destination.host));t.writeStringNT(e)}else{t.writeUInt8(0);t.writeUInt8(0);t.writeUInt8(0);t.writeUInt8(1);t.writeStringNT(e);t.writeStringNT(this.options.destination.host)}this.nextRequiredPacketBufferSize=c.SOCKS_INCOMING_PACKET_SIZES.Socks4Response;this.socket.write(t.toBuffer())}handleSocks4FinalHandshakeResponse(){const e=this.receiveBuffer.get(8);if(e[1]!==c.Socks4Response.Granted){this.closeSocket(`${c.ERRORS.Socks4ProxyRejectedConnection} - (${c.Socks4Response[e[1]]})`)}else{if(c.SocksCommand[this.options.command]===c.SocksCommand.bind){const t=a.SmartBuffer.fromBuffer(e);t.readOffset=2;const n={port:t.readUInt16BE(),host:i.fromLong(t.readUInt32BE())};if(n.host==="0.0.0.0"){n.host=this.options.proxy.ipaddress}this.setState(c.SocksClientState.BoundWaitingForConnection);this.emit("bound",{remoteHost:n,socket:this.socket})}else{this.setState(c.SocksClientState.Established);this.removeInternalSocketHandlers();this.emit("established",{socket:this.socket})}}}handleSocks4IncomingConnectionResponse(){const e=this.receiveBuffer.get(8);if(e[1]!==c.Socks4Response.Granted){this.closeSocket(`${c.ERRORS.Socks4ProxyRejectedIncomingBoundConnection} - (${c.Socks4Response[e[1]]})`)}else{const t=a.SmartBuffer.fromBuffer(e);t.readOffset=2;const n={port:t.readUInt16BE(),host:i.fromLong(t.readUInt32BE())};this.setState(c.SocksClientState.Established);this.removeInternalSocketHandlers();this.emit("established",{remoteHost:n,socket:this.socket})}}sendSocks5InitialHandshake(){const e=new a.SmartBuffer;const t=[c.Socks5Auth.NoAuth];if(this.options.proxy.userId||this.options.proxy.password){t.push(c.Socks5Auth.UserPass)}if(this.options.proxy.custom_auth_method!==undefined){t.push(this.options.proxy.custom_auth_method)}e.writeUInt8(5);e.writeUInt8(t.length);for(const n of t){e.writeUInt8(n)}this.nextRequiredPacketBufferSize=c.SOCKS_INCOMING_PACKET_SIZES.Socks5InitialHandshakeResponse;this.socket.write(e.toBuffer());this.setState(c.SocksClientState.SentInitialHandshake)}handleInitialSocks5HandshakeResponse(){const e=this.receiveBuffer.get(2);if(e[0]!==5){this.closeSocket(c.ERRORS.InvalidSocks5IntiailHandshakeSocksVersion)}else if(e[1]===c.SOCKS5_NO_ACCEPTABLE_AUTH){this.closeSocket(c.ERRORS.InvalidSocks5InitialHandshakeNoAcceptedAuthType)}else{if(e[1]===c.Socks5Auth.NoAuth){this.socks5ChosenAuthType=c.Socks5Auth.NoAuth;this.sendSocks5CommandRequest()}else if(e[1]===c.Socks5Auth.UserPass){this.socks5ChosenAuthType=c.Socks5Auth.UserPass;this.sendSocks5UserPassAuthentication()}else if(e[1]===this.options.proxy.custom_auth_method){this.socks5ChosenAuthType=this.options.proxy.custom_auth_method;this.sendSocks5CustomAuthentication()}else{this.closeSocket(c.ERRORS.InvalidSocks5InitialHandshakeUnknownAuthType)}}}sendSocks5UserPassAuthentication(){const e=this.options.proxy.userId||"";const t=this.options.proxy.password||"";const n=new a.SmartBuffer;n.writeUInt8(1);n.writeUInt8(Buffer.byteLength(e));n.writeString(e);n.writeUInt8(Buffer.byteLength(t));n.writeString(t);this.nextRequiredPacketBufferSize=c.SOCKS_INCOMING_PACKET_SIZES.Socks5UserPassAuthenticationResponse;this.socket.write(n.toBuffer());this.setState(c.SocksClientState.SentAuthentication)}sendSocks5CustomAuthentication(){return s(this,void 0,void 0,(function*(){this.nextRequiredPacketBufferSize=this.options.proxy.custom_auth_response_size;this.socket.write(yield this.options.proxy.custom_auth_request_handler());this.setState(c.SocksClientState.SentAuthentication)}))}handleSocks5CustomAuthHandshakeResponse(e){return s(this,void 0,void 0,(function*(){return yield this.options.proxy.custom_auth_response_handler(e)}))}handleSocks5AuthenticationNoAuthHandshakeResponse(e){return s(this,void 0,void 0,(function*(){return e[1]===0}))}handleSocks5AuthenticationUserPassHandshakeResponse(e){return s(this,void 0,void 0,(function*(){return e[1]===0}))}handleInitialSocks5AuthenticationHandshakeResponse(){return s(this,void 0,void 0,(function*(){this.setState(c.SocksClientState.ReceivedAuthenticationResponse);let e=false;if(this.socks5ChosenAuthType===c.Socks5Auth.NoAuth){e=yield this.handleSocks5AuthenticationNoAuthHandshakeResponse(this.receiveBuffer.get(2))}else if(this.socks5ChosenAuthType===c.Socks5Auth.UserPass){e=yield this.handleSocks5AuthenticationUserPassHandshakeResponse(this.receiveBuffer.get(2))}else if(this.socks5ChosenAuthType===this.options.proxy.custom_auth_method){e=yield this.handleSocks5CustomAuthHandshakeResponse(this.receiveBuffer.get(this.options.proxy.custom_auth_response_size))}if(!e){this.closeSocket(c.ERRORS.Socks5AuthenticationFailed)}else{this.sendSocks5CommandRequest()}}))}sendSocks5CommandRequest(){const e=new a.SmartBuffer;e.writeUInt8(5);e.writeUInt8(c.SocksCommand[this.options.command]);e.writeUInt8(0);if(o.isIPv4(this.options.destination.host)){e.writeUInt8(c.Socks5HostType.IPv4);e.writeBuffer(i.toBuffer(this.options.destination.host))}else if(o.isIPv6(this.options.destination.host)){e.writeUInt8(c.Socks5HostType.IPv6);e.writeBuffer(i.toBuffer(this.options.destination.host))}else{e.writeUInt8(c.Socks5HostType.Hostname);e.writeUInt8(this.options.destination.host.length);e.writeString(this.options.destination.host)}e.writeUInt16BE(this.options.destination.port);this.nextRequiredPacketBufferSize=c.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHeader;this.socket.write(e.toBuffer());this.setState(c.SocksClientState.SentFinalHandshake)}handleSocks5FinalHandshakeResponse(){const e=this.receiveBuffer.peek(5);if(e[0]!==5||e[1]!==c.Socks5Response.Granted){this.closeSocket(`${c.ERRORS.InvalidSocks5FinalHandshakeRejected} - ${c.Socks5Response[e[1]]}`)}else{const t=e[3];let n;let s;if(t===c.Socks5HostType.IPv4){const e=c.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4;if(this.receiveBuffer.lengthe+7,Socks4Response:8};t.SOCKS_INCOMING_PACKET_SIZES=r;var o;(function(e){e[e["connect"]=1]="connect";e[e["bind"]=2]="bind";e[e["associate"]=3]="associate"})(o||(o={}));t.SocksCommand=o;var i;(function(e){e[e["Granted"]=90]="Granted";e[e["Failed"]=91]="Failed";e[e["Rejected"]=92]="Rejected";e[e["RejectedIdent"]=93]="RejectedIdent"})(i||(i={}));t.Socks4Response=i;var a;(function(e){e[e["NoAuth"]=0]="NoAuth";e[e["GSSApi"]=1]="GSSApi";e[e["UserPass"]=2]="UserPass"})(a||(a={}));t.Socks5Auth=a;const c=128;t.SOCKS5_CUSTOM_AUTH_START=c;const u=254;t.SOCKS5_CUSTOM_AUTH_END=u;const f=255;t.SOCKS5_NO_ACCEPTABLE_AUTH=f;var l;(function(e){e[e["Granted"]=0]="Granted";e[e["Failure"]=1]="Failure";e[e["NotAllowed"]=2]="NotAllowed";e[e["NetworkUnreachable"]=3]="NetworkUnreachable";e[e["HostUnreachable"]=4]="HostUnreachable";e[e["ConnectionRefused"]=5]="ConnectionRefused";e[e["TTLExpired"]=6]="TTLExpired";e[e["CommandNotSupported"]=7]="CommandNotSupported";e[e["AddressNotSupported"]=8]="AddressNotSupported"})(l||(l={}));t.Socks5Response=l;var h;(function(e){e[e["IPv4"]=1]="IPv4";e[e["Hostname"]=3]="Hostname";e[e["IPv6"]=4]="IPv6"})(h||(h={}));t.Socks5HostType=h;var d;(function(e){e[e["Created"]=0]="Created";e[e["Connecting"]=1]="Connecting";e[e["Connected"]=2]="Connected";e[e["SentInitialHandshake"]=3]="SentInitialHandshake";e[e["ReceivedInitialHandshakeResponse"]=4]="ReceivedInitialHandshakeResponse";e[e["SentAuthentication"]=5]="SentAuthentication";e[e["ReceivedAuthenticationResponse"]=6]="ReceivedAuthenticationResponse";e[e["SentFinalHandshake"]=7]="SentFinalHandshake";e[e["ReceivedFinalResponse"]=8]="ReceivedFinalResponse";e[e["BoundWaitingForConnection"]=9]="BoundWaitingForConnection";e[e["Established"]=10]="Established";e[e["Disconnected"]=11]="Disconnected";e[e["Error"]=99]="Error"})(d||(d={}));t.SocksClientState=d},833:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.validateSocksClientChainOptions=t.validateSocksClientOptions=void 0;const s=n(453);const r=n(628);const o=n(781);function validateSocksClientOptions(e,t=["connect","bind","associate"]){if(!r.SocksCommand[e.command]){throw new s.SocksClientError(r.ERRORS.InvalidSocksCommand,e)}if(t.indexOf(e.command)===-1){throw new s.SocksClientError(r.ERRORS.InvalidSocksCommandForOperation,e)}if(!isValidSocksRemoteHost(e.destination)){throw new s.SocksClientError(r.ERRORS.InvalidSocksClientOptionsDestination,e)}if(!isValidSocksProxy(e.proxy)){throw new s.SocksClientError(r.ERRORS.InvalidSocksClientOptionsProxy,e)}validateCustomProxyAuth(e.proxy,e);if(e.timeout&&!isValidTimeoutValue(e.timeout)){throw new s.SocksClientError(r.ERRORS.InvalidSocksClientOptionsTimeout,e)}if(e.existing_socket&&!(e.existing_socket instanceof o.Duplex)){throw new s.SocksClientError(r.ERRORS.InvalidSocksClientOptionsExistingSocket,e)}}t.validateSocksClientOptions=validateSocksClientOptions;function validateSocksClientChainOptions(e){if(e.command!=="connect"){throw new s.SocksClientError(r.ERRORS.InvalidSocksCommandChain,e)}if(!isValidSocksRemoteHost(e.destination)){throw new s.SocksClientError(r.ERRORS.InvalidSocksClientOptionsDestination,e)}if(!(e.proxies&&Array.isArray(e.proxies)&&e.proxies.length>=2)){throw new s.SocksClientError(r.ERRORS.InvalidSocksClientOptionsProxiesLength,e)}e.proxies.forEach((t=>{if(!isValidSocksProxy(t)){throw new s.SocksClientError(r.ERRORS.InvalidSocksClientOptionsProxy,e)}validateCustomProxyAuth(t,e)}));if(e.timeout&&!isValidTimeoutValue(e.timeout)){throw new s.SocksClientError(r.ERRORS.InvalidSocksClientOptionsTimeout,e)}}t.validateSocksClientChainOptions=validateSocksClientChainOptions;function validateCustomProxyAuth(e,t){if(e.custom_auth_method!==undefined){if(e.custom_auth_methodr.SOCKS5_CUSTOM_AUTH_END){throw new s.SocksClientError(r.ERRORS.InvalidSocksClientOptionsCustomAuthRange,t)}if(e.custom_auth_request_handler===undefined||typeof e.custom_auth_request_handler!=="function"){throw new s.SocksClientError(r.ERRORS.InvalidSocksClientOptionsCustomAuthOptions,t)}if(e.custom_auth_response_size===undefined){throw new s.SocksClientError(r.ERRORS.InvalidSocksClientOptionsCustomAuthOptions,t)}if(e.custom_auth_response_handler===undefined||typeof e.custom_auth_response_handler!=="function"){throw new s.SocksClientError(r.ERRORS.InvalidSocksClientOptionsCustomAuthOptions,t)}}}function isValidSocksRemoteHost(e){return e&&typeof e.host==="string"&&typeof e.port==="number"&&e.port>=0&&e.port<=65535}function isValidSocksProxy(e){return e&&(typeof e.host==="string"||typeof e.ipaddress==="string")&&typeof e.port==="number"&&e.port>=0&&e.port<=65535&&(e.type===4||e.type===5)}function isValidTimeoutValue(e){return typeof e==="number"&&e>0}},390:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.ReceiveBuffer=void 0;class ReceiveBuffer{constructor(e=4096){this.buffer=Buffer.allocUnsafe(e);this.offset=0;this.originalSize=e}get length(){return this.offset}append(e){if(!Buffer.isBuffer(e)){throw new Error("Attempted to append a non-buffer instance to ReceiveBuffer.")}if(this.offset+e.length>=this.buffer.length){const t=this.buffer;this.buffer=Buffer.allocUnsafe(Math.max(this.buffer.length+this.originalSize,this.buffer.length+e.length));t.copy(this.buffer)}e.copy(this.buffer,this.offset);return this.offset+=e.length}peek(e){if(e>this.offset){throw new Error("Attempted to read beyond the bounds of the managed internal data.")}return this.buffer.slice(0,e)}get(e){if(e>this.offset){throw new Error("Attempted to read beyond the bounds of the managed internal data.")}const t=Buffer.allocUnsafe(e);this.buffer.slice(0,e).copy(t);this.buffer.copyWithin(0,e,e+this.offset-e);this.offset-=e;return t}}t.ReceiveBuffer=ReceiveBuffer},453:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.shuffleArray=t.SocksClientError=void 0;class SocksClientError extends Error{constructor(e,t){super(e);this.options=t}}t.SocksClientError=SocksClientError;function shuffleArray(e){for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}}t.shuffleArray=shuffleArray},651:function(e,t,n){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,n,s){if(s===undefined)s=n;var r=Object.getOwnPropertyDescriptor(t,n);if(!r||("get"in r?!t.__esModule:r.writable||r.configurable)){r={enumerable:true,get:function(){return t[n]}}}Object.defineProperty(e,s,r)}:function(e,t,n,s){if(s===undefined)s=n;e[s]=t[n]});var r=this&&this.__exportStar||function(e,t){for(var n in e)if(n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n))s(t,e,n)};Object.defineProperty(t,"__esModule",{value:true});r(n(650),t)},575:function(e,t,n){"use strict";const s=n(37);const r=n(224);const o=n(592);const{env:i}=process;let a;if(o("no-color")||o("no-colors")||o("color=false")||o("color=never")){a=0}else if(o("color")||o("colors")||o("color=true")||o("color=always")){a=1}if("FORCE_COLOR"in i){if(i.FORCE_COLOR==="true"){a=1}else if(i.FORCE_COLOR==="false"){a=0}else{a=i.FORCE_COLOR.length===0?1:Math.min(parseInt(i.FORCE_COLOR,10),3)}}function translateLevel(e){if(e===0){return false}return{level:e,hasBasic:true,has256:e>=2,has16m:e>=3}}function supportsColor(e,t){if(a===0){return 0}if(o("color=16m")||o("color=full")||o("color=truecolor")){return 3}if(o("color=256")){return 2}if(e&&!t&&a===undefined){return 0}const n=a||0;if(i.TERM==="dumb"){return n}if(process.platform==="win32"){const e=s.release().split(".");if(Number(e[0])>=10&&Number(e[2])>=10586){return Number(e[2])>=14931?3:2}return 1}if("CI"in i){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((e=>e in i))||i.CI_NAME==="codeship"){return 1}return n}if("TEAMCITY_VERSION"in i){return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(i.TEAMCITY_VERSION)?1:0}if(i.COLORTERM==="truecolor"){return 3}if("TERM_PROGRAM"in i){const e=parseInt((i.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(i.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(i.TERM)){return 2}if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(i.TERM)){return 1}if("COLORTERM"in i){return 1}return n}function getSupportLevel(e){const t=supportsColor(e,e&&e.isTTY);return translateLevel(t)}e.exports={supportsColor:getSupportLevel,stdout:translateLevel(supportsColor(true,r.isatty(1))),stderr:translateLevel(supportsColor(true,r.isatty(2)))}},300:function(e){"use strict";e.exports=require("buffer")},523:function(e){"use strict";e.exports=require("dns")},361:function(e){"use strict";e.exports=require("events")},808:function(e){"use strict";e.exports=require("net")},37:function(e){"use strict";e.exports=require("os")},781:function(e){"use strict";e.exports=require("stream")},404:function(e){"use strict";e.exports=require("tls")},224:function(e){"use strict";e.exports=require("tty")},837:function(e){"use strict";e.exports=require("util")}};var t={};function __nccwpck_require__(n){var s=t[n];if(s!==undefined){return s.exports}var r=t[n]={exports:{}};var o=true;try{e[n].call(r.exports,r,r.exports,__nccwpck_require__);o=false}finally{if(o)delete t[n]}return r.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var n=__nccwpck_require__(878);module.exports=n})(); \ No newline at end of file diff --git a/copilot/compiled/socks-proxy-agent/package.json b/copilot/compiled/socks-proxy-agent/package.json new file mode 100644 index 000000000000..3a5ec01b17c3 --- /dev/null +++ b/copilot/compiled/socks-proxy-agent/package.json @@ -0,0 +1 @@ +{"name":"socks-proxy-agent","version":"7.0.0","author":{"email":"nathan@tootallnate.net","name":"Nathan Rajlich","url":"http://n8.io/"},"license":"MIT","typings":"dist/index.d.ts"} diff --git a/copilot/package.json b/copilot/package.json index 9b8910c49f58..6f08a621d2fa 100644 --- a/copilot/package.json +++ b/copilot/package.json @@ -12,10 +12,12 @@ }, "files": [ "bin", - "dist" + "dist", + "compiled" ], "scripts": { "build": "father build", + "build:deps": "umi-scripts bundleDeps", "dev": "father dev", "doctor": "father doctor", "prebundle": "father prebundle", @@ -26,10 +28,24 @@ "@umijs/utils": "workspace:*", "zx": "^7.2.1" }, + "devDependencies": { + "https-proxy-agent": "5.0.1", + "socks-proxy-agent": "7.0.0" + }, "publishConfig": { "access": "public" }, "authors": [ "chencheng (https://github.com/sorrycc)" - ] + ], + "compiledConfig": { + "deps": [ + "https-proxy-agent", + "socks-proxy-agent" + ], + "excludeDtsDeps": [ + "https-proxy-agent", + "socks-proxy-agent" + ] + } } diff --git a/copilot/src/chatgpt.ts b/copilot/src/chatgpt.ts index b52a118c8cee..38d7567cb29f 100644 --- a/copilot/src/chatgpt.ts +++ b/copilot/src/chatgpt.ts @@ -1,4 +1,26 @@ -import { axios } from '@umijs/utils'; +import { axios, chalk, logger } from '@umijs/utils'; +// @ts-ignore +import HttpsProxyAgent from '../compiled/https-proxy-agent'; +// @ts-ignore +import { SocksProxyAgent } from '../compiled/socks-proxy-agent'; + +// for system proxy +const httpProxyUri = process.env.HTTPS_PROXY || process.env.HTTP_PROXY; +const socksProxyUri = process.env.ALL_PROXY; + +let axiosProxy: ReturnType | null = null; + +if (socksProxyUri) { + axiosProxy = axios.create({ + proxy: false, + httpsAgent: new SocksProxyAgent(socksProxyUri), + }); +} else if (httpProxyUri) { + axiosProxy = axios.create({ + proxy: false, + httpsAgent: new HttpsProxyAgent(httpProxyUri), + }); +} interface IMessage { role: 'system' | 'user' | 'assistant'; @@ -47,9 +69,11 @@ export async function sendMessage(opts: { timeout?: number; }) { const apiUrl = getApiUrl(opts.proxyUrl); + const axiosInstance = axiosProxy || axios; + let res: any = null; try { - res = await axios.post( + res = await axiosInstance.post( apiUrl, { ...requestParamsBase, @@ -70,6 +94,15 @@ export async function sendMessage(opts: { if (opts.controller?.signal.aborted === true) { // 用户手动取消了请求 } else { + if (e.message.includes('timeout')) { + logger.fatal(e.message); + logger.warn('Request is too slow or cannot be requested'); + logger.warn( + `Recommended to use a proxy host by passing ${chalk.yellow( + '--proxy-url', + )}`, + ); + } throw new Error('Network Error'); } } diff --git a/copilot/src/cli.ts b/copilot/src/cli.ts index 703239276942..edd4d951014a 100644 --- a/copilot/src/cli.ts +++ b/copilot/src/cli.ts @@ -1,7 +1,7 @@ import { chalk, clackPrompts, logger, resolve, yParser } from '@umijs/utils'; import { sendMessage } from './chatgpt'; -import { SYSTEM_PROMPT } from './constants'; import { printHelp } from './printHelp'; +import prompts from './prompts'; const { confirm, spinner } = clackPrompts; export async function main() { @@ -27,23 +27,53 @@ export async function main() { const message = args._.join(' '); const s = spinner(); s.start('🕖 Hold on, asking OpenAI...'); - const res = await sendMessage({ + + const commonParams = { + token, + proxyUrl: args.proxyUrl, + }; + + const commandRes = await sendMessage({ messages: [ { role: 'system', - content: SYSTEM_PROMPT, + content: prompts.commands, }, { role: 'user', content: message, }, ], - token, - // --proxy-url - proxyUrl: args.proxyUrl, + ...commonParams, + }); + const willUseCommand: string = commandRes.data.choices[0].message.content; + + if (!prompts[willUseCommand]) { + logger.warn(willUseCommand); + throw new Error('No matching command'); + } + + const questionRes = await sendMessage({ + messages: [ + { + role: 'system', + content: `${prompts[willUseCommand]}.无法根据要求返回命令时,给出提示`, + }, + { + role: 'user', + content: message, + }, + ], + ...commonParams, }); s.stop(); - const command = res.data.choices[0].message.content; + const command = questionRes.data.choices[0].message.content; + + if (!/^[\w\s=\-'"{}:.]+$/.test(command)) { + logger.warn(command); + return; + } + logger.info('The suggested command is:'); logger.info(chalk.green(command)); diff --git a/copilot/src/prompts/build.ts b/copilot/src/prompts/build.ts new file mode 100644 index 000000000000..5754088f5bdc --- /dev/null +++ b/copilot/src/prompts/build.ts @@ -0,0 +1,10 @@ +const BUILD_PROMPT = ` +umi build 命令用于构建项目.有以下功能: +- 通过COMPRESS环境变量值为 none,让构建不进行压缩。 + +环境变量需要在命令前传递,如:COMPRESS=none umi build + +基于以上知识,根据我的要求,返回我应该使用的命令,只需返回这条命令,不包括任何其他信息,不做任何提示 +`; + +export default BUILD_PROMPT; diff --git a/copilot/src/prompts/commands.ts b/copilot/src/prompts/commands.ts new file mode 100644 index 000000000000..0aa5c3162ecf --- /dev/null +++ b/copilot/src/prompts/commands.ts @@ -0,0 +1,10 @@ +const COMMAND_PROMPT = ` +umi 命令行有以下功能: +- dev 启动本地开发服务器,进行项目的开发与调试 +- build 构建项目 +- generate 创建或生成文件,以使某些功能生效,可用于生效ts +- config 查看所有或某个配置,或修改删除某个配置 +基于以上知识,根据我的要求,返回我应该使用的命令,只返回命令名称,如:dev,不清楚用哪个命令时统一用config,不需要任何其他信息 +`; + +export default COMMAND_PROMPT; diff --git a/copilot/src/prompts/config.ts b/copilot/src/prompts/config.ts new file mode 100644 index 000000000000..a39c53695085 --- /dev/null +++ b/copilot/src/prompts/config.ts @@ -0,0 +1,40 @@ +const CONFIG_PROMPT = ` +umi config 命令用于查看或修改配置,有以下功能: +- 传递 list 参数,列举当前项目所有配置 +- 传递 get,配置名,两个参数查看该配置的具体值 +- 传递 set,配置名,配置值,三个参数修改配置 +- 传递 remove,配置名,配置值,三个参数去除配置 + +配置的ts类型如下,类型属性对应配置名: +\` +interface IConfig { + alias?: Record; + autoCSSModules?: boolean; + base?: string; + /** copy file to dist */ + copy?: { from: string; to: string; }[] | string[]; + cssLoader?: { [key: string]: any }; + cssMinifier?: "esbuild" | "none" | "cssnano" | "pacelCSS"; + define?: { [key: string]: any }; + depTranspiler?: "babel" | "swc" | "esbuild" | "none"; + /** change source-map type */ + devtool: 'eval'|'eval-cheap-source-map'|'eval-cheap-module-source-map'|'eval-source-map'|'cheap-source-map'|'cheap-module-source-map'|'source-map'|'inline-cheap-source-map'|'inline-cheap-module-source-map'|'inline-source-map'; + hash?: boolean; + ignoreMomentLocale?: boolean; + jsMinifier?: "swc" | "esbuild" | "none" | "terser" | "uglifyJs"; + jsMinifierOptions?: { [key: string]: any }; + lessLoader?: { lessOptions: any }; + mfsu?: {} | false; + outputPath?: string; + polyfill?: any; + publicPath?: string; + sassLoader?: { [key: string]: any }; + targets?: { [key: string]: any }; + writeToDisk?: boolean; + babelLoaderCustomize?: string; + esbuildMinifyIIFE?: boolean; +} +\` +基于以上知识,根据我的要求,返回我应该使用的命令,只需返回这条命令,不包括任何其他信息,不做任何提示 +`; +export default CONFIG_PROMPT; diff --git a/copilot/src/prompts/dev.ts b/copilot/src/prompts/dev.ts new file mode 100644 index 000000000000..be5ff2fdbe61 --- /dev/null +++ b/copilot/src/prompts/dev.ts @@ -0,0 +1,13 @@ +const DEV_PROMPT = ` +umi dev 命令用于启动本地开发服务器.有以下功能: +- 通过PORT 环境变量指定开发服务器启动指定端口 +- 通过MOCK 环境变量为none,来去除mock + +环境变量的使用方法是在命令之前加入环境变量,如: +PORT=10 umi dev +MOCK=none umi dev + +基于以上知识,根据我的要求,返回我应该使用的命令,只需返回这条命令,不包括任何其他信息,不做任何提示 +`; + +export default DEV_PROMPT; diff --git a/copilot/src/prompts/generate.ts b/copilot/src/prompts/generate.ts new file mode 100644 index 000000000000..03eb5367a3c0 --- /dev/null +++ b/copilot/src/prompts/generate.ts @@ -0,0 +1,9 @@ +const GEN_PROMPT = ` +umi g 用于增量生成文件或启用功能,有以下功能: +- 不加任何参数,直接执行选择 +- 通过参数tsconfig,启用typescript + +基于以上知识,根据我的要求,返回我应该使用的命令,只需返回这条命令,不包括任何其他信息,不做任何提示 +`; + +export default GEN_PROMPT; diff --git a/copilot/src/prompts/index.ts b/copilot/src/prompts/index.ts new file mode 100644 index 000000000000..a976322b0655 --- /dev/null +++ b/copilot/src/prompts/index.ts @@ -0,0 +1,15 @@ +import build from './build'; +import commands from './commands'; +import config from './config'; +import dev from './dev'; +import generate from './generate'; + +const prompts: Record = { + commands, + dev, + build, + generate, + config, +}; + +export default prompts; diff --git a/packages/plugins/libs/qiankun/master/MicroApp.tsx b/packages/plugins/libs/qiankun/master/MicroApp.tsx index 2e7046fc8291..6b47d4a905a5 100644 --- a/packages/plugins/libs/qiankun/master/MicroApp.tsx +++ b/packages/plugins/libs/qiankun/master/MicroApp.tsx @@ -58,14 +58,17 @@ export type Props = { className?: string; } & Record; -function unmountMicroApp(microApp?: MicroAppType, updatingPromise?: Promise) { +function unmountMicroApp( + microApp?: MicroAppType, + updatingPromise?: Promise, +) { if (microApp) { microApp.mountPromise.then(() => { switch (microApp.getStatus()) { - case "MOUNTED": + case 'MOUNTED': microApp.unmount(); break; - case "UPDATING": + case 'UPDATING': // UPDATING 阶段 updatingPromise 一定存在 updatingPromise!.then(() => microApp.unmount()); break; @@ -156,7 +159,10 @@ export const MicroApp = forwardRef( const stateForSlave = (useModel || noop)( qiankunStateForSlaveModelNamespace, ); - const { entry, props: { settings: settingsFromConfig = {}, ...propsFromConfig } = {} } = appConfig || {}; + const { + entry, + props: { settings: settingsFromConfig = {}, ...propsFromConfig } = {}, + } = appConfig || {}; useEffect(() => { setComponentError(null); @@ -225,7 +231,8 @@ export const MicroApp = forwardRef( }, ); - return () => unmountMicroApp(microAppRef.current, updatingPromise.current); + return () => + unmountMicroApp(microAppRef.current, updatingPromise.current); }, [name]); useEffect(() => { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 153de259aa6f..ea5ba2e90ed4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -214,6 +214,13 @@ importers: zx: specifier: ^7.2.1 version: 7.2.1 + devDependencies: + https-proxy-agent: + specifier: 5.0.1 + version: 5.0.1 + socks-proxy-agent: + specifier: 7.0.0 + version: 7.0.0 did-you-know: devDependencies: @@ -18210,6 +18217,7 @@ packages: /commander@2.20.3: resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} + requiresBuild: true /commander@3.0.2: resolution: {integrity: sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow==} diff --git a/scripts/bundleDeps.ts b/scripts/bundleDeps.ts index dce688282e0c..7f8cc09ffd87 100644 --- a/scripts/bundleDeps.ts +++ b/scripts/bundleDeps.ts @@ -177,7 +177,9 @@ Object.keys(exported).forEach(function (key) { code.includes('"node:') && opts.pkgName && // skip local file bundle like babel/bundle.js opts.pkgName !== 'stylelint-declaration-block-no-ignored-properties' && - opts.pkgName !== 'vite' + opts.pkgName !== 'vite' && + opts.pkgName !== 'https-proxy-agent' && + opts.pkgName !== 'socks-proxy-agent' ) { throw new Error(`${opts.pkgName} has "node:"`); }