@github/copilot 0.0.349-2 → 0.0.349-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -2
- package/package.json +2 -2
- package/sdk/index.js +2 -2
- package/sdk/index.js.map +2 -2
package/index.js
CHANGED
|
@@ -801,7 +801,7 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr
|
|
|
801
801
|
`;if(this.options.debug){r&&(this.fullStaticOutput+=n),this.options.stdout.write(this.fullStaticOutput+e);return}if(A3){r&&this.options.stdout.write(n),this.lastOutput=e,this.lastOutputHeight=l;return}if(this.isScreenReaderEnabled){if(r){let s=this.lastOutputHeight>0?KG.eraseLines(this.lastOutputHeight):"";this.options.stdout.write(s+n),this.lastOutputHeight=0}if(e===this.lastOutput&&!r)return;let I=this.options.stdout.columns||80,a=iX(e,I,{trim:!1,hard:!0});if(r)this.options.stdout.write(a);else{let s=this.lastOutputHeight>0?KG.eraseLines(this.lastOutputHeight):"";this.options.stdout.write(s+a)}this.lastOutput=e,this.lastOutputHeight=a===""?0:a.split(`
|
|
802
802
|
`).length;return}if(r&&(this.fullStaticOutput+=n),this.lastOutputHeight>=this.options.stdout.rows){this.options.stdout.write(KG.clearTerminal+this.fullStaticOutput+e),this.lastOutput=e,this.lastOutputHeight=l,this.log.sync(e);return}r&&(this.log.clear(),this.options.stdout.write(n),this.log(e)),!r&&e!==this.lastOutput&&this.throttledLog(e),this.lastOutput=e,this.lastOutputHeight=l};render(e){let l=XXe.default.createElement(hF.Provider,{value:{isScreenReaderEnabled:this.isScreenReaderEnabled}},XXe.default.createElement(Iee,{stdin:this.options.stdin,stdout:this.options.stdout,stderr:this.options.stderr,writeToStdout:this.writeToStdout,writeToStderr:this.writeToStderr,exitOnCtrlC:this.options.exitOnCtrlC,onExit:this.unmount},e));pF.updateContainerSync(l,this.container,null,Rct),pF.flushSyncWork()}writeToStdout(e){if(!this.isUnmounted){if(this.options.debug){this.options.stdout.write(e+this.fullStaticOutput+this.lastOutput);return}if(A3){this.options.stdout.write(e);return}this.log.clear(),this.options.stdout.write(e),this.log(this.lastOutput)}}writeToStderr(e){if(!this.isUnmounted){if(this.options.debug){this.options.stderr.write(e),this.options.stdout.write(this.fullStaticOutput+this.lastOutput);return}if(A3){this.options.stderr.write(e);return}this.log.clear(),this.options.stderr.write(e),this.log(this.lastOutput)}}unmount(e){this.isUnmounted||(this.calculateLayout(),this.onRender(),this.unsubscribeExit(),typeof this.restoreConsole=="function"&&this.restoreConsole(),typeof this.unsubscribeResize=="function"&&this.unsubscribeResize(),A3?this.options.stdout.write(this.lastOutput+`
|
|
803
803
|
`):this.options.debug||this.log.done(),this.isUnmounted=!0,pF.updateContainerSync(null,this.container,null,Rct),pF.flushSyncWork(),vM.delete(this.options.stdout),e instanceof Error?this.rejectExitPromise(e):this.resolveExitPromise())}async waitUntilExit(){return this.exitPromise||=new Promise((e,l)=>{this.resolveExitPromise=e,this.rejectExitPromise=l}),this.exitPromise}clear(){!A3&&!this.options.debug&&this.log.clear()}patchConsole(){this.options.debug||(this.restoreConsole=Gpe((e,l)=>{e==="stdout"&&this.writeToStdout(l),e==="stderr"&&(l.startsWith("The above error occurred")||this.writeToStderr(l))}))}};var cRl=(t,e)=>{let l={stdout:qpe.stdout,stdin:qpe.stdin,stderr:qpe.stderr,debug:!1,exitOnCtrlC:!0,patchConsole:!0,maxFps:30,...dRl(e)},n=uRl(l.stdout,()=>new aee(l));return n.render(t),{rerender:n.render,unmount(){n.unmount()},waitUntilExit:n.waitUntilExit,cleanup:()=>vM.delete(l.stdout),clear:n.clear}},see=cRl,dRl=(t={})=>t instanceof iRl?{stdout:t,stdin:qpe.stdin}:t,uRl=(t,e)=>{let l=vM.get(t);return l||(l=e(),vM.set(t,l)),l};c();var ZF=nt(qt(),1);function $pe(t){let{items:e,children:l,style:n}=t,[r,I]=(0,ZF.useState)(0),a=(0,ZF.useMemo)(()=>e.slice(r),[e,r]);(0,ZF.useLayoutEffect)(()=>{I(e.length)},[e.length]);let s=a.map((d,u)=>l(d,r+u)),o=(0,ZF.useMemo)(()=>({position:"absolute",flexDirection:"column",...n}),[n]);return ZF.default.createElement("ink-box",{internal_static:!0,style:o},s)}c();var wct=nt(qt(),1);c();var mRl=nt(qt(),1);c();var bRl=nt(qt(),1);c();var kXe=nt(qt(),1);c();import{Buffer as GRl}from"node:buffer";var pRl=/^(?:\x1b)([a-zA-Z0-9])$/,hRl=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,Qct={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"},Fct=[...Object.values(Qct),"backspace"],ARl=t=>["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(t),ZRl=t=>["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(t),gRl=(t="")=>{let e;GRl.isBuffer(t)?t[0]>127&&t[1]===void 0?(t[0]-=128,t="\x1B"+String(t)):t=String(t):t!==void 0&&typeof t!="string"?t=String(t):t||(t="");let l={name:"",ctrl:!1,meta:!1,shift:!1,option:!1,sequence:t,raw:t};if(l.sequence=l.sequence||t||l.name,t==="\r")l.raw=void 0,l.name="return";else if(t===`
|
|
804
|
-
`)l.name="enter";else if(t===" ")l.name="tab";else if(t==="\b"||t==="\x1B\b")l.name="backspace",l.meta=t.charAt(0)==="\x1B";else if(t==="\x7F"||t==="\x1B\x7F")l.name="delete",l.meta=t.charAt(0)==="\x1B";else if(t==="\x1B"||t==="\x1B\x1B")l.name="escape",l.meta=t.length===2;else if(t===" "||t==="\x1B ")l.name="space",l.meta=t.length===2;else if(t.length===1&&t<="")l.name=String.fromCharCode(t.charCodeAt(0)+97-1),l.ctrl=!0;else if(t.length===1&&t>="0"&&t<="9")l.name="number";else if(t.length===1&&t>="a"&&t<="z")l.name=t;else if(t.length===1&&t>="A"&&t<="Z")l.name=t.toLowerCase(),l.shift=!0;else if(e=pRl.exec(t))l.meta=!0,l.shift=/^[A-Z]$/.test(e[1]);else if(e=hRl.exec(t)){let n=[...t];n[0]==="\x1B"&&n[1]==="\x1B"&&(l.option=!0);let r=[e[1],e[2],e[4],e[6]].filter(Boolean).join(""),I=(e[3]||e[5]||1)-1;l.ctrl=!!(I&4),l.meta=!!(I&10),l.shift=!!(I&1),l.code=r,l.name=Qct[r],l.shift=ARl(r)||l.shift,l.ctrl=ZRl(r)||l.ctrl}return l},Cct=gRl;c();var vct=nt(qt(),1);var NRl=()=>(0,vct.useContext)(Dpe),fM=NRl;var WRl=(t,e={})=>{let{stdin:l,setRawMode:n,internal_exitOnCtrlC:r,internal_eventEmitter:I}=fM();(0,kXe.useEffect)(()=>{if(e.isActive!==!1)return n(!0),()=>{n(!1)}},[e.isActive,n]),(0,kXe.useEffect)(()=>{if(e.isActive===!1)return;let a=s=>{let o=Cct(s),d={upArrow:o.name==="up",downArrow:o.name==="down",leftArrow:o.name==="left",rightArrow:o.name==="right",pageDown:o.name==="pagedown",pageUp:o.name==="pageup",return:o.name==="return",escape:o.name==="escape",ctrl:o.ctrl,shift:o.shift,tab:o.name==="tab",backspace:o.name==="backspace",delete:o.name==="delete",meta:o.meta||o.name==="escape"||o.option},u=o.ctrl?o.name:o.sequence;Fct.includes(o.name)&&(u=""),u.startsWith("\x1B")&&(u=u.slice(1)),u.length===1&&typeof u[0]=="string"&&/[A-Z]/.test(u[0])&&(d.shift=!0),(!(u==="c"&&d.ctrl)||!r)&&pF.batchedUpdates(()=>{t(u,d)})};return I?.on("input",a),()=>{I?.removeListener("input",a)}},[e.isActive,l,r,t])},I1=WRl;c();var yRl=nt(qt(),1);c();var fct=nt(qt(),1);var ERl=()=>(0,fct.useContext)(zpe),PN=ERl;c();var RRl=nt(qt(),1);c();var LXe=nt(qt(),1);c();var YRl=nt(qt(),1);c();var Hct=nt(qt(),1);var VRl=()=>{let{isScreenReaderEnabled:t}=(0,Hct.useContext)(hF);return t},y3=VRl;c();var wRl=t=>({width:t.yogaNode?.getComputedWidth()??0,height:t.yogaNode?.getComputedHeight()??0}),ehe=wRl;var Iat=nt(qt(),1);import psr,{join as rat}from"path";import{text as hsr}from"stream/consumers";c();c();var SAt=nt(V_(),1);c();c();c();c();var lp=[];for(let t=0;t<256;++t)lp.push((t+256).toString(16).slice(1));function uAt(t,e=0){return(lp[t[e+0]]+lp[t[e+1]]+lp[t[e+2]]+lp[t[e+3]]+"-"+lp[t[e+4]]+lp[t[e+5]]+"-"+lp[t[e+6]]+lp[t[e+7]]+"-"+lp[t[e+8]]+lp[t[e+9]]+"-"+lp[t[e+10]]+lp[t[e+11]]+lp[t[e+12]]+lp[t[e+13]]+lp[t[e+14]]+lp[t[e+15]]).toLowerCase()}c();import{randomFillSync as p5l}from"node:crypto";var tZe=new Uint8Array(256),eZe=tZe.length;function dLe(){return eZe>tZe.length-16&&(p5l(tZe),eZe=0),tZe.slice(eZe,eZe+=16)}c();c();import{randomUUID as h5l}from"node:crypto";var uLe={randomUUID:h5l};function A5l(t,e,l){t=t||{};let n=t.random??t.rng?.()??dLe();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){if(l=l||0,l<0||l+16>e.length)throw new RangeError(`UUID byte range ${l}:${l+15} is out of buffer bounds`);for(let r=0;r<16;++r)e[l+r]=n[r];return e}return uAt(n)}function Z5l(t,e,l){return uLe.randomUUID&&!e&&!t?uLe.randomUUID():A5l(t,e,l)}var Bu=Z5l;var M3=class{settings={};mergePartial(e,l){return{...e,...l}}setBlackbirdMode(e){return e!==void 0&&(e=="tool"||e=="initial-search")&&(this.settings.blackbird=this.mergePartial(this.settings.blackbird,{mode:e})),this}setSwebenchBaseCommit(e){return e!==void 0&&(this.settings.swebench_base_commit=e),this}setGithubUserName(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,name:e}})}return this}setGithubUserEmail(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,email:e}})}return this}setGithubToken(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{token:e})),this}setGithubServerUrl(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{serverUrl:e??"https://github.com"}),(!this.settings.github.host||!this.settings.github.hostProtocol)&&(this.settings.github=this.mergePartial(this.settings.github,new URL(e)))),this}setGithubHost(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{host:e})),this}setGithubHostProtocol(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{hostProtocol:e})),this}setGithubActorId(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,actorId:e}})}return this}setGithubActorLogin(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,actorLogin:e}})}return this}setAgentRuntimeVersion(e){return e!==void 0?this.settings.version=e:this.settings.version="latest",this}setGithubRepoName(e){if(e!==void 0){let l=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,name:e}})}return this}setGithubRepoId(e){if(e!==void 0){let l=this.settings.github?.repo||{},n=Number(e);isNaN(n)||(this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,id:n}}))}return this}setGithubRepoOwnerName(e){if(e!==void 0){let l=this.settings.github?.owner||{};this.settings.github=this.mergePartial(this.settings.github,{owner:{...l,name:e}})}return this}setGithubRepoOwnerId(e){if(e!==void 0){let l=this.settings.github?.owner||{},n=Number(e);isNaN(n)||(this.settings.github=this.mergePartial(this.settings.github,{owner:{...l,id:n}}))}return this}setGithubRepoBranch(e){if(e){let l=e.replace(/^refs\/heads\//,"");if(l.length===0)return this;let n=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...n,branch:l}})}return this}setGithubRepoCommit(e){if(e!==void 0){let l=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,commit:e}})}return this}setGithubRepoReadWrite(e){if(e!==void 0){let l=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,readWrite:e}})}return this}setProblemStatement(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{statement:e})),this}setProblemContentFilterMode(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{contentFilterMode:e})),this}setProblemAction(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{action:e})),this}setCustomAgentName(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{customAgentName:e})),this}setGithubPRCommitCount(e){if(e!==void 0){let l=this.settings.github?.pr||{};this.settings.github=this.mergePartial(this.settings.github,{pr:{...l,commitCount:e}})}return this}setInstanceId(e){return this.settings.service=this.mergePartial(this.settings.service,{instance:{id:e??Bu()}}),this}setAgentModel(e){if(e!==void 0){let l=this.settings.service?.agent||{};this.settings.service=this.mergePartial(this.settings.service,{agent:{...l,model:e}})}return this}setRequestHeaders(e){if(e!==void 0){let l=this.settings.service?.agent||{};this.settings.service=this.mergePartial(this.settings.service,{agent:{...l,requestHeaders:e}})}return this}setRetryPolicy(e){if(e!==void 0){let l=this.settings.service?.agent||{};this.settings.service=this.mergePartial(this.settings.service,{agent:{...l,retryPolicy:e}})}return this}setCallbackUrl(e){return e!==void 0&&(this.settings.service=this.mergePartial(this.settings.service,{callback:{url:e}})),this}setGitHubUploadsUrl(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{uploadsUrl:e})),this}setGitHubDownloadsUrl(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{downloadsUrl:e})),this}setAipSweAgentToken(e){return e!==void 0&&(this.settings.api=this.mergePartial(this.settings.api,{aipSweAgent:{token:e}})),this}setAnthropicApiKey(e){return e!==void 0&&(this.settings.api=this.mergePartial(this.settings.api,{anthropic:{key:e}})),this}setOpenAiApiKey(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,apiKey:e}})}return this}setOpenAiBaseUrl(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,baseUrl:e}})}return this}setAzureOpenAiUrl(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azure:{...l.azure,url:e}}})}return this}setAzureOpenAiApiVersion(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azure:{...l.azure,apiVersion:e}}})}return this}setAzureOpenAiKeyVaultUri(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azureKeyVaultUri:e}})}return this}setAzureOpenAiSecretName(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azureSecretName:e}})}return this}setCopilotUrl(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,url:e}})}return this}setCopilotIntegrationId(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,integrationId:e}})}return this}setCopilotHmacKey(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,hmacKey:e}})}return this}setCopilotToken(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,token:e}})}return this}setCopilotAzureKeyVaultUri(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,azureKeyVaultUri:e}})}return this}setCopilotSessionId(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,sessionId:e}})}return this}setCopilotPreviousSessionIds(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,previousSessionIds:e.split(",").map(n=>n.trim()).filter(n=>n.length>0)}})}return this}setCopilotUseSessions(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,useSessions:e}})}return this}setCopilotJobNonce(e){return e!==void 0&&(this.settings.job=this.mergePartial(this.settings.job,{nonce:e})),this}setTrajectoryOutputFile(e){return e!==void 0&&(this.settings.trajectory=this.mergePartial(this.settings.trajectory,{outputFile:e})),this}setEventsLogDirectory(e){return e!==void 0&&(this.settings.logs=this.mergePartial(this.settings.logs,{eventsLogDir:e})),this}setDisableOnlineEvaluation(e){return e==!0&&this.settings.onlineEvaluation?.disableOnlineEvaluation!==!0&&(this.settings.onlineEvaluation=this.mergePartial(this.settings.onlineEvaluation,{disableOnlineEvaluation:e})),this}setEnableOnlineEvaluationOutputFile(e){return e==!0&&this.settings.onlineEvaluation?.enableOnlineEvaluationOutputFile!==!0&&(this.settings.onlineEvaluation=this.mergePartial(this.settings.onlineEvaluation,{enableOnlineEvaluationOutputFile:e})),this}setGitHubMCPServerToken(e){return e!==void 0&&(this.settings.api=this.mergePartial(this.settings.api,{github:{mcpServerToken:e}})),this}setFeatureFlagEnabled(e){return this.settings.featureFlags=this.mergePartial(this.settings.featureFlags,{[e]:!0}),this}setExperiment(e,l){return this.settings.experiments=this.mergePartial(this.settings.experiments,{[e]:l}),this}setTimeoutMs(e){return e!==void 0&&(this.settings.timeoutMs=e),this}setStartTimeMs(e){return e!==void 0&&(this.settings.startTimeMs=e),this}build(){return this.settings}};var lZe=["GITHUB_TOKEN","GITHUB_COPILOT_API_TOKEN","CAPI_HMAC_KEY","CAPI_HMAC_KEY_OVERRIDE","ANTHROPIC_API_KEY","AIP_SWE_AGENT_TOKEN","CAPI_AZURE_KEY_VAULT_URI","COPILOT_JOB_NONCE","GITHUB_MCP_SERVER_TOKEN","OPENAI_BASE_URL","OPENAI_API_KEY","COPILOT_AGENT_REQUEST_HEADERS","AZURE_OPENAI_API_KEY","AZURE_OPENAI_API_ENDPOINT","AZURE_OPENAI_KEY_VAULT_URI","AZURE_OPENAI_KEY_VAULT_SECRET_NAME","BLACKBIRD_AUTH_METIS_API_KEY","BLACKBIRD_AUTH_MODEL_BASED_RETRIEVAL_TOKEN"],mAt=["COPILOT_CALLBACK_URL","COPILOT_AGENT_MODEL","COPILOT_AGENT_JOB_ID","COPILOT_AGENT_PROMPT","COPILOT_AGENT_PUSH","COPILOT_FIREWALL_ENABLED","COPILOT_FIREWALL_ALLOW_LIST","GITHUB_COPILOT_INTEGRATION_ID","COPILOT_INTEGRATION_ID_OVERRIDE","COPILOT_AGENT_SESSION_ID","COPILOT_AGENT_PREVIOUS_SESSION_IDS","COPILOT_AGENT_EVENT_URL","COPILOT_AGENT_EVENT_TYPE","COPILOT_AGENT_ACTOR","COPILOT_AGENT_ACTOR_ID",...lZe];async function bAt(){let t=new M3;t.setGithubServerUrl(process.env.GITHUB_SERVER_URL).setGithubHost(process.env.GITHUB_HOST).setGithubHostProtocol(process.env.GITHUB_HOST_PROTOCOL).setGithubToken(process.env.GITHUB_TOKEN).setGithubUserName(process.env.COPILOT_AGENT_COMMIT_LOGIN).setGithubUserEmail(process.env.COPILOT_AGENT_COMMIT_EMAIL).setGithubRepoOwnerId(process.env.GITHUB_REPOSITORY_OWNER_ID).setGithubRepoOwnerName(process.env.GITHUB_REPOSITORY_OWNER).setGithubRepoId(process.env.GITHUB_REPOSITORY_ID).setGithubRepoName(process.env.GITHUB_REPOSITORY).setGithubRepoBranch(process.env.COPILOT_AGENT_BRANCH_NAME).setGithubRepoCommit(process.env.COPILOT_AGENT_BASE_COMMIT).setAgentRuntimeVersion(process.env.COPILOT_AGENT_RUNTIME_VERSION),process.env.COPILOT_AGENT_PUSH!==void 0&&t.setGithubRepoReadWrite(process.env.COPILOT_AGENT_PUSH==="true"),t.setGithubPRCommitCount(process.env.COPILOT_AGENT_PR_COMMIT_COUNT?parseInt(process.env.COPILOT_AGENT_PR_COMMIT_COUNT,10):void 0),t.setProblemStatement(process.env.COPILOT_AGENT_PROMPT).setProblemContentFilterMode(process.env.COPILOT_AGENT_CONTENT_FILTER_MODE).setCustomAgentName(process.env.COPILOT_CUSTOM_AGENT);let e=process.env.COPILOT_AGENT_ACTION;if(e&&["fix","fix-pr-comment"].includes(e)&&t.setProblemAction(e),process.env.COPILOT_AGENT_ACTOR_ID&&t.setGithubActorId(parseInt(process.env.COPILOT_AGENT_ACTOR_ID,10)),process.env.COPILOT_AGENT_ACTOR&&t.setGithubActorLogin(process.env.COPILOT_AGENT_ACTOR),t.setInstanceId(process.env.COPILOT_AGENT_JOB_ID).setCopilotJobNonce(process.env.COPILOT_JOB_NONCE).setAgentModel(process.env.COPILOT_AGENT_MODEL).setCallbackUrl(process.env.COPILOT_AGENT_CALLBACK_URL).setGitHubUploadsUrl(process.env.GITHUB_UPLOADS_URL).setGitHubDownloadsUrl(process.env.GITHUB_DOWNLOADS_URL),t.setAipSweAgentToken(process.env.AIP_SWE_AGENT_TOKEN).setAnthropicApiKey(process.env.ANTHROPIC_API_KEY).setCopilotUrl(process.env.COPILOT_API_URL).setCopilotIntegrationId(process.env.GITHUB_COPILOT_INTEGRATION_ID).setCopilotHmacKey(process.env.CAPI_HMAC_KEY).setCopilotToken(process.env.GITHUB_COPILOT_API_TOKEN).setCopilotAzureKeyVaultUri(process.env.CAPI_AZURE_KEY_VAULT_URI).setBlackbirdMode(process.env.BLACKBIRD_MODE||"initial-search").setCopilotSessionId(process.env.COPILOT_AGENT_SESSION_ID).setCopilotPreviousSessionIds(process.env.COPILOT_AGENT_PREVIOUS_SESSION_IDS).setSwebenchBaseCommit(process.env.SWEBENCH_BASE_COMMIT).setGitHubMCPServerToken(process.env.GITHUB_MCP_SERVER_TOKEN).setAzureOpenAiKeyVaultUri(process.env.AZURE_OPENAI_KEY_VAULT_URI).setAzureOpenAiSecretName(process.env.AZURE_OPENAI_KEY_VAULT_SECRET_NAME).setOpenAiBaseUrl(process.env.OPENAI_BASE_URL).setOpenAiApiKey(process.env.AZURE_OPENAI_API_KEY||process.env.OPENAI_API_KEY).setAzureOpenAiUrl(process.env.AZURE_OPENAI_API_ENDPOINT).setAzureOpenAiApiVersion(process.env.AZURE_OPENAI_API_VERSION),process.env.COPILOT_USE_SESSIONS!==void 0&&t.setCopilotUseSessions(process.env.COPILOT_USE_SESSIONS==="true"),t.setTrajectoryOutputFile(process.env.CPD_SAVE_TRAJECTORY_OUTPUT),t.setEventsLogDirectory(process.env.COPILOT_EVENTS_LOG_DIRECTORY),process.env.COPILOT_AGENT_ONLINE_EVALUATION_DISABLED!==void 0&&t.setDisableOnlineEvaluation(process.env.COPILOT_AGENT_ONLINE_EVALUATION_DISABLED==="true"),process.env.COPILOT_AGENT_ONLINE_EVALUATION_OUTPUT_FILE!==void 0&&t.setEnableOnlineEvaluationOutputFile(process.env.COPILOT_AGENT_ONLINE_EVALUATION_OUTPUT_FILE==="true"),process.env.COPILOT_FEATURE_FLAGS&&process.env.COPILOT_FEATURE_FLAGS.split(",").map(r=>r.trim()).filter(r=>r.length>0).forEach(r=>t.setFeatureFlagEnabled(r)),process.env.COPILOT_EXPERIMENTS&&process.env.COPILOT_EXPERIMENTS.split(",").map(r=>{let[I,a]=r.split(":");t.setExperiment(I,a)}),process.env.COPILOT_AGENT_ERROR_CODES_TO_RETRY){let r=process.env.COPILOT_AGENT_ERROR_CODES_TO_RETRY.split(",").map(I=>parseInt(I.trim(),10));t.setRetryPolicy({errorCodesToRetry:r})}if(process.env.COPILOT_AGENT_REQUEST_HEADERS)try{let r=JSON.parse(process.env.COPILOT_AGENT_REQUEST_HEADERS);t.setRequestHeaders(r)}catch{}let l=process.env.COPILOT_AGENT_TIMEOUT_MIN?parseInt(process.env.COPILOT_AGENT_TIMEOUT_MIN,10):void 0;l!==void 0&&!Number.isNaN(l)&&t.setTimeoutMs(l*60*1e3);let n=process.env.COPILOT_AGENT_START_TIME_SEC?parseInt(process.env.COPILOT_AGENT_START_TIME_SEC,10):void 0;return n!==void 0&&!Number.isNaN(n)&&t.setStartTimeMs(n*1e3),t.build()}c();c();var yAt=nt(pAt(),1);import{exec as WAt,execFile as y5l}from"child_process";c();c();c();var Pee=null;function F_(){return!!Pee}function mLe(){if(!Pee)throw new Error("Settings have not been initialized");return Pee}function hAt(t){return Pee=t,t}function C_(){Pee=null}c();function oo(t,e){return t?.featureFlags?.[e]??!1}function AAt(t,e){return t?.experiments?.[e]}function bLe(t){return Object.keys(t.featureFlags??{}).filter(e=>t.featureFlags?.[e]).join(",")}var N5l=["token","secret","key","hmacKey","modelBasedRetrievalToken","metisApiKey"];function GLe(t,e=[]){for(let[l,n]of Object.entries(t))if(n!==null)switch(typeof n){case"object":GLe(n,e);break;case"undefined":break;default:if(N5l.includes(l)){let r=n.toString().trim();r!=""&&e.push(r)}break}return e}function ZAt(t,e){if(isNaN(e)||!isFinite(e)||e<=0)return{isWithin:!1,withinMs:e};if(e>1)return{isWithin:!1,withinMs:e};if(!t.timeoutMs)return{isWithin:!1,withinMs:e};let l=t.timeoutMs*e;return t.startTimeMs?{isWithin:Date.now()-t.startTimeMs>=t.timeoutMs-l,withinMs:l}:{isWithin:!1,withinMs:l}}c();import*as gAt from"process";function pLe(t){let e=gAt.env[t];if(e&&e.trim()!=="")return e}var W5l=[/\b(?:eyJ0eXAiOi|eyJhbGciOi|eyJ4NXQiOi|eyJraWQiOi)[^\s'";]+/g,/\bBearer\s+[^\s'";]+/g,/\b(?:Password|Pwd)=(?:[^\s'";]+|"[^"]+")/gi,/\s+-(?:Password|Pwd)\s+(?:[^\s'";]+|"[^"]+")/gi,/\bv1\.[0-9A-Fa-f]{40}\b/g,/\bgh[pousr]{1}_[A-Za-z0-9]{36}\b/g,/\bgithub_pat_[0-9][A-Za-z0-9]{21}_[A-Za-z0-9]{59}\b/g,/(?:[a-zA-Z][a-zA-Z\d+-.]*):\/\/([a-zA-Z\d\-._~!$&'()*+,;=%]+):([a-zA-Z\d\-._~!$&'()*+,;=:%]*)@/g,/\b[0-9A-Za-z-_~.]{3}7Q~[0-9A-Za-z-_~.]{31}\b|\b[0-9A-Za-z-_~.]{3}8Q~[0-9A-Za-z-_~.]{34}\b/g,/\b[0-9A-Za-z+/]{76}(APIM|ACDb|\+(ABa|AMC|ASt))[0-9A-Za-z+/]{5}[AQgw]==/g,/\b[0-9A-Za-z+/]{33}(AIoT|\+(ASb|AEh|ARm))[A-P][0-9A-Za-z+/]{5}=/g,/\b[0-9A-Za-z_-]{44}AzFu[0-9A-Za-z\-_]{5}[AQgw]==/g,/\b[0-9A-Za-z]{42}AzSe[A-D][0-9A-Za-z]{5}\b/g,/\b[0-9A-Za-z+/]{42}\+ACR[A-D][0-9A-Za-z+/]{5}\b/g,/\b[0-9A-Za-z]{33}AzCa[A-P][0-9A-Za-z]{5}=/g,/\boy2[a-p][0-9a-z]{15}[aq][0-9a-z]{11}[eu][bdfhjlnprtvxz357][a-p][0-9a-z]{11}[aeimquy4]\b/g,/\bnpm_[0-9A-Za-z]{36}\b/g,/\bx-ghcr-signature=[^&]+/g],NAt="******",g1=class t{static singleton;static getInstance(){return t.singleton||(t.singleton=new t),t.singleton}secretValuesToFilter;runner;logger;constructor(){}setRunner(e){this.runner=e,this.logger=e.logger,this.secretValuesToFilter=void 0}filterSecrets(e){let l=typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"message"),n=l?e.message??e.toString():e,r=this.getSecretValues();for(let I of r)n=n.replaceAll(I,NAt);for(let I of W5l)n=n.replaceAll(I,NAt);return l?(e.message=n,e):n}filterSecretsFromJsonString(e){try{let l=JSON.parse(e),n=this.filterSecretsFromObj(l);return JSON.stringify(n)}catch{return this.filterSecrets(e)}}filterSecretsFromObj(e){if(e==null)return e;if(typeof e=="string")return this.filterSecrets(e);if(typeof e=="number"){let l=this.filterSecrets(e.toString()),n=Number(l);return isNaN(n)?l:n}if(Array.isArray(e))return e.map(l=>this.filterSecretsFromObj(l));if(typeof e=="object"){let l={};for(let[n,r]of Object.entries(e))l[n]=this.filterSecretsFromObj(r);return l}return e}getSecretValues(){if(this.secretValuesToFilter)return this.secretValuesToFilter;let e={secretEnvVars:!1,runner:!1,settings:!1},l=new Set;for(let n of lZe){let r=pLe(n);r&&hLe(l,r)}if(e.secretEnvVars=!0,this.runner){for(let n of this.runner.sensitiveKeys){let r=pLe(n);r&&hLe(l,r)}e.runner=!0}if(F_()){let n=GLe(mLe());for(let r of n)hLe(l,r);e.settings=!0}return Object.values(e).every(n=>n)&&(this.secretValuesToFilter=l,this.logger?.debug("Caching secret values to filter from all sources.")),l}};function hLe(t,e){t.add(e),t.add(Buffer.from(e,"utf8").toString("base64"))}function jee(...t){let e=new Set(["DEBUG","COPILOT_AGENT_DEBUG",...t]);for(let l of e)if(process.env[l]==="1"||process.env[l]?.toLocaleLowerCase()==="true")return!0;return!1}var HF=class{logLevel;debugEnvironmentVariables;secretFilter=g1.getInstance();constructor(e,l){e===void 0?jee(...l??[])?this.logLevel=15:this.logLevel=7:this.logLevel=e,this.debugEnvironmentVariables=l}filterSecrets(e){return typeof e=="string"?this.secretFilter.filterSecrets(e):this.secretFilter.filterSecrets(e)}shouldLog(e){return this.logLevel===void 0||(this.logLevel&e)===e}isDebug(){return jee(...this.debugEnvironmentVariables??[])}};var aW=class{logger;constructor(e){this.logger=e}async exec(e,l,n,r=[]){let I=n?.silent??!1,a=n?.silentDebugLogging??!0;try{let s=(n?.isDirectAgentCommand?"Copilot: ":"")+(l?`${e} ${l.join(" ")}`:e);this.logger.startGroup(s,I?8:void 0);let o=await this._exec(e,l,n,r);if(o.error)throw o.error;return o.stdout&&(I?a&&this.logger.debug(o.stdout):this.logger.info(o.stdout)),o.stderr&&this.logger.error(o.stderr),0}catch(s){throw this.logger.error(s),s}finally{this.logger.endGroup(I?8:void 0)}}async execReturn(e,l,n,r=[]){let I=n?.silent??!1,a=n?.silentDebugLogging??!0;try{let s=(n?.isDirectAgentCommand?"Copilot: ":"")+(l?`${e} ${l.join(" ")}`:e);this.logger.startGroup(s,I?8:void 0);let o=await this._exec(e,l,n,r);if(o.error)throw o.error;return o.stdout&&(I?a&&this.logger.debug(o.stdout):this.logger.info(o.stdout)),o.stderr&&this.logger.error(o.stderr),{exitCode:o.exitCode,stdout:o.stdout,stderr:o.stderr}}catch(s){throw this.logger.error(s),s}finally{this.logger.endGroup(I?8:void 0)}}_exec(e,l,n,r=[]){n||(n={}),n.timeout||(n.timeout=9e5),l||(l=[]);let I={cwd:n.cwd,env:n.env,shell:n.shell,timeout:n.timeout,signal:n.abortSignal};return new Promise((a,s)=>{let o=n.shell&&l?.length===0?WAt(e,I):n.shell?WAt(`${e} ${(0,yAt.default)(l)}`,I):y5l(e,l,I),d="",u="";o.stdout?.on("data",b=>{d+=b}),o.stderr?.on("data",b=>{u+=b}),o.on("close",(b,p)=>{if(b!==0&&!n?.ignoreReturnCode){let h=this.filterCommand(e,l,r),Z=new Error(`Command failed with exit code ${b}: ${h}`);Z.cmd=h,Z.code=b,Z.stdout=d,Z.stderr=u,Z.signal=p,s(Z)}else a({error:null,stdout:d,stderr:u,exitCode:b})}),o.on("error",b=>{b.stdout=d,b.stderr=u,b.cmd=this.filterCommand(e,l,r),s(b)}),n.input&&(o.stdin?.write(n.input),o.stdin?.end())})}filterCommand(e,l=[],n){let r=l.reduce((I,a)=>(n.includes(a)?I.push("REDACTED"):I.push(a),I),[]);return`${e} ${r.join(" ")}`}};c();import{randomUUID as E5l}from"crypto";import{cpSync as R5l,existsSync as JAt,mkdtempSync as Y5l,rmSync as V5l}from"fs";import{homedir as xAt,tmpdir as w5l}from"os";import{join as ete}from"path";c();var _3=class t extends Error{cmd;killed;code;signal;stdout="";stderr="";errorType;skipReport;constructor(e,l,n=!1){if(!l){let r=e.code,I=e.message;"stdout"in e&&"stderr"in e&&(I+=`
|
|
804
|
+
`)l.name="enter";else if(t===" ")l.name="tab";else if(t==="\b"||t==="\x1B\b")l.name="backspace",l.meta=t.charAt(0)==="\x1B";else if(t==="\x7F"||t==="\x1B\x7F")l.name="delete",l.meta=t.charAt(0)==="\x1B";else if(t==="\x1B"||t==="\x1B\x1B")l.name="escape",l.meta=t.length===2;else if(t===" "||t==="\x1B ")l.name="space",l.meta=t.length===2;else if(t.length===1&&t<="")l.name=String.fromCharCode(t.charCodeAt(0)+97-1),l.ctrl=!0;else if(t.length===1&&t>="0"&&t<="9")l.name="number";else if(t.length===1&&t>="a"&&t<="z")l.name=t;else if(t.length===1&&t>="A"&&t<="Z")l.name=t.toLowerCase(),l.shift=!0;else if(e=pRl.exec(t))l.meta=!0,l.shift=/^[A-Z]$/.test(e[1]);else if(e=hRl.exec(t)){let n=[...t];n[0]==="\x1B"&&n[1]==="\x1B"&&(l.option=!0);let r=[e[1],e[2],e[4],e[6]].filter(Boolean).join(""),I=(e[3]||e[5]||1)-1;l.ctrl=!!(I&4),l.meta=!!(I&10),l.shift=!!(I&1),l.code=r,l.name=Qct[r],l.shift=ARl(r)||l.shift,l.ctrl=ZRl(r)||l.ctrl}return l},Cct=gRl;c();var vct=nt(qt(),1);var NRl=()=>(0,vct.useContext)(Dpe),fM=NRl;var WRl=(t,e={})=>{let{stdin:l,setRawMode:n,internal_exitOnCtrlC:r,internal_eventEmitter:I}=fM();(0,kXe.useEffect)(()=>{if(e.isActive!==!1)return n(!0),()=>{n(!1)}},[e.isActive,n]),(0,kXe.useEffect)(()=>{if(e.isActive===!1)return;let a=s=>{let o=Cct(s),d={upArrow:o.name==="up",downArrow:o.name==="down",leftArrow:o.name==="left",rightArrow:o.name==="right",pageDown:o.name==="pagedown",pageUp:o.name==="pageup",return:o.name==="return",escape:o.name==="escape",ctrl:o.ctrl,shift:o.shift,tab:o.name==="tab",backspace:o.name==="backspace",delete:o.name==="delete",meta:o.meta||o.name==="escape"||o.option},u=o.ctrl?o.name:o.sequence;Fct.includes(o.name)&&(u=""),u.startsWith("\x1B")&&(u=u.slice(1)),u.length===1&&typeof u[0]=="string"&&/[A-Z]/.test(u[0])&&(d.shift=!0),(!(u==="c"&&d.ctrl)||!r)&&pF.batchedUpdates(()=>{t(u,d)})};return I?.on("input",a),()=>{I?.removeListener("input",a)}},[e.isActive,l,r,t])},I1=WRl;c();var yRl=nt(qt(),1);c();var fct=nt(qt(),1);var ERl=()=>(0,fct.useContext)(zpe),PN=ERl;c();var RRl=nt(qt(),1);c();var LXe=nt(qt(),1);c();var YRl=nt(qt(),1);c();var Hct=nt(qt(),1);var VRl=()=>{let{isScreenReaderEnabled:t}=(0,Hct.useContext)(hF);return t},y3=VRl;c();var wRl=t=>({width:t.yogaNode?.getComputedWidth()??0,height:t.yogaNode?.getComputedHeight()??0}),ehe=wRl;var Iat=nt(qt(),1);import psr,{join as rat}from"path";import{text as hsr}from"stream/consumers";c();c();var SAt=nt(V_(),1);c();c();c();c();var lp=[];for(let t=0;t<256;++t)lp.push((t+256).toString(16).slice(1));function uAt(t,e=0){return(lp[t[e+0]]+lp[t[e+1]]+lp[t[e+2]]+lp[t[e+3]]+"-"+lp[t[e+4]]+lp[t[e+5]]+"-"+lp[t[e+6]]+lp[t[e+7]]+"-"+lp[t[e+8]]+lp[t[e+9]]+"-"+lp[t[e+10]]+lp[t[e+11]]+lp[t[e+12]]+lp[t[e+13]]+lp[t[e+14]]+lp[t[e+15]]).toLowerCase()}c();import{randomFillSync as p5l}from"node:crypto";var tZe=new Uint8Array(256),eZe=tZe.length;function dLe(){return eZe>tZe.length-16&&(p5l(tZe),eZe=0),tZe.slice(eZe,eZe+=16)}c();c();import{randomUUID as h5l}from"node:crypto";var uLe={randomUUID:h5l};function A5l(t,e,l){t=t||{};let n=t.random??t.rng?.()??dLe();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){if(l=l||0,l<0||l+16>e.length)throw new RangeError(`UUID byte range ${l}:${l+15} is out of buffer bounds`);for(let r=0;r<16;++r)e[l+r]=n[r];return e}return uAt(n)}function Z5l(t,e,l){return uLe.randomUUID&&!e&&!t?uLe.randomUUID():A5l(t,e,l)}var Bu=Z5l;var M3=class{settings={};mergePartial(e,l){return{...e,...l}}setBlackbirdMode(e){return e!==void 0&&(e=="tool"||e=="initial-search")&&(this.settings.blackbird=this.mergePartial(this.settings.blackbird,{mode:e})),this}setSwebenchBaseCommit(e){return e!==void 0&&(this.settings.swebench_base_commit=e),this}setGithubUserName(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,name:e}})}return this}setGithubUserEmail(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,email:e}})}return this}setGithubToken(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{token:e})),this}setGithubServerUrl(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{serverUrl:e??"https://github.com"}),(!this.settings.github.host||!this.settings.github.hostProtocol)&&(this.settings.github=this.mergePartial(this.settings.github,new URL(e)))),this}setGithubHost(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{host:e})),this}setGithubHostProtocol(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{hostProtocol:e})),this}setGithubActorId(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,actorId:e}})}return this}setGithubActorLogin(e){if(e!==void 0){let l=this.settings.github?.user||{};this.settings.github=this.mergePartial(this.settings.github,{user:{...l,actorLogin:e}})}return this}setAgentRuntimeVersion(e){return e!==void 0?this.settings.version=e:this.settings.version="latest",this}setGithubRepoName(e){if(e!==void 0){let l=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,name:e}})}return this}setGithubRepoId(e){if(e!==void 0){let l=this.settings.github?.repo||{},n=Number(e);isNaN(n)||(this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,id:n}}))}return this}setGithubRepoOwnerName(e){if(e!==void 0){let l=this.settings.github?.owner||{};this.settings.github=this.mergePartial(this.settings.github,{owner:{...l,name:e}})}return this}setGithubRepoOwnerId(e){if(e!==void 0){let l=this.settings.github?.owner||{},n=Number(e);isNaN(n)||(this.settings.github=this.mergePartial(this.settings.github,{owner:{...l,id:n}}))}return this}setGithubRepoBranch(e){if(e){let l=e.replace(/^refs\/heads\//,"");if(l.length===0)return this;let n=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...n,branch:l}})}return this}setGithubRepoCommit(e){if(e!==void 0){let l=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,commit:e}})}return this}setGithubRepoReadWrite(e){if(e!==void 0){let l=this.settings.github?.repo||{};this.settings.github=this.mergePartial(this.settings.github,{repo:{...l,readWrite:e}})}return this}setProblemStatement(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{statement:e})),this}setProblemContentFilterMode(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{contentFilterMode:e})),this}setProblemAction(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{action:e})),this}setCustomAgentName(e){return e!==void 0&&(this.settings.problem=this.mergePartial(this.settings.problem,{customAgentName:e})),this}setGithubPRCommitCount(e){if(e!==void 0){let l=this.settings.github?.pr||{};this.settings.github=this.mergePartial(this.settings.github,{pr:{...l,commitCount:e}})}return this}setInstanceId(e){return this.settings.service=this.mergePartial(this.settings.service,{instance:{id:e??Bu()}}),this}setAgentModel(e){if(e!==void 0){let l=this.settings.service?.agent||{};this.settings.service=this.mergePartial(this.settings.service,{agent:{...l,model:e}})}return this}setRequestHeaders(e){if(e!==void 0){let l=this.settings.service?.agent||{};this.settings.service=this.mergePartial(this.settings.service,{agent:{...l,requestHeaders:e}})}return this}setRetryPolicy(e){if(e!==void 0){let l=this.settings.service?.agent||{};this.settings.service=this.mergePartial(this.settings.service,{agent:{...l,retryPolicy:e}})}return this}setCallbackUrl(e){return e!==void 0&&(this.settings.service=this.mergePartial(this.settings.service,{callback:{url:e}})),this}setGitHubUploadsUrl(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{uploadsUrl:e})),this}setGitHubDownloadsUrl(e){return e!==void 0&&(this.settings.github=this.mergePartial(this.settings.github,{downloadsUrl:e})),this}setAipSweAgentToken(e){return e!==void 0&&(this.settings.api=this.mergePartial(this.settings.api,{aipSweAgent:{token:e}})),this}setAnthropicApiKey(e){return e!==void 0&&(this.settings.api=this.mergePartial(this.settings.api,{anthropic:{key:e}})),this}setOpenAiApiKey(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,apiKey:e}})}return this}setOpenAiBaseUrl(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,baseUrl:e}})}return this}setAzureOpenAiUrl(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azure:{...l.azure,url:e}}})}return this}setAzureOpenAiApiVersion(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azure:{...l.azure,apiVersion:e}}})}return this}setAzureOpenAiKeyVaultUri(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azureKeyVaultUri:e}})}return this}setAzureOpenAiSecretName(e){if(e!==void 0){let l=this.settings.api?.openai||{};this.settings.api=this.mergePartial(this.settings.api,{openai:{...l,azureSecretName:e}})}return this}setCopilotUrl(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,url:e}})}return this}setCopilotIntegrationId(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,integrationId:e}})}return this}setCopilotHmacKey(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,hmacKey:e}})}return this}setCopilotToken(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,token:e}})}return this}setCopilotAzureKeyVaultUri(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,azureKeyVaultUri:e}})}return this}setCopilotSessionId(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,sessionId:e}})}return this}setCopilotPreviousSessionIds(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,previousSessionIds:e.split(",").map(n=>n.trim()).filter(n=>n.length>0)}})}return this}setCopilotUseSessions(e){if(e!==void 0){let l=this.settings.api?.copilot||{};this.settings.api=this.mergePartial(this.settings.api,{copilot:{...l,useSessions:e}})}return this}setCopilotJobNonce(e){return e!==void 0&&(this.settings.job=this.mergePartial(this.settings.job,{nonce:e})),this}setCopilotJobEventType(e){return e!==void 0&&(this.settings.job=this.mergePartial(this.settings.job,{eventType:e})),this}setTrajectoryOutputFile(e){return e!==void 0&&(this.settings.trajectory=this.mergePartial(this.settings.trajectory,{outputFile:e})),this}setEventsLogDirectory(e){return e!==void 0&&(this.settings.logs=this.mergePartial(this.settings.logs,{eventsLogDir:e})),this}setDisableOnlineEvaluation(e){return e==!0&&this.settings.onlineEvaluation?.disableOnlineEvaluation!==!0&&(this.settings.onlineEvaluation=this.mergePartial(this.settings.onlineEvaluation,{disableOnlineEvaluation:e})),this}setEnableOnlineEvaluationOutputFile(e){return e==!0&&this.settings.onlineEvaluation?.enableOnlineEvaluationOutputFile!==!0&&(this.settings.onlineEvaluation=this.mergePartial(this.settings.onlineEvaluation,{enableOnlineEvaluationOutputFile:e})),this}setGitHubMCPServerToken(e){return e!==void 0&&(this.settings.api=this.mergePartial(this.settings.api,{github:{mcpServerToken:e}})),this}setFeatureFlagEnabled(e){return this.settings.featureFlags=this.mergePartial(this.settings.featureFlags,{[e]:!0}),this}setExperiment(e,l){return this.settings.experiments=this.mergePartial(this.settings.experiments,{[e]:l}),this}setTimeoutMs(e){return e!==void 0&&(this.settings.timeoutMs=e),this}setStartTimeMs(e){return e!==void 0&&(this.settings.startTimeMs=e),this}build(){return this.settings}};var lZe=["GITHUB_TOKEN","GITHUB_COPILOT_API_TOKEN","CAPI_HMAC_KEY","CAPI_HMAC_KEY_OVERRIDE","ANTHROPIC_API_KEY","AIP_SWE_AGENT_TOKEN","CAPI_AZURE_KEY_VAULT_URI","COPILOT_JOB_NONCE","GITHUB_MCP_SERVER_TOKEN","OPENAI_BASE_URL","OPENAI_API_KEY","COPILOT_AGENT_REQUEST_HEADERS","AZURE_OPENAI_API_KEY","AZURE_OPENAI_API_ENDPOINT","AZURE_OPENAI_KEY_VAULT_URI","AZURE_OPENAI_KEY_VAULT_SECRET_NAME","BLACKBIRD_AUTH_METIS_API_KEY","BLACKBIRD_AUTH_MODEL_BASED_RETRIEVAL_TOKEN"],mAt=["COPILOT_CALLBACK_URL","COPILOT_AGENT_MODEL","COPILOT_AGENT_JOB_ID","COPILOT_AGENT_PROMPT","COPILOT_AGENT_PUSH","COPILOT_FIREWALL_ENABLED","COPILOT_FIREWALL_ALLOW_LIST","GITHUB_COPILOT_INTEGRATION_ID","COPILOT_INTEGRATION_ID_OVERRIDE","COPILOT_AGENT_SESSION_ID","COPILOT_AGENT_PREVIOUS_SESSION_IDS","COPILOT_AGENT_EVENT_URL","COPILOT_AGENT_EVENT_TYPE","COPILOT_AGENT_ACTOR","COPILOT_AGENT_ACTOR_ID",...lZe];async function bAt(){let t=new M3;t.setGithubServerUrl(process.env.GITHUB_SERVER_URL).setGithubHost(process.env.GITHUB_HOST).setGithubHostProtocol(process.env.GITHUB_HOST_PROTOCOL).setGithubToken(process.env.GITHUB_TOKEN).setGithubUserName(process.env.COPILOT_AGENT_COMMIT_LOGIN).setGithubUserEmail(process.env.COPILOT_AGENT_COMMIT_EMAIL).setGithubRepoOwnerId(process.env.GITHUB_REPOSITORY_OWNER_ID).setGithubRepoOwnerName(process.env.GITHUB_REPOSITORY_OWNER).setGithubRepoId(process.env.GITHUB_REPOSITORY_ID).setGithubRepoName(process.env.GITHUB_REPOSITORY).setGithubRepoBranch(process.env.COPILOT_AGENT_BRANCH_NAME).setGithubRepoCommit(process.env.COPILOT_AGENT_BASE_COMMIT).setAgentRuntimeVersion(process.env.COPILOT_AGENT_RUNTIME_VERSION),process.env.COPILOT_AGENT_PUSH!==void 0&&t.setGithubRepoReadWrite(process.env.COPILOT_AGENT_PUSH==="true"),t.setGithubPRCommitCount(process.env.COPILOT_AGENT_PR_COMMIT_COUNT?parseInt(process.env.COPILOT_AGENT_PR_COMMIT_COUNT,10):void 0),t.setProblemStatement(process.env.COPILOT_AGENT_PROMPT).setProblemContentFilterMode(process.env.COPILOT_AGENT_CONTENT_FILTER_MODE).setCustomAgentName(process.env.COPILOT_CUSTOM_AGENT);let e=process.env.COPILOT_AGENT_ACTION;if(e&&["fix","fix-pr-comment"].includes(e)&&t.setProblemAction(e),process.env.COPILOT_AGENT_ACTOR_ID&&t.setGithubActorId(parseInt(process.env.COPILOT_AGENT_ACTOR_ID,10)),process.env.COPILOT_AGENT_ACTOR&&t.setGithubActorLogin(process.env.COPILOT_AGENT_ACTOR),t.setInstanceId(process.env.COPILOT_AGENT_JOB_ID).setCopilotJobNonce(process.env.COPILOT_JOB_NONCE).setCopilotJobEventType(process.env.COPILOT_JOB_EVENT_TYPE).setAgentModel(process.env.COPILOT_AGENT_MODEL).setCallbackUrl(process.env.COPILOT_AGENT_CALLBACK_URL).setGitHubUploadsUrl(process.env.GITHUB_UPLOADS_URL).setGitHubDownloadsUrl(process.env.GITHUB_DOWNLOADS_URL),t.setAipSweAgentToken(process.env.AIP_SWE_AGENT_TOKEN).setAnthropicApiKey(process.env.ANTHROPIC_API_KEY).setCopilotUrl(process.env.COPILOT_API_URL).setCopilotIntegrationId(process.env.GITHUB_COPILOT_INTEGRATION_ID).setCopilotHmacKey(process.env.CAPI_HMAC_KEY).setCopilotToken(process.env.GITHUB_COPILOT_API_TOKEN).setCopilotAzureKeyVaultUri(process.env.CAPI_AZURE_KEY_VAULT_URI).setBlackbirdMode(process.env.BLACKBIRD_MODE||"initial-search").setCopilotSessionId(process.env.COPILOT_AGENT_SESSION_ID).setCopilotPreviousSessionIds(process.env.COPILOT_AGENT_PREVIOUS_SESSION_IDS).setSwebenchBaseCommit(process.env.SWEBENCH_BASE_COMMIT).setGitHubMCPServerToken(process.env.GITHUB_MCP_SERVER_TOKEN).setAzureOpenAiKeyVaultUri(process.env.AZURE_OPENAI_KEY_VAULT_URI).setAzureOpenAiSecretName(process.env.AZURE_OPENAI_KEY_VAULT_SECRET_NAME).setOpenAiBaseUrl(process.env.OPENAI_BASE_URL).setOpenAiApiKey(process.env.AZURE_OPENAI_API_KEY||process.env.OPENAI_API_KEY).setAzureOpenAiUrl(process.env.AZURE_OPENAI_API_ENDPOINT).setAzureOpenAiApiVersion(process.env.AZURE_OPENAI_API_VERSION),process.env.COPILOT_USE_SESSIONS!==void 0&&t.setCopilotUseSessions(process.env.COPILOT_USE_SESSIONS==="true"),t.setTrajectoryOutputFile(process.env.CPD_SAVE_TRAJECTORY_OUTPUT),t.setEventsLogDirectory(process.env.COPILOT_EVENTS_LOG_DIRECTORY),process.env.COPILOT_AGENT_ONLINE_EVALUATION_DISABLED!==void 0&&t.setDisableOnlineEvaluation(process.env.COPILOT_AGENT_ONLINE_EVALUATION_DISABLED==="true"),process.env.COPILOT_AGENT_ONLINE_EVALUATION_OUTPUT_FILE!==void 0&&t.setEnableOnlineEvaluationOutputFile(process.env.COPILOT_AGENT_ONLINE_EVALUATION_OUTPUT_FILE==="true"),process.env.COPILOT_FEATURE_FLAGS&&process.env.COPILOT_FEATURE_FLAGS.split(",").map(r=>r.trim()).filter(r=>r.length>0).forEach(r=>t.setFeatureFlagEnabled(r)),process.env.COPILOT_EXPERIMENTS&&process.env.COPILOT_EXPERIMENTS.split(",").map(r=>{let[I,a]=r.split(":");t.setExperiment(I,a)}),process.env.COPILOT_AGENT_ERROR_CODES_TO_RETRY){let r=process.env.COPILOT_AGENT_ERROR_CODES_TO_RETRY.split(",").map(I=>parseInt(I.trim(),10));t.setRetryPolicy({errorCodesToRetry:r})}if(process.env.COPILOT_AGENT_REQUEST_HEADERS)try{let r=JSON.parse(process.env.COPILOT_AGENT_REQUEST_HEADERS);t.setRequestHeaders(r)}catch{}let l=process.env.COPILOT_AGENT_TIMEOUT_MIN?parseInt(process.env.COPILOT_AGENT_TIMEOUT_MIN,10):void 0;l!==void 0&&!Number.isNaN(l)&&t.setTimeoutMs(l*60*1e3);let n=process.env.COPILOT_AGENT_START_TIME_SEC?parseInt(process.env.COPILOT_AGENT_START_TIME_SEC,10):void 0;return n!==void 0&&!Number.isNaN(n)&&t.setStartTimeMs(n*1e3),t.build()}c();c();var yAt=nt(pAt(),1);import{exec as WAt,execFile as y5l}from"child_process";c();c();c();var Pee=null;function F_(){return!!Pee}function mLe(){if(!Pee)throw new Error("Settings have not been initialized");return Pee}function hAt(t){return Pee=t,t}function C_(){Pee=null}c();function oo(t,e){return t?.featureFlags?.[e]??!1}function AAt(t,e){return t?.experiments?.[e]}function bLe(t){return Object.keys(t.featureFlags??{}).filter(e=>t.featureFlags?.[e]).join(",")}var N5l=["token","secret","key","hmacKey","modelBasedRetrievalToken","metisApiKey"];function GLe(t,e=[]){for(let[l,n]of Object.entries(t))if(n!==null)switch(typeof n){case"object":GLe(n,e);break;case"undefined":break;default:if(N5l.includes(l)){let r=n.toString().trim();r!=""&&e.push(r)}break}return e}function ZAt(t,e){if(isNaN(e)||!isFinite(e)||e<=0)return{isWithin:!1,withinMs:e};if(e>1)return{isWithin:!1,withinMs:e};if(!t.timeoutMs)return{isWithin:!1,withinMs:e};let l=t.timeoutMs*e;return t.startTimeMs?{isWithin:Date.now()-t.startTimeMs>=t.timeoutMs-l,withinMs:l}:{isWithin:!1,withinMs:l}}c();import*as gAt from"process";function pLe(t){let e=gAt.env[t];if(e&&e.trim()!=="")return e}var W5l=[/\b(?:eyJ0eXAiOi|eyJhbGciOi|eyJ4NXQiOi|eyJraWQiOi)[^\s'";]+/g,/\bBearer\s+[^\s'";]+/g,/\b(?:Password|Pwd)=(?:[^\s'";]+|"[^"]+")/gi,/\s+-(?:Password|Pwd)\s+(?:[^\s'";]+|"[^"]+")/gi,/\bv1\.[0-9A-Fa-f]{40}\b/g,/\bgh[pousr]{1}_[A-Za-z0-9]{36}\b/g,/\bgithub_pat_[0-9][A-Za-z0-9]{21}_[A-Za-z0-9]{59}\b/g,/(?:[a-zA-Z][a-zA-Z\d+-.]*):\/\/([a-zA-Z\d\-._~!$&'()*+,;=%]+):([a-zA-Z\d\-._~!$&'()*+,;=:%]*)@/g,/\b[0-9A-Za-z-_~.]{3}7Q~[0-9A-Za-z-_~.]{31}\b|\b[0-9A-Za-z-_~.]{3}8Q~[0-9A-Za-z-_~.]{34}\b/g,/\b[0-9A-Za-z+/]{76}(APIM|ACDb|\+(ABa|AMC|ASt))[0-9A-Za-z+/]{5}[AQgw]==/g,/\b[0-9A-Za-z+/]{33}(AIoT|\+(ASb|AEh|ARm))[A-P][0-9A-Za-z+/]{5}=/g,/\b[0-9A-Za-z_-]{44}AzFu[0-9A-Za-z\-_]{5}[AQgw]==/g,/\b[0-9A-Za-z]{42}AzSe[A-D][0-9A-Za-z]{5}\b/g,/\b[0-9A-Za-z+/]{42}\+ACR[A-D][0-9A-Za-z+/]{5}\b/g,/\b[0-9A-Za-z]{33}AzCa[A-P][0-9A-Za-z]{5}=/g,/\boy2[a-p][0-9a-z]{15}[aq][0-9a-z]{11}[eu][bdfhjlnprtvxz357][a-p][0-9a-z]{11}[aeimquy4]\b/g,/\bnpm_[0-9A-Za-z]{36}\b/g,/\bx-ghcr-signature=[^&]+/g],NAt="******",g1=class t{static singleton;static getInstance(){return t.singleton||(t.singleton=new t),t.singleton}secretValuesToFilter;runner;logger;constructor(){}setRunner(e){this.runner=e,this.logger=e.logger,this.secretValuesToFilter=void 0}filterSecrets(e){let l=typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"message"),n=l?e.message??e.toString():e,r=this.getSecretValues();for(let I of r)n=n.replaceAll(I,NAt);for(let I of W5l)n=n.replaceAll(I,NAt);return l?(e.message=n,e):n}filterSecretsFromJsonString(e){try{let l=JSON.parse(e),n=this.filterSecretsFromObj(l);return JSON.stringify(n)}catch{return this.filterSecrets(e)}}filterSecretsFromObj(e){if(e==null)return e;if(typeof e=="string")return this.filterSecrets(e);if(typeof e=="number"){let l=this.filterSecrets(e.toString()),n=Number(l);return isNaN(n)?l:n}if(Array.isArray(e))return e.map(l=>this.filterSecretsFromObj(l));if(typeof e=="object"){let l={};for(let[n,r]of Object.entries(e))l[n]=this.filterSecretsFromObj(r);return l}return e}getSecretValues(){if(this.secretValuesToFilter)return this.secretValuesToFilter;let e={secretEnvVars:!1,runner:!1,settings:!1},l=new Set;for(let n of lZe){let r=pLe(n);r&&hLe(l,r)}if(e.secretEnvVars=!0,this.runner){for(let n of this.runner.sensitiveKeys){let r=pLe(n);r&&hLe(l,r)}e.runner=!0}if(F_()){let n=GLe(mLe());for(let r of n)hLe(l,r);e.settings=!0}return Object.values(e).every(n=>n)&&(this.secretValuesToFilter=l,this.logger?.debug("Caching secret values to filter from all sources.")),l}};function hLe(t,e){t.add(e),t.add(Buffer.from(e,"utf8").toString("base64"))}function jee(...t){let e=new Set(["DEBUG","COPILOT_AGENT_DEBUG",...t]);for(let l of e)if(process.env[l]==="1"||process.env[l]?.toLocaleLowerCase()==="true")return!0;return!1}var HF=class{logLevel;debugEnvironmentVariables;secretFilter=g1.getInstance();constructor(e,l){e===void 0?jee(...l??[])?this.logLevel=15:this.logLevel=7:this.logLevel=e,this.debugEnvironmentVariables=l}filterSecrets(e){return typeof e=="string"?this.secretFilter.filterSecrets(e):this.secretFilter.filterSecrets(e)}shouldLog(e){return this.logLevel===void 0||(this.logLevel&e)===e}isDebug(){return jee(...this.debugEnvironmentVariables??[])}};var aW=class{logger;constructor(e){this.logger=e}async exec(e,l,n,r=[]){let I=n?.silent??!1,a=n?.silentDebugLogging??!0;try{let s=(n?.isDirectAgentCommand?"Copilot: ":"")+(l?`${e} ${l.join(" ")}`:e);this.logger.startGroup(s,I?8:void 0);let o=await this._exec(e,l,n,r);if(o.error)throw o.error;return o.stdout&&(I?a&&this.logger.debug(o.stdout):this.logger.info(o.stdout)),o.stderr&&this.logger.error(o.stderr),0}catch(s){throw this.logger.error(s),s}finally{this.logger.endGroup(I?8:void 0)}}async execReturn(e,l,n,r=[]){let I=n?.silent??!1,a=n?.silentDebugLogging??!0;try{let s=(n?.isDirectAgentCommand?"Copilot: ":"")+(l?`${e} ${l.join(" ")}`:e);this.logger.startGroup(s,I?8:void 0);let o=await this._exec(e,l,n,r);if(o.error)throw o.error;return o.stdout&&(I?a&&this.logger.debug(o.stdout):this.logger.info(o.stdout)),o.stderr&&this.logger.error(o.stderr),{exitCode:o.exitCode,stdout:o.stdout,stderr:o.stderr}}catch(s){throw this.logger.error(s),s}finally{this.logger.endGroup(I?8:void 0)}}_exec(e,l,n,r=[]){n||(n={}),n.timeout||(n.timeout=9e5),l||(l=[]);let I={cwd:n.cwd,env:n.env,shell:n.shell,timeout:n.timeout,signal:n.abortSignal};return new Promise((a,s)=>{let o=n.shell&&l?.length===0?WAt(e,I):n.shell?WAt(`${e} ${(0,yAt.default)(l)}`,I):y5l(e,l,I),d="",u="";o.stdout?.on("data",b=>{d+=b}),o.stderr?.on("data",b=>{u+=b}),o.on("close",(b,p)=>{if(b!==0&&!n?.ignoreReturnCode){let h=this.filterCommand(e,l,r),Z=new Error(`Command failed with exit code ${b}: ${h}`);Z.cmd=h,Z.code=b,Z.stdout=d,Z.stderr=u,Z.signal=p,s(Z)}else a({error:null,stdout:d,stderr:u,exitCode:b})}),o.on("error",b=>{b.stdout=d,b.stderr=u,b.cmd=this.filterCommand(e,l,r),s(b)}),n.input&&(o.stdin?.write(n.input),o.stdin?.end())})}filterCommand(e,l=[],n){let r=l.reduce((I,a)=>(n.includes(a)?I.push("REDACTED"):I.push(a),I),[]);return`${e} ${r.join(" ")}`}};c();import{randomUUID as E5l}from"crypto";import{cpSync as R5l,existsSync as JAt,mkdtempSync as Y5l,rmSync as V5l}from"fs";import{homedir as xAt,tmpdir as w5l}from"os";import{join as ete}from"path";c();var _3=class t extends Error{cmd;killed;code;signal;stdout="";stderr="";errorType;skipReport;constructor(e,l,n=!1){if(!l){let r=e.code,I=e.message;"stdout"in e&&"stderr"in e&&(I+=`
|
|
805
805
|
`+e.stderr?.trim()+`
|
|
806
806
|
`+e.stdout?.trim()),I.includes("GH013: Repository rule violations found")||I.includes("unknown revision or path not in the working tree")?(l="protection rule",n=!0):I.includes("You may want to try Git Large File Storage")||I.includes("GH001: Large files detected")?(l="LFS",n=!0):r===1&&(I.includes("hook failed")||I.includes("husky -")||I.includes("hook declined")||I.includes("hook exited")||I.includes("vite ")||I.includes("eslint "))?(l="hook",n=!0):I.includes("use 'git pull' before pushing again")?(l="pull first",n=!0):I.includes("fetch first")?(l="fetch first",n=!0):I.includes("The requested URL returned error: 403")?(l="access denied",n=!1):I.includes("unexpected disconnect")?(l="disconnect",n=!1):(l="unknown",n=!(r==="ENOENT"||r===127||r===128||I.includes("fatal: ")))}super(`${l} git error: ${e.message}`);for(let r of Object.keys(e))this[r]=e[r];this.errorType=l??"unknown",this.skipReport=n,this.cause=e,Object.setPrototypeOf(this,t.prototype),this.name="GitError"}};c();var Kee="https://api.githubcopilot.com";function EAt(t){if(!t.github?.user?.name)throw new Error("GitHub user name is required");return t.github.user.name}function RAt(t){if(!t.github?.user?.email)throw new Error("GitHub user email is required");return t.github.user.email}function YAt(t){let e=t.github?.user?.actorLogin,l=t.github?.user?.actorId;if(!(!e||!l))return{login:e,id:l}}function VAt(t){if(!t.github?.serverUrl)throw new Error("GitHub server URL is required");return t.github.serverUrl}function wAt(t){if(!t.github?.host)throw new Error("GitHub host is required");return t.github.host}function QAt(t){if(!t.github?.hostProtocol)throw new Error("GitHub host protocol is required");return t.github.hostProtocol}function D3(t){if(!t.github?.token)throw new Error("GitHub token is required");return t.github.token}function nZe(t){if(!t.github?.repo?.name)throw new Error("GitHub repository name is required");return t.github.repo.name}function XF(t){if(!t.service?.instance?.id)throw new Error("Instance ID is required");return t.service.instance.id}function FAt(t){if(!t.service?.callback?.url)throw new Error("Callback URL is required");return t.service.callback.url}function CAt(t){if(!t.api?.anthropic?.key)throw new Error("Anthropic API key is required");return t.api.anthropic.key}function vAt(t){if(!t.api?.openai?.apiKey)throw new Error("OpenAI API key is required");return t.api.openai.apiKey}function fAt(t){if(!t.api?.openai?.azure?.url)throw new Error("Azure OpenAI deployment URL is required");return t.api.openai.azure.url}function HAt(t,e=Kee){let l=t.api?.copilot?.url||e;if(!l)throw new Error("Copilot URL is required");return l}function qee(t){if(!t.api?.copilot?.integrationId)throw new Error("Copilot integration ID is required");return t.api.copilot.integrationId}function $ee(t){if(!t.api?.copilot?.token)throw new Error("Copilot token is required");return t.api.copilot.token}function XAt(t){if(!t.github?.uploadsUrl)throw new Error("GitHub uploads URL is required");return t.github.uploadsUrl}function kAt(t){if(!t.github?.downloadsUrl)throw new Error("GitHub downloads URL is required");return t.github.downloadsUrl}c();function LAt(t){return t.startsWith('"')&&t.endsWith('"')?(t=t.substring(1,t.length-1),t.replace(/\\([abfnrtv\\"]|[0-7]{1,3})/g,(e,l)=>{switch(l[0]){case"a":return"\x07";case"b":return"\b";case"f":return"\f";case"n":return`
|
|
807
807
|
`;case"r":return"\r";case"t":return" ";case"v":return"\v";case"\\":return"\\";case'"':return'"';default:return String.fromCharCode(parseInt(l,8))}})):t}var ALe='!f() { test "$1" = get && echo "password=$GITHUB_TOKEN"; }; f',sg=class{constructor(e,l){this.logger=e;this.exec=l}resolveGitUrl(e,l){let n=null,r="";try{r=VAt(e),n=new URL(r)}catch(I){this.logger.warning(`Failed to parse GITHUB_SERVER_URL "${r}". Falling back to GITHUB_HOST and GITHUB_GIT_HOST_PROTOCOL. Error: ${I.message??I}`);let a=QAt(e),s=wAt(e);try{n=URL.parse(`${a}://${s}`)}catch(o){this.logger.warning(`Unable to determine GITHUB_SERVER_URL. Falling back to "https://github.com". Error: ${o.message??o}`),n=URL.parse("https://github.com")}}if(!n)throw new Error("Could not determine the Git URL");return l&&(n.pathname=l),this.logger.info(`Using Git URL: ${n.href}`),n}async cloneRepo(e,l,n,r,I,a){process.env.GITHUB_TOKEN=process.env.GITHUB_TOKEN??D3(e);let o=this.resolveGitUrl(e,l).href;if(I=I??1,I+=1,I<2&&(I=2),JAt(ete(n,".git"))){let N={cwd:n,silent:!0};if(this.logger.debug(`Repo ${l} already cloned to ${n}`),this.logger.debug(`Configuring git credential helper for ${l}`),await this.setGitConfig(e,N,!1),await this.execGit(["remote","set-url","origin",o],N,[o]),(await this.execGit(["rev-parse","--abbrev-ref","HEAD"],N)).stdout.toString().trim()===r){this.logger.debug(`Already on branch ${r} in repo ${l}`);return}if((await this.execGit(["branch","--list",r],N,[r])).stdout.toString().trim().length>0){this.logger.debug(`Local branch ${r} already exists in repo ${l}`),this.logger.debug(`Checking out branch ${r}`),await this.execGit(["checkout",r],N,[r]);return}if(await this.hasRemoteBranch(r,n)){this.logger.debug(`Remote branch ${r} exists in repo ${l}`);let{stdout:w}=await this.execGit(["rev-parse","--is-shallow-repository"],N);w.trim()==="true"?await this.execGit(["fetch","--unshallow","--update-head-ok","origin","+refs/heads/*:refs/heads/*"],N):await this.execGit(["fetch","origin"],N),this.logger.debug(`Pulling branch ${r} with depth ${I}`),await this.execGit(["pull","--depth",I.toString(),"origin",r],N,[I.toString(),r]),this.logger.debug(`Checking out branch ${r}`),await this.execGit(["checkout",r],N,[r]);return}if(a){this.logger.debug(`Base commit ${a} provided for branch ${r} in repo ${l}`),this.logger.debug(`Checking out branch ${r}`),await this.execGit(["checkout","-b",r,a],N,[r,a]);return}throw new Error(`Branch ${r} does not exist in repo ${l} and no base commit was provided.`)}this.logger.debug(`Repo ${l} not cloned to ${n} yet`);let u=process.env.HOME||xAt(),b=Y5l(ete(w5l(),`cpd-${E5l()}`));JAt(ete(u,".gitconfig"))&&R5l(ete(u,".gitconfig"),ete(b,".gitconfig"));let p={...process.env,HOME:b},h={silent:!0,env:p},Z={cwd:n,silent:!0,env:p};await this.setGitConfig(e,h,!0);try{this.logger.debug(`Cloning repo ${l} to ${n} with branch ${r} and depth ${I}`),await this.execGit(["clone","-b",r,"--single-branch","--depth",I.toString(),o,n],h,[o,n,r,I.toString()])}catch(N){if(this.logger.debug(`Error cloning repo ${l} to ${n}: ${N}`),a)this.logger.debug(`Base commit ${a} provided. Checking out branch ${r}`),await this.execGit(["clone",o,n],h,[o,n]),await this.execGit(["checkout","-b",r,a],Z,[r,a]);else throw new Error(`Branch ${r} does not exist in repo ${l} and no base commit was provided.`)}finally{await this.cleanGitConfig(h,!0,!0)}await this.setGitConfig(e,Z,!1)}async commitChanges(e,l,n,r,I=!1,a=!1){process.env.HOME||(process.env.HOME=xAt());let s={cwd:n,silent:!0},o=YAt(e);if(o){let b=`Co-authored-by: ${o.login} <${o.id}+${o.login}@users.noreply.github.com>`;r=r.trim()+`
|
|
@@ -1979,7 +1979,7 @@ ${I}`;await r.createOrUpdateMCPStartupToolCall({serverName:e,content:s}),this.lo
|
|
|
1979
1979
|
`)),s}}import{homedir as NDt}from"node:os";import jFn,{resolve as KFn}from"node:path";c();function WVn(t){return t.length>0&&/^[0-9a-zA-Z_-]+$/.test(t)}function $Mt(t){return!t||t.length===0?{valid:!1,error:"MCP server name cannot be empty"}:/^[0-9a-zA-Z_-]+$/.test(t)?{valid:!0}:{valid:!1,error:"MCP server name must only contain alphanumeric characters, underscores, and hyphens"}}var qMt=zg(["none","markdown","hidden_characters"]),e_t=_l({tools:xd(Et()),type:Et().optional(),isDefaultServer:bo().optional(),filterMapping:B2(Et(),qMt).or(qMt).optional()}),yVn=e_t.extend({type:gr("local").optional(),command:Et(),args:xd(Et()),env:B2(Et(),Et()).optional()}),EVn=e_t.extend({type:gr("http").or(gr("sse")),url:Et(),headers:B2(Et(),Et()).optional()}),R8e=_l({mcpServers:B2(Et().min(1,"MCP server name cannot be empty").refine(WVn,{message:"MCP server name must only contain alphanumeric characters, underscores, and hyphens"}),yVn.or(EVn))}),P2=CVe(R8e.parse,"mcp");c();c();function t_t(t){let e=t.r/255,l=t.g/255,n=t.b/255,r=Math.max(e,l,n),I=Math.min(e,l,n),a=r-I,s=0,o=0,d=(r+I)/2;if(a!==0){switch(o=d>.5?a/(2-r-I):a/(r+I),r){case e:s=(l-n)/a+(l<n?6:0);break;case l:s=(n-e)/a+2;break;case n:s=(e-l)/a+4;break}s/=6}return{h:s*360,s:o,l:d}}function RVn(t){if(t.length<12||t.length>18)return null;let e=t.match(/rgb:([0-9a-f]+)\/([0-9a-f]+)\/([0-9a-f]+)/i);if(!e)return null;let[,l,n,r]=e,I=d=>d.length>=2?parseInt(d.substring(0,2),16):d.length===1?parseInt(d+d,16):0,a=I(l),s=I(n),o=I(r);return{r:a,g:s,b:o}}var l_t=["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff","#000000","#00005f","#000087","#0000af","#0000d7","#0000ff","#005f00","#005f5f","#005f87","#005faf","#005fd7","#005fff","#008700","#00875f","#008787","#0087af","#0087d7","#0087ff","#00af00","#00af5f","#00af87","#00afaf","#00afd7","#00afff","#00d700","#00d75f","#00d787","#00d7af","#00d7d7","#00d7ff","#00ff00","#00ff5f","#00ff87","#00ffaf","#00ffd7","#00ffff","#5f0000","#5f005f","#5f0087","#5f00af","#5f00d7","#5f00ff","#5f5f00","#5f5f5f","#5f5f87","#5f5faf","#5f5fd7","#5f5fff","#5f8700","#5f875f","#5f8787","#5f87af","#5f87d7","#5f87ff","#5faf00","#5faf5f","#5faf87","#5fafaf","#5fafd7","#5fafff","#5fd700","#5fd75f","#5fd787","#5fd7af","#5fd7d7","#5fd7ff","#5fff00","#5fff5f","#5fff87","#5fffaf","#5fffd7","#5fffff","#870000","#87005f","#870087","#8700af","#8700d7","#8700ff","#875f00","#875f5f","#875f87","#875faf","#875fd7","#875fff","#878700","#87875f","#878787","#8787af","#8787d7","#8787ff","#87af00","#87af5f","#87af87","#87afaf","#87afd7","#87afff","#87d700","#87d75f","#87d787","#87d7af","#87d7d7","#87d7ff","#87ff00","#87ff5f","#87ff87","#87ffaf","#87ffd7","#87ffff","#af0000","#af005f","#af0087","#af00af","#af00d7","#af00ff","#af5f00","#af5f5f","#af5f87","#af5faf","#af5fd7","#af5fff","#af8700","#af875f","#af8787","#af87af","#af87d7","#af87ff","#afaf00","#afaf5f","#afaf87","#afafaf","#afafd7","#afafff","#afd700","#afd75f","#afd787","#afd7af","#afd7d7","#afd7ff","#afff00","#afff5f","#afff87","#afffaf","#afffd7","#afffff","#d70000","#d7005f","#d70087","#d700af","#d700d7","#d700ff","#d75f00","#d75f5f","#d75f87","#d75faf","#d75fd7","#d75fff","#d78700","#d7875f","#d78787","#d787af","#d787d7","#d787ff","#d7af00","#d7af5f","#d7af87","#d7afaf","#d7afd7","#d7afff","#d7d700","#d7d75f","#d7d787","#d7d7af","#d7d7d7","#d7d7ff","#d7ff00","#d7ff5f","#d7ff87","#d7ffaf","#d7ffd7","#d7ffff","#ff0000","#ff005f","#ff0087","#ff00af","#ff00d7","#ff00ff","#ff5f00","#ff5f5f","#ff5f87","#ff5faf","#ff5fd7","#ff5fff","#ff8700","#ff875f","#ff8787","#ff87af","#ff87d7","#ff87ff","#ffaf00","#ffaf5f","#ffaf87","#ffafaf","#ffafd7","#ffafff","#ffd700","#ffd75f","#ffd787","#ffd7af","#ffd7d7","#ffd7ff","#ffff00","#ffff5f","#ffff87","#ffffaf","#ffffd7","#ffffff","#080808","#121212","#1c1c1c","#262626","#303030","#3a3a3a","#444444","#4e4e4e","#585858","#626262","#6c6c6c","#767676","#808080","#8a8a8a","#949494","#9e9e9e","#a8a8a8","#b2b2b2","#bcbcbc","#c6c6c6","#d0d0d0","#dadada","#e4e4e4","#eeeeee"];function YVn(t){let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:{r:0,g:0,b:0}}function VVn(t){return t<0||t>=l_t.length?{r:0,g:0,b:0}:YVn(l_t[t])}function n_t(t){if(t.length<15||t.length>30)return null;let e=t;e.endsWith("\x07")?e=e.slice(0,-1):e.endsWith("\x1B\\")?e=e.slice(0,-2):e.endsWith("\x9C")&&(e=e.slice(0,-1));let l=e;return l.startsWith("11;")&&(l=l.substring(3)),l.startsWith("rgb:")?RVn(l):null}async function wVn(t=100){return new Promise(e=>{if(!process.stdout.isTTY||!process.stdin.isTTY){e(null);return}let l="",n=null,r=()=>{process.stdin.removeListener("data",I),process.stdin.setRawMode(!1),n&&clearTimeout(n)},I=a=>{l+=a.toString();let s=l.match(/\x1b\]11;([^\x07\x1b\x9c]*?)(?:\x07|\x1b\\|\x9c)/);if(s){r();let d=`11;${s[1]}`;e(n_t(d));return}let o=l.match(/11;rgb:([0-9a-f/]+)(?:\x07|\x1b\\|\x9c)/i);if(o){r(),e(n_t(`11;rgb:${o[1]}`));return}};n=setTimeout(()=>{r(),e(null)},t);try{process.stdin.setRawMode(!0),process.stdin.on("data",I),process.stdout.write("\x1B]11;?\x1B\\")}catch{r(),e(null)}})}function QVn(){let t=process.env.COLORFGBG;if(!t||!t.includes(";"))return null;let e=t.split(";"),l=e[e.length-1],n=parseInt(l,10);return isNaN(n)?null:VVn(n)}async function r_t(){try{let t=await wVn();if(t)return t_t(t).l<.5;let e=QVn();return e?t_t(e).l<.5:!0}catch{return!0}}var I_t={FG:"whiteBright",ACCENT:"blue",SUCCESS:"green",DIFF_ADDED_HIGHLIGHT_FG:"black",DIFF_REMOVED_HIGHLIGHT_FG:"whiteBright",ERROR:"red",WARNING:"yellow",COPILOT:"magenta",COPILOT_BRIGHT:"magentaBright",MUTED:"white",SELECTED:"cyan",BORDER:"blackBright"},FVn={FG:"black",ACCENT:"blue",SUCCESS:"green",DIFF_ADDED_HIGHLIGHT_FG:"black",DIFF_REMOVED_HIGHLIGHT_FG:"whiteBright",ERROR:"red",WARNING:"yellow",COPILOT:"magenta",COPILOT_BRIGHT:"magentaBright",MUTED:"blackBright",SELECTED:"cyan",BORDER:"blackBright"};function Y8e(t){return t==="auto"||t==="dark"||t==="light"}function JVe(t){switch(t){case"dark":return I_t;case"light":return FVn;default:return I_t}}var xVe=await r_t();async function SVe(){let e=(await Lr.load())?.theme||"";return Y8e(e)?e:"auto"}async function a_t(t){await Lr.writeKey("theme",t)}var s_t=t=>{let e=t?Jl.whiteBright:Jl.black,l=t?Jl.cyanBright:Jl.blueBright,n=t?Jl.magentaBright:Jl.magenta;return{text:e,paragraph:e,html:e,table:e,blockquote:e,heading:Jl.bold,firstHeading:Jl.whiteBright.bold,strong:Jl.bold,em:Jl.italic,del:Jl.strikethrough,hr:Jl.white,link:l,href:l,image:(r,I,a)=>n(a?`Image: ${a} \u2192 ${r}`:`Image: ${r}`),codespan:Jl.cyan,code:Jl.cyan,list:(r,I,a)=>{let s=r.replace(/^(\s*)\* /gm,"$1- ");return a&&(s=s.split(`
|
|
1980
1980
|
`).map(u=>u.startsWith(a)?u.slice(a.length):u).join(`
|
|
1981
1981
|
`)),s.trimEnd()},listitem:r=>e(r.trimEnd()),reflowText:!0,showSectionPrefix:!1,unescape:!0,emoji:!0,tab:2,tableOptions:{style:{compact:!1}}}},CVn=s_t(!0),vVn=s_t(!1);function o_t(t){return t==="light"?vVn:CVn}c();import{exec as DFn}from"node:child_process";import*as q8e from"node:os";import{promisify as zFn}from"node:util";c();c();c();import{execFile as fVn}from"node:child_process";import{normalize as HVn}from"node:path";import{promisify as XVn}from"node:util";var due=XVn(fVn);async function If(t=process.cwd()){try{let l=(await due("git",["rev-parse","--show-toplevel"],{cwd:t,encoding:"utf8",timeout:5e3,maxBuffer:1048576})).stdout.trim();if(l)return{gitRoot:HVn(l),found:!0}}catch{}return{gitRoot:t,found:!1}}async function i_t(t){let{stdout:e}=await due("git",["-C",t,"remote","-v"],{encoding:"utf8",timeout:5e3,maxBuffer:1048576}),l=e.trim().split(`
|
|
1982
|
-
`),n={};for(let r of l){let I=r.split(/\s+/);if(I.length>=3){let a=I[0],s=I[1],o=I[2].replace(/[()]/g,"");n[a]||(n[a]={Name:a,FetchURL:"",PushURL:""}),o==="fetch"?n[a].FetchURL=s:o==="push"&&(n[a].PushURL=s)}}return Object.values(n)}async function c_t(t){try{let{stdout:e}=await due("git",["status","--porcelain"],{cwd:t,encoding:"utf8",timeout:5e3,maxBuffer:1048576});return e.trim().length>0}catch{return!1}}async function d_t(t){try{let{stdout:e}=await due("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:t,encoding:"utf8",timeout:5e3,maxBuffer:1048576}),l=e.trim();if(l==="HEAD"){let{stdout:n}=await due("git",["rev-parse","--short","HEAD"],{cwd:t,encoding:"utf8",timeout:5e3,maxBuffer:1048576}),r=n.trim();return r?`detached@${r}`:null}return l||null}catch{return null}}c();var B_t=nt(S_t(),1);async function wQn(t={}){let e=await bAt();return hAt((0,B_t.default)({},e,t))}async function PVe(t={}){if(F_())throw new Error("Settings have already been initialized");return wQn(t)}c();c();c();import{promises as QQn}from"fs";import O_t from"path";var FQn=3*1024*1024;function T_t(t){let e=O_t.extname(t).toLowerCase();return[".png",".jpg",".jpeg",".gif",".webp"].includes(e)}function CQn(t){switch(O_t.extname(t).toLowerCase()){case".png":return"image/png";case".jpg":case".jpeg":return"image/jpeg";case".gif":return"image/gif";case".webp":return"image/webp";default:return null}}async function vQn(t,e){e.debug(`Processing local image file: ${t}`);let l=await QQn.readFile(t),n=CQn(t);if(!n)throw new Error(`Unsupported image format: ${t}`);let r=new ese,I=await zye(e,r,FQn,Kae,n,l);if(!I)throw new Error(`Image too large or couldn't be processed: ${t}`);let a=I.toString("base64");return`data:${n};base64,${a}`}async function fQn(t,e){let l=Bu();try{let n=await oSe({command:"view",path:t,view_range:void 0},{properties:{command:"view",resolvedPathAgainstCwd:"false",options:"{}",inputs:"[]"},metrics:{responseTokenLimit:void 0,resultLength:0,resultForLlmLength:0},restrictedProperties:{}},e);return{id:l,name:"view",arguments:{path:t},result:n.textResultForLlm||""}}catch(n){return{id:l,name:"view",arguments:{path:t},result:`Error reading ${t}: ${n}`}}}async function U_t(t,e){let l=[],n=t.filter(I=>!T_t(I.path));if(n.length===0)return l;let r=[];for(let I of n)try{let a=await fQn(I.path,e);r.push(a)}catch{}if(r.length>0){let I=r.map(a=>({id:a.id,type:"function",function:{name:a.name,arguments:JSON.stringify(a.arguments)}}));l.push({role:"assistant",content:"I need to read the content of those paths to answer this request.",tool_calls:I}),l.push(...r.map(a=>({role:"tool",tool_call_id:a.id,content:a.result})))}return l}async function M_t(t,e){let l=t.filter(r=>T_t(r.path));return(await Promise.all(l.map(async r=>{try{return{type:"image_url",image_url:{url:await vQn(r.path,e)}}}catch(I){e.error(`Failed to process image ${r.path}: ${I instanceof Error?I.message:String(I)}`);return}}))).filter(r=>r!==void 0)}var of=class{sessionId;startTime;modifiedTime;events=[];_chatMessages=[];_selectedModel;logger;eventCallbacks=[];eventProcessingQueue=Promise.resolve();constructor({sessionId:e,startTime:l,modifiedTime:n,logger:r}={}){this.sessionId=e||Bu(),this.startTime=l||new Date,this.modifiedTime=n||this.startTime,this.logger=r||new Hc}get messageCount(){let e=this.events.find(n=>n.type==="session.import_legacy"),l=0;return e&&(l=(e.data.legacySession?.chatMessages||[]).filter(I=>I.role==="user"||I.role==="assistant").length),this.logger.debug(`Imported message count: ${l}`),this.events.filter(n=>n.type==="user.message"||n.type==="assistant.message").length+l}get summary(){let e=this.events.find(I=>I.type==="session.import_legacy"||I.type==="user.message"),l;if(e?.type==="session.import_legacy"){let I=e.data.legacySession.chatMessages.find(a=>a.role==="user");I?.content&&(typeof I.content=="string"?l=I.content:l=I.content.find(a=>a.type==="text")?.text)}else e?.type==="user.message"&&(l=e.data.content);if(!l)return;let n=l.lastIndexOf("<reminder>");n!==-1&&(l=l.substring(0,n).trim());let r=l.replace(/\s+/g," ").trim();return r.length>75&&(r=r.substring(0,55).trim()+"..."),r=r.split("").filter(I=>{let a=I.charCodeAt(0);return a>=32&&a!==127}).join(""),r}static async fromEvents({events:e,logger:l}){if(e.length===0)throw new Error("Cannot create session from empty events array");let n=e[0];if(n.type!=="session.start")throw new Error("First event must be session.start");let r=new this({sessionId:n.data.sessionId,startTime:new Date(n.data.startTime),logger:l||new Hc});r._selectedModel=n.data.selectedModel,r.events.push(n);for(let I=1;I<e.length;I++){let a=e[I];r.events.push(a),await r.processEventForState(a)}return r}addEvent(e){let l=e.id||Bu(),n=e.timestamp||new Date().toISOString(),r=e.parentId!==void 0?e.parentId:this.getLastEventId(),I={...e,id:l,timestamp:n,parentId:r};return this.events.push(I),this.enqueueEventProcessing(()=>this.processEventForState(I).catch(a=>{this.logger.error(`Error processing event ${I.type} (${I.id}): ${a instanceof Error?a.message:String(a)}`)})).catch(a=>{this.logger.error(`Error processing event queue ${a instanceof Error?a.message:String(a)}`)}),this.notifyEventCallbacks(I),I}getEvents(){return this.events}onEvent(e){return this.eventCallbacks.push(e),()=>{let l=this.eventCallbacks.indexOf(e);l>-1&&this.eventCallbacks.splice(l,1)}}async getChatMessages(){return this.enqueueEventProcessing(()=>this._chatMessages)}async getChatContextMessages(){return(await this.getChatMessages()).filter(l=>l.role!=="system")}async getSystemContextMessages(){return(await this.getChatMessages()).filter(l=>l.role==="system")}async getSelectedModel(){return this.enqueueEventProcessing(()=>this._selectedModel)}setSelectedModel(e){let l=this._selectedModel;this._selectedModel=e,this.addEvent({type:"session.model_change",data:{previousModel:l,newModel:e}})}getLastEventId(){return this.events.length===0?null:this.events[this.events.length-1].id}enqueueEventProcessing(e){let l=this.eventProcessingQueue.then(()=>e());return this.eventProcessingQueue=l,l}async processEventForState(e){switch(e.type){case"session.start":e.data.selectedModel&&(this._selectedModel=e.data.selectedModel);break;case"session.model_change":this._selectedModel=e.data.newModel;break;case"user.message":{let l=[],n=[];if(e.data.attachments&&e.data.attachments.length>0){let r=await M_t(e.data.attachments,this.logger);l.push(...r);let I=await U_t(e.data.attachments,this.logger);n.push(...I)}l.length>0?this._chatMessages.push({role:"user",content:[{type:"text",text:e.data.content},...l]}):this._chatMessages.push({role:"user",content:e.data.content}),n.length>0&&this._chatMessages.push(...n);break}case"assistant.message":{let l={role:"assistant",content:e.data.content||null};e.data.toolRequests&&e.data.toolRequests.length>0&&(l.tool_calls=e.data.toolRequests.map(n=>({id:n.toolCallId,type:"function",function:{name:n.name,arguments:typeof n.arguments=="string"?n.arguments:JSON.stringify(n.arguments)}}))),this._chatMessages.push(l);break}case"tool.execution_complete":{e.data.isUserRequested||this._chatMessages.push({role:"tool",tool_call_id:e.data.toolCallId,content:e.data.success?e.data.result?.content||"":e.data.error?.message||"Tool execution failed"});break}case"system.message":this._chatMessages.push({role:e.data.role,content:e.data.content,...e.data.name&&{name:e.data.name}});break;case"session.import_legacy":this._chatMessages=[...e.data.legacySession.chatMessages],e.data.legacySession.selectedModel&&(this._selectedModel=e.data.legacySession.selectedModel);break;case"abort":case"session.resume":this._chatMessages=HQn(this._chatMessages,this.logger);break;case"session.error":case"session.info":case"assistant.turn_start":case"assistant.turn_end":case"assistant.usage":case"tool.user_requested":case"tool.execution_start":case"tool.execution_partial_result":case"hook.start":case"hook.end":break;default:{let l=e;this.logger.error(`Unknown event type: ${l.type}`);break}}}notifyEventCallbacks(e){for(let l of this.eventCallbacks)try{l(e)}catch(n){this.logger.error(`Error in event callback: ${n instanceof Error?n.message:String(n)}`)}}};function HQn(t,e){if(t.length===0)return t;let l=[],n=new Set,r=!1;for(let s=t.length-1;s>=0;s--){let o=t[s];if(o.role==="assistant"&&(r=!0),o.role==="assistant"&&"tool_calls"in o&&o.tool_calls&&o.tool_calls.length>0)for(let d of o.tool_calls)n.has(d.id)||l.push(d.id);else{if(r)break;o.role==="tool"&&o.tool_call_id&&n.add(o.tool_call_id)}}if(l.length===0)return t;let I="The execution of this tool, or a previous tool was interrupted.";e.info(`Completing ${l.length} orphaned tool calls.`);let a=l.map(s=>({role:"tool",tool_call_id:s,content:I}));return[...t,...a]}c();c();import{unlink as K_t}from"fs/promises";import{join as CFn}from"path";c();var jVe=class{sessions;logger;lastAccessedSessionId;constructor({logger:e}={}){this.sessions=new Map,this.logger=e||new Hc}async createSession(){let e=new of({logger:this.logger});return this.sessions.set(e.sessionId,e),this.lastAccessedSessionId=e.sessionId,e}async getSession(e){let l=this.sessions.get(e);return l&&(this.lastAccessedSessionId=e),l}async getLastSession(){if(this.lastAccessedSessionId){let n=this.sessions.get(this.lastAccessedSessionId);if(n)return n}let e=Array.from(this.sessions.values());if(e.length===0)return;e.sort((n,r)=>r.startTime.getTime()-n.startTime.getTime());let l=e[0];return this.lastAccessedSessionId=l.sessionId,l}async listSessions(){return Array.from(this.sessions.values()).map(e=>({sessionId:e.sessionId,startTime:e.startTime,modifiedTime:e.modifiedTime}))}async saveSession(e){}async deleteSession(e){this.sessions.delete(e.sessionId),this.lastAccessedSessionId===e.sessionId&&(this.lastAccessedSessionId=void 0)}};c();c();var XQn=_l({type:gr("copilot"),text:Et(),isStreaming:bo().optional()}),kQn=_l({type:gr("error"),text:Et()}),LQn=_l({type:gr("info"),text:Et()}),L0a=_l({displayText:Et(),fullPath:Et(),type:zg(["file","directory","unresolved","image"]),startIndex:FG()}),JQn=_l({type:gr("user"),text:Et()}),S8=_l({command:Et(),description:Et(),timeout:FG().optional(),sessionId:Et().optional(),async:bo().optional()}),L8e=_l({sessionId:Et(),input:Et(),delay:FG().optional()}),J8e=_l({sessionId:Et(),delay:FG()}),x8e=_l({sessionId:Et()}),__t=Hh([S8,L8e,J8e,x8e]),xQn=_l({command:gr("view"),path:Et(),view_range:KYe([FG(),FG()]).optional()}),SQn=_l({command:gr("create"),path:Et(),file_text:Et()}),BQn=_l({command:gr("str_replace"),path:Et(),new_str:Et().optional(),old_str:Et()}),OQn=_l({command:gr("insert"),path:Et(),insert_line:FG(),new_str:Et()}),S8e=ede("command",[xQn,SQn,BQn,OQn]),B8e=_l({path:Et(),view_range:KYe([FG(),FG()]).optional()}),O8e=_l({path:Et(),file_text:Et()}),T8e=_l({path:Et(),old_str:Et(),new_str:Et().optional()}),D_t=Hh([__t,S8e,Ww()]),TQn=_l({type:gr("tool_call_requested"),callId:Et(),name:Et(),toolTitle:Et().optional(),intentionSummary:Et().nullable(),arguments:D_t,partialOutput:Et().optional(),isHidden:bo().optional(),isAlwaysExpanded:bo().optional(),showNoContent:bo().optional()}),UQn=_l({type:gr("tool_call_completed"),callId:Et(),name:Et(),toolTitle:Et().optional(),intentionSummary:Et().nullable(),result:Hh([_l({type:gr("success"),log:Et(),markdown:bo().optional()}),_l({type:gr("failure"),log:Et(),markdown:bo().optional()}),_l({type:gr("rejected"),markdown:bo().optional()}),_l({type:gr("denied"),log:Et(),markdown:bo().optional()})]),arguments:D_t,isHidden:bo().optional(),isAlwaysExpanded:bo().optional(),showNoContent:bo().optional()}),MQn=Hh([XQn,kQn,LQn,JQn,TQn,UQn]),z_t=MQn.and(_l({id:Et(),timestamp:tde.date()}));function P_t(t,e){switch(t.type){case"copilot":return e.onCopilot(t);case"error":return e.onError(t);case"info":return e.onInfo(t);case"tool_call_requested":return e.onToolCallRequested(t);case"tool_call_completed":return e.onToolCallCompleted(t);case"user":return e.onUser(t);default:{let l=t;throw new Error(`Unexpected message type: ${JSON.stringify(t)}`)}}}var CO=class t extends Error{prUrl;timeoutContext;constructor(e,l,n){super(e),this.name="JobStatusTimeoutError",this.timeoutContext=l,this.prUrl=n,Error.captureStackTrace&&Error.captureStackTrace(this,t)}};var hue=_l({type:gr("text"),text:Et()}),_Qn=_l({type:gr("refusal"),refusal:Et()}),DQn=_l({type:gr("image_url"),image_url:_l({url:Et(),detail:zg(["auto","low","high"]).optional()})}),zQn=_l({type:gr("input_audio"),input_audio:_l({data:Et(),format:gr("wav").or(gr("mp3"))})}),PQn=_l({type:gr("file"),file:_l({file_date:Et().optional(),file_id:Et().optional(),filename:Et().optional()})}),jQn=Hh([hue,DQn,zQn,PQn]),KQn=_l({name:Et(),arguments:Et()}),qQn=_l({name:Et(),input:Et()}),$Qn=_l({id:Et(),type:gr("function"),function:KQn}),eFn=_l({id:Et(),type:gr("custom"),custom:qQn}),tFn=Hh([$Qn,eFn]),lFn=_l({name:Et(),arguments:Et()}),nFn=_l({id:Et()}),rFn=_l({content:Hh([Et(),xd(hue)]),role:gr("developer"),name:Et().optional()}),IFn=_l({content:Hh([Et(),xd(hue)]),role:gr("system"),name:Et().optional()}),aFn=_l({content:Hh([Et(),xd(jQn)]),role:gr("user"),name:Et().optional()}),sFn=_l({content:Hh([Et(),xd(Hh([hue,_Qn]))]).nullable().optional(),role:gr("assistant"),name:Et().optional(),refusal:Et().nullable().optional(),audio:nFn.nullable().optional(),function_call:lFn.nullable().optional(),tool_calls:xd(tFn).optional()}),oFn=_l({content:Hh([Et(),xd(hue)]),role:gr("tool"),tool_call_id:Et()}),iFn=_l({content:Et().nullable(),role:gr("function"),name:Et()}),cFn=Hh([rFn,IFn,aFn,sFn,oFn,iFn]),U8e=_l({sessionId:Et(),startTime:tde.date(),chatMessages:xd(cFn),timeline:xd(z_t),selectedModel:zg(RO).optional()}),Aue=vVe(U8e.parse,"history-session");c();c();var Vb=_l({id:Et().uuid(),timestamp:Et().datetime(),parentId:Et().uuid().nullable(),ephemeral:bo().optional()}),dFn=Vb.extend({type:gr("session.start"),data:_l({sessionId:Et(),version:FG(),producer:Et(),copilotVersion:Et(),startTime:Et().datetime(),selectedModel:Et().optional()})}),uFn=Vb.extend({type:gr("session.resume"),data:_l({resumeTime:Et().datetime(),eventCount:FG()})}),mFn=Vb.extend({type:gr("session.error"),data:_l({errorType:Et(),message:Et(),stack:Et().optional()})}),bFn=Vb.extend({type:gr("session.info"),data:_l({infoType:Et(),message:Et()})}),GFn=Vb.extend({type:gr("session.model_change"),data:_l({previousModel:Et().optional(),newModel:Et()})}),pFn=Vb.extend({type:gr("session.import_legacy"),data:_l({legacySession:U8e,importTime:Et().datetime(),sourceFile:Et()})}),hFn=_l({type:zg(["file","directory"]),path:Et(),displayName:Et()}),AFn=Vb.extend({type:gr("user.message"),data:_l({content:Et(),attachments:xd(hFn).optional()})}),ZFn=Vb.extend({type:gr("assistant.turn_start"),data:_l({turnId:Et()})}),gFn=Vb.extend({type:gr("assistant.message"),data:_l({messageId:Et(),content:Et(),toolRequests:xd(_l({toolCallId:Et(),name:Et(),arguments:Ww()})).optional()})}),NFn=Vb.extend({type:gr("assistant.turn_end"),data:_l({turnId:Et()})}),WFn=Vb.extend({type:gr("assistant.usage"),ephemeral:gr(!0),data:_l({model:Et().optional(),tokensUsed:FG().optional(),cost:FG().optional(),duration:FG().optional(),initiator:Et().optional()})}),yFn=Vb.extend({type:gr("abort"),data:_l({reason:Et()})}),EFn=Vb.extend({type:gr("tool.user_requested"),data:_l({toolCallId:Et(),toolName:Et(),arguments:Ww()})}),RFn=Vb.extend({type:gr("tool.execution_start"),data:_l({toolCallId:Et(),toolName:Et(),arguments:Ww()})}),YFn=Vb.extend({type:gr("tool.execution_partial_result"),ephemeral:gr(!0),data:_l({toolCallId:Et(),partialOutput:Et()})}),VFn=Vb.extend({type:gr("tool.execution_complete"),data:_l({toolCallId:Et(),success:bo(),isUserRequested:bo().optional(),result:_l({content:Et()}).optional(),error:_l({message:Et(),code:Et().optional()}).optional()})}),wFn=Vb.extend({type:gr("hook.start"),data:_l({hookInvocationId:Et(),hookType:Et(),input:Ww()})}),QFn=Vb.extend({type:gr("hook.end"),data:_l({hookInvocationId:Et(),hookType:Et(),output:Ww(),success:bo(),error:_l({message:Et(),stack:Et().optional()}).optional()})}),FFn=Vb.extend({type:gr("system.message"),data:_l({content:Et(),role:zg(["system","developer"]),name:Et().optional(),metadata:_l({promptVersion:Et().optional(),variables:B2(Ww()).optional()}).optional()})}),j_t=ede("type",[dFn,uFn,mFn,bFn,GFn,pFn,AFn,ZFn,gFn,NFn,WFn,yFn,EFn,RFn,YFn,VFn,wFn,QFn,FFn]);var vO=HMt(j_t.parse,"session");var KVe=class{constructor(e,l,n,r=!1,I){this.session=e;this.logger=l;this.flushDebounceMs=n;this.shouldSaveSession=r;this.legacySourceFile=I;this.unsubscribe=this.session.onEvent(a=>{a.ephemeral||(this.unflushedEvents.push(a),!this.shouldSaveSession&&a.type==="user.message"&&(this.shouldSaveSession=!0),this.shouldSaveSession&&(this.flushTimer&&clearTimeout(this.flushTimer),this.flushTimer=setTimeout(()=>{this.flush().catch(s=>{this.logger.error(`Error flushing session ${this.session.sessionId}: ${s instanceof Error?s.message:String(s)}`)})},this.flushDebounceMs)))})}flushTimer=null;unflushedEvents=[];migratedLegacy=!1;isFlushing=!1;needsFlushAfterCurrent=!1;unsubscribe;dispose(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null),this.unsubscribe()}async flush(){if(!this.shouldSaveSession||this.unflushedEvents.length===0)return;if(this.isFlushing){this.needsFlushAfterCurrent=!0;return}this.isFlushing=!0,this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null);let e=this.unflushedEvents;this.unflushedEvents=[];try{if(await vO.append(e,this.session.sessionId),this.logger.debug(`Flushed ${e.length} events to session ${this.session.sessionId}`),this.legacySourceFile&&!this.migratedLegacy){this.logger.debug(`Migrated legacy session ${this.session.sessionId} from ${this.legacySourceFile}`);try{await K_t(this.legacySourceFile)}catch(l){this.logger.error(`Failed to delete legacy session file ${this.legacySourceFile}: ${l}`)}this.migratedLegacy=!0}}catch(l){this.logger.error(`Failed to flush events for ${this.session.sessionId}: ${l instanceof Error?l.message:String(l)}`),this.unflushedEvents.unshift(...e)}finally{this.isFlushing=!1,this.needsFlushAfterCurrent&&(this.needsFlushAfterCurrent=!1,await this.flush())}}},qVe=class extends jVe{sessionWriters={};copilotVersion;flushDebounceMs;constructor({logger:e,version:l,flushDebounceMs:n}){super({logger:e}),this.copilotVersion=l||"unknown",this.flushDebounceMs=n||100}async createSession(e){let l=e?.sessionId??Bu(),n=new Date,r=new of({sessionId:l,startTime:n,logger:this.logger});return this.sessionWriters[l]=new KVe(r,this.logger,this.flushDebounceMs),r.addEvent({type:"session.start",data:{sessionId:l,version:1,producer:"copilot-agent",copilotVersion:this.copilotVersion,startTime:n.toISOString(),selectedModel:e?.selectedModel}}),r}async getSession(e){let l,n;try{l=await this.loadSession(e)}catch{try{let r=await this.loadLegacySession(e);l=r.session,n=r.legacySourceFile}catch{return}}return this.sessionWriters[e]||(this.sessionWriters[e]=new KVe(l,this.logger,this.flushDebounceMs,!0,n)),l.addEvent({type:"session.resume",data:{resumeTime:new Date().toISOString(),eventCount:l.getEvents().length}}),l}async saveSession(e){await this.sessionWriters[e.sessionId]?.flush()}async loadSession(e){let l=await vO.load(e);if(l.length===0)throw new Error(`Session ${e} has no events`);if(l[0].type!=="session.start")throw new Error("First event must be a session.start event");return await of.fromEvents({events:l,logger:this.logger})}async loadLegacySession(e){let n=(await Aue.directoryFiles()).filter(o=>{let d=o.match(/^session_(.+)_(\d+)\.json$/);return d&&d[1]===e});if(n.length===0)throw new Error(`Legacy session ${e} not found`);let r=n[0];n.length>1&&this.logger.info(`Multiple legacy sessions found for ${e}, using newest`);let I=await Aue.load(r);if(!I)throw new Error(`Failed to load legacy session from ${r}`);let a=new Date(I.startTime),s=new of({sessionId:I.sessionId,startTime:a,logger:this.logger});return s.addEvent({type:"session.start",data:{sessionId:I.sessionId,version:1,producer:"copilot-agent",copilotVersion:this.copilotVersion,startTime:a.toISOString(),selectedModel:I.selectedModel}}),s.addEvent({type:"session.import_legacy",data:{legacySession:{sessionId:I.sessionId,startTime:a,chatMessages:I.chatMessages,timeline:I.timeline,selectedModel:I.selectedModel},importTime:new Date().toISOString(),sourceFile:r}}),this.logger.info(`Loaded legacy session ${e} from ${r}`),{session:s,legacySourceFile:Aue.path(r.replace(/\.json$/,""))}}async listSessions(){let e=await vO.directoryFilesWithMetadata(),l=await Aue.directoryFilesWithMetadata(),n=await Promise.all(e.map(async a=>({sessionId:a.file.replace(".jsonl",""),startTime:a.ctime,modifiedTime:a.mtime}))),r=(await Promise.all(l.map(async a=>{let s=a.file.match(/^session_(.+)_(\d+)\.json$/);return s?{sessionId:s[1],startTime:a.ctime,modifiedTime:a.mtime}:null}))).filter(a=>a!==null);this.logger.debug(`Found ${n.length} JSONL sessions and ${r.length} legacy sessions`);let I=new Map;for(let a of r)I.set(a.sessionId,a);for(let a of n)I.set(a.sessionId,a);return Array.from(I.values()).sort((a,s)=>s.modifiedTime.getTime()-a.modifiedTime.getTime())}async getLastSession(){let e=await this.listSessions();if(e.length===0)return;e.sort((n,r)=>r.modifiedTime.getTime()-n.modifiedTime.getTime());let l=e[0].sessionId;return await this.getSession(l)}async deleteSession(e){this.sessionWriters[e.sessionId]?.dispose(),delete this.sessionWriters[e.sessionId];let l=vO.path(e.sessionId);this.logger.info(`Deleting session file ${l}`),await K_t(l)}getSessionsDirectory(){return CFn(vO.home(),vO.directory())}setLogger(e){this.logger=e}};c();c();c();c();function Sd(t){return t()}c();var Zue;function fFn(t,e){return t.includes("\x1B[?")&&t.includes(e)}async function HFn(t){let e=process.stdin.isRaw;e||process.stdin.setRawMode(!0);try{return await t()}finally{e||process.stdin.setRawMode(!1)}}function q_t(t,e,l){return new Promise(n=>{let r="",I,a=()=>{I=void 0,process.stdin.removeListener("data",s),n(!1)},s=o=>{I!==void 0&&(r+=o.toString(),fFn(r,e)&&(process.stdin.removeListener("data",s),clearTimeout(I),I=void 0,n(!0)))};process.stdin.on("data",s),process.stdout.write("\x1B["+t),I=setTimeout(a,l)})}async function XFn(){return!(!(process.stdin.isTTY&&process.stdout.isTTY)||!await q_t("?u","u",200)||!await q_t("c","c",1e3))}async function eDt(){Zue===void 0&&(Zue=await HFn(XFn),Zue===!0&&(kFn(),process.on("exit",$_t),process.on("SIGTERM",$_t)))}function kFn(){process.stdout.write("\x1B[>1u")}function $_t(){process.stdout.write("\x1B[<u"),Zue=void 0}function $Ve(){return Zue===!0}c();c();c();c();function Nue(t,e=!1){let l=t.length,n=0,r="",I=0,a=16,s=0,o=0,d=0,u=0,b=0;function p(H,J){let S=0,T=0;for(;S<H||!J;){let U=t.charCodeAt(n);if(U>=48&&U<=57)T=T*16+U-48;else if(U>=65&&U<=70)T=T*16+U-65+10;else if(U>=97&&U<=102)T=T*16+U-97+10;else break;n++,S++}return S<H&&(T=-1),T}function h(H){n=H,r="",I=0,a=16,b=0}function Z(){let H=n;if(t.charCodeAt(n)===48)n++;else for(n++;n<t.length&&B8(t.charCodeAt(n));)n++;if(n<t.length&&t.charCodeAt(n)===46)if(n++,n<t.length&&B8(t.charCodeAt(n)))for(n++;n<t.length&&B8(t.charCodeAt(n));)n++;else return b=3,t.substring(H,n);let J=n;if(n<t.length&&(t.charCodeAt(n)===69||t.charCodeAt(n)===101))if(n++,(n<t.length&&t.charCodeAt(n)===43||t.charCodeAt(n)===45)&&n++,n<t.length&&B8(t.charCodeAt(n))){for(n++;n<t.length&&B8(t.charCodeAt(n));)n++;J=n}else b=3;return t.substring(H,J)}function N(){let H="",J=n;for(;;){if(n>=l){H+=t.substring(J,n),b=2;break}let S=t.charCodeAt(n);if(S===34){H+=t.substring(J,n),n++;break}if(S===92){if(H+=t.substring(J,n),n++,n>=l){b=2;break}switch(t.charCodeAt(n++)){case 34:H+='"';break;case 92:H+="\\";break;case 47:H+="/";break;case 98:H+="\b";break;case 102:H+="\f";break;case 110:H+=`
|
|
1982
|
+
`),n={};for(let r of l){let I=r.split(/\s+/);if(I.length>=3){let a=I[0],s=I[1],o=I[2].replace(/[()]/g,"");n[a]||(n[a]={Name:a,FetchURL:"",PushURL:""}),o==="fetch"?n[a].FetchURL=s:o==="push"&&(n[a].PushURL=s)}}return Object.values(n)}async function c_t(t){try{let{stdout:e}=await due("git",["status","--porcelain"],{cwd:t,encoding:"utf8",timeout:5e3,maxBuffer:1048576});return e.trim().length>0}catch{return!1}}async function d_t(t){try{let{stdout:e}=await due("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:t,encoding:"utf8",timeout:5e3,maxBuffer:1048576}),l=e.trim();if(l==="HEAD"){let{stdout:n}=await due("git",["rev-parse","--short","HEAD"],{cwd:t,encoding:"utf8",timeout:5e3,maxBuffer:1048576}),r=n.trim();return r?`detached@${r}`:null}return l||null}catch{return null}}c();var B_t=nt(S_t(),1);async function wQn(t={}){let e=await bAt();return hAt((0,B_t.default)({},e,t))}async function PVe(t={}){if(F_())throw new Error("Settings have already been initialized");return wQn(t)}c();c();c();import{promises as QQn}from"fs";import O_t from"path";var FQn=3*1024*1024;function T_t(t){let e=O_t.extname(t).toLowerCase();return[".png",".jpg",".jpeg",".gif",".webp"].includes(e)}function CQn(t){switch(O_t.extname(t).toLowerCase()){case".png":return"image/png";case".jpg":case".jpeg":return"image/jpeg";case".gif":return"image/gif";case".webp":return"image/webp";default:return null}}async function vQn(t,e){e.debug(`Processing local image file: ${t}`);let l=await QQn.readFile(t),n=CQn(t);if(!n)throw new Error(`Unsupported image format: ${t}`);let r=new ese,I=await zye(e,r,FQn,Kae,n,l);if(!I)throw new Error(`Image too large or couldn't be processed: ${t}`);let a=I.toString("base64");return`data:${n};base64,${a}`}async function fQn(t,e){let l=Bu();try{let n=await oSe({command:"view",path:t,view_range:void 0},{properties:{command:"view",resolvedPathAgainstCwd:"false",options:"{}",inputs:"[]"},metrics:{responseTokenLimit:void 0,resultLength:0,resultForLlmLength:0},restrictedProperties:{}},e);return{id:l,name:"view",arguments:{path:t},result:n.textResultForLlm||""}}catch(n){return{id:l,name:"view",arguments:{path:t},result:`Error reading ${t}: ${n}`}}}async function U_t(t,e){let l=[],n=t.filter(I=>!T_t(I.path));if(n.length===0)return l;let r=[];for(let I of n)try{let a=await fQn(I.path,e);r.push(a)}catch{}if(r.length>0){let I=r.map(a=>({id:a.id,type:"function",function:{name:a.name,arguments:JSON.stringify(a.arguments)}}));l.push({role:"assistant",content:"I need to read the content of those paths to answer this request.",tool_calls:I}),l.push(...r.map(a=>({role:"tool",tool_call_id:a.id,content:a.result})))}return l}async function M_t(t,e){let l=t.filter(r=>T_t(r.path));return(await Promise.all(l.map(async r=>{try{return{type:"image_url",image_url:{url:await vQn(r.path,e)}}}catch(I){e.error(`Failed to process image ${r.path}: ${I instanceof Error?I.message:String(I)}`);return}}))).filter(r=>r!==void 0)}var of=class{sessionId;startTime;modifiedTime;events=[];_chatMessages=[];_selectedModel;logger;eventCallbacks=[];eventProcessingQueue=Promise.resolve();constructor({sessionId:e,startTime:l,modifiedTime:n,logger:r}={}){this.sessionId=e||Bu(),this.startTime=l||new Date,this.modifiedTime=n||this.startTime,this.logger=r||new Hc}get messageCount(){let e=this.events.find(n=>n.type==="session.import_legacy"),l=0;return e&&(l=(e.data.legacySession?.chatMessages||[]).filter(I=>I.role==="user"||I.role==="assistant").length),this.logger.debug(`Imported message count: ${l}`),this.events.filter(n=>n.type==="user.message"||n.type==="assistant.message").length+l}get summary(){let e=this.events.find(I=>I.type==="session.import_legacy"||I.type==="user.message"),l;if(e?.type==="session.import_legacy"){let I=e.data.legacySession.chatMessages.find(a=>a.role==="user");I?.content&&(typeof I.content=="string"?l=I.content:l=I.content.find(a=>a.type==="text")?.text)}else e?.type==="user.message"&&(l=e.data.content);if(!l)return;let n=l.lastIndexOf("<reminder>");n!==-1&&(l=l.substring(0,n).trim());let r=l.replace(/\s+/g," ").trim();return r.length>75&&(r=r.substring(0,55).trim()+"..."),r=r.split("").filter(I=>{let a=I.charCodeAt(0);return a>=32&&a!==127}).join(""),r}static async fromEvents({events:e,logger:l}){if(e.length===0)throw new Error("Cannot create session from empty events array");let n=e[0];if(n.type!=="session.start")throw new Error("First event must be session.start");let r=new this({sessionId:n.data.sessionId,startTime:new Date(n.data.startTime),logger:l||new Hc});r._selectedModel=n.data.selectedModel,r.events.push(n);for(let I=1;I<e.length;I++){let a=e[I];r.events.push(a),await r.processEventForState(a)}return r}addEvent(e){let l=e.id||Bu(),n=e.timestamp||new Date().toISOString(),r=e.parentId!==void 0?e.parentId:this.getLastEventId(),I={...e,id:l,timestamp:n,parentId:r};return this.events.push(I),this.enqueueEventProcessing(()=>this.processEventForState(I).catch(a=>{this.logger.error(`Error processing event ${I.type} (${I.id}): ${a instanceof Error?a.message:String(a)}`)})).catch(a=>{this.logger.error(`Error processing event queue ${a instanceof Error?a.message:String(a)}`)}),this.notifyEventCallbacks(I),I}getEvents(){return this.events}onEvent(e){return this.eventCallbacks.push(e),()=>{let l=this.eventCallbacks.indexOf(e);l>-1&&this.eventCallbacks.splice(l,1)}}async getChatMessages(){return this.enqueueEventProcessing(()=>this._chatMessages)}async getChatContextMessages(){return(await this.getChatMessages()).filter(l=>l.role!=="system")}async getSystemContextMessages(){return(await this.getChatMessages()).filter(l=>l.role==="system")}async getSelectedModel(){return this.enqueueEventProcessing(()=>this._selectedModel)}setSelectedModel(e){let l=this._selectedModel;this._selectedModel=e,this.addEvent({type:"session.model_change",data:{previousModel:l,newModel:e}})}getLastEventId(){return this.events.length===0?null:this.events[this.events.length-1].id}enqueueEventProcessing(e){let l=this.eventProcessingQueue.then(()=>e());return this.eventProcessingQueue=l,l}async processEventForState(e){switch(e.type){case"session.start":e.data.selectedModel&&(this._selectedModel=e.data.selectedModel);break;case"session.model_change":this._selectedModel=e.data.newModel;break;case"user.message":{let l=[],n=[];if(e.data.attachments&&e.data.attachments.length>0){let r=await M_t(e.data.attachments,this.logger);l.push(...r);let I=await U_t(e.data.attachments,this.logger);n.push(...I)}l.length>0?this._chatMessages.push({role:"user",content:[{type:"text",text:e.data.content},...l]}):this._chatMessages.push({role:"user",content:e.data.content}),n.length>0&&this._chatMessages.push(...n);break}case"assistant.message":{if(e.ephemeral)break;let l={role:"assistant",content:e.data.content||null};e.data.toolRequests&&e.data.toolRequests.length>0&&(l.tool_calls=e.data.toolRequests.map(n=>({id:n.toolCallId,type:"function",function:{name:n.name,arguments:typeof n.arguments=="string"?n.arguments:JSON.stringify(n.arguments)}}))),this._chatMessages.push(l);break}case"tool.execution_complete":{e.data.isUserRequested||this._chatMessages.push({role:"tool",tool_call_id:e.data.toolCallId,content:e.data.success?e.data.result?.content||"":e.data.error?.message||"Tool execution failed"});break}case"system.message":this._chatMessages.push({role:e.data.role,content:e.data.content,...e.data.name&&{name:e.data.name}});break;case"session.import_legacy":this._chatMessages=[...e.data.legacySession.chatMessages],e.data.legacySession.selectedModel&&(this._selectedModel=e.data.legacySession.selectedModel);break;case"abort":case"session.resume":this._chatMessages=HQn(this._chatMessages,this.logger);break;case"session.error":case"session.info":case"assistant.turn_start":case"assistant.turn_end":case"assistant.usage":case"tool.user_requested":case"tool.execution_start":case"tool.execution_partial_result":case"hook.start":case"hook.end":break;default:{let l=e;this.logger.error(`Unknown event type: ${l.type}`);break}}}notifyEventCallbacks(e){for(let l of this.eventCallbacks)try{l(e)}catch(n){this.logger.error(`Error in event callback: ${n instanceof Error?n.message:String(n)}`)}}};function HQn(t,e){if(t.length===0)return t;let l=[],n=new Set,r=!1;for(let s=t.length-1;s>=0;s--){let o=t[s];if(o.role==="assistant"&&(r=!0),o.role==="assistant"&&"tool_calls"in o&&o.tool_calls&&o.tool_calls.length>0)for(let d of o.tool_calls)n.has(d.id)||l.push(d.id);else{if(r)break;o.role==="tool"&&o.tool_call_id&&n.add(o.tool_call_id)}}if(l.length===0)return t;let I="The execution of this tool, or a previous tool was interrupted.";e.info(`Completing ${l.length} orphaned tool calls.`);let a=l.map(s=>({role:"tool",tool_call_id:s,content:I}));return[...t,...a]}c();c();import{unlink as K_t}from"fs/promises";import{join as CFn}from"path";c();var jVe=class{sessions;logger;lastAccessedSessionId;constructor({logger:e}={}){this.sessions=new Map,this.logger=e||new Hc}async createSession(){let e=new of({logger:this.logger});return this.sessions.set(e.sessionId,e),this.lastAccessedSessionId=e.sessionId,e}async getSession(e){let l=this.sessions.get(e);return l&&(this.lastAccessedSessionId=e),l}async getLastSession(){if(this.lastAccessedSessionId){let n=this.sessions.get(this.lastAccessedSessionId);if(n)return n}let e=Array.from(this.sessions.values());if(e.length===0)return;e.sort((n,r)=>r.startTime.getTime()-n.startTime.getTime());let l=e[0];return this.lastAccessedSessionId=l.sessionId,l}async listSessions(){return Array.from(this.sessions.values()).map(e=>({sessionId:e.sessionId,startTime:e.startTime,modifiedTime:e.modifiedTime}))}async saveSession(e){}async deleteSession(e){this.sessions.delete(e.sessionId),this.lastAccessedSessionId===e.sessionId&&(this.lastAccessedSessionId=void 0)}};c();c();var XQn=_l({type:gr("copilot"),text:Et(),isStreaming:bo().optional()}),kQn=_l({type:gr("error"),text:Et()}),LQn=_l({type:gr("info"),text:Et()}),L0a=_l({displayText:Et(),fullPath:Et(),type:zg(["file","directory","unresolved","image"]),startIndex:FG()}),JQn=_l({type:gr("user"),text:Et()}),S8=_l({command:Et(),description:Et(),timeout:FG().optional(),sessionId:Et().optional(),async:bo().optional()}),L8e=_l({sessionId:Et(),input:Et(),delay:FG().optional()}),J8e=_l({sessionId:Et(),delay:FG()}),x8e=_l({sessionId:Et()}),__t=Hh([S8,L8e,J8e,x8e]),xQn=_l({command:gr("view"),path:Et(),view_range:KYe([FG(),FG()]).optional()}),SQn=_l({command:gr("create"),path:Et(),file_text:Et()}),BQn=_l({command:gr("str_replace"),path:Et(),new_str:Et().optional(),old_str:Et()}),OQn=_l({command:gr("insert"),path:Et(),insert_line:FG(),new_str:Et()}),S8e=ede("command",[xQn,SQn,BQn,OQn]),B8e=_l({path:Et(),view_range:KYe([FG(),FG()]).optional()}),O8e=_l({path:Et(),file_text:Et()}),T8e=_l({path:Et(),old_str:Et(),new_str:Et().optional()}),D_t=Hh([__t,S8e,Ww()]),TQn=_l({type:gr("tool_call_requested"),callId:Et(),name:Et(),toolTitle:Et().optional(),intentionSummary:Et().nullable(),arguments:D_t,partialOutput:Et().optional(),isHidden:bo().optional(),isAlwaysExpanded:bo().optional(),showNoContent:bo().optional()}),UQn=_l({type:gr("tool_call_completed"),callId:Et(),name:Et(),toolTitle:Et().optional(),intentionSummary:Et().nullable(),result:Hh([_l({type:gr("success"),log:Et(),markdown:bo().optional()}),_l({type:gr("failure"),log:Et(),markdown:bo().optional()}),_l({type:gr("rejected"),markdown:bo().optional()}),_l({type:gr("denied"),log:Et(),markdown:bo().optional()})]),arguments:D_t,isHidden:bo().optional(),isAlwaysExpanded:bo().optional(),showNoContent:bo().optional()}),MQn=Hh([XQn,kQn,LQn,JQn,TQn,UQn]),z_t=MQn.and(_l({id:Et(),timestamp:tde.date()}));function P_t(t,e){switch(t.type){case"copilot":return e.onCopilot(t);case"error":return e.onError(t);case"info":return e.onInfo(t);case"tool_call_requested":return e.onToolCallRequested(t);case"tool_call_completed":return e.onToolCallCompleted(t);case"user":return e.onUser(t);default:{let l=t;throw new Error(`Unexpected message type: ${JSON.stringify(t)}`)}}}var CO=class t extends Error{prUrl;timeoutContext;constructor(e,l,n){super(e),this.name="JobStatusTimeoutError",this.timeoutContext=l,this.prUrl=n,Error.captureStackTrace&&Error.captureStackTrace(this,t)}};var hue=_l({type:gr("text"),text:Et()}),_Qn=_l({type:gr("refusal"),refusal:Et()}),DQn=_l({type:gr("image_url"),image_url:_l({url:Et(),detail:zg(["auto","low","high"]).optional()})}),zQn=_l({type:gr("input_audio"),input_audio:_l({data:Et(),format:gr("wav").or(gr("mp3"))})}),PQn=_l({type:gr("file"),file:_l({file_date:Et().optional(),file_id:Et().optional(),filename:Et().optional()})}),jQn=Hh([hue,DQn,zQn,PQn]),KQn=_l({name:Et(),arguments:Et()}),qQn=_l({name:Et(),input:Et()}),$Qn=_l({id:Et(),type:gr("function"),function:KQn}),eFn=_l({id:Et(),type:gr("custom"),custom:qQn}),tFn=Hh([$Qn,eFn]),lFn=_l({name:Et(),arguments:Et()}),nFn=_l({id:Et()}),rFn=_l({content:Hh([Et(),xd(hue)]),role:gr("developer"),name:Et().optional()}),IFn=_l({content:Hh([Et(),xd(hue)]),role:gr("system"),name:Et().optional()}),aFn=_l({content:Hh([Et(),xd(jQn)]),role:gr("user"),name:Et().optional()}),sFn=_l({content:Hh([Et(),xd(Hh([hue,_Qn]))]).nullable().optional(),role:gr("assistant"),name:Et().optional(),refusal:Et().nullable().optional(),audio:nFn.nullable().optional(),function_call:lFn.nullable().optional(),tool_calls:xd(tFn).optional()}),oFn=_l({content:Hh([Et(),xd(hue)]),role:gr("tool"),tool_call_id:Et()}),iFn=_l({content:Et().nullable(),role:gr("function"),name:Et()}),cFn=Hh([rFn,IFn,aFn,sFn,oFn,iFn]),U8e=_l({sessionId:Et(),startTime:tde.date(),chatMessages:xd(cFn),timeline:xd(z_t),selectedModel:zg(RO).optional()}),Aue=vVe(U8e.parse,"history-session");c();c();var Vb=_l({id:Et().uuid(),timestamp:Et().datetime(),parentId:Et().uuid().nullable(),ephemeral:bo().optional()}),dFn=Vb.extend({type:gr("session.start"),data:_l({sessionId:Et(),version:FG(),producer:Et(),copilotVersion:Et(),startTime:Et().datetime(),selectedModel:Et().optional()})}),uFn=Vb.extend({type:gr("session.resume"),data:_l({resumeTime:Et().datetime(),eventCount:FG()})}),mFn=Vb.extend({type:gr("session.error"),data:_l({errorType:Et(),message:Et(),stack:Et().optional()})}),bFn=Vb.extend({type:gr("session.info"),data:_l({infoType:Et(),message:Et()})}),GFn=Vb.extend({type:gr("session.model_change"),data:_l({previousModel:Et().optional(),newModel:Et()})}),pFn=Vb.extend({type:gr("session.import_legacy"),data:_l({legacySession:U8e,importTime:Et().datetime(),sourceFile:Et()})}),hFn=_l({type:zg(["file","directory"]),path:Et(),displayName:Et()}),AFn=Vb.extend({type:gr("user.message"),data:_l({content:Et(),attachments:xd(hFn).optional()})}),ZFn=Vb.extend({type:gr("assistant.turn_start"),data:_l({turnId:Et()})}),gFn=Vb.extend({type:gr("assistant.message"),data:_l({messageId:Et(),content:Et(),toolRequests:xd(_l({toolCallId:Et(),name:Et(),arguments:Ww()})).optional()})}),NFn=Vb.extend({type:gr("assistant.turn_end"),data:_l({turnId:Et()})}),WFn=Vb.extend({type:gr("assistant.usage"),ephemeral:gr(!0),data:_l({model:Et().optional(),tokensUsed:FG().optional(),cost:FG().optional(),duration:FG().optional(),initiator:Et().optional()})}),yFn=Vb.extend({type:gr("abort"),data:_l({reason:Et()})}),EFn=Vb.extend({type:gr("tool.user_requested"),data:_l({toolCallId:Et(),toolName:Et(),arguments:Ww()})}),RFn=Vb.extend({type:gr("tool.execution_start"),data:_l({toolCallId:Et(),toolName:Et(),arguments:Ww()})}),YFn=Vb.extend({type:gr("tool.execution_partial_result"),ephemeral:gr(!0),data:_l({toolCallId:Et(),partialOutput:Et()})}),VFn=Vb.extend({type:gr("tool.execution_complete"),data:_l({toolCallId:Et(),success:bo(),isUserRequested:bo().optional(),result:_l({content:Et()}).optional(),error:_l({message:Et(),code:Et().optional()}).optional()})}),wFn=Vb.extend({type:gr("hook.start"),data:_l({hookInvocationId:Et(),hookType:Et(),input:Ww()})}),QFn=Vb.extend({type:gr("hook.end"),data:_l({hookInvocationId:Et(),hookType:Et(),output:Ww(),success:bo(),error:_l({message:Et(),stack:Et().optional()}).optional()})}),FFn=Vb.extend({type:gr("system.message"),data:_l({content:Et(),role:zg(["system","developer"]),name:Et().optional(),metadata:_l({promptVersion:Et().optional(),variables:B2(Ww()).optional()}).optional()})}),j_t=ede("type",[dFn,uFn,mFn,bFn,GFn,pFn,AFn,ZFn,gFn,NFn,WFn,yFn,EFn,RFn,YFn,VFn,wFn,QFn,FFn]);var vO=HMt(j_t.parse,"session");var KVe=class{constructor(e,l,n,r=!1,I){this.session=e;this.logger=l;this.flushDebounceMs=n;this.shouldSaveSession=r;this.legacySourceFile=I;this.unsubscribe=this.session.onEvent(a=>{a.ephemeral||(this.unflushedEvents.push(a),!this.shouldSaveSession&&a.type==="user.message"&&(this.shouldSaveSession=!0),this.shouldSaveSession&&(this.flushTimer&&clearTimeout(this.flushTimer),this.flushTimer=setTimeout(()=>{this.flush().catch(s=>{this.logger.error(`Error flushing session ${this.session.sessionId}: ${s instanceof Error?s.message:String(s)}`)})},this.flushDebounceMs)))})}flushTimer=null;unflushedEvents=[];migratedLegacy=!1;isFlushing=!1;needsFlushAfterCurrent=!1;unsubscribe;dispose(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null),this.unsubscribe()}async flush(){if(!this.shouldSaveSession||this.unflushedEvents.length===0)return;if(this.isFlushing){this.needsFlushAfterCurrent=!0;return}this.isFlushing=!0,this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null);let e=this.unflushedEvents;this.unflushedEvents=[];try{if(await vO.append(e,this.session.sessionId),this.logger.debug(`Flushed ${e.length} events to session ${this.session.sessionId}`),this.legacySourceFile&&!this.migratedLegacy){this.logger.debug(`Migrated legacy session ${this.session.sessionId} from ${this.legacySourceFile}`);try{await K_t(this.legacySourceFile)}catch(l){this.logger.error(`Failed to delete legacy session file ${this.legacySourceFile}: ${l}`)}this.migratedLegacy=!0}}catch(l){this.logger.error(`Failed to flush events for ${this.session.sessionId}: ${l instanceof Error?l.message:String(l)}`),this.unflushedEvents.unshift(...e)}finally{this.isFlushing=!1,this.needsFlushAfterCurrent&&(this.needsFlushAfterCurrent=!1,await this.flush())}}},qVe=class extends jVe{sessionWriters={};copilotVersion;flushDebounceMs;constructor({logger:e,version:l,flushDebounceMs:n}){super({logger:e}),this.copilotVersion=l||"unknown",this.flushDebounceMs=n||100}async createSession(e){let l=e?.sessionId??Bu(),n=new Date,r=new of({sessionId:l,startTime:n,logger:this.logger});return this.sessionWriters[l]=new KVe(r,this.logger,this.flushDebounceMs),r.addEvent({type:"session.start",data:{sessionId:l,version:1,producer:"copilot-agent",copilotVersion:this.copilotVersion,startTime:n.toISOString(),selectedModel:e?.selectedModel}}),r}async getSession(e){let l,n;try{l=await this.loadSession(e)}catch{try{let r=await this.loadLegacySession(e);l=r.session,n=r.legacySourceFile}catch{return}}return this.sessionWriters[e]||(this.sessionWriters[e]=new KVe(l,this.logger,this.flushDebounceMs,!0,n)),l.addEvent({type:"session.resume",data:{resumeTime:new Date().toISOString(),eventCount:l.getEvents().length}}),l}async saveSession(e){await this.sessionWriters[e.sessionId]?.flush()}async loadSession(e){let l=await vO.load(e);if(l.length===0)throw new Error(`Session ${e} has no events`);if(l[0].type!=="session.start")throw new Error("First event must be a session.start event");return await of.fromEvents({events:l,logger:this.logger})}async loadLegacySession(e){let n=(await Aue.directoryFiles()).filter(o=>{let d=o.match(/^session_(.+)_(\d+)\.json$/);return d&&d[1]===e});if(n.length===0)throw new Error(`Legacy session ${e} not found`);let r=n[0];n.length>1&&this.logger.info(`Multiple legacy sessions found for ${e}, using newest`);let I=await Aue.load(r);if(!I)throw new Error(`Failed to load legacy session from ${r}`);let a=new Date(I.startTime),s=new of({sessionId:I.sessionId,startTime:a,logger:this.logger});return s.addEvent({type:"session.start",data:{sessionId:I.sessionId,version:1,producer:"copilot-agent",copilotVersion:this.copilotVersion,startTime:a.toISOString(),selectedModel:I.selectedModel}}),s.addEvent({type:"session.import_legacy",data:{legacySession:{sessionId:I.sessionId,startTime:a,chatMessages:I.chatMessages,timeline:I.timeline,selectedModel:I.selectedModel},importTime:new Date().toISOString(),sourceFile:r}}),this.logger.info(`Loaded legacy session ${e} from ${r}`),{session:s,legacySourceFile:Aue.path(r.replace(/\.json$/,""))}}async listSessions(){let e=await vO.directoryFilesWithMetadata(),l=await Aue.directoryFilesWithMetadata(),n=await Promise.all(e.map(async a=>({sessionId:a.file.replace(".jsonl",""),startTime:a.ctime,modifiedTime:a.mtime}))),r=(await Promise.all(l.map(async a=>{let s=a.file.match(/^session_(.+)_(\d+)\.json$/);return s?{sessionId:s[1],startTime:a.ctime,modifiedTime:a.mtime}:null}))).filter(a=>a!==null);this.logger.debug(`Found ${n.length} JSONL sessions and ${r.length} legacy sessions`);let I=new Map;for(let a of r)I.set(a.sessionId,a);for(let a of n)I.set(a.sessionId,a);return Array.from(I.values()).sort((a,s)=>s.modifiedTime.getTime()-a.modifiedTime.getTime())}async getLastSession(){let e=await this.listSessions();if(e.length===0)return;e.sort((n,r)=>r.modifiedTime.getTime()-n.modifiedTime.getTime());let l=e[0].sessionId;return await this.getSession(l)}async deleteSession(e){this.sessionWriters[e.sessionId]?.dispose(),delete this.sessionWriters[e.sessionId];let l=vO.path(e.sessionId);this.logger.info(`Deleting session file ${l}`),await K_t(l)}getSessionsDirectory(){return CFn(vO.home(),vO.directory())}setLogger(e){this.logger=e}};c();c();c();c();function Sd(t){return t()}c();var Zue;function fFn(t,e){return t.includes("\x1B[?")&&t.includes(e)}async function HFn(t){let e=process.stdin.isRaw;e||process.stdin.setRawMode(!0);try{return await t()}finally{e||process.stdin.setRawMode(!1)}}function q_t(t,e,l){return new Promise(n=>{let r="",I,a=()=>{I=void 0,process.stdin.removeListener("data",s),n(!1)},s=o=>{I!==void 0&&(r+=o.toString(),fFn(r,e)&&(process.stdin.removeListener("data",s),clearTimeout(I),I=void 0,n(!0)))};process.stdin.on("data",s),process.stdout.write("\x1B["+t),I=setTimeout(a,l)})}async function XFn(){return!(!(process.stdin.isTTY&&process.stdout.isTTY)||!await q_t("?u","u",200)||!await q_t("c","c",1e3))}async function eDt(){Zue===void 0&&(Zue=await HFn(XFn),Zue===!0&&(kFn(),process.on("exit",$_t),process.on("SIGTERM",$_t)))}function kFn(){process.stdout.write("\x1B[>1u")}function $_t(){process.stdout.write("\x1B[<u"),Zue=void 0}function $Ve(){return Zue===!0}c();c();c();c();function Nue(t,e=!1){let l=t.length,n=0,r="",I=0,a=16,s=0,o=0,d=0,u=0,b=0;function p(H,J){let S=0,T=0;for(;S<H||!J;){let U=t.charCodeAt(n);if(U>=48&&U<=57)T=T*16+U-48;else if(U>=65&&U<=70)T=T*16+U-65+10;else if(U>=97&&U<=102)T=T*16+U-97+10;else break;n++,S++}return S<H&&(T=-1),T}function h(H){n=H,r="",I=0,a=16,b=0}function Z(){let H=n;if(t.charCodeAt(n)===48)n++;else for(n++;n<t.length&&B8(t.charCodeAt(n));)n++;if(n<t.length&&t.charCodeAt(n)===46)if(n++,n<t.length&&B8(t.charCodeAt(n)))for(n++;n<t.length&&B8(t.charCodeAt(n));)n++;else return b=3,t.substring(H,n);let J=n;if(n<t.length&&(t.charCodeAt(n)===69||t.charCodeAt(n)===101))if(n++,(n<t.length&&t.charCodeAt(n)===43||t.charCodeAt(n)===45)&&n++,n<t.length&&B8(t.charCodeAt(n))){for(n++;n<t.length&&B8(t.charCodeAt(n));)n++;J=n}else b=3;return t.substring(H,J)}function N(){let H="",J=n;for(;;){if(n>=l){H+=t.substring(J,n),b=2;break}let S=t.charCodeAt(n);if(S===34){H+=t.substring(J,n),n++;break}if(S===92){if(H+=t.substring(J,n),n++,n>=l){b=2;break}switch(t.charCodeAt(n++)){case 34:H+='"';break;case 92:H+="\\";break;case 47:H+="/";break;case 98:H+="\b";break;case 102:H+="\f";break;case 110:H+=`
|
|
1983
1983
|
`;break;case 114:H+="\r";break;case 116:H+=" ";break;case 117:let U=p(4,!0);U>=0?H+=String.fromCharCode(U):b=4;break;default:b=5}J=n;continue}if(S>=0&&S<=31)if(gue(S)){H+=t.substring(J,n),b=2;break}else b=6;n++}return H}function y(){if(r="",b=0,I=n,o=s,u=d,n>=l)return I=l,a=17;let H=t.charCodeAt(n);if(M8e(H)){do n++,r+=String.fromCharCode(H),H=t.charCodeAt(n);while(M8e(H));return a=15}if(gue(H))return n++,r+=String.fromCharCode(H),H===13&&t.charCodeAt(n)===10&&(n++,r+=`
|
|
1984
1984
|
`),s++,d=n,a=14;switch(H){case 123:return n++,a=1;case 125:return n++,a=2;case 91:return n++,a=3;case 93:return n++,a=4;case 58:return n++,a=6;case 44:return n++,a=5;case 34:return n++,r=N(),a=10;case 47:let J=n-1;if(t.charCodeAt(n+1)===47){for(n+=2;n<l&&!gue(t.charCodeAt(n));)n++;return r=t.substring(J,n),a=12}if(t.charCodeAt(n+1)===42){n+=2;let S=l-1,T=!1;for(;n<S;){let U=t.charCodeAt(n);if(U===42&&t.charCodeAt(n+1)===47){n+=2,T=!0;break}n++,gue(U)&&(U===13&&t.charCodeAt(n)===10&&n++,s++,d=n)}return T||(n++,b=1),r=t.substring(J,n),a=13}return r+=String.fromCharCode(H),n++,a=16;case 45:if(r+=String.fromCharCode(H),n++,n===l||!B8(t.charCodeAt(n)))return a=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return r+=Z(),a=11;default:for(;n<l&&Y(H);)n++,H=t.charCodeAt(n);if(I!==n){switch(r=t.substring(I,n),r){case"true":return a=8;case"false":return a=9;case"null":return a=7}return a=16}return r+=String.fromCharCode(H),n++,a=16}}function Y(H){if(M8e(H)||gue(H))return!1;switch(H){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function w(){let H;do H=y();while(H>=12&&H<=15);return H}return{setPosition:h,getPosition:()=>n,scan:e?w:y,getToken:()=>a,getTokenValue:()=>r,getTokenOffset:()=>I,getTokenLength:()=>n-I,getTokenStartLine:()=>o,getTokenStartCharacter:()=>I-u,getTokenError:()=>b}}function M8e(t){return t===32||t===9}function gue(t){return t===10||t===13}function B8(t){return t>=48&&t<=57}var tDt;(function(t){t[t.lineFeed=10]="lineFeed",t[t.carriageReturn=13]="carriageReturn",t[t.space=32]="space",t[t._0=48]="_0",t[t._1=49]="_1",t[t._2=50]="_2",t[t._3=51]="_3",t[t._4=52]="_4",t[t._5=53]="_5",t[t._6=54]="_6",t[t._7=55]="_7",t[t._8=56]="_8",t[t._9=57]="_9",t[t.a=97]="a",t[t.b=98]="b",t[t.c=99]="c",t[t.d=100]="d",t[t.e=101]="e",t[t.f=102]="f",t[t.g=103]="g",t[t.h=104]="h",t[t.i=105]="i",t[t.j=106]="j",t[t.k=107]="k",t[t.l=108]="l",t[t.m=109]="m",t[t.n=110]="n",t[t.o=111]="o",t[t.p=112]="p",t[t.q=113]="q",t[t.r=114]="r",t[t.s=115]="s",t[t.t=116]="t",t[t.u=117]="u",t[t.v=118]="v",t[t.w=119]="w",t[t.x=120]="x",t[t.y=121]="y",t[t.z=122]="z",t[t.A=65]="A",t[t.B=66]="B",t[t.C=67]="C",t[t.D=68]="D",t[t.E=69]="E",t[t.F=70]="F",t[t.G=71]="G",t[t.H=72]="H",t[t.I=73]="I",t[t.J=74]="J",t[t.K=75]="K",t[t.L=76]="L",t[t.M=77]="M",t[t.N=78]="N",t[t.O=79]="O",t[t.P=80]="P",t[t.Q=81]="Q",t[t.R=82]="R",t[t.S=83]="S",t[t.T=84]="T",t[t.U=85]="U",t[t.V=86]="V",t[t.W=87]="W",t[t.X=88]="X",t[t.Y=89]="Y",t[t.Z=90]="Z",t[t.asterisk=42]="asterisk",t[t.backslash=92]="backslash",t[t.closeBrace=125]="closeBrace",t[t.closeBracket=93]="closeBracket",t[t.colon=58]="colon",t[t.comma=44]="comma",t[t.dot=46]="dot",t[t.doubleQuote=34]="doubleQuote",t[t.minus=45]="minus",t[t.openBrace=123]="openBrace",t[t.openBracket=91]="openBracket",t[t.plus=43]="plus",t[t.slash=47]="slash",t[t.formFeed=12]="formFeed",t[t.tab=9]="tab"})(tDt||(tDt={}));c();var KW=new Array(20).fill(0).map((t,e)=>" ".repeat(e)),O8=200,_8e={" ":{"\n":new Array(O8).fill(0).map((t,e)=>`
|
|
1985
1985
|
`+" ".repeat(e)),"\r":new Array(O8).fill(0).map((t,e)=>"\r"+" ".repeat(e)),"\r\n":new Array(O8).fill(0).map((t,e)=>`\r
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@github/copilot",
|
|
3
3
|
"description": "GitHub Copilot CLI brings the power of Copilot coding agent directly to your terminal.",
|
|
4
|
-
"version": "0.0.349-
|
|
4
|
+
"version": "0.0.349-4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"worker/**/*"
|
|
36
36
|
],
|
|
37
37
|
"buildMetadata": {
|
|
38
|
-
"gitCommit": "
|
|
38
|
+
"gitCommit": "490abfb"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"sharp": "^0.34.3"
|