@vscode/copilot-api 0.2.5 → 0.2.7

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/README.md CHANGED
@@ -38,6 +38,7 @@ const response = await client.makeRequest(fetchOptions, RequestType.ChatCompleti
38
38
  - `RequestType.RemoteAgent` - Remote agent requests
39
39
  - `RequestType.Embeddings` - Embeddings
40
40
  - `RequestType.Models` - Available models
41
+ - `RequestType.CCAModelsList` - Get available models for Copilot coding agent
41
42
  - `RequestType.Chunks` - Code chunks
42
43
  - `RequestType.EmbeddingsCodeSearch` - Embeddings code search
43
44
  - `RequestType.ListSkills` - List available skills
@@ -32,6 +32,7 @@ export interface IDomainService {
32
32
  readonly chatAttachmentUploadURL: string;
33
33
  readonly copilotAgentSessionsURL: string;
34
34
  readonly copilotAgentJobsURL: string;
35
+ readonly CCAModelsURL: string;
35
36
  readonly copilotCustomAgentsURL: string;
36
37
  updateDomains(copilotToken: CopilotToken | undefined, enterpriseUrlConfig: string | undefined): IDomainChangeResponse;
37
38
  }
@@ -83,5 +84,6 @@ export declare class DomainService implements IDomainService {
83
84
  get chatAttachmentUploadURL(): string;
84
85
  get copilotAgentSessionsURL(): string;
85
86
  get copilotAgentJobsURL(): string;
87
+ get CCAModelsURL(): string;
86
88
  get copilotCustomAgentsURL(): string;
87
89
  }
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var d=class{async fetch(i,e){let o={method:e.method||"GET",headers:e.headers,signal:e.signal};e.json?(o.body=JSON.stringify(e.json),o.headers={"Content-Type":"application/json",...o.headers}):e.body&&(o.body=e.body);let n,r;e.timeout&&!e.signal&&(r=new AbortController,o.signal=r.signal,n=setTimeout(()=>{r.abort()},e.timeout));try{let s=await fetch(i,o);return n&&clearTimeout(n),s}catch(s){throw n&&clearTimeout(n),s}}async fetchWithPagination(i,e){let o=[],n=e.pageSize??20,r=e.startPage??1,s=!1;do{let p=e.buildUrl(i,n,r),a=await this.fetch(p,e);if(!a.ok)return o;let S=await a.json(),m=e.getItemsFromResponse(S);o.push(...m),s=m.length===n,r++}while(s);return o}};var h=class h{constructor(){this._telemetryBaseUrl="https://copilot-telemetry.githubusercontent.com";this._originTrackerUrl="https://origin-tracker.githubusercontent.com";this._dotcomAPIUrl=this._getDotComAPIUrl(),this._proxyBaseUrl=this._getProxyUrl(void 0),this._capiBaseUrl=this._getCAPIUrl(void 0)}updateDomains(i,e){let o=this._dotcomAPIUrl,n=this._capiBaseUrl,r=this._telemetryBaseUrl,s=this._proxyBaseUrl;return this._enterpriseUrlConfig!==e&&(this._enterpriseUrlConfig=e,this._dotcomAPIUrl=this._getDotComAPIUrl()),i?(this._proxyBaseUrl=this._getProxyUrl(i),this._capiBaseUrl=this._getCAPIUrl(i),this._telemetryBaseUrl=i.endpoints.telemetry||"https://copilot-telemetry.githubusercontent.com",i.endpoints["origin-tracker"]&&(this._originTrackerUrl=i.endpoints["origin-tracker"])):(this._capiBaseUrl="https://api.githubcopilot.com",this._telemetryBaseUrl="https://copilot-telemetry.githubusercontent.com"),{dotcomUrlChanged:o!==this._dotcomAPIUrl,capiUrlChanged:n!==this._capiBaseUrl,telemetryUrlChanged:r!==this._telemetryBaseUrl,proxyUrlChanged:s!==this._proxyBaseUrl}}_getDotComAPIUrl(){if(this._enterpriseUrlConfig)try{let i=new URL(this._enterpriseUrlConfig);return`${i.protocol}//api.${i.hostname}${i.port?":"+i.port:""}`}catch(i){return console.warn("Failed to parse enterprise URL config:",this._enterpriseUrlConfig,i),"https://api.github.com"}return"https://api.github.com"}_getCAPIUrl(i){return i&&i.endpoints.api||"https://api.githubcopilot.com"}_getProxyUrl(i){return i&&i.endpoints.proxy||h.DEFAULT_PROXY_BASE_URL}get proxyBaseURL(){return this._proxyBaseUrl}get capiBaseURL(){return this._capiBaseUrl}get capiChatURL(){return`${this._capiBaseUrl}/chat/completions`}get capiResponsesURL(){return`${this._capiBaseUrl}/responses`}get capiMessagesURL(){return`${this._capiBaseUrl}/v1/messages`}get capiEmbeddingsURL(){return`${this._capiBaseUrl}/embeddings`}get capiModelsURL(){return`${this._capiBaseUrl}/models`}get capiAutoModelURL(){return`${this.capiModelsURL}/session`}get embeddingsModelURL(){return`${this.embeddingsURL}/models`}get chunksURL(){return`${this.dotComAPIURL}/chunks`}get embeddingsURL(){return`${this.dotComAPIURL}/embeddings`}get embeddingsCodeSearchURL(){return`${this.dotComAPIURL}/embeddings/code/search`}get telemetryURL(){return`${this._telemetryBaseUrl}/telemetry`}get remoteAgentsURL(){return`${this._capiBaseUrl}/agents`}get listSkillsURL(){return`${this._capiBaseUrl}/skills`}get searchSkillURL(){return`${this._capiBaseUrl}/search`}get contentExclusionURL(){return`${this._dotcomAPIUrl}/copilot_internal/content_exclusion`}get copilotUserInfoURL(){return`${this._dotcomAPIUrl}/copilot_internal/user`}get tokenURL(){return this._dotcomAPIUrl+"/copilot_internal/v2/token"}get tokenNoAuthURL(){return`${this._dotcomAPIUrl}/copilot_internal/v2/nltoken`}get dotComAPIURL(){return this._dotcomAPIUrl}get originTrackerURL(){return this._originTrackerUrl}get chatAttachmentUploadURL(){return"https://uploads.github.com/copilot/chat/attachments"}get copilotAgentSessionsURL(){return`${this._capiBaseUrl}/agents/sessions`}get copilotAgentJobsURL(){return`${this._capiBaseUrl}/agents/swe`}get copilotCustomAgentsURL(){return`${this._capiBaseUrl}/agents/swe/custom-agents`}};h.DEFAULT_PROXY_BASE_URL="https://copilot-proxy.githubusercontent.com",h.CAPI_MODEL_LAB_URL="https://api-model-lab.githubcopilot.com";var c=h;var C=`The \u201C@vscode/copilot-api\u201D npm Module Terms and Conditions ("Terms") are a legal agreement between you (either as an individual or on behalf of an entity) and GitHub, Inc. regarding your use of \u201C@vscode/copilot-api\u201D npm library and associated documentation (collectively, the "Software"). By using the Software, you accept these Terms. Please read all of these Terms; in many cases, provisions set forth later in the Terms limit and qualify provisions set forth earlier in the Terms. If you do not accept these Terms, do not download, install, use, or copy the Software.
1
+ var d=class{async fetch(i,e){let o={method:e.method||"GET",headers:e.headers,signal:e.signal};e.json?(o.body=JSON.stringify(e.json),o.headers={"Content-Type":"application/json",...o.headers}):e.body&&(o.body=e.body);let s,r;e.timeout&&!e.signal&&(r=new AbortController,o.signal=r.signal,s=setTimeout(()=>{r.abort()},e.timeout));try{let n=await fetch(i,o);return s&&clearTimeout(s),n}catch(n){throw s&&clearTimeout(s),n}}async fetchWithPagination(i,e){let o=[],s=e.pageSize??20,r=e.startPage??1,n=!1;do{let p=e.buildUrl(i,s,r),a=await this.fetch(p,e);if(!a.ok)return o;let C=await a.json(),m=e.getItemsFromResponse(C);o.push(...m),n=m.length===s,r++}while(n);return o}};var h=class h{constructor(){this._telemetryBaseUrl="https://copilot-telemetry.githubusercontent.com";this._originTrackerUrl="https://origin-tracker.githubusercontent.com";this._dotcomAPIUrl=this._getDotComAPIUrl(),this._proxyBaseUrl=this._getProxyUrl(void 0),this._capiBaseUrl=this._getCAPIUrl(void 0)}updateDomains(i,e){let o=this._dotcomAPIUrl,s=this._capiBaseUrl,r=this._telemetryBaseUrl,n=this._proxyBaseUrl;return this._enterpriseUrlConfig!==e&&(this._enterpriseUrlConfig=e,this._dotcomAPIUrl=this._getDotComAPIUrl()),i?(this._proxyBaseUrl=this._getProxyUrl(i),this._capiBaseUrl=this._getCAPIUrl(i),this._telemetryBaseUrl=i.endpoints.telemetry||"https://copilot-telemetry.githubusercontent.com",i.endpoints["origin-tracker"]&&(this._originTrackerUrl=i.endpoints["origin-tracker"])):(this._capiBaseUrl="https://api.githubcopilot.com",this._telemetryBaseUrl="https://copilot-telemetry.githubusercontent.com"),{dotcomUrlChanged:o!==this._dotcomAPIUrl,capiUrlChanged:s!==this._capiBaseUrl,telemetryUrlChanged:r!==this._telemetryBaseUrl,proxyUrlChanged:n!==this._proxyBaseUrl}}_getDotComAPIUrl(){if(this._enterpriseUrlConfig)try{let i=new URL(this._enterpriseUrlConfig);return`${i.protocol}//api.${i.hostname}${i.port?":"+i.port:""}`}catch(i){return console.warn("Failed to parse enterprise URL config:",this._enterpriseUrlConfig,i),"https://api.github.com"}return"https://api.github.com"}_getCAPIUrl(i){return i&&i.endpoints.api||"https://api.githubcopilot.com"}_getProxyUrl(i){return i&&i.endpoints.proxy||h.DEFAULT_PROXY_BASE_URL}get proxyBaseURL(){return this._proxyBaseUrl}get capiBaseURL(){return this._capiBaseUrl}get capiChatURL(){return`${this._capiBaseUrl}/chat/completions`}get capiResponsesURL(){return`${this._capiBaseUrl}/responses`}get capiMessagesURL(){return`${this._capiBaseUrl}/v1/messages`}get capiEmbeddingsURL(){return`${this._capiBaseUrl}/embeddings`}get capiModelsURL(){return`${this._capiBaseUrl}/models`}get capiAutoModelURL(){return`${this.capiModelsURL}/session`}get embeddingsModelURL(){return`${this.embeddingsURL}/models`}get chunksURL(){return`${this.dotComAPIURL}/chunks`}get embeddingsURL(){return`${this.dotComAPIURL}/embeddings`}get embeddingsCodeSearchURL(){return`${this.dotComAPIURL}/embeddings/code/search`}get telemetryURL(){return`${this._telemetryBaseUrl}/telemetry`}get remoteAgentsURL(){return`${this._capiBaseUrl}/agents`}get listSkillsURL(){return`${this._capiBaseUrl}/skills`}get searchSkillURL(){return`${this._capiBaseUrl}/search`}get contentExclusionURL(){return`${this._dotcomAPIUrl}/copilot_internal/content_exclusion`}get copilotUserInfoURL(){return`${this._dotcomAPIUrl}/copilot_internal/user`}get tokenURL(){return this._dotcomAPIUrl+"/copilot_internal/v2/token"}get tokenNoAuthURL(){return`${this._dotcomAPIUrl}/copilot_internal/v2/nltoken`}get dotComAPIURL(){return this._dotcomAPIUrl}get originTrackerURL(){return this._originTrackerUrl}get chatAttachmentUploadURL(){return"https://uploads.github.com/copilot/chat/attachments"}get copilotAgentSessionsURL(){return`${this._capiBaseUrl}/agents/sessions`}get copilotAgentJobsURL(){return`${this._capiBaseUrl}/agents/swe`}get CCAModelsURL(){return`${this._capiBaseUrl}/agents/swe/models`}get copilotCustomAgentsURL(){return`${this._capiBaseUrl}/agents/swe/custom-agents`}};h.DEFAULT_PROXY_BASE_URL="https://copilot-proxy.githubusercontent.com",h.CAPI_MODEL_LAB_URL="https://api-model-lab.githubcopilot.com";var c=h;var S=`The \u201C@vscode/copilot-api\u201D npm Module Terms and Conditions ("Terms") are a legal agreement between you (either as an individual or on behalf of an entity) and GitHub, Inc. regarding your use of \u201C@vscode/copilot-api\u201D npm library and associated documentation (collectively, the "Software"). By using the Software, you accept these Terms. Please read all of these Terms; in many cases, provisions set forth later in the Terms limit and qualify provisions set forth earlier in the Terms. If you do not accept these Terms, do not download, install, use, or copy the Software.
2
2
 
3
3
  IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS BELOW.
4
4
 
@@ -42,6 +42,6 @@ This limitation applies to (a) anything related to the software, services, conte
42
42
 
43
43
  It also applies even if GitHub knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your country may not allow the exclusion or limitation of incidental, consequential or other damages.`,u=`I have read and agree to the following license terms:
44
44
 
45
- ${C}
46
- `;var U=(t=>(t.CopilotToken="CopilotToken",t.CopilotNLToken="CopilotNLToken",t.ChatCompletions="ChatCompletions",t.ChatResponses="ChatResponses",t.ChatMessages="ChatMessages",t.ProxyCompletions="ProxyCompletions",t.ProxyChatCompletions="ProxyChatCompletions",t.RemoteAgent="RemoteAgent",t.RemoteAgentChat="RemoteAgentChat",t.CodeReviewAgent="CodeReviewAgent",t.CAPIEmbeddings="CAPIEmbeddings",t.DotcomEmbeddings="DotcomEmbeddings",t.EmbeddingsModels="EmbeddingsModels",t.Models="Models",t.AutoModels="AutoModels",t.Chunks="Chunks",t.EmbeddingsCodeSearch="EmbeddingsCodeSearch",t.ListSkills="ListSkills",t.SearchSkill="SearchSkill",t.ContentExclusion="ContentExclusion",t.Telemetry="Telemetry",t.CopilotUserInfo="CopilotUserInfo",t.ModelPolicy="ModelPolicy",t.ListModel="ListModel",t.SnippyMatch="SnippyMatch",t.SnippyFilesForMatch="SnippyFlesForMatch",t.CodingGuidelines="CodingGuidelines",t.EmbeddingsIndex="EmbedingsIndex",t.ChatAttachmentUpload="ChatAttachmentUpload",t.CopilotSessionLogs="CopilotSessionLogs",t.CopilotSessionDetails="CopilotSessionDetails",t.CopilotSessions="CopilotSessions",t.CopilotAgentJob="CopilotAgentJob",t.CopilotCustomAgents="CopilotCustomAgents",t.CopilotCustomAgentsDetail="CopilotCustomAgentsDetail",t))(U||{});async function f(l){if(!l)return;let i=await crypto.subtle.importKey("raw",new TextEncoder().encode(l),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),e=Math.floor(Date.now()/1e3).toString(),n=new TextEncoder().encode(e),r=await crypto.subtle.sign("HMAC",i,n),p=Array.from(new Uint8Array(r)).map(a=>a.toString(16).padStart(2,"0")).join("");return`${e}.${p}`}function y(l){return new Set(["ChatCompletions","ChatResponses","ChatMessages","CAPIEmbeddings","Models","RemoteAgent","CodeReviewAgent","RemoteAgentChat","ListSkills","SearchSkill","ModelPolicy","ListModel","AutoModels","CopilotSessionLogs","CopilotSessionDetails","CopilotSessions","CopilotAgentJob","CopilotCustomAgents"]).has(l)}var g=class{constructor(i,e,o,n,r){this._extensionInfo=i;this._integrationId=r;this._licenseCheckSucceeded=!1;if(e&&e===u&&(this._licenseCheckSucceeded=!0),this._domainService=new c,this._fetcherService=o??new d,this._hmacSecret=n,this._integrationId==="vscode-chat"||this._integrationId==="code-oss")throw new Error(`Integration ID ${this._integrationId} is reserved and cannot be used.`)}updateDomains(i,e){return i&&i.sku&&(this._copilotSku=i.sku),this._domainService.updateDomains(i,e)}async makeRequest(i,e){let{type:o}=e;switch(await this._mixinHeaders(i,e),o){case"CopilotToken":return this._fetcherService.fetch(this._domainService.tokenURL,i);case"CopilotNLToken":return this._fetcherService.fetch(this._domainService.tokenNoAuthURL,i);case"ProxyCompletions":return this._fetcherService.fetch(`${this._domainService.proxyBaseURL}/v1/engines/gpt-4o-copilot/completions`,i);case"ProxyChatCompletions":return this._fetcherService.fetch(`${this._domainService.proxyBaseURL}/chat/completions`,i);case"RemoteAgent":return this._fetcherService.fetch(this._domainService.remoteAgentsURL,i);case"CodeReviewAgent":return this._fetcherService.fetch(`${this._domainService.remoteAgentsURL}/github-code-review`,i);case"CAPIEmbeddings":return this._fetcherService.fetch(this._domainService.capiEmbeddingsURL,i);case"DotcomEmbeddings":return this._fetcherService.fetch(this._domainService.embeddingsURL,i);case"EmbeddingsModels":return this._fetcherService.fetch(this._domainService.embeddingsModelURL,i);case"Chunks":return this._fetcherService.fetch(this._domainService.chunksURL,i);case"EmbeddingsCodeSearch":return this._fetcherService.fetch(this._domainService.embeddingsCodeSearchURL,i);case"ListSkills":return this._fetcherService.fetch(this._domainService.listSkillsURL,i);case"Telemetry":return this._fetcherService.fetch(this._domainService.telemetryURL,i);case"CopilotUserInfo":return this._fetcherService.fetch(this._domainService.copilotUserInfoURL,i);case"SnippyMatch":return this._fetcherService.fetch(`${this._domainService.originTrackerURL}/twirp/github.snippy.v1.SnippyAPI/Match`,i);case"SnippyFlesForMatch":return this._fetcherService.fetch(`${this._domainService.originTrackerURL}/twirp/github.snippy.v1.SnippyAPI/FilesForMatch`,i);case"EmbedingsIndex":if(!("repoWithOwner"in e))throw new Error("repoWithOwner is required for EmbeddingsIndex request");return this._fetcherService.fetch(`${this._domainService.dotComAPIURL}/repos/${e.repoWithOwner}/copilot_internal/embeddings_index`,i);case"CodingGuidelines":if(!("repoWithOwner"in e))throw new Error("repoWithOwner is required for CodingGuidelines request");return this._fetcherService.fetch(`${this._domainService.dotComAPIURL}/repos/${e.repoWithOwner}/copilot_internal/coding_guidelines`,i);case"EmbeddingsModels":return this._fetcherService.fetch(this._domainService.embeddingsModelURL,i);case"AutoModels":return this._fetcherService.fetch(this._domainService.capiAutoModelURL,i);case"Models":return"isModelLab"in e&&e.isModelLab?this._fetcherService.fetch(`${c.CAPI_MODEL_LAB_URL}/models`,i):this._fetcherService.fetch(this._domainService.capiModelsURL,i);case"ChatCompletions":return"isModelLab"in e&&e.isModelLab?this._fetcherService.fetch(`${c.CAPI_MODEL_LAB_URL}/chat/completions`,i):this._fetcherService.fetch(this._domainService.capiChatURL,i);case"ChatResponses":return"isModelLab"in e&&e.isModelLab?this._fetcherService.fetch(`${c.CAPI_MODEL_LAB_URL}/responses`,i):this._fetcherService.fetch(this._domainService.capiResponsesURL,i);case"ChatMessages":return"isModelLab"in e&&e.isModelLab?this._fetcherService.fetch(`${c.CAPI_MODEL_LAB_URL}/v1/messages`,i):this._fetcherService.fetch(this._domainService.capiMessagesURL,i);case"ContentExclusion":if(!("repos"in e))throw new Error("Repos are required for ContentExclusion request");return this._fetcherService.fetch(this._prepareContentExclusionUrl(e.repos),i);case"RemoteAgentChat":return"slug"in e&&e.slug?this._fetcherService.fetch(`${this._domainService.remoteAgentsURL}/${e.slug}?chat`,i):this._fetcherService.fetch(`${this._domainService.remoteAgentsURL}/chat`,i);case"SearchSkill":if(!("slug"in e))throw new Error("Skill slug is required for SearchSkill request");return this._fetcherService.fetch(`${this._domainService.searchSkillURL}/${e.slug}`,i);case"ModelPolicy":if(!("modelId"in e))throw new Error("Model ID is required for ModelPolicy request");return this._fetcherService.fetch(`${this._domainService.capiModelsURL}/${e.modelId}/policy`,i);case"ListModel":if(!("modelId"in e))throw new Error("Model ID is required for ListModel request");return this._fetcherService.fetch(`${this._domainService.capiModelsURL}/${e.modelId}`,i);case"ChatAttachmentUpload":if(!("uploadName"in e)||!("mimeType"in e))throw new Error("uploadName and mimeType are required for ChatAttachmentUpload request");return this._fetcherService.fetch(`${this._domainService.chatAttachmentUploadURL}?name=${e.uploadName}&content_type=${e.mimeType}`,i);case"CopilotSessionLogs":if(!("sessionId"in e))throw new Error("sessionId is required for CopilotSessionLogs request");return this._fetcherService.fetch(`${this._domainService.copilotAgentSessionsURL}/${e.sessionId}/logs`,i);case"CopilotSessionDetails":if(!("sessionId"in e))throw new Error("sessionId is required for CopilotSessionDetails request");return this._fetcherService.fetch(`${this._domainService.copilotAgentSessionsURL}/${e.sessionId}`,i);case"CopilotSessions":let n={...i,getItemsFromResponse:r=>{let s=r;return s&&Array.isArray(s.sessions)?s.sessions:[]},buildUrl:(r,s,p)=>{let a=new URL(r);return a.searchParams.set("page_size",s.toString()),a.searchParams.set("page_number",p.toString()),"resourceState"in e&&e.resourceState&&a.searchParams.set("resource_state",e.resourceState),"nwo"in e&&e.nwo&&a.searchParams.set("repo_nwo",e.nwo),a.toString()}};return"prId"in e&&e.prId?this._fetcherService.fetch(`${this._domainService.copilotAgentSessionsURL}/resource/pull/${e.prId}`,i):this._fetcherService.fetchWithPagination(this._domainService.copilotAgentSessionsURL,n);case"CopilotAgentJob":if(!("owner"in e)||!("repo"in e))throw new Error("owner and repo are required for CopilotAgentJob request");if("jobId"in e&&e.jobId){let r="apiVersion"in e&&e.apiVersion||"v1";return this._fetcherService.fetch(`${this._domainService.copilotAgentJobsURL}/${r}/jobs/${e.owner}/${e.repo}/${e.jobId}`,i)}if("sessionId"in e&&e.sessionId){let r="apiVersion"in e&&e.apiVersion||"v1";return this._fetcherService.fetch(`${this._domainService.copilotAgentJobsURL}/${r}/jobs/${e.owner}/${e.repo}/session/${e.sessionId}`,i)}if("payload"in e&&e.payload){let r="apiVersion"in e&&e.apiVersion||"v1";return this._fetcherService.fetch(`${this._domainService.copilotAgentJobsURL}/${r}/jobs/${e.owner}/${e.repo}`,i)}throw new Error("jobId or sessionId is required for CopilotAgentJob request");case"CopilotCustomAgents":{if(!("owner"in e)||!("repo"in e))throw new Error("owner and repo are required for CopilotCustomAgents request");let r=new URL(`${this._domainService.copilotCustomAgentsURL}/${e.owner}/${e.repo}`);return"target"in e&&e.target&&r.searchParams.set("target",e.target),"exclude_invalid_config"in e&&e.exclude_invalid_config!==void 0&&r.searchParams.set("exclude_invalid_config",e.exclude_invalid_config.toString()),"dedupe"in e&&e.dedupe!==void 0&&r.searchParams.set("dedupe",e.dedupe.toString()),"include_sources"in e&&e.include_sources&&r.searchParams.set("include_sources",e.include_sources.join(",")),this._fetcherService.fetch(r.toString(),i)}case"CopilotCustomAgentsDetail":{if(!("owner"in e)||!("repo"in e)||!("customAgentName"in e))throw new Error("owner, repo and customAgentName are required for CopilotCustomAgents request");let r=new URL(`${this._domainService.copilotCustomAgentsURL}/${e.owner}/${e.repo}/${e.customAgentName}`);return"version"in e&&e.version&&r.searchParams.set("version",e.version),this._fetcherService.fetch(r.toString(),i)}default:throw new Error(`Unsupported request type: ${o}`)}}_prepareContentExclusionUrl(i){let e=i.join(","),o=new URL(this._domainService.contentExclusionURL);return i.length!==0&&o.searchParams.set("repos",e),o.searchParams.set("scope","repo"),o.toString()}async _mixinHeaders(i,e){if(!y(e.type))return;let o=i.headers||{};o["X-GitHub-Api-Version"]="2025-10-01",o["VScode-SessionId"]=this._extensionInfo.sessionId,o["VScode-MachineId"]=this._extensionInfo.machineId,o["Editor-Plugin-Version"]=`copilot-chat/${this._extensionInfo.version}`,o["Editor-Version"]=`vscode/${this._extensionInfo.vscodeVersion}`;let n="";i.suppressIntegrationId||(n="code-oss",this._integrationId&&this._hmacSecret?n=this._integrationId:this._copilotSku==="no_auth_limited_copilot"?n="vscode-nl":this._licenseCheckSucceeded&&this._extensionInfo.buildType==="prod"?n="vscode-chat":this._extensionInfo.buildType==="dev"&&this._hmacSecret&&(n="vscode-chat-dev"),o["Copilot-Integration-Id"]=n),n==="vscode-chat-dev"&&(o["Request-Hmac"]=await f(this._hmacSecret)),i.headers=o}get copilotTelemetryURL(){return this._domainService.telemetryURL}get dotcomAPIURL(){return this._domainService.dotComAPIURL}get capiPingURL(){return`${this._domainService.capiBaseURL}/_ping`}get proxyBaseURL(){return this._domainService.proxyBaseURL}get originTrackerURL(){return this._domainService.originTrackerURL}get snippyMatchPath(){return"twirp/github.snippy.v1.SnippyAPI/Match"}get snippyFilesForMatchPath(){return"twirp/github.snippy.v1.SnippyAPI/FilesForMatch"}};export{g as CAPIClient,U as RequestType};
45
+ ${S}
46
+ `;var _=(t=>(t.CopilotToken="CopilotToken",t.CopilotNLToken="CopilotNLToken",t.ChatCompletions="ChatCompletions",t.ChatResponses="ChatResponses",t.ChatMessages="ChatMessages",t.ProxyCompletions="ProxyCompletions",t.ProxyChatCompletions="ProxyChatCompletions",t.RemoteAgent="RemoteAgent",t.RemoteAgentChat="RemoteAgentChat",t.CodeReviewAgent="CodeReviewAgent",t.CAPIEmbeddings="CAPIEmbeddings",t.DotcomEmbeddings="DotcomEmbeddings",t.EmbeddingsModels="EmbeddingsModels",t.Models="Models",t.AutoModels="AutoModels",t.Chunks="Chunks",t.EmbeddingsCodeSearch="EmbeddingsCodeSearch",t.ListSkills="ListSkills",t.SearchSkill="SearchSkill",t.ContentExclusion="ContentExclusion",t.Telemetry="Telemetry",t.CopilotUserInfo="CopilotUserInfo",t.ModelPolicy="ModelPolicy",t.ListModel="ListModel",t.SnippyMatch="SnippyMatch",t.SnippyFilesForMatch="SnippyFlesForMatch",t.CodingGuidelines="CodingGuidelines",t.EmbeddingsIndex="EmbedingsIndex",t.ChatAttachmentUpload="ChatAttachmentUpload",t.CopilotSessionLogs="CopilotSessionLogs",t.CopilotSessionDetails="CopilotSessionDetails",t.CopilotSessions="CopilotSessions",t.CopilotAgentJob="CopilotAgentJob",t.CCAModelsList="CCAModelsList",t.CopilotCustomAgents="CopilotCustomAgents",t.CopilotCustomAgentsDetail="CopilotCustomAgentsDetail",t.OrgCustomInstructions="OrgCustomInstructions",t))(_||{});async function f(l){if(!l)return;let i=await crypto.subtle.importKey("raw",new TextEncoder().encode(l),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),e=Math.floor(Date.now()/1e3).toString(),s=new TextEncoder().encode(e),r=await crypto.subtle.sign("HMAC",i,s),p=Array.from(new Uint8Array(r)).map(a=>a.toString(16).padStart(2,"0")).join("");return`${e}.${p}`}function y(l){return new Set(["ChatCompletions","ChatResponses","ChatMessages","CAPIEmbeddings","Models","RemoteAgent","CodeReviewAgent","RemoteAgentChat","ListSkills","SearchSkill","ModelPolicy","ListModel","AutoModels","CopilotSessionLogs","CopilotSessionDetails","CopilotSessions","CopilotAgentJob","CCAModelsList","CopilotCustomAgents"]).has(l)}var g=class{constructor(i,e,o,s,r){this._extensionInfo=i;this._integrationId=r;this._licenseCheckSucceeded=!1;if(e&&e===u&&(this._licenseCheckSucceeded=!0),this._domainService=new c,this._fetcherService=o??new d,this._hmacSecret=s,this._integrationId==="vscode-chat"||this._integrationId==="code-oss")throw new Error(`Integration ID ${this._integrationId} is reserved and cannot be used.`)}updateDomains(i,e){return i&&i.sku&&(this._copilotSku=i.sku),this._domainService.updateDomains(i,e)}async makeRequest(i,e){let{type:o}=e;switch(await this._mixinHeaders(i,e),o){case"CopilotToken":return this._fetcherService.fetch(this._domainService.tokenURL,i);case"CopilotNLToken":return this._fetcherService.fetch(this._domainService.tokenNoAuthURL,i);case"ProxyCompletions":return this._fetcherService.fetch(`${this._domainService.proxyBaseURL}/v1/engines/gpt-4o-copilot/completions`,i);case"ProxyChatCompletions":return this._fetcherService.fetch(`${this._domainService.proxyBaseURL}/chat/completions`,i);case"RemoteAgent":return this._fetcherService.fetch(this._domainService.remoteAgentsURL,i);case"CodeReviewAgent":return this._fetcherService.fetch(`${this._domainService.remoteAgentsURL}/github-code-review`,i);case"CAPIEmbeddings":return this._fetcherService.fetch(this._domainService.capiEmbeddingsURL,i);case"DotcomEmbeddings":return this._fetcherService.fetch(this._domainService.embeddingsURL,i);case"EmbeddingsModels":return this._fetcherService.fetch(this._domainService.embeddingsModelURL,i);case"Chunks":return this._fetcherService.fetch(this._domainService.chunksURL,i);case"EmbeddingsCodeSearch":return this._fetcherService.fetch(this._domainService.embeddingsCodeSearchURL,i);case"ListSkills":return this._fetcherService.fetch(this._domainService.listSkillsURL,i);case"Telemetry":return this._fetcherService.fetch(this._domainService.telemetryURL,i);case"CopilotUserInfo":return this._fetcherService.fetch(this._domainService.copilotUserInfoURL,i);case"SnippyMatch":return this._fetcherService.fetch(`${this._domainService.originTrackerURL}/twirp/github.snippy.v1.SnippyAPI/Match`,i);case"SnippyFlesForMatch":return this._fetcherService.fetch(`${this._domainService.originTrackerURL}/twirp/github.snippy.v1.SnippyAPI/FilesForMatch`,i);case"EmbedingsIndex":if(!("repoWithOwner"in e))throw new Error("repoWithOwner is required for EmbeddingsIndex request");return this._fetcherService.fetch(`${this._domainService.dotComAPIURL}/repos/${e.repoWithOwner}/copilot_internal/embeddings_index`,i);case"CodingGuidelines":if(!("repoWithOwner"in e))throw new Error("repoWithOwner is required for CodingGuidelines request");return this._fetcherService.fetch(`${this._domainService.dotComAPIURL}/repos/${e.repoWithOwner}/copilot_internal/coding_guidelines`,i);case"EmbeddingsModels":return this._fetcherService.fetch(this._domainService.embeddingsModelURL,i);case"AutoModels":return this._fetcherService.fetch(this._domainService.capiAutoModelURL,i);case"Models":return"isModelLab"in e&&e.isModelLab?this._fetcherService.fetch(`${c.CAPI_MODEL_LAB_URL}/models`,i):this._fetcherService.fetch(this._domainService.capiModelsURL,i);case"ChatCompletions":return"isModelLab"in e&&e.isModelLab?this._fetcherService.fetch(`${c.CAPI_MODEL_LAB_URL}/chat/completions`,i):this._fetcherService.fetch(this._domainService.capiChatURL,i);case"ChatResponses":return"isModelLab"in e&&e.isModelLab?this._fetcherService.fetch(`${c.CAPI_MODEL_LAB_URL}/responses`,i):this._fetcherService.fetch(this._domainService.capiResponsesURL,i);case"ChatMessages":return"isModelLab"in e&&e.isModelLab?this._fetcherService.fetch(`${c.CAPI_MODEL_LAB_URL}/v1/messages`,i):this._fetcherService.fetch(this._domainService.capiMessagesURL,i);case"ContentExclusion":if(!("repos"in e))throw new Error("Repos are required for ContentExclusion request");return this._fetcherService.fetch(this._prepareContentExclusionUrl(e.repos),i);case"RemoteAgentChat":return"slug"in e&&e.slug?this._fetcherService.fetch(`${this._domainService.remoteAgentsURL}/${e.slug}?chat`,i):this._fetcherService.fetch(`${this._domainService.remoteAgentsURL}/chat`,i);case"SearchSkill":if(!("slug"in e))throw new Error("Skill slug is required for SearchSkill request");return this._fetcherService.fetch(`${this._domainService.searchSkillURL}/${e.slug}`,i);case"ModelPolicy":if(!("modelId"in e))throw new Error("Model ID is required for ModelPolicy request");return this._fetcherService.fetch(`${this._domainService.capiModelsURL}/${e.modelId}/policy`,i);case"ListModel":if(!("modelId"in e))throw new Error("Model ID is required for ListModel request");return this._fetcherService.fetch(`${this._domainService.capiModelsURL}/${e.modelId}`,i);case"ChatAttachmentUpload":if(!("uploadName"in e)||!("mimeType"in e))throw new Error("uploadName and mimeType are required for ChatAttachmentUpload request");return this._fetcherService.fetch(`${this._domainService.chatAttachmentUploadURL}?name=${e.uploadName}&content_type=${e.mimeType}`,i);case"CopilotSessionLogs":if(!("sessionId"in e))throw new Error("sessionId is required for CopilotSessionLogs request");return this._fetcherService.fetch(`${this._domainService.copilotAgentSessionsURL}/${e.sessionId}/logs`,i);case"CopilotSessionDetails":if(!("sessionId"in e))throw new Error("sessionId is required for CopilotSessionDetails request");return this._fetcherService.fetch(`${this._domainService.copilotAgentSessionsURL}/${e.sessionId}`,i);case"CopilotSessions":let s={...i,getItemsFromResponse:r=>{let n=r;return n&&Array.isArray(n.sessions)?n.sessions:[]},buildUrl:(r,n,p)=>{let a=new URL(r);return a.searchParams.set("page_size",n.toString()),a.searchParams.set("page_number",p.toString()),"resourceState"in e&&e.resourceState&&a.searchParams.set("resource_state",e.resourceState),"nwo"in e&&e.nwo&&a.searchParams.set("repo_nwo",e.nwo),a.toString()}};return"prId"in e&&e.prId?this._fetcherService.fetch(`${this._domainService.copilotAgentSessionsURL}/resource/pull/${e.prId}`,i):this._fetcherService.fetchWithPagination(this._domainService.copilotAgentSessionsURL,s);case"CopilotAgentJob":if(!("owner"in e)||!("repo"in e))throw new Error("owner and repo are required for CopilotAgentJob request");if("jobId"in e&&e.jobId){let r="apiVersion"in e&&e.apiVersion||"v1";return this._fetcherService.fetch(`${this._domainService.copilotAgentJobsURL}/${r}/jobs/${e.owner}/${e.repo}/${e.jobId}`,i)}if("sessionId"in e&&e.sessionId){let r="apiVersion"in e&&e.apiVersion||"v1";return this._fetcherService.fetch(`${this._domainService.copilotAgentJobsURL}/${r}/jobs/${e.owner}/${e.repo}/session/${e.sessionId}`,i)}if("payload"in e&&e.payload){let r="apiVersion"in e&&e.apiVersion||"v1";return this._fetcherService.fetch(`${this._domainService.copilotAgentJobsURL}/${r}/jobs/${e.owner}/${e.repo}`,i)}throw new Error("jobId or sessionId is required for CopilotAgentJob request");case"CCAModelsList":return this._fetcherService.fetch(this._domainService.CCAModelsURL,i);case"CopilotCustomAgents":{if(!("owner"in e)||!("repo"in e))throw new Error("owner and repo are required for CopilotCustomAgents request");let r=new URL(`${this._domainService.copilotCustomAgentsURL}/${e.owner}/${e.repo}`);return"target"in e&&e.target&&r.searchParams.set("target",e.target),"exclude_invalid_config"in e&&e.exclude_invalid_config!==void 0&&r.searchParams.set("exclude_invalid_config",e.exclude_invalid_config.toString()),"dedupe"in e&&e.dedupe!==void 0&&r.searchParams.set("dedupe",e.dedupe.toString()),"include_sources"in e&&e.include_sources&&r.searchParams.set("include_sources",e.include_sources.join(",")),this._fetcherService.fetch(r.toString(),i)}case"CopilotCustomAgentsDetail":{if(!("owner"in e)||!("repo"in e)||!("customAgentName"in e))throw new Error("owner, repo and customAgentName are required for CopilotCustomAgents request");let r=new URL(`${this._domainService.copilotCustomAgentsURL}/${e.owner}/${e.repo}/${e.customAgentName}`);return"version"in e&&e.version&&r.searchParams.set("version",e.version),this._fetcherService.fetch(r.toString(),i)}case"OrgCustomInstructions":if(!("orgLogin"in e))throw new Error("orgLogin is required for OrgCustomInstructions request");return this._fetcherService.fetch(`${this._domainService.dotComAPIURL}/copilot_internal/org_custom_instructions/${e.orgLogin}`,i);default:throw new Error(`Unsupported request type: ${o}`)}}_prepareContentExclusionUrl(i){let e=i.join(","),o=new URL(this._domainService.contentExclusionURL);return i.length!==0&&o.searchParams.set("repos",e),o.searchParams.set("scope","repo"),o.toString()}async _mixinHeaders(i,e){if(!y(e.type))return;let o=i.headers||{};o["X-GitHub-Api-Version"]="2025-10-01",o["VScode-SessionId"]=this._extensionInfo.sessionId,o["VScode-MachineId"]=this._extensionInfo.machineId,o["Editor-Plugin-Version"]=`copilot-chat/${this._extensionInfo.version}`,o["Editor-Version"]=`vscode/${this._extensionInfo.vscodeVersion}`;let s="";i.suppressIntegrationId||(s="code-oss",this._integrationId&&this._hmacSecret?s=this._integrationId:this._copilotSku==="no_auth_limited_copilot"?s="vscode-nl":this._licenseCheckSucceeded&&this._extensionInfo.buildType==="prod"?s="vscode-chat":this._extensionInfo.buildType==="dev"&&this._hmacSecret&&(s="vscode-chat-dev"),o["Copilot-Integration-Id"]=s),s==="vscode-chat-dev"&&(o["Request-Hmac"]=await f(this._hmacSecret)),i.headers=o}get copilotTelemetryURL(){return this._domainService.telemetryURL}get dotcomAPIURL(){return this._domainService.dotComAPIURL}get capiPingURL(){return`${this._domainService.capiBaseURL}/_ping`}get proxyBaseURL(){return this._domainService.proxyBaseURL}get originTrackerURL(){return this._domainService.originTrackerURL}get snippyMatchPath(){return"twirp/github.snippy.v1.SnippyAPI/Match"}get snippyFilesForMatchPath(){return"twirp/github.snippy.v1.SnippyAPI/FilesForMatch"}};export{g as CAPIClient,_ as RequestType};
47
47
  //# sourceMappingURL=index.js.map
package/dist/types.d.ts CHANGED
@@ -53,6 +53,8 @@ export interface RemoteAgentJobPayload {
53
53
  };
54
54
  run_name?: string;
55
55
  custom_agent?: string;
56
+ agent_id?: string;
57
+ model?: string;
56
58
  }
57
59
  export declare enum RequestType {
58
60
  CopilotToken = "CopilotToken",
@@ -88,11 +90,13 @@ export declare enum RequestType {
88
90
  CopilotSessionDetails = "CopilotSessionDetails",
89
91
  CopilotSessions = "CopilotSessions",
90
92
  CopilotAgentJob = "CopilotAgentJob",
93
+ CCAModelsList = "CCAModelsList",
91
94
  CopilotCustomAgents = "CopilotCustomAgents",
92
- CopilotCustomAgentsDetail = "CopilotCustomAgentsDetail"
95
+ CopilotCustomAgentsDetail = "CopilotCustomAgentsDetail",
96
+ OrgCustomInstructions = "OrgCustomInstructions"
93
97
  }
94
98
  export type RequestMetadata = {
95
- type: Omit<RequestType, RequestType.ListModel | RequestType.ModelPolicy | RequestType.SearchSkill | RequestType.RemoteAgentChat | RequestType.ContentExclusion | RequestType.ChatCompletions | RequestType.Models | RequestType.CodingGuidelines | RequestType.EmbeddingsIndex | RequestType.ChatAttachmentUpload | RequestType.CopilotSessionLogs | RequestType.CopilotSessionDetails | RequestType.CopilotSessions | RequestType.CopilotAgentJob | RequestType.CopilotCustomAgents>;
99
+ type: Omit<RequestType, RequestType.ListModel | RequestType.ModelPolicy | RequestType.SearchSkill | RequestType.RemoteAgentChat | RequestType.ContentExclusion | RequestType.ChatCompletions | RequestType.Models | RequestType.CodingGuidelines | RequestType.EmbeddingsIndex | RequestType.ChatAttachmentUpload | RequestType.CopilotSessionLogs | RequestType.CopilotSessionDetails | RequestType.CopilotSessions | RequestType.CopilotAgentJob | RequestType.CCAModelsList | RequestType.CopilotCustomAgents | RequestType.CopilotCustomAgentsDetail | RequestType.OrgCustomInstructions>;
96
100
  } | {
97
101
  type: RequestType.CodingGuidelines | RequestType.EmbeddingsIndex;
98
102
  repoWithOwner: string;
@@ -132,6 +136,8 @@ export type RequestMetadata = {
132
136
  jobId?: string;
133
137
  sessionId?: string;
134
138
  apiVersion?: string;
139
+ } | {
140
+ type: RequestType.CCAModelsList;
135
141
  } | {
136
142
  type: RequestType.CopilotCustomAgents;
137
143
  owner: string;
@@ -146,6 +152,9 @@ export type RequestMetadata = {
146
152
  repo: string;
147
153
  customAgentName: string;
148
154
  version?: string;
155
+ } | {
156
+ type: RequestType.OrgCustomInstructions;
157
+ orgLogin: string;
149
158
  };
150
159
  export interface IDomainChangeResponse {
151
160
  capiUrlChanged: boolean;
@@ -153,3 +162,56 @@ export interface IDomainChangeResponse {
153
162
  dotcomUrlChanged: boolean;
154
163
  proxyUrlChanged: boolean;
155
164
  }
165
+ interface CCAModelBilling {
166
+ is_premium: boolean;
167
+ multiplier: number;
168
+ restricted_to: string[];
169
+ }
170
+ interface CCAModelVisionLimits {
171
+ max_prompt_image_size: number;
172
+ max_prompt_images: number;
173
+ supported_media_types: string[];
174
+ }
175
+ interface CCAModelLimits {
176
+ max_context_window_tokens: number;
177
+ max_output_tokens: number;
178
+ max_prompt_tokens: number;
179
+ vision?: CCAModelVisionLimits;
180
+ }
181
+ interface CCAModelSupports {
182
+ max_thinking_budget?: number;
183
+ min_thinking_budget?: number;
184
+ parallel_tool_calls: boolean;
185
+ streaming: boolean;
186
+ tool_calls: boolean;
187
+ vision: boolean;
188
+ }
189
+ interface CCAModelCapabilities {
190
+ family: string;
191
+ limits: CCAModelLimits;
192
+ object: string;
193
+ supports: CCAModelSupports;
194
+ tokenizer: string;
195
+ type: string;
196
+ }
197
+ interface CCAModelPolicy {
198
+ state: string;
199
+ terms: string;
200
+ }
201
+ export interface CCAModel {
202
+ billing: CCAModelBilling;
203
+ capabilities: CCAModelCapabilities;
204
+ id: string;
205
+ is_chat_default: boolean;
206
+ is_chat_fallback: boolean;
207
+ model_picker_category: string;
208
+ model_picker_enabled: boolean;
209
+ name: string;
210
+ object: string;
211
+ policy: CCAModelPolicy;
212
+ preview: boolean;
213
+ supported_endpoints: string[];
214
+ vendor: string;
215
+ version: string;
216
+ }
217
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vscode/copilot-api",
3
3
  "description": "A module used for interacting with the GitHub Copilot API.",
4
- "version": "0.2.5",
4
+ "version": "0.2.7",
5
5
  "type": "module",
6
6
  "author": {
7
7
  "name": "Microsoft Corporation"