@github/copilot 0.0.344-3 → 0.0.344-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +4 -5
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1984,14 +1984,13 @@ ${I}`;await r.logMCPSetup(e,s),this.logger.log(`Updated session log for ${e} wit
|
|
|
1984
1984
|
`).map(u=>u.startsWith(a)?u.slice(a.length):u).join(`
|
|
1985
1985
|
`)),s.trimEnd()},listitem:r=>e(r.trimEnd()),reflowText:!0,showSectionPrefix:!1,unescape:!0,emoji:!0,tab:2,tableOptions:{style:{compact:!1}}}},hYn=lMt(!0),AYn=lMt(!1);function nMt(t){return t==="light"?AYn:hYn}c();import{exec as QQn}from"node:child_process";import*as n8e from"node:os";import{promisify as wQn}from"node:util";c();c();c();import{execFile as ZYn}from"node:child_process";import{normalize as gYn}from"node:path";import{promisify as NYn}from"node:util";var Mde=NYn(ZYn);async function nf(t=process.cwd()){try{let l=(await Mde("git",["rev-parse","--show-toplevel"],{cwd:t,encoding:"utf8",timeout:5e3,maxBuffer:1048576})).stdout.trim();if(l)return{gitRoot:gYn(l),found:!0}}catch{}return{gitRoot:t,found:!1}}async function rMt(t){let{stdout:e}=await Mde("git",["-C",t,"remote","-v"],{encoding:"utf8",timeout:5e3,maxBuffer:1048576}),l=e.trim().split(`
|
|
1986
1986
|
`),n={};for(let r of l){let I=r.split(/\s+/);if(I.length>=3){let a=I[0],s=I[1],o=I[2].replace(/[()]/g,"");n[a]||(n[a]={Name:a,FetchURL:"",PushURL:""}),o==="fetch"?n[a].FetchURL=s:o==="push"&&(n[a].PushURL=s)}}return Object.values(n)}async function IMt(t){try{let{stdout:e}=await Mde("git",["status","--porcelain"],{cwd:t,encoding:"utf8",timeout:5e3,maxBuffer:1048576});return e.trim().length>0}catch{return!1}}async function aMt(t){try{let{stdout:e}=await Mde("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:t,encoding:"utf8",timeout:5e3,maxBuffer:1048576}),l=e.trim();if(l==="HEAD"){let{stdout:n}=await Mde("git",["rev-parse","--short","HEAD"],{cwd:t,encoding:"utf8",timeout:5e3,maxBuffer:1048576}),r=n.trim();return r?`detached@${r}`:null}return l||null}catch{return null}}c();var kMt=tt(XMt(),1);async function bVn(t={}){let e=await pht();return Zht((0,kMt.default)({},e,t))}async function gVe(t={}){if(E_())throw new Error("Settings have already been initialized");return bVn(t)}c();c();c();import{promises as GVn}from"fs";import LMt from"path";var pVn=3*1024*1024;function JMt(t){let e=LMt.extname(t).toLowerCase();return[".png",".jpg",".jpeg",".gif",".webp"].includes(e)}function hVn(t){switch(LMt.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 AVn(t,e){e.debug(`Processing local image file: ${t}`);let l=await GVn.readFile(t),n=hVn(t);if(!n)throw new Error(`Unsupported image format: ${t}`);let r=new xae,I=await Wye(e,r,pVn,kae,n,l);if(!I)throw new Error(`Image too large or couldn't be processed: ${t}`);let a=I.toString("base64");return`data:${n};base64,${a}`}async function ZVn(t,e){let l=Su();try{let n=await vxe({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}`}}}async function xMt(t,e){let l=[],n=t.filter(I=>!JMt(I.path));if(n.length===0)return l;let r=[];for(let I of n)try{let a=await ZVn(I.path,e);r.push(a)}catch{}if(r.length>0){let I=r.map(a=>({id:a.id,type:"function",function:{name:a.name,arguments:JSON.stringify(a.arguments)}}));l.push({role:"assistant",content:"I need to read the content of those paths to answer this request.",tool_calls:I}),l.push(...r.map(a=>({role:"tool",tool_call_id:a.id,content:a.result})))}return l}async function SMt(t,e){let l=t.filter(r=>JMt(r.path));return(await Promise.all(l.map(async r=>{try{return{type:"image_url",image_url:{url:await AVn(r.path,e)}}}catch(I){e.error(`Failed to process image ${r.path}: ${I instanceof Error?I.message:String(I)}`);return}}))).filter(r=>r!==void 0)}var QO=class{sessionId;startTime;events=[];_chatMessages=[];_selectedModel;logger;eventCallbacks=[];eventProcessingQueue=Promise.resolve();constructor({sessionId:e,startTime:l,logger:n}={}){this.sessionId=e||Su(),this.startTime=l||new Date,this.logger=n||new Fc}static async fromEvents({events:e,logger:l}){if(e.length===0)throw new Error("Cannot create session from empty events array");let n=e[0];if(n.type!=="session.start")throw new Error("First event must be session.start");let r=new this({sessionId:n.data.sessionId,startTime:new Date(n.data.startTime),logger:l||new Fc});r._selectedModel=n.data.selectedModel,r.events.push(n);for(let I=1;I<e.length;I++){let a=e[I];r.events.push(a),await r.processEventForState(a)}return r}addEvent(e){let l=e.id||Su(),n=e.timestamp||new Date().toISOString(),r=e.parentId!==void 0?e.parentId:this.getLastEventId(),I={...e,id:l,timestamp:n,parentId:r};return this.events.push(I),this.enqueueEventProcessing(()=>this.processEventForState(I).catch(a=>{this.logger.error(`Error processing event ${I.type} (${I.id}): ${a instanceof Error?a.message:String(a)}`)})).catch(a=>{this.logger.error(`Error processing event queue ${a instanceof Error?a.message:String(a)}`)}),this.notifyEventCallbacks(I),I}getEvents(){return this.events}onEvent(e){return this.eventCallbacks.push(e),()=>{let l=this.eventCallbacks.indexOf(e);l>-1&&this.eventCallbacks.splice(l,1)}}async getChatMessages(){return this.enqueueEventProcessing(()=>this._chatMessages)}async getChatContextMessages(){return(await this.getChatMessages()).filter(l=>l.role!=="system")}async getSystemContextMessages(){return(await this.getChatMessages()).filter(l=>l.role==="system")}async getSelectedModel(){return this.enqueueEventProcessing(()=>this._selectedModel)}setSelectedModel(e){let l=this._selectedModel;this._selectedModel=e,this.addEvent({type:"session.model_change",data:{previousModel:l,newModel:e}})}getLastEventId(){return this.events.length===0?null:this.events[this.events.length-1].id}enqueueEventProcessing(e){let l=this.eventProcessingQueue.then(()=>e());return this.eventProcessingQueue=l,l}async processEventForState(e){switch(e.type){case"session.start":e.data.selectedModel&&(this._selectedModel=e.data.selectedModel);break;case"session.model_change":this._selectedModel=e.data.newModel;break;case"user.message":{let l=[],n=[];if(e.data.attachments&&e.data.attachments.length>0){let r=await SMt(e.data.attachments,this.logger);l.push(...r);let I=await xMt(e.data.attachments,this.logger);n.push(...I)}l.length>0?this._chatMessages.push({role:"user",content:[{type:"text",text:e.data.content},...l]}):this._chatMessages.push({role:"user",content:e.data.content}),n.length>0&&this._chatMessages.push(...n);break}case"assistant.message":{let l={role:"assistant",content:e.data.content||null};e.data.toolRequests&&e.data.toolRequests.length>0&&(l.tool_calls=e.data.toolRequests.map(n=>({id:n.toolCallId,type:"function",function:{name:n.name,arguments:typeof n.arguments=="string"?n.arguments:JSON.stringify(n.arguments)}}))),this._chatMessages.push(l);break}case"tool.execution_complete":{this._chatMessages.push({role:"tool",tool_call_id:e.data.toolCallId,content:e.data.success?e.data.result?.content||"":e.data.error?.message||"Tool execution failed"});break}case"system.message":this._chatMessages.push({role:e.data.role,content:e.data.content,...e.data.name&&{name:e.data.name}});break;case"session.import_legacy":this._chatMessages=[...e.data.legacySession.chatMessages],e.data.legacySession.selectedModel&&(this._selectedModel=e.data.legacySession.selectedModel);break;case"session.resume":case"session.error":case"session.info":case"assistant.turn_start":case"assistant.turn_end":case"assistant.usage":case"abort":case"tool.user_requested":case"tool.execution_start":case"tool.execution_partial_result":case"hook.start":case"hook.end":break;default:{let l=e;this.logger.error(`Unknown event type: ${l.type}`);break}}}notifyEventCallbacks(e){for(let l of this.eventCallbacks)try{l(e)}catch(n){this.logger.error(`Error in event callback: ${n instanceof Error?n.message:String(n)}`)}}};c();c();import{unlink as pQn}from"node:fs/promises";c();c();var gVn=$l({type:Zr("copilot"),text:Vt(),isStreaming:di().optional()}),NVn=$l({type:Zr("error"),text:Vt()}),WVn=$l({type:Zr("info"),text:Vt()}),GWa=$l({displayText:Vt(),fullPath:Vt(),type:Dg(["file","directory","unresolved","image"]),startIndex:vh()}),yVn=$l({type:Zr("user"),text:Vt()}),NVe=$l({command:Vt(),description:Vt(),timeout:vh().optional(),sessionId:Vt().optional(),async:di().optional()}),jKe=$l({sessionId:Vt(),input:Vt(),delay:vh().optional()}),KKe=$l({sessionId:Vt(),delay:vh()}),qKe=$l({sessionId:Vt()}),BMt=fh([NVe,jKe,KKe,qKe]),EVn=$l({command:Zr("view"),path:Vt(),view_range:TPe([vh(),vh()]).optional()}),RVn=$l({command:Zr("create"),path:Vt(),file_text:Vt()}),YVn=$l({command:Zr("str_replace"),path:Vt(),new_str:Vt().optional(),old_str:Vt()}),VVn=$l({command:Zr("insert"),path:Vt(),insert_line:vh(),new_str:Vt()}),$Ke=Lce("command",[EVn,RVn,YVn,VVn]),OMt=fh([BMt,$Ke,pQ()]),QVn=$l({type:Zr("tool_call_requested"),callId:Vt(),name:Vt(),toolTitle:Vt().optional(),intentionSummary:Vt().nullable(),arguments:OMt,partialOutput:Vt().optional(),isHidden:di().optional(),isAlwaysExpanded:di().optional(),showNoContent:di().optional()}),wVn=$l({type:Zr("tool_call_completed"),callId:Vt(),name:Vt(),toolTitle:Vt().optional(),intentionSummary:Vt().nullable(),result:fh([$l({type:Zr("success"),log:Vt(),markdown:di().optional()}),$l({type:Zr("failure"),log:Vt(),markdown:di().optional()}),$l({type:Zr("rejected"),markdown:di().optional()}),$l({type:Zr("denied"),log:Vt(),markdown:di().optional()})]),arguments:OMt,isHidden:di().optional(),isAlwaysExpanded:di().optional(),showNoContent:di().optional()}),FVn=fh([gVn,NVn,WVn,yVn,QVn,wVn]),TMt=FVn.and($l({id:Vt(),timestamp:Jce.date()}));function UMt(t,e){switch(t.type){case"copilot":return e.onCopilot(t);case"error":return e.onError(t);case"info":return e.onInfo(t);case"tool_call_requested":return e.onToolCallRequested(t);case"tool_call_completed":return e.onToolCallCompleted(t);case"user":return e.onUser(t);default:{let l=t;throw new Error(`Unexpected message type: ${JSON.stringify(t)}`)}}}var Kde=$l({type:Zr("text"),text:Vt()}),CVn=$l({type:Zr("refusal"),refusal:Vt()}),vVn=$l({type:Zr("image_url"),image_url:$l({url:Vt(),detail:Dg(["auto","low","high"]).optional()})}),fVn=$l({type:Zr("input_audio"),input_audio:$l({data:Vt(),format:Zr("wav").or(Zr("mp3"))})}),HVn=$l({type:Zr("file"),file:$l({file_date:Vt().optional(),file_id:Vt().optional(),filename:Vt().optional()})}),XVn=fh([Kde,vVn,fVn,HVn]),kVn=$l({name:Vt(),arguments:Vt()}),LVn=$l({name:Vt(),input:Vt()}),JVn=$l({id:Vt(),type:Zr("function"),function:kVn}),xVn=$l({id:Vt(),type:Zr("custom"),custom:LVn}),SVn=fh([JVn,xVn]),BVn=$l({name:Vt(),arguments:Vt()}),OVn=$l({id:Vt()}),TVn=$l({content:fh([Vt(),Sd(Kde)]),role:Zr("developer"),name:Vt().optional()}),UVn=$l({content:fh([Vt(),Sd(Kde)]),role:Zr("system"),name:Vt().optional()}),MVn=$l({content:fh([Vt(),Sd(XVn)]),role:Zr("user"),name:Vt().optional()}),_Vn=$l({content:fh([Vt(),Sd(fh([Kde,CVn]))]).nullable().optional(),role:Zr("assistant"),name:Vt().optional(),refusal:Vt().nullable().optional(),audio:OVn.nullable().optional(),function_call:BVn.nullable().optional(),tool_calls:Sd(SVn).optional()}),DVn=$l({content:fh([Vt(),Sd(Kde)]),role:Zr("tool"),tool_call_id:Vt()}),zVn=$l({content:Vt().nullable(),role:Zr("function"),name:Vt()}),PVn=fh([TVn,UVn,MVn,_Vn,DVn,zVn]),e8e=$l({sessionId:Vt(),startTime:Jce.date(),chatMessages:Sd(PVn),timeline:Sd(TMt),selectedModel:Dg(WO).optional()}),af=lVe(e8e.parse,"history-session");c();c();var wb=$l({id:Vt().uuid(),timestamp:Vt().datetime(),parentId:Vt().uuid().nullable(),ephemeral:di().optional()}),jVn=wb.extend({type:Zr("session.start"),data:$l({sessionId:Vt(),version:vh(),producer:Vt(),copilotVersion:Vt(),startTime:Vt().datetime(),selectedModel:Vt().optional()})}),KVn=wb.extend({type:Zr("session.resume"),data:$l({resumeTime:Vt().datetime(),eventCount:vh()})}),qVn=wb.extend({type:Zr("session.error"),data:$l({errorType:Vt(),message:Vt(),stack:Vt().optional()})}),$Vn=wb.extend({type:Zr("session.info"),data:$l({infoType:Vt(),message:Vt()})}),eQn=wb.extend({type:Zr("session.model_change"),data:$l({previousModel:Vt().optional(),newModel:Vt()})}),tQn=wb.extend({type:Zr("session.import_legacy"),data:$l({legacySession:e8e,importTime:Vt().datetime(),sourceFile:Vt()})}),lQn=$l({type:Dg(["file","directory"]),path:Vt(),displayName:Vt()}),nQn=wb.extend({type:Zr("user.message"),data:$l({content:Vt(),attachments:Sd(lQn).optional()})}),rQn=wb.extend({type:Zr("assistant.turn_start"),data:$l({turnId:Vt()})}),IQn=wb.extend({type:Zr("assistant.message"),data:$l({messageId:Vt(),content:Vt(),toolRequests:Sd($l({toolCallId:Vt(),name:Vt(),arguments:pQ()})).optional()})}),aQn=wb.extend({type:Zr("assistant.turn_end"),data:$l({turnId:Vt()})}),sQn=wb.extend({type:Zr("assistant.usage"),ephemeral:Zr(!0),data:$l({model:Vt().optional(),tokensUsed:vh().optional(),cost:vh().optional(),duration:vh().optional()})}),oQn=wb.extend({type:Zr("abort"),data:$l({reason:Vt()})}),iQn=wb.extend({type:Zr("tool.user_requested"),data:$l({toolCallId:Vt(),toolName:Vt(),arguments:pQ()})}),cQn=wb.extend({type:Zr("tool.execution_start"),data:$l({toolCallId:Vt(),toolName:Vt(),arguments:pQ()})}),dQn=wb.extend({type:Zr("tool.execution_partial_result"),ephemeral:Zr(!0),data:$l({toolCallId:Vt(),partialOutput:Vt()})}),uQn=wb.extend({type:Zr("tool.execution_complete"),data:$l({toolCallId:Vt(),success:di(),result:$l({content:Vt()}).optional(),error:$l({message:Vt(),code:Vt().optional()}).optional()})}),mQn=wb.extend({type:Zr("hook.start"),data:$l({hookInvocationId:Vt(),hookType:Vt(),input:pQ()})}),bQn=wb.extend({type:Zr("hook.end"),data:$l({hookInvocationId:Vt(),hookType:Vt(),output:pQ(),success:di(),error:$l({message:Vt(),stack:Vt().optional()}).optional()})}),GQn=wb.extend({type:Zr("system.message"),data:$l({content:Vt(),role:Dg(["system","developer"]),name:Vt().optional(),metadata:$l({promptVersion:Vt().optional(),variables:L2(pQ()).optional()}).optional()})}),MMt=Lce("type",[jVn,KVn,qVn,$Vn,eQn,tQn,nQn,rQn,IQn,aQn,sQn,oQn,iQn,cQn,dQn,uQn,mQn,bQn,GQn]);var EQ=wUt(MMt.parse,"session");var F8=class t extends QO{flushTimer=null;flushDebounceMs;isDirty=!1;shouldSaveSession=!1;unflushedEvents=[];_legacySourceFile;modelList;constructor({sessionId:e,startTime:l,logger:n,options:r}){super({sessionId:e,startTime:l,logger:n}),this.flushDebounceMs=r?.flushDebounceMs??100}setModelList(e){this.modelList=e}getModelList(){return this.modelList}addEvent(e){let l=super.addEvent(e);return this.unflushedEvents.push(l),this.isDirty=!0,!this.shouldSaveSession&&l.type==="user.message"&&(this.shouldSaveSession=!0),this.shouldSaveSession&&this.scheduleDebouncedFlush(),l}setShouldSaveSession(e){this.shouldSaveSession=e}scheduleDebouncedFlush(){this.flushTimer&&clearTimeout(this.flushTimer),this.flushTimer=setTimeout(()=>{this.flush().catch(e=>{this.logger.error(`Debounced flush failed: ${e}`)})},this.flushDebounceMs)}async flush(){if(!(!this.isDirty||this.unflushedEvents.length===0)){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null);try{let e=this.unflushedEvents.filter(l=>!l.ephemeral);if(e.length===0){this.unflushedEvents=[],this.isDirty=!1;return}await EQ.append(e,this.sessionId),this.logger.debug(`Flushed ${e.length} events to session ${this.sessionId}, ${this._legacySourceFile}`),this._legacySourceFile&&(this.logger.info(`Migrated legacy session ${this.sessionId} to JSONL format, cleaning up old file`),await pQn(this._legacySourceFile),this._legacySourceFile=void 0),this.unflushedEvents=[],this.isDirty=!1}catch(e){throw this.logger.error(`Failed to flush session ${this.sessionId}: ${e}`),e}}}getFilePath(){return EQ.path(this.sessionId)}setLegacySourceFile(e){this._legacySourceFile=af.path(e)}static async load(e,l){let n=await EQ.load(e);if(n.length===0)throw new Error(`Session ${e} has no events`);if(n[0].type!=="session.start")throw new Error("First event must be a session.start event");let I=await t.fromEvents({events:n,logger:l});return I.setShouldSaveSession(!0),I.isDirty=!1,I.unflushedEvents=[],I}};c();import{unlink as hQn}from"fs/promises";import{join as AQn}from"path";c();var WVe=class{sessions;logger;lastAccessedSessionId;constructor({logger:e}={}){this.sessions=new Map,this.logger=e||new Fc}async createSession(){let e=new QO({logger:this.logger});return this.sessions.set(e.sessionId,e),this.lastAccessedSessionId=e.sessionId,e}async getSession(e){let l=this.sessions.get(e);return l&&(this.lastAccessedSessionId=e),l}async getLastSession(){if(this.lastAccessedSessionId){let n=this.sessions.get(this.lastAccessedSessionId);if(n)return n}let e=Array.from(this.sessions.values());if(e.length===0)return;e.sort((n,r)=>r.startTime.getTime()-n.startTime.getTime());let l=e[0];return this.lastAccessedSessionId=l.sessionId,l}async listSessions(){return Array.from(this.sessions.values()).map(e=>({sessionId:e.sessionId,startTime:e.startTime}))}async saveSession(e){}async deleteSession(e){this.sessions.delete(e.sessionId),this.lastAccessedSessionId===e.sessionId&&(this.lastAccessedSessionId=void 0)}};var yVe=class extends WVe{copilotVersion;constructor({logger:e,version:l}){super({logger:e}),this.copilotVersion=l||"unknown"}async createSession(e){let l=e?.sessionId??Su(),n=new Date,r=new F8({sessionId:l,startTime:n,logger:this.logger});return r.addEvent({type:"session.start",data:{sessionId:l,version:1,producer:"copilot-agent",copilotVersion:this.copilotVersion,startTime:n.toISOString(),selectedModel:e?.selectedModel}}),r}async getSession(e){try{return await F8.load(e,this.logger)}catch{try{return await this.loadLegacySession(e)}catch{return}}}async loadLegacySession(e){let n=(await af.directoryFiles()).filter(o=>{let d=o.match(/^session_(.+)_(\d+)\.json$/);return d&&d[1]===e});if(n.length===0)throw new Error(`Legacy session ${e} not found`);let r=n[0];n.length>1&&this.logger.info(`Multiple legacy sessions found for ${e}, using newest`);let I=await af.load(r);if(!I)throw new Error(`Failed to load legacy session from ${r}`);let a=new Date(I.startTime),s=new F8({sessionId:I.sessionId,startTime:a,logger:this.logger});return s.addEvent({type:"session.start",data:{sessionId:I.sessionId,version:1,producer:"copilot-agent",copilotVersion:this.copilotVersion,startTime:a.toISOString(),selectedModel:I.selectedModel}}),s.addEvent({type:"session.import_legacy",data:{legacySession:{sessionId:I.sessionId,startTime:a,chatMessages:I.chatMessages,timeline:I.timeline,selectedModel:I.selectedModel},importTime:new Date().toISOString(),sourceFile:r}}),s.setLegacySourceFile(r),this.logger.info(`Loaded legacy session ${e} from ${r}`),s}async listSessions(){let e=await EQ.directoryFiles(),l=await af.directoryFiles(),n=await Promise.all(e.map(async s=>{let o=s.replace(".jsonl","");try{let d=await EQ.load(o);if(this.logger.debug(`Loaded ${d.length} events for session ${o}`),d.length===0)return this.logger.debug(`Empty file ${s}`),null;let u=d[0];return u.type!=="session.start"?(this.logger.debug("Invalid session file"),null):{sessionId:u.data.sessionId,startTime:new Date(u.data.startTime)}}catch(d){return this.logger.error(`Invalid session file ${d instanceof Error?d.message:String(d)}`),null}})),r=await Promise.all(l.map(async s=>{let o=s.match(/^session_(.+)_(\d+)\.json$/);if(!o)return null;let d=o[1],u=parseInt(o[2],10);try{return await af.load(s)?{sessionId:d,startTime:new Date(u)}:null}catch{return null}}));this.logger.debug(`Found ${n.filter(s=>s!==null).length} JSONL sessions and ${r.filter(s=>s!==null).length} legacy sessions`);let I=[...n,...r].filter(s=>s!==null),a=new Map;for(let s of I)a.get(s.sessionId)?n.find(d=>d?.sessionId===s.sessionId)&&a.set(s.sessionId,s):a.set(s.sessionId,s);return Array.from(a.values())}async getLastSession(){let e=await this.listSessions();if(e.length===0)return;e.sort((n,r)=>r.startTime.getTime()-n.startTime.getTime());let l=e[0].sessionId;return await this.getSession(l)}async deleteSession(e){let l=EQ.path(e.sessionId);await hQn(l)}getSessionsDirectory(){return AQn(EQ.home(),EQ.directory())}setLogger(e){this.logger=e}};c();c();c();c();function Zu(t){return t()}c();var qde;function gQn(t,e){return t.includes("\x1B[?")&&t.includes(e)}async function NQn(t){let e=process.stdin.isRaw;e||process.stdin.setRawMode(!0);try{return await t()}finally{e||process.stdin.setRawMode(!1)}}function _Mt(t,e,l){return new Promise(n=>{let r="",I,a=()=>{I=void 0,process.stdin.removeListener("data",s),n(!1)},s=o=>{I!==void 0&&(r+=o.toString(),gQn(r,e)&&(process.stdin.removeListener("data",s),clearTimeout(I),I=void 0,n(!0)))};process.stdin.on("data",s),process.stdout.write("\x1B["+t),I=setTimeout(a,l)})}async function WQn(){return!(!(process.stdin.isTTY&&process.stdout.isTTY)||!await _Mt("?u","u",200)||!await _Mt("c","c",1e3))}async function zMt(){qde===void 0&&(qde=await NQn(WQn),qde===!0&&(yQn(),process.on("exit",DMt),process.on("SIGTERM",DMt)))}function yQn(){process.stdout.write("\x1B[>1u")}function DMt(){process.stdout.write("\x1B[<u"),qde=void 0}function EVe(){return qde===!0}c();import{promises as RVe}from"node:fs";import*as tue from"node:os";import*as C8 from"node:path";var $de="workbench.action.terminal.sendSequence",EQn="terminalFocus",eue=`\\\r
|
|
1987
|
-
`,t8e="shift+enter",l8e="ctrl+enter",PMt={key:"",command:$de,when:EQn,args:{text:eue}};function RQn(t){return t.replace(/^\s*\/\/.*$/gm,"")}async function YQn(t,e){try{let l=new Date().toISOString().replace(/[:.]/g,"-"),n=`${e}.${l}.backup`;return await RVe.copyFile(e,n),n}catch(l){return t.warning(`Failed to backup ${e}: ${l}`),null}}function VQn(t,e){let l=tue.platform(),n=Zu(()=>l==="darwin"?C8.join(tue.homedir(),"Library","Application Support"):l==="win32"?process.env.APPDATA?C8.join(process.env.APPDATA):(t.warning(`Unable to determine ${e} config path on Windows. APPDATA environment variable is not set.`),null):C8.join(tue.homedir(),".config"));return n===null?null:C8.join(n,e,"User")}async function jMt(t,e,l){return qMt(t,e,l,async()=>{},async()=>null)}async function KMt(t,e,l){return qMt(t,e,l,async n=>{await RVe.mkdir(n,{recursive:!0})},async(n,r,I)=>{let a=await YQn(n,r);return await RVe.writeFile(r,JSON.stringify(I,null,4),"utf8"),a})}async function qMt(t,e,l,n,r){let I=VQn(t,l);if(!I)return{state:"failed",message:`Unable to determine ${e} config path.`};let a=C8.join(I,"keybindings.json"),s=null;try{await n(I);let o=[];try{let
|
|
1988
|
-
Path: ${a}`};o=
|
|
1987
|
+
`,t8e="shift+enter",l8e="ctrl+enter",PMt={key:"",command:$de,when:EQn,args:{text:eue}};function RQn(t){return t.replace(/^\s*\/\/.*$/gm,"")}async function YQn(t,e){try{let l=new Date().toISOString().replace(/[:.]/g,"-"),n=`${e}.${l}.backup`;return await RVe.copyFile(e,n),n}catch(l){return t.warning(`Failed to backup ${e}: ${l}`),null}}function VQn(t,e){let l=tue.platform(),n=Zu(()=>l==="darwin"?C8.join(tue.homedir(),"Library","Application Support"):l==="win32"?process.env.APPDATA?C8.join(process.env.APPDATA):(t.warning(`Unable to determine ${e} config path on Windows. APPDATA environment variable is not set.`),null):C8.join(tue.homedir(),".config"));return n===null?null:C8.join(n,e,"User")}async function jMt(t,e,l){return qMt(t,e,l,async()=>{},async()=>null)}async function KMt(t,e,l){return qMt(t,e,l,async n=>{await RVe.mkdir(n,{recursive:!0})},async(n,r,I)=>{let a=await YQn(n,r);return await RVe.writeFile(r,JSON.stringify(I,null,4),"utf8"),a})}async function qMt(t,e,l,n,r){let I=VQn(t,l);if(!I)return{state:"failed",message:`Unable to determine ${e} config path.`};let a=C8.join(I,"keybindings.json"),s=null;try{await n(I);let o=[];try{let N=await RVe.readFile(a,"utf8");try{let y=RQn(N),Y=JSON.parse(y);if(!Array.isArray(Y))return{state:"failed",message:`Key bindings file for ${e} found but it is not a valid JSON array. Fix the file manually or delete it and try to setup the terminal again.
|
|
1988
|
+
Path: ${a}`};o=Y}catch(y){return{state:"failed",message:`Failed to parse the key bindings file for ${e}: invalid JSON file.
|
|
1989
1989
|
Fix the file manually or delete it and try to setup the terminal again.
|
|
1990
1990
|
Path: ${a}
|
|
1991
|
-
Error: ${
|
|
1991
|
+
Error: ${y}`}}}catch{}let d={...PMt,key:t8e},u={...PMt,key:l8e},b=o.some(N=>{let y=N;return y.key===t8e&&y.command===$de&&y.args?.text===eue}),p=o.some(N=>{let y=N;return y.key===l8e&&y.command===$de&&y.args?.text===eue});if(p&&b)return{state:"not-needed",message:`Key bindings for ${e} are already set up. Your terminal already has multiline support with Shift+Enter and Ctrl+Enter.`};let h=o.find(N=>{let y=N;return y.key===t8e&&(y.command!==$de||y.args?.text!==eue)}),g=o.find(N=>{let y=N;return y.key===l8e&&(y.command!==$de||y.args?.text!==eue)});if(h||g){let N=[];return h&&N.push("Shift+Enter"),g&&N.push("Ctrl+Enter"),{state:"failed",message:`Found key bindings for ${new Intl.ListFormat("en").format(N)}. Those will not be modified.
|
|
1992
1992
|
Please make sure they are correct and modify them manually if needed, or delete them and try to setup the terminal again.
|
|
1993
|
-
Path: ${a}`}}b||o.unshift(d),p||o.unshift(u),s=await r(t,a,o)
|
|
1994
|
-
Previous key bindings were backed up in ${s}`:"";return{state:"succeeded",message:`Added key bindings Shift+Enter and Ctrl+Enter for ${e} in file ${a}${N}`}}catch(o){let d=s?`
|
|
1993
|
+
Path: ${a}`}}return b||o.unshift(d),p||o.unshift(u),s=await r(t,a,o),s&&t.info(`Backup of previous key bindings created at ${s}`),{state:"succeeded",message:`Added key bindings Shift+Enter and Ctrl+Enter for ${e} successfully.`}}catch(o){let d=s?`
|
|
1995
1994
|
You can restore your previous key bindings from ${s}`:"";return{state:"failed",message:`Failed to setup ${e}.
|
|
1996
1995
|
Path: ${a}${d}
|
|
1997
1996
|
Error: ${o}`}}}var FQn=wQn(QQn),r8e={vscode:{appName:"Code",terminalName:"VS Code"},"vscode-insiders":{appName:"Code - Insiders",terminalName:"VS Code (Insiders)"},cursor:{appName:"Cursor",terminalName:"Cursor"},windsurf:{appName:"Windsurf",terminalName:"Windsurf"}};async function $Mt(t){if(n8e.platform()==="linux"&&process.env.WSL_DISTRO_NAME)return"wsl";let e=(process.env.VSCODE_GIT_ASKPASS_MAIN||"").toLowerCase();if(process.env.CURSOR_TRACE_ID||e.includes("cursor"))return"cursor";if(e.includes("windsurf"))return"windsurf";if(e.includes("code"))return e.includes("insiders")?"vscode-insiders":"vscode";if(process.env.TERM_PROGRAM==="vscode"||process.env.VSCODE_GIT_IPC_HANDLE)return"vscode";try{let n=n8e.platform()==="win32"?'(Get-Process -Id (Get-CimInstance Win32_Process -Filter "ProcessId=$PID").ParentProcessId).Path':"ps -o comm= -p $PPID",{stdout:r}=await FQn(n),I=r.trim().toLowerCase();if(I.includes("windsurf"))return"windsurf";if(I.includes("cursor"))return"cursor";if(I.includes("code"))return I.includes("insiders")?"vscode-insiders":"vscode"}catch(n){t.debug(`Failed to detect parent process: ${n}`)}return null}async function e_t(t){if(EVe())return{state:"not-needed",message:"Your terminal already has multiline support with Shift+Enter and Ctrl+Enter."};let e=await $Mt(t);if(!e)return{state:"failed",message:"No supported terminal detected. `/terminal-setup` is supported only in VS Code, Cursor and Windsurf."};switch(e){case"vscode":case"vscode-insiders":case"cursor":case"windsurf":{let l=r8e[e];return KMt(t,l.terminalName,l.appName)}case"wsl":return{state:"failed",message:"WSL terminal detected.\n\nIf you're running WSL from VS Code, Windsurf or Cursor, please switch to a supported terminal within the IDE (e.g. PowerShell or Command Prompt) and run `/terminal-setup` again."};default:return{state:"failed",message:`Terminal "${e}" not supported. \`/terminal-setup\` is supported only in VS Code, Cursor and Windsurf.`}}}async function t_t(){let t=new Fc,e=await $Mt(t);if(!e||!Object.keys(r8e).includes(e))return null;try{if((await kr.load())?.asked_setup_terminals?.includes(e))return null}catch{}switch(e){case"vscode":case"vscode-insiders":case"cursor":case"windsurf":{let l=r8e[e];return(await jMt(t,l.terminalName,l.appName)).state==="succeeded"?{terminal:e,terminalName:l.terminalName}:null}default:return null}}async function l_t(t,e){let l=await Zu(async()=>{try{return await kr.load()??{}}catch{return{}}}),n=l.asked_setup_terminals??[];if(!n.includes(e)){n.push(e),l.asked_setup_terminals=n;try{await kr.writeKey("asked_setup_terminals",n)}catch(r){t.warning(`Failed to mark terminal ${e} as "already asked to set up": ${r}`)}}}function lue(t,e){let l=e.trim();if(!l.startsWith("/"))return[];let n=l.split(" ")[0];return t.filter(r=>r.name.startsWith(n))}function s_t(t,e){let l=" ".repeat(e),n=t.reduce((r,I)=>Math.max(r,I.name.length+(I.args?I.args.length+1:0)),0);return t.map(r=>{let I=(r.args?`${r.name} ${r.args}`:r.name).padEnd(n);return`${l}${I} ${r.help}`}).join(`
|
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.344-
|
|
4
|
+
"version": "0.0.344-4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"sdk/**/*"
|
|
35
35
|
],
|
|
36
36
|
"buildMetadata": {
|
|
37
|
-
"gitCommit": "
|
|
37
|
+
"gitCommit": "e024a0b"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"node-pty": "npm:@devm33/node-pty@^1.0.8",
|