@vscode/copilot-api 0.2.8 → 0.2.11

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.
@@ -34,6 +34,7 @@ export interface IDomainService {
34
34
  readonly copilotAgentJobsURL: string;
35
35
  readonly CCAModelsURL: string;
36
36
  readonly copilotCustomAgentsURL: string;
37
+ readonly copilotAgentMemoryURL: string;
37
38
  updateDomains(copilotToken: CopilotToken | undefined, enterpriseUrlConfig: string | undefined): IDomainChangeResponse;
38
39
  }
39
40
  export declare class DomainService implements IDomainService {
@@ -86,4 +87,5 @@ export declare class DomainService implements IDomainService {
86
87
  get copilotAgentJobsURL(): string;
87
88
  get CCAModelsURL(): string;
88
89
  get copilotCustomAgentsURL(): string;
90
+ get copilotAgentMemoryURL(): string;
89
91
  }
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 C=await a.json(),m=e.getItemsFromResponse(C);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 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.
1
+ var d=class{async fetch(i,e){let r={method:e.method||"GET",headers:e.headers,signal:e.signal};e.json?(r.body=JSON.stringify(e.json),r.headers={"Content-Type":"application/json",...r.headers}):e.body&&(r.body=e.body);let n,o;e.timeout&&!e.signal&&(o=new AbortController,r.signal=o.signal,n=setTimeout(()=>{o.abort()},e.timeout));try{let s=await fetch(i,r);return n&&clearTimeout(n),s}catch(s){throw n&&clearTimeout(n),s}}async fetchWithPagination(i,e){let r=[],n=e.pageSize??20,o=e.startPage??1,s=!1;do{let p=e.buildUrl(i,n,o),a=await this.fetch(p,e);if(!a.ok)return r;let C=await a.json(),m=e.getItemsFromResponse(C);r.push(...m),s=m.length===n,o++}while(s);return r}};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 r=this._dotcomAPIUrl,n=this._capiBaseUrl,o=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:r!==this._dotcomAPIUrl,capiUrlChanged:n!==this._capiBaseUrl,telemetryUrlChanged:o!==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 CCAModelsURL(){return`${this._capiBaseUrl}/agents/swe/models`}get copilotCustomAgentsURL(){return`${this._capiBaseUrl}/agents/swe/custom-agents`}get copilotAgentMemoryURL(){return`${this._capiBaseUrl}/agents/swe/internal/memory/v0`}};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
 
@@ -43,5 +43,5 @@ This limitation applies to (a) anything related to the software, services, conte
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
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(),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","CCAModelsList","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"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 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};
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.CopilotAgentMemory="CopilotAgentMemory",t.CopilotAgentJobEnabled="CopilotAgentJobEnabled",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),o=await crypto.subtle.sign("HMAC",i,n),p=Array.from(new Uint8Array(o)).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","CopilotAgentMemory"]).has(l)}var g=class{constructor(i,e,r,n,o){this._extensionInfo=i;this._integrationId=o;this._licenseCheckSucceeded=!1;if(e&&e===u&&(this._licenseCheckSucceeded=!0),this._domainService=new c,this._fetcherService=r??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:r}=e;switch(await this._mixinHeaders(i,e),r){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:o=>{let s=o;return s&&Array.isArray(s.sessions)?s.sessions:[]},buildUrl:(o,s,p)=>{let a=new URL(o);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 o="apiVersion"in e&&e.apiVersion||"v1";return this._fetcherService.fetch(`${this._domainService.copilotAgentJobsURL}/${o}/jobs/${e.owner}/${e.repo}/${e.jobId}`,i)}if("sessionId"in e&&e.sessionId){let o="apiVersion"in e&&e.apiVersion||"v1";return this._fetcherService.fetch(`${this._domainService.copilotAgentJobsURL}/${o}/jobs/${e.owner}/${e.repo}/session/${e.sessionId}`,i)}if("payload"in e&&e.payload){let o="apiVersion"in e&&e.apiVersion||"v1";return this._fetcherService.fetch(`${this._domainService.copilotAgentJobsURL}/${o}/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 o=new URL(`${this._domainService.copilotCustomAgentsURL}/${e.owner}/${e.repo}`);return"target"in e&&e.target&&o.searchParams.set("target",e.target),"exclude_invalid_config"in e&&e.exclude_invalid_config!==void 0&&o.searchParams.set("exclude_invalid_config",e.exclude_invalid_config.toString()),"dedupe"in e&&e.dedupe!==void 0&&o.searchParams.set("dedupe",e.dedupe.toString()),"include_sources"in e&&e.include_sources&&o.searchParams.set("include_sources",e.include_sources.join(",")),this._fetcherService.fetch(o.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 o=new URL(`${this._domainService.copilotCustomAgentsURL}/${e.owner}/${e.repo}/${e.customAgentName}`);return"version"in e&&e.version&&o.searchParams.set("version",e.version),this._fetcherService.fetch(o.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);case"CopilotAgentMemory":{if(!("repo"in e))throw new Error("repo is required for CopilotAgentMemory request");let o="action"in e?e.action:"",s=`${this._domainService.copilotAgentMemoryURL}/${e.repo}`;return o&&(s+=`/${o}`,o==="recent"&&"limit"in e&&e.limit!==void 0&&(s+=`?limit=${e.limit}`)),this._fetcherService.fetch(s,i)}case"CopilotAgentJobEnabled":{if(!("owner"in e)||!("repo"in e))throw new Error("owner and repo are required for CopilotAgentJobEnabled request");return this._fetcherService.fetch(`${this._domainService.copilotAgentJobsURL}/v1/jobs/${e.owner}/${e.repo}/enabled`,i)}default:throw new Error(`Unsupported request type: ${r}`)}}_prepareContentExclusionUrl(i){let e=i.join(","),r=new URL(this._domainService.contentExclusionURL);return i.length!==0&&r.searchParams.set("repos",e),r.searchParams.set("scope","repo"),r.toString()}async _mixinHeaders(i,e){if(!y(e.type))return;let r=i.headers||{};r["X-GitHub-Api-Version"]="2025-10-01",r["VScode-SessionId"]=this._extensionInfo.sessionId,r["VScode-MachineId"]=this._extensionInfo.machineId,r["Editor-Plugin-Version"]=`copilot-chat/${this._extensionInfo.version}`,r["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"),r["Copilot-Integration-Id"]=n),n==="vscode-chat-dev"&&(r["Request-Hmac"]=await f(this._hmacSecret)),i.headers=r}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
@@ -93,10 +93,12 @@ export declare enum RequestType {
93
93
  CCAModelsList = "CCAModelsList",
94
94
  CopilotCustomAgents = "CopilotCustomAgents",
95
95
  CopilotCustomAgentsDetail = "CopilotCustomAgentsDetail",
96
- OrgCustomInstructions = "OrgCustomInstructions"
96
+ OrgCustomInstructions = "OrgCustomInstructions",
97
+ CopilotAgentMemory = "CopilotAgentMemory",
98
+ CopilotAgentJobEnabled = "CopilotAgentJobEnabled"
97
99
  }
98
100
  export type RequestMetadata = {
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>;
101
+ 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 | RequestType.CopilotAgentMemory>;
100
102
  } | {
101
103
  type: RequestType.CodingGuidelines | RequestType.EmbeddingsIndex;
102
104
  repoWithOwner: string;
@@ -155,6 +157,15 @@ export type RequestMetadata = {
155
157
  } | {
156
158
  type: RequestType.OrgCustomInstructions;
157
159
  orgLogin: string;
160
+ } | {
161
+ type: RequestType.CopilotAgentMemory;
162
+ repo: string;
163
+ action?: "search" | "recent" | "enabled";
164
+ limit?: number;
165
+ } | {
166
+ type: RequestType.CopilotAgentJobEnabled;
167
+ owner: string;
168
+ repo: string;
158
169
  };
159
170
  export interface IDomainChangeResponse {
160
171
  capiUrlChanged: boolean;
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.8",
4
+ "version": "0.2.11",
5
5
  "type": "module",
6
6
  "author": {
7
7
  "name": "Microsoft Corporation"