@github/copilot 0.0.341-7 → 0.0.341-8

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
@@ -761,7 +761,7 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr
761
761
  `;if(this.options.debug){I&&(this.fullStaticOutput+=n),this.options.stdout.write(this.fullStaticOutput+e);return}if(xJ){I&&this.options.stdout.write(n),this.lastOutput=e,this.lastOutputHeight=l;return}if(this.isScreenReaderEnabled){if(I){let s=this.lastOutputHeight>0?Sb.eraseLines(this.lastOutputHeight):"";this.options.stdout.write(s+n),this.lastOutputHeight=0}if(e===this.lastOutput&&!I)return;let r=this.options.stdout.columns||80,a=XH(e,r,{trim:!1,hard:!0});if(I)this.options.stdout.write(a);else{let s=this.lastOutputHeight>0?Sb.eraseLines(this.lastOutputHeight):"";this.options.stdout.write(s+a)}this.lastOutput=e,this.lastOutputHeight=a===""?0:a.split(`
762
762
  `).length;return}if(I&&(this.fullStaticOutput+=n),this.lastOutputHeight>=this.options.stdout.rows){this.options.stdout.write(Sb.clearTerminal+this.fullStaticOutput+e),this.lastOutput=e,this.lastOutputHeight=l,this.log.sync(e);return}I&&(this.log.clear(),this.options.stdout.write(n),this.log(e)),!I&&e!==this.lastOutput&&this.throttledLog(e),this.lastOutput=e,this.lastOutputHeight=l};render(e){let l=gfe.default.createElement(Kw.Provider,{value:{isScreenReaderEnabled:this.isScreenReaderEnabled}},gfe.default.createElement(M7,{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));jw.updateContainerSync(l,this.container,null,Ast),jw.flushSyncWork()}writeToStdout(e){if(!this.isUnmounted){if(this.options.debug){this.options.stdout.write(e+this.fullStaticOutput+this.lastOutput);return}if(xJ){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(xJ){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(),xJ?this.options.stdout.write(this.lastOutput+`
763
763
  `):this.options.debug||this.log.done(),this.isUnmounted=!0,jw.updateContainerSync(null,this.container,null,Ast),jw.flushSyncWork(),HU.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(){!xJ&&!this.options.debug&&this.log.clear()}patchConsole(){this.options.debug||(this.restoreConsole=VGe((e,l)=>{e==="stdout"&&this.writeToStdout(l),e==="stderr"&&(l.startsWith("The above error occurred")||this.writeToStderr(l))}))}};var QZl=(t,e)=>{let l={stdout:cbe.stdout,stdin:cbe.stdin,stderr:cbe.stderr,debug:!1,exitOnCtrlC:!0,patchConsole:!0,maxFps:30,...wZl(e)},n=FZl(l.stdout,()=>new _7(l));return n.render(t),{rerender:n.render,unmount(){n.unmount()},waitUntilExit:n.waitUntilExit,cleanup:()=>HU.delete(l.stdout),clear:n.clear}},D7=QZl,wZl=(t={})=>t instanceof VZl?{stdout:t,stdin:cbe.stdin}:t,FZl=(t,e)=>{let l=HU.get(t);return l||(l=e(),HU.set(t,l)),l};c();var $w=st(sl(),1);function dbe(t){let{items:e,children:l,style:n}=t,[I,r]=(0,$w.useState)(0),a=(0,$w.useMemo)(()=>e.slice(I),[e,I]);(0,$w.useLayoutEffect)(()=>{r(e.length)},[e.length]);let s=a.map((d,u)=>l(d,I+u)),o=(0,$w.useMemo)(()=>({position:"absolute",flexDirection:"column",...n}),[n]);return $w.default.createElement("ink-box",{internal_static:!0,style:o},s)}c();var Nst=st(sl(),1);c();var CZl=st(sl(),1);c();var vZl=st(sl(),1);c();var Nfe=st(sl(),1);c();import{Buffer as fZl}from"node:buffer";var HZl=/^(?:\x1b)([a-zA-Z0-9])$/,XZl=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,Wst={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"},yst=[...Object.values(Wst),"backspace"],kZl=t=>["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(t),LZl=t=>["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(t),JZl=(t="")=>{let e;fZl.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===`
764
- `)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=HZl.exec(t))l.meta=!0,l.shift=/^[A-Z]$/.test(e[1]);else if(e=XZl.exec(t)){let n=[...t];n[0]==="\x1B"&&n[1]==="\x1B"&&(l.option=!0);let I=[e[1],e[2],e[4],e[6]].filter(Boolean).join(""),r=(e[3]||e[5]||1)-1;l.ctrl=!!(r&4),l.meta=!!(r&10),l.shift=!!(r&1),l.code=I,l.name=Wst[I],l.shift=kZl(I)||l.shift,l.ctrl=LZl(I)||l.ctrl}return l},Est=JZl;c();var Rst=st(sl(),1);var BZl=()=>(0,Rst.useContext)(rbe),XU=BZl;var xZl=(t,e={})=>{let{stdin:l,setRawMode:n,internal_exitOnCtrlC:I,internal_eventEmitter:r}=XU();(0,Nfe.useEffect)(()=>{if(e.isActive!==!1)return n(!0),()=>{n(!1)}},[e.isActive,n]),(0,Nfe.useEffect)(()=>{if(e.isActive===!1)return;let a=s=>{let o=Est(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;yst.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)||!I)&&jw.batchedUpdates(()=>{t(u,d)})};return r?.on("input",a),()=>{r?.removeListener("input",a)}},[e.isActive,l,I,t])},JY=xZl;c();var SZl=st(sl(),1);c();var Yst=st(sl(),1);var OZl=()=>(0,Yst.useContext)(abe),HN=OZl;c();var TZl=st(sl(),1);c();var Wfe=st(sl(),1);c();var UZl=st(sl(),1);c();var Vst=st(sl(),1);var MZl=()=>{let{isScreenReaderEnabled:t}=(0,Vst.useContext)(Kw);return t},MJ=MZl;c();var _Zl=t=>({width:t.yogaNode?.getComputedWidth()??0,height:t.yogaNode?.getComputedHeight()??0}),ube=_Zl;var qlt=st(sl(),1);import{join as UGl}from"path";import{text as NKn}from"stream/consumers";c();c();var fbt=st(wM(),1);c();c();c();c();var _b=[];for(let t=0;t<256;++t)_b.push((t+256).toString(16).slice(1));function rbt(t,e=0){return(_b[t[e+0]]+_b[t[e+1]]+_b[t[e+2]]+_b[t[e+3]]+"-"+_b[t[e+4]]+_b[t[e+5]]+"-"+_b[t[e+6]]+_b[t[e+7]]+"-"+_b[t[e+8]]+_b[t[e+9]]+"-"+_b[t[e+10]]+_b[t[e+11]]+_b[t[e+12]]+_b[t[e+13]]+_b[t[e+14]]+_b[t[e+15]]).toLowerCase()}c();import{randomFillSync as Hwl}from"node:crypto";var mhe=new Uint8Array(256),uhe=mhe.length;function j5e(){return uhe>mhe.length-16&&(Hwl(mhe),uhe=0),mhe.slice(uhe,uhe+=16)}c();c();import{randomUUID as Xwl}from"node:crypto";var K5e={randomUUID:Xwl};function kwl(t,e,l){t=t||{};let n=t.random??t.rng?.()??j5e();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 I=0;I<16;++I)e[l+I]=n[I];return e}return rbt(n)}function Lwl(t,e,l){return K5e.randomUUID&&!e&&!t?K5e.randomUUID():kwl(t,e,l)}var Ly=Lwl;var vM=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}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}setGithubIssueNumber(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{issue:{number: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??Ly()}}),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 Ghe=["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"],abt=["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",...Ghe];async function sbt(){let t=new vM;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),process.env.COPILOT_AGENT_PUSH!==void 0&&t.setGithubRepoReadWrite(process.env.COPILOT_AGENT_PUSH==="true");let e=process.env.COPILOT_AGENT_ISSUE_NUMBER?parseInt(process.env.COPILOT_AGENT_ISSUE_NUMBER,10):void 0;isNaN(e)||t.setGithubIssueNumber(e),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 l=process.env.COPILOT_AGENT_ACTION;if(l&&["fix","fix-pr-comment"].includes(l)&&t.setProblemAction(l),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[a,s]=r.split(":");t.setExperiment(a,s)}),process.env.COPILOT_AGENT_ERROR_CODES_TO_RETRY){let r=process.env.COPILOT_AGENT_ERROR_CODES_TO_RETRY.split(",").map(a=>parseInt(a.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 n=process.env.COPILOT_AGENT_TIMEOUT_MIN?parseInt(process.env.COPILOT_AGENT_TIMEOUT_MIN,10):void 0;n!==void 0&&!Number.isNaN(n)&&t.setTimeoutMs(n*60*1e3);let I=process.env.COPILOT_AGENT_START_TIME_SEC?parseInt(process.env.COPILOT_AGENT_START_TIME_SEC,10):void 0;return I!==void 0&&!Number.isNaN(I)&&t.setStartTimeMs(I*1e3),t.build()}c();c();var pbt=st(ibt(),1);import{exec as bbt,execFile as Swl}from"child_process";c();c();c();var X$=null;function fM(){return!!X$}function q5e(){if(!X$)throw new Error("Settings have not been initialized");return X$}function cbt(t){return X$=t,t}function k$(){X$=null}c();function So(t,e){return t?.featureFlags?.[e]??!1}function dbt(t,e){return t?.experiments?.[e]}function $5e(t){return Object.keys(t.featureFlags??{}).filter(e=>t.featureFlags?.[e]).join(",")}var Bwl=["token","secret","key","hmacKey","modelBasedRetrievalToken","metisApiKey"];function e4e(t,e=[]){for(let[l,n]of Object.entries(t))if(n!==null)switch(typeof n){case"object":e4e(n,e);break;case"undefined":break;default:if(Bwl.includes(l)){let I=n.toString().trim();I!=""&&e.push(I)}break}return e}function ubt(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 mbt from"process";function t4e(t){let e=mbt.env[t];if(e&&e.trim()!=="")return e}var xwl=[/\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],Gbt="******",$Y=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,I=this.getSecretValues();for(let r of I)n=n.replaceAll(r,Gbt);for(let r of xwl)n=n.replaceAll(r,Gbt);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,I]of Object.entries(e))l[n]=this.filterSecretsFromObj(I);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 Ghe){let I=t4e(n);I&&l4e(l,I)}if(e.secretEnvVars=!0,this.runner){for(let n of this.runner.sensitiveKeys){let I=t4e(n);I&&l4e(l,I)}e.runner=!0}if(fM()){let n=e4e(q5e());for(let I of n)l4e(l,I);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 l4e(t,e){t.add(e),t.add(Buffer.from(e,"utf8").toString("base64"))}function bhe(...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 $H=class{logLevel;debugEnvironmentVariables;secretFilter=$Y.getInstance();constructor(e,l){e===void 0?bhe(...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 bhe(...this.debugEnvironmentVariables??[])}};var MN=class{logger;constructor(e){this.logger=e}async exec(e,l,n,I=[]){let r=n?.silent??!1,a=n?.silentDebugLogging??!0;try{let s=(n?.isDirectAgentCommand?"Copilot: ":"")+(l?`${e} ${l.join(" ")}`:e);this.logger.startGroup(s,r?8:void 0);let o=await this._exec(e,l,n,I);if(o.error)throw o.error;return o.stdout&&(r?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(r?8:void 0)}}async execReturn(e,l,n,I=[]){let r=n?.silent??!1,a=n?.silentDebugLogging??!0;try{let s=(n?.isDirectAgentCommand?"Copilot: ":"")+(l?`${e} ${l.join(" ")}`:e);this.logger.startGroup(s,r?8:void 0);let o=await this._exec(e,l,n,I);if(o.error)throw o.error;return o.stdout&&(r?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(r?8:void 0)}}_exec(e,l,n,I=[]){n||(n={}),n.timeout||(n.timeout=9e5),l||(l=[]);let r={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?bbt(e,r):n.shell?bbt(`${e} ${(0,pbt.default)(l)}`,r):Swl(e,l,r),d="",u="";o.stdout?.on("data",G=>{d+=G}),o.stderr?.on("data",G=>{u+=G}),o.on("close",(G,p)=>{if(G!==0&&!n?.ignoreReturnCode){let h=this.filterCommand(e,l,I),W=new Error(`Command failed with exit code ${G}: ${h}`);W.cmd=h,W.code=G,W.stdout=d,W.stderr=u,W.signal=p,s(W)}else a({error:null,stdout:d,stderr:u,exitCode:G})}),o.on("error",G=>{G.stdout=d,G.stderr=u,G.cmd=this.filterCommand(e,l,I),s(G)}),n.input&&(o.stdin?.write(n.input),o.stdin?.end())})}filterCommand(e,l=[],n){let I=l.reduce((r,a)=>(n.includes(a)?r.push("REDACTED"):r.push(a),r),[]);return`${e} ${I.join(" ")}`}};c();import{randomUUID as Owl}from"crypto";import{cpSync as Twl,existsSync as Cbt,mkdtempSync as Uwl,rmSync as Mwl}from"fs";import{homedir as vbt,tmpdir as _wl}from"os";import{join as x$}from"path";c();var m3=class t extends Error{cmd;killed;code;signal;stdout="";stderr="";errorType;skipReport;constructor(e,l,n=!1){if(!l){let I=e.code,r=e.message;"stdout"in e&&"stderr"in e&&(r+=`
764
+ `)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=HZl.exec(t))l.meta=!0,l.shift=/^[A-Z]$/.test(e[1]);else if(e=XZl.exec(t)){let n=[...t];n[0]==="\x1B"&&n[1]==="\x1B"&&(l.option=!0);let I=[e[1],e[2],e[4],e[6]].filter(Boolean).join(""),r=(e[3]||e[5]||1)-1;l.ctrl=!!(r&4),l.meta=!!(r&10),l.shift=!!(r&1),l.code=I,l.name=Wst[I],l.shift=kZl(I)||l.shift,l.ctrl=LZl(I)||l.ctrl}return l},Est=JZl;c();var Rst=st(sl(),1);var BZl=()=>(0,Rst.useContext)(rbe),XU=BZl;var xZl=(t,e={})=>{let{stdin:l,setRawMode:n,internal_exitOnCtrlC:I,internal_eventEmitter:r}=XU();(0,Nfe.useEffect)(()=>{if(e.isActive!==!1)return n(!0),()=>{n(!1)}},[e.isActive,n]),(0,Nfe.useEffect)(()=>{if(e.isActive===!1)return;let a=s=>{let o=Est(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;yst.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)||!I)&&jw.batchedUpdates(()=>{t(u,d)})};return r?.on("input",a),()=>{r?.removeListener("input",a)}},[e.isActive,l,I,t])},JY=xZl;c();var SZl=st(sl(),1);c();var Yst=st(sl(),1);var OZl=()=>(0,Yst.useContext)(abe),HN=OZl;c();var TZl=st(sl(),1);c();var Wfe=st(sl(),1);c();var UZl=st(sl(),1);c();var Vst=st(sl(),1);var MZl=()=>{let{isScreenReaderEnabled:t}=(0,Vst.useContext)(Kw);return t},MJ=MZl;c();var _Zl=t=>({width:t.yogaNode?.getComputedWidth()??0,height:t.yogaNode?.getComputedHeight()??0}),ube=_Zl;var qlt=st(sl(),1);import{join as UGl}from"path";import{text as NKn}from"stream/consumers";c();c();var fbt=st(wM(),1);c();c();c();c();var _b=[];for(let t=0;t<256;++t)_b.push((t+256).toString(16).slice(1));function rbt(t,e=0){return(_b[t[e+0]]+_b[t[e+1]]+_b[t[e+2]]+_b[t[e+3]]+"-"+_b[t[e+4]]+_b[t[e+5]]+"-"+_b[t[e+6]]+_b[t[e+7]]+"-"+_b[t[e+8]]+_b[t[e+9]]+"-"+_b[t[e+10]]+_b[t[e+11]]+_b[t[e+12]]+_b[t[e+13]]+_b[t[e+14]]+_b[t[e+15]]).toLowerCase()}c();import{randomFillSync as Hwl}from"node:crypto";var mhe=new Uint8Array(256),uhe=mhe.length;function j5e(){return uhe>mhe.length-16&&(Hwl(mhe),uhe=0),mhe.slice(uhe,uhe+=16)}c();c();import{randomUUID as Xwl}from"node:crypto";var K5e={randomUUID:Xwl};function kwl(t,e,l){t=t||{};let n=t.random??t.rng?.()??j5e();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 I=0;I<16;++I)e[l+I]=n[I];return e}return rbt(n)}function Lwl(t,e,l){return K5e.randomUUID&&!e&&!t?K5e.randomUUID():kwl(t,e,l)}var Ly=Lwl;var vM=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}setGithubIssueNumber(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{issue:{number: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??Ly()}}),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 Ghe=["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"],abt=["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",...Ghe];async function sbt(){let t=new vM;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");let e=process.env.COPILOT_AGENT_ISSUE_NUMBER?parseInt(process.env.COPILOT_AGENT_ISSUE_NUMBER,10):void 0;isNaN(e)||t.setGithubIssueNumber(e),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 l=process.env.COPILOT_AGENT_ACTION;if(l&&["fix","fix-pr-comment"].includes(l)&&t.setProblemAction(l),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[a,s]=r.split(":");t.setExperiment(a,s)}),process.env.COPILOT_AGENT_ERROR_CODES_TO_RETRY){let r=process.env.COPILOT_AGENT_ERROR_CODES_TO_RETRY.split(",").map(a=>parseInt(a.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 n=process.env.COPILOT_AGENT_TIMEOUT_MIN?parseInt(process.env.COPILOT_AGENT_TIMEOUT_MIN,10):void 0;n!==void 0&&!Number.isNaN(n)&&t.setTimeoutMs(n*60*1e3);let I=process.env.COPILOT_AGENT_START_TIME_SEC?parseInt(process.env.COPILOT_AGENT_START_TIME_SEC,10):void 0;return I!==void 0&&!Number.isNaN(I)&&t.setStartTimeMs(I*1e3),t.build()}c();c();var pbt=st(ibt(),1);import{exec as bbt,execFile as Swl}from"child_process";c();c();c();var X$=null;function fM(){return!!X$}function q5e(){if(!X$)throw new Error("Settings have not been initialized");return X$}function cbt(t){return X$=t,t}function k$(){X$=null}c();function So(t,e){return t?.featureFlags?.[e]??!1}function dbt(t,e){return t?.experiments?.[e]}function $5e(t){return Object.keys(t.featureFlags??{}).filter(e=>t.featureFlags?.[e]).join(",")}var Bwl=["token","secret","key","hmacKey","modelBasedRetrievalToken","metisApiKey"];function e4e(t,e=[]){for(let[l,n]of Object.entries(t))if(n!==null)switch(typeof n){case"object":e4e(n,e);break;case"undefined":break;default:if(Bwl.includes(l)){let I=n.toString().trim();I!=""&&e.push(I)}break}return e}function ubt(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 mbt from"process";function t4e(t){let e=mbt.env[t];if(e&&e.trim()!=="")return e}var xwl=[/\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],Gbt="******",$Y=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,I=this.getSecretValues();for(let r of I)n=n.replaceAll(r,Gbt);for(let r of xwl)n=n.replaceAll(r,Gbt);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,I]of Object.entries(e))l[n]=this.filterSecretsFromObj(I);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 Ghe){let I=t4e(n);I&&l4e(l,I)}if(e.secretEnvVars=!0,this.runner){for(let n of this.runner.sensitiveKeys){let I=t4e(n);I&&l4e(l,I)}e.runner=!0}if(fM()){let n=e4e(q5e());for(let I of n)l4e(l,I);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 l4e(t,e){t.add(e),t.add(Buffer.from(e,"utf8").toString("base64"))}function bhe(...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 $H=class{logLevel;debugEnvironmentVariables;secretFilter=$Y.getInstance();constructor(e,l){e===void 0?bhe(...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 bhe(...this.debugEnvironmentVariables??[])}};var MN=class{logger;constructor(e){this.logger=e}async exec(e,l,n,I=[]){let r=n?.silent??!1,a=n?.silentDebugLogging??!0;try{let s=(n?.isDirectAgentCommand?"Copilot: ":"")+(l?`${e} ${l.join(" ")}`:e);this.logger.startGroup(s,r?8:void 0);let o=await this._exec(e,l,n,I);if(o.error)throw o.error;return o.stdout&&(r?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(r?8:void 0)}}async execReturn(e,l,n,I=[]){let r=n?.silent??!1,a=n?.silentDebugLogging??!0;try{let s=(n?.isDirectAgentCommand?"Copilot: ":"")+(l?`${e} ${l.join(" ")}`:e);this.logger.startGroup(s,r?8:void 0);let o=await this._exec(e,l,n,I);if(o.error)throw o.error;return o.stdout&&(r?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(r?8:void 0)}}_exec(e,l,n,I=[]){n||(n={}),n.timeout||(n.timeout=9e5),l||(l=[]);let r={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?bbt(e,r):n.shell?bbt(`${e} ${(0,pbt.default)(l)}`,r):Swl(e,l,r),d="",u="";o.stdout?.on("data",G=>{d+=G}),o.stderr?.on("data",G=>{u+=G}),o.on("close",(G,p)=>{if(G!==0&&!n?.ignoreReturnCode){let h=this.filterCommand(e,l,I),W=new Error(`Command failed with exit code ${G}: ${h}`);W.cmd=h,W.code=G,W.stdout=d,W.stderr=u,W.signal=p,s(W)}else a({error:null,stdout:d,stderr:u,exitCode:G})}),o.on("error",G=>{G.stdout=d,G.stderr=u,G.cmd=this.filterCommand(e,l,I),s(G)}),n.input&&(o.stdin?.write(n.input),o.stdin?.end())})}filterCommand(e,l=[],n){let I=l.reduce((r,a)=>(n.includes(a)?r.push("REDACTED"):r.push(a),r),[]);return`${e} ${I.join(" ")}`}};c();import{randomUUID as Owl}from"crypto";import{cpSync as Twl,existsSync as Cbt,mkdtempSync as Uwl,rmSync as Mwl}from"fs";import{homedir as vbt,tmpdir as _wl}from"os";import{join as x$}from"path";c();var m3=class t extends Error{cmd;killed;code;signal;stdout="";stderr="";errorType;skipReport;constructor(e,l,n=!1){if(!l){let I=e.code,r=e.message;"stdout"in e&&"stderr"in e&&(r+=`
765
765
  `+e.stderr?.trim()+`
766
766
  `+e.stdout?.trim()),r.includes("GH013: Repository rule violations found")||r.includes("unknown revision or path not in the working tree")?(l="protection rule",n=!0):r.includes("You may want to try Git Large File Storage")||r.includes("GH001: Large files detected")?(l="LFS",n=!0):I===1&&(r.includes("hook failed")||r.includes("husky -")||r.includes("hook declined")||r.includes("hook exited")||r.includes("vite ")||r.includes("eslint "))?(l="hook",n=!0):r.includes("use 'git pull' before pushing again")?(l="pull first",n=!0):r.includes("fetch first")?(l="fetch first",n=!0):r.includes("The requested URL returned error: 403")?(l="access denied",n=!1):r.includes("unexpected disconnect")?(l="disconnect",n=!1):(l="unknown",n=!(I==="ENOENT"||I===127||I===128||r.includes("fatal: ")))}super(`${l} git error: ${e.message}`);for(let I of Object.keys(e))this[I]=e[I];this.errorType=l??"unknown",this.skipReport=n,this.cause=e,Object.setPrototypeOf(this,t.prototype),this.name="GitError"}};c();var L$="https://api.githubcopilot.com";function hbt(t){if(!t.github?.user?.name)throw new Error("GitHub user name is required");return t.github.user.name}function Abt(t){if(!t.github?.user?.email)throw new Error("GitHub user email is required");return t.github.user.email}function Zbt(t){let e=t.github?.user?.actorLogin,l=t.github?.user?.actorId;if(!(!e||!l))return{login:e,id:l}}function gbt(t){if(!t.github?.serverUrl)throw new Error("GitHub server URL is required");return t.github.serverUrl}function Nbt(t){if(!t.github?.host)throw new Error("GitHub host is required");return t.github.host}function Wbt(t){if(!t.github?.hostProtocol)throw new Error("GitHub host protocol is required");return t.github.hostProtocol}function G3(t){if(!t.github?.token)throw new Error("GitHub token is required");return t.github.token}function phe(t){if(!t.github?.repo?.name)throw new Error("GitHub repository name is required");return t.github.repo.name}function b3(t){if(!t.service?.instance?.id)throw new Error("Instance ID is required");return t.service.instance.id}function ybt(t){if(!t.service?.callback?.url)throw new Error("Callback URL is required");return t.service.callback.url}function Ebt(t){if(!t.api?.anthropic?.key)throw new Error("Anthropic API key is required");return t.api.anthropic.key}function Rbt(t){if(!t.api?.openai?.apiKey)throw new Error("OpenAI API key is required");return t.api.openai.apiKey}function Ybt(t){if(!t.api?.openai?.azure?.url)throw new Error("Azure OpenAI deployment URL is required");return t.api.openai.azure.url}function Vbt(t,e=L$){let l=t.api?.copilot?.url||e;if(!l)throw new Error("Copilot URL is required");return l}function J$(t){if(!t.api?.copilot?.integrationId)throw new Error("Copilot integration ID is required");return t.api.copilot.integrationId}function B$(t){if(!t.api?.copilot?.token)throw new Error("Copilot token is required");return t.api.copilot.token}function Qbt(t){if(!t.github?.uploadsUrl)throw new Error("GitHub uploads URL is required");return t.github.uploadsUrl}function wbt(t){if(!t.github?.downloadsUrl)throw new Error("GitHub downloads URL is required");return t.github.downloadsUrl}c();function Fbt(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`
767
767
  `;case"r":return"\r";case"t":return" ";case"v":return"\v";case"\\":return"\\";case'"':return'"';default:return String.fromCharCode(parseInt(l,8))}})):t}var n4e='!f() { test "$1" = get && echo "password=$GITHUB_TOKEN"; }; f',PZ=class{constructor(e,l){this.logger=e;this.exec=l}resolveGitUrl(e,l){let n=null,I="";try{I=gbt(e),n=new URL(I)}catch(r){this.logger.warning(`Failed to parse GITHUB_SERVER_URL "${I}". Falling back to GITHUB_HOST and GITHUB_GIT_HOST_PROTOCOL. Error: ${r.message??r}`);let a=Wbt(e),s=Nbt(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,I,r,a){process.env.GITHUB_TOKEN=process.env.GITHUB_TOKEN??G3(e);let o=this.resolveGitUrl(e,l).href;if(r=r??1,r+=1,r<2&&(r=2),Cbt(x$(n,".git"))){let E={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,E,!1),await this.execGit(["remote","set-url","origin",o],E,[o]),(await this.execGit(["rev-parse","--abbrev-ref","HEAD"],E)).stdout.toString().trim()===I){this.logger.debug(`Already on branch ${I} in repo ${l}`);return}if((await this.execGit(["branch","--list",I],E,[I])).stdout.toString().trim().length>0){this.logger.debug(`Local branch ${I} already exists in repo ${l}`),this.logger.debug(`Checking out branch ${I}`),await this.execGit(["checkout",I],E,[I]);return}if(await this.hasRemoteBranch(I,n)){this.logger.debug(`Remote branch ${I} exists in repo ${l}`);let{stdout:C}=await this.execGit(["rev-parse","--is-shallow-repository"],E);C.trim()==="true"?await this.execGit(["fetch","--unshallow","--update-head-ok","origin","+refs/heads/*:refs/heads/*"],E):await this.execGit(["fetch","origin"],E),this.logger.debug(`Pulling branch ${I} with depth ${r}`),await this.execGit(["pull","--depth",r.toString(),"origin",I],E,[r.toString(),I]),this.logger.debug(`Checking out branch ${I}`),await this.execGit(["checkout",I],E,[I]);return}if(a){this.logger.debug(`Base commit ${a} provided for branch ${I} in repo ${l}`),this.logger.debug(`Checking out branch ${I}`),await this.execGit(["checkout","-b",I,a],E,[I,a]);return}throw new Error(`Branch ${I} 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||vbt(),G=Uwl(x$(_wl(),`cpd-${Owl()}`));Cbt(x$(u,".gitconfig"))&&Twl(x$(u,".gitconfig"),x$(G,".gitconfig"));let p={...process.env,HOME:G},h={silent:!0,env:p},W={cwd:n,silent:!0,env:p};await this.setGitConfig(e,h,!0);try{this.logger.debug(`Cloning repo ${l} to ${n} with branch ${I} and depth ${r}`),await this.execGit(["clone","-b",I,"--single-branch","--depth",r.toString(),o,n],h,[o,n,I,r.toString()])}catch(E){if(this.logger.debug(`Error cloning repo ${l} to ${n}: ${E}`),a)this.logger.debug(`Base commit ${a} provided. Checking out branch ${I}`),await this.execGit(["clone",o,n],h,[o,n]),await this.execGit(["checkout","-b",I,a],W,[I,a]);else throw new Error(`Branch ${I} does not exist in repo ${l} and no base commit was provided.`)}finally{await this.cleanGitConfig(h,!0,!0)}await this.setGitConfig(e,W,!1)}async commitChanges(e,l,n,I,r=!1,a=!1){process.env.HOME||(process.env.HOME=vbt());let s={cwd:n,silent:!0},o=Zbt(e);if(o){let G=`Co-authored-by: ${o.login} <${o.id}+${o.login}@users.noreply.github.com>`;I=I.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.341-7",
4
+ "version": "0.0.341-8",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -33,7 +33,7 @@
33
33
  "sdk/**/*"
34
34
  ],
35
35
  "buildMetadata": {
36
- "gitCommit": "d75ad94"
36
+ "gitCommit": "e87621a"
37
37
  },
38
38
  "dependencies": {
39
39
  "node-pty": "npm:@devm33/node-pty@^1.0.8",
package/sdk/index.d.ts CHANGED
@@ -709,15 +709,15 @@ declare const SessionEventSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
709
709
  startTime: z.ZodString;
710
710
  selectedModel: z.ZodOptional<z.ZodString>;
711
711
  }, "strip", z.ZodTypeAny, {
712
- sessionId: string;
713
712
  version: number;
713
+ sessionId: string;
714
714
  producer: string;
715
715
  copilotVersion: string;
716
716
  startTime: string;
717
717
  selectedModel?: string | undefined;
718
718
  }, {
719
- sessionId: string;
720
719
  version: number;
720
+ sessionId: string;
721
721
  producer: string;
722
722
  copilotVersion: string;
723
723
  startTime: string;
@@ -725,8 +725,8 @@ declare const SessionEventSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
725
725
  }>;
726
726
  }, "strip", z.ZodTypeAny, {
727
727
  data: {
728
- sessionId: string;
729
728
  version: number;
729
+ sessionId: string;
730
730
  producer: string;
731
731
  copilotVersion: string;
732
732
  startTime: string;
@@ -739,8 +739,8 @@ declare const SessionEventSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
739
739
  ephemeral?: boolean | undefined;
740
740
  }, {
741
741
  data: {
742
- sessionId: string;
743
742
  version: number;
743
+ sessionId: string;
744
744
  producer: string;
745
745
  copilotVersion: string;
746
746
  startTime: string;