@github/copilot 0.0.336 → 0.0.337-1
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 +3 -3
- package/package.json +2 -2
- package/sdk/index.js +2 -2
- package/sdk/index.js.map +2 -2
package/index.js
CHANGED
|
@@ -822,9 +822,9 @@ extensions:
|
|
|
822
822
|
`,r=t.map(o=>` - [${FNt.stringify(o.path,{lineWidth:0}).trim()}, ${o.startLine}, ${o.endLine}]
|
|
823
823
|
`).join("");r||(r=` - ["", 0, 0]
|
|
824
824
|
`);let a=I+r,s=aJe.join(n,"pr-diff-range.yml");return rJe.writeFileSync(s,a),l(`Wrote pr-diff-range extension pack to ${s}:
|
|
825
|
-
${a}`,8),n}c();import*as Lee from"os";import*as tZe from"fs";var z4l=.05,vNt=1024*1024;function fNt(t){let e=Lee.platform(),l=j4l(e,t)/(1024*1024),n=P4l(l,e),I=Math.floor(l-n);return t(`Using ${I} MB for CodeQL, out of ${l} MB total.`,8),I}function P4l(t,e){let l=1024*(e==="win32"?1.5:1),n=z4l*Math.max(t-8*1024,0);return l+n}function j4l(t,e){let l=[Lee.totalmem()];return t==="linux"&&l.push(...["/sys/fs/cgroup/memory/memory.limit_in_bytes","/sys/fs/cgroup/memory.max"].map(I=>K4l(I,e)).filter(I=>I!==void 0).map(I=>I)),Math.min(...l)}function K4l(t,e){if(!tZe.existsSync(t)){e(`While resolving RAM, did not find a cgroup memory limit at ${t}.`,8);return}let l=Number(tZe.readFileSync(t,"utf8"));if(!Number.isInteger(l)){e(`While resolving RAM, ignored the file ${t} that may contain a cgroup memory limit as this file did not contain an integer.`,8);return}let n=`${Math.floor(l/(1024*1024))} MiB`;if(l>Lee.totalmem()){e(`While resolving RAM, ignored the file ${t} that may contain a cgroup memory limit as its contents ${n} were greater than the total amount of system memory.`,8);return}if(l<vNt){e(`While resolving RAM, ignored a cgroup limit of ${n} in ${t} as it was below ${vNt/(1024*1024)} MiB.`,8);return}return e(`While resolving RAM, found a cgroup limit of ${n} in ${t}.`,8),l}c();import*as I_ from"fs";import*as lZe from"os";function HNt(t){let e=[lZe.cpus().length];return lZe.platform()==="linux"&&(e.push(...["/sys/fs/cgroup/cpuset.cpus.effective","/sys/fs/cgroup/cpuset.cpus"].map(n=>$4l(n,t)).filter(n=>n!==void 0&&n>0).map(n=>n)),e.push(...["/sys/fs/cgroup/cpu.max"].map(n=>q4l(n,t)).filter(n=>n!==void 0&&n>0).map(n=>n))),Math.min(...e)}function q4l(t,e){if(!I_.existsSync(t)){e(`While resolving threads, did not find a cgroup CPU file at ${t}.`,8);return}let n=I_.readFileSync(t,"utf-8").split(" ");if(n.length!==2){e(`While resolving threads, did not use cgroup CPU file at ${t} because it contained ${n.length} value(s) rather than the two expected.`,8);return}let I=n[0];if(I==="max")return;let r=n[1],a=Math.floor(parseInt(I)/parseInt(r));return e(`While resolving threads, found a cgroup CPU file with ${a} CPUs in ${t}.`,8),a}function $4l(t,e){if(!I_.existsSync(t)){e(`While resolving threads, did not find a cgroup CPUs file at ${t}.`,8);return}let l=0,n=I_.readFileSync(t,"utf-8").trim();if(n.length!==0){for(let I of n.split(","))if(!I.includes("-"))++l;else{let r=parseInt(I.split("-")[0]),a=parseInt(I.split("-")[1]);l+=a-r+1}return e(`While resolving threads, found a cgroup CPUs file with ${l} CPUs in ${t}.`,8),l}}var r_=class t{constructor(e,l,n,I,r){this.executablePath=e;this.databaseDir=l;this.settings=n;this.sourceRoot=I;this.progressLogger=r;this.ram=this.resolveRam(),this.threads=this.resolveThreads()}static DIFF_INFORMED_FEATURE_FLAG_NAME="copilot_swe_agent_codeql_diff_informed";ram;repositorySizeCache=new Map;threads;async createDatabase(e){let
|
|
825
|
+
${a}`,8),n}c();import*as Lee from"os";import*as tZe from"fs";var z4l=.05,vNt=1024*1024;function fNt(t){let e=Lee.platform(),l=j4l(e,t)/(1024*1024),n=P4l(l,e),I=Math.floor(l-n);return t(`Using ${I} MB for CodeQL, out of ${l} MB total.`,8),I}function P4l(t,e){let l=1024*(e==="win32"?1.5:1),n=z4l*Math.max(t-8*1024,0);return l+n}function j4l(t,e){let l=[Lee.totalmem()];return t==="linux"&&l.push(...["/sys/fs/cgroup/memory/memory.limit_in_bytes","/sys/fs/cgroup/memory.max"].map(I=>K4l(I,e)).filter(I=>I!==void 0).map(I=>I)),Math.min(...l)}function K4l(t,e){if(!tZe.existsSync(t)){e(`While resolving RAM, did not find a cgroup memory limit at ${t}.`,8);return}let l=Number(tZe.readFileSync(t,"utf8"));if(!Number.isInteger(l)){e(`While resolving RAM, ignored the file ${t} that may contain a cgroup memory limit as this file did not contain an integer.`,8);return}let n=`${Math.floor(l/(1024*1024))} MiB`;if(l>Lee.totalmem()){e(`While resolving RAM, ignored the file ${t} that may contain a cgroup memory limit as its contents ${n} were greater than the total amount of system memory.`,8);return}if(l<vNt){e(`While resolving RAM, ignored a cgroup limit of ${n} in ${t} as it was below ${vNt/(1024*1024)} MiB.`,8);return}return e(`While resolving RAM, found a cgroup limit of ${n} in ${t}.`,8),l}c();import*as I_ from"fs";import*as lZe from"os";function HNt(t){let e=[lZe.cpus().length];return lZe.platform()==="linux"&&(e.push(...["/sys/fs/cgroup/cpuset.cpus.effective","/sys/fs/cgroup/cpuset.cpus"].map(n=>$4l(n,t)).filter(n=>n!==void 0&&n>0).map(n=>n)),e.push(...["/sys/fs/cgroup/cpu.max"].map(n=>q4l(n,t)).filter(n=>n!==void 0&&n>0).map(n=>n))),Math.min(...e)}function q4l(t,e){if(!I_.existsSync(t)){e(`While resolving threads, did not find a cgroup CPU file at ${t}.`,8);return}let n=I_.readFileSync(t,"utf-8").split(" ");if(n.length!==2){e(`While resolving threads, did not use cgroup CPU file at ${t} because it contained ${n.length} value(s) rather than the two expected.`,8);return}let I=n[0];if(I==="max")return;let r=n[1],a=Math.floor(parseInt(I)/parseInt(r));return e(`While resolving threads, found a cgroup CPU file with ${a} CPUs in ${t}.`,8),a}function $4l(t,e){if(!I_.existsSync(t)){e(`While resolving threads, did not find a cgroup CPUs file at ${t}.`,8);return}let l=0,n=I_.readFileSync(t,"utf-8").trim();if(n.length!==0){for(let I of n.split(","))if(!I.includes("-"))++l;else{let r=parseInt(I.split("-")[0]),a=parseInt(I.split("-")[1]);l+=a-r+1}return e(`While resolving threads, found a cgroup CPUs file with ${l} CPUs in ${t}.`,8),l}}var r_=class t{constructor(e,l,n,I,r){this.executablePath=e;this.databaseDir=l;this.settings=n;this.sourceRoot=I;this.progressLogger=r;this.ram=this.resolveRam(),this.threads=this.resolveThreads()}static DIFF_INFORMED_FEATURE_FLAG_NAME="copilot_swe_agent_codeql_diff_informed";ram;repositorySizeCache=new Map;threads;async createDatabase(e,l){let n=`${this.databaseDir}/${l}`,I=this.getBuildMode(l);return await this.execCommand(e,`database create ${this.ram} ${this.threads} --no-sublanguage-file-coverage --no-calculate-baseline --overwrite --language ${l} --build-mode ${I} --source-root ${this.sourceRoot} ${n}`),n}static AUTOBUILD_ONLY_LANGUAGES=["cpp","go","swift"];getBuildMode(e){return t.AUTOBUILD_ONLY_LANGUAGES.includes(e)?"autobuild":"none"}async analyzeDatabase(e,l,n){let I=[];if(Wo(this.settings,t.DIFF_INFORMED_FEATURE_FLAG_NAME)){let d=a_.mkdtempSync(Jee.join(sJe.tmpdir(),"codeql-")),u=CNt(n,d,this.progressLogger);this.progressLogger(`Created diff range data extension pack at ${u}`,8),I=["--additional-packs",u,"--extension-packs","codeql-action/pr-diff-range"]}let r=`${this.databaseDir}/${l}`,a=`${r}/results-${l}.json`;await a_.promises.rm(a,{force:!0}),this.progressLogger(`Analyzing database at ${r} for language ${l}`);let s=["database","analyze",this.ram,this.threads,"--format","sarifv2.1.0","--output",a,...I,r,`codeql/${l}-queries`];return await this.execCommand(e,s.join(" ")),new IAe(a,this.progressLogger.bind(this)).summarize(l,n)}async version(e){let l=await this.execCommand(e,"version --format json");try{return JSON.parse(l).version}catch{throw new Error(`Failed to parse CodeQL version output: ${l}`)}}async getRepositorySize(e){return this.repositorySizeCache.has(e)||this.repositorySizeCache.set(e,await this.computeRepositorySize(e)),this.repositorySizeCache.get(e)}async execCommand(e,l){return this.progressLogger(`Executing CodeQL command: ${l}`),new Promise((n,I)=>{nZe.exec(`${this.executablePath} ${l}`,{signal:e},(r,a,s)=>{let o=r?1:4;this.progressLogger(s,o,"CodeQL Output"),r?r.name=="AbortError"?I(r):I(new Error(`Error executing command: ${r} ${s}`)):n(a)})})}resolveRam(){try{return`--ram ${fNt(this.progressLogger)}`}catch(e){return this.progressLogger(`Failed to resolve RAM, not passing --ram flag to CodeQL: ${e}`,2),""}}resolveThreads(){try{return`--threads ${HNt(this.progressLogger)}`}catch(e){return this.progressLogger(`Failed to resolve threads, not passing --threads flag to CodeQL: ${e}`,2),""}}getSccExecutablePath(){let e=Jee.dirname(this.executablePath),l;switch(sJe.platform()){case"win32":l=Jee.join(e,"tools/win64/scc.exe");break;case"darwin":l=Jee.join(e,"tools/osx64/scc");break;case"linux":l=Jee.join(e,"tools/linux64/scc");break;default:return}if(a_.existsSync(l))return l}async computeRepositorySize(e){let l=this.getSccExecutablePath();if(!l){this.progressLogger(`SCC executable not found for platform: ${sJe.platform()}`,2);return}let n=Hbt(e);if(!n){this.progressLogger(`No file extensions found for language: ${e}`,2);return}let I=["--exclude-dir",".git,.hg,.svn,target,build,dist","--format","json","--include-ext",n.join(","),"--no-complexity","--no-cocomo"],r=nZe.spawn(l,I,{cwd:this.sourceRoot}),a="",s="";r.stdout.on("data",d=>{a+=d}),r.stderr.on("data",d=>{s+=d});let o=await new Promise(d=>{r.on("close",d)});if(o!==0){this.progressLogger(`SCC failed with exit code ${o}: ${s}`,2);return}try{let u=JSON.parse(a).reduce((G,p)=>G+p.Bytes,0);return this.progressLogger(`SCC output for ${e}: ${u} bytes`,4),u}catch(d){this.progressLogger(`Failed to parse SCC output: ${d}`,2);return}}};var kNt="codeql-bundle-linux64.tar.gz",lkl=new NM;async function nkl(t,e){let I=(await new ahe({auth:t}).rest.repos.getLatestRelease({owner:"github",repo:"codeql-action"})).data.assets.find(r=>r.name===kNt);if(I)return e(`CodeQL asset ID: ${I.id}`),I.id;throw new Error("CodeQL asset not found")}async function Ikl(t,e,l,n){let I=await fetch(`https://api.github.com/repos/github/codeql-action/releases/assets/${t}`,{headers:{Authorization:`token ${l}`,Accept:"application/octet-stream"},redirect:"follow"});if(!I.ok||!I.body)throw new Error(`Failed to download asset: ${I.statusText}`);let r=s_.join(e,kNt),a=qY.createWriteStream(r,{flags:"wx"});return await tkl(ekl.fromWeb(I.body).pipe(a)),n(`CodeQL downloaded to ${r}`),r}async function rkl(t,e,l){await qY.promises.mkdir(e,{recursive:!0});try{return await yke({file:t,cwd:e}),l(`CodeQL unzipped to ${e}`),BNt(e)}catch(n){throw lkl.error(`Error unzipping CodeQL: ${String(n)}`),n}}async function akl(t,e,l){let n=process.env.GITHUB_TOKEN||I3(l),I=await nkl(n,e),r=skl(t);await qY.promises.mkdir(r,{recursive:!0});let a=await Ikl(I,r,n,e);return await rkl(a,t,e),await qY.promises.rm(a),JNt(t)}async function LNt(t,e,l,n){let I=okl(t);await qY.promises.mkdir(I,{recursive:!0});let r=await ikl(n);if(r)return new r_(r,I,l,e,n);let a=JNt(t);if(await oJe(a))return n(`CodeQL already exists at ${a}`),new r_(a,I,l,e,n);try{let s=await akl(t,n,l);return new r_(s,I,l,e,n)}catch(s){throw n(`Error ensuring CodeQL: ${String(s)}`,1),s}}function skl(t){return s_.join(t,"codeql-download")}function JNt(t){return s_.join(BNt(t),"codeql")}function BNt(t){return s_.join(t,"codeql")}function okl(t){return s_.join(t,"dbs")}async function ikl(t){if(!process.env.RUNNER_TOOL_CACHE)return;let e=IZe.findAllVersions("CodeQL");if(!e.length)return;let l=e[0],n=IZe.find("CodeQL",l,XNt.arch());if(n){let I=s_.join(n,"codeql","codeql");if(t(`CodeQL directory found in toolcache at '${n}'.`),!await oJe(I)){let r;throw await oJe(n)?r=qY.readdirSync(n):r=["path does not exist"],new Error(`CodeQL executable not found at '${I}'. Contents of toolcache: '${r.join(", ")}'.`)}return I}}async function oJe(t){try{return await qY.promises.stat(t),!0}catch{return!1}}var rZe=class t{constructor(e,l,n,I,r){this.config=e;this.git=l;this.baseCommit=n;this.settings=I;this.logger=r}static DEFAULT_MAX_REPO_SIZE_BYTES=1e7;static DEFAULT_TIMEOUT_MS=180*1e3;static TOOL_NAME="codeql_checker";static CODEQL_CHECKER_ENABLED_FF="copilot_swe_agent_enable_security_tool";static CODEQL_CHECKER_DISABLED_FF="copilot_swe_agent_enable_security_tool_disabled";static isEnabled(e){return Wo(e,t.CODEQL_CHECKER_ENABLED_FF)&&!Wo(e,t.CODEQL_CHECKER_DISABLED_FF)}executor;async getCodeQLCheckerTool(){let e=await this.createCodeQLScratchDir(this.config.location);return this.executor=await LNt(e,this.config.location,this.settings,this.logProgress.bind(this)),{name:t.TOOL_NAME,description:`This is a security tool that discovers vulnerabilities in code using CodeQL. It must always be run when there are code changes.
|
|
826
826
|
It is run after committing all changed code and before the final verification. Feedback from this tool must be incorporated into
|
|
827
|
-
the change and then the tool must be re-run.`,input_schema:{type:"object",properties:{}},callback:this.callback.bind(this),safeForTelemetry:!0}}async callback(){let e={},l="unknown",n=Date.now();try{if(!this.executor)throw new Error("CodeQL Executor is not initialized.");l=await this.executor.version(),await this.git.stageChanges(this.config.location);let
|
|
827
|
+
the change and then the tool must be re-run.`,input_schema:{type:"object",properties:{}},callback:this.callback.bind(this),safeForTelemetry:!0}}async callback(){let e={},l="unknown",n=Date.now();try{if(!this.executor)throw new Error("CodeQL Executor is not initialized.");let I=AbortSignal.timeout(this.settings.tools?.codeql?.timeout??t.DEFAULT_TIMEOUT_MS);I.throwIfAborted(),l=await this.executor.version(I),await this.git.stageChanges(this.config.location);let r=await this.git.getDiffRanges(this.config.location,this.baseCommit),a=fbt(r);a.length>0?this.logProgress(`Found ${a.join(", ")} languages to analyze.`):this.logProgress("No languages found to analyze.");let s=[],o=!0;for(let G of a){if(I.throwIfAborted(),!await this.shouldAnalyzeLanguage(this.executor,G)){e[G]={skipped:!0};continue}let p=Date.now();try{await this.executor.createDatabase(I,G),this.logProgress(`Created database for ${G}.`),e[G]={databaseCreationSuccess:!0,databaseCreationTimeMs:Date.now()-p}}catch(W){o=!1;let E=`Error creating database for ${G}: ${String(W)}`;this.logProgress(E,1),e[G]={databaseCreationError:W instanceof Error?W:new Error(String(W)),databaseCreationSuccess:!1,databaseCreationTimeMs:Date.now()-p};continue}I.throwIfAborted();let h=Date.now();try{let W=await this.executor.analyzeDatabase(I,G,r);s.push(W);let E=W.alerts.length;this.logProgress(`Completed analysis of ${G}. ${E} ${E===1?"alert":"alerts"} found.`),e[G]={...e[G],analysisSuccess:!0,analysisTimeMs:Date.now()-h,analysisRuleIds:W.alerts.flatMap(R=>R.ruleId?[R.ruleId]:[]),querySuite:`${G}-code-scanning`}}catch(W){o=!1;let E=`Error analyzing database for ${G}: ${String(W)}`;this.logProgress(E,1),e[G]={...e[G],analysisError:W instanceof Error?W:new Error(String(W)),analysisSuccess:!1,analysisTimeMs:Date.now()-h,analysisRuleIds:[]}}}let d=s.filter(G=>G.alerts.length>0).reduce((G,p)=>G+p.alerts.length,0),u=a.length===0?"No code changes detected for languages that CodeQL can analyze, so no analysis was performed.":`Analysis Result for '${a}'. Found ${d} alert(s): ${JSON.stringify(s,null,2)}`;return{resultType:o?"success":"failure",textResultForLlm:u,sessionLog:`Analysis completed successfully for '${a}'.`,toolTelemetry:{event:"tool_call_executed",properties:{"codeql.version":l},metrics:{"codeql.languages.count":a.length,"codeql.total.alerts":d,"codeql.duration.ms":Date.now()-n},restrictedProperties:{}}}}catch(I){let r=this.isAbortError(I)?`Operation cancelled due to timeout. Do not re-run the ${t.TOOL_NAME} tool because it will not complete successfully.`:`Error in CodeQL Checker: '${String(I)}'`;this.logProgress(r,1);let a={event:"tool_call_executed",properties:{"codeql.version":l,"codeql.aborted":this.isAbortError(I)?"true":"false"},metrics:{"codeql.languages.count":0,"codeql.total.alerts":0,"codeql.duration.ms":Date.now()-n},restrictedProperties:{"codeql.stack":I instanceof Error?I.stack??"":""}};return Xg({telemetry:a},I,"codeql.error"),{resultType:"failure",textResultForLlm:r,sessionLog:r,toolTelemetry:a}}finally{let I=this.createTelemetryByLanguage(e,l);for(let r of I)this.config.callback?.progress({kind:"telemetry",telemetry:r})}}isAbortError(e){return e instanceof Error&&(e.name==="TimeoutError"||e.name==="AbortError")}async logProgress(e,l=4,n){switch(n&&this.logger.startGroup(n),l){case 8:this.logger.debug(e);break;case 4:this.logger.info(e);break;case 2:this.logger.warning(e);break;case 1:this.logger.error(e);break;default:this.logger.log(e);break}n&&this.logger.endGroup(),this.config.callback&&await this.config.callback?.progress({kind:"log",message:e})}async createCodeQLScratchDir(e){let l=xNt.normalize(xNt.join(e,"..",".codeql-scratch"));return await SNt.promises.mkdir(l,{recursive:!0}),l}createTelemetryByLanguage(e,l){let n=[];for(let[I,r]of Object.entries(e)){if(Fbt(r)){let s={event:"codeql-checker-completion",properties:{"codeql.language":I,"codeql.skipped":"true","codeql.version":l},metrics:{},restrictedProperties:{}};n.push(s);continue}let a={event:"codeql-checker-completion",properties:{"codeql.language":I,"codeql.databaseCreationSuccess":r.databaseCreationSuccess?"true":"false","codeql.analysisRuleIds":EM(r)?r.analysisRuleIds.join(","):"","codeql.version":l,"codeql.querySuite":EM(r)?r.querySuite:void 0},metrics:{"codeql.databaseCreationTimeMs":r.databaseCreationTimeMs,"codeql.analysisTimeMs":EM(r)?r.analysisTimeMs:void 0,"codeql.alertCount":EM(r)?r.analysisRuleIds.length:0},restrictedProperties:{}};r.databaseCreationError&&(Xg({telemetry:a},r.databaseCreationError,"codeql.databaseCreationError"),a.restrictedProperties["codeql.databaseCreationStack"]=String(r.databaseCreationError.stack)),EM(r)&&(a.properties["codeql.analysisSuccess"]=r.analysisSuccess?"true":"false",r.analysisError&&(Xg({telemetry:a},r.analysisError,"codeql.analysisError"),a.restrictedProperties["codeql.analysisStack"]=String(r.analysisError.stack))),n.push(a)}return n}async shouldAnalyzeLanguage(e,l){if(l=="actions")return!0;let n=await e.getRepositorySize(l);if(n===void 0)return!0;let I=n<=t.DEFAULT_MAX_REPO_SIZE_BYTES;return I||this.logProgress(`Skipping analysis for ${l} because the repository size is ${n} bytes, which exceeds the limit of ${t.DEFAULT_MAX_REPO_SIZE_BYTES} bytes.`,2),I}};c();var ckl="gh-advisory-database",TNt="copilot_swe_agent_validation_agent_dependencies",dkl="security agent",UNt={name:ckl,description:"Security tool that checks the GitHub advisory DB and informs you about reported vulnerabilities in dependencies. Run this tool ALWAYS before you add new dependencies, to check if they contain vulnerabilities. This is NOT optional. If you don't know the version number you are going to install, retrieve that first. Feedback from this tool MUST be incorporated. Re-run the tool as appropriate.",input_schema:{type:"object",properties:{dependencies:{type:"array",items:{type:"object",properties:{version:{type:"string",description:"The version of the dependency in semver format. Examples: '1.0.0', '2.1.0'."},name:{type:"string",description:"The name of the dependency. Examples: 'express', 'lodash'."}},required:["name","version"]}}},required:["dependencies"]},callback:ukl,safeForTelemetry:{name:!0,inputsNames:!1}};async function ukl({dependencies:t},e){if(!t||t.length===0)return{textResultForLlm:"No dependencies provided for checking.",resultType:"success",sessionLog:"No dependencies provided for checking.",toolTelemetry:{}};let l=[];for(let n of t){let I=bkl(n);if(I)return Promise.resolve(I);try{let r=e?I3(e.settings):process.env.GH_TOKEN;if(!r){let s="GitHub token is required to use the dependency checker tool. Please set it in the settings or as the GH_TOKEN environment variable.";return{textResultForLlm:s,resultType:"failure",sessionLog:s,toolTelemetry:{properties:{error:s}}}}let a=new ahe({userAgent:dkl,auth:r});l.push(...await mkl(a,n))}catch(r){let a=`Error checking dependency ${n.name}: ${String(r)}`,s=r instanceof Error?r.stack:void 0;return{textResultForLlm:a,resultType:"failure",sessionLog:a,toolTelemetry:{restrictedProperties:{dep:`${n.name}@${n.version}`,error:a,stackTrace:s}}}}}if(l.length===0)return{textResultForLlm:"No vulnerabilities found in the provided dependencies.",resultType:"success",sessionLog:"No vulnerabilities found in the provided dependencies.",toolTelemetry:{}};{let n=Gkl(l);return{textResultForLlm:n,resultType:"success",sessionLog:n,toolTelemetry:{restrictedProperties:{vulnerableDeps:l.map(I=>`${I.name}@${I.version}`).join(", ")},metrics:{vulnerableDependencies:l.length}}}}}async function mkl(t,e){let l=await t.securityAdvisories.listGlobalAdvisories({affects:`${e.name}@${e.version}`,severity:"high"}),n=await t.securityAdvisories.listGlobalAdvisories({affects:`${e.name}@${e.version}`,severity:"critical"}),I=await t.securityAdvisories.listGlobalAdvisories({affects:`${e.name}@${e.version}`,type:"malware"}),r=[...l.data,...n.data,...I.data];return r.length===0?[]:r.flatMap(a=>a.vulnerabilities?.map(s=>({name:e.name,version:e.version,summary:a.summary,ecosystem:s.package.ecosystem,affectedVersions:s.vulnerable_version_range??"",patchedVersion:s.first_patched_version??"not available",severity:a.severity,type:a.type}))??[])}function Gkl(t){return t.map(e=>{let l=e.type==="malware"?"is malware":"has a vulnerability";return`Dependency ${e.name} version ${e.version} in ecosystem ${e.ecosystem} ${l}: ${e.summary}. Affected versions: ${e.affectedVersions}. Patched version: ${e.patchedVersion}.`}).join(`
|
|
828
828
|
|
|
829
829
|
`)}function ONt(t){if(typeof t!="string"||t.trim()==="")return"parameter must be a non-empty string."}function bkl(t){let e=[],l=ONt(t.name);l&&e.push(`name: ${l}`);let n=ONt(t.version);if(n&&e.push(`version: ${n}`),e.length>0){let I=`Invalid parameters found for dependency ${t.name}: ${e.join(", ")}`;return{textResultForLlm:I,resultType:"failure",sessionLog:I,toolTelemetry:{}}}}c();var MNt="reply_to_comment",_Nt=(t,e)=>({name:MNt,description:`Reply to new comments. Use when you've completed a meaningful unit of work that specifically addresses the request, question, or feedback in the comment.
|
|
830
830
|
* Use this tool no more than once per <comment_id>, and only after you have completed meaningful work that specifically addresses the text in the comment.
|
|
@@ -2288,7 +2288,7 @@ Run `+Bl.cyan("{updateCommand}")+" to update",r=e.message||I;e.boxenOptions??={p
|
|
|
2288
2288
|
`)||U.includes(" ")?{isAtMention:!1,atPosition:-1,query:""}:{isAtMention:!0,atPosition:S,query:U}},[t.text,t.cursorPosition]);(0,Bk.useEffect)(()=>{if(!u.isAtMention){I([]),a(0);return}let C=!1,L=async()=>{try{let U=await d.search(u.query),_=[...U];u.query===""&&l&&(_=[...l.getDirectories().map(T=>({path:T,relativePath:`[DIR] ${T}`,score:1})),...U]),C||(I(_),a(0))}catch{C||(I([]),a(0))}},S=setTimeout(()=>{L()},200);return()=>{C=!0,clearTimeout(S)}},[u.query,u.isAtMention,d]);let G=()=>{n.length!==0&&a(C=>C>0?C-1:n.length-1)},p=()=>{n.length!==0&&a(C=>C<n.length-1?C+1:0)},h=()=>{if(!u.isAtMention||n.length===0)return null;let C=n[r];if(!C)return null;let L=`@${C.relativePath}`,S=`${L} `,{text:U,cursorPosition:_}=t,z=U.slice(0,u.atPosition),q=U.slice(_),T=z+S+q,$={displayText:L,fullPath:C.path,type:C.relativePath.startsWith("[DIR]")?"directory":"file",startIndex:u.atPosition};return o(ue=>{let ge=new Map(ue);return ge.set($.startIndex,$),ge}),t.setText(T),t.setCursorPosition(u.atPosition+S.length),C.relativePath},W=()=>{I([]),a(0)},E=()=>{o(new Map)};return[{isActive:u.isAtMention&&n.length>0,query:u.query,suggestions:n,selectedIndex:r,atPosition:u.atPosition,storedMentions:s},{navigateUp:G,navigateDown:p,complete:h,reset:W,clearStoredMentions:E}]}c();var OE=dt(bl(),1);function tIl(t){let{cliModel:e,sessionManager:l,currentWorkingDirectory:n,stdoutColumns:I,models:r}=t,[a,s]=(0,OE.useState)({gitRoot:"",found:!1}),[o,d]=(0,OE.useState)(null);(0,OE.useEffect)(()=>{(async()=>{d(null);let R=await sge(n);s(R)})()},[n]);let u=(0,OE.useCallback)(async()=>{if(!a.found){d(null);return}let E=await vRt(a.gitRoot);if(!E){d(null);return}let R=await fRt(a.gitRoot);d(w=>w?.branch===E&&w?.hasChanges===R?w:{branch:E,hasChanges:R})},[a]),G=(0,OE.useMemo)(()=>oge(n),[n]),[p,h]=(0,OE.useState)("");(0,OE.useEffect)(()=>{(async()=>{if(!r)return;let R=await W9(e,l,r);h(w=>w===R?w:R)})()},[e,l,r]);let W=(0,OE.useMemo)(()=>{if(!o||!o.branch)return null;let E=I||80,R=p.length,w=G.length,C=o.hasChanges?6:5,S=R+w+C+4,_=Math.max(8,E-S)-3;return`[\u2387 ${o.branch.length>_?o.branch.substring(0,_)+"...":o.branch}${o.hasChanges?"*":""}]`},[o,I,G,p]);return{displayCwd:G,gitBranchInfo:W,selectedModel:p,setSelectedModel:h,updateGitStatus:u}}c();var $A=dt(bl(),1),dkn=3*1e3;function lIl(){let[t,e]=(0,$A.useState)("idle"),[l,n]=(0,$A.useState)(0),[I,r]=(0,$A.useState)(0),[a,s]=(0,$A.useState)(!1),o=(0,$A.useRef)(null);(0,$A.useEffect)(()=>()=>{o.current&&clearTimeout(o.current)},[]);let d=(0,$A.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null),e("indexing"),n(0),r(0),s(!0)},[]),u=(0,$A.useCallback)((W,E)=>{e("completed"),n(W),r(E),s(!0),o.current=setTimeout(()=>{s(!1),o.current=null},dkn)},[]),G=(0,$A.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null),e("idle"),n(0),r(0),s(!1)},[]),p={state:t,fileCount:l,durationMs:I,isVisible:a},h=(0,$A.useMemo)(()=>({startIndexing:d,completeIndexing:u,reset:G}),[d,u,G]);return[p,h]}c();var WQe=dt(bl(),1);function nIl(t,e,l,n){let[I,r]=(0,WQe.useState)();return(0,WQe.useEffect)(()=>{async function a(){if(!l)return;let s=await d7e(t,e,l,n);r(s)}a()},[l,e,n]),{models:I}}async function d7e(t,e,l,n){try{if(l.type==="hmac")return await BS.createWithHmac(t,R5e,n,l.hmac,e).listModels();let I=await uK(l);if(!I)return;let r=await aK(l.host,I);return await BS.createWithOAuthToken(t,r,n,I,e).listModels()}catch(I){t.error(`Error fetching models list: ${I}`)}}c();var GQ=dt(bl(),1);function IIl(t=3){let[e,l]=(0,GQ.useState)(!1),n=(0,GQ.useRef)(null),I=(0,GQ.useRef)(t*1e3);(0,GQ.useEffect)(()=>{I.current=t*1e3},[t]),(0,GQ.useEffect)(()=>()=>{n.current&&clearTimeout(n.current)},[]);let r=(0,GQ.useCallback)(a=>{n.current&&(clearTimeout(n.current),n.current=null),l(!0);let s=a!==void 0?a*1e3:I.current;n.current=setTimeout(()=>{l(!1),n.current=null},s)},[]);return[e,r]}c();var xk=dt(bl(),1);function rIl(t,e){let[l,n]=(0,xk.useState)(null),I=(0,xk.useRef)("");return(0,xk.useEffect)(()=>{t.text!==I.current&&(l?.availableOptions.some(s=>t.text===s.name)||n(null),I.current=t.text)},[t.text,l]),{handleTabCompletion:(0,xk.useCallback)(()=>{let a=s=>{let o=s.indexOf(" ");return o===-1?!1:s.slice(o+1).trim().length>0};if(l){if(a(t.text)){n(null);return}let s=(l.currentIndex+1)%l.availableOptions.length,o=l.availableOptions[s];t.setText(o.name),n({...l,currentIndex:s}),e.setSlashCommandPickerIndex(s)}else{if(a(t.text))return;let s=mce(t.text);if(s.length===1){let o=s[0],d=o.name;for(let u=d.length-1;u>=2;u--){let G=d.slice(0,u),p=mce(G);if(p.length>1){let h=p.findIndex(R=>R.name===o.name);n({originalInput:G,availableOptions:p,currentIndex:h>=0?h:0});let W=(h+1)%p.length,E=p[W];t.setText(E.name),n({originalInput:G,availableOptions:p,currentIndex:W}),e.setSlashCommandPickerIndex(W);return}}}s.length>1?(n({originalInput:t.text,availableOptions:s,currentIndex:0}),t.setText(s[0].name),e.setSlashCommandPickerIndex(0)):s.length===1&&t.setText(s[0].name)}},[l,t,e]),tabCyclingState:l}}c();var qv=dt(bl(),1);function aIl(){let[t,e]=(0,qv.useState)({columns:process.stdout.columns,rows:process.stdout.rows}),l=(0,qv.useRef)(()=>{}),n=(0,qv.useCallback)(r=>{l.current=r||(()=>{})},[]),I=(0,qv.useCallback)(()=>{let{columns:r,rows:a}=process.stdout;e({columns:r,rows:a}),l.current(r,a)},[]);return(0,qv.useEffect)(()=>(process.stdout.on("resize",I),()=>{process.stdout.off("resize",I)}),[]),{...t,setOnResize:n}}c();var R8=dt(bl(),1);var Ok=t=>/\s/.test(t);function ukn(t,e){if(e>=t.length)return t.length;let l=e;for(;l<t.length&&Ok(t[l]);)l+=t[l].length;for(;l<t.length&&!Ok(t[l]);)l+=t[l].length;return l}function sIl(t,e){if(e===0)return 0;let l=e-1;for(;l>=0&&Ok(t[l]);)l-=t[l].length;if(l<0)return 0;for(;l>=0&&!Ok(t[l]);)l-=t[l].length;return l+1}function mkn(t,e){if(e>=t.length)return t.length;let l=e;for(;l<t.length&&!Ok(t[l]);)l+=t[l].length;for(;l<t.length&&Ok(t[l]);)l+=t[l].length;return l}function Sk(t,e){if(e<=0)return[t];let l=t.split(`
|
|
2289
2289
|
`).map(I=>I+" "),n=[];for(let I of l){if(I.length<=e){n.push(I);continue}let r=I;for(;r.length>e;){let a=e;if(Ok(r.slice(0,e)))for(let o=e-1;o>=Math.max(0,e-20)&&!Ok(r[o]);o--)a=o;let s=r.slice(0,a);n.push(s),r=r.slice(a)}r.length>0&&n.push(r)}return n}function iO(t,e){if(e.length===0)return{line:0,column:0};let l=0;for(let I=0;I<e.length;I++){let r=e[I],a=l+r.length;if(t<a)return{line:I,column:t-l};l=a}let n=e.length-1;return{line:n,column:e[n].length}}function oO(t,e,l,n){if(t.length===0)return 0;let I=0;for(let r=0;r<Math.min(e,t.length);r++)I+=t[r].length;return e<t.length?I+=Math.min(l,t[e].length):I=n.length,Math.min(I,n.length)}function Gkn(t,e){switch(e.type){case"set_text":return{text:e.payload,cursorPosition:e.payload.length,width:t.width};case"set_cursor_position":return{...t,cursorPosition:Math.max(0,Math.min(e.payload,t.text.length))};case"set_cursor_line_position":{let{line:l,column:n}=e.payload,I=Sk(t.text,t.width),r=oO(I,l,n,t.text);return{...t,cursorPosition:r}}case"set_width":return t.width===e.payload?t:{...t,width:e.payload};case"insert_input":{let{text:l,cursorPosition:n}=t,{input:I,callback:r}=e.payload,a=I.replace(/\r\n/g,`
|
|
2290
2290
|
`).replace(/\r/g,`
|
|
2291
|
-
`),s=l.slice(0,n),o=l.slice(n),d=s+a+o,u=n+a.length;return r?.(d),{text:d,cursorPosition:u,width:t.width}}case"backspace":return t.cursorPosition===0?t:{text:t.text.slice(0,t.cursorPosition-1)+t.text.slice(t.cursorPosition),cursorPosition:t.cursorPosition-1,width:t.width};case"forward_delete":{if(t.cursorPosition>=t.text.length)return t;let l=t.text.slice(0,t.cursorPosition)+t.text.slice(t.cursorPosition+1);return{...t,text:l}}case"backspace_word":{let{text:l,cursorPosition:n}=t;if(n===0)return t;let I=sIl(l,n);return{text:l.slice(0,I)+l.slice(n),cursorPosition:I,width:t.width}}case"forward_delete_word":{let{text:l,cursorPosition:n}=t;if(n>=l.length)return t;let I=ukn(l,n),r=l.slice(0,n)+l.slice(I);return{...t,text:r}}case"move_word_left":{let{text:l,cursorPosition:n}=t;if(n===0)return t;let I=sIl(l,n);return{...t,cursorPosition:I}}case"move_word_right":{let{text:l,cursorPosition:n}=t;if(n>=l.length)return t;let I=mkn(l,n);return{...t,cursorPosition:I}}case"move_right":return t.cursorPosition===t.text.length?t:{...t,cursorPosition:t.cursorPosition+1};case"move_left":return t.cursorPosition===0?t:{...t,cursorPosition:t.cursorPosition-1};case"move_up":{let{text:l,cursorPosition:n,width:I}=t,r=Sk(l,I),a=iO(n,r);if(a.line>0){let s=a.line-1,o=Math.min(a.column,r[s].length-1),d=oO(r,s,o,l);return{...t,cursorPosition:d}}return t}case"move_down":{let{text:l,cursorPosition:n,width:I}=t,r=Sk(l,I),a=iO(n,r);if(a.line<r.length-1){let s=a.line+1,o=Math.min(a.column,r[s].length-1),d=oO(r,s,o,l);return{...t,cursorPosition:d}}return t}case"clear":return{text:"",cursorPosition:0,width:t.width};case"clear_before_cursor":{let{text:l,cursorPosition:n,width:I}=t,r=Sk(l,I),a=iO(n,r),s=oO(r,a.line,0,l);return{text:l.slice(0,s)+l.slice(n),cursorPosition:s,width:I}}case"clear_after_cursor":{let{text:l,cursorPosition:n,width:I}=t,r=Sk(l,I),a=iO(n,r),o=r[a.line].length-1,d=oO(r,a.line,o,l),u=l.slice(0,n)+l.slice(d);return{...t,text:u}}default:return t}}var oIl=(t,e=80)=>{let[l,n]=(0,R8.useReducer)(Gkn,{text:"",cursorPosition:0,width:e}),{text:I,cursorPosition:r,width:a}=l,s=Sk(I,a),o=iO(r,s),d=ne=>{n({type:"set_cursor_position",payload:ne})},u=(ne,P)=>{n({type:"set_cursor_line_position",payload:{line:ne,column:P}})},G=(0,R8.useCallback)(ne=>{n({type:"set_width",payload:ne})},[]),p=ne=>{n({type:"set_text",payload:ne})},h=ne=>{n({type:"insert_input",payload:{input:ne,callback:t}})},W=()=>{r!==0&&n({type:"backspace"})},E=()=>{r>=I.length||n({type:"forward_delete"})},R=()=>{r!==0&&n({type:"backspace_word"})},w=()=>{r>=I.length||n({type:"forward_delete_word"})},C=()=>{r!==0&&n({type:"move_left"})},L=()=>{r>=I.length||n({type:"move_right"})},S=()=>{n({type:"move_up"})},U=()=>{n({type:"move_down"})},_=()=>{r!==0&&n({type:"move_word_left"})},z=()=>{r>=I.length||n({type:"move_word_right"})},q=()=>{n({type:"clear"})},T=()=>{n({type:"clear_before_cursor"})},$=()=>{n({type:"clear_after_cursor"})},ue=(0,R8.useCallback)(()=>{let ne=Sk(I,a),P=iO(r,ne),be=oO(ne,P.line,0,I);n({type:"set_cursor_position",payload:be})},[I,a,r]),ge=(0,R8.useCallback)(()=>{let ne=Sk(I,a),P=iO(r,ne),be=ne[P.line]?.length||0,oe=oO(ne,P.line,be-1,I);n({type:"set_cursor_position",payload:oe})},[I,a,r]);return{text:I,visualLines:s,cursorPosition:r,cursorLinePosition:o,setCursorPosition:d,setCursorLinePosition:u,setText:p,setWidth:G,insertInput:h,backspace:W,forwardDelete:E,backspaceWord:R,forwardDeleteWord:w,moveLeft:C,moveRight:L,moveUp:S,moveDown:U,moveWordLeft:_,moveWordRight:z,moveToStartOfCurrentLine:ue,moveToEndOfCurrentLine:ge,clear:q,clearBeforeCursor:T,clearAfterCursor:$,handleCommonKeyPress:(ne,P)=>{if(P.ctrl||P.meta){if(P.ctrl&&ne==="u"){T();return}if(P.ctrl&&ne==="k"){$();return}if(P.backspace||P.ctrl&&ne==="w"){R();return}if(P.delete){w();return}if(P.leftArrow||P.meta&&ne==="b"){_();return}if(P.rightArrow||P.meta&&ne==="f"){z();return}if(P.ctrl&&ne==="a"){ue();return}if(P.ctrl&&ne==="e"){ge();return}if(P.ctrl&&ne==="h"){W();return}if(P.ctrl&&ne==="d"){E();return}}if(P.home){ue();return}if(P.end){ge();return}if(P.leftArrow){C();return}if(P.rightArrow){L();return}if(P.upArrow){S();return}if(P.downArrow){U();return}if(P.backspace){W();return}if(P.delete){E();return}if(!w1e.includes(ne)&&!P.ctrl&&!P.meta){h(ne);return}}}};c();var yQe=dt(bl(),1);function iIl(t,e,l){(0,yQe.useEffect)(()=>{let n;return t.setOnTimelineEntriesChangeCallback(I=>{l.current&&(clearTimeout(n),n=setTimeout(()=>{(0,yQe.startTransition)(()=>{e(I)})},120))}),()=>{clearTimeout(n),t.setOnTimelineEntriesChangeCallback(null)}},[t,e,l])}c();import{realpathSync as cIl}from"fs";import{isAbsolute as u7e,relative as bkn,sep as pkn}from"path";var qde=class{directories=[];primaryDirectory;constructor(e,l=[]){this.primaryDirectory=this.resolveAndValidateDirectory(e),this.directories=[this.primaryDirectory];for(let n of l){let I=this.resolveAndValidateDirectory(n);this.directories.includes(I)||this.directories.push(I)}}getDirectories(){return[...this.directories]}getPrimaryDirectory(){return this.primaryDirectory}async updatePrimaryDirectory(e){let l=this.resolveAndValidateDirectory(e);if(!await hX(l))throw new Error(`Directory does not exist: ${e}`);this.directories=this.directories.filter(I=>I!==this.primaryDirectory),this.directories.unshift(l),this.primaryDirectory=l}async addDirectory(e){let l=this.resolveAndValidateDirectory(e);if(!await hX(l))throw new Error(`Directory does not exist: ${e}`);this.directories.includes(l)||this.directories.push(l)}isPathWithinAllowedDirectories(e){if(e==="/dev/null")return!0;try{let l=this.fullyResolvedPath(e);for(let n of this.directories)if(this.isPathWithinRoot(l,n))return!0;return!1}catch{return!1}}fullyResolvedPath(e){try{if(!u7e(e))throw new Error(`Path must be absolute: ${e}`);return cIl(e)}catch{return e}}isPathWithinRoot(e,l){let n=bkn(l,e);return!n.startsWith(`..${pkn}`)&&n!==".."&&!u7e(n)}resolveAndValidateDirectory(e){if(!e)throw new Error("Directory path cannot be empty");if(!u7e(e))throw new Error(`Directory path must be absolute: ${e}`);try{return cIl(e)}catch{throw new Error(`Directory does not exist or cannot be accessed: ${e}`)}}};c();var Y8=class{turnStartTimes=new Map;turnModelCallTimes=new Map;turnToolExecutionTimes=new Map;turnToolCallCounts=new Map;startTurn(e,l){this.turnStartTimes.set(e,l),this.turnModelCallTimes.set(e,{}),this.turnToolExecutionTimes.set(e,0),this.turnToolCallCounts.set(e,0)}recordModelCall(e,l){let n=this.turnModelCallTimes.get(e)||{};n.duration=l,this.turnModelCallTimes.set(e,n)}recordToolExecution(e,l){let n=this.turnToolExecutionTimes.get(e)||0;this.turnToolExecutionTimes.set(e,n+l);let I=this.turnToolCallCounts.get(e)||0;this.turnToolCallCounts.set(e,I+1)}finishTurn(e,l){let n=this.turnStartTimes.get(e);if(n===void 0)return this.cleanup(e),null;let I=l-n,r=this.turnModelCallTimes.get(e)||{},a=this.turnToolExecutionTimes.get(e)||0,s=this.turnToolCallCounts.get(e)||0,o=r.duration||0,d={totalDurationMs:I,llmDurationMs:o,toolExecutionMs:a,toolCallCount:s,totalDurationSeconds:(I/1e3).toFixed(2),llmDurationSeconds:(o/1e3).toFixed(2),toolExecutionSeconds:(a/1e3).toFixed(2)};return this.cleanup(e),d}cleanup(e){this.turnStartTimes.delete(e),this.turnModelCallTimes.delete(e),this.turnToolExecutionTimes.delete(e),this.turnToolCallCounts.delete(e)}static formatTimingBreakdown(e){return`LLM: ${e.llmDurationSeconds}s | Tools: ${e.toolExecutionSeconds}s (${e.toolCallCount} calls) | Total: ${e.totalDurationSeconds}s`}};c();var hkn="You are not licensed to use Copilot.",Akn="You are not authorized to use this Copilot feature, it requires an enterprise or organization policy to be enabled.",Zkn="The provided personal access token (PAT) does not have Copilot Requests permission. Please generate a new Fine-Grained Access Token with Copilot Requests permission (not a Classic token), or log in using /login";function m7e(t){return t.includes("not licensed to use Copilot")?{kind:"not-licensed",message:hkn}:t.includes("not authorized to use this Copilot feature")?{kind:"not-authorized",message:Akn}:t.includes("Personal Access Token does not have Copilot Requests")?{kind:"not-authorized",message:Zkn}:null}c();import{promises as dIl}from"fs";import $de,{join as Nkn}from"path";function gkn(t){let e=[],l=/(?<![a-zA-Z0-9])(@[^\s@]+)/g,n;for(;(n=l.exec(t))!==null;)e.push({displayText:n[1],startIndex:n.index,endIndex:n.index+n[0].length});return e}async function Wkn(t){try{let e=await dIl.stat(t);return e.isDirectory()?"directory":e.isFile()?cre($de.basename(t))?"image":"file":null}catch{return null}}async function ykn(t,e=new Map,l=process.cwd()){let n=gkn(t),I=[];for(let r of n){let a=e.get(r.startIndex);if(a?.startIndex===r.startIndex)I.push(a);else{let s=r.displayText.slice(1).replace(/[.,;:!?]+$/,""),o=$de.isAbsolute(s)?s:$de.resolve(l,s),d=await Wkn(o);if(d===null)continue;I.push({displayText:r.displayText,fullPath:o,type:d,startIndex:r.startIndex})}}return I}async function uIl(t,e=new Map,l=process.cwd(),n){let I=await ykn(t,e,l),r=I.filter(u=>u.type==="image"),a=I.filter(u=>u.type!=="image"),s=Ekn(t,a),o=await Rkn(a,l,n),d=await wkn(r,n);return{expandedText:s,mentions:I,syntheticToolCalls:o,imageAttachments:d}}function Ekn(t,e){let l=[...e].sort((I,r)=>r.startIndex-I.startIndex),n=t;for(let I of l){let r=n.substring(0,I.startIndex),a=n.substring(I.startIndex+I.displayText.length);n=r+`${I.fullPath}`+a}return n}async function Rkn(t,e,l){let n=[],I=[];for(let r of t){let a=$de.isAbsolute(r.fullPath)?r.fullPath:Nkn(e,r.fullPath);try{let s=await Ykn(a,l);I.push(s)}catch{}}if(I.length>0){let r=I.map(a=>({id:a.id,type:"function",function:{name:a.name,arguments:JSON.stringify(a.arguments)}}));n.push({role:"assistant",content:"I need to read the content of those paths to answer this request.",tool_calls:r}),n.push(...I.map(a=>({role:"tool",tool_call_id:a.id,content:a.result})))}return n}async function Ykn(t,e){let l=yy();try{let n=await pJe({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:"str_replace_editor",arguments:{command:"view",path:t},result:n.textResultForLlm||""}}catch(n){return{id:l,name:"str_replace_editor",arguments:{command:"view",path:t},result:`Error reading ${t}: ${n}`}}}function Vkn(t){switch($de.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 Qkn(t,e){try{let l=await dIl.readFile(t),n=Vkn(t);if(!n)return e.error(`Unsupported image format: ${t}`),null;let I=new ire,r=await Nge(e,I,3145728,are,n,l);if(!r)return e.error(`Image too large or couldn't be processed: ${t}`),null;let a=r.toString("base64");return`data:${n};base64,${a}`}catch(l){return e.error(`Failed to read image ${t}: ${l}`),null}}async function wkn(t,e){let l=[];for(let n of t)try{let I=await Qkn(n.fullPath,e);I&&l.push({type:"image_url",image_url:{url:I}})}catch(I){e.error(`Failed to process image ${n.fullPath}: ${I}`)}return l}var mIl=1,b7e=!1;function vkn(t){b7e=t}var G7e=new Map;function sa(t,e){if(b7e){if(e.type==="tool_call_requested"){G7e.set(e.callId,{callId:e.callId,name:e.name,toolTitle:e.toolTitle,intentionSummary:e.intentionSummary,arguments:e.arguments}),t.addTimelineEntry(e);return}let l={...e,id:Date.now().toString(),timestamp:new Date},n=AIl(l);n.trim()&&Qs.stdout.write(n+`
|
|
2291
|
+
`),s=l.slice(0,n),o=l.slice(n),d=s+a+o,u=n+a.length;return r?.(d),{text:d,cursorPosition:u,width:t.width}}case"backspace":return t.cursorPosition===0?t:{text:t.text.slice(0,t.cursorPosition-1)+t.text.slice(t.cursorPosition),cursorPosition:t.cursorPosition-1,width:t.width};case"forward_delete":{if(t.cursorPosition>=t.text.length)return t;let l=t.text.slice(0,t.cursorPosition)+t.text.slice(t.cursorPosition+1);return{...t,text:l}}case"backspace_word":{let{text:l,cursorPosition:n}=t;if(n===0)return t;let I=sIl(l,n);return{text:l.slice(0,I)+l.slice(n),cursorPosition:I,width:t.width}}case"forward_delete_word":{let{text:l,cursorPosition:n}=t;if(n>=l.length)return t;let I=ukn(l,n),r=l.slice(0,n)+l.slice(I);return{...t,text:r}}case"move_word_left":{let{text:l,cursorPosition:n}=t;if(n===0)return t;let I=sIl(l,n);return{...t,cursorPosition:I}}case"move_word_right":{let{text:l,cursorPosition:n}=t;if(n>=l.length)return t;let I=mkn(l,n);return{...t,cursorPosition:I}}case"move_right":return t.cursorPosition===t.text.length?t:{...t,cursorPosition:t.cursorPosition+1};case"move_left":return t.cursorPosition===0?t:{...t,cursorPosition:t.cursorPosition-1};case"move_up":{let{text:l,cursorPosition:n,width:I}=t,r=Sk(l,I),a=iO(n,r);if(a.line>0){let s=a.line-1,o=Math.min(a.column,r[s].length-1),d=oO(r,s,o,l);return{...t,cursorPosition:d}}return t}case"move_down":{let{text:l,cursorPosition:n,width:I}=t,r=Sk(l,I),a=iO(n,r);if(a.line<r.length-1){let s=a.line+1,o=Math.min(a.column,r[s].length-1),d=oO(r,s,o,l);return{...t,cursorPosition:d}}return t}case"clear":return{text:"",cursorPosition:0,width:t.width};case"clear_before_cursor":{let{text:l,cursorPosition:n,width:I}=t,r=Sk(l,I),a=iO(n,r),s=oO(r,a.line,0,l);return{text:l.slice(0,s)+l.slice(n),cursorPosition:s,width:I}}case"clear_after_cursor":{let{text:l,cursorPosition:n,width:I}=t,r=Sk(l,I),a=iO(n,r),o=r[a.line].length-1,d=oO(r,a.line,o,l),u=l.slice(0,n)+l.slice(d);return{...t,text:u}}default:return t}}var oIl=(t,e=80)=>{let[l,n]=(0,R8.useReducer)(Gkn,{text:"",cursorPosition:0,width:e}),{text:I,cursorPosition:r,width:a}=l,s=Sk(I,a),o=iO(r,s),d=ne=>{n({type:"set_cursor_position",payload:ne})},u=(ne,P)=>{n({type:"set_cursor_line_position",payload:{line:ne,column:P}})},G=(0,R8.useCallback)(ne=>{n({type:"set_width",payload:ne})},[]),p=ne=>{n({type:"set_text",payload:ne})},h=ne=>{n({type:"insert_input",payload:{input:ne,callback:t}})},W=()=>{r!==0&&n({type:"backspace"})},E=()=>{r>=I.length||n({type:"forward_delete"})},R=()=>{r!==0&&n({type:"backspace_word"})},w=()=>{r>=I.length||n({type:"forward_delete_word"})},C=()=>{r!==0&&n({type:"move_left"})},L=()=>{r>=I.length||n({type:"move_right"})},S=()=>{n({type:"move_up"})},U=()=>{n({type:"move_down"})},_=()=>{r!==0&&n({type:"move_word_left"})},z=()=>{r>=I.length||n({type:"move_word_right"})},q=()=>{n({type:"clear"})},T=()=>{n({type:"clear_before_cursor"})},$=()=>{n({type:"clear_after_cursor"})},ue=(0,R8.useCallback)(()=>{let ne=Sk(I,a),P=iO(r,ne),be=oO(ne,P.line,0,I);n({type:"set_cursor_position",payload:be})},[I,a,r]),ge=(0,R8.useCallback)(()=>{let ne=Sk(I,a),P=iO(r,ne),be=ne[P.line]?.length||0,oe=oO(ne,P.line,be-1,I);n({type:"set_cursor_position",payload:oe})},[I,a,r]);return{text:I,visualLines:s,cursorPosition:r,cursorLinePosition:o,setCursorPosition:d,setCursorLinePosition:u,setText:p,setWidth:G,insertInput:h,backspace:W,forwardDelete:E,backspaceWord:R,forwardDeleteWord:w,moveLeft:C,moveRight:L,moveUp:S,moveDown:U,moveWordLeft:_,moveWordRight:z,moveToStartOfCurrentLine:ue,moveToEndOfCurrentLine:ge,clear:q,clearBeforeCursor:T,clearAfterCursor:$,handleCommonKeyPress:(ne,P)=>{if(P.ctrl||P.meta){if(P.ctrl&&ne==="u"){T();return}if(P.ctrl&&ne==="k"){$();return}if(P.backspace||P.ctrl&&ne==="w"){R();return}if(P.delete){w();return}if(P.leftArrow||P.meta&&ne==="b"){_();return}if(P.rightArrow||P.meta&&ne==="f"){z();return}if(P.ctrl&&ne==="a"){ue();return}if(P.ctrl&&ne==="e"){ge();return}if(process.platform==="darwin"&&P.ctrl&&ne==="b"){C();return}if(process.platform==="darwin"&&P.ctrl&&ne==="f"){L();return}if(P.ctrl&&ne==="h"){W();return}if(P.ctrl&&ne==="d"){E();return}}if(P.home){ue();return}if(P.end){ge();return}if(P.leftArrow){C();return}if(P.rightArrow){L();return}if(P.upArrow){S();return}if(P.downArrow){U();return}if(P.backspace){W();return}if(P.delete){E();return}if(!w1e.includes(ne)&&!P.ctrl&&!P.meta){h(ne);return}}}};c();var yQe=dt(bl(),1);function iIl(t,e,l){(0,yQe.useEffect)(()=>{let n;return t.setOnTimelineEntriesChangeCallback(I=>{l.current&&(clearTimeout(n),n=setTimeout(()=>{(0,yQe.startTransition)(()=>{e(I)})},120))}),()=>{clearTimeout(n),t.setOnTimelineEntriesChangeCallback(null)}},[t,e,l])}c();import{realpathSync as cIl}from"fs";import{isAbsolute as u7e,relative as bkn,sep as pkn}from"path";var qde=class{directories=[];primaryDirectory;constructor(e,l=[]){this.primaryDirectory=this.resolveAndValidateDirectory(e),this.directories=[this.primaryDirectory];for(let n of l){let I=this.resolveAndValidateDirectory(n);this.directories.includes(I)||this.directories.push(I)}}getDirectories(){return[...this.directories]}getPrimaryDirectory(){return this.primaryDirectory}async updatePrimaryDirectory(e){let l=this.resolveAndValidateDirectory(e);if(!await hX(l))throw new Error(`Directory does not exist: ${e}`);this.directories=this.directories.filter(I=>I!==this.primaryDirectory),this.directories.unshift(l),this.primaryDirectory=l}async addDirectory(e){let l=this.resolveAndValidateDirectory(e);if(!await hX(l))throw new Error(`Directory does not exist: ${e}`);this.directories.includes(l)||this.directories.push(l)}isPathWithinAllowedDirectories(e){if(e==="/dev/null")return!0;try{let l=this.fullyResolvedPath(e);for(let n of this.directories)if(this.isPathWithinRoot(l,n))return!0;return!1}catch{return!1}}fullyResolvedPath(e){try{if(!u7e(e))throw new Error(`Path must be absolute: ${e}`);return cIl(e)}catch{return e}}isPathWithinRoot(e,l){let n=bkn(l,e);return!n.startsWith(`..${pkn}`)&&n!==".."&&!u7e(n)}resolveAndValidateDirectory(e){if(!e)throw new Error("Directory path cannot be empty");if(!u7e(e))throw new Error(`Directory path must be absolute: ${e}`);try{return cIl(e)}catch{throw new Error(`Directory does not exist or cannot be accessed: ${e}`)}}};c();var Y8=class{turnStartTimes=new Map;turnModelCallTimes=new Map;turnToolExecutionTimes=new Map;turnToolCallCounts=new Map;startTurn(e,l){this.turnStartTimes.set(e,l),this.turnModelCallTimes.set(e,{}),this.turnToolExecutionTimes.set(e,0),this.turnToolCallCounts.set(e,0)}recordModelCall(e,l){let n=this.turnModelCallTimes.get(e)||{};n.duration=l,this.turnModelCallTimes.set(e,n)}recordToolExecution(e,l){let n=this.turnToolExecutionTimes.get(e)||0;this.turnToolExecutionTimes.set(e,n+l);let I=this.turnToolCallCounts.get(e)||0;this.turnToolCallCounts.set(e,I+1)}finishTurn(e,l){let n=this.turnStartTimes.get(e);if(n===void 0)return this.cleanup(e),null;let I=l-n,r=this.turnModelCallTimes.get(e)||{},a=this.turnToolExecutionTimes.get(e)||0,s=this.turnToolCallCounts.get(e)||0,o=r.duration||0,d={totalDurationMs:I,llmDurationMs:o,toolExecutionMs:a,toolCallCount:s,totalDurationSeconds:(I/1e3).toFixed(2),llmDurationSeconds:(o/1e3).toFixed(2),toolExecutionSeconds:(a/1e3).toFixed(2)};return this.cleanup(e),d}cleanup(e){this.turnStartTimes.delete(e),this.turnModelCallTimes.delete(e),this.turnToolExecutionTimes.delete(e),this.turnToolCallCounts.delete(e)}static formatTimingBreakdown(e){return`LLM: ${e.llmDurationSeconds}s | Tools: ${e.toolExecutionSeconds}s (${e.toolCallCount} calls) | Total: ${e.totalDurationSeconds}s`}};c();var hkn="You are not licensed to use Copilot.",Akn="You are not authorized to use this Copilot feature, it requires an enterprise or organization policy to be enabled.",Zkn="The provided personal access token (PAT) does not have Copilot Requests permission. Please generate a new Fine-Grained Access Token with Copilot Requests permission (not a Classic token), or log in using /login";function m7e(t){return t.includes("not licensed to use Copilot")?{kind:"not-licensed",message:hkn}:t.includes("not authorized to use this Copilot feature")?{kind:"not-authorized",message:Akn}:t.includes("Personal Access Token does not have Copilot Requests")?{kind:"not-authorized",message:Zkn}:null}c();import{promises as dIl}from"fs";import $de,{join as Nkn}from"path";function gkn(t){let e=[],l=/(?<![a-zA-Z0-9])(@[^\s@]+)/g,n;for(;(n=l.exec(t))!==null;)e.push({displayText:n[1],startIndex:n.index,endIndex:n.index+n[0].length});return e}async function Wkn(t){try{let e=await dIl.stat(t);return e.isDirectory()?"directory":e.isFile()?cre($de.basename(t))?"image":"file":null}catch{return null}}async function ykn(t,e=new Map,l=process.cwd()){let n=gkn(t),I=[];for(let r of n){let a=e.get(r.startIndex);if(a?.startIndex===r.startIndex)I.push(a);else{let s=r.displayText.slice(1).replace(/[.,;:!?]+$/,""),o=$de.isAbsolute(s)?s:$de.resolve(l,s),d=await Wkn(o);if(d===null)continue;I.push({displayText:r.displayText,fullPath:o,type:d,startIndex:r.startIndex})}}return I}async function uIl(t,e=new Map,l=process.cwd(),n){let I=await ykn(t,e,l),r=I.filter(u=>u.type==="image"),a=I.filter(u=>u.type!=="image"),s=Ekn(t,a),o=await Rkn(a,l,n),d=await wkn(r,n);return{expandedText:s,mentions:I,syntheticToolCalls:o,imageAttachments:d}}function Ekn(t,e){let l=[...e].sort((I,r)=>r.startIndex-I.startIndex),n=t;for(let I of l){let r=n.substring(0,I.startIndex),a=n.substring(I.startIndex+I.displayText.length);n=r+`${I.fullPath}`+a}return n}async function Rkn(t,e,l){let n=[],I=[];for(let r of t){let a=$de.isAbsolute(r.fullPath)?r.fullPath:Nkn(e,r.fullPath);try{let s=await Ykn(a,l);I.push(s)}catch{}}if(I.length>0){let r=I.map(a=>({id:a.id,type:"function",function:{name:a.name,arguments:JSON.stringify(a.arguments)}}));n.push({role:"assistant",content:"I need to read the content of those paths to answer this request.",tool_calls:r}),n.push(...I.map(a=>({role:"tool",tool_call_id:a.id,content:a.result})))}return n}async function Ykn(t,e){let l=yy();try{let n=await pJe({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:"str_replace_editor",arguments:{command:"view",path:t},result:n.textResultForLlm||""}}catch(n){return{id:l,name:"str_replace_editor",arguments:{command:"view",path:t},result:`Error reading ${t}: ${n}`}}}function Vkn(t){switch($de.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 Qkn(t,e){try{let l=await dIl.readFile(t),n=Vkn(t);if(!n)return e.error(`Unsupported image format: ${t}`),null;let I=new ire,r=await Nge(e,I,3145728,are,n,l);if(!r)return e.error(`Image too large or couldn't be processed: ${t}`),null;let a=r.toString("base64");return`data:${n};base64,${a}`}catch(l){return e.error(`Failed to read image ${t}: ${l}`),null}}async function wkn(t,e){let l=[];for(let n of t)try{let I=await Qkn(n.fullPath,e);I&&l.push({type:"image_url",image_url:{url:I}})}catch(I){e.error(`Failed to process image ${n.fullPath}: ${I}`)}return l}var mIl=1,b7e=!1;function vkn(t){b7e=t}var G7e=new Map;function sa(t,e){if(b7e){if(e.type==="tool_call_requested"){G7e.set(e.callId,{callId:e.callId,name:e.name,toolTitle:e.toolTitle,intentionSummary:e.intentionSummary,arguments:e.arguments}),t.addTimelineEntry(e);return}let l={...e,id:Date.now().toString(),timestamp:new Date},n=AIl(l);n.trim()&&Qs.stdout.write(n+`
|
|
2292
2292
|
|
|
2293
2293
|
`);return}t.addTimelineEntry(e)}var bQ=!1,EQe=[],Wh=null,cO=!1;async function bIl(){if(bQ||EQe.length===0)return;bQ=!0;let{messageId:t,messageContent:e,syntheticToolCalls:l,permissionService:n,authInfo:I,resolve:r,reject:a,completePendingToolCall:s,setQuotaSnapshots:o,setContextWindowMetrics:d,sessionManager:u,logger:G,pathManager:p,cliModel:h,trajectoryOutputFile:W,mcpHost:E,showLlmTiming:R,timingTracker:w}=EQe.shift();try{let C=await Hkn(t,e,l,n,I,s,o,d,u,G,p,h,W,E,R,w);r(C)}catch(C){C&&typeof C=="object"&&"name"in C&&C.name==="AbortError"||C&&typeof C=="object"&&"message"in C&&typeof C.message=="string"&&C.message.includes("Operation was cancelled")?r("Operation cancelled"):a(C)}finally{bQ=!1,EQe.length>0&&setTimeout(()=>void bIl(),100)}}var fkn=(0,GIl.default)(aK);async function Hkn(t,e,l,n,I,r,a,s,o,d,u,G,p,h,W,E){Wh=new AbortController,Ckn(0,Wh.signal);try{let R=await xr.load()||{},w=await uK(I),C=R.copilot_url;!C&&w&&I.type!=="hmac"&&(C=await fkn(I.host,w)),Qs.env.GITHUB_COPILOT_CLI_MODE="true";let S={...{problemStatement:typeof e=="string"?e:e.text,logger:d,saveTrajectoryOutput:p||void 0,apiCopilotIntegrationId:R.copilot_integration_id||Qs.env.GITHUB_COPILOT_INTEGRATION_ID||"copilot-developer-cli",apiCopilotHmacKey:I.type==="hmac"?I.hmac:void 0,apiCopilotUrl:C,apiCopilotToken:w,serviceInstanceId:o.getCurrentSessionId(),mcpHost:h,saveEventLogs:Qs.env.COPILOT_EVENTS_LOG_DIRECTORY},pathManager:u,serviceAgentModel:`sweagent-capi:${G}`,requestPermission:n.request,onToolPartialOutput:(U,_)=>{o.updateToolCallTimelineEntryPartialOutput(U,_)},showEvents:!0,showSessionLog:!1,useSessionLogOnly:!1,abortSignal:Wh.signal};try{let U=await yVe.createFromOptions(S),_=await sge(Qs.cwd()),z=U.getAgentKind(),q=U.getModel(),T=ekt()[z]?.[q]??$4t(),$=U.getToolConfig?.call(U)??{},ue=T.supports||{},ge=await $2t(_.found?_.gitRoot:"",W4t(),Qs.cwd(),{},ue,$),ne={role:"user",content:typeof e=="string"?Age(e,ue):ue.vision?[{type:"text",text:Age(e.text,ue)},...e.images]:Age(e.text,ue)},P=o.getChatContextMessages();o.addChatMessage(ne),l.forEach(Ee=>o.addChatMessage(Ee));let be=o.getCurrentModel(q);o.trackUserMessage(be);let oe=U.getCompletionWithTools(ge,[...P,ne,...l],{failIfInitialInputsTooLong:!1,processors:{preRequest:[new aP(d),new sP(ne,d)]},executeToolsInParallel:!1,abortSignal:Wh.signal});for await(let Ee of oe){if(Wh?.signal.aborted){let ie=new Error("Operation was cancelled");throw ie.name="AbortError",ie}lkt(Ee,{onImageProcessingEvent:ie=>{},onImageRemovalEvent:ie=>{},onMessage:ie=>{if(o.addChatMessage(ie.message),R6(ie)&&ie.message.content){if(typeof ie.message.content=="string"){sa(o,{type:"copilot",text:ie.message.content});return}d.warning(`Unexpected message content type: ${JSON.stringify(ie.message.content)}`)}if(iRe(ie))for(let Le of ie.message.tool_calls){let we=wj(Le.function.arguments),ye=U.getToolIntentionSummary(Le.function.name,we),se=U.getToolTitle(Le.function.name)||Le.function.name;sa(o,{type:"tool_call_requested",callId:Le.id,name:Le.function.name,toolTitle:se,intentionSummary:ye,arguments:we})}},onResponse:ie=>{},onModelCallFailure:ie=>{if(m7e(ie.modelCall?.error||""))return;let we=ie.modelCall?.error||"Unknown error occurred";sa(o,{type:"error",text:`Model call failed: ${we}`})},onModelCallSuccess:ie=>{a(ie.quotaSnapshots||{});let Le=o.getCurrentModel(q),we=ie.modelCallDurationMs||0,ye=ie.responseUsage;o.updateModelUsageMetrics(Le,we,ye),W&&E&&E.recordModelCall(ie.turn,ie.modelCallDurationMs)},onToolExecution:ie=>{r({callId:ie.toolCallId,resultType:ie.toolResult.resultType,log:(ie.toolResult.resultType==="failure"?ie.toolResult.error:void 0)||ie.toolResult.sessionLog||ie.toolResult.textResultForLlm}),W&&E&&E.recordToolExecution(ie.turn,ie.durationMs)},onTruncationEvent:ie=>{s(Le=>{let we=Math.max(Le.totalTokens,ie.truncateResult.preTruncationTokensInMessages);return{...Le,totalTokens:we,postTruncationTokens:ie.truncateResult.postTruncationTokensInMessages,tokenLimit:ie.truncateResult.tokenLimit,messagesRemoved:ie.truncateResult.messagesRemovedDuringTruncation,tokensRemoved:ie.truncateResult.tokensRemovedDuringTruncation}})},onTurnEvent:ie=>{if(ie.kind==="turn_started")W&&E&&E.startTurn(ie.turn,ie.timestampMs);else if(ie.kind==="turn_ended"&&W&&E){let Le=E.finishTurn(ie.turn,ie.timestampMs);if(Le){let we=Y8.formatTimingBreakdown(Le);b7e?Qs.stdout.write(`
|
|
2294
2294
|
\u{1F552} ${we}
|
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.
|
|
4
|
+
"version": "0.0.337-1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"sdk/**/*"
|
|
34
34
|
],
|
|
35
35
|
"buildMetadata": {
|
|
36
|
-
"gitCommit": "
|
|
36
|
+
"gitCommit": "6ec01fd"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"node-pty": "npm:@devm33/node-pty@^1.0.8",
|
package/sdk/index.js
CHANGED
|
@@ -284,9 +284,9 @@ extensions:
|
|
|
284
284
|
`,c=t.map(r=>` - [${Kwe.stringify(r.path,{lineWidth:0}).trim()}, ${r.startLine}, ${r.endLine}]
|
|
285
285
|
`).join("");c||(c=` - ["", 0, 0]
|
|
286
286
|
`);let a=n+c,s=zle.join(l,"pr-diff-range.yml");return Ble.writeFileSync(s,a),I(`Wrote pr-diff-range extension pack to ${s}:
|
|
287
|
-
${a}`,8),l}G();import*as XC from"os";import*as AO from"fs";var KpI=.05,qwe=1024*1024;function _we(t){let e=XC.platform(),I=qpI(e,t)/(1024*1024),l=PpI(I,e),n=Math.floor(I-l);return t(`Using ${n} MB for CodeQL, out of ${I} MB total.`,8),n}function PpI(t,e){let I=1024*(e==="win32"?1.5:1),l=KpI*Math.max(t-8*1024,0);return I+l}function qpI(t,e){let I=[XC.totalmem()];return t==="linux"&&I.push(...["/sys/fs/cgroup/memory/memory.limit_in_bytes","/sys/fs/cgroup/memory.max"].map(n=>_pI(n,e)).filter(n=>n!==void 0).map(n=>n)),Math.min(...I)}function _pI(t,e){if(!AO.existsSync(t)){e(`While resolving RAM, did not find a cgroup memory limit at ${t}.`,8);return}let I=Number(AO.readFileSync(t,"utf8"));if(!Number.isInteger(I)){e(`While resolving RAM, ignored the file ${t} that may contain a cgroup memory limit as this file did not contain an integer.`,8);return}let l=`${Math.floor(I/(1024*1024))} MiB`;if(I>XC.totalmem()){e(`While resolving RAM, ignored the file ${t} that may contain a cgroup memory limit as its contents ${l} were greater than the total amount of system memory.`,8);return}if(I<qwe){e(`While resolving RAM, ignored a cgroup limit of ${l} in ${t} as it was below ${qwe/(1024*1024)} MiB.`,8);return}return e(`While resolving RAM, found a cgroup limit of ${l} in ${t}.`,8),I}G();import*as hQ from"fs";import*as wO from"os";function $we(t){let e=[wO.cpus().length];return wO.platform()==="linux"&&(e.push(...["/sys/fs/cgroup/cpuset.cpus.effective","/sys/fs/cgroup/cpuset.cpus"].map(l=>eZI(l,t)).filter(l=>l!==void 0&&l>0).map(l=>l)),e.push(...["/sys/fs/cgroup/cpu.max"].map(l=>$pI(l,t)).filter(l=>l!==void 0&&l>0).map(l=>l))),Math.min(...e)}function $pI(t,e){if(!hQ.existsSync(t)){e(`While resolving threads, did not find a cgroup CPU file at ${t}.`,8);return}let l=hQ.readFileSync(t,"utf-8").split(" ");if(l.length!==2){e(`While resolving threads, did not use cgroup CPU file at ${t} because it contained ${l.length} value(s) rather than the two expected.`,8);return}let n=l[0];if(n==="max")return;let c=l[1],a=Math.floor(parseInt(n)/parseInt(c));return e(`While resolving threads, found a cgroup CPU file with ${a} CPUs in ${t}.`,8),a}function eZI(t,e){if(!hQ.existsSync(t)){e(`While resolving threads, did not find a cgroup CPUs file at ${t}.`,8);return}let I=0,l=hQ.readFileSync(t,"utf-8").trim();if(l.length!==0){for(let n of l.split(","))if(!n.includes("-"))++I;else{let c=parseInt(n.split("-")[0]),a=parseInt(n.split("-")[1]);I+=a-c+1}return e(`While resolving threads, found a cgroup CPUs file with ${I} CPUs in ${t}.`,8),I}}var pQ=class t{constructor(e,I,l,n,c){this.executablePath=e;this.databaseDir=I;this.settings=l;this.sourceRoot=n;this.progressLogger=c;this.ram=this.resolveRam(),this.threads=this.resolveThreads()}static DIFF_INFORMED_FEATURE_FLAG_NAME="copilot_swe_agent_codeql_diff_informed";ram;repositorySizeCache=new Map;threads;async createDatabase(e){let
|
|
287
|
+
${a}`,8),l}G();import*as XC from"os";import*as AO from"fs";var KpI=.05,qwe=1024*1024;function _we(t){let e=XC.platform(),I=qpI(e,t)/(1024*1024),l=PpI(I,e),n=Math.floor(I-l);return t(`Using ${n} MB for CodeQL, out of ${I} MB total.`,8),n}function PpI(t,e){let I=1024*(e==="win32"?1.5:1),l=KpI*Math.max(t-8*1024,0);return I+l}function qpI(t,e){let I=[XC.totalmem()];return t==="linux"&&I.push(...["/sys/fs/cgroup/memory/memory.limit_in_bytes","/sys/fs/cgroup/memory.max"].map(n=>_pI(n,e)).filter(n=>n!==void 0).map(n=>n)),Math.min(...I)}function _pI(t,e){if(!AO.existsSync(t)){e(`While resolving RAM, did not find a cgroup memory limit at ${t}.`,8);return}let I=Number(AO.readFileSync(t,"utf8"));if(!Number.isInteger(I)){e(`While resolving RAM, ignored the file ${t} that may contain a cgroup memory limit as this file did not contain an integer.`,8);return}let l=`${Math.floor(I/(1024*1024))} MiB`;if(I>XC.totalmem()){e(`While resolving RAM, ignored the file ${t} that may contain a cgroup memory limit as its contents ${l} were greater than the total amount of system memory.`,8);return}if(I<qwe){e(`While resolving RAM, ignored a cgroup limit of ${l} in ${t} as it was below ${qwe/(1024*1024)} MiB.`,8);return}return e(`While resolving RAM, found a cgroup limit of ${l} in ${t}.`,8),I}G();import*as hQ from"fs";import*as wO from"os";function $we(t){let e=[wO.cpus().length];return wO.platform()==="linux"&&(e.push(...["/sys/fs/cgroup/cpuset.cpus.effective","/sys/fs/cgroup/cpuset.cpus"].map(l=>eZI(l,t)).filter(l=>l!==void 0&&l>0).map(l=>l)),e.push(...["/sys/fs/cgroup/cpu.max"].map(l=>$pI(l,t)).filter(l=>l!==void 0&&l>0).map(l=>l))),Math.min(...e)}function $pI(t,e){if(!hQ.existsSync(t)){e(`While resolving threads, did not find a cgroup CPU file at ${t}.`,8);return}let l=hQ.readFileSync(t,"utf-8").split(" ");if(l.length!==2){e(`While resolving threads, did not use cgroup CPU file at ${t} because it contained ${l.length} value(s) rather than the two expected.`,8);return}let n=l[0];if(n==="max")return;let c=l[1],a=Math.floor(parseInt(n)/parseInt(c));return e(`While resolving threads, found a cgroup CPU file with ${a} CPUs in ${t}.`,8),a}function eZI(t,e){if(!hQ.existsSync(t)){e(`While resolving threads, did not find a cgroup CPUs file at ${t}.`,8);return}let I=0,l=hQ.readFileSync(t,"utf-8").trim();if(l.length!==0){for(let n of l.split(","))if(!n.includes("-"))++I;else{let c=parseInt(n.split("-")[0]),a=parseInt(n.split("-")[1]);I+=a-c+1}return e(`While resolving threads, found a cgroup CPUs file with ${I} CPUs in ${t}.`,8),I}}var pQ=class t{constructor(e,I,l,n,c){this.executablePath=e;this.databaseDir=I;this.settings=l;this.sourceRoot=n;this.progressLogger=c;this.ram=this.resolveRam(),this.threads=this.resolveThreads()}static DIFF_INFORMED_FEATURE_FLAG_NAME="copilot_swe_agent_codeql_diff_informed";ram;repositorySizeCache=new Map;threads;async createDatabase(e,I){let l=`${this.databaseDir}/${I}`,n=this.getBuildMode(I);return await this.execCommand(e,`database create ${this.ram} ${this.threads} --no-sublanguage-file-coverage --no-calculate-baseline --overwrite --language ${I} --build-mode ${n} --source-root ${this.sourceRoot} ${l}`),l}static AUTOBUILD_ONLY_LANGUAGES=["cpp","go","swift"];getBuildMode(e){return t.AUTOBUILD_ONLY_LANGUAGES.includes(e)?"autobuild":"none"}async analyzeDatabase(e,I,l){let n=[];if(Yl(this.settings,t.DIFF_INFORMED_FEATURE_FLAG_NAME)){let o=ZQ.mkdtempSync(HC.join(Ule.tmpdir(),"codeql-")),d=Pwe(l,o,this.progressLogger);this.progressLogger(`Created diff range data extension pack at ${d}`,8),n=["--additional-packs",d,"--extension-packs","codeql-action/pr-diff-range"]}let c=`${this.databaseDir}/${I}`,a=`${c}/results-${I}.json`;await ZQ.promises.rm(a,{force:!0}),this.progressLogger(`Analyzing database at ${c} for language ${I}`);let s=["database","analyze",this.ram,this.threads,"--format","sarifv2.1.0","--output",a,...n,c,`codeql/${I}-queries`];return await this.execCommand(e,s.join(" ")),new HS(a,this.progressLogger.bind(this)).summarize(I,l)}async version(e){let I=await this.execCommand(e,"version --format json");try{return JSON.parse(I).version}catch{throw new Error(`Failed to parse CodeQL version output: ${I}`)}}async getRepositorySize(e){return this.repositorySizeCache.has(e)||this.repositorySizeCache.set(e,await this.computeRepositorySize(e)),this.repositorySizeCache.get(e)}async execCommand(e,I){return this.progressLogger(`Executing CodeQL command: ${I}`),new Promise((l,n)=>{XO.exec(`${this.executablePath} ${I}`,{signal:e},(c,a,s)=>{let r=c?1:4;this.progressLogger(s,r,"CodeQL Output"),c?c.name=="AbortError"?n(c):n(new Error(`Error executing command: ${c} ${s}`)):l(a)})})}resolveRam(){try{return`--ram ${_we(this.progressLogger)}`}catch(e){return this.progressLogger(`Failed to resolve RAM, not passing --ram flag to CodeQL: ${e}`,2),""}}resolveThreads(){try{return`--threads ${$we(this.progressLogger)}`}catch(e){return this.progressLogger(`Failed to resolve threads, not passing --threads flag to CodeQL: ${e}`,2),""}}getSccExecutablePath(){let e=HC.dirname(this.executablePath),I;switch(Ule.platform()){case"win32":I=HC.join(e,"tools/win64/scc.exe");break;case"darwin":I=HC.join(e,"tools/osx64/scc");break;case"linux":I=HC.join(e,"tools/linux64/scc");break;default:return}if(ZQ.existsSync(I))return I}async computeRepositorySize(e){let I=this.getSccExecutablePath();if(!I){this.progressLogger(`SCC executable not found for platform: ${Ule.platform()}`,2);return}let l=$0e(e);if(!l){this.progressLogger(`No file extensions found for language: ${e}`,2);return}let n=["--exclude-dir",".git,.hg,.svn,target,build,dist","--format","json","--include-ext",l.join(","),"--no-complexity","--no-cocomo"],c=XO.spawn(I,n,{cwd:this.sourceRoot}),a="",s="";c.stdout.on("data",o=>{a+=o}),c.stderr.on("data",o=>{s+=o});let r=await new Promise(o=>{c.on("close",o)});if(r!==0){this.progressLogger(`SCC failed with exit code ${r}: ${s}`,2);return}try{let d=JSON.parse(a).reduce((i,h)=>i+h.Bytes,0);return this.progressLogger(`SCC output for ${e}: ${d} bytes`,4),d}catch(o){this.progressLogger(`Failed to parse SCC output: ${o}`,2);return}}};var IXe="codeql-bundle-linux64.tar.gz",lZI=new G2;async function nZI(t,e){let n=(await new vU({auth:t}).rest.repos.getLatestRelease({owner:"github",repo:"codeql-action"})).data.assets.find(c=>c.name===IXe);if(n)return e(`CodeQL asset ID: ${n.id}`),n.id;throw new Error("CodeQL asset not found")}async function cZI(t,e,I,l){let n=await fetch(`https://api.github.com/repos/github/codeql-action/releases/assets/${t}`,{headers:{Authorization:`token ${I}`,Accept:"application/octet-stream"},redirect:"follow"});if(!n.ok||!n.body)throw new Error(`Failed to download asset: ${n.statusText}`);let c=uQ.join(e,IXe),a=hm.createWriteStream(c,{flags:"wx"});return await tZI(IZI.fromWeb(n.body).pipe(a)),l(`CodeQL downloaded to ${c}`),c}async function aZI(t,e,I){await hm.promises.mkdir(e,{recursive:!0});try{return await nte({file:t,cwd:e}),I(`CodeQL unzipped to ${e}`),nXe(e)}catch(l){throw lZI.error(`Error unzipping CodeQL: ${String(l)}`),l}}async function sZI(t,e,I){let l=process.env.GITHUB_TOKEN||BV(I),n=await nZI(l,e),c=rZI(t);await hm.promises.mkdir(c,{recursive:!0});let a=await cZI(n,c,l,e);return await aZI(a,t,e),await hm.promises.rm(a),lXe(t)}async function tXe(t,e,I,l){let n=GZI(t);await hm.promises.mkdir(n,{recursive:!0});let c=await oZI(l);if(c)return new pQ(c,n,I,e,l);let a=lXe(t);if(await Sle(a))return l(`CodeQL already exists at ${a}`),new pQ(a,n,I,e,l);try{let s=await sZI(t,l,I);return new pQ(s,n,I,e,l)}catch(s){throw l(`Error ensuring CodeQL: ${String(s)}`,1),s}}function rZI(t){return uQ.join(t,"codeql-download")}function lXe(t){return uQ.join(nXe(t),"codeql")}function nXe(t){return uQ.join(t,"codeql")}function GZI(t){return uQ.join(t,"dbs")}async function oZI(t){if(!process.env.RUNNER_TOOL_CACHE)return;let e=HO.findAllVersions("CodeQL");if(!e.length)return;let I=e[0],l=HO.find("CodeQL",I,eXe.arch());if(l){let n=uQ.join(l,"codeql","codeql");if(t(`CodeQL directory found in toolcache at '${l}'.`),!await Sle(n)){let c;throw await Sle(l)?c=hm.readdirSync(l):c=["path does not exist"],new Error(`CodeQL executable not found at '${n}'. Contents of toolcache: '${c.join(", ")}'.`)}return n}}async function Sle(t){try{return await hm.promises.stat(t),!0}catch{return!1}}var EO=class t{constructor(e,I,l,n,c){this.config=e;this.git=I;this.baseCommit=l;this.settings=n;this.logger=c}static DEFAULT_MAX_REPO_SIZE_BYTES=1e7;static DEFAULT_TIMEOUT_MS=180*1e3;static TOOL_NAME="codeql_checker";static CODEQL_CHECKER_ENABLED_FF="copilot_swe_agent_enable_security_tool";static CODEQL_CHECKER_DISABLED_FF="copilot_swe_agent_enable_security_tool_disabled";static isEnabled(e){return Yl(e,t.CODEQL_CHECKER_ENABLED_FF)&&!Yl(e,t.CODEQL_CHECKER_DISABLED_FF)}executor;async getCodeQLCheckerTool(){let e=await this.createCodeQLScratchDir(this.config.location);return this.executor=await tXe(e,this.config.location,this.settings,this.logProgress.bind(this)),{name:t.TOOL_NAME,description:`This is a security tool that discovers vulnerabilities in code using CodeQL. It must always be run when there are code changes.
|
|
288
288
|
It is run after committing all changed code and before the final verification. Feedback from this tool must be incorporated into
|
|
289
|
-
the change and then the tool must be re-run.`,input_schema:{type:"object",properties:{}},callback:this.callback.bind(this),safeForTelemetry:!0}}async callback(){let e={},I="unknown",l=Date.now();try{if(!this.executor)throw new Error("CodeQL Executor is not initialized.");I=await this.executor.version(),await this.git.stageChanges(this.config.location);let
|
|
289
|
+
the change and then the tool must be re-run.`,input_schema:{type:"object",properties:{}},callback:this.callback.bind(this),safeForTelemetry:!0}}async callback(){let e={},I="unknown",l=Date.now();try{if(!this.executor)throw new Error("CodeQL Executor is not initialized.");let n=AbortSignal.timeout(this.settings.tools?.codeql?.timeout??t.DEFAULT_TIMEOUT_MS);n.throwIfAborted(),I=await this.executor.version(n),await this.git.stageChanges(this.config.location);let c=await this.git.getDiffRanges(this.config.location,this.baseCommit),a=_0e(c);a.length>0?this.logProgress(`Found ${a.join(", ")} languages to analyze.`):this.logProgress("No languages found to analyze.");let s=[],r=!0;for(let i of a){if(n.throwIfAborted(),!await this.shouldAnalyzeLanguage(this.executor,i)){e[i]={skipped:!0};continue}let h=Date.now();try{await this.executor.createDatabase(n,i),this.logProgress(`Created database for ${i}.`),e[i]={databaseCreationSuccess:!0,databaseCreationTimeMs:Date.now()-h}}catch(Z){r=!1;let u=`Error creating database for ${i}: ${String(Z)}`;this.logProgress(u,1),e[i]={databaseCreationError:Z instanceof Error?Z:new Error(String(Z)),databaseCreationSuccess:!1,databaseCreationTimeMs:Date.now()-h};continue}n.throwIfAborted();let p=Date.now();try{let Z=await this.executor.analyzeDatabase(n,i,c);s.push(Z);let u=Z.alerts.length;this.logProgress(`Completed analysis of ${i}. ${u} ${u===1?"alert":"alerts"} found.`),e[i]={...e[i],analysisSuccess:!0,analysisTimeMs:Date.now()-p,analysisRuleIds:Z.alerts.flatMap(N=>N.ruleId?[N.ruleId]:[]),querySuite:`${i}-code-scanning`}}catch(Z){r=!1;let u=`Error analyzing database for ${i}: ${String(Z)}`;this.logProgress(u,1),e[i]={...e[i],analysisError:Z instanceof Error?Z:new Error(String(Z)),analysisSuccess:!1,analysisTimeMs:Date.now()-p,analysisRuleIds:[]}}}let o=s.filter(i=>i.alerts.length>0).reduce((i,h)=>i+h.alerts.length,0),d=a.length===0?"No code changes detected for languages that CodeQL can analyze, so no analysis was performed.":`Analysis Result for '${a}'. Found ${o} alert(s): ${JSON.stringify(s,null,2)}`;return{resultType:r?"success":"failure",textResultForLlm:d,sessionLog:`Analysis completed successfully for '${a}'.`,toolTelemetry:{event:"tool_call_executed",properties:{"codeql.version":I},metrics:{"codeql.languages.count":a.length,"codeql.total.alerts":o,"codeql.duration.ms":Date.now()-l},restrictedProperties:{}}}}catch(n){let c=this.isAbortError(n)?`Operation cancelled due to timeout. Do not re-run the ${t.TOOL_NAME} tool because it will not complete successfully.`:`Error in CodeQL Checker: '${String(n)}'`;this.logProgress(c,1);let a={event:"tool_call_executed",properties:{"codeql.version":I,"codeql.aborted":this.isAbortError(n)?"true":"false"},metrics:{"codeql.languages.count":0,"codeql.total.alerts":0,"codeql.duration.ms":Date.now()-l},restrictedProperties:{"codeql.stack":n instanceof Error?n.stack??"":""}};return Vo({telemetry:a},n,"codeql.error"),{resultType:"failure",textResultForLlm:c,sessionLog:c,toolTelemetry:a}}finally{let n=this.createTelemetryByLanguage(e,I);for(let c of n)this.config.callback?.progress({kind:"telemetry",telemetry:c})}}isAbortError(e){return e instanceof Error&&(e.name==="TimeoutError"||e.name==="AbortError")}async logProgress(e,I=4,l){switch(l&&this.logger.startGroup(l),I){case 8:this.logger.debug(e);break;case 4:this.logger.info(e);break;case 2:this.logger.warning(e);break;case 1:this.logger.error(e);break;default:this.logger.log(e);break}l&&this.logger.endGroup(),this.config.callback&&await this.config.callback?.progress({kind:"log",message:e})}async createCodeQLScratchDir(e){let I=cXe.normalize(cXe.join(e,"..",".codeql-scratch"));return await aXe.promises.mkdir(I,{recursive:!0}),I}createTelemetryByLanguage(e,I){let l=[];for(let[n,c]of Object.entries(e)){if(K0e(c)){let s={event:"codeql-checker-completion",properties:{"codeql.language":n,"codeql.skipped":"true","codeql.version":I},metrics:{},restrictedProperties:{}};l.push(s);continue}let a={event:"codeql-checker-completion",properties:{"codeql.language":n,"codeql.databaseCreationSuccess":c.databaseCreationSuccess?"true":"false","codeql.analysisRuleIds":Jg(c)?c.analysisRuleIds.join(","):"","codeql.version":I,"codeql.querySuite":Jg(c)?c.querySuite:void 0},metrics:{"codeql.databaseCreationTimeMs":c.databaseCreationTimeMs,"codeql.analysisTimeMs":Jg(c)?c.analysisTimeMs:void 0,"codeql.alertCount":Jg(c)?c.analysisRuleIds.length:0},restrictedProperties:{}};c.databaseCreationError&&(Vo({telemetry:a},c.databaseCreationError,"codeql.databaseCreationError"),a.restrictedProperties["codeql.databaseCreationStack"]=String(c.databaseCreationError.stack)),Jg(c)&&(a.properties["codeql.analysisSuccess"]=c.analysisSuccess?"true":"false",c.analysisError&&(Vo({telemetry:a},c.analysisError,"codeql.analysisError"),a.restrictedProperties["codeql.analysisStack"]=String(c.analysisError.stack))),l.push(a)}return l}async shouldAnalyzeLanguage(e,I){if(I=="actions")return!0;let l=await e.getRepositorySize(I);if(l===void 0)return!0;let n=l<=t.DEFAULT_MAX_REPO_SIZE_BYTES;return n||this.logProgress(`Skipping analysis for ${I} because the repository size is ${l} bytes, which exceeds the limit of ${t.DEFAULT_MAX_REPO_SIZE_BYTES} bytes.`,2),n}};G();var dZI="gh-advisory-database",rXe="copilot_swe_agent_validation_agent_dependencies",iZI="security agent",GXe={name:dZI,description:"Security tool that checks the GitHub advisory DB and informs you about reported vulnerabilities in dependencies. Run this tool ALWAYS before you add new dependencies, to check if they contain vulnerabilities. This is NOT optional. If you don't know the version number you are going to install, retrieve that first. Feedback from this tool MUST be incorporated. Re-run the tool as appropriate.",input_schema:{type:"object",properties:{dependencies:{type:"array",items:{type:"object",properties:{version:{type:"string",description:"The version of the dependency in semver format. Examples: '1.0.0', '2.1.0'."},name:{type:"string",description:"The name of the dependency. Examples: 'express', 'lodash'."}},required:["name","version"]}}},required:["dependencies"]},callback:bZI,safeForTelemetry:{name:!0,inputsNames:!1}};async function bZI({dependencies:t},e){if(!t||t.length===0)return{textResultForLlm:"No dependencies provided for checking.",resultType:"success",sessionLog:"No dependencies provided for checking.",toolTelemetry:{}};let I=[];for(let l of t){let n=pZI(l);if(n)return Promise.resolve(n);try{let c=e?BV(e.settings):process.env.GH_TOKEN;if(!c){let s="GitHub token is required to use the dependency checker tool. Please set it in the settings or as the GH_TOKEN environment variable.";return{textResultForLlm:s,resultType:"failure",sessionLog:s,toolTelemetry:{properties:{error:s}}}}let a=new vU({userAgent:iZI,auth:c});I.push(...await mZI(a,l))}catch(c){let a=`Error checking dependency ${l.name}: ${String(c)}`,s=c instanceof Error?c.stack:void 0;return{textResultForLlm:a,resultType:"failure",sessionLog:a,toolTelemetry:{restrictedProperties:{dep:`${l.name}@${l.version}`,error:a,stackTrace:s}}}}}if(I.length===0)return{textResultForLlm:"No vulnerabilities found in the provided dependencies.",resultType:"success",sessionLog:"No vulnerabilities found in the provided dependencies.",toolTelemetry:{}};{let l=hZI(I);return{textResultForLlm:l,resultType:"success",sessionLog:l,toolTelemetry:{restrictedProperties:{vulnerableDeps:I.map(n=>`${n.name}@${n.version}`).join(", ")},metrics:{vulnerableDependencies:I.length}}}}}async function mZI(t,e){let I=await t.securityAdvisories.listGlobalAdvisories({affects:`${e.name}@${e.version}`,severity:"high"}),l=await t.securityAdvisories.listGlobalAdvisories({affects:`${e.name}@${e.version}`,severity:"critical"}),n=await t.securityAdvisories.listGlobalAdvisories({affects:`${e.name}@${e.version}`,type:"malware"}),c=[...I.data,...l.data,...n.data];return c.length===0?[]:c.flatMap(a=>a.vulnerabilities?.map(s=>({name:e.name,version:e.version,summary:a.summary,ecosystem:s.package.ecosystem,affectedVersions:s.vulnerable_version_range??"",patchedVersion:s.first_patched_version??"not available",severity:a.severity,type:a.type}))??[])}function hZI(t){return t.map(e=>{let I=e.type==="malware"?"is malware":"has a vulnerability";return`Dependency ${e.name} version ${e.version} in ecosystem ${e.ecosystem} ${I}: ${e.summary}. Affected versions: ${e.affectedVersions}. Patched version: ${e.patchedVersion}.`}).join(`
|
|
290
290
|
|
|
291
291
|
`)}function sXe(t){if(typeof t!="string"||t.trim()==="")return"parameter must be a non-empty string."}function pZI(t){let e=[],I=sXe(t.name);I&&e.push(`name: ${I}`);let l=sXe(t.version);if(l&&e.push(`version: ${l}`),e.length>0){let n=`Invalid parameters found for dependency ${t.name}: ${e.join(", ")}`;return{textResultForLlm:n,resultType:"failure",sessionLog:n,toolTelemetry:{}}}}G();var oXe="reply_to_comment",dXe=(t,e)=>({name:oXe,description:`Reply to new comments. Use when you've completed a meaningful unit of work that specifically addresses the request, question, or feedback in the comment.
|
|
292
292
|
* Use this tool no more than once per <comment_id>, and only after you have completed meaningful work that specifically addresses the text in the comment.
|