@github/copilot 0.0.349-3 → 0.0.349-4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -801,7 +801,7 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr
801
801
  `;if(this.options.debug){r&&(this.fullStaticOutput+=n),this.options.stdout.write(this.fullStaticOutput+e);return}if(A3){r&&this.options.stdout.write(n),this.lastOutput=e,this.lastOutputHeight=l;return}if(this.isScreenReaderEnabled){if(r){let s=this.lastOutputHeight>0?KG.eraseLines(this.lastOutputHeight):"";this.options.stdout.write(s+n),this.lastOutputHeight=0}if(e===this.lastOutput&&!r)return;let I=this.options.stdout.columns||80,a=iX(e,I,{trim:!1,hard:!0});if(r)this.options.stdout.write(a);else{let s=this.lastOutputHeight>0?KG.eraseLines(this.lastOutputHeight):"";this.options.stdout.write(s+a)}this.lastOutput=e,this.lastOutputHeight=a===""?0:a.split(`
802
802
  `).length;return}if(r&&(this.fullStaticOutput+=n),this.lastOutputHeight>=this.options.stdout.rows){this.options.stdout.write(KG.clearTerminal+this.fullStaticOutput+e),this.lastOutput=e,this.lastOutputHeight=l,this.log.sync(e);return}r&&(this.log.clear(),this.options.stdout.write(n),this.log(e)),!r&&e!==this.lastOutput&&this.throttledLog(e),this.lastOutput=e,this.lastOutputHeight=l};render(e){let l=XXe.default.createElement(hF.Provider,{value:{isScreenReaderEnabled:this.isScreenReaderEnabled}},XXe.default.createElement(Iee,{stdin:this.options.stdin,stdout:this.options.stdout,stderr:this.options.stderr,writeToStdout:this.writeToStdout,writeToStderr:this.writeToStderr,exitOnCtrlC:this.options.exitOnCtrlC,onExit:this.unmount},e));pF.updateContainerSync(l,this.container,null,Rct),pF.flushSyncWork()}writeToStdout(e){if(!this.isUnmounted){if(this.options.debug){this.options.stdout.write(e+this.fullStaticOutput+this.lastOutput);return}if(A3){this.options.stdout.write(e);return}this.log.clear(),this.options.stdout.write(e),this.log(this.lastOutput)}}writeToStderr(e){if(!this.isUnmounted){if(this.options.debug){this.options.stderr.write(e),this.options.stdout.write(this.fullStaticOutput+this.lastOutput);return}if(A3){this.options.stderr.write(e);return}this.log.clear(),this.options.stderr.write(e),this.log(this.lastOutput)}}unmount(e){this.isUnmounted||(this.calculateLayout(),this.onRender(),this.unsubscribeExit(),typeof this.restoreConsole=="function"&&this.restoreConsole(),typeof this.unsubscribeResize=="function"&&this.unsubscribeResize(),A3?this.options.stdout.write(this.lastOutput+`
803
803
  `):this.options.debug||this.log.done(),this.isUnmounted=!0,pF.updateContainerSync(null,this.container,null,Rct),pF.flushSyncWork(),vM.delete(this.options.stdout),e instanceof Error?this.rejectExitPromise(e):this.resolveExitPromise())}async waitUntilExit(){return this.exitPromise||=new Promise((e,l)=>{this.resolveExitPromise=e,this.rejectExitPromise=l}),this.exitPromise}clear(){!A3&&!this.options.debug&&this.log.clear()}patchConsole(){this.options.debug||(this.restoreConsole=Gpe((e,l)=>{e==="stdout"&&this.writeToStdout(l),e==="stderr"&&(l.startsWith("The above error occurred")||this.writeToStderr(l))}))}};var cRl=(t,e)=>{let l={stdout:qpe.stdout,stdin:qpe.stdin,stderr:qpe.stderr,debug:!1,exitOnCtrlC:!0,patchConsole:!0,maxFps:30,...dRl(e)},n=uRl(l.stdout,()=>new aee(l));return n.render(t),{rerender:n.render,unmount(){n.unmount()},waitUntilExit:n.waitUntilExit,cleanup:()=>vM.delete(l.stdout),clear:n.clear}},see=cRl,dRl=(t={})=>t instanceof iRl?{stdout:t,stdin:qpe.stdin}:t,uRl=(t,e)=>{let l=vM.get(t);return l||(l=e(),vM.set(t,l)),l};c();var ZF=nt(qt(),1);function $pe(t){let{items:e,children:l,style:n}=t,[r,I]=(0,ZF.useState)(0),a=(0,ZF.useMemo)(()=>e.slice(r),[e,r]);(0,ZF.useLayoutEffect)(()=>{I(e.length)},[e.length]);let s=a.map((d,u)=>l(d,r+u)),o=(0,ZF.useMemo)(()=>({position:"absolute",flexDirection:"column",...n}),[n]);return ZF.default.createElement("ink-box",{internal_static:!0,style:o},s)}c();var wct=nt(qt(),1);c();var mRl=nt(qt(),1);c();var bRl=nt(qt(),1);c();var kXe=nt(qt(),1);c();import{Buffer as GRl}from"node:buffer";var pRl=/^(?:\x1b)([a-zA-Z0-9])$/,hRl=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,Qct={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"},Fct=[...Object.values(Qct),"backspace"],ARl=t=>["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(t),ZRl=t=>["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(t),gRl=(t="")=>{let e;GRl.isBuffer(t)?t[0]>127&&t[1]===void 0?(t[0]-=128,t="\x1B"+String(t)):t=String(t):t!==void 0&&typeof t!="string"?t=String(t):t||(t="");let l={name:"",ctrl:!1,meta:!1,shift:!1,option:!1,sequence:t,raw:t};if(l.sequence=l.sequence||t||l.name,t==="\r")l.raw=void 0,l.name="return";else if(t===`
804
- `)l.name="enter";else if(t===" ")l.name="tab";else if(t==="\b"||t==="\x1B\b")l.name="backspace",l.meta=t.charAt(0)==="\x1B";else if(t==="\x7F"||t==="\x1B\x7F")l.name="delete",l.meta=t.charAt(0)==="\x1B";else if(t==="\x1B"||t==="\x1B\x1B")l.name="escape",l.meta=t.length===2;else if(t===" "||t==="\x1B ")l.name="space",l.meta=t.length===2;else if(t.length===1&&t<="")l.name=String.fromCharCode(t.charCodeAt(0)+97-1),l.ctrl=!0;else if(t.length===1&&t>="0"&&t<="9")l.name="number";else if(t.length===1&&t>="a"&&t<="z")l.name=t;else if(t.length===1&&t>="A"&&t<="Z")l.name=t.toLowerCase(),l.shift=!0;else if(e=pRl.exec(t))l.meta=!0,l.shift=/^[A-Z]$/.test(e[1]);else if(e=hRl.exec(t)){let n=[...t];n[0]==="\x1B"&&n[1]==="\x1B"&&(l.option=!0);let r=[e[1],e[2],e[4],e[6]].filter(Boolean).join(""),I=(e[3]||e[5]||1)-1;l.ctrl=!!(I&4),l.meta=!!(I&10),l.shift=!!(I&1),l.code=r,l.name=Qct[r],l.shift=ARl(r)||l.shift,l.ctrl=ZRl(r)||l.ctrl}return l},Cct=gRl;c();var vct=nt(qt(),1);var NRl=()=>(0,vct.useContext)(Dpe),fM=NRl;var WRl=(t,e={})=>{let{stdin:l,setRawMode:n,internal_exitOnCtrlC:r,internal_eventEmitter:I}=fM();(0,kXe.useEffect)(()=>{if(e.isActive!==!1)return n(!0),()=>{n(!1)}},[e.isActive,n]),(0,kXe.useEffect)(()=>{if(e.isActive===!1)return;let a=s=>{let o=Cct(s),d={upArrow:o.name==="up",downArrow:o.name==="down",leftArrow:o.name==="left",rightArrow:o.name==="right",pageDown:o.name==="pagedown",pageUp:o.name==="pageup",return:o.name==="return",escape:o.name==="escape",ctrl:o.ctrl,shift:o.shift,tab:o.name==="tab",backspace:o.name==="backspace",delete:o.name==="delete",meta:o.meta||o.name==="escape"||o.option},u=o.ctrl?o.name:o.sequence;Fct.includes(o.name)&&(u=""),u.startsWith("\x1B")&&(u=u.slice(1)),u.length===1&&typeof u[0]=="string"&&/[A-Z]/.test(u[0])&&(d.shift=!0),(!(u==="c"&&d.ctrl)||!r)&&pF.batchedUpdates(()=>{t(u,d)})};return I?.on("input",a),()=>{I?.removeListener("input",a)}},[e.isActive,l,r,t])},I1=WRl;c();var yRl=nt(qt(),1);c();var fct=nt(qt(),1);var ERl=()=>(0,fct.useContext)(zpe),PN=ERl;c();var RRl=nt(qt(),1);c();var LXe=nt(qt(),1);c();var YRl=nt(qt(),1);c();var Hct=nt(qt(),1);var VRl=()=>{let{isScreenReaderEnabled:t}=(0,Hct.useContext)(hF);return t},y3=VRl;c();var wRl=t=>({width:t.yogaNode?.getComputedWidth()??0,height:t.yogaNode?.getComputedHeight()??0}),ehe=wRl;var Iat=nt(qt(),1);import psr,{join as rat}from"path";import{text as hsr}from"stream/consumers";c();c();var SAt=nt(V_(),1);c();c();c();c();var lp=[];for(let t=0;t<256;++t)lp.push((t+256).toString(16).slice(1));function uAt(t,e=0){return(lp[t[e+0]]+lp[t[e+1]]+lp[t[e+2]]+lp[t[e+3]]+"-"+lp[t[e+4]]+lp[t[e+5]]+"-"+lp[t[e+6]]+lp[t[e+7]]+"-"+lp[t[e+8]]+lp[t[e+9]]+"-"+lp[t[e+10]]+lp[t[e+11]]+lp[t[e+12]]+lp[t[e+13]]+lp[t[e+14]]+lp[t[e+15]]).toLowerCase()}c();import{randomFillSync as p5l}from"node:crypto";var tZe=new Uint8Array(256),eZe=tZe.length;function dLe(){return eZe>tZe.length-16&&(p5l(tZe),eZe=0),tZe.slice(eZe,eZe+=16)}c();c();import{randomUUID as h5l}from"node:crypto";var uLe={randomUUID:h5l};function A5l(t,e,l){t=t||{};let n=t.random??t.rng?.()??dLe();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){if(l=l||0,l<0||l+16>e.length)throw new RangeError(`UUID byte range ${l}:${l+15} is out of buffer bounds`);for(let r=0;r<16;++r)e[l+r]=n[r];return e}return uAt(n)}function Z5l(t,e,l){return uLe.randomUUID&&!e&&!t?uLe.randomUUID():A5l(t,e,l)}var Bu=Z5l;var M3=class{settings={};mergePartial(e,l){return{...e,...l}}setBlackbirdMode(e){return e!==void 0&&(e=="tool"||e=="initial-search")&&(this.settings.blackbird=this.mergePartial(this.settings.blackbird,{mode:e})),this}setSwebenchBaseCommit(e){return e!==void 0&&(this.settings.swebench_base_commit=e),this}setGithubUserName(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,name:e}})}return this}setGithubUserEmail(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,email:e}})}return this}setGithubToken(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{token:e})),this}setGithubServerUrl(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{serverUrl:e??"https://github.com"}),(!this.settings.github.host||!this.settings.github.hostProtocol)&&(this.settings.github=this.mergePartial(this.settings.github,new URL(e)))),this}setGithubHost(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{host:e})),this}setGithubHostProtocol(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{hostProtocol:e})),this}setGithubActorId(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,actorId:e}})}return this}setGithubActorLogin(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,actorLogin:e}})}return this}setAgentRuntimeVersion(e){return e!==void 0?this.settings.version=e:this.settings.version="latest",this}setGithubRepoName(e){if(e!==void 0){let l=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,name:e}})}return this}setGithubRepoId(e){if(e!==void 0){let l=this.settings.github?.repo||{},n=Number(e);isNaN(n)||(this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,id:n}}))}return this}setGithubRepoOwnerName(e){if(e!==void 0){let l=this.settings.github?.owner||{};this.settings.github=this.mergePartial(this.settings.github,{owner:{...l,name:e}})}return this}setGithubRepoOwnerId(e){if(e!==void 0){let l=this.settings.github?.owner||{},n=Number(e);isNaN(n)||(this.settings.github=this.mergePartial(this.settings.github,{owner:{...l,id:n}}))}return this}setGithubRepoBranch(e){if(e){let l=e.replace(/^refs\/heads\//,"");if(l.length===0)return this;let n=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...n,branch:l}})}return this}setGithubRepoCommit(e){if(e!==void 0){let l=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,commit:e}})}return this}setGithubRepoReadWrite(e){if(e!==void 0){let l=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,readWrite:e}})}return this}setProblemStatement(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{statement:e})),this}setProblemContentFilterMode(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{contentFilterMode:e})),this}setProblemAction(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{action:e})),this}setCustomAgentName(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{customAgentName:e})),this}setGithubPRCommitCount(e){if(e!==void 0){let l=this.settings.github?.pr||{};this.settings.github=this.mergePartial(this.settings.github,{pr:{...l,commitCount:e}})}return this}setInstanceId(e){return this.settings.service=this.mergePartial(this.settings.service,{instance:{id:e??Bu()}}),this}setAgentModel(e){if(e!==void 0){let l=this.settings.service?.agent||{};this.settings.service=this.mergePartial(this.settings.service,{agent:{...l,model:e}})}return this}setRequestHeaders(e){if(e!==void 0){let l=this.settings.service?.agent||{};this.settings.service=this.mergePartial(this.settings.service,{agent:{...l,requestHeaders:e}})}return this}setRetryPolicy(e){if(e!==void 0){let l=this.settings.service?.agent||{};this.settings.service=this.mergePartial(this.settings.service,{agent:{...l,retryPolicy:e}})}return this}setCallbackUrl(e){return e!==void 0&&(this.settings.service=this.mergePartial(this.settings.service,{callback:{url:e}})),this}setGitHubUploadsUrl(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{uploadsUrl:e})),this}setGitHubDownloadsUrl(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{downloadsUrl:e})),this}setAipSweAgentToken(e){return e!==void 0&&(this.settings.api=this.mergePartial(this.settings.api,{aipSweAgent:{token:e}})),this}setAnthropicApiKey(e){return e!==void 0&&(this.settings.api=this.mergePartial(this.settings.api,{anthropic:{key:e}})),this}setOpenAiApiKey(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,apiKey:e}})}return this}setOpenAiBaseUrl(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,baseUrl:e}})}return this}setAzureOpenAiUrl(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azure:{...l.azure,url:e}}})}return this}setAzureOpenAiApiVersion(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azure:{...l.azure,apiVersion:e}}})}return this}setAzureOpenAiKeyVaultUri(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azureKeyVaultUri:e}})}return this}setAzureOpenAiSecretName(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azureSecretName:e}})}return this}setCopilotUrl(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,url:e}})}return this}setCopilotIntegrationId(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,integrationId:e}})}return this}setCopilotHmacKey(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,hmacKey:e}})}return this}setCopilotToken(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,token:e}})}return this}setCopilotAzureKeyVaultUri(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,azureKeyVaultUri:e}})}return this}setCopilotSessionId(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,sessionId:e}})}return this}setCopilotPreviousSessionIds(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,previousSessionIds:e.split(",").map(n=>n.trim()).filter(n=>n.length>0)}})}return this}setCopilotUseSessions(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,useSessions:e}})}return this}setCopilotJobNonce(e){return e!==void 0&&(this.settings.job=this.mergePartial(this.settings.job,{nonce:e})),this}setTrajectoryOutputFile(e){return e!==void 0&&(this.settings.trajectory=this.mergePartial(this.settings.trajectory,{outputFile:e})),this}setEventsLogDirectory(e){return e!==void 0&&(this.settings.logs=this.mergePartial(this.settings.logs,{eventsLogDir:e})),this}setDisableOnlineEvaluation(e){return e==!0&&this.settings.onlineEvaluation?.disableOnlineEvaluation!==!0&&(this.settings.onlineEvaluation=this.mergePartial(this.settings.onlineEvaluation,{disableOnlineEvaluation:e})),this}setEnableOnlineEvaluationOutputFile(e){return e==!0&&this.settings.onlineEvaluation?.enableOnlineEvaluationOutputFile!==!0&&(this.settings.onlineEvaluation=this.mergePartial(this.settings.onlineEvaluation,{enableOnlineEvaluationOutputFile:e})),this}setGitHubMCPServerToken(e){return e!==void 0&&(this.settings.api=this.mergePartial(this.settings.api,{github:{mcpServerToken:e}})),this}setFeatureFlagEnabled(e){return this.settings.featureFlags=this.mergePartial(this.settings.featureFlags,{[e]:!0}),this}setExperiment(e,l){return this.settings.experiments=this.mergePartial(this.settings.experiments,{[e]:l}),this}setTimeoutMs(e){return e!==void 0&&(this.settings.timeoutMs=e),this}setStartTimeMs(e){return e!==void 0&&(this.settings.startTimeMs=e),this}build(){return this.settings}};var lZe=["GITHUB_TOKEN","GITHUB_COPILOT_API_TOKEN","CAPI_HMAC_KEY","CAPI_HMAC_KEY_OVERRIDE","ANTHROPIC_API_KEY","AIP_SWE_AGENT_TOKEN","CAPI_AZURE_KEY_VAULT_URI","COPILOT_JOB_NONCE","GITHUB_MCP_SERVER_TOKEN","OPENAI_BASE_URL","OPENAI_API_KEY","COPILOT_AGENT_REQUEST_HEADERS","AZURE_OPENAI_API_KEY","AZURE_OPENAI_API_ENDPOINT","AZURE_OPENAI_KEY_VAULT_URI","AZURE_OPENAI_KEY_VAULT_SECRET_NAME","BLACKBIRD_AUTH_METIS_API_KEY","BLACKBIRD_AUTH_MODEL_BASED_RETRIEVAL_TOKEN"],mAt=["COPILOT_CALLBACK_URL","COPILOT_AGENT_MODEL","COPILOT_AGENT_JOB_ID","COPILOT_AGENT_PROMPT","COPILOT_AGENT_PUSH","COPILOT_FIREWALL_ENABLED","COPILOT_FIREWALL_ALLOW_LIST","GITHUB_COPILOT_INTEGRATION_ID","COPILOT_INTEGRATION_ID_OVERRIDE","COPILOT_AGENT_SESSION_ID","COPILOT_AGENT_PREVIOUS_SESSION_IDS","COPILOT_AGENT_EVENT_URL","COPILOT_AGENT_EVENT_TYPE","COPILOT_AGENT_ACTOR","COPILOT_AGENT_ACTOR_ID",...lZe];async function bAt(){let t=new M3;t.setGithubServerUrl(process.env.GITHUB_SERVER_URL).setGithubHost(process.env.GITHUB_HOST).setGithubHostProtocol(process.env.GITHUB_HOST_PROTOCOL).setGithubToken(process.env.GITHUB_TOKEN).setGithubUserName(process.env.COPILOT_AGENT_COMMIT_LOGIN).setGithubUserEmail(process.env.COPILOT_AGENT_COMMIT_EMAIL).setGithubRepoOwnerId(process.env.GITHUB_REPOSITORY_OWNER_ID).setGithubRepoOwnerName(process.env.GITHUB_REPOSITORY_OWNER).setGithubRepoId(process.env.GITHUB_REPOSITORY_ID).setGithubRepoName(process.env.GITHUB_REPOSITORY).setGithubRepoBranch(process.env.COPILOT_AGENT_BRANCH_NAME).setGithubRepoCommit(process.env.COPILOT_AGENT_BASE_COMMIT).setAgentRuntimeVersion(process.env.COPILOT_AGENT_RUNTIME_VERSION),process.env.COPILOT_AGENT_PUSH!==void 0&&t.setGithubRepoReadWrite(process.env.COPILOT_AGENT_PUSH==="true"),t.setGithubPRCommitCount(process.env.COPILOT_AGENT_PR_COMMIT_COUNT?parseInt(process.env.COPILOT_AGENT_PR_COMMIT_COUNT,10):void 0),t.setProblemStatement(process.env.COPILOT_AGENT_PROMPT).setProblemContentFilterMode(process.env.COPILOT_AGENT_CONTENT_FILTER_MODE).setCustomAgentName(process.env.COPILOT_CUSTOM_AGENT);let e=process.env.COPILOT_AGENT_ACTION;if(e&&["fix","fix-pr-comment"].includes(e)&&t.setProblemAction(e),process.env.COPILOT_AGENT_ACTOR_ID&&t.setGithubActorId(parseInt(process.env.COPILOT_AGENT_ACTOR_ID,10)),process.env.COPILOT_AGENT_ACTOR&&t.setGithubActorLogin(process.env.COPILOT_AGENT_ACTOR),t.setInstanceId(process.env.COPILOT_AGENT_JOB_ID).setCopilotJobNonce(process.env.COPILOT_JOB_NONCE).setAgentModel(process.env.COPILOT_AGENT_MODEL).setCallbackUrl(process.env.COPILOT_AGENT_CALLBACK_URL).setGitHubUploadsUrl(process.env.GITHUB_UPLOADS_URL).setGitHubDownloadsUrl(process.env.GITHUB_DOWNLOADS_URL),t.setAipSweAgentToken(process.env.AIP_SWE_AGENT_TOKEN).setAnthropicApiKey(process.env.ANTHROPIC_API_KEY).setCopilotUrl(process.env.COPILOT_API_URL).setCopilotIntegrationId(process.env.GITHUB_COPILOT_INTEGRATION_ID).setCopilotHmacKey(process.env.CAPI_HMAC_KEY).setCopilotToken(process.env.GITHUB_COPILOT_API_TOKEN).setCopilotAzureKeyVaultUri(process.env.CAPI_AZURE_KEY_VAULT_URI).setBlackbirdMode(process.env.BLACKBIRD_MODE||"initial-search").setCopilotSessionId(process.env.COPILOT_AGENT_SESSION_ID).setCopilotPreviousSessionIds(process.env.COPILOT_AGENT_PREVIOUS_SESSION_IDS).setSwebenchBaseCommit(process.env.SWEBENCH_BASE_COMMIT).setGitHubMCPServerToken(process.env.GITHUB_MCP_SERVER_TOKEN).setAzureOpenAiKeyVaultUri(process.env.AZURE_OPENAI_KEY_VAULT_URI).setAzureOpenAiSecretName(process.env.AZURE_OPENAI_KEY_VAULT_SECRET_NAME).setOpenAiBaseUrl(process.env.OPENAI_BASE_URL).setOpenAiApiKey(process.env.AZURE_OPENAI_API_KEY||process.env.OPENAI_API_KEY).setAzureOpenAiUrl(process.env.AZURE_OPENAI_API_ENDPOINT).setAzureOpenAiApiVersion(process.env.AZURE_OPENAI_API_VERSION),process.env.COPILOT_USE_SESSIONS!==void 0&&t.setCopilotUseSessions(process.env.COPILOT_USE_SESSIONS==="true"),t.setTrajectoryOutputFile(process.env.CPD_SAVE_TRAJECTORY_OUTPUT),t.setEventsLogDirectory(process.env.COPILOT_EVENTS_LOG_DIRECTORY),process.env.COPILOT_AGENT_ONLINE_EVALUATION_DISABLED!==void 0&&t.setDisableOnlineEvaluation(process.env.COPILOT_AGENT_ONLINE_EVALUATION_DISABLED==="true"),process.env.COPILOT_AGENT_ONLINE_EVALUATION_OUTPUT_FILE!==void 0&&t.setEnableOnlineEvaluationOutputFile(process.env.COPILOT_AGENT_ONLINE_EVALUATION_OUTPUT_FILE==="true"),process.env.COPILOT_FEATURE_FLAGS&&process.env.COPILOT_FEATURE_FLAGS.split(",").map(r=>r.trim()).filter(r=>r.length>0).forEach(r=>t.setFeatureFlagEnabled(r)),process.env.COPILOT_EXPERIMENTS&&process.env.COPILOT_EXPERIMENTS.split(",").map(r=>{let[I,a]=r.split(":");t.setExperiment(I,a)}),process.env.COPILOT_AGENT_ERROR_CODES_TO_RETRY){let r=process.env.COPILOT_AGENT_ERROR_CODES_TO_RETRY.split(",").map(I=>parseInt(I.trim(),10));t.setRetryPolicy({errorCodesToRetry:r})}if(process.env.COPILOT_AGENT_REQUEST_HEADERS)try{let r=JSON.parse(process.env.COPILOT_AGENT_REQUEST_HEADERS);t.setRequestHeaders(r)}catch{}let l=process.env.COPILOT_AGENT_TIMEOUT_MIN?parseInt(process.env.COPILOT_AGENT_TIMEOUT_MIN,10):void 0;l!==void 0&&!Number.isNaN(l)&&t.setTimeoutMs(l*60*1e3);let n=process.env.COPILOT_AGENT_START_TIME_SEC?parseInt(process.env.COPILOT_AGENT_START_TIME_SEC,10):void 0;return n!==void 0&&!Number.isNaN(n)&&t.setStartTimeMs(n*1e3),t.build()}c();c();var yAt=nt(pAt(),1);import{exec as WAt,execFile as y5l}from"child_process";c();c();c();var Pee=null;function F_(){return!!Pee}function mLe(){if(!Pee)throw new Error("Settings have not been initialized");return Pee}function hAt(t){return Pee=t,t}function C_(){Pee=null}c();function oo(t,e){return t?.featureFlags?.[e]??!1}function AAt(t,e){return t?.experiments?.[e]}function bLe(t){return Object.keys(t.featureFlags??{}).filter(e=>t.featureFlags?.[e]).join(",")}var N5l=["token","secret","key","hmacKey","modelBasedRetrievalToken","metisApiKey"];function GLe(t,e=[]){for(let[l,n]of Object.entries(t))if(n!==null)switch(typeof n){case"object":GLe(n,e);break;case"undefined":break;default:if(N5l.includes(l)){let r=n.toString().trim();r!=""&&e.push(r)}break}return e}function ZAt(t,e){if(isNaN(e)||!isFinite(e)||e<=0)return{isWithin:!1,withinMs:e};if(e>1)return{isWithin:!1,withinMs:e};if(!t.timeoutMs)return{isWithin:!1,withinMs:e};let l=t.timeoutMs*e;return t.startTimeMs?{isWithin:Date.now()-t.startTimeMs>=t.timeoutMs-l,withinMs:l}:{isWithin:!1,withinMs:l}}c();import*as gAt from"process";function pLe(t){let e=gAt.env[t];if(e&&e.trim()!=="")return e}var W5l=[/\b(?:eyJ0eXAiOi|eyJhbGciOi|eyJ4NXQiOi|eyJraWQiOi)[^\s'";]+/g,/\bBearer\s+[^\s'";]+/g,/\b(?:Password|Pwd)=(?:[^\s'";]+|"[^"]+")/gi,/\s+-(?:Password|Pwd)\s+(?:[^\s'";]+|"[^"]+")/gi,/\bv1\.[0-9A-Fa-f]{40}\b/g,/\bgh[pousr]{1}_[A-Za-z0-9]{36}\b/g,/\bgithub_pat_[0-9][A-Za-z0-9]{21}_[A-Za-z0-9]{59}\b/g,/(?:[a-zA-Z][a-zA-Z\d+-.]*):\/\/([a-zA-Z\d\-._~!$&'()*+,;=%]+):([a-zA-Z\d\-._~!$&'()*+,;=:%]*)@/g,/\b[0-9A-Za-z-_~.]{3}7Q~[0-9A-Za-z-_~.]{31}\b|\b[0-9A-Za-z-_~.]{3}8Q~[0-9A-Za-z-_~.]{34}\b/g,/\b[0-9A-Za-z+/]{76}(APIM|ACDb|\+(ABa|AMC|ASt))[0-9A-Za-z+/]{5}[AQgw]==/g,/\b[0-9A-Za-z+/]{33}(AIoT|\+(ASb|AEh|ARm))[A-P][0-9A-Za-z+/]{5}=/g,/\b[0-9A-Za-z_-]{44}AzFu[0-9A-Za-z\-_]{5}[AQgw]==/g,/\b[0-9A-Za-z]{42}AzSe[A-D][0-9A-Za-z]{5}\b/g,/\b[0-9A-Za-z+/]{42}\+ACR[A-D][0-9A-Za-z+/]{5}\b/g,/\b[0-9A-Za-z]{33}AzCa[A-P][0-9A-Za-z]{5}=/g,/\boy2[a-p][0-9a-z]{15}[aq][0-9a-z]{11}[eu][bdfhjlnprtvxz357][a-p][0-9a-z]{11}[aeimquy4]\b/g,/\bnpm_[0-9A-Za-z]{36}\b/g,/\bx-ghcr-signature=[^&]+/g],NAt="******",g1=class t{static singleton;static getInstance(){return t.singleton||(t.singleton=new t),t.singleton}secretValuesToFilter;runner;logger;constructor(){}setRunner(e){this.runner=e,this.logger=e.logger,this.secretValuesToFilter=void 0}filterSecrets(e){let l=typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"message"),n=l?e.message??e.toString():e,r=this.getSecretValues();for(let I of r)n=n.replaceAll(I,NAt);for(let I of W5l)n=n.replaceAll(I,NAt);return l?(e.message=n,e):n}filterSecretsFromJsonString(e){try{let l=JSON.parse(e),n=this.filterSecretsFromObj(l);return JSON.stringify(n)}catch{return this.filterSecrets(e)}}filterSecretsFromObj(e){if(e==null)return e;if(typeof e=="string")return this.filterSecrets(e);if(typeof e=="number"){let l=this.filterSecrets(e.toString()),n=Number(l);return isNaN(n)?l:n}if(Array.isArray(e))return e.map(l=>this.filterSecretsFromObj(l));if(typeof e=="object"){let l={};for(let[n,r]of Object.entries(e))l[n]=this.filterSecretsFromObj(r);return l}return e}getSecretValues(){if(this.secretValuesToFilter)return this.secretValuesToFilter;let e={secretEnvVars:!1,runner:!1,settings:!1},l=new Set;for(let n of lZe){let r=pLe(n);r&&hLe(l,r)}if(e.secretEnvVars=!0,this.runner){for(let n of this.runner.sensitiveKeys){let r=pLe(n);r&&hLe(l,r)}e.runner=!0}if(F_()){let n=GLe(mLe());for(let r of n)hLe(l,r);e.settings=!0}return Object.values(e).every(n=>n)&&(this.secretValuesToFilter=l,this.logger?.debug("Caching secret values to filter from all sources.")),l}};function hLe(t,e){t.add(e),t.add(Buffer.from(e,"utf8").toString("base64"))}function jee(...t){let e=new Set(["DEBUG","COPILOT_AGENT_DEBUG",...t]);for(let l of e)if(process.env[l]==="1"||process.env[l]?.toLocaleLowerCase()==="true")return!0;return!1}var HF=class{logLevel;debugEnvironmentVariables;secretFilter=g1.getInstance();constructor(e,l){e===void 0?jee(...l??[])?this.logLevel=15:this.logLevel=7:this.logLevel=e,this.debugEnvironmentVariables=l}filterSecrets(e){return typeof e=="string"?this.secretFilter.filterSecrets(e):this.secretFilter.filterSecrets(e)}shouldLog(e){return this.logLevel===void 0||(this.logLevel&e)===e}isDebug(){return jee(...this.debugEnvironmentVariables??[])}};var aW=class{logger;constructor(e){this.logger=e}async exec(e,l,n,r=[]){let I=n?.silent??!1,a=n?.silentDebugLogging??!0;try{let s=(n?.isDirectAgentCommand?"Copilot: ":"")+(l?`${e} ${l.join(" ")}`:e);this.logger.startGroup(s,I?8:void 0);let o=await this._exec(e,l,n,r);if(o.error)throw o.error;return o.stdout&&(I?a&&this.logger.debug(o.stdout):this.logger.info(o.stdout)),o.stderr&&this.logger.error(o.stderr),0}catch(s){throw this.logger.error(s),s}finally{this.logger.endGroup(I?8:void 0)}}async execReturn(e,l,n,r=[]){let I=n?.silent??!1,a=n?.silentDebugLogging??!0;try{let s=(n?.isDirectAgentCommand?"Copilot: ":"")+(l?`${e} ${l.join(" ")}`:e);this.logger.startGroup(s,I?8:void 0);let o=await this._exec(e,l,n,r);if(o.error)throw o.error;return o.stdout&&(I?a&&this.logger.debug(o.stdout):this.logger.info(o.stdout)),o.stderr&&this.logger.error(o.stderr),{exitCode:o.exitCode,stdout:o.stdout,stderr:o.stderr}}catch(s){throw this.logger.error(s),s}finally{this.logger.endGroup(I?8:void 0)}}_exec(e,l,n,r=[]){n||(n={}),n.timeout||(n.timeout=9e5),l||(l=[]);let I={cwd:n.cwd,env:n.env,shell:n.shell,timeout:n.timeout,signal:n.abortSignal};return new Promise((a,s)=>{let o=n.shell&&l?.length===0?WAt(e,I):n.shell?WAt(`${e} ${(0,yAt.default)(l)}`,I):y5l(e,l,I),d="",u="";o.stdout?.on("data",b=>{d+=b}),o.stderr?.on("data",b=>{u+=b}),o.on("close",(b,p)=>{if(b!==0&&!n?.ignoreReturnCode){let h=this.filterCommand(e,l,r),Z=new Error(`Command failed with exit code ${b}: ${h}`);Z.cmd=h,Z.code=b,Z.stdout=d,Z.stderr=u,Z.signal=p,s(Z)}else a({error:null,stdout:d,stderr:u,exitCode:b})}),o.on("error",b=>{b.stdout=d,b.stderr=u,b.cmd=this.filterCommand(e,l,r),s(b)}),n.input&&(o.stdin?.write(n.input),o.stdin?.end())})}filterCommand(e,l=[],n){let r=l.reduce((I,a)=>(n.includes(a)?I.push("REDACTED"):I.push(a),I),[]);return`${e} ${r.join(" ")}`}};c();import{randomUUID as E5l}from"crypto";import{cpSync as R5l,existsSync as JAt,mkdtempSync as Y5l,rmSync as V5l}from"fs";import{homedir as xAt,tmpdir as w5l}from"os";import{join as ete}from"path";c();var _3=class t extends Error{cmd;killed;code;signal;stdout="";stderr="";errorType;skipReport;constructor(e,l,n=!1){if(!l){let r=e.code,I=e.message;"stdout"in e&&"stderr"in e&&(I+=`
804
+ `)l.name="enter";else if(t===" ")l.name="tab";else if(t==="\b"||t==="\x1B\b")l.name="backspace",l.meta=t.charAt(0)==="\x1B";else if(t==="\x7F"||t==="\x1B\x7F")l.name="delete",l.meta=t.charAt(0)==="\x1B";else if(t==="\x1B"||t==="\x1B\x1B")l.name="escape",l.meta=t.length===2;else if(t===" "||t==="\x1B ")l.name="space",l.meta=t.length===2;else if(t.length===1&&t<="")l.name=String.fromCharCode(t.charCodeAt(0)+97-1),l.ctrl=!0;else if(t.length===1&&t>="0"&&t<="9")l.name="number";else if(t.length===1&&t>="a"&&t<="z")l.name=t;else if(t.length===1&&t>="A"&&t<="Z")l.name=t.toLowerCase(),l.shift=!0;else if(e=pRl.exec(t))l.meta=!0,l.shift=/^[A-Z]$/.test(e[1]);else if(e=hRl.exec(t)){let n=[...t];n[0]==="\x1B"&&n[1]==="\x1B"&&(l.option=!0);let r=[e[1],e[2],e[4],e[6]].filter(Boolean).join(""),I=(e[3]||e[5]||1)-1;l.ctrl=!!(I&4),l.meta=!!(I&10),l.shift=!!(I&1),l.code=r,l.name=Qct[r],l.shift=ARl(r)||l.shift,l.ctrl=ZRl(r)||l.ctrl}return l},Cct=gRl;c();var vct=nt(qt(),1);var NRl=()=>(0,vct.useContext)(Dpe),fM=NRl;var WRl=(t,e={})=>{let{stdin:l,setRawMode:n,internal_exitOnCtrlC:r,internal_eventEmitter:I}=fM();(0,kXe.useEffect)(()=>{if(e.isActive!==!1)return n(!0),()=>{n(!1)}},[e.isActive,n]),(0,kXe.useEffect)(()=>{if(e.isActive===!1)return;let a=s=>{let o=Cct(s),d={upArrow:o.name==="up",downArrow:o.name==="down",leftArrow:o.name==="left",rightArrow:o.name==="right",pageDown:o.name==="pagedown",pageUp:o.name==="pageup",return:o.name==="return",escape:o.name==="escape",ctrl:o.ctrl,shift:o.shift,tab:o.name==="tab",backspace:o.name==="backspace",delete:o.name==="delete",meta:o.meta||o.name==="escape"||o.option},u=o.ctrl?o.name:o.sequence;Fct.includes(o.name)&&(u=""),u.startsWith("\x1B")&&(u=u.slice(1)),u.length===1&&typeof u[0]=="string"&&/[A-Z]/.test(u[0])&&(d.shift=!0),(!(u==="c"&&d.ctrl)||!r)&&pF.batchedUpdates(()=>{t(u,d)})};return I?.on("input",a),()=>{I?.removeListener("input",a)}},[e.isActive,l,r,t])},I1=WRl;c();var yRl=nt(qt(),1);c();var fct=nt(qt(),1);var ERl=()=>(0,fct.useContext)(zpe),PN=ERl;c();var RRl=nt(qt(),1);c();var LXe=nt(qt(),1);c();var YRl=nt(qt(),1);c();var Hct=nt(qt(),1);var VRl=()=>{let{isScreenReaderEnabled:t}=(0,Hct.useContext)(hF);return t},y3=VRl;c();var wRl=t=>({width:t.yogaNode?.getComputedWidth()??0,height:t.yogaNode?.getComputedHeight()??0}),ehe=wRl;var Iat=nt(qt(),1);import psr,{join as rat}from"path";import{text as hsr}from"stream/consumers";c();c();var SAt=nt(V_(),1);c();c();c();c();var lp=[];for(let t=0;t<256;++t)lp.push((t+256).toString(16).slice(1));function uAt(t,e=0){return(lp[t[e+0]]+lp[t[e+1]]+lp[t[e+2]]+lp[t[e+3]]+"-"+lp[t[e+4]]+lp[t[e+5]]+"-"+lp[t[e+6]]+lp[t[e+7]]+"-"+lp[t[e+8]]+lp[t[e+9]]+"-"+lp[t[e+10]]+lp[t[e+11]]+lp[t[e+12]]+lp[t[e+13]]+lp[t[e+14]]+lp[t[e+15]]).toLowerCase()}c();import{randomFillSync as p5l}from"node:crypto";var tZe=new Uint8Array(256),eZe=tZe.length;function dLe(){return eZe>tZe.length-16&&(p5l(tZe),eZe=0),tZe.slice(eZe,eZe+=16)}c();c();import{randomUUID as h5l}from"node:crypto";var uLe={randomUUID:h5l};function A5l(t,e,l){t=t||{};let n=t.random??t.rng?.()??dLe();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){if(l=l||0,l<0||l+16>e.length)throw new RangeError(`UUID byte range ${l}:${l+15} is out of buffer bounds`);for(let r=0;r<16;++r)e[l+r]=n[r];return e}return uAt(n)}function Z5l(t,e,l){return uLe.randomUUID&&!e&&!t?uLe.randomUUID():A5l(t,e,l)}var Bu=Z5l;var M3=class{settings={};mergePartial(e,l){return{...e,...l}}setBlackbirdMode(e){return e!==void 0&&(e=="tool"||e=="initial-search")&&(this.settings.blackbird=this.mergePartial(this.settings.blackbird,{mode:e})),this}setSwebenchBaseCommit(e){return e!==void 0&&(this.settings.swebench_base_commit=e),this}setGithubUserName(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,name:e}})}return this}setGithubUserEmail(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,email:e}})}return this}setGithubToken(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{token:e})),this}setGithubServerUrl(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{serverUrl:e??"https://github.com"}),(!this.settings.github.host||!this.settings.github.hostProtocol)&&(this.settings.github=this.mergePartial(this.settings.github,new URL(e)))),this}setGithubHost(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{host:e})),this}setGithubHostProtocol(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{hostProtocol:e})),this}setGithubActorId(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,actorId:e}})}return this}setGithubActorLogin(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,actorLogin:e}})}return this}setAgentRuntimeVersion(e){return e!==void 0?this.settings.version=e:this.settings.version="latest",this}setGithubRepoName(e){if(e!==void 0){let l=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,name:e}})}return this}setGithubRepoId(e){if(e!==void 0){let l=this.settings.github?.repo||{},n=Number(e);isNaN(n)||(this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,id:n}}))}return this}setGithubRepoOwnerName(e){if(e!==void 0){let l=this.settings.github?.owner||{};this.settings.github=this.mergePartial(this.settings.github,{owner:{...l,name:e}})}return this}setGithubRepoOwnerId(e){if(e!==void 0){let l=this.settings.github?.owner||{},n=Number(e);isNaN(n)||(this.settings.github=this.mergePartial(this.settings.github,{owner:{...l,id:n}}))}return this}setGithubRepoBranch(e){if(e){let l=e.replace(/^refs\/heads\//,"");if(l.length===0)return this;let n=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...n,branch:l}})}return this}setGithubRepoCommit(e){if(e!==void 0){let l=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,commit:e}})}return this}setGithubRepoReadWrite(e){if(e!==void 0){let l=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,readWrite:e}})}return this}setProblemStatement(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{statement:e})),this}setProblemContentFilterMode(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{contentFilterMode:e})),this}setProblemAction(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{action:e})),this}setCustomAgentName(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{customAgentName:e})),this}setGithubPRCommitCount(e){if(e!==void 0){let l=this.settings.github?.pr||{};this.settings.github=this.mergePartial(this.settings.github,{pr:{...l,commitCount:e}})}return this}setInstanceId(e){return this.settings.service=this.mergePartial(this.settings.service,{instance:{id:e??Bu()}}),this}setAgentModel(e){if(e!==void 0){let l=this.settings.service?.agent||{};this.settings.service=this.mergePartial(this.settings.service,{agent:{...l,model:e}})}return this}setRequestHeaders(e){if(e!==void 0){let l=this.settings.service?.agent||{};this.settings.service=this.mergePartial(this.settings.service,{agent:{...l,requestHeaders:e}})}return this}setRetryPolicy(e){if(e!==void 0){let l=this.settings.service?.agent||{};this.settings.service=this.mergePartial(this.settings.service,{agent:{...l,retryPolicy:e}})}return this}setCallbackUrl(e){return e!==void 0&&(this.settings.service=this.mergePartial(this.settings.service,{callback:{url:e}})),this}setGitHubUploadsUrl(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{uploadsUrl:e})),this}setGitHubDownloadsUrl(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{downloadsUrl:e})),this}setAipSweAgentToken(e){return e!==void 0&&(this.settings.api=this.mergePartial(this.settings.api,{aipSweAgent:{token:e}})),this}setAnthropicApiKey(e){return e!==void 0&&(this.settings.api=this.mergePartial(this.settings.api,{anthropic:{key:e}})),this}setOpenAiApiKey(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,apiKey:e}})}return this}setOpenAiBaseUrl(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,baseUrl:e}})}return this}setAzureOpenAiUrl(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azure:{...l.azure,url:e}}})}return this}setAzureOpenAiApiVersion(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azure:{...l.azure,apiVersion:e}}})}return this}setAzureOpenAiKeyVaultUri(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azureKeyVaultUri:e}})}return this}setAzureOpenAiSecretName(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azureSecretName:e}})}return this}setCopilotUrl(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,url:e}})}return this}setCopilotIntegrationId(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,integrationId:e}})}return this}setCopilotHmacKey(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,hmacKey:e}})}return this}setCopilotToken(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,token:e}})}return this}setCopilotAzureKeyVaultUri(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,azureKeyVaultUri:e}})}return this}setCopilotSessionId(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,sessionId:e}})}return this}setCopilotPreviousSessionIds(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,previousSessionIds:e.split(",").map(n=>n.trim()).filter(n=>n.length>0)}})}return this}setCopilotUseSessions(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,useSessions:e}})}return this}setCopilotJobNonce(e){return e!==void 0&&(this.settings.job=this.mergePartial(this.settings.job,{nonce:e})),this}setCopilotJobEventType(e){return e!==void 0&&(this.settings.job=this.mergePartial(this.settings.job,{eventType:e})),this}setTrajectoryOutputFile(e){return e!==void 0&&(this.settings.trajectory=this.mergePartial(this.settings.trajectory,{outputFile:e})),this}setEventsLogDirectory(e){return e!==void 0&&(this.settings.logs=this.mergePartial(this.settings.logs,{eventsLogDir:e})),this}setDisableOnlineEvaluation(e){return e==!0&&this.settings.onlineEvaluation?.disableOnlineEvaluation!==!0&&(this.settings.onlineEvaluation=this.mergePartial(this.settings.onlineEvaluation,{disableOnlineEvaluation:e})),this}setEnableOnlineEvaluationOutputFile(e){return e==!0&&this.settings.onlineEvaluation?.enableOnlineEvaluationOutputFile!==!0&&(this.settings.onlineEvaluation=this.mergePartial(this.settings.onlineEvaluation,{enableOnlineEvaluationOutputFile:e})),this}setGitHubMCPServerToken(e){return e!==void 0&&(this.settings.api=this.mergePartial(this.settings.api,{github:{mcpServerToken:e}})),this}setFeatureFlagEnabled(e){return this.settings.featureFlags=this.mergePartial(this.settings.featureFlags,{[e]:!0}),this}setExperiment(e,l){return this.settings.experiments=this.mergePartial(this.settings.experiments,{[e]:l}),this}setTimeoutMs(e){return e!==void 0&&(this.settings.timeoutMs=e),this}setStartTimeMs(e){return e!==void 0&&(this.settings.startTimeMs=e),this}build(){return this.settings}};var lZe=["GITHUB_TOKEN","GITHUB_COPILOT_API_TOKEN","CAPI_HMAC_KEY","CAPI_HMAC_KEY_OVERRIDE","ANTHROPIC_API_KEY","AIP_SWE_AGENT_TOKEN","CAPI_AZURE_KEY_VAULT_URI","COPILOT_JOB_NONCE","GITHUB_MCP_SERVER_TOKEN","OPENAI_BASE_URL","OPENAI_API_KEY","COPILOT_AGENT_REQUEST_HEADERS","AZURE_OPENAI_API_KEY","AZURE_OPENAI_API_ENDPOINT","AZURE_OPENAI_KEY_VAULT_URI","AZURE_OPENAI_KEY_VAULT_SECRET_NAME","BLACKBIRD_AUTH_METIS_API_KEY","BLACKBIRD_AUTH_MODEL_BASED_RETRIEVAL_TOKEN"],mAt=["COPILOT_CALLBACK_URL","COPILOT_AGENT_MODEL","COPILOT_AGENT_JOB_ID","COPILOT_AGENT_PROMPT","COPILOT_AGENT_PUSH","COPILOT_FIREWALL_ENABLED","COPILOT_FIREWALL_ALLOW_LIST","GITHUB_COPILOT_INTEGRATION_ID","COPILOT_INTEGRATION_ID_OVERRIDE","COPILOT_AGENT_SESSION_ID","COPILOT_AGENT_PREVIOUS_SESSION_IDS","COPILOT_AGENT_EVENT_URL","COPILOT_AGENT_EVENT_TYPE","COPILOT_AGENT_ACTOR","COPILOT_AGENT_ACTOR_ID",...lZe];async function bAt(){let t=new M3;t.setGithubServerUrl(process.env.GITHUB_SERVER_URL).setGithubHost(process.env.GITHUB_HOST).setGithubHostProtocol(process.env.GITHUB_HOST_PROTOCOL).setGithubToken(process.env.GITHUB_TOKEN).setGithubUserName(process.env.COPILOT_AGENT_COMMIT_LOGIN).setGithubUserEmail(process.env.COPILOT_AGENT_COMMIT_EMAIL).setGithubRepoOwnerId(process.env.GITHUB_REPOSITORY_OWNER_ID).setGithubRepoOwnerName(process.env.GITHUB_REPOSITORY_OWNER).setGithubRepoId(process.env.GITHUB_REPOSITORY_ID).setGithubRepoName(process.env.GITHUB_REPOSITORY).setGithubRepoBranch(process.env.COPILOT_AGENT_BRANCH_NAME).setGithubRepoCommit(process.env.COPILOT_AGENT_BASE_COMMIT).setAgentRuntimeVersion(process.env.COPILOT_AGENT_RUNTIME_VERSION),process.env.COPILOT_AGENT_PUSH!==void 0&&t.setGithubRepoReadWrite(process.env.COPILOT_AGENT_PUSH==="true"),t.setGithubPRCommitCount(process.env.COPILOT_AGENT_PR_COMMIT_COUNT?parseInt(process.env.COPILOT_AGENT_PR_COMMIT_COUNT,10):void 0),t.setProblemStatement(process.env.COPILOT_AGENT_PROMPT).setProblemContentFilterMode(process.env.COPILOT_AGENT_CONTENT_FILTER_MODE).setCustomAgentName(process.env.COPILOT_CUSTOM_AGENT);let e=process.env.COPILOT_AGENT_ACTION;if(e&&["fix","fix-pr-comment"].includes(e)&&t.setProblemAction(e),process.env.COPILOT_AGENT_ACTOR_ID&&t.setGithubActorId(parseInt(process.env.COPILOT_AGENT_ACTOR_ID,10)),process.env.COPILOT_AGENT_ACTOR&&t.setGithubActorLogin(process.env.COPILOT_AGENT_ACTOR),t.setInstanceId(process.env.COPILOT_AGENT_JOB_ID).setCopilotJobNonce(process.env.COPILOT_JOB_NONCE).setCopilotJobEventType(process.env.COPILOT_JOB_EVENT_TYPE).setAgentModel(process.env.COPILOT_AGENT_MODEL).setCallbackUrl(process.env.COPILOT_AGENT_CALLBACK_URL).setGitHubUploadsUrl(process.env.GITHUB_UPLOADS_URL).setGitHubDownloadsUrl(process.env.GITHUB_DOWNLOADS_URL),t.setAipSweAgentToken(process.env.AIP_SWE_AGENT_TOKEN).setAnthropicApiKey(process.env.ANTHROPIC_API_KEY).setCopilotUrl(process.env.COPILOT_API_URL).setCopilotIntegrationId(process.env.GITHUB_COPILOT_INTEGRATION_ID).setCopilotHmacKey(process.env.CAPI_HMAC_KEY).setCopilotToken(process.env.GITHUB_COPILOT_API_TOKEN).setCopilotAzureKeyVaultUri(process.env.CAPI_AZURE_KEY_VAULT_URI).setBlackbirdMode(process.env.BLACKBIRD_MODE||"initial-search").setCopilotSessionId(process.env.COPILOT_AGENT_SESSION_ID).setCopilotPreviousSessionIds(process.env.COPILOT_AGENT_PREVIOUS_SESSION_IDS).setSwebenchBaseCommit(process.env.SWEBENCH_BASE_COMMIT).setGitHubMCPServerToken(process.env.GITHUB_MCP_SERVER_TOKEN).setAzureOpenAiKeyVaultUri(process.env.AZURE_OPENAI_KEY_VAULT_URI).setAzureOpenAiSecretName(process.env.AZURE_OPENAI_KEY_VAULT_SECRET_NAME).setOpenAiBaseUrl(process.env.OPENAI_BASE_URL).setOpenAiApiKey(process.env.AZURE_OPENAI_API_KEY||process.env.OPENAI_API_KEY).setAzureOpenAiUrl(process.env.AZURE_OPENAI_API_ENDPOINT).setAzureOpenAiApiVersion(process.env.AZURE_OPENAI_API_VERSION),process.env.COPILOT_USE_SESSIONS!==void 0&&t.setCopilotUseSessions(process.env.COPILOT_USE_SESSIONS==="true"),t.setTrajectoryOutputFile(process.env.CPD_SAVE_TRAJECTORY_OUTPUT),t.setEventsLogDirectory(process.env.COPILOT_EVENTS_LOG_DIRECTORY),process.env.COPILOT_AGENT_ONLINE_EVALUATION_DISABLED!==void 0&&t.setDisableOnlineEvaluation(process.env.COPILOT_AGENT_ONLINE_EVALUATION_DISABLED==="true"),process.env.COPILOT_AGENT_ONLINE_EVALUATION_OUTPUT_FILE!==void 0&&t.setEnableOnlineEvaluationOutputFile(process.env.COPILOT_AGENT_ONLINE_EVALUATION_OUTPUT_FILE==="true"),process.env.COPILOT_FEATURE_FLAGS&&process.env.COPILOT_FEATURE_FLAGS.split(",").map(r=>r.trim()).filter(r=>r.length>0).forEach(r=>t.setFeatureFlagEnabled(r)),process.env.COPILOT_EXPERIMENTS&&process.env.COPILOT_EXPERIMENTS.split(",").map(r=>{let[I,a]=r.split(":");t.setExperiment(I,a)}),process.env.COPILOT_AGENT_ERROR_CODES_TO_RETRY){let r=process.env.COPILOT_AGENT_ERROR_CODES_TO_RETRY.split(",").map(I=>parseInt(I.trim(),10));t.setRetryPolicy({errorCodesToRetry:r})}if(process.env.COPILOT_AGENT_REQUEST_HEADERS)try{let r=JSON.parse(process.env.COPILOT_AGENT_REQUEST_HEADERS);t.setRequestHeaders(r)}catch{}let l=process.env.COPILOT_AGENT_TIMEOUT_MIN?parseInt(process.env.COPILOT_AGENT_TIMEOUT_MIN,10):void 0;l!==void 0&&!Number.isNaN(l)&&t.setTimeoutMs(l*60*1e3);let n=process.env.COPILOT_AGENT_START_TIME_SEC?parseInt(process.env.COPILOT_AGENT_START_TIME_SEC,10):void 0;return n!==void 0&&!Number.isNaN(n)&&t.setStartTimeMs(n*1e3),t.build()}c();c();var yAt=nt(pAt(),1);import{exec as WAt,execFile as y5l}from"child_process";c();c();c();var Pee=null;function F_(){return!!Pee}function mLe(){if(!Pee)throw new Error("Settings have not been initialized");return Pee}function hAt(t){return Pee=t,t}function C_(){Pee=null}c();function oo(t,e){return t?.featureFlags?.[e]??!1}function AAt(t,e){return t?.experiments?.[e]}function bLe(t){return Object.keys(t.featureFlags??{}).filter(e=>t.featureFlags?.[e]).join(",")}var N5l=["token","secret","key","hmacKey","modelBasedRetrievalToken","metisApiKey"];function GLe(t,e=[]){for(let[l,n]of Object.entries(t))if(n!==null)switch(typeof n){case"object":GLe(n,e);break;case"undefined":break;default:if(N5l.includes(l)){let r=n.toString().trim();r!=""&&e.push(r)}break}return e}function ZAt(t,e){if(isNaN(e)||!isFinite(e)||e<=0)return{isWithin:!1,withinMs:e};if(e>1)return{isWithin:!1,withinMs:e};if(!t.timeoutMs)return{isWithin:!1,withinMs:e};let l=t.timeoutMs*e;return t.startTimeMs?{isWithin:Date.now()-t.startTimeMs>=t.timeoutMs-l,withinMs:l}:{isWithin:!1,withinMs:l}}c();import*as gAt from"process";function pLe(t){let e=gAt.env[t];if(e&&e.trim()!=="")return e}var W5l=[/\b(?:eyJ0eXAiOi|eyJhbGciOi|eyJ4NXQiOi|eyJraWQiOi)[^\s'";]+/g,/\bBearer\s+[^\s'";]+/g,/\b(?:Password|Pwd)=(?:[^\s'";]+|"[^"]+")/gi,/\s+-(?:Password|Pwd)\s+(?:[^\s'";]+|"[^"]+")/gi,/\bv1\.[0-9A-Fa-f]{40}\b/g,/\bgh[pousr]{1}_[A-Za-z0-9]{36}\b/g,/\bgithub_pat_[0-9][A-Za-z0-9]{21}_[A-Za-z0-9]{59}\b/g,/(?:[a-zA-Z][a-zA-Z\d+-.]*):\/\/([a-zA-Z\d\-._~!$&'()*+,;=%]+):([a-zA-Z\d\-._~!$&'()*+,;=:%]*)@/g,/\b[0-9A-Za-z-_~.]{3}7Q~[0-9A-Za-z-_~.]{31}\b|\b[0-9A-Za-z-_~.]{3}8Q~[0-9A-Za-z-_~.]{34}\b/g,/\b[0-9A-Za-z+/]{76}(APIM|ACDb|\+(ABa|AMC|ASt))[0-9A-Za-z+/]{5}[AQgw]==/g,/\b[0-9A-Za-z+/]{33}(AIoT|\+(ASb|AEh|ARm))[A-P][0-9A-Za-z+/]{5}=/g,/\b[0-9A-Za-z_-]{44}AzFu[0-9A-Za-z\-_]{5}[AQgw]==/g,/\b[0-9A-Za-z]{42}AzSe[A-D][0-9A-Za-z]{5}\b/g,/\b[0-9A-Za-z+/]{42}\+ACR[A-D][0-9A-Za-z+/]{5}\b/g,/\b[0-9A-Za-z]{33}AzCa[A-P][0-9A-Za-z]{5}=/g,/\boy2[a-p][0-9a-z]{15}[aq][0-9a-z]{11}[eu][bdfhjlnprtvxz357][a-p][0-9a-z]{11}[aeimquy4]\b/g,/\bnpm_[0-9A-Za-z]{36}\b/g,/\bx-ghcr-signature=[^&]+/g],NAt="******",g1=class t{static singleton;static getInstance(){return t.singleton||(t.singleton=new t),t.singleton}secretValuesToFilter;runner;logger;constructor(){}setRunner(e){this.runner=e,this.logger=e.logger,this.secretValuesToFilter=void 0}filterSecrets(e){let l=typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"message"),n=l?e.message??e.toString():e,r=this.getSecretValues();for(let I of r)n=n.replaceAll(I,NAt);for(let I of W5l)n=n.replaceAll(I,NAt);return l?(e.message=n,e):n}filterSecretsFromJsonString(e){try{let l=JSON.parse(e),n=this.filterSecretsFromObj(l);return JSON.stringify(n)}catch{return this.filterSecrets(e)}}filterSecretsFromObj(e){if(e==null)return e;if(typeof e=="string")return this.filterSecrets(e);if(typeof e=="number"){let l=this.filterSecrets(e.toString()),n=Number(l);return isNaN(n)?l:n}if(Array.isArray(e))return e.map(l=>this.filterSecretsFromObj(l));if(typeof e=="object"){let l={};for(let[n,r]of Object.entries(e))l[n]=this.filterSecretsFromObj(r);return l}return e}getSecretValues(){if(this.secretValuesToFilter)return this.secretValuesToFilter;let e={secretEnvVars:!1,runner:!1,settings:!1},l=new Set;for(let n of lZe){let r=pLe(n);r&&hLe(l,r)}if(e.secretEnvVars=!0,this.runner){for(let n of this.runner.sensitiveKeys){let r=pLe(n);r&&hLe(l,r)}e.runner=!0}if(F_()){let n=GLe(mLe());for(let r of n)hLe(l,r);e.settings=!0}return Object.values(e).every(n=>n)&&(this.secretValuesToFilter=l,this.logger?.debug("Caching secret values to filter from all sources.")),l}};function hLe(t,e){t.add(e),t.add(Buffer.from(e,"utf8").toString("base64"))}function jee(...t){let e=new Set(["DEBUG","COPILOT_AGENT_DEBUG",...t]);for(let l of e)if(process.env[l]==="1"||process.env[l]?.toLocaleLowerCase()==="true")return!0;return!1}var HF=class{logLevel;debugEnvironmentVariables;secretFilter=g1.getInstance();constructor(e,l){e===void 0?jee(...l??[])?this.logLevel=15:this.logLevel=7:this.logLevel=e,this.debugEnvironmentVariables=l}filterSecrets(e){return typeof e=="string"?this.secretFilter.filterSecrets(e):this.secretFilter.filterSecrets(e)}shouldLog(e){return this.logLevel===void 0||(this.logLevel&e)===e}isDebug(){return jee(...this.debugEnvironmentVariables??[])}};var aW=class{logger;constructor(e){this.logger=e}async exec(e,l,n,r=[]){let I=n?.silent??!1,a=n?.silentDebugLogging??!0;try{let s=(n?.isDirectAgentCommand?"Copilot: ":"")+(l?`${e} ${l.join(" ")}`:e);this.logger.startGroup(s,I?8:void 0);let o=await this._exec(e,l,n,r);if(o.error)throw o.error;return o.stdout&&(I?a&&this.logger.debug(o.stdout):this.logger.info(o.stdout)),o.stderr&&this.logger.error(o.stderr),0}catch(s){throw this.logger.error(s),s}finally{this.logger.endGroup(I?8:void 0)}}async execReturn(e,l,n,r=[]){let I=n?.silent??!1,a=n?.silentDebugLogging??!0;try{let s=(n?.isDirectAgentCommand?"Copilot: ":"")+(l?`${e} ${l.join(" ")}`:e);this.logger.startGroup(s,I?8:void 0);let o=await this._exec(e,l,n,r);if(o.error)throw o.error;return o.stdout&&(I?a&&this.logger.debug(o.stdout):this.logger.info(o.stdout)),o.stderr&&this.logger.error(o.stderr),{exitCode:o.exitCode,stdout:o.stdout,stderr:o.stderr}}catch(s){throw this.logger.error(s),s}finally{this.logger.endGroup(I?8:void 0)}}_exec(e,l,n,r=[]){n||(n={}),n.timeout||(n.timeout=9e5),l||(l=[]);let I={cwd:n.cwd,env:n.env,shell:n.shell,timeout:n.timeout,signal:n.abortSignal};return new Promise((a,s)=>{let o=n.shell&&l?.length===0?WAt(e,I):n.shell?WAt(`${e} ${(0,yAt.default)(l)}`,I):y5l(e,l,I),d="",u="";o.stdout?.on("data",b=>{d+=b}),o.stderr?.on("data",b=>{u+=b}),o.on("close",(b,p)=>{if(b!==0&&!n?.ignoreReturnCode){let h=this.filterCommand(e,l,r),Z=new Error(`Command failed with exit code ${b}: ${h}`);Z.cmd=h,Z.code=b,Z.stdout=d,Z.stderr=u,Z.signal=p,s(Z)}else a({error:null,stdout:d,stderr:u,exitCode:b})}),o.on("error",b=>{b.stdout=d,b.stderr=u,b.cmd=this.filterCommand(e,l,r),s(b)}),n.input&&(o.stdin?.write(n.input),o.stdin?.end())})}filterCommand(e,l=[],n){let r=l.reduce((I,a)=>(n.includes(a)?I.push("REDACTED"):I.push(a),I),[]);return`${e} ${r.join(" ")}`}};c();import{randomUUID as E5l}from"crypto";import{cpSync as R5l,existsSync as JAt,mkdtempSync as Y5l,rmSync as V5l}from"fs";import{homedir as xAt,tmpdir as w5l}from"os";import{join as ete}from"path";c();var _3=class t extends Error{cmd;killed;code;signal;stdout="";stderr="";errorType;skipReport;constructor(e,l,n=!1){if(!l){let r=e.code,I=e.message;"stdout"in e&&"stderr"in e&&(I+=`
805
805
  `+e.stderr?.trim()+`
806
806
  `+e.stdout?.trim()),I.includes("GH013: Repository rule violations found")||I.includes("unknown revision or path not in the working tree")?(l="protection rule",n=!0):I.includes("You may want to try Git Large File Storage")||I.includes("GH001: Large files detected")?(l="LFS",n=!0):r===1&&(I.includes("hook failed")||I.includes("husky -")||I.includes("hook declined")||I.includes("hook exited")||I.includes("vite ")||I.includes("eslint "))?(l="hook",n=!0):I.includes("use 'git pull' before pushing again")?(l="pull first",n=!0):I.includes("fetch first")?(l="fetch first",n=!0):I.includes("The requested URL returned error: 403")?(l="access denied",n=!1):I.includes("unexpected disconnect")?(l="disconnect",n=!1):(l="unknown",n=!(r==="ENOENT"||r===127||r===128||I.includes("fatal: ")))}super(`${l} git error: ${e.message}`);for(let r of Object.keys(e))this[r]=e[r];this.errorType=l??"unknown",this.skipReport=n,this.cause=e,Object.setPrototypeOf(this,t.prototype),this.name="GitError"}};c();var Kee="https://api.githubcopilot.com";function EAt(t){if(!t.github?.user?.name)throw new Error("GitHub user name is required");return t.github.user.name}function RAt(t){if(!t.github?.user?.email)throw new Error("GitHub user email is required");return t.github.user.email}function YAt(t){let e=t.github?.user?.actorLogin,l=t.github?.user?.actorId;if(!(!e||!l))return{login:e,id:l}}function VAt(t){if(!t.github?.serverUrl)throw new Error("GitHub server URL is required");return t.github.serverUrl}function wAt(t){if(!t.github?.host)throw new Error("GitHub host is required");return t.github.host}function QAt(t){if(!t.github?.hostProtocol)throw new Error("GitHub host protocol is required");return t.github.hostProtocol}function D3(t){if(!t.github?.token)throw new Error("GitHub token is required");return t.github.token}function nZe(t){if(!t.github?.repo?.name)throw new Error("GitHub repository name is required");return t.github.repo.name}function XF(t){if(!t.service?.instance?.id)throw new Error("Instance ID is required");return t.service.instance.id}function FAt(t){if(!t.service?.callback?.url)throw new Error("Callback URL is required");return t.service.callback.url}function CAt(t){if(!t.api?.anthropic?.key)throw new Error("Anthropic API key is required");return t.api.anthropic.key}function vAt(t){if(!t.api?.openai?.apiKey)throw new Error("OpenAI API key is required");return t.api.openai.apiKey}function fAt(t){if(!t.api?.openai?.azure?.url)throw new Error("Azure OpenAI deployment URL is required");return t.api.openai.azure.url}function HAt(t,e=Kee){let l=t.api?.copilot?.url||e;if(!l)throw new Error("Copilot URL is required");return l}function qee(t){if(!t.api?.copilot?.integrationId)throw new Error("Copilot integration ID is required");return t.api.copilot.integrationId}function $ee(t){if(!t.api?.copilot?.token)throw new Error("Copilot token is required");return t.api.copilot.token}function XAt(t){if(!t.github?.uploadsUrl)throw new Error("GitHub uploads URL is required");return t.github.uploadsUrl}function kAt(t){if(!t.github?.downloadsUrl)throw new Error("GitHub downloads URL is required");return t.github.downloadsUrl}c();function LAt(t){return t.startsWith('"')&&t.endsWith('"')?(t=t.substring(1,t.length-1),t.replace(/\\([abfnrtv\\"]|[0-7]{1,3})/g,(e,l)=>{switch(l[0]){case"a":return"\x07";case"b":return"\b";case"f":return"\f";case"n":return`
807
807
  `;case"r":return"\r";case"t":return" ";case"v":return"\v";case"\\":return"\\";case'"':return'"';default:return String.fromCharCode(parseInt(l,8))}})):t}var ALe='!f() { test "$1" = get && echo "password=$GITHUB_TOKEN"; }; f',sg=class{constructor(e,l){this.logger=e;this.exec=l}resolveGitUrl(e,l){let n=null,r="";try{r=VAt(e),n=new URL(r)}catch(I){this.logger.warning(`Failed to parse GITHUB_SERVER_URL "${r}". Falling back to GITHUB_HOST and GITHUB_GIT_HOST_PROTOCOL. Error: ${I.message??I}`);let a=QAt(e),s=wAt(e);try{n=URL.parse(`${a}://${s}`)}catch(o){this.logger.warning(`Unable to determine GITHUB_SERVER_URL. Falling back to "https://github.com". Error: ${o.message??o}`),n=URL.parse("https://github.com")}}if(!n)throw new Error("Could not determine the Git URL");return l&&(n.pathname=l),this.logger.info(`Using Git URL: ${n.href}`),n}async cloneRepo(e,l,n,r,I,a){process.env.GITHUB_TOKEN=process.env.GITHUB_TOKEN??D3(e);let o=this.resolveGitUrl(e,l).href;if(I=I??1,I+=1,I<2&&(I=2),JAt(ete(n,".git"))){let N={cwd:n,silent:!0};if(this.logger.debug(`Repo ${l} already cloned to ${n}`),this.logger.debug(`Configuring git credential helper for ${l}`),await this.setGitConfig(e,N,!1),await this.execGit(["remote","set-url","origin",o],N,[o]),(await this.execGit(["rev-parse","--abbrev-ref","HEAD"],N)).stdout.toString().trim()===r){this.logger.debug(`Already on branch ${r} in repo ${l}`);return}if((await this.execGit(["branch","--list",r],N,[r])).stdout.toString().trim().length>0){this.logger.debug(`Local branch ${r} already exists in repo ${l}`),this.logger.debug(`Checking out branch ${r}`),await this.execGit(["checkout",r],N,[r]);return}if(await this.hasRemoteBranch(r,n)){this.logger.debug(`Remote branch ${r} exists in repo ${l}`);let{stdout:w}=await this.execGit(["rev-parse","--is-shallow-repository"],N);w.trim()==="true"?await this.execGit(["fetch","--unshallow","--update-head-ok","origin","+refs/heads/*:refs/heads/*"],N):await this.execGit(["fetch","origin"],N),this.logger.debug(`Pulling branch ${r} with depth ${I}`),await this.execGit(["pull","--depth",I.toString(),"origin",r],N,[I.toString(),r]),this.logger.debug(`Checking out branch ${r}`),await this.execGit(["checkout",r],N,[r]);return}if(a){this.logger.debug(`Base commit ${a} provided for branch ${r} in repo ${l}`),this.logger.debug(`Checking out branch ${r}`),await this.execGit(["checkout","-b",r,a],N,[r,a]);return}throw new Error(`Branch ${r} does not exist in repo ${l} and no base commit was provided.`)}this.logger.debug(`Repo ${l} not cloned to ${n} yet`);let u=process.env.HOME||xAt(),b=Y5l(ete(w5l(),`cpd-${E5l()}`));JAt(ete(u,".gitconfig"))&&R5l(ete(u,".gitconfig"),ete(b,".gitconfig"));let p={...process.env,HOME:b},h={silent:!0,env:p},Z={cwd:n,silent:!0,env:p};await this.setGitConfig(e,h,!0);try{this.logger.debug(`Cloning repo ${l} to ${n} with branch ${r} and depth ${I}`),await this.execGit(["clone","-b",r,"--single-branch","--depth",I.toString(),o,n],h,[o,n,r,I.toString()])}catch(N){if(this.logger.debug(`Error cloning repo ${l} to ${n}: ${N}`),a)this.logger.debug(`Base commit ${a} provided. Checking out branch ${r}`),await this.execGit(["clone",o,n],h,[o,n]),await this.execGit(["checkout","-b",r,a],Z,[r,a]);else throw new Error(`Branch ${r} does not exist in repo ${l} and no base commit was provided.`)}finally{await this.cleanGitConfig(h,!0,!0)}await this.setGitConfig(e,Z,!1)}async commitChanges(e,l,n,r,I=!1,a=!1){process.env.HOME||(process.env.HOME=xAt());let s={cwd:n,silent:!0},o=YAt(e);if(o){let b=`Co-authored-by: ${o.login} <${o.id}+${o.login}@users.noreply.github.com>`;r=r.trim()+`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@github/copilot",
3
3
  "description": "GitHub Copilot CLI brings the power of Copilot coding agent directly to your terminal.",
4
- "version": "0.0.349-3",
4
+ "version": "0.0.349-4",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -35,7 +35,7 @@
35
35
  "worker/**/*"
36
36
  ],
37
37
  "buildMetadata": {
38
- "gitCommit": "0d91e89"
38
+ "gitCommit": "490abfb"
39
39
  },
40
40
  "dependencies": {
41
41
  "sharp": "^0.34.3"