@vscode/copilot-api 0.2.4 → 0.2.6
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/dist/index.js +4 -4
- package/dist/types.d.ts +13 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
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.
|
|
2
2
|
|
|
3
3
|
IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS BELOW.
|
|
4
4
|
|
|
@@ -40,8 +40,8 @@ Subject to the foregoing clause (ii), GitHub will only be liable for slight negl
|
|
|
40
40
|
|
|
41
41
|
This limitation applies to (a) anything related to the software, services, content (including code) on third party Internet sites, or third party applications; and (b) claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence, or other tort to the extent permitted by applicable law.
|
|
42
42
|
|
|
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.`,
|
|
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
|
-
${
|
|
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.CopilotCustomAgents="CopilotCustomAgents",t))(_||{});async function y(h){if(!h)return;let i=await crypto.subtle.importKey("raw",new TextEncoder().encode(h),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),e=Math.floor(Date.now()/1e3).toString(),r=new TextEncoder().encode(e),n=await crypto.subtle.sign("HMAC",i,r),a=Array.from(new Uint8Array(n)).map(d=>d.toString(16).padStart(2,"0")).join("");return`${e}.${a}`}function S(h){return new Set(["ChatCompletions","ChatResponses","ChatMessages","CAPIEmbeddings","Models","RemoteAgent","CodeReviewAgent","RemoteAgentChat","ListSkills","SearchSkill","ModelPolicy","ListModel","AutoModels","CopilotSessionLogs","CopilotSessionDetails","CopilotSessions","CopilotAgentJob","CopilotCustomAgents"]).has(h)}var m=class{constructor(i,e,o,r,n){this._extensionInfo=i;this._integrationId=n;this._licenseCheckSucceeded=!1;if(e&&e===f&&(this._licenseCheckSucceeded=!0),this._domainService=new c,this._fetcherService=o??new g,this._hmacSecret=r,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 r={...i,getItemsFromResponse:s=>{let a=s;return a&&Array.isArray(a.sessions)?a.sessions:[]},buildUrl:(s,a,d)=>{let l=new URL(s);return l.searchParams.set("page_size",a.toString()),l.searchParams.set("page_number",d.toString()),"resourceState"in e&&e.resourceState&&l.searchParams.set("resource_state",e.resourceState),"nwo"in e&&e.nwo&&l.searchParams.set("repo_nwo",e.nwo),l.toString()}};return"prId"in e&&e.prId?this._fetcherService.fetch(`${this._domainService.copilotAgentSessionsURL}/resource/pull/${e.prId}`,i):this._fetcherService.fetchWithPagination(this._domainService.copilotAgentSessionsURL,r);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 s="apiVersion"in e&&e.apiVersion||"v1";return this._fetcherService.fetch(`${this._domainService.copilotAgentJobsURL}/${s}/jobs/${e.owner}/${e.repo}/${e.jobId}`,i)}if("sessionId"in e&&e.sessionId){let s="apiVersion"in e&&e.apiVersion||"v1";return this._fetcherService.fetch(`${this._domainService.copilotAgentJobsURL}/${s}/jobs/${e.owner}/${e.repo}/session/${e.sessionId}`,i)}if("payload"in e&&e.payload){let s="apiVersion"in e&&e.apiVersion||"v1";return this._fetcherService.fetch(`${this._domainService.copilotAgentJobsURL}/${s}/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 n=new URL(`${this._domainService.copilotCustomAgentsURL}/${e.owner}/${e.repo}`);return"target"in e&&e.target&&n.searchParams.set("target",e.target),"exclude_invalid_config"in e&&e.exclude_invalid_config!==void 0&&n.searchParams.set("exclude_invalid_config",e.exclude_invalid_config.toString()),"dedupe"in e&&e.dedupe!==void 0&&n.searchParams.set("dedupe",e.dedupe.toString()),"include_sources"in e&&e.include_sources&&n.searchParams.set("include_sources",e.include_sources.join(",")),this._fetcherService.fetch(n.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(!S(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 r="";i.suppressIntegrationId||(r="code-oss",this._integrationId&&this._hmacSecret?r=this._integrationId:this._copilotSku==="no_auth_limited_copilot"?r="vscode-nl":this._licenseCheckSucceeded&&this._extensionInfo.buildType==="prod"?r="vscode-chat":this._extensionInfo.buildType==="dev"&&this._hmacSecret&&(r="vscode-chat-dev"),o["Copilot-Integration-Id"]=r),r==="vscode-chat-dev"&&(o["Request-Hmac"]=await y(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{m as CAPIClient,_ as RequestType};
|
|
45
|
+
${C}
|
|
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.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(),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)}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 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,_ as RequestType};
|
|
47
47
|
//# sourceMappingURL=index.js.map
|
package/dist/types.d.ts
CHANGED
|
@@ -88,10 +88,12 @@ export declare enum RequestType {
|
|
|
88
88
|
CopilotSessionDetails = "CopilotSessionDetails",
|
|
89
89
|
CopilotSessions = "CopilotSessions",
|
|
90
90
|
CopilotAgentJob = "CopilotAgentJob",
|
|
91
|
-
CopilotCustomAgents = "CopilotCustomAgents"
|
|
91
|
+
CopilotCustomAgents = "CopilotCustomAgents",
|
|
92
|
+
CopilotCustomAgentsDetail = "CopilotCustomAgentsDetail",
|
|
93
|
+
OrgCustomInstructions = "OrgCustomInstructions"
|
|
92
94
|
}
|
|
93
95
|
export type RequestMetadata = {
|
|
94
|
-
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>;
|
|
96
|
+
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 | RequestType.OrgCustomInstructions>;
|
|
95
97
|
} | {
|
|
96
98
|
type: RequestType.CodingGuidelines | RequestType.EmbeddingsIndex;
|
|
97
99
|
repoWithOwner: string;
|
|
@@ -139,6 +141,15 @@ export type RequestMetadata = {
|
|
|
139
141
|
exclude_invalid_config?: boolean;
|
|
140
142
|
dedupe?: boolean;
|
|
141
143
|
include_sources?: Array<"repo" | "org" | "enterprise">;
|
|
144
|
+
} | {
|
|
145
|
+
type: RequestType.CopilotCustomAgentsDetail;
|
|
146
|
+
owner: string;
|
|
147
|
+
repo: string;
|
|
148
|
+
customAgentName: string;
|
|
149
|
+
version?: string;
|
|
150
|
+
} | {
|
|
151
|
+
type: RequestType.OrgCustomInstructions;
|
|
152
|
+
orgLogin: string;
|
|
142
153
|
};
|
|
143
154
|
export interface IDomainChangeResponse {
|
|
144
155
|
capiUrlChanged: boolean;
|