@vscode/copilot-api 0.2.9 → 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.
- package/dist/index.js +1 -1
- package/dist/types.d.ts +7 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -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.CopilotAgentMemory="CopilotAgentMemory",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)}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};
|
|
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
|
@@ -94,7 +94,8 @@ export declare enum RequestType {
|
|
|
94
94
|
CopilotCustomAgents = "CopilotCustomAgents",
|
|
95
95
|
CopilotCustomAgentsDetail = "CopilotCustomAgentsDetail",
|
|
96
96
|
OrgCustomInstructions = "OrgCustomInstructions",
|
|
97
|
-
CopilotAgentMemory = "CopilotAgentMemory"
|
|
97
|
+
CopilotAgentMemory = "CopilotAgentMemory",
|
|
98
|
+
CopilotAgentJobEnabled = "CopilotAgentJobEnabled"
|
|
98
99
|
}
|
|
99
100
|
export type RequestMetadata = {
|
|
100
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>;
|
|
@@ -159,8 +160,12 @@ export type RequestMetadata = {
|
|
|
159
160
|
} | {
|
|
160
161
|
type: RequestType.CopilotAgentMemory;
|
|
161
162
|
repo: string;
|
|
162
|
-
action?: "search" | "recent";
|
|
163
|
+
action?: "search" | "recent" | "enabled";
|
|
163
164
|
limit?: number;
|
|
165
|
+
} | {
|
|
166
|
+
type: RequestType.CopilotAgentJobEnabled;
|
|
167
|
+
owner: string;
|
|
168
|
+
repo: string;
|
|
164
169
|
};
|
|
165
170
|
export interface IDomainChangeResponse {
|
|
166
171
|
capiUrlChanged: boolean;
|