@github/copilot 0.0.353 → 0.0.354-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.
- package/index.js +2 -1
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -2020,12 +2020,13 @@ Pay attention to the following when using it:
|
|
|
2020
2020
|
${a}`;await r.createOrUpdateMCPStartupToolCall({serverName:e,content:o,toolNamesToDisplayNames:I}),this.logger.log(`Updated session log for ${e} with ${l.length} tools`)}catch(a){this.logger.error(`Failed to update session log for ${e}: ${a}`)}}};var HL=class t{static resolveString(e,l){return!l||e.length>1e3?e:e.replace(/\$\{([A-Z0-9_]+)(?::-([^}]*))?\}|\$([A-Z0-9_]+)(?![A-Z0-9_])/g,(n,r,a,I)=>{let o=l[r||I];return o!==void 0?o:a!==void 0?a:n})}static resolveArray(e,l){return e?l?e.map(n=>t.resolveString(n,l)):e:[]}static resolveHeaders(e,l){if(!e)return{};if(!l)return e;let n={};for(let[r,a]of Object.entries(e)){let I=t.resolveArray([a],l);n[r]=I[0]}return n}static resolveLocalServerConfig(e,l){let n=t.resolveString(e.command,l),r=t.resolveArray(e.args,l),a;return e.cwd&&(a=t.resolveString(e.cwd,l)),{...e,command:n,args:r,cwd:a}}static resolveRemoteServerConfig(e,l=process.env){let n=t.resolveString(e.url,l),r=t.resolveHeaders(e.headers,l);return{...e,url:n,headers:r}}};var Qqe={mcpServers:{}},mwe=class{constructor(e,l,n){this.logger=e;this.registry=l;this.remoteEnabled=n?.remoteEnabled??!1,this.mcp3pEnabled=n?.mcp3pEnabled??!1,this.blackbirdMetisIndexEnabled=n?.blackbirdMetisIndexEnabled??!1,this.sessionClient=n?.sessionClient,this.mcpEnvConfig=void 0,this.envValueMode=n?.envValueMode??this.registry.envValueMode}remoteEnabled;mcp3pEnabled;blackbirdMetisIndexEnabled;mcpEnvConfig;sessionClient;envValueMode;ReadMcpConfigFromEnv(e){this.mcpEnvConfig=process.env.GITHUB_COPILOT_MCP_JSON,this.mcp3pEnabled=process.env.GITHUB_COPILOT_3P_MCP_ENABLED==="true",this.remoteEnabled=process.env.GITHUB_COPILOT_REMOTE_MCP_ENABLED==="true",this.blackbirdMetisIndexEnabled=process.env.BLACKBIRD_METIS_INDEX_ENABLED==="true";let l=this.validateEnvConfig();return process.env.GITHUB_COPILOT_CLI_MODE==="true"?this.logger.log("CLI mode detected - skipping default MCP servers"):(this.logger.log("Adding default MCP servers to configuration"),this.configureBlackbirdMcp(l,e),this.configureGitHubMcp(l,e),this.configurePlaywrightMcp(l)),l}validateEnvConfig(){if(!this.mcp3pEnabled)return this.logger.log("User-provided MCPs are disabled"),Qqe;if(this.logger.log("User-provided MCPs are enabled, checking for environment variable"),!this.mcpEnvConfig)return this.logger.log("No user-provided MCP servers found"),Qqe;try{let e=JSON.parse(this.mcpEnvConfig);if(!e.mcpServers)throw new Error("User-provided config had incorrect format. Missing 'mcpServers' property.");for(let l in e.mcpServers){if(l.indexOf("/")===-1)continue;let n=l.replace(/\//g,"__");e.mcpServers[n]=e.mcpServers[l],delete e.mcpServers[l]}for(let l in e.mcpServers)e.mcpServers[l].isDefaultServer=!1;return e}catch(e){return this.logger.error(`Warning: User-provided MCP servers were defined but invalid: ${e}`),Qqe}}configureGitHubMcp(e,l){this.remoteEnabled?this.configureRemoteGitHubMcp(e,l):this.configureLocalGitHubMcp(e)}configureRemoteGitHubMcp(e,l){let n="repos,issues,users,pull_requests,code_security,secret_protection,actions,web_search";process.env.COPILOT_MCP_COPILOT_SPACES_ENABLED==="true"&&(this.logger.log("Enabling Copilot Spaces in GitHub MCP server configuration"),n=n+",copilot_spaces");let r={Authorization:"Bearer "+process.env.GITHUB_PERSONAL_ACCESS_TOKEN,"X-MCP-Toolsets":n,"X-MCP-Host":"github-coding-agent","X-Initiator":"agent"};l&&l.api?.copilot?.integrationId&&(r["Copilot-Integration-Id"]=l.api.copilot.integrationId),process.env.GITHUB_COPILOT_INTERACTION_ID&&(r["X-Interaction-Id"]=process.env.GITHUB_COPILOT_INTERACTION_ID);let a={type:"http",url:this.getCapiMcpUrl(),headers:r,tools:["*"],isDefaultServer:!0};this.setDefaultGitHubFilterMapping(a);let I=e.mcpServers[vL]??void 0;if(I&&fL(I)){let s=structuredClone(I);this.logger.log("GitHub MCP server configuration already provided by user, skipping default remote configuration"),I.headers===void 0&&(I.headers={}),s.headers={...r,...I.headers},s.isDefaultServer=!0,this.setDefaultGitHubFilterMapping(s),e.mcpServers[vL]=s}else this.logger.log("Using default remote GitHub MCP server configuration"),e.mcpServers[vL]=a}configureLocalGitHubMcp(e){if(e.mcpServers[vL]){this.logger.log("Using user-provided GitHub MCP server configuration");let l=e.mcpServers[vL]??{};Nq(l)&&!l.command&&(e.mcpServers[vL]={...l,command:"./copilot-developer-action-main/github-mcp-server/github-mcp-server",isDefaultServer:!0},this.logger.log("Added default command to user-provided GitHub MCP server configuration"))}else{this.logger.log("Using default local GitHub MCP server configuration");let l={command:"./copilot-developer-action-main/github-mcp-server/github-mcp-server",args:["stdio","--read-only"],env:{GITHUB_PERSONAL_ACCESS_TOKEN:"GITHUB_PERSONAL_ACCESS_TOKEN",GITHUB_HOST:"GITHUB_SERVER_URL"},tools:["*"],isDefaultServer:!0};e.mcpServers[vL]=l}}setDefaultGitHubFilterMapping(e){e.filterMapping??={get_issue:"markdown",get_issue_comments:"markdown",get_pull_request:"markdown",get_pull_request_comments:"markdown",get_pull_request_reviews:"markdown"}}configurePlaywrightMcp(e){if(!e.mcpServers[Vqe]){if((process.env.COPILOT_FEATURE_FLAGS??"").split(",").map(n=>n.trim()).includes("copilot_swe_agent_playwright_use_firewall")){this.logger.log("Playwright MCP server is configured to use the firewall, skipping launch.");return}this.logger.log("Enabling Playwright MCP server");let l={command:"npx",args:[...sMe,"--allowed-origins","localhost;localhost:*;127.0.0.1;127.0.0.1:*"],tools:["*"],isDefaultServer:!0};e.mcpServers[Vqe]=l}}configureBlackbirdMcp(e,l){this.remoteEnabled?this.configureRemoteBlackbirdMcp(e):this.blackbirdMetisIndexEnabled?this.configureLocalMetisBlackbirdMCP(e,l):this.configureLocalBlackbirdMcp(e)}configureLocalMetisBlackbirdMCP(e,l){this.logger.log("Using local Metis Blackbird MCP server configuration"),this.logger.log(`Using blackbird mode: ${l.blackbird?.mode}`);let n=process.env.AGENT_DIR||"/agent";this.logger.log(`Using agent directory: ${n}`);let r=[];l.blackbird?.mode==="tool"&&(r=["*"]),this.logger.log(`Using blackbird Metis server: ${l.blackbird?.mode}`);let a={command:`${n}/blackbird/mcp`,args:["serve","--index",`${n}/blackbird/metis`],env:{GITHUB_PERSONAL_ACCESS_TOKEN:"GITHUB_PERSONAL_ACCESS_TOKEN",COPILOT_API_HMAC_KEY:"CAPI_HMAC_KEY",MODEL_BASED_RETRIEVAL_TOKEN:"BLACKBIRD_AUTH_MODEL_BASED_RETRIEVAL_TOKEN",METIS_API_KEY:"BLACKBIRD_AUTH_METIS_API_KEY"},tools:r,isDefaultServer:!0};e.mcpServers[Due]=a}configureLocalBlackbirdMcp(e){this.logger.log("Using local Blackbird MCP server configuration"),this.logger.log(`Using blackbird mode: ${process.env.BLACKBIRD_MODE}`);let l=[];process.env.BLACKBIRD_MODE==="tool"&&(l=["*"]);let n={command:"./copilot-developer-action-main/blackbird-mcp-server/blackbird-mcp-server",args:["stdio"],env:{GITHUB_PERSONAL_ACCESS_TOKEN:"GITHUB_PERSONAL_ACCESS_TOKEN",CAPI_HOST:"COPILOT_API_URL"},tools:l,isDefaultServer:!0};e.mcpServers[Due]=n}configureRemoteBlackbirdMcp(e){this.logger.log("Using remote Blackbird MCP server configuration"),this.logger.log(`Using blackbird mode: ${process.env.BLACKBIRD_MODE}`);let l=[];process.env.BLACKBIRD_MODE==="tool"&&(l=["*"]);let n={Authorization:"Bearer "+process.env.GITHUB_PERSONAL_ACCESS_TOKEN,"X-MCP-Toolsets":"search_agent","X-MCP-Host":"github-coding-agent"};process.env.GITHUB_COPILOT_INTERACTION_ID&&(n["X-Interaction-Id"]=process.env.GITHUB_COPILOT_INTERACTION_ID);let r={type:"http",url:this.getCapiMcpUrl(),headers:n,tools:l,isDefaultServer:!0};e.mcpServers[Due]=r}getCapiMcpUrl(){return process.env.COPILOT_API_URL?new URL("/mcp/readonly",process.env.COPILOT_API_URL).toString():"https://api.githubcopilot.com/mcp/readonly"}isValidServerType(e){return Nq(e)||Pue(e)||jue(e)||Kue(e)}isValidLocalServerConfig(e){return e.command!==void 0&&e.command.trim()!==""&&Array.isArray(e.args)}isValidRemoteServerConfig(e){return e.url!==void 0&&e.url.trim()!==""}isValidInMemoryServerConfig(e){return e.serverInstance!==void 0&&typeof e.serverInstance=="object"}validateServerConfig(e,l){return this.remoteEnabled&&!this.isValidServerType(l)?(this.logger.error(`Unsupported server type "${l.type}" for server "${e}". Only "Local", "STDIO", "HTTP", "SSE", or "Memory" are supported.`),!1):!this.remoteEnabled&&!Nq(l)&&!Kue(l)?(this.logger.error(`Unsupported server type "${l.type}" for server "${e}". Only "Local", "STDIO", or "Memory" are supported.`),!1):l.tools?Nq(l)&&!this.isValidLocalServerConfig(l)?(this.logger.error(`Invalid local server configuration for "${e}". Please ensure 'command' and 'args' are provided.`),!1):(Pue(l)||jue(l))&&!this.isValidRemoteServerConfig(l)?(this.logger.error(`Invalid remote server configuration for "${e}". Please ensure 'url' is provided.`),!1):Kue(l)&&!this.isValidInMemoryServerConfig(l)?(this.logger.error(`Invalid in-memory server configuration for "${e}". Please ensure 'serverInstance' is provided and is an instance of MCPServer.`),!1):!0:(this.logger.error(`No tools specified for server "${e}". Please provide a list of tools or "*" to include all tools.`),!1)}async processHttpServer(e,l){try{let n=HL.resolveHeaders(l.headers,process.env),r={...l,headers:n};await this.registry.startHttpMcpClient(e,r),this.logger.log(`Started MCP client for remote server ${e}`)}catch(n){throw this.logger.error(`Failed to start MCP client for remote server ${e}: ${n}`),n}}async processSseServer(e,l){try{let n=HL.resolveRemoteServerConfig(l,process.env);await this.registry.startSseMcpClient(e,n),this.logger.log(`Started MCP client for remote server ${e}`)}catch(n){throw this.logger.error(`Failed to start MCP client for remote server ${e}: ${n}`),n}}async processInMemoryServer(e,l){try{await this.registry.startInMemoryMcpClient(e,l.serverInstance),this.logger.log(`Started in-memory MCP client for ${e}`)}catch(n){throw this.logger.error(`Failed to start in-memory MCP client for ${e}: ${n}`),n}}async processLocalServer(e,l){let n={...l};if(l.command==="python")try{n=await this.convertPythonToPipx(n)}catch(I){this.logger.error(`Failed to handle Python module for ${e}: ${I}`)}let r=this.buildEnvironment(n),a=HL.resolveLocalServerConfig(n,r);this.logger.log(`Starting MCP client for ${e} with command: ${a.command} and args: ${a.args}`),a.cwd&&this.logger.log(`cwd: ${a.cwd}`);try{await this.registry.startLocalMcpClient(e,r,a.command,a.args,a.cwd),this.logger.log(`Started MCP client for ${e}`)}catch(I){throw this.logger.error(`Failed to start MCP client for ${e}: ${I}`),I}}convertPythonToPipx(e){if(!e||!e.args||e.args.length===0)return e;let l=e.args;if(l.length>1e3)throw new Error("Too many arguments provided to Python command");let n=l.indexOf("-m");if(n===-1||n===l.length-1)throw new Error("Python command with -m flag must specify a module");let r=l[n+1];this.logger.log(`Converting Python module: ${r} to pipx command`);let a=["run",r];for(let I=n+2;I<l.length;I++)a.push(l[I]);for(let I=0;I<n;I++)a.push(l[I]);return{...e,command:"pipx",args:a}}buildEnvironment(e){let l={};if(e.env)if(this.envValueMode==="direct")for(let[n,r]of Object.entries(e.env))l[n]=HL.resolveString(r,process.env);else for(let[n,r]of Object.entries(e.env)){let a=r.trim(),I=a;if(a.includes("$")&&(I=HL.resolveString(a,process.env)),I!==a){l[n]=I;continue}process.env[a]!==void 0&&(l[n]=process.env[a])}return l}async processServers(e){if(!e)throw new Error("No servers to process");let l=Object.entries(e.mcpServers).map(([n,r])=>this.processServer(n,r));await Promise.all(l)}async processServer(e,l){if(e=e.replace(/\//g,"__"),!this.validateServerConfig(e,l)){this.logger.error(`Skipping server "${e}" due to invalid configuration.`);return}zue.includes(e)||await this.sessionClient?.createOrUpdateMCPStartupToolCall({serverName:e});try{Nq(l)?await this.processLocalServer(e,l):Pue(l)&&this.remoteEnabled?await this.processHttpServer(e,l):jue(l)&&this.remoteEnabled?await this.processSseServer(e,l):Kue(l)&&await this.processInMemoryServer(e,l)}catch(n){zue.includes(e)||await this.logServerFailure(e,n)}}async logServerFailure(e,l){if(this.sessionClient)try{await this.sessionClient.createOrUpdateMCPStartupToolCall({serverName:e,content:`<error>MCP server failed to start: ${l.message} - for the full output, see the verbose logs</error>`})}catch(n){this.logger.error(`Failed to log failure for MCP Server '${e}': '${n}'`)}}};var XL=class{constructor(e,l,n,r="indirect"){this.logger=e;let a;if(typeof l=="string"){if(a=JSON.parse(l),typeof a!="object")throw new Error("Invalid MCP configuration: must be an object");if(a===null||!("mcpServers"in a)||typeof a.mcpServers!="object")throw new Error("Invalid MCP configuration: missing or invalid mcpServers property");this.config=a}else this.config=l;this.disabledServers=new Set(n||[]),this.registry=new uwe(this.logger,void 0,void 0,r),this.processor=new mwe(this.logger,this.registry,{mcp3pEnabled:!0,remoteEnabled:!0})}registry;processor;config;startServersPromise=null;transport=null;disabledServers;async startServers(){return this.startServersPromise||(this.startServersPromise=this.processServersWithExtensions()),this.startServersPromise}async injectDefaultServers(e){}async processServersWithExtensions(){await this.injectDefaultServers(this.config);let e;if(this.disabledServers.size>0){let l={};for(let[n,r]of Object.entries(this.config.mcpServers))this.disabledServers.has(n)?this.logger.log(`Skipping disabled MCP server: ${n}`):l[n]=r;e={...this.config,mcpServers:l}}else e=this.config;return this.processor.processServers(e)}async stopServers(){for(let[e,l]of Object.entries(this.registry.transports))try{await l.close()}catch(n){this.logger.error(`Error closing transport for ${e}: ${n}`)}this.startServersPromise=null,this.transport=null}async getTools(e,l,n){await this.startServers(),this.transport=this.transport??new Ioe(e,l,!0);let r=[];for(let a of Object.keys(this.registry.clients)){let I=await this.transport.loadTools({mcpClient:this.registry.clients[a],clientName:a,tools:this.config.mcpServers[a]?.tools||["*"],filterMapping:this.config.mcpServers[a]?.filterMapping||"hidden_characters"},n);r.push(...I)}return r}getConfig(){return this.config}getClients(){return this.registry.clients}async startServer(e,l){await this.startServers(),this.config.mcpServers[e]=l,await this.processor.processServer(e,l),this.transport=null}async stopServer(e){let l=this.registry.transports[e];if(l)try{await l.close(),delete this.registry.transports[e]}catch(n){this.logger.error(`Error closing transport for ${e}: ${n}`)}this.registry.clients[e]&&delete this.registry.clients[e],this.transport=null}async restartServer(e,l){this.isServerRunning(e)&&await this.stopServer(e),delete this.config.mcpServers[e],await this.startServer(e,l)}isServerRunning(e){return e in this.registry.transports&&e in this.registry.clients}isServerDisabled(e){return this.disabledServers.has(e)}async disableServer(e){if(this.disabledServers.has(e)){this.logger.log(`Server ${e} is already disabled`);return}this.disabledServers.add(e),this.logger.log(`Disabled server ${e} for this session`),this.isServerRunning(e)&&await this.stopServer(e),this.transport=null}async enableServer(e){if(!this.disabledServers.has(e)){this.logger.log(`Server ${e} is not disabled`);return}this.disabledServers.delete(e),this.logger.log(`Enabled server ${e} for this session`);let l=this.getServerConfig(e);l?await this.startServer(e,l):await this.startBuiltInServer(e),this.transport=null}async startBuiltInServer(e){}getServerConfig(e){return this.config.mcpServers[e]}};var fCn="/login/device/code",HCn="/login/oauth/access_token",szt="Ov23ctDVkRmgkPke0Mmm",LL="https://github.com",kL=class extends Error{constructor(l,n){super(n);this.status=l;this.message=n;this.name="GitHubApiError"}};function aO(t){let e=new URL(t);return e.hostname.startsWith("api.")||(e.hostname="api."+e.hostname),e.href}async function ozt(t){let e=new URL(fCn,t),l=await fetch(e.href,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({client_id:szt,scope:"user:email,read:user,repo,workflow"})});if(!l.ok)throw new kL(l.status,`Failed to request device code: ${l.statusText}`);return await l.json()}async function izt(t,e){let l=new URL(HCn,t),n=await fetch(l.href,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({client_id:szt,device_code:e,grant_type:"urn:ietf:params:oauth:grant-type:device_code"})});if(!n.ok)throw new kL(n.status,`Failed to authorize: ${n.statusText}`);let r=await n.json();if(typeof r.access_token=="string")return r.access_token;if(r.error!=="authorization_pending"&&r.error!=="slow_down")throw new Error(r.error_description||`Unexpected error: ${r.error}`)}async function Wq(t,e){let l=new URL("/user",aO(t)),n=await fetch(l.href,{headers:{Authorization:`Bearer ${e}`,Accept:"application/json"}});if(!n.ok)throw new kL(n.status,`Failed to fetch user info: ${n.statusText}`);return(await n.json()).login}async function E0(t,e,l){let n=`
|
|
2021
2021
|
{
|
|
2022
2022
|
viewer {
|
|
2023
|
+
login
|
|
2023
2024
|
copilotEndpoints {
|
|
2024
2025
|
api
|
|
2025
2026
|
}
|
|
2026
2027
|
}
|
|
2027
2028
|
}
|
|
2028
|
-
`,r=new URL("/graphql",aO(t)),a=await fetch(r.href,{method:"POST",headers:{Authorization:`Bearer ${e}`,Accept:"application/json"},body:JSON.stringify({query:n})});if(!a.ok)throw new Error(`Failed to fetch Copilot info: ${a.status} ${a.statusText}`);let I=await a.json(),{viewer:s}=I.data;return l.debug(`Fetched Copilot URL: ${a.status} ${s.copilotEndpoints.api}`),s.copilotEndpoints.api}var XCn=zl({data:zl({viewer:zl({isEmployee:ro()})})});async function czt(t,e){let l=`
|
|
2029
|
+
`,r=new URL("/graphql",aO(t)),a=await fetch(r.href,{method:"POST",headers:{Authorization:`Bearer ${e}`,Accept:"application/json"},body:JSON.stringify({query:n})});if(!a.ok)throw new Error(`Failed to fetch Copilot info: ${a.status} ${a.statusText}`);let I=await a.json(),{viewer:s}=I.data;return l.debug(`Fetched Copilot URL for ${s.login} from ${r}: ${a.status} ${s.copilotEndpoints.api}`),s.copilotEndpoints.api}var XCn=zl({data:zl({viewer:zl({isEmployee:ro()})})});async function czt(t,e){let l=`
|
|
2029
2030
|
{
|
|
2030
2031
|
viewer {
|
|
2031
2032
|
isEmployee
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@github/copilot",
|
|
3
3
|
"description": "GitHub Copilot CLI brings the power of Copilot coding agent directly to your terminal.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.354-0",
|
|
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": "d0c91e7"
|
|
41
41
|
}
|
|
42
42
|
}
|