@github/copilot 0.0.352-2 → 0.0.352-3
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 +1 -1
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -2036,7 +2036,7 @@ ${a}`;await r.createOrUpdateMCPStartupToolCall({serverName:e,content:o,toolNames
|
|
|
2036
2036
|
`).filter(A=>A.trim()),p=[];for(let A=0;A<G.length;A++)try{let Z=JSON.parse(G[A]),W=t(Z);p.push(W)}catch(Z){throw new Error(`Invalid event at line ${A+1} in ${d}: ${Z}`)}return p}catch(m){throw new Error(`Failed to read JSONL from ${d}: ${m}`)}},append:async(c,d)=>{let m=r(d),G=Array.isArray(c)?c:[c];try{await jzt(m);let p=G.map(A=>JSON.stringify(A)).join(`
|
|
2037
2037
|
`)+`
|
|
2038
2038
|
`;await kwe.runExclusive(m,()=>Vfn(m,p,{mode:384}))}catch(p){throw new Error(`Failed to append to JSONL file ${m}: ${p}`)}},path:r,directoryFiles:async()=>{let c=cN(l(),n());try{let m=(await fwe(c,{withFileTypes:!0})).filter(p=>p.isFile()&&p.name.endsWith(".jsonl")).map(p=>p.name),G=await Promise.all(m.map(async p=>{let A=cN(c,p);try{let Z=await Hwe(A);return{file:p,mtime:Z.mtime}}catch{return{file:p,mtime:new Date}}}));return G.sort((p,A)=>A.mtime.getTime()-p.mtime.getTime()),G.map(p=>p.file)}catch{return[]}},directoryFilesWithMetadata:async()=>{let c=cN(l(),n());try{let m=(await fwe(c,{withFileTypes:!0})).filter(p=>p.isFile()&&p.name.endsWith(".jsonl")).map(p=>p.name),G=await Promise.all(m.map(async p=>{let A=cN(c,p);try{let Z=await Hwe(A);return{file:p,mtime:Z.mtime,birthtime:Z.birthtime}}catch{return{file:p,mtime:new Date,birthtime:new Date}}}));return G.sort((p,A)=>A.mtime.getTime()-p.mtime.getTime()),G}catch{return[]}},home:l,directory:n}};var $zt=zl({host:Qt(),login:Qt()}),ffn=zl({banner:G0(["always","once","never"]).optional(),beep:ro().optional(),last_logged_in_user:$zt.optional(),logged_in_users:Od($zt).optional(),model:Qt().optional(),render_markdown:ro().optional(),screen_reader:ro().optional(),theme:Qt().optional(),trusted_folders:Od(Qt()).optional(),store_token_plaintext:ro().optional(),stream:ro().optional(),parallel_tool_execution:ro().optional(),feature_flags:zl({enabled:Od(Qt()).optional()}).optional(),asked_setup_terminals:Od(Qt()).optional(),capi_hmac_key:Qt().optional(),copilot_hmac_key:Qt().optional(),copilot_integration_id:Qt().optional(),copilot_tokens:rY(Qt(),Qt()).optional(),copilot_url:Qt().optional(),staff:ro().optional(),log_level:G0(["none","error","warning","info","debug","all","default"]).optional()}),Hfn=rY(Qt(),lKe()),Xfn=Hfn.transform(t=>(0,ePt.default)(t,(e,l)=>{let n=l.toLowerCase();return n==="github_copilot_integration_id"?"copilot_integration_id":n})),kfn=Xfn.pipe(ffn),Sr=Jwe(kfn.parse,"config");function xL(){return process.env.COPILOT_ENABLE_ALT_PROVIDERS==="true"}var oO=["claude-sonnet-4.5","claude-sonnet-4","claude-haiku-4.5","gpt-5"];function tPt(t,e){let l=" ".repeat(e);return t.map(n=>`${l}- "${n}"`).join(`
|
|
2039
|
-
`)}function wq(t){return oO.includes(t)||xL()}function sO(t,e){if(!e)return!0;let l=e.find(n=>n.id===t);return l?l.policy?l.policy.state!=="disabled":!0:!1}function Uqe(t){return oO.find(e=>sO(e,t))}function Qq(t,e){if(e&&e.length>0){let n=e.find(r=>r.id===t);if(n?.billing?.multiplier!==void 0)return n.billing.multiplier}return{"claude-sonnet-4":1,"gpt-5":1,"claude-sonnet-4.5":1,"claude-haiku-4.5":.33}[t]??1}async function iO(t,e,l,n){if(xL()&&process.env.COPILOT_AGENT_MODEL){let{model:I}=HB(process.env.COPILOT_AGENT_MODEL);if(I)return I}if(t){if(sO(t,l))return t;n?.warning(`Model '${t}' from CLI argument is not available. Falling back to next option.`)}if(e){let I=await e?.getSelectedModel?.();if(I){if(sO(I,l))return I;n?.warning(`Model '${I}' from session is not available. Falling back to next option.`)}}let r=process.env.COPILOT_MODEL;if(r&&wq(r)){if(sO(r,l))return r;n?.warning(`Model '${r}' from COPILOT_MODEL environment variable is not available. Falling back to next option.`)}try{let s=(await Sr.load()||{}).model;if(typeof s=="string"&&s&&wq(s)){if(sO(s,l))return s;n?.warning(`Model '${s}' from config file is not available. Falling back to default.`)}}catch{}let a=Uqe(l);return a&&n?.info(`Using default model: ${a}`),a}function _w(t){return"host"in t?t.host:"https://github.com"}function lme(t){return cY(t,{onHMACAuthInfo:()=>"Logged in with HMAC",onEnvAuthInfo:e=>`Logged in with ${e.envVar} as user: ${e.login}`,onUserAuthInfo:e=>`Logged in as user: ${tme(e)}`,onGhCliAuthInfo:e=>`Logged in with gh as user: ${tme(e)}`,onApiKeyAuthInfo:e=>`Logged in with API key to ${e.host}`})}function nme(t){return cY(t,{onHMACAuthInfo:()=>"Unknown (via HMAC)",onEnvAuthInfo:e=>`${e.login} (via ${e.envVar})`,onUserAuthInfo:e=>tme(e),onGhCliAuthInfo:e=>`${e.login} (via gh)`,onApiKeyAuthInfo:e=>`${e.host} (via API key)`})}function Mqe(t,e){return cY(t,{onHMACAuthInfo:l=>e.type==="hmac"&&l.hmac===e.hmac,onEnvAuthInfo:l=>e.type==="env"&&l.envVar===e.envVar&&l.login===e.login,onUserAuthInfo:l=>e.type==="user"&&cO(l,e),onGhCliAuthInfo:l=>e.type==="gh-cli"&&cO(l,e),onApiKeyAuthInfo:l=>e.type==="api-key"&&l.host===e.host&&l.apiKey===e.apiKey})}async function lPt(t,e){let l=await t.getAllAuthAvailable(),n=">",r="-";return l.map(a=>`${e&&Mqe(a.authInfo,e)?n:r} ${nme(a.authInfo)}`)}function tme(t){return t.host!==kL?`${t.login} (${t.host})`:t.login}async function nPt(){let t=await Sr.load()||{};return t?.last_logged_in_user??t.logged_in_users?.[0]??void 0}async function _qe(t){await Sr.writeKey("last_logged_in_user",t)}async function Swe(){return(await Sr.load()||{}).logged_in_users||[]}async function rPt(t,e){await Sr.writeKey("last_logged_in_user",t),await Sr.writeKey("logged_in_users",e)}async function aPt(t){let e=await Swe();return e.some(n=>cO(n,t))?(e=e.filter(n=>!cO(n,t)),await rPt(void 0,e),e.length>0):!1}async function IPt(t){let e=await Swe();e.some(n=>cO(n,t))||(e.push(t),await rPt(t,e))}function cO(t,e){return t.login===e.login&&t.host===e.host}async function sPt(t,e){try{let l=Lfn(),n=await e.execReturn("gh",["auth","token","--hostname",l],{silent:!0,ignoreReturnCode:!0});if(n.exitCode!==0||!n.stdout.trim()){let a=`Failed to retrieve GitHub token from CLI (exit code: ${n.exitCode})`,I=n.stderr?.trim();return I?t.debug(`${a}: ${I}`):t.debug(a),null}let r=n.stdout.trim();return r.startsWith("ghp_")?(t.debug("GitHub token is a classic PAT"),null):(t.debug("GitHub CLI authenticated with valid token"),{token:r,host:l})}catch(l){let n=`Error checking GitHub CLI: ${l}`;return l&&typeof l=="object"&&"stderr"in l&&typeof l.stderr=="string"&&(n+=` (stderr: ${l.stderr.trim()})`),t.debug(n),null}}function Lfn(){return process.env.GH_HOST||"github.com"}function Dqe(){let t=process.env.GH_HOST;return t?t.startsWith("https://")?t:`https://${t}`:kL}import{existsSync as cPt}from"fs";var Bwe="copilot-cli",Twe;async function Owe(){if(Twe)return Twe;let t=await Promise.resolve().then(()=>$e(iPt(),1));return Twe=t.default||t,Twe}var ame=(t,e)=>{if(!(!t||!e))return`${t}:${e}`},Sfn=()=>{let t=new Map,e=async(o,c)=>{let d=ame(o,c);if(d)if(cPt(Sr.path()))try{let p=(await Sr.load())?.copilot_tokens?.[d];t.set(d,p&&p.trim()!==""?p:void 0)}catch{t.set(d,void 0)}else t.set(d,void 0)},l=async()=>{if(cPt(Sr.path()))try{let c=(await Sr.load())?.copilot_tokens;if(c){let d=Object.values(c).filter(m=>m&&m.trim()!=="");if(d.length>0)return d[0]}}catch{return}},n=async(o,c)=>{let d=ame(o,c);if(!d)return;if(t.has(d))return t.get(d);if((await Sr.load())?.store_token_plaintext)return await e(o,c),t.get(d);try{let p=await(await Owe()).getPassword(Bwe,d);p?t.set(d,p):await e(o,c)}catch{await e(o,c)}return t.get(d)},r=async()=>{if(t.size>0)return t.values().next().value;if((await Sr.load())?.store_token_plaintext)return await l();let c;try{c=await(await Owe()).findPassword(Bwe)}catch{}return c||(c=await l()),c},a=async(o,c)=>{let d=ame(o,c);if(d){t.delete(d);try{return(await Owe()).deletePassword(Bwe,d)}catch{let p=(await Sr.load())?.copilot_tokens??{};return delete p[d],await Sr.writeKey("copilot_tokens",p),Promise.resolve(!0)}}},I=async(o,c,d)=>{if(!o)throw new Error("No token provided to store");let m=ame(c,d);if(!m)return;if(t.set(m,o),(await Sr.load())?.store_token_plaintext)return await s(c,d),!0;try{return await(await Owe()).setPassword(Bwe,m,o),!0}catch{return!1}},s=async(o,c)=>{let d=ame(o,c);if(!d)return;let m=t.get(d);if(!m)return;let p=(await Sr.load())?.copilot_tokens??{};p[d]=m,await Sr.writeKey("copilot_tokens",p)};return{getToken:n,getAnyToken:r,removeToken:a,storeToken:I,storeCurrentTokenInConfig:s}},Ef=Sfn();function cY(t,e){switch(t.type){case"hmac":return e.onHMACAuthInfo(t);case"env":return e.onEnvAuthInfo(t);case"user":return e.onUserAuthInfo(t);case"gh-cli":return e.onGhCliAuthInfo(t);case"api-key":return e.onApiKeyAuthInfo(t);default:{let l=t;throw new Error(`unexpected auth info type: ${JSON.stringify(t)}`)}}}async function Iy(t){return await cY(t,{onHMACAuthInfo:async()=>process.env.GITHUB_MCP_SERVER_TOKEN,onEnvAuthInfo:async e=>e.token,onUserAuthInfo:async e=>await Ef.getToken(e.host,e.login)||void 0,onGhCliAuthInfo:async e=>e.token,onApiKeyAuthInfo:async()=>{}})}var zqe=class{currentAuthInfo=null;logger=new xd;authCallbacks=[];setLogger(e){this.logger=e}onAuthChange(e){this.authCallbacks.push(e)}removeAuthCallback(e){let l=this.authCallbacks.indexOf(e);l>-1&&this.authCallbacks.splice(l,1)}async notifyAuthChange(e,l){this.currentAuthInfo=e;for(let n of this.authCallbacks)try{await n(e,l)}catch(r){this.logger.error(`Error in auth change callback: ${r}`)}}async tryHMACLogin(){let e=await Sr.load()||{},l=e.copilot_hmac_key||e.capi_hmac_key||process.env.CAPI_HMAC_KEY||process.env.COPILOT_HMAC_KEY;return l?[{authInfo:{type:"hmac",hmac:l}}]:[]}async tryGitHubTokenLogin(){let e=process.env.GH_TOKEN||process.env.GITHUB_TOKEN;if(!e)return[];if(e.startsWith("ghp_"))return this.logger.error("Classic PATs are not supported. Please use fine-grained PATs or other supported token types."),[];if(!e.startsWith("gho_")&&!e.startsWith("ghu_")&&!e.startsWith("github_pat_"))return this.logger.error("Unsupported token type, ignoring."),[];let l=Dqe();try{let n=await Wq(l,e);return[{authInfo:{type:"env",host:l,login:n,token:e,envVar:process.env.GH_TOKEN?"GH_TOKEN":"GITHUB_TOKEN"},token:e}]}catch(n){n instanceof XL?this.logger.error(`Failed to fetch PAT user login (${n.status}): ${n.message}`):this.logger.error("Failed to fetch PAT user login")}return[]}async tryGhCliTokenLogin(){let e=new XA(this.logger),l=await sPt(this.logger,e);if(!l)return[];let{token:n,host:r}=l;try{let a=r.startsWith("https://")?r:`https://${r}`,I=await Wq(a,n);return[{authInfo:{type:"gh-cli",host:a,login:I,token:n},token:n}]}catch(a){a instanceof XL?this.logger.error(`Failed to fetch GitHub CLI user login (${a.status}): ${a.message}`):this.logger.error("Failed to fetch GitHub CLI user login")}return[]}async tryApiKeyLogin(){if(!xL())return[];let e=process.env.ANTHROPIC_API_KEY||process.env.AZURE_OPENAI_API_KEY,l=process.env.ANTHROPIC_API_KEY?"https://api.anthropic.com":process.env.AZURE_OPENAI_API_KEY?process.env.AZURE_OPENAI_API_ENDPOINT||process.env.OPENAI_BASE_URL||"https://api.openai.com":void 0;return!e||!l?[]:[{authInfo:{type:"api-key",apiKey:e,host:l}}]}async tryLoginToken(){let e=await nPt(),l;if(e){if(l=await Ef.getToken(e.host,e.login),!l||l.trim()==="")return[]}else{if(l=await Ef.getAnyToken(),!l||l.trim()==="")return[];let n=Dqe();e={host:n,login:await Wq(n,l)}}return[{authInfo:{type:"user",host:e.host,login:e.login},token:l}]}async getAllGitHubLoginTokens(){let l=(await this.tryGitHubTokenLogin()).at(0),n=await Swe(),r=[];for(let a of n){if(l?.authInfo.type==="user"&&cO(a,l.authInfo))continue;let I=await Ef.getToken(a.host,a.login);I&&r.push({authInfo:{type:"user",host:a.host,login:a.login},token:I})}return r}async getAllAuthAvailable(){let e=[],l=this.getPrioritizedAuthMethods(!0);for(let n of l){let r=await n();e.push(...r)}return e}getPrioritizedAuthMethods(e){return[this.tryHMACLogin.bind(this),this.tryApiKeyLogin.bind(this),this.tryGitHubTokenLogin.bind(this),e?this.getAllGitHubLoginTokens.bind(this):this.tryLoginToken.bind(this),this.tryGhCliTokenLogin.bind(this)]}async loadAuthInfo(){let e=this.currentAuthInfo!==null;this.currentAuthInfo=null;let l=this.getPrioritizedAuthMethods(!1);for(let n of l){let r=await n();if(r.length>0){let{authInfo:a,token:I}=r[0];a.type==="user"&&_qe({host:a.host,login:a.login}),this.currentAuthInfo=a,e||await this.notifyAuthChange(a,I);return}}}async getCurrentAuthInfo(){return this.currentAuthInfo||await this.loadAuthInfo(),this.currentAuthInfo}async loginUser(e,l){let n={host:e,login:l},r={type:"user",...n};await IPt(n);let a=await Iy(r);await this.notifyAuthChange(r,a)}async switchToAuth(e){this.currentAuthInfo=e.authInfo,e.authInfo.type==="user"&&await _qe({host:e.authInfo.host,login:e.authInfo.login}),await this.notifyAuthChange(e.authInfo,e.token)}async logout(){if(!this.currentAuthInfo)return!1;let e=await cY(this.currentAuthInfo,{onHMACAuthInfo:async()=>!1,onEnvAuthInfo:async()=>!1,onUserAuthInfo:async l=>(await Ef.removeToken(l.host,l.login),await aPt(l)),onGhCliAuthInfo:async()=>!1,onApiKeyAuthInfo:async()=>!1});return await this.notifyAuthChange(null),e}},Bfn=new zqe,Uwe=Bfn;var Rf=class t extends HL{constructor(l,n,r,a,I){super(l,n,a,"direct");this.exec=r;this.enableAllGithubMcpTools=I??!1}static GITHUB_SERVER_NAME="github-mcp-server";static CLI_DEFAULT_GITHUB_MCP_TOOLS=["get_file_contents","search_code","search_repositories","list_branches","list_commits","get_commit","get_issue","list_issues","get_issue_comments","search_issues","pull_request_read","list_pull_requests","search_pull_requests","list_workflow_runs","get_job_logs","get_workflow_run","list_workflows","get_workflow_run_logs","web_search","search_users"];static BUILTIN_SERVERS=[t.GITHUB_SERVER_NAME];static getBuiltInServerNames(){return[...t.BUILTIN_SERVERS]}hasUserConfiguredGitHubServer=!1;lastGitHubAuthInfo=null;githubMcpToken;enableAllGithubMcpTools;async configureGitHubAuth(l){if(this.isServerDisabled(t.GITHUB_SERVER_NAME))return this.logger.debug("GitHub MCP server is disabled, skipping auto-configuration"),!1;if(this.hasUserConfiguredGitHubServer)return this.logger.debug("User has explicitly configured github-mcp-server, ignoring auth changes"),!1;if(await this.shouldHandleGitHubAuth(l)){let r=await Iy(l);if(!r)return this.logger.debug("No token available for GitHub authentication"),!1;if(this.lastGitHubAuthInfo=l,r===this.githubMcpToken)return!1;this.githubMcpToken=r;let a=await this.createGitHubServerConfig(r,l);try{return await this.restartServer(t.GITHUB_SERVER_NAME,a),this.logger.log("GitHub MCP server configured after authentication"),!0}catch(I){return this.logger.error(`Failed to configure GitHub MCP server after auth: ${I}`),!1}}return!1}async removeGitHubAuth(){if(this.hasUserConfiguredGitHubServer)return this.logger.debug("User has explicitly configured github-mcp-server, ignoring auth changes"),!1;this.githubMcpToken=void 0;try{return this.isServerRunning(t.GITHUB_SERVER_NAME)?(await this.stopServer(t.GITHUB_SERVER_NAME),this.logger.debug("Removed GitHub MCP server"),!0):!1}catch(l){return this.logger.error(`Failed to remove GitHub server: ${l}`),!1}}async shouldHandleGitHubAuth(l){return await cY(l,{onHMACAuthInfo:async()=>!!process.env.GITHUB_MCP_SERVER_TOKEN,onEnvAuthInfo:async()=>!0,onUserAuthInfo:async()=>!0,onGhCliAuthInfo:async()=>!0,onApiKeyAuthInfo:async()=>!1})}async createGitHubServerConfig(l,n){let r="https://api.githubcopilot.com/mcp/readonly";try{let a=await cY(n,{onHMACAuthInfo:async()=>"https://github.com",onEnvAuthInfo:async s=>s.host,onUserAuthInfo:async s=>s.host,onGhCliAuthInfo:async s=>s.host,onApiKeyAuthInfo:async s=>s.host}),I=await E0(a,l,this.logger);r=new URL("/mcp/readonly",I).toString()}catch(a){this.logger.error(`Failed to fetch Copilot URL, using default: ${a}`)}return{type:"http",url:r,headers:{Authorization:"Bearer "+l,"X-MCP-Toolsets":"repos,issues,users,pull_requests,code_security,secret_protection,actions,web_search","X-MCP-Host":"copilot-cli"},tools:this.enableAllGithubMcpTools?["*"]:t.CLI_DEFAULT_GITHUB_MCP_TOOLS,isDefaultServer:!0,filterMapping:{get_issue:"markdown",get_issue_comments:"markdown",get_pull_request:"markdown",get_pull_request_comments:"markdown",get_pull_request_reviews:"markdown"}}}async injectDefaultServers(l){if(l.mcpServers[t.GITHUB_SERVER_NAME]){this.hasUserConfiguredGitHubServer=!0,this.logger.debug("User has already configured github-mcp-server, skipping auto-configuration");return}}async startBuiltInServer(l){l===t.GITHUB_SERVER_NAME&&!this.hasUserConfiguredGitHubServer?this.lastGitHubAuthInfo?(this.logger.log("Attempting to configure GitHub MCP server using stored authentication"),await this.configureGitHubAuth(this.lastGitHubAuthInfo)?this.logger.log("GitHub MCP server configured successfully after enabling"):this.logger.log("GitHub MCP server enabled but could not be configured - authentication may be invalid or insufficient")):this.logger.log("GitHub MCP server enabled - will be configured automatically when authentication becomes available"):await super.startBuiltInServer(l)}};var Tfn=zl({commandHistory:Od(Qt())}),Pqe=xwe(Tfn.parse,"command-history");var Ofn=50,jqe=class{commandHistory=[];historyIndex=-1;isNavigatingHistory=!1;unSubmittedCommand=null;async initialize(){try{let e=await Pqe.load();this.commandHistory=e?.commandHistory||[],this.resetNavigation()}catch{this.commandHistory=[]}}async addCommand(e){this.commandHistory=this.commandHistory.filter(l=>l!==e),this.commandHistory.unshift(e),this.commandHistory=this.commandHistory.slice(0,Ofn),this.resetNavigation(),this.unSubmittedCommand=null,await this.saveHistory()}async updateCurrentCommand(e){this.historyIndex!==-1?(this.commandHistory[this.historyIndex]=e,await this.saveHistory()):this.unSubmittedCommand=e}navigateUp(e){if(this.commandHistory.length===0)return;let l=this.historyIndex+1;if(l<this.commandHistory.length){this.historyIndex=l,this.isNavigatingHistory=!0;let n=this.getCurrentHistoryItem();n&&e.setText(n)}}navigateDown(e){if(this.historyIndex===-1)return;if(this.historyIndex===0)this.resetNavigation();else{let n=this.historyIndex-1;this.historyIndex=n,this.isNavigatingHistory=!0}let l=this.getCurrentHistoryItem();l?(e.setText(l),e.setCursorPosition(0)):e.clear()}resetNavigation(){this.historyIndex=-1,this.isNavigatingHistory=!1}getHistoryIndex(){return this.historyIndex}getHistory(){return this.commandHistory}getCurrentHistoryItem(){return this.historyIndex===-1?this.unSubmittedCommand?this.unSubmittedCommand:void 0:this.commandHistory[this.historyIndex]}isNavigating(){return this.isNavigatingHistory}setNavigating(e){this.isNavigatingHistory=e}async saveHistory(){try{await Pqe.write({commandHistory:this.commandHistory})}catch{}}},dY=new jqe;function uPt(t,e){var l=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),l.push.apply(l,n)}return l}function mPt(t){for(var e=1;e<arguments.length;e++){var l=arguments[e]!=null?arguments[e]:{};e%2?uPt(Object(l),!0).forEach(function(n){Ufn(t,n,l[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(l)):uPt(Object(l)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(l,n))})}return t}function Ufn(t,e,l){return e=Mfn(e),e in t?Object.defineProperty(t,e,{value:l,enumerable:!0,configurable:!0,writable:!0}):t[e]=l,t}function Mfn(t){var e=_fn(t,"string");return typeof e=="symbol"?e:String(e)}function _fn(t,e){if(typeof t!="object"||t===null)return t;var l=t[Symbol.toPrimitive];if(l!==void 0){var n=l.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Dfn=GPt({}),bPt=Dfn;function GPt(t){return e.withOptions=l=>GPt(mPt(mPt({},t),l)),e;function e(l,...n){let r=typeof l=="string"?[l]:l.raw,{escapeSpecialCharacters:a=Array.isArray(l),trimWhitespace:I=!0}=t,s="";for(let d=0;d<r.length;d++){let m=r[d];a&&(m=m.replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`").replace(/\\\$/g,"$").replace(/\\\{/g,"{")),s+=m,d<n.length&&(s+=n[d])}let o=s.split(`
|
|
2039
|
+
`)}function wq(t){return oO.includes(t)||xL()}function sO(t,e){if(!e)return!0;let l=e.find(n=>n.id===t);return l?l.policy?l.policy.state!=="disabled":!0:!1}function Uqe(t){return oO.find(e=>sO(e,t))}function Qq(t,e){if(e&&e.length>0){let n=e.find(r=>r.id===t);if(n?.billing?.multiplier!==void 0)return n.billing.multiplier}return{"claude-sonnet-4":1,"gpt-5":1,"claude-sonnet-4.5":1,"claude-haiku-4.5":.33}[t]??1}async function iO(t,e,l,n){if(xL()&&process.env.COPILOT_AGENT_MODEL){let{model:I}=HB(process.env.COPILOT_AGENT_MODEL);if(I)return I}if(t){if(sO(t,l))return t;n?.warning(`Model '${t}' from CLI argument is not available. Falling back to next option.`)}if(e){let I=await e?.getSelectedModel?.();if(I){if(sO(I,l))return I;n?.warning(`Model '${I}' from session is not available. Falling back to next option.`)}}let r=process.env.COPILOT_MODEL;if(r&&wq(r)){if(sO(r,l))return r;n?.warning(`Model '${r}' from COPILOT_MODEL environment variable is not available. Falling back to next option.`)}try{let s=(await Sr.load()||{}).model;if(typeof s=="string"&&s&&wq(s)){if(sO(s,l))return s;n?.warning(`Model '${s}' from config file is not available. Falling back to default.`)}}catch{}let a=Uqe(l);return a&&n?.info(`Using default model: ${a}`),a}function _w(t){return"host"in t?t.host:"https://github.com"}function lme(t){return cY(t,{onHMACAuthInfo:()=>"Logged in with HMAC",onEnvAuthInfo:e=>`Logged in with ${e.envVar} as user: ${e.login}`,onUserAuthInfo:e=>`Logged in as user: ${tme(e)}`,onGhCliAuthInfo:e=>`Logged in with gh as user: ${tme(e)}`,onApiKeyAuthInfo:e=>`Logged in with API key to ${e.host}`})}function nme(t){return cY(t,{onHMACAuthInfo:()=>"Unknown (via HMAC)",onEnvAuthInfo:e=>`${e.login} (via ${e.envVar})`,onUserAuthInfo:e=>tme(e),onGhCliAuthInfo:e=>`${e.login} (via gh)`,onApiKeyAuthInfo:e=>`${e.host} (via API key)`})}function Mqe(t,e){return cY(t,{onHMACAuthInfo:l=>e.type==="hmac"&&l.hmac===e.hmac,onEnvAuthInfo:l=>e.type==="env"&&l.envVar===e.envVar&&l.login===e.login,onUserAuthInfo:l=>e.type==="user"&&cO(l,e),onGhCliAuthInfo:l=>e.type==="gh-cli"&&cO(l,e),onApiKeyAuthInfo:l=>e.type==="api-key"&&l.host===e.host&&l.apiKey===e.apiKey})}async function lPt(t,e){let l=await t.getAllAuthAvailable(),n=">",r="-";return l.map(a=>`${e&&Mqe(a.authInfo,e)?n:r} ${nme(a.authInfo)}`)}function tme(t){return t.host!==kL?`${t.login} (${t.host})`:t.login}async function nPt(){let t=await Sr.load()||{};return t?.last_logged_in_user??t.logged_in_users?.[0]??void 0}async function _qe(t){await Sr.writeKey("last_logged_in_user",t)}async function Swe(){return(await Sr.load()||{}).logged_in_users||[]}async function rPt(t,e){await Sr.writeKey("last_logged_in_user",t),await Sr.writeKey("logged_in_users",e)}async function aPt(t){let e=await Swe();return e.some(n=>cO(n,t))?(e=e.filter(n=>!cO(n,t)),await rPt(void 0,e),e.length>0):!1}async function IPt(t){let e=await Swe();e.some(n=>cO(n,t))||(e.push(t),await rPt(t,e))}function cO(t,e){return t.login===e.login&&t.host===e.host}async function sPt(t,e){try{let l=Lfn(),n=await e.execReturn("gh",["auth","token","--hostname",l],{silent:!0,ignoreReturnCode:!0});if(n.exitCode!==0||!n.stdout.trim()){let a=`Failed to retrieve GitHub token from CLI (exit code: ${n.exitCode})`,I=n.stderr?.trim();return I?t.debug(`${a}: ${I}`):t.debug(a),null}let r=n.stdout.trim();return r.startsWith("ghp_")?(t.debug("GitHub token is a classic PAT"),null):(t.debug("GitHub CLI authenticated with valid token"),{token:r,host:l})}catch(l){let n=`Error checking GitHub CLI: ${l}`;return l&&typeof l=="object"&&"stderr"in l&&typeof l.stderr=="string"&&(n+=` (stderr: ${l.stderr.trim()})`),t.debug(n),null}}function Lfn(){return process.env.GH_HOST||"github.com"}function Dqe(){let t=process.env.GH_HOST;return t?t.startsWith("https://")?t:`https://${t}`:kL}import{existsSync as cPt}from"fs";var Bwe="copilot-cli",Twe;async function Owe(){if(Twe)return Twe;let t=await Promise.resolve().then(()=>$e(iPt(),1));return Twe=t.default||t,Twe}var ame=(t,e)=>{if(!(!t||!e))return`${t}:${e}`},Sfn=()=>{let t=new Map,e=async(o,c)=>{let d=ame(o,c);if(d)if(cPt(Sr.path()))try{let p=(await Sr.load())?.copilot_tokens?.[d];t.set(d,p&&p.trim()!==""?p:void 0)}catch{t.set(d,void 0)}else t.set(d,void 0)},l=async()=>{if(cPt(Sr.path()))try{let c=(await Sr.load())?.copilot_tokens;if(c){let d=Object.values(c).filter(m=>m&&m.trim()!=="");if(d.length>0)return d[0]}}catch{return}},n=async(o,c)=>{let d=ame(o,c);if(!d)return;if(t.has(d))return t.get(d);if((await Sr.load())?.store_token_plaintext)return await e(o,c),t.get(d);try{let p=await(await Owe()).getPassword(Bwe,d);p?t.set(d,p):await e(o,c)}catch{await e(o,c)}return t.get(d)},r=async()=>{if(t.size>0)return t.values().next().value;if((await Sr.load())?.store_token_plaintext)return await l();let c;try{c=await(await Owe()).findPassword(Bwe)}catch{}return c||(c=await l()),c},a=async(o,c)=>{let d=ame(o,c);if(d){t.delete(d);try{return(await Owe()).deletePassword(Bwe,d)}catch{let p=(await Sr.load())?.copilot_tokens??{};return delete p[d],await Sr.writeKey("copilot_tokens",p),Promise.resolve(!0)}}},I=async(o,c,d)=>{if(!o)throw new Error("No token provided to store");let m=ame(c,d);if(!m)return;if(t.set(m,o),(await Sr.load())?.store_token_plaintext)return await s(c,d),!0;try{return await(await Owe()).setPassword(Bwe,m,o),!0}catch{return!1}},s=async(o,c)=>{let d=ame(o,c);if(!d)return;let m=t.get(d);if(!m)return;let p=(await Sr.load())?.copilot_tokens??{};p[d]=m,await Sr.writeKey("copilot_tokens",p)};return{getToken:n,getAnyToken:r,removeToken:a,storeToken:I,storeCurrentTokenInConfig:s}},Ef=Sfn();function cY(t,e){switch(t.type){case"hmac":return e.onHMACAuthInfo(t);case"env":return e.onEnvAuthInfo(t);case"user":return e.onUserAuthInfo(t);case"gh-cli":return e.onGhCliAuthInfo(t);case"api-key":return e.onApiKeyAuthInfo(t);default:{let l=t;throw new Error(`unexpected auth info type: ${JSON.stringify(t)}`)}}}async function Iy(t){return await cY(t,{onHMACAuthInfo:async()=>process.env.GITHUB_MCP_SERVER_TOKEN,onEnvAuthInfo:async e=>e.token,onUserAuthInfo:async e=>await Ef.getToken(e.host,e.login)||void 0,onGhCliAuthInfo:async e=>e.token,onApiKeyAuthInfo:async()=>{}})}var zqe=class{currentAuthInfo=null;logger=new xd;authCallbacks=[];setLogger(e){this.logger=e}onAuthChange(e){this.authCallbacks.push(e)}removeAuthCallback(e){let l=this.authCallbacks.indexOf(e);l>-1&&this.authCallbacks.splice(l,1)}async notifyAuthChange(e,l){this.currentAuthInfo=e;for(let n of this.authCallbacks)try{await n(e,l)}catch(r){this.logger.error(`Error in auth change callback: ${r}`)}}async tryHMACLogin(){let e=await Sr.load()||{},l=e.copilot_hmac_key||e.capi_hmac_key||process.env.CAPI_HMAC_KEY||process.env.COPILOT_HMAC_KEY;return l?[{authInfo:{type:"hmac",hmac:l}}]:[]}async tryGitHubTokenLogin(){let e=process.env.GH_TOKEN||process.env.GITHUB_TOKEN;if(!e)return[];if(e.startsWith("ghp_"))return this.logger.error("Classic PATs are not supported. Please use fine-grained PATs or other supported token types."),[];if(!e.startsWith("gho_")&&!e.startsWith("ghu_")&&!e.startsWith("github_pat_"))return this.logger.error("Unsupported token type, ignoring."),[];let l=Dqe();try{let n=await Wq(l,e);return[{authInfo:{type:"env",host:l,login:n,token:e,envVar:process.env.GH_TOKEN?"GH_TOKEN":"GITHUB_TOKEN"},token:e}]}catch(n){n instanceof XL?this.logger.error(`Failed to fetch PAT user login (${n.status}): ${n.message}`):this.logger.error("Failed to fetch PAT user login")}return[]}async tryGhCliTokenLogin(){let e=new XA(this.logger),l=await sPt(this.logger,e);if(!l)return[];let{token:n,host:r}=l;try{let a=r.startsWith("https://")?r:`https://${r}`,I=await Wq(a,n);return[{authInfo:{type:"gh-cli",host:a,login:I,token:n},token:n}]}catch(a){a instanceof XL?this.logger.error(`Failed to fetch GitHub CLI user login (${a.status}): ${a.message}`):this.logger.error("Failed to fetch GitHub CLI user login")}return[]}async tryApiKeyLogin(){if(!xL())return[];let e,l;return process.env.ANTHROPIC_API_KEY?(e=process.env.ANTHROPIC_API_KEY,l="https://api.anthropic.com"):process.env.OPENAI_API_KEY?(e=process.env.OPENAI_API_KEY,l=process.env.OPENAI_BASE_URL||"https://api.openai.com"):process.env.AZURE_OPENAI_API_KEY&&(e=process.env.AZURE_OPENAI_API_KEY,l=process.env.AZURE_OPENAI_API_ENDPOINT),!e||!l?[]:[{authInfo:{type:"api-key",apiKey:e,host:l}}]}async tryLoginToken(){let e=await nPt(),l;if(e){if(l=await Ef.getToken(e.host,e.login),!l||l.trim()==="")return[]}else{if(l=await Ef.getAnyToken(),!l||l.trim()==="")return[];let n=Dqe();e={host:n,login:await Wq(n,l)}}return[{authInfo:{type:"user",host:e.host,login:e.login},token:l}]}async getAllGitHubLoginTokens(){let l=(await this.tryGitHubTokenLogin()).at(0),n=await Swe(),r=[];for(let a of n){if(l?.authInfo.type==="user"&&cO(a,l.authInfo))continue;let I=await Ef.getToken(a.host,a.login);I&&r.push({authInfo:{type:"user",host:a.host,login:a.login},token:I})}return r}async getAllAuthAvailable(){let e=[],l=this.getPrioritizedAuthMethods(!0);for(let n of l){let r=await n();e.push(...r)}return e}getPrioritizedAuthMethods(e){return[this.tryHMACLogin.bind(this),this.tryApiKeyLogin.bind(this),this.tryGitHubTokenLogin.bind(this),e?this.getAllGitHubLoginTokens.bind(this):this.tryLoginToken.bind(this),this.tryGhCliTokenLogin.bind(this)]}async loadAuthInfo(){let e=this.currentAuthInfo!==null;this.currentAuthInfo=null;let l=this.getPrioritizedAuthMethods(!1);for(let n of l){let r=await n();if(r.length>0){let{authInfo:a,token:I}=r[0];a.type==="user"&&_qe({host:a.host,login:a.login}),this.currentAuthInfo=a,e||await this.notifyAuthChange(a,I);return}}}async getCurrentAuthInfo(){return this.currentAuthInfo||await this.loadAuthInfo(),this.currentAuthInfo}async loginUser(e,l){let n={host:e,login:l},r={type:"user",...n};await IPt(n);let a=await Iy(r);await this.notifyAuthChange(r,a)}async switchToAuth(e){this.currentAuthInfo=e.authInfo,e.authInfo.type==="user"&&await _qe({host:e.authInfo.host,login:e.authInfo.login}),await this.notifyAuthChange(e.authInfo,e.token)}async logout(){if(!this.currentAuthInfo)return!1;let e=await cY(this.currentAuthInfo,{onHMACAuthInfo:async()=>!1,onEnvAuthInfo:async()=>!1,onUserAuthInfo:async l=>(await Ef.removeToken(l.host,l.login),await aPt(l)),onGhCliAuthInfo:async()=>!1,onApiKeyAuthInfo:async()=>!1});return await this.notifyAuthChange(null),e}},Bfn=new zqe,Uwe=Bfn;var Rf=class t extends HL{constructor(l,n,r,a,I){super(l,n,a,"direct");this.exec=r;this.enableAllGithubMcpTools=I??!1}static GITHUB_SERVER_NAME="github-mcp-server";static CLI_DEFAULT_GITHUB_MCP_TOOLS=["get_file_contents","search_code","search_repositories","list_branches","list_commits","get_commit","get_issue","list_issues","get_issue_comments","search_issues","pull_request_read","list_pull_requests","search_pull_requests","list_workflow_runs","get_job_logs","get_workflow_run","list_workflows","get_workflow_run_logs","web_search","search_users"];static BUILTIN_SERVERS=[t.GITHUB_SERVER_NAME];static getBuiltInServerNames(){return[...t.BUILTIN_SERVERS]}hasUserConfiguredGitHubServer=!1;lastGitHubAuthInfo=null;githubMcpToken;enableAllGithubMcpTools;async configureGitHubAuth(l){if(this.isServerDisabled(t.GITHUB_SERVER_NAME))return this.logger.debug("GitHub MCP server is disabled, skipping auto-configuration"),!1;if(this.hasUserConfiguredGitHubServer)return this.logger.debug("User has explicitly configured github-mcp-server, ignoring auth changes"),!1;if(await this.shouldHandleGitHubAuth(l)){let r=await Iy(l);if(!r)return this.logger.debug("No token available for GitHub authentication"),!1;if(this.lastGitHubAuthInfo=l,r===this.githubMcpToken)return!1;this.githubMcpToken=r;let a=await this.createGitHubServerConfig(r,l);try{return await this.restartServer(t.GITHUB_SERVER_NAME,a),this.logger.log("GitHub MCP server configured after authentication"),!0}catch(I){return this.logger.error(`Failed to configure GitHub MCP server after auth: ${I}`),!1}}return!1}async removeGitHubAuth(){if(this.hasUserConfiguredGitHubServer)return this.logger.debug("User has explicitly configured github-mcp-server, ignoring auth changes"),!1;this.githubMcpToken=void 0;try{return this.isServerRunning(t.GITHUB_SERVER_NAME)?(await this.stopServer(t.GITHUB_SERVER_NAME),this.logger.debug("Removed GitHub MCP server"),!0):!1}catch(l){return this.logger.error(`Failed to remove GitHub server: ${l}`),!1}}async shouldHandleGitHubAuth(l){return await cY(l,{onHMACAuthInfo:async()=>!!process.env.GITHUB_MCP_SERVER_TOKEN,onEnvAuthInfo:async()=>!0,onUserAuthInfo:async()=>!0,onGhCliAuthInfo:async()=>!0,onApiKeyAuthInfo:async()=>!1})}async createGitHubServerConfig(l,n){let r="https://api.githubcopilot.com/mcp/readonly";try{let a=await cY(n,{onHMACAuthInfo:async()=>"https://github.com",onEnvAuthInfo:async s=>s.host,onUserAuthInfo:async s=>s.host,onGhCliAuthInfo:async s=>s.host,onApiKeyAuthInfo:async s=>s.host}),I=await E0(a,l,this.logger);r=new URL("/mcp/readonly",I).toString()}catch(a){this.logger.error(`Failed to fetch Copilot URL, using default: ${a}`)}return{type:"http",url:r,headers:{Authorization:"Bearer "+l,"X-MCP-Toolsets":"repos,issues,users,pull_requests,code_security,secret_protection,actions,web_search","X-MCP-Host":"copilot-cli"},tools:this.enableAllGithubMcpTools?["*"]:t.CLI_DEFAULT_GITHUB_MCP_TOOLS,isDefaultServer:!0,filterMapping:{get_issue:"markdown",get_issue_comments:"markdown",get_pull_request:"markdown",get_pull_request_comments:"markdown",get_pull_request_reviews:"markdown"}}}async injectDefaultServers(l){if(l.mcpServers[t.GITHUB_SERVER_NAME]){this.hasUserConfiguredGitHubServer=!0,this.logger.debug("User has already configured github-mcp-server, skipping auto-configuration");return}}async startBuiltInServer(l){l===t.GITHUB_SERVER_NAME&&!this.hasUserConfiguredGitHubServer?this.lastGitHubAuthInfo?(this.logger.log("Attempting to configure GitHub MCP server using stored authentication"),await this.configureGitHubAuth(this.lastGitHubAuthInfo)?this.logger.log("GitHub MCP server configured successfully after enabling"):this.logger.log("GitHub MCP server enabled but could not be configured - authentication may be invalid or insufficient")):this.logger.log("GitHub MCP server enabled - will be configured automatically when authentication becomes available"):await super.startBuiltInServer(l)}};var Tfn=zl({commandHistory:Od(Qt())}),Pqe=xwe(Tfn.parse,"command-history");var Ofn=50,jqe=class{commandHistory=[];historyIndex=-1;isNavigatingHistory=!1;unSubmittedCommand=null;async initialize(){try{let e=await Pqe.load();this.commandHistory=e?.commandHistory||[],this.resetNavigation()}catch{this.commandHistory=[]}}async addCommand(e){this.commandHistory=this.commandHistory.filter(l=>l!==e),this.commandHistory.unshift(e),this.commandHistory=this.commandHistory.slice(0,Ofn),this.resetNavigation(),this.unSubmittedCommand=null,await this.saveHistory()}async updateCurrentCommand(e){this.historyIndex!==-1?(this.commandHistory[this.historyIndex]=e,await this.saveHistory()):this.unSubmittedCommand=e}navigateUp(e){if(this.commandHistory.length===0)return;let l=this.historyIndex+1;if(l<this.commandHistory.length){this.historyIndex=l,this.isNavigatingHistory=!0;let n=this.getCurrentHistoryItem();n&&e.setText(n)}}navigateDown(e){if(this.historyIndex===-1)return;if(this.historyIndex===0)this.resetNavigation();else{let n=this.historyIndex-1;this.historyIndex=n,this.isNavigatingHistory=!0}let l=this.getCurrentHistoryItem();l?(e.setText(l),e.setCursorPosition(0)):e.clear()}resetNavigation(){this.historyIndex=-1,this.isNavigatingHistory=!1}getHistoryIndex(){return this.historyIndex}getHistory(){return this.commandHistory}getCurrentHistoryItem(){return this.historyIndex===-1?this.unSubmittedCommand?this.unSubmittedCommand:void 0:this.commandHistory[this.historyIndex]}isNavigating(){return this.isNavigatingHistory}setNavigating(e){this.isNavigatingHistory=e}async saveHistory(){try{await Pqe.write({commandHistory:this.commandHistory})}catch{}}},dY=new jqe;function uPt(t,e){var l=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),l.push.apply(l,n)}return l}function mPt(t){for(var e=1;e<arguments.length;e++){var l=arguments[e]!=null?arguments[e]:{};e%2?uPt(Object(l),!0).forEach(function(n){Ufn(t,n,l[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(l)):uPt(Object(l)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(l,n))})}return t}function Ufn(t,e,l){return e=Mfn(e),e in t?Object.defineProperty(t,e,{value:l,enumerable:!0,configurable:!0,writable:!0}):t[e]=l,t}function Mfn(t){var e=_fn(t,"string");return typeof e=="symbol"?e:String(e)}function _fn(t,e){if(typeof t!="object"||t===null)return t;var l=t[Symbol.toPrimitive];if(l!==void 0){var n=l.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Dfn=GPt({}),bPt=Dfn;function GPt(t){return e.withOptions=l=>GPt(mPt(mPt({},t),l)),e;function e(l,...n){let r=typeof l=="string"?[l]:l.raw,{escapeSpecialCharacters:a=Array.isArray(l),trimWhitespace:I=!0}=t,s="";for(let d=0;d<r.length;d++){let m=r[d];a&&(m=m.replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`").replace(/\\\$/g,"$").replace(/\\\{/g,"{")),s+=m,d<n.length&&(s+=n[d])}let o=s.split(`
|
|
2040
2040
|
`),c=null;for(let d of o){let m=d.match(/^(\s+)\S+/);if(m){let G=m[1].length;c?c=Math.min(c,G):c=G}}if(c!==null){let d=c;s=o.map(m=>m[0]===" "||m[0]===" "?m.slice(d):m).join(`
|
|
2041
2041
|
`)}return I&&(s=s.trim()),a&&(s=s.replace(/\\n/g,`
|
|
2042
2042
|
`)),s}}import{homedir as xjt}from"node:os";import E4n,{resolve as R4n}from"node:path";function zfn(t){return t.length>0&&/^[0-9a-zA-Z_-]+$/.test(t)}function hPt(t){return!t||t.length===0?{valid:!1,error:"MCP server name cannot be empty"}:/^[0-9a-zA-Z_-]+$/.test(t)?{valid:!0}:{valid:!1,error:"MCP server name must only contain alphanumeric characters, underscores, and hyphens"}}var pPt=G0(["none","markdown","hidden_characters"]),APt=zl({tools:Od(Qt()),type:Qt().optional(),isDefaultServer:ro().optional(),filterMapping:rY(Qt(),pPt).or(pPt).optional()}),Pfn=APt.extend({type:pr("local").optional(),command:Qt(),args:Od(Qt()),env:rY(Qt(),Qt()).optional()}),jfn=APt.extend({type:pr("http").or(pr("sse")),url:Qt(),headers:rY(Qt(),Qt()).optional()}),Kqe=zl({mcpServers:rY(Qt().min(1,"MCP server name cannot be empty").refine(zfn,{message:"MCP server name must only contain alphanumeric characters, underscores, and hyphens"}),Pfn.or(jfn))}),uY=Jwe(Kqe.parse,"mcp");function gPt(t){let e=t.r/255,l=t.g/255,n=t.b/255,r=Math.max(e,l,n),a=Math.min(e,l,n),I=r-a,s=0,o=0,c=(r+a)/2;if(I!==0){switch(o=c>.5?I/(2-r-a):I/(r+a),r){case e:s=(l-n)/I+(l<n?6:0);break;case l:s=(n-e)/I+2;break;case n:s=(e-l)/I+4;break}s/=6}return{h:s*360,s:o,l:c}}function Kfn(t){if(t.length<12||t.length>18)return null;let e=t.match(/rgb:([0-9a-f]+)\/([0-9a-f]+)\/([0-9a-f]+)/i);if(!e)return null;let[,l,n,r]=e,a=c=>c.length>=2?parseInt(c.substring(0,2),16):c.length===1?parseInt(c+c,16):0,I=a(l),s=a(n),o=a(r);return{r:I,g:s,b:o}}var ZPt=["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff","#000000","#00005f","#000087","#0000af","#0000d7","#0000ff","#005f00","#005f5f","#005f87","#005faf","#005fd7","#005fff","#008700","#00875f","#008787","#0087af","#0087d7","#0087ff","#00af00","#00af5f","#00af87","#00afaf","#00afd7","#00afff","#00d700","#00d75f","#00d787","#00d7af","#00d7d7","#00d7ff","#00ff00","#00ff5f","#00ff87","#00ffaf","#00ffd7","#00ffff","#5f0000","#5f005f","#5f0087","#5f00af","#5f00d7","#5f00ff","#5f5f00","#5f5f5f","#5f5f87","#5f5faf","#5f5fd7","#5f5fff","#5f8700","#5f875f","#5f8787","#5f87af","#5f87d7","#5f87ff","#5faf00","#5faf5f","#5faf87","#5fafaf","#5fafd7","#5fafff","#5fd700","#5fd75f","#5fd787","#5fd7af","#5fd7d7","#5fd7ff","#5fff00","#5fff5f","#5fff87","#5fffaf","#5fffd7","#5fffff","#870000","#87005f","#870087","#8700af","#8700d7","#8700ff","#875f00","#875f5f","#875f87","#875faf","#875fd7","#875fff","#878700","#87875f","#878787","#8787af","#8787d7","#8787ff","#87af00","#87af5f","#87af87","#87afaf","#87afd7","#87afff","#87d700","#87d75f","#87d787","#87d7af","#87d7d7","#87d7ff","#87ff00","#87ff5f","#87ff87","#87ffaf","#87ffd7","#87ffff","#af0000","#af005f","#af0087","#af00af","#af00d7","#af00ff","#af5f00","#af5f5f","#af5f87","#af5faf","#af5fd7","#af5fff","#af8700","#af875f","#af8787","#af87af","#af87d7","#af87ff","#afaf00","#afaf5f","#afaf87","#afafaf","#afafd7","#afafff","#afd700","#afd75f","#afd787","#afd7af","#afd7d7","#afd7ff","#afff00","#afff5f","#afff87","#afffaf","#afffd7","#afffff","#d70000","#d7005f","#d70087","#d700af","#d700d7","#d700ff","#d75f00","#d75f5f","#d75f87","#d75faf","#d75fd7","#d75fff","#d78700","#d7875f","#d78787","#d787af","#d787d7","#d787ff","#d7af00","#d7af5f","#d7af87","#d7afaf","#d7afd7","#d7afff","#d7d700","#d7d75f","#d7d787","#d7d7af","#d7d7d7","#d7d7ff","#d7ff00","#d7ff5f","#d7ff87","#d7ffaf","#d7ffd7","#d7ffff","#ff0000","#ff005f","#ff0087","#ff00af","#ff00d7","#ff00ff","#ff5f00","#ff5f5f","#ff5f87","#ff5faf","#ff5fd7","#ff5fff","#ff8700","#ff875f","#ff8787","#ff87af","#ff87d7","#ff87ff","#ffaf00","#ffaf5f","#ffaf87","#ffafaf","#ffafd7","#ffafff","#ffd700","#ffd75f","#ffd787","#ffd7af","#ffd7d7","#ffd7ff","#ffff00","#ffff5f","#ffff87","#ffffaf","#ffffd7","#ffffff","#080808","#121212","#1c1c1c","#262626","#303030","#3a3a3a","#444444","#4e4e4e","#585858","#626262","#6c6c6c","#767676","#808080","#8a8a8a","#949494","#9e9e9e","#a8a8a8","#b2b2b2","#bcbcbc","#c6c6c6","#d0d0d0","#dadada","#e4e4e4","#eeeeee"];function qfn(t){let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:{r:0,g:0,b:0}}function $fn(t){return t<0||t>=ZPt.length?{r:0,g:0,b:0}:qfn(ZPt[t])}function NPt(t){if(t.length<15||t.length>30)return null;let e=t;e.endsWith("\x07")?e=e.slice(0,-1):e.endsWith("\x1B\\")?e=e.slice(0,-2):e.endsWith("\x9C")&&(e=e.slice(0,-1));let l=e;return l.startsWith("11;")&&(l=l.substring(3)),l.startsWith("rgb:")?Kfn(l):null}async function eHn(t=100){return new Promise(e=>{if(!process.stdout.isTTY||!process.stdin.isTTY){e(null);return}let l="",n=null,r=()=>{process.stdin.removeListener("data",a),process.stdin.setRawMode(!1),n&&clearTimeout(n)},a=I=>{l+=I.toString();let s=l.match(/\x1b\]11;([^\x07\x1b\x9c]*?)(?:\x07|\x1b\\|\x9c)/);if(s){r();let c=`11;${s[1]}`;e(NPt(c));return}let o=l.match(/11;rgb:([0-9a-f/]+)(?:\x07|\x1b\\|\x9c)/i);if(o){r(),e(NPt(`11;rgb:${o[1]}`));return}};n=setTimeout(()=>{r(),e(null)},t);try{process.stdin.setRawMode(!0),process.stdin.on("data",a),process.stdout.write("\x1B]11;?\x1B\\")}catch{r(),e(null)}})}function tHn(){let t=process.env.COLORFGBG;if(!t||!t.includes(";"))return null;let e=t.split(";"),l=e[e.length-1],n=parseInt(l,10);return isNaN(n)?null:$fn(n)}async function WPt(){try{let t=await eHn();if(t)return gPt(t).l<.5;let e=tHn();return e?gPt(e).l<.5:!0}catch{return!0}}var yPt={FG:"whiteBright",ACCENT:"blue",SUCCESS:"green",DIFF_ADDED_HIGHLIGHT_FG:"black",DIFF_REMOVED_HIGHLIGHT_FG:"whiteBright",ERROR:"red",WARNING:"yellow",COPILOT:"magenta",COPILOT_BRIGHT:"magentaBright",MUTED:"white",SELECTED:"cyan",BORDER:"blackBright"},lHn={FG:"black",ACCENT:"blue",SUCCESS:"green",DIFF_ADDED_HIGHLIGHT_FG:"black",DIFF_REMOVED_HIGHLIGHT_FG:"whiteBright",ERROR:"red",WARNING:"yellow",COPILOT:"magenta",COPILOT_BRIGHT:"magentaBright",MUTED:"blackBright",SELECTED:"cyan",BORDER:"blackBright"};function qqe(t){return t==="auto"||t==="dark"||t==="light"}function Mwe(t){switch(t){case"dark":return yPt;case"light":return lHn;default:return yPt}}var _we=await WPt();async function Dwe(){let e=(await Sr.load())?.theme||"";return qqe(e)?e:"auto"}async function EPt(t){await Sr.writeKey("theme",t)}var RPt=t=>{let e=t?Sl.whiteBright:Sl.black,l=t?Sl.cyanBright:Sl.blueBright,n=t?Sl.magentaBright:Sl.magenta;return{text:e,paragraph:e,html:e,table:e,blockquote:e,heading:Sl.bold,firstHeading:Sl.whiteBright.bold,strong:Sl.bold,em:Sl.italic,del:Sl.strikethrough,hr:Sl.white,link:l,href:l,image:(r,a,I)=>n(I?`Image: ${I} \u2192 ${r}`:`Image: ${r}`),codespan:Sl.cyan,code:Sl.cyan,list:(r,a,I)=>{let s=r.replace(/^(\s*)\* /gm,"$1- ");return I&&(s=s.split(`
|
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.352-
|
|
4
|
+
"version": "0.0.352-3",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
@@ -37,6 +37,6 @@
|
|
|
37
37
|
"worker/**/*"
|
|
38
38
|
],
|
|
39
39
|
"buildMetadata": {
|
|
40
|
-
"gitCommit": "
|
|
40
|
+
"gitCommit": "d484d2d"
|
|
41
41
|
}
|
|
42
42
|
}
|