diff --git a/dist/artifact-DZtNN4TE.js b/dist/artifact-B9OeWxWy.js similarity index 99% rename from dist/artifact-DZtNN4TE.js rename to dist/artifact-B9OeWxWy.js index 2fbf3fb9..d011f02b 100644 --- a/dist/artifact-DZtNN4TE.js +++ b/dist/artifact-B9OeWxWy.js @@ -13,7 +13,7 @@ Content-Type: ${c.type||`application/octet-stream`}\r\n\r\n`);a.push(e,c,o),type ${n.count} ${n.noun} ${n.is} pending: ${e.format(t)} -`.trim())}}})),Mt=U(((e,t)=>{let n=Symbol.for(`undici.globalDispatcher.1`),{InvalidArgumentError:r}=ke(),i=lt();o()===void 0&&a(new i);function a(e){if(!e||typeof e.dispatch!=`function`)throw new r(`Argument agent must implement Agent`);Object.defineProperty(globalThis,n,{value:e,writable:!0,enumerable:!1,configurable:!1})}function o(){return globalThis[n]}t.exports={setGlobalDispatcher:a,getGlobalDispatcher:o}})),Nt=U(((e,t)=>{t.exports=class{#e;constructor(e){if(typeof e!=`object`||!e)throw TypeError(`handler must be an object`);this.#e=e}onConnect(...e){return this.#e.onConnect?.(...e)}onError(...e){return this.#e.onError?.(...e)}onUpgrade(...e){return this.#e.onUpgrade?.(...e)}onResponseStarted(...e){return this.#e.onResponseStarted?.(...e)}onHeaders(...e){return this.#e.onHeaders?.(...e)}onData(...e){return this.#e.onData?.(...e)}onComplete(...e){return this.#e.onComplete?.(...e)}onBodySent(...e){return this.#e.onBodySent?.(...e)}}})),Pt=U(((e,t)=>{let n=tt();t.exports=e=>{let t=e?.maxRedirections;return e=>function(r,i){let{maxRedirections:a=t,...o}=r;return a?e(o,new n(e,a,r,i)):e(r,i)}}})),Ft=U(((e,t)=>{let n=ft();t.exports=e=>t=>function(r,i){return t(r,new n({...r,retryOptions:{...e,...r.retryOptions}},{handler:i,dispatch:t}))}})),It=U(((e,t)=>{let n=Me(),{InvalidArgumentError:r,RequestAbortedError:i}=ke(),a=Nt();var o=class extends a{#e=1024*1024;#t=null;#n=!1;#r=!1;#i=0;#a=null;#o=null;constructor({maxSize:e},t){if(super(t),e!=null&&(!Number.isFinite(e)||e<1))throw new r(`maxSize must be a number greater than 0`);this.#e=e??this.#e,this.#o=t}onConnect(e){this.#t=e,this.#o.onConnect(this.#s.bind(this))}#s(e){this.#r=!0,this.#a=e}onHeaders(e,t,r,a){let o=n.parseHeaders(t)[`content-length`];if(o!=null&&o>this.#e)throw new i(`Response size (${o}) larger than maxSize (${this.#e})`);return this.#r?!0:this.#o.onHeaders(e,t,r,a)}onError(e){this.#n||(e=this.#a??e,this.#o.onError(e))}onData(e){return this.#i+=e.length,this.#i>=this.#e&&(this.#n=!0,this.#r?this.#o.onError(this.#a):this.#o.onComplete([])),!0}onComplete(e){if(!this.#n){if(this.#r){this.#o.onError(this.reason);return}this.#o.onComplete(e)}}};function s({maxSize:e}={maxSize:1024*1024}){return t=>function(n,r){let{dumpMaxSize:i=e}=n;return t(n,new o({maxSize:i},r))}}t.exports=s})),Lt=U(((e,t)=>{let{isIP:n}=W(`node:net`),{lookup:r}=W(`node:dns`),i=Nt(),{InvalidArgumentError:a,InformationalError:o}=ke(),s=2**31-1;var c=class{#e=0;#t=0;#n=new Map;dualStack=!0;affinity=null;lookup=null;pick=null;constructor(e){this.#e=e.maxTTL,this.#t=e.maxItems,this.dualStack=e.dualStack,this.affinity=e.affinity,this.lookup=e.lookup??this.#r,this.pick=e.pick??this.#i}get full(){return this.#n.size===this.#t}runLookup(e,t,n){let r=this.#n.get(e.hostname);if(r==null&&this.full){n(null,e.origin);return}let i={affinity:this.affinity,dualStack:this.dualStack,lookup:this.lookup,pick:this.pick,...t.dns,maxTTL:this.#e,maxItems:this.#t};if(r==null)this.lookup(e,i,(t,r)=>{if(t||r==null||r.length===0){n(t??new o(`No DNS entries found`));return}this.setRecords(e,r);let a=this.#n.get(e.hostname),s=this.pick(e,a,i.affinity),c;c=typeof s.port==`number`?`:${s.port}`:e.port===``?``:`:${e.port}`,n(null,`${e.protocol}//${s.family===6?`[${s.address}]`:s.address}${c}`)});else{let a=this.pick(e,r,i.affinity);if(a==null){this.#n.delete(e.hostname),this.runLookup(e,t,n);return}let o;o=typeof a.port==`number`?`:${a.port}`:e.port===``?``:`:${e.port}`,n(null,`${e.protocol}//${a.family===6?`[${a.address}]`:a.address}${o}`)}}#r(e,t,n){r(e.hostname,{all:!0,family:this.dualStack===!1?this.affinity:0,order:`ipv4first`},(e,t)=>{if(e)return n(e);let r=new Map;for(let e of t)r.set(`${e.address}:${e.family}`,e);n(null,r.values())})}#i(e,t,n){let r=null,{records:i,offset:a}=t,o;if(this.dualStack?(n??(a==null||a===s?(t.offset=0,n=4):(t.offset++,n=(t.offset&1)==1?6:4)),o=i[n]!=null&&i[n].ips.length>0?i[n]:i[n===4?6:4]):o=i[n],o==null||o.ips.length===0)return r;o.offset==null||o.offset===s?o.offset=0:o.offset++;let c=o.offset%o.ips.length;return r=o.ips[c]??null,r==null?r:Date.now()-r.timestamp>r.ttl?(o.ips.splice(c,1),this.pick(e,t,n)):r}setRecords(e,t){let n=Date.now(),r={records:{4:null,6:null}};for(let e of t){e.timestamp=n,typeof e.ttl==`number`?e.ttl=Math.min(e.ttl,this.#e):e.ttl=this.#e;let t=r.records[e.family]??{ips:[]};t.ips.push(e),r.records[e.family]=t}this.#n.set(e.hostname,r)}getHandler(e,t){return new l(this,e,t)}},l=class extends i{#e=null;#t=null;#n=null;#r=null;#i=null;constructor(e,{origin:t,handler:n,dispatch:r},i){super(n),this.#i=t,this.#r=n,this.#t={...i},this.#e=e,this.#n=r}onError(e){switch(e.code){case`ETIMEDOUT`:case`ECONNREFUSED`:if(this.#e.dualStack){this.#e.runLookup(this.#i,this.#t,(e,t)=>{if(e)return this.#r.onError(e);let n={...this.#t,origin:t};this.#n(n,this)});return}this.#r.onError(e);return;case`ENOTFOUND`:this.#e.deleteRecord(this.#i);default:this.#r.onError(e);break}}};t.exports=e=>{if(e?.maxTTL!=null&&(typeof e?.maxTTL!=`number`||e?.maxTTL<0))throw new a(`Invalid maxTTL. Must be a positive number`);if(e?.maxItems!=null&&(typeof e?.maxItems!=`number`||e?.maxItems<1))throw new a(`Invalid maxItems. Must be a positive number and greater than zero`);if(e?.affinity!=null&&e?.affinity!==4&&e?.affinity!==6)throw new a(`Invalid affinity. Must be either 4 or 6`);if(e?.dualStack!=null&&typeof e?.dualStack!=`boolean`)throw new a(`Invalid dualStack. Must be a boolean`);if(e?.lookup!=null&&typeof e?.lookup!=`function`)throw new a(`Invalid lookup. Must be a function`);if(e?.pick!=null&&typeof e?.pick!=`function`)throw new a(`Invalid pick. Must be a function`);let t=e?.dualStack??!0,r;r=t?e?.affinity??null:e?.affinity??4;let i=new c({maxTTL:e?.maxTTL??1e4,lookup:e?.lookup??null,pick:e?.pick??null,dualStack:t,affinity:r,maxItems:e?.maxItems??1/0});return e=>function(t,r){let a=t.origin.constructor===URL?t.origin:new URL(t.origin);return n(a.hostname)===0?(i.runLookup(a,t,(n,o)=>{if(n)return r.onError(n);let s=null;s={...t,servername:a.hostname,origin:o,headers:{host:a.hostname,...t.headers}},e(s,i.getHandler({origin:a,dispatch:e,handler:r},t))}),!0):e(t,r)}}})),Rt=U(((e,t)=>{let{kConstruct:n}=Oe(),{kEnumerableProperty:r}=Me(),{iteratorMixin:i,isValidHeaderName:a,isValidHeaderValue:o}=qe(),{webidl:s}=Ke(),c=W(`node:assert`),l=W(`node:util`),u=Symbol(`headers map`),d=Symbol(`headers map sorted`);function f(e){return e===10||e===13||e===9||e===32}function p(e){let t=0,n=e.length;for(;n>t&&f(e.charCodeAt(n-1));)--n;for(;n>t&&f(e.charCodeAt(t));)++t;return t===0&&n===e.length?e:e.substring(t,n)}function m(e,t){if(Array.isArray(t))for(let n=0;n>`,`record`]})}function h(e,t,n){if(n=p(n),!a(t))throw s.errors.invalidArgument({prefix:`Headers.append`,value:t,type:`header name`});if(!o(n))throw s.errors.invalidArgument({prefix:`Headers.append`,value:n,type:`header value`});if(b(e)===`immutable`)throw TypeError(`immutable`);return S(e).append(t,n,!1)}function g(e,t){return e[0]>1),t[s][0]<=l[0]?o=s+1:a=s;if(r!==s){for(i=r;i>o;)t[i]=t[--i];t[o]=l}}if(!n.next().done)throw TypeError(`Unreachable`);return t}else{let e=0;for(let{0:n,1:{value:r}}of this[u])t[e++]=[n,r],c(r!==null);return t.sort(g)}}},y=class e{#e;#t;constructor(e=void 0){s.util.markAsUncloneable(this),e!==n&&(this.#t=new v,this.#e=`none`,e!==void 0&&(e=s.converters.HeadersInit(e,`Headers contructor`,`init`),m(this,e)))}append(t,n){s.brandCheck(this,e),s.argumentLengthCheck(arguments,2,`Headers.append`);let r=`Headers.append`;return t=s.converters.ByteString(t,r,`name`),n=s.converters.ByteString(n,r,`value`),h(this,t,n)}delete(t){if(s.brandCheck(this,e),s.argumentLengthCheck(arguments,1,`Headers.delete`),t=s.converters.ByteString(t,`Headers.delete`,`name`),!a(t))throw s.errors.invalidArgument({prefix:`Headers.delete`,value:t,type:`header name`});if(this.#e===`immutable`)throw TypeError(`immutable`);this.#t.contains(t,!1)&&this.#t.delete(t,!1)}get(t){s.brandCheck(this,e),s.argumentLengthCheck(arguments,1,`Headers.get`);let n=`Headers.get`;if(t=s.converters.ByteString(t,n,`name`),!a(t))throw s.errors.invalidArgument({prefix:n,value:t,type:`header name`});return this.#t.get(t,!1)}has(t){s.brandCheck(this,e),s.argumentLengthCheck(arguments,1,`Headers.has`);let n=`Headers.has`;if(t=s.converters.ByteString(t,n,`name`),!a(t))throw s.errors.invalidArgument({prefix:n,value:t,type:`header name`});return this.#t.contains(t,!1)}set(t,n){s.brandCheck(this,e),s.argumentLengthCheck(arguments,2,`Headers.set`);let r=`Headers.set`;if(t=s.converters.ByteString(t,r,`name`),n=s.converters.ByteString(n,r,`value`),n=p(n),!a(t))throw s.errors.invalidArgument({prefix:r,value:t,type:`header name`});if(!o(n))throw s.errors.invalidArgument({prefix:r,value:n,type:`header value`});if(this.#e===`immutable`)throw TypeError(`immutable`);this.#t.set(t,n,!1)}getSetCookie(){s.brandCheck(this,e);let t=this.#t.cookies;return t?[...t]:[]}get[d](){if(this.#t[d])return this.#t[d];let e=[],t=this.#t.toSortedArray(),n=this.#t.cookies;if(n===null||n.length===1)return this.#t[d]=t;for(let r=0;r>`](e,t,n,r.bind(e)):s.converters[`record`](e,t,n)}throw s.errors.conversionFailed({prefix:`Headers constructor`,argument:`Argument 1`,types:[`sequence>`,`record`]})},t.exports={fill:m,compareHeaderName:g,Headers:y,HeadersList:v,getHeadersGuard:b,setHeadersGuard:x,setHeadersList:C,getHeadersList:S}})),zt=U(((e,t)=>{let{Headers:n,HeadersList:r,fill:i,getHeadersGuard:a,setHeadersGuard:o,setHeadersList:s}=Rt(),{extractBody:c,cloneBody:l,mixinBody:u,hasFinalizationRegistry:d,streamRegistry:f,bodyUnusable:p}=Qe(),m=Me(),h=W(`node:util`),{kEnumerableProperty:g}=m,{isValidReasonPhrase:v,isCancelled:y,isAborted:b,isBlobLike:x,serializeJavascriptValueToJSONString:S,isErrorLike:C,isomorphicEncode:w,environmentSettingsObject:T}=qe(),{redirectStatusSet:E,nullBodyStatus:D}=Ue(),{kState:O,kHeaders:k}=Je(),{webidl:A}=Ke(),{FormData:j}=Xe(),{URLSerializer:M}=Ge(),{kConstruct:N}=Oe(),P=W(`node:assert`),{types:F}=W(`node:util`),I=new TextEncoder(`utf-8`);var L=class e{static error(){return re(ee(),`immutable`)}static json(e,t={}){A.argumentLengthCheck(arguments,1,`Response.json`),t!==null&&(t=A.converters.ResponseInit(t));let n=c(I.encode(S(e))),r=re(z({}),`response`);return H(r,t,{body:n[0],type:`application/json`}),r}static redirect(e,t=302){A.argumentLengthCheck(arguments,1,`Response.redirect`),e=A.converters.USVString(e),t=A.converters[`unsigned short`](t);let n;try{n=new URL(e,T.settingsObject.baseUrl)}catch(t){throw TypeError(`Failed to parse URL from ${e}`,{cause:t})}if(!E.has(t))throw RangeError(`Invalid status code ${t}`);let r=re(z({}),`immutable`);r[O].status=t;let i=w(M(n));return r[O].headersList.append(`location`,i,!0),r}constructor(e=null,t={}){if(A.util.markAsUncloneable(this),e===N)return;e!==null&&(e=A.converters.BodyInit(e)),t=A.converters.ResponseInit(t),this[O]=z({}),this[k]=new n(N),o(this[k],`response`),s(this[k],this[O].headersList);let r=null;if(e!=null){let[t,n]=c(e);r={body:t,type:n}}H(this,t,r)}get type(){return A.brandCheck(this,e),this[O].type}get url(){A.brandCheck(this,e);let t=this[O].urlList,n=t[t.length-1]??null;return n===null?``:M(n,!0)}get redirected(){return A.brandCheck(this,e),this[O].urlList.length>1}get status(){return A.brandCheck(this,e),this[O].status}get ok(){return A.brandCheck(this,e),this[O].status>=200&&this[O].status<=299}get statusText(){return A.brandCheck(this,e),this[O].statusText}get headers(){return A.brandCheck(this,e),this[k]}get body(){return A.brandCheck(this,e),this[O].body?this[O].body.stream:null}get bodyUsed(){return A.brandCheck(this,e),!!this[O].body&&m.isDisturbed(this[O].body.stream)}clone(){if(A.brandCheck(this,e),p(this))throw A.errors.exception({header:`Response.clone`,message:`Body has already been consumed.`});let t=R(this[O]);return d&&this[O].body?.stream&&f.register(this,new WeakRef(this[O].body.stream)),re(t,a(this[k]))}[h.inspect.custom](e,t){t.depth===null&&(t.depth=2),t.colors??=!0;let n={status:this.status,statusText:this.statusText,headers:this.headers,body:this.body,bodyUsed:this.bodyUsed,ok:this.ok,redirected:this.redirected,type:this.type,url:this.url};return`Response ${h.formatWithOptions(t,n)}`}};u(L),Object.defineProperties(L.prototype,{type:g,url:g,status:g,ok:g,redirected:g,statusText:g,headers:g,clone:g,body:g,bodyUsed:g,[Symbol.toStringTag]:{value:`Response`,configurable:!0}}),Object.defineProperties(L,{json:g,redirect:g,error:g});function R(e){if(e.internalResponse)return V(R(e.internalResponse),e.type);let t=z({...e,body:null});return e.body!=null&&(t.body=l(t,e.body)),t}function z(e){return{aborted:!1,rangeRequested:!1,timingAllowPassed:!1,requestIncludesCredentials:!1,type:`default`,status:200,timingInfo:null,cacheState:``,statusText:``,...e,headersList:e?.headersList?new r(e?.headersList):new r,urlList:e?.urlList?[...e.urlList]:[]}}function ee(e){return z({type:`error`,status:0,error:C(e)?e:Error(e&&String(e)),aborted:e&&e.name===`AbortError`})}function B(e){return e.type===`error`&&e.status===0}function te(e,t){return t={internalResponse:e,...t},new Proxy(e,{get(e,n){return n in t?t[n]:e[n]},set(e,n,r){return P(!(n in t)),e[n]=r,!0}})}function V(e,t){if(t===`basic`)return te(e,{type:`basic`,headersList:e.headersList});if(t===`cors`)return te(e,{type:`cors`,headersList:e.headersList});if(t===`opaque`)return te(e,{type:`opaque`,urlList:Object.freeze([]),status:0,statusText:``,body:null});if(t===`opaqueredirect`)return te(e,{type:`opaqueredirect`,status:0,statusText:``,headersList:[],body:null});P(!1)}function ne(e,t=null){return P(y(e)),b(e)?ee(Object.assign(new DOMException(`The operation was aborted.`,`AbortError`),{cause:t})):ee(Object.assign(new DOMException(`Request was cancelled.`),{cause:t}))}function H(e,t,n){if(t.status!==null&&(t.status<200||t.status>599))throw RangeError(`init["status"] must be in the range of 200 to 599, inclusive.`);if(`statusText`in t&&t.statusText!=null&&!v(String(t.statusText)))throw TypeError(`Invalid statusText`);if(`status`in t&&t.status!=null&&(e[O].status=t.status),`statusText`in t&&t.statusText!=null&&(e[O].statusText=t.statusText),`headers`in t&&t.headers!=null&&i(e[k],t.headers),n){if(D.includes(e.status))throw A.errors.exception({header:`Response constructor`,message:`Invalid response status code ${e.status}`});e[O].body=n.body,n.type!=null&&!e[O].headersList.contains(`content-type`,!0)&&e[O].headersList.append(`content-type`,n.type,!0)}}function re(e,t){let r=new L(N);return r[O]=e,r[k]=new n(N),s(r[k],e.headersList),o(r[k],t),d&&e.body?.stream&&f.register(r,new WeakRef(e.body.stream)),r}A.converters.ReadableStream=A.interfaceConverter(ReadableStream),A.converters.FormData=A.interfaceConverter(j),A.converters.URLSearchParams=A.interfaceConverter(URLSearchParams),A.converters.XMLHttpRequestBodyInit=function(e,t,n){return typeof e==`string`?A.converters.USVString(e,t,n):x(e)?A.converters.Blob(e,t,n,{strict:!1}):ArrayBuffer.isView(e)||F.isArrayBuffer(e)?A.converters.BufferSource(e,t,n):m.isFormDataLike(e)?A.converters.FormData(e,t,n,{strict:!1}):e instanceof URLSearchParams?A.converters.URLSearchParams(e,t,n):A.converters.DOMString(e,t,n)},A.converters.BodyInit=function(e,t,n){return e instanceof ReadableStream?A.converters.ReadableStream(e,t,n):e?.[Symbol.asyncIterator]?e:A.converters.XMLHttpRequestBodyInit(e,t,n)},A.converters.ResponseInit=A.dictionaryConverter([{key:`status`,converter:A.converters[`unsigned short`],defaultValue:()=>200},{key:`statusText`,converter:A.converters.ByteString,defaultValue:()=>``},{key:`headers`,converter:A.converters.HeadersInit}]),t.exports={isNetworkError:B,makeNetworkError:ee,makeResponse:z,makeAppropriateNetworkError:ne,filterResponse:V,Response:L,cloneResponse:R,fromInnerResponse:re}})),Bt=U(((e,t)=>{let{kConnected:n,kSize:r}=Oe();var i=class{constructor(e){this.value=e}deref(){return this.value[n]===0&&this.value[r]===0?void 0:this.value}},a=class{constructor(e){this.finalizer=e}register(e,t){e.on&&e.on(`disconnect`,()=>{e[n]===0&&e[r]===0&&this.finalizer(t)})}unregister(e){}};t.exports=function(){return process.env.NODE_V8_COVERAGE&&process.version.startsWith(`v18`)?(process._rawDebug(`Using compatibility WeakRef and FinalizationRegistry`),{WeakRef:i,FinalizationRegistry:a}):{WeakRef,FinalizationRegistry}}})),Vt=U(((e,t)=>{let{extractBody:n,mixinBody:r,cloneBody:i,bodyUnusable:a}=Qe(),{Headers:o,fill:s,HeadersList:c,setHeadersGuard:l,getHeadersGuard:u,setHeadersList:d,getHeadersList:f}=Rt(),{FinalizationRegistry:p}=Bt()(),m=Me(),h=W(`node:util`),{isValidHTTPToken:g,sameOrigin:v,environmentSettingsObject:y}=qe(),{forbiddenMethodsSet:b,corsSafeListedMethodsSet:x,referrerPolicy:S,requestRedirect:C,requestMode:w,requestCredentials:T,requestCache:E,requestDuplex:D}=Ue(),{kEnumerableProperty:O,normalizedMethodRecordsBase:k,normalizedMethodRecords:A}=m,{kHeaders:j,kSignal:M,kState:N,kDispatcher:P}=Je(),{webidl:F}=Ke(),{URLSerializer:I}=Ge(),{kConstruct:L}=Oe(),R=W(`node:assert`),{getMaxListeners:z,setMaxListeners:ee,getEventListeners:B,defaultMaxListeners:te}=W(`node:events`),V=Symbol(`abortController`),ne=new p(({signal:e,abort:t})=>{e.removeEventListener(`abort`,t)}),H=new WeakMap;function re(e){return t;function t(){let n=e.deref();if(n!==void 0){ne.unregister(t),this.removeEventListener(`abort`,t),n.abort(this.reason);let e=H.get(n.signal);if(e!==void 0){if(e.size!==0){for(let t of e){let e=t.deref();e!==void 0&&e.abort(this.reason)}e.clear()}H.delete(n.signal)}}}}let ie=!1;var ae=class e{constructor(t,r={}){if(F.util.markAsUncloneable(this),t===L)return;let i=`Request constructor`;F.argumentLengthCheck(arguments,1,i),t=F.converters.RequestInfo(t,i,`input`),r=F.converters.RequestInit(r,i,`init`);let u=null,p=null,h=y.settingsObject.baseUrl,S=null;if(typeof t==`string`){this[P]=r.dispatcher;let e;try{e=new URL(t,h)}catch(e){throw TypeError(`Failed to parse URL from `+t,{cause:e})}if(e.username||e.password)throw TypeError(`Request cannot be constructed from a URL that includes credentials: `+t);u=oe({urlList:[e]}),p=`cors`}else this[P]=r.dispatcher||t[P],R(t instanceof e),u=t[N],S=t[M];let C=y.settingsObject.origin,w=`client`;if(u.window?.constructor?.name===`EnvironmentSettingsObject`&&v(u.window,C)&&(w=u.window),r.window!=null)throw TypeError(`'window' option '${w}' must be null`);`window`in r&&(w=`no-window`),u=oe({method:u.method,headersList:u.headersList,unsafeRequest:u.unsafeRequest,client:y.settingsObject,window:w,priority:u.priority,origin:u.origin,referrer:u.referrer,referrerPolicy:u.referrerPolicy,mode:u.mode,credentials:u.credentials,cache:u.cache,redirect:u.redirect,integrity:u.integrity,keepalive:u.keepalive,reloadNavigation:u.reloadNavigation,historyNavigation:u.historyNavigation,urlList:[...u.urlList]});let T=Object.keys(r).length!==0;if(T&&(u.mode===`navigate`&&(u.mode=`same-origin`),u.reloadNavigation=!1,u.historyNavigation=!1,u.origin=`client`,u.referrer=`client`,u.referrerPolicy=``,u.url=u.urlList[u.urlList.length-1],u.urlList=[u.url]),r.referrer!==void 0){let e=r.referrer;if(e===``)u.referrer=`no-referrer`;else{let t;try{t=new URL(e,h)}catch(t){throw TypeError(`Referrer "${e}" is not a valid URL.`,{cause:t})}t.protocol===`about:`&&t.hostname===`client`||C&&!v(t,y.settingsObject.baseUrl)?u.referrer=`client`:u.referrer=t}}r.referrerPolicy!==void 0&&(u.referrerPolicy=r.referrerPolicy);let E;if(E=r.mode===void 0?p:r.mode,E===`navigate`)throw F.errors.exception({header:`Request constructor`,message:`invalid request mode navigate.`});if(E!=null&&(u.mode=E),r.credentials!==void 0&&(u.credentials=r.credentials),r.cache!==void 0&&(u.cache=r.cache),u.cache===`only-if-cached`&&u.mode!==`same-origin`)throw TypeError(`'only-if-cached' can be set only with 'same-origin' mode`);if(r.redirect!==void 0&&(u.redirect=r.redirect),r.integrity!=null&&(u.integrity=String(r.integrity)),r.keepalive!==void 0&&(u.keepalive=!!r.keepalive),r.method!==void 0){let e=r.method,t=A[e];if(t!==void 0)u.method=t;else{if(!g(e))throw TypeError(`'${e}' is not a valid HTTP method.`);let t=e.toUpperCase();if(b.has(t))throw TypeError(`'${e}' HTTP method is unsupported.`);e=k[t]??e,u.method=e}!ie&&u.method===`patch`&&(process.emitWarning("Using `patch` is highly likely to result in a `405 Method Not Allowed`. `PATCH` is much more likely to succeed.",{code:`UNDICI-FETCH-patch`}),ie=!0)}r.signal!==void 0&&(S=r.signal),this[N]=u;let D=new AbortController;if(this[M]=D.signal,S!=null){if(!S||typeof S.aborted!=`boolean`||typeof S.addEventListener!=`function`)throw TypeError(`Failed to construct 'Request': member signal is not of type AbortSignal.`);if(S.aborted)D.abort(S.reason);else{this[V]=D;let e=re(new WeakRef(D));try{(typeof z==`function`&&z(S)===te||B(S,`abort`).length>=te)&&ee(1500,S)}catch{}m.addAbortListener(S,e),ne.register(D,{signal:S,abort:e},e)}}if(this[j]=new o(L),d(this[j],u.headersList),l(this[j],`request`),E===`no-cors`){if(!x.has(u.method))throw TypeError(`'${u.method} is unsupported in no-cors mode.`);l(this[j],`request-no-cors`)}if(T){let e=f(this[j]),t=r.headers===void 0?new c(e):r.headers;if(e.clear(),t instanceof c){for(let{name:n,value:r}of t.rawValues())e.append(n,r,!1);e.cookies=t.cookies}else s(this[j],t)}let O=t instanceof e?t[N].body:null;if((r.body!=null||O!=null)&&(u.method===`GET`||u.method===`HEAD`))throw TypeError(`Request with GET/HEAD method cannot have body.`);let I=null;if(r.body!=null){let[e,t]=n(r.body,u.keepalive);I=e,t&&!f(this[j]).contains(`content-type`,!0)&&this[j].append(`content-type`,t)}let H=I??O;if(H!=null&&H.source==null){if(I!=null&&r.duplex==null)throw TypeError(`RequestInit: duplex option is required when sending a body.`);if(u.mode!==`same-origin`&&u.mode!==`cors`)throw TypeError(`If request is made from ReadableStream, mode should be "same-origin" or "cors"`);u.useCORSPreflightFlag=!0}let ae=H;if(I==null&&O!=null){if(a(t))throw TypeError(`Cannot construct a Request with a Request object that has already been used.`);let e=new TransformStream;O.stream.pipeThrough(e),ae={source:O.source,length:O.length,stream:e.readable}}this[N].body=ae}get method(){return F.brandCheck(this,e),this[N].method}get url(){return F.brandCheck(this,e),I(this[N].url)}get headers(){return F.brandCheck(this,e),this[j]}get destination(){return F.brandCheck(this,e),this[N].destination}get referrer(){return F.brandCheck(this,e),this[N].referrer===`no-referrer`?``:this[N].referrer===`client`?`about:client`:this[N].referrer.toString()}get referrerPolicy(){return F.brandCheck(this,e),this[N].referrerPolicy}get mode(){return F.brandCheck(this,e),this[N].mode}get credentials(){return this[N].credentials}get cache(){return F.brandCheck(this,e),this[N].cache}get redirect(){return F.brandCheck(this,e),this[N].redirect}get integrity(){return F.brandCheck(this,e),this[N].integrity}get keepalive(){return F.brandCheck(this,e),this[N].keepalive}get isReloadNavigation(){return F.brandCheck(this,e),this[N].reloadNavigation}get isHistoryNavigation(){return F.brandCheck(this,e),this[N].historyNavigation}get signal(){return F.brandCheck(this,e),this[M]}get body(){return F.brandCheck(this,e),this[N].body?this[N].body.stream:null}get bodyUsed(){return F.brandCheck(this,e),!!this[N].body&&m.isDisturbed(this[N].body.stream)}get duplex(){return F.brandCheck(this,e),`half`}clone(){if(F.brandCheck(this,e),a(this))throw TypeError(`unusable`);let t=se(this[N]),n=new AbortController;if(this.signal.aborted)n.abort(this.signal.reason);else{let e=H.get(this.signal);e===void 0&&(e=new Set,H.set(this.signal,e));let t=new WeakRef(n);e.add(t),m.addAbortListener(n.signal,re(t))}return ce(t,n.signal,u(this[j]))}[h.inspect.custom](e,t){t.depth===null&&(t.depth=2),t.colors??=!0;let n={method:this.method,url:this.url,headers:this.headers,destination:this.destination,referrer:this.referrer,referrerPolicy:this.referrerPolicy,mode:this.mode,credentials:this.credentials,cache:this.cache,redirect:this.redirect,integrity:this.integrity,keepalive:this.keepalive,isReloadNavigation:this.isReloadNavigation,isHistoryNavigation:this.isHistoryNavigation,signal:this.signal};return`Request ${h.formatWithOptions(t,n)}`}};r(ae);function oe(e){return{method:e.method??`GET`,localURLsOnly:e.localURLsOnly??!1,unsafeRequest:e.unsafeRequest??!1,body:e.body??null,client:e.client??null,reservedClient:e.reservedClient??null,replacesClientId:e.replacesClientId??``,window:e.window??`client`,keepalive:e.keepalive??!1,serviceWorkers:e.serviceWorkers??`all`,initiator:e.initiator??``,destination:e.destination??``,priority:e.priority??null,origin:e.origin??`client`,policyContainer:e.policyContainer??`client`,referrer:e.referrer??`client`,referrerPolicy:e.referrerPolicy??``,mode:e.mode??`no-cors`,useCORSPreflightFlag:e.useCORSPreflightFlag??!1,credentials:e.credentials??`same-origin`,useCredentials:e.useCredentials??!1,cache:e.cache??`default`,redirect:e.redirect??`follow`,integrity:e.integrity??``,cryptoGraphicsNonceMetadata:e.cryptoGraphicsNonceMetadata??``,parserMetadata:e.parserMetadata??``,reloadNavigation:e.reloadNavigation??!1,historyNavigation:e.historyNavigation??!1,userActivation:e.userActivation??!1,taintedOrigin:e.taintedOrigin??!1,redirectCount:e.redirectCount??0,responseTainting:e.responseTainting??`basic`,preventNoCacheCacheControlHeaderModification:e.preventNoCacheCacheControlHeaderModification??!1,done:e.done??!1,timingAllowFailed:e.timingAllowFailed??!1,urlList:e.urlList,url:e.urlList[0],headersList:e.headersList?new c(e.headersList):new c}}function se(e){let t=oe({...e,body:null});return e.body!=null&&(t.body=i(t,e.body)),t}function ce(e,t,n){let r=new ae(L);return r[N]=e,r[M]=t,r[j]=new o(L),d(r[j],e.headersList),l(r[j],n),r}Object.defineProperties(ae.prototype,{method:O,url:O,headers:O,redirect:O,clone:O,signal:O,duplex:O,destination:O,body:O,bodyUsed:O,isHistoryNavigation:O,isReloadNavigation:O,keepalive:O,integrity:O,cache:O,credentials:O,attribute:O,referrerPolicy:O,referrer:O,mode:O,[Symbol.toStringTag]:{value:`Request`,configurable:!0}}),F.converters.Request=F.interfaceConverter(ae),F.converters.RequestInfo=function(e,t,n){return typeof e==`string`?F.converters.USVString(e,t,n):e instanceof ae?F.converters.Request(e,t,n):F.converters.USVString(e,t,n)},F.converters.AbortSignal=F.interfaceConverter(AbortSignal),F.converters.RequestInit=F.dictionaryConverter([{key:`method`,converter:F.converters.ByteString},{key:`headers`,converter:F.converters.HeadersInit},{key:`body`,converter:F.nullableConverter(F.converters.BodyInit)},{key:`referrer`,converter:F.converters.USVString},{key:`referrerPolicy`,converter:F.converters.DOMString,allowedValues:S},{key:`mode`,converter:F.converters.DOMString,allowedValues:w},{key:`credentials`,converter:F.converters.DOMString,allowedValues:T},{key:`cache`,converter:F.converters.DOMString,allowedValues:E},{key:`redirect`,converter:F.converters.DOMString,allowedValues:C},{key:`integrity`,converter:F.converters.DOMString},{key:`keepalive`,converter:F.converters.boolean},{key:`signal`,converter:F.nullableConverter(e=>F.converters.AbortSignal(e,`RequestInit`,`signal`,{strict:!1}))},{key:`window`,converter:F.converters.any},{key:`duplex`,converter:F.converters.DOMString,allowedValues:D},{key:`dispatcher`,converter:F.converters.any}]),t.exports={Request:ae,makeRequest:oe,fromInnerRequest:ce,cloneRequest:se}})),Ht=U(((e,t)=>{let{makeNetworkError:n,makeAppropriateNetworkError:r,filterResponse:i,makeResponse:a,fromInnerResponse:o}=zt(),{HeadersList:s}=Rt(),{Request:c,cloneRequest:l}=Vt(),u=W(`node:zlib`),{bytesMatch:d,makePolicyContainer:f,clonePolicyContainer:p,requestBadPort:m,TAOCheck:h,appendRequestOriginHeader:g,responseLocationURL:v,requestCurrentURL:y,setRequestReferrerPolicyOnRedirect:b,tryUpgradeRequestToAPotentiallyTrustworthyURL:x,createOpaqueTimingInfo:S,appendFetchMetadata:C,corsCheck:w,crossOriginResourcePolicyCheck:T,determineRequestsReferrer:E,coarsenedSharedCurrentTime:D,createDeferredPromise:O,isBlobLike:k,sameOrigin:A,isCancelled:j,isAborted:M,isErrorLike:N,fullyReadBody:P,readableStreamClose:F,isomorphicEncode:I,urlIsLocal:L,urlIsHttpHttpsScheme:R,urlHasHttpsScheme:z,clampAndCoarsenConnectionTimingInfo:ee,simpleRangeHeaderValue:B,buildContentRange:te,createInflate:V,extractMimeType:ne}=qe(),{kState:H,kDispatcher:re}=Je(),ie=W(`node:assert`),{safelyExtractBody:ae,extractBody:oe}=Qe(),{redirectStatusSet:se,nullBodyStatus:ce,safeMethodsSet:le,requestBodyHeader:ue,subresourceSet:U}=Ue(),de=W(`node:events`),{Readable:fe,pipeline:pe,finished:me}=W(`node:stream`),{addAbortListener:he,isErrored:ge,isReadable:_e,bufferToLowerCasedHeaderName:ve}=Me(),{dataURLProcessor:ye,serializeAMimeType:be,minimizeSupportedMimeType:xe}=Ge(),{getGlobalDispatcher:Se}=Mt(),{webidl:Ce}=Ke(),{STATUS_CODES:we}=W(`node:http`),Te=[`GET`,`HEAD`],Ee=typeof __UNDICI_IS_NODE__<`u`||typeof esbuildDetection<`u`?`node`:`undici`,De;var Oe=class extends de{constructor(e){super(),this.dispatcher=e,this.connection=null,this.dump=!1,this.state=`ongoing`}terminate(e){this.state===`ongoing`&&(this.state=`terminated`,this.connection?.destroy(e),this.emit(`terminated`,e))}abort(e){this.state===`ongoing`&&(this.state=`aborted`,e||=new DOMException(`The operation was aborted.`,`AbortError`),this.serializedAbortReason=e,this.connection?.destroy(e),this.emit(`terminated`,e))}};function ke(e){je(e,`fetch`)}function Ae(e,t=void 0){Ce.argumentLengthCheck(arguments,1,`globalThis.fetch`);let n=O(),r;try{r=new c(e,t)}catch(e){return n.reject(e),n.promise}let i=r[H];if(r.signal.aborted)return Pe(n,i,null,r.signal.reason),n.promise;i.client.globalObject?.constructor?.name===`ServiceWorkerGlobalScope`&&(i.serviceWorkers=`none`);let a=null,s=!1,l=null;return he(r.signal,()=>{s=!0,ie(l!=null),l.abort(r.signal.reason);let e=a?.deref();Pe(n,i,e,r.signal.reason)}),l=Fe({request:i,processResponseEndOfBody:ke,processResponse:e=>{if(!s){if(e.aborted){Pe(n,i,a,l.serializedAbortReason);return}if(e.type===`error`){n.reject(TypeError(`fetch failed`,{cause:e.error}));return}a=new WeakRef(o(e,`immutable`)),n.resolve(a.deref()),n=null}},dispatcher:r[re]}),n.promise}function je(e,t=`other`){if(e.type===`error`&&e.aborted||!e.urlList?.length)return;let n=e.urlList[0],r=e.timingInfo,i=e.cacheState;R(n)&&r!==null&&(e.timingAllowPassed||(r=S({startTime:r.startTime}),i=``),r.endTime=D(),e.timingInfo=r,Ne(r,n.href,t,globalThis,i))}let Ne=performance.markResourceTiming;function Pe(e,t,n,r){if(e&&e.reject(r),t.body!=null&&_e(t.body?.stream)&&t.body.stream.cancel(r).catch(e=>{if(e.code!==`ERR_INVALID_STATE`)throw e}),n==null)return;let i=n[H];i.body!=null&&_e(i.body?.stream)&&i.body.stream.cancel(r).catch(e=>{if(e.code!==`ERR_INVALID_STATE`)throw e})}function Fe({request:e,processRequestBodyChunkLength:t,processRequestEndOfBody:n,processResponse:r,processResponseEndOfBody:i,processResponseConsumeBody:a,useParallelQueue:o=!1,dispatcher:s=Se()}){ie(s);let c=null,l=!1;e.client!=null&&(c=e.client.globalObject,l=e.client.crossOriginIsolatedCapability);let u=S({startTime:D(l)}),d={controller:new Oe(s),request:e,timingInfo:u,processRequestBodyChunkLength:t,processRequestEndOfBody:n,processResponse:r,processResponseConsumeBody:a,processResponseEndOfBody:i,taskDestination:c,crossOriginIsolatedCapability:l};return ie(!e.body||e.body.stream),e.window===`client`&&(e.window=e.client?.globalObject?.constructor?.name===`Window`?e.client:`no-window`),e.origin===`client`&&(e.origin=e.client.origin),e.policyContainer===`client`&&(e.client==null?e.policyContainer=f():e.policyContainer=p(e.client.policyContainer)),e.headersList.contains(`accept`,!0)||e.headersList.append(`accept`,`*/*`,!0),e.headersList.contains(`accept-language`,!0)||e.headersList.append(`accept-language`,`*`,!0),e.priority,U.has(e.destination),Ie(d).catch(e=>{d.controller.terminate(e)}),d.controller}async function Ie(e,t=!1){let r=e.request,a=null;if(r.localURLsOnly&&!L(y(r))&&(a=n(`local URLs only`)),x(r),m(r)===`blocked`&&(a=n(`bad port`)),r.referrerPolicy===``&&(r.referrerPolicy=r.policyContainer.referrerPolicy),r.referrer!==`no-referrer`&&(r.referrer=E(r)),a===null&&(a=await(async()=>{let t=y(r);return A(t,r.url)&&r.responseTainting===`basic`||t.protocol===`data:`||r.mode===`navigate`||r.mode===`websocket`?(r.responseTainting=`basic`,await Le(e)):r.mode===`same-origin`?n(`request mode cannot be "same-origin"`):r.mode===`no-cors`?r.redirect===`follow`?(r.responseTainting=`opaque`,await Le(e)):n(`redirect mode cannot be "follow" for "no-cors" request`):R(y(r))?(r.responseTainting=`cors`,await Be(e)):n(`URL scheme must be a HTTP(S) scheme`)})()),t)return a;a.status!==0&&!a.internalResponse&&(r.responseTainting,r.responseTainting===`basic`?a=i(a,`basic`):r.responseTainting===`cors`?a=i(a,`cors`):r.responseTainting===`opaque`?a=i(a,`opaque`):ie(!1));let o=a.status===0?a:a.internalResponse;if(o.urlList.length===0&&o.urlList.push(...r.urlList),r.timingAllowFailed||(a.timingAllowPassed=!0),a.type===`opaque`&&o.status===206&&o.rangeRequested&&!r.headers.contains(`range`,!0)&&(a=o=n()),a.status!==0&&(r.method===`HEAD`||r.method===`CONNECT`||ce.includes(o.status))&&(o.body=null,e.controller.dump=!0),r.integrity){let t=t=>ze(e,n(t));if(r.responseTainting===`opaque`||a.body==null){t(a.error);return}await P(a.body,n=>{if(!d(n,r.integrity)){t(`integrity mismatch`);return}a.body=ae(n)[0],ze(e,a)},t)}else ze(e,a)}function Le(e){if(j(e)&&e.request.redirectCount===0)return Promise.resolve(r(e));let{request:t}=e,{protocol:i}=y(t);switch(i){case`about:`:return Promise.resolve(n(`about scheme is not supported`));case`blob:`:{De||=W(`node:buffer`).resolveObjectURL;let e=y(t);if(e.search.length!==0)return Promise.resolve(n(`NetworkError when attempting to fetch resource.`));let r=De(e.toString());if(t.method!==`GET`||!k(r))return Promise.resolve(n(`invalid method`));let i=a(),o=r.size,s=I(`${o}`),c=r.type;if(t.headersList.contains(`range`,!0)){i.rangeRequested=!0;let e=B(t.headersList.get(`range`,!0),!0);if(e===`failure`)return Promise.resolve(n(`failed to fetch the data URL`));let{rangeStartValue:a,rangeEndValue:s}=e;if(a===null)a=o-s,s=a+s-1;else{if(a>=o)return Promise.resolve(n(`Range start is greater than the blob's size.`));(s===null||s>=o)&&(s=o-1)}let l=r.slice(a,s,c);i.body=oe(l)[0];let u=I(`${l.size}`),d=te(a,s,o);i.status=206,i.statusText=`Partial Content`,i.headersList.set(`content-length`,u,!0),i.headersList.set(`content-type`,c,!0),i.headersList.set(`content-range`,d,!0)}else{let e=oe(r);i.statusText=`OK`,i.body=e[0],i.headersList.set(`content-length`,s,!0),i.headersList.set(`content-type`,c,!0)}return Promise.resolve(i)}case`data:`:{let e=ye(y(t));if(e===`failure`)return Promise.resolve(n(`failed to fetch the data URL`));let r=be(e.mimeType);return Promise.resolve(a({statusText:`OK`,headersList:[[`content-type`,{name:`Content-Type`,value:r}]],body:ae(e.body)[0]}))}case`file:`:return Promise.resolve(n(`not implemented... yet...`));case`http:`:case`https:`:return Be(e).catch(e=>n(e));default:return Promise.resolve(n(`unknown scheme`))}}function Re(e,t){e.request.done=!0,e.processResponseDone!=null&&queueMicrotask(()=>e.processResponseDone(t))}function ze(e,t){let n=e.timingInfo,r=()=>{let r=Date.now();e.request.destination===`document`&&(e.controller.fullTimingInfo=n),e.controller.reportTimingSteps=()=>{if(e.request.url.protocol!==`https:`)return;n.endTime=r;let i=t.cacheState,a=t.bodyInfo;t.timingAllowPassed||(n=S(n),i=``);let o=0;if(e.request.mode!==`navigator`||!t.hasCrossOriginRedirects){o=t.status;let e=ne(t.headersList);e!==`failure`&&(a.contentType=xe(e))}e.request.initiatorType!=null&&Ne(n,e.request.url.href,e.request.initiatorType,globalThis,i,a,o)};let i=()=>{e.request.done=!0,e.processResponseEndOfBody!=null&&queueMicrotask(()=>e.processResponseEndOfBody(t)),e.request.initiatorType!=null&&e.controller.reportTimingSteps()};queueMicrotask(()=>i())};e.processResponse!=null&&queueMicrotask(()=>{e.processResponse(t),e.processResponse=null});let i=t.type===`error`?t:t.internalResponse??t;i.body==null?r():me(i.body.stream,()=>{r()})}async function Be(e){let t=e.request,r=null,i=null,a=e.timingInfo;if(t.serviceWorkers,r===null){if(t.redirect===`follow`&&(t.serviceWorkers=`none`),i=r=await He(e),t.responseTainting===`cors`&&w(t,r)===`failure`)return n(`cors failure`);h(t,r)===`failure`&&(t.timingAllowFailed=!0)}return(t.responseTainting===`opaque`||r.type===`opaque`)&&T(t.origin,t.client,t.destination,i)===`blocked`?n(`blocked`):(se.has(i.status)&&(t.redirect!==`manual`&&e.controller.connection.destroy(void 0,!1),t.redirect===`error`?r=n(`unexpected redirect`):t.redirect===`manual`?r=i:t.redirect===`follow`?r=await Ve(e,r):ie(!1)),r.timingInfo=a,r)}function Ve(e,t){let r=e.request,i=t.internalResponse?t.internalResponse:t,a;try{if(a=v(i,y(r).hash),a==null)return t}catch(e){return Promise.resolve(n(e))}if(!R(a))return Promise.resolve(n(`URL scheme must be a HTTP(S) scheme`));if(r.redirectCount===20)return Promise.resolve(n(`redirect count exceeded`));if(r.redirectCount+=1,r.mode===`cors`&&(a.username||a.password)&&!A(r,a))return Promise.resolve(n(`cross origin not allowed for request mode "cors"`));if(r.responseTainting===`cors`&&(a.username||a.password))return Promise.resolve(n(`URL cannot contain credentials for request mode "cors"`));if(i.status!==303&&r.body!=null&&r.body.source==null)return Promise.resolve(n());if([301,302].includes(i.status)&&r.method===`POST`||i.status===303&&!Te.includes(r.method)){r.method=`GET`,r.body=null;for(let e of ue)r.headersList.delete(e)}A(y(r),a)||(r.headersList.delete(`authorization`,!0),r.headersList.delete(`proxy-authorization`,!0),r.headersList.delete(`cookie`,!0),r.headersList.delete(`host`,!0)),r.body!=null&&(ie(r.body.source!=null),r.body=ae(r.body.source)[0]);let o=e.timingInfo;return o.redirectEndTime=o.postRedirectStartTime=D(e.crossOriginIsolatedCapability),o.redirectStartTime===0&&(o.redirectStartTime=o.startTime),r.urlList.push(a),b(r,i),Ie(e,!0)}async function He(e,t=!1,i=!1){let a=e.request,o=null,s=null,c=null;a.window===`no-window`&&a.redirect===`error`?(o=e,s=a):(s=l(a),o={...e},o.request=s);let u=a.credentials===`include`||a.credentials===`same-origin`&&a.responseTainting===`basic`,d=s.body?s.body.length:null,f=null;if(s.body==null&&[`POST`,`PUT`].includes(s.method)&&(f=`0`),d!=null&&(f=I(`${d}`)),f!=null&&s.headersList.append(`content-length`,f,!0),d!=null&&s.keepalive,s.referrer instanceof URL&&s.headersList.append(`referer`,I(s.referrer.href),!0),g(s),C(s),s.headersList.contains(`user-agent`,!0)||s.headersList.append(`user-agent`,Ee),s.cache===`default`&&(s.headersList.contains(`if-modified-since`,!0)||s.headersList.contains(`if-none-match`,!0)||s.headersList.contains(`if-unmodified-since`,!0)||s.headersList.contains(`if-match`,!0)||s.headersList.contains(`if-range`,!0))&&(s.cache=`no-store`),s.cache===`no-cache`&&!s.preventNoCacheCacheControlHeaderModification&&!s.headersList.contains(`cache-control`,!0)&&s.headersList.append(`cache-control`,`max-age=0`,!0),(s.cache===`no-store`||s.cache===`reload`)&&(s.headersList.contains(`pragma`,!0)||s.headersList.append(`pragma`,`no-cache`,!0),s.headersList.contains(`cache-control`,!0)||s.headersList.append(`cache-control`,`no-cache`,!0)),s.headersList.contains(`range`,!0)&&s.headersList.append(`accept-encoding`,`identity`,!0),s.headersList.contains(`accept-encoding`,!0)||(z(y(s))?s.headersList.append(`accept-encoding`,`br, gzip, deflate`,!0):s.headersList.append(`accept-encoding`,`gzip, deflate`,!0)),s.headersList.delete(`host`,!0),s.cache=`no-store`,s.cache!==`no-store`&&s.cache,c==null){if(s.cache===`only-if-cached`)return n(`only if cached`);let e=await We(o,u,i);!le.has(s.method)&&e.status>=200&&e.status,c??=e}if(c.urlList=[...s.urlList],s.headersList.contains(`range`,!0)&&(c.rangeRequested=!0),c.requestIncludesCredentials=u,c.status===407)return a.window===`no-window`?n():j(e)?r(e):n(`proxy authentication required`);if(c.status===421&&!i&&(a.body==null||a.body.source!=null)){if(j(e))return r(e);e.controller.connection.destroy(),c=await He(e,t,!0)}return c}async function We(e,t=!1,i=!1){ie(!e.controller.connection||e.controller.connection.destroyed),e.controller.connection={abort:null,destroyed:!1,destroy(e,t=!0){this.destroyed||(this.destroyed=!0,t&&this.abort?.(e??new DOMException(`The operation was aborted.`,`AbortError`)))}};let o=e.request,c=null,l=e.timingInfo;o.cache=`no-store`,o.mode;let d=null;if(o.body==null&&e.processRequestEndOfBody)queueMicrotask(()=>e.processRequestEndOfBody());else if(o.body!=null){let t=async function*(t){j(e)||(yield t,e.processRequestBodyChunkLength?.(t.byteLength))},n=()=>{j(e)||e.processRequestEndOfBody&&e.processRequestEndOfBody()},r=t=>{j(e)||(t.name===`AbortError`?e.controller.abort():e.controller.terminate(t))};d=(async function*(){try{for await(let e of o.body.stream)yield*t(e);n()}catch(e){r(e)}})()}try{let{body:t,status:n,statusText:r,headersList:i,socket:o}=await g({body:d});if(o)c=a({status:n,statusText:r,headersList:i,socket:o});else{let o=t[Symbol.asyncIterator]();e.controller.next=()=>o.next(),c=a({status:n,statusText:r,headersList:i})}}catch(t){return t.name===`AbortError`?(e.controller.connection.destroy(),r(e,t)):n(t)}let f=async()=>{await e.controller.resume()},p=t=>{j(e)||e.controller.abort(t)},m=new ReadableStream({async start(t){e.controller.controller=t},async pull(e){await f(e)},async cancel(e){await p(e)},type:`bytes`});c.body={stream:m,source:null,length:null},e.controller.onAborted=h,e.controller.on(`terminated`,h),e.controller.resume=async()=>{for(;;){let t,n;try{let{done:n,value:r}=await e.controller.next();if(M(e))break;t=n?void 0:r}catch(r){e.controller.ended&&!l.encodedBodySize?t=void 0:(t=r,n=!0)}if(t===void 0){F(e.controller.controller),Re(e,c);return}if(l.decodedBodySize+=t?.byteLength??0,n){e.controller.terminate(t);return}let r=new Uint8Array(t);if(r.byteLength&&e.controller.controller.enqueue(r),ge(m)){e.controller.terminate();return}if(e.controller.controller.desiredSize<=0)return}};function h(t){M(e)?(c.aborted=!0,_e(m)&&e.controller.controller.error(e.controller.serializedAbortReason)):_e(m)&&e.controller.controller.error(TypeError(`terminated`,{cause:N(t)?t:void 0})),e.controller.connection.destroy()}return c;function g({body:t}){let n=y(o),r=e.controller.dispatcher;return new Promise((i,a)=>r.dispatch({path:n.pathname+n.search,origin:n.origin,method:o.method,body:r.isMockActive?o.body&&(o.body.source||o.body.stream):t,headers:o.headersList.entries,maxRedirections:0,upgrade:o.mode===`websocket`?`websocket`:void 0},{body:null,abort:null,onConnect(t){let{connection:n}=e.controller;l.finalConnectionTimingInfo=ee(void 0,l.postRedirectStartTime,e.crossOriginIsolatedCapability),n.destroyed?t(new DOMException(`The operation was aborted.`,`AbortError`)):(e.controller.on(`terminated`,t),this.abort=n.abort=t),l.finalNetworkRequestStartTime=D(e.crossOriginIsolatedCapability)},onResponseStarted(){l.finalNetworkResponseStartTime=D(e.crossOriginIsolatedCapability)},onHeaders(e,t,n,r){if(e<200)return;let c=``,l=new s;for(let e=0;e5)return a(Error(`too many content-encodings in response: ${t.length}, maximum allowed is 5`)),!0;for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n===`x-gzip`||n===`gzip`)d.push(u.createGunzip({flush:u.constants.Z_SYNC_FLUSH,finishFlush:u.constants.Z_SYNC_FLUSH}));else if(n===`deflate`)d.push(V({flush:u.constants.Z_SYNC_FLUSH,finishFlush:u.constants.Z_SYNC_FLUSH}));else if(n===`br`)d.push(u.createBrotliDecompress({flush:u.constants.BROTLI_OPERATION_FLUSH,finishFlush:u.constants.BROTLI_OPERATION_FLUSH}));else{d.length=0;break}}}let p=this.onError.bind(this);return i({status:e,statusText:r,headersList:l,body:d.length?pe(this.body,...d,e=>{e&&this.onError(e)}).on(`error`,p):this.body.on(`error`,p)}),!0},onData(t){if(e.controller.dump)return;let n=t;return l.encodedBodySize+=n.byteLength,this.body.push(n)},onComplete(){this.abort&&e.controller.off(`terminated`,this.abort),e.controller.onAborted&&e.controller.off(`terminated`,e.controller.onAborted),e.controller.ended=!0,this.body.push(null)},onError(t){this.abort&&e.controller.off(`terminated`,this.abort),this.body?.destroy(t),e.controller.terminate(t),a(t)},onUpgrade(e,t,n){if(e!==101)return;let r=new s;for(let e=0;e{t.exports={kState:Symbol(`FileReader state`),kResult:Symbol(`FileReader result`),kError:Symbol(`FileReader error`),kLastProgressEventFired:Symbol(`FileReader last progress event fired timestamp`),kEvents:Symbol(`FileReader events`),kAborted:Symbol(`FileReader aborted`)}})),Wt=U(((e,t)=>{let{webidl:n}=Ke(),r=Symbol(`ProgressEvent state`);var i=class e extends Event{constructor(e,t={}){e=n.converters.DOMString(e,`ProgressEvent constructor`,`type`),t=n.converters.ProgressEventInit(t??{}),super(e,t),this[r]={lengthComputable:t.lengthComputable,loaded:t.loaded,total:t.total}}get lengthComputable(){return n.brandCheck(this,e),this[r].lengthComputable}get loaded(){return n.brandCheck(this,e),this[r].loaded}get total(){return n.brandCheck(this,e),this[r].total}};n.converters.ProgressEventInit=n.dictionaryConverter([{key:`lengthComputable`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`loaded`,converter:n.converters[`unsigned long long`],defaultValue:()=>0},{key:`total`,converter:n.converters[`unsigned long long`],defaultValue:()=>0},{key:`bubbles`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`cancelable`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`composed`,converter:n.converters.boolean,defaultValue:()=>!1}]),t.exports={ProgressEvent:i}})),Gt=U(((e,t)=>{function n(e){if(!e)return`failure`;switch(e.trim().toLowerCase()){case`unicode-1-1-utf-8`:case`unicode11utf8`:case`unicode20utf8`:case`utf-8`:case`utf8`:case`x-unicode20utf8`:return`UTF-8`;case`866`:case`cp866`:case`csibm866`:case`ibm866`:return`IBM866`;case`csisolatin2`:case`iso-8859-2`:case`iso-ir-101`:case`iso8859-2`:case`iso88592`:case`iso_8859-2`:case`iso_8859-2:1987`:case`l2`:case`latin2`:return`ISO-8859-2`;case`csisolatin3`:case`iso-8859-3`:case`iso-ir-109`:case`iso8859-3`:case`iso88593`:case`iso_8859-3`:case`iso_8859-3:1988`:case`l3`:case`latin3`:return`ISO-8859-3`;case`csisolatin4`:case`iso-8859-4`:case`iso-ir-110`:case`iso8859-4`:case`iso88594`:case`iso_8859-4`:case`iso_8859-4:1988`:case`l4`:case`latin4`:return`ISO-8859-4`;case`csisolatincyrillic`:case`cyrillic`:case`iso-8859-5`:case`iso-ir-144`:case`iso8859-5`:case`iso88595`:case`iso_8859-5`:case`iso_8859-5:1988`:return`ISO-8859-5`;case`arabic`:case`asmo-708`:case`csiso88596e`:case`csiso88596i`:case`csisolatinarabic`:case`ecma-114`:case`iso-8859-6`:case`iso-8859-6-e`:case`iso-8859-6-i`:case`iso-ir-127`:case`iso8859-6`:case`iso88596`:case`iso_8859-6`:case`iso_8859-6:1987`:return`ISO-8859-6`;case`csisolatingreek`:case`ecma-118`:case`elot_928`:case`greek`:case`greek8`:case`iso-8859-7`:case`iso-ir-126`:case`iso8859-7`:case`iso88597`:case`iso_8859-7`:case`iso_8859-7:1987`:case`sun_eu_greek`:return`ISO-8859-7`;case`csiso88598e`:case`csisolatinhebrew`:case`hebrew`:case`iso-8859-8`:case`iso-8859-8-e`:case`iso-ir-138`:case`iso8859-8`:case`iso88598`:case`iso_8859-8`:case`iso_8859-8:1988`:case`visual`:return`ISO-8859-8`;case`csiso88598i`:case`iso-8859-8-i`:case`logical`:return`ISO-8859-8-I`;case`csisolatin6`:case`iso-8859-10`:case`iso-ir-157`:case`iso8859-10`:case`iso885910`:case`l6`:case`latin6`:return`ISO-8859-10`;case`iso-8859-13`:case`iso8859-13`:case`iso885913`:return`ISO-8859-13`;case`iso-8859-14`:case`iso8859-14`:case`iso885914`:return`ISO-8859-14`;case`csisolatin9`:case`iso-8859-15`:case`iso8859-15`:case`iso885915`:case`iso_8859-15`:case`l9`:return`ISO-8859-15`;case`iso-8859-16`:return`ISO-8859-16`;case`cskoi8r`:case`koi`:case`koi8`:case`koi8-r`:case`koi8_r`:return`KOI8-R`;case`koi8-ru`:case`koi8-u`:return`KOI8-U`;case`csmacintosh`:case`mac`:case`macintosh`:case`x-mac-roman`:return`macintosh`;case`iso-8859-11`:case`iso8859-11`:case`iso885911`:case`tis-620`:case`windows-874`:return`windows-874`;case`cp1250`:case`windows-1250`:case`x-cp1250`:return`windows-1250`;case`cp1251`:case`windows-1251`:case`x-cp1251`:return`windows-1251`;case`ansi_x3.4-1968`:case`ascii`:case`cp1252`:case`cp819`:case`csisolatin1`:case`ibm819`:case`iso-8859-1`:case`iso-ir-100`:case`iso8859-1`:case`iso88591`:case`iso_8859-1`:case`iso_8859-1:1987`:case`l1`:case`latin1`:case`us-ascii`:case`windows-1252`:case`x-cp1252`:return`windows-1252`;case`cp1253`:case`windows-1253`:case`x-cp1253`:return`windows-1253`;case`cp1254`:case`csisolatin5`:case`iso-8859-9`:case`iso-ir-148`:case`iso8859-9`:case`iso88599`:case`iso_8859-9`:case`iso_8859-9:1989`:case`l5`:case`latin5`:case`windows-1254`:case`x-cp1254`:return`windows-1254`;case`cp1255`:case`windows-1255`:case`x-cp1255`:return`windows-1255`;case`cp1256`:case`windows-1256`:case`x-cp1256`:return`windows-1256`;case`cp1257`:case`windows-1257`:case`x-cp1257`:return`windows-1257`;case`cp1258`:case`windows-1258`:case`x-cp1258`:return`windows-1258`;case`x-mac-cyrillic`:case`x-mac-ukrainian`:return`x-mac-cyrillic`;case`chinese`:case`csgb2312`:case`csiso58gb231280`:case`gb2312`:case`gb_2312`:case`gb_2312-80`:case`gbk`:case`iso-ir-58`:case`x-gbk`:return`GBK`;case`gb18030`:return`gb18030`;case`big5`:case`big5-hkscs`:case`cn-big5`:case`csbig5`:case`x-x-big5`:return`Big5`;case`cseucpkdfmtjapanese`:case`euc-jp`:case`x-euc-jp`:return`EUC-JP`;case`csiso2022jp`:case`iso-2022-jp`:return`ISO-2022-JP`;case`csshiftjis`:case`ms932`:case`ms_kanji`:case`shift-jis`:case`shift_jis`:case`sjis`:case`windows-31j`:case`x-sjis`:return`Shift_JIS`;case`cseuckr`:case`csksc56011987`:case`euc-kr`:case`iso-ir-149`:case`korean`:case`ks_c_5601-1987`:case`ks_c_5601-1989`:case`ksc5601`:case`ksc_5601`:case`windows-949`:return`EUC-KR`;case`csiso2022kr`:case`hz-gb-2312`:case`iso-2022-cn`:case`iso-2022-cn-ext`:case`iso-2022-kr`:case`replacement`:return`replacement`;case`unicodefffe`:case`utf-16be`:return`UTF-16BE`;case`csunicode`:case`iso-10646-ucs-2`:case`ucs-2`:case`unicode`:case`unicodefeff`:case`utf-16`:case`utf-16le`:return`UTF-16LE`;case`x-user-defined`:return`x-user-defined`;default:return`failure`}}t.exports={getEncoding:n}})),Kt=U(((e,t)=>{let{kState:n,kError:r,kResult:i,kAborted:a,kLastProgressEventFired:o}=Ut(),{ProgressEvent:s}=Wt(),{getEncoding:c}=Gt(),{serializeAMimeType:l,parseMIMEType:u}=Ge(),{types:d}=W(`node:util`),{StringDecoder:f}=W(`string_decoder`),{btoa:p}=W(`node:buffer`),m={enumerable:!0,writable:!1,configurable:!1};function h(e,t,s,c){if(e[n]===`loading`)throw new DOMException(`Invalid state`,`InvalidStateError`);e[n]=`loading`,e[i]=null,e[r]=null;let l=t.stream().getReader(),u=[],f=l.read(),p=!0;(async()=>{for(;!e[a];)try{let{done:m,value:h}=await f;if(p&&!e[a]&&queueMicrotask(()=>{g(`loadstart`,e)}),p=!1,!m&&d.isUint8Array(h))u.push(h),(e[o]===void 0||Date.now()-e[o]>=50)&&!e[a]&&(e[o]=Date.now(),queueMicrotask(()=>{g(`progress`,e)})),f=l.read();else if(m){queueMicrotask(()=>{e[n]=`done`;try{let n=v(u,s,t.type,c);if(e[a])return;e[i]=n,g(`load`,e)}catch(t){e[r]=t,g(`error`,e)}e[n]!==`loading`&&g(`loadend`,e)});break}}catch(t){if(e[a])return;queueMicrotask(()=>{e[n]=`done`,e[r]=t,g(`error`,e),e[n]!==`loading`&&g(`loadend`,e)});break}})()}function g(e,t){let n=new s(e,{bubbles:!1,cancelable:!1});t.dispatchEvent(n)}function v(e,t,n,r){switch(t){case`DataURL`:{let t=`data:`,r=u(n||`application/octet-stream`);r!==`failure`&&(t+=l(r)),t+=`;base64,`;let i=new f(`latin1`);for(let n of e)t+=p(i.write(n));return t+=p(i.end()),t}case`Text`:{let t=`failure`;if(r&&(t=c(r)),t===`failure`&&n){let e=u(n);e!==`failure`&&(t=c(e.parameters.get(`charset`)))}return t===`failure`&&(t=`UTF-8`),y(e,t)}case`ArrayBuffer`:return x(e).buffer;case`BinaryString`:{let t=``,n=new f(`latin1`);for(let r of e)t+=n.write(r);return t+=n.end(),t}}}function y(e,t){let n=x(e),r=b(n),i=0;r!==null&&(t=r,i=r===`UTF-8`?3:2);let a=n.slice(i);return new TextDecoder(t).decode(a)}function b(e){let[t,n,r]=e;return t===239&&n===187&&r===191?`UTF-8`:t===254&&n===255?`UTF-16BE`:t===255&&n===254?`UTF-16LE`:null}function x(e){let t=e.reduce((e,t)=>e+t.byteLength,0),n=0;return e.reduce((e,t)=>(e.set(t,n),n+=t.byteLength,e),new Uint8Array(t))}t.exports={staticPropertyDescriptors:m,readOperation:h,fireAProgressEvent:g}})),qt=U(((e,t)=>{let{staticPropertyDescriptors:n,readOperation:r,fireAProgressEvent:i}=Kt(),{kState:a,kError:o,kResult:s,kEvents:c,kAborted:l}=Ut(),{webidl:u}=Ke(),{kEnumerableProperty:d}=Me();var f=class e extends EventTarget{constructor(){super(),this[a]=`empty`,this[s]=null,this[o]=null,this[c]={loadend:null,error:null,abort:null,load:null,progress:null,loadstart:null}}readAsArrayBuffer(t){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsArrayBuffer`),t=u.converters.Blob(t,{strict:!1}),r(this,t,`ArrayBuffer`)}readAsBinaryString(t){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsBinaryString`),t=u.converters.Blob(t,{strict:!1}),r(this,t,`BinaryString`)}readAsText(t,n=void 0){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsText`),t=u.converters.Blob(t,{strict:!1}),n!==void 0&&(n=u.converters.DOMString(n,`FileReader.readAsText`,`encoding`)),r(this,t,`Text`,n)}readAsDataURL(t){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsDataURL`),t=u.converters.Blob(t,{strict:!1}),r(this,t,`DataURL`)}abort(){if(this[a]===`empty`||this[a]===`done`){this[s]=null;return}this[a]===`loading`&&(this[a]=`done`,this[s]=null),this[l]=!0,i(`abort`,this),this[a]!==`loading`&&i(`loadend`,this)}get readyState(){switch(u.brandCheck(this,e),this[a]){case`empty`:return this.EMPTY;case`loading`:return this.LOADING;case`done`:return this.DONE}}get result(){return u.brandCheck(this,e),this[s]}get error(){return u.brandCheck(this,e),this[o]}get onloadend(){return u.brandCheck(this,e),this[c].loadend}set onloadend(t){u.brandCheck(this,e),this[c].loadend&&this.removeEventListener(`loadend`,this[c].loadend),typeof t==`function`?(this[c].loadend=t,this.addEventListener(`loadend`,t)):this[c].loadend=null}get onerror(){return u.brandCheck(this,e),this[c].error}set onerror(t){u.brandCheck(this,e),this[c].error&&this.removeEventListener(`error`,this[c].error),typeof t==`function`?(this[c].error=t,this.addEventListener(`error`,t)):this[c].error=null}get onloadstart(){return u.brandCheck(this,e),this[c].loadstart}set onloadstart(t){u.brandCheck(this,e),this[c].loadstart&&this.removeEventListener(`loadstart`,this[c].loadstart),typeof t==`function`?(this[c].loadstart=t,this.addEventListener(`loadstart`,t)):this[c].loadstart=null}get onprogress(){return u.brandCheck(this,e),this[c].progress}set onprogress(t){u.brandCheck(this,e),this[c].progress&&this.removeEventListener(`progress`,this[c].progress),typeof t==`function`?(this[c].progress=t,this.addEventListener(`progress`,t)):this[c].progress=null}get onload(){return u.brandCheck(this,e),this[c].load}set onload(t){u.brandCheck(this,e),this[c].load&&this.removeEventListener(`load`,this[c].load),typeof t==`function`?(this[c].load=t,this.addEventListener(`load`,t)):this[c].load=null}get onabort(){return u.brandCheck(this,e),this[c].abort}set onabort(t){u.brandCheck(this,e),this[c].abort&&this.removeEventListener(`abort`,this[c].abort),typeof t==`function`?(this[c].abort=t,this.addEventListener(`abort`,t)):this[c].abort=null}};f.EMPTY=f.prototype.EMPTY=0,f.LOADING=f.prototype.LOADING=1,f.DONE=f.prototype.DONE=2,Object.defineProperties(f.prototype,{EMPTY:n,LOADING:n,DONE:n,readAsArrayBuffer:d,readAsBinaryString:d,readAsText:d,readAsDataURL:d,abort:d,readyState:d,result:d,error:d,onloadstart:d,onprogress:d,onload:d,onabort:d,onerror:d,onloadend:d,[Symbol.toStringTag]:{value:`FileReader`,writable:!1,enumerable:!1,configurable:!0}}),Object.defineProperties(f,{EMPTY:n,LOADING:n,DONE:n}),t.exports={FileReader:f}})),Jt=U(((e,t)=>{t.exports={kConstruct:Oe().kConstruct}})),Yt=U(((e,t)=>{let n=W(`node:assert`),{URLSerializer:r}=Ge(),{isValidHeaderName:i}=qe();function a(e,t,n=!1){return r(e,n)===r(t,n)}function o(e){n(e!==null);let t=[];for(let n of e.split(`,`))n=n.trim(),i(n)&&t.push(n);return t}t.exports={urlEquals:a,getFieldValues:o}})),Xt=U(((e,t)=>{let{kConstruct:n}=Jt(),{urlEquals:r,getFieldValues:i}=Yt(),{kEnumerableProperty:a,isDisturbed:o}=Me(),{webidl:s}=Ke(),{Response:c,cloneResponse:l,fromInnerResponse:u}=zt(),{Request:d,fromInnerRequest:f}=Vt(),{kState:p}=Je(),{fetching:m}=Ht(),{urlIsHttpHttpsScheme:h,createDeferredPromise:g,readAllBytes:v}=qe(),y=W(`node:assert`);var b=class e{#e;constructor(){arguments[0]!==n&&s.illegalConstructor(),s.util.markAsUncloneable(this),this.#e=arguments[1]}async match(t,n={}){s.brandCheck(this,e);let r=`Cache.match`;s.argumentLengthCheck(arguments,1,r),t=s.converters.RequestInfo(t,r,`request`),n=s.converters.CacheQueryOptions(n,r,`options`);let i=this.#i(t,n,1);if(i.length!==0)return i[0]}async matchAll(t=void 0,n={}){s.brandCheck(this,e);let r=`Cache.matchAll`;return t!==void 0&&(t=s.converters.RequestInfo(t,r,`request`)),n=s.converters.CacheQueryOptions(n,r,`options`),this.#i(t,n)}async add(t){s.brandCheck(this,e);let n=`Cache.add`;s.argumentLengthCheck(arguments,1,n),t=s.converters.RequestInfo(t,n,`request`);let r=[t];return await this.addAll(r)}async addAll(t){s.brandCheck(this,e);let n=`Cache.addAll`;s.argumentLengthCheck(arguments,1,n);let r=[],a=[];for(let e of t){if(e===void 0)throw s.errors.conversionFailed({prefix:n,argument:`Argument 1`,types:[`undefined is not allowed`]});if(e=s.converters.RequestInfo(e),typeof e==`string`)continue;let t=e[p];if(!h(t.url)||t.method!==`GET`)throw s.errors.exception({header:n,message:`Expected http/s scheme when method is not GET.`})}let o=[];for(let e of t){let t=new d(e)[p];if(!h(t.url))throw s.errors.exception({header:n,message:`Expected http/s scheme.`});t.initiator=`fetch`,t.destination=`subresource`,a.push(t);let c=g();o.push(m({request:t,processResponse(e){if(e.type===`error`||e.status===206||e.status<200||e.status>299)c.reject(s.errors.exception({header:`Cache.addAll`,message:`Received an invalid status code or the request failed.`}));else if(e.headersList.contains(`vary`)){let t=i(e.headersList.get(`vary`));for(let e of t)if(e===`*`){c.reject(s.errors.exception({header:`Cache.addAll`,message:`invalid vary field value`}));for(let e of o)e.abort();return}}},processResponseEndOfBody(e){if(e.aborted){c.reject(new DOMException(`aborted`,`AbortError`));return}c.resolve(e)}})),r.push(c.promise)}let c=await Promise.all(r),l=[],u=0;for(let e of c){let t={type:`put`,request:a[u],response:e};l.push(t),u++}let f=g(),v=null;try{this.#t(l)}catch(e){v=e}return queueMicrotask(()=>{v===null?f.resolve(void 0):f.reject(v)}),f.promise}async put(t,n){s.brandCheck(this,e);let r=`Cache.put`;s.argumentLengthCheck(arguments,2,r),t=s.converters.RequestInfo(t,r,`request`),n=s.converters.Response(n,r,`response`);let a=null;if(a=t instanceof d?t[p]:new d(t)[p],!h(a.url)||a.method!==`GET`)throw s.errors.exception({header:r,message:`Expected an http/s scheme when method is not GET`});let c=n[p];if(c.status===206)throw s.errors.exception({header:r,message:`Got 206 status`});if(c.headersList.contains(`vary`)){let e=i(c.headersList.get(`vary`));for(let t of e)if(t===`*`)throw s.errors.exception({header:r,message:`Got * vary field value`})}if(c.body&&(o(c.body.stream)||c.body.stream.locked))throw s.errors.exception({header:r,message:`Response body is locked or disturbed`});let u=l(c),f=g();c.body==null?f.resolve(void 0):v(c.body.stream.getReader()).then(f.resolve,f.reject);let m=[],y={type:`put`,request:a,response:u};m.push(y);let b=await f.promise;u.body!=null&&(u.body.source=b);let x=g(),S=null;try{this.#t(m)}catch(e){S=e}return queueMicrotask(()=>{S===null?x.resolve():x.reject(S)}),x.promise}async delete(t,n={}){s.brandCheck(this,e);let r=`Cache.delete`;s.argumentLengthCheck(arguments,1,r),t=s.converters.RequestInfo(t,r,`request`),n=s.converters.CacheQueryOptions(n,r,`options`);let i=null;if(t instanceof d){if(i=t[p],i.method!==`GET`&&!n.ignoreMethod)return!1}else y(typeof t==`string`),i=new d(t)[p];let a=[],o={type:`delete`,request:i,options:n};a.push(o);let c=g(),l=null,u;try{u=this.#t(a)}catch(e){l=e}return queueMicrotask(()=>{l===null?c.resolve(!!u?.length):c.reject(l)}),c.promise}async keys(t=void 0,n={}){s.brandCheck(this,e);let r=`Cache.keys`;t!==void 0&&(t=s.converters.RequestInfo(t,r,`request`)),n=s.converters.CacheQueryOptions(n,r,`options`);let i=null;if(t!==void 0)if(t instanceof d){if(i=t[p],i.method!==`GET`&&!n.ignoreMethod)return[]}else typeof t==`string`&&(i=new d(t)[p]);let a=g(),o=[];if(t===void 0)for(let e of this.#e)o.push(e[0]);else{let e=this.#n(i,n);for(let t of e)o.push(t[0])}return queueMicrotask(()=>{let e=[];for(let t of o){let n=f(t,new AbortController().signal,`immutable`);e.push(n)}a.resolve(Object.freeze(e))}),a.promise}#t(e){let t=this.#e,n=[...t],r=[],i=[];try{for(let n of e){if(n.type!==`delete`&&n.type!==`put`)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`operation type does not match "delete" or "put"`});if(n.type===`delete`&&n.response!=null)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`delete operation should not have an associated response`});if(this.#n(n.request,n.options,r).length)throw new DOMException(`???`,`InvalidStateError`);let e;if(n.type===`delete`){if(e=this.#n(n.request,n.options),e.length===0)return[];for(let n of e){let e=t.indexOf(n);y(e!==-1),t.splice(e,1)}}else if(n.type===`put`){if(n.response==null)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`put operation should have an associated response`});let i=n.request;if(!h(i.url))throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`expected http or https scheme`});if(i.method!==`GET`)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`not get method`});if(n.options!=null)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`options must not be defined`});e=this.#n(n.request);for(let n of e){let e=t.indexOf(n);y(e!==-1),t.splice(e,1)}t.push([n.request,n.response]),r.push([n.request,n.response])}i.push([n.request,n.response])}return i}catch(e){throw this.#e.length=0,this.#e=n,e}}#n(e,t,n){let r=[],i=n??this.#e;for(let n of i){let[i,a]=n;this.#r(e,i,a,t)&&r.push(n)}return r}#r(e,t,n=null,a){let o=new URL(e.url),s=new URL(t.url);if(a?.ignoreSearch&&(s.search=``,o.search=``),!r(o,s,!0))return!1;if(n==null||a?.ignoreVary||!n.headersList.contains(`vary`))return!0;let c=i(n.headersList.get(`vary`));for(let n of c)if(n===`*`||t.headersList.get(n)!==e.headersList.get(n))return!1;return!0}#i(e,t,n=1/0){let r=null;if(e!==void 0)if(e instanceof d){if(r=e[p],r.method!==`GET`&&!t.ignoreMethod)return[]}else typeof e==`string`&&(r=new d(e)[p]);let i=[];if(e===void 0)for(let e of this.#e)i.push(e[1]);else{let e=this.#n(r,t);for(let t of e)i.push(t[1])}let a=[];for(let e of i){let t=u(e,`immutable`);if(a.push(t.clone()),a.length>=n)break}return Object.freeze(a)}};Object.defineProperties(b.prototype,{[Symbol.toStringTag]:{value:`Cache`,configurable:!0},match:a,matchAll:a,add:a,addAll:a,put:a,delete:a,keys:a});let x=[{key:`ignoreSearch`,converter:s.converters.boolean,defaultValue:()=>!1},{key:`ignoreMethod`,converter:s.converters.boolean,defaultValue:()=>!1},{key:`ignoreVary`,converter:s.converters.boolean,defaultValue:()=>!1}];s.converters.CacheQueryOptions=s.dictionaryConverter(x),s.converters.MultiCacheQueryOptions=s.dictionaryConverter([...x,{key:`cacheName`,converter:s.converters.DOMString}]),s.converters.Response=s.interfaceConverter(c),s.converters[`sequence`]=s.sequenceConverter(s.converters.RequestInfo),t.exports={Cache:b}})),Zt=U(((e,t)=>{let{kConstruct:n}=Jt(),{Cache:r}=Xt(),{webidl:i}=Ke(),{kEnumerableProperty:a}=Me();var o=class e{#e=new Map;constructor(){arguments[0]!==n&&i.illegalConstructor(),i.util.markAsUncloneable(this)}async match(t,a={}){if(i.brandCheck(this,e),i.argumentLengthCheck(arguments,1,`CacheStorage.match`),t=i.converters.RequestInfo(t),a=i.converters.MultiCacheQueryOptions(a),a.cacheName!=null){if(this.#e.has(a.cacheName))return await new r(n,this.#e.get(a.cacheName)).match(t,a)}else for(let e of this.#e.values()){let i=await new r(n,e).match(t,a);if(i!==void 0)return i}}async has(t){i.brandCheck(this,e);let n=`CacheStorage.has`;return i.argumentLengthCheck(arguments,1,n),t=i.converters.DOMString(t,n,`cacheName`),this.#e.has(t)}async open(t){i.brandCheck(this,e);let a=`CacheStorage.open`;if(i.argumentLengthCheck(arguments,1,a),t=i.converters.DOMString(t,a,`cacheName`),this.#e.has(t))return new r(n,this.#e.get(t));let o=[];return this.#e.set(t,o),new r(n,o)}async delete(t){i.brandCheck(this,e);let n=`CacheStorage.delete`;return i.argumentLengthCheck(arguments,1,n),t=i.converters.DOMString(t,n,`cacheName`),this.#e.delete(t)}async keys(){return i.brandCheck(this,e),[...this.#e.keys()]}};Object.defineProperties(o.prototype,{[Symbol.toStringTag]:{value:`CacheStorage`,configurable:!0},match:a,has:a,open:a,delete:a,keys:a}),t.exports={CacheStorage:o}})),Qt=U(((e,t)=>{t.exports={maxAttributeValueSize:1024,maxNameValuePairSize:4096}})),$t=U(((e,t)=>{function n(e){for(let t=0;t=0&&n<=8||n>=10&&n<=31||n===127)return!0}return!1}function r(e){for(let t=0;t126||n===34||n===40||n===41||n===60||n===62||n===64||n===44||n===59||n===58||n===92||n===47||n===91||n===93||n===63||n===61||n===123||n===125)throw Error(`Invalid cookie name`)}}function i(e){let t=e.length,n=0;if(e[0]===`"`){if(t===1||e[t-1]!==`"`)throw Error(`Invalid cookie value`);--t,++n}for(;n126||t===34||t===44||t===59||t===92)throw Error(`Invalid cookie value`)}}function a(e){for(let t=0;tt.toString().padStart(2,`0`));function u(e){return typeof e==`number`&&(e=new Date(e)),`${s[e.getUTCDay()]}, ${l[e.getUTCDate()]} ${c[e.getUTCMonth()]} ${e.getUTCFullYear()} ${l[e.getUTCHours()]}:${l[e.getUTCMinutes()]}:${l[e.getUTCSeconds()]} GMT`}function d(e){if(e<0)throw Error(`Invalid cookie max-age`)}function f(e){if(e.name.length===0)return null;r(e.name),i(e.value);let t=[`${e.name}=${e.value}`];e.name.startsWith(`__Secure-`)&&(e.secure=!0),e.name.startsWith(`__Host-`)&&(e.secure=!0,e.domain=null,e.path=`/`),e.secure&&t.push(`Secure`),e.httpOnly&&t.push(`HttpOnly`),typeof e.maxAge==`number`&&(d(e.maxAge),t.push(`Max-Age=${e.maxAge}`)),e.domain&&(o(e.domain),t.push(`Domain=${e.domain}`)),e.path&&(a(e.path),t.push(`Path=${e.path}`)),e.expires&&e.expires.toString()!==`Invalid Date`&&t.push(`Expires=${u(e.expires)}`),e.sameSite&&t.push(`SameSite=${e.sameSite}`);for(let n of e.unparsed){if(!n.includes(`=`))throw Error(`Invalid unparsed`);let[e,...r]=n.split(`=`);t.push(`${e.trim()}=${r.join(`=`)}`)}return t.join(`; `)}t.exports={isCTLExcludingHtab:n,validateCookieName:r,validateCookiePath:a,validateCookieValue:i,toIMFDate:u,stringify:f}})),en=U(((e,t)=>{let{maxNameValuePairSize:n,maxAttributeValueSize:r}=Qt(),{isCTLExcludingHtab:i}=$t(),{collectASequenceOfCodePointsFast:a}=Ge(),o=W(`node:assert`);function s(e){if(i(e))return null;let t=``,r=``,o=``,s=``;if(e.includes(`;`)){let n={position:0};t=a(`;`,e,n),r=e.slice(n.position)}else t=e;if(!t.includes(`=`))s=t;else{let e={position:0};o=a(`=`,t,e),s=t.slice(e.position+1)}return o=o.trim(),s=s.trim(),o.length+s.length>n?null:{name:o,value:s,...c(r)}}function c(e,t={}){if(e.length===0)return t;o(e[0]===`;`),e=e.slice(1);let n=``;e.includes(`;`)?(n=a(`;`,e,{position:0}),e=e.slice(n.length)):(n=e,e=``);let i=``,s=``;if(n.includes(`=`)){let e={position:0};i=a(`=`,n,e),s=n.slice(e.position+1)}else i=n;if(i=i.trim(),s=s.trim(),s.length>r)return c(e,t);let l=i.toLowerCase();if(l===`expires`)t.expires=new Date(s);else if(l===`max-age`){let n=s.charCodeAt(0);if((n<48||n>57)&&s[0]!==`-`||!/^\d+$/.test(s))return c(e,t);t.maxAge=Number(s)}else if(l===`domain`){let e=s;e[0]===`.`&&(e=e.slice(1)),e=e.toLowerCase(),t.domain=e}else if(l===`path`){let e=``;e=s.length===0||s[0]!==`/`?`/`:s,t.path=e}else if(l===`secure`)t.secure=!0;else if(l===`httponly`)t.httpOnly=!0;else if(l===`samesite`){let e=`Default`,n=s.toLowerCase();n.includes(`none`)&&(e=`None`),n.includes(`strict`)&&(e=`Strict`),n.includes(`lax`)&&(e=`Lax`),t.sameSite=e}else t.unparsed??=[],t.unparsed.push(`${i}=${s}`);return c(e,t)}t.exports={parseSetCookie:s,parseUnparsedAttributes:c}})),tn=U(((e,t)=>{let{parseSetCookie:n}=en(),{stringify:r}=$t(),{webidl:i}=Ke(),{Headers:a}=Rt();function o(e){i.argumentLengthCheck(arguments,1,`getCookies`),i.brandCheck(e,a,{strict:!1});let t=e.get(`cookie`),n={};if(!t)return n;for(let e of t.split(`;`)){let[t,...r]=e.split(`=`);n[t.trim()]=r.join(`=`)}return n}function s(e,t,n){i.brandCheck(e,a,{strict:!1});let r=`deleteCookie`;i.argumentLengthCheck(arguments,2,r),t=i.converters.DOMString(t,r,`name`),n=i.converters.DeleteCookieAttributes(n),l(e,{name:t,value:``,expires:new Date(0),...n})}function c(e){i.argumentLengthCheck(arguments,1,`getSetCookies`),i.brandCheck(e,a,{strict:!1});let t=e.getSetCookie();return t?t.map(e=>n(e)):[]}function l(e,t){i.argumentLengthCheck(arguments,2,`setCookie`),i.brandCheck(e,a,{strict:!1}),t=i.converters.Cookie(t);let n=r(t);n&&e.append(`Set-Cookie`,n)}i.converters.DeleteCookieAttributes=i.dictionaryConverter([{converter:i.nullableConverter(i.converters.DOMString),key:`path`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:`domain`,defaultValue:()=>null}]),i.converters.Cookie=i.dictionaryConverter([{converter:i.converters.DOMString,key:`name`},{converter:i.converters.DOMString,key:`value`},{converter:i.nullableConverter(e=>typeof e==`number`?i.converters[`unsigned long long`](e):new Date(e)),key:`expires`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters[`long long`]),key:`maxAge`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:`domain`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:`path`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.boolean),key:`secure`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.boolean),key:`httpOnly`,defaultValue:()=>null},{converter:i.converters.USVString,key:`sameSite`,allowedValues:[`Strict`,`Lax`,`None`]},{converter:i.sequenceConverter(i.converters.DOMString),key:`unparsed`,defaultValue:()=>[]}]),t.exports={getCookies:o,deleteCookie:s,getSetCookies:c,setCookie:l}})),nn=U(((e,t)=>{let{webidl:n}=Ke(),{kEnumerableProperty:r}=Me(),{kConstruct:i}=Oe(),{MessagePort:a}=W(`node:worker_threads`);var o=class e extends Event{#e;constructor(e,t={}){if(e===i){super(arguments[1],arguments[2]),n.util.markAsUncloneable(this);return}let r=`MessageEvent constructor`;n.argumentLengthCheck(arguments,1,r),e=n.converters.DOMString(e,r,`type`),t=n.converters.MessageEventInit(t,r,`eventInitDict`),super(e,t),this.#e=t,n.util.markAsUncloneable(this)}get data(){return n.brandCheck(this,e),this.#e.data}get origin(){return n.brandCheck(this,e),this.#e.origin}get lastEventId(){return n.brandCheck(this,e),this.#e.lastEventId}get source(){return n.brandCheck(this,e),this.#e.source}get ports(){return n.brandCheck(this,e),Object.isFrozen(this.#e.ports)||Object.freeze(this.#e.ports),this.#e.ports}initMessageEvent(t,r=!1,i=!1,a=null,o=``,s=``,c=null,l=[]){return n.brandCheck(this,e),n.argumentLengthCheck(arguments,1,`MessageEvent.initMessageEvent`),new e(t,{bubbles:r,cancelable:i,data:a,origin:o,lastEventId:s,source:c,ports:l})}static createFastMessageEvent(t,n){let r=new e(i,t,n);return r.#e=n,r.#e.data??=null,r.#e.origin??=``,r.#e.lastEventId??=``,r.#e.source??=null,r.#e.ports??=[],r}};let{createFastMessageEvent:s}=o;delete o.createFastMessageEvent;var c=class e extends Event{#e;constructor(e,t={}){let r=`CloseEvent constructor`;n.argumentLengthCheck(arguments,1,r),e=n.converters.DOMString(e,r,`type`),t=n.converters.CloseEventInit(t),super(e,t),this.#e=t,n.util.markAsUncloneable(this)}get wasClean(){return n.brandCheck(this,e),this.#e.wasClean}get code(){return n.brandCheck(this,e),this.#e.code}get reason(){return n.brandCheck(this,e),this.#e.reason}},l=class e extends Event{#e;constructor(e,t){let r=`ErrorEvent constructor`;n.argumentLengthCheck(arguments,1,r),super(e,t),n.util.markAsUncloneable(this),e=n.converters.DOMString(e,r,`type`),t=n.converters.ErrorEventInit(t??{}),this.#e=t}get message(){return n.brandCheck(this,e),this.#e.message}get filename(){return n.brandCheck(this,e),this.#e.filename}get lineno(){return n.brandCheck(this,e),this.#e.lineno}get colno(){return n.brandCheck(this,e),this.#e.colno}get error(){return n.brandCheck(this,e),this.#e.error}};Object.defineProperties(o.prototype,{[Symbol.toStringTag]:{value:`MessageEvent`,configurable:!0},data:r,origin:r,lastEventId:r,source:r,ports:r,initMessageEvent:r}),Object.defineProperties(c.prototype,{[Symbol.toStringTag]:{value:`CloseEvent`,configurable:!0},reason:r,code:r,wasClean:r}),Object.defineProperties(l.prototype,{[Symbol.toStringTag]:{value:`ErrorEvent`,configurable:!0},message:r,filename:r,lineno:r,colno:r,error:r}),n.converters.MessagePort=n.interfaceConverter(a),n.converters[`sequence`]=n.sequenceConverter(n.converters.MessagePort);let u=[{key:`bubbles`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`cancelable`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`composed`,converter:n.converters.boolean,defaultValue:()=>!1}];n.converters.MessageEventInit=n.dictionaryConverter([...u,{key:`data`,converter:n.converters.any,defaultValue:()=>null},{key:`origin`,converter:n.converters.USVString,defaultValue:()=>``},{key:`lastEventId`,converter:n.converters.DOMString,defaultValue:()=>``},{key:`source`,converter:n.nullableConverter(n.converters.MessagePort),defaultValue:()=>null},{key:`ports`,converter:n.converters[`sequence`],defaultValue:()=>[]}]),n.converters.CloseEventInit=n.dictionaryConverter([...u,{key:`wasClean`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`code`,converter:n.converters[`unsigned short`],defaultValue:()=>0},{key:`reason`,converter:n.converters.USVString,defaultValue:()=>``}]),n.converters.ErrorEventInit=n.dictionaryConverter([...u,{key:`message`,converter:n.converters.DOMString,defaultValue:()=>``},{key:`filename`,converter:n.converters.USVString,defaultValue:()=>``},{key:`lineno`,converter:n.converters[`unsigned long`],defaultValue:()=>0},{key:`colno`,converter:n.converters[`unsigned long`],defaultValue:()=>0},{key:`error`,converter:n.converters.any}]),t.exports={MessageEvent:o,CloseEvent:c,ErrorEvent:l,createFastMessageEvent:s}})),rn=U(((e,t)=>{t.exports={uid:`258EAFA5-E914-47DA-95CA-C5AB0DC85B11`,sentCloseFrameState:{NOT_SENT:0,PROCESSING:1,SENT:2},staticPropertyDescriptors:{enumerable:!0,writable:!1,configurable:!1},states:{CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3},opcodes:{CONTINUATION:0,TEXT:1,BINARY:2,CLOSE:8,PING:9,PONG:10},maxUnsigned16Bit:2**16-1,parserStates:{INFO:0,PAYLOADLENGTH_16:2,PAYLOADLENGTH_64:3,READ_DATA:4},emptyBuffer:Buffer.allocUnsafe(0),sendHints:{string:1,typedArray:2,arrayBuffer:3,blob:4}}})),an=U(((e,t)=>{t.exports={kWebSocketURL:Symbol(`url`),kReadyState:Symbol(`ready state`),kController:Symbol(`controller`),kResponse:Symbol(`response`),kBinaryType:Symbol(`binary type`),kSentClose:Symbol(`sent close`),kReceivedClose:Symbol(`received close`),kByteParser:Symbol(`byte parser`)}})),on=U(((e,t)=>{let{kReadyState:n,kController:r,kResponse:i,kBinaryType:a,kWebSocketURL:o}=an(),{states:s,opcodes:c}=rn(),{ErrorEvent:l,createFastMessageEvent:u}=nn(),{isUtf8:d}=W(`node:buffer`),{collectASequenceOfCodePointsFast:f,removeHTTPWhitespace:p}=Ge();function m(e){return e[n]===s.CONNECTING}function h(e){return e[n]===s.OPEN}function g(e){return e[n]===s.CLOSING}function v(e){return e[n]===s.CLOSED}function y(e,t,n=(e,t)=>new Event(e,t),r={}){let i=n(e,r);t.dispatchEvent(i)}function b(e,t,r){if(e[n]!==s.OPEN)return;let i;if(t===c.TEXT)try{i=N(r)}catch{w(e,`Received invalid UTF-8 in text frame.`);return}else t===c.BINARY&&(i=e[a]===`blob`?new Blob([r]):x(r));y(`message`,e,u,{origin:e[o].origin,data:i})}function x(e){return e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function S(e){if(e.length===0)return!1;for(let t=0;t126||n===34||n===40||n===41||n===44||n===47||n===58||n===59||n===60||n===61||n===62||n===63||n===64||n===91||n===92||n===93||n===123||n===125)return!1}return!0}function C(e){return e>=1e3&&e<1015?e!==1004&&e!==1005&&e!==1006:e>=3e3&&e<=4999}function w(e,t){let{[r]:n,[i]:a}=e;n.abort(),a?.socket&&!a.socket.destroyed&&a.socket.destroy(),t&&y(`error`,e,(e,t)=>new l(e,t),{error:Error(t),message:t})}function T(e){return e===c.CLOSE||e===c.PING||e===c.PONG}function E(e){return e===c.CONTINUATION}function D(e){return e===c.TEXT||e===c.BINARY}function O(e){return D(e)||E(e)||T(e)}function k(e){let t={position:0},n=new Map;for(;t.position57)return!1}let t=Number.parseInt(e,10);return t>=8&&t<=15}let j=typeof process.versions.icu==`string`,M=j?new TextDecoder(`utf-8`,{fatal:!0}):void 0,N=j?M.decode.bind(M):function(e){if(d(e))return e.toString(`utf-8`);throw TypeError(`Invalid utf-8 received.`)};t.exports={isConnecting:m,isEstablished:h,isClosing:g,isClosed:v,fireEvent:y,isValidSubprotocol:S,isValidStatusCode:C,failWebsocketConnection:w,websocketMessageReceived:b,utf8Decode:N,isControlFrame:T,isContinuationFrame:E,isTextBinaryFrame:D,isValidOpcode:O,parseExtensions:k,isValidClientWindowBits:A}})),sn=U(((e,t)=>{let{maxUnsigned16Bit:n}=rn(),r=16386,i,a=null,o=r;try{i=W(`node:crypto`)}catch{i={randomFillSync:function(e,t,n){for(let t=0;tn?(o+=8,a=127):i>125&&(o+=2,a=126);let c=Buffer.allocUnsafe(i+o);c[0]=c[1]=0,c[0]|=128,c[0]=(c[0]&240)+e,c[o-4]=r[0],c[o-3]=r[1],c[o-2]=r[2],c[o-1]=r[3],c[1]=a,a===126?c.writeUInt16BE(i,2):a===127&&(c[2]=c[3]=0,c.writeUIntBE(i,4,6)),c[1]|=128;for(let e=0;e{let{uid:n,states:r,sentCloseFrameState:i,emptyBuffer:a,opcodes:o}=rn(),{kReadyState:s,kSentClose:c,kByteParser:l,kReceivedClose:u,kResponse:d}=an(),{fireEvent:f,failWebsocketConnection:p,isClosing:m,isClosed:h,isEstablished:g,parseExtensions:v}=on(),{channels:y}=Ne(),{CloseEvent:b}=nn(),{makeRequest:x}=Vt(),{fetching:S}=Ht(),{Headers:C,getHeadersList:w}=Rt(),{getDecodeSplit:T}=qe(),{WebsocketFrameSend:E}=sn(),D;try{D=W(`node:crypto`)}catch{}function O(e,t,r,i,a,o){let s=e;s.protocol=e.protocol===`ws:`?`http:`:`https:`;let c=x({urlList:[s],client:r,serviceWorkers:`none`,referrer:`no-referrer`,mode:`websocket`,credentials:`include`,cache:`no-store`,redirect:`error`});o.headers&&(c.headersList=w(new C(o.headers)));let l=D.randomBytes(16).toString(`base64`);c.headersList.append(`sec-websocket-key`,l),c.headersList.append(`sec-websocket-version`,`13`);for(let e of t)c.headersList.append(`sec-websocket-protocol`,e);return c.headersList.append(`sec-websocket-extensions`,`permessage-deflate; client_max_window_bits`),S({request:c,useParallelQueue:!0,dispatcher:o.dispatcher,processResponse(e){if(e.type===`error`||e.status!==101){p(i,`Received network error or non-101 status code.`);return}if(t.length!==0&&!e.headersList.get(`Sec-WebSocket-Protocol`)){p(i,`Server did not respond with sent protocols.`);return}if(e.headersList.get(`Upgrade`)?.toLowerCase()!==`websocket`){p(i,`Server did not set Upgrade header to "websocket".`);return}if(e.headersList.get(`Connection`)?.toLowerCase()!==`upgrade`){p(i,`Server did not set Connection header to "upgrade".`);return}if(e.headersList.get(`Sec-WebSocket-Accept`)!==D.createHash(`sha1`).update(l+n).digest(`base64`)){p(i,`Incorrect hash received in Sec-WebSocket-Accept header.`);return}let r=e.headersList.get(`Sec-WebSocket-Extensions`),o;if(r!==null&&(o=v(r),!o.has(`permessage-deflate`))){p(i,`Sec-WebSocket-Extensions header does not match.`);return}let s=e.headersList.get(`Sec-WebSocket-Protocol`);if(s!==null&&!T(`sec-websocket-protocol`,c.headersList).includes(s)){p(i,`Protocol was not set in the opening handshake.`);return}e.socket.on(`data`,A),e.socket.on(`close`,j),e.socket.on(`error`,M),y.open.hasSubscribers&&y.open.publish({address:e.socket.address(),protocol:s,extensions:r}),a(e,o)}})}function k(e,t,n,l){if(!(m(e)||h(e)))if(!g(e))p(e,`Connection was closed before it was established.`),e[s]=r.CLOSING;else if(e[c]===i.NOT_SENT){e[c]=i.PROCESSING;let u=new E;t!==void 0&&n===void 0?(u.frameData=Buffer.allocUnsafe(2),u.frameData.writeUInt16BE(t,0)):t!==void 0&&n!==void 0?(u.frameData=Buffer.allocUnsafe(2+l),u.frameData.writeUInt16BE(t,0),u.frameData.write(n,2,`utf-8`)):u.frameData=a,e[d].socket.write(u.createFrame(o.CLOSE)),e[c]=i.SENT,e[s]=r.CLOSING}else e[s]=r.CLOSING}function A(e){this.ws[l].write(e)||this.pause()}function j(){let{ws:e}=this,{[d]:t}=e;t.socket.off(`data`,A),t.socket.off(`close`,j),t.socket.off(`error`,M);let n=e[c]===i.SENT&&e[u],a=1005,o=``,p=e[l].closingInfo;p&&!p.error?(a=p.code??1005,o=p.reason):e[u]||(a=1006),e[s]=r.CLOSED,f(`close`,e,(e,t)=>new b(e,t),{wasClean:n,code:a,reason:o}),y.close.hasSubscribers&&y.close.publish({websocket:e,code:a,reason:o})}function M(e){let{ws:t}=this;t[s]=r.CLOSING,y.socketError.hasSubscribers&&y.socketError.publish(e),this.destroy()}t.exports={establishWebSocketConnection:O,closeWebSocketConnection:k}})),ln=U(((e,t)=>{let{createInflateRaw:n,Z_DEFAULT_WINDOWBITS:r}=W(`node:zlib`),{isValidClientWindowBits:i}=on(),{MessageSizeExceededError:a}=ke(),o=Buffer.from([0,0,255,255]),s=Symbol(`kBuffer`),c=Symbol(`kLength`);t.exports={PerMessageDeflate:class{#e;#t={};#n=!1;#r=null;constructor(e){this.#t.serverNoContextTakeover=e.has(`server_no_context_takeover`),this.#t.serverMaxWindowBits=e.get(`server_max_window_bits`)}decompress(e,t,l){if(this.#n){l(new a);return}if(!this.#e){let e=r;if(this.#t.serverMaxWindowBits){if(!i(this.#t.serverMaxWindowBits)){l(Error(`Invalid server_max_window_bits`));return}e=Number.parseInt(this.#t.serverMaxWindowBits)}try{this.#e=n({windowBits:e})}catch(e){l(e);return}this.#e[s]=[],this.#e[c]=0,this.#e.on(`data`,e=>{if(!this.#n){if(this.#e[c]+=e.length,this.#e[c]>4194304){if(this.#n=!0,this.#e.removeAllListeners(),this.#e.destroy(),this.#e=null,this.#r){let e=this.#r;this.#r=null,e(new a)}return}this.#e[s].push(e)}}),this.#e.on(`error`,e=>{this.#e=null,l(e)})}this.#r=l,this.#e.write(e),t&&this.#e.write(o),this.#e.flush(()=>{if(this.#n||!this.#e)return;let e=Buffer.concat(this.#e[s],this.#e[c]);this.#e[s].length=0,this.#e[c]=0,this.#r=null,l(null,e)})}}}})),un=U(((e,t)=>{let{Writable:n}=W(`node:stream`),r=W(`node:assert`),{parserStates:i,opcodes:a,states:o,emptyBuffer:s,sentCloseFrameState:c}=rn(),{kReadyState:l,kSentClose:u,kResponse:d,kReceivedClose:f}=an(),{channels:p}=Ne(),{isValidStatusCode:m,isValidOpcode:h,failWebsocketConnection:g,websocketMessageReceived:v,utf8Decode:y,isControlFrame:b,isTextBinaryFrame:x,isContinuationFrame:S}=on(),{WebsocketFrameSend:C}=sn(),{closeWebSocketConnection:w}=cn(),{PerMessageDeflate:T}=ln();t.exports={ByteParser:class extends n{#e=[];#t=0;#n=!1;#r=i.INFO;#i={};#a=[];#o;constructor(e,t){super(),this.ws=e,this.#o=t??new Map,this.#o.has(`permessage-deflate`)&&this.#o.set(`permessage-deflate`,new T(t))}_write(e,t,n){this.#e.push(e),this.#t+=e.length,this.#n=!0,this.run(n)}run(e){for(;this.#n;)if(this.#r===i.INFO){if(this.#t<2)return e();let t=this.consume(2),n=(t[0]&128)!=0,r=t[0]&15,o=(t[1]&128)==128,s=!n&&r!==a.CONTINUATION,c=t[1]&127,l=t[0]&64,u=t[0]&32,d=t[0]&16;if(!h(r))return g(this.ws,`Invalid opcode received`),e();if(o)return g(this.ws,`Frame cannot be masked`),e();if(l!==0&&!this.#o.has(`permessage-deflate`)){g(this.ws,`Expected RSV1 to be clear.`);return}if(u!==0||d!==0){g(this.ws,`RSV1, RSV2, RSV3 must be clear`);return}if(s&&!x(r)){g(this.ws,`Invalid frame type was fragmented.`);return}if(x(r)&&this.#a.length>0){g(this.ws,`Expected continuation frame`);return}if(this.#i.fragmented&&s){g(this.ws,`Fragmented frame exceeded 125 bytes.`);return}if((c>125||s)&&b(r)){g(this.ws,`Control frame either too large or fragmented`);return}if(S(r)&&this.#a.length===0&&!this.#i.compressed){g(this.ws,`Unexpected continuation frame`);return}c<=125?(this.#i.payloadLength=c,this.#r=i.READ_DATA):c===126?this.#r=i.PAYLOADLENGTH_16:c===127&&(this.#r=i.PAYLOADLENGTH_64),x(r)&&(this.#i.binaryType=r,this.#i.compressed=l!==0),this.#i.opcode=r,this.#i.masked=o,this.#i.fin=n,this.#i.fragmented=s}else if(this.#r===i.PAYLOADLENGTH_16){if(this.#t<2)return e();let t=this.consume(2);this.#i.payloadLength=t.readUInt16BE(0),this.#r=i.READ_DATA}else if(this.#r===i.PAYLOADLENGTH_64){if(this.#t<8)return e();let t=this.consume(8),n=t.readUInt32BE(0),r=t.readUInt32BE(4);if(n!==0||r>2**31-1){g(this.ws,`Received payload length > 2^31 bytes.`);return}this.#i.payloadLength=r,this.#r=i.READ_DATA}else if(this.#r===i.READ_DATA){if(this.#t{if(t){g(this.ws,t.message);return}if(this.#a.push(n),!this.#i.fin){this.#r=i.INFO,this.#n=!0,this.run(e);return}v(this.ws,this.#i.binaryType,Buffer.concat(this.#a)),this.#n=!0,this.#r=i.INFO,this.#a.length=0,this.run(e)}),this.#n=!1;break}else{if(this.#a.push(t),!this.#i.fragmented&&this.#i.fin){let e=Buffer.concat(this.#a);v(this.ws,this.#i.binaryType,e),this.#a.length=0}this.#r=i.INFO}}}consume(e){if(e>this.#t)throw Error(`Called consume() before buffers satiated.`);if(e===0)return s;if(this.#e[0].length===e)return this.#t-=this.#e[0].length,this.#e.shift();let t=Buffer.allocUnsafe(e),n=0;for(;n!==e;){let r=this.#e[0],{length:i}=r;if(i+n===e){t.set(this.#e.shift(),n);break}else if(i+n>e){t.set(r.subarray(0,e-n),n),this.#e[0]=r.subarray(e-n);break}else t.set(this.#e.shift(),n),n+=r.length}return this.#t-=e,t}parseCloseBody(e){r(e.length!==1);let t;if(e.length>=2&&(t=e.readUInt16BE(0)),t!==void 0&&!m(t))return{code:1002,reason:`Invalid status code`,error:!0};let n=e.subarray(2);n[0]===239&&n[1]===187&&n[2]===191&&(n=n.subarray(3));try{n=y(n)}catch{return{code:1007,reason:`Invalid UTF-8`,error:!0}}return{code:t,reason:n,error:!1}}parseControlFrame(e){let{opcode:t,payloadLength:n}=this.#i;if(t===a.CLOSE){if(n===1)return g(this.ws,`Received close frame with a 1-byte body.`),!1;if(this.#i.closeInfo=this.parseCloseBody(e),this.#i.closeInfo.error){let{code:e,reason:t}=this.#i.closeInfo;return w(this.ws,e,t,t.length),g(this.ws,t),!1}if(this.ws[u]!==c.SENT){let e=s;this.#i.closeInfo.code&&(e=Buffer.allocUnsafe(2),e.writeUInt16BE(this.#i.closeInfo.code,0));let t=new C(e);this.ws[d].socket.write(t.createFrame(a.CLOSE),e=>{e||(this.ws[u]=c.SENT)})}return this.ws[l]=o.CLOSING,this.ws[f]=!0,!1}else if(t===a.PING){if(!this.ws[f]){let t=new C(e);this.ws[d].socket.write(t.createFrame(a.PONG)),p.ping.hasSubscribers&&p.ping.publish({payload:e})}}else t===a.PONG&&p.pong.hasSubscribers&&p.pong.publish({payload:e});return!0}get closingInfo(){return this.#i.closeInfo}}}})),dn=U(((e,t)=>{let{WebsocketFrameSend:n}=sn(),{opcodes:r,sendHints:i}=rn(),a=it(),o=Buffer[Symbol.species];var s=class{#e=new a;#t=!1;#n;constructor(e){this.#n=e}add(e,t,n){if(n!==i.blob){let r=c(e,n);if(!this.#t)this.#n.write(r,t);else{let e={promise:null,callback:t,frame:r};this.#e.push(e)}return}let r={promise:e.arrayBuffer().then(e=>{r.promise=null,r.frame=c(e,n)}),callback:t,frame:null};this.#e.push(r),this.#t||this.#r()}async#r(){this.#t=!0;let e=this.#e;for(;!e.isEmpty();){let t=e.shift();t.promise!==null&&await t.promise,this.#n.write(t.frame,t.callback),t.callback=t.frame=null}this.#t=!1}};function c(e,t){return new n(l(e,t)).createFrame(t===i.string?r.TEXT:r.BINARY)}function l(e,t){switch(t){case i.string:return Buffer.from(e);case i.arrayBuffer:case i.blob:return new o(e);case i.typedArray:return new o(e.buffer,e.byteOffset,e.byteLength)}}t.exports={SendQueue:s}})),fn=U(((e,t)=>{let{webidl:n}=Ke(),{URLSerializer:r}=Ge(),{environmentSettingsObject:i}=qe(),{staticPropertyDescriptors:a,states:o,sentCloseFrameState:s,sendHints:c}=rn(),{kWebSocketURL:l,kReadyState:u,kController:d,kBinaryType:f,kResponse:p,kSentClose:m,kByteParser:h}=an(),{isConnecting:g,isEstablished:v,isClosing:y,isValidSubprotocol:b,fireEvent:x}=on(),{establishWebSocketConnection:S,closeWebSocketConnection:C}=cn(),{ByteParser:w}=un(),{kEnumerableProperty:T,isBlobLike:E}=Me(),{getGlobalDispatcher:D}=Mt(),{types:O}=W(`node:util`),{ErrorEvent:k,CloseEvent:A}=nn(),{SendQueue:j}=dn();var M=class e extends EventTarget{#e={open:null,error:null,close:null,message:null};#t=0;#n=``;#r=``;#i;constructor(t,r=[]){super(),n.util.markAsUncloneable(this);let a=`WebSocket constructor`;n.argumentLengthCheck(arguments,1,a);let o=n.converters[`DOMString or sequence or WebSocketInit`](r,a,`options`);t=n.converters.USVString(t,a,`url`),r=o.protocols;let c=i.settingsObject.baseUrl,p;try{p=new URL(t,c)}catch(e){throw new DOMException(e,`SyntaxError`)}if(p.protocol===`http:`?p.protocol=`ws:`:p.protocol===`https:`&&(p.protocol=`wss:`),p.protocol!==`ws:`&&p.protocol!==`wss:`)throw new DOMException(`Expected a ws: or wss: protocol, got ${p.protocol}`,`SyntaxError`);if(p.hash||p.href.endsWith(`#`))throw new DOMException(`Got fragment`,`SyntaxError`);if(typeof r==`string`&&(r=[r]),r.length!==new Set(r.map(e=>e.toLowerCase())).size||r.length>0&&!r.every(e=>b(e)))throw new DOMException(`Invalid Sec-WebSocket-Protocol value`,`SyntaxError`);this[l]=new URL(p.href);let h=i.settingsObject;this[d]=S(p,r,h,this,(e,t)=>this.#a(e,t),o),this[u]=e.CONNECTING,this[m]=s.NOT_SENT,this[f]=`blob`}close(t=void 0,r=void 0){n.brandCheck(this,e);let i=`WebSocket.close`;if(t!==void 0&&(t=n.converters[`unsigned short`](t,i,`code`,{clamp:!0})),r!==void 0&&(r=n.converters.USVString(r,i,`reason`)),t!==void 0&&t!==1e3&&(t<3e3||t>4999))throw new DOMException(`invalid code`,`InvalidAccessError`);let a=0;if(r!==void 0&&(a=Buffer.byteLength(r),a>123))throw new DOMException(`Reason must be less than 123 bytes; received ${a}`,`SyntaxError`);C(this,t,r,a)}send(t){n.brandCheck(this,e);let r=`WebSocket.send`;if(n.argumentLengthCheck(arguments,1,r),t=n.converters.WebSocketSendData(t,r,`data`),g(this))throw new DOMException(`Sent before connected.`,`InvalidStateError`);if(!(!v(this)||y(this)))if(typeof t==`string`){let e=Buffer.byteLength(t);this.#t+=e,this.#i.add(t,()=>{this.#t-=e},c.string)}else O.isArrayBuffer(t)?(this.#t+=t.byteLength,this.#i.add(t,()=>{this.#t-=t.byteLength},c.arrayBuffer)):ArrayBuffer.isView(t)?(this.#t+=t.byteLength,this.#i.add(t,()=>{this.#t-=t.byteLength},c.typedArray)):E(t)&&(this.#t+=t.size,this.#i.add(t,()=>{this.#t-=t.size},c.blob))}get readyState(){return n.brandCheck(this,e),this[u]}get bufferedAmount(){return n.brandCheck(this,e),this.#t}get url(){return n.brandCheck(this,e),r(this[l])}get extensions(){return n.brandCheck(this,e),this.#r}get protocol(){return n.brandCheck(this,e),this.#n}get onopen(){return n.brandCheck(this,e),this.#e.open}set onopen(t){n.brandCheck(this,e),this.#e.open&&this.removeEventListener(`open`,this.#e.open),typeof t==`function`?(this.#e.open=t,this.addEventListener(`open`,t)):this.#e.open=null}get onerror(){return n.brandCheck(this,e),this.#e.error}set onerror(t){n.brandCheck(this,e),this.#e.error&&this.removeEventListener(`error`,this.#e.error),typeof t==`function`?(this.#e.error=t,this.addEventListener(`error`,t)):this.#e.error=null}get onclose(){return n.brandCheck(this,e),this.#e.close}set onclose(t){n.brandCheck(this,e),this.#e.close&&this.removeEventListener(`close`,this.#e.close),typeof t==`function`?(this.#e.close=t,this.addEventListener(`close`,t)):this.#e.close=null}get onmessage(){return n.brandCheck(this,e),this.#e.message}set onmessage(t){n.brandCheck(this,e),this.#e.message&&this.removeEventListener(`message`,this.#e.message),typeof t==`function`?(this.#e.message=t,this.addEventListener(`message`,t)):this.#e.message=null}get binaryType(){return n.brandCheck(this,e),this[f]}set binaryType(t){n.brandCheck(this,e),t!==`blob`&&t!==`arraybuffer`?this[f]=`blob`:this[f]=t}#a(e,t){this[p]=e;let n=new w(this,t);n.on(`drain`,N),n.on(`error`,P.bind(this)),e.socket.ws=this,this[h]=n,this.#i=new j(e.socket),this[u]=o.OPEN;let r=e.headersList.get(`sec-websocket-extensions`);r!==null&&(this.#r=r);let i=e.headersList.get(`sec-websocket-protocol`);i!==null&&(this.#n=i),x(`open`,this)}};M.CONNECTING=M.prototype.CONNECTING=o.CONNECTING,M.OPEN=M.prototype.OPEN=o.OPEN,M.CLOSING=M.prototype.CLOSING=o.CLOSING,M.CLOSED=M.prototype.CLOSED=o.CLOSED,Object.defineProperties(M.prototype,{CONNECTING:a,OPEN:a,CLOSING:a,CLOSED:a,url:T,readyState:T,bufferedAmount:T,onopen:T,onerror:T,onclose:T,close:T,onmessage:T,binaryType:T,send:T,extensions:T,protocol:T,[Symbol.toStringTag]:{value:`WebSocket`,writable:!1,enumerable:!1,configurable:!0}}),Object.defineProperties(M,{CONNECTING:a,OPEN:a,CLOSING:a,CLOSED:a}),n.converters[`sequence`]=n.sequenceConverter(n.converters.DOMString),n.converters[`DOMString or sequence`]=function(e,t,r){return n.util.Type(e)===`Object`&&Symbol.iterator in e?n.converters[`sequence`](e):n.converters.DOMString(e,t,r)},n.converters.WebSocketInit=n.dictionaryConverter([{key:`protocols`,converter:n.converters[`DOMString or sequence`],defaultValue:()=>[]},{key:`dispatcher`,converter:n.converters.any,defaultValue:()=>D()},{key:`headers`,converter:n.nullableConverter(n.converters.HeadersInit)}]),n.converters[`DOMString or sequence or WebSocketInit`]=function(e){return n.util.Type(e)===`Object`&&!(Symbol.iterator in e)?n.converters.WebSocketInit(e):{protocols:n.converters[`DOMString or sequence`](e)}},n.converters.WebSocketSendData=function(e){if(n.util.Type(e)===`Object`){if(E(e))return n.converters.Blob(e,{strict:!1});if(ArrayBuffer.isView(e)||O.isArrayBuffer(e))return n.converters.BufferSource(e)}return n.converters.USVString(e)};function N(){this.ws[p].socket.resume()}function P(e){let t,n;e instanceof A?(t=e.reason,n=e.code):t=e.message,x(`error`,this,()=>new k(`error`,{error:e,message:t})),C(this,n)}t.exports={WebSocket:M}})),pn=U(((e,t)=>{function n(e){return e.indexOf(`\0`)===-1}function r(e){if(e.length===0)return!1;for(let t=0;t57)return!1;return!0}function i(e){return new Promise(t=>{setTimeout(t,e).unref()})}t.exports={isValidLastEventId:n,isASCIINumber:r,delay:i}})),mn=U(((e,t)=>{let{Transform:n}=W(`node:stream`),{isASCIINumber:r,isValidLastEventId:i}=pn(),a=[239,187,191];t.exports={EventSourceStream:class extends n{state=null;checkBOM=!0;crlfCheck=!1;eventEndCheck=!1;buffer=null;pos=0;event={data:void 0,event:void 0,id:void 0,retry:void 0};constructor(e={}){e.readableObjectMode=!0,super(e),this.state=e.eventSourceSettings||{},e.push&&(this.push=e.push)}_transform(e,t,n){if(e.length===0){n();return}if(this.buffer?this.buffer=Buffer.concat([this.buffer,e]):this.buffer=e,this.checkBOM)switch(this.buffer.length){case 1:if(this.buffer[0]===a[0]){n();return}this.checkBOM=!1,n();return;case 2:if(this.buffer[0]===a[0]&&this.buffer[1]===a[1]){n();return}this.checkBOM=!1;break;case 3:if(this.buffer[0]===a[0]&&this.buffer[1]===a[1]&&this.buffer[2]===a[2]){this.buffer=Buffer.alloc(0),this.checkBOM=!1,n();return}this.checkBOM=!1;break;default:this.buffer[0]===a[0]&&this.buffer[1]===a[1]&&this.buffer[2]===a[2]&&(this.buffer=this.buffer.subarray(3)),this.checkBOM=!1;break}for(;this.pos0&&(t[a]=o);break}}processEvent(e){e.retry&&r(e.retry)&&(this.state.reconnectionTime=parseInt(e.retry,10)),e.id&&i(e.id)&&(this.state.lastEventId=e.id),e.data!==void 0&&this.push({type:e.event||`message`,options:{data:e.data,lastEventId:this.state.lastEventId,origin:this.state.origin}})}clearEvent(){this.event={data:void 0,event:void 0,id:void 0,retry:void 0}}}}})),hn=U(((e,t)=>{let{pipeline:n}=W(`node:stream`),{fetching:r}=Ht(),{makeRequest:i}=Vt(),{webidl:a}=Ke(),{EventSourceStream:o}=mn(),{parseMIMEType:s}=Ge(),{createFastMessageEvent:c}=nn(),{isNetworkError:l}=zt(),{delay:u}=pn(),{kEnumerableProperty:d}=Me(),{environmentSettingsObject:f}=qe(),p=!1,m=3e3;var h=class e extends EventTarget{#e={open:null,error:null,message:null};#t=null;#n=!1;#r=0;#i=null;#a=null;#o;#s;constructor(e,t={}){super(),a.util.markAsUncloneable(this);let n=`EventSource constructor`;a.argumentLengthCheck(arguments,1,n),p||(p=!0,process.emitWarning(`EventSource is experimental, expect them to change at any time.`,{code:`UNDICI-ES`})),e=a.converters.USVString(e,n,`url`),t=a.converters.EventSourceInitDict(t,n,`eventSourceInitDict`),this.#o=t.dispatcher,this.#s={lastEventId:``,reconnectionTime:m};let r=f,o;try{o=new URL(e,r.settingsObject.baseUrl),this.#s.origin=o.origin}catch(e){throw new DOMException(e,`SyntaxError`)}this.#t=o.href;let s=`anonymous`;t.withCredentials&&(s=`use-credentials`,this.#n=!0);let c={redirect:`follow`,keepalive:!0,mode:`cors`,credentials:s===`anonymous`?`same-origin`:`omit`,referrer:`no-referrer`};c.client=f.settingsObject,c.headersList=[[`accept`,{name:`accept`,value:`text/event-stream`}]],c.cache=`no-store`,c.initiator=`other`,c.urlList=[new URL(this.#t)],this.#i=i(c),this.#c()}get readyState(){return this.#r}get url(){return this.#t}get withCredentials(){return this.#n}#c(){if(this.#r===2)return;this.#r=0;let e={request:this.#i,dispatcher:this.#o};e.processResponseEndOfBody=e=>{l(e)&&(this.dispatchEvent(new Event(`error`)),this.close()),this.#l()},e.processResponse=e=>{if(l(e))if(e.aborted){this.close(),this.dispatchEvent(new Event(`error`));return}else{this.#l();return}let t=e.headersList.get(`content-type`,!0),r=t===null?`failure`:s(t),i=r!==`failure`&&r.essence===`text/event-stream`;if(e.status!==200||i===!1){this.close(),this.dispatchEvent(new Event(`error`));return}this.#r=1,this.dispatchEvent(new Event(`open`)),this.#s.origin=e.urlList[e.urlList.length-1].origin;let a=new o({eventSourceSettings:this.#s,push:e=>{this.dispatchEvent(c(e.type,e.options))}});n(e.body.stream,a,e=>{e?.aborted===!1&&(this.close(),this.dispatchEvent(new Event(`error`)))})},this.#a=r(e)}async#l(){this.#r!==2&&(this.#r=0,this.dispatchEvent(new Event(`error`)),await u(this.#s.reconnectionTime),this.#r===0&&(this.#s.lastEventId.length&&this.#i.headersList.set(`last-event-id`,this.#s.lastEventId,!0),this.#c()))}close(){a.brandCheck(this,e),this.#r!==2&&(this.#r=2,this.#a.abort(),this.#i=null)}get onopen(){return this.#e.open}set onopen(e){this.#e.open&&this.removeEventListener(`open`,this.#e.open),typeof e==`function`?(this.#e.open=e,this.addEventListener(`open`,e)):this.#e.open=null}get onmessage(){return this.#e.message}set onmessage(e){this.#e.message&&this.removeEventListener(`message`,this.#e.message),typeof e==`function`?(this.#e.message=e,this.addEventListener(`message`,e)):this.#e.message=null}get onerror(){return this.#e.error}set onerror(e){this.#e.error&&this.removeEventListener(`error`,this.#e.error),typeof e==`function`?(this.#e.error=e,this.addEventListener(`error`,e)):this.#e.error=null}};let g={CONNECTING:{__proto__:null,configurable:!1,enumerable:!0,value:0,writable:!1},OPEN:{__proto__:null,configurable:!1,enumerable:!0,value:1,writable:!1},CLOSED:{__proto__:null,configurable:!1,enumerable:!0,value:2,writable:!1}};Object.defineProperties(h,g),Object.defineProperties(h.prototype,g),Object.defineProperties(h.prototype,{close:d,onerror:d,onmessage:d,onopen:d,readyState:d,url:d,withCredentials:d}),a.converters.EventSourceInitDict=a.dictionaryConverter([{key:`withCredentials`,converter:a.converters.boolean,defaultValue:()=>!1},{key:`dispatcher`,converter:a.converters.any}]),t.exports={EventSource:h,defaultReconnectionTime:m}})),gn=U(((e,t)=>{let n=rt(),r=Fe(),i=st(),a=ct(),o=lt(),s=ut(),c=dt(),l=pt(),u=ke(),d=Me(),{InvalidArgumentError:f}=u,p=St(),m=Re(),h=Dt(),g=jt(),v=Ot(),y=Ct(),b=ft(),{getGlobalDispatcher:x,setGlobalDispatcher:S}=Mt(),C=Nt(),w=tt(),T=nt();Object.assign(r.prototype,p),t.exports.Dispatcher=r,t.exports.Client=n,t.exports.Pool=i,t.exports.BalancedPool=a,t.exports.Agent=o,t.exports.ProxyAgent=s,t.exports.EnvHttpProxyAgent=c,t.exports.RetryAgent=l,t.exports.RetryHandler=b,t.exports.DecoratorHandler=C,t.exports.RedirectHandler=w,t.exports.createRedirectInterceptor=T,t.exports.interceptors={redirect:Pt(),retry:Ft(),dump:It(),dns:Lt()},t.exports.buildConnector=m,t.exports.errors=u,t.exports.util={parseHeaders:d.parseHeaders,headerNameToString:d.headerNameToString};function E(e){return(t,n,r)=>{if(typeof n==`function`&&(r=n,n=null),!t||typeof t!=`string`&&typeof t!=`object`&&!(t instanceof URL))throw new f(`invalid url`);if(n!=null&&typeof n!=`object`)throw new f(`invalid opts`);if(n&&n.path!=null){if(typeof n.path!=`string`)throw new f(`invalid opts.path`);let e=n.path;n.path.startsWith(`/`)||(e=`/${e}`),t=new URL(d.parseOrigin(t).origin+e)}else n||=typeof t==`object`?t:{},t=d.parseURL(t);let{agent:i,dispatcher:a=x()}=n;if(i)throw new f(`unsupported opts.agent. Did you mean opts.client?`);return e.call(a,{...n,origin:t.origin,path:t.search?`${t.pathname}${t.search}`:t.pathname,method:n.method||(n.body?`PUT`:`GET`)},r)}}t.exports.setGlobalDispatcher=S,t.exports.getGlobalDispatcher=x;let D=Ht().fetch;t.exports.fetch=async function(e,t=void 0){try{return await D(e,t)}catch(e){throw e&&typeof e==`object`&&Error.captureStackTrace(e),e}},t.exports.Headers=Rt().Headers,t.exports.Response=zt().Response,t.exports.Request=Vt().Request,t.exports.FormData=Xe().FormData,t.exports.File=globalThis.File??W(`node:buffer`).File,t.exports.FileReader=qt().FileReader;let{setGlobalOrigin:O,getGlobalOrigin:k}=We();t.exports.setGlobalOrigin=O,t.exports.getGlobalOrigin=k;let{CacheStorage:A}=Zt(),{kConstruct:j}=Jt();t.exports.caches=new A(j);let{deleteCookie:M,getCookies:N,getSetCookies:P,setCookie:F}=tn();t.exports.deleteCookie=M,t.exports.getCookies=N,t.exports.getSetCookies=P,t.exports.setCookie=F;let{parseMIMEType:I,serializeAMimeType:L}=Ge();t.exports.parseMIMEType=I,t.exports.serializeAMimeType=L;let{CloseEvent:R,ErrorEvent:z,MessageEvent:ee}=nn();t.exports.WebSocket=fn().WebSocket,t.exports.CloseEvent=R,t.exports.ErrorEvent=z,t.exports.MessageEvent=ee,t.exports.request=E(p.request),t.exports.stream=E(p.stream),t.exports.pipeline=E(p.pipeline),t.exports.connect=E(p.connect),t.exports.upgrade=E(p.upgrade),t.exports.MockClient=h,t.exports.MockPool=v,t.exports.MockAgent=g,t.exports.mockErrors=y;let{EventSource:B}=hn();t.exports.EventSource=B})),_n=pe(De(),1),vn=gn(),yn=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},bn;(function(e){e[e.OK=200]=`OK`,e[e.MultipleChoices=300]=`MultipleChoices`,e[e.MovedPermanently=301]=`MovedPermanently`,e[e.ResourceMoved=302]=`ResourceMoved`,e[e.SeeOther=303]=`SeeOther`,e[e.NotModified=304]=`NotModified`,e[e.UseProxy=305]=`UseProxy`,e[e.SwitchProxy=306]=`SwitchProxy`,e[e.TemporaryRedirect=307]=`TemporaryRedirect`,e[e.PermanentRedirect=308]=`PermanentRedirect`,e[e.BadRequest=400]=`BadRequest`,e[e.Unauthorized=401]=`Unauthorized`,e[e.PaymentRequired=402]=`PaymentRequired`,e[e.Forbidden=403]=`Forbidden`,e[e.NotFound=404]=`NotFound`,e[e.MethodNotAllowed=405]=`MethodNotAllowed`,e[e.NotAcceptable=406]=`NotAcceptable`,e[e.ProxyAuthenticationRequired=407]=`ProxyAuthenticationRequired`,e[e.RequestTimeout=408]=`RequestTimeout`,e[e.Conflict=409]=`Conflict`,e[e.Gone=410]=`Gone`,e[e.TooManyRequests=429]=`TooManyRequests`,e[e.InternalServerError=500]=`InternalServerError`,e[e.NotImplemented=501]=`NotImplemented`,e[e.BadGateway=502]=`BadGateway`,e[e.ServiceUnavailable=503]=`ServiceUnavailable`,e[e.GatewayTimeout=504]=`GatewayTimeout`})(bn||={});var xn;(function(e){e.Accept=`accept`,e.ContentType=`content-type`})(xn||={});var Sn;(function(e){e.ApplicationJson=`application/json`})(Sn||={});const Cn=[bn.MovedPermanently,bn.ResourceMoved,bn.SeeOther,bn.TemporaryRedirect,bn.PermanentRedirect],wn=[bn.BadGateway,bn.ServiceUnavailable,bn.GatewayTimeout],Tn=[`OPTIONS`,`GET`,`DELETE`,`HEAD`];var En=class e extends Error{constructor(t,n){super(t),this.name=`HttpClientError`,this.statusCode=n,Object.setPrototypeOf(this,e.prototype)}},Dn=class{constructor(e){this.message=e}readBody(){return yn(this,void 0,void 0,function*(){return new Promise(e=>yn(this,void 0,void 0,function*(){let t=Buffer.alloc(0);this.message.on(`data`,e=>{t=Buffer.concat([t,e])}),this.message.on(`end`,()=>{e(t.toString())})}))})}readBodyBuffer(){return yn(this,void 0,void 0,function*(){return new Promise(e=>yn(this,void 0,void 0,function*(){let t=[];this.message.on(`data`,e=>{t.push(e)}),this.message.on(`end`,()=>{e(Buffer.concat(t))})}))})}},On=class{constructor(e,t,n){this._ignoreSslError=!1,this._allowRedirects=!0,this._allowRedirectDowngrade=!1,this._maxRedirects=50,this._allowRetries=!1,this._maxRetries=1,this._keepAlive=!1,this._disposed=!1,this.userAgent=this._getUserAgentWithOrchestrationId(e),this.handlers=t||[],this.requestOptions=n,n&&(n.ignoreSslError!=null&&(this._ignoreSslError=n.ignoreSslError),this._socketTimeout=n.socketTimeout,n.allowRedirects!=null&&(this._allowRedirects=n.allowRedirects),n.allowRedirectDowngrade!=null&&(this._allowRedirectDowngrade=n.allowRedirectDowngrade),n.maxRedirects!=null&&(this._maxRedirects=Math.max(n.maxRedirects,0)),n.keepAlive!=null&&(this._keepAlive=n.keepAlive),n.allowRetries!=null&&(this._allowRetries=n.allowRetries),n.maxRetries!=null&&(this._maxRetries=n.maxRetries))}options(e,t){return yn(this,void 0,void 0,function*(){return this.request(`OPTIONS`,e,null,t||{})})}get(e,t){return yn(this,void 0,void 0,function*(){return this.request(`GET`,e,null,t||{})})}del(e,t){return yn(this,void 0,void 0,function*(){return this.request(`DELETE`,e,null,t||{})})}post(e,t,n){return yn(this,void 0,void 0,function*(){return this.request(`POST`,e,t,n||{})})}patch(e,t,n){return yn(this,void 0,void 0,function*(){return this.request(`PATCH`,e,t,n||{})})}put(e,t,n){return yn(this,void 0,void 0,function*(){return this.request(`PUT`,e,t,n||{})})}head(e,t){return yn(this,void 0,void 0,function*(){return this.request(`HEAD`,e,null,t||{})})}sendStream(e,t,n,r){return yn(this,void 0,void 0,function*(){return this.request(e,t,n,r)})}getJson(e){return yn(this,arguments,void 0,function*(e,t={}){t[xn.Accept]=this._getExistingOrDefaultHeader(t,xn.Accept,Sn.ApplicationJson);let n=yield this.get(e,t);return this._processResponse(n,this.requestOptions)})}postJson(e,t){return yn(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[xn.Accept]=this._getExistingOrDefaultHeader(n,xn.Accept,Sn.ApplicationJson),n[xn.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,Sn.ApplicationJson);let i=yield this.post(e,r,n);return this._processResponse(i,this.requestOptions)})}putJson(e,t){return yn(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[xn.Accept]=this._getExistingOrDefaultHeader(n,xn.Accept,Sn.ApplicationJson),n[xn.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,Sn.ApplicationJson);let i=yield this.put(e,r,n);return this._processResponse(i,this.requestOptions)})}patchJson(e,t){return yn(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[xn.Accept]=this._getExistingOrDefaultHeader(n,xn.Accept,Sn.ApplicationJson),n[xn.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,Sn.ApplicationJson);let i=yield this.patch(e,r,n);return this._processResponse(i,this.requestOptions)})}request(e,t,n,r){return yn(this,void 0,void 0,function*(){if(this._disposed)throw Error(`Client has already been disposed.`);let i=new URL(t),a=this._prepareRequest(e,i,r),o=this._allowRetries&&Tn.includes(e)?this._maxRetries+1:1,s=0,c;do{if(c=yield this.requestRaw(a,n),c&&c.message&&c.message.statusCode===bn.Unauthorized){let e;for(let t of this.handlers)if(t.canHandleAuthentication(c)){e=t;break}return e?e.handleAuthentication(this,a,n):c}let t=this._maxRedirects;for(;c.message.statusCode&&Cn.includes(c.message.statusCode)&&this._allowRedirects&&t>0;){let o=c.message.headers.location;if(!o)break;let s=new URL(o);if(i.protocol===`https:`&&i.protocol!==s.protocol&&!this._allowRedirectDowngrade)throw Error(`Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.`);if(yield c.readBody(),s.hostname!==i.hostname)for(let e in r)e.toLowerCase()===`authorization`&&delete r[e];a=this._prepareRequest(e,s,r),c=yield this.requestRaw(a,n),t--}if(!c.message.statusCode||!wn.includes(c.message.statusCode))return c;s+=1,s{function i(e,t){e?r(e):t?n(t):r(Error(`Unknown error`))}this.requestRawWithCallback(e,t,i)})})}requestRawWithCallback(e,t,n){typeof t==`string`&&(e.options.headers||(e.options.headers={}),e.options.headers[`Content-Length`]=Buffer.byteLength(t,`utf8`));let r=!1;function i(e,t){r||(r=!0,n(e,t))}let a=e.httpModule.request(e.options,e=>{i(void 0,new Dn(e))}),o;a.on(`socket`,e=>{o=e}),a.setTimeout(this._socketTimeout||3*6e4,()=>{o&&o.end(),i(Error(`Request timeout: ${e.options.path}`))}),a.on(`error`,function(e){i(e)}),t&&typeof t==`string`&&a.write(t,`utf8`),t&&typeof t!=`string`?(t.on(`close`,function(){a.end()}),t.pipe(a)):a.end()}getAgent(e){let t=new URL(e);return this._getAgent(t)}getAgentDispatcher(e){let t=new URL(e),n=Se(t);if(n&&n.hostname)return this._getProxyAgentDispatcher(t,n)}_prepareRequest(e,t,n){let r={};r.parsedUrl=t;let i=r.parsedUrl.protocol===`https:`;r.httpModule=i?g:h;let a=i?443:80;if(r.options={},r.options.host=r.parsedUrl.hostname,r.options.port=r.parsedUrl.port?parseInt(r.parsedUrl.port):a,r.options.path=(r.parsedUrl.pathname||``)+(r.parsedUrl.search||``),r.options.method=e,r.options.headers=this._mergeHeaders(n),this.userAgent!=null&&(r.options.headers[`user-agent`]=this.userAgent),r.options.agent=this._getAgent(r.parsedUrl),this.handlers)for(let e of this.handlers)e.prepareRequest(r.options);return r}_mergeHeaders(e){return this.requestOptions&&this.requestOptions.headers?Object.assign({},kn(this.requestOptions.headers),kn(e||{})):kn(e||{})}_getExistingOrDefaultHeader(e,t,n){let r;if(this.requestOptions&&this.requestOptions.headers){let e=kn(this.requestOptions.headers)[t];e&&(r=typeof e==`number`?e.toString():e)}let i=e[t];return i===void 0?r===void 0?n:r:typeof i==`number`?i.toString():i}_getExistingOrDefaultContentTypeHeader(e,t){let n;if(this.requestOptions&&this.requestOptions.headers){let e=kn(this.requestOptions.headers)[xn.ContentType];e&&(n=typeof e==`number`?String(e):Array.isArray(e)?e.join(`, `):e)}let r=e[xn.ContentType];return r===void 0?n===void 0?t:n:typeof r==`number`?String(r):Array.isArray(r)?r.join(`, `):r}_getAgent(e){let t,n=Se(e),r=n&&n.hostname;if(this._keepAlive&&r&&(t=this._proxyAgent),r||(t=this._agent),t)return t;let i=e.protocol===`https:`,a=100;if(this.requestOptions&&(a=this.requestOptions.maxSockets||h.globalAgent.maxSockets),n&&n.hostname){let e={maxSockets:a,keepAlive:this._keepAlive,proxy:Object.assign(Object.assign({},(n.username||n.password)&&{proxyAuth:`${n.username}:${n.password}`}),{host:n.hostname,port:n.port})},r,o=n.protocol===`https:`;r=i?o?_n.httpsOverHttps:_n.httpsOverHttp:o?_n.httpOverHttps:_n.httpOverHttp,t=r(e),this._proxyAgent=t}if(!t){let e={keepAlive:this._keepAlive,maxSockets:a};t=i?new g.Agent(e):new h.Agent(e),this._agent=t}return i&&this._ignoreSslError&&(t.options=Object.assign(t.options||{},{rejectUnauthorized:!1})),t}_getProxyAgentDispatcher(e,t){let n;if(this._keepAlive&&(n=this._proxyAgentDispatcher),n)return n;let r=e.protocol===`https:`;return n=new vn.ProxyAgent(Object.assign({uri:t.href,pipelining:this._keepAlive?1:0},(t.username||t.password)&&{token:`Basic ${Buffer.from(`${t.username}:${t.password}`).toString(`base64`)}`})),this._proxyAgentDispatcher=n,r&&this._ignoreSslError&&(n.options=Object.assign(n.options.requestTls||{},{rejectUnauthorized:!1})),n}_getUserAgentWithOrchestrationId(e){let t=e||`actions/http-client`,n=process.env.ACTIONS_ORCHESTRATION_ID;return n?`${t} actions_orchestration_id/${n.replace(/[^a-z0-9_.-]/gi,`_`)}`:t}_performExponentialBackoff(e){return yn(this,void 0,void 0,function*(){e=Math.min(10,e);let t=5*2**e;return new Promise(e=>setTimeout(()=>e(),t))})}_processResponse(e,t){return yn(this,void 0,void 0,function*(){return new Promise((n,r)=>yn(this,void 0,void 0,function*(){let i=e.message.statusCode||0,a={statusCode:i,result:null,headers:{}};i===bn.NotFound&&n(a);function o(e,t){if(typeof t==`string`){let e=new Date(t);if(!isNaN(e.valueOf()))return e}return t}let s,c;try{c=yield e.readBody(),c&&c.length>0&&(s=t&&t.deserializeDates?JSON.parse(c,o):JSON.parse(c),a.result=s),a.headers=e.message.headers}catch{}if(i>299){let e;e=s&&s.message?s.message:c&&c.length>0?c:`Failed request: (${i})`;let t=new En(e,i);t.result=a.result,r(t)}else n(a)}))})}};const kn=e=>Object.keys(e).reduce((t,n)=>(t[n.toLowerCase()]=e[n],t),{});var An=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},jn=class{constructor(e){this.token=e}prepareRequest(e){if(!e.headers)throw Error(`The request has no headers`);e.headers.Authorization=`Bearer ${this.token}`}canHandleAuthentication(){return!1}handleAuthentication(){return An(this,void 0,void 0,function*(){throw Error(`not implemented`)})}},Mn=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const{access:Nn,appendFile:Pn,writeFile:Fn}=l,In=`GITHUB_STEP_SUMMARY`,Ln=new class{constructor(){this._buffer=``}filePath(){return Mn(this,void 0,void 0,function*(){if(this._filePath)return this._filePath;let e=process.env[In];if(!e)throw Error(`Unable to find environment variable for $${In}. Check if your runtime environment supports job summaries.`);try{yield Nn(e,s.R_OK|s.W_OK)}catch{throw Error(`Unable to access summary file: '${e}'. Check if the file has correct read/write permissions.`)}return this._filePath=e,this._filePath})}wrap(e,t,n={}){let r=Object.entries(n).map(([e,t])=>` ${e}="${t}"`).join(``);return t?`<${e}${r}>${t}`:`<${e}${r}>`}write(e){return Mn(this,void 0,void 0,function*(){let t=!!e?.overwrite,n=yield this.filePath();return yield(t?Fn:Pn)(n,this._buffer,{encoding:`utf8`}),this.emptyBuffer()})}clear(){return Mn(this,void 0,void 0,function*(){return this.emptyBuffer().write({overwrite:!0})})}stringify(){return this._buffer}isEmptyBuffer(){return this._buffer.length===0}emptyBuffer(){return this._buffer=``,this}addRaw(e,t=!1){return this._buffer+=e,t?this.addEOL():this}addEOL(){return this.addRaw(i)}addCodeBlock(e,t){let n=Object.assign({},t&&{lang:t}),r=this.wrap(`pre`,this.wrap(`code`,e),n);return this.addRaw(r).addEOL()}addList(e,t=!1){let n=t?`ol`:`ul`,r=e.map(e=>this.wrap(`li`,e)).join(``),i=this.wrap(n,r);return this.addRaw(i).addEOL()}addTable(e){let t=e.map(e=>{let t=e.map(e=>{if(typeof e==`string`)return this.wrap(`td`,e);let{header:t,data:n,colspan:r,rowspan:i}=e,a=t?`th`:`td`,o=Object.assign(Object.assign({},r&&{colspan:r}),i&&{rowspan:i});return this.wrap(a,n,o)}).join(``);return this.wrap(`tr`,t)}).join(``),n=this.wrap(`table`,t);return this.addRaw(n).addEOL()}addDetails(e,t){let n=this.wrap(`details`,this.wrap(`summary`,e)+t);return this.addRaw(n).addEOL()}addImage(e,t,n){let{width:r,height:i}=n||{},a=Object.assign(Object.assign({},r&&{width:r}),i&&{height:i}),o=this.wrap(`img`,null,Object.assign({src:e,alt:t},a));return this.addRaw(o).addEOL()}addHeading(e,t){let n=`h${t}`,r=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`].includes(n)?n:`h1`,i=this.wrap(r,e);return this.addRaw(i).addEOL()}addSeparator(){let e=this.wrap(`hr`,null);return this.addRaw(e).addEOL()}addBreak(){let e=this.wrap(`br`,null);return this.addRaw(e).addEOL()}addQuote(e,t){let n=Object.assign({},t&&{cite:t}),r=this.wrap(`blockquote`,e,n);return this.addRaw(r).addEOL()}addLink(e,t){let n=this.wrap(`a`,e,{href:t});return this.addRaw(n).addEOL()}};var Rn=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const{chmod:zn,copyFile:Bn,lstat:Vn,mkdir:Hn,open:Un,readdir:Wn,rename:Gn,rm:Kn,rmdir:qn,stat:Jn,symlink:Yn,unlink:Xn}=o.promises,Zn=process.platform===`win32`;function Qn(e){return Rn(this,void 0,void 0,function*(){let t=yield o.promises.readlink(e);return Zn&&!t.endsWith(`\\`)?`${t}\\`:t})}o.constants.O_RDONLY;function $n(e){return Rn(this,void 0,void 0,function*(){try{yield Jn(e)}catch(e){if(e.code===`ENOENT`)return!1;throw e}return!0})}function er(e){if(e=nr(e),!e)throw Error(`isRooted() parameter "p" cannot be empty`);return Zn?e.startsWith(`\\`)||/^[A-Z]:/i.test(e):e.startsWith(`/`)}function tr(e,t){return Rn(this,void 0,void 0,function*(){let n;try{n=yield Jn(e)}catch(t){t.code!==`ENOENT`&&console.log(`Unexpected error attempting to determine if executable file exists '${e}': ${t}`)}if(n&&n.isFile()){if(Zn){let n=f.extname(e).toUpperCase();if(t.some(e=>e.toUpperCase()===n))return e}else if(rr(n))return e}let r=e;for(let i of t){e=r+i,n=void 0;try{n=yield Jn(e)}catch(t){t.code!==`ENOENT`&&console.log(`Unexpected error attempting to determine if executable file exists '${e}': ${t}`)}if(n&&n.isFile()){if(Zn){try{let t=f.dirname(e),n=f.basename(e).toUpperCase();for(let r of yield Wn(t))if(n===r.toUpperCase()){e=f.join(t,r);break}}catch(t){console.log(`Unexpected error attempting to determine the actual case of the file '${e}': ${t}`)}return e}else if(rr(n))return e}}return``})}function nr(e){return e||=``,Zn?(e=e.replace(/\//g,`\\`),e.replace(/\\\\+/g,`\\`)):e.replace(/\/\/+/g,`/`)}function rr(e){return(e.mode&1)>0||(e.mode&8)>0&&process.getgid!==void 0&&e.gid===process.getgid()||(e.mode&64)>0&&process.getuid!==void 0&&e.uid===process.getuid()}var ir=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function ar(e,t){return ir(this,arguments,void 0,function*(e,t,n={}){let{force:r,recursive:i,copySourceDirectory:a}=ur(n),o=(yield $n(t))?yield Jn(t):null;if(o&&o.isFile()&&!r)return;let s=o&&o.isDirectory()&&a?f.join(t,f.basename(e)):t;if(!(yield $n(e)))throw Error(`no such file or directory: ${e}`);if((yield Jn(e)).isDirectory())if(i)yield dr(e,s,0,r);else throw Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`);else{if(f.relative(e,s)===``)throw Error(`'${s}' and '${e}' are the same file`);yield fr(e,s,r)}})}function or(e){return ir(this,void 0,void 0,function*(){if(Zn&&/[*"<>|]/.test(e))throw Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');try{yield Kn(e,{force:!0,maxRetries:3,recursive:!0,retryDelay:300})}catch(e){throw Error(`File was unable to be removed ${e}`)}})}function sr(e){return ir(this,void 0,void 0,function*(){x(e,`a path argument must be provided`),yield Hn(e,{recursive:!0})})}function cr(e,t){return ir(this,void 0,void 0,function*(){if(!e)throw Error(`parameter 'tool' is required`);if(t){let t=yield cr(e,!1);if(!t)throw Error(Zn?`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`:`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);return t}let n=yield lr(e);return n&&n.length>0?n[0]:``})}function lr(e){return ir(this,void 0,void 0,function*(){if(!e)throw Error(`parameter 'tool' is required`);let t=[];if(Zn&&process.env.PATHEXT)for(let e of process.env.PATHEXT.split(f.delimiter))e&&t.push(e);if(er(e)){let n=yield tr(e,t);return n?[n]:[]}if(e.includes(f.sep))return[];let n=[];if(process.env.PATH)for(let e of process.env.PATH.split(f.delimiter))e&&n.push(e);let r=[];for(let i of n){let n=yield tr(f.join(i,e),t);n&&r.push(n)}return r})}function ur(e){return{force:e.force==null?!0:e.force,recursive:!!e.recursive,copySourceDirectory:e.copySourceDirectory==null?!0:!!e.copySourceDirectory}}function dr(e,t,n,r){return ir(this,void 0,void 0,function*(){if(n>=255)return;n++,yield sr(t);let i=yield Wn(e);for(let a of i){let i=`${e}/${a}`,o=`${t}/${a}`;(yield Vn(i)).isDirectory()?yield dr(i,o,n,r):yield fr(i,o,r)}yield zn(t,(yield Jn(e)).mode)})}function fr(e,t,n){return ir(this,void 0,void 0,function*(){if((yield Vn(e)).isSymbolicLink()){try{yield Vn(t),yield Xn(t)}catch(e){e.code===`EPERM`&&(yield zn(t,`0666`),yield Xn(t))}yield Yn(yield Qn(e),t,Zn?`junction`:null)}else (!(yield $n(t))||n)&&(yield Bn(e,t))})}var pr=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const mr=process.platform===`win32`;var hr=class extends v.EventEmitter{constructor(e,t,n){if(super(),!e)throw Error(`Parameter 'toolPath' cannot be null or empty.`);this.toolPath=e,this.args=t||[],this.options=n||{}}_debug(e){this.options.listeners&&this.options.listeners.debug&&this.options.listeners.debug(e)}_getCommandString(e,t){let n=this._getSpawnFileName(),r=this._getSpawnArgs(e),i=t?``:`[command]`;if(mr)if(this._isCmdFile()){i+=n;for(let e of r)i+=` ${e}`}else if(e.windowsVerbatimArguments){i+=`"${n}"`;for(let e of r)i+=` ${e}`}else{i+=this._windowsQuoteCmdArg(n);for(let e of r)i+=` ${this._windowsQuoteCmdArg(e)}`}else{i+=n;for(let e of r)i+=` ${e}`}return i}_processLineBuffer(e,t,r){try{let i=t+e.toString(),a=i.indexOf(n.EOL);for(;a>-1;)r(i.substring(0,a)),i=i.substring(a+n.EOL.length),a=i.indexOf(n.EOL);return i}catch(e){return this._debug(`error processing line. Failed with error ${e}`),``}}_getSpawnFileName(){return mr&&this._isCmdFile()?process.env.COMSPEC||`cmd.exe`:this.toolPath}_getSpawnArgs(e){if(mr&&this._isCmdFile()){let t=`/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;for(let n of this.args)t+=` `,t+=e.windowsVerbatimArguments?n:this._windowsQuoteCmdArg(n);return t+=`"`,[t]}return this.args}_endsWith(e,t){return e.endsWith(t)}_isCmdFile(){let e=this.toolPath.toUpperCase();return this._endsWith(e,`.CMD`)||this._endsWith(e,`.BAT`)}_windowsQuoteCmdArg(e){if(!this._isCmdFile())return this._uvQuoteCmdArg(e);if(!e)return`""`;let t=[` `,` `,`&`,`(`,`)`,`[`,`]`,`{`,`}`,`^`,`=`,`;`,`!`,`'`,`+`,`,`,"`",`~`,`|`,`<`,`>`,`"`],n=!1;for(let r of e)if(t.some(e=>e===r)){n=!0;break}if(!n)return e;let r=`"`,i=!0;for(let t=e.length;t>0;t--)r+=e[t-1],i&&e[t-1]===`\\`?r+=`\\`:e[t-1]===`"`?(i=!0,r+=`"`):i=!1;return r+=`"`,r.split(``).reverse().join(``)}_uvQuoteCmdArg(e){if(!e)return`""`;if(!e.includes(` `)&&!e.includes(` `)&&!e.includes(`"`))return e;if(!e.includes(`"`)&&!e.includes(`\\`))return`"${e}"`;let t=`"`,n=!0;for(let r=e.length;r>0;r--)t+=e[r-1],n&&e[r-1]===`\\`?t+=`\\`:e[r-1]===`"`?(n=!0,t+=`\\`):n=!1;return t+=`"`,t.split(``).reverse().join(``)}_cloneExecOptions(e){e||={};let t={cwd:e.cwd||process.cwd(),env:e.env||process.env,silent:e.silent||!1,windowsVerbatimArguments:e.windowsVerbatimArguments||!1,failOnStdErr:e.failOnStdErr||!1,ignoreReturnCode:e.ignoreReturnCode||!1,delay:e.delay||1e4};return t.outStream=e.outStream||process.stdout,t.errStream=e.errStream||process.stderr,t}_getSpawnOptions(e,t){e||={};let n={};return n.cwd=e.cwd,n.env=e.env,n.windowsVerbatimArguments=e.windowsVerbatimArguments||this._isCmdFile(),e.windowsVerbatimArguments&&(n.argv0=`"${t}"`),n}exec(){return pr(this,void 0,void 0,function*(){return!er(this.toolPath)&&(this.toolPath.includes(`/`)||mr&&this.toolPath.includes(`\\`))&&(this.toolPath=f.resolve(process.cwd(),this.options.cwd||process.cwd(),this.toolPath)),this.toolPath=yield cr(this.toolPath,!0),new Promise((e,t)=>pr(this,void 0,void 0,function*(){this._debug(`exec tool: ${this.toolPath}`),this._debug(`arguments:`);for(let e of this.args)this._debug(` ${e}`);let r=this._cloneExecOptions(this.options);!r.silent&&r.outStream&&r.outStream.write(this._getCommandString(r)+n.EOL);let i=new _r(r,this.toolPath);if(i.on(`debug`,e=>{this._debug(e)}),this.options.cwd&&!(yield $n(this.options.cwd)))return t(Error(`The cwd: ${this.options.cwd} does not exist!`));let a=this._getSpawnFileName(),o=M.spawn(a,this._getSpawnArgs(r),this._getSpawnOptions(this.options,a)),s=``;o.stdout&&o.stdout.on(`data`,e=>{this.options.listeners&&this.options.listeners.stdout&&this.options.listeners.stdout(e),!r.silent&&r.outStream&&r.outStream.write(e),s=this._processLineBuffer(e,s,e=>{this.options.listeners&&this.options.listeners.stdline&&this.options.listeners.stdline(e)})});let c=``;if(o.stderr&&o.stderr.on(`data`,e=>{i.processStderr=!0,this.options.listeners&&this.options.listeners.stderr&&this.options.listeners.stderr(e),!r.silent&&r.errStream&&r.outStream&&(r.failOnStdErr?r.errStream:r.outStream).write(e),c=this._processLineBuffer(e,c,e=>{this.options.listeners&&this.options.listeners.errline&&this.options.listeners.errline(e)})}),o.on(`error`,e=>{i.processError=e.message,i.processExited=!0,i.processClosed=!0,i.CheckComplete()}),o.on(`exit`,e=>{i.processExitCode=e,i.processExited=!0,this._debug(`Exit code ${e} received from tool '${this.toolPath}'`),i.CheckComplete()}),o.on(`close`,e=>{i.processExitCode=e,i.processExited=!0,i.processClosed=!0,this._debug(`STDIO streams have closed for tool '${this.toolPath}'`),i.CheckComplete()}),i.on(`done`,(n,r)=>{s.length>0&&this.emit(`stdline`,s),c.length>0&&this.emit(`errline`,c),o.removeAllListeners(),n?t(n):e(r)}),this.options.input){if(!o.stdin)throw Error(`child process missing stdin`);o.stdin.end(this.options.input)}}))})}};function gr(e){let t=[],n=!1,r=!1,i=``;function a(e){r&&e!==`"`&&(i+=`\\`),i+=e,r=!1}for(let o=0;o0&&(t.push(i),i=``);continue}a(s)}return i.length>0&&t.push(i.trim()),t}var _r=class e extends v.EventEmitter{constructor(e,t){if(super(),this.processClosed=!1,this.processError=``,this.processExitCode=0,this.processExited=!1,this.processStderr=!1,this.delay=1e4,this.done=!1,this.timeout=null,!t)throw Error(`toolPath must not be empty`);this.options=e,this.toolPath=t,e.delay&&(this.delay=e.delay)}CheckComplete(){this.done||(this.processClosed?this._setResult():this.processExited&&(this.timeout=N(e.HandleTimeout,this.delay,this)))}_debug(e){this.emit(`debug`,e)}_setResult(){let e;this.processExited&&(this.processError?e=Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`):this.processExitCode!==0&&!this.options.ignoreReturnCode?e=Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`):this.processStderr&&this.options.failOnStdErr&&(e=Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`))),this.timeout&&=(clearTimeout(this.timeout),null),this.done=!0,this.emit(`done`,e,this.processExitCode)}static HandleTimeout(e){if(!e.done){if(!e.processClosed&&e.processExited){let t=`The STDIO streams did not close within ${e.delay/1e3} seconds of the exit event from process '${e.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`;e._debug(t)}e._setResult()}}},vr=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function yr(e,t,n){return vr(this,void 0,void 0,function*(){let r=gr(e);if(r.length===0)throw Error(`Parameter 'commandLine' cannot be null or empty.`);let i=r[0];return t=r.slice(1).concat(t||[]),new hr(i,t,n).exec()})}function br(e,t,n){return vr(this,void 0,void 0,function*(){let r=``,i=``,a=new j(`utf8`),o=new j(`utf8`),s=n?.listeners?.stdout,c=n?.listeners?.stderr,l=Object.assign(Object.assign({},n?.listeners),{stdout:e=>{r+=a.write(e),s&&s(e)},stderr:e=>{i+=o.write(e),c&&c(e)}}),u=yield yr(e,t,Object.assign(Object.assign({},n),{listeners:l}));return r+=a.end(),i+=o.end(),{exitCode:u,stdout:r,stderr:i}})}r.platform(),r.arch();var xr;(function(e){e[e.Success=0]=`Success`,e[e.Failure=1]=`Failure`})(xr||={});function Sr(e,t){let n=me(t);if(process.env[e]=n,process.env.GITHUB_ENV)return be(`ENV`,xe(e,t));ge(`set-env`,{name:e},n)}function Cr(e){ge(`add-mask`,{},e)}function wr(e){process.env.GITHUB_PATH?be(`PATH`,e):ge(`add-path`,{},e),process.env.PATH=`${e}${f.delimiter}${process.env.PATH}`}function Tr(e,t){let n=process.env[`INPUT_${e.replace(/ /g,`_`).toUpperCase()}`]||``;if(t&&t.required&&!n)throw Error(`Input required and not supplied: ${e}`);return t&&t.trimWhitespace===!1?n:n.trim()}function Er(e,t){if(process.env.GITHUB_OUTPUT)return be(`OUTPUT`,xe(e,t));process.stdout.write(n.EOL),ge(`set-output`,{name:e},me(t))}function Dr(e){process.exitCode=xr.Failure,kr(e)}function Or(){return process.env.RUNNER_DEBUG===`1`}function G(e){ge(`debug`,{},e)}function kr(e,t={}){ge(`error`,he(t),e instanceof Error?e.toString():e)}function Ar(e,t={}){ge(`warning`,he(t),e instanceof Error?e.toString():e)}function jr(e){process.stdout.write(e+n.EOL)}function Mr(e,t){if(process.env.GITHUB_STATE)return be(`STATE`,xe(e,t));ge(`save-state`,{name:e},me(t))}function Nr(e){return process.env[`STATE_${e}`]||``}function Pr(e){return e instanceof Error?e.message:String(e)}const Fr=[`token`,`password`,`secret`,`key`,`auth`,`credential`,`bearer`,`apikey`,`api_key`,`access_token`,`refresh_token`,`private`];function Ir(e,t){let n=e.toLowerCase();return t.some(e=>n.includes(e.toLowerCase()))}function Lr(e,t=Fr){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>Lr(e,t));let n={};for(let[r,i]of Object.entries(e))Ir(r,t)&&typeof i==`string`?n[r]=`[REDACTED]`:typeof i==`object`&&i?n[r]=Lr(i,t):n[r]=i;return n}function Rr(e,t,n,r){let i=Lr({...n,...r}),a={timestamp:new Date().toISOString(),level:e,message:t,...i};if(r!=null&&`error`in r&&r.error instanceof Error){let e=r.error;a.error={message:e.message,name:e.name,stack:e.stack}}return JSON.stringify(a)}function zr(e){return{debug:(t,n)=>{G(Rr(`debug`,t,e,n))},info:(t,n)=>{jr(Rr(`info`,t,e,n))},warning:(t,n)=>{Ar(Rr(`warning`,t,e,n))},error:(t,n)=>{kr(Rr(`error`,t,e,n))}}}const Br={SHOULD_SAVE_CACHE:`shouldSaveCache`,SESSION_ID:`sessionId`,CACHE_SAVED:`cacheSaved`,ARTIFACT_UPLOADED:`artifactUploaded`,OPENCODE_VERSION:`opencodeVersion`},Vr=`sisyphus`,Hr=18e5,Ur={providerID:`opencode`,modelID:`big-pickle`},Wr=`1.3.3`,Gr=`1.3.11`,Kr=`3.14.0`,qr=`opencode-storage`,Jr=`opencode-tools`,Yr=6e5,Xr=`fro-bot-dedup-v1`;function Zr(){let e=t.env.XDG_DATA_HOME;return e!=null&&e.trim().length>0?e:F.join(I.homedir(),`.local`,`share`)}function Qr(){return F.join(Zr(),`opencode`,`storage`)}function $r(){return F.join(Zr(),`opencode`,`auth.json`)}function ei(){return F.join(Zr(),`opencode`,`log`)}function ti(){let e=t.env.OPENCODE_PROMPT_ARTIFACT;return e===`true`||e===`1`}function ni(){let e=t.env.RUNNER_OS;if(e!=null&&e.trim().length>0)return e;switch(I.platform()){case`darwin`:return`macOS`;case`win32`:return`Windows`;case`aix`:case`android`:case`freebsd`:case`haiku`:case`linux`:case`openbsd`:case`sunos`:case`cygwin`:case`netbsd`:return`Linux`}}function ri(){let e=t.env.GITHUB_REPOSITORY;return e!=null&&e.trim().length>0?e:`unknown/unknown`}function ii(){let e=t.env.GITHUB_REF_NAME;return e!=null&&e.trim().length>0?e:`main`}function ai(){let e=t.env.GITHUB_RUN_ID;return e!=null&&e.trim().length>0?Number(e):0}function oi(){let e=t.env.GITHUB_RUN_ATTEMPT;if(e!=null&&e.trim().length>0){let t=Number(e);if(Number.isFinite(t)&&t>0)return t}return 1}function si(){let e=t.env.GITHUB_WORKSPACE;return e!=null&&e.trim().length>0?e:t.cwd()}var ci=class{constructor(){if(this.payload={},process.env.GITHUB_EVENT_PATH)if(c(process.env.GITHUB_EVENT_PATH))this.payload=JSON.parse(u(process.env.GITHUB_EVENT_PATH,{encoding:`utf8`}));else{let e=process.env.GITHUB_EVENT_PATH;process.stdout.write(`GITHUB_EVENT_PATH ${e} does not exist${i}`)}this.eventName=process.env.GITHUB_EVENT_NAME,this.sha=process.env.GITHUB_SHA,this.ref=process.env.GITHUB_REF,this.workflow=process.env.GITHUB_WORKFLOW,this.action=process.env.GITHUB_ACTION,this.actor=process.env.GITHUB_ACTOR,this.job=process.env.GITHUB_JOB,this.runAttempt=parseInt(process.env.GITHUB_RUN_ATTEMPT,10),this.runNumber=parseInt(process.env.GITHUB_RUN_NUMBER,10),this.runId=parseInt(process.env.GITHUB_RUN_ID,10),this.apiUrl=process.env.GITHUB_API_URL??`https://api.github.com`,this.serverUrl=process.env.GITHUB_SERVER_URL??`https://github.com`,this.graphqlUrl=process.env.GITHUB_GRAPHQL_URL??`https://api.github.com/graphql`}get issue(){let e=this.payload;return Object.assign(Object.assign({},this.repo),{number:(e.issue||e.pull_request||e).number})}get repo(){if(process.env.GITHUB_REPOSITORY){let[e,t]=process.env.GITHUB_REPOSITORY.split(`/`);return{owner:e,repo:t}}if(this.payload.repository)return{owner:this.payload.repository.owner.login,repo:this.payload.repository.name};throw Error(`context.repo requires a GITHUB_REPOSITORY environment variable like 'owner/repo'`)}},li=U((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getProxyUrl=t,e.checkBypass=n;function t(e){let t=e.protocol===`https:`;if(n(e))return;let r=t?process.env.https_proxy||process.env.HTTPS_PROXY:process.env.http_proxy||process.env.HTTP_PROXY;if(r)try{return new i(r)}catch{if(!r.startsWith(`http://`)&&!r.startsWith(`https://`))return new i(`http://${r}`)}else return}function n(e){if(!e.hostname)return!1;let t=e.hostname;if(r(t))return!0;let n=process.env.no_proxy||process.env.NO_PROXY||``;if(!n)return!1;let i;e.port?i=Number(e.port):e.protocol===`http:`?i=80:e.protocol===`https:`&&(i=443);let a=[e.hostname.toUpperCase()];typeof i==`number`&&a.push(`${a[0]}:${i}`);for(let e of n.split(`,`).map(e=>e.trim().toUpperCase()).filter(e=>e))if(e===`*`||a.some(t=>t===e||t.endsWith(`.${e}`)||e.startsWith(`.`)&&t.endsWith(`${e}`)))return!0;return!1}function r(e){let t=e.toLowerCase();return t===`localhost`||t.startsWith(`127.`)||t.startsWith(`[::1]`)||t.startsWith(`[0:0:0:0:0:0:0:1]`)}var i=class extends URL{constructor(e,t){super(e,t),this._decodedUsername=decodeURIComponent(super.username),this._decodedPassword=decodeURIComponent(super.password)}get username(){return this._decodedUsername}get password(){return this._decodedPassword}}})),ui=pe(U((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},e(t)};return function(r){if(r&&r.__esModule)return r;var i={};if(r!=null)for(var a=e(r),o=0;oi(this,void 0,void 0,function*(){let t=Buffer.alloc(0);this.message.on(`data`,e=>{t=Buffer.concat([t,e])}),this.message.on(`end`,()=>{e(t.toString())})}))})}readBodyBuffer(){return i(this,void 0,void 0,function*(){return new Promise(e=>i(this,void 0,void 0,function*(){let t=[];this.message.on(`data`,e=>{t.push(e)}),this.message.on(`end`,()=>{e(Buffer.concat(t))})}))})}};e.HttpClientResponse=y;function b(e){return new URL(e).protocol===`https:`}e.HttpClient=class{constructor(e,t,n){this._ignoreSslError=!1,this._allowRedirects=!0,this._allowRedirectDowngrade=!1,this._maxRedirects=50,this._allowRetries=!1,this._maxRetries=1,this._keepAlive=!1,this._disposed=!1,this.userAgent=this._getUserAgentWithOrchestrationId(e),this.handlers=t||[],this.requestOptions=n,n&&(n.ignoreSslError!=null&&(this._ignoreSslError=n.ignoreSslError),this._socketTimeout=n.socketTimeout,n.allowRedirects!=null&&(this._allowRedirects=n.allowRedirects),n.allowRedirectDowngrade!=null&&(this._allowRedirectDowngrade=n.allowRedirectDowngrade),n.maxRedirects!=null&&(this._maxRedirects=Math.max(n.maxRedirects,0)),n.keepAlive!=null&&(this._keepAlive=n.keepAlive),n.allowRetries!=null&&(this._allowRetries=n.allowRetries),n.maxRetries!=null&&(this._maxRetries=n.maxRetries))}options(e,t){return i(this,void 0,void 0,function*(){return this.request(`OPTIONS`,e,null,t||{})})}get(e,t){return i(this,void 0,void 0,function*(){return this.request(`GET`,e,null,t||{})})}del(e,t){return i(this,void 0,void 0,function*(){return this.request(`DELETE`,e,null,t||{})})}post(e,t,n){return i(this,void 0,void 0,function*(){return this.request(`POST`,e,t,n||{})})}patch(e,t,n){return i(this,void 0,void 0,function*(){return this.request(`PATCH`,e,t,n||{})})}put(e,t,n){return i(this,void 0,void 0,function*(){return this.request(`PUT`,e,t,n||{})})}head(e,t){return i(this,void 0,void 0,function*(){return this.request(`HEAD`,e,null,t||{})})}sendStream(e,t,n,r){return i(this,void 0,void 0,function*(){return this.request(e,t,n,r)})}getJson(e){return i(this,arguments,void 0,function*(e,t={}){t[d.Accept]=this._getExistingOrDefaultHeader(t,d.Accept,f.ApplicationJson);let n=yield this.get(e,t);return this._processResponse(n,this.requestOptions)})}postJson(e,t){return i(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[d.Accept]=this._getExistingOrDefaultHeader(n,d.Accept,f.ApplicationJson),n[d.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,f.ApplicationJson);let i=yield this.post(e,r,n);return this._processResponse(i,this.requestOptions)})}putJson(e,t){return i(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[d.Accept]=this._getExistingOrDefaultHeader(n,d.Accept,f.ApplicationJson),n[d.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,f.ApplicationJson);let i=yield this.put(e,r,n);return this._processResponse(i,this.requestOptions)})}patchJson(e,t){return i(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[d.Accept]=this._getExistingOrDefaultHeader(n,d.Accept,f.ApplicationJson),n[d.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,f.ApplicationJson);let i=yield this.patch(e,r,n);return this._processResponse(i,this.requestOptions)})}request(e,t,n,r){return i(this,void 0,void 0,function*(){if(this._disposed)throw Error(`Client has already been disposed.`);let i=new URL(t),a=this._prepareRequest(e,i,r),o=this._allowRetries&&g.includes(e)?this._maxRetries+1:1,s=0,c;do{if(c=yield this.requestRaw(a,n),c&&c.message&&c.message.statusCode===u.Unauthorized){let e;for(let t of this.handlers)if(t.canHandleAuthentication(c)){e=t;break}return e?e.handleAuthentication(this,a,n):c}let t=this._maxRedirects;for(;c.message.statusCode&&m.includes(c.message.statusCode)&&this._allowRedirects&&t>0;){let o=c.message.headers.location;if(!o)break;let s=new URL(o);if(i.protocol===`https:`&&i.protocol!==s.protocol&&!this._allowRedirectDowngrade)throw Error(`Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.`);if(yield c.readBody(),s.hostname!==i.hostname)for(let e in r)e.toLowerCase()===`authorization`&&delete r[e];a=this._prepareRequest(e,s,r),c=yield this.requestRaw(a,n),t--}if(!c.message.statusCode||!h.includes(c.message.statusCode))return c;s+=1,s{function i(e,t){e?r(e):t?n(t):r(Error(`Unknown error`))}this.requestRawWithCallback(e,t,i)})})}requestRawWithCallback(e,t,n){typeof t==`string`&&(e.options.headers||(e.options.headers={}),e.options.headers[`Content-Length`]=Buffer.byteLength(t,`utf8`));let r=!1;function i(e,t){r||(r=!0,n(e,t))}let a=e.httpModule.request(e.options,e=>{i(void 0,new y(e))}),o;a.on(`socket`,e=>{o=e}),a.setTimeout(this._socketTimeout||3*6e4,()=>{o&&o.end(),i(Error(`Request timeout: ${e.options.path}`))}),a.on(`error`,function(e){i(e)}),t&&typeof t==`string`&&a.write(t,`utf8`),t&&typeof t!=`string`?(t.on(`close`,function(){a.end()}),t.pipe(a)):a.end()}getAgent(e){let t=new URL(e);return this._getAgent(t)}getAgentDispatcher(e){let t=new URL(e),n=s.getProxyUrl(t);if(n&&n.hostname)return this._getProxyAgentDispatcher(t,n)}_prepareRequest(e,t,n){let r={};r.parsedUrl=t;let i=r.parsedUrl.protocol===`https:`;r.httpModule=i?o:a;let s=i?443:80;if(r.options={},r.options.host=r.parsedUrl.hostname,r.options.port=r.parsedUrl.port?parseInt(r.parsedUrl.port):s,r.options.path=(r.parsedUrl.pathname||``)+(r.parsedUrl.search||``),r.options.method=e,r.options.headers=this._mergeHeaders(n),this.userAgent!=null&&(r.options.headers[`user-agent`]=this.userAgent),r.options.agent=this._getAgent(r.parsedUrl),this.handlers)for(let e of this.handlers)e.prepareRequest(r.options);return r}_mergeHeaders(e){return this.requestOptions&&this.requestOptions.headers?Object.assign({},x(this.requestOptions.headers),x(e||{})):x(e||{})}_getExistingOrDefaultHeader(e,t,n){let r;if(this.requestOptions&&this.requestOptions.headers){let e=x(this.requestOptions.headers)[t];e&&(r=typeof e==`number`?e.toString():e)}let i=e[t];return i===void 0?r===void 0?n:r:typeof i==`number`?i.toString():i}_getExistingOrDefaultContentTypeHeader(e,t){let n;if(this.requestOptions&&this.requestOptions.headers){let e=x(this.requestOptions.headers)[d.ContentType];e&&(n=typeof e==`number`?String(e):Array.isArray(e)?e.join(`, `):e)}let r=e[d.ContentType];return r===void 0?n===void 0?t:n:typeof r==`number`?String(r):Array.isArray(r)?r.join(`, `):r}_getAgent(e){let t,n=s.getProxyUrl(e),r=n&&n.hostname;if(this._keepAlive&&r&&(t=this._proxyAgent),r||(t=this._agent),t)return t;let i=e.protocol===`https:`,l=100;if(this.requestOptions&&(l=this.requestOptions.maxSockets||a.globalAgent.maxSockets),n&&n.hostname){let e={maxSockets:l,keepAlive:this._keepAlive,proxy:Object.assign(Object.assign({},(n.username||n.password)&&{proxyAuth:`${n.username}:${n.password}`}),{host:n.hostname,port:n.port})},r,a=n.protocol===`https:`;r=i?a?c.httpsOverHttps:c.httpsOverHttp:a?c.httpOverHttps:c.httpOverHttp,t=r(e),this._proxyAgent=t}if(!t){let e={keepAlive:this._keepAlive,maxSockets:l};t=i?new o.Agent(e):new a.Agent(e),this._agent=t}return i&&this._ignoreSslError&&(t.options=Object.assign(t.options||{},{rejectUnauthorized:!1})),t}_getProxyAgentDispatcher(e,t){let n;if(this._keepAlive&&(n=this._proxyAgentDispatcher),n)return n;let r=e.protocol===`https:`;return n=new l.ProxyAgent(Object.assign({uri:t.href,pipelining:this._keepAlive?1:0},(t.username||t.password)&&{token:`Basic ${Buffer.from(`${t.username}:${t.password}`).toString(`base64`)}`})),this._proxyAgentDispatcher=n,r&&this._ignoreSslError&&(n.options=Object.assign(n.options.requestTls||{},{rejectUnauthorized:!1})),n}_getUserAgentWithOrchestrationId(e){let t=e||`actions/http-client`,n=process.env.ACTIONS_ORCHESTRATION_ID;return n?`${t} actions_orchestration_id/${n.replace(/[^a-z0-9_.-]/gi,`_`)}`:t}_performExponentialBackoff(e){return i(this,void 0,void 0,function*(){e=Math.min(10,e);let t=5*2**e;return new Promise(e=>setTimeout(()=>e(),t))})}_processResponse(e,t){return i(this,void 0,void 0,function*(){return new Promise((n,r)=>i(this,void 0,void 0,function*(){let i=e.message.statusCode||0,a={statusCode:i,result:null,headers:{}};i===u.NotFound&&n(a);function o(e,t){if(typeof t==`string`){let e=new Date(t);if(!isNaN(e.valueOf()))return e}return t}let s,c;try{c=yield e.readBody(),c&&c.length>0&&(s=t&&t.deserializeDates?JSON.parse(c,o):JSON.parse(c),a.result=s),a.headers=e.message.headers}catch{}if(i>299){let e;e=s&&s.message?s.message:c&&c.length>0?c:`Failed request: (${i})`;let t=new v(e,i);t.result=a.result,r(t)}else n(a)}))})}};let x=e=>Object.keys(e).reduce((t,n)=>(t[n.toLowerCase()]=e[n],t),{})}))(),1),di=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function fi(e,t){if(!e&&!t.auth)throw Error(`Parameter token or opts.auth is required`);if(e&&t.auth)throw Error(`Parameters token and opts.auth may not both be specified`);return typeof t.auth==`string`?t.auth:`token ${e}`}function pi(e){return new ui.HttpClient().getAgent(e)}function mi(e){return new ui.HttpClient().getAgentDispatcher(e)}function hi(e){let t=mi(e);return(e,n)=>di(this,void 0,void 0,function*(){return(0,vn.fetch)(e,Object.assign(Object.assign({},n),{dispatcher:t}))})}function gi(){return process.env.GITHUB_API_URL||`https://api.github.com`}function _i(){return typeof navigator==`object`&&`userAgent`in navigator?navigator.userAgent:typeof process==`object`&&process.version!==void 0?`Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`:``}function vi(e,t,n,r){if(typeof n!=`function`)throw Error(`method for before hook must be a function`);return r||={},Array.isArray(t)?t.reverse().reduce((t,n)=>vi.bind(null,e,n,t,r),n)():Promise.resolve().then(()=>e.registry[t]?e.registry[t].reduce((e,t)=>t.hook.bind(null,e,r),n)():n(r))}function yi(e,t,n,r){let i=r;e.registry[n]||(e.registry[n]=[]),t===`before`&&(r=(e,t)=>Promise.resolve().then(i.bind(null,t)).then(e.bind(null,t))),t===`after`&&(r=(e,t)=>{let n;return Promise.resolve().then(e.bind(null,t)).then(e=>(n=e,i(n,t))).then(()=>n)}),t===`error`&&(r=(e,t)=>Promise.resolve().then(e.bind(null,t)).catch(e=>i(e,t))),e.registry[n].push({hook:r,orig:i})}function bi(e,t,n){if(!e.registry[t])return;let r=e.registry[t].map(e=>e.orig).indexOf(n);r!==-1&&e.registry[t].splice(r,1)}const xi=Function.bind,Si=xi.bind(xi);function Ci(e,t,n){let r=Si(bi,null).apply(null,n?[t,n]:[t]);e.api={remove:r},e.remove=r,[`before`,`error`,`after`,`wrap`].forEach(r=>{let i=n?[t,r,n]:[t,r];e[r]=e.api[r]=Si(yi,null).apply(null,i)})}function wi(){let e=Symbol(`Singular`),t={registry:{}},n=vi.bind(null,t,e);return Ci(n,t,e),n}function Ti(){let e={registry:{}},t=vi.bind(null,e);return Ci(t,e),t}var Ei={Singular:wi,Collection:Ti},Di=`octokit-endpoint.js/0.0.0-development ${_i()}`,Oi={method:`GET`,baseUrl:`https://api.github.com`,headers:{accept:`application/vnd.github.v3+json`,"user-agent":Di},mediaType:{format:``}};function ki(e){return e?Object.keys(e).reduce((t,n)=>(t[n.toLowerCase()]=e[n],t),{}):{}}function Ai(e){if(typeof e!=`object`||!e||Object.prototype.toString.call(e)!==`[object Object]`)return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let n=Object.prototype.hasOwnProperty.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&Function.prototype.call(n)===Function.prototype.call(e)}function ji(e,t){let n=Object.assign({},e);return Object.keys(t).forEach(r=>{Ai(t[r])&&r in e?n[r]=ji(e[r],t[r]):Object.assign(n,{[r]:t[r]})}),n}function Mi(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function Ni(e,t,n){if(typeof t==`string`){let[e,r]=t.split(` `);n=Object.assign(r?{method:e,url:r}:{url:e},n)}else n=Object.assign({},t);n.headers=ki(n.headers),Mi(n),Mi(n.headers);let r=ji(e||{},n);return n.url===`/graphql`&&(e&&e.mediaType.previews?.length&&(r.mediaType.previews=e.mediaType.previews.filter(e=>!r.mediaType.previews.includes(e)).concat(r.mediaType.previews)),r.mediaType.previews=(r.mediaType.previews||[]).map(e=>e.replace(/-preview/,``))),r}function Pi(e,t){let n=/\?/.test(e)?`&`:`?`,r=Object.keys(t);return r.length===0?e:e+n+r.map(e=>e===`q`?`q=`+t.q.split(`+`).map(encodeURIComponent).join(`+`):`${e}=${encodeURIComponent(t[e])}`).join(`&`)}var Fi=/\{[^{}}]+\}/g;function Ii(e){return e.replace(/(?:^\W+)|(?:(?e.concat(t),[]):[]}function Ri(e,t){let n={__proto__:null};for(let r of Object.keys(e))t.indexOf(r)===-1&&(n[r]=e[r]);return n}function zi(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(e){return/%[0-9A-Fa-f]/.test(e)||(e=encodeURI(e).replace(/%5B/g,`[`).replace(/%5D/g,`]`)),e}).join(``)}function Bi(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return`%`+e.charCodeAt(0).toString(16).toUpperCase()})}function Vi(e,t,n){return t=e===`+`||e===`#`?zi(t):Bi(t),n?Bi(n)+`=`+t:t}function Hi(e){return e!=null}function Ui(e){return e===`;`||e===`&`||e===`?`}function Wi(e,t,n,r){var i=e[n],a=[];if(Hi(i)&&i!==``)if(typeof i==`string`||typeof i==`number`||typeof i==`bigint`||typeof i==`boolean`)i=i.toString(),r&&r!==`*`&&(i=i.substring(0,parseInt(r,10))),a.push(Vi(t,i,Ui(t)?n:``));else if(r===`*`)Array.isArray(i)?i.filter(Hi).forEach(function(e){a.push(Vi(t,e,Ui(t)?n:``))}):Object.keys(i).forEach(function(e){Hi(i[e])&&a.push(Vi(t,i[e],e))});else{let e=[];Array.isArray(i)?i.filter(Hi).forEach(function(n){e.push(Vi(t,n))}):Object.keys(i).forEach(function(n){Hi(i[n])&&(e.push(Bi(n)),e.push(Vi(t,i[n].toString())))}),Ui(t)?a.push(Bi(n)+`=`+e.join(`,`)):e.length!==0&&a.push(e.join(`,`))}else t===`;`?Hi(i)&&a.push(Bi(n)):i===``&&(t===`&`||t===`?`)?a.push(Bi(n)+`=`):i===``&&a.push(``);return a}function Gi(e){return{expand:Ki.bind(null,e)}}function Ki(e,t){var n=[`+`,`#`,`.`,`/`,`;`,`?`,`&`];return e=e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(e,r,i){if(r){let e=``,i=[];if(n.indexOf(r.charAt(0))!==-1&&(e=r.charAt(0),r=r.substr(1)),r.split(/,/g).forEach(function(n){var r=/([^:\*]*)(?::(\d+)|(\*))?/.exec(n);i.push(Wi(t,e,r[1],r[2]||r[3]))}),e&&e!==`+`){var a=`,`;return e===`?`?a=`&`:e!==`#`&&(a=e),(i.length===0?``:e)+i.join(a)}else return i.join(`,`)}else return zi(i)}),e===`/`?e:e.replace(/\/$/,``)}function qi(e){let t=e.method.toUpperCase(),n=(e.url||`/`).replace(/:([a-z]\w+)/g,`{$1}`),r=Object.assign({},e.headers),i,a=Ri(e,[`method`,`baseUrl`,`url`,`headers`,`request`,`mediaType`]),o=Li(n);n=Gi(n).expand(a),/^http/.test(n)||(n=e.baseUrl+n);let s=Ri(a,Object.keys(e).filter(e=>o.includes(e)).concat(`baseUrl`));return/application\/octet-stream/i.test(r.accept)||(e.mediaType.format&&(r.accept=r.accept.split(/,/).map(t=>t.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,`application/vnd$1$2.${e.mediaType.format}`)).join(`,`)),n.endsWith(`/graphql`)&&e.mediaType.previews?.length&&(r.accept=(r.accept.match(/(?`application/vnd.github.${t}-preview${e.mediaType.format?`.${e.mediaType.format}`:`+json`}`).join(`,`))),[`GET`,`HEAD`].includes(t)?n=Pi(n,s):`data`in s?i=s.data:Object.keys(s).length&&(i=s),!r[`content-type`]&&i!==void 0&&(r[`content-type`]=`application/json; charset=utf-8`),[`PATCH`,`PUT`].includes(t)&&i===void 0&&(i=``),Object.assign({method:t,url:n,headers:r},i===void 0?null:{body:i},e.request?{request:e.request}:null)}function Ji(e,t,n){return qi(Ni(e,t,n))}function Yi(e,t){let n=Ni(e,t),r=Ji.bind(null,n);return Object.assign(r,{DEFAULTS:n,defaults:Yi.bind(null,n),merge:Ni.bind(null,n),parse:qi})}var Xi=Yi(null,Oi),Zi=U(((e,t)=>{let n=function(){};n.prototype=Object.create(null);let r=/; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu,i=/\\([\v\u0020-\u00ff])/gu,a=/^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u,o={type:``,parameters:new n};Object.freeze(o.parameters),Object.freeze(o);function s(e){if(typeof e!=`string`)throw TypeError(`argument header is required and must be a string`);let t=e.indexOf(`;`),o=t===-1?e.trim():e.slice(0,t).trim();if(a.test(o)===!1)throw TypeError(`invalid media type`);let s={type:o.toLowerCase(),parameters:new n};if(t===-1)return s;let c,l,u;for(r.lastIndex=t;l=r.exec(e);){if(l.index!==t)throw TypeError(`invalid parameter format`);t+=l[0].length,c=l[1].toLowerCase(),u=l[2],u[0]===`"`&&(u=u.slice(1,u.length-1),i.test(u)&&(u=u.replace(i,`$1`))),s.parameters[c]=u}if(t!==e.length)throw TypeError(`invalid parameter format`);return s}function c(e){if(typeof e!=`string`)return o;let t=e.indexOf(`;`),s=t===-1?e.trim():e.slice(0,t).trim();if(a.test(s)===!1)return o;let c={type:s.toLowerCase(),parameters:new n};if(t===-1)return c;let l,u,d;for(r.lastIndex=t;u=r.exec(e);){if(u.index!==t)return o;t+=u[0].length,l=u[1].toLowerCase(),d=u[2],d[0]===`"`&&(d=d.slice(1,d.length-1),i.test(d)&&(d=d.replace(i,`$1`))),c.parameters[l]=d}return t===e.length?c:o}t.exports.default={parse:s,safeParse:c},t.exports.parse=s,t.exports.safeParse=c,t.exports.defaultContentType=o}));const Qi=/^-?\d+$/,$i=/^-?\d+n+$/,ea=JSON.stringify,ta=JSON.parse,na=/^-?\d+n$/,ra=/([\[:])?"(-?\d+)n"($|([\\n]|\s)*(\s|[\\n])*[,\}\]])/g,ia=/([\[:])?("-?\d+n+)n("$|"([\\n]|\s)*(\s|[\\n])*[,\}\]])/g,aa=(e,t,n)=>`rawJSON`in JSON?ea(e,(e,n)=>typeof n==`bigint`?JSON.rawJSON(n.toString()):typeof t==`function`?t(e,n):(Array.isArray(t)&&t.includes(e),n),n):e?ea(e,(e,n)=>typeof n==`string`&&n.match($i)||typeof n==`bigint`?n.toString()+`n`:typeof t==`function`?t(e,n):(Array.isArray(t)&&t.includes(e),n),n).replace(ra,`$1$2$3`).replace(ia,`$1$2$3`):ea(e,t,n),oa=()=>JSON.parse(`1`,(e,t,n)=>!!n&&n.source===`1`),sa=(e,t,n,r)=>typeof t==`string`&&t.match(na)?BigInt(t.slice(0,-1)):typeof t==`string`&&t.match($i)?t.slice(0,-1):typeof r==`function`?r(e,t,n):t,ca=(e,t)=>JSON.parse(e,(e,n,r)=>{let i=typeof n==`number`&&(n>2**53-1||n<-(2**53-1)),a=r&&Qi.test(r.source);return i&&a?BigInt(r.source):typeof t==`function`?t(e,n,r):n}),la=(2**53-1).toString(),ua=la.length,da=/"(?:\\.|[^"])*"|-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?/g,fa=/^"-?\d+n+"$/,pa=(e,t)=>e?oa()?ca(e,t):ta(e.replace(da,(e,t,n,r)=>{let i=e[0]===`"`;if(i&&e.match(fa))return e.substring(0,e.length-1)+`n"`;let a=n||r,o=t&&(t.lengthsa(e,n,r,t)):ta(e,t);var ma=class extends Error{name;status;request;response;constructor(e,t,n){super(e,{cause:n.cause}),this.name=`HttpError`,this.status=Number.parseInt(t),Number.isNaN(this.status)&&(this.status=0),`response`in n&&(this.response=n.response);let r=Object.assign({},n.request);n.request.headers.authorization&&(r.headers=Object.assign({},n.request.headers,{authorization:n.request.headers.authorization.replace(/(?``;async function ba(e){let t=e.request?.fetch||globalThis.fetch;if(!t)throw Error(`fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing`);let n=e.request?.log||console,r=e.request?.parseSuccessResponseBody!==!1,i=va(e.body)||Array.isArray(e.body)?aa(e.body):e.body,a=Object.fromEntries(Object.entries(e.headers).map(([e,t])=>[e,String(t)])),o;try{o=await t(e.url,{method:e.method,body:i,redirect:e.request?.redirect,headers:a,signal:e.request?.signal,...e.body&&{duplex:`half`}})}catch(t){let n=`Unknown Error`;if(t instanceof Error){if(t.name===`AbortError`)throw t.status=500,t;n=t.message,t.name===`TypeError`&&`cause`in t&&(t.cause instanceof Error?n=t.cause.message:typeof t.cause==`string`&&(n=t.cause))}let r=new ma(n,500,{request:e});throw r.cause=t,r}let s=o.status,c=o.url,l={};for(let[e,t]of o.headers)l[e]=t;let u={url:c,status:s,headers:l,data:``};if(`deprecation`in l){let t=l.link&&l.link.match(/<([^<>]+)>; rel="deprecation"/),r=t&&t.pop();n.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${l.sunset}${r?`. See ${r}`:``}`)}if(s===204||s===205)return u;if(e.method===`HEAD`){if(s<400)return u;throw new ma(o.statusText,s,{response:u,request:e})}if(s===304)throw u.data=await xa(o),new ma(`Not modified`,s,{response:u,request:e});if(s>=400)throw u.data=await xa(o),new ma(Ca(u.data),s,{response:u,request:e});return u.data=r?await xa(o):o.body,u}async function xa(e){let t=e.headers.get(`content-type`);if(!t)return e.text().catch(ya);let n=(0,ha.safeParse)(t);if(Sa(n)){let t=``;try{return t=await e.text(),pa(t)}catch{return t}}else if(n.type.startsWith(`text/`)||n.parameters.charset?.toLowerCase()===`utf-8`)return e.text().catch(ya);else return e.arrayBuffer().catch(()=>new ArrayBuffer(0))}function Sa(e){return e.type===`application/json`||e.type===`application/scim+json`}function Ca(e){if(typeof e==`string`)return e;if(e instanceof ArrayBuffer)return`Unknown error`;if(`message`in e){let t=`documentation_url`in e?` - ${e.documentation_url}`:``;return Array.isArray(e.errors)?`${e.message}: ${e.errors.map(e=>JSON.stringify(e)).join(`, `)}${t}`:`${e.message}${t}`}return`Unknown error: ${JSON.stringify(e)}`}function wa(e,t){let n=e.defaults(t);return Object.assign(function(e,t){let r=n.merge(e,t);if(!r.request||!r.request.hook)return ba(n.parse(r));let i=(e,t)=>ba(n.parse(n.merge(e,t)));return Object.assign(i,{endpoint:n,defaults:wa.bind(null,n)}),r.request.hook(i,r)},{endpoint:n,defaults:wa.bind(null,n)})}var Ta=wa(Xi,_a),Ea=`0.0.0-development`;function Da(e){return`Request failed due to following response errors: +`.trim())}}})),Mt=U(((e,t)=>{let n=Symbol.for(`undici.globalDispatcher.1`),{InvalidArgumentError:r}=ke(),i=lt();o()===void 0&&a(new i);function a(e){if(!e||typeof e.dispatch!=`function`)throw new r(`Argument agent must implement Agent`);Object.defineProperty(globalThis,n,{value:e,writable:!0,enumerable:!1,configurable:!1})}function o(){return globalThis[n]}t.exports={setGlobalDispatcher:a,getGlobalDispatcher:o}})),Nt=U(((e,t)=>{t.exports=class{#e;constructor(e){if(typeof e!=`object`||!e)throw TypeError(`handler must be an object`);this.#e=e}onConnect(...e){return this.#e.onConnect?.(...e)}onError(...e){return this.#e.onError?.(...e)}onUpgrade(...e){return this.#e.onUpgrade?.(...e)}onResponseStarted(...e){return this.#e.onResponseStarted?.(...e)}onHeaders(...e){return this.#e.onHeaders?.(...e)}onData(...e){return this.#e.onData?.(...e)}onComplete(...e){return this.#e.onComplete?.(...e)}onBodySent(...e){return this.#e.onBodySent?.(...e)}}})),Pt=U(((e,t)=>{let n=tt();t.exports=e=>{let t=e?.maxRedirections;return e=>function(r,i){let{maxRedirections:a=t,...o}=r;return a?e(o,new n(e,a,r,i)):e(r,i)}}})),Ft=U(((e,t)=>{let n=ft();t.exports=e=>t=>function(r,i){return t(r,new n({...r,retryOptions:{...e,...r.retryOptions}},{handler:i,dispatch:t}))}})),It=U(((e,t)=>{let n=Me(),{InvalidArgumentError:r,RequestAbortedError:i}=ke(),a=Nt();var o=class extends a{#e=1024*1024;#t=null;#n=!1;#r=!1;#i=0;#a=null;#o=null;constructor({maxSize:e},t){if(super(t),e!=null&&(!Number.isFinite(e)||e<1))throw new r(`maxSize must be a number greater than 0`);this.#e=e??this.#e,this.#o=t}onConnect(e){this.#t=e,this.#o.onConnect(this.#s.bind(this))}#s(e){this.#r=!0,this.#a=e}onHeaders(e,t,r,a){let o=n.parseHeaders(t)[`content-length`];if(o!=null&&o>this.#e)throw new i(`Response size (${o}) larger than maxSize (${this.#e})`);return this.#r?!0:this.#o.onHeaders(e,t,r,a)}onError(e){this.#n||(e=this.#a??e,this.#o.onError(e))}onData(e){return this.#i+=e.length,this.#i>=this.#e&&(this.#n=!0,this.#r?this.#o.onError(this.#a):this.#o.onComplete([])),!0}onComplete(e){if(!this.#n){if(this.#r){this.#o.onError(this.reason);return}this.#o.onComplete(e)}}};function s({maxSize:e}={maxSize:1024*1024}){return t=>function(n,r){let{dumpMaxSize:i=e}=n;return t(n,new o({maxSize:i},r))}}t.exports=s})),Lt=U(((e,t)=>{let{isIP:n}=W(`node:net`),{lookup:r}=W(`node:dns`),i=Nt(),{InvalidArgumentError:a,InformationalError:o}=ke(),s=2**31-1;var c=class{#e=0;#t=0;#n=new Map;dualStack=!0;affinity=null;lookup=null;pick=null;constructor(e){this.#e=e.maxTTL,this.#t=e.maxItems,this.dualStack=e.dualStack,this.affinity=e.affinity,this.lookup=e.lookup??this.#r,this.pick=e.pick??this.#i}get full(){return this.#n.size===this.#t}runLookup(e,t,n){let r=this.#n.get(e.hostname);if(r==null&&this.full){n(null,e.origin);return}let i={affinity:this.affinity,dualStack:this.dualStack,lookup:this.lookup,pick:this.pick,...t.dns,maxTTL:this.#e,maxItems:this.#t};if(r==null)this.lookup(e,i,(t,r)=>{if(t||r==null||r.length===0){n(t??new o(`No DNS entries found`));return}this.setRecords(e,r);let a=this.#n.get(e.hostname),s=this.pick(e,a,i.affinity),c;c=typeof s.port==`number`?`:${s.port}`:e.port===``?``:`:${e.port}`,n(null,`${e.protocol}//${s.family===6?`[${s.address}]`:s.address}${c}`)});else{let a=this.pick(e,r,i.affinity);if(a==null){this.#n.delete(e.hostname),this.runLookup(e,t,n);return}let o;o=typeof a.port==`number`?`:${a.port}`:e.port===``?``:`:${e.port}`,n(null,`${e.protocol}//${a.family===6?`[${a.address}]`:a.address}${o}`)}}#r(e,t,n){r(e.hostname,{all:!0,family:this.dualStack===!1?this.affinity:0,order:`ipv4first`},(e,t)=>{if(e)return n(e);let r=new Map;for(let e of t)r.set(`${e.address}:${e.family}`,e);n(null,r.values())})}#i(e,t,n){let r=null,{records:i,offset:a}=t,o;if(this.dualStack?(n??(a==null||a===s?(t.offset=0,n=4):(t.offset++,n=(t.offset&1)==1?6:4)),o=i[n]!=null&&i[n].ips.length>0?i[n]:i[n===4?6:4]):o=i[n],o==null||o.ips.length===0)return r;o.offset==null||o.offset===s?o.offset=0:o.offset++;let c=o.offset%o.ips.length;return r=o.ips[c]??null,r==null?r:Date.now()-r.timestamp>r.ttl?(o.ips.splice(c,1),this.pick(e,t,n)):r}setRecords(e,t){let n=Date.now(),r={records:{4:null,6:null}};for(let e of t){e.timestamp=n,typeof e.ttl==`number`?e.ttl=Math.min(e.ttl,this.#e):e.ttl=this.#e;let t=r.records[e.family]??{ips:[]};t.ips.push(e),r.records[e.family]=t}this.#n.set(e.hostname,r)}getHandler(e,t){return new l(this,e,t)}},l=class extends i{#e=null;#t=null;#n=null;#r=null;#i=null;constructor(e,{origin:t,handler:n,dispatch:r},i){super(n),this.#i=t,this.#r=n,this.#t={...i},this.#e=e,this.#n=r}onError(e){switch(e.code){case`ETIMEDOUT`:case`ECONNREFUSED`:if(this.#e.dualStack){this.#e.runLookup(this.#i,this.#t,(e,t)=>{if(e)return this.#r.onError(e);let n={...this.#t,origin:t};this.#n(n,this)});return}this.#r.onError(e);return;case`ENOTFOUND`:this.#e.deleteRecord(this.#i);default:this.#r.onError(e);break}}};t.exports=e=>{if(e?.maxTTL!=null&&(typeof e?.maxTTL!=`number`||e?.maxTTL<0))throw new a(`Invalid maxTTL. Must be a positive number`);if(e?.maxItems!=null&&(typeof e?.maxItems!=`number`||e?.maxItems<1))throw new a(`Invalid maxItems. Must be a positive number and greater than zero`);if(e?.affinity!=null&&e?.affinity!==4&&e?.affinity!==6)throw new a(`Invalid affinity. Must be either 4 or 6`);if(e?.dualStack!=null&&typeof e?.dualStack!=`boolean`)throw new a(`Invalid dualStack. Must be a boolean`);if(e?.lookup!=null&&typeof e?.lookup!=`function`)throw new a(`Invalid lookup. Must be a function`);if(e?.pick!=null&&typeof e?.pick!=`function`)throw new a(`Invalid pick. Must be a function`);let t=e?.dualStack??!0,r;r=t?e?.affinity??null:e?.affinity??4;let i=new c({maxTTL:e?.maxTTL??1e4,lookup:e?.lookup??null,pick:e?.pick??null,dualStack:t,affinity:r,maxItems:e?.maxItems??1/0});return e=>function(t,r){let a=t.origin.constructor===URL?t.origin:new URL(t.origin);return n(a.hostname)===0?(i.runLookup(a,t,(n,o)=>{if(n)return r.onError(n);let s=null;s={...t,servername:a.hostname,origin:o,headers:{host:a.hostname,...t.headers}},e(s,i.getHandler({origin:a,dispatch:e,handler:r},t))}),!0):e(t,r)}}})),Rt=U(((e,t)=>{let{kConstruct:n}=Oe(),{kEnumerableProperty:r}=Me(),{iteratorMixin:i,isValidHeaderName:a,isValidHeaderValue:o}=qe(),{webidl:s}=Ke(),c=W(`node:assert`),l=W(`node:util`),u=Symbol(`headers map`),d=Symbol(`headers map sorted`);function f(e){return e===10||e===13||e===9||e===32}function p(e){let t=0,n=e.length;for(;n>t&&f(e.charCodeAt(n-1));)--n;for(;n>t&&f(e.charCodeAt(t));)++t;return t===0&&n===e.length?e:e.substring(t,n)}function m(e,t){if(Array.isArray(t))for(let n=0;n>`,`record`]})}function h(e,t,n){if(n=p(n),!a(t))throw s.errors.invalidArgument({prefix:`Headers.append`,value:t,type:`header name`});if(!o(n))throw s.errors.invalidArgument({prefix:`Headers.append`,value:n,type:`header value`});if(b(e)===`immutable`)throw TypeError(`immutable`);return S(e).append(t,n,!1)}function g(e,t){return e[0]>1),t[s][0]<=l[0]?o=s+1:a=s;if(r!==s){for(i=r;i>o;)t[i]=t[--i];t[o]=l}}if(!n.next().done)throw TypeError(`Unreachable`);return t}else{let e=0;for(let{0:n,1:{value:r}}of this[u])t[e++]=[n,r],c(r!==null);return t.sort(g)}}},y=class e{#e;#t;constructor(e=void 0){s.util.markAsUncloneable(this),e!==n&&(this.#t=new v,this.#e=`none`,e!==void 0&&(e=s.converters.HeadersInit(e,`Headers contructor`,`init`),m(this,e)))}append(t,n){s.brandCheck(this,e),s.argumentLengthCheck(arguments,2,`Headers.append`);let r=`Headers.append`;return t=s.converters.ByteString(t,r,`name`),n=s.converters.ByteString(n,r,`value`),h(this,t,n)}delete(t){if(s.brandCheck(this,e),s.argumentLengthCheck(arguments,1,`Headers.delete`),t=s.converters.ByteString(t,`Headers.delete`,`name`),!a(t))throw s.errors.invalidArgument({prefix:`Headers.delete`,value:t,type:`header name`});if(this.#e===`immutable`)throw TypeError(`immutable`);this.#t.contains(t,!1)&&this.#t.delete(t,!1)}get(t){s.brandCheck(this,e),s.argumentLengthCheck(arguments,1,`Headers.get`);let n=`Headers.get`;if(t=s.converters.ByteString(t,n,`name`),!a(t))throw s.errors.invalidArgument({prefix:n,value:t,type:`header name`});return this.#t.get(t,!1)}has(t){s.brandCheck(this,e),s.argumentLengthCheck(arguments,1,`Headers.has`);let n=`Headers.has`;if(t=s.converters.ByteString(t,n,`name`),!a(t))throw s.errors.invalidArgument({prefix:n,value:t,type:`header name`});return this.#t.contains(t,!1)}set(t,n){s.brandCheck(this,e),s.argumentLengthCheck(arguments,2,`Headers.set`);let r=`Headers.set`;if(t=s.converters.ByteString(t,r,`name`),n=s.converters.ByteString(n,r,`value`),n=p(n),!a(t))throw s.errors.invalidArgument({prefix:r,value:t,type:`header name`});if(!o(n))throw s.errors.invalidArgument({prefix:r,value:n,type:`header value`});if(this.#e===`immutable`)throw TypeError(`immutable`);this.#t.set(t,n,!1)}getSetCookie(){s.brandCheck(this,e);let t=this.#t.cookies;return t?[...t]:[]}get[d](){if(this.#t[d])return this.#t[d];let e=[],t=this.#t.toSortedArray(),n=this.#t.cookies;if(n===null||n.length===1)return this.#t[d]=t;for(let r=0;r>`](e,t,n,r.bind(e)):s.converters[`record`](e,t,n)}throw s.errors.conversionFailed({prefix:`Headers constructor`,argument:`Argument 1`,types:[`sequence>`,`record`]})},t.exports={fill:m,compareHeaderName:g,Headers:y,HeadersList:v,getHeadersGuard:b,setHeadersGuard:x,setHeadersList:C,getHeadersList:S}})),zt=U(((e,t)=>{let{Headers:n,HeadersList:r,fill:i,getHeadersGuard:a,setHeadersGuard:o,setHeadersList:s}=Rt(),{extractBody:c,cloneBody:l,mixinBody:u,hasFinalizationRegistry:d,streamRegistry:f,bodyUnusable:p}=Qe(),m=Me(),h=W(`node:util`),{kEnumerableProperty:g}=m,{isValidReasonPhrase:v,isCancelled:y,isAborted:b,isBlobLike:x,serializeJavascriptValueToJSONString:S,isErrorLike:C,isomorphicEncode:w,environmentSettingsObject:T}=qe(),{redirectStatusSet:E,nullBodyStatus:D}=Ue(),{kState:O,kHeaders:k}=Je(),{webidl:A}=Ke(),{FormData:j}=Xe(),{URLSerializer:M}=Ge(),{kConstruct:N}=Oe(),P=W(`node:assert`),{types:F}=W(`node:util`),I=new TextEncoder(`utf-8`);var L=class e{static error(){return re(ee(),`immutable`)}static json(e,t={}){A.argumentLengthCheck(arguments,1,`Response.json`),t!==null&&(t=A.converters.ResponseInit(t));let n=c(I.encode(S(e))),r=re(z({}),`response`);return H(r,t,{body:n[0],type:`application/json`}),r}static redirect(e,t=302){A.argumentLengthCheck(arguments,1,`Response.redirect`),e=A.converters.USVString(e),t=A.converters[`unsigned short`](t);let n;try{n=new URL(e,T.settingsObject.baseUrl)}catch(t){throw TypeError(`Failed to parse URL from ${e}`,{cause:t})}if(!E.has(t))throw RangeError(`Invalid status code ${t}`);let r=re(z({}),`immutable`);r[O].status=t;let i=w(M(n));return r[O].headersList.append(`location`,i,!0),r}constructor(e=null,t={}){if(A.util.markAsUncloneable(this),e===N)return;e!==null&&(e=A.converters.BodyInit(e)),t=A.converters.ResponseInit(t),this[O]=z({}),this[k]=new n(N),o(this[k],`response`),s(this[k],this[O].headersList);let r=null;if(e!=null){let[t,n]=c(e);r={body:t,type:n}}H(this,t,r)}get type(){return A.brandCheck(this,e),this[O].type}get url(){A.brandCheck(this,e);let t=this[O].urlList,n=t[t.length-1]??null;return n===null?``:M(n,!0)}get redirected(){return A.brandCheck(this,e),this[O].urlList.length>1}get status(){return A.brandCheck(this,e),this[O].status}get ok(){return A.brandCheck(this,e),this[O].status>=200&&this[O].status<=299}get statusText(){return A.brandCheck(this,e),this[O].statusText}get headers(){return A.brandCheck(this,e),this[k]}get body(){return A.brandCheck(this,e),this[O].body?this[O].body.stream:null}get bodyUsed(){return A.brandCheck(this,e),!!this[O].body&&m.isDisturbed(this[O].body.stream)}clone(){if(A.brandCheck(this,e),p(this))throw A.errors.exception({header:`Response.clone`,message:`Body has already been consumed.`});let t=R(this[O]);return d&&this[O].body?.stream&&f.register(this,new WeakRef(this[O].body.stream)),re(t,a(this[k]))}[h.inspect.custom](e,t){t.depth===null&&(t.depth=2),t.colors??=!0;let n={status:this.status,statusText:this.statusText,headers:this.headers,body:this.body,bodyUsed:this.bodyUsed,ok:this.ok,redirected:this.redirected,type:this.type,url:this.url};return`Response ${h.formatWithOptions(t,n)}`}};u(L),Object.defineProperties(L.prototype,{type:g,url:g,status:g,ok:g,redirected:g,statusText:g,headers:g,clone:g,body:g,bodyUsed:g,[Symbol.toStringTag]:{value:`Response`,configurable:!0}}),Object.defineProperties(L,{json:g,redirect:g,error:g});function R(e){if(e.internalResponse)return V(R(e.internalResponse),e.type);let t=z({...e,body:null});return e.body!=null&&(t.body=l(t,e.body)),t}function z(e){return{aborted:!1,rangeRequested:!1,timingAllowPassed:!1,requestIncludesCredentials:!1,type:`default`,status:200,timingInfo:null,cacheState:``,statusText:``,...e,headersList:e?.headersList?new r(e?.headersList):new r,urlList:e?.urlList?[...e.urlList]:[]}}function ee(e){return z({type:`error`,status:0,error:C(e)?e:Error(e&&String(e)),aborted:e&&e.name===`AbortError`})}function B(e){return e.type===`error`&&e.status===0}function te(e,t){return t={internalResponse:e,...t},new Proxy(e,{get(e,n){return n in t?t[n]:e[n]},set(e,n,r){return P(!(n in t)),e[n]=r,!0}})}function V(e,t){if(t===`basic`)return te(e,{type:`basic`,headersList:e.headersList});if(t===`cors`)return te(e,{type:`cors`,headersList:e.headersList});if(t===`opaque`)return te(e,{type:`opaque`,urlList:Object.freeze([]),status:0,statusText:``,body:null});if(t===`opaqueredirect`)return te(e,{type:`opaqueredirect`,status:0,statusText:``,headersList:[],body:null});P(!1)}function ne(e,t=null){return P(y(e)),b(e)?ee(Object.assign(new DOMException(`The operation was aborted.`,`AbortError`),{cause:t})):ee(Object.assign(new DOMException(`Request was cancelled.`),{cause:t}))}function H(e,t,n){if(t.status!==null&&(t.status<200||t.status>599))throw RangeError(`init["status"] must be in the range of 200 to 599, inclusive.`);if(`statusText`in t&&t.statusText!=null&&!v(String(t.statusText)))throw TypeError(`Invalid statusText`);if(`status`in t&&t.status!=null&&(e[O].status=t.status),`statusText`in t&&t.statusText!=null&&(e[O].statusText=t.statusText),`headers`in t&&t.headers!=null&&i(e[k],t.headers),n){if(D.includes(e.status))throw A.errors.exception({header:`Response constructor`,message:`Invalid response status code ${e.status}`});e[O].body=n.body,n.type!=null&&!e[O].headersList.contains(`content-type`,!0)&&e[O].headersList.append(`content-type`,n.type,!0)}}function re(e,t){let r=new L(N);return r[O]=e,r[k]=new n(N),s(r[k],e.headersList),o(r[k],t),d&&e.body?.stream&&f.register(r,new WeakRef(e.body.stream)),r}A.converters.ReadableStream=A.interfaceConverter(ReadableStream),A.converters.FormData=A.interfaceConverter(j),A.converters.URLSearchParams=A.interfaceConverter(URLSearchParams),A.converters.XMLHttpRequestBodyInit=function(e,t,n){return typeof e==`string`?A.converters.USVString(e,t,n):x(e)?A.converters.Blob(e,t,n,{strict:!1}):ArrayBuffer.isView(e)||F.isArrayBuffer(e)?A.converters.BufferSource(e,t,n):m.isFormDataLike(e)?A.converters.FormData(e,t,n,{strict:!1}):e instanceof URLSearchParams?A.converters.URLSearchParams(e,t,n):A.converters.DOMString(e,t,n)},A.converters.BodyInit=function(e,t,n){return e instanceof ReadableStream?A.converters.ReadableStream(e,t,n):e?.[Symbol.asyncIterator]?e:A.converters.XMLHttpRequestBodyInit(e,t,n)},A.converters.ResponseInit=A.dictionaryConverter([{key:`status`,converter:A.converters[`unsigned short`],defaultValue:()=>200},{key:`statusText`,converter:A.converters.ByteString,defaultValue:()=>``},{key:`headers`,converter:A.converters.HeadersInit}]),t.exports={isNetworkError:B,makeNetworkError:ee,makeResponse:z,makeAppropriateNetworkError:ne,filterResponse:V,Response:L,cloneResponse:R,fromInnerResponse:re}})),Bt=U(((e,t)=>{let{kConnected:n,kSize:r}=Oe();var i=class{constructor(e){this.value=e}deref(){return this.value[n]===0&&this.value[r]===0?void 0:this.value}},a=class{constructor(e){this.finalizer=e}register(e,t){e.on&&e.on(`disconnect`,()=>{e[n]===0&&e[r]===0&&this.finalizer(t)})}unregister(e){}};t.exports=function(){return process.env.NODE_V8_COVERAGE&&process.version.startsWith(`v18`)?(process._rawDebug(`Using compatibility WeakRef and FinalizationRegistry`),{WeakRef:i,FinalizationRegistry:a}):{WeakRef,FinalizationRegistry}}})),Vt=U(((e,t)=>{let{extractBody:n,mixinBody:r,cloneBody:i,bodyUnusable:a}=Qe(),{Headers:o,fill:s,HeadersList:c,setHeadersGuard:l,getHeadersGuard:u,setHeadersList:d,getHeadersList:f}=Rt(),{FinalizationRegistry:p}=Bt()(),m=Me(),h=W(`node:util`),{isValidHTTPToken:g,sameOrigin:v,environmentSettingsObject:y}=qe(),{forbiddenMethodsSet:b,corsSafeListedMethodsSet:x,referrerPolicy:S,requestRedirect:C,requestMode:w,requestCredentials:T,requestCache:E,requestDuplex:D}=Ue(),{kEnumerableProperty:O,normalizedMethodRecordsBase:k,normalizedMethodRecords:A}=m,{kHeaders:j,kSignal:M,kState:N,kDispatcher:P}=Je(),{webidl:F}=Ke(),{URLSerializer:I}=Ge(),{kConstruct:L}=Oe(),R=W(`node:assert`),{getMaxListeners:z,setMaxListeners:ee,getEventListeners:B,defaultMaxListeners:te}=W(`node:events`),V=Symbol(`abortController`),ne=new p(({signal:e,abort:t})=>{e.removeEventListener(`abort`,t)}),H=new WeakMap;function re(e){return t;function t(){let n=e.deref();if(n!==void 0){ne.unregister(t),this.removeEventListener(`abort`,t),n.abort(this.reason);let e=H.get(n.signal);if(e!==void 0){if(e.size!==0){for(let t of e){let e=t.deref();e!==void 0&&e.abort(this.reason)}e.clear()}H.delete(n.signal)}}}}let ie=!1;var ae=class e{constructor(t,r={}){if(F.util.markAsUncloneable(this),t===L)return;let i=`Request constructor`;F.argumentLengthCheck(arguments,1,i),t=F.converters.RequestInfo(t,i,`input`),r=F.converters.RequestInit(r,i,`init`);let u=null,p=null,h=y.settingsObject.baseUrl,S=null;if(typeof t==`string`){this[P]=r.dispatcher;let e;try{e=new URL(t,h)}catch(e){throw TypeError(`Failed to parse URL from `+t,{cause:e})}if(e.username||e.password)throw TypeError(`Request cannot be constructed from a URL that includes credentials: `+t);u=oe({urlList:[e]}),p=`cors`}else this[P]=r.dispatcher||t[P],R(t instanceof e),u=t[N],S=t[M];let C=y.settingsObject.origin,w=`client`;if(u.window?.constructor?.name===`EnvironmentSettingsObject`&&v(u.window,C)&&(w=u.window),r.window!=null)throw TypeError(`'window' option '${w}' must be null`);`window`in r&&(w=`no-window`),u=oe({method:u.method,headersList:u.headersList,unsafeRequest:u.unsafeRequest,client:y.settingsObject,window:w,priority:u.priority,origin:u.origin,referrer:u.referrer,referrerPolicy:u.referrerPolicy,mode:u.mode,credentials:u.credentials,cache:u.cache,redirect:u.redirect,integrity:u.integrity,keepalive:u.keepalive,reloadNavigation:u.reloadNavigation,historyNavigation:u.historyNavigation,urlList:[...u.urlList]});let T=Object.keys(r).length!==0;if(T&&(u.mode===`navigate`&&(u.mode=`same-origin`),u.reloadNavigation=!1,u.historyNavigation=!1,u.origin=`client`,u.referrer=`client`,u.referrerPolicy=``,u.url=u.urlList[u.urlList.length-1],u.urlList=[u.url]),r.referrer!==void 0){let e=r.referrer;if(e===``)u.referrer=`no-referrer`;else{let t;try{t=new URL(e,h)}catch(t){throw TypeError(`Referrer "${e}" is not a valid URL.`,{cause:t})}t.protocol===`about:`&&t.hostname===`client`||C&&!v(t,y.settingsObject.baseUrl)?u.referrer=`client`:u.referrer=t}}r.referrerPolicy!==void 0&&(u.referrerPolicy=r.referrerPolicy);let E;if(E=r.mode===void 0?p:r.mode,E===`navigate`)throw F.errors.exception({header:`Request constructor`,message:`invalid request mode navigate.`});if(E!=null&&(u.mode=E),r.credentials!==void 0&&(u.credentials=r.credentials),r.cache!==void 0&&(u.cache=r.cache),u.cache===`only-if-cached`&&u.mode!==`same-origin`)throw TypeError(`'only-if-cached' can be set only with 'same-origin' mode`);if(r.redirect!==void 0&&(u.redirect=r.redirect),r.integrity!=null&&(u.integrity=String(r.integrity)),r.keepalive!==void 0&&(u.keepalive=!!r.keepalive),r.method!==void 0){let e=r.method,t=A[e];if(t!==void 0)u.method=t;else{if(!g(e))throw TypeError(`'${e}' is not a valid HTTP method.`);let t=e.toUpperCase();if(b.has(t))throw TypeError(`'${e}' HTTP method is unsupported.`);e=k[t]??e,u.method=e}!ie&&u.method===`patch`&&(process.emitWarning("Using `patch` is highly likely to result in a `405 Method Not Allowed`. `PATCH` is much more likely to succeed.",{code:`UNDICI-FETCH-patch`}),ie=!0)}r.signal!==void 0&&(S=r.signal),this[N]=u;let D=new AbortController;if(this[M]=D.signal,S!=null){if(!S||typeof S.aborted!=`boolean`||typeof S.addEventListener!=`function`)throw TypeError(`Failed to construct 'Request': member signal is not of type AbortSignal.`);if(S.aborted)D.abort(S.reason);else{this[V]=D;let e=re(new WeakRef(D));try{(typeof z==`function`&&z(S)===te||B(S,`abort`).length>=te)&&ee(1500,S)}catch{}m.addAbortListener(S,e),ne.register(D,{signal:S,abort:e},e)}}if(this[j]=new o(L),d(this[j],u.headersList),l(this[j],`request`),E===`no-cors`){if(!x.has(u.method))throw TypeError(`'${u.method} is unsupported in no-cors mode.`);l(this[j],`request-no-cors`)}if(T){let e=f(this[j]),t=r.headers===void 0?new c(e):r.headers;if(e.clear(),t instanceof c){for(let{name:n,value:r}of t.rawValues())e.append(n,r,!1);e.cookies=t.cookies}else s(this[j],t)}let O=t instanceof e?t[N].body:null;if((r.body!=null||O!=null)&&(u.method===`GET`||u.method===`HEAD`))throw TypeError(`Request with GET/HEAD method cannot have body.`);let I=null;if(r.body!=null){let[e,t]=n(r.body,u.keepalive);I=e,t&&!f(this[j]).contains(`content-type`,!0)&&this[j].append(`content-type`,t)}let H=I??O;if(H!=null&&H.source==null){if(I!=null&&r.duplex==null)throw TypeError(`RequestInit: duplex option is required when sending a body.`);if(u.mode!==`same-origin`&&u.mode!==`cors`)throw TypeError(`If request is made from ReadableStream, mode should be "same-origin" or "cors"`);u.useCORSPreflightFlag=!0}let ae=H;if(I==null&&O!=null){if(a(t))throw TypeError(`Cannot construct a Request with a Request object that has already been used.`);let e=new TransformStream;O.stream.pipeThrough(e),ae={source:O.source,length:O.length,stream:e.readable}}this[N].body=ae}get method(){return F.brandCheck(this,e),this[N].method}get url(){return F.brandCheck(this,e),I(this[N].url)}get headers(){return F.brandCheck(this,e),this[j]}get destination(){return F.brandCheck(this,e),this[N].destination}get referrer(){return F.brandCheck(this,e),this[N].referrer===`no-referrer`?``:this[N].referrer===`client`?`about:client`:this[N].referrer.toString()}get referrerPolicy(){return F.brandCheck(this,e),this[N].referrerPolicy}get mode(){return F.brandCheck(this,e),this[N].mode}get credentials(){return this[N].credentials}get cache(){return F.brandCheck(this,e),this[N].cache}get redirect(){return F.brandCheck(this,e),this[N].redirect}get integrity(){return F.brandCheck(this,e),this[N].integrity}get keepalive(){return F.brandCheck(this,e),this[N].keepalive}get isReloadNavigation(){return F.brandCheck(this,e),this[N].reloadNavigation}get isHistoryNavigation(){return F.brandCheck(this,e),this[N].historyNavigation}get signal(){return F.brandCheck(this,e),this[M]}get body(){return F.brandCheck(this,e),this[N].body?this[N].body.stream:null}get bodyUsed(){return F.brandCheck(this,e),!!this[N].body&&m.isDisturbed(this[N].body.stream)}get duplex(){return F.brandCheck(this,e),`half`}clone(){if(F.brandCheck(this,e),a(this))throw TypeError(`unusable`);let t=se(this[N]),n=new AbortController;if(this.signal.aborted)n.abort(this.signal.reason);else{let e=H.get(this.signal);e===void 0&&(e=new Set,H.set(this.signal,e));let t=new WeakRef(n);e.add(t),m.addAbortListener(n.signal,re(t))}return ce(t,n.signal,u(this[j]))}[h.inspect.custom](e,t){t.depth===null&&(t.depth=2),t.colors??=!0;let n={method:this.method,url:this.url,headers:this.headers,destination:this.destination,referrer:this.referrer,referrerPolicy:this.referrerPolicy,mode:this.mode,credentials:this.credentials,cache:this.cache,redirect:this.redirect,integrity:this.integrity,keepalive:this.keepalive,isReloadNavigation:this.isReloadNavigation,isHistoryNavigation:this.isHistoryNavigation,signal:this.signal};return`Request ${h.formatWithOptions(t,n)}`}};r(ae);function oe(e){return{method:e.method??`GET`,localURLsOnly:e.localURLsOnly??!1,unsafeRequest:e.unsafeRequest??!1,body:e.body??null,client:e.client??null,reservedClient:e.reservedClient??null,replacesClientId:e.replacesClientId??``,window:e.window??`client`,keepalive:e.keepalive??!1,serviceWorkers:e.serviceWorkers??`all`,initiator:e.initiator??``,destination:e.destination??``,priority:e.priority??null,origin:e.origin??`client`,policyContainer:e.policyContainer??`client`,referrer:e.referrer??`client`,referrerPolicy:e.referrerPolicy??``,mode:e.mode??`no-cors`,useCORSPreflightFlag:e.useCORSPreflightFlag??!1,credentials:e.credentials??`same-origin`,useCredentials:e.useCredentials??!1,cache:e.cache??`default`,redirect:e.redirect??`follow`,integrity:e.integrity??``,cryptoGraphicsNonceMetadata:e.cryptoGraphicsNonceMetadata??``,parserMetadata:e.parserMetadata??``,reloadNavigation:e.reloadNavigation??!1,historyNavigation:e.historyNavigation??!1,userActivation:e.userActivation??!1,taintedOrigin:e.taintedOrigin??!1,redirectCount:e.redirectCount??0,responseTainting:e.responseTainting??`basic`,preventNoCacheCacheControlHeaderModification:e.preventNoCacheCacheControlHeaderModification??!1,done:e.done??!1,timingAllowFailed:e.timingAllowFailed??!1,urlList:e.urlList,url:e.urlList[0],headersList:e.headersList?new c(e.headersList):new c}}function se(e){let t=oe({...e,body:null});return e.body!=null&&(t.body=i(t,e.body)),t}function ce(e,t,n){let r=new ae(L);return r[N]=e,r[M]=t,r[j]=new o(L),d(r[j],e.headersList),l(r[j],n),r}Object.defineProperties(ae.prototype,{method:O,url:O,headers:O,redirect:O,clone:O,signal:O,duplex:O,destination:O,body:O,bodyUsed:O,isHistoryNavigation:O,isReloadNavigation:O,keepalive:O,integrity:O,cache:O,credentials:O,attribute:O,referrerPolicy:O,referrer:O,mode:O,[Symbol.toStringTag]:{value:`Request`,configurable:!0}}),F.converters.Request=F.interfaceConverter(ae),F.converters.RequestInfo=function(e,t,n){return typeof e==`string`?F.converters.USVString(e,t,n):e instanceof ae?F.converters.Request(e,t,n):F.converters.USVString(e,t,n)},F.converters.AbortSignal=F.interfaceConverter(AbortSignal),F.converters.RequestInit=F.dictionaryConverter([{key:`method`,converter:F.converters.ByteString},{key:`headers`,converter:F.converters.HeadersInit},{key:`body`,converter:F.nullableConverter(F.converters.BodyInit)},{key:`referrer`,converter:F.converters.USVString},{key:`referrerPolicy`,converter:F.converters.DOMString,allowedValues:S},{key:`mode`,converter:F.converters.DOMString,allowedValues:w},{key:`credentials`,converter:F.converters.DOMString,allowedValues:T},{key:`cache`,converter:F.converters.DOMString,allowedValues:E},{key:`redirect`,converter:F.converters.DOMString,allowedValues:C},{key:`integrity`,converter:F.converters.DOMString},{key:`keepalive`,converter:F.converters.boolean},{key:`signal`,converter:F.nullableConverter(e=>F.converters.AbortSignal(e,`RequestInit`,`signal`,{strict:!1}))},{key:`window`,converter:F.converters.any},{key:`duplex`,converter:F.converters.DOMString,allowedValues:D},{key:`dispatcher`,converter:F.converters.any}]),t.exports={Request:ae,makeRequest:oe,fromInnerRequest:ce,cloneRequest:se}})),Ht=U(((e,t)=>{let{makeNetworkError:n,makeAppropriateNetworkError:r,filterResponse:i,makeResponse:a,fromInnerResponse:o}=zt(),{HeadersList:s}=Rt(),{Request:c,cloneRequest:l}=Vt(),u=W(`node:zlib`),{bytesMatch:d,makePolicyContainer:f,clonePolicyContainer:p,requestBadPort:m,TAOCheck:h,appendRequestOriginHeader:g,responseLocationURL:v,requestCurrentURL:y,setRequestReferrerPolicyOnRedirect:b,tryUpgradeRequestToAPotentiallyTrustworthyURL:x,createOpaqueTimingInfo:S,appendFetchMetadata:C,corsCheck:w,crossOriginResourcePolicyCheck:T,determineRequestsReferrer:E,coarsenedSharedCurrentTime:D,createDeferredPromise:O,isBlobLike:k,sameOrigin:A,isCancelled:j,isAborted:M,isErrorLike:N,fullyReadBody:P,readableStreamClose:F,isomorphicEncode:I,urlIsLocal:L,urlIsHttpHttpsScheme:R,urlHasHttpsScheme:z,clampAndCoarsenConnectionTimingInfo:ee,simpleRangeHeaderValue:B,buildContentRange:te,createInflate:V,extractMimeType:ne}=qe(),{kState:H,kDispatcher:re}=Je(),ie=W(`node:assert`),{safelyExtractBody:ae,extractBody:oe}=Qe(),{redirectStatusSet:se,nullBodyStatus:ce,safeMethodsSet:le,requestBodyHeader:ue,subresourceSet:U}=Ue(),de=W(`node:events`),{Readable:fe,pipeline:pe,finished:me}=W(`node:stream`),{addAbortListener:he,isErrored:ge,isReadable:_e,bufferToLowerCasedHeaderName:ve}=Me(),{dataURLProcessor:ye,serializeAMimeType:be,minimizeSupportedMimeType:xe}=Ge(),{getGlobalDispatcher:Se}=Mt(),{webidl:Ce}=Ke(),{STATUS_CODES:we}=W(`node:http`),Te=[`GET`,`HEAD`],Ee=typeof __UNDICI_IS_NODE__<`u`||typeof esbuildDetection<`u`?`node`:`undici`,De;var Oe=class extends de{constructor(e){super(),this.dispatcher=e,this.connection=null,this.dump=!1,this.state=`ongoing`}terminate(e){this.state===`ongoing`&&(this.state=`terminated`,this.connection?.destroy(e),this.emit(`terminated`,e))}abort(e){this.state===`ongoing`&&(this.state=`aborted`,e||=new DOMException(`The operation was aborted.`,`AbortError`),this.serializedAbortReason=e,this.connection?.destroy(e),this.emit(`terminated`,e))}};function ke(e){je(e,`fetch`)}function Ae(e,t=void 0){Ce.argumentLengthCheck(arguments,1,`globalThis.fetch`);let n=O(),r;try{r=new c(e,t)}catch(e){return n.reject(e),n.promise}let i=r[H];if(r.signal.aborted)return Pe(n,i,null,r.signal.reason),n.promise;i.client.globalObject?.constructor?.name===`ServiceWorkerGlobalScope`&&(i.serviceWorkers=`none`);let a=null,s=!1,l=null;return he(r.signal,()=>{s=!0,ie(l!=null),l.abort(r.signal.reason);let e=a?.deref();Pe(n,i,e,r.signal.reason)}),l=Fe({request:i,processResponseEndOfBody:ke,processResponse:e=>{if(!s){if(e.aborted){Pe(n,i,a,l.serializedAbortReason);return}if(e.type===`error`){n.reject(TypeError(`fetch failed`,{cause:e.error}));return}a=new WeakRef(o(e,`immutable`)),n.resolve(a.deref()),n=null}},dispatcher:r[re]}),n.promise}function je(e,t=`other`){if(e.type===`error`&&e.aborted||!e.urlList?.length)return;let n=e.urlList[0],r=e.timingInfo,i=e.cacheState;R(n)&&r!==null&&(e.timingAllowPassed||(r=S({startTime:r.startTime}),i=``),r.endTime=D(),e.timingInfo=r,Ne(r,n.href,t,globalThis,i))}let Ne=performance.markResourceTiming;function Pe(e,t,n,r){if(e&&e.reject(r),t.body!=null&&_e(t.body?.stream)&&t.body.stream.cancel(r).catch(e=>{if(e.code!==`ERR_INVALID_STATE`)throw e}),n==null)return;let i=n[H];i.body!=null&&_e(i.body?.stream)&&i.body.stream.cancel(r).catch(e=>{if(e.code!==`ERR_INVALID_STATE`)throw e})}function Fe({request:e,processRequestBodyChunkLength:t,processRequestEndOfBody:n,processResponse:r,processResponseEndOfBody:i,processResponseConsumeBody:a,useParallelQueue:o=!1,dispatcher:s=Se()}){ie(s);let c=null,l=!1;e.client!=null&&(c=e.client.globalObject,l=e.client.crossOriginIsolatedCapability);let u=S({startTime:D(l)}),d={controller:new Oe(s),request:e,timingInfo:u,processRequestBodyChunkLength:t,processRequestEndOfBody:n,processResponse:r,processResponseConsumeBody:a,processResponseEndOfBody:i,taskDestination:c,crossOriginIsolatedCapability:l};return ie(!e.body||e.body.stream),e.window===`client`&&(e.window=e.client?.globalObject?.constructor?.name===`Window`?e.client:`no-window`),e.origin===`client`&&(e.origin=e.client.origin),e.policyContainer===`client`&&(e.client==null?e.policyContainer=f():e.policyContainer=p(e.client.policyContainer)),e.headersList.contains(`accept`,!0)||e.headersList.append(`accept`,`*/*`,!0),e.headersList.contains(`accept-language`,!0)||e.headersList.append(`accept-language`,`*`,!0),e.priority,U.has(e.destination),Ie(d).catch(e=>{d.controller.terminate(e)}),d.controller}async function Ie(e,t=!1){let r=e.request,a=null;if(r.localURLsOnly&&!L(y(r))&&(a=n(`local URLs only`)),x(r),m(r)===`blocked`&&(a=n(`bad port`)),r.referrerPolicy===``&&(r.referrerPolicy=r.policyContainer.referrerPolicy),r.referrer!==`no-referrer`&&(r.referrer=E(r)),a===null&&(a=await(async()=>{let t=y(r);return A(t,r.url)&&r.responseTainting===`basic`||t.protocol===`data:`||r.mode===`navigate`||r.mode===`websocket`?(r.responseTainting=`basic`,await Le(e)):r.mode===`same-origin`?n(`request mode cannot be "same-origin"`):r.mode===`no-cors`?r.redirect===`follow`?(r.responseTainting=`opaque`,await Le(e)):n(`redirect mode cannot be "follow" for "no-cors" request`):R(y(r))?(r.responseTainting=`cors`,await Be(e)):n(`URL scheme must be a HTTP(S) scheme`)})()),t)return a;a.status!==0&&!a.internalResponse&&(r.responseTainting,r.responseTainting===`basic`?a=i(a,`basic`):r.responseTainting===`cors`?a=i(a,`cors`):r.responseTainting===`opaque`?a=i(a,`opaque`):ie(!1));let o=a.status===0?a:a.internalResponse;if(o.urlList.length===0&&o.urlList.push(...r.urlList),r.timingAllowFailed||(a.timingAllowPassed=!0),a.type===`opaque`&&o.status===206&&o.rangeRequested&&!r.headers.contains(`range`,!0)&&(a=o=n()),a.status!==0&&(r.method===`HEAD`||r.method===`CONNECT`||ce.includes(o.status))&&(o.body=null,e.controller.dump=!0),r.integrity){let t=t=>ze(e,n(t));if(r.responseTainting===`opaque`||a.body==null){t(a.error);return}await P(a.body,n=>{if(!d(n,r.integrity)){t(`integrity mismatch`);return}a.body=ae(n)[0],ze(e,a)},t)}else ze(e,a)}function Le(e){if(j(e)&&e.request.redirectCount===0)return Promise.resolve(r(e));let{request:t}=e,{protocol:i}=y(t);switch(i){case`about:`:return Promise.resolve(n(`about scheme is not supported`));case`blob:`:{De||=W(`node:buffer`).resolveObjectURL;let e=y(t);if(e.search.length!==0)return Promise.resolve(n(`NetworkError when attempting to fetch resource.`));let r=De(e.toString());if(t.method!==`GET`||!k(r))return Promise.resolve(n(`invalid method`));let i=a(),o=r.size,s=I(`${o}`),c=r.type;if(t.headersList.contains(`range`,!0)){i.rangeRequested=!0;let e=B(t.headersList.get(`range`,!0),!0);if(e===`failure`)return Promise.resolve(n(`failed to fetch the data URL`));let{rangeStartValue:a,rangeEndValue:s}=e;if(a===null)a=o-s,s=a+s-1;else{if(a>=o)return Promise.resolve(n(`Range start is greater than the blob's size.`));(s===null||s>=o)&&(s=o-1)}let l=r.slice(a,s,c);i.body=oe(l)[0];let u=I(`${l.size}`),d=te(a,s,o);i.status=206,i.statusText=`Partial Content`,i.headersList.set(`content-length`,u,!0),i.headersList.set(`content-type`,c,!0),i.headersList.set(`content-range`,d,!0)}else{let e=oe(r);i.statusText=`OK`,i.body=e[0],i.headersList.set(`content-length`,s,!0),i.headersList.set(`content-type`,c,!0)}return Promise.resolve(i)}case`data:`:{let e=ye(y(t));if(e===`failure`)return Promise.resolve(n(`failed to fetch the data URL`));let r=be(e.mimeType);return Promise.resolve(a({statusText:`OK`,headersList:[[`content-type`,{name:`Content-Type`,value:r}]],body:ae(e.body)[0]}))}case`file:`:return Promise.resolve(n(`not implemented... yet...`));case`http:`:case`https:`:return Be(e).catch(e=>n(e));default:return Promise.resolve(n(`unknown scheme`))}}function Re(e,t){e.request.done=!0,e.processResponseDone!=null&&queueMicrotask(()=>e.processResponseDone(t))}function ze(e,t){let n=e.timingInfo,r=()=>{let r=Date.now();e.request.destination===`document`&&(e.controller.fullTimingInfo=n),e.controller.reportTimingSteps=()=>{if(e.request.url.protocol!==`https:`)return;n.endTime=r;let i=t.cacheState,a=t.bodyInfo;t.timingAllowPassed||(n=S(n),i=``);let o=0;if(e.request.mode!==`navigator`||!t.hasCrossOriginRedirects){o=t.status;let e=ne(t.headersList);e!==`failure`&&(a.contentType=xe(e))}e.request.initiatorType!=null&&Ne(n,e.request.url.href,e.request.initiatorType,globalThis,i,a,o)};let i=()=>{e.request.done=!0,e.processResponseEndOfBody!=null&&queueMicrotask(()=>e.processResponseEndOfBody(t)),e.request.initiatorType!=null&&e.controller.reportTimingSteps()};queueMicrotask(()=>i())};e.processResponse!=null&&queueMicrotask(()=>{e.processResponse(t),e.processResponse=null});let i=t.type===`error`?t:t.internalResponse??t;i.body==null?r():me(i.body.stream,()=>{r()})}async function Be(e){let t=e.request,r=null,i=null,a=e.timingInfo;if(t.serviceWorkers,r===null){if(t.redirect===`follow`&&(t.serviceWorkers=`none`),i=r=await He(e),t.responseTainting===`cors`&&w(t,r)===`failure`)return n(`cors failure`);h(t,r)===`failure`&&(t.timingAllowFailed=!0)}return(t.responseTainting===`opaque`||r.type===`opaque`)&&T(t.origin,t.client,t.destination,i)===`blocked`?n(`blocked`):(se.has(i.status)&&(t.redirect!==`manual`&&e.controller.connection.destroy(void 0,!1),t.redirect===`error`?r=n(`unexpected redirect`):t.redirect===`manual`?r=i:t.redirect===`follow`?r=await Ve(e,r):ie(!1)),r.timingInfo=a,r)}function Ve(e,t){let r=e.request,i=t.internalResponse?t.internalResponse:t,a;try{if(a=v(i,y(r).hash),a==null)return t}catch(e){return Promise.resolve(n(e))}if(!R(a))return Promise.resolve(n(`URL scheme must be a HTTP(S) scheme`));if(r.redirectCount===20)return Promise.resolve(n(`redirect count exceeded`));if(r.redirectCount+=1,r.mode===`cors`&&(a.username||a.password)&&!A(r,a))return Promise.resolve(n(`cross origin not allowed for request mode "cors"`));if(r.responseTainting===`cors`&&(a.username||a.password))return Promise.resolve(n(`URL cannot contain credentials for request mode "cors"`));if(i.status!==303&&r.body!=null&&r.body.source==null)return Promise.resolve(n());if([301,302].includes(i.status)&&r.method===`POST`||i.status===303&&!Te.includes(r.method)){r.method=`GET`,r.body=null;for(let e of ue)r.headersList.delete(e)}A(y(r),a)||(r.headersList.delete(`authorization`,!0),r.headersList.delete(`proxy-authorization`,!0),r.headersList.delete(`cookie`,!0),r.headersList.delete(`host`,!0)),r.body!=null&&(ie(r.body.source!=null),r.body=ae(r.body.source)[0]);let o=e.timingInfo;return o.redirectEndTime=o.postRedirectStartTime=D(e.crossOriginIsolatedCapability),o.redirectStartTime===0&&(o.redirectStartTime=o.startTime),r.urlList.push(a),b(r,i),Ie(e,!0)}async function He(e,t=!1,i=!1){let a=e.request,o=null,s=null,c=null;a.window===`no-window`&&a.redirect===`error`?(o=e,s=a):(s=l(a),o={...e},o.request=s);let u=a.credentials===`include`||a.credentials===`same-origin`&&a.responseTainting===`basic`,d=s.body?s.body.length:null,f=null;if(s.body==null&&[`POST`,`PUT`].includes(s.method)&&(f=`0`),d!=null&&(f=I(`${d}`)),f!=null&&s.headersList.append(`content-length`,f,!0),d!=null&&s.keepalive,s.referrer instanceof URL&&s.headersList.append(`referer`,I(s.referrer.href),!0),g(s),C(s),s.headersList.contains(`user-agent`,!0)||s.headersList.append(`user-agent`,Ee),s.cache===`default`&&(s.headersList.contains(`if-modified-since`,!0)||s.headersList.contains(`if-none-match`,!0)||s.headersList.contains(`if-unmodified-since`,!0)||s.headersList.contains(`if-match`,!0)||s.headersList.contains(`if-range`,!0))&&(s.cache=`no-store`),s.cache===`no-cache`&&!s.preventNoCacheCacheControlHeaderModification&&!s.headersList.contains(`cache-control`,!0)&&s.headersList.append(`cache-control`,`max-age=0`,!0),(s.cache===`no-store`||s.cache===`reload`)&&(s.headersList.contains(`pragma`,!0)||s.headersList.append(`pragma`,`no-cache`,!0),s.headersList.contains(`cache-control`,!0)||s.headersList.append(`cache-control`,`no-cache`,!0)),s.headersList.contains(`range`,!0)&&s.headersList.append(`accept-encoding`,`identity`,!0),s.headersList.contains(`accept-encoding`,!0)||(z(y(s))?s.headersList.append(`accept-encoding`,`br, gzip, deflate`,!0):s.headersList.append(`accept-encoding`,`gzip, deflate`,!0)),s.headersList.delete(`host`,!0),s.cache=`no-store`,s.cache!==`no-store`&&s.cache,c==null){if(s.cache===`only-if-cached`)return n(`only if cached`);let e=await We(o,u,i);!le.has(s.method)&&e.status>=200&&e.status,c??=e}if(c.urlList=[...s.urlList],s.headersList.contains(`range`,!0)&&(c.rangeRequested=!0),c.requestIncludesCredentials=u,c.status===407)return a.window===`no-window`?n():j(e)?r(e):n(`proxy authentication required`);if(c.status===421&&!i&&(a.body==null||a.body.source!=null)){if(j(e))return r(e);e.controller.connection.destroy(),c=await He(e,t,!0)}return c}async function We(e,t=!1,i=!1){ie(!e.controller.connection||e.controller.connection.destroyed),e.controller.connection={abort:null,destroyed:!1,destroy(e,t=!0){this.destroyed||(this.destroyed=!0,t&&this.abort?.(e??new DOMException(`The operation was aborted.`,`AbortError`)))}};let o=e.request,c=null,l=e.timingInfo;o.cache=`no-store`,o.mode;let d=null;if(o.body==null&&e.processRequestEndOfBody)queueMicrotask(()=>e.processRequestEndOfBody());else if(o.body!=null){let t=async function*(t){j(e)||(yield t,e.processRequestBodyChunkLength?.(t.byteLength))},n=()=>{j(e)||e.processRequestEndOfBody&&e.processRequestEndOfBody()},r=t=>{j(e)||(t.name===`AbortError`?e.controller.abort():e.controller.terminate(t))};d=(async function*(){try{for await(let e of o.body.stream)yield*t(e);n()}catch(e){r(e)}})()}try{let{body:t,status:n,statusText:r,headersList:i,socket:o}=await g({body:d});if(o)c=a({status:n,statusText:r,headersList:i,socket:o});else{let o=t[Symbol.asyncIterator]();e.controller.next=()=>o.next(),c=a({status:n,statusText:r,headersList:i})}}catch(t){return t.name===`AbortError`?(e.controller.connection.destroy(),r(e,t)):n(t)}let f=async()=>{await e.controller.resume()},p=t=>{j(e)||e.controller.abort(t)},m=new ReadableStream({async start(t){e.controller.controller=t},async pull(e){await f(e)},async cancel(e){await p(e)},type:`bytes`});c.body={stream:m,source:null,length:null},e.controller.onAborted=h,e.controller.on(`terminated`,h),e.controller.resume=async()=>{for(;;){let t,n;try{let{done:n,value:r}=await e.controller.next();if(M(e))break;t=n?void 0:r}catch(r){e.controller.ended&&!l.encodedBodySize?t=void 0:(t=r,n=!0)}if(t===void 0){F(e.controller.controller),Re(e,c);return}if(l.decodedBodySize+=t?.byteLength??0,n){e.controller.terminate(t);return}let r=new Uint8Array(t);if(r.byteLength&&e.controller.controller.enqueue(r),ge(m)){e.controller.terminate();return}if(e.controller.controller.desiredSize<=0)return}};function h(t){M(e)?(c.aborted=!0,_e(m)&&e.controller.controller.error(e.controller.serializedAbortReason)):_e(m)&&e.controller.controller.error(TypeError(`terminated`,{cause:N(t)?t:void 0})),e.controller.connection.destroy()}return c;function g({body:t}){let n=y(o),r=e.controller.dispatcher;return new Promise((i,a)=>r.dispatch({path:n.pathname+n.search,origin:n.origin,method:o.method,body:r.isMockActive?o.body&&(o.body.source||o.body.stream):t,headers:o.headersList.entries,maxRedirections:0,upgrade:o.mode===`websocket`?`websocket`:void 0},{body:null,abort:null,onConnect(t){let{connection:n}=e.controller;l.finalConnectionTimingInfo=ee(void 0,l.postRedirectStartTime,e.crossOriginIsolatedCapability),n.destroyed?t(new DOMException(`The operation was aborted.`,`AbortError`)):(e.controller.on(`terminated`,t),this.abort=n.abort=t),l.finalNetworkRequestStartTime=D(e.crossOriginIsolatedCapability)},onResponseStarted(){l.finalNetworkResponseStartTime=D(e.crossOriginIsolatedCapability)},onHeaders(e,t,n,r){if(e<200)return;let c=``,l=new s;for(let e=0;e5)return a(Error(`too many content-encodings in response: ${t.length}, maximum allowed is 5`)),!0;for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n===`x-gzip`||n===`gzip`)d.push(u.createGunzip({flush:u.constants.Z_SYNC_FLUSH,finishFlush:u.constants.Z_SYNC_FLUSH}));else if(n===`deflate`)d.push(V({flush:u.constants.Z_SYNC_FLUSH,finishFlush:u.constants.Z_SYNC_FLUSH}));else if(n===`br`)d.push(u.createBrotliDecompress({flush:u.constants.BROTLI_OPERATION_FLUSH,finishFlush:u.constants.BROTLI_OPERATION_FLUSH}));else{d.length=0;break}}}let p=this.onError.bind(this);return i({status:e,statusText:r,headersList:l,body:d.length?pe(this.body,...d,e=>{e&&this.onError(e)}).on(`error`,p):this.body.on(`error`,p)}),!0},onData(t){if(e.controller.dump)return;let n=t;return l.encodedBodySize+=n.byteLength,this.body.push(n)},onComplete(){this.abort&&e.controller.off(`terminated`,this.abort),e.controller.onAborted&&e.controller.off(`terminated`,e.controller.onAborted),e.controller.ended=!0,this.body.push(null)},onError(t){this.abort&&e.controller.off(`terminated`,this.abort),this.body?.destroy(t),e.controller.terminate(t),a(t)},onUpgrade(e,t,n){if(e!==101)return;let r=new s;for(let e=0;e{t.exports={kState:Symbol(`FileReader state`),kResult:Symbol(`FileReader result`),kError:Symbol(`FileReader error`),kLastProgressEventFired:Symbol(`FileReader last progress event fired timestamp`),kEvents:Symbol(`FileReader events`),kAborted:Symbol(`FileReader aborted`)}})),Wt=U(((e,t)=>{let{webidl:n}=Ke(),r=Symbol(`ProgressEvent state`);var i=class e extends Event{constructor(e,t={}){e=n.converters.DOMString(e,`ProgressEvent constructor`,`type`),t=n.converters.ProgressEventInit(t??{}),super(e,t),this[r]={lengthComputable:t.lengthComputable,loaded:t.loaded,total:t.total}}get lengthComputable(){return n.brandCheck(this,e),this[r].lengthComputable}get loaded(){return n.brandCheck(this,e),this[r].loaded}get total(){return n.brandCheck(this,e),this[r].total}};n.converters.ProgressEventInit=n.dictionaryConverter([{key:`lengthComputable`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`loaded`,converter:n.converters[`unsigned long long`],defaultValue:()=>0},{key:`total`,converter:n.converters[`unsigned long long`],defaultValue:()=>0},{key:`bubbles`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`cancelable`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`composed`,converter:n.converters.boolean,defaultValue:()=>!1}]),t.exports={ProgressEvent:i}})),Gt=U(((e,t)=>{function n(e){if(!e)return`failure`;switch(e.trim().toLowerCase()){case`unicode-1-1-utf-8`:case`unicode11utf8`:case`unicode20utf8`:case`utf-8`:case`utf8`:case`x-unicode20utf8`:return`UTF-8`;case`866`:case`cp866`:case`csibm866`:case`ibm866`:return`IBM866`;case`csisolatin2`:case`iso-8859-2`:case`iso-ir-101`:case`iso8859-2`:case`iso88592`:case`iso_8859-2`:case`iso_8859-2:1987`:case`l2`:case`latin2`:return`ISO-8859-2`;case`csisolatin3`:case`iso-8859-3`:case`iso-ir-109`:case`iso8859-3`:case`iso88593`:case`iso_8859-3`:case`iso_8859-3:1988`:case`l3`:case`latin3`:return`ISO-8859-3`;case`csisolatin4`:case`iso-8859-4`:case`iso-ir-110`:case`iso8859-4`:case`iso88594`:case`iso_8859-4`:case`iso_8859-4:1988`:case`l4`:case`latin4`:return`ISO-8859-4`;case`csisolatincyrillic`:case`cyrillic`:case`iso-8859-5`:case`iso-ir-144`:case`iso8859-5`:case`iso88595`:case`iso_8859-5`:case`iso_8859-5:1988`:return`ISO-8859-5`;case`arabic`:case`asmo-708`:case`csiso88596e`:case`csiso88596i`:case`csisolatinarabic`:case`ecma-114`:case`iso-8859-6`:case`iso-8859-6-e`:case`iso-8859-6-i`:case`iso-ir-127`:case`iso8859-6`:case`iso88596`:case`iso_8859-6`:case`iso_8859-6:1987`:return`ISO-8859-6`;case`csisolatingreek`:case`ecma-118`:case`elot_928`:case`greek`:case`greek8`:case`iso-8859-7`:case`iso-ir-126`:case`iso8859-7`:case`iso88597`:case`iso_8859-7`:case`iso_8859-7:1987`:case`sun_eu_greek`:return`ISO-8859-7`;case`csiso88598e`:case`csisolatinhebrew`:case`hebrew`:case`iso-8859-8`:case`iso-8859-8-e`:case`iso-ir-138`:case`iso8859-8`:case`iso88598`:case`iso_8859-8`:case`iso_8859-8:1988`:case`visual`:return`ISO-8859-8`;case`csiso88598i`:case`iso-8859-8-i`:case`logical`:return`ISO-8859-8-I`;case`csisolatin6`:case`iso-8859-10`:case`iso-ir-157`:case`iso8859-10`:case`iso885910`:case`l6`:case`latin6`:return`ISO-8859-10`;case`iso-8859-13`:case`iso8859-13`:case`iso885913`:return`ISO-8859-13`;case`iso-8859-14`:case`iso8859-14`:case`iso885914`:return`ISO-8859-14`;case`csisolatin9`:case`iso-8859-15`:case`iso8859-15`:case`iso885915`:case`iso_8859-15`:case`l9`:return`ISO-8859-15`;case`iso-8859-16`:return`ISO-8859-16`;case`cskoi8r`:case`koi`:case`koi8`:case`koi8-r`:case`koi8_r`:return`KOI8-R`;case`koi8-ru`:case`koi8-u`:return`KOI8-U`;case`csmacintosh`:case`mac`:case`macintosh`:case`x-mac-roman`:return`macintosh`;case`iso-8859-11`:case`iso8859-11`:case`iso885911`:case`tis-620`:case`windows-874`:return`windows-874`;case`cp1250`:case`windows-1250`:case`x-cp1250`:return`windows-1250`;case`cp1251`:case`windows-1251`:case`x-cp1251`:return`windows-1251`;case`ansi_x3.4-1968`:case`ascii`:case`cp1252`:case`cp819`:case`csisolatin1`:case`ibm819`:case`iso-8859-1`:case`iso-ir-100`:case`iso8859-1`:case`iso88591`:case`iso_8859-1`:case`iso_8859-1:1987`:case`l1`:case`latin1`:case`us-ascii`:case`windows-1252`:case`x-cp1252`:return`windows-1252`;case`cp1253`:case`windows-1253`:case`x-cp1253`:return`windows-1253`;case`cp1254`:case`csisolatin5`:case`iso-8859-9`:case`iso-ir-148`:case`iso8859-9`:case`iso88599`:case`iso_8859-9`:case`iso_8859-9:1989`:case`l5`:case`latin5`:case`windows-1254`:case`x-cp1254`:return`windows-1254`;case`cp1255`:case`windows-1255`:case`x-cp1255`:return`windows-1255`;case`cp1256`:case`windows-1256`:case`x-cp1256`:return`windows-1256`;case`cp1257`:case`windows-1257`:case`x-cp1257`:return`windows-1257`;case`cp1258`:case`windows-1258`:case`x-cp1258`:return`windows-1258`;case`x-mac-cyrillic`:case`x-mac-ukrainian`:return`x-mac-cyrillic`;case`chinese`:case`csgb2312`:case`csiso58gb231280`:case`gb2312`:case`gb_2312`:case`gb_2312-80`:case`gbk`:case`iso-ir-58`:case`x-gbk`:return`GBK`;case`gb18030`:return`gb18030`;case`big5`:case`big5-hkscs`:case`cn-big5`:case`csbig5`:case`x-x-big5`:return`Big5`;case`cseucpkdfmtjapanese`:case`euc-jp`:case`x-euc-jp`:return`EUC-JP`;case`csiso2022jp`:case`iso-2022-jp`:return`ISO-2022-JP`;case`csshiftjis`:case`ms932`:case`ms_kanji`:case`shift-jis`:case`shift_jis`:case`sjis`:case`windows-31j`:case`x-sjis`:return`Shift_JIS`;case`cseuckr`:case`csksc56011987`:case`euc-kr`:case`iso-ir-149`:case`korean`:case`ks_c_5601-1987`:case`ks_c_5601-1989`:case`ksc5601`:case`ksc_5601`:case`windows-949`:return`EUC-KR`;case`csiso2022kr`:case`hz-gb-2312`:case`iso-2022-cn`:case`iso-2022-cn-ext`:case`iso-2022-kr`:case`replacement`:return`replacement`;case`unicodefffe`:case`utf-16be`:return`UTF-16BE`;case`csunicode`:case`iso-10646-ucs-2`:case`ucs-2`:case`unicode`:case`unicodefeff`:case`utf-16`:case`utf-16le`:return`UTF-16LE`;case`x-user-defined`:return`x-user-defined`;default:return`failure`}}t.exports={getEncoding:n}})),Kt=U(((e,t)=>{let{kState:n,kError:r,kResult:i,kAborted:a,kLastProgressEventFired:o}=Ut(),{ProgressEvent:s}=Wt(),{getEncoding:c}=Gt(),{serializeAMimeType:l,parseMIMEType:u}=Ge(),{types:d}=W(`node:util`),{StringDecoder:f}=W(`string_decoder`),{btoa:p}=W(`node:buffer`),m={enumerable:!0,writable:!1,configurable:!1};function h(e,t,s,c){if(e[n]===`loading`)throw new DOMException(`Invalid state`,`InvalidStateError`);e[n]=`loading`,e[i]=null,e[r]=null;let l=t.stream().getReader(),u=[],f=l.read(),p=!0;(async()=>{for(;!e[a];)try{let{done:m,value:h}=await f;if(p&&!e[a]&&queueMicrotask(()=>{g(`loadstart`,e)}),p=!1,!m&&d.isUint8Array(h))u.push(h),(e[o]===void 0||Date.now()-e[o]>=50)&&!e[a]&&(e[o]=Date.now(),queueMicrotask(()=>{g(`progress`,e)})),f=l.read();else if(m){queueMicrotask(()=>{e[n]=`done`;try{let n=v(u,s,t.type,c);if(e[a])return;e[i]=n,g(`load`,e)}catch(t){e[r]=t,g(`error`,e)}e[n]!==`loading`&&g(`loadend`,e)});break}}catch(t){if(e[a])return;queueMicrotask(()=>{e[n]=`done`,e[r]=t,g(`error`,e),e[n]!==`loading`&&g(`loadend`,e)});break}})()}function g(e,t){let n=new s(e,{bubbles:!1,cancelable:!1});t.dispatchEvent(n)}function v(e,t,n,r){switch(t){case`DataURL`:{let t=`data:`,r=u(n||`application/octet-stream`);r!==`failure`&&(t+=l(r)),t+=`;base64,`;let i=new f(`latin1`);for(let n of e)t+=p(i.write(n));return t+=p(i.end()),t}case`Text`:{let t=`failure`;if(r&&(t=c(r)),t===`failure`&&n){let e=u(n);e!==`failure`&&(t=c(e.parameters.get(`charset`)))}return t===`failure`&&(t=`UTF-8`),y(e,t)}case`ArrayBuffer`:return x(e).buffer;case`BinaryString`:{let t=``,n=new f(`latin1`);for(let r of e)t+=n.write(r);return t+=n.end(),t}}}function y(e,t){let n=x(e),r=b(n),i=0;r!==null&&(t=r,i=r===`UTF-8`?3:2);let a=n.slice(i);return new TextDecoder(t).decode(a)}function b(e){let[t,n,r]=e;return t===239&&n===187&&r===191?`UTF-8`:t===254&&n===255?`UTF-16BE`:t===255&&n===254?`UTF-16LE`:null}function x(e){let t=e.reduce((e,t)=>e+t.byteLength,0),n=0;return e.reduce((e,t)=>(e.set(t,n),n+=t.byteLength,e),new Uint8Array(t))}t.exports={staticPropertyDescriptors:m,readOperation:h,fireAProgressEvent:g}})),qt=U(((e,t)=>{let{staticPropertyDescriptors:n,readOperation:r,fireAProgressEvent:i}=Kt(),{kState:a,kError:o,kResult:s,kEvents:c,kAborted:l}=Ut(),{webidl:u}=Ke(),{kEnumerableProperty:d}=Me();var f=class e extends EventTarget{constructor(){super(),this[a]=`empty`,this[s]=null,this[o]=null,this[c]={loadend:null,error:null,abort:null,load:null,progress:null,loadstart:null}}readAsArrayBuffer(t){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsArrayBuffer`),t=u.converters.Blob(t,{strict:!1}),r(this,t,`ArrayBuffer`)}readAsBinaryString(t){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsBinaryString`),t=u.converters.Blob(t,{strict:!1}),r(this,t,`BinaryString`)}readAsText(t,n=void 0){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsText`),t=u.converters.Blob(t,{strict:!1}),n!==void 0&&(n=u.converters.DOMString(n,`FileReader.readAsText`,`encoding`)),r(this,t,`Text`,n)}readAsDataURL(t){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsDataURL`),t=u.converters.Blob(t,{strict:!1}),r(this,t,`DataURL`)}abort(){if(this[a]===`empty`||this[a]===`done`){this[s]=null;return}this[a]===`loading`&&(this[a]=`done`,this[s]=null),this[l]=!0,i(`abort`,this),this[a]!==`loading`&&i(`loadend`,this)}get readyState(){switch(u.brandCheck(this,e),this[a]){case`empty`:return this.EMPTY;case`loading`:return this.LOADING;case`done`:return this.DONE}}get result(){return u.brandCheck(this,e),this[s]}get error(){return u.brandCheck(this,e),this[o]}get onloadend(){return u.brandCheck(this,e),this[c].loadend}set onloadend(t){u.brandCheck(this,e),this[c].loadend&&this.removeEventListener(`loadend`,this[c].loadend),typeof t==`function`?(this[c].loadend=t,this.addEventListener(`loadend`,t)):this[c].loadend=null}get onerror(){return u.brandCheck(this,e),this[c].error}set onerror(t){u.brandCheck(this,e),this[c].error&&this.removeEventListener(`error`,this[c].error),typeof t==`function`?(this[c].error=t,this.addEventListener(`error`,t)):this[c].error=null}get onloadstart(){return u.brandCheck(this,e),this[c].loadstart}set onloadstart(t){u.brandCheck(this,e),this[c].loadstart&&this.removeEventListener(`loadstart`,this[c].loadstart),typeof t==`function`?(this[c].loadstart=t,this.addEventListener(`loadstart`,t)):this[c].loadstart=null}get onprogress(){return u.brandCheck(this,e),this[c].progress}set onprogress(t){u.brandCheck(this,e),this[c].progress&&this.removeEventListener(`progress`,this[c].progress),typeof t==`function`?(this[c].progress=t,this.addEventListener(`progress`,t)):this[c].progress=null}get onload(){return u.brandCheck(this,e),this[c].load}set onload(t){u.brandCheck(this,e),this[c].load&&this.removeEventListener(`load`,this[c].load),typeof t==`function`?(this[c].load=t,this.addEventListener(`load`,t)):this[c].load=null}get onabort(){return u.brandCheck(this,e),this[c].abort}set onabort(t){u.brandCheck(this,e),this[c].abort&&this.removeEventListener(`abort`,this[c].abort),typeof t==`function`?(this[c].abort=t,this.addEventListener(`abort`,t)):this[c].abort=null}};f.EMPTY=f.prototype.EMPTY=0,f.LOADING=f.prototype.LOADING=1,f.DONE=f.prototype.DONE=2,Object.defineProperties(f.prototype,{EMPTY:n,LOADING:n,DONE:n,readAsArrayBuffer:d,readAsBinaryString:d,readAsText:d,readAsDataURL:d,abort:d,readyState:d,result:d,error:d,onloadstart:d,onprogress:d,onload:d,onabort:d,onerror:d,onloadend:d,[Symbol.toStringTag]:{value:`FileReader`,writable:!1,enumerable:!1,configurable:!0}}),Object.defineProperties(f,{EMPTY:n,LOADING:n,DONE:n}),t.exports={FileReader:f}})),Jt=U(((e,t)=>{t.exports={kConstruct:Oe().kConstruct}})),Yt=U(((e,t)=>{let n=W(`node:assert`),{URLSerializer:r}=Ge(),{isValidHeaderName:i}=qe();function a(e,t,n=!1){return r(e,n)===r(t,n)}function o(e){n(e!==null);let t=[];for(let n of e.split(`,`))n=n.trim(),i(n)&&t.push(n);return t}t.exports={urlEquals:a,getFieldValues:o}})),Xt=U(((e,t)=>{let{kConstruct:n}=Jt(),{urlEquals:r,getFieldValues:i}=Yt(),{kEnumerableProperty:a,isDisturbed:o}=Me(),{webidl:s}=Ke(),{Response:c,cloneResponse:l,fromInnerResponse:u}=zt(),{Request:d,fromInnerRequest:f}=Vt(),{kState:p}=Je(),{fetching:m}=Ht(),{urlIsHttpHttpsScheme:h,createDeferredPromise:g,readAllBytes:v}=qe(),y=W(`node:assert`);var b=class e{#e;constructor(){arguments[0]!==n&&s.illegalConstructor(),s.util.markAsUncloneable(this),this.#e=arguments[1]}async match(t,n={}){s.brandCheck(this,e);let r=`Cache.match`;s.argumentLengthCheck(arguments,1,r),t=s.converters.RequestInfo(t,r,`request`),n=s.converters.CacheQueryOptions(n,r,`options`);let i=this.#i(t,n,1);if(i.length!==0)return i[0]}async matchAll(t=void 0,n={}){s.brandCheck(this,e);let r=`Cache.matchAll`;return t!==void 0&&(t=s.converters.RequestInfo(t,r,`request`)),n=s.converters.CacheQueryOptions(n,r,`options`),this.#i(t,n)}async add(t){s.brandCheck(this,e);let n=`Cache.add`;s.argumentLengthCheck(arguments,1,n),t=s.converters.RequestInfo(t,n,`request`);let r=[t];return await this.addAll(r)}async addAll(t){s.brandCheck(this,e);let n=`Cache.addAll`;s.argumentLengthCheck(arguments,1,n);let r=[],a=[];for(let e of t){if(e===void 0)throw s.errors.conversionFailed({prefix:n,argument:`Argument 1`,types:[`undefined is not allowed`]});if(e=s.converters.RequestInfo(e),typeof e==`string`)continue;let t=e[p];if(!h(t.url)||t.method!==`GET`)throw s.errors.exception({header:n,message:`Expected http/s scheme when method is not GET.`})}let o=[];for(let e of t){let t=new d(e)[p];if(!h(t.url))throw s.errors.exception({header:n,message:`Expected http/s scheme.`});t.initiator=`fetch`,t.destination=`subresource`,a.push(t);let c=g();o.push(m({request:t,processResponse(e){if(e.type===`error`||e.status===206||e.status<200||e.status>299)c.reject(s.errors.exception({header:`Cache.addAll`,message:`Received an invalid status code or the request failed.`}));else if(e.headersList.contains(`vary`)){let t=i(e.headersList.get(`vary`));for(let e of t)if(e===`*`){c.reject(s.errors.exception({header:`Cache.addAll`,message:`invalid vary field value`}));for(let e of o)e.abort();return}}},processResponseEndOfBody(e){if(e.aborted){c.reject(new DOMException(`aborted`,`AbortError`));return}c.resolve(e)}})),r.push(c.promise)}let c=await Promise.all(r),l=[],u=0;for(let e of c){let t={type:`put`,request:a[u],response:e};l.push(t),u++}let f=g(),v=null;try{this.#t(l)}catch(e){v=e}return queueMicrotask(()=>{v===null?f.resolve(void 0):f.reject(v)}),f.promise}async put(t,n){s.brandCheck(this,e);let r=`Cache.put`;s.argumentLengthCheck(arguments,2,r),t=s.converters.RequestInfo(t,r,`request`),n=s.converters.Response(n,r,`response`);let a=null;if(a=t instanceof d?t[p]:new d(t)[p],!h(a.url)||a.method!==`GET`)throw s.errors.exception({header:r,message:`Expected an http/s scheme when method is not GET`});let c=n[p];if(c.status===206)throw s.errors.exception({header:r,message:`Got 206 status`});if(c.headersList.contains(`vary`)){let e=i(c.headersList.get(`vary`));for(let t of e)if(t===`*`)throw s.errors.exception({header:r,message:`Got * vary field value`})}if(c.body&&(o(c.body.stream)||c.body.stream.locked))throw s.errors.exception({header:r,message:`Response body is locked or disturbed`});let u=l(c),f=g();c.body==null?f.resolve(void 0):v(c.body.stream.getReader()).then(f.resolve,f.reject);let m=[],y={type:`put`,request:a,response:u};m.push(y);let b=await f.promise;u.body!=null&&(u.body.source=b);let x=g(),S=null;try{this.#t(m)}catch(e){S=e}return queueMicrotask(()=>{S===null?x.resolve():x.reject(S)}),x.promise}async delete(t,n={}){s.brandCheck(this,e);let r=`Cache.delete`;s.argumentLengthCheck(arguments,1,r),t=s.converters.RequestInfo(t,r,`request`),n=s.converters.CacheQueryOptions(n,r,`options`);let i=null;if(t instanceof d){if(i=t[p],i.method!==`GET`&&!n.ignoreMethod)return!1}else y(typeof t==`string`),i=new d(t)[p];let a=[],o={type:`delete`,request:i,options:n};a.push(o);let c=g(),l=null,u;try{u=this.#t(a)}catch(e){l=e}return queueMicrotask(()=>{l===null?c.resolve(!!u?.length):c.reject(l)}),c.promise}async keys(t=void 0,n={}){s.brandCheck(this,e);let r=`Cache.keys`;t!==void 0&&(t=s.converters.RequestInfo(t,r,`request`)),n=s.converters.CacheQueryOptions(n,r,`options`);let i=null;if(t!==void 0)if(t instanceof d){if(i=t[p],i.method!==`GET`&&!n.ignoreMethod)return[]}else typeof t==`string`&&(i=new d(t)[p]);let a=g(),o=[];if(t===void 0)for(let e of this.#e)o.push(e[0]);else{let e=this.#n(i,n);for(let t of e)o.push(t[0])}return queueMicrotask(()=>{let e=[];for(let t of o){let n=f(t,new AbortController().signal,`immutable`);e.push(n)}a.resolve(Object.freeze(e))}),a.promise}#t(e){let t=this.#e,n=[...t],r=[],i=[];try{for(let n of e){if(n.type!==`delete`&&n.type!==`put`)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`operation type does not match "delete" or "put"`});if(n.type===`delete`&&n.response!=null)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`delete operation should not have an associated response`});if(this.#n(n.request,n.options,r).length)throw new DOMException(`???`,`InvalidStateError`);let e;if(n.type===`delete`){if(e=this.#n(n.request,n.options),e.length===0)return[];for(let n of e){let e=t.indexOf(n);y(e!==-1),t.splice(e,1)}}else if(n.type===`put`){if(n.response==null)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`put operation should have an associated response`});let i=n.request;if(!h(i.url))throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`expected http or https scheme`});if(i.method!==`GET`)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`not get method`});if(n.options!=null)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`options must not be defined`});e=this.#n(n.request);for(let n of e){let e=t.indexOf(n);y(e!==-1),t.splice(e,1)}t.push([n.request,n.response]),r.push([n.request,n.response])}i.push([n.request,n.response])}return i}catch(e){throw this.#e.length=0,this.#e=n,e}}#n(e,t,n){let r=[],i=n??this.#e;for(let n of i){let[i,a]=n;this.#r(e,i,a,t)&&r.push(n)}return r}#r(e,t,n=null,a){let o=new URL(e.url),s=new URL(t.url);if(a?.ignoreSearch&&(s.search=``,o.search=``),!r(o,s,!0))return!1;if(n==null||a?.ignoreVary||!n.headersList.contains(`vary`))return!0;let c=i(n.headersList.get(`vary`));for(let n of c)if(n===`*`||t.headersList.get(n)!==e.headersList.get(n))return!1;return!0}#i(e,t,n=1/0){let r=null;if(e!==void 0)if(e instanceof d){if(r=e[p],r.method!==`GET`&&!t.ignoreMethod)return[]}else typeof e==`string`&&(r=new d(e)[p]);let i=[];if(e===void 0)for(let e of this.#e)i.push(e[1]);else{let e=this.#n(r,t);for(let t of e)i.push(t[1])}let a=[];for(let e of i){let t=u(e,`immutable`);if(a.push(t.clone()),a.length>=n)break}return Object.freeze(a)}};Object.defineProperties(b.prototype,{[Symbol.toStringTag]:{value:`Cache`,configurable:!0},match:a,matchAll:a,add:a,addAll:a,put:a,delete:a,keys:a});let x=[{key:`ignoreSearch`,converter:s.converters.boolean,defaultValue:()=>!1},{key:`ignoreMethod`,converter:s.converters.boolean,defaultValue:()=>!1},{key:`ignoreVary`,converter:s.converters.boolean,defaultValue:()=>!1}];s.converters.CacheQueryOptions=s.dictionaryConverter(x),s.converters.MultiCacheQueryOptions=s.dictionaryConverter([...x,{key:`cacheName`,converter:s.converters.DOMString}]),s.converters.Response=s.interfaceConverter(c),s.converters[`sequence`]=s.sequenceConverter(s.converters.RequestInfo),t.exports={Cache:b}})),Zt=U(((e,t)=>{let{kConstruct:n}=Jt(),{Cache:r}=Xt(),{webidl:i}=Ke(),{kEnumerableProperty:a}=Me();var o=class e{#e=new Map;constructor(){arguments[0]!==n&&i.illegalConstructor(),i.util.markAsUncloneable(this)}async match(t,a={}){if(i.brandCheck(this,e),i.argumentLengthCheck(arguments,1,`CacheStorage.match`),t=i.converters.RequestInfo(t),a=i.converters.MultiCacheQueryOptions(a),a.cacheName!=null){if(this.#e.has(a.cacheName))return await new r(n,this.#e.get(a.cacheName)).match(t,a)}else for(let e of this.#e.values()){let i=await new r(n,e).match(t,a);if(i!==void 0)return i}}async has(t){i.brandCheck(this,e);let n=`CacheStorage.has`;return i.argumentLengthCheck(arguments,1,n),t=i.converters.DOMString(t,n,`cacheName`),this.#e.has(t)}async open(t){i.brandCheck(this,e);let a=`CacheStorage.open`;if(i.argumentLengthCheck(arguments,1,a),t=i.converters.DOMString(t,a,`cacheName`),this.#e.has(t))return new r(n,this.#e.get(t));let o=[];return this.#e.set(t,o),new r(n,o)}async delete(t){i.brandCheck(this,e);let n=`CacheStorage.delete`;return i.argumentLengthCheck(arguments,1,n),t=i.converters.DOMString(t,n,`cacheName`),this.#e.delete(t)}async keys(){return i.brandCheck(this,e),[...this.#e.keys()]}};Object.defineProperties(o.prototype,{[Symbol.toStringTag]:{value:`CacheStorage`,configurable:!0},match:a,has:a,open:a,delete:a,keys:a}),t.exports={CacheStorage:o}})),Qt=U(((e,t)=>{t.exports={maxAttributeValueSize:1024,maxNameValuePairSize:4096}})),$t=U(((e,t)=>{function n(e){for(let t=0;t=0&&n<=8||n>=10&&n<=31||n===127)return!0}return!1}function r(e){for(let t=0;t126||n===34||n===40||n===41||n===60||n===62||n===64||n===44||n===59||n===58||n===92||n===47||n===91||n===93||n===63||n===61||n===123||n===125)throw Error(`Invalid cookie name`)}}function i(e){let t=e.length,n=0;if(e[0]===`"`){if(t===1||e[t-1]!==`"`)throw Error(`Invalid cookie value`);--t,++n}for(;n126||t===34||t===44||t===59||t===92)throw Error(`Invalid cookie value`)}}function a(e){for(let t=0;tt.toString().padStart(2,`0`));function u(e){return typeof e==`number`&&(e=new Date(e)),`${s[e.getUTCDay()]}, ${l[e.getUTCDate()]} ${c[e.getUTCMonth()]} ${e.getUTCFullYear()} ${l[e.getUTCHours()]}:${l[e.getUTCMinutes()]}:${l[e.getUTCSeconds()]} GMT`}function d(e){if(e<0)throw Error(`Invalid cookie max-age`)}function f(e){if(e.name.length===0)return null;r(e.name),i(e.value);let t=[`${e.name}=${e.value}`];e.name.startsWith(`__Secure-`)&&(e.secure=!0),e.name.startsWith(`__Host-`)&&(e.secure=!0,e.domain=null,e.path=`/`),e.secure&&t.push(`Secure`),e.httpOnly&&t.push(`HttpOnly`),typeof e.maxAge==`number`&&(d(e.maxAge),t.push(`Max-Age=${e.maxAge}`)),e.domain&&(o(e.domain),t.push(`Domain=${e.domain}`)),e.path&&(a(e.path),t.push(`Path=${e.path}`)),e.expires&&e.expires.toString()!==`Invalid Date`&&t.push(`Expires=${u(e.expires)}`),e.sameSite&&t.push(`SameSite=${e.sameSite}`);for(let n of e.unparsed){if(!n.includes(`=`))throw Error(`Invalid unparsed`);let[e,...r]=n.split(`=`);t.push(`${e.trim()}=${r.join(`=`)}`)}return t.join(`; `)}t.exports={isCTLExcludingHtab:n,validateCookieName:r,validateCookiePath:a,validateCookieValue:i,toIMFDate:u,stringify:f}})),en=U(((e,t)=>{let{maxNameValuePairSize:n,maxAttributeValueSize:r}=Qt(),{isCTLExcludingHtab:i}=$t(),{collectASequenceOfCodePointsFast:a}=Ge(),o=W(`node:assert`);function s(e){if(i(e))return null;let t=``,r=``,o=``,s=``;if(e.includes(`;`)){let n={position:0};t=a(`;`,e,n),r=e.slice(n.position)}else t=e;if(!t.includes(`=`))s=t;else{let e={position:0};o=a(`=`,t,e),s=t.slice(e.position+1)}return o=o.trim(),s=s.trim(),o.length+s.length>n?null:{name:o,value:s,...c(r)}}function c(e,t={}){if(e.length===0)return t;o(e[0]===`;`),e=e.slice(1);let n=``;e.includes(`;`)?(n=a(`;`,e,{position:0}),e=e.slice(n.length)):(n=e,e=``);let i=``,s=``;if(n.includes(`=`)){let e={position:0};i=a(`=`,n,e),s=n.slice(e.position+1)}else i=n;if(i=i.trim(),s=s.trim(),s.length>r)return c(e,t);let l=i.toLowerCase();if(l===`expires`)t.expires=new Date(s);else if(l===`max-age`){let n=s.charCodeAt(0);if((n<48||n>57)&&s[0]!==`-`||!/^\d+$/.test(s))return c(e,t);t.maxAge=Number(s)}else if(l===`domain`){let e=s;e[0]===`.`&&(e=e.slice(1)),e=e.toLowerCase(),t.domain=e}else if(l===`path`){let e=``;e=s.length===0||s[0]!==`/`?`/`:s,t.path=e}else if(l===`secure`)t.secure=!0;else if(l===`httponly`)t.httpOnly=!0;else if(l===`samesite`){let e=`Default`,n=s.toLowerCase();n.includes(`none`)&&(e=`None`),n.includes(`strict`)&&(e=`Strict`),n.includes(`lax`)&&(e=`Lax`),t.sameSite=e}else t.unparsed??=[],t.unparsed.push(`${i}=${s}`);return c(e,t)}t.exports={parseSetCookie:s,parseUnparsedAttributes:c}})),tn=U(((e,t)=>{let{parseSetCookie:n}=en(),{stringify:r}=$t(),{webidl:i}=Ke(),{Headers:a}=Rt();function o(e){i.argumentLengthCheck(arguments,1,`getCookies`),i.brandCheck(e,a,{strict:!1});let t=e.get(`cookie`),n={};if(!t)return n;for(let e of t.split(`;`)){let[t,...r]=e.split(`=`);n[t.trim()]=r.join(`=`)}return n}function s(e,t,n){i.brandCheck(e,a,{strict:!1});let r=`deleteCookie`;i.argumentLengthCheck(arguments,2,r),t=i.converters.DOMString(t,r,`name`),n=i.converters.DeleteCookieAttributes(n),l(e,{name:t,value:``,expires:new Date(0),...n})}function c(e){i.argumentLengthCheck(arguments,1,`getSetCookies`),i.brandCheck(e,a,{strict:!1});let t=e.getSetCookie();return t?t.map(e=>n(e)):[]}function l(e,t){i.argumentLengthCheck(arguments,2,`setCookie`),i.brandCheck(e,a,{strict:!1}),t=i.converters.Cookie(t);let n=r(t);n&&e.append(`Set-Cookie`,n)}i.converters.DeleteCookieAttributes=i.dictionaryConverter([{converter:i.nullableConverter(i.converters.DOMString),key:`path`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:`domain`,defaultValue:()=>null}]),i.converters.Cookie=i.dictionaryConverter([{converter:i.converters.DOMString,key:`name`},{converter:i.converters.DOMString,key:`value`},{converter:i.nullableConverter(e=>typeof e==`number`?i.converters[`unsigned long long`](e):new Date(e)),key:`expires`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters[`long long`]),key:`maxAge`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:`domain`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:`path`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.boolean),key:`secure`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.boolean),key:`httpOnly`,defaultValue:()=>null},{converter:i.converters.USVString,key:`sameSite`,allowedValues:[`Strict`,`Lax`,`None`]},{converter:i.sequenceConverter(i.converters.DOMString),key:`unparsed`,defaultValue:()=>[]}]),t.exports={getCookies:o,deleteCookie:s,getSetCookies:c,setCookie:l}})),nn=U(((e,t)=>{let{webidl:n}=Ke(),{kEnumerableProperty:r}=Me(),{kConstruct:i}=Oe(),{MessagePort:a}=W(`node:worker_threads`);var o=class e extends Event{#e;constructor(e,t={}){if(e===i){super(arguments[1],arguments[2]),n.util.markAsUncloneable(this);return}let r=`MessageEvent constructor`;n.argumentLengthCheck(arguments,1,r),e=n.converters.DOMString(e,r,`type`),t=n.converters.MessageEventInit(t,r,`eventInitDict`),super(e,t),this.#e=t,n.util.markAsUncloneable(this)}get data(){return n.brandCheck(this,e),this.#e.data}get origin(){return n.brandCheck(this,e),this.#e.origin}get lastEventId(){return n.brandCheck(this,e),this.#e.lastEventId}get source(){return n.brandCheck(this,e),this.#e.source}get ports(){return n.brandCheck(this,e),Object.isFrozen(this.#e.ports)||Object.freeze(this.#e.ports),this.#e.ports}initMessageEvent(t,r=!1,i=!1,a=null,o=``,s=``,c=null,l=[]){return n.brandCheck(this,e),n.argumentLengthCheck(arguments,1,`MessageEvent.initMessageEvent`),new e(t,{bubbles:r,cancelable:i,data:a,origin:o,lastEventId:s,source:c,ports:l})}static createFastMessageEvent(t,n){let r=new e(i,t,n);return r.#e=n,r.#e.data??=null,r.#e.origin??=``,r.#e.lastEventId??=``,r.#e.source??=null,r.#e.ports??=[],r}};let{createFastMessageEvent:s}=o;delete o.createFastMessageEvent;var c=class e extends Event{#e;constructor(e,t={}){let r=`CloseEvent constructor`;n.argumentLengthCheck(arguments,1,r),e=n.converters.DOMString(e,r,`type`),t=n.converters.CloseEventInit(t),super(e,t),this.#e=t,n.util.markAsUncloneable(this)}get wasClean(){return n.brandCheck(this,e),this.#e.wasClean}get code(){return n.brandCheck(this,e),this.#e.code}get reason(){return n.brandCheck(this,e),this.#e.reason}},l=class e extends Event{#e;constructor(e,t){let r=`ErrorEvent constructor`;n.argumentLengthCheck(arguments,1,r),super(e,t),n.util.markAsUncloneable(this),e=n.converters.DOMString(e,r,`type`),t=n.converters.ErrorEventInit(t??{}),this.#e=t}get message(){return n.brandCheck(this,e),this.#e.message}get filename(){return n.brandCheck(this,e),this.#e.filename}get lineno(){return n.brandCheck(this,e),this.#e.lineno}get colno(){return n.brandCheck(this,e),this.#e.colno}get error(){return n.brandCheck(this,e),this.#e.error}};Object.defineProperties(o.prototype,{[Symbol.toStringTag]:{value:`MessageEvent`,configurable:!0},data:r,origin:r,lastEventId:r,source:r,ports:r,initMessageEvent:r}),Object.defineProperties(c.prototype,{[Symbol.toStringTag]:{value:`CloseEvent`,configurable:!0},reason:r,code:r,wasClean:r}),Object.defineProperties(l.prototype,{[Symbol.toStringTag]:{value:`ErrorEvent`,configurable:!0},message:r,filename:r,lineno:r,colno:r,error:r}),n.converters.MessagePort=n.interfaceConverter(a),n.converters[`sequence`]=n.sequenceConverter(n.converters.MessagePort);let u=[{key:`bubbles`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`cancelable`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`composed`,converter:n.converters.boolean,defaultValue:()=>!1}];n.converters.MessageEventInit=n.dictionaryConverter([...u,{key:`data`,converter:n.converters.any,defaultValue:()=>null},{key:`origin`,converter:n.converters.USVString,defaultValue:()=>``},{key:`lastEventId`,converter:n.converters.DOMString,defaultValue:()=>``},{key:`source`,converter:n.nullableConverter(n.converters.MessagePort),defaultValue:()=>null},{key:`ports`,converter:n.converters[`sequence`],defaultValue:()=>[]}]),n.converters.CloseEventInit=n.dictionaryConverter([...u,{key:`wasClean`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`code`,converter:n.converters[`unsigned short`],defaultValue:()=>0},{key:`reason`,converter:n.converters.USVString,defaultValue:()=>``}]),n.converters.ErrorEventInit=n.dictionaryConverter([...u,{key:`message`,converter:n.converters.DOMString,defaultValue:()=>``},{key:`filename`,converter:n.converters.USVString,defaultValue:()=>``},{key:`lineno`,converter:n.converters[`unsigned long`],defaultValue:()=>0},{key:`colno`,converter:n.converters[`unsigned long`],defaultValue:()=>0},{key:`error`,converter:n.converters.any}]),t.exports={MessageEvent:o,CloseEvent:c,ErrorEvent:l,createFastMessageEvent:s}})),rn=U(((e,t)=>{t.exports={uid:`258EAFA5-E914-47DA-95CA-C5AB0DC85B11`,sentCloseFrameState:{NOT_SENT:0,PROCESSING:1,SENT:2},staticPropertyDescriptors:{enumerable:!0,writable:!1,configurable:!1},states:{CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3},opcodes:{CONTINUATION:0,TEXT:1,BINARY:2,CLOSE:8,PING:9,PONG:10},maxUnsigned16Bit:2**16-1,parserStates:{INFO:0,PAYLOADLENGTH_16:2,PAYLOADLENGTH_64:3,READ_DATA:4},emptyBuffer:Buffer.allocUnsafe(0),sendHints:{string:1,typedArray:2,arrayBuffer:3,blob:4}}})),an=U(((e,t)=>{t.exports={kWebSocketURL:Symbol(`url`),kReadyState:Symbol(`ready state`),kController:Symbol(`controller`),kResponse:Symbol(`response`),kBinaryType:Symbol(`binary type`),kSentClose:Symbol(`sent close`),kReceivedClose:Symbol(`received close`),kByteParser:Symbol(`byte parser`)}})),on=U(((e,t)=>{let{kReadyState:n,kController:r,kResponse:i,kBinaryType:a,kWebSocketURL:o}=an(),{states:s,opcodes:c}=rn(),{ErrorEvent:l,createFastMessageEvent:u}=nn(),{isUtf8:d}=W(`node:buffer`),{collectASequenceOfCodePointsFast:f,removeHTTPWhitespace:p}=Ge();function m(e){return e[n]===s.CONNECTING}function h(e){return e[n]===s.OPEN}function g(e){return e[n]===s.CLOSING}function v(e){return e[n]===s.CLOSED}function y(e,t,n=(e,t)=>new Event(e,t),r={}){let i=n(e,r);t.dispatchEvent(i)}function b(e,t,r){if(e[n]!==s.OPEN)return;let i;if(t===c.TEXT)try{i=N(r)}catch{w(e,`Received invalid UTF-8 in text frame.`);return}else t===c.BINARY&&(i=e[a]===`blob`?new Blob([r]):x(r));y(`message`,e,u,{origin:e[o].origin,data:i})}function x(e){return e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function S(e){if(e.length===0)return!1;for(let t=0;t126||n===34||n===40||n===41||n===44||n===47||n===58||n===59||n===60||n===61||n===62||n===63||n===64||n===91||n===92||n===93||n===123||n===125)return!1}return!0}function C(e){return e>=1e3&&e<1015?e!==1004&&e!==1005&&e!==1006:e>=3e3&&e<=4999}function w(e,t){let{[r]:n,[i]:a}=e;n.abort(),a?.socket&&!a.socket.destroyed&&a.socket.destroy(),t&&y(`error`,e,(e,t)=>new l(e,t),{error:Error(t),message:t})}function T(e){return e===c.CLOSE||e===c.PING||e===c.PONG}function E(e){return e===c.CONTINUATION}function D(e){return e===c.TEXT||e===c.BINARY}function O(e){return D(e)||E(e)||T(e)}function k(e){let t={position:0},n=new Map;for(;t.position57)return!1}let t=Number.parseInt(e,10);return t>=8&&t<=15}let j=typeof process.versions.icu==`string`,M=j?new TextDecoder(`utf-8`,{fatal:!0}):void 0,N=j?M.decode.bind(M):function(e){if(d(e))return e.toString(`utf-8`);throw TypeError(`Invalid utf-8 received.`)};t.exports={isConnecting:m,isEstablished:h,isClosing:g,isClosed:v,fireEvent:y,isValidSubprotocol:S,isValidStatusCode:C,failWebsocketConnection:w,websocketMessageReceived:b,utf8Decode:N,isControlFrame:T,isContinuationFrame:E,isTextBinaryFrame:D,isValidOpcode:O,parseExtensions:k,isValidClientWindowBits:A}})),sn=U(((e,t)=>{let{maxUnsigned16Bit:n}=rn(),r=16386,i,a=null,o=r;try{i=W(`node:crypto`)}catch{i={randomFillSync:function(e,t,n){for(let t=0;tn?(o+=8,a=127):i>125&&(o+=2,a=126);let c=Buffer.allocUnsafe(i+o);c[0]=c[1]=0,c[0]|=128,c[0]=(c[0]&240)+e,c[o-4]=r[0],c[o-3]=r[1],c[o-2]=r[2],c[o-1]=r[3],c[1]=a,a===126?c.writeUInt16BE(i,2):a===127&&(c[2]=c[3]=0,c.writeUIntBE(i,4,6)),c[1]|=128;for(let e=0;e{let{uid:n,states:r,sentCloseFrameState:i,emptyBuffer:a,opcodes:o}=rn(),{kReadyState:s,kSentClose:c,kByteParser:l,kReceivedClose:u,kResponse:d}=an(),{fireEvent:f,failWebsocketConnection:p,isClosing:m,isClosed:h,isEstablished:g,parseExtensions:v}=on(),{channels:y}=Ne(),{CloseEvent:b}=nn(),{makeRequest:x}=Vt(),{fetching:S}=Ht(),{Headers:C,getHeadersList:w}=Rt(),{getDecodeSplit:T}=qe(),{WebsocketFrameSend:E}=sn(),D;try{D=W(`node:crypto`)}catch{}function O(e,t,r,i,a,o){let s=e;s.protocol=e.protocol===`ws:`?`http:`:`https:`;let c=x({urlList:[s],client:r,serviceWorkers:`none`,referrer:`no-referrer`,mode:`websocket`,credentials:`include`,cache:`no-store`,redirect:`error`});o.headers&&(c.headersList=w(new C(o.headers)));let l=D.randomBytes(16).toString(`base64`);c.headersList.append(`sec-websocket-key`,l),c.headersList.append(`sec-websocket-version`,`13`);for(let e of t)c.headersList.append(`sec-websocket-protocol`,e);return c.headersList.append(`sec-websocket-extensions`,`permessage-deflate; client_max_window_bits`),S({request:c,useParallelQueue:!0,dispatcher:o.dispatcher,processResponse(e){if(e.type===`error`||e.status!==101){p(i,`Received network error or non-101 status code.`);return}if(t.length!==0&&!e.headersList.get(`Sec-WebSocket-Protocol`)){p(i,`Server did not respond with sent protocols.`);return}if(e.headersList.get(`Upgrade`)?.toLowerCase()!==`websocket`){p(i,`Server did not set Upgrade header to "websocket".`);return}if(e.headersList.get(`Connection`)?.toLowerCase()!==`upgrade`){p(i,`Server did not set Connection header to "upgrade".`);return}if(e.headersList.get(`Sec-WebSocket-Accept`)!==D.createHash(`sha1`).update(l+n).digest(`base64`)){p(i,`Incorrect hash received in Sec-WebSocket-Accept header.`);return}let r=e.headersList.get(`Sec-WebSocket-Extensions`),o;if(r!==null&&(o=v(r),!o.has(`permessage-deflate`))){p(i,`Sec-WebSocket-Extensions header does not match.`);return}let s=e.headersList.get(`Sec-WebSocket-Protocol`);if(s!==null&&!T(`sec-websocket-protocol`,c.headersList).includes(s)){p(i,`Protocol was not set in the opening handshake.`);return}e.socket.on(`data`,A),e.socket.on(`close`,j),e.socket.on(`error`,M),y.open.hasSubscribers&&y.open.publish({address:e.socket.address(),protocol:s,extensions:r}),a(e,o)}})}function k(e,t,n,l){if(!(m(e)||h(e)))if(!g(e))p(e,`Connection was closed before it was established.`),e[s]=r.CLOSING;else if(e[c]===i.NOT_SENT){e[c]=i.PROCESSING;let u=new E;t!==void 0&&n===void 0?(u.frameData=Buffer.allocUnsafe(2),u.frameData.writeUInt16BE(t,0)):t!==void 0&&n!==void 0?(u.frameData=Buffer.allocUnsafe(2+l),u.frameData.writeUInt16BE(t,0),u.frameData.write(n,2,`utf-8`)):u.frameData=a,e[d].socket.write(u.createFrame(o.CLOSE)),e[c]=i.SENT,e[s]=r.CLOSING}else e[s]=r.CLOSING}function A(e){this.ws[l].write(e)||this.pause()}function j(){let{ws:e}=this,{[d]:t}=e;t.socket.off(`data`,A),t.socket.off(`close`,j),t.socket.off(`error`,M);let n=e[c]===i.SENT&&e[u],a=1005,o=``,p=e[l].closingInfo;p&&!p.error?(a=p.code??1005,o=p.reason):e[u]||(a=1006),e[s]=r.CLOSED,f(`close`,e,(e,t)=>new b(e,t),{wasClean:n,code:a,reason:o}),y.close.hasSubscribers&&y.close.publish({websocket:e,code:a,reason:o})}function M(e){let{ws:t}=this;t[s]=r.CLOSING,y.socketError.hasSubscribers&&y.socketError.publish(e),this.destroy()}t.exports={establishWebSocketConnection:O,closeWebSocketConnection:k}})),ln=U(((e,t)=>{let{createInflateRaw:n,Z_DEFAULT_WINDOWBITS:r}=W(`node:zlib`),{isValidClientWindowBits:i}=on(),{MessageSizeExceededError:a}=ke(),o=Buffer.from([0,0,255,255]),s=Symbol(`kBuffer`),c=Symbol(`kLength`);t.exports={PerMessageDeflate:class{#e;#t={};#n=!1;#r=null;constructor(e){this.#t.serverNoContextTakeover=e.has(`server_no_context_takeover`),this.#t.serverMaxWindowBits=e.get(`server_max_window_bits`)}decompress(e,t,l){if(this.#n){l(new a);return}if(!this.#e){let e=r;if(this.#t.serverMaxWindowBits){if(!i(this.#t.serverMaxWindowBits)){l(Error(`Invalid server_max_window_bits`));return}e=Number.parseInt(this.#t.serverMaxWindowBits)}try{this.#e=n({windowBits:e})}catch(e){l(e);return}this.#e[s]=[],this.#e[c]=0,this.#e.on(`data`,e=>{if(!this.#n){if(this.#e[c]+=e.length,this.#e[c]>4194304){if(this.#n=!0,this.#e.removeAllListeners(),this.#e.destroy(),this.#e=null,this.#r){let e=this.#r;this.#r=null,e(new a)}return}this.#e[s].push(e)}}),this.#e.on(`error`,e=>{this.#e=null,l(e)})}this.#r=l,this.#e.write(e),t&&this.#e.write(o),this.#e.flush(()=>{if(this.#n||!this.#e)return;let e=Buffer.concat(this.#e[s],this.#e[c]);this.#e[s].length=0,this.#e[c]=0,this.#r=null,l(null,e)})}}}})),un=U(((e,t)=>{let{Writable:n}=W(`node:stream`),r=W(`node:assert`),{parserStates:i,opcodes:a,states:o,emptyBuffer:s,sentCloseFrameState:c}=rn(),{kReadyState:l,kSentClose:u,kResponse:d,kReceivedClose:f}=an(),{channels:p}=Ne(),{isValidStatusCode:m,isValidOpcode:h,failWebsocketConnection:g,websocketMessageReceived:v,utf8Decode:y,isControlFrame:b,isTextBinaryFrame:x,isContinuationFrame:S}=on(),{WebsocketFrameSend:C}=sn(),{closeWebSocketConnection:w}=cn(),{PerMessageDeflate:T}=ln();t.exports={ByteParser:class extends n{#e=[];#t=0;#n=!1;#r=i.INFO;#i={};#a=[];#o;constructor(e,t){super(),this.ws=e,this.#o=t??new Map,this.#o.has(`permessage-deflate`)&&this.#o.set(`permessage-deflate`,new T(t))}_write(e,t,n){this.#e.push(e),this.#t+=e.length,this.#n=!0,this.run(n)}run(e){for(;this.#n;)if(this.#r===i.INFO){if(this.#t<2)return e();let t=this.consume(2),n=(t[0]&128)!=0,r=t[0]&15,o=(t[1]&128)==128,s=!n&&r!==a.CONTINUATION,c=t[1]&127,l=t[0]&64,u=t[0]&32,d=t[0]&16;if(!h(r))return g(this.ws,`Invalid opcode received`),e();if(o)return g(this.ws,`Frame cannot be masked`),e();if(l!==0&&!this.#o.has(`permessage-deflate`)){g(this.ws,`Expected RSV1 to be clear.`);return}if(u!==0||d!==0){g(this.ws,`RSV1, RSV2, RSV3 must be clear`);return}if(s&&!x(r)){g(this.ws,`Invalid frame type was fragmented.`);return}if(x(r)&&this.#a.length>0){g(this.ws,`Expected continuation frame`);return}if(this.#i.fragmented&&s){g(this.ws,`Fragmented frame exceeded 125 bytes.`);return}if((c>125||s)&&b(r)){g(this.ws,`Control frame either too large or fragmented`);return}if(S(r)&&this.#a.length===0&&!this.#i.compressed){g(this.ws,`Unexpected continuation frame`);return}c<=125?(this.#i.payloadLength=c,this.#r=i.READ_DATA):c===126?this.#r=i.PAYLOADLENGTH_16:c===127&&(this.#r=i.PAYLOADLENGTH_64),x(r)&&(this.#i.binaryType=r,this.#i.compressed=l!==0),this.#i.opcode=r,this.#i.masked=o,this.#i.fin=n,this.#i.fragmented=s}else if(this.#r===i.PAYLOADLENGTH_16){if(this.#t<2)return e();let t=this.consume(2);this.#i.payloadLength=t.readUInt16BE(0),this.#r=i.READ_DATA}else if(this.#r===i.PAYLOADLENGTH_64){if(this.#t<8)return e();let t=this.consume(8),n=t.readUInt32BE(0),r=t.readUInt32BE(4);if(n!==0||r>2**31-1){g(this.ws,`Received payload length > 2^31 bytes.`);return}this.#i.payloadLength=r,this.#r=i.READ_DATA}else if(this.#r===i.READ_DATA){if(this.#t{if(t){g(this.ws,t.message);return}if(this.#a.push(n),!this.#i.fin){this.#r=i.INFO,this.#n=!0,this.run(e);return}v(this.ws,this.#i.binaryType,Buffer.concat(this.#a)),this.#n=!0,this.#r=i.INFO,this.#a.length=0,this.run(e)}),this.#n=!1;break}else{if(this.#a.push(t),!this.#i.fragmented&&this.#i.fin){let e=Buffer.concat(this.#a);v(this.ws,this.#i.binaryType,e),this.#a.length=0}this.#r=i.INFO}}}consume(e){if(e>this.#t)throw Error(`Called consume() before buffers satiated.`);if(e===0)return s;if(this.#e[0].length===e)return this.#t-=this.#e[0].length,this.#e.shift();let t=Buffer.allocUnsafe(e),n=0;for(;n!==e;){let r=this.#e[0],{length:i}=r;if(i+n===e){t.set(this.#e.shift(),n);break}else if(i+n>e){t.set(r.subarray(0,e-n),n),this.#e[0]=r.subarray(e-n);break}else t.set(this.#e.shift(),n),n+=r.length}return this.#t-=e,t}parseCloseBody(e){r(e.length!==1);let t;if(e.length>=2&&(t=e.readUInt16BE(0)),t!==void 0&&!m(t))return{code:1002,reason:`Invalid status code`,error:!0};let n=e.subarray(2);n[0]===239&&n[1]===187&&n[2]===191&&(n=n.subarray(3));try{n=y(n)}catch{return{code:1007,reason:`Invalid UTF-8`,error:!0}}return{code:t,reason:n,error:!1}}parseControlFrame(e){let{opcode:t,payloadLength:n}=this.#i;if(t===a.CLOSE){if(n===1)return g(this.ws,`Received close frame with a 1-byte body.`),!1;if(this.#i.closeInfo=this.parseCloseBody(e),this.#i.closeInfo.error){let{code:e,reason:t}=this.#i.closeInfo;return w(this.ws,e,t,t.length),g(this.ws,t),!1}if(this.ws[u]!==c.SENT){let e=s;this.#i.closeInfo.code&&(e=Buffer.allocUnsafe(2),e.writeUInt16BE(this.#i.closeInfo.code,0));let t=new C(e);this.ws[d].socket.write(t.createFrame(a.CLOSE),e=>{e||(this.ws[u]=c.SENT)})}return this.ws[l]=o.CLOSING,this.ws[f]=!0,!1}else if(t===a.PING){if(!this.ws[f]){let t=new C(e);this.ws[d].socket.write(t.createFrame(a.PONG)),p.ping.hasSubscribers&&p.ping.publish({payload:e})}}else t===a.PONG&&p.pong.hasSubscribers&&p.pong.publish({payload:e});return!0}get closingInfo(){return this.#i.closeInfo}}}})),dn=U(((e,t)=>{let{WebsocketFrameSend:n}=sn(),{opcodes:r,sendHints:i}=rn(),a=it(),o=Buffer[Symbol.species];var s=class{#e=new a;#t=!1;#n;constructor(e){this.#n=e}add(e,t,n){if(n!==i.blob){let r=c(e,n);if(!this.#t)this.#n.write(r,t);else{let e={promise:null,callback:t,frame:r};this.#e.push(e)}return}let r={promise:e.arrayBuffer().then(e=>{r.promise=null,r.frame=c(e,n)}),callback:t,frame:null};this.#e.push(r),this.#t||this.#r()}async#r(){this.#t=!0;let e=this.#e;for(;!e.isEmpty();){let t=e.shift();t.promise!==null&&await t.promise,this.#n.write(t.frame,t.callback),t.callback=t.frame=null}this.#t=!1}};function c(e,t){return new n(l(e,t)).createFrame(t===i.string?r.TEXT:r.BINARY)}function l(e,t){switch(t){case i.string:return Buffer.from(e);case i.arrayBuffer:case i.blob:return new o(e);case i.typedArray:return new o(e.buffer,e.byteOffset,e.byteLength)}}t.exports={SendQueue:s}})),fn=U(((e,t)=>{let{webidl:n}=Ke(),{URLSerializer:r}=Ge(),{environmentSettingsObject:i}=qe(),{staticPropertyDescriptors:a,states:o,sentCloseFrameState:s,sendHints:c}=rn(),{kWebSocketURL:l,kReadyState:u,kController:d,kBinaryType:f,kResponse:p,kSentClose:m,kByteParser:h}=an(),{isConnecting:g,isEstablished:v,isClosing:y,isValidSubprotocol:b,fireEvent:x}=on(),{establishWebSocketConnection:S,closeWebSocketConnection:C}=cn(),{ByteParser:w}=un(),{kEnumerableProperty:T,isBlobLike:E}=Me(),{getGlobalDispatcher:D}=Mt(),{types:O}=W(`node:util`),{ErrorEvent:k,CloseEvent:A}=nn(),{SendQueue:j}=dn();var M=class e extends EventTarget{#e={open:null,error:null,close:null,message:null};#t=0;#n=``;#r=``;#i;constructor(t,r=[]){super(),n.util.markAsUncloneable(this);let a=`WebSocket constructor`;n.argumentLengthCheck(arguments,1,a);let o=n.converters[`DOMString or sequence or WebSocketInit`](r,a,`options`);t=n.converters.USVString(t,a,`url`),r=o.protocols;let c=i.settingsObject.baseUrl,p;try{p=new URL(t,c)}catch(e){throw new DOMException(e,`SyntaxError`)}if(p.protocol===`http:`?p.protocol=`ws:`:p.protocol===`https:`&&(p.protocol=`wss:`),p.protocol!==`ws:`&&p.protocol!==`wss:`)throw new DOMException(`Expected a ws: or wss: protocol, got ${p.protocol}`,`SyntaxError`);if(p.hash||p.href.endsWith(`#`))throw new DOMException(`Got fragment`,`SyntaxError`);if(typeof r==`string`&&(r=[r]),r.length!==new Set(r.map(e=>e.toLowerCase())).size||r.length>0&&!r.every(e=>b(e)))throw new DOMException(`Invalid Sec-WebSocket-Protocol value`,`SyntaxError`);this[l]=new URL(p.href);let h=i.settingsObject;this[d]=S(p,r,h,this,(e,t)=>this.#a(e,t),o),this[u]=e.CONNECTING,this[m]=s.NOT_SENT,this[f]=`blob`}close(t=void 0,r=void 0){n.brandCheck(this,e);let i=`WebSocket.close`;if(t!==void 0&&(t=n.converters[`unsigned short`](t,i,`code`,{clamp:!0})),r!==void 0&&(r=n.converters.USVString(r,i,`reason`)),t!==void 0&&t!==1e3&&(t<3e3||t>4999))throw new DOMException(`invalid code`,`InvalidAccessError`);let a=0;if(r!==void 0&&(a=Buffer.byteLength(r),a>123))throw new DOMException(`Reason must be less than 123 bytes; received ${a}`,`SyntaxError`);C(this,t,r,a)}send(t){n.brandCheck(this,e);let r=`WebSocket.send`;if(n.argumentLengthCheck(arguments,1,r),t=n.converters.WebSocketSendData(t,r,`data`),g(this))throw new DOMException(`Sent before connected.`,`InvalidStateError`);if(!(!v(this)||y(this)))if(typeof t==`string`){let e=Buffer.byteLength(t);this.#t+=e,this.#i.add(t,()=>{this.#t-=e},c.string)}else O.isArrayBuffer(t)?(this.#t+=t.byteLength,this.#i.add(t,()=>{this.#t-=t.byteLength},c.arrayBuffer)):ArrayBuffer.isView(t)?(this.#t+=t.byteLength,this.#i.add(t,()=>{this.#t-=t.byteLength},c.typedArray)):E(t)&&(this.#t+=t.size,this.#i.add(t,()=>{this.#t-=t.size},c.blob))}get readyState(){return n.brandCheck(this,e),this[u]}get bufferedAmount(){return n.brandCheck(this,e),this.#t}get url(){return n.brandCheck(this,e),r(this[l])}get extensions(){return n.brandCheck(this,e),this.#r}get protocol(){return n.brandCheck(this,e),this.#n}get onopen(){return n.brandCheck(this,e),this.#e.open}set onopen(t){n.brandCheck(this,e),this.#e.open&&this.removeEventListener(`open`,this.#e.open),typeof t==`function`?(this.#e.open=t,this.addEventListener(`open`,t)):this.#e.open=null}get onerror(){return n.brandCheck(this,e),this.#e.error}set onerror(t){n.brandCheck(this,e),this.#e.error&&this.removeEventListener(`error`,this.#e.error),typeof t==`function`?(this.#e.error=t,this.addEventListener(`error`,t)):this.#e.error=null}get onclose(){return n.brandCheck(this,e),this.#e.close}set onclose(t){n.brandCheck(this,e),this.#e.close&&this.removeEventListener(`close`,this.#e.close),typeof t==`function`?(this.#e.close=t,this.addEventListener(`close`,t)):this.#e.close=null}get onmessage(){return n.brandCheck(this,e),this.#e.message}set onmessage(t){n.brandCheck(this,e),this.#e.message&&this.removeEventListener(`message`,this.#e.message),typeof t==`function`?(this.#e.message=t,this.addEventListener(`message`,t)):this.#e.message=null}get binaryType(){return n.brandCheck(this,e),this[f]}set binaryType(t){n.brandCheck(this,e),t!==`blob`&&t!==`arraybuffer`?this[f]=`blob`:this[f]=t}#a(e,t){this[p]=e;let n=new w(this,t);n.on(`drain`,N),n.on(`error`,P.bind(this)),e.socket.ws=this,this[h]=n,this.#i=new j(e.socket),this[u]=o.OPEN;let r=e.headersList.get(`sec-websocket-extensions`);r!==null&&(this.#r=r);let i=e.headersList.get(`sec-websocket-protocol`);i!==null&&(this.#n=i),x(`open`,this)}};M.CONNECTING=M.prototype.CONNECTING=o.CONNECTING,M.OPEN=M.prototype.OPEN=o.OPEN,M.CLOSING=M.prototype.CLOSING=o.CLOSING,M.CLOSED=M.prototype.CLOSED=o.CLOSED,Object.defineProperties(M.prototype,{CONNECTING:a,OPEN:a,CLOSING:a,CLOSED:a,url:T,readyState:T,bufferedAmount:T,onopen:T,onerror:T,onclose:T,close:T,onmessage:T,binaryType:T,send:T,extensions:T,protocol:T,[Symbol.toStringTag]:{value:`WebSocket`,writable:!1,enumerable:!1,configurable:!0}}),Object.defineProperties(M,{CONNECTING:a,OPEN:a,CLOSING:a,CLOSED:a}),n.converters[`sequence`]=n.sequenceConverter(n.converters.DOMString),n.converters[`DOMString or sequence`]=function(e,t,r){return n.util.Type(e)===`Object`&&Symbol.iterator in e?n.converters[`sequence`](e):n.converters.DOMString(e,t,r)},n.converters.WebSocketInit=n.dictionaryConverter([{key:`protocols`,converter:n.converters[`DOMString or sequence`],defaultValue:()=>[]},{key:`dispatcher`,converter:n.converters.any,defaultValue:()=>D()},{key:`headers`,converter:n.nullableConverter(n.converters.HeadersInit)}]),n.converters[`DOMString or sequence or WebSocketInit`]=function(e){return n.util.Type(e)===`Object`&&!(Symbol.iterator in e)?n.converters.WebSocketInit(e):{protocols:n.converters[`DOMString or sequence`](e)}},n.converters.WebSocketSendData=function(e){if(n.util.Type(e)===`Object`){if(E(e))return n.converters.Blob(e,{strict:!1});if(ArrayBuffer.isView(e)||O.isArrayBuffer(e))return n.converters.BufferSource(e)}return n.converters.USVString(e)};function N(){this.ws[p].socket.resume()}function P(e){let t,n;e instanceof A?(t=e.reason,n=e.code):t=e.message,x(`error`,this,()=>new k(`error`,{error:e,message:t})),C(this,n)}t.exports={WebSocket:M}})),pn=U(((e,t)=>{function n(e){return e.indexOf(`\0`)===-1}function r(e){if(e.length===0)return!1;for(let t=0;t57)return!1;return!0}function i(e){return new Promise(t=>{setTimeout(t,e).unref()})}t.exports={isValidLastEventId:n,isASCIINumber:r,delay:i}})),mn=U(((e,t)=>{let{Transform:n}=W(`node:stream`),{isASCIINumber:r,isValidLastEventId:i}=pn(),a=[239,187,191];t.exports={EventSourceStream:class extends n{state=null;checkBOM=!0;crlfCheck=!1;eventEndCheck=!1;buffer=null;pos=0;event={data:void 0,event:void 0,id:void 0,retry:void 0};constructor(e={}){e.readableObjectMode=!0,super(e),this.state=e.eventSourceSettings||{},e.push&&(this.push=e.push)}_transform(e,t,n){if(e.length===0){n();return}if(this.buffer?this.buffer=Buffer.concat([this.buffer,e]):this.buffer=e,this.checkBOM)switch(this.buffer.length){case 1:if(this.buffer[0]===a[0]){n();return}this.checkBOM=!1,n();return;case 2:if(this.buffer[0]===a[0]&&this.buffer[1]===a[1]){n();return}this.checkBOM=!1;break;case 3:if(this.buffer[0]===a[0]&&this.buffer[1]===a[1]&&this.buffer[2]===a[2]){this.buffer=Buffer.alloc(0),this.checkBOM=!1,n();return}this.checkBOM=!1;break;default:this.buffer[0]===a[0]&&this.buffer[1]===a[1]&&this.buffer[2]===a[2]&&(this.buffer=this.buffer.subarray(3)),this.checkBOM=!1;break}for(;this.pos0&&(t[a]=o);break}}processEvent(e){e.retry&&r(e.retry)&&(this.state.reconnectionTime=parseInt(e.retry,10)),e.id&&i(e.id)&&(this.state.lastEventId=e.id),e.data!==void 0&&this.push({type:e.event||`message`,options:{data:e.data,lastEventId:this.state.lastEventId,origin:this.state.origin}})}clearEvent(){this.event={data:void 0,event:void 0,id:void 0,retry:void 0}}}}})),hn=U(((e,t)=>{let{pipeline:n}=W(`node:stream`),{fetching:r}=Ht(),{makeRequest:i}=Vt(),{webidl:a}=Ke(),{EventSourceStream:o}=mn(),{parseMIMEType:s}=Ge(),{createFastMessageEvent:c}=nn(),{isNetworkError:l}=zt(),{delay:u}=pn(),{kEnumerableProperty:d}=Me(),{environmentSettingsObject:f}=qe(),p=!1,m=3e3;var h=class e extends EventTarget{#e={open:null,error:null,message:null};#t=null;#n=!1;#r=0;#i=null;#a=null;#o;#s;constructor(e,t={}){super(),a.util.markAsUncloneable(this);let n=`EventSource constructor`;a.argumentLengthCheck(arguments,1,n),p||(p=!0,process.emitWarning(`EventSource is experimental, expect them to change at any time.`,{code:`UNDICI-ES`})),e=a.converters.USVString(e,n,`url`),t=a.converters.EventSourceInitDict(t,n,`eventSourceInitDict`),this.#o=t.dispatcher,this.#s={lastEventId:``,reconnectionTime:m};let r=f,o;try{o=new URL(e,r.settingsObject.baseUrl),this.#s.origin=o.origin}catch(e){throw new DOMException(e,`SyntaxError`)}this.#t=o.href;let s=`anonymous`;t.withCredentials&&(s=`use-credentials`,this.#n=!0);let c={redirect:`follow`,keepalive:!0,mode:`cors`,credentials:s===`anonymous`?`same-origin`:`omit`,referrer:`no-referrer`};c.client=f.settingsObject,c.headersList=[[`accept`,{name:`accept`,value:`text/event-stream`}]],c.cache=`no-store`,c.initiator=`other`,c.urlList=[new URL(this.#t)],this.#i=i(c),this.#c()}get readyState(){return this.#r}get url(){return this.#t}get withCredentials(){return this.#n}#c(){if(this.#r===2)return;this.#r=0;let e={request:this.#i,dispatcher:this.#o};e.processResponseEndOfBody=e=>{l(e)&&(this.dispatchEvent(new Event(`error`)),this.close()),this.#l()},e.processResponse=e=>{if(l(e))if(e.aborted){this.close(),this.dispatchEvent(new Event(`error`));return}else{this.#l();return}let t=e.headersList.get(`content-type`,!0),r=t===null?`failure`:s(t),i=r!==`failure`&&r.essence===`text/event-stream`;if(e.status!==200||i===!1){this.close(),this.dispatchEvent(new Event(`error`));return}this.#r=1,this.dispatchEvent(new Event(`open`)),this.#s.origin=e.urlList[e.urlList.length-1].origin;let a=new o({eventSourceSettings:this.#s,push:e=>{this.dispatchEvent(c(e.type,e.options))}});n(e.body.stream,a,e=>{e?.aborted===!1&&(this.close(),this.dispatchEvent(new Event(`error`)))})},this.#a=r(e)}async#l(){this.#r!==2&&(this.#r=0,this.dispatchEvent(new Event(`error`)),await u(this.#s.reconnectionTime),this.#r===0&&(this.#s.lastEventId.length&&this.#i.headersList.set(`last-event-id`,this.#s.lastEventId,!0),this.#c()))}close(){a.brandCheck(this,e),this.#r!==2&&(this.#r=2,this.#a.abort(),this.#i=null)}get onopen(){return this.#e.open}set onopen(e){this.#e.open&&this.removeEventListener(`open`,this.#e.open),typeof e==`function`?(this.#e.open=e,this.addEventListener(`open`,e)):this.#e.open=null}get onmessage(){return this.#e.message}set onmessage(e){this.#e.message&&this.removeEventListener(`message`,this.#e.message),typeof e==`function`?(this.#e.message=e,this.addEventListener(`message`,e)):this.#e.message=null}get onerror(){return this.#e.error}set onerror(e){this.#e.error&&this.removeEventListener(`error`,this.#e.error),typeof e==`function`?(this.#e.error=e,this.addEventListener(`error`,e)):this.#e.error=null}};let g={CONNECTING:{__proto__:null,configurable:!1,enumerable:!0,value:0,writable:!1},OPEN:{__proto__:null,configurable:!1,enumerable:!0,value:1,writable:!1},CLOSED:{__proto__:null,configurable:!1,enumerable:!0,value:2,writable:!1}};Object.defineProperties(h,g),Object.defineProperties(h.prototype,g),Object.defineProperties(h.prototype,{close:d,onerror:d,onmessage:d,onopen:d,readyState:d,url:d,withCredentials:d}),a.converters.EventSourceInitDict=a.dictionaryConverter([{key:`withCredentials`,converter:a.converters.boolean,defaultValue:()=>!1},{key:`dispatcher`,converter:a.converters.any}]),t.exports={EventSource:h,defaultReconnectionTime:m}})),gn=U(((e,t)=>{let n=rt(),r=Fe(),i=st(),a=ct(),o=lt(),s=ut(),c=dt(),l=pt(),u=ke(),d=Me(),{InvalidArgumentError:f}=u,p=St(),m=Re(),h=Dt(),g=jt(),v=Ot(),y=Ct(),b=ft(),{getGlobalDispatcher:x,setGlobalDispatcher:S}=Mt(),C=Nt(),w=tt(),T=nt();Object.assign(r.prototype,p),t.exports.Dispatcher=r,t.exports.Client=n,t.exports.Pool=i,t.exports.BalancedPool=a,t.exports.Agent=o,t.exports.ProxyAgent=s,t.exports.EnvHttpProxyAgent=c,t.exports.RetryAgent=l,t.exports.RetryHandler=b,t.exports.DecoratorHandler=C,t.exports.RedirectHandler=w,t.exports.createRedirectInterceptor=T,t.exports.interceptors={redirect:Pt(),retry:Ft(),dump:It(),dns:Lt()},t.exports.buildConnector=m,t.exports.errors=u,t.exports.util={parseHeaders:d.parseHeaders,headerNameToString:d.headerNameToString};function E(e){return(t,n,r)=>{if(typeof n==`function`&&(r=n,n=null),!t||typeof t!=`string`&&typeof t!=`object`&&!(t instanceof URL))throw new f(`invalid url`);if(n!=null&&typeof n!=`object`)throw new f(`invalid opts`);if(n&&n.path!=null){if(typeof n.path!=`string`)throw new f(`invalid opts.path`);let e=n.path;n.path.startsWith(`/`)||(e=`/${e}`),t=new URL(d.parseOrigin(t).origin+e)}else n||=typeof t==`object`?t:{},t=d.parseURL(t);let{agent:i,dispatcher:a=x()}=n;if(i)throw new f(`unsupported opts.agent. Did you mean opts.client?`);return e.call(a,{...n,origin:t.origin,path:t.search?`${t.pathname}${t.search}`:t.pathname,method:n.method||(n.body?`PUT`:`GET`)},r)}}t.exports.setGlobalDispatcher=S,t.exports.getGlobalDispatcher=x;let D=Ht().fetch;t.exports.fetch=async function(e,t=void 0){try{return await D(e,t)}catch(e){throw e&&typeof e==`object`&&Error.captureStackTrace(e),e}},t.exports.Headers=Rt().Headers,t.exports.Response=zt().Response,t.exports.Request=Vt().Request,t.exports.FormData=Xe().FormData,t.exports.File=globalThis.File??W(`node:buffer`).File,t.exports.FileReader=qt().FileReader;let{setGlobalOrigin:O,getGlobalOrigin:k}=We();t.exports.setGlobalOrigin=O,t.exports.getGlobalOrigin=k;let{CacheStorage:A}=Zt(),{kConstruct:j}=Jt();t.exports.caches=new A(j);let{deleteCookie:M,getCookies:N,getSetCookies:P,setCookie:F}=tn();t.exports.deleteCookie=M,t.exports.getCookies=N,t.exports.getSetCookies=P,t.exports.setCookie=F;let{parseMIMEType:I,serializeAMimeType:L}=Ge();t.exports.parseMIMEType=I,t.exports.serializeAMimeType=L;let{CloseEvent:R,ErrorEvent:z,MessageEvent:ee}=nn();t.exports.WebSocket=fn().WebSocket,t.exports.CloseEvent=R,t.exports.ErrorEvent=z,t.exports.MessageEvent=ee,t.exports.request=E(p.request),t.exports.stream=E(p.stream),t.exports.pipeline=E(p.pipeline),t.exports.connect=E(p.connect),t.exports.upgrade=E(p.upgrade),t.exports.MockClient=h,t.exports.MockPool=v,t.exports.MockAgent=g,t.exports.mockErrors=y;let{EventSource:B}=hn();t.exports.EventSource=B})),_n=pe(De(),1),vn=gn(),yn=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},bn;(function(e){e[e.OK=200]=`OK`,e[e.MultipleChoices=300]=`MultipleChoices`,e[e.MovedPermanently=301]=`MovedPermanently`,e[e.ResourceMoved=302]=`ResourceMoved`,e[e.SeeOther=303]=`SeeOther`,e[e.NotModified=304]=`NotModified`,e[e.UseProxy=305]=`UseProxy`,e[e.SwitchProxy=306]=`SwitchProxy`,e[e.TemporaryRedirect=307]=`TemporaryRedirect`,e[e.PermanentRedirect=308]=`PermanentRedirect`,e[e.BadRequest=400]=`BadRequest`,e[e.Unauthorized=401]=`Unauthorized`,e[e.PaymentRequired=402]=`PaymentRequired`,e[e.Forbidden=403]=`Forbidden`,e[e.NotFound=404]=`NotFound`,e[e.MethodNotAllowed=405]=`MethodNotAllowed`,e[e.NotAcceptable=406]=`NotAcceptable`,e[e.ProxyAuthenticationRequired=407]=`ProxyAuthenticationRequired`,e[e.RequestTimeout=408]=`RequestTimeout`,e[e.Conflict=409]=`Conflict`,e[e.Gone=410]=`Gone`,e[e.TooManyRequests=429]=`TooManyRequests`,e[e.InternalServerError=500]=`InternalServerError`,e[e.NotImplemented=501]=`NotImplemented`,e[e.BadGateway=502]=`BadGateway`,e[e.ServiceUnavailable=503]=`ServiceUnavailable`,e[e.GatewayTimeout=504]=`GatewayTimeout`})(bn||={});var xn;(function(e){e.Accept=`accept`,e.ContentType=`content-type`})(xn||={});var Sn;(function(e){e.ApplicationJson=`application/json`})(Sn||={});const Cn=[bn.MovedPermanently,bn.ResourceMoved,bn.SeeOther,bn.TemporaryRedirect,bn.PermanentRedirect],wn=[bn.BadGateway,bn.ServiceUnavailable,bn.GatewayTimeout],Tn=[`OPTIONS`,`GET`,`DELETE`,`HEAD`];var En=class e extends Error{constructor(t,n){super(t),this.name=`HttpClientError`,this.statusCode=n,Object.setPrototypeOf(this,e.prototype)}},Dn=class{constructor(e){this.message=e}readBody(){return yn(this,void 0,void 0,function*(){return new Promise(e=>yn(this,void 0,void 0,function*(){let t=Buffer.alloc(0);this.message.on(`data`,e=>{t=Buffer.concat([t,e])}),this.message.on(`end`,()=>{e(t.toString())})}))})}readBodyBuffer(){return yn(this,void 0,void 0,function*(){return new Promise(e=>yn(this,void 0,void 0,function*(){let t=[];this.message.on(`data`,e=>{t.push(e)}),this.message.on(`end`,()=>{e(Buffer.concat(t))})}))})}},On=class{constructor(e,t,n){this._ignoreSslError=!1,this._allowRedirects=!0,this._allowRedirectDowngrade=!1,this._maxRedirects=50,this._allowRetries=!1,this._maxRetries=1,this._keepAlive=!1,this._disposed=!1,this.userAgent=this._getUserAgentWithOrchestrationId(e),this.handlers=t||[],this.requestOptions=n,n&&(n.ignoreSslError!=null&&(this._ignoreSslError=n.ignoreSslError),this._socketTimeout=n.socketTimeout,n.allowRedirects!=null&&(this._allowRedirects=n.allowRedirects),n.allowRedirectDowngrade!=null&&(this._allowRedirectDowngrade=n.allowRedirectDowngrade),n.maxRedirects!=null&&(this._maxRedirects=Math.max(n.maxRedirects,0)),n.keepAlive!=null&&(this._keepAlive=n.keepAlive),n.allowRetries!=null&&(this._allowRetries=n.allowRetries),n.maxRetries!=null&&(this._maxRetries=n.maxRetries))}options(e,t){return yn(this,void 0,void 0,function*(){return this.request(`OPTIONS`,e,null,t||{})})}get(e,t){return yn(this,void 0,void 0,function*(){return this.request(`GET`,e,null,t||{})})}del(e,t){return yn(this,void 0,void 0,function*(){return this.request(`DELETE`,e,null,t||{})})}post(e,t,n){return yn(this,void 0,void 0,function*(){return this.request(`POST`,e,t,n||{})})}patch(e,t,n){return yn(this,void 0,void 0,function*(){return this.request(`PATCH`,e,t,n||{})})}put(e,t,n){return yn(this,void 0,void 0,function*(){return this.request(`PUT`,e,t,n||{})})}head(e,t){return yn(this,void 0,void 0,function*(){return this.request(`HEAD`,e,null,t||{})})}sendStream(e,t,n,r){return yn(this,void 0,void 0,function*(){return this.request(e,t,n,r)})}getJson(e){return yn(this,arguments,void 0,function*(e,t={}){t[xn.Accept]=this._getExistingOrDefaultHeader(t,xn.Accept,Sn.ApplicationJson);let n=yield this.get(e,t);return this._processResponse(n,this.requestOptions)})}postJson(e,t){return yn(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[xn.Accept]=this._getExistingOrDefaultHeader(n,xn.Accept,Sn.ApplicationJson),n[xn.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,Sn.ApplicationJson);let i=yield this.post(e,r,n);return this._processResponse(i,this.requestOptions)})}putJson(e,t){return yn(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[xn.Accept]=this._getExistingOrDefaultHeader(n,xn.Accept,Sn.ApplicationJson),n[xn.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,Sn.ApplicationJson);let i=yield this.put(e,r,n);return this._processResponse(i,this.requestOptions)})}patchJson(e,t){return yn(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[xn.Accept]=this._getExistingOrDefaultHeader(n,xn.Accept,Sn.ApplicationJson),n[xn.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,Sn.ApplicationJson);let i=yield this.patch(e,r,n);return this._processResponse(i,this.requestOptions)})}request(e,t,n,r){return yn(this,void 0,void 0,function*(){if(this._disposed)throw Error(`Client has already been disposed.`);let i=new URL(t),a=this._prepareRequest(e,i,r),o=this._allowRetries&&Tn.includes(e)?this._maxRetries+1:1,s=0,c;do{if(c=yield this.requestRaw(a,n),c&&c.message&&c.message.statusCode===bn.Unauthorized){let e;for(let t of this.handlers)if(t.canHandleAuthentication(c)){e=t;break}return e?e.handleAuthentication(this,a,n):c}let t=this._maxRedirects;for(;c.message.statusCode&&Cn.includes(c.message.statusCode)&&this._allowRedirects&&t>0;){let o=c.message.headers.location;if(!o)break;let s=new URL(o);if(i.protocol===`https:`&&i.protocol!==s.protocol&&!this._allowRedirectDowngrade)throw Error(`Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.`);if(yield c.readBody(),s.hostname!==i.hostname)for(let e in r)e.toLowerCase()===`authorization`&&delete r[e];a=this._prepareRequest(e,s,r),c=yield this.requestRaw(a,n),t--}if(!c.message.statusCode||!wn.includes(c.message.statusCode))return c;s+=1,s{function i(e,t){e?r(e):t?n(t):r(Error(`Unknown error`))}this.requestRawWithCallback(e,t,i)})})}requestRawWithCallback(e,t,n){typeof t==`string`&&(e.options.headers||(e.options.headers={}),e.options.headers[`Content-Length`]=Buffer.byteLength(t,`utf8`));let r=!1;function i(e,t){r||(r=!0,n(e,t))}let a=e.httpModule.request(e.options,e=>{i(void 0,new Dn(e))}),o;a.on(`socket`,e=>{o=e}),a.setTimeout(this._socketTimeout||3*6e4,()=>{o&&o.end(),i(Error(`Request timeout: ${e.options.path}`))}),a.on(`error`,function(e){i(e)}),t&&typeof t==`string`&&a.write(t,`utf8`),t&&typeof t!=`string`?(t.on(`close`,function(){a.end()}),t.pipe(a)):a.end()}getAgent(e){let t=new URL(e);return this._getAgent(t)}getAgentDispatcher(e){let t=new URL(e),n=Se(t);if(n&&n.hostname)return this._getProxyAgentDispatcher(t,n)}_prepareRequest(e,t,n){let r={};r.parsedUrl=t;let i=r.parsedUrl.protocol===`https:`;r.httpModule=i?g:h;let a=i?443:80;if(r.options={},r.options.host=r.parsedUrl.hostname,r.options.port=r.parsedUrl.port?parseInt(r.parsedUrl.port):a,r.options.path=(r.parsedUrl.pathname||``)+(r.parsedUrl.search||``),r.options.method=e,r.options.headers=this._mergeHeaders(n),this.userAgent!=null&&(r.options.headers[`user-agent`]=this.userAgent),r.options.agent=this._getAgent(r.parsedUrl),this.handlers)for(let e of this.handlers)e.prepareRequest(r.options);return r}_mergeHeaders(e){return this.requestOptions&&this.requestOptions.headers?Object.assign({},kn(this.requestOptions.headers),kn(e||{})):kn(e||{})}_getExistingOrDefaultHeader(e,t,n){let r;if(this.requestOptions&&this.requestOptions.headers){let e=kn(this.requestOptions.headers)[t];e&&(r=typeof e==`number`?e.toString():e)}let i=e[t];return i===void 0?r===void 0?n:r:typeof i==`number`?i.toString():i}_getExistingOrDefaultContentTypeHeader(e,t){let n;if(this.requestOptions&&this.requestOptions.headers){let e=kn(this.requestOptions.headers)[xn.ContentType];e&&(n=typeof e==`number`?String(e):Array.isArray(e)?e.join(`, `):e)}let r=e[xn.ContentType];return r===void 0?n===void 0?t:n:typeof r==`number`?String(r):Array.isArray(r)?r.join(`, `):r}_getAgent(e){let t,n=Se(e),r=n&&n.hostname;if(this._keepAlive&&r&&(t=this._proxyAgent),r||(t=this._agent),t)return t;let i=e.protocol===`https:`,a=100;if(this.requestOptions&&(a=this.requestOptions.maxSockets||h.globalAgent.maxSockets),n&&n.hostname){let e={maxSockets:a,keepAlive:this._keepAlive,proxy:Object.assign(Object.assign({},(n.username||n.password)&&{proxyAuth:`${n.username}:${n.password}`}),{host:n.hostname,port:n.port})},r,o=n.protocol===`https:`;r=i?o?_n.httpsOverHttps:_n.httpsOverHttp:o?_n.httpOverHttps:_n.httpOverHttp,t=r(e),this._proxyAgent=t}if(!t){let e={keepAlive:this._keepAlive,maxSockets:a};t=i?new g.Agent(e):new h.Agent(e),this._agent=t}return i&&this._ignoreSslError&&(t.options=Object.assign(t.options||{},{rejectUnauthorized:!1})),t}_getProxyAgentDispatcher(e,t){let n;if(this._keepAlive&&(n=this._proxyAgentDispatcher),n)return n;let r=e.protocol===`https:`;return n=new vn.ProxyAgent(Object.assign({uri:t.href,pipelining:this._keepAlive?1:0},(t.username||t.password)&&{token:`Basic ${Buffer.from(`${t.username}:${t.password}`).toString(`base64`)}`})),this._proxyAgentDispatcher=n,r&&this._ignoreSslError&&(n.options=Object.assign(n.options.requestTls||{},{rejectUnauthorized:!1})),n}_getUserAgentWithOrchestrationId(e){let t=e||`actions/http-client`,n=process.env.ACTIONS_ORCHESTRATION_ID;return n?`${t} actions_orchestration_id/${n.replace(/[^a-z0-9_.-]/gi,`_`)}`:t}_performExponentialBackoff(e){return yn(this,void 0,void 0,function*(){e=Math.min(10,e);let t=5*2**e;return new Promise(e=>setTimeout(()=>e(),t))})}_processResponse(e,t){return yn(this,void 0,void 0,function*(){return new Promise((n,r)=>yn(this,void 0,void 0,function*(){let i=e.message.statusCode||0,a={statusCode:i,result:null,headers:{}};i===bn.NotFound&&n(a);function o(e,t){if(typeof t==`string`){let e=new Date(t);if(!isNaN(e.valueOf()))return e}return t}let s,c;try{c=yield e.readBody(),c&&c.length>0&&(s=t&&t.deserializeDates?JSON.parse(c,o):JSON.parse(c),a.result=s),a.headers=e.message.headers}catch{}if(i>299){let e;e=s&&s.message?s.message:c&&c.length>0?c:`Failed request: (${i})`;let t=new En(e,i);t.result=a.result,r(t)}else n(a)}))})}};const kn=e=>Object.keys(e).reduce((t,n)=>(t[n.toLowerCase()]=e[n],t),{});var An=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},jn=class{constructor(e){this.token=e}prepareRequest(e){if(!e.headers)throw Error(`The request has no headers`);e.headers.Authorization=`Bearer ${this.token}`}canHandleAuthentication(){return!1}handleAuthentication(){return An(this,void 0,void 0,function*(){throw Error(`not implemented`)})}},Mn=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const{access:Nn,appendFile:Pn,writeFile:Fn}=l,In=`GITHUB_STEP_SUMMARY`,Ln=new class{constructor(){this._buffer=``}filePath(){return Mn(this,void 0,void 0,function*(){if(this._filePath)return this._filePath;let e=process.env[In];if(!e)throw Error(`Unable to find environment variable for $${In}. Check if your runtime environment supports job summaries.`);try{yield Nn(e,s.R_OK|s.W_OK)}catch{throw Error(`Unable to access summary file: '${e}'. Check if the file has correct read/write permissions.`)}return this._filePath=e,this._filePath})}wrap(e,t,n={}){let r=Object.entries(n).map(([e,t])=>` ${e}="${t}"`).join(``);return t?`<${e}${r}>${t}`:`<${e}${r}>`}write(e){return Mn(this,void 0,void 0,function*(){let t=!!e?.overwrite,n=yield this.filePath();return yield(t?Fn:Pn)(n,this._buffer,{encoding:`utf8`}),this.emptyBuffer()})}clear(){return Mn(this,void 0,void 0,function*(){return this.emptyBuffer().write({overwrite:!0})})}stringify(){return this._buffer}isEmptyBuffer(){return this._buffer.length===0}emptyBuffer(){return this._buffer=``,this}addRaw(e,t=!1){return this._buffer+=e,t?this.addEOL():this}addEOL(){return this.addRaw(i)}addCodeBlock(e,t){let n=Object.assign({},t&&{lang:t}),r=this.wrap(`pre`,this.wrap(`code`,e),n);return this.addRaw(r).addEOL()}addList(e,t=!1){let n=t?`ol`:`ul`,r=e.map(e=>this.wrap(`li`,e)).join(``),i=this.wrap(n,r);return this.addRaw(i).addEOL()}addTable(e){let t=e.map(e=>{let t=e.map(e=>{if(typeof e==`string`)return this.wrap(`td`,e);let{header:t,data:n,colspan:r,rowspan:i}=e,a=t?`th`:`td`,o=Object.assign(Object.assign({},r&&{colspan:r}),i&&{rowspan:i});return this.wrap(a,n,o)}).join(``);return this.wrap(`tr`,t)}).join(``),n=this.wrap(`table`,t);return this.addRaw(n).addEOL()}addDetails(e,t){let n=this.wrap(`details`,this.wrap(`summary`,e)+t);return this.addRaw(n).addEOL()}addImage(e,t,n){let{width:r,height:i}=n||{},a=Object.assign(Object.assign({},r&&{width:r}),i&&{height:i}),o=this.wrap(`img`,null,Object.assign({src:e,alt:t},a));return this.addRaw(o).addEOL()}addHeading(e,t){let n=`h${t}`,r=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`].includes(n)?n:`h1`,i=this.wrap(r,e);return this.addRaw(i).addEOL()}addSeparator(){let e=this.wrap(`hr`,null);return this.addRaw(e).addEOL()}addBreak(){let e=this.wrap(`br`,null);return this.addRaw(e).addEOL()}addQuote(e,t){let n=Object.assign({},t&&{cite:t}),r=this.wrap(`blockquote`,e,n);return this.addRaw(r).addEOL()}addLink(e,t){let n=this.wrap(`a`,e,{href:t});return this.addRaw(n).addEOL()}};var Rn=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const{chmod:zn,copyFile:Bn,lstat:Vn,mkdir:Hn,open:Un,readdir:Wn,rename:Gn,rm:Kn,rmdir:qn,stat:Jn,symlink:Yn,unlink:Xn}=o.promises,Zn=process.platform===`win32`;function Qn(e){return Rn(this,void 0,void 0,function*(){let t=yield o.promises.readlink(e);return Zn&&!t.endsWith(`\\`)?`${t}\\`:t})}o.constants.O_RDONLY;function $n(e){return Rn(this,void 0,void 0,function*(){try{yield Jn(e)}catch(e){if(e.code===`ENOENT`)return!1;throw e}return!0})}function er(e){if(e=nr(e),!e)throw Error(`isRooted() parameter "p" cannot be empty`);return Zn?e.startsWith(`\\`)||/^[A-Z]:/i.test(e):e.startsWith(`/`)}function tr(e,t){return Rn(this,void 0,void 0,function*(){let n;try{n=yield Jn(e)}catch(t){t.code!==`ENOENT`&&console.log(`Unexpected error attempting to determine if executable file exists '${e}': ${t}`)}if(n&&n.isFile()){if(Zn){let n=f.extname(e).toUpperCase();if(t.some(e=>e.toUpperCase()===n))return e}else if(rr(n))return e}let r=e;for(let i of t){e=r+i,n=void 0;try{n=yield Jn(e)}catch(t){t.code!==`ENOENT`&&console.log(`Unexpected error attempting to determine if executable file exists '${e}': ${t}`)}if(n&&n.isFile()){if(Zn){try{let t=f.dirname(e),n=f.basename(e).toUpperCase();for(let r of yield Wn(t))if(n===r.toUpperCase()){e=f.join(t,r);break}}catch(t){console.log(`Unexpected error attempting to determine the actual case of the file '${e}': ${t}`)}return e}else if(rr(n))return e}}return``})}function nr(e){return e||=``,Zn?(e=e.replace(/\//g,`\\`),e.replace(/\\\\+/g,`\\`)):e.replace(/\/\/+/g,`/`)}function rr(e){return(e.mode&1)>0||(e.mode&8)>0&&process.getgid!==void 0&&e.gid===process.getgid()||(e.mode&64)>0&&process.getuid!==void 0&&e.uid===process.getuid()}var ir=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function ar(e,t){return ir(this,arguments,void 0,function*(e,t,n={}){let{force:r,recursive:i,copySourceDirectory:a}=ur(n),o=(yield $n(t))?yield Jn(t):null;if(o&&o.isFile()&&!r)return;let s=o&&o.isDirectory()&&a?f.join(t,f.basename(e)):t;if(!(yield $n(e)))throw Error(`no such file or directory: ${e}`);if((yield Jn(e)).isDirectory())if(i)yield dr(e,s,0,r);else throw Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`);else{if(f.relative(e,s)===``)throw Error(`'${s}' and '${e}' are the same file`);yield fr(e,s,r)}})}function or(e){return ir(this,void 0,void 0,function*(){if(Zn&&/[*"<>|]/.test(e))throw Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');try{yield Kn(e,{force:!0,maxRetries:3,recursive:!0,retryDelay:300})}catch(e){throw Error(`File was unable to be removed ${e}`)}})}function sr(e){return ir(this,void 0,void 0,function*(){x(e,`a path argument must be provided`),yield Hn(e,{recursive:!0})})}function cr(e,t){return ir(this,void 0,void 0,function*(){if(!e)throw Error(`parameter 'tool' is required`);if(t){let t=yield cr(e,!1);if(!t)throw Error(Zn?`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`:`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);return t}let n=yield lr(e);return n&&n.length>0?n[0]:``})}function lr(e){return ir(this,void 0,void 0,function*(){if(!e)throw Error(`parameter 'tool' is required`);let t=[];if(Zn&&process.env.PATHEXT)for(let e of process.env.PATHEXT.split(f.delimiter))e&&t.push(e);if(er(e)){let n=yield tr(e,t);return n?[n]:[]}if(e.includes(f.sep))return[];let n=[];if(process.env.PATH)for(let e of process.env.PATH.split(f.delimiter))e&&n.push(e);let r=[];for(let i of n){let n=yield tr(f.join(i,e),t);n&&r.push(n)}return r})}function ur(e){return{force:e.force==null?!0:e.force,recursive:!!e.recursive,copySourceDirectory:e.copySourceDirectory==null?!0:!!e.copySourceDirectory}}function dr(e,t,n,r){return ir(this,void 0,void 0,function*(){if(n>=255)return;n++,yield sr(t);let i=yield Wn(e);for(let a of i){let i=`${e}/${a}`,o=`${t}/${a}`;(yield Vn(i)).isDirectory()?yield dr(i,o,n,r):yield fr(i,o,r)}yield zn(t,(yield Jn(e)).mode)})}function fr(e,t,n){return ir(this,void 0,void 0,function*(){if((yield Vn(e)).isSymbolicLink()){try{yield Vn(t),yield Xn(t)}catch(e){e.code===`EPERM`&&(yield zn(t,`0666`),yield Xn(t))}yield Yn(yield Qn(e),t,Zn?`junction`:null)}else (!(yield $n(t))||n)&&(yield Bn(e,t))})}var pr=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const mr=process.platform===`win32`;var hr=class extends v.EventEmitter{constructor(e,t,n){if(super(),!e)throw Error(`Parameter 'toolPath' cannot be null or empty.`);this.toolPath=e,this.args=t||[],this.options=n||{}}_debug(e){this.options.listeners&&this.options.listeners.debug&&this.options.listeners.debug(e)}_getCommandString(e,t){let n=this._getSpawnFileName(),r=this._getSpawnArgs(e),i=t?``:`[command]`;if(mr)if(this._isCmdFile()){i+=n;for(let e of r)i+=` ${e}`}else if(e.windowsVerbatimArguments){i+=`"${n}"`;for(let e of r)i+=` ${e}`}else{i+=this._windowsQuoteCmdArg(n);for(let e of r)i+=` ${this._windowsQuoteCmdArg(e)}`}else{i+=n;for(let e of r)i+=` ${e}`}return i}_processLineBuffer(e,t,r){try{let i=t+e.toString(),a=i.indexOf(n.EOL);for(;a>-1;)r(i.substring(0,a)),i=i.substring(a+n.EOL.length),a=i.indexOf(n.EOL);return i}catch(e){return this._debug(`error processing line. Failed with error ${e}`),``}}_getSpawnFileName(){return mr&&this._isCmdFile()?process.env.COMSPEC||`cmd.exe`:this.toolPath}_getSpawnArgs(e){if(mr&&this._isCmdFile()){let t=`/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;for(let n of this.args)t+=` `,t+=e.windowsVerbatimArguments?n:this._windowsQuoteCmdArg(n);return t+=`"`,[t]}return this.args}_endsWith(e,t){return e.endsWith(t)}_isCmdFile(){let e=this.toolPath.toUpperCase();return this._endsWith(e,`.CMD`)||this._endsWith(e,`.BAT`)}_windowsQuoteCmdArg(e){if(!this._isCmdFile())return this._uvQuoteCmdArg(e);if(!e)return`""`;let t=[` `,` `,`&`,`(`,`)`,`[`,`]`,`{`,`}`,`^`,`=`,`;`,`!`,`'`,`+`,`,`,"`",`~`,`|`,`<`,`>`,`"`],n=!1;for(let r of e)if(t.some(e=>e===r)){n=!0;break}if(!n)return e;let r=`"`,i=!0;for(let t=e.length;t>0;t--)r+=e[t-1],i&&e[t-1]===`\\`?r+=`\\`:e[t-1]===`"`?(i=!0,r+=`"`):i=!1;return r+=`"`,r.split(``).reverse().join(``)}_uvQuoteCmdArg(e){if(!e)return`""`;if(!e.includes(` `)&&!e.includes(` `)&&!e.includes(`"`))return e;if(!e.includes(`"`)&&!e.includes(`\\`))return`"${e}"`;let t=`"`,n=!0;for(let r=e.length;r>0;r--)t+=e[r-1],n&&e[r-1]===`\\`?t+=`\\`:e[r-1]===`"`?(n=!0,t+=`\\`):n=!1;return t+=`"`,t.split(``).reverse().join(``)}_cloneExecOptions(e){e||={};let t={cwd:e.cwd||process.cwd(),env:e.env||process.env,silent:e.silent||!1,windowsVerbatimArguments:e.windowsVerbatimArguments||!1,failOnStdErr:e.failOnStdErr||!1,ignoreReturnCode:e.ignoreReturnCode||!1,delay:e.delay||1e4};return t.outStream=e.outStream||process.stdout,t.errStream=e.errStream||process.stderr,t}_getSpawnOptions(e,t){e||={};let n={};return n.cwd=e.cwd,n.env=e.env,n.windowsVerbatimArguments=e.windowsVerbatimArguments||this._isCmdFile(),e.windowsVerbatimArguments&&(n.argv0=`"${t}"`),n}exec(){return pr(this,void 0,void 0,function*(){return!er(this.toolPath)&&(this.toolPath.includes(`/`)||mr&&this.toolPath.includes(`\\`))&&(this.toolPath=f.resolve(process.cwd(),this.options.cwd||process.cwd(),this.toolPath)),this.toolPath=yield cr(this.toolPath,!0),new Promise((e,t)=>pr(this,void 0,void 0,function*(){this._debug(`exec tool: ${this.toolPath}`),this._debug(`arguments:`);for(let e of this.args)this._debug(` ${e}`);let r=this._cloneExecOptions(this.options);!r.silent&&r.outStream&&r.outStream.write(this._getCommandString(r)+n.EOL);let i=new _r(r,this.toolPath);if(i.on(`debug`,e=>{this._debug(e)}),this.options.cwd&&!(yield $n(this.options.cwd)))return t(Error(`The cwd: ${this.options.cwd} does not exist!`));let a=this._getSpawnFileName(),o=M.spawn(a,this._getSpawnArgs(r),this._getSpawnOptions(this.options,a)),s=``;o.stdout&&o.stdout.on(`data`,e=>{this.options.listeners&&this.options.listeners.stdout&&this.options.listeners.stdout(e),!r.silent&&r.outStream&&r.outStream.write(e),s=this._processLineBuffer(e,s,e=>{this.options.listeners&&this.options.listeners.stdline&&this.options.listeners.stdline(e)})});let c=``;if(o.stderr&&o.stderr.on(`data`,e=>{i.processStderr=!0,this.options.listeners&&this.options.listeners.stderr&&this.options.listeners.stderr(e),!r.silent&&r.errStream&&r.outStream&&(r.failOnStdErr?r.errStream:r.outStream).write(e),c=this._processLineBuffer(e,c,e=>{this.options.listeners&&this.options.listeners.errline&&this.options.listeners.errline(e)})}),o.on(`error`,e=>{i.processError=e.message,i.processExited=!0,i.processClosed=!0,i.CheckComplete()}),o.on(`exit`,e=>{i.processExitCode=e,i.processExited=!0,this._debug(`Exit code ${e} received from tool '${this.toolPath}'`),i.CheckComplete()}),o.on(`close`,e=>{i.processExitCode=e,i.processExited=!0,i.processClosed=!0,this._debug(`STDIO streams have closed for tool '${this.toolPath}'`),i.CheckComplete()}),i.on(`done`,(n,r)=>{s.length>0&&this.emit(`stdline`,s),c.length>0&&this.emit(`errline`,c),o.removeAllListeners(),n?t(n):e(r)}),this.options.input){if(!o.stdin)throw Error(`child process missing stdin`);o.stdin.end(this.options.input)}}))})}};function gr(e){let t=[],n=!1,r=!1,i=``;function a(e){r&&e!==`"`&&(i+=`\\`),i+=e,r=!1}for(let o=0;o0&&(t.push(i),i=``);continue}a(s)}return i.length>0&&t.push(i.trim()),t}var _r=class e extends v.EventEmitter{constructor(e,t){if(super(),this.processClosed=!1,this.processError=``,this.processExitCode=0,this.processExited=!1,this.processStderr=!1,this.delay=1e4,this.done=!1,this.timeout=null,!t)throw Error(`toolPath must not be empty`);this.options=e,this.toolPath=t,e.delay&&(this.delay=e.delay)}CheckComplete(){this.done||(this.processClosed?this._setResult():this.processExited&&(this.timeout=N(e.HandleTimeout,this.delay,this)))}_debug(e){this.emit(`debug`,e)}_setResult(){let e;this.processExited&&(this.processError?e=Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`):this.processExitCode!==0&&!this.options.ignoreReturnCode?e=Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`):this.processStderr&&this.options.failOnStdErr&&(e=Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`))),this.timeout&&=(clearTimeout(this.timeout),null),this.done=!0,this.emit(`done`,e,this.processExitCode)}static HandleTimeout(e){if(!e.done){if(!e.processClosed&&e.processExited){let t=`The STDIO streams did not close within ${e.delay/1e3} seconds of the exit event from process '${e.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`;e._debug(t)}e._setResult()}}},vr=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function yr(e,t,n){return vr(this,void 0,void 0,function*(){let r=gr(e);if(r.length===0)throw Error(`Parameter 'commandLine' cannot be null or empty.`);let i=r[0];return t=r.slice(1).concat(t||[]),new hr(i,t,n).exec()})}function br(e,t,n){return vr(this,void 0,void 0,function*(){let r=``,i=``,a=new j(`utf8`),o=new j(`utf8`),s=n?.listeners?.stdout,c=n?.listeners?.stderr,l=Object.assign(Object.assign({},n?.listeners),{stdout:e=>{r+=a.write(e),s&&s(e)},stderr:e=>{i+=o.write(e),c&&c(e)}}),u=yield yr(e,t,Object.assign(Object.assign({},n),{listeners:l}));return r+=a.end(),i+=o.end(),{exitCode:u,stdout:r,stderr:i}})}r.platform(),r.arch();var xr;(function(e){e[e.Success=0]=`Success`,e[e.Failure=1]=`Failure`})(xr||={});function Sr(e,t){let n=me(t);if(process.env[e]=n,process.env.GITHUB_ENV)return be(`ENV`,xe(e,t));ge(`set-env`,{name:e},n)}function Cr(e){ge(`add-mask`,{},e)}function wr(e){process.env.GITHUB_PATH?be(`PATH`,e):ge(`add-path`,{},e),process.env.PATH=`${e}${f.delimiter}${process.env.PATH}`}function Tr(e,t){let n=process.env[`INPUT_${e.replace(/ /g,`_`).toUpperCase()}`]||``;if(t&&t.required&&!n)throw Error(`Input required and not supplied: ${e}`);return t&&t.trimWhitespace===!1?n:n.trim()}function Er(e,t){if(process.env.GITHUB_OUTPUT)return be(`OUTPUT`,xe(e,t));process.stdout.write(n.EOL),ge(`set-output`,{name:e},me(t))}function Dr(e){process.exitCode=xr.Failure,kr(e)}function Or(){return process.env.RUNNER_DEBUG===`1`}function G(e){ge(`debug`,{},e)}function kr(e,t={}){ge(`error`,he(t),e instanceof Error?e.toString():e)}function Ar(e,t={}){ge(`warning`,he(t),e instanceof Error?e.toString():e)}function jr(e){process.stdout.write(e+n.EOL)}function Mr(e,t){if(process.env.GITHUB_STATE)return be(`STATE`,xe(e,t));ge(`save-state`,{name:e},me(t))}function Nr(e){return process.env[`STATE_${e}`]||``}function Pr(e){return e instanceof Error?e.message:String(e)}const Fr=[`token`,`password`,`secret`,`key`,`auth`,`credential`,`bearer`,`apikey`,`api_key`,`access_token`,`refresh_token`,`private`];function Ir(e,t){let n=e.toLowerCase();return t.some(e=>n.includes(e.toLowerCase()))}function Lr(e,t=Fr){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>Lr(e,t));let n={};for(let[r,i]of Object.entries(e))Ir(r,t)&&typeof i==`string`?n[r]=`[REDACTED]`:typeof i==`object`&&i?n[r]=Lr(i,t):n[r]=i;return n}function Rr(e,t,n,r){let i=Lr({...n,...r}),a={timestamp:new Date().toISOString(),level:e,message:t,...i};if(r!=null&&`error`in r&&r.error instanceof Error){let e=r.error;a.error={message:e.message,name:e.name,stack:e.stack}}return JSON.stringify(a)}function zr(e){return{debug:(t,n)=>{G(Rr(`debug`,t,e,n))},info:(t,n)=>{jr(Rr(`info`,t,e,n))},warning:(t,n)=>{Ar(Rr(`warning`,t,e,n))},error:(t,n)=>{kr(Rr(`error`,t,e,n))}}}const Br={SHOULD_SAVE_CACHE:`shouldSaveCache`,SESSION_ID:`sessionId`,CACHE_SAVED:`cacheSaved`,ARTIFACT_UPLOADED:`artifactUploaded`,OPENCODE_VERSION:`opencodeVersion`},Vr=`sisyphus`,Hr=18e5,Ur={providerID:`opencode`,modelID:`big-pickle`},Wr=`1.3.5`,Gr=`1.3.11`,Kr=`3.14.0`,qr=`opencode-storage`,Jr=`opencode-tools`,Yr=6e5,Xr=`fro-bot-dedup-v1`;function Zr(){let e=t.env.XDG_DATA_HOME;return e!=null&&e.trim().length>0?e:F.join(I.homedir(),`.local`,`share`)}function Qr(){return F.join(Zr(),`opencode`,`storage`)}function $r(){return F.join(Zr(),`opencode`,`auth.json`)}function ei(){return F.join(Zr(),`opencode`,`log`)}function ti(){let e=t.env.OPENCODE_PROMPT_ARTIFACT;return e===`true`||e===`1`}function ni(){let e=t.env.RUNNER_OS;if(e!=null&&e.trim().length>0)return e;switch(I.platform()){case`darwin`:return`macOS`;case`win32`:return`Windows`;case`aix`:case`android`:case`freebsd`:case`haiku`:case`linux`:case`openbsd`:case`sunos`:case`cygwin`:case`netbsd`:return`Linux`}}function ri(){let e=t.env.GITHUB_REPOSITORY;return e!=null&&e.trim().length>0?e:`unknown/unknown`}function ii(){let e=t.env.GITHUB_REF_NAME;return e!=null&&e.trim().length>0?e:`main`}function ai(){let e=t.env.GITHUB_RUN_ID;return e!=null&&e.trim().length>0?Number(e):0}function oi(){let e=t.env.GITHUB_RUN_ATTEMPT;if(e!=null&&e.trim().length>0){let t=Number(e);if(Number.isFinite(t)&&t>0)return t}return 1}function si(){let e=t.env.GITHUB_WORKSPACE;return e!=null&&e.trim().length>0?e:t.cwd()}var ci=class{constructor(){if(this.payload={},process.env.GITHUB_EVENT_PATH)if(c(process.env.GITHUB_EVENT_PATH))this.payload=JSON.parse(u(process.env.GITHUB_EVENT_PATH,{encoding:`utf8`}));else{let e=process.env.GITHUB_EVENT_PATH;process.stdout.write(`GITHUB_EVENT_PATH ${e} does not exist${i}`)}this.eventName=process.env.GITHUB_EVENT_NAME,this.sha=process.env.GITHUB_SHA,this.ref=process.env.GITHUB_REF,this.workflow=process.env.GITHUB_WORKFLOW,this.action=process.env.GITHUB_ACTION,this.actor=process.env.GITHUB_ACTOR,this.job=process.env.GITHUB_JOB,this.runAttempt=parseInt(process.env.GITHUB_RUN_ATTEMPT,10),this.runNumber=parseInt(process.env.GITHUB_RUN_NUMBER,10),this.runId=parseInt(process.env.GITHUB_RUN_ID,10),this.apiUrl=process.env.GITHUB_API_URL??`https://api.github.com`,this.serverUrl=process.env.GITHUB_SERVER_URL??`https://github.com`,this.graphqlUrl=process.env.GITHUB_GRAPHQL_URL??`https://api.github.com/graphql`}get issue(){let e=this.payload;return Object.assign(Object.assign({},this.repo),{number:(e.issue||e.pull_request||e).number})}get repo(){if(process.env.GITHUB_REPOSITORY){let[e,t]=process.env.GITHUB_REPOSITORY.split(`/`);return{owner:e,repo:t}}if(this.payload.repository)return{owner:this.payload.repository.owner.login,repo:this.payload.repository.name};throw Error(`context.repo requires a GITHUB_REPOSITORY environment variable like 'owner/repo'`)}},li=U((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getProxyUrl=t,e.checkBypass=n;function t(e){let t=e.protocol===`https:`;if(n(e))return;let r=t?process.env.https_proxy||process.env.HTTPS_PROXY:process.env.http_proxy||process.env.HTTP_PROXY;if(r)try{return new i(r)}catch{if(!r.startsWith(`http://`)&&!r.startsWith(`https://`))return new i(`http://${r}`)}else return}function n(e){if(!e.hostname)return!1;let t=e.hostname;if(r(t))return!0;let n=process.env.no_proxy||process.env.NO_PROXY||``;if(!n)return!1;let i;e.port?i=Number(e.port):e.protocol===`http:`?i=80:e.protocol===`https:`&&(i=443);let a=[e.hostname.toUpperCase()];typeof i==`number`&&a.push(`${a[0]}:${i}`);for(let e of n.split(`,`).map(e=>e.trim().toUpperCase()).filter(e=>e))if(e===`*`||a.some(t=>t===e||t.endsWith(`.${e}`)||e.startsWith(`.`)&&t.endsWith(`${e}`)))return!0;return!1}function r(e){let t=e.toLowerCase();return t===`localhost`||t.startsWith(`127.`)||t.startsWith(`[::1]`)||t.startsWith(`[0:0:0:0:0:0:0:1]`)}var i=class extends URL{constructor(e,t){super(e,t),this._decodedUsername=decodeURIComponent(super.username),this._decodedPassword=decodeURIComponent(super.password)}get username(){return this._decodedUsername}get password(){return this._decodedPassword}}})),ui=pe(U((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},e(t)};return function(r){if(r&&r.__esModule)return r;var i={};if(r!=null)for(var a=e(r),o=0;oi(this,void 0,void 0,function*(){let t=Buffer.alloc(0);this.message.on(`data`,e=>{t=Buffer.concat([t,e])}),this.message.on(`end`,()=>{e(t.toString())})}))})}readBodyBuffer(){return i(this,void 0,void 0,function*(){return new Promise(e=>i(this,void 0,void 0,function*(){let t=[];this.message.on(`data`,e=>{t.push(e)}),this.message.on(`end`,()=>{e(Buffer.concat(t))})}))})}};e.HttpClientResponse=y;function b(e){return new URL(e).protocol===`https:`}e.HttpClient=class{constructor(e,t,n){this._ignoreSslError=!1,this._allowRedirects=!0,this._allowRedirectDowngrade=!1,this._maxRedirects=50,this._allowRetries=!1,this._maxRetries=1,this._keepAlive=!1,this._disposed=!1,this.userAgent=this._getUserAgentWithOrchestrationId(e),this.handlers=t||[],this.requestOptions=n,n&&(n.ignoreSslError!=null&&(this._ignoreSslError=n.ignoreSslError),this._socketTimeout=n.socketTimeout,n.allowRedirects!=null&&(this._allowRedirects=n.allowRedirects),n.allowRedirectDowngrade!=null&&(this._allowRedirectDowngrade=n.allowRedirectDowngrade),n.maxRedirects!=null&&(this._maxRedirects=Math.max(n.maxRedirects,0)),n.keepAlive!=null&&(this._keepAlive=n.keepAlive),n.allowRetries!=null&&(this._allowRetries=n.allowRetries),n.maxRetries!=null&&(this._maxRetries=n.maxRetries))}options(e,t){return i(this,void 0,void 0,function*(){return this.request(`OPTIONS`,e,null,t||{})})}get(e,t){return i(this,void 0,void 0,function*(){return this.request(`GET`,e,null,t||{})})}del(e,t){return i(this,void 0,void 0,function*(){return this.request(`DELETE`,e,null,t||{})})}post(e,t,n){return i(this,void 0,void 0,function*(){return this.request(`POST`,e,t,n||{})})}patch(e,t,n){return i(this,void 0,void 0,function*(){return this.request(`PATCH`,e,t,n||{})})}put(e,t,n){return i(this,void 0,void 0,function*(){return this.request(`PUT`,e,t,n||{})})}head(e,t){return i(this,void 0,void 0,function*(){return this.request(`HEAD`,e,null,t||{})})}sendStream(e,t,n,r){return i(this,void 0,void 0,function*(){return this.request(e,t,n,r)})}getJson(e){return i(this,arguments,void 0,function*(e,t={}){t[d.Accept]=this._getExistingOrDefaultHeader(t,d.Accept,f.ApplicationJson);let n=yield this.get(e,t);return this._processResponse(n,this.requestOptions)})}postJson(e,t){return i(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[d.Accept]=this._getExistingOrDefaultHeader(n,d.Accept,f.ApplicationJson),n[d.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,f.ApplicationJson);let i=yield this.post(e,r,n);return this._processResponse(i,this.requestOptions)})}putJson(e,t){return i(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[d.Accept]=this._getExistingOrDefaultHeader(n,d.Accept,f.ApplicationJson),n[d.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,f.ApplicationJson);let i=yield this.put(e,r,n);return this._processResponse(i,this.requestOptions)})}patchJson(e,t){return i(this,arguments,void 0,function*(e,t,n={}){let r=JSON.stringify(t,null,2);n[d.Accept]=this._getExistingOrDefaultHeader(n,d.Accept,f.ApplicationJson),n[d.ContentType]=this._getExistingOrDefaultContentTypeHeader(n,f.ApplicationJson);let i=yield this.patch(e,r,n);return this._processResponse(i,this.requestOptions)})}request(e,t,n,r){return i(this,void 0,void 0,function*(){if(this._disposed)throw Error(`Client has already been disposed.`);let i=new URL(t),a=this._prepareRequest(e,i,r),o=this._allowRetries&&g.includes(e)?this._maxRetries+1:1,s=0,c;do{if(c=yield this.requestRaw(a,n),c&&c.message&&c.message.statusCode===u.Unauthorized){let e;for(let t of this.handlers)if(t.canHandleAuthentication(c)){e=t;break}return e?e.handleAuthentication(this,a,n):c}let t=this._maxRedirects;for(;c.message.statusCode&&m.includes(c.message.statusCode)&&this._allowRedirects&&t>0;){let o=c.message.headers.location;if(!o)break;let s=new URL(o);if(i.protocol===`https:`&&i.protocol!==s.protocol&&!this._allowRedirectDowngrade)throw Error(`Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.`);if(yield c.readBody(),s.hostname!==i.hostname)for(let e in r)e.toLowerCase()===`authorization`&&delete r[e];a=this._prepareRequest(e,s,r),c=yield this.requestRaw(a,n),t--}if(!c.message.statusCode||!h.includes(c.message.statusCode))return c;s+=1,s{function i(e,t){e?r(e):t?n(t):r(Error(`Unknown error`))}this.requestRawWithCallback(e,t,i)})})}requestRawWithCallback(e,t,n){typeof t==`string`&&(e.options.headers||(e.options.headers={}),e.options.headers[`Content-Length`]=Buffer.byteLength(t,`utf8`));let r=!1;function i(e,t){r||(r=!0,n(e,t))}let a=e.httpModule.request(e.options,e=>{i(void 0,new y(e))}),o;a.on(`socket`,e=>{o=e}),a.setTimeout(this._socketTimeout||3*6e4,()=>{o&&o.end(),i(Error(`Request timeout: ${e.options.path}`))}),a.on(`error`,function(e){i(e)}),t&&typeof t==`string`&&a.write(t,`utf8`),t&&typeof t!=`string`?(t.on(`close`,function(){a.end()}),t.pipe(a)):a.end()}getAgent(e){let t=new URL(e);return this._getAgent(t)}getAgentDispatcher(e){let t=new URL(e),n=s.getProxyUrl(t);if(n&&n.hostname)return this._getProxyAgentDispatcher(t,n)}_prepareRequest(e,t,n){let r={};r.parsedUrl=t;let i=r.parsedUrl.protocol===`https:`;r.httpModule=i?o:a;let s=i?443:80;if(r.options={},r.options.host=r.parsedUrl.hostname,r.options.port=r.parsedUrl.port?parseInt(r.parsedUrl.port):s,r.options.path=(r.parsedUrl.pathname||``)+(r.parsedUrl.search||``),r.options.method=e,r.options.headers=this._mergeHeaders(n),this.userAgent!=null&&(r.options.headers[`user-agent`]=this.userAgent),r.options.agent=this._getAgent(r.parsedUrl),this.handlers)for(let e of this.handlers)e.prepareRequest(r.options);return r}_mergeHeaders(e){return this.requestOptions&&this.requestOptions.headers?Object.assign({},x(this.requestOptions.headers),x(e||{})):x(e||{})}_getExistingOrDefaultHeader(e,t,n){let r;if(this.requestOptions&&this.requestOptions.headers){let e=x(this.requestOptions.headers)[t];e&&(r=typeof e==`number`?e.toString():e)}let i=e[t];return i===void 0?r===void 0?n:r:typeof i==`number`?i.toString():i}_getExistingOrDefaultContentTypeHeader(e,t){let n;if(this.requestOptions&&this.requestOptions.headers){let e=x(this.requestOptions.headers)[d.ContentType];e&&(n=typeof e==`number`?String(e):Array.isArray(e)?e.join(`, `):e)}let r=e[d.ContentType];return r===void 0?n===void 0?t:n:typeof r==`number`?String(r):Array.isArray(r)?r.join(`, `):r}_getAgent(e){let t,n=s.getProxyUrl(e),r=n&&n.hostname;if(this._keepAlive&&r&&(t=this._proxyAgent),r||(t=this._agent),t)return t;let i=e.protocol===`https:`,l=100;if(this.requestOptions&&(l=this.requestOptions.maxSockets||a.globalAgent.maxSockets),n&&n.hostname){let e={maxSockets:l,keepAlive:this._keepAlive,proxy:Object.assign(Object.assign({},(n.username||n.password)&&{proxyAuth:`${n.username}:${n.password}`}),{host:n.hostname,port:n.port})},r,a=n.protocol===`https:`;r=i?a?c.httpsOverHttps:c.httpsOverHttp:a?c.httpOverHttps:c.httpOverHttp,t=r(e),this._proxyAgent=t}if(!t){let e={keepAlive:this._keepAlive,maxSockets:l};t=i?new o.Agent(e):new a.Agent(e),this._agent=t}return i&&this._ignoreSslError&&(t.options=Object.assign(t.options||{},{rejectUnauthorized:!1})),t}_getProxyAgentDispatcher(e,t){let n;if(this._keepAlive&&(n=this._proxyAgentDispatcher),n)return n;let r=e.protocol===`https:`;return n=new l.ProxyAgent(Object.assign({uri:t.href,pipelining:this._keepAlive?1:0},(t.username||t.password)&&{token:`Basic ${Buffer.from(`${t.username}:${t.password}`).toString(`base64`)}`})),this._proxyAgentDispatcher=n,r&&this._ignoreSslError&&(n.options=Object.assign(n.options.requestTls||{},{rejectUnauthorized:!1})),n}_getUserAgentWithOrchestrationId(e){let t=e||`actions/http-client`,n=process.env.ACTIONS_ORCHESTRATION_ID;return n?`${t} actions_orchestration_id/${n.replace(/[^a-z0-9_.-]/gi,`_`)}`:t}_performExponentialBackoff(e){return i(this,void 0,void 0,function*(){e=Math.min(10,e);let t=5*2**e;return new Promise(e=>setTimeout(()=>e(),t))})}_processResponse(e,t){return i(this,void 0,void 0,function*(){return new Promise((n,r)=>i(this,void 0,void 0,function*(){let i=e.message.statusCode||0,a={statusCode:i,result:null,headers:{}};i===u.NotFound&&n(a);function o(e,t){if(typeof t==`string`){let e=new Date(t);if(!isNaN(e.valueOf()))return e}return t}let s,c;try{c=yield e.readBody(),c&&c.length>0&&(s=t&&t.deserializeDates?JSON.parse(c,o):JSON.parse(c),a.result=s),a.headers=e.message.headers}catch{}if(i>299){let e;e=s&&s.message?s.message:c&&c.length>0?c:`Failed request: (${i})`;let t=new v(e,i);t.result=a.result,r(t)}else n(a)}))})}};let x=e=>Object.keys(e).reduce((t,n)=>(t[n.toLowerCase()]=e[n],t),{})}))(),1),di=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function fi(e,t){if(!e&&!t.auth)throw Error(`Parameter token or opts.auth is required`);if(e&&t.auth)throw Error(`Parameters token and opts.auth may not both be specified`);return typeof t.auth==`string`?t.auth:`token ${e}`}function pi(e){return new ui.HttpClient().getAgent(e)}function mi(e){return new ui.HttpClient().getAgentDispatcher(e)}function hi(e){let t=mi(e);return(e,n)=>di(this,void 0,void 0,function*(){return(0,vn.fetch)(e,Object.assign(Object.assign({},n),{dispatcher:t}))})}function gi(){return process.env.GITHUB_API_URL||`https://api.github.com`}function _i(){return typeof navigator==`object`&&`userAgent`in navigator?navigator.userAgent:typeof process==`object`&&process.version!==void 0?`Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`:``}function vi(e,t,n,r){if(typeof n!=`function`)throw Error(`method for before hook must be a function`);return r||={},Array.isArray(t)?t.reverse().reduce((t,n)=>vi.bind(null,e,n,t,r),n)():Promise.resolve().then(()=>e.registry[t]?e.registry[t].reduce((e,t)=>t.hook.bind(null,e,r),n)():n(r))}function yi(e,t,n,r){let i=r;e.registry[n]||(e.registry[n]=[]),t===`before`&&(r=(e,t)=>Promise.resolve().then(i.bind(null,t)).then(e.bind(null,t))),t===`after`&&(r=(e,t)=>{let n;return Promise.resolve().then(e.bind(null,t)).then(e=>(n=e,i(n,t))).then(()=>n)}),t===`error`&&(r=(e,t)=>Promise.resolve().then(e.bind(null,t)).catch(e=>i(e,t))),e.registry[n].push({hook:r,orig:i})}function bi(e,t,n){if(!e.registry[t])return;let r=e.registry[t].map(e=>e.orig).indexOf(n);r!==-1&&e.registry[t].splice(r,1)}const xi=Function.bind,Si=xi.bind(xi);function Ci(e,t,n){let r=Si(bi,null).apply(null,n?[t,n]:[t]);e.api={remove:r},e.remove=r,[`before`,`error`,`after`,`wrap`].forEach(r=>{let i=n?[t,r,n]:[t,r];e[r]=e.api[r]=Si(yi,null).apply(null,i)})}function wi(){let e=Symbol(`Singular`),t={registry:{}},n=vi.bind(null,t,e);return Ci(n,t,e),n}function Ti(){let e={registry:{}},t=vi.bind(null,e);return Ci(t,e),t}var Ei={Singular:wi,Collection:Ti},Di=`octokit-endpoint.js/0.0.0-development ${_i()}`,Oi={method:`GET`,baseUrl:`https://api.github.com`,headers:{accept:`application/vnd.github.v3+json`,"user-agent":Di},mediaType:{format:``}};function ki(e){return e?Object.keys(e).reduce((t,n)=>(t[n.toLowerCase()]=e[n],t),{}):{}}function Ai(e){if(typeof e!=`object`||!e||Object.prototype.toString.call(e)!==`[object Object]`)return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let n=Object.prototype.hasOwnProperty.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&Function.prototype.call(n)===Function.prototype.call(e)}function ji(e,t){let n=Object.assign({},e);return Object.keys(t).forEach(r=>{Ai(t[r])&&r in e?n[r]=ji(e[r],t[r]):Object.assign(n,{[r]:t[r]})}),n}function Mi(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function Ni(e,t,n){if(typeof t==`string`){let[e,r]=t.split(` `);n=Object.assign(r?{method:e,url:r}:{url:e},n)}else n=Object.assign({},t);n.headers=ki(n.headers),Mi(n),Mi(n.headers);let r=ji(e||{},n);return n.url===`/graphql`&&(e&&e.mediaType.previews?.length&&(r.mediaType.previews=e.mediaType.previews.filter(e=>!r.mediaType.previews.includes(e)).concat(r.mediaType.previews)),r.mediaType.previews=(r.mediaType.previews||[]).map(e=>e.replace(/-preview/,``))),r}function Pi(e,t){let n=/\?/.test(e)?`&`:`?`,r=Object.keys(t);return r.length===0?e:e+n+r.map(e=>e===`q`?`q=`+t.q.split(`+`).map(encodeURIComponent).join(`+`):`${e}=${encodeURIComponent(t[e])}`).join(`&`)}var Fi=/\{[^{}}]+\}/g;function Ii(e){return e.replace(/(?:^\W+)|(?:(?e.concat(t),[]):[]}function Ri(e,t){let n={__proto__:null};for(let r of Object.keys(e))t.indexOf(r)===-1&&(n[r]=e[r]);return n}function zi(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(e){return/%[0-9A-Fa-f]/.test(e)||(e=encodeURI(e).replace(/%5B/g,`[`).replace(/%5D/g,`]`)),e}).join(``)}function Bi(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return`%`+e.charCodeAt(0).toString(16).toUpperCase()})}function Vi(e,t,n){return t=e===`+`||e===`#`?zi(t):Bi(t),n?Bi(n)+`=`+t:t}function Hi(e){return e!=null}function Ui(e){return e===`;`||e===`&`||e===`?`}function Wi(e,t,n,r){var i=e[n],a=[];if(Hi(i)&&i!==``)if(typeof i==`string`||typeof i==`number`||typeof i==`bigint`||typeof i==`boolean`)i=i.toString(),r&&r!==`*`&&(i=i.substring(0,parseInt(r,10))),a.push(Vi(t,i,Ui(t)?n:``));else if(r===`*`)Array.isArray(i)?i.filter(Hi).forEach(function(e){a.push(Vi(t,e,Ui(t)?n:``))}):Object.keys(i).forEach(function(e){Hi(i[e])&&a.push(Vi(t,i[e],e))});else{let e=[];Array.isArray(i)?i.filter(Hi).forEach(function(n){e.push(Vi(t,n))}):Object.keys(i).forEach(function(n){Hi(i[n])&&(e.push(Bi(n)),e.push(Vi(t,i[n].toString())))}),Ui(t)?a.push(Bi(n)+`=`+e.join(`,`)):e.length!==0&&a.push(e.join(`,`))}else t===`;`?Hi(i)&&a.push(Bi(n)):i===``&&(t===`&`||t===`?`)?a.push(Bi(n)+`=`):i===``&&a.push(``);return a}function Gi(e){return{expand:Ki.bind(null,e)}}function Ki(e,t){var n=[`+`,`#`,`.`,`/`,`;`,`?`,`&`];return e=e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(e,r,i){if(r){let e=``,i=[];if(n.indexOf(r.charAt(0))!==-1&&(e=r.charAt(0),r=r.substr(1)),r.split(/,/g).forEach(function(n){var r=/([^:\*]*)(?::(\d+)|(\*))?/.exec(n);i.push(Wi(t,e,r[1],r[2]||r[3]))}),e&&e!==`+`){var a=`,`;return e===`?`?a=`&`:e!==`#`&&(a=e),(i.length===0?``:e)+i.join(a)}else return i.join(`,`)}else return zi(i)}),e===`/`?e:e.replace(/\/$/,``)}function qi(e){let t=e.method.toUpperCase(),n=(e.url||`/`).replace(/:([a-z]\w+)/g,`{$1}`),r=Object.assign({},e.headers),i,a=Ri(e,[`method`,`baseUrl`,`url`,`headers`,`request`,`mediaType`]),o=Li(n);n=Gi(n).expand(a),/^http/.test(n)||(n=e.baseUrl+n);let s=Ri(a,Object.keys(e).filter(e=>o.includes(e)).concat(`baseUrl`));return/application\/octet-stream/i.test(r.accept)||(e.mediaType.format&&(r.accept=r.accept.split(/,/).map(t=>t.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,`application/vnd$1$2.${e.mediaType.format}`)).join(`,`)),n.endsWith(`/graphql`)&&e.mediaType.previews?.length&&(r.accept=(r.accept.match(/(?`application/vnd.github.${t}-preview${e.mediaType.format?`.${e.mediaType.format}`:`+json`}`).join(`,`))),[`GET`,`HEAD`].includes(t)?n=Pi(n,s):`data`in s?i=s.data:Object.keys(s).length&&(i=s),!r[`content-type`]&&i!==void 0&&(r[`content-type`]=`application/json; charset=utf-8`),[`PATCH`,`PUT`].includes(t)&&i===void 0&&(i=``),Object.assign({method:t,url:n,headers:r},i===void 0?null:{body:i},e.request?{request:e.request}:null)}function Ji(e,t,n){return qi(Ni(e,t,n))}function Yi(e,t){let n=Ni(e,t),r=Ji.bind(null,n);return Object.assign(r,{DEFAULTS:n,defaults:Yi.bind(null,n),merge:Ni.bind(null,n),parse:qi})}var Xi=Yi(null,Oi),Zi=U(((e,t)=>{let n=function(){};n.prototype=Object.create(null);let r=/; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu,i=/\\([\v\u0020-\u00ff])/gu,a=/^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u,o={type:``,parameters:new n};Object.freeze(o.parameters),Object.freeze(o);function s(e){if(typeof e!=`string`)throw TypeError(`argument header is required and must be a string`);let t=e.indexOf(`;`),o=t===-1?e.trim():e.slice(0,t).trim();if(a.test(o)===!1)throw TypeError(`invalid media type`);let s={type:o.toLowerCase(),parameters:new n};if(t===-1)return s;let c,l,u;for(r.lastIndex=t;l=r.exec(e);){if(l.index!==t)throw TypeError(`invalid parameter format`);t+=l[0].length,c=l[1].toLowerCase(),u=l[2],u[0]===`"`&&(u=u.slice(1,u.length-1),i.test(u)&&(u=u.replace(i,`$1`))),s.parameters[c]=u}if(t!==e.length)throw TypeError(`invalid parameter format`);return s}function c(e){if(typeof e!=`string`)return o;let t=e.indexOf(`;`),s=t===-1?e.trim():e.slice(0,t).trim();if(a.test(s)===!1)return o;let c={type:s.toLowerCase(),parameters:new n};if(t===-1)return c;let l,u,d;for(r.lastIndex=t;u=r.exec(e);){if(u.index!==t)return o;t+=u[0].length,l=u[1].toLowerCase(),d=u[2],d[0]===`"`&&(d=d.slice(1,d.length-1),i.test(d)&&(d=d.replace(i,`$1`))),c.parameters[l]=d}return t===e.length?c:o}t.exports.default={parse:s,safeParse:c},t.exports.parse=s,t.exports.safeParse=c,t.exports.defaultContentType=o}));const Qi=/^-?\d+$/,$i=/^-?\d+n+$/,ea=JSON.stringify,ta=JSON.parse,na=/^-?\d+n$/,ra=/([\[:])?"(-?\d+)n"($|([\\n]|\s)*(\s|[\\n])*[,\}\]])/g,ia=/([\[:])?("-?\d+n+)n("$|"([\\n]|\s)*(\s|[\\n])*[,\}\]])/g,aa=(e,t,n)=>`rawJSON`in JSON?ea(e,(e,n)=>typeof n==`bigint`?JSON.rawJSON(n.toString()):typeof t==`function`?t(e,n):(Array.isArray(t)&&t.includes(e),n),n):e?ea(e,(e,n)=>typeof n==`string`&&n.match($i)||typeof n==`bigint`?n.toString()+`n`:typeof t==`function`?t(e,n):(Array.isArray(t)&&t.includes(e),n),n).replace(ra,`$1$2$3`).replace(ia,`$1$2$3`):ea(e,t,n),oa=()=>JSON.parse(`1`,(e,t,n)=>!!n&&n.source===`1`),sa=(e,t,n,r)=>typeof t==`string`&&t.match(na)?BigInt(t.slice(0,-1)):typeof t==`string`&&t.match($i)?t.slice(0,-1):typeof r==`function`?r(e,t,n):t,ca=(e,t)=>JSON.parse(e,(e,n,r)=>{let i=typeof n==`number`&&(n>2**53-1||n<-(2**53-1)),a=r&&Qi.test(r.source);return i&&a?BigInt(r.source):typeof t==`function`?t(e,n,r):n}),la=(2**53-1).toString(),ua=la.length,da=/"(?:\\.|[^"])*"|-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?/g,fa=/^"-?\d+n+"$/,pa=(e,t)=>e?oa()?ca(e,t):ta(e.replace(da,(e,t,n,r)=>{let i=e[0]===`"`;if(i&&e.match(fa))return e.substring(0,e.length-1)+`n"`;let a=n||r,o=t&&(t.lengthsa(e,n,r,t)):ta(e,t);var ma=class extends Error{name;status;request;response;constructor(e,t,n){super(e,{cause:n.cause}),this.name=`HttpError`,this.status=Number.parseInt(t),Number.isNaN(this.status)&&(this.status=0),`response`in n&&(this.response=n.response);let r=Object.assign({},n.request);n.request.headers.authorization&&(r.headers=Object.assign({},n.request.headers,{authorization:n.request.headers.authorization.replace(/(?``;async function ba(e){let t=e.request?.fetch||globalThis.fetch;if(!t)throw Error(`fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing`);let n=e.request?.log||console,r=e.request?.parseSuccessResponseBody!==!1,i=va(e.body)||Array.isArray(e.body)?aa(e.body):e.body,a=Object.fromEntries(Object.entries(e.headers).map(([e,t])=>[e,String(t)])),o;try{o=await t(e.url,{method:e.method,body:i,redirect:e.request?.redirect,headers:a,signal:e.request?.signal,...e.body&&{duplex:`half`}})}catch(t){let n=`Unknown Error`;if(t instanceof Error){if(t.name===`AbortError`)throw t.status=500,t;n=t.message,t.name===`TypeError`&&`cause`in t&&(t.cause instanceof Error?n=t.cause.message:typeof t.cause==`string`&&(n=t.cause))}let r=new ma(n,500,{request:e});throw r.cause=t,r}let s=o.status,c=o.url,l={};for(let[e,t]of o.headers)l[e]=t;let u={url:c,status:s,headers:l,data:``};if(`deprecation`in l){let t=l.link&&l.link.match(/<([^<>]+)>; rel="deprecation"/),r=t&&t.pop();n.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${l.sunset}${r?`. See ${r}`:``}`)}if(s===204||s===205)return u;if(e.method===`HEAD`){if(s<400)return u;throw new ma(o.statusText,s,{response:u,request:e})}if(s===304)throw u.data=await xa(o),new ma(`Not modified`,s,{response:u,request:e});if(s>=400)throw u.data=await xa(o),new ma(Ca(u.data),s,{response:u,request:e});return u.data=r?await xa(o):o.body,u}async function xa(e){let t=e.headers.get(`content-type`);if(!t)return e.text().catch(ya);let n=(0,ha.safeParse)(t);if(Sa(n)){let t=``;try{return t=await e.text(),pa(t)}catch{return t}}else if(n.type.startsWith(`text/`)||n.parameters.charset?.toLowerCase()===`utf-8`)return e.text().catch(ya);else return e.arrayBuffer().catch(()=>new ArrayBuffer(0))}function Sa(e){return e.type===`application/json`||e.type===`application/scim+json`}function Ca(e){if(typeof e==`string`)return e;if(e instanceof ArrayBuffer)return`Unknown error`;if(`message`in e){let t=`documentation_url`in e?` - ${e.documentation_url}`:``;return Array.isArray(e.errors)?`${e.message}: ${e.errors.map(e=>JSON.stringify(e)).join(`, `)}${t}`:`${e.message}${t}`}return`Unknown error: ${JSON.stringify(e)}`}function wa(e,t){let n=e.defaults(t);return Object.assign(function(e,t){let r=n.merge(e,t);if(!r.request||!r.request.hook)return ba(n.parse(r));let i=(e,t)=>ba(n.parse(n.merge(e,t)));return Object.assign(i,{endpoint:n,defaults:wa.bind(null,n)}),r.request.hook(i,r)},{endpoint:n,defaults:wa.bind(null,n)})}var Ta=wa(Xi,_a),Ea=`0.0.0-development`;function Da(e){return`Request failed due to following response errors: `+e.errors.map(e=>` - ${e.message}`).join(` `)}var Oa=class extends Error{constructor(e,t,n){super(Da(n)),this.request=e,this.headers=t,this.response=n,this.errors=n.errors,this.data=n.data,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}name=`GraphqlResponseError`;errors;data},ka=[`method`,`baseUrl`,`url`,`headers`,`request`,`query`,`mediaType`,`operationName`],Aa=[`query`,`method`,`url`],ja=/\/api\/v3\/?$/;function Ma(e,t,n){if(n){if(typeof t==`string`&&`query`in n)return Promise.reject(Error(`[@octokit/graphql] "query" cannot be used as variable name`));for(let e in n)if(Aa.includes(e))return Promise.reject(Error(`[@octokit/graphql] "${e}" cannot be used as variable name`))}let r=typeof t==`string`?Object.assign({query:t},n):t,i=Object.keys(r).reduce((e,t)=>ka.includes(t)?(e[t]=r[t],e):(e.variables||={},e.variables[t]=r[t],e),{}),a=r.baseUrl||e.endpoint.DEFAULTS.baseUrl;return ja.test(a)&&(i.url=a.replace(ja,`/api/graphql`)),e(i).then(e=>{if(e.data.errors){let t={};for(let n of Object.keys(e.headers))t[n]=e.headers[n];throw new Oa(i,t,e.data)}return e.data.data})}function Na(e,t){let n=e.defaults(t);return Object.assign((e,t)=>Ma(n,e,t),{defaults:Na.bind(null,n),endpoint:n.endpoint})}Na(Ta,{headers:{"user-agent":`octokit-graphql.js/${Ea} ${_i()}`},method:`POST`,url:`/graphql`});function Pa(e){return Na(e,{method:`POST`,url:`/graphql`})}var Fa=`(?:[a-zA-Z0-9_-]+)`,Ia=`\\.`,La=RegExp(`^${Fa}${Ia}${Fa}${Ia}${Fa}$`),Ra=La.test.bind(La);async function za(e){let t=Ra(e),n=e.startsWith(`v1.`)||e.startsWith(`ghs_`),r=e.startsWith(`ghu_`);return{type:`token`,token:e,tokenType:t?`app`:n?`installation`:r?`user-to-server`:`oauth`}}function Ba(e){return e.split(/\./).length===3?`bearer ${e}`:`token ${e}`}async function Va(e,t,n,r){let i=t.endpoint.merge(n,r);return i.headers.authorization=Ba(e),t(i)}var Ha=function(e){if(!e)throw Error(`[@octokit/auth-token] No token passed to createTokenAuth`);if(typeof e!=`string`)throw Error(`[@octokit/auth-token] Token passed to createTokenAuth is not a string`);return e=e.replace(/^(token|bearer) +/i,``),Object.assign(za.bind(null,e),{hook:Va.bind(null,e)})};const Ua=`7.0.6`,Wa=()=>{},Ga=console.warn.bind(console),Ka=console.error.bind(console);function qa(e={}){return typeof e.debug!=`function`&&(e.debug=Wa),typeof e.info!=`function`&&(e.info=Wa),typeof e.warn!=`function`&&(e.warn=Ga),typeof e.error!=`function`&&(e.error=Ka),e}const Ja=`octokit-core.js/${Ua} ${_i()}`;var Ya=class{static VERSION=Ua;static defaults(e){return class extends this{constructor(...t){let n=t[0]||{};if(typeof e==`function`){super(e(n));return}super(Object.assign({},e,n,n.userAgent&&e.userAgent?{userAgent:`${n.userAgent} ${e.userAgent}`}:null))}}}static plugins=[];static plugin(...e){let t=this.plugins;return class extends this{static plugins=t.concat(e.filter(e=>!t.includes(e)))}}constructor(e={}){let t=new Ei.Collection,n={baseUrl:Ta.endpoint.DEFAULTS.baseUrl,headers:{},request:Object.assign({},e.request,{hook:t.bind(null,`request`)}),mediaType:{previews:[],format:``}};if(n.headers[`user-agent`]=e.userAgent?`${e.userAgent} ${Ja}`:Ja,e.baseUrl&&(n.baseUrl=e.baseUrl),e.previews&&(n.mediaType.previews=e.previews),e.timeZone&&(n.headers[`time-zone`]=e.timeZone),this.request=Ta.defaults(n),this.graphql=Pa(this.request).defaults(n),this.log=qa(e.log),this.hook=t,e.authStrategy){let{authStrategy:n,...r}=e,i=n(Object.assign({request:this.request,log:this.log,octokit:this,octokitOptions:r},e.auth));t.wrap(`request`,i.hook),this.auth=i}else if(!e.auth)this.auth=async()=>({type:`unauthenticated`});else{let n=Ha(e.auth);t.wrap(`request`,n.hook),this.auth=n}let r=this.constructor;for(let t=0;t({async next(){if(!s)return{done:!0};try{let e=ao(await i({method:a,url:s,headers:o}));if(s=((e.headers.link||``).match(/<([^<>]+)>;\s*rel="next"/)||[])[1],!s&&`total_commits`in e.data){let t=new URL(e.url),n=t.searchParams,r=parseInt(n.get(`page`)||`1`,10);r*parseInt(n.get(`per_page`)||`250`,10){if(i.done)return t;let a=!1;function o(){a=!0}return t=t.concat(r?r(i.value,o):i.value.data),a?t:co(e,t,n,r)})}Object.assign(so,{iterator:oo});function lo(e){return{paginate:Object.assign(so.bind(null,e),{iterator:oo.bind(null,e)})}}lo.VERSION=io,new ci;const uo=gi(),fo={baseUrl:uo,request:{agent:pi(uo),fetch:hi(uo)}},po=Ya.plugin(no,lo).defaults(fo);function mo(e,t){let n=Object.assign({},t||{}),r=fi(e,n);return r&&(n.auth=r),n}const ho=new ci;function go(e,t,...n){return new(po.plugin(...n))(mo(e,t))}var _o=U(((e,t)=>{t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}})),vo=U(((e,t)=>{t.exports=typeof process==`object`&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{}})),yo=U(((e,t)=>{let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=_o(),a=vo();e=t.exports={};let o=e.re=[],s=e.safeRe=[],c=e.src=[],l=e.safeSrc=[],u=e.t={},d=0,f=`[a-zA-Z0-9-]`,p=[[`\\s`,1],[`\\d`,i],[f,r]],m=e=>{for(let[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},h=(e,t,n)=>{let r=m(t),i=d++;a(e,i,t),u[e]=i,c[i]=t,l[i]=r,o[i]=new RegExp(t,n?`g`:void 0),s[i]=new RegExp(r,n?`g`:void 0)};h(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),h(`NUMERICIDENTIFIERLOOSE`,`\\d+`),h(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${f}*`),h(`MAINVERSION`,`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h(`MAINVERSIONLOOSE`,`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASEIDENTIFIER`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h(`PRERELEASEIDENTIFIERLOOSE`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASE`,`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h(`PRERELEASELOOSE`,`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h(`BUILDIDENTIFIER`,`${f}+`),h(`BUILD`,`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h(`FULLPLAIN`,`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h(`FULL`,`^${c[u.FULLPLAIN]}$`),h(`LOOSEPLAIN`,`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h(`LOOSE`,`^${c[u.LOOSEPLAIN]}$`),h(`GTLT`,`((?:<|>)?=?)`),h(`XRANGEIDENTIFIERLOOSE`,`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h(`XRANGEIDENTIFIER`,`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h(`XRANGEPLAIN`,`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h(`XRANGEPLAINLOOSE`,`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h(`XRANGE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h(`XRANGELOOSE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),h(`COERCE`,`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h(`COERCEFULL`,c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),h(`COERCERTL`,c[u.COERCE],!0),h(`COERCERTLFULL`,c[u.COERCEFULL],!0),h(`LONETILDE`,`(?:~>?)`),h(`TILDETRIM`,`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace=`$1~`,h(`TILDE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h(`TILDELOOSE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h(`LONECARET`,`(?:\\^)`),h(`CARETTRIM`,`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace=`$1^`,h(`CARET`,`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h(`CARETLOOSE`,`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h(`COMPARATORLOOSE`,`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h(`COMPARATOR`,`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h(`COMPARATORTRIM`,`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=`$1$2$3`,h(`HYPHENRANGE`,`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h(`HYPHENRANGELOOSE`,`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h(`STAR`,`(<|>)?=?\\s*\\*`),h(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),h(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})),bo=U(((e,t)=>{let n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),xo=U(((e,t)=>{let n=/^[0-9]+$/,r=(e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e===t?0:er(t,e)}})),So=U(((e,t)=>{let n=vo(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=_o(),{safeRe:a,t:o}=yo(),s=bo(),{compareIdentifiers:c}=xo();t.exports=class e{constructor(t,c){if(c=s(c),t instanceof e){if(t.loose===!!c.loose&&t.includePrerelease===!!c.includePrerelease)return t;t=t.version}else if(typeof t!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>r)throw TypeError(`version is longer than ${r} characters`);n(`SemVer`,t,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;let l=t.trim().match(c.loose?a[o.LOOSE]:a[o.FULL]);if(!l)throw TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>i||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>i||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>i||this.patch<0)throw TypeError(`Invalid patch version`);l[4]?this.prerelease=l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&tt.major?1:this.minort.minor?1:this.patcht.patch?1:0}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let e=this.prerelease[r],i=t.prerelease[r];if(n(`prerelease compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let e=this.build[r],i=t.build[r];if(n(`build compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}inc(e,t,n){if(e.startsWith(`pre`)){if(!t&&n===!1)throw Error(`invalid increment argument: identifier is empty`);if(t){let e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case`premajor`:this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc(`pre`,t,n);break;case`preminor`:this.prerelease.length=0,this.patch=0,this.minor++,this.inc(`pre`,t,n);break;case`prepatch`:this.prerelease.length=0,this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`prerelease`:this.prerelease.length===0&&this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`release`:if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case`major`:(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case`minor`:(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case`patch`:this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case`pre`:{let e=Number(n)?1:0;if(this.prerelease.length===0)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];n===!1&&(r=[t]),c(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}})),Co=U(((e,t)=>{let n=So();t.exports=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}}})),wo=U(((e,t)=>{let n=Co();t.exports=(e,t)=>{let r=n(e,t);return r?r.version:null}})),To=U(((e,t)=>{let n=Co();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),Eo=U(((e,t)=>{let n=So();t.exports=(e,t,r,i,a)=>{typeof r==`string`&&(a=i,i=r,r=void 0);try{return new n(e instanceof n?e.version:e,r).inc(t,i,a).version}catch{return null}}})),Do=U(((e,t)=>{let n=Co();t.exports=(e,t)=>{let r=n(e,null,!0),i=n(t,null,!0),a=r.compare(i);if(a===0)return null;let o=a>0,s=o?r:i,c=o?i:r,l=!!s.prerelease.length;if(c.prerelease.length&&!l){if(!c.patch&&!c.minor)return`major`;if(c.compareMain(s)===0)return c.minor&&!c.patch?`minor`:`patch`}let u=l?`pre`:``;return r.major===i.major?r.minor===i.minor?r.patch===i.patch?`prerelease`:u+`patch`:u+`minor`:u+`major`}})),Oo=U(((e,t)=>{let n=So();t.exports=(e,t)=>new n(e,t).major})),ko=U(((e,t)=>{let n=So();t.exports=(e,t)=>new n(e,t).minor})),Ao=U(((e,t)=>{let n=So();t.exports=(e,t)=>new n(e,t).patch})),jo=U(((e,t)=>{let n=Co();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),Mo=U(((e,t)=>{let n=So();t.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))})),No=U(((e,t)=>{let n=Mo();t.exports=(e,t,r)=>n(t,e,r)})),Po=U(((e,t)=>{let n=Mo();t.exports=(e,t)=>n(e,t,!0)})),Fo=U(((e,t)=>{let n=So();t.exports=(e,t,r)=>{let i=new n(e,r),a=new n(t,r);return i.compare(a)||i.compareBuild(a)}})),Io=U(((e,t)=>{let n=Fo();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),Lo=U(((e,t)=>{let n=Fo();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),Ro=U(((e,t)=>{let n=Mo();t.exports=(e,t,r)=>n(e,t,r)>0})),zo=U(((e,t)=>{let n=Mo();t.exports=(e,t,r)=>n(e,t,r)<0})),Bo=U(((e,t)=>{let n=Mo();t.exports=(e,t,r)=>n(e,t,r)===0})),Vo=U(((e,t)=>{let n=Mo();t.exports=(e,t,r)=>n(e,t,r)!==0})),Ho=U(((e,t)=>{let n=Mo();t.exports=(e,t,r)=>n(e,t,r)>=0})),Uo=U(((e,t)=>{let n=Mo();t.exports=(e,t,r)=>n(e,t,r)<=0})),Wo=U(((e,t)=>{let n=Bo(),r=Vo(),i=Ro(),a=Ho(),o=zo(),s=Uo();t.exports=(e,t,c,l)=>{switch(t){case`===`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e===c;case`!==`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e!==c;case``:case`=`:case`==`:return n(e,c,l);case`!=`:return r(e,c,l);case`>`:return i(e,c,l);case`>=`:return a(e,c,l);case`<`:return o(e,c,l);case`<=`:return s(e,c,l);default:throw TypeError(`Invalid operator: ${t}`)}}})),Go=U(((e,t)=>{let n=So(),r=Co(),{safeRe:i,t:a}=yo();t.exports=(e,t)=>{if(e instanceof n)return e;if(typeof e==`number`&&(e=String(e)),typeof e!=`string`)return null;t||={};let o=null;if(!t.rtl)o=e.match(t.includePrerelease?i[a.COERCEFULL]:i[a.COERCE]);else{let n=t.includePrerelease?i[a.COERCERTLFULL]:i[a.COERCERTL],r;for(;(r=n.exec(e))&&(!o||o.index+o[0].length!==e.length);)(!o||r.index+r[0].length!==o.index+o[0].length)&&(o=r),n.lastIndex=r.index+r[1].length+r[2].length;n.lastIndex=-1}if(o===null)return null;let s=o[2];return r(`${s}.${o[3]||`0`}.${o[4]||`0`}${t.includePrerelease&&o[5]?`-${o[5]}`:``}${t.includePrerelease&&o[6]?`+${o[6]}`:``}`,t)}})),Ko=U(((e,t)=>{t.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}})),qo=U(((e,t)=>{let n=/\s+/g;t.exports=class e{constructor(t,r){if(r=i(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof a)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(n,` `),this.set=this.raw.split(`||`).map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let e=this.set[0];if(this.set=this.set.filter(e=>!h(e[0])),this.set.length===0)this.set=[e];else if(this.set.length>1){for(let e of this.set)if(e.length===1&&g(e[0])){this.set=[e];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted=``;for(let e=0;e0&&(this.formatted+=`||`);let t=this.set[e];for(let e=0;e0&&(this.formatted+=` `),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let t=((this.options.includePrerelease&&p)|(this.options.loose&&m))+`:`+e,n=r.get(t);if(n)return n;let i=this.options.loose,s=i?c[l.HYPHENRANGELOOSE]:c[l.HYPHENRANGE];e=e.replace(s,k(this.options.includePrerelease)),o(`hyphen replace`,e),e=e.replace(c[l.COMPARATORTRIM],u),o(`comparator trim`,e),e=e.replace(c[l.TILDETRIM],d),o(`tilde trim`,e),e=e.replace(c[l.CARETTRIM],f),o(`caret trim`,e);let g=e.split(` `).map(e=>y(e,this.options)).join(` `).split(/\s+/).map(e=>O(e,this.options));i&&(g=g.filter(e=>(o(`loose invalid filter`,e,this.options),!!e.match(c[l.COMPARATORLOOSE])))),o(`range list`,g);let v=new Map,b=g.map(e=>new a(e,this.options));for(let e of b){if(h(e))return[e];v.set(e.value,e)}v.size>1&&v.has(``)&&v.delete(``);let x=[...v.values()];return r.set(t,x),x}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Range is required`);return this.set.some(e=>v(e,n)&&t.set.some(t=>v(t,n)&&e.every(e=>t.every(t=>e.intersects(t,n)))))}test(e){if(!e)return!1;if(typeof e==`string`)try{e=new s(e,this.options)}catch{return!1}for(let t=0;te.value===`<0.0.0-0`,g=e=>e.value===``,v=(e,t)=>{let n=!0,r=e.slice(),i=r.pop();for(;n&&r.length;)n=r.every(e=>i.intersects(e,t)),i=r.pop();return n},y=(e,t)=>(e=e.replace(c[l.BUILD],``),o(`comp`,e,t),e=C(e,t),o(`caret`,e),e=x(e,t),o(`tildes`,e),e=T(e,t),o(`xrange`,e),e=D(e,t),o(`stars`,e),e),b=e=>!e||e.toLowerCase()===`x`||e===`*`,x=(e,t)=>e.trim().split(/\s+/).map(e=>S(e,t)).join(` `),S=(e,t)=>{let n=t.loose?c[l.TILDELOOSE]:c[l.TILDE];return e.replace(n,(t,n,r,i,a)=>{o(`tilde`,e,t,n,r,i,a);let s;return b(n)?s=``:b(r)?s=`>=${n}.0.0 <${+n+1}.0.0-0`:b(i)?s=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:a?(o(`replaceTilde pr`,a),s=`>=${n}.${r}.${i}-${a} <${n}.${+r+1}.0-0`):s=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`,o(`tilde return`,s),s})},C=(e,t)=>e.trim().split(/\s+/).map(e=>w(e,t)).join(` `),w=(e,t)=>{o(`caret`,e,t);let n=t.loose?c[l.CARETLOOSE]:c[l.CARET],r=t.includePrerelease?`-0`:``;return e.replace(n,(t,n,i,a,s)=>{o(`caret`,e,t,n,i,a,s);let c;return b(n)?c=``:b(i)?c=`>=${n}.0.0${r} <${+n+1}.0.0-0`:b(a)?c=n===`0`?`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.0${r} <${+n+1}.0.0-0`:s?(o(`replaceCaret pr`,s),c=n===`0`?i===`0`?`>=${n}.${i}.${a}-${s} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}-${s} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a}-${s} <${+n+1}.0.0-0`):(o(`no pr`),c=n===`0`?i===`0`?`>=${n}.${i}.${a}${r} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a} <${+n+1}.0.0-0`),o(`caret return`,c),c})},T=(e,t)=>(o(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>E(e,t)).join(` `)),E=(e,t)=>{e=e.trim();let n=t.loose?c[l.XRANGELOOSE]:c[l.XRANGE];return e.replace(n,(n,r,i,a,s,c)=>{o(`xRange`,e,n,r,i,a,s,c);let l=b(i),u=l||b(a),d=u||b(s),f=d;return r===`=`&&f&&(r=``),c=t.includePrerelease?`-0`:``,l?n=r===`>`||r===`<`?`<0.0.0-0`:`*`:r&&f?(u&&(a=0),s=0,r===`>`?(r=`>=`,u?(i=+i+1,a=0,s=0):(a=+a+1,s=0)):r===`<=`&&(r=`<`,u?i=+i+1:a=+a+1),r===`<`&&(c=`-0`),n=`${r+i}.${a}.${s}${c}`):u?n=`>=${i}.0.0${c} <${+i+1}.0.0-0`:d&&(n=`>=${i}.${a}.0${c} <${i}.${+a+1}.0-0`),o(`xRange return`,n),n})},D=(e,t)=>(o(`replaceStars`,e,t),e.trim().replace(c[l.STAR],``)),O=(e,t)=>(o(`replaceGTE0`,e,t),e.trim().replace(c[t.includePrerelease?l.GTE0PRE:l.GTE0],``)),k=e=>(t,n,r,i,a,o,s,c,l,u,d,f)=>(n=b(r)?``:b(i)?`>=${r}.0.0${e?`-0`:``}`:b(a)?`>=${r}.${i}.0${e?`-0`:``}`:o?`>=${n}`:`>=${n}${e?`-0`:``}`,c=b(l)?``:b(u)?`<${+l+1}.0.0-0`:b(d)?`<${l}.${+u+1}.0-0`:f?`<=${l}.${u}.${d}-${f}`:e?`<${l}.${u}.${+d+1}-0`:`<=${c}`,`${n} ${c}`.trim()),A=(e,t,n)=>{for(let n=0;n0){let r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0}})),Jo=U(((e,t)=>{let n=Symbol(`SemVer ANY`);t.exports=class e{static get ANY(){return n}constructor(t,i){if(i=r(i),t instanceof e){if(t.loose===!!i.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(` `),s(`comparator`,t,i),this.options=i,this.loose=!!i.loose,this.parse(t),this.semver===n?this.value=``:this.value=this.operator+this.semver.version,s(`comp`,this)}parse(e){let t=this.options.loose?i[a.COMPARATORLOOSE]:i[a.COMPARATOR],r=e.match(t);if(!r)throw TypeError(`Invalid comparator: ${e}`);this.operator=r[1]===void 0?``:r[1],this.operator===`=`&&(this.operator=``),r[2]?this.semver=new c(r[2],this.options.loose):this.semver=n}toString(){return this.value}test(e){if(s(`Comparator.test`,e,this.options.loose),this.semver===n||e===n)return!0;if(typeof e==`string`)try{e=new c(e,this.options)}catch{return!1}return o(e,this.operator,this.semver,this.options)}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Comparator is required`);return this.operator===``?this.value===``?!0:new l(t.value,n).test(this.value):t.operator===``?t.value===``?!0:new l(this.value,n).test(t.semver):(n=r(n),n.includePrerelease&&(this.value===`<0.0.0-0`||t.value===`<0.0.0-0`)||!n.includePrerelease&&(this.value.startsWith(`<0.0.0`)||t.value.startsWith(`<0.0.0`))?!1:!!(this.operator.startsWith(`>`)&&t.operator.startsWith(`>`)||this.operator.startsWith(`<`)&&t.operator.startsWith(`<`)||this.semver.version===t.semver.version&&this.operator.includes(`=`)&&t.operator.includes(`=`)||o(this.semver,`<`,t.semver,n)&&this.operator.startsWith(`>`)&&t.operator.startsWith(`<`)||o(this.semver,`>`,t.semver,n)&&this.operator.startsWith(`<`)&&t.operator.startsWith(`>`)))}};let r=bo(),{safeRe:i,t:a}=yo(),o=Wo(),s=vo(),c=So(),l=qo()})),Yo=U(((e,t)=>{let n=qo();t.exports=(e,t,r)=>{try{t=new n(t,r)}catch{return!1}return t.test(e)}})),Xo=U(((e,t)=>{let n=qo();t.exports=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),Zo=U(((e,t)=>{let n=So(),r=qo();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===-1)&&(a=e,o=new n(a,i))}),a}})),Qo=U(((e,t)=>{let n=So(),r=qo();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===1)&&(a=e,o=new n(a,i))}),a}})),$o=U(((e,t)=>{let n=So(),r=qo(),i=Ro();t.exports=(e,t)=>{e=new r(e,t);let a=new n(`0.0.0`);if(e.test(a)||(a=new n(`0.0.0-0`),e.test(a)))return a;a=null;for(let t=0;t{let t=new n(e.semver.version);switch(e.operator){case`>`:t.prerelease.length===0?t.patch++:t.prerelease.push(0),t.raw=t.format();case``:case`>=`:(!o||i(t,o))&&(o=t);break;case`<`:case`<=`:break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),o&&(!a||i(a,o))&&(a=o)}return a&&e.test(a)?a:null}})),es=U(((e,t)=>{let n=qo();t.exports=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}}})),ts=U(((e,t)=>{let n=So(),r=Jo(),{ANY:i}=r,a=qo(),o=Yo(),s=Ro(),c=zo(),l=Uo(),u=Ho();t.exports=(e,t,d,f)=>{e=new n(e,f),t=new a(t,f);let p,m,h,g,v;switch(d){case`>`:p=s,m=l,h=c,g=`>`,v=`>=`;break;case`<`:p=c,m=u,h=s,g=`<`,v=`<=`;break;default:throw TypeError(`Must provide a hilo val of "<" or ">"`)}if(o(e,t,f))return!1;for(let n=0;n{e.semver===i&&(e=new r(`>=0.0.0`)),o||=e,s||=e,p(e.semver,o.semver,f)?o=e:h(e.semver,s.semver,f)&&(s=e)}),o.operator===g||o.operator===v||(!s.operator||s.operator===g)&&m(e,s.semver)||s.operator===v&&h(e,s.semver))return!1}return!0}})),ns=U(((e,t)=>{let n=ts();t.exports=(e,t,r)=>n(e,t,`>`,r)})),rs=U(((e,t)=>{let n=ts();t.exports=(e,t,r)=>n(e,t,`<`,r)})),is=U(((e,t)=>{let n=qo();t.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))})),as=U(((e,t)=>{let n=Yo(),r=Mo();t.exports=(e,t,i)=>{let a=[],o=null,s=null,c=e.sort((e,t)=>r(e,t,i));for(let e of c)n(e,t,i)?(s=e,o||=e):(s&&a.push([o,s]),s=null,o=null);o&&a.push([o,null]);let l=[];for(let[e,t]of a)e===t?l.push(e):!t&&e===c[0]?l.push(`*`):t?e===c[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`);let u=l.join(` || `),d=typeof t.raw==`string`?t.raw:String(t);return u.length{let n=qo(),r=Jo(),{ANY:i}=r,a=Yo(),o=Mo(),s=(e,t,r={})=>{if(e===t)return!0;e=new n(e,r),t=new n(t,r);let i=!1;OUTER:for(let n of e.set){for(let e of t.set){let t=u(n,e,r);if(i||=t!==null,t)continue OUTER}if(i)return!1}return!0},c=[new r(`>=0.0.0-0`)],l=[new r(`>=0.0.0`)],u=(e,t,n)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===i){if(t.length===1&&t[0].semver===i)return!0;e=n.includePrerelease?c:l}if(t.length===1&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}let r=new Set,s,u;for(let t of e)t.operator===`>`||t.operator===`>=`?s=d(s,t,n):t.operator===`<`||t.operator===`<=`?u=f(u,t,n):r.add(t.semver);if(r.size>1)return null;let p;if(s&&u&&(p=o(s.semver,u.semver,n),p>0||p===0&&(s.operator!==`>=`||u.operator!==`<=`)))return null;for(let e of r){if(s&&!a(e,String(s),n)||u&&!a(e,String(u),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let m,h,g,v,y=u&&!n.includePrerelease&&u.semver.prerelease.length?u.semver:!1,b=s&&!n.includePrerelease&&s.semver.prerelease.length?s.semver:!1;y&&y.prerelease.length===1&&u.operator===`<`&&y.prerelease[0]===0&&(y=!1);for(let e of t){if(v=v||e.operator===`>`||e.operator===`>=`,g=g||e.operator===`<`||e.operator===`<=`,s){if(b&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===b.major&&e.semver.minor===b.minor&&e.semver.patch===b.patch&&(b=!1),e.operator===`>`||e.operator===`>=`){if(m=d(s,e,n),m===e&&m!==s)return!1}else if(s.operator===`>=`&&!a(s.semver,String(e),n))return!1}if(u){if(y&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===y.major&&e.semver.minor===y.minor&&e.semver.patch===y.patch&&(y=!1),e.operator===`<`||e.operator===`<=`){if(h=f(u,e,n),h===e&&h!==u)return!1}else if(u.operator===`<=`&&!a(u.semver,String(e),n))return!1}if(!e.operator&&(u||s)&&p!==0)return!1}return!(s&&g&&!u&&p!==0||u&&v&&!s&&p!==0||b||y)},d=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r>0?e:r<0||t.operator===`>`&&e.operator===`>=`?t:e},f=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r<0?e:r>0||t.operator===`<`&&e.operator===`<=`?t:e};t.exports=s})),ss=U(((e,t)=>{let n=yo(),r=_o(),i=So(),a=xo();t.exports={parse:Co(),valid:wo(),clean:To(),inc:Eo(),diff:Do(),major:Oo(),minor:ko(),patch:Ao(),prerelease:jo(),compare:Mo(),rcompare:No(),compareLoose:Po(),compareBuild:Fo(),sort:Io(),rsort:Lo(),gt:Ro(),lt:zo(),eq:Bo(),neq:Vo(),gte:Ho(),lte:Uo(),cmp:Wo(),coerce:Go(),Comparator:Jo(),Range:qo(),satisfies:Yo(),toComparators:Xo(),maxSatisfying:Zo(),minSatisfying:Qo(),minVersion:$o(),validRange:es(),outside:ts(),gtr:ns(),ltr:rs(),intersects:is(),simplifyRange:as(),subset:os(),SemVer:i,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:r.SEMVER_SPEC_VERSION,RELEASE_TYPES:r.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}}));function cs(e){let t={followSymbolicLinks:!0,implicitDescendants:!0,matchDirectories:!0,omitBrokenSymbolicLinks:!0,excludeHiddenFiles:!1};return e&&(typeof e.followSymbolicLinks==`boolean`&&(t.followSymbolicLinks=e.followSymbolicLinks,G(`followSymbolicLinks '${t.followSymbolicLinks}'`)),typeof e.implicitDescendants==`boolean`&&(t.implicitDescendants=e.implicitDescendants,G(`implicitDescendants '${t.implicitDescendants}'`)),typeof e.matchDirectories==`boolean`&&(t.matchDirectories=e.matchDirectories,G(`matchDirectories '${t.matchDirectories}'`)),typeof e.omitBrokenSymbolicLinks==`boolean`&&(t.omitBrokenSymbolicLinks=e.omitBrokenSymbolicLinks,G(`omitBrokenSymbolicLinks '${t.omitBrokenSymbolicLinks}'`)),typeof e.excludeHiddenFiles==`boolean`&&(t.excludeHiddenFiles=e.excludeHiddenFiles,G(`excludeHiddenFiles '${t.excludeHiddenFiles}'`))),t}const ls=process.platform===`win32`;function us(e){if(e=hs(e),ls&&/^\\\\[^\\]+(\\[^\\]+)?$/.test(e))return e;let t=f.dirname(e);return ls&&/^\\\\[^\\]+\\[^\\]+\\$/.test(t)&&(t=hs(t)),t}function ds(e,t){if(b(e,`ensureAbsoluteRoot parameter 'root' must not be empty`),b(t,`ensureAbsoluteRoot parameter 'itemPath' must not be empty`),fs(t))return t;if(ls){if(t.match(/^[A-Z]:[^\\/]|^[A-Z]:$/i)){let e=process.cwd();return b(e.match(/^[A-Z]:\\/i),`Expected current directory to start with an absolute drive root. Actual '${e}'`),t[0].toUpperCase()===e[0].toUpperCase()?t.length===2?`${t[0]}:\\${e.substr(3)}`:(e.endsWith(`\\`)||(e+=`\\`),`${t[0]}:\\${e.substr(3)}${t.substr(2)}`):`${t[0]}:\\${t.substr(2)}`}else if(ms(t).match(/^\\$|^\\[^\\]/)){let e=process.cwd();return b(e.match(/^[A-Z]:\\/i),`Expected current directory to start with an absolute drive root. Actual '${e}'`),`${e[0]}:\\${t.substr(1)}`}}return b(fs(e),`ensureAbsoluteRoot parameter 'root' must have an absolute root`),e.endsWith(`/`)||ls&&e.endsWith(`\\`)||(e+=f.sep),e+t}function fs(e){return b(e,`hasAbsoluteRoot parameter 'itemPath' must not be empty`),e=ms(e),ls?e.startsWith(`\\\\`)||/^[A-Z]:\\/i.test(e):e.startsWith(`/`)}function ps(e){return b(e,`isRooted parameter 'itemPath' must not be empty`),e=ms(e),ls?e.startsWith(`\\`)||/^[A-Z]:/i.test(e):e.startsWith(`/`)}function ms(e){return e||=``,ls?(e=e.replace(/\//g,`\\`),(/^\\\\+[^\\]/.test(e)?`\\`:``)+e.replace(/\\\\+/g,`\\`)):e.replace(/\/\/+/g,`/`)}function hs(e){return e?(e=ms(e),!e.endsWith(f.sep)||e===f.sep||ls&&/^[A-Z]:\\$/i.test(e)?e:e.substr(0,e.length-1)):``}var gs;(function(e){e[e.None=0]=`None`,e[e.Directory=1]=`Directory`,e[e.File=2]=`File`,e[e.All=3]=`All`})(gs||={});const _s=process.platform===`win32`;function vs(e){e=e.filter(e=>!e.negate);let t={};for(let n of e){let e=_s?n.searchPath.toUpperCase():n.searchPath;t[e]=`candidate`}let n=[];for(let r of e){let e=_s?r.searchPath.toUpperCase():r.searchPath;if(t[e]===`included`)continue;let i=!1,a=e,o=us(a);for(;o!==a;){if(t[o]){i=!0;break}a=o,o=us(a)}i||(n.push(r.searchPath),t[e]=`included`)}return n}function ys(e,t){let n=gs.None;for(let r of e)r.negate?n&=~r.match(t):n|=r.match(t);return n}function bs(e,t){return e.some(e=>!e.negate&&e.partialMatch(t))}var xs=U(((e,t)=>{t.exports=function(e,t){for(var r=[],i=0;i{t.exports=n;function n(e,t,n){e instanceof RegExp&&(e=r(e,n)),t instanceof RegExp&&(t=r(t,n));var a=i(e,t,n);return a&&{start:a[0],end:a[1],pre:n.slice(0,a[0]),body:n.slice(a[0]+e.length,a[1]),post:n.slice(a[1]+t.length)}}function r(e,t){var n=t.match(e);return n?n[0]:null}n.range=i;function i(e,t,n){var r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;)u==c?(r.push(u),c=n.indexOf(e,u+1)):r.length==1?s=[r.pop(),l]:(i=r.pop(),i=0?c:l;r.length&&(s=[a,o])}return s}})),Cs=U(((e,t)=>{var n=xs(),r=Ss();t.exports=p;var i=`\0SLASH`+Math.random()+`\0`,a=`\0OPEN`+Math.random()+`\0`,o=`\0CLOSE`+Math.random()+`\0`,s=`\0COMMA`+Math.random()+`\0`,c=`\0PERIOD`+Math.random()+`\0`;function l(e){return parseInt(e,10)==e?parseInt(e,10):e.charCodeAt(0)}function u(e){return e.split(`\\\\`).join(i).split(`\\{`).join(a).split(`\\}`).join(o).split(`\\,`).join(s).split(`\\.`).join(c)}function d(e){return e.split(i).join(`\\`).split(a).join(`{`).split(o).join(`}`).split(s).join(`,`).split(c).join(`.`)}function f(e){if(!e)return[``];var t=[],n=r(`{`,`}`,e);if(!n)return e.split(`,`);var i=n.pre,a=n.body,o=n.post,s=i.split(`,`);s[s.length-1]+=`{`+a+`}`;var c=f(o);return o.length&&(s[s.length-1]+=c.shift(),s.push.apply(s,c)),t.push.apply(t,s),t}function p(e){return e?(e.substr(0,2)===`{}`&&(e=`\\{\\}`+e.substr(2)),y(u(e),!0).map(d)):[]}function m(e){return`{`+e+`}`}function h(e){return/^-?0\d/.test(e)}function g(e,t){return e<=t}function v(e,t){return e>=t}function y(e,t){var i=[],a=r(`{`,`}`,e);if(!a||/\$$/.test(a.pre))return[e];var s=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),u=s||c,d=a.body.indexOf(`,`)>=0;if(!u&&!d)return a.post.match(/,(?!,).*\}/)?(e=a.pre+`{`+a.body+o+a.post,y(e)):[e];var p;if(u)p=a.body.split(/\.\./);else if(p=f(a.body),p.length===1&&(p=y(p[0],!1).map(m),p.length===1)){var b=a.post.length?y(a.post,!1):[``];return b.map(function(e){return a.pre+p[0]+e})}var x=a.pre,b=a.post.length?y(a.post,!1):[``],S;if(u){var C=l(p[0]),w=l(p[1]),T=Math.max(p[0].length,p[1].length),E=p.length==3?Math.abs(l(p[2])):1,D=g;w0){var M=Array(j+1).join(`0`);A=k<0?`-`+M+A.slice(1):M+A}}S.push(A)}}else S=n(p,function(e){return y(e,!1)});for(var N=0;N{t.exports=h,h.Minimatch=g;var n=function(){try{return W(`path`)}catch{}}()||{sep:`/`};h.sep=n.sep;var r=h.GLOBSTAR=g.GLOBSTAR={},i=Cs(),a={"!":{open:`(?:(?!(?:`,close:`))[^/]*?)`},"?":{open:`(?:`,close:`)?`},"+":{open:`(?:`,close:`)+`},"*":{open:`(?:`,close:`)*`},"@":{open:`(?:`,close:`)`}},o=`[^/]`,s=o+`*?`,c=`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`,l=`(?:(?!(?:\\/|^)\\.).)*?`,u=d(`().*{}+?[]^$\\!`);function d(e){return e.split(``).reduce(function(e,t){return e[t]=!0,e},{})}var f=/\/+/;h.filter=p;function p(e,t){return t||={},function(n,r,i){return h(n,e,t)}}function m(e,t){t||={};var n={};return Object.keys(e).forEach(function(t){n[t]=e[t]}),Object.keys(t).forEach(function(e){n[e]=t[e]}),n}h.defaults=function(e){if(!e||typeof e!=`object`||!Object.keys(e).length)return h;var t=h,n=function(n,r,i){return t(n,r,m(e,i))};return n.Minimatch=function(n,r){return new t.Minimatch(n,m(e,r))},n.Minimatch.defaults=function(n){return t.defaults(m(e,n)).Minimatch},n.filter=function(n,r){return t.filter(n,m(e,r))},n.defaults=function(n){return t.defaults(m(e,n))},n.makeRe=function(n,r){return t.makeRe(n,m(e,r))},n.braceExpand=function(n,r){return t.braceExpand(n,m(e,r))},n.match=function(n,r,i){return t.match(n,r,m(e,i))},n},g.defaults=function(e){return h.defaults(e).Minimatch};function h(e,t,n){return S(t),n||={},!n.nocomment&&t.charAt(0)===`#`?!1:new g(t,n).match(e)}function g(e,t){if(!(this instanceof g))return new g(e,t);S(e),t||={},e=e.trim(),!t.allowWindowsEscape&&n.sep!==`/`&&(e=e.split(n.sep).join(`/`)),this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion===void 0?200:t.maxGlobstarRecursion,this.set=[],this.pattern=e,this.regexp=null,this.negate=!1,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.make()}g.prototype.debug=function(){},g.prototype.make=v;function v(){var e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate();var n=this.globSet=this.braceExpand();t.debug&&(this.debug=function(){console.error.apply(console,arguments)}),this.debug(this.pattern,n),n=this.globParts=n.map(function(e){return e.split(f)}),this.debug(this.pattern,n),n=n.map(function(e,t,n){return e.map(this.parse,this)},this),this.debug(this.pattern,n),n=n.filter(function(e){return e.indexOf(!1)===-1}),this.debug(this.pattern,n),this.set=n}g.prototype.parseNegate=y;function y(){var e=this.pattern,t=!1,n=this.options,r=0;if(!n.nonegate){for(var i=0,a=e.length;ix)throw TypeError(`pattern is too long`)};g.prototype.parse=w;var C={};function w(e,t){S(e);var n=this.options;if(e===`**`)if(n.noglobstar)e=`*`;else return r;if(e===``)return``;var i=``,c=!!n.nocase,l=!1,d=[],f=[],p,m=!1,h=-1,g=-1,v=e.charAt(0)===`.`?``:n.dot?`(?!(?:^|\\/)\\.{1,2}(?:$|\\/))`:`(?!\\.)`,y=this;function b(){if(p){switch(p){case`*`:i+=s,c=!0;break;case`?`:i+=o,c=!0;break;default:i+=`\\`+p;break}y.debug(`clearStateChar %j %j`,p,i),p=!1}}for(var x=0,w=e.length,T;x-1;N--){var P=f[N],F=i.slice(0,P.reStart),I=i.slice(P.reStart,P.reEnd-8),L=i.slice(P.reEnd-8,P.reEnd),R=i.slice(P.reEnd);L+=R;var z=F.split(`(`).length-1,ee=R;for(x=0;x=0&&(a=e[o],!a);o--);for(o=0;o=0;o--)if(t[o]===r){c=o;break}var l=t.slice(a,s),u=n?t.slice(s+1):t.slice(s+1,c),d=n?[]:t.slice(c+1);if(l.length){var f=e.slice(i,i+l.length);if(!this._matchOne(f,l,n,0,0))return!1;i+=l.length}var p=0;if(d.length){if(d.length+i>e.length)return!1;var m=e.length-d.length;if(this._matchOne(e,d,n,m,0))p=d.length;else{if(e[e.length-1]!==``||i+d.length===e.length||(m--,!this._matchOne(e,d,n,m,0)))return!1;p=d.length+1}}if(!u.length){var h=!!p;for(o=i;o0,`Parameter 'itemPath' must not be an empty array`);for(let t=0;te.getLiteral(t)).filter(e=>!o&&!(o=e===``));this.searchPath=new Es(s).toString(),this.rootRegExp=new RegExp(e.regExpEscape(s[0]),Os?`i`:``),this.isImplicitPattern=n;let c={dot:!0,nobrace:!0,nocase:Os,nocomment:!0,noext:!0,nonegate:!0};a=Os?a.replace(/\\/g,`/`):a,this.minimatch=new Ds(a,c)}match(e){return this.segments[this.segments.length-1]===`**`?(e=ms(e),!e.endsWith(f.sep)&&this.isImplicitPattern===!1&&(e=`${e}${f.sep}`)):e=hs(e),this.minimatch.match(e)?this.trailingSeparator?gs.Directory:gs.All:gs.None}partialMatch(e){return e=hs(e),us(e)===e?this.rootRegExp.test(e):this.minimatch.matchOne(e.split(Os?/\\+/:/\/+/),this.minimatch.set[0],!0)}static globEscape(e){return(Os?e:e.replace(/\\/g,`\\\\`)).replace(/(\[)(?=[^/]+\])/g,`[[]`).replace(/\?/g,`[?]`).replace(/\*/g,`[*]`)}static fixupPattern(t,r){b(t,`pattern cannot be empty`);let i=new Es(t).segments.map(t=>e.getLiteral(t));if(b(i.every((e,t)=>(e!==`.`||t===0)&&e!==`..`),`Invalid pattern '${t}'. Relative pathing '.' and '..' is not allowed.`),b(!ps(t)||i[0],`Invalid pattern '${t}'. Root segment must not contain globs.`),t=ms(t),t===`.`||t.startsWith(`.${f.sep}`))t=e.globEscape(process.cwd())+t.substr(1);else if(t===`~`||t.startsWith(`~${f.sep}`))r||=n.homedir(),b(r,`Unable to determine HOME directory`),b(fs(r),`Expected HOME directory to be a rooted path. Actual '${r}'`),t=e.globEscape(r)+t.substr(1);else if(Os&&(t.match(/^[A-Z]:$/i)||t.match(/^[A-Z]:[^\\]/i))){let n=ds(`C:\\dummy-root`,t.substr(0,2));t.length>2&&!n.endsWith(`\\`)&&(n+=`\\`),t=e.globEscape(n)+t.substr(2)}else if(Os&&(t===`\\`||t.match(/^\\[^\\]/))){let n=ds(`C:\\dummy-root`,`\\`);n.endsWith(`\\`)||(n+=`\\`),t=e.globEscape(n)+t.substr(1)}else t=ds(e.globEscape(process.cwd()),t);return ms(t)}static getLiteral(e){let t=``;for(let n=0;n=0){if(r.length>1)return``;if(r){t+=r,n=i;continue}}}t+=r}return t}static regExpEscape(e){return e.replace(/[[\\^$.|?*+()]/g,`\\$&`)}},As=class{constructor(e,t){this.path=e,this.level=t}},js=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},Ms=function(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values==`function`?__values(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}},Ns=function(e){return this instanceof Ns?(this.v=e,this):new Ns(e)},Ps=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof Ns?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}};const Fs=process.platform===`win32`;var Is=class e{constructor(e){this.patterns=[],this.searchPaths=[],this.options=cs(e)}getSearchPaths(){return this.searchPaths.slice()}glob(){return js(this,void 0,void 0,function*(){var e,t,n,r;let i=[];try{for(var a=!0,o=Ms(this.globGenerator()),s;s=yield o.next(),e=s.done,!e;a=!0){r=s.value,a=!1;let e=r;i.push(e)}}catch(e){t={error:e}}finally{try{!a&&!e&&(n=o.return)&&(yield n.call(o))}finally{if(t)throw t.error}}return i})}globGenerator(){return Ps(this,arguments,function*(){let t=cs(this.options),n=[];for(let e of this.patterns)n.push(e),t.implicitDescendants&&(e.trailingSeparator||e.segments[e.segments.length-1]!==`**`)&&n.push(new ks(e.negate,!0,e.segments.concat(`**`)));let r=[];for(let e of vs(n)){G(`Search path '${e}'`);try{yield Ns(o.promises.lstat(e))}catch(e){if(e.code===`ENOENT`)continue;throw e}r.unshift(new As(e,1))}let i=[];for(;r.length;){let a=r.pop(),s=ys(n,a.path),c=!!s||bs(n,a.path);if(!s&&!c)continue;let l=yield Ns(e.stat(a,t,i));if(l&&!(t.excludeHiddenFiles&&f.basename(a.path).match(/^\./)))if(l.isDirectory()){if(s&gs.Directory&&t.matchDirectories)yield yield Ns(a.path);else if(!c)continue;let e=a.level+1,n=(yield Ns(o.promises.readdir(a.path))).map(t=>new As(f.join(a.path,t),e));r.push(...n.reverse())}else s&gs.File&&(yield yield Ns(a.path))}})}static create(t,n){return js(this,void 0,void 0,function*(){let r=new e(n);Fs&&(t=t.replace(/\r\n/g,` diff --git a/dist/licenses.txt b/dist/licenses.txt index f7296952..926a1bf5 100644 --- a/dist/licenses.txt +++ b/dist/licenses.txt @@ -817,7 +817,7 @@ The above copyright notice and this permission notice (including the next paragr THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -@opencode-ai/sdk@1.3.2 +@opencode-ai/sdk@1.3.5 MIT MIT diff --git a/dist/main.js b/dist/main.js index 573c0b72..baed8ed9 100644 --- a/dist/main.js +++ b/dist/main.js @@ -1,7 +1,7 @@ -import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,J as c,K as l,L as u,M as d,N as f,O as p,P as m,R as h,S as g,T as _,U as v,V as y,W as b,X as x,Y as S,Z as C,_ as ee,a as w,b as T,c as E,d as te,f as D,g as O,h as k,i as ne,j as A,k as j,l as re,m as ie,n as ae,o as oe,p as se,q as ce,r as le,s as ue,t as de,u as fe,v as pe,w as me,x as he,y as ge,z as M}from"./artifact-DZtNN4TE.js";import N from"node:process";import*as _e from"os";import*as ve from"crypto";import*as P from"fs";import*as F from"path";import{ok as ye}from"assert";import*as be from"util";import{Buffer as xe}from"node:buffer";import*as Se from"node:crypto";import{createHash as Ce}from"node:crypto";import{pathToFileURL as we}from"node:url";import*as I from"node:fs/promises";import Te from"node:fs/promises";import*as L from"node:path";import Ee,{join as R}from"node:path";import{spawn as De}from"node:child_process";import*as Oe from"node:os";import ke,{homedir as Ae}from"node:os";import*as je from"stream";function Me(e){switch(e){case`hit`:return`✅ hit`;case`miss`:return`🆕 miss`;case`corrupted`:return`⚠️ corrupted (clean start)`}}function Ne(e){let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}async function Pe(e,t){let{eventType:n,repo:r,ref:i,runId:a,runUrl:o,metrics:c,agent:l}=e;try{if(S.addHeading(`Fro Bot Agent Run`,2).addTable([[{data:`Field`,header:!0},{data:`Value`,header:!0}],[`Event`,n],[`Repository`,r],[`Ref`,i],[`Run ID`,`[${a}](${o})`],[`Agent`,l],[`Cache Status`,Me(c.cacheStatus)],[`Duration`,c.duration==null?`N/A`:Ne(c.duration)]]),(c.sessionsUsed.length>0||c.sessionsCreated.length>0)&&(S.addHeading(`Sessions`,3),c.sessionsUsed.length>0&&S.addRaw(`**Used:** ${c.sessionsUsed.join(`, `)}\n`),c.sessionsCreated.length>0&&S.addRaw(`**Created:** ${c.sessionsCreated.join(`, `)}\n`)),c.tokenUsage!=null&&(S.addHeading(`Token Usage`,3),S.addTable([[{data:`Metric`,header:!0},{data:`Count`,header:!0}],[`Input`,c.tokenUsage.input.toLocaleString()],[`Output`,c.tokenUsage.output.toLocaleString()],[`Reasoning`,c.tokenUsage.reasoning.toLocaleString()],[`Cache Read`,c.tokenUsage.cache.read.toLocaleString()],[`Cache Write`,c.tokenUsage.cache.write.toLocaleString()]]),c.model!=null&&S.addRaw(`**Model:** ${c.model}\n`),c.cost!=null&&S.addRaw(`**Cost:** $${c.cost.toFixed(4)}\n`)),(c.prsCreated.length>0||c.commitsCreated.length>0||c.commentsPosted>0)&&(S.addHeading(`Created Artifacts`,3),c.prsCreated.length>0&&S.addList([...c.prsCreated]),c.commitsCreated.length>0&&S.addList(c.commitsCreated.map(e=>`Commit \`${e.slice(0,7)}\``)),c.commentsPosted>0&&S.addRaw(`**Comments Posted:** ${c.commentsPosted}\n`)),c.errors.length>0){S.addHeading(`Errors`,3);for(let e of c.errors){let t=e.recoverable?`🔄 Recovered`:`❌ Failed`;S.addRaw(`- **${e.type}** (${t}): ${e.message}\n`)}}await S.write(),t.debug(`Wrote job summary`)}catch(e){let n=A(e);t.warning(`Failed to write job summary`,{error:n}),s(`Failed to write job summary: ${n}`)}}function Fe(){let e=0,t=null,n=`miss`,r=[],i=[],a=[],o=[],s=0,c=null,l=null,u=null,d=[];return{start(){e=Date.now()},end(){t=Date.now()},setCacheStatus(e){n=e},addSessionUsed(e){r.includes(e)||r.push(e)},addSessionCreated(e){i.includes(e)||i.push(e)},addPRCreated(e){a.includes(e)||a.push(e)},addCommitCreated(e){o.includes(e)||o.push(e)},incrementComments(){s++},setTokenUsage(e,t,n){c=e,l=t,u=n},recordError(e,t,n){d.push({timestamp:new Date().toISOString(),type:e,message:t,recoverable:n})},getMetrics(){let f=t==null?Date.now()-e:t-e;return Object.freeze({startTime:e,endTime:t,duration:f,cacheStatus:n,sessionsUsed:Object.freeze([...r]),sessionsCreated:Object.freeze([...i]),prsCreated:Object.freeze([...a]),commitsCreated:Object.freeze([...o]),commentsPosted:s,tokenUsage:c,model:l,cost:u,errors:Object.freeze([...d])})}}}function z(e){y(`session-id`,e.sessionId??``),y(`cache-status`,e.cacheStatus),y(`duration`,e.duration)}function B(e){let[t,n]=e.split(`/`);if(t==null||n==null||t.length===0||n.length===0)throw Error(`Invalid repository string: ${e}`);return{owner:t,repo:n}}async function Ie(e,t,n,r,i){try{let{owner:a,repo:o}=B(t),{data:s}=await e.rest.reactions.createForIssueComment({owner:a,repo:o,comment_id:n,content:r});return i.debug(`Created comment reaction`,{commentId:n,content:r,reactionId:s.id}),{id:s.id}}catch(e){return i.warning(`Failed to create comment reaction`,{commentId:n,content:r,error:A(e)}),null}}async function Le(e,t,n,r){try{let{owner:r,repo:i}=B(t),{data:a}=await e.rest.reactions.listForIssueComment({owner:r,repo:i,comment_id:n,per_page:100});return a.map(e=>({id:e.id,content:e.content,userLogin:e.user?.login??null}))}catch(e){return r.warning(`Failed to list comment reactions`,{commentId:n,error:A(e)}),[]}}async function Re(e,t,n,r,i){try{let{owner:a,repo:o}=B(t);return await e.rest.reactions.deleteForIssueComment({owner:a,repo:o,comment_id:n,reaction_id:r}),i.debug(`Deleted comment reaction`,{commentId:n,reactionId:r}),!0}catch(e){return i.warning(`Failed to delete comment reaction`,{commentId:n,reactionId:r,error:A(e)}),!1}}async function ze(e,t,n,r,i,a){let{owner:o,repo:s}=B(t);try{return await e.rest.issues.createLabel({owner:o,repo:s,name:n,color:r,description:i}),a.debug(`Created label`,{name:n,color:r}),!0}catch(e){return e instanceof Error&&`status`in e&&e.status===422?(a.debug(`Label already exists`,{name:n}),!0):(a.warning(`Failed to create label`,{name:n,error:A(e)}),!1)}}async function Be(e,t,n,r,i){try{let{owner:a,repo:o}=B(t);return await e.rest.issues.addLabels({owner:a,repo:o,issue_number:n,labels:[...r]}),i.debug(`Added labels to issue`,{issueNumber:n,labels:r}),!0}catch(e){return i.warning(`Failed to add labels to issue`,{issueNumber:n,labels:r,error:A(e)}),!1}}async function Ve(e,t,n,r,i){try{let{owner:a,repo:o}=B(t);return await e.rest.issues.removeLabel({owner:a,repo:o,issue_number:n,name:r}),i.debug(`Removed label from issue`,{issueNumber:n,label:r}),!0}catch(e){return e instanceof Error&&`status`in e&&e.status===404?(i.debug(`Label was not present on issue`,{issueNumber:n,label:r}),!0):(i.warning(`Failed to remove label from issue`,{issueNumber:n,label:r,error:A(e)}),!1)}}async function He(e,t,n){try{let{owner:n,repo:r}=B(t),{data:i}=await e.rest.repos.get({owner:n,repo:r});return i.default_branch}catch(e){return n.warning(`Failed to get default branch`,{repo:t,error:A(e)}),`main`}}const Ue={admin:`OWNER`,maintain:`MEMBER`,write:`COLLABORATOR`,triage:`COLLABORATOR`};async function We(e,t,n,r,i){try{let{data:a}=await e.rest.repos.getCollaboratorPermissionLevel({owner:t,repo:n,username:r}),o=Ue[a.permission]??null;return i.debug(`Resolved sender permission`,{username:r,permission:a.permission,association:o}),o}catch(e){return i.warning(`Failed to resolve sender permission`,{username:r,error:A(e)}),null}}async function Ge(e,t,n){try{let{data:n}=await e.rest.users.getByUsername({username:t});return{id:n.id,login:n.login}}catch(e){return n.debug(`Failed to get user by username`,{username:t,error:A(e)}),null}}const Ke={maxComments:50,maxCommits:100,maxFiles:100,maxReviews:100,maxBodyBytes:10*1024,maxTotalBytes:100*1024},qe=`…[truncated]`;function V(e,t){if(e.length===0)return{text:``,truncated:!1};let n=new TextEncoder,r=n.encode(e);if(r.length<=t)return{text:e,truncated:!1};let i=t-n.encode(qe).length;if(i<=0)return{text:qe,truncated:!0};let a=r.slice(0,i),o=new TextDecoder(`utf-8`,{fatal:!1}).decode(a);for(;o.length>0&&o.charCodeAt(o.length-1)===65533;)a=a.slice(0,-1),o=new TextDecoder(`utf-8`,{fatal:!1}).decode(a);return{text:o+qe,truncated:!0}}function Je(e){return e.length===0?``:`**Labels:** ${e.map(e=>`\`${e.name}\``).join(`, `)}\n`}function Ye(e){return e.length===0?``:`**Assignees:** ${e.map(e=>`@${e.login}`).join(`, `)}\n`}function Xe(e){let t=[];t.push(`## Issue #${e.number}`),t.push(``),t.push(`**Title:** ${e.title}`),t.push(`**State:** ${e.state}`),t.push(`**Author:** ${e.author??`unknown`}`),t.push(`**Created:** ${e.createdAt}`);let n=Je(e.labels);n.length>0&&t.push(n.trimEnd());let r=Ye(e.assignees);if(r.length>0&&t.push(r.trimEnd()),t.push(``),t.push(`### Body`),t.push(``),t.push(e.body),e.bodyTruncated&&(t.push(``),t.push(`*Note: Body was truncated due to size limits.*`)),e.comments.length>0){t.push(``),t.push(`### Comments (${e.comments.length}${e.commentsTruncated?` of ${e.totalComments}`:``})`),e.commentsTruncated&&(t.push(``),t.push(`*Note: Comments were truncated due to limits.*`)),t.push(``);for(let n of e.comments)t.push(`**${n.author??`unknown`}** (${n.createdAt}):`),t.push(n.body),t.push(``)}return t.join(` -`)}function Ze(e){let t=[];t.push(`## Pull Request #${e.number}`),t.push(``),t.push(`**Title:** ${e.title}`),t.push(`**State:** ${e.state}`),t.push(`**Author:** ${e.author??`unknown`}`),t.push(`**Created:** ${e.createdAt}`),t.push(`**Base:** ${e.baseBranch} ← **Head:** ${e.headBranch}`),e.isFork&&t.push(`**Fork:** Yes (external contributor)`);let n=Je(e.labels);n.length>0&&t.push(n.trimEnd());let r=Ye(e.assignees);if(r.length>0&&t.push(r.trimEnd()),t.push(``),t.push(`### Description`),t.push(``),t.push(e.body),e.bodyTruncated&&(t.push(``),t.push(`*Note: Description was truncated due to size limits.*`)),e.files.length>0){t.push(``),t.push(`### Files Changed (${e.files.length}${e.filesTruncated?` of ${e.totalFiles}`:``})`),t.push(``),t.push(`| File | +/- |`),t.push(`|------|-----|`);for(let n of e.files)t.push(`| \`${n.path}\` | +${n.additions}/-${n.deletions} |`)}if(e.commits.length>0){t.push(``),t.push(`### Commits (${e.commits.length}${e.commitsTruncated?` of ${e.totalCommits}`:``})`),t.push(``);for(let n of e.commits){let e=n.oid.slice(0,7);t.push(`- \`${e}\` ${n.message.split(` +import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,J as c,K as l,L as u,M as d,N as f,O as p,P as m,R as h,S as g,T as _,U as v,V as y,W as b,X as x,Y as S,Z as C,_ as w,a as T,b as E,c as D,d as O,f as k,g as A,h as j,i as ee,j as M,k as N,l as te,m as ne,n as re,o as ie,p as P,q as ae,r as oe,s as se,t as ce,u as le,v as ue,w as de,x as fe,y as pe,z as F}from"./artifact-B9OeWxWy.js";import I from"node:process";import*as me from"os";import*as he from"crypto";import*as L from"fs";import*as R from"path";import{ok as ge}from"assert";import*as _e from"util";import{Buffer as ve}from"node:buffer";import*as ye from"node:crypto";import{createHash as be}from"node:crypto";import{pathToFileURL as xe}from"node:url";import*as z from"node:fs/promises";import Se from"node:fs/promises";import*as B from"node:path";import Ce,{join as we}from"node:path";import{spawn as Te}from"node:child_process";import*as Ee from"node:os";import De,{homedir as Oe}from"node:os";import*as ke from"stream";function Ae(e){switch(e){case`hit`:return`✅ hit`;case`miss`:return`🆕 miss`;case`corrupted`:return`⚠️ corrupted (clean start)`}}function je(e){let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}async function Me(e,t){let{eventType:n,repo:r,ref:i,runId:a,runUrl:o,metrics:c,agent:l}=e;try{if(S.addHeading(`Fro Bot Agent Run`,2).addTable([[{data:`Field`,header:!0},{data:`Value`,header:!0}],[`Event`,n],[`Repository`,r],[`Ref`,i],[`Run ID`,`[${a}](${o})`],[`Agent`,l],[`Cache Status`,Ae(c.cacheStatus)],[`Duration`,c.duration==null?`N/A`:je(c.duration)]]),(c.sessionsUsed.length>0||c.sessionsCreated.length>0)&&(S.addHeading(`Sessions`,3),c.sessionsUsed.length>0&&S.addRaw(`**Used:** ${c.sessionsUsed.join(`, `)}\n`),c.sessionsCreated.length>0&&S.addRaw(`**Created:** ${c.sessionsCreated.join(`, `)}\n`)),c.tokenUsage!=null&&(S.addHeading(`Token Usage`,3),S.addTable([[{data:`Metric`,header:!0},{data:`Count`,header:!0}],[`Input`,c.tokenUsage.input.toLocaleString()],[`Output`,c.tokenUsage.output.toLocaleString()],[`Reasoning`,c.tokenUsage.reasoning.toLocaleString()],[`Cache Read`,c.tokenUsage.cache.read.toLocaleString()],[`Cache Write`,c.tokenUsage.cache.write.toLocaleString()]]),c.model!=null&&S.addRaw(`**Model:** ${c.model}\n`),c.cost!=null&&S.addRaw(`**Cost:** $${c.cost.toFixed(4)}\n`)),(c.prsCreated.length>0||c.commitsCreated.length>0||c.commentsPosted>0)&&(S.addHeading(`Created Artifacts`,3),c.prsCreated.length>0&&S.addList([...c.prsCreated]),c.commitsCreated.length>0&&S.addList(c.commitsCreated.map(e=>`Commit \`${e.slice(0,7)}\``)),c.commentsPosted>0&&S.addRaw(`**Comments Posted:** ${c.commentsPosted}\n`)),c.errors.length>0){S.addHeading(`Errors`,3);for(let e of c.errors){let t=e.recoverable?`🔄 Recovered`:`❌ Failed`;S.addRaw(`- **${e.type}** (${t}): ${e.message}\n`)}}await S.write(),t.debug(`Wrote job summary`)}catch(e){let n=M(e);t.warning(`Failed to write job summary`,{error:n}),s(`Failed to write job summary: ${n}`)}}function Ne(){let e=0,t=null,n=`miss`,r=[],i=[],a=[],o=[],s=0,c=null,l=null,u=null,d=[];return{start(){e=Date.now()},end(){t=Date.now()},setCacheStatus(e){n=e},addSessionUsed(e){r.includes(e)||r.push(e)},addSessionCreated(e){i.includes(e)||i.push(e)},addPRCreated(e){a.includes(e)||a.push(e)},addCommitCreated(e){o.includes(e)||o.push(e)},incrementComments(){s++},setTokenUsage(e,t,n){c=e,l=t,u=n},recordError(e,t,n){d.push({timestamp:new Date().toISOString(),type:e,message:t,recoverable:n})},getMetrics(){let f=t==null?Date.now()-e:t-e;return Object.freeze({startTime:e,endTime:t,duration:f,cacheStatus:n,sessionsUsed:Object.freeze([...r]),sessionsCreated:Object.freeze([...i]),prsCreated:Object.freeze([...a]),commitsCreated:Object.freeze([...o]),commentsPosted:s,tokenUsage:c,model:l,cost:u,errors:Object.freeze([...d])})}}}function V(e){y(`session-id`,e.sessionId??``),y(`cache-status`,e.cacheStatus),y(`duration`,e.duration)}function H(e){let[t,n]=e.split(`/`);if(t==null||n==null||t.length===0||n.length===0)throw Error(`Invalid repository string: ${e}`);return{owner:t,repo:n}}async function Pe(e,t,n,r,i){try{let{owner:a,repo:o}=H(t),{data:s}=await e.rest.reactions.createForIssueComment({owner:a,repo:o,comment_id:n,content:r});return i.debug(`Created comment reaction`,{commentId:n,content:r,reactionId:s.id}),{id:s.id}}catch(e){return i.warning(`Failed to create comment reaction`,{commentId:n,content:r,error:M(e)}),null}}async function Fe(e,t,n,r){try{let{owner:r,repo:i}=H(t),{data:a}=await e.rest.reactions.listForIssueComment({owner:r,repo:i,comment_id:n,per_page:100});return a.map(e=>({id:e.id,content:e.content,userLogin:e.user?.login??null}))}catch(e){return r.warning(`Failed to list comment reactions`,{commentId:n,error:M(e)}),[]}}async function Ie(e,t,n,r,i){try{let{owner:a,repo:o}=H(t);return await e.rest.reactions.deleteForIssueComment({owner:a,repo:o,comment_id:n,reaction_id:r}),i.debug(`Deleted comment reaction`,{commentId:n,reactionId:r}),!0}catch(e){return i.warning(`Failed to delete comment reaction`,{commentId:n,reactionId:r,error:M(e)}),!1}}async function Le(e,t,n,r,i,a){let{owner:o,repo:s}=H(t);try{return await e.rest.issues.createLabel({owner:o,repo:s,name:n,color:r,description:i}),a.debug(`Created label`,{name:n,color:r}),!0}catch(e){return e instanceof Error&&`status`in e&&e.status===422?(a.debug(`Label already exists`,{name:n}),!0):(a.warning(`Failed to create label`,{name:n,error:M(e)}),!1)}}async function Re(e,t,n,r,i){try{let{owner:a,repo:o}=H(t);return await e.rest.issues.addLabels({owner:a,repo:o,issue_number:n,labels:[...r]}),i.debug(`Added labels to issue`,{issueNumber:n,labels:r}),!0}catch(e){return i.warning(`Failed to add labels to issue`,{issueNumber:n,labels:r,error:M(e)}),!1}}async function ze(e,t,n,r,i){try{let{owner:a,repo:o}=H(t);return await e.rest.issues.removeLabel({owner:a,repo:o,issue_number:n,name:r}),i.debug(`Removed label from issue`,{issueNumber:n,label:r}),!0}catch(e){return e instanceof Error&&`status`in e&&e.status===404?(i.debug(`Label was not present on issue`,{issueNumber:n,label:r}),!0):(i.warning(`Failed to remove label from issue`,{issueNumber:n,label:r,error:M(e)}),!1)}}async function Be(e,t,n){try{let{owner:n,repo:r}=H(t),{data:i}=await e.rest.repos.get({owner:n,repo:r});return i.default_branch}catch(e){return n.warning(`Failed to get default branch`,{repo:t,error:M(e)}),`main`}}const Ve={admin:`OWNER`,maintain:`MEMBER`,write:`COLLABORATOR`,triage:`COLLABORATOR`};async function He(e,t,n,r,i){try{let{data:a}=await e.rest.repos.getCollaboratorPermissionLevel({owner:t,repo:n,username:r}),o=Ve[a.permission]??null;return i.debug(`Resolved sender permission`,{username:r,permission:a.permission,association:o}),o}catch(e){return i.warning(`Failed to resolve sender permission`,{username:r,error:M(e)}),null}}async function Ue(e,t,n){try{let{data:n}=await e.rest.users.getByUsername({username:t});return{id:n.id,login:n.login}}catch(e){return n.debug(`Failed to get user by username`,{username:t,error:M(e)}),null}}const We={maxComments:50,maxCommits:100,maxFiles:100,maxReviews:100,maxBodyBytes:10*1024,maxTotalBytes:100*1024},Ge=`…[truncated]`;function Ke(e,t){if(e.length===0)return{text:``,truncated:!1};let n=new TextEncoder,r=n.encode(e);if(r.length<=t)return{text:e,truncated:!1};let i=t-n.encode(Ge).length;if(i<=0)return{text:Ge,truncated:!0};let a=r.slice(0,i),o=new TextDecoder(`utf-8`,{fatal:!1}).decode(a);for(;o.length>0&&o.charCodeAt(o.length-1)===65533;)a=a.slice(0,-1),o=new TextDecoder(`utf-8`,{fatal:!1}).decode(a);return{text:o+Ge,truncated:!0}}function qe(e){return e.length===0?``:`**Labels:** ${e.map(e=>`\`${e.name}\``).join(`, `)}\n`}function Je(e){return e.length===0?``:`**Assignees:** ${e.map(e=>`@${e.login}`).join(`, `)}\n`}function Ye(e){let t=[];t.push(`## Issue #${e.number}`),t.push(``),t.push(`**Title:** ${e.title}`),t.push(`**State:** ${e.state}`),t.push(`**Author:** ${e.author??`unknown`}`),t.push(`**Created:** ${e.createdAt}`);let n=qe(e.labels);n.length>0&&t.push(n.trimEnd());let r=Je(e.assignees);if(r.length>0&&t.push(r.trimEnd()),t.push(``),t.push(`### Body`),t.push(``),t.push(e.body),e.bodyTruncated&&(t.push(``),t.push(`*Note: Body was truncated due to size limits.*`)),e.comments.length>0){t.push(``),t.push(`### Comments (${e.comments.length}${e.commentsTruncated?` of ${e.totalComments}`:``})`),e.commentsTruncated&&(t.push(``),t.push(`*Note: Comments were truncated due to limits.*`)),t.push(``);for(let n of e.comments)t.push(`**${n.author??`unknown`}** (${n.createdAt}):`),t.push(n.body),t.push(``)}return t.join(` +`)}function Xe(e){let t=[];t.push(`## Pull Request #${e.number}`),t.push(``),t.push(`**Title:** ${e.title}`),t.push(`**State:** ${e.state}`),t.push(`**Author:** ${e.author??`unknown`}`),t.push(`**Created:** ${e.createdAt}`),t.push(`**Base:** ${e.baseBranch} ← **Head:** ${e.headBranch}`),e.isFork&&t.push(`**Fork:** Yes (external contributor)`);let n=qe(e.labels);n.length>0&&t.push(n.trimEnd());let r=Je(e.assignees);if(r.length>0&&t.push(r.trimEnd()),t.push(``),t.push(`### Description`),t.push(``),t.push(e.body),e.bodyTruncated&&(t.push(``),t.push(`*Note: Description was truncated due to size limits.*`)),e.files.length>0){t.push(``),t.push(`### Files Changed (${e.files.length}${e.filesTruncated?` of ${e.totalFiles}`:``})`),t.push(``),t.push(`| File | +/- |`),t.push(`|------|-----|`);for(let n of e.files)t.push(`| \`${n.path}\` | +${n.additions}/-${n.deletions} |`)}if(e.commits.length>0){t.push(``),t.push(`### Commits (${e.commits.length}${e.commitsTruncated?` of ${e.totalCommits}`:``})`),t.push(``);for(let n of e.commits){let e=n.oid.slice(0,7);t.push(`- \`${e}\` ${n.message.split(` `)[0]}`)}}if(e.reviews.length>0){t.push(``),t.push(`### Reviews (${e.reviews.length}${e.reviewsTruncated?` of ${e.totalReviews}`:``})`),t.push(``);for(let n of e.reviews)t.push(`**${n.author??`unknown`}** - ${n.state}`),n.body.length>0&&t.push(n.body),t.push(``)}if(e.comments.length>0){t.push(``),t.push(`### Comments (${e.comments.length}${e.commentsTruncated?` of ${e.totalComments}`:``})`),t.push(``);for(let n of e.comments)t.push(`**${n.author??`unknown`}** (${n.createdAt}):`),t.push(n.body),t.push(``)}return t.join(` -`)}function Qe(e){return e.type===`issue`?Xe(e):Ze(e)}async function $e(e,t,n,r,i,a){try{let[a,o]=await Promise.all([e.rest.issues.get({owner:t,repo:n,issue_number:r}),e.rest.issues.listComments({owner:t,repo:n,issue_number:r,per_page:i.maxComments})]),s=a.data,c=V(s.body??``,i.maxBodyBytes),l=o.data.slice(0,i.maxComments).map(e=>({id:e.node_id??String(e.id),author:e.user?.login??null,body:e.body??``,createdAt:e.created_at,authorAssociation:e.author_association,isMinimized:!1})),u=(s.labels??[]).filter(e=>typeof e==`object`&&!!e&&`name`in e).map(e=>({name:e.name??``,color:e.color})),d=(s.assignees??[]).map(e=>({login:e?.login??``}));return{type:`issue`,number:s.number,title:s.title,body:c.text,bodyTruncated:c.truncated,state:s.state,author:s.user?.login??null,createdAt:s.created_at,labels:u,assignees:d,comments:l,commentsTruncated:o.data.length>=i.maxComments,totalComments:o.data.length}}catch(e){return a.warning(`REST issue fallback failed`,{owner:t,repo:n,number:r,error:A(e)}),null}}async function et(e,t,n,r,i,a){try{let[o,s,c,l,u]=await Promise.all([e.rest.pulls.get({owner:t,repo:n,pull_number:r}),e.rest.pulls.listCommits({owner:t,repo:n,pull_number:r,per_page:i.maxCommits}),e.rest.pulls.listFiles({owner:t,repo:n,pull_number:r,per_page:i.maxFiles}),e.rest.pulls.listReviews({owner:t,repo:n,pull_number:r,per_page:i.maxReviews}),e.rest.issues.listComments({owner:t,repo:n,issue_number:r,per_page:i.maxComments})]),d=await e.rest.pulls.listRequestedReviewers({owner:t,repo:n,pull_number:r}).catch(e=>(a.warning(`Failed to fetch requested reviewers, defaulting to empty`,{owner:t,repo:n,number:r,error:A(e)}),{data:{users:[],teams:[]}})),f=o.data,p=V(f.body??``,i.maxBodyBytes),m=f.base.repo?.owner.login,h=f.head.repo?.owner.login,g=h==null||m!==h,_=u.data.slice(0,i.maxComments).map(e=>({id:e.node_id??String(e.id),author:e.user?.login??null,body:e.body??``,createdAt:e.created_at,authorAssociation:e.author_association,isMinimized:!1})),v=s.data.slice(0,i.maxCommits).map(e=>({oid:e.sha,message:e.commit.message,author:e.commit.author?.name??null})),y=c.data.slice(0,i.maxFiles).map(e=>({path:e.filename,additions:e.additions,deletions:e.deletions,status:e.status})),b=l.data.slice(0,i.maxReviews).map(e=>({author:e.user?.login??null,state:e.state,body:e.body??``,createdAt:e.submitted_at??``,comments:[]})),x=(f.labels??[]).map(e=>({name:e.name??``,color:e.color})),S=(f.assignees??[]).map(e=>({login:e?.login??``})),C=(d.data.users??[]).map(e=>e.login),ee=(d.data.teams??[]).map(e=>e.name);return{type:`pull_request`,number:f.number,title:f.title,body:p.text,bodyTruncated:p.truncated,state:f.state,author:f.user?.login??null,createdAt:f.created_at,baseBranch:f.base.ref,headBranch:f.head.ref,isFork:g,labels:x,assignees:S,comments:_,commentsTruncated:u.data.length>=i.maxComments,totalComments:u.data.length,commits:v,commitsTruncated:s.data.length>=i.maxCommits,totalCommits:s.data.length,files:y,filesTruncated:c.data.length>=i.maxFiles,totalFiles:c.data.length,reviews:b,reviewsTruncated:l.data.length>=i.maxReviews,totalReviews:l.data.length,authorAssociation:f.author_association,requestedReviewers:C,requestedReviewerTeams:ee}}catch(e){return a.warning(`REST pull request fallback failed`,{owner:t,repo:n,number:r,error:A(e)}),null}}async function tt(e,t,n,r,i,a){try{return await e.graphql(` +`)}function Ze(e){return e.type===`issue`?Ye(e):Xe(e)}async function Qe(e,t,n,r,i,a){try{let[a,o]=await Promise.all([e.rest.issues.get({owner:t,repo:n,issue_number:r}),e.rest.issues.listComments({owner:t,repo:n,issue_number:r,per_page:i.maxComments})]),s=a.data,c=Ke(s.body??``,i.maxBodyBytes),l=o.data.slice(0,i.maxComments).map(e=>({id:e.node_id??String(e.id),author:e.user?.login??null,body:e.body??``,createdAt:e.created_at,authorAssociation:e.author_association,isMinimized:!1})),u=(s.labels??[]).filter(e=>typeof e==`object`&&!!e&&`name`in e).map(e=>({name:e.name??``,color:e.color})),d=(s.assignees??[]).map(e=>({login:e?.login??``}));return{type:`issue`,number:s.number,title:s.title,body:c.text,bodyTruncated:c.truncated,state:s.state,author:s.user?.login??null,createdAt:s.created_at,labels:u,assignees:d,comments:l,commentsTruncated:o.data.length>=i.maxComments,totalComments:o.data.length}}catch(e){return a.warning(`REST issue fallback failed`,{owner:t,repo:n,number:r,error:M(e)}),null}}async function $e(e,t,n,r,i,a){try{let[o,s,c,l,u]=await Promise.all([e.rest.pulls.get({owner:t,repo:n,pull_number:r}),e.rest.pulls.listCommits({owner:t,repo:n,pull_number:r,per_page:i.maxCommits}),e.rest.pulls.listFiles({owner:t,repo:n,pull_number:r,per_page:i.maxFiles}),e.rest.pulls.listReviews({owner:t,repo:n,pull_number:r,per_page:i.maxReviews}),e.rest.issues.listComments({owner:t,repo:n,issue_number:r,per_page:i.maxComments})]),d=await e.rest.pulls.listRequestedReviewers({owner:t,repo:n,pull_number:r}).catch(e=>(a.warning(`Failed to fetch requested reviewers, defaulting to empty`,{owner:t,repo:n,number:r,error:M(e)}),{data:{users:[],teams:[]}})),f=o.data,p=Ke(f.body??``,i.maxBodyBytes),m=f.base.repo?.owner.login,h=f.head.repo?.owner.login,g=h==null||m!==h,_=u.data.slice(0,i.maxComments).map(e=>({id:e.node_id??String(e.id),author:e.user?.login??null,body:e.body??``,createdAt:e.created_at,authorAssociation:e.author_association,isMinimized:!1})),v=s.data.slice(0,i.maxCommits).map(e=>({oid:e.sha,message:e.commit.message,author:e.commit.author?.name??null})),y=c.data.slice(0,i.maxFiles).map(e=>({path:e.filename,additions:e.additions,deletions:e.deletions,status:e.status})),b=l.data.slice(0,i.maxReviews).map(e=>({author:e.user?.login??null,state:e.state,body:e.body??``,createdAt:e.submitted_at??``,comments:[]})),x=(f.labels??[]).map(e=>({name:e.name??``,color:e.color})),S=(f.assignees??[]).map(e=>({login:e?.login??``})),C=(d.data.users??[]).map(e=>e.login),w=(d.data.teams??[]).map(e=>e.name);return{type:`pull_request`,number:f.number,title:f.title,body:p.text,bodyTruncated:p.truncated,state:f.state,author:f.user?.login??null,createdAt:f.created_at,baseBranch:f.base.ref,headBranch:f.head.ref,isFork:g,labels:x,assignees:S,comments:_,commentsTruncated:u.data.length>=i.maxComments,totalComments:u.data.length,commits:v,commitsTruncated:s.data.length>=i.maxCommits,totalCommits:s.data.length,files:y,filesTruncated:c.data.length>=i.maxFiles,totalFiles:c.data.length,reviews:b,reviewsTruncated:l.data.length>=i.maxReviews,totalReviews:l.data.length,authorAssociation:f.author_association,requestedReviewers:C,requestedReviewerTeams:w}}catch(e){return a.warning(`REST pull request fallback failed`,{owner:t,repo:n,number:r,error:M(e)}),null}}async function et(e,t,n,r,i,a){try{return await e.graphql(` query GetIssue($owner: String!, $repo: String!, $number: Int!, $maxComments: Int!) { repository(owner: $owner, name: $repo) { issue(number: $number) { @@ -31,7 +31,7 @@ import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,J as c,K as l,L a } } } -`,{owner:t,repo:n,number:r,maxComments:i})}catch(e){return a.warning(`GraphQL issue query failed`,{owner:t,repo:n,number:r,error:A(e)}),null}}async function nt(e,t,n,r,i,a,o,s,c){try{return await e.graphql(` +`,{owner:t,repo:n,number:r,maxComments:i})}catch(e){return a.warning(`GraphQL issue query failed`,{owner:t,repo:n,number:r,error:M(e)}),null}}async function tt(e,t,n,r,i,a,o,s,c){try{return await e.graphql(` query GetPullRequest( $owner: String!, $repo: String!, @@ -119,35 +119,35 @@ import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,J as c,K as l,L a } } } -`,{owner:t,repo:n,number:r,maxComments:i,maxCommits:a,maxFiles:o,maxReviews:s})}catch(e){return c.warning(`GraphQL pull request query failed`,{owner:t,repo:n,number:r,error:A(e)}),null}}async function rt(e,t,n,r,i,a){let o=await tt(e,t,n,r,i.maxComments,a);if(o==null)return null;let s=o.repository.issue;if(s==null)return a.debug(`Issue not found`,{owner:t,repo:n,number:r}),null;let c=V(s.body??``,i.maxBodyBytes),l=s.comments.nodes.slice(0,i.maxComments),u=s.comments.totalCount>l.length,d=l.map(e=>({id:e.id,author:e.author?.login??null,body:e.body,createdAt:e.createdAt,authorAssociation:e.authorAssociation,isMinimized:e.isMinimized})),f=s.labels.nodes.map(e=>({name:e.name,color:e.color})),p=s.assignees.nodes.map(e=>({login:e.login}));return{type:`issue`,number:s.number,title:s.title,body:c.text,bodyTruncated:c.truncated,state:s.state,author:s.author?.login??null,createdAt:s.createdAt,labels:f,assignees:p,comments:d,commentsTruncated:u,totalComments:s.comments.totalCount}}async function it(e,t,n,r,i,a){let o=await nt(e,t,n,r,i.maxComments,i.maxCommits,i.maxFiles,i.maxReviews,a);if(o==null)return null;let s=o.repository.pullRequest;if(s==null)return a.debug(`Pull request not found`,{owner:t,repo:n,number:r}),null;let c=V(s.body??``,i.maxBodyBytes),l=s.baseRepository?.owner.login,u=s.headRepository?.owner.login,d=u==null||l!==u,f=s.comments.nodes.slice(0,i.maxComments),p=s.comments.totalCount>f.length,m=f.map(e=>({id:e.id,author:e.author?.login??null,body:e.body,createdAt:e.createdAt,authorAssociation:e.authorAssociation,isMinimized:e.isMinimized})),h=s.commits.nodes.slice(0,i.maxCommits),g=s.commits.totalCount>h.length,_=h.map(e=>({oid:e.commit.oid,message:e.commit.message,author:e.commit.author?.name??null})),v=s.files.nodes.slice(0,i.maxFiles),y=s.files.totalCount>v.length,b=v.map(e=>({path:e.path,additions:e.additions,deletions:e.deletions})),x=s.reviews.nodes.slice(0,i.maxReviews),S=s.reviews.totalCount>x.length,C=x.map(e=>({author:e.author?.login??null,state:e.state,body:e.body,createdAt:e.createdAt,comments:e.comments.nodes.map(e=>({id:e.id,author:e.author?.login??null,body:e.body,path:e.path,line:e.line,createdAt:e.createdAt}))})),ee=s.labels.nodes.map(e=>({name:e.name,color:e.color})),w=s.assignees.nodes.map(e=>({login:e.login})),T=s.reviewRequests.nodes.map(e=>`login`in e.requestedReviewer?e.requestedReviewer.login:null).filter(e=>e!=null),E=s.reviewRequests.nodes.map(e=>`name`in e.requestedReviewer?e.requestedReviewer.name:null).filter(e=>e!=null);return{type:`pull_request`,number:s.number,title:s.title,body:c.text,bodyTruncated:c.truncated,state:s.state,author:s.author?.login??null,createdAt:s.createdAt,baseBranch:s.baseRefName,headBranch:s.headRefName,isFork:d,labels:ee,assignees:w,comments:m,commentsTruncated:p,totalComments:s.comments.totalCount,commits:_,commitsTruncated:g,totalCommits:s.commits.totalCount,files:b,filesTruncated:y,totalFiles:s.files.totalCount,reviews:C,reviewsTruncated:S,totalReviews:s.reviews.totalCount,authorAssociation:s.authorAssociation,requestedReviewers:T,requestedReviewerTeams:E}}const H={PER_PAGE:100,MAX_PAGES:50};async function at(e,t,n,r,i){i.debug(`Fetching PR diff`,{prNumber:r});let a=[],o=1,s=!1;for(;o<=H.MAX_PAGES;){let{data:c}=await e.rest.pulls.listFiles({owner:t,repo:n,pull_number:r,per_page:H.PER_PAGE,page:o}),l=c.map(e=>({filename:e.filename,status:e.status,additions:e.additions,deletions:e.deletions,patch:e.patch??null,previousFilename:e.previous_filename??null}));if(a.push(...l),c.lengthH.MAX_PAGES&&(s=!0,i.warning(`PR diff pagination limit reached`,{filesLoaded:a.length,maxPages:H.MAX_PAGES}))}let c=a.reduce((e,t)=>({additions:e.additions+t.additions,deletions:e.deletions+t.deletions}),{additions:0,deletions:0});return i.debug(`Fetched diff`,{files:a.length,additions:c.additions,deletions:c.deletions,truncated:s}),{files:a,additions:c.additions,deletions:c.deletions,changedFiles:a.length,truncated:s}}async function ot(e,t,n,r){if(e.eventType!==`pull_request`)return null;let i=e.target?.number;if(i==null)return r.debug(`No PR number in trigger context, skipping diff collection`),null;let[a,o]=n.split(`/`);if(a==null||o==null)return r.warning(`Invalid repo format, skipping diff collection`,{repo:n}),null;try{let e=await at(t,a,o,i,r),n={changedFiles:e.changedFiles,additions:e.additions,deletions:e.deletions,truncated:e.truncated,files:e.files.slice(0,50).map(e=>({filename:e.filename,status:e.status,additions:e.additions,deletions:e.deletions}))};return r.debug(`Collected diff context`,{files:n.changedFiles,additions:n.additions,deletions:n.deletions,truncated:n.truncated}),n}catch(e){return r.warning(`Failed to fetch PR diff`,{error:A(e)}),null}}async function st(e){let{logger:t,octokit:n,triggerContext:r,botLogin:i}=e,{repo:a,ref:o,actor:s,runId:c,target:l,author:u,commentBody:d,commentId:f}=r,p=`${a.owner}/${a.repo}`,m=l?.kind===`issue`||l?.kind===`pr`?l.kind:null,h=l?.number??null,g=l?.title??null,_=u?.login??null,v=await ot(r,n,p,t),y=await ct(n,a.owner,a.repo,h,m,t),b=y?.type===`pull_request`?y:null,x=b?.authorAssociation??null,S=i!=null&&b!=null?b.requestedReviewers.includes(i):!1;return t.info(`Collected agent context`,{eventName:r.eventName,repo:p,issueNumber:h,issueType:m,hasComment:d!=null,hasDiffContext:v!=null,hasHydratedContext:y!=null}),{eventName:r.eventName,repo:p,ref:o,actor:s,runId:String(c),issueNumber:h,issueTitle:g,issueType:m,commentBody:d,commentAuthor:_,commentId:f,defaultBranch:await He(n,p,t),diffContext:v,hydratedContext:y,authorAssociation:x,isRequestedReviewer:S}}async function ct(e,t,n,r,i,a){if(r==null||i==null)return null;let o=Ke;return i===`issue`?await rt(e,t,n,r,o,a)??$e(e,t,n,r,o,a):await it(e,t,n,r,o,a)??et(e,t,n,r,o,a)}const lt=({onSseError:e,onSseEvent:t,responseTransformer:n,responseValidator:r,sseDefaultRetryDelay:i,sseMaxRetryAttempts:a,sseMaxRetryDelay:o,sseSleepFn:s,url:c,...l})=>{let u,d=s??(e=>new Promise(t=>setTimeout(t,e)));return{stream:async function*(){let s=i??3e3,f=0,p=l.signal??new AbortController().signal;for(;!p.aborted;){f++;let i=l.headers instanceof Headers?l.headers:new Headers(l.headers);u!==void 0&&i.set(`Last-Event-ID`,u);try{let e=await fetch(c,{...l,headers:i,signal:p});if(!e.ok)throw Error(`SSE failed: ${e.status} ${e.statusText}`);if(!e.body)throw Error(`No body in SSE response`);let a=e.body.pipeThrough(new TextDecoderStream).getReader(),o=``,d=()=>{try{a.cancel()}catch{}};p.addEventListener(`abort`,d);try{for(;;){let{done:e,value:i}=await a.read();if(e)break;o+=i;let c=o.split(` +`,{owner:t,repo:n,number:r,maxComments:i,maxCommits:a,maxFiles:o,maxReviews:s})}catch(e){return c.warning(`GraphQL pull request query failed`,{owner:t,repo:n,number:r,error:M(e)}),null}}async function nt(e,t,n,r,i,a){let o=await et(e,t,n,r,i.maxComments,a);if(o==null)return null;let s=o.repository.issue;if(s==null)return a.debug(`Issue not found`,{owner:t,repo:n,number:r}),null;let c=Ke(s.body??``,i.maxBodyBytes),l=s.comments.nodes.slice(0,i.maxComments),u=s.comments.totalCount>l.length,d=l.map(e=>({id:e.id,author:e.author?.login??null,body:e.body,createdAt:e.createdAt,authorAssociation:e.authorAssociation,isMinimized:e.isMinimized})),f=s.labels.nodes.map(e=>({name:e.name,color:e.color})),p=s.assignees.nodes.map(e=>({login:e.login}));return{type:`issue`,number:s.number,title:s.title,body:c.text,bodyTruncated:c.truncated,state:s.state,author:s.author?.login??null,createdAt:s.createdAt,labels:f,assignees:p,comments:d,commentsTruncated:u,totalComments:s.comments.totalCount}}async function rt(e,t,n,r,i,a){let o=await tt(e,t,n,r,i.maxComments,i.maxCommits,i.maxFiles,i.maxReviews,a);if(o==null)return null;let s=o.repository.pullRequest;if(s==null)return a.debug(`Pull request not found`,{owner:t,repo:n,number:r}),null;let c=Ke(s.body??``,i.maxBodyBytes),l=s.baseRepository?.owner.login,u=s.headRepository?.owner.login,d=u==null||l!==u,f=s.comments.nodes.slice(0,i.maxComments),p=s.comments.totalCount>f.length,m=f.map(e=>({id:e.id,author:e.author?.login??null,body:e.body,createdAt:e.createdAt,authorAssociation:e.authorAssociation,isMinimized:e.isMinimized})),h=s.commits.nodes.slice(0,i.maxCommits),g=s.commits.totalCount>h.length,_=h.map(e=>({oid:e.commit.oid,message:e.commit.message,author:e.commit.author?.name??null})),v=s.files.nodes.slice(0,i.maxFiles),y=s.files.totalCount>v.length,b=v.map(e=>({path:e.path,additions:e.additions,deletions:e.deletions})),x=s.reviews.nodes.slice(0,i.maxReviews),S=s.reviews.totalCount>x.length,C=x.map(e=>({author:e.author?.login??null,state:e.state,body:e.body,createdAt:e.createdAt,comments:e.comments.nodes.map(e=>({id:e.id,author:e.author?.login??null,body:e.body,path:e.path,line:e.line,createdAt:e.createdAt}))})),w=s.labels.nodes.map(e=>({name:e.name,color:e.color})),T=s.assignees.nodes.map(e=>({login:e.login})),E=s.reviewRequests.nodes.map(e=>`login`in e.requestedReviewer?e.requestedReviewer.login:null).filter(e=>e!=null),D=s.reviewRequests.nodes.map(e=>`name`in e.requestedReviewer?e.requestedReviewer.name:null).filter(e=>e!=null);return{type:`pull_request`,number:s.number,title:s.title,body:c.text,bodyTruncated:c.truncated,state:s.state,author:s.author?.login??null,createdAt:s.createdAt,baseBranch:s.baseRefName,headBranch:s.headRefName,isFork:d,labels:w,assignees:T,comments:m,commentsTruncated:p,totalComments:s.comments.totalCount,commits:_,commitsTruncated:g,totalCommits:s.commits.totalCount,files:b,filesTruncated:y,totalFiles:s.files.totalCount,reviews:C,reviewsTruncated:S,totalReviews:s.reviews.totalCount,authorAssociation:s.authorAssociation,requestedReviewers:E,requestedReviewerTeams:D}}const U={PER_PAGE:100,MAX_PAGES:50};async function it(e,t,n,r,i){i.debug(`Fetching PR diff`,{prNumber:r});let a=[],o=1,s=!1;for(;o<=U.MAX_PAGES;){let{data:c}=await e.rest.pulls.listFiles({owner:t,repo:n,pull_number:r,per_page:U.PER_PAGE,page:o}),l=c.map(e=>({filename:e.filename,status:e.status,additions:e.additions,deletions:e.deletions,patch:e.patch??null,previousFilename:e.previous_filename??null}));if(a.push(...l),c.lengthU.MAX_PAGES&&(s=!0,i.warning(`PR diff pagination limit reached`,{filesLoaded:a.length,maxPages:U.MAX_PAGES}))}let c=a.reduce((e,t)=>({additions:e.additions+t.additions,deletions:e.deletions+t.deletions}),{additions:0,deletions:0});return i.debug(`Fetched diff`,{files:a.length,additions:c.additions,deletions:c.deletions,truncated:s}),{files:a,additions:c.additions,deletions:c.deletions,changedFiles:a.length,truncated:s}}async function at(e,t,n,r){if(e.eventType!==`pull_request`)return null;let i=e.target?.number;if(i==null)return r.debug(`No PR number in trigger context, skipping diff collection`),null;let[a,o]=n.split(`/`);if(a==null||o==null)return r.warning(`Invalid repo format, skipping diff collection`,{repo:n}),null;try{let e=await it(t,a,o,i,r),n={changedFiles:e.changedFiles,additions:e.additions,deletions:e.deletions,truncated:e.truncated,files:e.files.slice(0,50).map(e=>({filename:e.filename,status:e.status,additions:e.additions,deletions:e.deletions}))};return r.debug(`Collected diff context`,{files:n.changedFiles,additions:n.additions,deletions:n.deletions,truncated:n.truncated}),n}catch(e){return r.warning(`Failed to fetch PR diff`,{error:M(e)}),null}}async function ot(e){let{logger:t,octokit:n,triggerContext:r,botLogin:i}=e,{repo:a,ref:o,actor:s,runId:c,target:l,author:u,commentBody:d,commentId:f}=r,p=`${a.owner}/${a.repo}`,m=l?.kind===`issue`||l?.kind===`pr`?l.kind:null,h=l?.number??null,g=l?.title??null,_=u?.login??null,v=await at(r,n,p,t),y=await st(n,a.owner,a.repo,h,m,t),b=y?.type===`pull_request`?y:null,x=b?.authorAssociation??null,S=i!=null&&b!=null?b.requestedReviewers.includes(i):!1;return t.info(`Collected agent context`,{eventName:r.eventName,repo:p,issueNumber:h,issueType:m,hasComment:d!=null,hasDiffContext:v!=null,hasHydratedContext:y!=null}),{eventName:r.eventName,repo:p,ref:o,actor:s,runId:String(c),issueNumber:h,issueTitle:g,issueType:m,commentBody:d,commentAuthor:_,commentId:f,defaultBranch:await Be(n,p,t),diffContext:v,hydratedContext:y,authorAssociation:x,isRequestedReviewer:S}}async function st(e,t,n,r,i,a){if(r==null||i==null)return null;let o=We;return i===`issue`?await nt(e,t,n,r,o,a)??Qe(e,t,n,r,o,a):await rt(e,t,n,r,o,a)??$e(e,t,n,r,o,a)}const ct=({onSseError:e,onSseEvent:t,responseTransformer:n,responseValidator:r,sseDefaultRetryDelay:i,sseMaxRetryAttempts:a,sseMaxRetryDelay:o,sseSleepFn:s,url:c,...l})=>{let u,d=s??(e=>new Promise(t=>setTimeout(t,e)));return{stream:async function*(){let s=i??3e3,f=0,p=l.signal??new AbortController().signal;for(;!p.aborted;){f++;let i=l.headers instanceof Headers?l.headers:new Headers(l.headers);u!==void 0&&i.set(`Last-Event-ID`,u);try{let e=await fetch(c,{...l,headers:i,signal:p});if(!e.ok)throw Error(`SSE failed: ${e.status} ${e.statusText}`);if(!e.body)throw Error(`No body in SSE response`);let a=e.body.pipeThrough(new TextDecoderStream).getReader(),o=``,d=()=>{try{a.cancel()}catch{}};p.addEventListener(`abort`,d);try{for(;;){let{done:e,value:i}=await a.read();if(e)break;o+=i;let c=o.split(` `);o=c.pop()??``;for(let e of c){let i=e.split(` `),a=[],o;for(let e of i)if(e.startsWith(`data:`))a.push(e.replace(/^data:\s*/,``));else if(e.startsWith(`event:`))o=e.replace(/^event:\s*/,``);else if(e.startsWith(`id:`))u=e.replace(/^id:\s*/,``);else if(e.startsWith(`retry:`)){let t=Number.parseInt(e.replace(/^retry:\s*/,``),10);Number.isNaN(t)||(s=t)}let c,l=!1;if(a.length){let e=a.join(` -`);try{c=JSON.parse(e),l=!0}catch{c=e}}l&&(r&&await r(c),n&&(c=await n(c))),t?.({data:c,event:o,id:u,retry:s}),a.length&&(yield c)}}}finally{p.removeEventListener(`abort`,d),a.releaseLock()}break}catch(t){if(e?.(t),a!==void 0&&f>=a)break;await d(Math.min(s*2**(f-1),o??3e4))}}}()}},ut=async(e,t)=>{let n=typeof t==`function`?await t(e):t;if(n)return e.scheme===`bearer`?`Bearer ${n}`:e.scheme===`basic`?`Basic ${btoa(n)}`:n},dt={bodySerializer:e=>JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t)},ft=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},pt=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},mt=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},ht=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(pt(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=ft(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):U({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},U=({allowReserved:e,name:t,value:n})=>{if(n==null)return``;if(typeof n==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},gt=({allowReserved:e,explode:t,name:n,style:r,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${n}=${i.toISOString()}`;if(r!==`deepObject`&&!t){let t=[];Object.entries(i).forEach(([n,r])=>{t=[...t,n,e?r:encodeURIComponent(r)]});let a=t.join(`,`);switch(r){case`form`:return`${n}=${a}`;case`label`:return`.${a}`;case`matrix`:return`;${n}=${a}`;default:return a}}let o=mt(r),s=Object.entries(i).map(([t,i])=>U({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},_t=/\{[^{}]+\}/g,vt=({path:e,url:t})=>{let n=t,r=t.match(_t);if(r)for(let t of r){let r=!1,i=t.substring(1,t.length-1),a=`simple`;i.endsWith(`*`)&&(r=!0,i=i.substring(0,i.length-1)),i.startsWith(`.`)?(i=i.substring(1),a=`label`):i.startsWith(`;`)&&(i=i.substring(1),a=`matrix`);let o=e[i];if(o==null)continue;if(Array.isArray(o)){n=n.replace(t,ht({explode:r,name:i,style:a,value:o}));continue}if(typeof o==`object`){n=n.replace(t,gt({explode:r,name:i,style:a,value:o,valueOnly:!0}));continue}if(a===`matrix`){n=n.replace(t,`;${U({name:i,value:o})}`);continue}let s=encodeURIComponent(a===`label`?`.${o}`:o);n=n.replace(t,s)}return n},yt=({baseUrl:e,path:t,query:n,querySerializer:r,url:i})=>{let a=i.startsWith(`/`)?i:`/${i}`,o=(e??``)+a;t&&(o=vt({path:t,url:o}));let s=n?r(n):``;return s.startsWith(`?`)&&(s=s.substring(1)),s&&(o+=`?${s}`),o},bt=({allowReserved:e,array:t,object:n}={})=>r=>{let i=[];if(r&&typeof r==`object`)for(let a in r){let o=r[a];if(o!=null)if(Array.isArray(o)){let n=ht({allowReserved:e,explode:!0,name:a,style:`form`,value:o,...t});n&&i.push(n)}else if(typeof o==`object`){let t=gt({allowReserved:e,explode:!0,name:a,style:`deepObject`,value:o,...n});t&&i.push(t)}else{let t=U({allowReserved:e,name:a,value:o});t&&i.push(t)}}return i.join(`&`)},xt=e=>{if(!e)return`stream`;let t=e.split(`;`)[0]?.trim();if(t){if(t.startsWith(`application/json`)||t.endsWith(`+json`))return`json`;if(t===`multipart/form-data`)return`formData`;if([`application/`,`audio/`,`image/`,`video/`].some(e=>t.startsWith(e)))return`blob`;if(t.startsWith(`text/`))return`text`}},St=(e,t)=>t?!!(e.headers.has(t)||e.query?.[t]||e.headers.get(`Cookie`)?.includes(`${t}=`)):!1,Ct=async({security:e,...t})=>{for(let n of e){if(St(t,n.name))continue;let e=await ut(n,t.auth);if(!e)continue;let r=n.name??`Authorization`;switch(n.in){case`query`:t.query||={},t.query[r]=e;break;case`cookie`:t.headers.append(`Cookie`,`${r}=${e}`);break;default:t.headers.set(r,e);break}}},wt=e=>yt({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer==`function`?e.querySerializer:bt(e.querySerializer),url:e.url}),Tt=(e,t)=>{let n={...e,...t};return n.baseUrl?.endsWith(`/`)&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=Et(e.headers,t.headers),n},Et=(...e)=>{let t=new Headers;for(let n of e){if(!n||typeof n!=`object`)continue;let e=n instanceof Headers?n.entries():Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,typeof r==`object`?JSON.stringify(r):r)}return t};var Dt=class{_fns;constructor(){this._fns=[]}clear(){this._fns=[]}getInterceptorIndex(e){return typeof e==`number`?this._fns[e]?e:-1:this._fns.indexOf(e)}exists(e){let t=this.getInterceptorIndex(e);return!!this._fns[t]}eject(e){let t=this.getInterceptorIndex(e);this._fns[t]&&(this._fns[t]=null)}update(e,t){let n=this.getInterceptorIndex(e);return this._fns[n]?(this._fns[n]=t,e):!1}use(e){return this._fns=[...this._fns,e],this._fns.length-1}};const Ot=()=>({error:new Dt,request:new Dt,response:new Dt}),kt=bt({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}}),At={"Content-Type":`application/json`},jt=(e={})=>({...dt,headers:At,parseAs:`auto`,querySerializer:kt,...e}),Mt=(e={})=>{let t=Tt(jt(),e),n=()=>({...t}),r=e=>(t=Tt(t,e),n()),i=Ot(),a=async e=>{let n={...t,...e,fetch:e.fetch??t.fetch??globalThis.fetch,headers:Et(t.headers,e.headers),serializedBody:void 0};return n.security&&await Ct({...n,security:n.security}),n.requestValidator&&await n.requestValidator(n),n.body&&n.bodySerializer&&(n.serializedBody=n.bodySerializer(n.body)),(n.serializedBody===void 0||n.serializedBody===``)&&n.headers.delete(`Content-Type`),{opts:n,url:wt(n)}},o=async e=>{let{opts:t,url:n}=await a(e),r={redirect:`follow`,...t,body:t.serializedBody},o=new Request(n,r);for(let e of i.request._fns)e&&(o=await e(o,t));let s=t.fetch,c=await s(o);for(let e of i.response._fns)e&&(c=await e(c,o,t));let l={request:o,response:c};if(c.ok){if(c.status===204||c.headers.get(`Content-Length`)===`0`)return t.responseStyle===`data`?{}:{data:{},...l};let e=(t.parseAs===`auto`?xt(c.headers.get(`Content-Type`)):t.parseAs)??`json`,n;switch(e){case`arrayBuffer`:case`blob`:case`formData`:case`json`:case`text`:n=await c[e]();break;case`stream`:return t.responseStyle===`data`?c.body:{data:c.body,...l}}return e===`json`&&(t.responseValidator&&await t.responseValidator(n),t.responseTransformer&&(n=await t.responseTransformer(n))),t.responseStyle===`data`?n:{data:n,...l}}let u=await c.text(),d;try{d=JSON.parse(u)}catch{}let f=d??u,p=f;for(let e of i.error._fns)e&&(p=await e(f,c,o,t));if(p||={},t.throwOnError)throw p;return t.responseStyle===`data`?void 0:{error:p,...l}},s=e=>{let t=t=>o({...t,method:e});return t.sse=async t=>{let{opts:n,url:r}=await a(t);return lt({...n,body:n.body,headers:n.headers,method:e,url:r})},t};return{buildUrl:wt,connect:s(`CONNECT`),delete:s(`DELETE`),get:s(`GET`),getConfig:n,head:s(`HEAD`),interceptors:i,options:s(`OPTIONS`),patch:s(`PATCH`),post:s(`POST`),put:s(`PUT`),request:o,setConfig:r,trace:s(`TRACE`)}};Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`});const Nt=Mt(jt({baseUrl:`http://localhost:4096`}));var W=class{_client=Nt;constructor(e){e?.client&&(this._client=e.client)}},Pt=class extends W{event(e){return(e?.client??this._client).get.sse({url:`/global/event`,...e})}},Ft=class extends W{list(e){return(e?.client??this._client).get({url:`/project`,...e})}current(e){return(e?.client??this._client).get({url:`/project/current`,...e})}},It=class extends W{list(e){return(e?.client??this._client).get({url:`/pty`,...e})}create(e){return(e?.client??this._client).post({url:`/pty`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}remove(e){return(e.client??this._client).delete({url:`/pty/{id}`,...e})}get(e){return(e.client??this._client).get({url:`/pty/{id}`,...e})}update(e){return(e.client??this._client).put({url:`/pty/{id}`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}connect(e){return(e.client??this._client).get({url:`/pty/{id}/connect`,...e})}},Lt=class extends W{get(e){return(e?.client??this._client).get({url:`/config`,...e})}update(e){return(e?.client??this._client).patch({url:`/config`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}providers(e){return(e?.client??this._client).get({url:`/config/providers`,...e})}},Rt=class extends W{ids(e){return(e?.client??this._client).get({url:`/experimental/tool/ids`,...e})}list(e){return(e.client??this._client).get({url:`/experimental/tool`,...e})}},zt=class extends W{dispose(e){return(e?.client??this._client).post({url:`/instance/dispose`,...e})}},Bt=class extends W{get(e){return(e?.client??this._client).get({url:`/path`,...e})}},Vt=class extends W{get(e){return(e?.client??this._client).get({url:`/vcs`,...e})}},Ht=class extends W{list(e){return(e?.client??this._client).get({url:`/session`,...e})}create(e){return(e?.client??this._client).post({url:`/session`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}status(e){return(e?.client??this._client).get({url:`/session/status`,...e})}delete(e){return(e.client??this._client).delete({url:`/session/{id}`,...e})}get(e){return(e.client??this._client).get({url:`/session/{id}`,...e})}update(e){return(e.client??this._client).patch({url:`/session/{id}`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}children(e){return(e.client??this._client).get({url:`/session/{id}/children`,...e})}todo(e){return(e.client??this._client).get({url:`/session/{id}/todo`,...e})}init(e){return(e.client??this._client).post({url:`/session/{id}/init`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}fork(e){return(e.client??this._client).post({url:`/session/{id}/fork`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}abort(e){return(e.client??this._client).post({url:`/session/{id}/abort`,...e})}unshare(e){return(e.client??this._client).delete({url:`/session/{id}/share`,...e})}share(e){return(e.client??this._client).post({url:`/session/{id}/share`,...e})}diff(e){return(e.client??this._client).get({url:`/session/{id}/diff`,...e})}summarize(e){return(e.client??this._client).post({url:`/session/{id}/summarize`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}messages(e){return(e.client??this._client).get({url:`/session/{id}/message`,...e})}prompt(e){return(e.client??this._client).post({url:`/session/{id}/message`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}message(e){return(e.client??this._client).get({url:`/session/{id}/message/{messageID}`,...e})}promptAsync(e){return(e.client??this._client).post({url:`/session/{id}/prompt_async`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}command(e){return(e.client??this._client).post({url:`/session/{id}/command`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}shell(e){return(e.client??this._client).post({url:`/session/{id}/shell`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}revert(e){return(e.client??this._client).post({url:`/session/{id}/revert`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}unrevert(e){return(e.client??this._client).post({url:`/session/{id}/unrevert`,...e})}},Ut=class extends W{list(e){return(e?.client??this._client).get({url:`/command`,...e})}},Wt=class extends W{authorize(e){return(e.client??this._client).post({url:`/provider/{id}/oauth/authorize`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}callback(e){return(e.client??this._client).post({url:`/provider/{id}/oauth/callback`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}},Gt=class extends W{list(e){return(e?.client??this._client).get({url:`/provider`,...e})}auth(e){return(e?.client??this._client).get({url:`/provider/auth`,...e})}oauth=new Wt({client:this._client})},Kt=class extends W{text(e){return(e.client??this._client).get({url:`/find`,...e})}files(e){return(e.client??this._client).get({url:`/find/file`,...e})}symbols(e){return(e.client??this._client).get({url:`/find/symbol`,...e})}},qt=class extends W{list(e){return(e.client??this._client).get({url:`/file`,...e})}read(e){return(e.client??this._client).get({url:`/file/content`,...e})}status(e){return(e?.client??this._client).get({url:`/file/status`,...e})}},Jt=class extends W{log(e){return(e?.client??this._client).post({url:`/log`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}agents(e){return(e?.client??this._client).get({url:`/agent`,...e})}},Yt=class extends W{remove(e){return(e.client??this._client).delete({url:`/mcp/{name}/auth`,...e})}start(e){return(e.client??this._client).post({url:`/mcp/{name}/auth`,...e})}callback(e){return(e.client??this._client).post({url:`/mcp/{name}/auth/callback`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}authenticate(e){return(e.client??this._client).post({url:`/mcp/{name}/auth/authenticate`,...e})}set(e){return(e.client??this._client).put({url:`/auth/{id}`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}},Xt=class extends W{status(e){return(e?.client??this._client).get({url:`/mcp`,...e})}add(e){return(e?.client??this._client).post({url:`/mcp`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}connect(e){return(e.client??this._client).post({url:`/mcp/{name}/connect`,...e})}disconnect(e){return(e.client??this._client).post({url:`/mcp/{name}/disconnect`,...e})}auth=new Yt({client:this._client})},Zt=class extends W{status(e){return(e?.client??this._client).get({url:`/lsp`,...e})}},Qt=class extends W{status(e){return(e?.client??this._client).get({url:`/formatter`,...e})}},$t=class extends W{next(e){return(e?.client??this._client).get({url:`/tui/control/next`,...e})}response(e){return(e?.client??this._client).post({url:`/tui/control/response`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}},en=class extends W{appendPrompt(e){return(e?.client??this._client).post({url:`/tui/append-prompt`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}openHelp(e){return(e?.client??this._client).post({url:`/tui/open-help`,...e})}openSessions(e){return(e?.client??this._client).post({url:`/tui/open-sessions`,...e})}openThemes(e){return(e?.client??this._client).post({url:`/tui/open-themes`,...e})}openModels(e){return(e?.client??this._client).post({url:`/tui/open-models`,...e})}submitPrompt(e){return(e?.client??this._client).post({url:`/tui/submit-prompt`,...e})}clearPrompt(e){return(e?.client??this._client).post({url:`/tui/clear-prompt`,...e})}executeCommand(e){return(e?.client??this._client).post({url:`/tui/execute-command`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}showToast(e){return(e?.client??this._client).post({url:`/tui/show-toast`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}publish(e){return(e?.client??this._client).post({url:`/tui/publish`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}control=new $t({client:this._client})},tn=class extends W{subscribe(e){return(e?.client??this._client).get.sse({url:`/event`,...e})}},nn=class extends W{postSessionIdPermissionsPermissionId(e){return(e.client??this._client).post({url:`/session/{id}/permissions/{permissionID}`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}global=new Pt({client:this._client});project=new Ft({client:this._client});pty=new It({client:this._client});config=new Lt({client:this._client});tool=new Rt({client:this._client});instance=new zt({client:this._client});path=new Bt({client:this._client});vcs=new Vt({client:this._client});session=new Ht({client:this._client});command=new Ut({client:this._client});provider=new Gt({client:this._client});find=new Kt({client:this._client});file=new qt({client:this._client});app=new Jt({client:this._client});mcp=new Xt({client:this._client});lsp=new Zt({client:this._client});formatter=new Qt({client:this._client});tui=new en({client:this._client});auth=new Yt({client:this._client});event=new tn({client:this._client})};function rn(e){if(!e?.fetch){let t=e=>(e.timeout=!1,fetch(e));e={...e,fetch:t}}return e?.directory&&(e.headers={...e.headers,"x-opencode-directory":encodeURIComponent(e.directory)}),new nn({client:Mt(e)})}async function an(e){e=Object.assign({hostname:`127.0.0.1`,port:4096,timeout:5e3},e??{});let t=[`serve`,`--hostname=${e.hostname}`,`--port=${e.port}`];e.config?.logLevel&&t.push(`--log-level=${e.config.logLevel}`);let n=De(`opencode`,t,{signal:e.signal,env:{...process.env,OPENCODE_CONFIG_CONTENT:JSON.stringify(e.config??{})}});return{url:await new Promise((t,r)=>{let i=setTimeout(()=>{r(Error(`Timeout waiting for server to start after ${e.timeout}ms`))},e.timeout),a=``;n.stdout?.on(`data`,e=>{a+=e.toString();let n=a.split(` -`);for(let e of n)if(e.startsWith(`opencode server listening`)){let n=e.match(/on\s+(https?:\/\/[^\s]+)/);if(!n)throw Error(`Failed to parse server url from output: ${e}`);clearTimeout(i),t(n[1]);return}}),n.stderr?.on(`data`,e=>{a+=e.toString()}),n.on(`exit`,e=>{clearTimeout(i);let t=`Server exited with code ${e}`;a.trim()&&(t+=`\nServer output: ${a}`),r(Error(t))}),n.on(`error`,e=>{clearTimeout(i),r(e)}),e.signal&&e.signal.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Aborted`))})}),close(){n.kill()}}}async function on(e){let t=await an({...e});return{client:rn({baseUrl:t.url}),server:t}}async function sn(e,t,n,r){if(n!=null)try{let i=await e.session.update({path:{id:t},body:{title:n}});i.error!=null&&r.warning(`Best-effort session title re-assertion failed`,{sessionId:t,sessionTitle:n,error:String(i.error)})}catch(e){r.warning(`Best-effort session title re-assertion failed`,{sessionId:t,sessionTitle:n,error:e instanceof Error?e.message:String(e)})}}async function cn(e){if(e<0||!Number.isFinite(e))throw Error(`Invalid sleep duration: ${e}`);return new Promise(t=>setTimeout(t,e))}const ln={api_error:`API Error`,configuration:`Configuration Error`,internal:`Internal Error`,llm_fetch_error:`LLM Fetch Error`,llm_timeout:`LLM Timeout`,permission:`Permission Error`,rate_limit:`Rate Limit`,validation:`Validation Error`};function un(e){return e.type===`rate_limit`?`:warning:`:e.type===`llm_timeout`?`:hourglass:`:e.type===`llm_fetch_error`||e.retryable?`:warning:`:`:x:`}function dn(e){let t=un(e),n=ln[e.type],r=[];return r.push(`${t} **${n}**`),r.push(``),r.push(e.message),e.details!=null&&(r.push(``),r.push(`> ${e.details}`)),e.suggestedAction!=null&&(r.push(``),r.push(`**Suggested action:** ${e.suggestedAction}`)),e.retryable&&(r.push(``),r.push(`_This error is retryable._`)),e.resetTime!=null&&(r.push(``),r.push(`_Rate limit resets at: ${e.resetTime.toISOString()}_`)),r.join(` -`)}function fn(e,t,n,r){return{type:e,message:t,retryable:n,details:r?.details,suggestedAction:r?.suggestedAction,resetTime:r?.resetTime}}const pn=[/fetch failed/i,/connect\s*timeout/i,/connecttimeouterror/i,/timed?\s*out/i,/econnrefused/i,/econnreset/i,/etimedout/i,/network error/i];function mn(e){if(e==null)return!1;let t=``;if(typeof e==`string`)t=e;else if(e instanceof Error)t=e.message,`cause`in e&&typeof e.cause==`string`&&(t+=` ${e.cause}`);else if(typeof e==`object`){let n=e;typeof n.message==`string`&&(t=n.message),typeof n.cause==`string`&&(t+=` ${n.cause}`)}return pn.some(e=>e.test(t))}function hn(e,t){return fn(`llm_fetch_error`,`LLM request failed: ${e}`,!0,{details:t==null?void 0:`Model: ${t}`,suggestedAction:`This is a transient network error. The request may succeed on retry, or try a different model.`})}function gn(e,t){return fn(`configuration`,`Agent error: ${e}`,!1,{details:t==null?void 0:`Requested agent: ${t}`,suggestedAction:`Verify the agent name is correct and the required plugins (e.g., oMo) are installed.`})}async function _n(e,t,n,i,a,o=r,s){let c=Date.now(),l=0;for(;!i.aborted;){if(await cn(500),i.aborted)return{completed:!1,error:`Aborted`};if(s?.sessionError==null)l=0;else{if(l++,l>=3)return a.error(`Session error persisted through grace period`,{sessionId:t,error:s.sessionError,graceCycles:l}),{completed:!1,error:`Session error: ${s.sessionError}`};continue}if(s?.sessionIdle===!0)return a.debug(`Session idle detected via event stream`,{sessionId:t}),{completed:!0,error:null};let r=Date.now()-c;if(o>0&&r>=o)return a.warning(`Poll timeout reached`,{elapsedMs:r,maxPollTimeMs:o}),{completed:!1,error:`Poll timeout after ${r}ms`};try{let r=((await e.session.status({query:{directory:n}})).data??{})[t];if(r==null)a.debug(`Session status not found in poll response`,{sessionId:t});else if(r.type===`idle`)return a.debug(`Session idle detected via polling`,{sessionId:t}),{completed:!0,error:null};else a.debug(`Session status`,{sessionId:t,type:r.type});if(s!=null&&!s.firstMeaningfulEventReceived){let e=Date.now()-c;if(e>=9e4)return a.error(`No agent activity detected — server may have crashed during prompt processing`,{elapsedMs:e,sessionId:t}),{completed:!1,error:`No agent activity detected after ${e}ms — server may have crashed during prompt processing`}}}catch(e){a.debug(`Poll request failed`,{error:A(e)})}}return{completed:!1,error:`Aborted`}}async function vn(e,t=2e3){await Promise.race([e,new Promise(e=>{setTimeout(e,t)})])}function yn(e){try{let t=new URL(e);return t.hostname===`github.com`||t.hostname===`api.github.com`}catch{return!1}}function bn(e){try{let t=new URL(e);return t.hostname===`github.com`&&(t.pathname.startsWith(`/user-attachments/assets/`)||t.pathname.startsWith(`/user-attachments/files/`))}catch{return!1}}function xn(e){let t=e.match(/https:\/\/github\.com\/[a-zA-Z0-9-]+\/[\w.-]+\/(?:pull|issues)\/\d+(?:#issuecomment-\d+)?/g)??[];return[...new Set(t)].filter(yn)}function Sn(e){let t=/\[[\w-]+\s+([a-f0-9]{7,40})\]/g,n=[];for(let r of e.matchAll(t))r[1]!=null&&n.push(r[1]);return[...new Set(n)]}const Cn={todowrite:[`Todo`,`\x1B[33m\x1B[1m`],todoread:[`Todo`,`\x1B[33m\x1B[1m`],bash:[`Bash`,`\x1B[31m\x1B[1m`],edit:[`Edit`,`\x1B[32m\x1B[1m`],glob:[`Glob`,`\x1B[34m\x1B[1m`],grep:[`Grep`,`\x1B[34m\x1B[1m`],list:[`List`,`\x1B[34m\x1B[1m`],read:[`Read`,`\x1B[35m\x1B[1m`],write:[`Write`,`\x1B[32m\x1B[1m`],websearch:[`Search`,`\x1B[2m\x1B[1m`]},wn=`\x1B[0m`;function Tn(){return N.env.NO_COLOR==null}function En(e,t){let[n,r]=Cn[e.toLowerCase()]??[e,`\x1B[36m\x1B[1m`],i=n.padEnd(10,` `);Tn()?N.stdout.write(`\n${r}|${wn} ${i} ${wn}${t}\n`):N.stdout.write(`\n| ${i} ${t}\n`)}function Dn(e){N.stdout.write(`\n${e}\n`)}function On(e,t){t.debug(`Server event`,{eventType:e.type,properties:e.properties})}function kn(e,t,n,r,i){let a=xn(t);if(e.includes(`gh pr create`)){let e=a.filter(e=>e.includes(`/pull/`)&&!e.includes(`#`));for(let t of e)n.includes(t)||n.push(t)}if(e.includes(`git commit`)){let e=Sn(t);for(let t of e)r.includes(t)||r.push(t)}(e.includes(`gh issue comment`)||e.includes(`gh pr comment`))&&a.some(e=>e.includes(`#issuecomment`))&&i()}async function An(e,t,n,r,i){let a=``,o=null,s=null,c=null,l=[],u=[],d=0,f=null;for await(let p of e){if(n.aborted)break;if(On(p,r),p.type===`message.part.updated`){let e=p.properties.part;if(e.sessionID!==t)continue;if(i!=null&&(i.firstMeaningfulEventReceived=!0),e.type===`text`&&`text`in e&&typeof e.text==`string`){a=e.text;let t=`time`in e?e.time?.end:void 0;t!=null&&Number.isFinite(t)&&(Dn(a),a=``)}else if(e.type===`tool`){let t=e.state;t.status===`completed`&&(En(e.tool,t.title),e.tool.toLowerCase()===`bash`&&kn(String(t.input.command??t.input.cmd??``),String(t.output),l,u,()=>{d++}))}}else if(p.type===`message.updated`){let e=p.properties.info;e.sessionID===t&&e.role===`assistant`&&e.tokens!=null&&(i!=null&&(i.firstMeaningfulEventReceived=!0),o={input:e.tokens.input??0,output:e.tokens.output??0,reasoning:e.tokens.reasoning??0,cache:{read:e.tokens.cache?.read??0,write:e.tokens.cache?.write??0}},s=e.modelID??null,c=e.cost??null,r.debug(`Token usage received`,{tokens:o,model:s,cost:c}))}else if(p.type===`session.error`){if(p.properties.sessionID===t){let e=p.properties.error,t=typeof e==`string`?e:String(e);r.error(`Session error`,{error:e}),f=mn(e)?hn(t,s??void 0):gn(t),i!=null&&(i.sessionError=t)}}else p.type===`session.idle`&&p.properties.sessionID===t&&(i!=null&&(i.sessionIdle=!0),a.length>0&&(Dn(a),a=``))}return a.length>0&&Dn(a),{tokens:o,model:s,cost:c,prsCreated:l,commitsCreated:u,commentsPosted:d,llmError:f}}const jn=5e3;async function Mn(e,t,n,r,i){let a=new AbortController,o={firstMeaningfulEventReceived:!1,sessionIdle:!1,sessionError:null},s=await e.event.subscribe(),c={tokens:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:null},l=An(s.stream,t,a.signal,i,o).then(e=>{c=e}).catch(e=>{e instanceof Error&&e.name!==`AbortError`&&i.debug(`Event stream error`,{error:e.message})}),u=async()=>{a.abort(),await vn(l)};try{let s=await _n(e,t,n,a.signal,i,r,o);if(await u(),!s.completed){let e=s.error??`Session did not reach idle state`;return i.error(`Session completion polling failed`,{error:e,sessionId:t}),{success:!1,error:e,llmError:c.llmError,shouldRetry:c.llmError!=null,eventStreamResult:c}}return{success:!0,error:null,llmError:null,shouldRetry:!1,eventStreamResult:c}}finally{a.abort(),await vn(l)}}const Nn=e=>{if(e?.model!=null)return{providerID:e.model.providerID,modelID:e.model.modelID};if(!(e!=null&&Object.values(e.omoProviders).some(e=>e!==`no`)))return{providerID:me.providerID,modelID:me.modelID}};async function Pn(e,t,n,r,i,a,o){let s={parts:[{type:`text`,text:n},...r??[]]},c=Nn(a);c!=null&&(s.model=c);let l=a?.agent??`sisyphus`;l!==`sisyphus`&&(s.agent=l);let u=await e.session.promptAsync({path:{id:t},body:s,query:{directory:i}});if(u.error!=null){let e=String(u.error),t=mn(u.error)?hn(e):null;return{success:!1,error:e,llmError:t,shouldRetry:t!=null,eventStreamResult:{tokens:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:t}}}return Mn(e,t,i,a?.timeoutMs??18e5,o)}function Fn(){return[`## Critical Rules (NON-NEGOTIABLE)`,`- You are a NON-INTERACTIVE CI agent. Do NOT ask questions. Make decisions autonomously.`,`- Post EXACTLY ONE comment or review per invocation. Never multiple.`,`- Include the Run Summary marker block in your comment.`,"- Use `gh` CLI for all GitHub operations. Do not use the GitHub API directly.",`- Mark your comment with the bot identification marker.`].join(` -`)}function In(e,t,n){if(e==null)return``;let r=[`## Thread Identity`];return r.push(`**Logical Thread**: \`${e.key}\` (${e.entityType} #${e.entityId})`),t?(r.push(`**Status**: Continuing previous conversation thread.`),n!=null&&n.length>0&&(r.push(``),r.push(`**Thread Summary**:`),r.push(n))):r.push(`**Status**: Fresh conversation — no prior thread found for this entity.`),r.join(` -`)}function Ln(e){return e==null||e.length===0?``:[`## Current Thread Context`,`This is work from your PREVIOUS runs on this same entity:`,``,e].join(` -`)}function Rn(){return[`## Reminder: Critical Rules`,"- ONE comment/review only. Include Run Summary marker. Use `gh` CLI only."].join(` -`)}function zn(e,t){switch(e.eventType){case`issue_comment`:return{directive:`Respond to the comment above. Post your response as a single comment on this thread.`,appendMode:!0};case`discussion_comment`:return{directive:`Respond to the discussion comment above. Post your response as a single comment.`,appendMode:!0};case`issues`:return e.action===`opened`?{directive:`Triage this issue: summarize, reproduce if possible, propose next steps. Post your response as a single comment.`,appendMode:!0}:{directive:`Respond to the mention in this issue. Post your response as a single comment.`,appendMode:!0};case`pull_request`:return{directive:[`Review this pull request for code quality, potential bugs, and improvements.`,"If you are a requested reviewer, submit a review via `gh pr review` with your full response (including Run Summary) in the --body.",`Include the Run Summary in the review body. Do not post a separate comment.`,`If the author is a collaborator, prioritize actionable feedback over style nits.`].join(` -`),appendMode:!0};case`pull_request_review_comment`:return{directive:Bn(e),appendMode:!0};case`schedule`:case`workflow_dispatch`:return{directive:t??``,appendMode:!1};default:return{directive:`Execute the requested operation.`,appendMode:!0}}}function Bn(e){let t=e.target,n=[`Respond to the review comment.`,``];return t?.path!=null&&n.push(`**File:** \`${t.path}\``),t?.line!=null&&n.push(`**Line:** ${t.line}`),t?.commitId!=null&&n.push(`**Commit:** \`${t.commitId}\``),t?.diffHunk!=null&&t.diffHunk.length>0&&n.push(``,`**Diff Context:**`,"```diff",t.diffHunk,"```"),n.join(` -`)}function Vn(e,t){let{directive:n,appendMode:r}=zn(e,t),i=[`## Task`,``];return r?(i.push(n),t!=null&&t.trim().length>0&&i.push(``,`**Additional Instructions:**`,t.trim())):i.push(n),i.push(``),i.join(` -`)}function Hn(e,t){let{context:n,customPrompt:r,cacheStatus:i,sessionContext:a,logicalKey:o,isContinuation:s,currentThreadSessionId:c}=e,l=[],u=s===!0;l.push(Fn());let d=In(o??null,u,null);d.length>0&&l.push(d);let f=a!=null&&u&&c!=null?Gn(a.priorWorkContext,c):null;e.triggerContext==null?n.commentBody==null?l.push(`## Task +`);try{c=JSON.parse(e),l=!0}catch{c=e}}l&&(r&&await r(c),n&&(c=await n(c))),t?.({data:c,event:o,id:u,retry:s}),a.length&&(yield c)}}}finally{p.removeEventListener(`abort`,d),a.releaseLock()}break}catch(t){if(e?.(t),a!==void 0&&f>=a)break;await d(Math.min(s*2**(f-1),o??3e4))}}}()}},lt=async(e,t)=>{let n=typeof t==`function`?await t(e):t;if(n)return e.scheme===`bearer`?`Bearer ${n}`:e.scheme===`basic`?`Basic ${btoa(n)}`:n},ut={bodySerializer:e=>JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t)},dt=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},ft=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},pt=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},mt=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(ft(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=dt(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):ht({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},ht=({allowReserved:e,name:t,value:n})=>{if(n==null)return``;if(typeof n==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},gt=({allowReserved:e,explode:t,name:n,style:r,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${n}=${i.toISOString()}`;if(r!==`deepObject`&&!t){let t=[];Object.entries(i).forEach(([n,r])=>{t=[...t,n,e?r:encodeURIComponent(r)]});let a=t.join(`,`);switch(r){case`form`:return`${n}=${a}`;case`label`:return`.${a}`;case`matrix`:return`;${n}=${a}`;default:return a}}let o=pt(r),s=Object.entries(i).map(([t,i])=>ht({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},_t=/\{[^{}]+\}/g,vt=({path:e,url:t})=>{let n=t,r=t.match(_t);if(r)for(let t of r){let r=!1,i=t.substring(1,t.length-1),a=`simple`;i.endsWith(`*`)&&(r=!0,i=i.substring(0,i.length-1)),i.startsWith(`.`)?(i=i.substring(1),a=`label`):i.startsWith(`;`)&&(i=i.substring(1),a=`matrix`);let o=e[i];if(o==null)continue;if(Array.isArray(o)){n=n.replace(t,mt({explode:r,name:i,style:a,value:o}));continue}if(typeof o==`object`){n=n.replace(t,gt({explode:r,name:i,style:a,value:o,valueOnly:!0}));continue}if(a===`matrix`){n=n.replace(t,`;${ht({name:i,value:o})}`);continue}let s=encodeURIComponent(a===`label`?`.${o}`:o);n=n.replace(t,s)}return n},yt=({baseUrl:e,path:t,query:n,querySerializer:r,url:i})=>{let a=i.startsWith(`/`)?i:`/${i}`,o=(e??``)+a;t&&(o=vt({path:t,url:o}));let s=n?r(n):``;return s.startsWith(`?`)&&(s=s.substring(1)),s&&(o+=`?${s}`),o},bt=({allowReserved:e,array:t,object:n}={})=>r=>{let i=[];if(r&&typeof r==`object`)for(let a in r){let o=r[a];if(o!=null)if(Array.isArray(o)){let n=mt({allowReserved:e,explode:!0,name:a,style:`form`,value:o,...t});n&&i.push(n)}else if(typeof o==`object`){let t=gt({allowReserved:e,explode:!0,name:a,style:`deepObject`,value:o,...n});t&&i.push(t)}else{let t=ht({allowReserved:e,name:a,value:o});t&&i.push(t)}}return i.join(`&`)},xt=e=>{if(!e)return`stream`;let t=e.split(`;`)[0]?.trim();if(t){if(t.startsWith(`application/json`)||t.endsWith(`+json`))return`json`;if(t===`multipart/form-data`)return`formData`;if([`application/`,`audio/`,`image/`,`video/`].some(e=>t.startsWith(e)))return`blob`;if(t.startsWith(`text/`))return`text`}},St=(e,t)=>t?!!(e.headers.has(t)||e.query?.[t]||e.headers.get(`Cookie`)?.includes(`${t}=`)):!1,Ct=async({security:e,...t})=>{for(let n of e){if(St(t,n.name))continue;let e=await lt(n,t.auth);if(!e)continue;let r=n.name??`Authorization`;switch(n.in){case`query`:t.query||={},t.query[r]=e;break;case`cookie`:t.headers.append(`Cookie`,`${r}=${e}`);break;default:t.headers.set(r,e);break}}},wt=e=>yt({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer==`function`?e.querySerializer:bt(e.querySerializer),url:e.url}),Tt=(e,t)=>{let n={...e,...t};return n.baseUrl?.endsWith(`/`)&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=Et(e.headers,t.headers),n},Et=(...e)=>{let t=new Headers;for(let n of e){if(!n||typeof n!=`object`)continue;let e=n instanceof Headers?n.entries():Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,typeof r==`object`?JSON.stringify(r):r)}return t};var Dt=class{_fns;constructor(){this._fns=[]}clear(){this._fns=[]}getInterceptorIndex(e){return typeof e==`number`?this._fns[e]?e:-1:this._fns.indexOf(e)}exists(e){let t=this.getInterceptorIndex(e);return!!this._fns[t]}eject(e){let t=this.getInterceptorIndex(e);this._fns[t]&&(this._fns[t]=null)}update(e,t){let n=this.getInterceptorIndex(e);return this._fns[n]?(this._fns[n]=t,e):!1}use(e){return this._fns=[...this._fns,e],this._fns.length-1}};const Ot=()=>({error:new Dt,request:new Dt,response:new Dt}),kt=bt({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}}),At={"Content-Type":`application/json`},jt=(e={})=>({...ut,headers:At,parseAs:`auto`,querySerializer:kt,...e}),Mt=(e={})=>{let t=Tt(jt(),e),n=()=>({...t}),r=e=>(t=Tt(t,e),n()),i=Ot(),a=async e=>{let n={...t,...e,fetch:e.fetch??t.fetch??globalThis.fetch,headers:Et(t.headers,e.headers),serializedBody:void 0};return n.security&&await Ct({...n,security:n.security}),n.requestValidator&&await n.requestValidator(n),n.body&&n.bodySerializer&&(n.serializedBody=n.bodySerializer(n.body)),(n.serializedBody===void 0||n.serializedBody===``)&&n.headers.delete(`Content-Type`),{opts:n,url:wt(n)}},o=async e=>{let{opts:t,url:n}=await a(e),r={redirect:`follow`,...t,body:t.serializedBody},o=new Request(n,r);for(let e of i.request._fns)e&&(o=await e(o,t));let s=t.fetch,c=await s(o);for(let e of i.response._fns)e&&(c=await e(c,o,t));let l={request:o,response:c};if(c.ok){if(c.status===204||c.headers.get(`Content-Length`)===`0`)return t.responseStyle===`data`?{}:{data:{},...l};let e=(t.parseAs===`auto`?xt(c.headers.get(`Content-Type`)):t.parseAs)??`json`,n;switch(e){case`arrayBuffer`:case`blob`:case`formData`:case`json`:case`text`:n=await c[e]();break;case`stream`:return t.responseStyle===`data`?c.body:{data:c.body,...l}}return e===`json`&&(t.responseValidator&&await t.responseValidator(n),t.responseTransformer&&(n=await t.responseTransformer(n))),t.responseStyle===`data`?n:{data:n,...l}}let u=await c.text(),d;try{d=JSON.parse(u)}catch{}let f=d??u,p=f;for(let e of i.error._fns)e&&(p=await e(f,c,o,t));if(p||={},t.throwOnError)throw p;return t.responseStyle===`data`?void 0:{error:p,...l}},s=e=>{let t=t=>o({...t,method:e});return t.sse=async t=>{let{opts:n,url:r}=await a(t);return ct({...n,body:n.body,headers:n.headers,method:e,url:r})},t};return{buildUrl:wt,connect:s(`CONNECT`),delete:s(`DELETE`),get:s(`GET`),getConfig:n,head:s(`HEAD`),interceptors:i,options:s(`OPTIONS`),patch:s(`PATCH`),post:s(`POST`),put:s(`PUT`),request:o,setConfig:r,trace:s(`TRACE`)}};Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`});const Nt=Mt(jt({baseUrl:`http://localhost:4096`}));var W=class{_client=Nt;constructor(e){e?.client&&(this._client=e.client)}},Pt=class extends W{event(e){return(e?.client??this._client).get.sse({url:`/global/event`,...e})}},Ft=class extends W{list(e){return(e?.client??this._client).get({url:`/project`,...e})}current(e){return(e?.client??this._client).get({url:`/project/current`,...e})}},It=class extends W{list(e){return(e?.client??this._client).get({url:`/pty`,...e})}create(e){return(e?.client??this._client).post({url:`/pty`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}remove(e){return(e.client??this._client).delete({url:`/pty/{id}`,...e})}get(e){return(e.client??this._client).get({url:`/pty/{id}`,...e})}update(e){return(e.client??this._client).put({url:`/pty/{id}`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}connect(e){return(e.client??this._client).get({url:`/pty/{id}/connect`,...e})}},Lt=class extends W{get(e){return(e?.client??this._client).get({url:`/config`,...e})}update(e){return(e?.client??this._client).patch({url:`/config`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}providers(e){return(e?.client??this._client).get({url:`/config/providers`,...e})}},Rt=class extends W{ids(e){return(e?.client??this._client).get({url:`/experimental/tool/ids`,...e})}list(e){return(e.client??this._client).get({url:`/experimental/tool`,...e})}},zt=class extends W{dispose(e){return(e?.client??this._client).post({url:`/instance/dispose`,...e})}},Bt=class extends W{get(e){return(e?.client??this._client).get({url:`/path`,...e})}},Vt=class extends W{get(e){return(e?.client??this._client).get({url:`/vcs`,...e})}},Ht=class extends W{list(e){return(e?.client??this._client).get({url:`/session`,...e})}create(e){return(e?.client??this._client).post({url:`/session`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}status(e){return(e?.client??this._client).get({url:`/session/status`,...e})}delete(e){return(e.client??this._client).delete({url:`/session/{id}`,...e})}get(e){return(e.client??this._client).get({url:`/session/{id}`,...e})}update(e){return(e.client??this._client).patch({url:`/session/{id}`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}children(e){return(e.client??this._client).get({url:`/session/{id}/children`,...e})}todo(e){return(e.client??this._client).get({url:`/session/{id}/todo`,...e})}init(e){return(e.client??this._client).post({url:`/session/{id}/init`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}fork(e){return(e.client??this._client).post({url:`/session/{id}/fork`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}abort(e){return(e.client??this._client).post({url:`/session/{id}/abort`,...e})}unshare(e){return(e.client??this._client).delete({url:`/session/{id}/share`,...e})}share(e){return(e.client??this._client).post({url:`/session/{id}/share`,...e})}diff(e){return(e.client??this._client).get({url:`/session/{id}/diff`,...e})}summarize(e){return(e.client??this._client).post({url:`/session/{id}/summarize`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}messages(e){return(e.client??this._client).get({url:`/session/{id}/message`,...e})}prompt(e){return(e.client??this._client).post({url:`/session/{id}/message`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}message(e){return(e.client??this._client).get({url:`/session/{id}/message/{messageID}`,...e})}promptAsync(e){return(e.client??this._client).post({url:`/session/{id}/prompt_async`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}command(e){return(e.client??this._client).post({url:`/session/{id}/command`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}shell(e){return(e.client??this._client).post({url:`/session/{id}/shell`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}revert(e){return(e.client??this._client).post({url:`/session/{id}/revert`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}unrevert(e){return(e.client??this._client).post({url:`/session/{id}/unrevert`,...e})}},Ut=class extends W{list(e){return(e?.client??this._client).get({url:`/command`,...e})}},Wt=class extends W{authorize(e){return(e.client??this._client).post({url:`/provider/{id}/oauth/authorize`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}callback(e){return(e.client??this._client).post({url:`/provider/{id}/oauth/callback`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}},Gt=class extends W{list(e){return(e?.client??this._client).get({url:`/provider`,...e})}auth(e){return(e?.client??this._client).get({url:`/provider/auth`,...e})}oauth=new Wt({client:this._client})},Kt=class extends W{text(e){return(e.client??this._client).get({url:`/find`,...e})}files(e){return(e.client??this._client).get({url:`/find/file`,...e})}symbols(e){return(e.client??this._client).get({url:`/find/symbol`,...e})}},qt=class extends W{list(e){return(e.client??this._client).get({url:`/file`,...e})}read(e){return(e.client??this._client).get({url:`/file/content`,...e})}status(e){return(e?.client??this._client).get({url:`/file/status`,...e})}},Jt=class extends W{log(e){return(e?.client??this._client).post({url:`/log`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}agents(e){return(e?.client??this._client).get({url:`/agent`,...e})}},Yt=class extends W{remove(e){return(e.client??this._client).delete({url:`/mcp/{name}/auth`,...e})}start(e){return(e.client??this._client).post({url:`/mcp/{name}/auth`,...e})}callback(e){return(e.client??this._client).post({url:`/mcp/{name}/auth/callback`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}authenticate(e){return(e.client??this._client).post({url:`/mcp/{name}/auth/authenticate`,...e})}set(e){return(e.client??this._client).put({url:`/auth/{id}`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}},Xt=class extends W{status(e){return(e?.client??this._client).get({url:`/mcp`,...e})}add(e){return(e?.client??this._client).post({url:`/mcp`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}connect(e){return(e.client??this._client).post({url:`/mcp/{name}/connect`,...e})}disconnect(e){return(e.client??this._client).post({url:`/mcp/{name}/disconnect`,...e})}auth=new Yt({client:this._client})},Zt=class extends W{status(e){return(e?.client??this._client).get({url:`/lsp`,...e})}},Qt=class extends W{status(e){return(e?.client??this._client).get({url:`/formatter`,...e})}},$t=class extends W{next(e){return(e?.client??this._client).get({url:`/tui/control/next`,...e})}response(e){return(e?.client??this._client).post({url:`/tui/control/response`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}},en=class extends W{appendPrompt(e){return(e?.client??this._client).post({url:`/tui/append-prompt`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}openHelp(e){return(e?.client??this._client).post({url:`/tui/open-help`,...e})}openSessions(e){return(e?.client??this._client).post({url:`/tui/open-sessions`,...e})}openThemes(e){return(e?.client??this._client).post({url:`/tui/open-themes`,...e})}openModels(e){return(e?.client??this._client).post({url:`/tui/open-models`,...e})}submitPrompt(e){return(e?.client??this._client).post({url:`/tui/submit-prompt`,...e})}clearPrompt(e){return(e?.client??this._client).post({url:`/tui/clear-prompt`,...e})}executeCommand(e){return(e?.client??this._client).post({url:`/tui/execute-command`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}showToast(e){return(e?.client??this._client).post({url:`/tui/show-toast`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}publish(e){return(e?.client??this._client).post({url:`/tui/publish`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}control=new $t({client:this._client})},tn=class extends W{subscribe(e){return(e?.client??this._client).get.sse({url:`/event`,...e})}},nn=class extends W{postSessionIdPermissionsPermissionId(e){return(e.client??this._client).post({url:`/session/{id}/permissions/{permissionID}`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}global=new Pt({client:this._client});project=new Ft({client:this._client});pty=new It({client:this._client});config=new Lt({client:this._client});tool=new Rt({client:this._client});instance=new zt({client:this._client});path=new Bt({client:this._client});vcs=new Vt({client:this._client});session=new Ht({client:this._client});command=new Ut({client:this._client});provider=new Gt({client:this._client});find=new Kt({client:this._client});file=new qt({client:this._client});app=new Jt({client:this._client});mcp=new Xt({client:this._client});lsp=new Zt({client:this._client});formatter=new Qt({client:this._client});tui=new en({client:this._client});auth=new Yt({client:this._client});event=new tn({client:this._client})};function rn(e,t){if(e)return t&&(e===t||e===encodeURIComponent(t))?t:e}function an(e,t){if(e.method!==`GET`&&e.method!==`HEAD`)return e;let n=rn(e.headers.get(`x-opencode-directory`),t);if(!n)return e;let r=new URL(e.url);r.searchParams.has(`directory`)||r.searchParams.set(`directory`,n);let i=new Request(r,e);return i.headers.delete(`x-opencode-directory`),i}function on(e){if(!e?.fetch){let t=e=>(e.timeout=!1,fetch(e));e={...e,fetch:t}}e?.directory&&(e.headers={...e.headers,"x-opencode-directory":encodeURIComponent(e.directory)});let t=Mt(e);return t.interceptors.request.use(t=>an(t,e?.directory)),new nn({client:t})}async function sn(e){e=Object.assign({hostname:`127.0.0.1`,port:4096,timeout:5e3},e??{});let t=[`serve`,`--hostname=${e.hostname}`,`--port=${e.port}`];e.config?.logLevel&&t.push(`--log-level=${e.config.logLevel}`);let n=Te(`opencode`,t,{signal:e.signal,env:{...process.env,OPENCODE_CONFIG_CONTENT:JSON.stringify(e.config??{})}});return{url:await new Promise((t,r)=>{let i=setTimeout(()=>{r(Error(`Timeout waiting for server to start after ${e.timeout}ms`))},e.timeout),a=``;n.stdout?.on(`data`,e=>{a+=e.toString();let n=a.split(` +`);for(let e of n)if(e.startsWith(`opencode server listening`)){let n=e.match(/on\s+(https?:\/\/[^\s]+)/);if(!n)throw Error(`Failed to parse server url from output: ${e}`);clearTimeout(i),t(n[1]);return}}),n.stderr?.on(`data`,e=>{a+=e.toString()}),n.on(`exit`,e=>{clearTimeout(i);let t=`Server exited with code ${e}`;a.trim()&&(t+=`\nServer output: ${a}`),r(Error(t))}),n.on(`error`,e=>{clearTimeout(i),r(e)}),e.signal&&e.signal.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Aborted`))})}),close(){n.kill()}}}async function cn(e){let t=await sn({...e});return{client:on({baseUrl:t.url}),server:t}}async function ln(e,t,n,r){if(n!=null)try{let i=await e.session.update({path:{id:t},body:{title:n}});i.error!=null&&r.warning(`Best-effort session title re-assertion failed`,{sessionId:t,sessionTitle:n,error:String(i.error)})}catch(e){r.warning(`Best-effort session title re-assertion failed`,{sessionId:t,sessionTitle:n,error:e instanceof Error?e.message:String(e)})}}async function un(e){if(e<0||!Number.isFinite(e))throw Error(`Invalid sleep duration: ${e}`);return new Promise(t=>setTimeout(t,e))}const dn={api_error:`API Error`,configuration:`Configuration Error`,internal:`Internal Error`,llm_fetch_error:`LLM Fetch Error`,llm_timeout:`LLM Timeout`,permission:`Permission Error`,rate_limit:`Rate Limit`,validation:`Validation Error`};function fn(e){return e.type===`rate_limit`?`:warning:`:e.type===`llm_timeout`?`:hourglass:`:e.type===`llm_fetch_error`||e.retryable?`:warning:`:`:x:`}function pn(e){let t=fn(e),n=dn[e.type],r=[];return r.push(`${t} **${n}**`),r.push(``),r.push(e.message),e.details!=null&&(r.push(``),r.push(`> ${e.details}`)),e.suggestedAction!=null&&(r.push(``),r.push(`**Suggested action:** ${e.suggestedAction}`)),e.retryable&&(r.push(``),r.push(`_This error is retryable._`)),e.resetTime!=null&&(r.push(``),r.push(`_Rate limit resets at: ${e.resetTime.toISOString()}_`)),r.join(` +`)}function mn(e,t,n,r){return{type:e,message:t,retryable:n,details:r?.details,suggestedAction:r?.suggestedAction,resetTime:r?.resetTime}}const hn=[/fetch failed/i,/connect\s*timeout/i,/connecttimeouterror/i,/timed?\s*out/i,/econnrefused/i,/econnreset/i,/etimedout/i,/network error/i];function gn(e){if(e==null)return!1;let t=``;if(typeof e==`string`)t=e;else if(e instanceof Error)t=e.message,`cause`in e&&typeof e.cause==`string`&&(t+=` ${e.cause}`);else if(typeof e==`object`){let n=e;typeof n.message==`string`&&(t=n.message),typeof n.cause==`string`&&(t+=` ${n.cause}`)}return hn.some(e=>e.test(t))}function _n(e,t){return mn(`llm_fetch_error`,`LLM request failed: ${e}`,!0,{details:t==null?void 0:`Model: ${t}`,suggestedAction:`This is a transient network error. The request may succeed on retry, or try a different model.`})}function vn(e,t){return mn(`configuration`,`Agent error: ${e}`,!1,{details:t==null?void 0:`Requested agent: ${t}`,suggestedAction:`Verify the agent name is correct and the required plugins (e.g., oMo) are installed.`})}async function yn(e,t,n,i,a,o=r,s){let c=Date.now(),l=0;for(;!i.aborted;){if(await un(500),i.aborted)return{completed:!1,error:`Aborted`};if(s?.sessionError==null)l=0;else{if(l++,l>=3)return a.error(`Session error persisted through grace period`,{sessionId:t,error:s.sessionError,graceCycles:l}),{completed:!1,error:`Session error: ${s.sessionError}`};continue}if(s?.sessionIdle===!0)return a.debug(`Session idle detected via event stream`,{sessionId:t}),{completed:!0,error:null};let r=Date.now()-c;if(o>0&&r>=o)return a.warning(`Poll timeout reached`,{elapsedMs:r,maxPollTimeMs:o}),{completed:!1,error:`Poll timeout after ${r}ms`};try{let r=((await e.session.status({query:{directory:n}})).data??{})[t];if(r==null)a.debug(`Session status not found in poll response`,{sessionId:t});else if(r.type===`idle`)return a.debug(`Session idle detected via polling`,{sessionId:t}),{completed:!0,error:null};else a.debug(`Session status`,{sessionId:t,type:r.type});if(s!=null&&!s.firstMeaningfulEventReceived){let e=Date.now()-c;if(e>=9e4)return a.error(`No agent activity detected — server may have crashed during prompt processing`,{elapsedMs:e,sessionId:t}),{completed:!1,error:`No agent activity detected after ${e}ms — server may have crashed during prompt processing`}}}catch(e){a.debug(`Poll request failed`,{error:M(e)})}}return{completed:!1,error:`Aborted`}}async function bn(e,t=2e3){await Promise.race([e,new Promise(e=>{setTimeout(e,t)})])}function xn(e){try{let t=new URL(e);return t.hostname===`github.com`||t.hostname===`api.github.com`}catch{return!1}}function Sn(e){try{let t=new URL(e);return t.hostname===`github.com`&&(t.pathname.startsWith(`/user-attachments/assets/`)||t.pathname.startsWith(`/user-attachments/files/`))}catch{return!1}}function Cn(e){let t=e.match(/https:\/\/github\.com\/[a-zA-Z0-9-]+\/[\w.-]+\/(?:pull|issues)\/\d+(?:#issuecomment-\d+)?/g)??[];return[...new Set(t)].filter(xn)}function wn(e){let t=/\[[\w-]+\s+([a-f0-9]{7,40})\]/g,n=[];for(let r of e.matchAll(t))r[1]!=null&&n.push(r[1]);return[...new Set(n)]}const Tn={todowrite:[`Todo`,`\x1B[33m\x1B[1m`],todoread:[`Todo`,`\x1B[33m\x1B[1m`],bash:[`Bash`,`\x1B[31m\x1B[1m`],edit:[`Edit`,`\x1B[32m\x1B[1m`],glob:[`Glob`,`\x1B[34m\x1B[1m`],grep:[`Grep`,`\x1B[34m\x1B[1m`],list:[`List`,`\x1B[34m\x1B[1m`],read:[`Read`,`\x1B[35m\x1B[1m`],write:[`Write`,`\x1B[32m\x1B[1m`],websearch:[`Search`,`\x1B[2m\x1B[1m`]},En=`\x1B[0m`;function Dn(){return I.env.NO_COLOR==null}function On(e,t){let[n,r]=Tn[e.toLowerCase()]??[e,`\x1B[36m\x1B[1m`],i=n.padEnd(10,` `);Dn()?I.stdout.write(`\n${r}|${En} ${i} ${En}${t}\n`):I.stdout.write(`\n| ${i} ${t}\n`)}function kn(e){I.stdout.write(`\n${e}\n`)}function An(e,t){t.debug(`Server event`,{eventType:e.type,properties:e.properties})}function jn(e,t,n,r,i){let a=Cn(t);if(e.includes(`gh pr create`)){let e=a.filter(e=>e.includes(`/pull/`)&&!e.includes(`#`));for(let t of e)n.includes(t)||n.push(t)}if(e.includes(`git commit`)){let e=wn(t);for(let t of e)r.includes(t)||r.push(t)}(e.includes(`gh issue comment`)||e.includes(`gh pr comment`))&&a.some(e=>e.includes(`#issuecomment`))&&i()}async function Mn(e,t,n,r,i){let a=``,o=null,s=null,c=null,l=[],u=[],d=0,f=null;for await(let p of e){if(n.aborted)break;if(An(p,r),p.type===`message.part.updated`){let e=p.properties.part;if(e.sessionID!==t)continue;if(i!=null&&(i.firstMeaningfulEventReceived=!0),e.type===`text`&&`text`in e&&typeof e.text==`string`){a=e.text;let t=`time`in e?e.time?.end:void 0;t!=null&&Number.isFinite(t)&&(kn(a),a=``)}else if(e.type===`tool`){let t=e.state;t.status===`completed`&&(On(e.tool,t.title),e.tool.toLowerCase()===`bash`&&jn(String(t.input.command??t.input.cmd??``),String(t.output),l,u,()=>{d++}))}}else if(p.type===`message.updated`){let e=p.properties.info;e.sessionID===t&&e.role===`assistant`&&e.tokens!=null&&(i!=null&&(i.firstMeaningfulEventReceived=!0),o={input:e.tokens.input??0,output:e.tokens.output??0,reasoning:e.tokens.reasoning??0,cache:{read:e.tokens.cache?.read??0,write:e.tokens.cache?.write??0}},s=e.modelID??null,c=e.cost??null,r.debug(`Token usage received`,{tokens:o,model:s,cost:c}))}else if(p.type===`session.error`){if(p.properties.sessionID===t){let e=p.properties.error,t=typeof e==`string`?e:String(e);r.error(`Session error`,{error:e}),f=gn(e)?_n(t,s??void 0):vn(t),i!=null&&(i.sessionError=t)}}else p.type===`session.idle`&&p.properties.sessionID===t&&(i!=null&&(i.sessionIdle=!0),a.length>0&&(kn(a),a=``))}return a.length>0&&kn(a),{tokens:o,model:s,cost:c,prsCreated:l,commitsCreated:u,commentsPosted:d,llmError:f}}const Nn=5e3;async function Pn(e,t,n,r,i){let a=new AbortController,o={firstMeaningfulEventReceived:!1,sessionIdle:!1,sessionError:null},s=await e.event.subscribe(),c={tokens:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:null},l=Mn(s.stream,t,a.signal,i,o).then(e=>{c=e}).catch(e=>{e instanceof Error&&e.name!==`AbortError`&&i.debug(`Event stream error`,{error:e.message})}),u=async()=>{a.abort(),await bn(l)};try{let s=await yn(e,t,n,a.signal,i,r,o);if(await u(),!s.completed){let e=s.error??`Session did not reach idle state`;return i.error(`Session completion polling failed`,{error:e,sessionId:t}),{success:!1,error:e,llmError:c.llmError,shouldRetry:c.llmError!=null,eventStreamResult:c}}return{success:!0,error:null,llmError:null,shouldRetry:!1,eventStreamResult:c}}finally{a.abort(),await bn(l)}}const Fn=e=>{if(e?.model!=null)return{providerID:e.model.providerID,modelID:e.model.modelID};if(!(e!=null&&Object.values(e.omoProviders).some(e=>e!==`no`)))return{providerID:de.providerID,modelID:de.modelID}};async function In(e,t,n,r,i,a,o){let s={parts:[{type:`text`,text:n},...r??[]]},c=Fn(a);c!=null&&(s.model=c);let l=a?.agent??`sisyphus`;l!==`sisyphus`&&(s.agent=l);let u=await e.session.promptAsync({path:{id:t},body:s,query:{directory:i}});if(u.error!=null){let e=String(u.error),t=gn(u.error)?_n(e):null;return{success:!1,error:e,llmError:t,shouldRetry:t!=null,eventStreamResult:{tokens:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:t}}}return Pn(e,t,i,a?.timeoutMs??18e5,o)}function Ln(){return[`## Critical Rules (NON-NEGOTIABLE)`,`- You are a NON-INTERACTIVE CI agent. Do NOT ask questions. Make decisions autonomously.`,`- Post EXACTLY ONE comment or review per invocation. Never multiple.`,`- Include the Run Summary marker block in your comment.`,"- Use `gh` CLI for all GitHub operations. Do not use the GitHub API directly.",`- Mark your comment with the bot identification marker.`].join(` +`)}function Rn(e,t,n){if(e==null)return``;let r=[`## Thread Identity`];return r.push(`**Logical Thread**: \`${e.key}\` (${e.entityType} #${e.entityId})`),t?(r.push(`**Status**: Continuing previous conversation thread.`),n!=null&&n.length>0&&(r.push(``),r.push(`**Thread Summary**:`),r.push(n))):r.push(`**Status**: Fresh conversation — no prior thread found for this entity.`),r.join(` +`)}function zn(e){return e==null||e.length===0?``:[`## Current Thread Context`,`This is work from your PREVIOUS runs on this same entity:`,``,e].join(` +`)}function Bn(){return[`## Reminder: Critical Rules`,"- ONE comment/review only. Include Run Summary marker. Use `gh` CLI only."].join(` +`)}function Vn(e,t){switch(e.eventType){case`issue_comment`:return{directive:`Respond to the comment above. Post your response as a single comment on this thread.`,appendMode:!0};case`discussion_comment`:return{directive:`Respond to the discussion comment above. Post your response as a single comment.`,appendMode:!0};case`issues`:return e.action===`opened`?{directive:`Triage this issue: summarize, reproduce if possible, propose next steps. Post your response as a single comment.`,appendMode:!0}:{directive:`Respond to the mention in this issue. Post your response as a single comment.`,appendMode:!0};case`pull_request`:return{directive:[`Review this pull request for code quality, potential bugs, and improvements.`,"If you are a requested reviewer, submit a review via `gh pr review` with your full response (including Run Summary) in the --body.",`Include the Run Summary in the review body. Do not post a separate comment.`,`If the author is a collaborator, prioritize actionable feedback over style nits.`].join(` +`),appendMode:!0};case`pull_request_review_comment`:return{directive:Hn(e),appendMode:!0};case`schedule`:case`workflow_dispatch`:return{directive:t??``,appendMode:!1};default:return{directive:`Execute the requested operation.`,appendMode:!0}}}function Hn(e){let t=e.target,n=[`Respond to the review comment.`,``];return t?.path!=null&&n.push(`**File:** \`${t.path}\``),t?.line!=null&&n.push(`**Line:** ${t.line}`),t?.commitId!=null&&n.push(`**Commit:** \`${t.commitId}\``),t?.diffHunk!=null&&t.diffHunk.length>0&&n.push(``,`**Diff Context:**`,"```diff",t.diffHunk,"```"),n.join(` +`)}function Un(e,t){let{directive:n,appendMode:r}=Vn(e,t),i=[`## Task`,``];return r?(i.push(n),t!=null&&t.trim().length>0&&i.push(``,`**Additional Instructions:**`,t.trim())):i.push(n),i.push(``),i.join(` +`)}function Wn(e,t){let{context:n,customPrompt:r,cacheStatus:i,sessionContext:a,logicalKey:o,isContinuation:s,currentThreadSessionId:c}=e,l=[],u=s===!0;l.push(Ln());let d=Rn(o??null,u,null);d.length>0&&l.push(d);let f=a!=null&&u&&c!=null?qn(a.priorWorkContext,c):null;e.triggerContext==null?n.commentBody==null?l.push(`## Task Execute the requested operation for repository ${n.repo}. Follow all instructions and requirements listed in this prompt. `):l.push(`## Task Respond to the trigger comment above. Follow all instructions and requirements listed in this prompt. -`):l.push(Vn(e.triggerContext,r));let p=r?.trim()??null,m=n.commentBody?.trim()??null,h=p!=null&&p.length>0&&m!=null&&m.length>0&&p===m;n.commentBody!=null&&!h&&l.push(`## Trigger Comment +`):l.push(Un(e.triggerContext,r));let p=r?.trim()??null,m=n.commentBody?.trim()??null,h=p!=null&&p.length>0&&m!=null&&m.length>0&&p===m;n.commentBody!=null&&!h&&l.push(`## Trigger Comment **Author:** ${n.commentAuthor??`unknown`} \`\`\` ${n.commentBody} \`\`\` -`);let g=Ln(f);if(g.length>0&&l.push(g),r!=null&&r.trim().length>0&&e.triggerContext==null&&l.push(` +`);let g=zn(f);if(g.length>0&&l.push(g),r!=null&&r.trim().length>0&&e.triggerContext==null&&l.push(` ${r.trim()} -`),e.triggerContext!=null){let t=e.triggerContext.eventType;(t===`pull_request`||t===`pull_request_review_comment`)&&l.push(Jn(n))}if(l.push(` +`),e.triggerContext!=null){let t=e.triggerContext.eventType;(t===`pull_request`||t===`pull_request_review_comment`)&&l.push(Xn(n))}if(l.push(` ## Environment - **Repository:** ${n.repo} - **Branch/Ref:** ${n.ref} @@ -159,7 +159,7 @@ ${r.trim()} - **Number:** #${n.issueNumber} - **Title:** ${n.issueTitle??`N/A`} - **Type:** ${n.issueType??`unknown`} -`)}if(n.diffContext!=null&&l.push(qn(n.diffContext)),n.hydratedContext!=null&&l.push(Qe(n.hydratedContext)),a!=null){let e=Kn(a,u,c,f!=null);e!=null&&l.push(e)}l.push(`# Agent Context +`)}if(n.diffContext!=null&&l.push(Yn(n.diffContext)),n.hydratedContext!=null&&l.push(Ze(n.hydratedContext)),a!=null){let e=Jn(a,u,c,f!=null);e!=null&&l.push(e)}l.push(`# Agent Context You are the Fro Bot Agent running in a non-interactive CI environment (GitHub Actions). @@ -180,7 +180,7 @@ Before completing: 1. Ensure your session contains a summary of work done 2. Include key decisions, findings, and outcomes 3. This summary will be searchable in future agent runs -`),n.issueNumber!=null&&l.push(Un(n,i,e.sessionId));let _=n.issueNumber??``,v=n.issueNumber!=null;l.push(`## GitHub Operations (Use gh CLI) +`),n.issueNumber!=null&&l.push(Gn(n,i,e.sessionId));let _=n.issueNumber??``,v=n.issueNumber!=null;l.push(`## GitHub Operations (Use gh CLI) The \`gh\` CLI is pre-authenticated. Use it for all GitHub operations. ${v?` @@ -216,8 +216,8 @@ git push origin HEAD gh api repos/${n.repo}/issues --jq '.[].title' gh api repos/${n.repo}/pulls/${_}/files --jq '.[].filename' \`\`\` -`),l.push(Rn());let y=l.join(` -`);return t.debug(`Built agent prompt`,{length:y.length,hasCustom:r!=null,hasSessionContext:a!=null}),y}function Un(e,t,n){let r=e.issueNumber??``;return`## Response Protocol (REQUIRED) +`),l.push(Bn());let y=l.join(` +`);return t.debug(`Built agent prompt`,{length:y.length,hasCustom:r!=null,hasSessionContext:a!=null}),y}function Gn(e,t,n){let r=e.issueNumber??``;return`## Response Protocol (REQUIRED) You MUST post exactly ONE comment or review per invocation. All of your output — your response content AND the Run Summary — goes into that single artifact. @@ -253,17 +253,17 @@ Every response you post — regardless of channel (issue, PR, discussion, review \`\`\` -`}function Wn(e,t,n){let r=[t];if(e.recentSessions.length>0){r.push(``),r.push(`### Recent Sessions`),r.push(`| ID | Title | Updated | Messages | Agents |`),r.push(`|----|-------|---------|----------|--------|`);for(let t of e.recentSessions.slice(0,5)){let e=new Date(t.updatedAt).toISOString().split(`T`)[0],n=t.agents.join(`, `)||`N/A`,i=t.title||`Untitled`;r.push(`| ${t.id} | ${i} | ${e} | ${t.messageCount} | ${n} |`)}r.push(``),r.push("Use `session_read` to review any of these sessions in detail.")}if(n.length>0){r.push(``),r.push(`### Relevant Prior Work`),r.push(``),r.push(`The following sessions contain content related to this issue:`),r.push(``);for(let e of n.slice(0,3)){r.push(`**Session ${e.sessionId}:**`),r.push("```markdown");for(let t of e.matches.slice(0,2))r.push(`- ${t.excerpt}`);r.push("```"),r.push(``)}r.push("Use `session_read` to review full context before starting new investigation.")}return r.push(``),r.join(` -`)}function Gn(e,t){let n=e.filter(e=>e.sessionId===t);if(n.length===0)return null;let r=[];for(let e of n.slice(0,1)){r.push(`**Session ${e.sessionId}:**`),r.push("```markdown");for(let t of e.matches.slice(0,3))r.push(`- ${t.excerpt}`);r.push("```")}return r.join(` -`)}function Kn(e,t,n,r){if(t&&n!=null){let t=e.priorWorkContext.filter(e=>e.sessionId!==n);return e.recentSessions.length===0&&t.length===0?null:Wn(e,`## Related Historical Context`,t)}return e.recentSessions.length===0&&e.priorWorkContext.length===0&&r?null:Wn(e,`## Prior Session Context`,e.priorWorkContext)}function qn(e){let t=[`## Pull Request Diff Summary`];if(t.push(``),t.push(`- **Changed Files:** ${e.changedFiles}`),t.push(`- **Additions:** +${e.additions}`),t.push(`- **Deletions:** -${e.deletions}`),e.truncated&&t.push(`- **Note:** Diff was truncated due to size limits`),e.files.length>0){t.push(``),t.push(`### Changed Files`),t.push(`| File | Status | +/- |`),t.push(`|------|--------|-----|`);for(let n of e.files.slice(0,20))t.push(`| \`${n.filename}\` | ${n.status} | +${n.additions}/-${n.deletions} |`);e.files.length>20&&t.push(`| ... | | +${e.files.length-20} more files |`)}return t.push(``),t.join(` -`)}function Jn(e){let t=[`## Output Contract`,``];return t.push(`- Review action: approve/request-changes if confident; otherwise comment-only`),t.push(`- Requested reviewer: ${e.isRequestedReviewer?`yes`:`no`}`),e.authorAssociation!=null&&t.push(`- Author association: ${e.authorAssociation}`),t.push(``),t.join(` -`)}async function Yn(e,t,n,r){let i=Date.now(),a=new AbortController,o=n?.timeoutMs??18e5,s=null,c=!1,l=r==null,u=null;o>0&&(s=setTimeout(()=>{c=!0,t.warning(`Execution timeout reached`,{timeoutMs:o}),a.abort()},o)),t.info(`Executing OpenCode agent (SDK mode)`,{agent:n?.agent??`sisyphus`,hasModelOverride:n?.model!=null,timeoutMs:o});try{let s;if(r==null){let e=await on({signal:a.signal});s=e.client,u=e.server}else s=r.client;let l;if(n?.continueSessionId==null){let e=n?.sessionTitle==null?void 0:{body:{title:n.sessionTitle}},r=e==null?await s.session.create():await s.session.create(e);if(r.data==null||r.error!=null)throw Error(`Failed to create session: ${r.error==null?`No data returned`:String(r.error)}`);l=r.data.id,t.info(`Created new OpenCode session`,{sessionId:l,sessionTitle:n?.sessionTitle??null})}else l=n.continueSessionId,t.info(`Continuing existing OpenCode session`,{sessionId:l});let d=Hn({...e,sessionId:l},t),f=se();if(ge()){let e=k(),n=Se.createHash(`sha256`).update(d).digest(`hex`),r=L.join(e,`prompt-${l}-${n.slice(0,8)}.txt`);try{await I.mkdir(e,{recursive:!0}),await I.writeFile(r,d,`utf8`),t.info(`Prompt artifact written`,{hash:n,path:r})}catch(e){t.warning(`Failed to write prompt artifact`,{error:e instanceof Error?e.message:String(e),path:r})}}let p={tokens:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:null},m=null,h=null;for(let r=1;r<=3;r++){if(c)return{success:!1,exitCode:130,duration:Date.now()-i,sessionId:l,error:`Execution timed out after ${o}ms`,tokenUsage:p.tokens,model:p.model,cost:p.cost,prsCreated:p.prsCreated,commitsCreated:p.commitsCreated,commentsPosted:p.commentsPosted,llmError:h};if(o>0&&o-(Date.now()-i)<=5e3&&r>1)break;let a=r===1?d:`The previous request was interrupted by a network error (fetch failed). +`}function Kn(e,t,n){let r=[t];if(e.recentSessions.length>0){r.push(``),r.push(`### Recent Sessions`),r.push(`| ID | Title | Updated | Messages | Agents |`),r.push(`|----|-------|---------|----------|--------|`);for(let t of e.recentSessions.slice(0,5)){let e=new Date(t.updatedAt).toISOString().split(`T`)[0],n=t.agents.join(`, `)||`N/A`,i=t.title||`Untitled`;r.push(`| ${t.id} | ${i} | ${e} | ${t.messageCount} | ${n} |`)}r.push(``),r.push("Use `session_read` to review any of these sessions in detail.")}if(n.length>0){r.push(``),r.push(`### Relevant Prior Work`),r.push(``),r.push(`The following sessions contain content related to this issue:`),r.push(``);for(let e of n.slice(0,3)){r.push(`**Session ${e.sessionId}:**`),r.push("```markdown");for(let t of e.matches.slice(0,2))r.push(`- ${t.excerpt}`);r.push("```"),r.push(``)}r.push("Use `session_read` to review full context before starting new investigation.")}return r.push(``),r.join(` +`)}function qn(e,t){let n=e.filter(e=>e.sessionId===t);if(n.length===0)return null;let r=[];for(let e of n.slice(0,1)){r.push(`**Session ${e.sessionId}:**`),r.push("```markdown");for(let t of e.matches.slice(0,3))r.push(`- ${t.excerpt}`);r.push("```")}return r.join(` +`)}function Jn(e,t,n,r){if(t&&n!=null){let t=e.priorWorkContext.filter(e=>e.sessionId!==n);return e.recentSessions.length===0&&t.length===0?null:Kn(e,`## Related Historical Context`,t)}return e.recentSessions.length===0&&e.priorWorkContext.length===0&&r?null:Kn(e,`## Prior Session Context`,e.priorWorkContext)}function Yn(e){let t=[`## Pull Request Diff Summary`];if(t.push(``),t.push(`- **Changed Files:** ${e.changedFiles}`),t.push(`- **Additions:** +${e.additions}`),t.push(`- **Deletions:** -${e.deletions}`),e.truncated&&t.push(`- **Note:** Diff was truncated due to size limits`),e.files.length>0){t.push(``),t.push(`### Changed Files`),t.push(`| File | Status | +/- |`),t.push(`|------|--------|-----|`);for(let n of e.files.slice(0,20))t.push(`| \`${n.filename}\` | ${n.status} | +${n.additions}/-${n.deletions} |`);e.files.length>20&&t.push(`| ... | | +${e.files.length-20} more files |`)}return t.push(``),t.join(` +`)}function Xn(e){let t=[`## Output Contract`,``];return t.push(`- Review action: approve/request-changes if confident; otherwise comment-only`),t.push(`- Requested reviewer: ${e.isRequestedReviewer?`yes`:`no`}`),e.authorAssociation!=null&&t.push(`- Author association: ${e.authorAssociation}`),t.push(``),t.join(` +`)}async function Zn(e,t,n,r){let i=Date.now(),a=new AbortController,o=n?.timeoutMs??18e5,s=null,c=!1,l=r==null,u=null;o>0&&(s=setTimeout(()=>{c=!0,t.warning(`Execution timeout reached`,{timeoutMs:o}),a.abort()},o)),t.info(`Executing OpenCode agent (SDK mode)`,{agent:n?.agent??`sisyphus`,hasModelOverride:n?.model!=null,timeoutMs:o});try{let s;if(r==null){let e=await cn({signal:a.signal});s=e.client,u=e.server}else s=r.client;let l;if(n?.continueSessionId==null){let e=n?.sessionTitle==null?void 0:{body:{title:n.sessionTitle}},r=e==null?await s.session.create():await s.session.create(e);if(r.data==null||r.error!=null)throw Error(`Failed to create session: ${r.error==null?`No data returned`:String(r.error)}`);l=r.data.id,t.info(`Created new OpenCode session`,{sessionId:l,sessionTitle:n?.sessionTitle??null})}else l=n.continueSessionId,t.info(`Continuing existing OpenCode session`,{sessionId:l});let d=Wn({...e,sessionId:l},t),f=P();if(pe()){let e=j(),n=ye.createHash(`sha256`).update(d).digest(`hex`),r=B.join(e,`prompt-${l}-${n.slice(0,8)}.txt`);try{await z.mkdir(e,{recursive:!0}),await z.writeFile(r,d,`utf8`),t.info(`Prompt artifact written`,{hash:n,path:r})}catch(e){t.warning(`Failed to write prompt artifact`,{error:e instanceof Error?e.message:String(e),path:r})}}let p={tokens:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:null},m=null,h=null;for(let r=1;r<=3;r++){if(c)return{success:!1,exitCode:130,duration:Date.now()-i,sessionId:l,error:`Execution timed out after ${o}ms`,tokenUsage:p.tokens,model:p.model,cost:p.cost,prsCreated:p.prsCreated,commitsCreated:p.commitsCreated,commentsPosted:p.commentsPosted,llmError:h};if(o>0&&o-(Date.now()-i)<=5e3&&r>1)break;let a=r===1?d:`The previous request was interrupted by a network error (fetch failed). Please continue where you left off. If you were in the middle of a task, resume it. -If you had completed the task, confirm the completion.`,u=r===1?e.fileParts:void 0,g=await(async()=>{try{return await Pn(s,l,a,u,f,n,t)}finally{await sn(s,l,n?.sessionTitle,t)}})();if(g.success)return p=g.eventStreamResult,{success:!0,exitCode:0,duration:Date.now()-i,sessionId:l,error:null,tokenUsage:p.tokens,model:p.model,cost:p.cost,prsCreated:p.prsCreated,commitsCreated:p.commitsCreated,commentsPosted:p.commentsPosted,llmError:null};if(m=g.error,h=g.llmError,!g.shouldRetry||r>=3)break;t.warning(`LLM fetch error detected, retrying with continuation prompt`,{attempt:r,maxAttempts:3,error:g.error,delayMs:jn,sessionId:l}),await cn(jn)}return{success:!1,exitCode:1,duration:Date.now()-i,sessionId:l,error:m??`Unknown error`,tokenUsage:p.tokens,model:p.model,cost:p.cost,prsCreated:p.prsCreated,commitsCreated:p.commitsCreated,commentsPosted:p.commentsPosted,llmError:h}}catch(e){let n=Date.now()-i,r=A(e);return t.error(`OpenCode execution failed`,{error:r,durationMs:n}),{success:!1,exitCode:1,duration:n,sessionId:null,error:r,tokenUsage:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:mn(e)?hn(r):null}}finally{s!=null&&clearTimeout(s),a.abort(),l&&u?.close()}}async function Xn(e,t,n){return t.commentId==null?(n.debug(`No comment ID, skipping eyes reaction`),!1):await Ie(e,t.repo,t.commentId,`eyes`,n)==null?!1:(n.info(`Added eyes reaction`,{commentId:t.commentId}),!0)}async function Zn(e,t,n){return t.issueNumber==null?(n.debug(`No issue number, skipping working label`),!1):await ze(e,t.repo,`agent: working`,`fcf2e1`,`Agent is currently working on this`,n)&&await Be(e,t.repo,t.issueNumber,[`agent: working`],n)?(n.info(`Added working label`,{issueNumber:t.issueNumber}),!0):!1}async function Qn(e,t,n){await Promise.all([Xn(e,t,n),Zn(e,t,n)])}async function $n(e,t,n){if(t.commentId==null||t.botLogin==null)return;let r=(await Le(e,t.repo,t.commentId,n)).find(e=>e.content===`eyes`&&e.userLogin===t.botLogin);r!=null&&await Re(e,t.repo,t.commentId,r.id,n)}async function er(e,t,n,r){t.commentId!=null&&await Ie(e,t.repo,t.commentId,n,r)}async function tr(e,t,n){if(t.commentId==null||t.botLogin==null){n.debug(`Missing comment ID or bot login, skipping reaction update`);return}try{await $n(e,t,n),await er(e,t,`hooray`,n),n.info(`Updated reaction to success indicator`,{commentId:t.commentId,reaction:`hooray`})}catch(e){n.warning(`Failed to update reaction (non-fatal)`,{error:A(e)})}}async function nr(e,t,n){if(t.commentId==null||t.botLogin==null){n.debug(`Missing comment ID or bot login, skipping reaction update`);return}try{await $n(e,t,n),await er(e,t,`confused`,n),n.info(`Updated reaction to confused`,{commentId:t.commentId})}catch(e){n.warning(`Failed to update failure reaction (non-fatal)`,{error:A(e)})}}async function rr(e,t,n){if(t.issueNumber==null){n.debug(`No issue number, skipping label removal`);return}await Ve(e,t.repo,t.issueNumber,`agent: working`,n)&&n.info(`Removed working label`,{issueNumber:t.issueNumber})}async function ir(e,t,n,r){n?await tr(e,t,r):await nr(e,t,r),await rr(e,t,r)}var G=C(E(),1),ar=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},or=class{constructor(e,t,n){if(e<1)throw Error(`max attempts should be greater than or equal to 1`);if(this.maxAttempts=e,this.minSeconds=Math.floor(t),this.maxSeconds=Math.floor(n),this.minSeconds>this.maxSeconds)throw Error(`min seconds should be less than or equal to max seconds`)}execute(e,t){return ar(this,void 0,void 0,function*(){let n=1;for(;nsetTimeout(t,e*1e3))})}},K=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},sr=class extends Error{constructor(e){super(`Unexpected HTTP response: ${e}`),this.httpStatusCode=e,Object.setPrototypeOf(this,new.target.prototype)}};const cr=process.platform===`win32`;process.platform;function lr(e,t,n,r){return K(this,void 0,void 0,function*(){return t||=F.join(wr(),ve.randomUUID()),yield l(F.dirname(t)),f(`Downloading ${e}`),f(`Destination ${t}`),yield new or(3,Tr(`TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS`,10),Tr(`TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS`,20)).execute(()=>K(this,void 0,void 0,function*(){return yield ur(e,t||``,n,r)}),e=>!(e instanceof sr&&e.httpStatusCode&&e.httpStatusCode<500&&e.httpStatusCode!==408&&e.httpStatusCode!==429))})}function ur(e,t,n,r){return K(this,void 0,void 0,function*(){if(P.existsSync(t))throw Error(`Destination file path ${t} already exists`);let i=new x(`actions/tool-cache`,[],{allowRetries:!1});n&&(f(`set auth`),r===void 0&&(r={}),r.authorization=n);let a=yield i.get(e,r);if(a.message.statusCode!==200){let t=new sr(a.message.statusCode);throw f(`Failed to download from "${e}". Code(${a.message.statusCode}) Message(${a.message.statusMessage})`),t}let o=be.promisify(je.pipeline),s=Tr(`TEST_DOWNLOAD_TOOL_RESPONSE_MESSAGE_FACTORY`,()=>a.message)(),c=!1;try{return yield o(s,P.createWriteStream(t)),f(`download complete`),c=!0,t}finally{if(!c){f(`download failed`);try{yield ce(t)}catch(e){f(`Failed to delete '${t}'. ${e.message}`)}}}})}function dr(e,t){return K(this,arguments,void 0,function*(e,t,n=`xz`){if(!e)throw Error(`parameter 'file' is required`);t=yield vr(t),f(`Checking tar --version`);let r=``;yield v(`tar --version`,[],{ignoreReturnCode:!0,silent:!0,listeners:{stdout:e=>r+=e.toString(),stderr:e=>r+=e.toString()}}),f(r.trim());let i=r.toUpperCase().includes(`GNU TAR`),a;a=n instanceof Array?n:[n],h()&&!n.includes(`v`)&&a.push(`-v`);let o=t,s=e;return cr&&i&&(a.push(`--force-local`),o=t.replace(/\\/g,`/`),s=e.replace(/\\/g,`/`)),i&&(a.push(`--warning=no-unknown-keyword`),a.push(`--overwrite`)),a.push(`-C`,o,`-f`,s),yield v(`tar`,a),t})}function fr(e,t){return K(this,void 0,void 0,function*(){if(!e)throw Error(`parameter 'file' is required`);return t=yield vr(t),cr?yield pr(e,t):yield mr(e,t),t})}function pr(e,t){return K(this,void 0,void 0,function*(){let n=e.replace(/'/g,`''`).replace(/"|\n|\r/g,``),r=t.replace(/'/g,`''`).replace(/"|\n|\r/g,``),i=yield c(`pwsh`,!1);if(i){let e=[`-NoLogo`,`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Unrestricted`,`-Command`,[`$ErrorActionPreference = 'Stop' ;`,`try { Add-Type -AssemblyName System.IO.Compression.ZipFile } catch { } ;`,`try { [System.IO.Compression.ZipFile]::ExtractToDirectory('${n}', '${r}', $true) }`,`catch { if (($_.Exception.GetType().FullName -eq 'System.Management.Automation.MethodException') -or ($_.Exception.GetType().FullName -eq 'System.Management.Automation.RuntimeException') ){ Expand-Archive -LiteralPath '${n}' -DestinationPath '${r}' -Force } else { throw $_ } } ;`].join(` `)];f(`Using pwsh at path: ${i}`),yield v(`"${i}"`,e)}else{let e=[`-NoLogo`,`-Sta`,`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Unrestricted`,`-Command`,[`$ErrorActionPreference = 'Stop' ;`,`try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ;`,`if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath '${n}' -DestinationPath '${r}' -Force }`,`else {[System.IO.Compression.ZipFile]::ExtractToDirectory('${n}', '${r}', $true) }`].join(` `)],t=yield c(`powershell`,!0);f(`Using powershell at path: ${t}`),yield v(`"${t}"`,e)}})}function mr(e,t){return K(this,void 0,void 0,function*(){let n=yield c(`unzip`,!0),r=[e];h()||r.unshift(`-q`),r.unshift(`-o`),yield v(`"${n}"`,r,{cwd:t})})}function hr(e,t,n,r){return K(this,void 0,void 0,function*(){if(n=G.clean(n)||n,r||=_e.arch(),f(`Caching tool ${t} ${n} ${r}`),f(`source dir: ${e}`),!P.statSync(e).isDirectory())throw Error(`sourceDir is not a directory`);let i=yield yr(t,n,r);for(let t of P.readdirSync(e))yield o(F.join(e,t),i,{recursive:!0});return br(t,n,r),i})}function gr(e,t,n){if(!e)throw Error(`toolName parameter is required`);if(!t)throw Error(`versionSpec parameter is required`);n||=_e.arch(),xr(t)||(t=Sr(_r(e,n),t));let r=``;if(t){t=G.clean(t)||``;let i=F.join(Cr(),e,t,n);f(`checking cache: ${i}`),P.existsSync(i)&&P.existsSync(`${i}.complete`)?(f(`Found tool in cache ${e} ${t} ${n}`),r=i):f(`not found`)}return r}function _r(e,t){let n=[];t||=_e.arch();let r=F.join(Cr(),e);if(P.existsSync(r)){let e=P.readdirSync(r);for(let i of e)if(xr(i)){let e=F.join(r,i,t||``);P.existsSync(e)&&P.existsSync(`${e}.complete`)&&n.push(i)}}return n}function vr(e){return K(this,void 0,void 0,function*(){return e||=F.join(wr(),ve.randomUUID()),yield l(e),e})}function yr(e,t,n){return K(this,void 0,void 0,function*(){let r=F.join(Cr(),e,G.clean(t)||t,n||``);f(`destination ${r}`);let i=`${r}.complete`;return yield ce(r),yield ce(i),yield l(r),r})}function br(e,t,n){let r=`${F.join(Cr(),e,G.clean(t)||t,n||``)}.complete`;P.writeFileSync(r,``),f(`finished caching tool`)}function xr(e){let t=G.clean(e)||``;f(`isExplicit: ${t}`);let n=G.valid(t)!=null;return f(`explicit? ${n}`),n}function Sr(e,t){let n=``;f(`evaluating ${e.length} versions`),e=e.sort((e,t)=>G.gt(e,t)?1:-1);for(let r=e.length-1;r>=0;r--){let i=e[r];if(G.satisfies(i,t)){n=i;break}}return f(n?`matched: ${n}`:`match not found`),n}function Cr(){let e=process.env.RUNNER_TOOL_CACHE||``;return ye(e,`Expected RUNNER_TOOL_CACHE to be defined`),e}function wr(){let e=process.env.RUNNER_TEMP||``;return ye(e,`Expected RUNNER_TEMP to be defined`),e}function Tr(e,t){let n=global[e];return n===void 0?t:n}function Er(e){let t;try{t=JSON.parse(e)}catch(e){throw e instanceof SyntaxError?Error(`Invalid auth-json format: ${e.message}`):e}if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`auth-json must be a JSON object`);return t}async function Dr(e,t,n){let r=L.join(t,`auth.json`);await I.mkdir(t,{recursive:!0});let i=JSON.stringify(e,null,2);return await I.writeFile(r,i,{mode:384}),n.info(`Populated auth.json`,{path:r,providers:Object.keys(e).length}),r}function Or(){let e=N.platform,t=N.arch;return{os:{darwin:`darwin`,linux:`linux`,win32:`windows`}[e]??`linux`,arch:{arm64:`aarch64`,x64:`x64`}[t]??`x64`,ext:`.zip`}}function kr(e,t){return`https://github.com/oven-sh/bun/releases/download/bun-${e.startsWith(`v`)?e:`v${e}`}/${`bun-${t.os}-${t.arch}${t.ext}`}`}async function Ar(e,t,n,r,i=g){let a=Or(),o=t.find(`bun`,i,a.arch);if(o.length>0)return e.info(`Bun found in cache`,{version:i,path:o}),r(o),await Mr(o),{path:o,version:i,cached:!0};e.info(`Downloading Bun`,{version:i});let s=kr(i,a);try{let o=await t.downloadTool(s);if(N.platform!==`win32`&&!await Nr(o,e,n))throw Error(`Downloaded Bun archive appears corrupted`);e.info(`Extracting Bun`);let c=await jr(await t.extractZip(o),t),l=Ee.dirname(c);e.info(`Caching Bun`);let u=await t.cacheDir(l,`bun`,i,a.arch);return r(u),await Mr(u),e.info(`Bun installed`,{version:i,path:u}),{path:u,version:i,cached:!1}}catch(e){let t=A(e);throw Error(`Failed to install Bun ${i}: ${t}`)}}async function jr(e,t){for(let n of await Te.readdir(e,{withFileTypes:!0})){let{name:r}=n,i=Ee.join(e,r);if(n.isFile()){if(r===`bun`||r===`bun.exe`)return i;if(/^bun.*\.zip/.test(r))return jr(await t.extractZip(i),t)}if(r.startsWith(`bun`)&&n.isDirectory())return jr(i,t)}throw Error(`Could not find executable: bun`)}async function Mr(e){let t=e=>N.platform===`win32`?`${e}.exe`:e,n=Ee.join(e,t(`bun`));try{await Te.symlink(n,Ee.join(e,t(`bunx`)))}catch(e){let t=typeof e==`object`?e.code:void 0;if(t!==`EEXIST`&&t!==`EPERM`&&t!==`EACCES`)throw e}}async function Nr(e,t,n){try{let{stdout:r}=await n.getExecOutput(`file`,[e],{silent:!0}),i=r.includes(`Zip archive`)||r.includes(`ZIP`);return i||t.warning(`Bun download validation failed`,{output:r.trim()}),i}catch{return t.debug(`Could not validate Bun download (file command unavailable)`),!0}}function Pr(e){return{debug:t=>e.debug(t),info:t=>e.info(t),warn:t=>e.warning(t),error:t=>e.error(t)}}function Fr(e){let{token:t,logger:n}=e;return n.debug(`Creating GitHub client with token`),fe(t,{log:Pr(n)})}async function Ir(e,t){try{let{data:n}=await e.rest.users.getAuthenticated();return t.debug(`Authenticated as`,{login:n.login,type:n.type}),n.login}catch{return t.debug(`Failed to get authenticated user, may be app token`),`fro-bot[bot]`}}async function Lr(e,t,n,r){let i=t??n,a=t==null?n.length>0?`github-token`:`none`:`app-token`;if(i.length===0)return r.warning(`No GitHub token available`),{authenticated:!1,method:`none`,botLogin:null};N.env.GH_TOKEN=i,r.info(`Configured authentication`,{method:a});let o=null;return e!=null&&(o=await Ir(e,r)),{authenticated:!0,method:a,botLogin:o}}async function Rr(e,t){let n=await t.getExecOutput(`git`,[`config`,e],{ignoreReturnCode:!0,silent:!0});return n.exitCode===0&&n.stdout.trim().length>0?n.stdout.trim():null}async function zr(e,t,n,r){let i=await Rr(`user.name`,r),a=await Rr(`user.email`,r);if(i!=null&&a!=null){n.info(`Git identity already configured`,{name:i,email:a});return}if(t==null)throw Error(`Cannot configure Git identity: no authenticated GitHub user`);let o=null;if(a==null){let r=await Ge(e,t,n);if(r==null)throw Error(`Cannot configure Git identity: failed to look up user ID for '${t}'`);o=String(r.id)}i??await r.exec(`git`,[`config`,`--global`,`user.name`,t],void 0);let s=`${o}+${t}@users.noreply.github.com`;a??await r.exec(`git`,[`config`,`--global`,`user.email`,s],void 0),n.info(`Configured git identity`,{name:i??t,email:a??s})}const Br=new Set([`__proto__`,`prototype`,`constructor`]);function Vr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Hr(e,t){let n=Object.create(null);for(let[t,r]of Object.entries(e))Br.has(t)||(n[t]=r);for(let[e,r]of Object.entries(t)){if(Br.has(e))continue;let t=n[e];Vr(r)&&Vr(t)?n[e]=Hr(t,r):n[e]=r}return n}async function Ur(e,t,n){let r=JSON.parse(e);if(!Vr(r))throw Error(`omo-config must be a JSON object (non-null, non-array)`);let i=r;await I.mkdir(t,{recursive:!0});let a=L.join(t,`oh-my-opencode.json`),o={};try{let e=await I.readFile(a,`utf8`),t=JSON.parse(e);typeof t==`object`&&t&&!Array.isArray(t)&&(o=t)}catch(e){n.debug(`Using empty base oMo config`,{path:a,error:String(e)})}let s=Hr(o,i);await I.writeFile(a,JSON.stringify(s,null,2)),n.info(`Wrote oMo config`,{path:a,keyCount:Object.keys(i).length})}async function Wr(e,t,n={}){let{logger:r,execAdapter:i}=t,{claude:a=`no`,copilot:o=`no`,gemini:s=`no`,openai:c=`no`,opencodeZen:l=`no`,zaiCodingPlan:u=`no`,kimiForCoding:d=`no`}=n;r.info(`Installing Oh My OpenAgent plugin`,{version:e,claude:a,copilot:o,gemini:s,openai:c,opencodeZen:l,zaiCodingPlan:u,kimiForCoding:d});let f=``,p=[`oh-my-openagent@${e}`,`install`,`--no-tui`,`--skip-auth`,`--claude=${a}`,`--copilot=${o}`,`--gemini=${s}`,`--openai=${c}`,`--opencode-zen=${l}`,`--zai-coding-plan=${u}`,`--kimi-for-coding=${d}`];try{let t=await i.exec(`bunx`,p,{listeners:{stdout:e=>{f+=e.toString()},stderr:e=>{f+=e.toString()}},ignoreReturnCode:!0});if(t!==0){let e=`bunx oh-my-openagent install returned exit code ${t}`;return r.error(e,{output:f.slice(0,1e3)}),{installed:!1,version:null,error:`${e}\n${f.slice(0,500)}`}}let n=/oh-my-opencode@(\d+\.\d+\.\d+)/i.exec(f),a=n!=null&&n[1]!=null?n[1]:e;return r.info(`oMo plugin installed`,{version:a}),{installed:!0,version:a,error:null}}catch(e){let t=A(e),n=f.length>0?`${t}\nOutput: ${f.slice(0,500)}`:t;return r.error(`Failed to run oMo installer`,{error:t,output:f.slice(0,500)}),{installed:!1,version:null,error:`bunx oh-my-openagent install failed: ${n}`}}}const Gr=`opencode`,Kr=i;function qr(){let e=ke.platform(),t=ke.arch(),n={darwin:`darwin`,linux:`linux`,win32:`windows`},r={x64:`x64`,arm64:`arm64`},i=e===`win32`||e===`darwin`?`.zip`:`.tar.gz`;return{os:n[e]??`linux`,arch:r[t]??`x64`,ext:i}}function Jr(e,t){return`https://github.com/anomalyco/opencode/releases/download/${e.startsWith(`v`)?e:`v${e}`}/${`opencode-${t.os}-${t.arch}${t.ext}`}`}async function Yr(e,t,n,r){if(N.platform===`win32`)return!0;try{let{stdout:i}=await r.getExecOutput(`file`,[e],{silent:!0}),a=(t===`.zip`?[`Zip archive`,`ZIP`]:[`gzip`,`tar`,`compressed`]).some(e=>i.includes(e));return a||n.warning(`Download validation failed`,{output:i.trim()}),a}catch{return n.debug(`Could not validate download (file command unavailable)`),!0}}async function Xr(e,t,n,r,i=Kr){let a=qr(),o=n.find(Gr,e,a.arch);if(o.length>0)return t.info(`OpenCode found in cache`,{version:e,path:o}),{path:o,version:e,cached:!0};try{return await Zr(e,a,t,n,r)}catch(n){t.warning(`Primary version install failed, trying fallback`,{requestedVersion:e,fallbackVersion:i,error:A(n)})}if(e!==i)try{let e=await Zr(i,a,t,n,r);return t.info(`Installed fallback version`,{version:i}),e}catch(t){throw Error(`Failed to install OpenCode (tried ${e} and ${i}): ${A(t)}`)}throw Error(`Failed to install OpenCode version ${e}`)}async function Zr(e,t,n,r,i){n.info(`Downloading OpenCode`,{version:e});let a=Jr(e,t),o=await r.downloadTool(a);if(!await Yr(o,t.ext,n,i))throw Error(`Downloaded archive appears corrupted`);n.info(`Extracting OpenCode`);let s=t.ext===`.zip`?await r.extractZip(o):await r.extractTar(o);n.info(`Caching OpenCode`);let c=await r.cacheDir(s,Gr,e,t.arch);return n.info(`OpenCode installed`,{version:e,path:c}),{path:c,version:e,cached:!1}}async function Qr(e){let t=await fetch(`https://api.github.com/repos/anomalyco/opencode/releases/latest`);if(!t.ok)throw Error(`Failed to fetch latest OpenCode version: ${t.statusText}`);let n=(await t.json()).tag_name.replace(/^v/,``);return e.info(`Latest OpenCode version`,{version:n}),n}const $r={restoreCache:async(e,t,n)=>oe(e,t,n),saveCache:async(e,t)=>ue(e,t)};function ei(e){let{os:t,opencodeVersion:n,omoVersion:r}=e;return`${p}-${t}-oc-${n}-omo-${r}`}function ti(e){let{os:t,opencodeVersion:n,omoVersion:r}=e;return[`${p}-${t}-oc-${n}-omo-${r}-`]}async function ni(e){let{logger:t,os:n,opencodeVersion:r,omoVersion:i,toolCachePath:a,bunCachePath:o,omoConfigPath:s,cacheAdapter:c=$r}=e,l=ei({os:n,opencodeVersion:r,omoVersion:i}),u=ti({os:n,opencodeVersion:r,omoVersion:i}),d=[a,o,s];t.info(`Restoring tools cache`,{primaryKey:l,restoreKeys:[...u],paths:d});try{let e=await c.restoreCache(d,l,[...u]);return e==null?(t.info(`Tools cache miss - will install tools`),{hit:!1,restoredKey:null}):(t.info(`Tools cache restored`,{restoredKey:e}),{hit:!0,restoredKey:e})}catch(e){return t.warning(`Tools cache restore failed`,{error:A(e)}),{hit:!1,restoredKey:null}}}async function ri(e){let{logger:t,os:n,opencodeVersion:r,omoVersion:i,toolCachePath:a,bunCachePath:o,omoConfigPath:s,cacheAdapter:c=$r}=e,l=ei({os:n,opencodeVersion:r,omoVersion:i}),u=[a,o,s];t.info(`Saving tools cache`,{saveKey:l,paths:u});try{return await c.saveCache(u,l),t.info(`Tools cache saved`,{saveKey:l}),!0}catch(e){return e instanceof Error&&e.message.includes(`already exists`)?(t.info(`Tools cache key already exists, skipping save`),!0):(t.warning(`Tools cache save failed`,{error:A(e)}),!1)}}function ii(){return{find:gr,downloadTool:lr,extractTar:dr,extractZip:fr,cacheDir:hr}}function ai(){return{exec:v,getExecOutput:b}}async function oi(n,r){let i=Date.now(),a=e({component:`setup`}),o=ii(),s=ai();try{a.info(`Starting setup`,{version:n.opencodeVersion});let e;try{e=Er(n.authJson)}catch(e){return t(`Invalid auth-json: ${A(e)}`),null}let c=n.opencodeVersion;if(c===`latest`)try{c=await Qr(a)}catch(e){a.warning(`Failed to get latest version, using fallback`,{error:A(e)}),c=Kr}let l=n.omoVersion,u=N.env.RUNNER_TOOL_CACHE??`/opt/hostedtoolcache`,f=R(u,`opencode`),p=R(u,`bun`),h=R(Ae(),`.config`,`opencode`),_=ee(),v=await ni({logger:a,os:_,opencodeVersion:c,omoVersion:l,toolCachePath:f,bunCachePath:p,omoConfigPath:h}),b=v.hit?`hit`:`miss`,x,S=!1,C=null;if(v.hit){let e=o.find(`opencode`,c);e.length>0?(x={path:e,version:c,cached:!0},a.info(`Tools cache hit, using cached OpenCode CLI`,{version:c,omoVersion:l})):a.warning(`Tools cache hit but binary not found in tool-cache, falling through to install`,{requestedVersion:c,restoredKey:v.restoredKey})}if(x==null)try{x=await Xr(c,a,o,s)}catch(e){return t(`Failed to install OpenCode: ${A(e)}`),null}let w=!1;try{await Ar(a,o,s,d,g),w=!0}catch(e){a.warning(`Bun installation failed, oMo will be unavailable`,{error:A(e)})}if(w){if(n.omoConfig!=null)try{await Ur(n.omoConfig,h,a)}catch(e){a.warning(`Failed to write omo-config, continuing without custom config`,{error:A(e)})}let e=await Wr(l,{logger:a,execAdapter:s},n.omoProviders);e.installed?(a.info(`oMo installed`,{version:e.version}),S=!0):a.warning(`oMo installation failed, continuing without oMo`,{error:e.error??`unknown error`}),C=e.error}let T={autoupdate:!1};if(n.opencodeConfig!=null){let e;try{e=JSON.parse(n.opencodeConfig)}catch{return t(`opencode-config must be valid JSON`),null}if(typeof e!=`object`||!e||Array.isArray(e))return t(`opencode-config must be a JSON object`),null;Object.assign(T,e)}m(`OPENCODE_CONFIG_CONTENT`,JSON.stringify(T)),v.hit||await ri({logger:a,os:_,opencodeVersion:c,omoVersion:l,toolCachePath:f,bunCachePath:p,omoConfigPath:h}),d(x.path),y(`opencode-path`,x.path),y(`opencode-version`,x.version),a.info(`OpenCode ready`,{version:x.version,cached:x.cached});let E=fe(r),te=await Lr(E,null,r,a);m(`GH_TOKEN`,r),a.info(`GitHub CLI configured`),await zr(E,te.botLogin,a,s);let D=R(pe(),`opencode`),O=await Dr(e,D,a);y(`auth-json-path`,O),a.info(`auth.json populated`,{path:O});let k=Date.now()-i,ne={opencodePath:x.path,opencodeVersion:x.version,ghAuthenticated:te.authenticated,omoInstalled:S,omoError:C,toolsCacheStatus:b,duration:k};return a.info(`Setup complete`,{duration:k}),ne}catch(e){let n=A(e);return a.error(`Setup failed`,{error:n}),t(n),null}}function si(e){return{success:!0,data:e}}function ci(e){return{success:!1,error:e}}const li=[`OWNER`,`MEMBER`,`COLLABORATOR`];async function ui(e,t){try{let{client:n,server:r}=await on({signal:e});return t.debug(`OpenCode server bootstrapped`,{url:r.url}),si({client:n,server:r,shutdown:()=>{r.close()}})}catch(e){let n=e instanceof Error?e.message:String(e);return t.warning(`Failed to bootstrap OpenCode server`,{error:n}),ci(Error(`Server bootstrap failed: ${n}`))}}async function di(e,t){let n=e??`opencode`;try{let e=``;await v(n,[`--version`],{listeners:{stdout:t=>{e+=t.toString()}},silent:!0});let r=/(\d+\.\d+\.\d+)/.exec(e)?.[1]??null;return t.debug(`OpenCode version verified`,{version:r}),{available:!0,version:r}}catch{return t.debug(`OpenCode not available, will attempt auto-setup`),{available:!1,version:null}}}async function fi(e){let{logger:t,opencodeVersion:n}=e,r=N.env.OPENCODE_PATH??null,i=await di(r,t);if(i.available&&i.version!=null)return t.info(`OpenCode already available`,{version:i.version}),{path:r??`opencode`,version:i.version,didSetup:!1};t.info(`OpenCode not found, running auto-setup`,{requestedVersion:n});let a=await oi({opencodeVersion:n,authJson:e.authJson,appId:null,privateKey:null,opencodeConfig:e.opencodeConfig,omoConfig:null,omoVersion:e.omoVersion,omoProviders:e.omoProviders},e.githubToken);if(a==null)throw Error(`Auto-setup failed: runSetup returned null`);return d(a.opencodePath),N.env.OPENCODE_PATH=a.opencodePath,t.info(`Auto-setup completed`,{version:a.opencodeVersion,path:a.opencodePath}),{path:a.opencodePath,version:a.opencodeVersion,didSetup:!0}}async function pi(t,n){let r={repo:t.agentContext.repo,commentId:t.agentContext.commentId,issueNumber:t.agentContext.issueNumber,issueType:t.agentContext.issueType,botLogin:t.botLogin},i=e({phase:`acknowledgment`});return await Qn(t.githubClient,r,i),n.debug(`Acknowledgment phase completed`),r}function mi(e,t){try{JSON.parse(e)}catch{throw Error(`${t} must be valid JSON`)}}function hi(e,t){let n=e.trim();if(!/^\d+$/.test(n))throw Error(`${t} must be a positive integer, received: ${e}`);let r=Number.parseInt(n,10);if(r===0)throw Error(`${t} must be a positive integer, received: ${e}`);return r}function gi(e){let t=e.trim(),n=t.indexOf(`/`);if(n===-1)throw Error(`Invalid model format: "${e}". Expected "provider/model" (e.g., "anthropic/claude-sonnet-4-20250514")`);let r=t.slice(0,n).trim(),i=t.slice(n+1).trim();if(r.length===0)throw Error(`Invalid model format: "${e}". Provider cannot be empty.`);if(i.length===0)throw Error(`Invalid model format: "${e}". Model ID cannot be empty.`);return{providerID:r,modelID:i}}function _i(e,t=`timeout`){let n=e.trim();if(!/^\d+$/.test(n))throw Error(`${t} must be a non-negative integer, received: ${e}`);let r=Number.parseInt(n,10);if(Number.isNaN(r)||r<0)throw Error(`${t} must be a non-negative integer, received: ${e}`);return r}const vi=[`claude`,`claude-max20`,`copilot`,`gemini`,`openai`,`opencode-zen`,`zai-coding-plan`,`kimi-for-coding`];function yi(e){let t=e.split(`,`).map(e=>e.trim().toLowerCase()).filter(e=>e.length>0),n=`no`,r=`no`,i=`no`,a=`no`,o=`no`,s=`no`,c=`no`;for(let e of t){if(!vi.includes(e))throw Error(`Invalid omo-providers value: "${e}". Valid values: ${vi.join(`, `)}`);switch(e){case`claude`:n=`yes`;break;case`claude-max20`:n=`max20`;break;case`copilot`:r=`yes`;break;case`gemini`:i=`yes`;break;case`openai`:a=`yes`;break;case`opencode-zen`:o=`yes`;break;case`zai-coding-plan`:s=`yes`;break;case`kimi-for-coding`:c=`yes`;break}}return{claude:n,copilot:r,gemini:i,openai:a,opencodeZen:o,zaiCodingPlan:s,kimiForCoding:c}}function bi(){try{let e=a(`github-token`,{required:!0}).trim();if(e.length===0)return ci(Error(`github-token is required but was not provided`));let t=a(`auth-json`,{required:!0}).trim();if(t.length===0)return ci(Error(`auth-json is required but was not provided`));mi(t,`auth-json`);let o=a(`prompt`).trim(),s=o.length>0?o:null,c=a(`session-retention`).trim(),l=c.length>0?hi(c,`session-retention`):50,u=a(`s3-backup`).trim().toLowerCase()===`true`,d=a(`s3-bucket`).trim(),f=d.length>0?d:null,p=a(`aws-region`).trim(),m=p.length>0?p:null,h=a(`agent`).trim(),g=h.length>0?h:he,v=a(`model`).trim(),y=v.length>0?gi(v):null,b=a(`timeout`).trim(),x=b.length>0?_i(b):r,S=a(`opencode-version`).trim(),C=S.length>0?S:i,ee=a(`skip-cache`).trim().toLowerCase()===`true`,w=a(`omo-version`).trim(),T=w.length>0?w:_,E=a(`omo-providers`).trim(),te=yi(E.length>0?E:``),D=a(`opencode-config`).trim(),O=D.length>0?D:null,k=a(`dedup-window`).trim(),ne=k.length>0?_i(k,`dedup-window`):n;if(O!=null){mi(O,`opencode-config`);let e=JSON.parse(O);if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Input 'opencode-config' must be a JSON object`)}return si({githubToken:e,authJson:t,prompt:s,sessionRetention:l,s3Backup:u,s3Bucket:f,awsRegion:m,agent:g,model:y,timeoutMs:x,opencodeVersion:C,skipCache:ee,omoVersion:T,omoProviders:te,opencodeConfig:O,dedupWindow:ne})}catch(e){return ci(e instanceof Error?e:Error(String(e)))}}async function xi(n){let r=bi();if(!r.success)return t(`Invalid inputs: ${r.error.message}`),null;let i=r.data,a=e({phase:`main`});a.info(`Action inputs parsed`,{sessionRetention:i.sessionRetention,s3Backup:i.s3Backup,hasGithubToken:i.githubToken.length>0,hasPrompt:i.prompt!=null,agent:i.agent,hasModelOverride:i.model!=null,timeoutMs:i.timeoutMs});let o=await fi({logger:a,opencodeVersion:i.opencodeVersion,githubToken:i.githubToken,authJson:i.authJson,omoVersion:i.omoVersion,omoProviders:i.omoProviders,opencodeConfig:i.opencodeConfig});return o.didSetup?a.info(`OpenCode auto-setup completed`,{version:o.version}):a.info(`OpenCode already available`,{version:o.version}),M(j.OPENCODE_VERSION,o.version),n.debug(`Bootstrap phase completed`,{opencodeVersion:o.version}),{inputs:i,logger:a,opencodeResult:o}}const Si=/^[0-9a-f]{40}$/i;function Ci(){return{exec:v,getExecOutput:b}}async function wi(e){let{workspacePath:t,logger:n,execAdapter:r=Ci()}=e,i=L.join(t,`.git`),a=L.join(i,`opencode`);try{let e=(await I.readFile(a,`utf8`)).trim();if(e.length>0){if(Si.test(e))return n.debug(`Project ID loaded from cache`,{projectId:e}),{projectId:e,source:`cached`};n.warning(`Invalid cached project ID format, regenerating`,{cachedId:e})}}catch(e){n.debug(`No cached project ID found`,{error:A(e)})}try{let e=await I.readFile(i,`utf8`),n=/^gitdir: (.+)$/m.exec(e);if(n==null)return{projectId:null,source:`error`,error:`Invalid .git file format`};i=L.resolve(t,n[1]),a=L.join(i,`opencode`)}catch(e){if((typeof e==`object`?e.code:void 0)!==`EISDIR`)return{projectId:null,source:`error`,error:`Not a git repository`}}try{let{stdout:e,exitCode:i}=await r.getExecOutput(`git`,[`rev-list`,`--max-parents=0`,`--all`],{cwd:t,silent:!0});if(i!==0||e.trim().length===0)return{projectId:null,source:`error`,error:`No commits found in repository`};let o=e.trim().split(` -`).map(e=>e.trim()).filter(e=>e.length>0).sort();if(o.length===0)return{projectId:null,source:`error`,error:`No root commits found`};let s=o[0];try{await I.writeFile(a,s,{encoding:`utf8`,flag:`wx`}),n.info(`Project ID generated and cached`,{projectId:s,source:`generated`})}catch(e){(typeof e==`object`?e.code:void 0)===`EEXIST`?n.debug(`Project ID file already written by concurrent process, skipping`,{projectId:s}):n.warning(`Failed to cache project ID (continuing)`,{error:A(e)})}return{projectId:s,source:`generated`}}catch(e){return{projectId:null,source:`error`,error:A(e)}}}async function Ti(n){let r=w(),i=e({phase:`cache`}),a=se(),o=L.join(a,`.git`,`opencode`),s=await le({components:r,logger:i,storagePath:O(),authPath:ie(),projectIdPath:o,opencodeVersion:n.opencodeResult.version}),c=s.corrupted?`corrupted`:s.hit?`hit`:`miss`;n.logger.info(`Cache restore completed`,{cacheStatus:c,key:s.key});let l=await wi({workspacePath:a,logger:i});l.source===`error`?i.warning(`Failed to generate project ID (continuing)`,{error:l.error}):i.debug(`Project ID ready`,{projectId:l.projectId,source:l.source});let u=e({phase:`server-bootstrap`}),d=await ui(new AbortController().signal,u);if(!d.success)return t(`OpenCode server bootstrap failed: ${d.error.message}`),null;let f=d.data;return u.info(`SDK server bootstrapped successfully`),{cacheResult:s,cacheStatus:c,serverHandle:f}}const Ei={markdownImage:/!\[([^\]]*)\]\((https:\/\/github\.com\/user-attachments\/assets\/[^)]+)\)/gi,markdownLink:/\[([^\]]+)\]\((https:\/\/github\.com\/user-attachments\/files\/[^)]+)\)/gi,htmlImage:/]*src=["'](https:\/\/github\.com\/user-attachments\/assets\/[^"']+)["'][^>]*>/gi};function Di(e,t,n){e.lastIndex=0;let r=e.exec(t);for(;r!=null;)n(r),r=e.exec(t);e.lastIndex=0}function Oi(e){let t=[],n=new Set;return Di(Ei.markdownImage,e,e=>{let r=e[2],i=e[1],a=e[0];r!=null&&i!=null&&!n.has(r)&&bn(r)&&(n.add(r),t.push({url:r,originalMarkdown:a,altText:i,type:`image`}))}),Di(Ei.markdownLink,e,e=>{let r=e[2],i=e[1],a=e[0];r!=null&&i!=null&&!n.has(r)&&bn(r)&&(n.add(r),t.push({url:r,originalMarkdown:a,altText:i,type:`file`}))}),Di(Ei.htmlImage,e,e=>{let r=e[1],i=e[0];if(r!=null&&!n.has(r)&&bn(r)){n.add(r);let e=/alt=["']([^"']*)["']/i.exec(i);t.push({url:r,originalMarkdown:i,altText:e?.[1]??``,type:`image`})}}),Ei.htmlImage.lastIndex=0,t}function ki(e,t,n){try{let r=new URL(e).pathname.split(`/`).at(-1);if(r!=null&&/\.[a-z0-9]+$/i.test(r))return r;if(t.trim().length>0){let e=t.replaceAll(/[^\w.-]/g,`_`).slice(0,50);return e.trim().length>0?e:`attachment_${n+1}`}return`attachment_${n+1}`}catch{return`attachment_${n+1}`}}const Ai={maxFiles:5,maxFileSizeBytes:5*1024*1024,maxTotalSizeBytes:15*1024*1024,allowedMimeTypes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`text/plain`,`text/markdown`,`text/csv`,`application/json`,`application/pdf`]},ji=[`github.com`,`githubusercontent.com`];async function Mi(e,t,n,r,i){i.debug(`Downloading attachment`,{url:e.url});try{let a=await fetch(e.url,{headers:{Authorization:`Bearer ${n}`,Accept:`*/*`,"User-Agent":`fro-bot-agent`},redirect:`manual`}),o=a;if(a.status>=300&&a.status<400){let t=a.headers.get(`location`);if(t==null)return i.warning(`Redirect without location`,{url:e.url}),null;let n=new URL(t);if(!ji.some(e=>n.hostname===e||n.hostname.endsWith(`.${e}`)))return i.warning(`Redirect to non-GitHub host blocked`,{url:e.url,redirectTo:n.hostname}),null;o=await fetch(t,{headers:{Accept:`*/*`,"User-Agent":`fro-bot-agent`},redirect:`follow`})}if(!o.ok)return i.warning(`Attachment download failed`,{url:e.url,status:o.status}),null;let s=o.headers.get(`content-length`);if(s!=null){let t=Number.parseInt(s,10);if(t>r.maxFileSizeBytes)return i.warning(`Attachment exceeds size limit (Content-Length)`,{url:e.url,size:t,limit:r.maxFileSizeBytes}),null}let c=xe.from(await o.arrayBuffer());if(c.length>r.maxFileSizeBytes)return i.warning(`Attachment exceeds size limit`,{url:e.url,size:c.length,limit:r.maxFileSizeBytes}),null;let l=o.headers.get(`content-type`)??`application/octet-stream`,u=ki(e.url,e.altText,t),d=l.split(`;`)[0],f=d==null?`application/octet-stream`:d.trim(),p=await I.mkdtemp(L.join(Oe.tmpdir(),`fro-bot-attachments-`)),m=u.trim().length>0?u:`attachment_${t+1}`,h=L.join(p,m);return await I.writeFile(h,c),i.debug(`Attachment downloaded`,{filename:u,mime:f,sizeBytes:c.length,tempPath:h}),{url:e.url,filename:u,mime:f,sizeBytes:c.length,tempPath:h}}catch(t){return i.warning(`Attachment download error`,{url:e.url,error:A(t)}),null}}async function Ni(e,t,n=Ai,r){return Promise.all(e.map(async(e,i)=>Mi(e,i,t,n,r)))}async function Pi(e,t){for(let n of e)try{await I.unlink(n);let e=L.dirname(n);await I.rmdir(e).catch(()=>{})}catch(e){t.debug(`Failed to cleanup temp file`,{path:n,error:A(e)})}}function Fi(e){return e.map(e=>({type:`file`,mime:e.mime,url:we(e.tempPath).toString(),filename:e.filename}))}function Ii(e,t,n){let r=e,i=new Set(n.map(e=>e.filename));for(let e of t){let t=n.find(e=>i.has(e.filename));t!=null&&(r=r.replace(e.originalMarkdown,`@${t.filename}`))}return r}function Li(e,t,n,r){return{processed:n,skipped:r,modifiedBody:Ii(e,t,n),fileParts:Fi(n),tempFiles:n.map(e=>e.tempPath)}}function Ri(e){if(e<0||!Number.isFinite(e))throw Error(`Invalid bytes value: ${e}`);return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function zi(e,t=Ai,n){let r=[],i=[],a=0;for(let o of e)if(o!=null){if(r.length>=t.maxFiles){i.push({url:o.url,reason:`Exceeds max file count (${t.maxFiles})`}),n.debug(`Attachment skipped: max count`,{url:o.url});continue}if(o.sizeBytes>t.maxFileSizeBytes){i.push({url:o.url,reason:`File too large (${Ri(o.sizeBytes)} > ${Ri(t.maxFileSizeBytes)})`}),n.debug(`Attachment skipped: too large`,{url:o.url,size:o.sizeBytes});continue}if(a+o.sizeBytes>t.maxTotalSizeBytes){i.push({url:o.url,reason:`Would exceed total size limit (${Ri(t.maxTotalSizeBytes)})`}),n.debug(`Attachment skipped: total size exceeded`,{url:o.url});continue}if(!Bi(o.mime,t.allowedMimeTypes)){i.push({url:o.url,reason:`MIME type not allowed: ${o.mime}`}),n.debug(`Attachment skipped: MIME type`,{url:o.url,mime:o.mime});continue}a+=o.sizeBytes,r.push({filename:o.filename,mime:o.mime,sizeBytes:o.sizeBytes,tempPath:o.tempPath}),n.info(`Attachment validated`,{filename:o.filename,mime:o.mime,sizeBytes:o.sizeBytes})}return{validated:r,skipped:i}}function Bi(e,t){let[n]=e.split(`/`);for(let r of t)if(r===e||r.endsWith(`/*`)&&n!=null&&n===r.slice(0,-2))return!0;return!1}function q(e){let t=L.resolve(e);return t.endsWith(L.sep)&&t.length>1?t.slice(0,-1):t}const Vi=e=>typeof e==`object`&&!!e,J=e=>typeof e==`string`?e:null,Hi=e=>typeof e==`number`?e:null;function Ui(e){if(Array.isArray(e))return e.filter(Vi).map(e=>({file:J(e.file)??``,additions:Hi(e.additions)??0,deletions:Hi(e.deletions)??0}))}function Wi(e){return{id:e.id,version:e.version,projectID:e.projectID,directory:e.directory,parentID:e.parentID,title:e.title,time:{created:e.time.created,updated:e.time.updated,compacting:e.time.compacting,archived:e.time.archived},summary:e.summary==null?void 0:{additions:e.summary.additions,deletions:e.summary.deletions,files:e.summary.files,diffs:Ui(e.summary.diffs)},share:e.share?.url==null?void 0:{url:e.share.url},permission:e.permission==null?void 0:{rules:e.permission.rules},revert:e.revert==null?void 0:{messageID:e.revert.messageID,partID:e.revert.partID,snapshot:e.revert.snapshot,diff:e.revert.diff}}}async function Gi(e,t){let n=await e.project.list();if(n.error!=null||n.data==null)return t.warning(`SDK project list failed`,{error:String(n.error)}),[];if(!Array.isArray(n.data))return[];let r=[];for(let e of n.data){if(!Vi(e))continue;let t=J(e.id),n=J(e.worktree),i=J(e.path);t==null||n==null||i==null||r.push({id:t,worktree:n,path:i,vcs:`git`,time:{created:0,updated:0}})}return r}async function Ki(e,t,n){let r=q(t),i=await Gi(e,n);for(let e of i){if(q(e.worktree)===r)return e;let t=J(e.path);if(t!=null&&q(t)===r)return e}return null}function qi(e){return e.status===`running`?{status:`running`,input:e.input,time:{start:e.time.start}}:e.status===`error`?{status:`error`,input:e.input,error:e.error,time:{start:e.time.start,end:e.time.end}}:e.status===`pending`?{status:`pending`}:{status:`completed`,input:e.input,output:e.output,title:e.title,metadata:e.metadata,time:{start:e.time.start,end:e.time.end,compacted:e.time.compacted},attachments:void 0}}function Ji(e){let t={id:e.id,sessionID:e.sessionID,messageID:e.messageID};if(e.type===`text`)return{...t,type:`text`,text:e.text,synthetic:e.synthetic,ignored:e.ignored,time:e.time,metadata:e.metadata};if(e.type===`reasoning`)return{...t,type:`reasoning`,reasoning:e.reasoning??e.text,time:e.time};if(e.type===`tool`)return{...t,type:`tool`,callID:e.callID,tool:e.tool,state:qi(e.state),metadata:e.metadata};if(e.type!==`step-finish`)return{...t,type:`text`,text:`text`in e?e.text:``};let n=e;return{...t,type:`step-finish`,reason:n.reason,snapshot:n.snapshot,cost:n.cost,tokens:{input:n.tokens.input,output:n.tokens.output,reasoning:n.tokens.reasoning,cache:{read:n.tokens.cache.read,write:n.tokens.cache.write}}}}function Yi(e){if(e.role===`user`){let t=e;return{id:t.id,sessionID:t.sessionID,role:`user`,time:{created:t.time.created},summary:t.summary==null?void 0:{title:t.summary.title,body:t.summary.body,diffs:Ui(t.summary.diffs)??[]},agent:t.agent,model:{providerID:t.model.providerID,modelID:t.model.modelID},system:t.system,tools:t.tools,variant:t.variant}}let t=e;return{id:t.id,sessionID:t.sessionID,role:`assistant`,time:{created:t.time.created,completed:t.time.completed},parentID:t.parentID,modelID:t.modelID,providerID:t.providerID,mode:t.mode,agent:t.agent??``,path:{cwd:t.path.cwd,root:t.path.root},summary:t.summary,cost:t.cost,tokens:{input:t.tokens.input,output:t.tokens.output,reasoning:t.tokens.reasoning,cache:{read:t.tokens.cache.read,write:t.tokens.cache.write}},finish:t.finish,error:t.error?{name:t.error.name,message:J(t.error.data.message)??``}:void 0}}function Xi(e){return[...e.map(e=>{let t=Yi(`info`in e?e.info:e),n=`parts`in e?e.parts.map(Ji):void 0;return n==null||n.length===0?t:{...t,parts:n}})].sort((e,t)=>e.time.created-t.time.created)}async function Zi(e,t,n){let r=await e.session.list({query:{directory:t}});return r.error==null&&r.data!=null?Array.isArray(r.data)?r.data.map(Wi):[]:(n.warning(`SDK session list failed`,{error:String(r.error)}),[])}async function Qi(e,t,n){let r=await e.session.messages({path:{id:t}});return r.error==null&&r.data!=null?Xi(r.data):(n.warning(`SDK session messages failed`,{error:String(r.error)}),[])}async function $i(e,t,n,r){let i=await e.session.list({query:{directory:t,start:n,roots:!0,limit:10}});if(i.error!=null||i.data==null)return r.warning(`SDK session list failed`,{error:String(i.error)}),null;if(!Array.isArray(i.data)||i.data.length===0)return null;let a=i.data.map(Wi);if(a.length===0)return null;let o=a.reduce((e,t)=>t.time.created>e.time.created?t:e);return{projectID:o.projectID,session:o}}async function ea(e,t,n){let r=await e.session.delete({path:{id:t}});if(r.error!=null){n.warning(`SDK session delete failed`,{sessionID:t,error:String(r.error)});return}n.debug(`Deleted session via SDK`,{sessionID:t})}const ta={maxSessions:50,maxAgeDays:30};async function na(e,t,n,r){let{maxSessions:i,maxAgeDays:a}=n;if(r.info(`Starting session pruning`,{workspacePath:t,maxSessions:i,maxAgeDays:a}),await Ki(e,t,r)==null)return r.debug(`No project found for pruning`,{workspacePath:t}),{prunedCount:0,prunedSessionIds:[],remainingCount:0,freedBytes:0};let o=await Zi(e,t,r),s=o.filter(e=>e.parentID==null);if(s.length===0)return{prunedCount:0,prunedSessionIds:[],remainingCount:0,freedBytes:0};let c=[...s].sort((e,t)=>t.time.updated-e.time.updated),l=new Date;l.setDate(l.getDate()-a);let u=l.getTime(),d=new Set;for(let e of c)e.time.updated>=u&&d.add(e.id);for(let e=0;e!d.has(e.id)),p=new Set;for(let e of f){p.add(e.id);for(let t of o)t.parentID===e.id&&p.add(t.id)}if(p.size===0)return r.info(`No sessions to prune`),{prunedCount:0,prunedSessionIds:[],remainingCount:s.length,freedBytes:0};let m=[];for(let t of p)try{await ea(e,t,r),m.push(t),r.debug(`Pruned session`,{sessionId:t})}catch(e){r.warning(`Failed to prune session`,{sessionId:t,error:A(e)})}let h=s.length-f.length;return r.info(`Session pruning complete`,{prunedCount:m.length,remainingCount:h}),{prunedCount:m.length,prunedSessionIds:m,remainingCount:h,freedBytes:0}}async function ra(e,t,n,r){let{limit:i,fromDate:a,toDate:o}=n;r.debug(`Listing sessions`,{directory:t,limit:i});let s=[...(await Zi(e,t,r)).filter(e=>!(e.parentID!=null||a!=null&&e.time.createdo.getTime()))].sort((e,t)=>t.time.updated-e.time.updated),c=[],l=i==null?s:s.slice(0,i);for(let t of l){let n=await Qi(e,t.id,r),i=ia(n);c.push({id:t.id,projectID:t.projectID,directory:t.directory,title:t.title,createdAt:t.time.created,updatedAt:t.time.updated,messageCount:n.length,agents:i,isChild:!1})}return r.info(`Listed sessions`,{count:c.length,directory:t}),c}function ia(e){let t=new Set;for(let n of e)n.agent!=null&&t.add(n.agent);return[...t]}async function aa(e,t,n,r,i){let{limit:a=20,caseSensitive:o=!1,sessionId:s}=r;i.debug(`Searching sessions`,{query:e,directory:n,limit:a,caseSensitive:o});let c=o?e:e.toLowerCase(),l=[],u=0;if(s!=null){let e=await oa(t,s,c,o,i);return e.length>0&&l.push({sessionId:s,matches:e.slice(0,a)}),l}let d=await ra(t,n,{},i);for(let e of d){if(u>=a)break;let n=await oa(t,e.id,c,o,i);if(n.length>0){let t=a-u;l.push({sessionId:e.id,matches:n.slice(0,t)}),u+=Math.min(n.length,t)}}return i.info(`Session search complete`,{query:e,resultCount:l.length,totalMatches:u}),l}async function oa(e,t,n,r,i){let a=await Qi(e,t,i),o=[];for(let e of a){let t=e.parts??[];for(let i of t){let t=sa(i);if(t==null)continue;let a=r?t:t.toLowerCase();if(a.includes(n)){let r=a.indexOf(n),s=Math.max(0,r-50),c=Math.min(t.length,r+n.length+50),l=t.slice(s,c);o.push({messageId:e.id,partId:i.id,excerpt:`...${l}...`,role:e.role,agent:e.agent})}}}return o}function sa(e){switch(e.type){case`text`:return e.text;case`reasoning`:return e.reasoning;case`tool`:return e.state.status===`completed`?`${e.tool}: ${e.state.output}`:null;case`step-finish`:return null}}function ca(e){let t=[`--- Fro Bot Run Summary ---`,`Event: ${e.eventType}`,`Repo: ${e.repo}`,`Ref: ${e.ref}`,`Run ID: ${e.runId}`,`Cache: ${e.cacheStatus}`,`Duration: ${e.duration}s`];return e.sessionIds.length>0&&t.push(`Sessions used: ${e.sessionIds.join(`, `)}`),e.logicalKey!=null&&t.push(`Logical Thread: ${e.logicalKey}`),e.createdPRs.length>0&&t.push(`PRs created: ${e.createdPRs.join(`, `)}`),e.createdCommits.length>0&&t.push(`Commits: ${e.createdCommits.join(`, `)}`),e.tokenUsage!=null&&t.push(`Tokens: ${e.tokenUsage.input} in / ${e.tokenUsage.output} out`),t.join(` -`)}async function la(e,t,n,r){let i=ca(t);try{let t=await n.session.prompt({path:{id:e},body:{noReply:!0,parts:[{type:`text`,text:i}]}});if(t.error!=null){r.warning(`SDK prompt writeback failed`,{sessionId:e,error:String(t.error)});return}r.info(`Session summary written via SDK`,{sessionId:e})}catch(t){r.warning(`SDK prompt writeback failed`,{sessionId:e,error:A(t)})}}async function ua(t){let{bootstrapLogger:n,reactionCtx:r,githubClient:i,agentSuccess:a,attachmentResult:o,serverHandle:s,detectedOpencodeVersion:c}=t;try{if(o!=null){let t=e({phase:`attachment-cleanup`});await Pi(o.tempFiles,t)}r!=null&&i!=null&&await ir(i,r,a,e({phase:`cleanup`}));let t=e({phase:`prune`}),n=se();if(s!=null){let e=q(n),r=await na(s.client,e,ta,t);r.prunedCount>0&&t.info(`Pruned old sessions`,{pruned:r.prunedCount,remaining:r.remainingCount})}let l=w(),u=e({phase:`cache-save`}),d=L.join(n,`.git`,`opencode`);if(await ae({components:l,runId:D(),logger:u,storagePath:O(),authPath:ie(),projectIdPath:d,opencodeVersion:c})&&M(j.CACHE_SAVED,`true`),ge()){let t=e({phase:`artifact-upload`});await de({logPath:k(),runId:D(),runAttempt:te(),logger:t})&&M(j.ARTIFACT_UPLOADED,`true`)}}catch(e){n.warning(`Cleanup failed (non-fatal)`,{error:e instanceof Error?e.message:String(e)})}finally{if(s!=null)try{s.shutdown()}catch(e){n.warning(`Server shutdown failed (non-fatal)`,{error:e instanceof Error?e.message:String(e)})}}}const da=L.join(ke.homedir(),`.cache`,`fro-bot-dedup`);function fa(e){return e.replaceAll(`/`,`-`)}function pa(e,t){let n=fa(e);return L.join(da,`${n}-${t.entityType}-${t.entityNumber}`)}function ma(e,t){return`${T}-${fa(e)}-${t.entityType}-${t.entityNumber}-`}function ha(e,t,n){return`${ma(e,t)}${n}`}async function ga(e,t,n,r=ne){let i=pa(e,t),a=L.join(i,`sentinel.json`),o=ma(e,t);try{if(await I.rm(i,{recursive:!0,force:!0}),await I.mkdir(i,{recursive:!0}),await r.restoreCache([i],o,[])==null)return null;let e=await I.readFile(a,`utf8`);return JSON.parse(e)}catch(e){return n.debug(`Dedup marker restore failed; proceeding without marker`,{error:A(e),entityType:t.entityType,entityNumber:t.entityNumber}),null}}async function _a(e,t,n,r,i=ne){let a=pa(e,t),o=L.join(a,`sentinel.json`),s=ha(e,t,n.runId);try{return await I.mkdir(a,{recursive:!0}),await I.writeFile(o,JSON.stringify(n),`utf8`),await i.saveCache([a],s),!0}catch(e){return A(e).toLowerCase().includes(`already exists`)?!0:(r.debug(`Dedup marker save failed`,{error:A(e),entityType:t.entityType,entityNumber:t.entityNumber,saveKey:s}),!1)}}const va=new Set([`pull_request`,`issues`]),ya=new Set([`synchronize`,`reopened`]);function ba(e){return e.target==null||!va.has(e.eventType)?null:e.eventType===`pull_request`&&e.target.kind===`pr`?{entityType:`pr`,entityNumber:e.target.number}:e.eventType===`issues`&&e.target.kind===`issue`?{entityType:`issue`,entityNumber:e.target.number}:null}async function xa(t,n,r,i,a=e({phase:`dedup`}),o){let s=ba(n);if(t===0)return{shouldProceed:!0,entity:s};if(s==null)return{shouldProceed:!0,entity:null};if(n.action!=null&&ya.has(n.action))return a.debug(`Dedup bypassed for action`,{action:n.action}),{shouldProceed:!0,entity:s};let c=await ga(r,s,a,o);if(c==null||c.runId===n.runId)return{shouldProceed:!0,entity:s};let l=new Date(c.timestamp).getTime();if(Number.isNaN(l))return a.warning(`Dedup marker timestamp is invalid; proceeding without dedup`,{markerTimestamp:c.timestamp}),{shouldProceed:!0,entity:s};let u=Date.now()-l;if(u<-6e4)return a.warning(`Dedup marker timestamp is too far in the future; proceeding without dedup`,{markerTimestamp:c.timestamp,markerAge:u}),{shouldProceed:!0,entity:s};let d=Math.max(0,u);return d>t?{shouldProceed:!0,entity:s}:(a.info(`Skipping duplicate trigger within dedup window`,{eventType:n.eventType,action:n.action,runId:n.runId,markerRunId:c.runId,markerTimestamp:c.timestamp,dedupWindow:t,entityType:s.entityType,entityNumber:s.entityNumber}),z({sessionId:null,cacheStatus:`miss`,duration:Date.now()-i}),await Ca(n,s,c,d,t,a),{shouldProceed:!1,entity:s})}async function Sa(t,n,r,i=e({phase:`dedup`}),a){await _a(r,n,{timestamp:new Date().toISOString(),runId:t.runId,action:t.action??`unknown`,eventType:t.eventType,entityType:n.entityType,entityNumber:n.entityNumber},i,a)}async function Ca(e,t,n,r,i,a){try{let a=Math.round(r/1e3),o=Math.round(i/1e3),s=`${t.entityType} #${t.entityNumber}`,c=`https://github.com/${e.repo.owner}/${e.repo.repo}/actions/runs/${n.runId}`;S.addHeading(`Fro Bot Agent Run — Skipped (Dedup)`,2).addRaw(`Execution skipped because the agent already ran for **${s}** recently.\n\n`).addTable([[{data:`Detail`,header:!0},{data:`Value`,header:!0}],[`Current action`,`\`${e.eventType}.${e.action??`unknown`}\``],[`Prior run`,`[${n.runId}](${c})`],[`Prior action`,`\`${n.eventType}.${n.action}\``],[`Time since prior run`,`${a}s`],[`Dedup window`,`${o}s`]]).addRaw(` +If you had completed the task, confirm the completion.`,u=r===1?e.fileParts:void 0,g=await(async()=>{try{return await In(s,l,a,u,f,n,t)}finally{await ln(s,l,n?.sessionTitle,t)}})();if(g.success)return p=g.eventStreamResult,{success:!0,exitCode:0,duration:Date.now()-i,sessionId:l,error:null,tokenUsage:p.tokens,model:p.model,cost:p.cost,prsCreated:p.prsCreated,commitsCreated:p.commitsCreated,commentsPosted:p.commentsPosted,llmError:null};if(m=g.error,h=g.llmError,!g.shouldRetry||r>=3)break;t.warning(`LLM fetch error detected, retrying with continuation prompt`,{attempt:r,maxAttempts:3,error:g.error,delayMs:Nn,sessionId:l}),await un(Nn)}return{success:!1,exitCode:1,duration:Date.now()-i,sessionId:l,error:m??`Unknown error`,tokenUsage:p.tokens,model:p.model,cost:p.cost,prsCreated:p.prsCreated,commitsCreated:p.commitsCreated,commentsPosted:p.commentsPosted,llmError:h}}catch(e){let n=Date.now()-i,r=M(e);return t.error(`OpenCode execution failed`,{error:r,durationMs:n}),{success:!1,exitCode:1,duration:n,sessionId:null,error:r,tokenUsage:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:gn(e)?_n(r):null}}finally{s!=null&&clearTimeout(s),a.abort(),l&&u?.close()}}async function Qn(e,t,n){return t.commentId==null?(n.debug(`No comment ID, skipping eyes reaction`),!1):await Pe(e,t.repo,t.commentId,`eyes`,n)==null?!1:(n.info(`Added eyes reaction`,{commentId:t.commentId}),!0)}async function $n(e,t,n){return t.issueNumber==null?(n.debug(`No issue number, skipping working label`),!1):await Le(e,t.repo,`agent: working`,`fcf2e1`,`Agent is currently working on this`,n)&&await Re(e,t.repo,t.issueNumber,[`agent: working`],n)?(n.info(`Added working label`,{issueNumber:t.issueNumber}),!0):!1}async function er(e,t,n){await Promise.all([Qn(e,t,n),$n(e,t,n)])}async function tr(e,t,n){if(t.commentId==null||t.botLogin==null)return;let r=(await Fe(e,t.repo,t.commentId,n)).find(e=>e.content===`eyes`&&e.userLogin===t.botLogin);r!=null&&await Ie(e,t.repo,t.commentId,r.id,n)}async function nr(e,t,n,r){t.commentId!=null&&await Pe(e,t.repo,t.commentId,n,r)}async function rr(e,t,n){if(t.commentId==null||t.botLogin==null){n.debug(`Missing comment ID or bot login, skipping reaction update`);return}try{await tr(e,t,n),await nr(e,t,`hooray`,n),n.info(`Updated reaction to success indicator`,{commentId:t.commentId,reaction:`hooray`})}catch(e){n.warning(`Failed to update reaction (non-fatal)`,{error:M(e)})}}async function ir(e,t,n){if(t.commentId==null||t.botLogin==null){n.debug(`Missing comment ID or bot login, skipping reaction update`);return}try{await tr(e,t,n),await nr(e,t,`confused`,n),n.info(`Updated reaction to confused`,{commentId:t.commentId})}catch(e){n.warning(`Failed to update failure reaction (non-fatal)`,{error:M(e)})}}async function ar(e,t,n){if(t.issueNumber==null){n.debug(`No issue number, skipping label removal`);return}await ze(e,t.repo,t.issueNumber,`agent: working`,n)&&n.info(`Removed working label`,{issueNumber:t.issueNumber})}async function or(e,t,n,r){n?await rr(e,t,r):await ir(e,t,r),await ar(e,t,r)}var G=C(D(),1),sr=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},cr=class{constructor(e,t,n){if(e<1)throw Error(`max attempts should be greater than or equal to 1`);if(this.maxAttempts=e,this.minSeconds=Math.floor(t),this.maxSeconds=Math.floor(n),this.minSeconds>this.maxSeconds)throw Error(`min seconds should be less than or equal to max seconds`)}execute(e,t){return sr(this,void 0,void 0,function*(){let n=1;for(;nsetTimeout(t,e*1e3))})}},K=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},lr=class extends Error{constructor(e){super(`Unexpected HTTP response: ${e}`),this.httpStatusCode=e,Object.setPrototypeOf(this,new.target.prototype)}};const ur=process.platform===`win32`;process.platform;function dr(e,t,n,r){return K(this,void 0,void 0,function*(){return t||=R.join(Tr(),he.randomUUID()),yield l(R.dirname(t)),f(`Downloading ${e}`),f(`Destination ${t}`),yield new cr(3,Er(`TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS`,10),Er(`TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS`,20)).execute(()=>K(this,void 0,void 0,function*(){return yield fr(e,t||``,n,r)}),e=>!(e instanceof lr&&e.httpStatusCode&&e.httpStatusCode<500&&e.httpStatusCode!==408&&e.httpStatusCode!==429))})}function fr(e,t,n,r){return K(this,void 0,void 0,function*(){if(L.existsSync(t))throw Error(`Destination file path ${t} already exists`);let i=new x(`actions/tool-cache`,[],{allowRetries:!1});n&&(f(`set auth`),r===void 0&&(r={}),r.authorization=n);let a=yield i.get(e,r);if(a.message.statusCode!==200){let t=new lr(a.message.statusCode);throw f(`Failed to download from "${e}". Code(${a.message.statusCode}) Message(${a.message.statusMessage})`),t}let o=_e.promisify(ke.pipeline),s=Er(`TEST_DOWNLOAD_TOOL_RESPONSE_MESSAGE_FACTORY`,()=>a.message)(),c=!1;try{return yield o(s,L.createWriteStream(t)),f(`download complete`),c=!0,t}finally{if(!c){f(`download failed`);try{yield ae(t)}catch(e){f(`Failed to delete '${t}'. ${e.message}`)}}}})}function pr(e,t){return K(this,arguments,void 0,function*(e,t,n=`xz`){if(!e)throw Error(`parameter 'file' is required`);t=yield br(t),f(`Checking tar --version`);let r=``;yield v(`tar --version`,[],{ignoreReturnCode:!0,silent:!0,listeners:{stdout:e=>r+=e.toString(),stderr:e=>r+=e.toString()}}),f(r.trim());let i=r.toUpperCase().includes(`GNU TAR`),a;a=n instanceof Array?n:[n],h()&&!n.includes(`v`)&&a.push(`-v`);let o=t,s=e;return ur&&i&&(a.push(`--force-local`),o=t.replace(/\\/g,`/`),s=e.replace(/\\/g,`/`)),i&&(a.push(`--warning=no-unknown-keyword`),a.push(`--overwrite`)),a.push(`-C`,o,`-f`,s),yield v(`tar`,a),t})}function mr(e,t){return K(this,void 0,void 0,function*(){if(!e)throw Error(`parameter 'file' is required`);return t=yield br(t),ur?yield hr(e,t):yield gr(e,t),t})}function hr(e,t){return K(this,void 0,void 0,function*(){let n=e.replace(/'/g,`''`).replace(/"|\n|\r/g,``),r=t.replace(/'/g,`''`).replace(/"|\n|\r/g,``),i=yield c(`pwsh`,!1);if(i){let e=[`-NoLogo`,`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Unrestricted`,`-Command`,[`$ErrorActionPreference = 'Stop' ;`,`try { Add-Type -AssemblyName System.IO.Compression.ZipFile } catch { } ;`,`try { [System.IO.Compression.ZipFile]::ExtractToDirectory('${n}', '${r}', $true) }`,`catch { if (($_.Exception.GetType().FullName -eq 'System.Management.Automation.MethodException') -or ($_.Exception.GetType().FullName -eq 'System.Management.Automation.RuntimeException') ){ Expand-Archive -LiteralPath '${n}' -DestinationPath '${r}' -Force } else { throw $_ } } ;`].join(` `)];f(`Using pwsh at path: ${i}`),yield v(`"${i}"`,e)}else{let e=[`-NoLogo`,`-Sta`,`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Unrestricted`,`-Command`,[`$ErrorActionPreference = 'Stop' ;`,`try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ;`,`if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath '${n}' -DestinationPath '${r}' -Force }`,`else {[System.IO.Compression.ZipFile]::ExtractToDirectory('${n}', '${r}', $true) }`].join(` `)],t=yield c(`powershell`,!0);f(`Using powershell at path: ${t}`),yield v(`"${t}"`,e)}})}function gr(e,t){return K(this,void 0,void 0,function*(){let n=yield c(`unzip`,!0),r=[e];h()||r.unshift(`-q`),r.unshift(`-o`),yield v(`"${n}"`,r,{cwd:t})})}function _r(e,t,n,r){return K(this,void 0,void 0,function*(){if(n=G.clean(n)||n,r||=me.arch(),f(`Caching tool ${t} ${n} ${r}`),f(`source dir: ${e}`),!L.statSync(e).isDirectory())throw Error(`sourceDir is not a directory`);let i=yield xr(t,n,r);for(let t of L.readdirSync(e))yield o(R.join(e,t),i,{recursive:!0});return Sr(t,n,r),i})}function vr(e,t,n){if(!e)throw Error(`toolName parameter is required`);if(!t)throw Error(`versionSpec parameter is required`);n||=me.arch(),Cr(t)||(t=wr(yr(e,n),t));let r=``;if(t){t=G.clean(t)||``;let i=R.join(q(),e,t,n);f(`checking cache: ${i}`),L.existsSync(i)&&L.existsSync(`${i}.complete`)?(f(`Found tool in cache ${e} ${t} ${n}`),r=i):f(`not found`)}return r}function yr(e,t){let n=[];t||=me.arch();let r=R.join(q(),e);if(L.existsSync(r)){let e=L.readdirSync(r);for(let i of e)if(Cr(i)){let e=R.join(r,i,t||``);L.existsSync(e)&&L.existsSync(`${e}.complete`)&&n.push(i)}}return n}function br(e){return K(this,void 0,void 0,function*(){return e||=R.join(Tr(),he.randomUUID()),yield l(e),e})}function xr(e,t,n){return K(this,void 0,void 0,function*(){let r=R.join(q(),e,G.clean(t)||t,n||``);f(`destination ${r}`);let i=`${r}.complete`;return yield ae(r),yield ae(i),yield l(r),r})}function Sr(e,t,n){let r=`${R.join(q(),e,G.clean(t)||t,n||``)}.complete`;L.writeFileSync(r,``),f(`finished caching tool`)}function Cr(e){let t=G.clean(e)||``;f(`isExplicit: ${t}`);let n=G.valid(t)!=null;return f(`explicit? ${n}`),n}function wr(e,t){let n=``;f(`evaluating ${e.length} versions`),e=e.sort((e,t)=>G.gt(e,t)?1:-1);for(let r=e.length-1;r>=0;r--){let i=e[r];if(G.satisfies(i,t)){n=i;break}}return f(n?`matched: ${n}`:`match not found`),n}function q(){let e=process.env.RUNNER_TOOL_CACHE||``;return ge(e,`Expected RUNNER_TOOL_CACHE to be defined`),e}function Tr(){let e=process.env.RUNNER_TEMP||``;return ge(e,`Expected RUNNER_TEMP to be defined`),e}function Er(e,t){let n=global[e];return n===void 0?t:n}function Dr(e){let t;try{t=JSON.parse(e)}catch(e){throw e instanceof SyntaxError?Error(`Invalid auth-json format: ${e.message}`):e}if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`auth-json must be a JSON object`);return t}async function Or(e,t,n){let r=B.join(t,`auth.json`);await z.mkdir(t,{recursive:!0});let i=JSON.stringify(e,null,2);return await z.writeFile(r,i,{mode:384}),n.info(`Populated auth.json`,{path:r,providers:Object.keys(e).length}),r}function kr(){let e=I.platform,t=I.arch;return{os:{darwin:`darwin`,linux:`linux`,win32:`windows`}[e]??`linux`,arch:{arm64:`aarch64`,x64:`x64`}[t]??`x64`,ext:`.zip`}}function Ar(e,t){return`https://github.com/oven-sh/bun/releases/download/bun-${e.startsWith(`v`)?e:`v${e}`}/${`bun-${t.os}-${t.arch}${t.ext}`}`}async function jr(e,t,n,r,i=g){let a=kr(),o=t.find(`bun`,i,a.arch);if(o.length>0)return e.info(`Bun found in cache`,{version:i,path:o}),r(o),await Nr(o),{path:o,version:i,cached:!0};e.info(`Downloading Bun`,{version:i});let s=Ar(i,a);try{let o=await t.downloadTool(s);if(I.platform!==`win32`&&!await Pr(o,e,n))throw Error(`Downloaded Bun archive appears corrupted`);e.info(`Extracting Bun`);let c=await Mr(await t.extractZip(o),t),l=Ce.dirname(c);e.info(`Caching Bun`);let u=await t.cacheDir(l,`bun`,i,a.arch);return r(u),await Nr(u),e.info(`Bun installed`,{version:i,path:u}),{path:u,version:i,cached:!1}}catch(e){let t=M(e);throw Error(`Failed to install Bun ${i}: ${t}`)}}async function Mr(e,t){for(let n of await Se.readdir(e,{withFileTypes:!0})){let{name:r}=n,i=Ce.join(e,r);if(n.isFile()){if(r===`bun`||r===`bun.exe`)return i;if(/^bun.*\.zip/.test(r))return Mr(await t.extractZip(i),t)}if(r.startsWith(`bun`)&&n.isDirectory())return Mr(i,t)}throw Error(`Could not find executable: bun`)}async function Nr(e){let t=e=>I.platform===`win32`?`${e}.exe`:e,n=Ce.join(e,t(`bun`));try{await Se.symlink(n,Ce.join(e,t(`bunx`)))}catch(e){let t=typeof e==`object`?e.code:void 0;if(t!==`EEXIST`&&t!==`EPERM`&&t!==`EACCES`)throw e}}async function Pr(e,t,n){try{let{stdout:r}=await n.getExecOutput(`file`,[e],{silent:!0}),i=r.includes(`Zip archive`)||r.includes(`ZIP`);return i||t.warning(`Bun download validation failed`,{output:r.trim()}),i}catch{return t.debug(`Could not validate Bun download (file command unavailable)`),!0}}function Fr(e){return{debug:t=>e.debug(t),info:t=>e.info(t),warn:t=>e.warning(t),error:t=>e.error(t)}}function Ir(e){let{token:t,logger:n}=e;return n.debug(`Creating GitHub client with token`),le(t,{log:Fr(n)})}async function Lr(e,t){try{let{data:n}=await e.rest.users.getAuthenticated();return t.debug(`Authenticated as`,{login:n.login,type:n.type}),n.login}catch{return t.debug(`Failed to get authenticated user, may be app token`),`fro-bot[bot]`}}async function Rr(e,t,n,r){let i=t??n,a=t==null?n.length>0?`github-token`:`none`:`app-token`;if(i.length===0)return r.warning(`No GitHub token available`),{authenticated:!1,method:`none`,botLogin:null};I.env.GH_TOKEN=i,r.info(`Configured authentication`,{method:a});let o=null;return e!=null&&(o=await Lr(e,r)),{authenticated:!0,method:a,botLogin:o}}async function zr(e,t){let n=await t.getExecOutput(`git`,[`config`,e],{ignoreReturnCode:!0,silent:!0});return n.exitCode===0&&n.stdout.trim().length>0?n.stdout.trim():null}async function Br(e,t,n,r){let i=await zr(`user.name`,r),a=await zr(`user.email`,r);if(i!=null&&a!=null){n.info(`Git identity already configured`,{name:i,email:a});return}if(t==null)throw Error(`Cannot configure Git identity: no authenticated GitHub user`);let o=null;if(a==null){let r=await Ue(e,t,n);if(r==null)throw Error(`Cannot configure Git identity: failed to look up user ID for '${t}'`);o=String(r.id)}i??await r.exec(`git`,[`config`,`--global`,`user.name`,t],void 0);let s=`${o}+${t}@users.noreply.github.com`;a??await r.exec(`git`,[`config`,`--global`,`user.email`,s],void 0),n.info(`Configured git identity`,{name:i??t,email:a??s})}const Vr=new Set([`__proto__`,`prototype`,`constructor`]);function Hr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ur(e,t){let n=Object.create(null);for(let[t,r]of Object.entries(e))Vr.has(t)||(n[t]=r);for(let[e,r]of Object.entries(t)){if(Vr.has(e))continue;let t=n[e];Hr(r)&&Hr(t)?n[e]=Ur(t,r):n[e]=r}return n}async function Wr(e,t,n){let r=JSON.parse(e);if(!Hr(r))throw Error(`omo-config must be a JSON object (non-null, non-array)`);let i=r;await z.mkdir(t,{recursive:!0});let a=B.join(t,`oh-my-opencode.json`),o={};try{let e=await z.readFile(a,`utf8`),t=JSON.parse(e);typeof t==`object`&&t&&!Array.isArray(t)&&(o=t)}catch(e){n.debug(`Using empty base oMo config`,{path:a,error:String(e)})}let s=Ur(o,i);await z.writeFile(a,JSON.stringify(s,null,2)),n.info(`Wrote oMo config`,{path:a,keyCount:Object.keys(i).length})}async function Gr(e,t,n={}){let{logger:r,execAdapter:i}=t,{claude:a=`no`,copilot:o=`no`,gemini:s=`no`,openai:c=`no`,opencodeZen:l=`no`,zaiCodingPlan:u=`no`,kimiForCoding:d=`no`}=n;r.info(`Installing Oh My OpenAgent plugin`,{version:e,claude:a,copilot:o,gemini:s,openai:c,opencodeZen:l,zaiCodingPlan:u,kimiForCoding:d});let f=``,p=[`oh-my-openagent@${e}`,`install`,`--no-tui`,`--skip-auth`,`--claude=${a}`,`--copilot=${o}`,`--gemini=${s}`,`--openai=${c}`,`--opencode-zen=${l}`,`--zai-coding-plan=${u}`,`--kimi-for-coding=${d}`];try{let t=await i.exec(`bunx`,p,{listeners:{stdout:e=>{f+=e.toString()},stderr:e=>{f+=e.toString()}},ignoreReturnCode:!0});if(t!==0){let e=`bunx oh-my-openagent install returned exit code ${t}`;return r.error(e,{output:f.slice(0,1e3)}),{installed:!1,version:null,error:`${e}\n${f.slice(0,500)}`}}let n=/oh-my-opencode@(\d+\.\d+\.\d+)/i.exec(f),a=n!=null&&n[1]!=null?n[1]:e;return r.info(`oMo plugin installed`,{version:a}),{installed:!0,version:a,error:null}}catch(e){let t=M(e),n=f.length>0?`${t}\nOutput: ${f.slice(0,500)}`:t;return r.error(`Failed to run oMo installer`,{error:t,output:f.slice(0,500)}),{installed:!1,version:null,error:`bunx oh-my-openagent install failed: ${n}`}}}const Kr=`opencode`,qr=i;function Jr(){let e=De.platform(),t=De.arch(),n={darwin:`darwin`,linux:`linux`,win32:`windows`},r={x64:`x64`,arm64:`arm64`},i=e===`win32`||e===`darwin`?`.zip`:`.tar.gz`;return{os:n[e]??`linux`,arch:r[t]??`x64`,ext:i}}function Yr(e,t){return`https://github.com/anomalyco/opencode/releases/download/${e.startsWith(`v`)?e:`v${e}`}/${`opencode-${t.os}-${t.arch}${t.ext}`}`}async function Xr(e,t,n,r){if(I.platform===`win32`)return!0;try{let{stdout:i}=await r.getExecOutput(`file`,[e],{silent:!0}),a=(t===`.zip`?[`Zip archive`,`ZIP`]:[`gzip`,`tar`,`compressed`]).some(e=>i.includes(e));return a||n.warning(`Download validation failed`,{output:i.trim()}),a}catch{return n.debug(`Could not validate download (file command unavailable)`),!0}}async function Zr(e,t,n,r,i=qr){let a=Jr(),o=n.find(Kr,e,a.arch);if(o.length>0)return t.info(`OpenCode found in cache`,{version:e,path:o}),{path:o,version:e,cached:!0};try{return await Qr(e,a,t,n,r)}catch(n){t.warning(`Primary version install failed, trying fallback`,{requestedVersion:e,fallbackVersion:i,error:M(n)})}if(e!==i)try{let e=await Qr(i,a,t,n,r);return t.info(`Installed fallback version`,{version:i}),e}catch(t){throw Error(`Failed to install OpenCode (tried ${e} and ${i}): ${M(t)}`)}throw Error(`Failed to install OpenCode version ${e}`)}async function Qr(e,t,n,r,i){n.info(`Downloading OpenCode`,{version:e});let a=Yr(e,t),o=await r.downloadTool(a);if(!await Xr(o,t.ext,n,i))throw Error(`Downloaded archive appears corrupted`);n.info(`Extracting OpenCode`);let s=t.ext===`.zip`?await r.extractZip(o):await r.extractTar(o);n.info(`Caching OpenCode`);let c=await r.cacheDir(s,Kr,e,t.arch);return n.info(`OpenCode installed`,{version:e,path:c}),{path:c,version:e,cached:!1}}async function $r(e){let t=await fetch(`https://api.github.com/repos/anomalyco/opencode/releases/latest`);if(!t.ok)throw Error(`Failed to fetch latest OpenCode version: ${t.statusText}`);let n=(await t.json()).tag_name.replace(/^v/,``);return e.info(`Latest OpenCode version`,{version:n}),n}const ei={restoreCache:async(e,t,n)=>ie(e,t,n),saveCache:async(e,t)=>se(e,t)};function ti(e){let{os:t,opencodeVersion:n,omoVersion:r}=e;return`${p}-${t}-oc-${n}-omo-${r}`}function ni(e){let{os:t,opencodeVersion:n,omoVersion:r}=e;return[`${p}-${t}-oc-${n}-omo-${r}-`]}async function ri(e){let{logger:t,os:n,opencodeVersion:r,omoVersion:i,toolCachePath:a,bunCachePath:o,omoConfigPath:s,cacheAdapter:c=ei}=e,l=ti({os:n,opencodeVersion:r,omoVersion:i}),u=ni({os:n,opencodeVersion:r,omoVersion:i}),d=[a,o,s];t.info(`Restoring tools cache`,{primaryKey:l,restoreKeys:[...u],paths:d});try{let e=await c.restoreCache(d,l,[...u]);return e==null?(t.info(`Tools cache miss - will install tools`),{hit:!1,restoredKey:null}):(t.info(`Tools cache restored`,{restoredKey:e}),{hit:!0,restoredKey:e})}catch(e){return t.warning(`Tools cache restore failed`,{error:M(e)}),{hit:!1,restoredKey:null}}}async function ii(e){let{logger:t,os:n,opencodeVersion:r,omoVersion:i,toolCachePath:a,bunCachePath:o,omoConfigPath:s,cacheAdapter:c=ei}=e,l=ti({os:n,opencodeVersion:r,omoVersion:i}),u=[a,o,s];t.info(`Saving tools cache`,{saveKey:l,paths:u});try{return await c.saveCache(u,l),t.info(`Tools cache saved`,{saveKey:l}),!0}catch(e){return e instanceof Error&&e.message.includes(`already exists`)?(t.info(`Tools cache key already exists, skipping save`),!0):(t.warning(`Tools cache save failed`,{error:M(e)}),!1)}}function ai(){return{find:vr,downloadTool:dr,extractTar:pr,extractZip:mr,cacheDir:_r}}function oi(){return{exec:v,getExecOutput:b}}async function si(n,r){let i=Date.now(),a=e({component:`setup`}),o=ai(),s=oi();try{a.info(`Starting setup`,{version:n.opencodeVersion});let e;try{e=Dr(n.authJson)}catch(e){return t(`Invalid auth-json: ${M(e)}`),null}let c=n.opencodeVersion;if(c===`latest`)try{c=await $r(a)}catch(e){a.warning(`Failed to get latest version, using fallback`,{error:M(e)}),c=qr}let l=n.omoVersion,u=I.env.RUNNER_TOOL_CACHE??`/opt/hostedtoolcache`,f=we(u,`opencode`),p=we(u,`bun`),h=we(Oe(),`.config`,`opencode`),_=w(),v=await ri({logger:a,os:_,opencodeVersion:c,omoVersion:l,toolCachePath:f,bunCachePath:p,omoConfigPath:h}),b=v.hit?`hit`:`miss`,x,S=!1,C=null;if(v.hit){let e=o.find(`opencode`,c);e.length>0?(x={path:e,version:c,cached:!0},a.info(`Tools cache hit, using cached OpenCode CLI`,{version:c,omoVersion:l})):a.warning(`Tools cache hit but binary not found in tool-cache, falling through to install`,{requestedVersion:c,restoredKey:v.restoredKey})}if(x==null)try{x=await Zr(c,a,o,s)}catch(e){return t(`Failed to install OpenCode: ${M(e)}`),null}let T=!1;try{await jr(a,o,s,d,g),T=!0}catch(e){a.warning(`Bun installation failed, oMo will be unavailable`,{error:M(e)})}if(T){if(n.omoConfig!=null)try{await Wr(n.omoConfig,h,a)}catch(e){a.warning(`Failed to write omo-config, continuing without custom config`,{error:M(e)})}let e=await Gr(l,{logger:a,execAdapter:s},n.omoProviders);e.installed?(a.info(`oMo installed`,{version:e.version}),S=!0):a.warning(`oMo installation failed, continuing without oMo`,{error:e.error??`unknown error`}),C=e.error}let E={autoupdate:!1};if(n.opencodeConfig!=null){let e;try{e=JSON.parse(n.opencodeConfig)}catch{return t(`opencode-config must be valid JSON`),null}if(typeof e!=`object`||!e||Array.isArray(e))return t(`opencode-config must be a JSON object`),null;Object.assign(E,e)}m(`OPENCODE_CONFIG_CONTENT`,JSON.stringify(E)),v.hit||await ii({logger:a,os:_,opencodeVersion:c,omoVersion:l,toolCachePath:f,bunCachePath:p,omoConfigPath:h}),d(x.path),y(`opencode-path`,x.path),y(`opencode-version`,x.version),a.info(`OpenCode ready`,{version:x.version,cached:x.cached});let D=le(r),O=await Rr(D,null,r,a);m(`GH_TOKEN`,r),a.info(`GitHub CLI configured`),await Br(D,O.botLogin,a,s);let k=we(ue(),`opencode`),A=await Or(e,k,a);y(`auth-json-path`,A),a.info(`auth.json populated`,{path:A});let j=Date.now()-i,ee={opencodePath:x.path,opencodeVersion:x.version,ghAuthenticated:O.authenticated,omoInstalled:S,omoError:C,toolsCacheStatus:b,duration:j};return a.info(`Setup complete`,{duration:j}),ee}catch(e){let n=M(e);return a.error(`Setup failed`,{error:n}),t(n),null}}function ci(e){return{success:!0,data:e}}function li(e){return{success:!1,error:e}}const ui=[`OWNER`,`MEMBER`,`COLLABORATOR`];async function di(e,t){try{let{client:n,server:r}=await cn({signal:e});return t.debug(`OpenCode server bootstrapped`,{url:r.url}),ci({client:n,server:r,shutdown:()=>{r.close()}})}catch(e){let n=e instanceof Error?e.message:String(e);return t.warning(`Failed to bootstrap OpenCode server`,{error:n}),li(Error(`Server bootstrap failed: ${n}`))}}async function fi(e,t){let n=e??`opencode`;try{let e=``;await v(n,[`--version`],{listeners:{stdout:t=>{e+=t.toString()}},silent:!0});let r=/(\d+\.\d+\.\d+)/.exec(e)?.[1]??null;return t.debug(`OpenCode version verified`,{version:r}),{available:!0,version:r}}catch{return t.debug(`OpenCode not available, will attempt auto-setup`),{available:!1,version:null}}}async function pi(e){let{logger:t,opencodeVersion:n}=e,r=I.env.OPENCODE_PATH??null,i=await fi(r,t);if(i.available&&i.version!=null)return t.info(`OpenCode already available`,{version:i.version}),{path:r??`opencode`,version:i.version,didSetup:!1};t.info(`OpenCode not found, running auto-setup`,{requestedVersion:n});let a=await si({opencodeVersion:n,authJson:e.authJson,appId:null,privateKey:null,opencodeConfig:e.opencodeConfig,omoConfig:null,omoVersion:e.omoVersion,omoProviders:e.omoProviders},e.githubToken);if(a==null)throw Error(`Auto-setup failed: runSetup returned null`);return d(a.opencodePath),I.env.OPENCODE_PATH=a.opencodePath,t.info(`Auto-setup completed`,{version:a.opencodeVersion,path:a.opencodePath}),{path:a.opencodePath,version:a.opencodeVersion,didSetup:!0}}async function mi(t,n){let r={repo:t.agentContext.repo,commentId:t.agentContext.commentId,issueNumber:t.agentContext.issueNumber,issueType:t.agentContext.issueType,botLogin:t.botLogin},i=e({phase:`acknowledgment`});return await er(t.githubClient,r,i),n.debug(`Acknowledgment phase completed`),r}function hi(e,t){try{JSON.parse(e)}catch{throw Error(`${t} must be valid JSON`)}}function gi(e,t){let n=e.trim();if(!/^\d+$/.test(n))throw Error(`${t} must be a positive integer, received: ${e}`);let r=Number.parseInt(n,10);if(r===0)throw Error(`${t} must be a positive integer, received: ${e}`);return r}function _i(e){let t=e.trim(),n=t.indexOf(`/`);if(n===-1)throw Error(`Invalid model format: "${e}". Expected "provider/model" (e.g., "anthropic/claude-sonnet-4-20250514")`);let r=t.slice(0,n).trim(),i=t.slice(n+1).trim();if(r.length===0)throw Error(`Invalid model format: "${e}". Provider cannot be empty.`);if(i.length===0)throw Error(`Invalid model format: "${e}". Model ID cannot be empty.`);return{providerID:r,modelID:i}}function vi(e,t=`timeout`){let n=e.trim();if(!/^\d+$/.test(n))throw Error(`${t} must be a non-negative integer, received: ${e}`);let r=Number.parseInt(n,10);if(Number.isNaN(r)||r<0)throw Error(`${t} must be a non-negative integer, received: ${e}`);return r}const yi=[`claude`,`claude-max20`,`copilot`,`gemini`,`openai`,`opencode-zen`,`zai-coding-plan`,`kimi-for-coding`];function bi(e){let t=e.split(`,`).map(e=>e.trim().toLowerCase()).filter(e=>e.length>0),n=`no`,r=`no`,i=`no`,a=`no`,o=`no`,s=`no`,c=`no`;for(let e of t){if(!yi.includes(e))throw Error(`Invalid omo-providers value: "${e}". Valid values: ${yi.join(`, `)}`);switch(e){case`claude`:n=`yes`;break;case`claude-max20`:n=`max20`;break;case`copilot`:r=`yes`;break;case`gemini`:i=`yes`;break;case`openai`:a=`yes`;break;case`opencode-zen`:o=`yes`;break;case`zai-coding-plan`:s=`yes`;break;case`kimi-for-coding`:c=`yes`;break}}return{claude:n,copilot:r,gemini:i,openai:a,opencodeZen:o,zaiCodingPlan:s,kimiForCoding:c}}function xi(){try{let e=a(`github-token`,{required:!0}).trim();if(e.length===0)return li(Error(`github-token is required but was not provided`));let t=a(`auth-json`,{required:!0}).trim();if(t.length===0)return li(Error(`auth-json is required but was not provided`));hi(t,`auth-json`);let o=a(`prompt`).trim(),s=o.length>0?o:null,c=a(`session-retention`).trim(),l=c.length>0?gi(c,`session-retention`):50,u=a(`s3-backup`).trim().toLowerCase()===`true`,d=a(`s3-bucket`).trim(),f=d.length>0?d:null,p=a(`aws-region`).trim(),m=p.length>0?p:null,h=a(`agent`).trim(),g=h.length>0?h:fe,v=a(`model`).trim(),y=v.length>0?_i(v):null,b=a(`timeout`).trim(),x=b.length>0?vi(b):r,S=a(`opencode-version`).trim(),C=S.length>0?S:i,w=a(`skip-cache`).trim().toLowerCase()===`true`,T=a(`omo-version`).trim(),E=T.length>0?T:_,D=a(`omo-providers`).trim(),O=bi(D.length>0?D:``),k=a(`opencode-config`).trim(),A=k.length>0?k:null,j=a(`dedup-window`).trim(),ee=j.length>0?vi(j,`dedup-window`):n;if(A!=null){hi(A,`opencode-config`);let e=JSON.parse(A);if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Input 'opencode-config' must be a JSON object`)}return ci({githubToken:e,authJson:t,prompt:s,sessionRetention:l,s3Backup:u,s3Bucket:f,awsRegion:m,agent:g,model:y,timeoutMs:x,opencodeVersion:C,skipCache:w,omoVersion:E,omoProviders:O,opencodeConfig:A,dedupWindow:ee})}catch(e){return li(e instanceof Error?e:Error(String(e)))}}async function Si(n){let r=xi();if(!r.success)return t(`Invalid inputs: ${r.error.message}`),null;let i=r.data,a=e({phase:`main`});a.info(`Action inputs parsed`,{sessionRetention:i.sessionRetention,s3Backup:i.s3Backup,hasGithubToken:i.githubToken.length>0,hasPrompt:i.prompt!=null,agent:i.agent,hasModelOverride:i.model!=null,timeoutMs:i.timeoutMs});let o=await pi({logger:a,opencodeVersion:i.opencodeVersion,githubToken:i.githubToken,authJson:i.authJson,omoVersion:i.omoVersion,omoProviders:i.omoProviders,opencodeConfig:i.opencodeConfig});return o.didSetup?a.info(`OpenCode auto-setup completed`,{version:o.version}):a.info(`OpenCode already available`,{version:o.version}),F(N.OPENCODE_VERSION,o.version),n.debug(`Bootstrap phase completed`,{opencodeVersion:o.version}),{inputs:i,logger:a,opencodeResult:o}}const Ci=/^[0-9a-f]{40}$/i;function wi(){return{exec:v,getExecOutput:b}}async function Ti(e){let{workspacePath:t,logger:n,execAdapter:r=wi()}=e,i=B.join(t,`.git`),a=B.join(i,`opencode`);try{let e=(await z.readFile(a,`utf8`)).trim();if(e.length>0){if(Ci.test(e))return n.debug(`Project ID loaded from cache`,{projectId:e}),{projectId:e,source:`cached`};n.warning(`Invalid cached project ID format, regenerating`,{cachedId:e})}}catch(e){n.debug(`No cached project ID found`,{error:M(e)})}try{let e=await z.readFile(i,`utf8`),n=/^gitdir: (.+)$/m.exec(e);if(n==null)return{projectId:null,source:`error`,error:`Invalid .git file format`};i=B.resolve(t,n[1]),a=B.join(i,`opencode`)}catch(e){if((typeof e==`object`?e.code:void 0)!==`EISDIR`)return{projectId:null,source:`error`,error:`Not a git repository`}}try{let{stdout:e,exitCode:i}=await r.getExecOutput(`git`,[`rev-list`,`--max-parents=0`,`--all`],{cwd:t,silent:!0});if(i!==0||e.trim().length===0)return{projectId:null,source:`error`,error:`No commits found in repository`};let o=e.trim().split(` +`).map(e=>e.trim()).filter(e=>e.length>0).sort();if(o.length===0)return{projectId:null,source:`error`,error:`No root commits found`};let s=o[0];try{await z.writeFile(a,s,{encoding:`utf8`,flag:`wx`}),n.info(`Project ID generated and cached`,{projectId:s,source:`generated`})}catch(e){(typeof e==`object`?e.code:void 0)===`EEXIST`?n.debug(`Project ID file already written by concurrent process, skipping`,{projectId:s}):n.warning(`Failed to cache project ID (continuing)`,{error:M(e)})}return{projectId:s,source:`generated`}}catch(e){return{projectId:null,source:`error`,error:M(e)}}}async function Ei(n){let r=T(),i=e({phase:`cache`}),a=P(),o=B.join(a,`.git`,`opencode`),s=await oe({components:r,logger:i,storagePath:A(),authPath:ne(),projectIdPath:o,opencodeVersion:n.opencodeResult.version}),c=s.corrupted?`corrupted`:s.hit?`hit`:`miss`;n.logger.info(`Cache restore completed`,{cacheStatus:c,key:s.key});let l=await Ti({workspacePath:a,logger:i});l.source===`error`?i.warning(`Failed to generate project ID (continuing)`,{error:l.error}):i.debug(`Project ID ready`,{projectId:l.projectId,source:l.source});let u=e({phase:`server-bootstrap`}),d=await di(new AbortController().signal,u);if(!d.success)return t(`OpenCode server bootstrap failed: ${d.error.message}`),null;let f=d.data;return u.info(`SDK server bootstrapped successfully`),{cacheResult:s,cacheStatus:c,serverHandle:f}}const Di={markdownImage:/!\[([^\]]*)\]\((https:\/\/github\.com\/user-attachments\/assets\/[^)]+)\)/gi,markdownLink:/\[([^\]]+)\]\((https:\/\/github\.com\/user-attachments\/files\/[^)]+)\)/gi,htmlImage:/]*src=["'](https:\/\/github\.com\/user-attachments\/assets\/[^"']+)["'][^>]*>/gi};function Oi(e,t,n){e.lastIndex=0;let r=e.exec(t);for(;r!=null;)n(r),r=e.exec(t);e.lastIndex=0}function ki(e){let t=[],n=new Set;return Oi(Di.markdownImage,e,e=>{let r=e[2],i=e[1],a=e[0];r!=null&&i!=null&&!n.has(r)&&Sn(r)&&(n.add(r),t.push({url:r,originalMarkdown:a,altText:i,type:`image`}))}),Oi(Di.markdownLink,e,e=>{let r=e[2],i=e[1],a=e[0];r!=null&&i!=null&&!n.has(r)&&Sn(r)&&(n.add(r),t.push({url:r,originalMarkdown:a,altText:i,type:`file`}))}),Oi(Di.htmlImage,e,e=>{let r=e[1],i=e[0];if(r!=null&&!n.has(r)&&Sn(r)){n.add(r);let e=/alt=["']([^"']*)["']/i.exec(i);t.push({url:r,originalMarkdown:i,altText:e?.[1]??``,type:`image`})}}),Di.htmlImage.lastIndex=0,t}function Ai(e,t,n){try{let r=new URL(e).pathname.split(`/`).at(-1);if(r!=null&&/\.[a-z0-9]+$/i.test(r))return r;if(t.trim().length>0){let e=t.replaceAll(/[^\w.-]/g,`_`).slice(0,50);return e.trim().length>0?e:`attachment_${n+1}`}return`attachment_${n+1}`}catch{return`attachment_${n+1}`}}const ji={maxFiles:5,maxFileSizeBytes:5*1024*1024,maxTotalSizeBytes:15*1024*1024,allowedMimeTypes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`text/plain`,`text/markdown`,`text/csv`,`application/json`,`application/pdf`]},Mi=[`github.com`,`githubusercontent.com`];async function Ni(e,t,n,r,i){i.debug(`Downloading attachment`,{url:e.url});try{let a=await fetch(e.url,{headers:{Authorization:`Bearer ${n}`,Accept:`*/*`,"User-Agent":`fro-bot-agent`},redirect:`manual`}),o=a;if(a.status>=300&&a.status<400){let t=a.headers.get(`location`);if(t==null)return i.warning(`Redirect without location`,{url:e.url}),null;let n=new URL(t);if(!Mi.some(e=>n.hostname===e||n.hostname.endsWith(`.${e}`)))return i.warning(`Redirect to non-GitHub host blocked`,{url:e.url,redirectTo:n.hostname}),null;o=await fetch(t,{headers:{Accept:`*/*`,"User-Agent":`fro-bot-agent`},redirect:`follow`})}if(!o.ok)return i.warning(`Attachment download failed`,{url:e.url,status:o.status}),null;let s=o.headers.get(`content-length`);if(s!=null){let t=Number.parseInt(s,10);if(t>r.maxFileSizeBytes)return i.warning(`Attachment exceeds size limit (Content-Length)`,{url:e.url,size:t,limit:r.maxFileSizeBytes}),null}let c=ve.from(await o.arrayBuffer());if(c.length>r.maxFileSizeBytes)return i.warning(`Attachment exceeds size limit`,{url:e.url,size:c.length,limit:r.maxFileSizeBytes}),null;let l=o.headers.get(`content-type`)??`application/octet-stream`,u=Ai(e.url,e.altText,t),d=l.split(`;`)[0],f=d==null?`application/octet-stream`:d.trim(),p=await z.mkdtemp(B.join(Ee.tmpdir(),`fro-bot-attachments-`)),m=u.trim().length>0?u:`attachment_${t+1}`,h=B.join(p,m);return await z.writeFile(h,c),i.debug(`Attachment downloaded`,{filename:u,mime:f,sizeBytes:c.length,tempPath:h}),{url:e.url,filename:u,mime:f,sizeBytes:c.length,tempPath:h}}catch(t){return i.warning(`Attachment download error`,{url:e.url,error:M(t)}),null}}async function Pi(e,t,n=ji,r){return Promise.all(e.map(async(e,i)=>Ni(e,i,t,n,r)))}async function Fi(e,t){for(let n of e)try{await z.unlink(n);let e=B.dirname(n);await z.rmdir(e).catch(()=>{})}catch(e){t.debug(`Failed to cleanup temp file`,{path:n,error:M(e)})}}function Ii(e){return e.map(e=>({type:`file`,mime:e.mime,url:xe(e.tempPath).toString(),filename:e.filename}))}function Li(e,t,n){let r=e,i=new Set(n.map(e=>e.filename));for(let e of t){let t=n.find(e=>i.has(e.filename));t!=null&&(r=r.replace(e.originalMarkdown,`@${t.filename}`))}return r}function Ri(e,t,n,r){return{processed:n,skipped:r,modifiedBody:Li(e,t,n),fileParts:Ii(n),tempFiles:n.map(e=>e.tempPath)}}function zi(e){if(e<0||!Number.isFinite(e))throw Error(`Invalid bytes value: ${e}`);return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Bi(e,t=ji,n){let r=[],i=[],a=0;for(let o of e)if(o!=null){if(r.length>=t.maxFiles){i.push({url:o.url,reason:`Exceeds max file count (${t.maxFiles})`}),n.debug(`Attachment skipped: max count`,{url:o.url});continue}if(o.sizeBytes>t.maxFileSizeBytes){i.push({url:o.url,reason:`File too large (${zi(o.sizeBytes)} > ${zi(t.maxFileSizeBytes)})`}),n.debug(`Attachment skipped: too large`,{url:o.url,size:o.sizeBytes});continue}if(a+o.sizeBytes>t.maxTotalSizeBytes){i.push({url:o.url,reason:`Would exceed total size limit (${zi(t.maxTotalSizeBytes)})`}),n.debug(`Attachment skipped: total size exceeded`,{url:o.url});continue}if(!Vi(o.mime,t.allowedMimeTypes)){i.push({url:o.url,reason:`MIME type not allowed: ${o.mime}`}),n.debug(`Attachment skipped: MIME type`,{url:o.url,mime:o.mime});continue}a+=o.sizeBytes,r.push({filename:o.filename,mime:o.mime,sizeBytes:o.sizeBytes,tempPath:o.tempPath}),n.info(`Attachment validated`,{filename:o.filename,mime:o.mime,sizeBytes:o.sizeBytes})}return{validated:r,skipped:i}}function Vi(e,t){let[n]=e.split(`/`);for(let r of t)if(r===e||r.endsWith(`/*`)&&n!=null&&n===r.slice(0,-2))return!0;return!1}function J(e){let t=B.resolve(e);return t.endsWith(B.sep)&&t.length>1?t.slice(0,-1):t}const Hi=e=>typeof e==`object`&&!!e,Y=e=>typeof e==`string`?e:null,Ui=e=>typeof e==`number`?e:null;function Wi(e){if(Array.isArray(e))return e.filter(Hi).map(e=>({file:Y(e.file)??``,additions:Ui(e.additions)??0,deletions:Ui(e.deletions)??0}))}function Gi(e){return{id:e.id,version:e.version,projectID:e.projectID,directory:e.directory,parentID:e.parentID,title:e.title,time:{created:e.time.created,updated:e.time.updated,compacting:e.time.compacting,archived:e.time.archived},summary:e.summary==null?void 0:{additions:e.summary.additions,deletions:e.summary.deletions,files:e.summary.files,diffs:Wi(e.summary.diffs)},share:e.share?.url==null?void 0:{url:e.share.url},permission:e.permission==null?void 0:{rules:e.permission.rules},revert:e.revert==null?void 0:{messageID:e.revert.messageID,partID:e.revert.partID,snapshot:e.revert.snapshot,diff:e.revert.diff}}}async function Ki(e,t){let n=await e.project.list();if(n.error!=null||n.data==null)return t.warning(`SDK project list failed`,{error:String(n.error)}),[];if(!Array.isArray(n.data))return[];let r=[];for(let e of n.data){if(!Hi(e))continue;let t=Y(e.id),n=Y(e.worktree),i=Y(e.path);t==null||n==null||i==null||r.push({id:t,worktree:n,path:i,vcs:`git`,time:{created:0,updated:0}})}return r}async function qi(e,t,n){let r=J(t),i=await Ki(e,n);for(let e of i){if(J(e.worktree)===r)return e;let t=Y(e.path);if(t!=null&&J(t)===r)return e}return null}function Ji(e){return e.status===`running`?{status:`running`,input:e.input,time:{start:e.time.start}}:e.status===`error`?{status:`error`,input:e.input,error:e.error,time:{start:e.time.start,end:e.time.end}}:e.status===`pending`?{status:`pending`}:{status:`completed`,input:e.input,output:e.output,title:e.title,metadata:e.metadata,time:{start:e.time.start,end:e.time.end,compacted:e.time.compacted},attachments:void 0}}function Yi(e){let t={id:e.id,sessionID:e.sessionID,messageID:e.messageID};if(e.type===`text`)return{...t,type:`text`,text:e.text,synthetic:e.synthetic,ignored:e.ignored,time:e.time,metadata:e.metadata};if(e.type===`reasoning`)return{...t,type:`reasoning`,reasoning:e.reasoning??e.text,time:e.time};if(e.type===`tool`)return{...t,type:`tool`,callID:e.callID,tool:e.tool,state:Ji(e.state),metadata:e.metadata};if(e.type!==`step-finish`)return{...t,type:`text`,text:`text`in e?e.text:``};let n=e;return{...t,type:`step-finish`,reason:n.reason,snapshot:n.snapshot,cost:n.cost,tokens:{input:n.tokens.input,output:n.tokens.output,reasoning:n.tokens.reasoning,cache:{read:n.tokens.cache.read,write:n.tokens.cache.write}}}}function Xi(e){if(e.role===`user`){let t=e;return{id:t.id,sessionID:t.sessionID,role:`user`,time:{created:t.time.created},summary:t.summary==null?void 0:{title:t.summary.title,body:t.summary.body,diffs:Wi(t.summary.diffs)??[]},agent:t.agent,model:{providerID:t.model.providerID,modelID:t.model.modelID},system:t.system,tools:t.tools,variant:t.variant}}let t=e;return{id:t.id,sessionID:t.sessionID,role:`assistant`,time:{created:t.time.created,completed:t.time.completed},parentID:t.parentID,modelID:t.modelID,providerID:t.providerID,mode:t.mode,agent:t.agent??``,path:{cwd:t.path.cwd,root:t.path.root},summary:t.summary,cost:t.cost,tokens:{input:t.tokens.input,output:t.tokens.output,reasoning:t.tokens.reasoning,cache:{read:t.tokens.cache.read,write:t.tokens.cache.write}},finish:t.finish,error:t.error?{name:t.error.name,message:Y(t.error.data.message)??``}:void 0}}function Zi(e){return[...e.map(e=>{let t=Xi(`info`in e?e.info:e),n=`parts`in e?e.parts.map(Yi):void 0;return n==null||n.length===0?t:{...t,parts:n}})].sort((e,t)=>e.time.created-t.time.created)}async function Qi(e,t,n){let r=await e.session.list({query:{directory:t}});return r.error==null&&r.data!=null?Array.isArray(r.data)?r.data.map(Gi):[]:(n.warning(`SDK session list failed`,{error:String(r.error)}),[])}async function $i(e,t,n){let r=await e.session.messages({path:{id:t}});return r.error==null&&r.data!=null?Zi(r.data):(n.warning(`SDK session messages failed`,{error:String(r.error)}),[])}async function ea(e,t,n,r){let i=await e.session.list({query:{directory:t,start:n,roots:!0,limit:10}});if(i.error!=null||i.data==null)return r.warning(`SDK session list failed`,{error:String(i.error)}),null;if(!Array.isArray(i.data)||i.data.length===0)return null;let a=i.data.map(Gi);if(a.length===0)return null;let o=a.reduce((e,t)=>t.time.created>e.time.created?t:e);return{projectID:o.projectID,session:o}}async function ta(e,t,n){let r=await e.session.delete({path:{id:t}});if(r.error!=null){n.warning(`SDK session delete failed`,{sessionID:t,error:String(r.error)});return}n.debug(`Deleted session via SDK`,{sessionID:t})}const na={maxSessions:50,maxAgeDays:30};async function ra(e,t,n,r){let{maxSessions:i,maxAgeDays:a}=n;if(r.info(`Starting session pruning`,{workspacePath:t,maxSessions:i,maxAgeDays:a}),await qi(e,t,r)==null)return r.debug(`No project found for pruning`,{workspacePath:t}),{prunedCount:0,prunedSessionIds:[],remainingCount:0,freedBytes:0};let o=await Qi(e,t,r),s=o.filter(e=>e.parentID==null);if(s.length===0)return{prunedCount:0,prunedSessionIds:[],remainingCount:0,freedBytes:0};let c=[...s].sort((e,t)=>t.time.updated-e.time.updated),l=new Date;l.setDate(l.getDate()-a);let u=l.getTime(),d=new Set;for(let e of c)e.time.updated>=u&&d.add(e.id);for(let e=0;e!d.has(e.id)),p=new Set;for(let e of f){p.add(e.id);for(let t of o)t.parentID===e.id&&p.add(t.id)}if(p.size===0)return r.info(`No sessions to prune`),{prunedCount:0,prunedSessionIds:[],remainingCount:s.length,freedBytes:0};let m=[];for(let t of p)try{await ta(e,t,r),m.push(t),r.debug(`Pruned session`,{sessionId:t})}catch(e){r.warning(`Failed to prune session`,{sessionId:t,error:M(e)})}let h=s.length-f.length;return r.info(`Session pruning complete`,{prunedCount:m.length,remainingCount:h}),{prunedCount:m.length,prunedSessionIds:m,remainingCount:h,freedBytes:0}}async function ia(e,t,n,r){let{limit:i,fromDate:a,toDate:o}=n;r.debug(`Listing sessions`,{directory:t,limit:i});let s=[...(await Qi(e,t,r)).filter(e=>!(e.parentID!=null||a!=null&&e.time.createdo.getTime()))].sort((e,t)=>t.time.updated-e.time.updated),c=[],l=i==null?s:s.slice(0,i);for(let t of l){let n=await $i(e,t.id,r),i=aa(n);c.push({id:t.id,projectID:t.projectID,directory:t.directory,title:t.title,createdAt:t.time.created,updatedAt:t.time.updated,messageCount:n.length,agents:i,isChild:!1})}return r.info(`Listed sessions`,{count:c.length,directory:t}),c}function aa(e){let t=new Set;for(let n of e)n.agent!=null&&t.add(n.agent);return[...t]}async function oa(e,t,n,r,i){let{limit:a=20,caseSensitive:o=!1,sessionId:s}=r;i.debug(`Searching sessions`,{query:e,directory:n,limit:a,caseSensitive:o});let c=o?e:e.toLowerCase(),l=[],u=0;if(s!=null){let e=await sa(t,s,c,o,i);return e.length>0&&l.push({sessionId:s,matches:e.slice(0,a)}),l}let d=await ia(t,n,{},i);for(let e of d){if(u>=a)break;let n=await sa(t,e.id,c,o,i);if(n.length>0){let t=a-u;l.push({sessionId:e.id,matches:n.slice(0,t)}),u+=Math.min(n.length,t)}}return i.info(`Session search complete`,{query:e,resultCount:l.length,totalMatches:u}),l}async function sa(e,t,n,r,i){let a=await $i(e,t,i),o=[];for(let e of a){let t=e.parts??[];for(let i of t){let t=ca(i);if(t==null)continue;let a=r?t:t.toLowerCase();if(a.includes(n)){let r=a.indexOf(n),s=Math.max(0,r-50),c=Math.min(t.length,r+n.length+50),l=t.slice(s,c);o.push({messageId:e.id,partId:i.id,excerpt:`...${l}...`,role:e.role,agent:e.agent})}}}return o}function ca(e){switch(e.type){case`text`:return e.text;case`reasoning`:return e.reasoning;case`tool`:return e.state.status===`completed`?`${e.tool}: ${e.state.output}`:null;case`step-finish`:return null}}function la(e){let t=[`--- Fro Bot Run Summary ---`,`Event: ${e.eventType}`,`Repo: ${e.repo}`,`Ref: ${e.ref}`,`Run ID: ${e.runId}`,`Cache: ${e.cacheStatus}`,`Duration: ${e.duration}s`];return e.sessionIds.length>0&&t.push(`Sessions used: ${e.sessionIds.join(`, `)}`),e.logicalKey!=null&&t.push(`Logical Thread: ${e.logicalKey}`),e.createdPRs.length>0&&t.push(`PRs created: ${e.createdPRs.join(`, `)}`),e.createdCommits.length>0&&t.push(`Commits: ${e.createdCommits.join(`, `)}`),e.tokenUsage!=null&&t.push(`Tokens: ${e.tokenUsage.input} in / ${e.tokenUsage.output} out`),t.join(` +`)}async function ua(e,t,n,r){let i=la(t);try{let t=await n.session.prompt({path:{id:e},body:{noReply:!0,parts:[{type:`text`,text:i}]}});if(t.error!=null){r.warning(`SDK prompt writeback failed`,{sessionId:e,error:String(t.error)});return}r.info(`Session summary written via SDK`,{sessionId:e})}catch(t){r.warning(`SDK prompt writeback failed`,{sessionId:e,error:M(t)})}}async function da(t){let{bootstrapLogger:n,reactionCtx:r,githubClient:i,agentSuccess:a,attachmentResult:o,serverHandle:s,detectedOpencodeVersion:c}=t;try{if(o!=null){let t=e({phase:`attachment-cleanup`});await Fi(o.tempFiles,t)}r!=null&&i!=null&&await or(i,r,a,e({phase:`cleanup`}));let t=e({phase:`prune`}),n=P();if(s!=null){let e=J(n),r=await ra(s.client,e,na,t);r.prunedCount>0&&t.info(`Pruned old sessions`,{pruned:r.prunedCount,remaining:r.remainingCount})}let l=T(),u=e({phase:`cache-save`}),d=B.join(n,`.git`,`opencode`);if(await re({components:l,runId:k(),logger:u,storagePath:A(),authPath:ne(),projectIdPath:d,opencodeVersion:c})&&F(N.CACHE_SAVED,`true`),pe()){let t=e({phase:`artifact-upload`});await ce({logPath:j(),runId:k(),runAttempt:O(),logger:t})&&F(N.ARTIFACT_UPLOADED,`true`)}}catch(e){n.warning(`Cleanup failed (non-fatal)`,{error:e instanceof Error?e.message:String(e)})}finally{if(s!=null)try{s.shutdown()}catch(e){n.warning(`Server shutdown failed (non-fatal)`,{error:e instanceof Error?e.message:String(e)})}}}const fa=B.join(De.homedir(),`.cache`,`fro-bot-dedup`);function pa(e){return e.replaceAll(`/`,`-`)}function ma(e,t){let n=pa(e);return B.join(fa,`${n}-${t.entityType}-${t.entityNumber}`)}function ha(e,t){return`${E}-${pa(e)}-${t.entityType}-${t.entityNumber}-`}function ga(e,t,n){return`${ha(e,t)}${n}`}async function _a(e,t,n,r=ee){let i=ma(e,t),a=B.join(i,`sentinel.json`),o=ha(e,t);try{if(await z.rm(i,{recursive:!0,force:!0}),await z.mkdir(i,{recursive:!0}),await r.restoreCache([i],o,[])==null)return null;let e=await z.readFile(a,`utf8`);return JSON.parse(e)}catch(e){return n.debug(`Dedup marker restore failed; proceeding without marker`,{error:M(e),entityType:t.entityType,entityNumber:t.entityNumber}),null}}async function va(e,t,n,r,i=ee){let a=ma(e,t),o=B.join(a,`sentinel.json`),s=ga(e,t,n.runId);try{return await z.mkdir(a,{recursive:!0}),await z.writeFile(o,JSON.stringify(n),`utf8`),await i.saveCache([a],s),!0}catch(e){return M(e).toLowerCase().includes(`already exists`)?!0:(r.debug(`Dedup marker save failed`,{error:M(e),entityType:t.entityType,entityNumber:t.entityNumber,saveKey:s}),!1)}}const ya=new Set([`pull_request`,`issues`]),ba=new Set([`synchronize`,`reopened`]);function xa(e){return e.target==null||!ya.has(e.eventType)?null:e.eventType===`pull_request`&&e.target.kind===`pr`?{entityType:`pr`,entityNumber:e.target.number}:e.eventType===`issues`&&e.target.kind===`issue`?{entityType:`issue`,entityNumber:e.target.number}:null}async function Sa(t,n,r,i,a=e({phase:`dedup`}),o){let s=xa(n);if(t===0)return{shouldProceed:!0,entity:s};if(s==null)return{shouldProceed:!0,entity:null};if(n.action!=null&&ba.has(n.action))return a.debug(`Dedup bypassed for action`,{action:n.action}),{shouldProceed:!0,entity:s};let c=await _a(r,s,a,o);if(c==null||c.runId===n.runId)return{shouldProceed:!0,entity:s};let l=new Date(c.timestamp).getTime();if(Number.isNaN(l))return a.warning(`Dedup marker timestamp is invalid; proceeding without dedup`,{markerTimestamp:c.timestamp}),{shouldProceed:!0,entity:s};let u=Date.now()-l;if(u<-6e4)return a.warning(`Dedup marker timestamp is too far in the future; proceeding without dedup`,{markerTimestamp:c.timestamp,markerAge:u}),{shouldProceed:!0,entity:s};let d=Math.max(0,u);return d>t?{shouldProceed:!0,entity:s}:(a.info(`Skipping duplicate trigger within dedup window`,{eventType:n.eventType,action:n.action,runId:n.runId,markerRunId:c.runId,markerTimestamp:c.timestamp,dedupWindow:t,entityType:s.entityType,entityNumber:s.entityNumber}),V({sessionId:null,cacheStatus:`miss`,duration:Date.now()-i}),await wa(n,s,c,d,t,a),{shouldProceed:!1,entity:s})}async function Ca(t,n,r,i=e({phase:`dedup`}),a){await va(r,n,{timestamp:new Date().toISOString(),runId:t.runId,action:t.action??`unknown`,eventType:t.eventType,entityType:n.entityType,entityNumber:n.entityNumber},i,a)}async function wa(e,t,n,r,i,a){try{let a=Math.round(r/1e3),o=Math.round(i/1e3),s=`${t.entityType} #${t.entityNumber}`,c=`https://github.com/${e.repo.owner}/${e.repo.repo}/actions/runs/${n.runId}`;S.addHeading(`Fro Bot Agent Run — Skipped (Dedup)`,2).addRaw(`Execution skipped because the agent already ran for **${s}** recently.\n\n`).addTable([[{data:`Detail`,header:!0},{data:`Value`,header:!0}],[`Current action`,`\`${e.eventType}.${e.action??`unknown`}\``],[`Prior run`,`[${n.runId}](${c})`],[`Prior action`,`\`${n.eventType}.${n.action}\``],[`Time since prior run`,`${a}s`],[`Dedup window`,`${o}s`]]).addRaw(` > Dedup is best-effort suppression. Use workflow concurrency groups to prevent overlapping runs. -`),await S.write()}catch(e){a.warning(`Failed to write dedup skip summary`,{error:A(e)})}}async function wa(t,n,r,i,a,o){let s={context:n.agentContext,customPrompt:t.inputs.prompt,cacheStatus:r.cacheStatus,sessionContext:{recentSessions:i.recentSessions,priorWorkContext:i.priorWorkContext},logicalKey:i.logicalKey??null,isContinuation:i.isContinuation,currentThreadSessionId:i.continueSessionId??null,triggerContext:n.triggerResult.context,fileParts:i.attachmentResult?.fileParts},c=N.env.SKIP_AGENT_EXECUTION===`true`,l=Date.now(),u;if(c)t.logger.info(`Skipping agent execution (SKIP_AGENT_EXECUTION=true)`),u={success:!0,exitCode:0,sessionId:null,error:null,tokenUsage:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:null};else{let n=e({phase:`execution`});n.info(`Starting OpenCode execution`,{logicalKey:i.logicalKey?.key??null,continueSessionId:i.continueSessionId});let a=await Yn(s,n,{agent:t.inputs.agent,model:t.inputs.model,timeoutMs:t.inputs.timeoutMs,omoProviders:t.inputs.omoProviders,continueSessionId:i.continueSessionId??void 0,sessionTitle:i.sessionTitle??void 0},r.serverHandle),o=a.sessionId;if(o==null){let t=e({phase:`session`}),n=await $i(r.serverHandle.client,i.normalizedWorkspace,l,t);n!=null&&(o=n.session.id,t.debug(`Identified session from execution`,{sessionId:o}))}u={...a,sessionId:o},n.info(`Completed OpenCode execution`,{success:u.success,sessionId:u.sessionId,logicalKey:i.logicalKey?.key??null})}u.sessionId!=null&&(M(j.SESSION_ID,u.sessionId),a.addSessionCreated(u.sessionId)),u.tokenUsage!=null&&a.setTokenUsage(u.tokenUsage,u.model,u.cost);for(let e of u.prsCreated)a.addPRCreated(e);for(let e of u.commitsCreated)a.addCommitCreated(e);for(let e=0;e`)}async function Da(e,t,n){try{if(t.type===`pr`){let{data:n}=await e.rest.pulls.get({owner:t.owner,repo:t.repo,pull_number:t.number});return{title:n.title,body:n.body??``,author:n.user?.login??`unknown`}}let{data:n}=await e.rest.issues.get({owner:t.owner,repo:t.repo,issue_number:t.number});return{title:n.title,body:n.body??``,author:n.user?.login??`unknown`}}catch(e){return n.warning(`Failed to fetch issue/PR`,{target:t,error:A(e)}),null}}async function Oa(e,t,n,r){let i=[],a=1;for(;a<=50;)try{let{data:r}=await e.rest.issues.listComments({owner:t.owner,repo:t.repo,issue_number:t.number,per_page:100,page:a});if(r.length===0)break;for(let e of r){let t=e.user?.login??`unknown`;i.push({id:e.id,body:e.body??``,author:t,authorAssociation:e.author_association??`NONE`,createdAt:e.created_at,updatedAt:e.updated_at,isBot:Ea(t,e.body??``,n)})}if(r.length<100)break;a++}catch(e){r.warning(`Failed to fetch comments page`,{target:t,page:a,error:A(e)});break}return i}async function ka(e,t,n,r){try{let i=[],a=null,o=null,s=``,c=``,l=`unknown`,u=0;for(;u<50;){let d=(await e.graphql(` +`),await S.write()}catch(e){a.warning(`Failed to write dedup skip summary`,{error:M(e)})}}async function Ta(t,n,r,i,a,o){let s={context:n.agentContext,customPrompt:t.inputs.prompt,cacheStatus:r.cacheStatus,sessionContext:{recentSessions:i.recentSessions,priorWorkContext:i.priorWorkContext},logicalKey:i.logicalKey??null,isContinuation:i.isContinuation,currentThreadSessionId:i.continueSessionId??null,triggerContext:n.triggerResult.context,fileParts:i.attachmentResult?.fileParts},c=I.env.SKIP_AGENT_EXECUTION===`true`,l=Date.now(),u;if(c)t.logger.info(`Skipping agent execution (SKIP_AGENT_EXECUTION=true)`),u={success:!0,exitCode:0,sessionId:null,error:null,tokenUsage:null,model:null,cost:null,prsCreated:[],commitsCreated:[],commentsPosted:0,llmError:null};else{let n=e({phase:`execution`});n.info(`Starting OpenCode execution`,{logicalKey:i.logicalKey?.key??null,continueSessionId:i.continueSessionId});let a=await Zn(s,n,{agent:t.inputs.agent,model:t.inputs.model,timeoutMs:t.inputs.timeoutMs,omoProviders:t.inputs.omoProviders,continueSessionId:i.continueSessionId??void 0,sessionTitle:i.sessionTitle??void 0},r.serverHandle),o=a.sessionId;if(o==null){let t=e({phase:`session`}),n=await ea(r.serverHandle.client,i.normalizedWorkspace,l,t);n!=null&&(o=n.session.id,t.debug(`Identified session from execution`,{sessionId:o}))}u={...a,sessionId:o},n.info(`Completed OpenCode execution`,{success:u.success,sessionId:u.sessionId,logicalKey:i.logicalKey?.key??null})}u.sessionId!=null&&(F(N.SESSION_ID,u.sessionId),a.addSessionCreated(u.sessionId)),u.tokenUsage!=null&&a.setTokenUsage(u.tokenUsage,u.model,u.cost);for(let e of u.prsCreated)a.addPRCreated(e);for(let e of u.commitsCreated)a.addCommitCreated(e);for(let e=0;e`)}async function Oa(e,t,n){try{if(t.type===`pr`){let{data:n}=await e.rest.pulls.get({owner:t.owner,repo:t.repo,pull_number:t.number});return{title:n.title,body:n.body??``,author:n.user?.login??`unknown`}}let{data:n}=await e.rest.issues.get({owner:t.owner,repo:t.repo,issue_number:t.number});return{title:n.title,body:n.body??``,author:n.user?.login??`unknown`}}catch(e){return n.warning(`Failed to fetch issue/PR`,{target:t,error:M(e)}),null}}async function ka(e,t,n,r){let i=[],a=1;for(;a<=50;)try{let{data:r}=await e.rest.issues.listComments({owner:t.owner,repo:t.repo,issue_number:t.number,per_page:100,page:a});if(r.length===0)break;for(let e of r){let t=e.user?.login??`unknown`;i.push({id:e.id,body:e.body??``,author:t,authorAssociation:e.author_association??`NONE`,createdAt:e.created_at,updatedAt:e.updated_at,isBot:Da(t,e.body??``,n)})}if(r.length<100)break;a++}catch(e){r.warning(`Failed to fetch comments page`,{target:t,page:a,error:M(e)});break}return i}async function Aa(e,t,n,r){try{let i=[],a=null,o=null,s=``,c=``,l=`unknown`,u=0;for(;u<50;){let d=(await e.graphql(` query GetDiscussion($owner: String!, $repo: String!, $number: Int!, $after: String) { repository(owner: $owner, name: $repo) { discussion(number: $number) { @@ -287,7 +287,7 @@ If you had completed the task, confirm the completion.`,u=r===1?e.fileParts:void } } } -`,{owner:t.owner,repo:t.repo,number:t.number,after:a})).repository.discussion;if(d==null)return r.debug(`Discussion not found`,{target:t}),null;u===0&&(o=d.id,s=d.title,c=d.body,l=d.author?.login??`unknown`);for(let e of d.comments.nodes){let t=e.author?.login??`unknown`;i.push({id:e.id,body:e.body,author:t,authorAssociation:`NONE`,createdAt:e.createdAt,updatedAt:e.updatedAt,isBot:Ea(t,e.body,n)})}if(!d.comments.pageInfo.hasNextPage)break;a=d.comments.pageInfo.endCursor,u++}return{type:`discussion`,number:t.number,title:s,body:c,author:l,comments:i,discussionId:o??void 0}}catch(e){return r.warning(`Failed to fetch discussion`,{target:t,error:A(e)}),null}}async function Aa(e,t,n,r){if(t.type===`discussion`)return ka(e,t,n,r);let i=await Da(e,t,r);if(i==null)return null;let a=await Oa(e,t,n,r);return{type:t.type,number:t.number,title:i.title,body:i.body,author:i.author,comments:a}}function ja(e,t){let n=e.comments.filter(e=>Ta(e.author,t)&&e.body.includes(``));return n.length===0?null:n.at(-1)??null}async function Ma(e,t,n,r){try{let{data:i}=await e.rest.issues.createComment({owner:t.owner,repo:t.repo,issue_number:t.number,body:n});return r.debug(`Created issue comment`,{commentId:i.id,target:t}),{commentId:i.id,created:!0,updated:!1,url:i.html_url}}catch(e){return r.warning(`Failed to create issue comment`,{target:t,error:A(e)}),null}}async function Na(e,t,n,r,i){try{let{data:a}=await e.rest.issues.updateComment({owner:t.owner,repo:t.repo,comment_id:n,body:r});return i.debug(`Updated issue comment`,{commentId:a.id,target:t}),{commentId:a.id,created:!1,updated:!0,url:a.html_url}}catch(e){return i.warning(`Failed to update issue comment`,{target:t,commentId:n,error:A(e)}),null}}async function Pa(e,t,n,r){try{let i=(await e.graphql(` +`,{owner:t.owner,repo:t.repo,number:t.number,after:a})).repository.discussion;if(d==null)return r.debug(`Discussion not found`,{target:t}),null;u===0&&(o=d.id,s=d.title,c=d.body,l=d.author?.login??`unknown`);for(let e of d.comments.nodes){let t=e.author?.login??`unknown`;i.push({id:e.id,body:e.body,author:t,authorAssociation:`NONE`,createdAt:e.createdAt,updatedAt:e.updatedAt,isBot:Da(t,e.body,n)})}if(!d.comments.pageInfo.hasNextPage)break;a=d.comments.pageInfo.endCursor,u++}return{type:`discussion`,number:t.number,title:s,body:c,author:l,comments:i,discussionId:o??void 0}}catch(e){return r.warning(`Failed to fetch discussion`,{target:t,error:M(e)}),null}}async function ja(e,t,n,r){if(t.type===`discussion`)return Aa(e,t,n,r);let i=await Oa(e,t,r);if(i==null)return null;let a=await ka(e,t,n,r);return{type:t.type,number:t.number,title:i.title,body:i.body,author:i.author,comments:a}}function Ma(e,t){let n=e.comments.filter(e=>Ea(e.author,t)&&e.body.includes(``));return n.length===0?null:n.at(-1)??null}async function Na(e,t,n,r){try{let{data:i}=await e.rest.issues.createComment({owner:t.owner,repo:t.repo,issue_number:t.number,body:n});return r.debug(`Created issue comment`,{commentId:i.id,target:t}),{commentId:i.id,created:!0,updated:!1,url:i.html_url}}catch(e){return r.warning(`Failed to create issue comment`,{target:t,error:M(e)}),null}}async function Pa(e,t,n,r,i){try{let{data:a}=await e.rest.issues.updateComment({owner:t.owner,repo:t.repo,comment_id:n,body:r});return i.debug(`Updated issue comment`,{commentId:a.id,target:t}),{commentId:a.id,created:!1,updated:!0,url:a.html_url}}catch(e){return i.warning(`Failed to update issue comment`,{target:t,commentId:n,error:M(e)}),null}}async function Fa(e,t,n,r){try{let i=(await e.graphql(` query GetDiscussionId($owner: String!, $repo: String!, $number: Int!) { repository(owner: $owner, name: $repo) { discussion(number: $number) { @@ -308,7 +308,7 @@ If you had completed the task, confirm the completion.`,u=r===1?e.fileParts:void } } } -`,{owner:t.owner,repo:t.repo,number:t.number})).repository.discussion;if(i==null)return r.warning(`Discussion not found`,{target:t}),null;if(n.updateExisting===!0&&n.botLogin!=null){let i=await Aa(e,t,n.botLogin,r);if(i!=null){let t=ja(i,n.botLogin);if(t!=null&&typeof t.id==`string`){let i=await e.graphql(` +`,{owner:t.owner,repo:t.repo,number:t.number})).repository.discussion;if(i==null)return r.warning(`Discussion not found`,{target:t}),null;if(n.updateExisting===!0&&n.botLogin!=null){let i=await ja(e,t,n.botLogin,r);if(i!=null){let t=Ma(i,n.botLogin);if(t!=null&&typeof t.id==`string`){let i=await e.graphql(` mutation UpdateDiscussionComment($commentId: ID!, $body: String!) { updateDiscussionComment(input: {commentId: $commentId, body: $body}) { comment { id url } @@ -320,4 +320,4 @@ If you had completed the task, confirm the completion.`,u=r===1?e.fileParts:void comment { id url } } } -`,{discussionId:i.id,body:n.body});return r.debug(`Created discussion comment`,{discussionId:i.id}),{commentId:a.addDiscussionComment.comment.id,created:!0,updated:!1,url:a.addDiscussionComment.comment.url}}catch(e){return r.warning(`Failed to post discussion comment`,{target:t,error:A(e)}),null}}async function Fa(e,t,n,r){if(t.type===`discussion`)return Pa(e,t,n,r);if(n.updateExisting===!0&&n.botLogin!=null){let i=await Aa(e,t,n.botLogin,r);if(i!=null){let a=ja(i,n.botLogin);if(a!=null&&typeof a.id==`number`)return Na(e,t,a.id,n.body,r)}}return Ma(e,t,n.body,r)}async function Ia(n,r,i,a,o,s,c){let l=Date.now()-s;if(z({sessionId:a.sessionId,cacheStatus:i.cacheStatus,duration:l}),await Pe({eventType:r.agentContext.eventName,repo:r.agentContext.repo,ref:r.agentContext.ref,runId:Number(r.agentContext.runId),runUrl:`https://github.com/${r.agentContext.repo}/actions/runs/${r.agentContext.runId}`,metrics:o.getMetrics(),agent:n.inputs.agent},c),a.success)return c.info(`Agent run completed successfully`,{durationMs:l}),0;if(a.llmError==null)return t(`Agent execution failed with exit code ${a.exitCode}`),a.exitCode;c.info(`Agent failed with recoverable LLM error`,{error:a.llmError.message,type:a.llmError.type,durationMs:l});let[u,d]=r.agentContext.repo.split(`/`),f={type:r.triggerResult.context.eventType===`discussion_comment`?`discussion`:r.agentContext.issueType===`pr`?`pr`:`issue`,number:r.agentContext.issueNumber??0,owner:u??``,repo:d??``};if(f.number>0&&f.owner.length>0&&f.repo.length>0){let t=dn(a.llmError),n=e({phase:`error-comment`}),i=await Fa(r.githubClient,f,{body:t},n);i==null?n.warning(`Failed to post LLM error comment`):(n.info(`Posted LLM error comment`,{commentUrl:i.url}),o.incrementComments())}else c.warning(`Cannot post error comment: missing target context`);return 0}function La(e){switch(e){case`issue_comment`:return`issue_comment`;case`discussion`:case`discussion_comment`:return`discussion_comment`;case`workflow_dispatch`:return`workflow_dispatch`;case`issues`:return`issues`;case`pull_request`:return`pull_request`;case`pull_request_review_comment`:return`pull_request_review_comment`;case`schedule`:return`schedule`;default:return`unsupported`}}function Ra(e,t){switch(e){case`issue_comment`:{let e=t;return{type:`issue_comment`,action:e.action,issue:{number:e.issue.number,title:e.issue.title,body:e.issue.body??null,locked:e.issue.locked??!1,isPullRequest:e.issue.pull_request!=null},comment:{id:e.comment.id,body:e.comment.body,author:e.comment.user.login,authorAssociation:e.comment.author_association??`NONE`}}}case`discussion_comment`:{let e=t;return{type:`discussion_comment`,action:e.action,discussion:{number:e.discussion.number,title:e.discussion.title,body:e.discussion.body??null,locked:e.discussion.locked??!1},comment:{id:e.comment.id,body:e.comment.body??null,author:e.comment.user.login,authorAssociation:e.comment.author_association??`NONE`}}}case`issues`:{let e=t;return{type:`issues`,action:e.action,issue:{number:e.issue.number,title:e.issue.title,body:e.issue.body??null,locked:e.issue.locked??!1,authorAssociation:e.issue.author_association??`NONE`},sender:{login:e.sender.login}}}case`pull_request`:{let e=t,n=e.pull_request.requested_reviewers??[],r=`requested_reviewer`in e&&e.requested_reviewer!=null?{login:e.requested_reviewer.login,type:e.requested_reviewer.type}:null,i=`requested_team`in e&&e.requested_team!=null?{name:e.requested_team.name,slug:e.requested_team.slug}:null,a=n.flatMap(e=>`login`in e&&`type`in e?[{login:e.login,type:e.type}]:[]);return{type:`pull_request`,action:e.action,requestedReviewer:r,requestedTeam:i,pullRequest:{number:e.pull_request.number,title:e.pull_request.title,body:e.pull_request.body??null,locked:e.pull_request.locked??!1,draft:e.pull_request.draft??!1,authorAssociation:e.pull_request.author_association??`NONE`,requestedReviewers:a},sender:{login:e.sender.login}}}case`pull_request_review_comment`:{let e=t;return{type:`pull_request_review_comment`,action:e.action,pullRequest:{number:e.pull_request.number,title:e.pull_request.title,locked:e.pull_request.locked??!1},comment:{id:e.comment.id,body:e.comment.body,author:e.comment.user.login,authorAssociation:e.comment.author_association,path:e.comment.path,line:e.comment.line??null,diffHunk:e.comment.diff_hunk,commitId:e.comment.commit_id}}}case`workflow_dispatch`:return{type:`workflow_dispatch`,inputs:{prompt:t.inputs?.prompt??void 0}};case`schedule`:return{type:`schedule`,schedule:t.schedule??void 0};case`unsupported`:return{type:`unsupported`}}}function za(e){let t=re,n=La(t.eventName),r=Ra(n,t.payload);return e.debug(`Parsed GitHub context`,{eventName:t.eventName,eventType:n,repo:`${t.repo.owner}/${t.repo.repo}`}),{eventName:t.eventName,eventType:n,repo:t.repo,ref:t.ref,sha:t.sha,runId:t.runId,actor:t.actor,payload:t.payload,event:r}}function Y(e,t){return t.includes(e)}function X(e){return e.endsWith(`[bot]`)}function Ba(e,t){if(t.length===0)return!1;let n=t.replace(/\[bot\]$/i,``);return n.length===0?!1:new RegExp(String.raw`@${Va(n)}(?:\[bot\])?(?:$|[^\w])`,`i`).test(e)}function Va(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}function Ha(e,t){if(t.length===0)return null;let n=t.replace(/\[bot\]$/i,``);if(n.length===0)return null;let r=new RegExp(String.raw`@${Va(n)}(?:\[bot\])?\s*(.*)`,`is`).exec(e)?.[1];if(r==null)return null;let i=r.trim();if(i.length===0)return{raw:``,action:null,args:``};let a=i.split(/\s+/),o=a[0]??``;return{raw:i,action:o===``?null:o,args:a.slice(1).join(` `)}}function Z(e,t){if(t==null||t===``||e==null)return{hasMention:!1,command:null};let n=Ba(e,t);return{hasMention:n,command:n?Ha(e,t):null}}function Ua(e,t){if(e.type!==`issue_comment`)throw Error(`Event type must be issue_comment`);let n={login:e.comment.author,association:e.comment.authorAssociation,isBot:X(e.comment.author)},r={kind:e.issue.isPullRequest?`pr`:`issue`,number:e.issue.number,title:e.issue.title,body:e.comment.body??null,locked:e.issue.locked},{hasMention:i,command:a}=Z(e.comment.body,t);return{action:e.action,author:n,target:r,commentBody:e.comment.body,commentId:e.comment.id,hasMention:i,command:a,isBotReviewRequested:!1}}function Wa(e,t){if(e.type!==`discussion_comment`)throw Error(`Event type must be discussion_comment`);let n={login:e.comment.author,association:e.comment.authorAssociation,isBot:X(e.comment.author)},r=e.comment.body??null,i={kind:`discussion`,number:e.discussion.number,title:e.discussion.title,body:r??e.discussion.body??null,locked:e.discussion.locked},{hasMention:a,command:o}=Z(r,t);return{action:e.action,author:n,target:i,commentBody:r,commentId:e.comment.id,hasMention:a,command:o,isBotReviewRequested:!1}}function Ga(e,t){if(e.type!==`pull_request_review_comment`)throw Error(`Event type must be pull_request_review_comment`);let n={login:e.comment.author,association:e.comment.authorAssociation,isBot:X(e.comment.author)},r={kind:`pr`,number:e.pullRequest.number,title:e.pullRequest.title,body:e.comment.body,locked:e.pullRequest.locked,path:e.comment.path,line:e.comment.line??void 0,diffHunk:e.comment.diffHunk,commitId:e.comment.commitId},{hasMention:i,command:a}=Z(e.comment.body,t);return{action:e.action,author:n,target:r,commentBody:e.comment.body,commentId:e.comment.id,hasMention:i,command:a,isBotReviewRequested:!1}}function Ka(e,t,n){if(e.type!==`workflow_dispatch`)throw Error(`Event type must be workflow_dispatch`);let r=(n??e.inputs?.prompt??``).trim();return{action:null,author:{login:t,association:`OWNER`,isBot:!1},target:{kind:`manual`,number:0,title:`Manual workflow dispatch`,body:r===``?null:r,locked:!1},commentBody:r===``?null:r,commentId:null,hasMention:!1,command:null,isBotReviewRequested:!1}}function qa(e,t,n){let r=n?.trim()??``;return{action:null,author:{login:t,association:`OWNER`,isBot:!1},target:{kind:`manual`,number:0,title:`Scheduled workflow`,body:r===``?null:r,locked:!1},commentBody:r===``?null:r,commentId:null,hasMention:!1,command:null,isBotReviewRequested:!1}}function Ja(e){return e.toLowerCase().replace(/\[bot\]$/i,``)}function Ya(e,t){if(e.type!==`pull_request`||t==null||t===``)return!1;let n=Ja(t);if(n===``)return!1;if(e.action===`review_requested`){let t=e.requestedReviewer?.login;return t!=null&&Ja(t)===n}return e.action===`ready_for_review`?e.pullRequest.requestedReviewers.some(e=>Ja(e.login)===n):!1}function Xa(e,t){if(e.type!==`issues`)throw Error(`Event type must be issues`);let n={login:e.sender.login,association:e.issue.authorAssociation,isBot:X(e.sender.login)},r={kind:`issue`,number:e.issue.number,title:e.issue.title,body:e.issue.body,locked:e.issue.locked},{hasMention:i,command:a}=Z(e.issue.body??``,t);return{action:e.action,author:n,target:r,commentBody:e.issue.body,commentId:null,hasMention:i,command:a,isBotReviewRequested:!1}}function Za(e,t){if(e.type!==`pull_request`)throw Error(`Event type must be pull_request`);let n={login:e.sender.login,association:e.pullRequest.authorAssociation,isBot:X(e.sender.login)},r={kind:`pr`,number:e.pullRequest.number,title:e.pullRequest.title,body:e.pullRequest.body,locked:e.pullRequest.locked,isDraft:e.pullRequest.draft,requestedReviewerLogin:e.requestedReviewer?.login,requestedTeamSlug:e.requestedTeam?.slug,requestedReviewerLogins:e.pullRequest.requestedReviewers.map(e=>e.login)},{hasMention:i,command:a}=Z(e.pullRequest.body??``,t);return{action:e.action,author:n,target:r,commentBody:e.pullRequest.body,commentId:null,hasMention:i,command:a,isBotReviewRequested:Ya(e,t)}}function Q(e,t){return{...e,action:t.action,author:t.author,target:t.target,commentBody:t.commentBody,commentId:t.commentId,hasMention:t.hasMention,command:t.command,isBotReviewRequested:t.isBotReviewRequested}}function Qa(e,t,n){let r={eventType:e.eventType,eventName:e.eventName,repo:e.repo,ref:e.ref,sha:e.sha,runId:e.runId,actor:e.actor,raw:e};switch(e.eventType){case`issue_comment`:return Q(r,Ua(e.event,t));case`discussion_comment`:return Q(r,Wa(e.event,t));case`workflow_dispatch`:return Q(r,Ka(e.event,e.actor,n));case`issues`:return Q(r,Xa(e.event,t));case`pull_request`:return Q(r,Za(e.event,t));case`pull_request_review_comment`:return Q(r,Ga(e.event,t));case`schedule`:return Q(r,qa(e.event,e.actor,n));case`unsupported`:return{...r,action:null,author:null,target:null,commentBody:null,commentId:null,hasMention:!1,command:null,isBotReviewRequested:!1}}}function $a(e,t,n){let{targetLabel:r,actionLabel:i}=n;return e.action===`created`?e.target?.locked===!0?{shouldSkip:!0,reason:`issue_locked`,message:`${r} is locked`}:e.author!=null&&e.author.isBot?{shouldSkip:!0,reason:`self_comment`,message:`Comments from bots (${e.author.login}) are not processed`}:e.author!=null&&!Y(e.author.association,t.allowedAssociations)?{shouldSkip:!0,reason:`unauthorized_author`,message:`Author association '${e.author.association}' is not authorized`}:t.requireMention&&!e.hasMention?{shouldSkip:!0,reason:`no_mention`,message:`Comment does not mention the bot`}:{shouldSkip:!1}:{shouldSkip:!0,reason:`action_not_created`,message:`${i} action is '${e.action}', not 'created'`}}function eo(e,t){return $a(e,t,{targetLabel:`Issue or PR`,actionLabel:`Comment`})}function to(e,t){return $a(e,t,{targetLabel:`Discussion`,actionLabel:`Discussion comment`})}const no=[`opened`,`edited`];function ro(e){return no.includes(e)}function io(e,t){let n=e.action;return n==null||!ro(n)?{shouldSkip:!0,reason:`action_not_supported`,message:`Issues action '${n}' is not supported (only 'opened' and 'edited')`}:e.author!=null&&e.author.isBot?{shouldSkip:!0,reason:`self_comment`,message:`Issues from bots (${e.author.login}) are not processed`}:e.author!=null&&!Y(e.author.association,t.allowedAssociations)?{shouldSkip:!0,reason:`unauthorized_author`,message:`Author association '${e.author.association}' is not authorized`}:n===`edited`&&!e.hasMention?{shouldSkip:!0,reason:`no_mention`,message:`Issue edit does not mention the bot`}:e.target?.locked===!0?{shouldSkip:!0,reason:`issue_locked`,message:`Issue is locked`}:{shouldSkip:!1}}function ao(e){return(e.promptInput?.trim()??``)===``?{shouldSkip:!0,reason:`prompt_required`,message:`Schedule trigger requires prompt input`}:{shouldSkip:!1}}function oo(e){return(e.commentBody?.trim()??``)===``?{shouldSkip:!0,reason:`prompt_required`,message:`Workflow dispatch requires prompt input`}:{shouldSkip:!1}}const so=[`opened`,`synchronize`,`reopened`,`ready_for_review`,`review_requested`];function co(e){return so.includes(e)}function lo(e,t){let n=e.action;return n==null||!co(n)?{shouldSkip:!0,reason:`action_not_supported`,message:`Pull request action '${n}' is not supported`}:e.action!==`review_requested`&&e.action!==`ready_for_review`&&e.author!=null&&e.author.isBot?{shouldSkip:!0,reason:`self_comment`,message:`Pull requests from bots (${e.author.login}) are not processed`}:e.author!=null&&!Y(e.author.association,t.allowedAssociations)?{shouldSkip:!0,reason:`unauthorized_author`,message:`Author association '${e.author.association}' is not authorized`}:t.skipDraftPRs&&e.target?.isDraft===!0?{shouldSkip:!0,reason:`draft_pr`,message:`Pull request is a draft`}:e.target?.locked===!0?{shouldSkip:!0,reason:`issue_locked`,message:`Pull request is locked`}:t.botLogin!=null&&t.botLogin!==``&&(e.action===`ready_for_review`||e.action===`review_requested`)&&e.isBotReviewRequested!==!0?{shouldSkip:!0,reason:`bot_not_requested`,message:`Pull request action '${e.action}' did not request review from the bot`}:{shouldSkip:!1}}function uo(e,t){let n=e.action;return n===`created`?e.target?.locked===!0?{shouldSkip:!0,reason:`issue_locked`,message:`Pull request is locked`}:e.author!=null&&e.author.isBot?{shouldSkip:!0,reason:`self_comment`,message:`Review comments from bots (${e.author.login}) are not processed`}:e.author!=null&&!Y(e.author.association,t.allowedAssociations)?{shouldSkip:!0,reason:`unauthorized_author`,message:`Author association '${e.author.association}' is not authorized`}:t.requireMention&&!e.hasMention?{shouldSkip:!0,reason:`no_mention`,message:`Review comment does not mention the bot`}:{shouldSkip:!1}:{shouldSkip:!0,reason:`action_not_created`,message:`Review comment action '${n}' is not supported (only 'created')`}}function fo(e){return{shouldSkip:!0,reason:`unsupported_event`,message:`Unsupported event type: ${e}`}}function po(e,t,n){if(e.eventType===`unsupported`)return n.debug(`Skipping unsupported event`,{eventName:e.eventName}),fo(e.eventName);switch(e.eventType){case`issue_comment`:return eo(e,t);case`discussion_comment`:return to(e,t);case`issues`:return io(e,t);case`pull_request`:return lo(e,t);case`pull_request_review_comment`:return uo(e,t);case`schedule`:return ao(t);case`workflow_dispatch`:return oo(e);default:return{shouldSkip:!1}}}const mo={botLogin:null,requireMention:!0,allowedAssociations:li,skipDraftPRs:!0,promptInput:null,senderAssociation:null};function ho(e,t,n={}){let r={...mo,...n},i=Qa(e,r.botLogin,r.promptInput);r.senderAssociation!=null&&(i.action===`review_requested`||i.action===`ready_for_review`)&&i.author!=null&&(i={...i,author:{...i.author,association:r.senderAssociation}}),t.debug(`Routing event`,{eventName:e.eventName,eventType:e.eventType,hasMention:i.hasMention});let a=po(i,r,t);return a.shouldSkip?{shouldProcess:!1,skipReason:a.reason,skipMessage:a.message,context:i}:{shouldProcess:!0,context:i}}async function go(t,n){let r=e({phase:`context`}),i=za(r),a=Fr({token:t.inputs.githubToken,logger:r}),o=await Ir(a,r),s=null;if(i.event.type===`pull_request`&&(i.event.action===`review_requested`||i.event.action===`ready_for_review`)){let{owner:e,repo:t}=i.repo;s=await We(a,e,t,i.event.sender.login,r)}let c=e({phase:`trigger`}),l=ho(i,c,{botLogin:o,requireMention:!0,promptInput:t.inputs.prompt,senderAssociation:s});return l.shouldProcess?(c.info(`Event routed for processing`,{eventType:l.context.eventType,hasMention:l.context.hasMention,command:l.context.command?.action??null}),M(j.SHOULD_SAVE_CACHE,`true`),{githubClient:a,triggerResult:l,agentContext:await st({logger:r,octokit:a,triggerContext:l.context,botLogin:o}),botLogin:o}):(c.info(`Skipping event`,{reason:l.skipReason,message:l.skipMessage}),z({sessionId:null,cacheStatus:`miss`,duration:Date.now()-n}),null)}function $(e,t){return{key:`${e}-${t}`,entityType:e,entityId:t}}function _o(e){return Ce(`sha256`).update(e).digest(`hex`).slice(0,8)}function vo(e){if(e.eventType===`unsupported`)return null;if(e.eventType===`schedule`){let t=e.raw.event.type===`schedule`?e.raw.event.schedule:void 0;return $(`schedule`,_o((t!=null&&t.trim().length>0?t:e.action)??`default`))}return e.eventType===`workflow_dispatch`?$(`dispatch`,String(e.runId)):e.target==null?null:e.eventType===`issue_comment`?e.target.kind===`issue`?$(`issue`,String(e.target.number)):e.target.kind===`pr`?$(`pr`,String(e.target.number)):null:e.eventType===`discussion_comment`?e.target.kind===`discussion`?$(`discussion`,String(e.target.number)):null:e.eventType===`issues`?e.target.kind===`issue`?$(`issue`,String(e.target.number)):null:(e.eventType===`pull_request`||e.eventType===`pull_request_review_comment`)&&e.target.kind===`pr`?$(`pr`,String(e.target.number)):null}function yo(e){return`fro-bot: ${e.key}`}function bo(e,t){let n=e.filter(e=>e.title===t);return n.length===0?null:n.reduce((e,t)=>t.time.updated>e.time.updated?t:e)}async function xo(e,t,n,r){try{let i=bo(await Zi(e,t,r),yo(n));return i==null||i.time.archived!=null||i.time.compacting!=null?{status:`not-found`}:{status:`found`,session:i}}catch(e){return{status:`error`,error:e instanceof Error?e.message:String(e)}}}async function So(t,n,r,i){let a=e({phase:`session`}),o=q(se()),s=await ra(r.serverHandle.client,o,{limit:10},a);a.debug(`Listed recent sessions`,{count:s.length});let c=vo(n.triggerResult.context),l=c==null?null:yo(c),u=null,d=!1;if(c!=null){let e=await xo(r.serverHandle.client,o,c,a);e.status===`found`?(u=e.session.id,d=!0,a.info(`Session continuity: found existing session`,{logicalKey:c.key,sessionId:u})):e.status===`error`?a.warning(`Session continuity: lookup error, will create new`,{logicalKey:c.key,error:e.error}):a.info(`Session continuity: no existing session found`,{logicalKey:c.key})}let f=c?.key??n.agentContext.issueTitle??n.agentContext.repo,p=await aa(f,r.serverHandle.client,o,{limit:5},a);a.debug(`Searched prior sessions`,{query:f,resultCount:p.length});for(let e of p)i.addSessionUsed(e.sessionId);let m=e({phase:`attachments`}),h=n.agentContext.commentBody??``,g=Oi(h),_=null;if(g.length>0){m.info(`Processing attachments`,{count:g.length});let{validated:e,skipped:n}=zi(await Ni(g,t.inputs.githubToken,void 0,m),void 0,m);(e.length>0||n.length>0)&&(_=Li(h,g,e,n),m.info(`Attachments processed`,{processed:e.length,skipped:n.length}))}return{recentSessions:s,priorWorkContext:p,attachmentResult:_,normalizedWorkspace:o,logicalKey:c,continueSessionId:u,isContinuation:d,sessionTitle:l}}async function Co(){let n=Date.now(),r=e({phase:`bootstrap`}),i=Fe();i.start();let a=null,o=!1,s=0,c=null,l=null,u=null,d=null;M(j.SHOULD_SAVE_CACHE,`false`),M(j.CACHE_SAVED,`false`);try{r.info(`Starting Fro Bot Agent`);let e=await xi(r);if(e==null)return 1;u=e.opencodeResult.version;let t=await go(e,n);if(t==null)return 0;c=t.githubClient;let f=`${t.triggerResult.context.repo.owner}/${t.triggerResult.context.repo.repo}`,p=await xa(e.inputs.dedupWindow,t.triggerResult.context,f,n);if(!p.shouldProceed)return 0;a=await pi(t,e.logger);let m=await Ti(e);if(m==null)return 1;d=m.serverHandle,i.setCacheStatus(m.cacheStatus);let h=await So(e,t,m,i);l=h.attachmentResult;let g=await wa(e,t,m,h,i,n);o=g.success,o&&p.entity!=null&&await Sa(t.triggerResult.context,p.entity,f),i.end(),s=await Ia(e,t,m,g,i,n,e.logger)}catch(e){s=1;let a=Date.now()-n,o=e instanceof Error?e.name:`UnknownError`,c=e instanceof Error?e.message:String(e);i.recordError(o,c,!1),i.end(),z({sessionId:null,cacheStatus:`miss`,duration:a}),e instanceof Error?(r.error(`Agent failed`,{error:e.message}),t(e.message)):(r.error(`Agent failed with unknown error`),t(`An unknown error occurred`))}finally{await ua({bootstrapLogger:r,reactionCtx:a,githubClient:c,agentSuccess:o,attachmentResult:l,serverHandle:d,detectedOpencodeVersion:u})}return s}await Co().then(e=>{N.exit(e)});export{}; \ No newline at end of file +`,{discussionId:i.id,body:n.body});return r.debug(`Created discussion comment`,{discussionId:i.id}),{commentId:a.addDiscussionComment.comment.id,created:!0,updated:!1,url:a.addDiscussionComment.comment.url}}catch(e){return r.warning(`Failed to post discussion comment`,{target:t,error:M(e)}),null}}async function Ia(e,t,n,r){if(t.type===`discussion`)return Fa(e,t,n,r);if(n.updateExisting===!0&&n.botLogin!=null){let i=await ja(e,t,n.botLogin,r);if(i!=null){let a=Ma(i,n.botLogin);if(a!=null&&typeof a.id==`number`)return Pa(e,t,a.id,n.body,r)}}return Na(e,t,n.body,r)}async function La(n,r,i,a,o,s,c){let l=Date.now()-s;if(V({sessionId:a.sessionId,cacheStatus:i.cacheStatus,duration:l}),await Me({eventType:r.agentContext.eventName,repo:r.agentContext.repo,ref:r.agentContext.ref,runId:Number(r.agentContext.runId),runUrl:`https://github.com/${r.agentContext.repo}/actions/runs/${r.agentContext.runId}`,metrics:o.getMetrics(),agent:n.inputs.agent},c),a.success)return c.info(`Agent run completed successfully`,{durationMs:l}),0;if(a.llmError==null)return t(`Agent execution failed with exit code ${a.exitCode}`),a.exitCode;c.info(`Agent failed with recoverable LLM error`,{error:a.llmError.message,type:a.llmError.type,durationMs:l});let[u,d]=r.agentContext.repo.split(`/`),f={type:r.triggerResult.context.eventType===`discussion_comment`?`discussion`:r.agentContext.issueType===`pr`?`pr`:`issue`,number:r.agentContext.issueNumber??0,owner:u??``,repo:d??``};if(f.number>0&&f.owner.length>0&&f.repo.length>0){let t=pn(a.llmError),n=e({phase:`error-comment`}),i=await Ia(r.githubClient,f,{body:t},n);i==null?n.warning(`Failed to post LLM error comment`):(n.info(`Posted LLM error comment`,{commentUrl:i.url}),o.incrementComments())}else c.warning(`Cannot post error comment: missing target context`);return 0}function Ra(e){switch(e){case`issue_comment`:return`issue_comment`;case`discussion`:case`discussion_comment`:return`discussion_comment`;case`workflow_dispatch`:return`workflow_dispatch`;case`issues`:return`issues`;case`pull_request`:return`pull_request`;case`pull_request_review_comment`:return`pull_request_review_comment`;case`schedule`:return`schedule`;default:return`unsupported`}}function za(e,t){switch(e){case`issue_comment`:{let e=t;return{type:`issue_comment`,action:e.action,issue:{number:e.issue.number,title:e.issue.title,body:e.issue.body??null,locked:e.issue.locked??!1,isPullRequest:e.issue.pull_request!=null},comment:{id:e.comment.id,body:e.comment.body,author:e.comment.user.login,authorAssociation:e.comment.author_association??`NONE`}}}case`discussion_comment`:{let e=t;return{type:`discussion_comment`,action:e.action,discussion:{number:e.discussion.number,title:e.discussion.title,body:e.discussion.body??null,locked:e.discussion.locked??!1},comment:{id:e.comment.id,body:e.comment.body??null,author:e.comment.user.login,authorAssociation:e.comment.author_association??`NONE`}}}case`issues`:{let e=t;return{type:`issues`,action:e.action,issue:{number:e.issue.number,title:e.issue.title,body:e.issue.body??null,locked:e.issue.locked??!1,authorAssociation:e.issue.author_association??`NONE`},sender:{login:e.sender.login}}}case`pull_request`:{let e=t,n=e.pull_request.requested_reviewers??[],r=`requested_reviewer`in e&&e.requested_reviewer!=null?{login:e.requested_reviewer.login,type:e.requested_reviewer.type}:null,i=`requested_team`in e&&e.requested_team!=null?{name:e.requested_team.name,slug:e.requested_team.slug}:null,a=n.flatMap(e=>`login`in e&&`type`in e?[{login:e.login,type:e.type}]:[]);return{type:`pull_request`,action:e.action,requestedReviewer:r,requestedTeam:i,pullRequest:{number:e.pull_request.number,title:e.pull_request.title,body:e.pull_request.body??null,locked:e.pull_request.locked??!1,draft:e.pull_request.draft??!1,authorAssociation:e.pull_request.author_association??`NONE`,requestedReviewers:a},sender:{login:e.sender.login}}}case`pull_request_review_comment`:{let e=t;return{type:`pull_request_review_comment`,action:e.action,pullRequest:{number:e.pull_request.number,title:e.pull_request.title,locked:e.pull_request.locked??!1},comment:{id:e.comment.id,body:e.comment.body,author:e.comment.user.login,authorAssociation:e.comment.author_association,path:e.comment.path,line:e.comment.line??null,diffHunk:e.comment.diff_hunk,commitId:e.comment.commit_id}}}case`workflow_dispatch`:return{type:`workflow_dispatch`,inputs:{prompt:t.inputs?.prompt??void 0}};case`schedule`:return{type:`schedule`,schedule:t.schedule??void 0};case`unsupported`:return{type:`unsupported`}}}function Ba(e){let t=te,n=Ra(t.eventName),r=za(n,t.payload);return e.debug(`Parsed GitHub context`,{eventName:t.eventName,eventType:n,repo:`${t.repo.owner}/${t.repo.repo}`}),{eventName:t.eventName,eventType:n,repo:t.repo,ref:t.ref,sha:t.sha,runId:t.runId,actor:t.actor,payload:t.payload,event:r}}function Va(e,t){return t.includes(e)}function X(e){return e.endsWith(`[bot]`)}function Ha(e,t){if(t.length===0)return!1;let n=t.replace(/\[bot\]$/i,``);return n.length===0?!1:new RegExp(String.raw`@${Ua(n)}(?:\[bot\])?(?:$|[^\w])`,`i`).test(e)}function Ua(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}function Wa(e,t){if(t.length===0)return null;let n=t.replace(/\[bot\]$/i,``);if(n.length===0)return null;let r=new RegExp(String.raw`@${Ua(n)}(?:\[bot\])?\s*(.*)`,`is`).exec(e)?.[1];if(r==null)return null;let i=r.trim();if(i.length===0)return{raw:``,action:null,args:``};let a=i.split(/\s+/),o=a[0]??``;return{raw:i,action:o===``?null:o,args:a.slice(1).join(` `)}}function Z(e,t){if(t==null||t===``||e==null)return{hasMention:!1,command:null};let n=Ha(e,t);return{hasMention:n,command:n?Wa(e,t):null}}function Ga(e,t){if(e.type!==`issue_comment`)throw Error(`Event type must be issue_comment`);let n={login:e.comment.author,association:e.comment.authorAssociation,isBot:X(e.comment.author)},r={kind:e.issue.isPullRequest?`pr`:`issue`,number:e.issue.number,title:e.issue.title,body:e.comment.body??null,locked:e.issue.locked},{hasMention:i,command:a}=Z(e.comment.body,t);return{action:e.action,author:n,target:r,commentBody:e.comment.body,commentId:e.comment.id,hasMention:i,command:a,isBotReviewRequested:!1}}function Ka(e,t){if(e.type!==`discussion_comment`)throw Error(`Event type must be discussion_comment`);let n={login:e.comment.author,association:e.comment.authorAssociation,isBot:X(e.comment.author)},r=e.comment.body??null,i={kind:`discussion`,number:e.discussion.number,title:e.discussion.title,body:r??e.discussion.body??null,locked:e.discussion.locked},{hasMention:a,command:o}=Z(r,t);return{action:e.action,author:n,target:i,commentBody:r,commentId:e.comment.id,hasMention:a,command:o,isBotReviewRequested:!1}}function qa(e,t){if(e.type!==`pull_request_review_comment`)throw Error(`Event type must be pull_request_review_comment`);let n={login:e.comment.author,association:e.comment.authorAssociation,isBot:X(e.comment.author)},r={kind:`pr`,number:e.pullRequest.number,title:e.pullRequest.title,body:e.comment.body,locked:e.pullRequest.locked,path:e.comment.path,line:e.comment.line??void 0,diffHunk:e.comment.diffHunk,commitId:e.comment.commitId},{hasMention:i,command:a}=Z(e.comment.body,t);return{action:e.action,author:n,target:r,commentBody:e.comment.body,commentId:e.comment.id,hasMention:i,command:a,isBotReviewRequested:!1}}function Ja(e,t,n){if(e.type!==`workflow_dispatch`)throw Error(`Event type must be workflow_dispatch`);let r=(n??e.inputs?.prompt??``).trim();return{action:null,author:{login:t,association:`OWNER`,isBot:!1},target:{kind:`manual`,number:0,title:`Manual workflow dispatch`,body:r===``?null:r,locked:!1},commentBody:r===``?null:r,commentId:null,hasMention:!1,command:null,isBotReviewRequested:!1}}function Ya(e,t,n){let r=n?.trim()??``;return{action:null,author:{login:t,association:`OWNER`,isBot:!1},target:{kind:`manual`,number:0,title:`Scheduled workflow`,body:r===``?null:r,locked:!1},commentBody:r===``?null:r,commentId:null,hasMention:!1,command:null,isBotReviewRequested:!1}}function Xa(e){return e.toLowerCase().replace(/\[bot\]$/i,``)}function Za(e,t){if(e.type!==`pull_request`||t==null||t===``)return!1;let n=Xa(t);if(n===``)return!1;if(e.action===`review_requested`){let t=e.requestedReviewer?.login;return t!=null&&Xa(t)===n}return e.action===`ready_for_review`?e.pullRequest.requestedReviewers.some(e=>Xa(e.login)===n):!1}function Qa(e,t){if(e.type!==`issues`)throw Error(`Event type must be issues`);let n={login:e.sender.login,association:e.issue.authorAssociation,isBot:X(e.sender.login)},r={kind:`issue`,number:e.issue.number,title:e.issue.title,body:e.issue.body,locked:e.issue.locked},{hasMention:i,command:a}=Z(e.issue.body??``,t);return{action:e.action,author:n,target:r,commentBody:e.issue.body,commentId:null,hasMention:i,command:a,isBotReviewRequested:!1}}function $a(e,t){if(e.type!==`pull_request`)throw Error(`Event type must be pull_request`);let n={login:e.sender.login,association:e.pullRequest.authorAssociation,isBot:X(e.sender.login)},r={kind:`pr`,number:e.pullRequest.number,title:e.pullRequest.title,body:e.pullRequest.body,locked:e.pullRequest.locked,isDraft:e.pullRequest.draft,requestedReviewerLogin:e.requestedReviewer?.login,requestedTeamSlug:e.requestedTeam?.slug,requestedReviewerLogins:e.pullRequest.requestedReviewers.map(e=>e.login)},{hasMention:i,command:a}=Z(e.pullRequest.body??``,t);return{action:e.action,author:n,target:r,commentBody:e.pullRequest.body,commentId:null,hasMention:i,command:a,isBotReviewRequested:Za(e,t)}}function Q(e,t){return{...e,action:t.action,author:t.author,target:t.target,commentBody:t.commentBody,commentId:t.commentId,hasMention:t.hasMention,command:t.command,isBotReviewRequested:t.isBotReviewRequested}}function eo(e,t,n){let r={eventType:e.eventType,eventName:e.eventName,repo:e.repo,ref:e.ref,sha:e.sha,runId:e.runId,actor:e.actor,raw:e};switch(e.eventType){case`issue_comment`:return Q(r,Ga(e.event,t));case`discussion_comment`:return Q(r,Ka(e.event,t));case`workflow_dispatch`:return Q(r,Ja(e.event,e.actor,n));case`issues`:return Q(r,Qa(e.event,t));case`pull_request`:return Q(r,$a(e.event,t));case`pull_request_review_comment`:return Q(r,qa(e.event,t));case`schedule`:return Q(r,Ya(e.event,e.actor,n));case`unsupported`:return{...r,action:null,author:null,target:null,commentBody:null,commentId:null,hasMention:!1,command:null,isBotReviewRequested:!1}}}function to(e,t,n){let{targetLabel:r,actionLabel:i}=n;return e.action===`created`?e.target?.locked===!0?{shouldSkip:!0,reason:`issue_locked`,message:`${r} is locked`}:e.author!=null&&e.author.isBot?{shouldSkip:!0,reason:`self_comment`,message:`Comments from bots (${e.author.login}) are not processed`}:e.author!=null&&!Va(e.author.association,t.allowedAssociations)?{shouldSkip:!0,reason:`unauthorized_author`,message:`Author association '${e.author.association}' is not authorized`}:t.requireMention&&!e.hasMention?{shouldSkip:!0,reason:`no_mention`,message:`Comment does not mention the bot`}:{shouldSkip:!1}:{shouldSkip:!0,reason:`action_not_created`,message:`${i} action is '${e.action}', not 'created'`}}function no(e,t){return to(e,t,{targetLabel:`Issue or PR`,actionLabel:`Comment`})}function ro(e,t){return to(e,t,{targetLabel:`Discussion`,actionLabel:`Discussion comment`})}const io=[`opened`,`edited`];function ao(e){return io.includes(e)}function oo(e,t){let n=e.action;return n==null||!ao(n)?{shouldSkip:!0,reason:`action_not_supported`,message:`Issues action '${n}' is not supported (only 'opened' and 'edited')`}:e.author!=null&&e.author.isBot?{shouldSkip:!0,reason:`self_comment`,message:`Issues from bots (${e.author.login}) are not processed`}:e.author!=null&&!Va(e.author.association,t.allowedAssociations)?{shouldSkip:!0,reason:`unauthorized_author`,message:`Author association '${e.author.association}' is not authorized`}:n===`edited`&&!e.hasMention?{shouldSkip:!0,reason:`no_mention`,message:`Issue edit does not mention the bot`}:e.target?.locked===!0?{shouldSkip:!0,reason:`issue_locked`,message:`Issue is locked`}:{shouldSkip:!1}}function so(e){return(e.promptInput?.trim()??``)===``?{shouldSkip:!0,reason:`prompt_required`,message:`Schedule trigger requires prompt input`}:{shouldSkip:!1}}function co(e){return(e.commentBody?.trim()??``)===``?{shouldSkip:!0,reason:`prompt_required`,message:`Workflow dispatch requires prompt input`}:{shouldSkip:!1}}const lo=[`opened`,`synchronize`,`reopened`,`ready_for_review`,`review_requested`];function uo(e){return lo.includes(e)}function fo(e,t){let n=e.action;return n==null||!uo(n)?{shouldSkip:!0,reason:`action_not_supported`,message:`Pull request action '${n}' is not supported`}:e.action!==`review_requested`&&e.action!==`ready_for_review`&&e.author!=null&&e.author.isBot?{shouldSkip:!0,reason:`self_comment`,message:`Pull requests from bots (${e.author.login}) are not processed`}:e.author!=null&&!Va(e.author.association,t.allowedAssociations)?{shouldSkip:!0,reason:`unauthorized_author`,message:`Author association '${e.author.association}' is not authorized`}:t.skipDraftPRs&&e.target?.isDraft===!0?{shouldSkip:!0,reason:`draft_pr`,message:`Pull request is a draft`}:e.target?.locked===!0?{shouldSkip:!0,reason:`issue_locked`,message:`Pull request is locked`}:t.botLogin!=null&&t.botLogin!==``&&(e.action===`ready_for_review`||e.action===`review_requested`)&&e.isBotReviewRequested!==!0?{shouldSkip:!0,reason:`bot_not_requested`,message:`Pull request action '${e.action}' did not request review from the bot`}:{shouldSkip:!1}}function po(e,t){let n=e.action;return n===`created`?e.target?.locked===!0?{shouldSkip:!0,reason:`issue_locked`,message:`Pull request is locked`}:e.author!=null&&e.author.isBot?{shouldSkip:!0,reason:`self_comment`,message:`Review comments from bots (${e.author.login}) are not processed`}:e.author!=null&&!Va(e.author.association,t.allowedAssociations)?{shouldSkip:!0,reason:`unauthorized_author`,message:`Author association '${e.author.association}' is not authorized`}:t.requireMention&&!e.hasMention?{shouldSkip:!0,reason:`no_mention`,message:`Review comment does not mention the bot`}:{shouldSkip:!1}:{shouldSkip:!0,reason:`action_not_created`,message:`Review comment action '${n}' is not supported (only 'created')`}}function mo(e){return{shouldSkip:!0,reason:`unsupported_event`,message:`Unsupported event type: ${e}`}}function ho(e,t,n){if(e.eventType===`unsupported`)return n.debug(`Skipping unsupported event`,{eventName:e.eventName}),mo(e.eventName);switch(e.eventType){case`issue_comment`:return no(e,t);case`discussion_comment`:return ro(e,t);case`issues`:return oo(e,t);case`pull_request`:return fo(e,t);case`pull_request_review_comment`:return po(e,t);case`schedule`:return so(t);case`workflow_dispatch`:return co(e);default:return{shouldSkip:!1}}}const go={botLogin:null,requireMention:!0,allowedAssociations:ui,skipDraftPRs:!0,promptInput:null,senderAssociation:null};function _o(e,t,n={}){let r={...go,...n},i=eo(e,r.botLogin,r.promptInput);r.senderAssociation!=null&&(i.action===`review_requested`||i.action===`ready_for_review`)&&i.author!=null&&(i={...i,author:{...i.author,association:r.senderAssociation}}),t.debug(`Routing event`,{eventName:e.eventName,eventType:e.eventType,hasMention:i.hasMention});let a=ho(i,r,t);return a.shouldSkip?{shouldProcess:!1,skipReason:a.reason,skipMessage:a.message,context:i}:{shouldProcess:!0,context:i}}async function vo(t,n){let r=e({phase:`context`}),i=Ba(r),a=Ir({token:t.inputs.githubToken,logger:r}),o=await Lr(a,r),s=null;if(i.event.type===`pull_request`&&(i.event.action===`review_requested`||i.event.action===`ready_for_review`)){let{owner:e,repo:t}=i.repo;s=await He(a,e,t,i.event.sender.login,r)}let c=e({phase:`trigger`}),l=_o(i,c,{botLogin:o,requireMention:!0,promptInput:t.inputs.prompt,senderAssociation:s});return l.shouldProcess?(c.info(`Event routed for processing`,{eventType:l.context.eventType,hasMention:l.context.hasMention,command:l.context.command?.action??null}),F(N.SHOULD_SAVE_CACHE,`true`),{githubClient:a,triggerResult:l,agentContext:await ot({logger:r,octokit:a,triggerContext:l.context,botLogin:o}),botLogin:o}):(c.info(`Skipping event`,{reason:l.skipReason,message:l.skipMessage}),V({sessionId:null,cacheStatus:`miss`,duration:Date.now()-n}),null)}function $(e,t){return{key:`${e}-${t}`,entityType:e,entityId:t}}function yo(e){return be(`sha256`).update(e).digest(`hex`).slice(0,8)}function bo(e){if(e.eventType===`unsupported`)return null;if(e.eventType===`schedule`){let t=e.raw.event.type===`schedule`?e.raw.event.schedule:void 0;return $(`schedule`,yo((t!=null&&t.trim().length>0?t:e.action)??`default`))}return e.eventType===`workflow_dispatch`?$(`dispatch`,String(e.runId)):e.target==null?null:e.eventType===`issue_comment`?e.target.kind===`issue`?$(`issue`,String(e.target.number)):e.target.kind===`pr`?$(`pr`,String(e.target.number)):null:e.eventType===`discussion_comment`?e.target.kind===`discussion`?$(`discussion`,String(e.target.number)):null:e.eventType===`issues`?e.target.kind===`issue`?$(`issue`,String(e.target.number)):null:(e.eventType===`pull_request`||e.eventType===`pull_request_review_comment`)&&e.target.kind===`pr`?$(`pr`,String(e.target.number)):null}function xo(e){return`fro-bot: ${e.key}`}function So(e,t){let n=e.filter(e=>e.title===t);return n.length===0?null:n.reduce((e,t)=>t.time.updated>e.time.updated?t:e)}async function Co(e,t,n,r){try{let i=So(await Qi(e,t,r),xo(n));return i==null||i.time.archived!=null||i.time.compacting!=null?{status:`not-found`}:{status:`found`,session:i}}catch(e){return{status:`error`,error:e instanceof Error?e.message:String(e)}}}async function wo(t,n,r,i){let a=e({phase:`session`}),o=J(P()),s=await ia(r.serverHandle.client,o,{limit:10},a);a.debug(`Listed recent sessions`,{count:s.length});let c=bo(n.triggerResult.context),l=c==null?null:xo(c),u=null,d=!1;if(c!=null){let e=await Co(r.serverHandle.client,o,c,a);e.status===`found`?(u=e.session.id,d=!0,a.info(`Session continuity: found existing session`,{logicalKey:c.key,sessionId:u})):e.status===`error`?a.warning(`Session continuity: lookup error, will create new`,{logicalKey:c.key,error:e.error}):a.info(`Session continuity: no existing session found`,{logicalKey:c.key})}let f=c?.key??n.agentContext.issueTitle??n.agentContext.repo,p=await oa(f,r.serverHandle.client,o,{limit:5},a);a.debug(`Searched prior sessions`,{query:f,resultCount:p.length});for(let e of p)i.addSessionUsed(e.sessionId);let m=e({phase:`attachments`}),h=n.agentContext.commentBody??``,g=ki(h),_=null;if(g.length>0){m.info(`Processing attachments`,{count:g.length});let{validated:e,skipped:n}=Bi(await Pi(g,t.inputs.githubToken,void 0,m),void 0,m);(e.length>0||n.length>0)&&(_=Ri(h,g,e,n),m.info(`Attachments processed`,{processed:e.length,skipped:n.length}))}return{recentSessions:s,priorWorkContext:p,attachmentResult:_,normalizedWorkspace:o,logicalKey:c,continueSessionId:u,isContinuation:d,sessionTitle:l}}async function To(){let n=Date.now(),r=e({phase:`bootstrap`}),i=Ne();i.start();let a=null,o=!1,s=0,c=null,l=null,u=null,d=null;F(N.SHOULD_SAVE_CACHE,`false`),F(N.CACHE_SAVED,`false`);try{r.info(`Starting Fro Bot Agent`);let e=await Si(r);if(e==null)return 1;u=e.opencodeResult.version;let t=await vo(e,n);if(t==null)return 0;c=t.githubClient;let f=`${t.triggerResult.context.repo.owner}/${t.triggerResult.context.repo.repo}`,p=await Sa(e.inputs.dedupWindow,t.triggerResult.context,f,n);if(!p.shouldProceed)return 0;a=await mi(t,e.logger);let m=await Ei(e);if(m==null)return 1;d=m.serverHandle,i.setCacheStatus(m.cacheStatus);let h=await wo(e,t,m,i);l=h.attachmentResult;let g=await Ta(e,t,m,h,i,n);o=g.success,o&&p.entity!=null&&await Ca(t.triggerResult.context,p.entity,f),i.end(),s=await La(e,t,m,g,i,n,e.logger)}catch(e){s=1;let a=Date.now()-n,o=e instanceof Error?e.name:`UnknownError`,c=e instanceof Error?e.message:String(e);i.recordError(o,c,!1),i.end(),V({sessionId:null,cacheStatus:`miss`,duration:a}),e instanceof Error?(r.error(`Agent failed`,{error:e.message}),t(e.message)):(r.error(`Agent failed with unknown error`),t(`An unknown error occurred`))}finally{await da({bootstrapLogger:r,reactionCtx:a,githubClient:c,agentSuccess:o,attachmentResult:l,serverHandle:d,detectedOpencodeVersion:u})}return s}await To().then(e=>{I.exit(e)});export{}; \ No newline at end of file diff --git a/dist/post.js b/dist/post.js index 8357d0f9..f7c77932 100644 --- a/dist/post.js +++ b/dist/post.js @@ -1 +1 @@ -import{A as e,I as t,a as n,d as r,f as i,g as a,h as o,j as s,k as c,m as l,n as u,t as d,y as f}from"./artifact-DZtNN4TE.js";async function p(p={}){let m=p.logger??e({phase:`post`}),h=t(c.SHOULD_SAVE_CACHE),g=t(c.CACHE_SAVED),_=t(c.SESSION_ID)||null,v=t(c.OPENCODE_VERSION)||null;if(m.debug(`Post-action state`,{shouldSaveCache:h,cacheSaved:g,sessionId:_,opencodeVersion:v}),h!==`true`){m.info(`Skipping post-action: event was not processed`,{shouldSaveCache:h});return}if(g===`true`)m.info(`Skipping post-action: cache already saved by main action`,{cacheSaved:g});else try{await u({components:n(),runId:i(),logger:m,storagePath:a(),authPath:l(),opencodeVersion:v})?m.info(`Post-action cache saved`,{sessionId:_}):m.info(`Post-action: no cache content to save`,{sessionId:_})}catch(e){m.warning(`Post-action cache save failed (non-fatal)`,{error:s(e)})}if(f()&&t(c.ARTIFACT_UPLOADED)!==`true`)try{let t=e({phase:`post-artifact-upload`});await d({logPath:o(),runId:i(),runAttempt:r(),logger:t})}catch(e){m.warning(`Post-action artifact upload failed (non-fatal)`,{error:s(e)})}}await p();export{}; \ No newline at end of file +import{A as e,I as t,a as n,d as r,f as i,g as a,h as o,j as s,k as c,m as l,n as u,t as d,y as f}from"./artifact-B9OeWxWy.js";async function p(p={}){let m=p.logger??e({phase:`post`}),h=t(c.SHOULD_SAVE_CACHE),g=t(c.CACHE_SAVED),_=t(c.SESSION_ID)||null,v=t(c.OPENCODE_VERSION)||null;if(m.debug(`Post-action state`,{shouldSaveCache:h,cacheSaved:g,sessionId:_,opencodeVersion:v}),h!==`true`){m.info(`Skipping post-action: event was not processed`,{shouldSaveCache:h});return}if(g===`true`)m.info(`Skipping post-action: cache already saved by main action`,{cacheSaved:g});else try{await u({components:n(),runId:i(),logger:m,storagePath:a(),authPath:l(),opencodeVersion:v})?m.info(`Post-action cache saved`,{sessionId:_}):m.info(`Post-action: no cache content to save`,{sessionId:_})}catch(e){m.warning(`Post-action cache save failed (non-fatal)`,{error:s(e)})}if(f()&&t(c.ARTIFACT_UPLOADED)!==`true`)try{let t=e({phase:`post-artifact-upload`});await d({logPath:o(),runId:i(),runAttempt:r(),logger:t})}catch(e){m.warning(`Post-action artifact upload failed (non-fatal)`,{error:s(e)})}}await p();export{}; \ No newline at end of file diff --git a/package.json b/package.json index 0c2ca654..b83858b7 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@actions/tool-cache": "4.0.0", "@bfra.me/es": "0.1.0", "@octokit/auth-app": "8.2.0", - "@opencode-ai/sdk": "1.3.2" + "@opencode-ai/sdk": "1.3.5" }, "devDependencies": { "@bfra.me/eslint-config": "0.50.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9b84e941..fbf8c287 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -39,8 +39,8 @@ importers: specifier: 8.2.0 version: 8.2.0 '@opencode-ai/sdk': - specifier: 1.3.2 - version: 1.3.2 + specifier: 1.3.5 + version: 1.3.5 devDependencies: '@bfra.me/eslint-config': specifier: 0.50.1 @@ -724,8 +724,8 @@ packages: '@octokit/webhooks-types@7.6.1': resolution: {integrity: sha512-S8u2cJzklBC0FgTwWVLaM8tMrDuDMVE4xiTK4EYXM9GntyvrdbSoxqDQa+Fh57CCNApyIpyeqPhhFEmHPfrXgw==} - '@opencode-ai/sdk@1.3.2': - resolution: {integrity: sha512-u7sXVKn0kyAA5vVVHuHQfq3+3UGWOU1Sh6d/e+aS4zO8AwriTSWNQ9r8Qy5yxBH+PoeOGl5WIVdp+s2Ea2zuAg==} + '@opencode-ai/sdk@1.3.5': + resolution: {integrity: sha512-ckKedqONnigSejAm/UVlBuQP0U1Ozn9uC54zLxz/EqQZPWE8y7V+8PT048zC7q6gqI+puj2jns65/+enJSkTEQ==} '@ota-meshi/ast-token-store@0.3.0': resolution: {integrity: sha512-XRO0zi2NIUKq2lUk3T1ecFSld1fMWRKE6naRFGkgkdeosx7IslyUKNv5Dcb5PJTja9tHJoFu0v/7yEpAkrkrTg==} @@ -5147,7 +5147,7 @@ snapshots: '@octokit/webhooks-types@7.6.1': {} - '@opencode-ai/sdk@1.3.2': {} + '@opencode-ai/sdk@1.3.5': {} '@ota-meshi/ast-token-store@0.3.0': {} diff --git a/src/shared/constants.ts b/src/shared/constants.ts index 1045a53f..751bbe52 100644 --- a/src/shared/constants.ts +++ b/src/shared/constants.ts @@ -20,7 +20,7 @@ export const DEFAULT_MODEL = { } as const // Setup consolidation defaults -export const DEFAULT_OPENCODE_VERSION = '1.3.3' +export const DEFAULT_OPENCODE_VERSION = '1.3.5' export const DEFAULT_BUN_VERSION = '1.3.11' export const DEFAULT_OMO_VERSION = '3.14.0' export const DEFAULT_OMO_PROVIDERS = ''