@onyxsecurity/mcp-gateway 1.0.29 → 1.0.30

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.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{AccessControlBlockError as e,BUILD_TIME_CONFIG as t,Client as n,ConfigurationError as r,ProcessSpawnError as i,ProxyConnectionError as a,ReadBuffer as o,SSEClientTransport as s,Server as c,StdioServerTransport as l,StreamableHTTPClientTransport as u,TransportError as d,UnauthorizedError as f,__commonJSMin as p,__toESM as m,addBreadcrumbSafe as h,addGlobalTags as g,captureExceptionSafe as _,compressClientInfo as v,config as y,createParser as b,discoverAuthorizationServerMetadata as ee,discoverOAuthProtectedResourceMetadata as te,exchangeAuthorization as ne,getSessionData as re,initSentrySafe as x,initializeTrafficMirror as ie,logger as S,proxyServer as C,refreshAuthorization as ae,registerClient as oe,serializeMessage as se,startAuthorization as ce,startHTTPServer as le}from"../stdio-BLIz92Ri.js";import"../pkce-BlbkGwOt.js";import{createRequire as ue}from"node:module";import{readFileSync as de,readdirSync as fe}from"node:fs";import{join as pe}from"node:path";import{platform as me}from"node:os";import{createHash as w}from"node:crypto";import{basename as he,dirname as ge,extname as _e,join as ve,normalize as ye,relative as be,resolve as xe}from"path";import{format as Se,inspect as Ce}from"util";import{fileURLToPath as we}from"url";import{createServer as Te}from"node:http";import{setTimeout as Ee}from"node:timers";import De from"node:util";import{notStrictEqual as Oe,strictEqual as ke}from"assert";import{readFileSync as Ae,readdirSync as je,statSync as Me,writeFile as Ne}from"fs";import{execFile as Pe,spawn as Fe}from"node:child_process";import{URL as Ie}from"node:url";import{chmod as Le,mkdir as Re,readFile as ze,rm as Be,writeFile as Ve}from"node:fs/promises";import{PassThrough as He,Transform as Ue}from"node:stream";var We=class extends Event{constructor(e,t){super(e),this.code=t?.code??void 0,this.message=t?.message??void 0}[Symbol.for(`nodejs.util.inspect.custom`)](e,t,n){return n(qe(this),t)}[Symbol.for(`Deno.customInspect`)](e,t){return e(qe(this),t)}};function Ge(e){let t=globalThis.DOMException;return typeof t==`function`?new t(e,`SyntaxError`):SyntaxError(e)}function Ke(e){return e instanceof Error?`errors`in e&&Array.isArray(e.errors)?e.errors.map(Ke).join(`, `):`cause`in e&&e.cause instanceof Error?`${e}: ${Ke(e.cause)}`:e.message:`${e}`}function qe(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var Je=e=>{throw TypeError(e)},Ye=(e,t,n)=>t.has(e)||Je(`Cannot `+n),T=(e,t,n)=>(Ye(e,t,`read from private field`),n?n.call(e):t.get(e)),E=(e,t,n)=>t.has(e)?Je(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),D=(e,t,n,r)=>(Ye(e,t,`write to private field`),t.set(e,n),n),Xe=(e,t,n)=>(Ye(e,t,`access private method`),n),O,Ze,Qe,$e,et,tt,nt,rt,it,at,ot,st,ct,lt,ut,dt,ft,pt,mt,ht,gt,_t,vt,yt=class extends EventTarget{constructor(e,t){super(),E(this,lt),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,E(this,O),E(this,Ze),E(this,Qe),E(this,$e),E(this,et),E(this,tt),E(this,nt),E(this,rt,null),E(this,it),E(this,at),E(this,ot,null),E(this,st,null),E(this,ct,null),E(this,dt,async e=>{var t;T(this,at).reset();let{body:n,redirected:r,status:i,headers:a}=e;if(i===204){Xe(this,lt,gt).call(this,`Server sent HTTP 204, not reconnecting`,204),this.close();return}if(r?D(this,Qe,new URL(e.url)):D(this,Qe,void 0),i!==200){Xe(this,lt,gt).call(this,`Non-200 status code (${i})`,i);return}if(!(a.get(`content-type`)||``).startsWith(`text/event-stream`)){Xe(this,lt,gt).call(this,`Invalid content type, expected "text/event-stream"`,i);return}if(T(this,O)===this.CLOSED)return;D(this,O,this.OPEN);let o=new Event(`open`);if((t=T(this,ct))==null||t.call(this,o),this.dispatchEvent(o),typeof n!=`object`||!n||!(`getReader`in n)){Xe(this,lt,gt).call(this,`Invalid response body, expected a web ReadableStream`,i),this.close();return}let s=new TextDecoder,c=n.getReader(),l=!0;do{let{done:e,value:t}=await c.read();t&&T(this,at).feed(s.decode(t,{stream:!e})),e&&(l=!1,T(this,at).reset(),Xe(this,lt,_t).call(this))}while(l)}),E(this,ft,e=>{D(this,it,void 0),!(e.name===`AbortError`||e.type===`aborted`)&&Xe(this,lt,_t).call(this,Ke(e))}),E(this,mt,e=>{typeof e.id==`string`&&D(this,rt,e.id);let t=new MessageEvent(e.event||`message`,{data:e.data,origin:T(this,Qe)?T(this,Qe).origin:T(this,Ze).origin,lastEventId:e.id||``});T(this,st)&&(!e.event||e.event===`message`)&&T(this,st).call(this,t),this.dispatchEvent(t)}),E(this,ht,e=>{D(this,tt,e)}),E(this,vt,()=>{D(this,nt,void 0),T(this,O)===this.CONNECTING&&Xe(this,lt,ut).call(this)});try{if(e instanceof URL)D(this,Ze,e);else if(typeof e==`string`)D(this,Ze,new URL(e,bt()));else throw Error(`Invalid URL`)}catch{throw Ge(`An invalid or illegal string was specified`)}D(this,at,b({onEvent:T(this,mt),onRetry:T(this,ht)})),D(this,O,this.CONNECTING),D(this,tt,3e3),D(this,et,t?.fetch??globalThis.fetch),D(this,$e,t?.withCredentials??!1),Xe(this,lt,ut).call(this)}get readyState(){return T(this,O)}get url(){return T(this,Ze).href}get withCredentials(){return T(this,$e)}get onerror(){return T(this,ot)}set onerror(e){D(this,ot,e)}get onmessage(){return T(this,st)}set onmessage(e){D(this,st,e)}get onopen(){return T(this,ct)}set onopen(e){D(this,ct,e)}addEventListener(e,t,n){let r=t;super.addEventListener(e,r,n)}removeEventListener(e,t,n){let r=t;super.removeEventListener(e,r,n)}close(){T(this,nt)&&clearTimeout(T(this,nt)),T(this,O)!==this.CLOSED&&(T(this,it)&&T(this,it).abort(),D(this,O,this.CLOSED),D(this,it,void 0))}};O=new WeakMap,Ze=new WeakMap,Qe=new WeakMap,$e=new WeakMap,et=new WeakMap,tt=new WeakMap,nt=new WeakMap,rt=new WeakMap,it=new WeakMap,at=new WeakMap,ot=new WeakMap,st=new WeakMap,ct=new WeakMap,lt=new WeakSet,ut=function(){D(this,O,this.CONNECTING),D(this,it,new AbortController),T(this,et)(T(this,Ze),Xe(this,lt,pt).call(this)).then(T(this,dt)).catch(T(this,ft))},dt=new WeakMap,ft=new WeakMap,pt=function(){let e={mode:`cors`,redirect:`follow`,headers:{Accept:`text/event-stream`,...T(this,rt)?{"Last-Event-ID":T(this,rt)}:void 0},cache:`no-store`,signal:T(this,it)?.signal};return`window`in globalThis&&(e.credentials=this.withCredentials?`include`:`same-origin`),e},mt=new WeakMap,ht=new WeakMap,gt=function(e,t){var n;T(this,O)!==this.CLOSED&&D(this,O,this.CLOSED);let r=new We(`error`,{code:t,message:e});(n=T(this,ot))==null||n.call(this,r),this.dispatchEvent(r)},_t=function(e,t){var n;if(T(this,O)===this.CLOSED)return;D(this,O,this.CONNECTING);let r=new We(`error`,{code:t,message:e});(n=T(this,ot))==null||n.call(this,r),this.dispatchEvent(r),D(this,nt,setTimeout(T(this,vt),T(this,tt)))},vt=new WeakMap,yt.CONNECTING=0,yt.OPEN=1,yt.CLOSED=2;function bt(){let e=`document`in globalThis?globalThis.document:void 0;return e&&typeof e==`object`&&`baseURI`in e&&typeof e.baseURI==`string`?e.baseURI:void 0}const xt={right:Et,center:Dt};var St=class{constructor(e){this.width=e.width,this.wrap=e.wrap??!0,this.rows=[]}span(...e){let t=this.div(...e);t.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0&&this.div(``),this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]==`string`)return this.applyLayoutDSL(e[0]);let t=e.map(e=>typeof e==`string`?this.colFromString(e):e);return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]==`string`&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let t=e.split(`
2
+ import{AccessControlBlockError as e,BUILD_TIME_CONFIG as t,Client as n,ConfigurationError as r,ProcessSpawnError as i,ProxyConnectionError as a,ReadBuffer as o,SSEClientTransport as s,Server as c,StdioServerTransport as l,StreamableHTTPClientTransport as u,TransportError as d,UnauthorizedError as f,__commonJSMin as p,__toESM as m,addBreadcrumbSafe as h,addGlobalTags as g,captureExceptionSafe as _,compressClientInfo as v,config as y,createParser as b,discoverAuthorizationServerMetadata as ee,discoverOAuthProtectedResourceMetadata as te,exchangeAuthorization as ne,getSessionData as re,initSentrySafe as x,initializeTrafficMirror as ie,logger as S,proxyServer as C,refreshAuthorization as ae,registerClient as oe,serializeMessage as se,startAuthorization as ce,startHTTPServer as le}from"../stdio-MCoGGhXw.js";import"../pkce-BlbkGwOt.js";import{createRequire as ue}from"node:module";import{readFileSync as de,readdirSync as fe}from"node:fs";import{join as pe}from"node:path";import{platform as me}from"node:os";import{createHash as w}from"node:crypto";import{basename as he,dirname as ge,extname as _e,join as ve,normalize as ye,relative as be,resolve as xe}from"path";import{format as Se,inspect as Ce}from"util";import{fileURLToPath as we}from"url";import{createServer as Te}from"node:http";import{setTimeout as Ee}from"node:timers";import De from"node:util";import{notStrictEqual as Oe,strictEqual as ke}from"assert";import{readFileSync as Ae,readdirSync as je,statSync as Me,writeFile as Ne}from"fs";import{execFile as Pe,spawn as Fe}from"node:child_process";import{URL as Ie}from"node:url";import{chmod as Le,mkdir as Re,readFile as ze,rm as Be,writeFile as Ve}from"node:fs/promises";import{PassThrough as He,Transform as Ue}from"node:stream";var We=class extends Event{constructor(e,t){super(e),this.code=t?.code??void 0,this.message=t?.message??void 0}[Symbol.for(`nodejs.util.inspect.custom`)](e,t,n){return n(qe(this),t)}[Symbol.for(`Deno.customInspect`)](e,t){return e(qe(this),t)}};function Ge(e){let t=globalThis.DOMException;return typeof t==`function`?new t(e,`SyntaxError`):SyntaxError(e)}function Ke(e){return e instanceof Error?`errors`in e&&Array.isArray(e.errors)?e.errors.map(Ke).join(`, `):`cause`in e&&e.cause instanceof Error?`${e}: ${Ke(e.cause)}`:e.message:`${e}`}function qe(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var Je=e=>{throw TypeError(e)},Ye=(e,t,n)=>t.has(e)||Je(`Cannot `+n),T=(e,t,n)=>(Ye(e,t,`read from private field`),n?n.call(e):t.get(e)),E=(e,t,n)=>t.has(e)?Je(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),D=(e,t,n,r)=>(Ye(e,t,`write to private field`),t.set(e,n),n),Xe=(e,t,n)=>(Ye(e,t,`access private method`),n),O,Ze,Qe,$e,et,tt,nt,rt,it,at,ot,st,ct,lt,ut,dt,ft,pt,mt,ht,gt,_t,vt,yt=class extends EventTarget{constructor(e,t){super(),E(this,lt),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,E(this,O),E(this,Ze),E(this,Qe),E(this,$e),E(this,et),E(this,tt),E(this,nt),E(this,rt,null),E(this,it),E(this,at),E(this,ot,null),E(this,st,null),E(this,ct,null),E(this,dt,async e=>{var t;T(this,at).reset();let{body:n,redirected:r,status:i,headers:a}=e;if(i===204){Xe(this,lt,gt).call(this,`Server sent HTTP 204, not reconnecting`,204),this.close();return}if(r?D(this,Qe,new URL(e.url)):D(this,Qe,void 0),i!==200){Xe(this,lt,gt).call(this,`Non-200 status code (${i})`,i);return}if(!(a.get(`content-type`)||``).startsWith(`text/event-stream`)){Xe(this,lt,gt).call(this,`Invalid content type, expected "text/event-stream"`,i);return}if(T(this,O)===this.CLOSED)return;D(this,O,this.OPEN);let o=new Event(`open`);if((t=T(this,ct))==null||t.call(this,o),this.dispatchEvent(o),typeof n!=`object`||!n||!(`getReader`in n)){Xe(this,lt,gt).call(this,`Invalid response body, expected a web ReadableStream`,i),this.close();return}let s=new TextDecoder,c=n.getReader(),l=!0;do{let{done:e,value:t}=await c.read();t&&T(this,at).feed(s.decode(t,{stream:!e})),e&&(l=!1,T(this,at).reset(),Xe(this,lt,_t).call(this))}while(l)}),E(this,ft,e=>{D(this,it,void 0),!(e.name===`AbortError`||e.type===`aborted`)&&Xe(this,lt,_t).call(this,Ke(e))}),E(this,mt,e=>{typeof e.id==`string`&&D(this,rt,e.id);let t=new MessageEvent(e.event||`message`,{data:e.data,origin:T(this,Qe)?T(this,Qe).origin:T(this,Ze).origin,lastEventId:e.id||``});T(this,st)&&(!e.event||e.event===`message`)&&T(this,st).call(this,t),this.dispatchEvent(t)}),E(this,ht,e=>{D(this,tt,e)}),E(this,vt,()=>{D(this,nt,void 0),T(this,O)===this.CONNECTING&&Xe(this,lt,ut).call(this)});try{if(e instanceof URL)D(this,Ze,e);else if(typeof e==`string`)D(this,Ze,new URL(e,bt()));else throw Error(`Invalid URL`)}catch{throw Ge(`An invalid or illegal string was specified`)}D(this,at,b({onEvent:T(this,mt),onRetry:T(this,ht)})),D(this,O,this.CONNECTING),D(this,tt,3e3),D(this,et,t?.fetch??globalThis.fetch),D(this,$e,t?.withCredentials??!1),Xe(this,lt,ut).call(this)}get readyState(){return T(this,O)}get url(){return T(this,Ze).href}get withCredentials(){return T(this,$e)}get onerror(){return T(this,ot)}set onerror(e){D(this,ot,e)}get onmessage(){return T(this,st)}set onmessage(e){D(this,st,e)}get onopen(){return T(this,ct)}set onopen(e){D(this,ct,e)}addEventListener(e,t,n){let r=t;super.addEventListener(e,r,n)}removeEventListener(e,t,n){let r=t;super.removeEventListener(e,r,n)}close(){T(this,nt)&&clearTimeout(T(this,nt)),T(this,O)!==this.CLOSED&&(T(this,it)&&T(this,it).abort(),D(this,O,this.CLOSED),D(this,it,void 0))}};O=new WeakMap,Ze=new WeakMap,Qe=new WeakMap,$e=new WeakMap,et=new WeakMap,tt=new WeakMap,nt=new WeakMap,rt=new WeakMap,it=new WeakMap,at=new WeakMap,ot=new WeakMap,st=new WeakMap,ct=new WeakMap,lt=new WeakSet,ut=function(){D(this,O,this.CONNECTING),D(this,it,new AbortController),T(this,et)(T(this,Ze),Xe(this,lt,pt).call(this)).then(T(this,dt)).catch(T(this,ft))},dt=new WeakMap,ft=new WeakMap,pt=function(){let e={mode:`cors`,redirect:`follow`,headers:{Accept:`text/event-stream`,...T(this,rt)?{"Last-Event-ID":T(this,rt)}:void 0},cache:`no-store`,signal:T(this,it)?.signal};return`window`in globalThis&&(e.credentials=this.withCredentials?`include`:`same-origin`),e},mt=new WeakMap,ht=new WeakMap,gt=function(e,t){var n;T(this,O)!==this.CLOSED&&D(this,O,this.CLOSED);let r=new We(`error`,{code:t,message:e});(n=T(this,ot))==null||n.call(this,r),this.dispatchEvent(r)},_t=function(e,t){var n;if(T(this,O)===this.CLOSED)return;D(this,O,this.CONNECTING);let r=new We(`error`,{code:t,message:e});(n=T(this,ot))==null||n.call(this,r),this.dispatchEvent(r),D(this,nt,setTimeout(T(this,vt),T(this,tt)))},vt=new WeakMap,yt.CONNECTING=0,yt.OPEN=1,yt.CLOSED=2;function bt(){let e=`document`in globalThis?globalThis.document:void 0;return e&&typeof e==`object`&&`baseURI`in e&&typeof e.baseURI==`string`?e.baseURI:void 0}const xt={right:Et,center:Dt};var St=class{constructor(e){this.width=e.width,this.wrap=e.wrap??!0,this.rows=[]}span(...e){let t=this.div(...e);t.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0&&this.div(``),this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]==`string`)return this.applyLayoutDSL(e[0]);let t=e.map(e=>typeof e==`string`?this.colFromString(e):e);return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]==`string`&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let t=e.split(`
3
3
  `).map(e=>e.split(` `)),n=0;return t.forEach(e=>{e.length>1&&k.stringWidth(e[0])>n&&(n=Math.min(Math.floor(this.width*.5),k.stringWidth(e[0])))}),t.forEach(e=>{this.div(...e.map((t,r)=>({text:t.trim(),padding:this.measurePadding(t),width:r===0&&e.length>1?n:void 0})))}),this.rows[this.rows.length-1]}colFromString(e){return{text:e,padding:this.measurePadding(e)}}measurePadding(e){let t=k.stripAnsi(e);return[0,t.match(/\s*$/)[0].length,0,t.match(/^\s*/)[0].length]}toString(){let e=[];return this.rows.forEach(t=>{this.rowToString(t,e)}),e.filter(e=>!e.hidden).map(e=>e.text).join(`
4
4
  `)}rowToString(e,t){return this.rasterize(e).forEach((n,r)=>{let i=``;n.forEach((n,a)=>{let{width:o}=e[a],s=this.negatePadding(e[a]),c=n;if(s>k.stringWidth(n)&&(c+=` `.repeat(s-k.stringWidth(n))),e[a].align&&e[a].align!==`left`&&this.wrap){let t=xt[e[a].align];c=t(c,s),k.stringWidth(c)<s&&(c+=` `.repeat((o||0)-k.stringWidth(c)-1))}let l=e[a].padding||[0,0,0,0];l[3]&&(i+=` `.repeat(l[3])),i+=Ct(e[a],c,`| `),i+=c,i+=Ct(e[a],c,` |`),l[1]&&(i+=` `.repeat(l[1])),r===0&&t.length>0&&(i=this.renderInline(i,t[t.length-1]))}),t.push({text:i.replace(/ +$/,``),span:e.span})}),t}renderInline(e,t){let n=e.match(/^ */),r=n?n[0].length:0,i=t.text,a=k.stringWidth(i.trimRight());return t.span?this.wrap?r<a?e:(t.hidden=!0,i.trimRight()+` `.repeat(r-a)+e.trimLeft()):(t.hidden=!0,i+e):e}rasterize(e){let t=[],n=this.columnWidths(e),r;return e.forEach((e,i)=>{e.width=n[i],r=this.wrap?k.wrap(e.text,this.negatePadding(e),{hard:!0}).split(`
5
5
  `):e.text.split(`
@@ -89,7 +89,7 @@ complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name
89
89
  `)}`:``;t.fail(i(`Missing required argument: %s`,`Missing required arguments: %s`,Object.keys(r).length,Object.keys(r).join(`, `)+n))}},a.unknownArguments=function(n,r,o,s,c=!0){let l=e.getInternalMethods().getCommandInstance().getCommands(),u=[],d=e.getInternalMethods().getContext();if(Object.keys(n).forEach(t=>{!Tr.includes(t)&&!Object.prototype.hasOwnProperty.call(o,t)&&!Object.prototype.hasOwnProperty.call(e.getInternalMethods().getParseContext(),t)&&!a.isValidAndSomeAliasIsNotNew(t,r)&&u.push(t)}),c&&(d.commands.length>0||l.length>0||s)&&n._.slice(d.commands.length).forEach(e=>{l.includes(``+e)||u.push(``+e)}),c){let t=e.getDemandedCommands()._?.max||0,r=d.commands.length+t;r<n._.length&&n._.slice(r).forEach(e=>{e=String(e),!d.commands.includes(e)&&!u.includes(e)&&u.push(e)})}u.length&&t.fail(i(`Unknown argument: %s`,`Unknown arguments: %s`,u.length,u.map(e=>e.trim()?e:`"${e}"`).join(`, `)))},a.unknownCommands=function(n){let r=e.getInternalMethods().getCommandInstance().getCommands(),a=[],o=e.getInternalMethods().getContext();return(o.commands.length>0||r.length>0)&&n._.slice(o.commands.length).forEach(e=>{r.includes(``+e)||a.push(``+e)}),a.length>0?(t.fail(i(`Unknown command: %s`,`Unknown commands: %s`,a.length,a.join(`, `))),!0):!1},a.isValidAndSomeAliasIsNotNew=function(t,n){if(!Object.prototype.hasOwnProperty.call(n,t))return!1;let r=e.parsed.newAliases;return[t,...n[t]].some(e=>!Object.prototype.hasOwnProperty.call(r,e)||!r[t])},a.limitedChoices=function(n){let i=e.getOptions(),a={};if(!Object.keys(i.choices).length)return;Object.keys(n).forEach(e=>{Tr.indexOf(e)===-1&&Object.prototype.hasOwnProperty.call(i.choices,e)&&[].concat(n[e]).forEach(t=>{i.choices[e].indexOf(t)===-1&&t!==void 0&&(a[e]=(a[e]||[]).concat(t))})});let o=Object.keys(a);if(!o.length)return;let s=r(`Invalid values:`);o.forEach(e=>{s+=`\n ${r(`Argument: %s, Given: %s, Choices: %s`,e,t.stringifiedValues(a[e]),t.stringifiedValues(i.choices[e]))}`}),t.fail(s)};let o={};a.implies=function(t,r){N(`<string|object> [array|number|string]`,[t,r],arguments.length),typeof t==`object`?Object.keys(t).forEach(e=>{a.implies(e,t[e])}):(e.global(t),o[t]||(o[t]=[]),Array.isArray(r)?r.forEach(e=>a.implies(t,e)):(Kn(r,void 0,n),o[t].push(r)))},a.getImplied=function(){return o};function s(e,t){let n=Number(t);return t=isNaN(n)?t:n,typeof t==`number`?t=e._.length>=t:t.match(/^--no-.+/)?(t=t.match(/^--no-(.+)/)[1],t=!Object.prototype.hasOwnProperty.call(e,t)):t=Object.prototype.hasOwnProperty.call(e,t),t}a.implications=function(e){let n=[];if(Object.keys(o).forEach(t=>{let r=t;(o[t]||[]).forEach(t=>{let i=r,a=t;i=s(e,i),t=s(e,t),i&&!t&&n.push(` ${r} -> ${a}`)})}),n.length){let e=`${r(`Implications failed:`)}\n`;n.forEach(t=>{e+=t}),t.fail(e)}};let c={};a.conflicts=function(t,n){N(`<string|object> [array|string]`,[t,n],arguments.length),typeof t==`object`?Object.keys(t).forEach(e=>{a.conflicts(e,t[e])}):(e.global(t),c[t]||(c[t]=[]),Array.isArray(n)?n.forEach(e=>a.conflicts(t,e)):c[t].push(n))},a.getConflicting=()=>c,a.conflicting=function(i){Object.keys(i).forEach(e=>{c[e]&&c[e].forEach(n=>{n&&i[e]!==void 0&&i[n]!==void 0&&t.fail(r(`Arguments %s and %s are mutually exclusive`,e,n))})}),e.getInternalMethods().getParserConfiguration()[`strip-dashed`]&&Object.keys(c).forEach(e=>{c[e].forEach(a=>{a&&i[n.Parser.camelCase(e)]!==void 0&&i[n.Parser.camelCase(a)]!==void 0&&t.fail(r(`Arguments %s and %s are mutually exclusive`,e,a))})})},a.recommendCommands=function(e,n){n=n.sort((e,t)=>t.length-e.length);let i=null,a=1/0;for(let t=0,r;(r=n[t])!==void 0;t++){let t=wr(e,r);t<=3&&t<a&&(a=t,i=r)}i&&t.fail(r(`Did you mean %s?`,i))},a.reset=function(e){return o=fr(o,t=>!e[t]),c=fr(c,t=>!e[t]),a};let l=[];return a.freeze=function(){l.push({implied:o,conflicting:c})},a.unfreeze=function(){let e=l.pop();Kn(e,void 0,n),{implied:o,conflicting:c}=e},a}let Dr=[],Or;function kr(e,t,n,r){Or=r;let i={};if(Object.prototype.hasOwnProperty.call(e,`extends`)){if(typeof e.extends!=`string`)return i;let a=/\.json|\..*rc$/.test(e.extends),o=null;if(a)o=jr(t,e.extends);else try{o=import.meta.resolve(e.extends)}catch{return e}Ar(o),Dr.push(o),i=a?JSON.parse(Or.readFileSync(o,`utf8`)):r.require(e.extends),delete e.extends,i=kr(i,Or.path.dirname(o),n,Or)}return Dr=[],n?Mr(i,e):Object.assign({},i,e)}function Ar(e){if(Dr.indexOf(e)>-1)throw new M(`Circular extended configurations: '${e}'.`)}function jr(e,t){return Or.path.resolve(e,t)}function Mr(e,t){let n={};function r(e){return e&&typeof e==`object`&&!Array.isArray(e)}Object.assign(n,e);for(let i of Object.keys(t))r(t[i])&&r(n[i])?n[i]=Mr(e[i],t[i]):n[i]=t[i];return n}var P=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},F=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},I,Nr,Pr,L,R,Fr,Ir,Lr,Rr,z,zr,B,Br,V,H,Vr,Hr,U,W,Ur,Wr,G,Gr,Kr,qr,Jr,Yr,K,Xr,Zr,Qr,q,$r,ei,J;function ti(e){return(t=[],n=e.process.cwd(),r)=>{let i=new Ri(t,n,r,e);return Object.defineProperty(i,`argv`,{get:()=>i.parse(),enumerable:!0}),i.help(),i.version(),i}}const ni=Symbol(`copyDoubleDash`),ri=Symbol(`copyDoubleDash`),ii=Symbol(`deleteFromParserHintObject`),ai=Symbol(`emitWarning`),oi=Symbol(`freeze`),si=Symbol(`getDollarZero`),ci=Symbol(`getParserConfiguration`),li=Symbol(`getUsageConfiguration`),ui=Symbol(`guessLocale`),di=Symbol(`guessVersion`),fi=Symbol(`parsePositionalNumbers`),pi=Symbol(`pkgUp`),mi=Symbol(`populateParserHintArray`),hi=Symbol(`populateParserHintSingleValueDictionary`),gi=Symbol(`populateParserHintArrayDictionary`),_i=Symbol(`populateParserHintDictionary`),vi=Symbol(`sanitizeKey`),yi=Symbol(`setKey`),bi=Symbol(`unfreeze`),xi=Symbol(`validateAsync`),Si=Symbol(`getCommandInstance`),Ci=Symbol(`getContext`),wi=Symbol(`getHasOutput`),Ti=Symbol(`getLoggerInstance`),Ei=Symbol(`getParseContext`),Di=Symbol(`getUsageInstance`),Oi=Symbol(`getValidationInstance`),ki=Symbol(`hasParseCallback`),Ai=Symbol(`isGlobalContext`),ji=Symbol(`postProcess`),Mi=Symbol(`rebase`),Ni=Symbol(`reset`),Pi=Symbol(`runYargsParserAndExecuteCommands`),Fi=Symbol(`runValidation`),Ii=Symbol(`setHasOutput`),Li=Symbol(`kTrackManuallySetKeys`);var Ri=class{constructor(e=[],t,n,r){this.customScriptName=!1,this.parsed=!1,I.set(this,void 0),Nr.set(this,void 0),Pr.set(this,{commands:[],fullCommands:[]}),L.set(this,null),R.set(this,null),Fr.set(this,`show-hidden`),Ir.set(this,null),Lr.set(this,!0),Rr.set(this,{}),z.set(this,!0),zr.set(this,[]),B.set(this,void 0),Br.set(this,{}),V.set(this,!1),H.set(this,null),Vr.set(this,!0),Hr.set(this,void 0),U.set(this,``),W.set(this,void 0),Ur.set(this,void 0),Wr.set(this,{}),G.set(this,null),Gr.set(this,null),Kr.set(this,{}),qr.set(this,{}),Jr.set(this,void 0),Yr.set(this,!1),K.set(this,void 0),Xr.set(this,!1),Zr.set(this,!1),Qr.set(this,!1),q.set(this,void 0),$r.set(this,{}),ei.set(this,null),J.set(this,void 0),P(this,K,r,`f`),P(this,Jr,e,`f`),P(this,Nr,t,`f`),P(this,Ur,n,`f`),P(this,B,new $n(this),`f`),this.$0=this[si](),this[Ni](),P(this,I,F(this,I,`f`),`f`),P(this,q,F(this,q,`f`),`f`),P(this,J,F(this,J,`f`),`f`),P(this,W,F(this,W,`f`),`f`),F(this,W,`f`).showHiddenOpt=F(this,Fr,`f`),P(this,Hr,this[ri](),`f`),F(this,K,`f`).y18n.setLocale(`en_US`)}addHelpOpt(e,t){return N(`[string|boolean] [string]`,[e,t],arguments.length),F(this,H,`f`)&&(this[ii](F(this,H,`f`)),P(this,H,null,`f`)),e===!1&&t===void 0?this:(P(this,H,typeof e==`string`?e:`help`,`f`),this.boolean(F(this,H,`f`)),this.describe(F(this,H,`f`),t||F(this,q,`f`).deferY18nLookup(`Show help`)),this)}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(N(`[string|boolean] [string]`,[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e==`string`?e:F(this,Fr,`f`);return this.boolean(n),this.describe(n,t||F(this,q,`f`).deferY18nLookup(`Show hidden options`)),F(this,W,`f`).showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return N(`<object|string|array> [string|array]`,[e,t],arguments.length),this[gi](this.alias.bind(this),`alias`,e,t),this}array(e){return N(`<array|string>`,[e],arguments.length),this[mi](`array`,e),this[Li](e),this}boolean(e){return N(`<array|string>`,[e],arguments.length),this[mi](`boolean`,e),this[Li](e),this}check(e,t){return N(`<function> [boolean]`,[e,t],arguments.length),this.middleware((t,n)=>nr(()=>e(t,n.getOptions()),n=>(n?(typeof n==`string`||n instanceof Error)&&F(this,q,`f`).fail(n.toString(),n):F(this,q,`f`).fail(F(this,K,`f`).y18n.__(`Argument check failed: %s`,e.toString())),t),e=>(F(this,q,`f`).fail(e.message?e.message:e.toString(),e),t)),!1,t),this}choices(e,t){return N(`<object|string|array> [string|array]`,[e,t],arguments.length),this[gi](this.choices.bind(this),`choices`,e,t),this}coerce(e,t){if(N(`<object|string|array> [function]`,[e,t],arguments.length),Array.isArray(e)){if(!t)throw new M(`coerce callback must be provided`);for(let n of e)this.coerce(n,t);return this}else if(typeof e==`object`){for(let t of Object.keys(e))this.coerce(t,e[t]);return this}if(!t)throw new M(`coerce callback must be provided`);let n=e;return F(this,W,`f`).key[n]=!0,F(this,B,`f`).addCoerceMiddleware((e,r)=>{let i=r.getAliases()[n]??[],a=[n,...i].filter(t=>Object.prototype.hasOwnProperty.call(e,t));return a.length===0?e:nr(()=>t(e[a[0]]),t=>(a.forEach(n=>{e[n]=t}),e),e=>{throw new M(e.message)})},n),this}conflicts(e,t){return N(`<string|object> [string|array]`,[e,t],arguments.length),F(this,J,`f`).conflicts(e,t),this}config(e=`config`,t,n){return N(`[object|string] [string|function] [function]`,[e,t,n],arguments.length),typeof e==`object`&&!Array.isArray(e)?(e=kr(e,F(this,Nr,`f`),this[ci]()[`deep-merge-config`]||!1,F(this,K,`f`)),F(this,W,`f`).configObjects=(F(this,W,`f`).configObjects||[]).concat(e),this):(typeof t==`function`&&(n=t,t=void 0),this.describe(e,t||F(this,q,`f`).deferY18nLookup(`Path to JSON config file`)),(Array.isArray(e)?e:[e]).forEach(e=>{F(this,W,`f`).config[e]=n||!0}),this)}completion(e,t,n){return N(`[string] [string|boolean|function] [function]`,[e,t,n],arguments.length),typeof t==`function`&&(n=t,t=void 0),P(this,R,e||F(this,R,`f`)||`completion`,`f`),!t&&t!==!1&&(t=`generate completion script`),this.command(F(this,R,`f`),t),n&&F(this,L,`f`).registerFunction(n),this}command(e,t,n,r,i,a){return N(`<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]`,[e,t,n,r,i,a],arguments.length),F(this,I,`f`).addHandler(e,t,n,r,i,a),this}commands(e,t,n,r,i,a){return this.command(e,t,n,r,i,a)}commandDir(e,t){N(`<string> [object]`,[e,t],arguments.length);let n=F(this,Ur,`f`)||F(this,K,`f`).require;return F(this,I,`f`).addDirectory(e,n,F(this,K,`f`).getCallerFile(),t),this}count(e){return N(`<array|string>`,[e],arguments.length),this[mi](`count`,e),this[Li](e),this}default(e,t,n){return N(`<object|string|array> [*] [string]`,[e,t,n],arguments.length),n&&(qn(e,F(this,K,`f`)),F(this,W,`f`).defaultDescription[e]=n),typeof t==`function`&&(qn(e,F(this,K,`f`)),F(this,W,`f`).defaultDescription[e]||(F(this,W,`f`).defaultDescription[e]=F(this,q,`f`).functionDescription(t)),t=t.call()),this[hi](this.default.bind(this),`default`,e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,r){return N(`[number] [number|string] [string|null|undefined] [string|null|undefined]`,[e,t,n,r],arguments.length),typeof t!=`number`&&(n=t,t=1/0),this.global(`_`,!1),F(this,W,`f`).demandedCommands._={min:e,max:t,minMsg:n,maxMsg:r},this}demand(e,t,n){return Array.isArray(t)?(t.forEach(e=>{Kn(n,!0,F(this,K,`f`)),this.demandOption(e,n)}),t=1/0):typeof t!=`number`&&(n=t,t=1/0),typeof e==`number`?(Kn(n,!0,F(this,K,`f`)),this.demandCommand(e,t,n,n)):Array.isArray(e)?e.forEach(e=>{Kn(n,!0,F(this,K,`f`)),this.demandOption(e,n)}):typeof n==`string`?this.demandOption(e,n):(n===!0||n===void 0)&&this.demandOption(e),this}demandOption(e,t){return N(`<object|string|array> [string]`,[e,t],arguments.length),this[hi](this.demandOption.bind(this),`demandedOptions`,e,t),this}deprecateOption(e,t){return N(`<string> [string|boolean]`,[e,t],arguments.length),F(this,W,`f`).deprecatedOptions[e]=t,this}describe(e,t){return N(`<object|string|array> [string]`,[e,t],arguments.length),this[yi](e,!0),F(this,q,`f`).describe(e,t),this}detectLocale(e){return N(`<boolean>`,[e],arguments.length),P(this,Lr,e,`f`),this}env(e){return N(`[string|boolean]`,[e],arguments.length),e===!1?delete F(this,W,`f`).envPrefix:F(this,W,`f`).envPrefix=e||``,this}epilogue(e){return N(`<string>`,[e],arguments.length),F(this,q,`f`).epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){return N(`<string|array> [string]`,[e,t],arguments.length),Array.isArray(e)?e.forEach(e=>this.example(...e)):F(this,q,`f`).example(e,t),this}exit(e,t){P(this,V,!0,`f`),P(this,Ir,t,`f`),F(this,z,`f`)&&F(this,K,`f`).process.exit(e)}exitProcess(e=!0){return N(`[boolean]`,[e],arguments.length),P(this,z,e,`f`),this}fail(e){if(N(`<function|boolean>`,[e],arguments.length),typeof e==`boolean`&&e!==!1)throw new M(`Invalid first argument. Expected function or boolean 'false'`);return F(this,q,`f`).failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){return N(`<array> [function]`,[e,t],arguments.length),t?F(this,L,`f`).getCompletion(e,t):new Promise((t,n)=>{F(this,L,`f`).getCompletion(e,(e,r)=>{e?n(e):t(r)})})}getDemandedOptions(){return N([],0),F(this,W,`f`).demandedOptions}getDemandedCommands(){return N([],0),F(this,W,`f`).demandedCommands}getDeprecatedOptions(){return N([],0),F(this,W,`f`).deprecatedOptions}getDetectLocale(){return F(this,Lr,`f`)}getExitProcess(){return F(this,z,`f`)}getGroups(){return Object.assign({},F(this,Br,`f`),F(this,qr,`f`))}getHelp(){if(P(this,V,!0,`f`),!F(this,q,`f`).hasCachedHelpMessage()){if(!this.parsed){let e=this[Pi](F(this,Jr,`f`),void 0,void 0,0,!0);if(j(e))return e.then(()=>F(this,q,`f`).help())}let e=F(this,I,`f`).runDefaultBuilderOn(this);if(j(e))return e.then(()=>F(this,q,`f`).help())}return Promise.resolve(F(this,q,`f`).help())}getOptions(){return F(this,W,`f`)}getStrict(){return F(this,Xr,`f`)}getStrictCommands(){return F(this,Zr,`f`)}getStrictOptions(){return F(this,Qr,`f`)}global(e,t){return N(`<string|array> [boolean]`,[e,t],arguments.length),e=[].concat(e),t===!1?e.forEach(e=>{F(this,W,`f`).local.includes(e)||F(this,W,`f`).local.push(e)}):F(this,W,`f`).local=F(this,W,`f`).local.filter(t=>e.indexOf(t)===-1),this}group(e,t){N(`<string|array> <string>`,[e,t],arguments.length);let n=F(this,qr,`f`)[t]||F(this,Br,`f`)[t];F(this,qr,`f`)[t]&&delete F(this,qr,`f`)[t];let r={};return F(this,Br,`f`)[t]=(n||[]).concat(e).filter(e=>r[e]?!1:r[e]=!0),this}hide(e){return N(`<string>`,[e],arguments.length),F(this,W,`f`).hiddenOptions.push(e),this}implies(e,t){return N(`<string|object> [number|string|array]`,[e,t],arguments.length),F(this,J,`f`).implies(e,t),this}locale(e){return N(`[string]`,[e],arguments.length),e===void 0?(this[ui](),F(this,K,`f`).y18n.getLocale()):(P(this,Lr,!1,`f`),F(this,K,`f`).y18n.setLocale(e),this)}middleware(e,t,n){return F(this,B,`f`).addMiddleware(e,!!t,n)}nargs(e,t){return N(`<string|object|array> [number]`,[e,t],arguments.length),this[hi](this.nargs.bind(this),`narg`,e,t),this}normalize(e){return N(`<array|string>`,[e],arguments.length),this[mi](`normalize`,e),this}number(e){return N(`<array|string>`,[e],arguments.length),this[mi](`number`,e),this[Li](e),this}option(e,t){if(N(`<string|object> [object]`,[e,t],arguments.length),typeof e==`object`)Object.keys(e).forEach(t=>{this.options(t,e[t])});else{typeof t!=`object`&&(t={}),this[Li](e),F(this,ei,`f`)&&(e===`version`||t?.alias===`version`)&&this[ai]([`"version" is a reserved word.`,`Please do one of the following:`,'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)",`- Use a different option key`,`https://yargs.js.org/docs/#api-reference-version`].join(`
90
90
  `),void 0,`versionWarning`),F(this,W,`f`).key[e]=!0,t.alias&&this.alias(e,t.alias);let n=t.deprecate||t.deprecated;n&&this.deprecateOption(e,n);let r=t.demand||t.required||t.require;r&&this.demand(e,r),t.demandOption&&this.demandOption(e,typeof t.demandOption==`string`?t.demandOption:void 0),t.conflicts&&this.conflicts(e,t.conflicts),`default`in t&&this.default(e,t.default),t.implies!==void 0&&this.implies(e,t.implies),t.nargs!==void 0&&this.nargs(e,t.nargs),t.config&&this.config(e,t.configParser),t.normalize&&this.normalize(e),t.choices&&this.choices(e,t.choices),t.coerce&&this.coerce(e,t.coerce),t.group&&this.group(e,t.group),(t.boolean||t.type===`boolean`)&&(this.boolean(e),t.alias&&this.boolean(t.alias)),(t.array||t.type===`array`)&&(this.array(e),t.alias&&this.array(t.alias)),(t.number||t.type===`number`)&&(this.number(e),t.alias&&this.number(t.alias)),(t.string||t.type===`string`)&&(this.string(e),t.alias&&this.string(t.alias)),(t.count||t.type===`count`)&&this.count(e),typeof t.global==`boolean`&&this.global(e,t.global),t.defaultDescription&&(F(this,W,`f`).defaultDescription[e]=t.defaultDescription),t.skipValidation&&this.skipValidation(e);let i=t.describe||t.description||t.desc,a=F(this,q,`f`).getDescriptions();(!Object.prototype.hasOwnProperty.call(a,e)||typeof i==`string`)&&this.describe(e,i),t.hidden&&this.hide(e),t.requiresArg&&this.requiresArg(e)}return this}options(e,t){return this.option(e,t)}parse(e,t,n){N(`[string|array] [function|boolean|object] [function]`,[e,t,n],arguments.length),this[oi](),e===void 0&&(e=F(this,Jr,`f`)),typeof t==`object`&&(P(this,Gr,t,`f`),t=n),typeof t==`function`&&(P(this,G,t,`f`),t=!1),t||P(this,Jr,e,`f`),F(this,G,`f`)&&P(this,z,!1,`f`);let r=this[Pi](e,!!t),i=this.parsed;return F(this,L,`f`).setParsed(this.parsed),j(r)?r.then(e=>(F(this,G,`f`)&&F(this,G,`f`).call(this,F(this,Ir,`f`),e,F(this,U,`f`)),e)).catch(e=>{throw F(this,G,`f`)&&F(this,G,`f`)(e,this.parsed.argv,F(this,U,`f`)),e}).finally(()=>{this[bi](),this.parsed=i}):(F(this,G,`f`)&&F(this,G,`f`).call(this,F(this,Ir,`f`),r,F(this,U,`f`)),this[bi](),this.parsed=i,r)}parseAsync(e,t,n){let r=this.parse(e,t,n);return j(r)?r:Promise.resolve(r)}parseSync(e,t,n){let r=this.parse(e,t,n);if(j(r))throw new M(`.parseSync() must not be used with asynchronous builders, handlers, or middleware`);return r}parserConfiguration(e){return N(`<object>`,[e],arguments.length),P(this,Wr,e,`f`),this}pkgConf(e,t){N(`<string> [string]`,[e,t],arguments.length);let n=null,r=this[pi](t||F(this,Nr,`f`));return r[e]&&typeof r[e]==`object`&&(n=kr(r[e],t||F(this,Nr,`f`),this[ci]()[`deep-merge-config`]||!1,F(this,K,`f`)),F(this,W,`f`).configObjects=(F(this,W,`f`).configObjects||[]).concat(n)),this}positional(e,t){N(`<string> <object>`,[e,t],arguments.length);let n=[`default`,`defaultDescription`,`implies`,`normalize`,`choices`,`conflicts`,`coerce`,`type`,`describe`,`desc`,`description`,`alias`];t=fr(t,(e,t)=>e===`type`&&![`string`,`number`,`boolean`].includes(t)?!1:n.includes(e));let r=F(this,Pr,`f`).fullCommands[F(this,Pr,`f`).fullCommands.length-1],i=r?F(this,I,`f`).cmdToParseOptions(r):{array:[],alias:{},default:{},demand:{}};return Jn(i).forEach(n=>{let r=i[n];Array.isArray(r)?r.indexOf(e)!==-1&&(t[n]=!0):r[e]&&!(n in t)&&(t[n]=r[e])}),this.group(e,F(this,q,`f`).getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return N(`[boolean]`,[e],arguments.length),P(this,Yr,e,`f`),this}required(e,t,n){return this.demand(e,t,n)}require(e,t,n){return this.demand(e,t,n)}requiresArg(e){return N(`<array|string|object> [number]`,[e],arguments.length),typeof e==`string`&&F(this,W,`f`).narg[e]||this[hi](this.requiresArg.bind(this),`narg`,e,NaN),this}showCompletionScript(e,t){return N(`[string] [string]`,[e,t],arguments.length),e||=this.$0,F(this,Hr,`f`).log(F(this,L,`f`).generateCompletionScript(e,t||F(this,R,`f`)||`completion`)),this}showHelp(e){if(N(`[string|function]`,[e],arguments.length),P(this,V,!0,`f`),!F(this,q,`f`).hasCachedHelpMessage()){if(!this.parsed){let t=this[Pi](F(this,Jr,`f`),void 0,void 0,0,!0);if(j(t))return t.then(()=>{F(this,q,`f`).showHelp(e)}),this}let t=F(this,I,`f`).runDefaultBuilderOn(this);if(j(t))return t.then(()=>{F(this,q,`f`).showHelp(e)}),this}return F(this,q,`f`).showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return N(`[boolean|string] [string]`,[e,t],arguments.length),F(this,q,`f`).showHelpOnFail(e,t),this}showVersion(e){return N(`[string|function]`,[e],arguments.length),F(this,q,`f`).showVersion(e),this}skipValidation(e){return N(`<array|string>`,[e],arguments.length),this[mi](`skipValidation`,e),this}strict(e){return N(`[boolean]`,[e],arguments.length),P(this,Xr,e!==!1,`f`),this}strictCommands(e){return N(`[boolean]`,[e],arguments.length),P(this,Zr,e!==!1,`f`),this}strictOptions(e){return N(`[boolean]`,[e],arguments.length),P(this,Qr,e!==!1,`f`),this}string(e){return N(`<array|string>`,[e],arguments.length),this[mi](`string`,e),this[Li](e),this}terminalWidth(){return N([],0),F(this,K,`f`).process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return N(`<object>`,[e],arguments.length),P(this,Lr,!1,`f`),F(this,K,`f`).y18n.updateLocale(e),this}usage(e,t,n,r){if(N(`<string|null|undefined> [string|boolean] [function|object] [function]`,[e,t,n,r],arguments.length),t!==void 0){if(Kn(e,null,F(this,K,`f`)),(e||``).match(/^\$0( |$)/))return this.command(e,t,n,r);throw new M(`.usage() description must start with $0 if being used as alias for .command()`)}else return F(this,q,`f`).usage(e),this}usageConfiguration(e){return N(`<object>`,[e],arguments.length),P(this,$r,e,`f`),this}version(e,t,n){let r=`version`;if(N(`[boolean|string] [string] [string]`,[e,t,n],arguments.length),F(this,ei,`f`)&&(this[ii](F(this,ei,`f`)),F(this,q,`f`).version(void 0),P(this,ei,null,`f`)),arguments.length===0)n=this[di](),e=r;else if(arguments.length===1){if(e===!1)return this;n=e,e=r}else arguments.length===2&&(n=t,t=void 0);return P(this,ei,typeof e==`string`?e:r,`f`),t||=F(this,q,`f`).deferY18nLookup(`Show version number`),F(this,q,`f`).version(n||void 0),this.boolean(F(this,ei,`f`)),this.describe(F(this,ei,`f`),t),this}wrap(e){return N(`<number|null|undefined>`,[e],arguments.length),F(this,q,`f`).wrap(e),this}[(I=new WeakMap,Nr=new WeakMap,Pr=new WeakMap,L=new WeakMap,R=new WeakMap,Fr=new WeakMap,Ir=new WeakMap,Lr=new WeakMap,Rr=new WeakMap,z=new WeakMap,zr=new WeakMap,B=new WeakMap,Br=new WeakMap,V=new WeakMap,H=new WeakMap,Vr=new WeakMap,Hr=new WeakMap,U=new WeakMap,W=new WeakMap,Ur=new WeakMap,Wr=new WeakMap,G=new WeakMap,Gr=new WeakMap,Kr=new WeakMap,qr=new WeakMap,Jr=new WeakMap,Yr=new WeakMap,K=new WeakMap,Xr=new WeakMap,Zr=new WeakMap,Qr=new WeakMap,q=new WeakMap,$r=new WeakMap,ei=new WeakMap,J=new WeakMap,ni)](e){if(!e._||!e[`--`])return e;e._.push.apply(e._,e[`--`]);try{delete e[`--`]}catch{}return e}[ri](){return{log:(...e)=>{this[ki]()||console.log(...e),P(this,V,!0,`f`),F(this,U,`f`).length&&P(this,U,F(this,U,`f`)+`
91
91
  `,`f`),P(this,U,F(this,U,`f`)+e.join(` `),`f`)},error:(...e)=>{this[ki]()||console.error(...e),P(this,V,!0,`f`),F(this,U,`f`).length&&P(this,U,F(this,U,`f`)+`
92
- `,`f`),P(this,U,F(this,U,`f`)+e.join(` `),`f`)}}}[ii](e){Jn(F(this,W,`f`)).forEach(t=>{if((e=>e===`configObjects`)(t))return;let n=F(this,W,`f`)[t];Array.isArray(n)?n.includes(e)&&n.splice(n.indexOf(e),1):typeof n==`object`&&delete n[e]}),delete F(this,q,`f`).getDescriptions()[e]}[ai](e,t,n){F(this,Rr,`f`)[n]||(F(this,K,`f`).process.emitWarning(e,t),F(this,Rr,`f`)[n]=!0)}[oi](){F(this,zr,`f`).push({options:F(this,W,`f`),configObjects:F(this,W,`f`).configObjects.slice(0),exitProcess:F(this,z,`f`),groups:F(this,Br,`f`),strict:F(this,Xr,`f`),strictCommands:F(this,Zr,`f`),strictOptions:F(this,Qr,`f`),completionCommand:F(this,R,`f`),output:F(this,U,`f`),exitError:F(this,Ir,`f`),hasOutput:F(this,V,`f`),parsed:this.parsed,parseFn:F(this,G,`f`),parseContext:F(this,Gr,`f`)}),F(this,q,`f`).freeze(),F(this,J,`f`).freeze(),F(this,I,`f`).freeze(),F(this,B,`f`).freeze()}[si](){let e=``,t;return t=/\b(node|iojs|electron)(\.exe)?$/.test(F(this,K,`f`).process.argv()[0])?F(this,K,`f`).process.argv().slice(1,2):F(this,K,`f`).process.argv().slice(0,1),e=t.map(e=>{let t=this[Mi](F(this,Nr,`f`),e);return e.match(/^(\/|([a-zA-Z]:)?\\)/)&&t.length<e.length?t:e}).join(` `).trim(),F(this,K,`f`).getEnv(`_`)&&F(this,K,`f`).getProcessArgvBin()===F(this,K,`f`).getEnv(`_`)&&(e=F(this,K,`f`).getEnv(`_`).replace(`${F(this,K,`f`).path.dirname(F(this,K,`f`).process.execPath())}/`,``)),e}[ci](){return F(this,Wr,`f`)}[li](){return F(this,$r,`f`)}[ui](){if(!F(this,Lr,`f`))return;let e=F(this,K,`f`).getEnv(`LC_ALL`)||F(this,K,`f`).getEnv(`LC_MESSAGES`)||F(this,K,`f`).getEnv(`LANG`)||F(this,K,`f`).getEnv(`LANGUAGE`)||`en_US`;this.locale(e.replace(/[.:].*/,``))}[di](){return this[pi]().version||`unknown`}[fi](e){let t=e[`--`]?e[`--`]:e._;for(let e=0,n;(n=t[e])!==void 0;e++)F(this,K,`f`).Parser.looksLikeNumber(n)&&Number.isSafeInteger(Math.floor(parseFloat(`${n}`)))&&(t[e]=Number(n));return e}[pi](e){let t=e||`*`;if(F(this,Kr,`f`)[t])return F(this,Kr,`f`)[t];let n={};try{let t=e||F(this,K,`f`).mainFilename;F(this,K,`f`).path.extname(t)&&(t=F(this,K,`f`).path.dirname(t));let r=F(this,K,`f`).findUp(t,(e,t)=>{if(t.includes(`package.json`))return`package.json`});Kn(r,void 0,F(this,K,`f`)),n=JSON.parse(F(this,K,`f`).readFileSync(r,`utf8`))}catch{}return F(this,Kr,`f`)[t]=n||{},F(this,Kr,`f`)[t]}[mi](e,t){t=[].concat(t),t.forEach(t=>{t=this[vi](t),F(this,W,`f`)[e].push(t)})}[hi](e,t,n,r){this[_i](e,t,n,r,(e,t,n)=>{F(this,W,`f`)[e][t]=n})}[gi](e,t,n,r){this[_i](e,t,n,r,(e,t,n)=>{F(this,W,`f`)[e][t]=(F(this,W,`f`)[e][t]||[]).concat(n)})}[_i](e,t,n,r,i){if(Array.isArray(n))n.forEach(t=>{e(t,r)});else if((e=>typeof e==`object`)(n))for(let t of Jn(n))e(t,n[t]);else i(t,this[vi](n),r)}[vi](e){return e===`__proto__`?`___proto___`:e}[yi](e,t){return this[hi](this[yi].bind(this),`key`,e,t),this}[bi](){var e,t,n,r,i,a,o,s,c,l,u,d;let f=F(this,zr,`f`).pop();Kn(f,void 0,F(this,K,`f`));let p;e=this,t=this,n=this,r=this,i=this,a=this,o=this,s=this,c=this,l=this,u=this,d=this,{options:{set value(t){P(e,W,t,`f`)}}.value,configObjects:p,exitProcess:{set value(e){P(t,z,e,`f`)}}.value,groups:{set value(e){P(n,Br,e,`f`)}}.value,output:{set value(e){P(r,U,e,`f`)}}.value,exitError:{set value(e){P(i,Ir,e,`f`)}}.value,hasOutput:{set value(e){P(a,V,e,`f`)}}.value,parsed:this.parsed,strict:{set value(e){P(o,Xr,e,`f`)}}.value,strictCommands:{set value(e){P(s,Zr,e,`f`)}}.value,strictOptions:{set value(e){P(c,Qr,e,`f`)}}.value,completionCommand:{set value(e){P(l,R,e,`f`)}}.value,parseFn:{set value(e){P(u,G,e,`f`)}}.value,parseContext:{set value(e){P(d,Gr,e,`f`)}}.value}=f,F(this,W,`f`).configObjects=p,F(this,q,`f`).unfreeze(),F(this,J,`f`).unfreeze(),F(this,I,`f`).unfreeze(),F(this,B,`f`).unfreeze()}[xi](e,t){return nr(t,t=>(e(t),t))}getInternalMethods(){return{getCommandInstance:this[Si].bind(this),getContext:this[Ci].bind(this),getHasOutput:this[wi].bind(this),getLoggerInstance:this[Ti].bind(this),getParseContext:this[Ei].bind(this),getParserConfiguration:this[ci].bind(this),getUsageConfiguration:this[li].bind(this),getUsageInstance:this[Di].bind(this),getValidationInstance:this[Oi].bind(this),hasParseCallback:this[ki].bind(this),isGlobalContext:this[Ai].bind(this),postProcess:this[ji].bind(this),reset:this[Ni].bind(this),runValidation:this[Fi].bind(this),runYargsParserAndExecuteCommands:this[Pi].bind(this),setHasOutput:this[Ii].bind(this)}}[Si](){return F(this,I,`f`)}[Ci](){return F(this,Pr,`f`)}[wi](){return F(this,V,`f`)}[Ti](){return F(this,Hr,`f`)}[Ei](){return F(this,Gr,`f`)||{}}[Di](){return F(this,q,`f`)}[Oi](){return F(this,J,`f`)}[ki](){return!!F(this,G,`f`)}[Ai](){return F(this,Vr,`f`)}[ji](e,t,n,r){return n||j(e)?e:(t||(e=this[ni](e)),(this[ci]()[`parse-positional-numbers`]||this[ci]()[`parse-positional-numbers`]===void 0)&&(e=this[fi](e)),r&&(e=tr(e,this,F(this,B,`f`).getMiddleware(),!1)),e)}[Ni](e={}){P(this,W,F(this,W,`f`)||{},`f`);let t={};t.local=F(this,W,`f`).local||[],t.configObjects=F(this,W,`f`).configObjects||[];let n={};return t.local.forEach(t=>{n[t]=!0,(e[t]||[]).forEach(e=>{n[e]=!0})}),Object.assign(F(this,qr,`f`),Object.keys(F(this,Br,`f`)).reduce((e,t)=>{let r=F(this,Br,`f`)[t].filter(e=>!(e in n));return r.length>0&&(e[t]=r),e},{})),P(this,Br,{},`f`),[`array`,`boolean`,`string`,`skipValidation`,`count`,`normalize`,`number`,`hiddenOptions`].forEach(e=>{t[e]=(F(this,W,`f`)[e]||[]).filter(e=>!n[e])}),[`narg`,`key`,`alias`,`default`,`defaultDescription`,`config`,`choices`,`demandedOptions`,`demandedCommands`,`deprecatedOptions`].forEach(e=>{t[e]=fr(F(this,W,`f`)[e],e=>!n[e])}),t.envPrefix=F(this,W,`f`).envPrefix,P(this,W,t,`f`),P(this,q,F(this,q,`f`)?F(this,q,`f`).reset(n):hr(this,F(this,K,`f`)),`f`),P(this,J,F(this,J,`f`)?F(this,J,`f`).reset(n):Er(this,F(this,q,`f`),F(this,K,`f`)),`f`),P(this,I,F(this,I,`f`)?F(this,I,`f`).reset():or(F(this,q,`f`),F(this,J,`f`),F(this,B,`f`),F(this,K,`f`)),`f`),F(this,L,`f`)||P(this,L,xr(this,F(this,q,`f`),F(this,I,`f`),F(this,K,`f`)),`f`),F(this,B,`f`).reset(),P(this,R,null,`f`),P(this,U,``,`f`),P(this,Ir,null,`f`),P(this,V,!1,`f`),this.parsed=!1,this}[Mi](e,t){return F(this,K,`f`).path.relative(e,t)}[Pi](e,t,n,r=0,i=!1){let a=!!n||i;e||=F(this,Jr,`f`),F(this,W,`f`).__=F(this,K,`f`).y18n.__,F(this,W,`f`).configuration=this[ci]();let o=!!F(this,W,`f`).configuration[`populate--`],s=Object.assign({},F(this,W,`f`).configuration,{"populate--":!0}),c=F(this,K,`f`).Parser.detailed(e,Object.assign({},F(this,W,`f`),{configuration:{"parse-positional-numbers":!1,...s}})),l=Object.assign(c.argv,F(this,Gr,`f`)),u,d=c.aliases,f=!1,p=!1;Object.keys(l).forEach(e=>{e===F(this,H,`f`)&&l[e]?f=!0:e===F(this,ei,`f`)&&l[e]&&(p=!0)}),l.$0=this.$0,this.parsed=c,r===0&&F(this,q,`f`).clearCachedHelpMessage();try{if(this[ui](),t)return this[ji](l,o,!!n,!1);F(this,H,`f`)&&[F(this,H,`f`)].concat(d[F(this,H,`f`)]||[]).filter(e=>e.length>1).includes(``+l._[l._.length-1])&&(l._.pop(),f=!0),P(this,Vr,!1,`f`);let s=F(this,I,`f`).getCommands(),m=F(this,L,`f`)?.completionKey?[F(this,L,`f`)?.completionKey,...this.getAliases()[F(this,L,`f`)?.completionKey]??[]].some(e=>Object.prototype.hasOwnProperty.call(l,e)):!1,h=f||m||i;if(l._.length){if(s.length){let e;for(let t=r||0,a;l._[t]!==void 0;t++)if(a=String(l._[t]),s.includes(a)&&a!==F(this,R,`f`)){let e=F(this,I,`f`).runCommand(a,this,c,t+1,i,f||p||i);return this[ji](e,o,!!n,!1)}else if(!e&&a!==F(this,R,`f`)){e=a;break}!F(this,I,`f`).hasDefaultCommand()&&F(this,Yr,`f`)&&e&&!h&&F(this,J,`f`).recommendCommands(e,s)}F(this,R,`f`)&&l._.includes(F(this,R,`f`))&&!m&&(F(this,z,`f`)&&pr(!0),this.showCompletionScript(),this.exit(0))}if(F(this,I,`f`).hasDefaultCommand()&&!h){let e=F(this,I,`f`).runCommand(null,this,c,0,i,f||p||i);return this[ji](e,o,!!n,!1)}if(m){F(this,z,`f`)&&pr(!0),e=[].concat(e);let t=e.slice(e.indexOf(`--${F(this,L,`f`).completionKey}`)+1);return F(this,L,`f`).getCompletion(t,(e,t)=>{if(e)throw new M(e.message);(t||[]).forEach(e=>{F(this,Hr,`f`).log(e)}),this.exit(0)}),this[ji](l,!o,!!n,!1)}if(F(this,V,`f`)||(f?(F(this,z,`f`)&&pr(!0),a=!0,this.showHelp(e=>{F(this,Hr,`f`).log(e),this.exit(0)})):p&&(F(this,z,`f`)&&pr(!0),a=!0,F(this,q,`f`).showVersion(`log`),this.exit(0))),!a&&F(this,W,`f`).skipValidation.length>0&&(a=Object.keys(l).some(e=>F(this,W,`f`).skipValidation.indexOf(e)>=0&&l[e]===!0)),!a){if(c.error)throw new M(c.error.message);if(!m){let e=this[Fi](d,{},c.error);n||(u=tr(l,this,F(this,B,`f`).getMiddleware(),!0)),u=this[xi](e,u??l),j(u)&&!n&&(u=u.then(()=>tr(l,this,F(this,B,`f`).getMiddleware(),!1)))}}}catch(e){if(e instanceof M)F(this,q,`f`).fail(e.message,e);else throw e}return this[ji](u??l,o,!!n,!0)}[Fi](e,t,n,r){let i={...this.getDemandedOptions()};return a=>{if(n)throw new M(n.message);F(this,J,`f`).nonOptionCount(a),F(this,J,`f`).requiredArguments(a,i);let o=!1;F(this,Zr,`f`)&&(o=F(this,J,`f`).unknownCommands(a)),F(this,Xr,`f`)&&!o?F(this,J,`f`).unknownArguments(a,e,t,!!r):F(this,Qr,`f`)&&F(this,J,`f`).unknownArguments(a,e,{},!1,!1),F(this,J,`f`).limitedChoices(a),F(this,J,`f`).implications(a),F(this,J,`f`).conflicting(a)}}[Ii](){P(this,V,!0,`f`)}[Li](e){if(typeof e==`string`)F(this,W,`f`).key[e]=!0;else for(let t of e)F(this,W,`f`).key[t]=!0}};function zi(e){return!!e&&typeof e.getInternalMethods==`function`}var Bi=ti(Gn),Vi=class{client;enabled;lastBlockReason;serverName;constructor(e){this.enabled=e.enabled,this.client=e.client,this.serverName=e.serverName,S.info(`AccessControlAuthorizer initialized`,{enabled:this.enabled,hasClient:!!this.client,serverName:this.serverName})}getBlockReason(){return this.lastBlockReason?this.lastBlockReason:`MCP server${this.serverName?` '${this.serverName}'`:``} is not authorized for use in your organization and has been blocked by Onyx.`}async isAllowed(){if(!this.enabled)return!0;if(this.client)try{let e=await this.client.authorize();return e.action===`block`?(e.reason?this.lastBlockReason=e.reason:this.lastBlockReason=`MCP server${this.serverName?` '${this.serverName}'`:``} is not authorized for use in your organization and has been blocked by Onyx.`,!1):!0}catch(e){return S.error(`Access control authorization failed with unexpected error`,{error:String(e)}),!0}return S.warn(`No access control client configured, allowing by default`),!0}},Hi=class{clientInfoBase64;config;constructor(e){this.config=e,this.clientInfoBase64=this.getClientInfoBase64(),S.info(`AccessControlClient initialized`,{timeoutMs:e.timeoutMs,url:e.url})}async authorize(){try{let e=await this.sendAuthorizeRequest();return S.debug(`Access control check successful`,{action:e.action}),e}catch(e){return S.warn(`Access control check failed, failing open (allowing by default)`,{error:String(e)}),{action:`allow`}}}getClientInfoBase64(){return v(this.config.sessionData)}async sendAuthorizeRequest(){let e=new AbortController,t=setTimeout(()=>e.abort(),this.config.timeoutMs);try{let t=`${this.config.url}/${this.config.apiKey}/mcp/${this.clientInfoBase64}`,n=await fetch(t,{headers:{...this.config.headers},method:`POST`,signal:e.signal});if(!n.ok)throw Error(`Access control service returned ${n.status}: ${n.statusText}`);let r=await n.json();if(!r.action||![`allow`,`block`].includes(r.action))throw Error(`Invalid access control response format: action="${r.action}"`);return r}catch(e){throw e instanceof Error&&e.name===`AbortError`?Error(`Access control check timed out after ${this.config.timeoutMs}ms`):e}finally{clearTimeout(t)}}};async function Ui(e){let t=e.toString(),n=me(),r,i;switch(n){case`darwin`:r=`open`,i=[t];break;case`win32`:r=`cmd`,i=[`/c`,`start`,``,`"${t}"`];break;case`linux`:default:r=`xdg-open`,i=[t];break}return S.info(`Opening browser for OAuth authorization`,{os:n,url:t}),new Promise(e=>{Pe(r,i,(t,n,a)=>{if(t){S.warn(`Failed to open browser automatically`,{args:i,command:r,error:t.message,stderr:a}),e();return}S.debug(`Browser opened successfully`),e()})})}const Wi=49152;function Gi(){return Math.floor(Math.random()*(65535-Wi+1))+Wi}function Ki(e,t){return new Promise((n,r)=>{let i=t=>{e.removeListener(`listening`,a),r(t)},a=()=>{e.removeListener(`error`,i),n()};e.once(`error`,i),e.once(`listening`,a),e.listen(t,`127.0.0.1`)})}async function qi(e={}){let{maxAttempts:t=5,preferredPort:n,timeoutMs:r=3e5}=e,i,a,o={},s=new Promise((e,t)=>{i=e,a=t}),c,l=Te((e,t)=>{if(e.url===`/favicon.ico`){t.writeHead(404),t.end();return}if(!e.url?.startsWith(`/callback`)){t.writeHead(404),t.end(`Not Found`);return}try{let n=new Ie(e.url,`http://localhost:${c}`),r=n.searchParams.get(`code`),s=n.searchParams.get(`error`),u=n.searchParams.get(`error_description`),d=n.searchParams.get(`state`);if(s){S.error(`OAuth authorization error`,{error:s,errorDescription:u}),t.writeHead(400,{"Content-Type":`text/html`}),t.end(Yi(s,u||void 0)),clearTimeout(o.id),a(Error(`OAuth authorization failed: ${s}${u?` - ${u}`:``}`));return}if(!r){S.error(`OAuth callback missing authorization code`),t.writeHead(400,{"Content-Type":`text/html`}),t.end(Yi(`missing_code`,`No authorization code was provided`)),clearTimeout(o.id),a(Error(`OAuth callback missing authorization code`));return}S.info(`OAuth authorization code received`,{codePrefix:`${r.substring(0,10)}...`,hasState:!!d}),t.writeHead(200,{"Content-Type":`text/html`}),t.end(`<!DOCTYPE html>
92
+ `,`f`),P(this,U,F(this,U,`f`)+e.join(` `),`f`)}}}[ii](e){Jn(F(this,W,`f`)).forEach(t=>{if((e=>e===`configObjects`)(t))return;let n=F(this,W,`f`)[t];Array.isArray(n)?n.includes(e)&&n.splice(n.indexOf(e),1):typeof n==`object`&&delete n[e]}),delete F(this,q,`f`).getDescriptions()[e]}[ai](e,t,n){F(this,Rr,`f`)[n]||(F(this,K,`f`).process.emitWarning(e,t),F(this,Rr,`f`)[n]=!0)}[oi](){F(this,zr,`f`).push({options:F(this,W,`f`),configObjects:F(this,W,`f`).configObjects.slice(0),exitProcess:F(this,z,`f`),groups:F(this,Br,`f`),strict:F(this,Xr,`f`),strictCommands:F(this,Zr,`f`),strictOptions:F(this,Qr,`f`),completionCommand:F(this,R,`f`),output:F(this,U,`f`),exitError:F(this,Ir,`f`),hasOutput:F(this,V,`f`),parsed:this.parsed,parseFn:F(this,G,`f`),parseContext:F(this,Gr,`f`)}),F(this,q,`f`).freeze(),F(this,J,`f`).freeze(),F(this,I,`f`).freeze(),F(this,B,`f`).freeze()}[si](){let e=``,t;return t=/\b(node|iojs|electron)(\.exe)?$/.test(F(this,K,`f`).process.argv()[0])?F(this,K,`f`).process.argv().slice(1,2):F(this,K,`f`).process.argv().slice(0,1),e=t.map(e=>{let t=this[Mi](F(this,Nr,`f`),e);return e.match(/^(\/|([a-zA-Z]:)?\\)/)&&t.length<e.length?t:e}).join(` `).trim(),F(this,K,`f`).getEnv(`_`)&&F(this,K,`f`).getProcessArgvBin()===F(this,K,`f`).getEnv(`_`)&&(e=F(this,K,`f`).getEnv(`_`).replace(`${F(this,K,`f`).path.dirname(F(this,K,`f`).process.execPath())}/`,``)),e}[ci](){return F(this,Wr,`f`)}[li](){return F(this,$r,`f`)}[ui](){if(!F(this,Lr,`f`))return;let e=F(this,K,`f`).getEnv(`LC_ALL`)||F(this,K,`f`).getEnv(`LC_MESSAGES`)||F(this,K,`f`).getEnv(`LANG`)||F(this,K,`f`).getEnv(`LANGUAGE`)||`en_US`;this.locale(e.replace(/[.:].*/,``))}[di](){return this[pi]().version||`unknown`}[fi](e){let t=e[`--`]?e[`--`]:e._;for(let e=0,n;(n=t[e])!==void 0;e++)F(this,K,`f`).Parser.looksLikeNumber(n)&&Number.isSafeInteger(Math.floor(parseFloat(`${n}`)))&&(t[e]=Number(n));return e}[pi](e){let t=e||`*`;if(F(this,Kr,`f`)[t])return F(this,Kr,`f`)[t];let n={};try{let t=e||F(this,K,`f`).mainFilename;F(this,K,`f`).path.extname(t)&&(t=F(this,K,`f`).path.dirname(t));let r=F(this,K,`f`).findUp(t,(e,t)=>{if(t.includes(`package.json`))return`package.json`});Kn(r,void 0,F(this,K,`f`)),n=JSON.parse(F(this,K,`f`).readFileSync(r,`utf8`))}catch{}return F(this,Kr,`f`)[t]=n||{},F(this,Kr,`f`)[t]}[mi](e,t){t=[].concat(t),t.forEach(t=>{t=this[vi](t),F(this,W,`f`)[e].push(t)})}[hi](e,t,n,r){this[_i](e,t,n,r,(e,t,n)=>{F(this,W,`f`)[e][t]=n})}[gi](e,t,n,r){this[_i](e,t,n,r,(e,t,n)=>{F(this,W,`f`)[e][t]=(F(this,W,`f`)[e][t]||[]).concat(n)})}[_i](e,t,n,r,i){if(Array.isArray(n))n.forEach(t=>{e(t,r)});else if((e=>typeof e==`object`)(n))for(let t of Jn(n))e(t,n[t]);else i(t,this[vi](n),r)}[vi](e){return e===`__proto__`?`___proto___`:e}[yi](e,t){return this[hi](this[yi].bind(this),`key`,e,t),this}[bi](){var e,t,n,r,i,a,o,s,c,l,u,d;let f=F(this,zr,`f`).pop();Kn(f,void 0,F(this,K,`f`));let p;e=this,t=this,n=this,r=this,i=this,a=this,o=this,s=this,c=this,l=this,u=this,d=this,{options:{set value(t){P(e,W,t,`f`)}}.value,configObjects:p,exitProcess:{set value(e){P(t,z,e,`f`)}}.value,groups:{set value(e){P(n,Br,e,`f`)}}.value,output:{set value(e){P(r,U,e,`f`)}}.value,exitError:{set value(e){P(i,Ir,e,`f`)}}.value,hasOutput:{set value(e){P(a,V,e,`f`)}}.value,parsed:this.parsed,strict:{set value(e){P(o,Xr,e,`f`)}}.value,strictCommands:{set value(e){P(s,Zr,e,`f`)}}.value,strictOptions:{set value(e){P(c,Qr,e,`f`)}}.value,completionCommand:{set value(e){P(l,R,e,`f`)}}.value,parseFn:{set value(e){P(u,G,e,`f`)}}.value,parseContext:{set value(e){P(d,Gr,e,`f`)}}.value}=f,F(this,W,`f`).configObjects=p,F(this,q,`f`).unfreeze(),F(this,J,`f`).unfreeze(),F(this,I,`f`).unfreeze(),F(this,B,`f`).unfreeze()}[xi](e,t){return nr(t,t=>(e(t),t))}getInternalMethods(){return{getCommandInstance:this[Si].bind(this),getContext:this[Ci].bind(this),getHasOutput:this[wi].bind(this),getLoggerInstance:this[Ti].bind(this),getParseContext:this[Ei].bind(this),getParserConfiguration:this[ci].bind(this),getUsageConfiguration:this[li].bind(this),getUsageInstance:this[Di].bind(this),getValidationInstance:this[Oi].bind(this),hasParseCallback:this[ki].bind(this),isGlobalContext:this[Ai].bind(this),postProcess:this[ji].bind(this),reset:this[Ni].bind(this),runValidation:this[Fi].bind(this),runYargsParserAndExecuteCommands:this[Pi].bind(this),setHasOutput:this[Ii].bind(this)}}[Si](){return F(this,I,`f`)}[Ci](){return F(this,Pr,`f`)}[wi](){return F(this,V,`f`)}[Ti](){return F(this,Hr,`f`)}[Ei](){return F(this,Gr,`f`)||{}}[Di](){return F(this,q,`f`)}[Oi](){return F(this,J,`f`)}[ki](){return!!F(this,G,`f`)}[Ai](){return F(this,Vr,`f`)}[ji](e,t,n,r){return n||j(e)?e:(t||(e=this[ni](e)),(this[ci]()[`parse-positional-numbers`]||this[ci]()[`parse-positional-numbers`]===void 0)&&(e=this[fi](e)),r&&(e=tr(e,this,F(this,B,`f`).getMiddleware(),!1)),e)}[Ni](e={}){P(this,W,F(this,W,`f`)||{},`f`);let t={};t.local=F(this,W,`f`).local||[],t.configObjects=F(this,W,`f`).configObjects||[];let n={};return t.local.forEach(t=>{n[t]=!0,(e[t]||[]).forEach(e=>{n[e]=!0})}),Object.assign(F(this,qr,`f`),Object.keys(F(this,Br,`f`)).reduce((e,t)=>{let r=F(this,Br,`f`)[t].filter(e=>!(e in n));return r.length>0&&(e[t]=r),e},{})),P(this,Br,{},`f`),[`array`,`boolean`,`string`,`skipValidation`,`count`,`normalize`,`number`,`hiddenOptions`].forEach(e=>{t[e]=(F(this,W,`f`)[e]||[]).filter(e=>!n[e])}),[`narg`,`key`,`alias`,`default`,`defaultDescription`,`config`,`choices`,`demandedOptions`,`demandedCommands`,`deprecatedOptions`].forEach(e=>{t[e]=fr(F(this,W,`f`)[e],e=>!n[e])}),t.envPrefix=F(this,W,`f`).envPrefix,P(this,W,t,`f`),P(this,q,F(this,q,`f`)?F(this,q,`f`).reset(n):hr(this,F(this,K,`f`)),`f`),P(this,J,F(this,J,`f`)?F(this,J,`f`).reset(n):Er(this,F(this,q,`f`),F(this,K,`f`)),`f`),P(this,I,F(this,I,`f`)?F(this,I,`f`).reset():or(F(this,q,`f`),F(this,J,`f`),F(this,B,`f`),F(this,K,`f`)),`f`),F(this,L,`f`)||P(this,L,xr(this,F(this,q,`f`),F(this,I,`f`),F(this,K,`f`)),`f`),F(this,B,`f`).reset(),P(this,R,null,`f`),P(this,U,``,`f`),P(this,Ir,null,`f`),P(this,V,!1,`f`),this.parsed=!1,this}[Mi](e,t){return F(this,K,`f`).path.relative(e,t)}[Pi](e,t,n,r=0,i=!1){let a=!!n||i;e||=F(this,Jr,`f`),F(this,W,`f`).__=F(this,K,`f`).y18n.__,F(this,W,`f`).configuration=this[ci]();let o=!!F(this,W,`f`).configuration[`populate--`],s=Object.assign({},F(this,W,`f`).configuration,{"populate--":!0}),c=F(this,K,`f`).Parser.detailed(e,Object.assign({},F(this,W,`f`),{configuration:{"parse-positional-numbers":!1,...s}})),l=Object.assign(c.argv,F(this,Gr,`f`)),u,d=c.aliases,f=!1,p=!1;Object.keys(l).forEach(e=>{e===F(this,H,`f`)&&l[e]?f=!0:e===F(this,ei,`f`)&&l[e]&&(p=!0)}),l.$0=this.$0,this.parsed=c,r===0&&F(this,q,`f`).clearCachedHelpMessage();try{if(this[ui](),t)return this[ji](l,o,!!n,!1);F(this,H,`f`)&&[F(this,H,`f`)].concat(d[F(this,H,`f`)]||[]).filter(e=>e.length>1).includes(``+l._[l._.length-1])&&(l._.pop(),f=!0),P(this,Vr,!1,`f`);let s=F(this,I,`f`).getCommands(),m=F(this,L,`f`)?.completionKey?[F(this,L,`f`)?.completionKey,...this.getAliases()[F(this,L,`f`)?.completionKey]??[]].some(e=>Object.prototype.hasOwnProperty.call(l,e)):!1,h=f||m||i;if(l._.length){if(s.length){let e;for(let t=r||0,a;l._[t]!==void 0;t++)if(a=String(l._[t]),s.includes(a)&&a!==F(this,R,`f`)){let e=F(this,I,`f`).runCommand(a,this,c,t+1,i,f||p||i);return this[ji](e,o,!!n,!1)}else if(!e&&a!==F(this,R,`f`)){e=a;break}!F(this,I,`f`).hasDefaultCommand()&&F(this,Yr,`f`)&&e&&!h&&F(this,J,`f`).recommendCommands(e,s)}F(this,R,`f`)&&l._.includes(F(this,R,`f`))&&!m&&(F(this,z,`f`)&&pr(!0),this.showCompletionScript(),this.exit(0))}if(F(this,I,`f`).hasDefaultCommand()&&!h){let e=F(this,I,`f`).runCommand(null,this,c,0,i,f||p||i);return this[ji](e,o,!!n,!1)}if(m){F(this,z,`f`)&&pr(!0),e=[].concat(e);let t=e.slice(e.indexOf(`--${F(this,L,`f`).completionKey}`)+1);return F(this,L,`f`).getCompletion(t,(e,t)=>{if(e)throw new M(e.message);(t||[]).forEach(e=>{F(this,Hr,`f`).log(e)}),this.exit(0)}),this[ji](l,!o,!!n,!1)}if(F(this,V,`f`)||(f?(F(this,z,`f`)&&pr(!0),a=!0,this.showHelp(e=>{F(this,Hr,`f`).log(e),this.exit(0)})):p&&(F(this,z,`f`)&&pr(!0),a=!0,F(this,q,`f`).showVersion(`log`),this.exit(0))),!a&&F(this,W,`f`).skipValidation.length>0&&(a=Object.keys(l).some(e=>F(this,W,`f`).skipValidation.indexOf(e)>=0&&l[e]===!0)),!a){if(c.error)throw new M(c.error.message);if(!m){let e=this[Fi](d,{},c.error);n||(u=tr(l,this,F(this,B,`f`).getMiddleware(),!0)),u=this[xi](e,u??l),j(u)&&!n&&(u=u.then(()=>tr(l,this,F(this,B,`f`).getMiddleware(),!1)))}}}catch(e){if(e instanceof M)F(this,q,`f`).fail(e.message,e);else throw e}return this[ji](u??l,o,!!n,!0)}[Fi](e,t,n,r){let i={...this.getDemandedOptions()};return a=>{if(n)throw new M(n.message);F(this,J,`f`).nonOptionCount(a),F(this,J,`f`).requiredArguments(a,i);let o=!1;F(this,Zr,`f`)&&(o=F(this,J,`f`).unknownCommands(a)),F(this,Xr,`f`)&&!o?F(this,J,`f`).unknownArguments(a,e,t,!!r):F(this,Qr,`f`)&&F(this,J,`f`).unknownArguments(a,e,{},!1,!1),F(this,J,`f`).limitedChoices(a),F(this,J,`f`).implications(a),F(this,J,`f`).conflicting(a)}}[Ii](){P(this,V,!0,`f`)}[Li](e){if(typeof e==`string`)F(this,W,`f`).key[e]=!0;else for(let t of e)F(this,W,`f`).key[t]=!0}};function zi(e){return!!e&&typeof e.getInternalMethods==`function`}var Bi=ti(Gn),Vi=class{client;enabled;lastBlockReason;serverName;constructor(e){this.enabled=e.enabled,this.client=e.client,this.serverName=e.serverName,S.info(`AccessControlAuthorizer initialized`,{enabled:this.enabled,hasClient:!!this.client,serverName:this.serverName})}getBlockReason(){return this.lastBlockReason?this.lastBlockReason:`MCP server${this.serverName?` '${this.serverName}'`:``} is not authorized for use in your organization and has been blocked by Onyx.`}async isAllowed(){if(!this.enabled)return!0;if(this.client)try{let e=await this.client.authorize();return e.action===`block`?(e.reason?this.lastBlockReason=e.reason:this.lastBlockReason=`MCP server${this.serverName?` '${this.serverName}'`:``} is not authorized for use in your organization and has been blocked by Onyx.`,!1):!0}catch(e){return S.error(`Access control authorization failed with unexpected error`,{error:String(e)}),!0}return S.warn(`No access control client configured, allowing by default`),!0}},Hi=class{clientInfoBase64;config;constructor(e){this.config=e,this.clientInfoBase64=this.getClientInfoBase64(),S.info(`AccessControlClient initialized`,{timeoutMs:e.timeoutMs,url:e.url})}async authorize(){try{let e=await this.sendAuthorizeRequest();return S.debug(`Access control check successful`,{action:e.action}),e}catch(e){return S.warn(`Access control check failed, failing open (allowing by default)`,{error:String(e)}),{action:`allow`}}}getClientInfoBase64(){return v(this.config.sessionData)}async sendAuthorizeRequest(){let e=new AbortController,t=setTimeout(()=>e.abort(),this.config.timeoutMs);try{let t=`${this.config.url}/${this.config.apiKey}/mcp/${this.clientInfoBase64}`,n=await fetch(t,{headers:{...this.config.headers},method:`POST`,signal:e.signal});if(!n.ok)throw Error(`Access control service returned ${n.status}: ${n.statusText}`);let r=await n.json();if(!r.action||![`allow`,`block`].includes(r.action))throw Error(`Invalid access control response format: action="${r.action}"`);return r}catch(e){throw e instanceof Error&&e.name===`AbortError`?Error(`Access control check timed out after ${this.config.timeoutMs}ms`):e}finally{clearTimeout(t)}}};async function Ui(e){let t=e.toString(),n=me(),r,i;switch(n){case`darwin`:r=`open`,i=[t];break;case`win32`:r=`explorer`,i=[t];break;case`linux`:default:r=`xdg-open`,i=[t];break}return S.info(`Opening browser for OAuth authorization`,{os:n,url:t}),new Promise(e=>{Pe(r,i,(t,n,a)=>{if(t){S.warn(`Failed to open browser automatically`,{args:i,command:r,error:t.message,stderr:a}),e();return}S.debug(`Browser opened successfully`),e()})})}const Wi=49152;function Gi(){return Math.floor(Math.random()*(65535-Wi+1))+Wi}function Ki(e,t){return new Promise((n,r)=>{let i=t=>{e.removeListener(`listening`,a),r(t)},a=()=>{e.removeListener(`error`,i),n()};e.once(`error`,i),e.once(`listening`,a),e.listen(t,`127.0.0.1`)})}async function qi(e={}){let{maxAttempts:t=5,preferredPort:n,timeoutMs:r=3e5}=e,i,a,o={},s=new Promise((e,t)=>{i=e,a=t}),c,l=Te((e,t)=>{if(e.url===`/favicon.ico`){t.writeHead(404),t.end();return}if(!e.url?.startsWith(`/callback`)){t.writeHead(404),t.end(`Not Found`);return}try{let n=new Ie(e.url,`http://localhost:${c}`),r=n.searchParams.get(`code`),s=n.searchParams.get(`error`),u=n.searchParams.get(`error_description`),d=n.searchParams.get(`state`);if(s){S.error(`OAuth authorization error`,{error:s,errorDescription:u}),t.writeHead(400,{"Content-Type":`text/html`}),t.end(Yi(s,u||void 0)),clearTimeout(o.id),a(Error(`OAuth authorization failed: ${s}${u?` - ${u}`:``}`));return}if(!r){S.error(`OAuth callback missing authorization code`),t.writeHead(400,{"Content-Type":`text/html`}),t.end(Yi(`missing_code`,`No authorization code was provided`)),clearTimeout(o.id),a(Error(`OAuth callback missing authorization code`));return}S.info(`OAuth authorization code received`,{codePrefix:`${r.substring(0,10)}...`,hasState:!!d}),t.writeHead(200,{"Content-Type":`text/html`}),t.end(`<!DOCTYPE html>
93
93
  <html lang="en">
94
94
  <head>
95
95
  <meta charset="UTF-8">