@github/copilot 0.0.335-12 → 0.0.335-14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -612,7 +612,7 @@ It will not obtain new information or make any changes to the repository, but ju
612
612
  Use it when complex reasoning or brainstorming is needed.
613
613
  For example, if you explore the repo and discover the source of a bug, call this tool to brainstorm several unique ways of fixing the bug, and assess which change(s) are likely to be simplest and most effective.
614
614
  Alternatively, if you receive some test results, call this tool to brainstorm ways to fix the failing tests.`,input_schema:{type:"object",properties:{thought:{type:"string",description:"Your thoughts."}},required:["thought"]},callback:async e=>!e||!e.thought||typeof e.thought!="string"||e.thought.trim()===""?{textResultForLlm:"No thought provided",resultType:"success",sessionLog:"No thought provided",toolTelemetry:{}}:{textResultForLlm:"Thought logged",resultType:"success",sessionLog:e.thought,toolTelemetry:{}},safeForTelemetry:!0});function MFe(t){return typeof t=="object"&&t!==null&&"textResultForLlm"in t}function OIt(t,e,l,I){return{truncationOptions:{tokenLimit:e,countTokens:n=>bw(n,t)},client:l,settings:I}}var LO="The tool call required approval from the user, but the user rejected it or an earlier tool call.",vme={textResultForLlm:LO,resultType:"rejected",error:LO,sessionLog:LO,toolTelemetry:{}},Cme=t=>{let e=Kie(t);return{textResultForLlm:`Permission to run this tool was denied due the following rules: ${e}`,resultType:"denied",error:`Permission to run this tool was denied due the following rules: ${e}`,sessionLog:`Permission to run this tool was denied due the following rules: ${e}`,toolTelemetry:{}}},Hme={textResultForLlm:"Permission denied and could not request permission from user",resultType:"denied",error:"Permission denied and could not request permission from user",sessionLog:"Permission denied and could not request permission from user",toolTelemetry:{}},Gdl=async()=>({result:"failed",reason:"assessment not implemented"}),TZ=class t{constructor(e,l,I,n,r,a,s,o=Gdl){this.shellType=e;this.displayName=l;this.shellToolName=I;this.readShellToolName=n;this.writeShellToolName=r;this.stopShellToolName=a;this.descriptionLines=s;this.assessScriptSafety=o}withScriptSafetyAssessor(e){return new t(this.shellType,this.displayName,this.shellToolName,this.readShellToolName,this.writeShellToolName,this.stopShellToolName,this.descriptionLines,l=>e(this.shellType,l))}static bash=new t("bash","Bash","bash","read_bash","write_bash","stop_bash",["* You can install Linux, Python, JavaScript and Go packages with the `apt`, `pip`, `npm` and `go` commands."]);static powerShell=new t("powershell","PowerShell","powershell","read_powershell","write_powershell","stop_powershell",["* You can install Python, JavaScript and Go packages with the `pip`, `npm` and `go` commands.","* Use native PowerShell commands not DOS commands (e.g., use Get-ChildItem rather than dir). DOS commands may not work."])},aH=t=>{let e={};return t.forEach(l=>{e[l.name]=l}),e};c();c();import{exec as udl}from"child_process";import{promisify as pdl}from"util";var vw="___BEGIN___COMMAND_OUTPUT_MARKER___",TIt=`
615
- ${vw}`,$K="___BEGIN___COMMAND_DONE_MARKER___",hdl=new RegExp(`${$K}(\\d+)`),Zdl=100,UIt=5e3,qK=10*1024*1024;var xO=class t{constructor(e,l,I={},n){this.config=e;this.createdAtMs=Date.now(),this.lastUsedAtMs=Date.now();let r=this.config.shellType==="powershell",a=r?"pwsh.exe":"bash",s=r?[]:["--norc","--noprofile"],o=r?!1:void 0;this.process=n(a,s,{name:"xterm-color",cols:120,rows:80,cwd:l,env:I,useConpty:o}),this.process.onData(d=>{let u=W0(d).replaceAll("\r","");if(this.outputBuffer.length+u.length>qK){this.wasTruncated=!0;let h=this.outputBuffer.lastIndexOf(vw);if(h!==-1){let W=this.outputBuffer.substring(0,h+vw.length),y=this.outputBuffer.substring(h+vw.length),R=qK-u.length-W.length;if(R>0){let V=$c(y,"output",R,"start");this.outputBuffer=W+V}else{this.outputBuffer=W+$c(u,"output",qK-W.length,"start");return}}else{let W=qK-u.length;if(W>0)this.outputBuffer=$c(this.outputBuffer,"output",W,"start");else{this.outputBuffer=$c(u,"output",qK,"start");return}}}this.outputBuffer+=u}),this.process.onExit(d=>this.shutdown())}process;outputBuffer="";isCommandInProgress=!1;wasTruncated=!1;createdAtMs;lastUsedAtMs;onPartialOutputChanged;static shellIsSupportedCache=new Map;writeDelay=Promise.resolve();static async create(e,l,I={}){await t.ensureShellIsSupported(e.shellType);let n=await import("node-pty"),r=new t(e,l,I,n.spawn);return await r.initializeShellEnvironment(),r}setPartialOutputChangedCallback(e){this.onPartialOutputChanged=e}async executeCommand(e,l){if(this.updateLastUsedTime(),!this.process)throw new Error(`Failed to start ${this.config.shellType} process`);if(this.tryStartCommand(e))return await(l?this.waitForCommandCompletionOrTimeout(l):this.waitForCommandCompletion())}async cwd(){try{let e=this.config.shellType==="powershell"?"(pwd).Path":"pwd",l=await this.executeCommand(e,UIt);return l?.exitCode===0?l.output:void 0}catch{return}}async tryExecuteAsyncCommand(e){return this.updateLastUsedTime(),this.tryStartCommand(e)?(this.waitForCommandCompletion().catch(l=>{}),this.config.shellType==="powershell"&&await new Promise(l=>setTimeout(l,250)),!0):!1}trySendInput(e){if(this.updateLastUsedTime(),!this.process)throw new Error(`Failed to start ${this.config.shellType} process`);if(!this.isCommandInProgress)return!1;let l=this.config.shellType==="powershell"?e.replaceAll(`
615
+ ${vw}`,$K="___BEGIN___COMMAND_DONE_MARKER___",hdl=new RegExp(`${$K}(\\d+)`),Zdl=100,UIt=5e3,qK=10*1024*1024;var xO=class t{constructor(e,l,I={},n){this.config=e;this.createdAtMs=Date.now(),this.lastUsedAtMs=Date.now();let r=this.config.shellType==="powershell",a=r?"pwsh.exe":"bash",s=r?["-nop","-nol"]:["--norc","--noprofile"],o=r?!1:void 0;this.process=n(a,s,{name:"xterm-color",cols:120,rows:80,cwd:l,env:I,useConpty:o}),this.process.onData(d=>{let u=W0(d).replaceAll("\r","");if(this.outputBuffer.length+u.length>qK){this.wasTruncated=!0;let h=this.outputBuffer.lastIndexOf(vw);if(h!==-1){let W=this.outputBuffer.substring(0,h+vw.length),y=this.outputBuffer.substring(h+vw.length),R=qK-u.length-W.length;if(R>0){let V=$c(y,"output",R,"start");this.outputBuffer=W+V}else{this.outputBuffer=W+$c(u,"output",qK-W.length,"start");return}}else{let W=qK-u.length;if(W>0)this.outputBuffer=$c(this.outputBuffer,"output",W,"start");else{this.outputBuffer=$c(u,"output",qK,"start");return}}}this.outputBuffer+=u}),this.process.onExit(d=>this.shutdown())}process;outputBuffer="";isCommandInProgress=!1;wasTruncated=!1;createdAtMs;lastUsedAtMs;onPartialOutputChanged;static shellIsSupportedCache=new Map;writeDelay=Promise.resolve();static async create(e,l,I={}){await t.ensureShellIsSupported(e.shellType);let n=await import("node-pty"),r=new t(e,l,I,n.spawn);return await r.initializeShellEnvironment(),r}setPartialOutputChangedCallback(e){this.onPartialOutputChanged=e}async executeCommand(e,l){if(this.updateLastUsedTime(),!this.process)throw new Error(`Failed to start ${this.config.shellType} process`);if(this.tryStartCommand(e))return await(l?this.waitForCommandCompletionOrTimeout(l):this.waitForCommandCompletion())}async cwd(){try{let e=this.config.shellType==="powershell"?"(pwd).Path":"pwd",l=await this.executeCommand(e,UIt);return l?.exitCode===0?l.output:void 0}catch{return}}async tryExecuteAsyncCommand(e){return this.updateLastUsedTime(),this.tryStartCommand(e)?(this.waitForCommandCompletion().catch(l=>{}),this.config.shellType==="powershell"&&await new Promise(l=>setTimeout(l,250)),!0):!1}trySendInput(e){if(this.updateLastUsedTime(),!this.process)throw new Error(`Failed to start ${this.config.shellType} process`);if(!this.isCommandInProgress)return!1;let l=this.config.shellType==="powershell"?e.replaceAll(`
616
616
  `,"\r"):e;return this.writeDelay=Ndl(this.writeDelay,this.process,l),!0}readOutput(){this.updateLastUsedTime();let e=this.tryExtractOutputFromDoneMarker();if(e)return e;let l=this.outputBuffer.lastIndexOf(TIt);return{output:l>-1?this.outputBuffer.substring(l+TIt.length).trim():"",exitCode:void 0,truncated:this.wasTruncated}}getStats(){return{createdAtMs:this.createdAtMs,lastUsedAtMs:this.lastUsedAtMs}}waitForCommandCompletionOrTimeout(e){let l=this.waitForCommandCompletion(),I=new Promise((n,r)=>{setTimeout(()=>{r(new Error("Command timed out"))},e)});return Promise.race([l,I])}clearBuffer(){let e=this.outputBuffer.lastIndexOf($K);this.outputBuffer=e>0?`${vw}
617
617
  ${this.outputBuffer.substring(e).trim()}`:""}shutdown(){if(this.process){this.isCommandInProgress=!1;try{this.process.kill()}catch{}this.process=void 0,this.outputBuffer=""}}updateLastUsedTime(){this.lastUsedAtMs=Date.now()}async initializeShellEnvironment(){if(!this.process)throw new Error(`Failed to start ${this.config.shellType} process`);let l=this.config.shellType==="powershell"?`function prompt {" "}; $PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'`:'PS1="";PS2=""';await this.executeCommand(l,UIt)}tryStartCommand(e){if(!this.process)throw new Error(`Failed to start ${this.config.shellType} process`);if(this.isCommandInProgress)return!1;this.isCommandInProgress=!0,this.wasTruncated=!1;let I=this.config.shellType==="powershell"?`$LASTEXITCODE = 0; echo ${vw}; &{\r${e}\r}; echo ${$K}$LASTEXITCODE\r`:`
618
618
  {
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.335-12",
4
+ "version": "0.0.335-14",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -33,7 +33,7 @@
33
33
  "sdk/**/*"
34
34
  ],
35
35
  "buildMetadata": {
36
- "gitCommit": "7da3c67"
36
+ "gitCommit": "0ad8f81"
37
37
  },
38
38
  "dependencies": {
39
39
  "node-pty": "npm:@devm33/node-pty@^1.0.8",
package/sdk/index.js CHANGED
@@ -354,7 +354,7 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
354
354
  ${h}`)}try{c=await i.getSecret("capi-token")}catch(h){e.debug(`Failed to get Copilot GitHub OAuth token from secret provider:
355
355
  ${h}`)}a=!!(n||c)}let s,r=OmI(I),o=fE(I),d=I.api?.copilot?.sessionId??uV(I);if(e.debug(`Using Copilot API at ${r} with integration ID ${o}`),c&&(e.debug("Using GitHub OAuth token for Copilot API"),s=aj.createWithOAuthToken(e,r,o,c,d,l?.requestHeaders)),n){e.debug("Using Copilot HMAC key for Copilot API");let i=process.env.GITHUB_USER_ID;i?e.debug(`Using user ID ${i} for Copilot HMAC key`):e.debug("No user ID provided for Copilot HMAC key"),s=aj.createWithHmac(e,r,o,n,d,i,l?.requestHeaders)}if(s===void 0)throw new Error("No GitHub OAuth token or Copilot HMAC key provided");return s}},KA=class t extends tn{request_id;constructor(I){super(I.status,I.error,I.message,I.headers),this.name="CAPIError",this.ghRequestId=I.headers?.get("x-github-request-id")||this.requestID,this.request_id=this.requestID}ghRequestId;static fromAPIError(I){if(!(!I||!(I instanceof tn)))return new t(I)}};G();var AaI="x-quota-snapshot-";function d5I(t){if(t)try{let I=new URLSearchParams(t),e=parseInt(I.get("ent")||"0",10),l=parseFloat(I.get("ov")||"0.0"),c=I.get("ovPerm")==="true",n=parseFloat(I.get("rem")||"0.0"),a=I.get("rst"),s;a?s=new Date(a):(s=new Date,s.setMonth(s.getMonth()+1));let r=Math.round(Math.max(0,e*(1-n/100)));return isNaN(e)||isNaN(l)||isNaN(n)?void 0:{isUnlimitedEntitlement:e===-1,entitlementRequests:e,usedRequests:r,usageAllowedWithExhaustedQuota:c,overage:l,overageAllowedWithExhaustedQuota:c,remainingPercentage:n,resetDate:s}}catch{return}}var XaI={type:"ephemeral"},PA=class t{constructor(I,e,l,c){this.settings=e;this.logger=l;this.clientOptions=t.initDefaultOptions(c),l.info(" "),l.debug(`Using model: ${this.model}`),this.clientPromise=I.createClient(e,l,c),this.modelPromise=this.clientPromise.then(async()=>{let n=await this.getModel();return l.debug(`Got model info: ${JSON.stringify(n,null,2)}`),n})}clientOptions;clientPromise;modelPromise;get model(){return this.clientOptions.model}static initDefaultOptions(I){return{model:I?.model||ZnI.model,toolTokenBudgetProportion:I?.toolTokenBudgetProportion??.25,retryPolicy:{maxRetries:I?.retryPolicy?.maxRetries??5,errorCodesToRetry:I?.retryPolicy?.errorCodesToRetry??[],rateLimitRetryPolicy:{defaultRetryAfterSeconds:I?.retryPolicy?.rateLimitRetryPolicy?.defaultRetryAfterSeconds??5,initialRetryBackoffExtraSeconds:I?.retryPolicy?.rateLimitRetryPolicy?.initialRetryBackoffExtraSeconds??1,retryBackoffExtraGrowth:I?.retryPolicy?.rateLimitRetryPolicy?.retryBackoffExtraGrowth??2,maxRetryAfterSeconds:I?.retryPolicy?.rateLimitRetryPolicy?.maxRetryAfterSeconds??180}},thinkingMode:I?.thinkingMode??!1,requestHeaders:I?.requestHeaders??{}}}getCompletionOptions(I,e){let l={snippy:{enabled:!1}};return{temperature:0,top_p:.95,frequency_penalty:0,presence_penalty:0,tool_choice:e?.toolChoice,...l}}makeRequest(I,e,l,c,n,a,s){return I.chat.completions.create({model:e,messages:[...l],...c,tools:n},{maxRetries:a,headers:s?.requestHeaders,signal:s?.abortSignal}).withResponse()}async*getCompletionWithTools(I,e,l,c){let n=this.model,a=await this.clientPromise,s=await this.modelPromise,r=iW(l),o=[{role:"system",content:I,copilot_cache_control:XaI},...e.map(W=>XJ(W))],d=l.map((W,N)=>({type:"function",function:{name:W.name,description:W.description,parameters:W.input_schema},copilot_cache_control:N===l.length-1?XaI:void 0}));this.logger.startGroup("Completion request configuration: ",8),this.logger.debug("Client options: "),this.logger.debug(JSON.stringify(this.clientOptions,null,2)),this.logger.debug("Request options: "),this.logger.debug(JSON.stringify(c??{},null,2)),this.logger.debug("Tools: "),this.logger.debug(JSON.stringify(d,null,2)),this.logger.endGroup(8);let i=this.getCompletionOptions(l,c),h=c?.initialTurnCount!==void 0?c.initialTurnCount+1:0,p=!1,Z=!1;for(;!p&&!Z;){let W=Date.now();yield{kind:"turn_started",model:n,modelInfo:s,turn:h,timestampMs:W};let N=0,Y=0,F=0,g=[429,503,500,400],A=this.clientOptions.retryPolicy.maxRetries,X=this.clientOptions.retryPolicy.rateLimitRetryPolicy.initialRetryBackoffExtraSeconds,v=0,C=this.clientOptions.retryPolicy.rateLimitRetryPolicy.maxRetryAfterSeconds,k=s.capabilities.limits.max_prompt_tokens||s.capabilities.limits.max_context_window_tokens,z=1,O=.5,II=()=>k*z,pI,FI;try{if(h===0){let wI=mmI(o,n),bI=hmI(d,n);if(wI+bI>k){if(c?.failIfInitialInputsTooLong)throw new Error(`Initial inputs exceed the model's token limit of ${k} tokens.`);this.logger.warning(`Initial inputs exceed the model's token limit of ${k} tokens. The model may not be able to process the inputs correctly.`)}}let yI=[],HI;do{F>0&&(yield{kind:"turn_retry",model:n,modelInfo:s,turn:h,timestampMs:Date.now()});try{for(let iI of c?.processors?.preRequest||[]){let ce=iI.preRequest({turn:h,messages:o,toolDefinitions:d,modelInfo:s,tokenLimit:II()});for await(let SI of ce)yield SI}if(this.logger.startGroup("Sending request to the AI model",8),_l(this.settings,"copilot_swe_agent_request_logging")){let iI=JSON.stringify(o,null,2),ce=JSON.stringify(i,null,2);this.logger.debug(`Request messages: ${iI}`),this.logger.debug(`Request options: ${ce}`)}yI=o.map((iI,ce)=>ce===o.length-1?{...iI,copilot_cache_control:XaI}:iI),N=Date.now();let wI=await this.makeRequest(a,n,yI,i,d,A,c);Y=Date.now()-N,pI=wI.data,HI={model:n,api_id:pI.id,request_id:wI.response.headers.get("x-github-request-id")||void 0};let bI={};wI.response.headers.forEach((iI,ce)=>{if(ce.toLowerCase().startsWith(AaI)){let SI=d5I(iI);SI&&(bI[ce.replace(AaI,"")]=SI)}}),yield{kind:"model_call_success",turn:h,modelCallDurationMs:Y,modelCall:HI,responseChunk:BvI(pI),responseUsage:pI.usage,requestMessages:JSON.stringify(yI),quotaSnapshots:bI},this.logger.debug(`response (Request-ID ${wI.request_id}):`),this.logger.debug("data:"),this.logger.debug(JSON.stringify(wI.data,null,2))}catch(wI){Y=Date.now()-N;let bI=KA.fromAPIError(wI),iI=bI?.error;if(bI){yield{kind:"model_call_failure",turn:h,modelCallDurationMs:Y,requestMessages:JSON.stringify(yI),modelCall:{model:n,status:bI.status,error:JSON.stringify(bI?.error||bI?.message||"unknown error"),api_id:bI.requestID||void 0,request_id:bI.headers?.get("x-github-request-id")||""}},FI=bI;let SI=bI.ghRequestId||bI.headers?.get("x-github-request-id")||bI.requestID;this.logger.error(`error (Request-ID ${SI})`),this.logger.error(JSON.stringify(bI,null,2)),this.logger.debug(`Failed to get response from the AI model: ${bI}`),iI&&this.logger.debug(`Inner error: ${JSON.stringify(iI,null,2)}`);for(let jI of c?.processors?.onRequestError||[])await jI.onRequestError(iI);let Qe=bI.status,Tc=Qe?this.clientOptions.retryPolicy.errorCodesToRetry.some(jI=>Array.isArray(jI)?Qe>=jI[0]&&(jI[1]===void 0||Qe<=jI[1]):Qe===jI):!1,_I,Mt=typeof iI?.message=="string"?iI.message.match(/prompt token count of (\d+) exceeds the limit of (\d+)/):void 0;if(bI.status!==402){if(bI.status===400&&Mt){_I=1;let jI=parseInt(Mt[2],10);jI<k?(k=jI,z=1):z=Math.max(z-O/A,O),this.logger.debug(`Adjusted model token limit to ${k}, token limit retry buffer to ${z}`)}else if(bI.status===413){this.logger.debug("Request is too large, trying to remove images from the request");let jI=0;for(let Gn=o.length-1;Gn>=0;Gn--)tA(o[Gn])&&(o.splice(Gn,1),jI++,yield{kind:"images_removed",turn:h,imagesRemoved:1,largeImagesRemoved:1});jI>0?(this.logger.info(`Images have been removed from the request due to size constraints. Please resize images to be smaller than ${cm(s.capabilities.limits.vision?.max_prompt_image_size||0)}.`),this.logger.debug(`Removed ${jI} image messages from the request`),_I=1):this.logger.debug("No image messages found in the request - unsure why the request is too large - will fail")}else if((typeof bI.status=="number"&&g.includes(bI.status)||Tc)&&(_I=parseInt(bI.headers?.get("retry-after")||`${this.clientOptions.retryPolicy.rateLimitRetryPolicy.defaultRetryAfterSeconds}`,10)+X,X*=this.clientOptions.retryPolicy.rateLimitRetryPolicy.retryBackoffExtraGrowth,F==A-1))for(let jI=o.length-1;jI>=0;jI--)tA(o[jI])&&(this.logger.debug(`Removing image message at index ${jI} to avoid failure`),o.splice(jI,1),yield{kind:"images_removed",turn:h,imagesRemoved:1})}if(_I!==void 0&&_I<=C){let jI=.8+Math.random()*.4,Gn=_I*jI;this.logger.debug(`Retrying after ${Gn} seconds...`),await new Promise(Ph=>setTimeout(Ph,Gn*1e3)),v+=Gn,this.logger.debug(`Retrying after ${_I} seconds... Will try again now!`);continue}else _I?this.logger.error(`Retry after ${_I} seconds is too long. Giving up.`):this.logger.error("Retry after is not set. Giving up.")}let ce=bI||wI;for(let SI of c?.processors?.onRequestError||[])await SI.preErrorThrow(wI);throw this.logger.error("error"),this.logger.error(JSON.stringify(ce,null,2)),ce}finally{this.logger.endGroup(8)}}while(!pI&&F++<A);if(!pI){this.logger.debug("Recent messages prior to failure:");for(let bI=Math.max(0,o.length-6);bI<o.length;bI++)this.logger.debug(`${bI}: ${JSON.stringify(o[bI],null,2)}`);let wI=new Error(`Failed to get response from the AI model; retried ${F-1} times (total retry wait time: ${v} seconds)`,{cause:FI});throw this.isRateLimitExceededError(wI)&&(this.logger.info(`Rate limit exceeded after ${F-1} retries, will fail job but skip Sentry reporting`),wI.skipReport=!0),wI}for(let wI of pI.choices.map(bI=>bI.message))rRe(wI.tool_calls||[]),o.push(wI),yield{kind:"message",modelCall:HI,message:XJ(eA(wI)),turn:h};if(this.isToolCallResponse(pI)){let wI=II()*this.clientOptions.toolTokenBudgetProportion,bI=W0I(n,wI,this,this.settings),ce=pI.choices.filter(_I=>_I.message.tool_calls!==void 0).flatMap(_I=>_I.message.tool_calls||[]).filter(eo),SI=new Map;for(let _I of c?.processors?.preToolsExecution||[]){let Mt=await _I.preToolsExecution({turn:h,toolCalls:ce,modelInfo:s});if(Mt)for(let[jI,Gn]of Mt)SI.set(jI,Gn)}let Qe=ce.filter(_I=>!SI.has(_I.id)),Tc=this.mergeToolResults(SI,ce,Qe,r,bI,c?.executeToolsInParallel);for await(let _I of Tc){_I.toolResult.resultType==="rejected"&&(Z=!0);let Mt={role:"tool",tool_call_id:_I.originalCall.id,content:_I.toolResult.textResultForLlm};o.push(Mt),yield{kind:"message",modelCall:HI,message:XJ(Mt),turn:h},yield{kind:"tool_execution",turn:h,toolCallId:_I.originalCall.id,toolResult:_I.toolResult,durationMs:_I.durationMs};for(let jI of c?.processors?.postToolExecution||[])await jI.postToolExecution({toolCall:_I.originalCall,toolResult:_I.toolResult,turn:h,modelInfo:s})}}else for(let wI of pI.choices.map(bI=>bI.message))yield{kind:"response",modelCall:{model:n,api_id:pI.id},response:XJ(eA(wI)),turn:h},p=!0;a.setInitiatorHeader("agent")}catch(yI){let HI;throw yI instanceof Error&&yI.cause&&yI.cause instanceof KA?HI=`${yI} (Cause: ${yI.cause})`:HI=`${yI}`,yield{kind:"turn_failed",model:n,modelInfo:s,turn:h,error:HI,timestampMs:Date.now()},yI}finally{let yI=Date.now();yield{kind:"turn_ended",model:n,modelInfo:s,turn:h,timestampMs:yI},h++}}}async*mergeToolResults(I,e,l,c,n,a=!1){for(let[s,r]of I){let o=e.find(d=>d.id===s);o&&(yield{durationMs:0,originalCall:o,toolResult:r})}l.length>0&&(yield*this.callTools(l,c,n,a))}async*callTools(I,e,l,c=!1){if(I.length===0)throw new Error("Tool call is missing");if(this.logger.debug(`Tool calls count: ${I.length}`),c)this.logger.debug("Running tool calls in parallel"),yield*m0I(I.map(n=>()=>this.callTool(n,e,l)));else{this.logger.debug("Running tool calls sequentially");for(let n of I)yield await this.callTool(n,e,l)}}async callTool(I,e,l){let c=0,n=I?.function.name;if(!n)throw new Error("Tool name is missing");let a=I?.function.arguments;if(!a)throw new Error("Tool call arguments are missing");let s=I?.id;if(!s)throw new Error("Tool call id is missing");let r,o=e[n];try{let d=IA(a);if(!o||!o.callback)r={textResultForLlm:`Tool '${n}' does not exist. Available tools that can be called are ${Object.keys(e).join(", ")}.`,resultType:"failure",error:`Tool '${n}' does not exist.`,sessionLog:`<error>Tool '${n}' does not exist.</error>`,toolTelemetry:{}};else{let i=o.callback,h=Date.now(),p={...l,toolCallId:s,toolOptions:this.settings.service?.tools?.[n]},Z=await i({...d},p);c=Date.now()-h,r=typeof Z=="string"?{textResultForLlm:Z,resultType:"success",toolTelemetry:{}}:Z}}catch(d){d instanceof SyntaxError?(r={textResultForLlm:`The arguments for the tool call '${n}' were not valid JSON. The arguments have been cleared. Arguments: ${a}. JSON parse error: ${d.message}`,resultType:"failure",error:`${d.message}`,sessionLog:`<error>Failed to execute \`${n}\` tool with arguments: ${a} due to syntax error: ${d.message}</error>`,toolTelemetry:{properties:{wasSyntaxError:"true"}}},I.function.arguments="{}"):r={textResultForLlm:`Failed to execute \`${n}\` tool with arguments: ${a} due to error: ${d}`,resultType:"failure",error:d instanceof Error?d.message:`${d}`,sessionLog:`<error>Failed to execute \`${n}\` tool with arguments: ${a}</error>`,toolTelemetry:{}}}return{durationMs:c,originalCall:I,toolResult:r}}isToolCallResponse(I){return I.choices.find(e=>e.message.tool_calls!==void 0)!==void 0}isRateLimitExceededError(I){if(I instanceof Error){if(I.message?.includes("exceeded maximum number of retries")&&I.message?.includes("rate-limited requests"))return!0;if(I.message?.includes("Failed to get response from the AI model")&&I.cause instanceof KA)return I.cause.status===429}return!1}async getModel(){let I=this.clientOptions.model,e={id:I,name:I,capabilities:{supports:{vision:!1},limits:{max_prompt_tokens:9e4,max_context_window_tokens:128e3,vision:{max_prompt_image_size:3145728,max_prompt_images:1,supported_media_types:["image/jpeg","image/png","image/webp"]}}}};return(await(await this.clientPromise).listModels()).filter(a=>a.id===I).at(0)||e}};function rRe(t){for(let I of t)I.function.name=I.function.name.replace(/[^a-zA-Z0-9_-]+/g,"_")}var sj=class extends PA{constructor(I,e,l){let c=new DA;super(c,I,e,l)}};G();G();var qA=class t{constructor(I,e,l,c){this.settings=e;this.logger=l;this.clientOptions=t.initDefaultOptions(c),this.logger.info(`Using responses with model: ${this.model}`),this.clientPromise=I.createClient(e,l,this.clientOptions)}clientOptions;clientPromise;get model(){return this.clientOptions.model}static initDefaultOptions(I){return{model:I?.model||"o4-mini",toolTokenBudgetProportion:I?.toolTokenBudgetProportion??.25,retryPolicy:{maxRetries:I?.retryPolicy?.maxRetries??5,errorCodesToRetry:I?.retryPolicy?.errorCodesToRetry??[],rateLimitRetryPolicy:{defaultRetryAfterSeconds:I?.retryPolicy?.rateLimitRetryPolicy?.defaultRetryAfterSeconds??5,initialRetryBackoffExtraSeconds:I?.retryPolicy?.rateLimitRetryPolicy?.initialRetryBackoffExtraSeconds??1,retryBackoffExtraGrowth:I?.retryPolicy?.rateLimitRetryPolicy?.retryBackoffExtraGrowth??2,maxRetryAfterSeconds:I?.retryPolicy?.rateLimitRetryPolicy?.maxRetryAfterSeconds??60}},thinkingMode:I?.thinkingMode??!0,requestHeaders:I?.requestHeaders??{}}}makeRequest(I,e,l,c,n,a,s,r){return I.responses.create({model:e,previous_response_id:a,instructions:l,input:c,parallel_tool_calls:n.length>0?!0:void 0,tools:n,reasoning:{summary:"auto",effort:"medium"},store:!1,include:["reasoning.encrypted_content"]},{maxRetries:s||this.clientOptions.retryPolicy.maxRetries,headers:r?.requestHeaders,signal:r?.abortSignal}).withResponse()}async*getCompletionWithTools(I,e,l,c){let n=await this.clientPromise,a=iW(l),s=l.map(N=>({name:N.name,description:N.description,parameters:N.input_schema,strict:!1,type:"function"})),r=0,o=this.clientOptions.retryPolicy.maxRetries,d=this.clientOptions.retryPolicy.rateLimitRetryPolicy.initialRetryBackoffExtraSeconds,i=0,h=this.clientOptions.retryPolicy.rateLimitRetryPolicy.maxRetryAfterSeconds,p=e.flatMap(GRe),Z,W=!1;for(;!W;){let N;do{N=void 0;try{let Y=await this.makeRequest(n,this.model,I,p,s,void 0,o,c);Z=Y.data,p.push(...Z.output),this.logger.debug(`response (Request-ID ${Y.request_id}):`),this.logger.debug("data:"),this.logger.debug(JSON.stringify(Y.data,null,2))}catch(Y){let F=Y,g=F.error;if(F){N=F,this.logger.error(`error (Request-ID ${F.requestID})`),this.logger.error(JSON.stringify(F,null,2)),this.logger.debug(`Failed to get response from the AI model: ${F}`),g&&this.logger.debug(`Inner error: ${JSON.stringify(g,null,2)}`);let A=F.status,X=A?this.clientOptions.retryPolicy.errorCodesToRetry.some(C=>Array.isArray(C)?A>=C[0]&&(C[1]===void 0||A<=C[1]):A===C):!1,v;if((F.status===429||X)&&(v=parseInt(F.headers?.get("retry-after")||`${this.clientOptions.retryPolicy.rateLimitRetryPolicy.defaultRetryAfterSeconds}`,10)+d,d*=this.clientOptions.retryPolicy.rateLimitRetryPolicy.retryBackoffExtraGrowth),v!==void 0&&v<=h){this.logger.debug(`Retrying after ${v} seconds...`),await new Promise(C=>setTimeout(C,v*1e3)),i+=v,this.logger.debug(`Retrying after ${v} seconds... Will try again now!`);continue}else v?this.logger.error(`Retry after ${v} seconds is too long. Giving up.`):this.logger.error("Retry after is not set. Giving up.")}throw this.logger.error("error"),this.logger.error(JSON.stringify(Y,null,2)),Y}finally{this.logger.endGroup(8)}}while(N&&r++<o);if(!Z||N){this.logger.debug("Recent messages prior to failure:");for(let Y=Math.max(0,p.length-6);Y<p.length;Y++)this.logger.debug(`${Y}: ${JSON.stringify(p[Y],null,2)}`);throw new Error(`Failed to get response from the AI model; retried ${r-1} times (total retry wait time: ${i} seconds)`,{cause:N})}for(let Y of Z.output)yield{kind:"message",message:i5I(Y)};if(this.requiresToolOutput(Z)){let F=(await this.runTool(Z,a)).map(g=>({type:"function_call_output",call_id:g.toolCallId,output:g.textResultForLlm}));p.push(...F);for(let g of F)yield{kind:"message",message:i5I(g)}}else yield{kind:"response",response:{content:Z.output_text,refusal:null,role:"assistant"}},W=!0}}async runTool(I,e,l){let c=I.output.filter(a=>a.type==="function_call");if(!c||c.length===0)throw new Error("Tool calls in response are missing");let n=[];for(let a of c){let s=a.name;if(!s)throw new Error("Tool name is missing");let r=a.arguments;if(!r)throw new Error("Tool call arguments are missing");let o=a.call_id;if(!o)throw new Error("Tool call id is missing");let d,i=e[s];try{let h=IA(r);if(!i||!i.callback)d={textResultForLlm:`Tool '${s}' does not exist. Available tools that can be called are ${Object.keys(e).join(", ")}.`,resultType:"failure",error:`Tool '${s}' does not exist.`,sessionLog:`<error>Tool '${s}' does not exist.</error>`,toolTelemetry:{}};else{let p=i.callback,Z={...l,toolOptions:this.settings.service?.tools?.[s],settings:this.settings},W=await p({...h},Z);d=typeof W=="string"?{textResultForLlm:W,resultType:"success",toolTelemetry:{}}:W}}catch(h){d={textResultForLlm:`Failed to execute \`${s}\` tool with arguments: ${r} due to error: ${h}`,resultType:"failure",error:h instanceof Error?h.message:`${h}`,sessionLog:`<error>Failed to execute \`${s}\` tool with arguments: ${r}</error>`,toolTelemetry:{properties:{wasSyntaxError:h instanceof SyntaxError?"true":"false"}}}}n.push({toolCallId:o,textResultForLlm:d.textResultForLlm,sessionLog:d.resultType=="success"?d.sessionLog:d.error?`<error>${d.error}</error>`:void 0})}return n}requiresToolOutput(I){return I.output.filter(e=>e.type==="function_call").length>0}};function GRe(t){if(t.role==="function")throw new Error("Function role is not supported");let I=[];if(t.reasoning_opaque&&I.push({id:t.reasoning_opaque,type:"reasoning",summary:t.reasoning_text?[{text:t.reasoning_text,type:"summary_text"}]:[],encrypted_content:t.encrypted_content}),t.role==="assistant"&&t.tool_calls&&t.tool_calls.length>0&&eo(t.tool_calls[0])){let e=t.tool_calls[0];return[...I,{type:"function_call",id:t.id,name:e.function.name,arguments:e.function.arguments,call_id:e.id}]}return t.role==="tool"?[...I,{type:"function_call_output",call_id:t.tool_call_id,output:typeof t.content=="string"?t.content:t.content?.map(e=>e.type==="text"?e:{type:"text",text:""}).join(" ")??""}]:t.content?t.role==="assistant"?[...I,{type:"message",id:t.id,role:t.role,content:[{annotations:[],type:"output_text",text:typeof t.content=="string"?t.content:t.content?.map(e=>e.type==="text"?e.text:"").join(" ")??""}]}]:[...I,{role:t.role,content:typeof t.content=="string"?t.content:t.content?.map(e=>e.type==="text"?e.text:"").join(" ")??"",type:"message"}]:I}function i5I(t){if(t.type==="reasoning")return{role:"assistant",reasoning_opaque:t.id,reasoning_text:t.summary?t.summary.map(I=>I.text).join(" "):void 0,content:"",encrypted_content:t.encrypted_content};if(t.type==="function_call")return{role:"assistant",id:t.id,tool_calls:[{id:t.call_id,type:"function",function:{name:t.name,arguments:t.arguments}}],content:""};if(t.type==="function_call_output")return{role:"tool",content:t.output,tool_call_id:t.call_id};if(t.type==="message")return{id:"id"in t?t.id:void 0,role:t.role,content:typeof t.content=="string"?t.content:t.content?.map(I=>I.type==="input_text"||I.type==="output_text"?I.text:"").join(" ")??""};throw new Error(`Unknown item type: ${t.type}`)}var rj=class extends qA{constructor(I,e,l){let c=new DA;super(c,I,e,l)}};var l4=class{constructor(I,e,l){this.settings=I;this.logger=e;this.clientOptions=l;this.chatClient=new sj(I,e,l)}chatClient;get model(){return this.chatClient.model}async*getCompletionWithTools(I,e,l,c){let n=await this.chatClient.modelPromise;(this.clientOptions?.thinkingMode||_l(this.settings,"copilot_swe_agent_enable_responses_api"))&&n&&n.supported_endpoints?.includes("/responses")?yield*new rj(this.settings,this.logger,{model:this.chatClient.model,...this.clientOptions}).getCompletionWithTools(I,e,l,c):yield*this.chatClient.getCompletionWithTools(I,e,l,c)}};G();var Gj=class extends PA{constructor(I,e,l,c){super(I,e,l,c)}getCompletionOptions(I,e){return{...this.model.startsWith("gpt-4")?{temperature:0,top_p:.95,frequency_penalty:0,presence_penalty:0,parallel_tool_calls:I?!1:void 0}:{},tool_choice:e?.toolChoice}}async*getCompletionWithTools(I,e,l,c){let n=await super.getCompletionWithTools(I,e,l,c);for await(let a of n)a.kind==="message"?yield{...a,message:eA({...a.message,reasoning_text:a.message?.cot_summary})}:yield a}};G();var oj=class extends qA{constructor(I,e,l,c){super(I,e,l,c)}};G();var waI=class extends PJ{constructor(I){super(I)}setInitiatorHeader(I){}listModels(){return Promise.resolve([])}},dj=class{async createClient(I,e,l){e.startGroup("configured settings:",8),e.debug(JSON.stringify(I,null,2)),e.endGroup(8);let c=I.api?.openai?.apiKey,n=I.api?.openai?.azureKeyVaultUri,a=I.api?.openai?.azureSecretName;if(!c&&n){e.debug("No API_KEY provided, trying secret provider");let d=gaI(n,e);try{c=await d.getSecret(a||"azure-openai-api-key")}catch(i){e.debug(`Failed to get API Key from secret provider:
356
356
  ${i}`)}}let s=SmI(I);e.debug(`Using Azure Open API at ${s}`);let o={baseURL:`${new URL(s).origin}/openai`,apiVersion:I.api?.openai?.azure?.apiVersion||"2024-10-21",deployment:l?.model,defaultHeaders:l?.requestHeaders};if(c)o={...o,apiKey:c},e.debug("Using Azure OpenAI API Key");else{let d=new Wm,h=flI(d,"https://cognitiveservices.azure.com/.default");o={...o,azureADTokenProvider:h},e.debug("Using Azure Managed Identity")}return new waI(o)}};G();var HaI=class extends ve{constructor(I){super(I)}setInitiatorHeader(I){}listModels(){return Promise.resolve([])}},ij=class{async createClient(I,e,l){e.startGroup("configured settings:",8),e.debug(JSON.stringify(I,null,2)),e.endGroup(8);let c=UmI(I),n=I.api?.openai?.baseUrl,a=l?.requestHeaders;return new HaI({baseURL:n,apiKey:c,defaultHeaders:a})}};function EaI(t,I,e,l){switch(e){case"sweagent-aip":return new KO(t,I,l);case"sweagent-anthropic":return new ZT(t,I,l);case"sweagent-capi":return new l4(t,I,l);case"sweagent-openai":return l?.thinkingMode?new oj(b5I(t),t,I,l):new Gj(b5I(t),t,I,l);default:return new l4(t,I,l)}}function b5I(t){return t.api?.openai?.azure?.url?new dj:new ij}G();G();G();G();G();function vaI({onlyFirst:t=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(e,t?void 0:"g")}var oRe=vaI();function CaI(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(oRe,"")}import{exec as dRe}from"child_process";import{promisify as iRe}from"util";var FZ="___BEGIN___COMMAND_OUTPUT_MARKER___",m5I=`
357
- ${FZ}`,n4="___BEGIN___COMMAND_DONE_MARKER___",bRe=new RegExp(`${n4}(\\d+)`),mRe=100,h5I=5e3,c4=10*1024*1024;var _A=class t{constructor(I,e,l={},c){this.config=I;this.createdAtMs=Date.now(),this.lastUsedAtMs=Date.now();let n=this.config.shellType==="powershell",a=n?"pwsh.exe":"bash",s=n?[]:["--norc","--noprofile"],r=n?!1:void 0;this.process=c(a,s,{name:"xterm-color",cols:120,rows:80,cwd:e,env:l,useConpty:r}),this.process.onData(o=>{let i=CaI(o).replaceAll("\r","");if(this.outputBuffer.length+i.length>c4){this.wasTruncated=!0;let h=this.outputBuffer.lastIndexOf(FZ);if(h!==-1){let p=this.outputBuffer.substring(0,h+FZ.length),Z=this.outputBuffer.substring(h+FZ.length),W=c4-i.length-p.length;if(W>0){let N=Pc(Z,"output",W,"start");this.outputBuffer=p+N}else{this.outputBuffer=p+Pc(i,"output",c4-p.length,"start");return}}else{let p=c4-i.length;if(p>0)this.outputBuffer=Pc(this.outputBuffer,"output",p,"start");else{this.outputBuffer=Pc(i,"output",c4,"start");return}}}this.outputBuffer+=i}),this.process.onExit(o=>this.shutdown())}process;outputBuffer="";isCommandInProgress=!1;wasTruncated=!1;createdAtMs;lastUsedAtMs;onPartialOutputChanged;static shellIsSupportedCache=new Map;writeDelay=Promise.resolve();static async create(I,e,l={}){await t.ensureShellIsSupported(I.shellType);let c=await import("node-pty"),n=new t(I,e,l,c.spawn);return await n.initializeShellEnvironment(),n}setPartialOutputChangedCallback(I){this.onPartialOutputChanged=I}async executeCommand(I,e){if(this.updateLastUsedTime(),!this.process)throw new Error(`Failed to start ${this.config.shellType} process`);if(this.tryStartCommand(I))return await(e?this.waitForCommandCompletionOrTimeout(e):this.waitForCommandCompletion())}async cwd(){try{let I=this.config.shellType==="powershell"?"(pwd).Path":"pwd",e=await this.executeCommand(I,h5I);return e?.exitCode===0?e.output:void 0}catch{return}}async tryExecuteAsyncCommand(I){return this.updateLastUsedTime(),this.tryStartCommand(I)?(this.waitForCommandCompletion().catch(e=>{}),this.config.shellType==="powershell"&&await new Promise(e=>setTimeout(e,250)),!0):!1}trySendInput(I){if(this.updateLastUsedTime(),!this.process)throw new Error(`Failed to start ${this.config.shellType} process`);if(!this.isCommandInProgress)return!1;let e=this.config.shellType==="powershell"?I.replaceAll(`
357
+ ${FZ}`,n4="___BEGIN___COMMAND_DONE_MARKER___",bRe=new RegExp(`${n4}(\\d+)`),mRe=100,h5I=5e3,c4=10*1024*1024;var _A=class t{constructor(I,e,l={},c){this.config=I;this.createdAtMs=Date.now(),this.lastUsedAtMs=Date.now();let n=this.config.shellType==="powershell",a=n?"pwsh.exe":"bash",s=n?["-nop","-nol"]:["--norc","--noprofile"],r=n?!1:void 0;this.process=c(a,s,{name:"xterm-color",cols:120,rows:80,cwd:e,env:l,useConpty:r}),this.process.onData(o=>{let i=CaI(o).replaceAll("\r","");if(this.outputBuffer.length+i.length>c4){this.wasTruncated=!0;let h=this.outputBuffer.lastIndexOf(FZ);if(h!==-1){let p=this.outputBuffer.substring(0,h+FZ.length),Z=this.outputBuffer.substring(h+FZ.length),W=c4-i.length-p.length;if(W>0){let N=Pc(Z,"output",W,"start");this.outputBuffer=p+N}else{this.outputBuffer=p+Pc(i,"output",c4-p.length,"start");return}}else{let p=c4-i.length;if(p>0)this.outputBuffer=Pc(this.outputBuffer,"output",p,"start");else{this.outputBuffer=Pc(i,"output",c4,"start");return}}}this.outputBuffer+=i}),this.process.onExit(o=>this.shutdown())}process;outputBuffer="";isCommandInProgress=!1;wasTruncated=!1;createdAtMs;lastUsedAtMs;onPartialOutputChanged;static shellIsSupportedCache=new Map;writeDelay=Promise.resolve();static async create(I,e,l={}){await t.ensureShellIsSupported(I.shellType);let c=await import("node-pty"),n=new t(I,e,l,c.spawn);return await n.initializeShellEnvironment(),n}setPartialOutputChangedCallback(I){this.onPartialOutputChanged=I}async executeCommand(I,e){if(this.updateLastUsedTime(),!this.process)throw new Error(`Failed to start ${this.config.shellType} process`);if(this.tryStartCommand(I))return await(e?this.waitForCommandCompletionOrTimeout(e):this.waitForCommandCompletion())}async cwd(){try{let I=this.config.shellType==="powershell"?"(pwd).Path":"pwd",e=await this.executeCommand(I,h5I);return e?.exitCode===0?e.output:void 0}catch{return}}async tryExecuteAsyncCommand(I){return this.updateLastUsedTime(),this.tryStartCommand(I)?(this.waitForCommandCompletion().catch(e=>{}),this.config.shellType==="powershell"&&await new Promise(e=>setTimeout(e,250)),!0):!1}trySendInput(I){if(this.updateLastUsedTime(),!this.process)throw new Error(`Failed to start ${this.config.shellType} process`);if(!this.isCommandInProgress)return!1;let e=this.config.shellType==="powershell"?I.replaceAll(`
358
358
  `,"\r"):I;return this.writeDelay=hRe(this.writeDelay,this.process,e),!0}readOutput(){this.updateLastUsedTime();let I=this.tryExtractOutputFromDoneMarker();if(I)return I;let e=this.outputBuffer.lastIndexOf(m5I);return{output:e>-1?this.outputBuffer.substring(e+m5I.length).trim():"",exitCode:void 0,truncated:this.wasTruncated}}getStats(){return{createdAtMs:this.createdAtMs,lastUsedAtMs:this.lastUsedAtMs}}waitForCommandCompletionOrTimeout(I){let e=this.waitForCommandCompletion(),l=new Promise((c,n)=>{setTimeout(()=>{n(new Error("Command timed out"))},I)});return Promise.race([e,l])}clearBuffer(){let I=this.outputBuffer.lastIndexOf(n4);this.outputBuffer=I>0?`${FZ}
359
359
  ${this.outputBuffer.substring(I).trim()}`:""}shutdown(){if(this.process){this.isCommandInProgress=!1;try{this.process.kill()}catch{}this.process=void 0,this.outputBuffer=""}}updateLastUsedTime(){this.lastUsedAtMs=Date.now()}async initializeShellEnvironment(){if(!this.process)throw new Error(`Failed to start ${this.config.shellType} process`);let e=this.config.shellType==="powershell"?`function prompt {" "}; $PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'`:'PS1="";PS2=""';await this.executeCommand(e,h5I)}tryStartCommand(I){if(!this.process)throw new Error(`Failed to start ${this.config.shellType} process`);if(this.isCommandInProgress)return!1;this.isCommandInProgress=!0,this.wasTruncated=!1;let l=this.config.shellType==="powershell"?`$LASTEXITCODE = 0; echo ${FZ}; &{\r${I}\r}; echo ${n4}$LASTEXITCODE\r`:`
360
360
  {