@github/copilot 0.0.336 → 0.0.337-0

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.
Files changed (2) hide show
  1. package/index.js +1 -1
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -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.336",
4
+ "version": "0.0.337-0",
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": "75151b8"
36
+ "gitCommit": "13e2bcf"
37
37
  },
38
38
  "dependencies": {
39
39
  "node-pty": "npm:@devm33/node-pty@^1.0.8",