@github/copilot 0.0.337-11 → 0.0.337-12
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 +1 -1
- package/package.json +2 -2
- package/sdk/index.js +1 -1
- package/sdk/index.js.map +1 -1
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(FJ){I&&this.options.stdout.write(n),this.lastOutput=e,this.lastOutputHeight=l;return}if(this.isScreenReaderEnabled){if(I){let s=this.lastOutputHeight>0?Hb.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=YH(e,r,{trim:!1,hard:!0});if(I)this.options.stdout.write(a);else{let s=this.lastOutputHeight>0?Hb.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(Hb.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=Uve.default.createElement(Tw.Provider,{value:{isScreenReaderEnabled:this.isScreenReaderEnabled}},Uve.default.createElement(w7,{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));Ow.updateContainerSync(l,this.container,null,Xat),Ow.flushSyncWork()}writeToStdout(e){if(!this.isUnmounted){if(this.options.debug){this.options.stdout.write(e+this.fullStaticOutput+this.lastOutput);return}if(FJ){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(FJ){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(),FJ?this.options.stdout.write(this.lastOutput+`
|
|
763
763
|
`):this.options.debug||this.log.done(),this.isUnmounted=!0,Ow.updateContainerSync(null,this.container,null,Xat),Ow.flushSyncWork(),WU.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(){!FJ&&!this.options.debug&&this.log.clear()}patchConsole(){this.options.debug||(this.restoreConsole=eGe((e,l)=>{e==="stdout"&&this.writeToStdout(l),e==="stderr"&&(l.startsWith("The above error occurred")||this.writeToStderr(l))}))}};var qhl=(t,e)=>{let l={stdout:LGe.stdout,stdin:LGe.stdin,stderr:LGe.stderr,debug:!1,exitOnCtrlC:!0,patchConsole:!0,maxFps:30,...$hl(e)},n=eAl(l.stdout,()=>new F7(l));return n.render(t),{rerender:n.render,unmount(){n.unmount()},waitUntilExit:n.waitUntilExit,cleanup:()=>WU.delete(l.stdout),clear:n.clear}},C7=qhl,$hl=(t={})=>t instanceof Khl?{stdout:t,stdin:LGe.stdin}:t,eAl=(t,e)=>{let l=WU.get(t);return l||(l=e(),WU.set(t,l)),l};c();var Mw=dt(bl(),1);function JGe(t){let{items:e,children:l,style:n}=t,[I,r]=(0,Mw.useState)(0),a=(0,Mw.useMemo)(()=>e.slice(I),[e,I]);(0,Mw.useLayoutEffect)(()=>{r(e.length)},[e.length]);let s=a.map((d,u)=>l(d,I+u)),o=(0,Mw.useMemo)(()=>({position:"absolute",flexDirection:"column",...n}),[n]);return Mw.default.createElement("ink-box",{internal_static:!0,style:o},s)}c();var Jat=dt(bl(),1);c();var tAl=dt(bl(),1);c();var lAl=dt(bl(),1);c();var Mve=dt(bl(),1);c();import{Buffer as nAl}from"node:buffer";var IAl=/^(?:\x1b)([a-zA-Z0-9])$/,rAl=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,Bat={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"},xat=[...Object.values(Bat),"backspace"],aAl=t=>["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(t),sAl=t=>["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(t),oAl=(t="")=>{let e;nAl.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=IAl.exec(t))l.meta=!0,l.shift=/^[A-Z]$/.test(e[1]);else if(e=rAl.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=Bat[I],l.shift=aAl(I)||l.shift,l.ctrl=sAl(I)||l.ctrl}return l},Sat=oAl;c();var Oat=dt(bl(),1);var iAl=()=>(0,Oat.useContext)(vGe),yU=iAl;var cAl=(t,e={})=>{let{stdin:l,setRawMode:n,internal_exitOnCtrlC:I,internal_eventEmitter:r}=yU();(0,Mve.useEffect)(()=>{if(e.isActive!==!1)return n(!0),()=>{n(!1)}},[e.isActive,n]),(0,Mve.useEffect)(()=>{if(e.isActive===!1)return;let a=s=>{let o=Sat(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;xat.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)&&Ow.batchedUpdates(()=>{t(u,d)})};return r?.on("input",a),()=>{r?.removeListener("input",a)}},[e.isActive,l,I,t])},EY=cAl;c();var dAl=dt(bl(),1);c();var Tat=dt(bl(),1);var uAl=()=>(0,Tat.useContext)(fGe),WN=uAl;c();var mAl=dt(bl(),1);c();var _ve=dt(bl(),1);c();var GAl=dt(bl(),1);c();var Uat=dt(bl(),1);var bAl=()=>{let{isScreenReaderEnabled:t}=(0,Uat.useContext)(Tw);return t},XJ=bAl;c();import{homedir as FPn}from"os";var hlt=dt(bl(),1);import{join as VFe}from"path";import{text as CPn}from"stream/consumers";c();c();var jGt=dt(hM(),1);c();c();c();c();var Bb=[];for(let t=0;t<256;++t)Bb.push((t+256).toString(16).slice(1));function WGt(t,e=0){return(Bb[t[e+0]]+Bb[t[e+1]]+Bb[t[e+2]]+Bb[t[e+3]]+"-"+Bb[t[e+4]]+Bb[t[e+5]]+"-"+Bb[t[e+6]]+Bb[t[e+7]]+"-"+Bb[t[e+8]]+Bb[t[e+9]]+"-"+Bb[t[e+10]]+Bb[t[e+11]]+Bb[t[e+12]]+Bb[t[e+13]]+Bb[t[e+14]]+Bb[t[e+15]]).toLowerCase()}c();import{randomFillSync as IQl}from"crypto";var Bpe=new Uint8Array(256),Jpe=Bpe.length;function g5e(){return Jpe>Bpe.length-16&&(IQl(Bpe),Jpe=0),Bpe.slice(Jpe,Jpe+=16)}c();c();import{randomUUID as rQl}from"crypto";var N5e={randomUUID:rQl};function aQl(t,e,l){if(N5e.randomUUID&&!e&&!t)return N5e.randomUUID();t=t||{};let n=t.random??t.rng?.()??g5e();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 WGt(n)}var Ey=aQl;var gM=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}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??Ey()}}),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 xpe=["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"],yGt=["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",...xpe];async function EGt(){let t=new gM;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);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 fGt=dt(YGt(),1);import{exec as vGt,execFile as cQl}from"child_process";c();c();c();var Z$=null;function NM(){return!!Z$}function W5e(){if(!Z$)throw new Error("Settings have not been initialized");return Z$}function VGt(t){return Z$=t,t}function g$(){Z$=null}c();function Ii(t,e){return t?.featureFlags?.[e]??!1}function QGt(t,e){return t?.experiments?.[e]}function y5e(t){return Object.keys(t.featureFlags??{}).filter(e=>t.featureFlags?.[e]).join(",")}var oQl=["token","secret","key","hmacKey","modelBasedRetrievalToken","metisApiKey"];function E5e(t,e=[]){for(let[l,n]of Object.entries(t))if(n!==null)switch(typeof n){case"object":E5e(n,e);break;case"undefined":break;default:if(oQl.includes(l)){let I=n.toString().trim();I!=""&&e.push(I)}break}return e}function wGt(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 FGt from"process";function R5e(t){let e=FGt.env[t];if(e&&e.trim()!=="")return e}var iQl=[/\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],CGt="******",BY=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,CGt);for(let r of iQl)n=n.replaceAll(r,CGt);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 xpe){let I=R5e(n);I&&Y5e(l,I)}if(e.secretEnvVars=!0,this.runner){for(let n of this.runner.sensitiveKeys){let I=R5e(n);I&&Y5e(l,I)}e.runner=!0}if(NM()){let n=E5e(W5e());for(let I of n)Y5e(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 Y5e(t,e){t.add(e),t.add(Buffer.from(e,"utf8").toString("base64"))}function Spe(...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 UH=class{logLevel;debugEnvironmentVariables;secretFilter=BY.getInstance();constructor(e,l){e===void 0?Spe(...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 Spe(...this.debugEnvironmentVariables??[])}};var K0=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};return new Promise((a,s)=>{let o=n.shell&&l?.length===0?vGt(e,r):n.shell?vGt(`${e} ${(0,fGt.default)(l)}`,r):cQl(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 dQl}from"crypto";import{cpSync as uQl,existsSync as zGt,mkdtempSync as mQl,rmSync as GQl}from"fs";import{homedir as PGt,tmpdir as bQl}from"os";import{join as y$}from"path";c();var n3=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=IAl.exec(t))l.meta=!0,l.shift=/^[A-Z]$/.test(e[1]);else if(e=rAl.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=Bat[I],l.shift=aAl(I)||l.shift,l.ctrl=sAl(I)||l.ctrl}return l},Sat=oAl;c();var Oat=dt(bl(),1);var iAl=()=>(0,Oat.useContext)(vGe),yU=iAl;var cAl=(t,e={})=>{let{stdin:l,setRawMode:n,internal_exitOnCtrlC:I,internal_eventEmitter:r}=yU();(0,Mve.useEffect)(()=>{if(e.isActive!==!1)return n(!0),()=>{n(!1)}},[e.isActive,n]),(0,Mve.useEffect)(()=>{if(e.isActive===!1)return;let a=s=>{let o=Sat(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;xat.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)&&Ow.batchedUpdates(()=>{t(u,d)})};return r?.on("input",a),()=>{r?.removeListener("input",a)}},[e.isActive,l,I,t])},EY=cAl;c();var dAl=dt(bl(),1);c();var Tat=dt(bl(),1);var uAl=()=>(0,Tat.useContext)(fGe),WN=uAl;c();var mAl=dt(bl(),1);c();var _ve=dt(bl(),1);c();var GAl=dt(bl(),1);c();var Uat=dt(bl(),1);var bAl=()=>{let{isScreenReaderEnabled:t}=(0,Uat.useContext)(Tw);return t},XJ=bAl;c();import{homedir as FPn}from"os";var hlt=dt(bl(),1);import{join as VFe}from"path";import{text as CPn}from"stream/consumers";c();c();var jGt=dt(hM(),1);c();c();c();c();var Bb=[];for(let t=0;t<256;++t)Bb.push((t+256).toString(16).slice(1));function WGt(t,e=0){return(Bb[t[e+0]]+Bb[t[e+1]]+Bb[t[e+2]]+Bb[t[e+3]]+"-"+Bb[t[e+4]]+Bb[t[e+5]]+"-"+Bb[t[e+6]]+Bb[t[e+7]]+"-"+Bb[t[e+8]]+Bb[t[e+9]]+"-"+Bb[t[e+10]]+Bb[t[e+11]]+Bb[t[e+12]]+Bb[t[e+13]]+Bb[t[e+14]]+Bb[t[e+15]]).toLowerCase()}c();import{randomFillSync as IQl}from"crypto";var Bpe=new Uint8Array(256),Jpe=Bpe.length;function g5e(){return Jpe>Bpe.length-16&&(IQl(Bpe),Jpe=0),Bpe.slice(Jpe,Jpe+=16)}c();c();import{randomUUID as rQl}from"crypto";var N5e={randomUUID:rQl};function aQl(t,e,l){if(N5e.randomUUID&&!e&&!t)return N5e.randomUUID();t=t||{};let n=t.random??t.rng?.()??g5e();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 WGt(n)}var Ey=aQl;var gM=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??Ey()}}),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 xpe=["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"],yGt=["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",...xpe];async function EGt(){let t=new gM;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 fGt=dt(YGt(),1);import{exec as vGt,execFile as cQl}from"child_process";c();c();c();var Z$=null;function NM(){return!!Z$}function W5e(){if(!Z$)throw new Error("Settings have not been initialized");return Z$}function VGt(t){return Z$=t,t}function g$(){Z$=null}c();function Ii(t,e){return t?.featureFlags?.[e]??!1}function QGt(t,e){return t?.experiments?.[e]}function y5e(t){return Object.keys(t.featureFlags??{}).filter(e=>t.featureFlags?.[e]).join(",")}var oQl=["token","secret","key","hmacKey","modelBasedRetrievalToken","metisApiKey"];function E5e(t,e=[]){for(let[l,n]of Object.entries(t))if(n!==null)switch(typeof n){case"object":E5e(n,e);break;case"undefined":break;default:if(oQl.includes(l)){let I=n.toString().trim();I!=""&&e.push(I)}break}return e}function wGt(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 FGt from"process";function R5e(t){let e=FGt.env[t];if(e&&e.trim()!=="")return e}var iQl=[/\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],CGt="******",BY=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,CGt);for(let r of iQl)n=n.replaceAll(r,CGt);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 xpe){let I=R5e(n);I&&Y5e(l,I)}if(e.secretEnvVars=!0,this.runner){for(let n of this.runner.sensitiveKeys){let I=R5e(n);I&&Y5e(l,I)}e.runner=!0}if(NM()){let n=E5e(W5e());for(let I of n)Y5e(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 Y5e(t,e){t.add(e),t.add(Buffer.from(e,"utf8").toString("base64"))}function Spe(...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 UH=class{logLevel;debugEnvironmentVariables;secretFilter=BY.getInstance();constructor(e,l){e===void 0?Spe(...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 Spe(...this.debugEnvironmentVariables??[])}};var K0=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};return new Promise((a,s)=>{let o=n.shell&&l?.length===0?vGt(e,r):n.shell?vGt(`${e} ${(0,fGt.default)(l)}`,r):cQl(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 dQl}from"crypto";import{cpSync as uQl,existsSync as zGt,mkdtempSync as mQl,rmSync as GQl}from"fs";import{homedir as PGt,tmpdir as bQl}from"os";import{join as y$}from"path";c();var n3=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 V5e="https://api.githubcopilot.com";function HGt(t){if(!t.github?.user?.name)throw new Error("GitHub user name is required");return t.github.user.name}function XGt(t){if(!t.github?.user?.email)throw new Error("GitHub user email is required");return t.github.user.email}function kGt(t){let e=t.github?.user?.actorLogin,l=t.github?.user?.actorId;if(!(!e||!l))return{login:e,id:l}}function LGt(t){if(!t.github?.serverUrl)throw new Error("GitHub server URL is required");return t.github.serverUrl}function JGt(t){if(!t.github?.host)throw new Error("GitHub host is required");return t.github.host}function BGt(t){if(!t.github?.hostProtocol)throw new Error("GitHub host protocol is required");return t.github.hostProtocol}function I3(t){if(!t.github?.token)throw new Error("GitHub token is required");return t.github.token}function Ope(t){if(!t.github?.repo?.name)throw new Error("GitHub repository name is required");return t.github.repo.name}function r3(t){if(!t.service?.instance?.id)throw new Error("Instance ID is required");return t.service.instance.id}function xGt(t){if(!t.service?.callback?.url)throw new Error("Callback URL is required");return t.service.callback.url}function SGt(t){if(!t.api?.anthropic?.key)throw new Error("Anthropic API key is required");return t.api.anthropic.key}function OGt(t){if(!t.api?.openai?.apiKey)throw new Error("OpenAI API key is required");return t.api.openai.apiKey}function TGt(t){if(!t.api?.openai?.azure?.url)throw new Error("Azure OpenAI deployment URL is required");return t.api.openai.azure.url}function UGt(t,e=V5e){let l=t.api?.copilot?.url||e;if(!l)throw new Error("Copilot URL is required");return l}function N$(t){if(!t.api?.copilot?.integrationId)throw new Error("Copilot integration ID is required");return t.api.copilot.integrationId}function W$(t){if(!t.api?.copilot?.token)throw new Error("Copilot token is required");return t.api.copilot.token}function MGt(t){if(!t.github?.uploadsUrl)throw new Error("GitHub uploads URL is required");return t.github.uploadsUrl}function _Gt(t){if(!t.github?.downloadsUrl)throw new Error("GitHub downloads URL is required");return t.github.downloadsUrl}c();function DGt(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 Q5e='!f() { test "$1" = get && echo "password=$GITHUB_TOKEN"; }; f',BZ=class{constructor(e,l){this.logger=e;this.exec=l}resolveGitUrl(e,l){let n=null,I="";try{I=LGt(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=BGt(e),s=JGt(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??I3(e);let o=this.resolveGitUrl(e,l).href;if(r=r??1,r+=1,r<2&&(r=2),zGt(y$(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||PGt(),G=mQl(y$(bQl(),`cpd-${dQl()}`));zGt(y$(u,".gitconfig"))&&uQl(y$(u,".gitconfig"),y$(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=PGt());let s={cwd:n,silent:!0},o=kGt(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.337-
|
|
4
|
+
"version": "0.0.337-12",
|
|
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": "
|
|
36
|
+
"gitCommit": "ec29c2a"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"node-pty": "npm:@devm33/node-pty@^1.0.8",
|