sliccy 3.44.0 → 3.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +1 -1
  2. package/dist/node-server/electron-controller.d.ts +66 -0
  3. package/dist/node-server/electron-controller.js +351 -227
  4. package/dist/ui/assets/{adobe-DfX5Y34s.js → adobe-CSxcey5r.js} +2 -2
  5. package/dist/ui/assets/{adobe-ChVGhtP9.js → adobe-Da115bHB.js} +1 -1
  6. package/dist/ui/assets/{agent-bridge-C5enj1WV.js → agent-bridge-ZRdlTYxI.js} +1 -1
  7. package/dist/ui/assets/agent-message-to-chat-B5VQCgc6.js +7 -0
  8. package/dist/ui/assets/{apps-Crb9N_ly.js → apps-LCRJf-Bj.js} +1 -1
  9. package/dist/ui/assets/{azure-openai-C4klGbBq.js → azure-openai-DrpoflZr.js} +1 -1
  10. package/dist/ui/assets/{azure-openai-z_V4V786.js → azure-openai-e68lAEyj.js} +1 -1
  11. package/dist/ui/assets/{bsh-watchdog-X8O_f3CL.js → bsh-watchdog-B1zIY2sM.js} +1 -1
  12. package/dist/ui/assets/{cdp-rsA_ALer.js → cdp-Cy4upOhT.js} +3 -3
  13. package/dist/ui/assets/{connect-surface-KLfqgi-g.js → connect-surface-BahfcMFA.js} +1 -1
  14. package/dist/ui/assets/cost-command-B1SUEdVQ.js +1 -0
  15. package/dist/ui/assets/{dist-LiJ_YnhF.js → dist-DLO6_i_i.js} +1 -1
  16. package/dist/ui/assets/{dist-Bm5Z71wh.js → dist-DUVVOtT3.js} +1 -1
  17. package/dist/ui/assets/{es-BJGCk_7v.js → es-CBKhaKNo.js} +1 -1
  18. package/dist/ui/assets/{follower-sprinkle-bridge-Q2unDn_f.js → follower-sprinkle-bridge-CknbkmDw.js} +1 -1
  19. package/dist/ui/assets/{fs-OBeSd3iT.js → fs-jtOU7if2.js} +1 -1
  20. package/dist/ui/assets/{github-kiWl2pok.js → github-B4cLbBmQ.js} +1 -1
  21. package/dist/ui/assets/{github-Ca90QHu7.js → github-BSaD-jMI.js} +2 -2
  22. package/dist/ui/assets/{github-copilot-CwAq3lpN.js → github-copilot-BsW7hhJu.js} +1 -1
  23. package/dist/ui/assets/{github-copilot-BrwsrJ0a.js → github-copilot-DodI4DS1.js} +1 -1
  24. package/dist/ui/assets/{kernel-worker-D7kDM6z5.js → kernel-worker-BTrLFznM.js} +919 -891
  25. package/dist/ui/assets/lick-ws-bridge-E1g3lRps.js +1 -0
  26. package/dist/ui/assets/{local-llm-BlEhi-EE.js → local-llm-CwKk0-sh.js} +1 -1
  27. package/dist/ui/assets/{magick-wasm-1dtYEyLr.js → magick-wasm-Muqi5nQe.js} +1 -1
  28. package/dist/ui/assets/{main-DQNfRwQ_.js → main-BAt3GJms.js} +169 -169
  29. package/dist/ui/assets/{main-cherry-zUoPE3cg.js → main-cherry-TgxLxBGI.js} +1 -1
  30. package/dist/ui/assets/{migration-run--a8o7LGm.js → migration-run-BDogYJcC.js} +1 -1
  31. package/dist/ui/assets/{mount-B7zmIwVP.js → mount-CSayJ5xj.js} +1 -1
  32. package/dist/ui/assets/{nuke-command-DlkLMgeD.js → nuke-command-B1G-iwiX.js} +1 -1
  33. package/dist/ui/assets/{oauth-bootstrap--CDdXr74.js → oauth-bootstrap-CJO5Uc9n.js} +2 -2
  34. package/dist/ui/assets/{oauth-service-BcS-bhoB.js → oauth-service-DB4fWEIw.js} +1 -1
  35. package/dist/ui/assets/{onboarding-orchestrator-Dpk9ts40.js → onboarding-orchestrator-xRYzOs-B.js} +1 -1
  36. package/dist/ui/assets/{openai-codex-DzqY9hsC.js → openai-codex-B5qZu8bN.js} +1 -1
  37. package/dist/ui/assets/{openai-codex-D1-QVrzy.js → openai-codex-CgxGUy87.js} +1 -1
  38. package/dist/ui/assets/{panel-rpc-handlers-CnJYQP27.js → panel-rpc-handlers-DbDQuWjm.js} +1 -1
  39. package/dist/ui/assets/{provider-BiMU6jfy.js → provider-BbqMcfYp.js} +2 -2
  40. package/dist/ui/assets/{provider-BBaMH9k3.js → provider-j_DAU9YR.js} +1 -1
  41. package/dist/ui/assets/{provider-settings-Cg_hqZuj.js → provider-settings-BfWBLG45.js} +2 -2
  42. package/dist/ui/assets/provider-store-access-DREH5Rn0.js +1 -0
  43. package/dist/ui/assets/provider-store-access-Dvt6Obmo.js +1 -0
  44. package/dist/ui/assets/{providers-BHEqlrX_.js → providers-B-eUneAQ.js} +1 -1
  45. package/dist/ui/assets/{proxied-fetch-Czuq7h2B.js → proxied-fetch-DLNoZln5.js} +1 -1
  46. package/dist/ui/assets/{remote-terminal-view-DkDiLkBM.js → remote-terminal-view-8J05xBYs.js} +1 -1
  47. package/dist/ui/assets/{store-DFdPyEaa.js → store-s3uG1ved.js} +1 -1
  48. package/dist/ui/assets/{sudo-CDWHE-XG.js → sudo-6xMv5Je5.js} +1 -1
  49. package/dist/ui/assets/{tray-leave-runtime-CedcHQX5.js → tray-leave-runtime-DnWFIWXy.js} +1 -1
  50. package/dist/ui/assets/{upgrade-detection-Bxb3OurB.js → upgrade-detection-366FmFL3.js} +1 -1
  51. package/dist/ui/assets/{xai-grok-CaWgmHbx.js → xai-grok-BG6yWHMj.js} +1 -1
  52. package/dist/ui/assets/{xai-grok-BrDEN2gc.js → xai-grok-hGf99Tc7.js} +1 -1
  53. package/dist/ui/electron-overlay-entry.js +127 -10
  54. package/dist/ui/index.html +1 -1
  55. package/dist/ui/packages/webapp/index.html +1 -1
  56. package/package.json +1 -1
  57. package/dist/ui/assets/agent-message-to-chat-FbjZc5O-.js +0 -7
  58. package/dist/ui/assets/cost-command-JwQpMwfk.js +0 -1
  59. package/dist/ui/assets/lick-ws-bridge-X9yJaxZX.js +0 -1
  60. package/dist/ui/assets/provider-store-access-DumMYBkr.js +0 -1
  61. package/dist/ui/assets/provider-store-access-k0kSINjn.js +0 -1
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/main-DQNfRwQ_.js","assets/chunk-aKtaBQYM.js","assets/modulepreload-polyfill-Dezn_h7o.js","assets/preload-helper-zJ_50EbN.js","assets/bedrock-camp-CWvhREqw.js","assets/transform-messages-B3Q-Bwv-.js","assets/json-parse-BUunmmNl.js","assets/logger-DDBAeTLF.js","assets/mime-types-B9LIwKG5.js","assets/mount-picker-popup-DncaR5N8.js","assets/path-utils-DU6QhF_k.js","assets/types-idfTVsM8.js","assets/hid-device-registry-D2LsJCRr.js","assets/picker-approval-tzbkMw-e.js","assets/tool-ui-YOPqzMmL.js","assets/clipboard-DgFtRQbq.js","assets/main-B-eXD0kW.css"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-zJ_50EbN.js";import{$ as t,W as n,X as r,ct as i,ot as a}from"./main-DQNfRwQ_.js";import{getOAuthPageOrigin as o}from"./oauth-service-BcS-bhoB.js";import{t as s}from"./global-db-CbuLl-zx.js";var c={clientId:``,scopes:`repo,read:user,user:email`};function l(){try{let e=localStorage.getItem(i);if(e)return e.replace(/\/$/,``)}catch{}return a}async function u(e){let t=`${l()}/oauth/token`,n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,code:e.code,redirect_uri:e.redirectUri})}),r;try{r=await n.json()}catch{throw Error(`Token exchange failed (HTTP ${n.status}): non-JSON response`)}if(!n.ok&&n.status!==200){let e=r.error_description??r.error??`Token exchange failed (HTTP ${n.status})`;throw Error(e)}if(r.error){let e=r.error_description??r.error;throw Error(e)}return r}async function d(e){let t=`${l()}/oauth/revoke`,n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,access_token:e.accessToken})});if(!(n.status===204||n.ok)){if(n.status===400)try{if((await n.json()).error===`unsupported`)return}catch{}throw Error(`Token revocation failed (HTTP ${n.status})`)}}var f=Object.assign({"/packages/webapp/providers/github-config.json":c})[`/packages/webapp/providers/github-config.json`]??{clientId:``,scopes:`repo,read:user,user:email`},p=null,m=null;function h(e){let{isExtension:t,isConnectMode:n,workerBaseUrl:r,pageOrigin:i,pageHref:a,extensionId:o,nonce:s}=e;if(t)return{redirectUri:`${r}/auth/callback`,state:{source:`extension`,extensionId:o,path:`/github`,nonce:s}};if(n){let e=i??``;if(/^https?:\/\/(localhost|127\.0\.0\.1):\d+$/.test(e)){let t=parseInt(new URL(a??e).port||`8790`,10);return{redirectUri:`${r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:s}}}return{redirectUri:`${r}/auth/callback`,state:{source:`remote`,origin:e,path:`/auth/callback`,nonce:s}}}return{redirectUri:`${e.runtimeWorkerBaseUrl??i??``}/auth/callback`,state:{port:parseInt(new URL(a??i??`http://localhost:5710`).port||`5710`,10),path:`/auth/callback`,nonce:s}}}async function g(){if(p)return p;if(_){try{let e=await fetch(`${l()}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return p=t.oauth.github,p}}catch{}return f.clientId}try{let e=await fetch(`/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return p=t.oauth.github,p;if(t.trayWorkerBaseUrl){m=t.trayWorkerBaseUrl;let e=await fetch(`${t.trayWorkerBaseUrl}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return p=t.oauth.github,p}}}}catch{}return f.clientId}var _=typeof chrome<`u`&&!!chrome?.runtime?.id;function v(){return n().find(e=>e.providerId===`github`)}function y(e){try{return new URL(e).searchParams.get(`code`)}catch{return null}}async function b(e){try{let t=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${e}`,Accept:`application/vnd.github+json`}});if(t.ok){let e=await t.json();return{name:e.name||e.login,avatar:e.avatar_url,login:e.login,id:e.id}}}catch(e){console.warn(`[github] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function x(e,t){return`${e}+${t}@users.noreply.github.com`}async function S(t){try{let{VirtualFS:n}=await e(async()=>{let{VirtualFS:e}=await import(`./main-DQNfRwQ_.js`).then(e=>e.r);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]));await(await n.create({dbName:s})).writeFile(`/workspace/.git/github-token`,t),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch(e){console.warn(`[github] Failed to write git token:`,e instanceof Error?e.message:String(e))}}async function C(){try{let{VirtualFS:t}=await e(async()=>{let{VirtualFS:e}=await import(`./main-DQNfRwQ_.js`).then(e=>e.r);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]));await(await t.create({dbName:s})).rm(`/workspace/.git/github-token`),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch{}}async function w(t){if(!(!t.login||t.id===void 0))try{let{VirtualFS:n}=await e(async()=>{let{VirtualFS:e}=await import(`./main-DQNfRwQ_.js`).then(e=>e.r);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])),{readGlobalGitConfigValue:r,writeGlobalGitConfigValue:i}=await e(async()=>{let{readGlobalGitConfigValue:e,writeGlobalGitConfigValue:t}=await import(`./git-config-DLJIrKjL.js`);return{readGlobalGitConfigValue:e,writeGlobalGitConfigValue:t}},[]),a=await n.create({dbName:s}),o=t.name||t.login,c=x(t.id,t.login);!await r(a,`user.name`)&&o&&await i(a,`user.name`,o),await r(a,`user.email`)||await i(a,`user.email`,c)}catch(e){console.warn(`[github] Failed to seed git identity:`,e instanceof Error?e.message:String(e))}}async function T(){let e=v();if(!e?.accessToken)throw Error(`Not logged in to GitHub — please log in first`);return e.accessToken}var E={id:`github`,name:`GitHub`,description:"Sign in with GitHub for git authentication (push/pull/clone) and the `oauth-token github` shell command. Does not expose LLM models — use the GitHub Copilot provider for those.",requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,oauthTokenDomains:[`github.com`,`*.github.com`,`api.github.com`,`raw.githubusercontent.com`],getModelIds:()=>[],onOAuthLogin:async(e,n,i)=>{let a=await g();if(!a)throw Error(`GitHub OAuth not configured — no client ID available`);let s=i?.scopes??f.scopes,c=_?null:await o(),d=crypto.randomUUID(),p=_?chrome.runtime.id:``,{redirectUri:v,state:x}=h({isExtension:_,isConnectMode:!!globalThis.__slicc_connect_mode,workerBaseUrl:l(),runtimeWorkerBaseUrl:m,pageOrigin:c?.origin??null,pageHref:c?.href??null,extensionId:p,nonce:d}),T=btoa(JSON.stringify(x)),E=d,D=new URLSearchParams({client_id:a,scope:s,redirect_uri:v});T&&D.set(`state`,T);let O=await e(`https://github.com/login/oauth/authorize?${D}`);if(!O)return;if(E)try{if(new URL(O).searchParams.get(`nonce`)!==E){console.error(`[github] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[github] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let k=y(O);if(!k){console.error(`[github] Could not extract authorization code from redirect URL`);return}let A=await u({provider:`github`,code:k,redirectUri:v}),j=await b(A.access_token);await t({providerId:`github`,accessToken:A.access_token,userName:j.name,userAvatar:j.avatar});let M=r(`github`)?.maskedValue;M?await S(M):await C(),await w(j),n()},onOAuthLogout:async()=>{let e=v();e?.accessToken&&await d({provider:`github`,accessToken:e.accessToken}).catch(e=>console.warn(`[github] Token revocation failed:`,e instanceof Error?e.message:String(e))),await C(),await t({providerId:`github`,accessToken:``})},getOAuthLogoutUrl:e=>`https://github.com/logout`};export{x as buildNoreplyEmail,E as config,y as extractCodeFromUrl,T as getValidAccessToken,h as resolveGithubOAuthRedirect,w as syncGitIdentityFromGitHub};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/main-BAt3GJms.js","assets/chunk-aKtaBQYM.js","assets/modulepreload-polyfill-Dezn_h7o.js","assets/preload-helper-zJ_50EbN.js","assets/bedrock-camp-CWvhREqw.js","assets/transform-messages-B3Q-Bwv-.js","assets/json-parse-BUunmmNl.js","assets/logger-DDBAeTLF.js","assets/mime-types-B9LIwKG5.js","assets/mount-picker-popup-DncaR5N8.js","assets/path-utils-DU6QhF_k.js","assets/types-idfTVsM8.js","assets/hid-device-registry-D2LsJCRr.js","assets/picker-approval-tzbkMw-e.js","assets/tool-ui-YOPqzMmL.js","assets/clipboard-DgFtRQbq.js","assets/main-B-eXD0kW.css"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./preload-helper-zJ_50EbN.js";import{$ as t,W as n,X as r,ct as i,ot as a}from"./main-BAt3GJms.js";import{getOAuthPageOrigin as o}from"./oauth-service-DB4fWEIw.js";import{t as s}from"./global-db-CbuLl-zx.js";var c={clientId:``,scopes:`repo,read:user,user:email`};function l(){try{let e=localStorage.getItem(i);if(e)return e.replace(/\/$/,``)}catch{}return a}async function u(e){let t=`${l()}/oauth/token`,n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,code:e.code,redirect_uri:e.redirectUri})}),r;try{r=await n.json()}catch{throw Error(`Token exchange failed (HTTP ${n.status}): non-JSON response`)}if(!n.ok&&n.status!==200){let e=r.error_description??r.error??`Token exchange failed (HTTP ${n.status})`;throw Error(e)}if(r.error){let e=r.error_description??r.error;throw Error(e)}return r}async function d(e){let t=`${l()}/oauth/revoke`,n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,access_token:e.accessToken})});if(!(n.status===204||n.ok)){if(n.status===400)try{if((await n.json()).error===`unsupported`)return}catch{}throw Error(`Token revocation failed (HTTP ${n.status})`)}}var f=Object.assign({"/packages/webapp/providers/github-config.json":c})[`/packages/webapp/providers/github-config.json`]??{clientId:``,scopes:`repo,read:user,user:email`},p=null,m=null;function h(e){let{isExtension:t,isConnectMode:n,workerBaseUrl:r,pageOrigin:i,pageHref:a,extensionId:o,nonce:s}=e;if(t)return{redirectUri:`${r}/auth/callback`,state:{source:`extension`,extensionId:o,path:`/github`,nonce:s}};if(n){let e=i??``;if(/^https?:\/\/(localhost|127\.0\.0\.1):\d+$/.test(e)){let t=parseInt(new URL(a??e).port||`8790`,10);return{redirectUri:`${r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:s}}}return{redirectUri:`${r}/auth/callback`,state:{source:`remote`,origin:e,path:`/auth/callback`,nonce:s}}}return{redirectUri:`${e.runtimeWorkerBaseUrl??i??``}/auth/callback`,state:{port:parseInt(new URL(a??i??`http://localhost:5710`).port||`5710`,10),path:`/auth/callback`,nonce:s}}}async function g(){if(p)return p;if(_){try{let e=await fetch(`${l()}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return p=t.oauth.github,p}}catch{}return f.clientId}try{let e=await fetch(`/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return p=t.oauth.github,p;if(t.trayWorkerBaseUrl){m=t.trayWorkerBaseUrl;let e=await fetch(`${t.trayWorkerBaseUrl}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return p=t.oauth.github,p}}}}catch{}return f.clientId}var _=typeof chrome<`u`&&!!chrome?.runtime?.id;function v(){return n().find(e=>e.providerId===`github`)}function y(e){try{return new URL(e).searchParams.get(`code`)}catch{return null}}async function b(e){try{let t=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${e}`,Accept:`application/vnd.github+json`}});if(t.ok){let e=await t.json();return{name:e.name||e.login,avatar:e.avatar_url,login:e.login,id:e.id}}}catch(e){console.warn(`[github] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function x(e,t){return`${e}+${t}@users.noreply.github.com`}async function S(t){try{let{VirtualFS:n}=await e(async()=>{let{VirtualFS:e}=await import(`./main-BAt3GJms.js`).then(e=>e.r);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]));await(await n.create({dbName:s})).writeFile(`/workspace/.git/github-token`,t),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch(e){console.warn(`[github] Failed to write git token:`,e instanceof Error?e.message:String(e))}}async function C(){try{let{VirtualFS:t}=await e(async()=>{let{VirtualFS:e}=await import(`./main-BAt3GJms.js`).then(e=>e.r);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]));await(await t.create({dbName:s})).rm(`/workspace/.git/github-token`),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch{}}async function w(t){if(!(!t.login||t.id===void 0))try{let{VirtualFS:n}=await e(async()=>{let{VirtualFS:e}=await import(`./main-BAt3GJms.js`).then(e=>e.r);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])),{readGlobalGitConfigValue:r,writeGlobalGitConfigValue:i}=await e(async()=>{let{readGlobalGitConfigValue:e,writeGlobalGitConfigValue:t}=await import(`./git-config-DLJIrKjL.js`);return{readGlobalGitConfigValue:e,writeGlobalGitConfigValue:t}},[]),a=await n.create({dbName:s}),o=t.name||t.login,c=x(t.id,t.login);!await r(a,`user.name`)&&o&&await i(a,`user.name`,o),await r(a,`user.email`)||await i(a,`user.email`,c)}catch(e){console.warn(`[github] Failed to seed git identity:`,e instanceof Error?e.message:String(e))}}async function T(){let e=v();if(!e?.accessToken)throw Error(`Not logged in to GitHub — please log in first`);return e.accessToken}var E={id:`github`,name:`GitHub`,description:"Sign in with GitHub for git authentication (push/pull/clone) and the `oauth-token github` shell command. Does not expose LLM models — use the GitHub Copilot provider for those.",requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,oauthTokenDomains:[`github.com`,`*.github.com`,`api.github.com`,`raw.githubusercontent.com`],getModelIds:()=>[],onOAuthLogin:async(e,n,i)=>{let a=await g();if(!a)throw Error(`GitHub OAuth not configured — no client ID available`);let s=i?.scopes??f.scopes,c=_?null:await o(),d=crypto.randomUUID(),p=_?chrome.runtime.id:``,{redirectUri:v,state:x}=h({isExtension:_,isConnectMode:!!globalThis.__slicc_connect_mode,workerBaseUrl:l(),runtimeWorkerBaseUrl:m,pageOrigin:c?.origin??null,pageHref:c?.href??null,extensionId:p,nonce:d}),T=btoa(JSON.stringify(x)),E=d,D=new URLSearchParams({client_id:a,scope:s,redirect_uri:v});T&&D.set(`state`,T);let O=await e(`https://github.com/login/oauth/authorize?${D}`);if(!O)return;if(E)try{if(new URL(O).searchParams.get(`nonce`)!==E){console.error(`[github] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[github] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let k=y(O);if(!k){console.error(`[github] Could not extract authorization code from redirect URL`);return}let A=await u({provider:`github`,code:k,redirectUri:v}),j=await b(A.access_token);await t({providerId:`github`,accessToken:A.access_token,userName:j.name,userAvatar:j.avatar});let M=r(`github`)?.maskedValue;M?await S(M):await C(),await w(j),n()},onOAuthLogout:async()=>{let e=v();e?.accessToken&&await d({provider:`github`,accessToken:e.accessToken}).catch(e=>console.warn(`[github] Token revocation failed:`,e instanceof Error?e.message:String(e))),await C(),await t({providerId:`github`,accessToken:``})},getOAuthLogoutUrl:e=>`https://github.com/logout`};export{x as buildNoreplyEmail,E as config,y as extractCodeFromUrl,T as getValidAccessToken,h as resolveGithubOAuthRedirect,w as syncGitIdentityFromGitHub};
@@ -1 +1 @@
1
- import{m as e,t}from"./provider-settings-Cg_hqZuj.js";import{_ as n,d as r,f as i,g as a,h as o,l as s,p as c}from"./bedrock-camp-Cg_vY0Xg.js";import{l,o as u,u as d}from"./transform-messages-C1X1O3BY.js";const f=`github-copilot`,p=atob(`SXYxLmI1MDdhMDhjODdlY2ZlOTg=`),m={Accept:`application/json`,"Editor-Version":`vscode/1.107.0`,"Editor-Plugin-Version":`copilot-chat/0.35.0`,"Copilot-Integration-Id":`vscode-chat`},h={Accept:`application/json`,"Content-Type":`application/x-www-form-urlencoded`};function g(){return t().find(e=>e.providerId===f)}async function _(){let e=await fetch(`https://github.com/login/device/code`,{method:`POST`,headers:h,body:new URLSearchParams({client_id:p,scope:`read:user`})});if(!e.ok)throw Error(`GitHub device-code request failed: ${e.status} ${e.statusText} — ${await e.text().catch(()=>``)}`);let t=await e.json();if(typeof t.device_code!=`string`||typeof t.user_code!=`string`||typeof t.verification_uri!=`string`||typeof t.expires_in!=`number`||typeof t.interval!=`number`)throw Error(`GitHub device-code response had an unexpected shape`);return t}async function v(e,t){let n=Date.now()+e.expires_in*1e3,r=Math.max(1e3,Math.floor(e.interval*1e3)),i=1.2;for(;Date.now()<n;){if(t.aborted)throw Error(`Copilot login cancelled`);await y(Math.ceil(r*i),t);let n=await fetch(`https://github.com/login/oauth/access_token`,{method:`POST`,headers:h,body:new URLSearchParams({client_id:p,device_code:e.device_code,grant_type:`urn:ietf:params:oauth:grant-type:device_code`})});if(!n.ok)throw Error(`GitHub token poll failed: ${n.status} ${n.statusText} — ${await n.text().catch(()=>``)}`);let a=await n.json();if(typeof a.access_token==`string`&&a.access_token.length>0)return a.access_token;if(a.error!==`authorization_pending`){if(a.error===`slow_down`){r=typeof a.interval==`number`?a.interval*1e3:r+5e3,i=1.4;continue}if(a.error){let e=a.error_description?`: ${a.error_description}`:``;throw Error(`Device flow failed (${a.error})${e}`)}}}throw Error(`Copilot device flow timed out (device code expired)`)}function y(e,t){return new Promise((n,r)=>{if(t.aborted){r(Error(`Copilot login cancelled`));return}let i=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Copilot login cancelled`))},{once:!0})})}function b(e){let t=e.match(/proxy-ep=([^;]+)/);return t?`https://${t[1].replace(/^proxy\./,`api.`)}`:null}async function x(e){let t=await fetch(`https://api.github.com/copilot_internal/v2/token`,{headers:{...m,Authorization:`Bearer ${e}`}});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`Copilot token exchange failed: ${t.status} ${t.statusText} — ${e.slice(0,300)}`)}let n=await t.json();if(typeof n.token!=`string`||typeof n.expires_at!=`number`)throw Error(`Copilot token exchange returned an unexpected payload`);if(n.chat_enabled===!1)throw Error(`GitHub Copilot Chat is disabled for this account (no chat features granted)`);return{copilotToken:n.token,expiresAtMs:n.expires_at*1e3-300*1e3,apiBaseUrl:b(n.token)??`https://api.individual.githubcopilot.com`,githubAccessToken:e}}const S=`github-copilot.models.v1`;function C(e){let t=e.supported_endpoints??[],n=(e.vendor??``).toLowerCase(),r=e.id;return n===`anthropic`&&t.includes(`/v1/messages`)?`anthropic-messages`:n===`openai`&&(/^gpt-5/i.test(r)||/codex/i.test(r)||/^o\d/i.test(r))?`openai-responses`:`openai-completions`}function w(e){if(!e||typeof e!=`object`)return[];let t=e.data;if(!Array.isArray(t))return[];let n=[];for(let e of t)e.capabilities?.type&&e.capabilities.type!==`chat`||e.model_picker_enabled!==!1&&e.id&&n.push({id:e.id,name:e.name??e.id,vendor:e.vendor??``,api:C(e),contextWindow:e.capabilities?.limits?.max_context_window_tokens??e.capabilities?.limits?.max_prompt_tokens??128e3,maxTokens:e.capabilities?.limits?.max_output_tokens??8192,supportsTools:e.capabilities?.supports?.tool_calls===!0,supportsStreaming:e.capabilities?.supports?.streaming!==!1,supportsVision:e.capabilities?.supports?.vision===!0,supportsReasoning:e.capabilities?.supports?.adaptive_thinking===!0||Array.isArray(e.capabilities?.supports?.reasoning_effort),policyState:e.policy?.state??`enabled`});return n}async function T(e){let t=await fetch(`${e.apiBaseUrl}/models`,{headers:{...m,Authorization:`Bearer ${e.copilotToken}`,Accept:`application/json`}});if(!t.ok)throw Error(`Copilot /models returned ${t.status} ${t.statusText}`);return w(await t.json())}function E(){if(typeof localStorage>`u`)return[];try{let e=localStorage.getItem(S);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function D(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(S,JSON.stringify(e))}catch{}}function O(e){return E().find(t=>t.id===e)??null}async function k(e){let t;try{t=await T(e)}catch(e){console.warn(`[github-copilot] Catalog refresh failed; keeping previous cache.`,e instanceof Error?e.message:String(e));return}D(t),await Promise.all(t.filter(e=>e.policyState===`disabled`).map(async t=>{let n=`${e.apiBaseUrl}/models/${encodeURIComponent(t.id)}/policy`;try{let r=await fetch(n,{method:`POST`,headers:{...m,"Content-Type":`application/json`,Authorization:`Bearer ${e.copilotToken}`,"openai-intent":`chat-policy`,"x-interaction-type":`chat-policy`},body:JSON.stringify({state:`enabled`})});r.ok?t.policyState=`enabled`:r.status!==404&&r.status!==400&&console.warn(`[github-copilot] enable policy for ${t.id} returned ${r.status} ${r.statusText}`)}catch(e){console.warn(`[github-copilot] enable policy for ${t.id} failed:`,e instanceof Error?e.message:String(e))}})),D(t)}async function A(t,n){await e({providerId:f,accessToken:t.copilotToken,refreshToken:t.githubAccessToken,tokenExpiresAt:t.expiresAtMs,baseUrl:t.apiBaseUrl,userName:n})}async function j(){let e=g();if(!e?.accessToken||!e.refreshToken)throw Error(`Not logged in to GitHub Copilot — click "Login" in the provider settings`);let t=e.tokenExpiresAt??0;if(Date.now()<t-6e4)return e.accessToken;let n=await x(e.refreshToken);return await A(n,e.userName),n.copilotToken}const M=[`mini`,`nano`,`flash`,`haiku`,`lite`,`embedding`];function N(e){let t=[e.id,e.name??``].flatMap(e=>{let t=e.toLowerCase();return[t,t.replace(/[\s_.:]+/g,`-`)]});return!M.some(e=>t.some(t=>t.includes(e)))}function P(){if(!g()?.accessToken)return[];let e=E();if(e.length>0)return e.filter(e=>!e.policyState.startsWith(`unavailable:`)).filter(e=>N(e)).map(e=>({id:e.id,name:e.name,api:e.api===`anthropic-messages`?`anthropic`:`openai`,context_window:e.contextWindow,max_tokens:e.maxTokens,reasoning:e.supportsReasoning,input:e.supportsVision?[`text`,`image`]:[`text`]}));let t;try{t=d(`github-copilot`)}catch{return[]}return t.filter(e=>N({id:e.id,name:e.name})).map(e=>({id:e.id,name:e.name??e.id,api:e.api===`anthropic-messages`?`anthropic`:`openai`,context_window:e.contextWindow,max_tokens:e.maxTokens,reasoning:e.reasoning,input:e.input}))}function F(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:e.api,provider:f,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}const I={"User-Agent":`GitHubCopilotChat/0.35.0`,"Editor-Version":`vscode/1.107.0`,"Editor-Plugin-Version":`copilot-chat/0.35.0`,"Copilot-Integration-Id":`vscode-chat`};function L(e){let t=g(),n=t?.baseUrl??`https://api.individual.githubcopilot.com`,r=O(e);if(r)return{api:r.api,baseUrl:n,headers:{...I}};try{let n=l(`github-copilot`,e);return{api:n.api,baseUrl:t?.baseUrl??n.baseUrl,headers:{...n.headers??{},...I}}}catch{return null}}function R(e,t){let n=E(),r=n.findIndex(t=>t.id===e);r<0||(n[r]={...n[r],policyState:`unavailable:${t}`},D(n))}function z(e,t){return`GitHub Copilot rejected "${e}" with model_not_supported. This usually means the model isn't included in your Copilot plan (Opus and other premium models require Copilot Pro / Pro+ / Business / Enterprise). Try Claude Sonnet 4.6 or another model that appears in the picker after a fresh login. Original error: ${t}`}function B(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.type!==`error`)return null;if(t.error&&typeof t.error==`object`){let e=t.error.errorMessage;if(typeof e==`string`)return e}return typeof t.errorMessage==`string`?t.errorMessage:null}function V(e){return(t,n,l={})=>{let d=u();return(async()=>{try{let u=await j(),f=L(t.id);if(!f)throw Error(`GitHub Copilot does not recognize "${t.id}" — open the picker (the model list refreshes on login) and pick a current model.`);let p={...t,api:f.api,baseUrl:f.baseUrl,headers:f.headers,provider:`github-copilot`},m={...l,apiKey:u},h;h=f.api===`anthropic-messages`?(e?c:s)(p,n,m):f.api===`openai-responses`?(e?a:i)(p,n,m):(e?o:r)(p,n,m);for await(let e of h){let n=B(e);if(n&&/model_not_supported/i.test(n)){R(t.id,`model_not_supported`);let e=z(t.id,n);console.error(`[github-copilot] Plan-gated model rejection:`,e),d.push(F(t,Error(e))),d.end();return}d.push(e)}d.end()}catch(e){let n=e instanceof Error?e.message:String(e),r=e;/model_not_supported/i.test(n)&&(R(t.id,`model_not_supported`),r=Error(z(t.id,n))),console.error(`[github-copilot] Stream error:`,r instanceof Error?r.message:String(r)),d.push(F(t,r)),d.end()}})(),d}}const H=V(!1),U=V(!0),W=({userCode:e,verificationUrl:t})=>typeof document>`u`?(console.info(`[github-copilot] Device verification code: ${e} — open ${t} in a browser to authorize.`),Promise.resolve(`continue`)):new Promise(t=>{let n=document.createElement(`div`);n.setAttribute(`data-slicc-overlay`,`github-copilot-device`),n.style.cssText=[`position:fixed`,`top:24px`,`right:24px`,`z-index:2147483647`,`background:#0d1117`,`color:#e6edf3`,`border:1px solid #30363d`,`border-radius:10px`,`padding:16px 18px`,`box-shadow:0 8px 32px rgba(0,0,0,0.45)`,`font:13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,`min-width:260px`,`max-width:340px`].join(`;`);let r=document.createElement(`div`);r.textContent=`GitHub Copilot — verification code`,r.style.cssText=`font-weight:600;margin-bottom:8px;color:#7ee787`;let i=document.createElement(`div`);i.textContent=e,i.style.cssText=[`font:600 22px ui-monospace, SFMono-Regular, Menlo, monospace`,`letter-spacing:2px`,`background:#161b22`,`border:1px solid #30363d`,`border-radius:6px`,`padding:10px 12px`,`text-align:center`,`margin-bottom:10px`,`user-select:all`,`cursor:text`].join(`;`);let a=document.createElement(`div`);a.style.cssText=`color:#8b949e;font-size:12px;line-height:1.5`,a.textContent=`Copy the code, then click Continue to open the GitHub authorization page in a new tab.`;let o=document.createElement(`div`);o.style.cssText=`display:flex;gap:8px;margin-top:12px;justify-content:flex-end`;let s=document.createElement(`button`);s.type=`button`,s.textContent=`Cancel`,s.style.cssText=[`background:transparent`,`color:#e6edf3`,`border:1px solid #30363d`,`border-radius:6px`,`padding:6px 12px`,`font:600 12px inherit`,`cursor:pointer`].join(`;`);let c=document.createElement(`button`);c.type=`button`,c.textContent=`Copy & Continue`,c.style.cssText=[`background:#238636`,`color:#fff`,`border:0`,`border-radius:6px`,`padding:6px 12px`,`font:600 12px inherit`,`cursor:pointer`].join(`;`);let l=()=>{try{n.remove()}catch{}};s.addEventListener(`click`,()=>{l(),t(`cancel`)}),c.addEventListener(`click`,()=>{(async()=>{try{let{copyTextToClipboard:t}=await import(`./clipboard-C2cR8flR.js`).then(e=>e.t);await t(e)}catch{}l(),t(`continue`)})()}),o.appendChild(s),o.appendChild(c),n.appendChild(r),n.appendChild(i),n.appendChild(a),n.appendChild(o),document.body.appendChild(n)}),G={id:f,name:`GitHub Copilot`,description:`Use your GitHub Copilot subscription to access Claude, GPT-5, Codex, Gemini, and Grok models. Sign in with the GitHub device-code flow.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`claude-sonnet-4.6`,oauthTokenDomains:[`*.githubcopilot.com`,`api.individual.githubcopilot.com`,`api.business.githubcopilot.com`,`api.enterprise.githubcopilot.com`],getModelIds:P,onOAuthLoginIntercepted:async(e,t,n)=>{let r=await _(),i=new URL(r.verification_uri);if(i.searchParams.set(`user_code`,r.user_code),await(n?.presentDeviceCode??W)({userCode:r.user_code,verificationUrl:i.toString(),expiresInSeconds:r.expires_in})===`cancel`)throw Error(`GitHub Copilot login cancelled`);let a=new AbortController,o=e({authorizeUrl:i.toString(),redirectUriPattern:`https://github.com/login/device/success*`,onCapture:`close`,timeoutMs:r.expires_in*1e3}).catch(e=>(console.warn(`[github-copilot] Launcher failed:`,e instanceof Error?e.message:String(e)),null)),s;try{s=await v(r,a.signal)}catch(e){throw a.abort(),await o,e}await o;let c=await x(s),l;try{let e=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${s}`,Accept:`application/json`}});if(e.ok){let t=await e.json();l=t.name||t.login}}catch{}await A(c,l),await k(c),t()},onOAuthLogout:async()=>{await e({providerId:f,accessToken:``})},onSilentRenew:async()=>{let e=g();if(!e?.refreshToken)return null;try{let t=await x(e.refreshToken);return await A(t,e.userName),await k(t),t.copilotToken}catch(e){return console.warn(`[github-copilot] Silent renew failed:`,e instanceof Error?e.message:String(e)),null}}};function K(){n({api:`github-copilot-anthropic`,stream:H,streamSimple:U}),n({api:`github-copilot-openai`,stream:H,streamSimple:U})}export{G as config,N as isCopilotConeCompatible,K as register};
1
+ import{m as e,t}from"./provider-settings-BfWBLG45.js";import{_ as n,d as r,f as i,g as a,h as o,l as s,p as c}from"./bedrock-camp-Cg_vY0Xg.js";import{l,o as u,u as d}from"./transform-messages-C1X1O3BY.js";const f=`github-copilot`,p=atob(`SXYxLmI1MDdhMDhjODdlY2ZlOTg=`),m={Accept:`application/json`,"Editor-Version":`vscode/1.107.0`,"Editor-Plugin-Version":`copilot-chat/0.35.0`,"Copilot-Integration-Id":`vscode-chat`},h={Accept:`application/json`,"Content-Type":`application/x-www-form-urlencoded`};function g(){return t().find(e=>e.providerId===f)}async function _(){let e=await fetch(`https://github.com/login/device/code`,{method:`POST`,headers:h,body:new URLSearchParams({client_id:p,scope:`read:user`})});if(!e.ok)throw Error(`GitHub device-code request failed: ${e.status} ${e.statusText} — ${await e.text().catch(()=>``)}`);let t=await e.json();if(typeof t.device_code!=`string`||typeof t.user_code!=`string`||typeof t.verification_uri!=`string`||typeof t.expires_in!=`number`||typeof t.interval!=`number`)throw Error(`GitHub device-code response had an unexpected shape`);return t}async function v(e,t){let n=Date.now()+e.expires_in*1e3,r=Math.max(1e3,Math.floor(e.interval*1e3)),i=1.2;for(;Date.now()<n;){if(t.aborted)throw Error(`Copilot login cancelled`);await y(Math.ceil(r*i),t);let n=await fetch(`https://github.com/login/oauth/access_token`,{method:`POST`,headers:h,body:new URLSearchParams({client_id:p,device_code:e.device_code,grant_type:`urn:ietf:params:oauth:grant-type:device_code`})});if(!n.ok)throw Error(`GitHub token poll failed: ${n.status} ${n.statusText} — ${await n.text().catch(()=>``)}`);let a=await n.json();if(typeof a.access_token==`string`&&a.access_token.length>0)return a.access_token;if(a.error!==`authorization_pending`){if(a.error===`slow_down`){r=typeof a.interval==`number`?a.interval*1e3:r+5e3,i=1.4;continue}if(a.error){let e=a.error_description?`: ${a.error_description}`:``;throw Error(`Device flow failed (${a.error})${e}`)}}}throw Error(`Copilot device flow timed out (device code expired)`)}function y(e,t){return new Promise((n,r)=>{if(t.aborted){r(Error(`Copilot login cancelled`));return}let i=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Copilot login cancelled`))},{once:!0})})}function b(e){let t=e.match(/proxy-ep=([^;]+)/);return t?`https://${t[1].replace(/^proxy\./,`api.`)}`:null}async function x(e){let t=await fetch(`https://api.github.com/copilot_internal/v2/token`,{headers:{...m,Authorization:`Bearer ${e}`}});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`Copilot token exchange failed: ${t.status} ${t.statusText} — ${e.slice(0,300)}`)}let n=await t.json();if(typeof n.token!=`string`||typeof n.expires_at!=`number`)throw Error(`Copilot token exchange returned an unexpected payload`);if(n.chat_enabled===!1)throw Error(`GitHub Copilot Chat is disabled for this account (no chat features granted)`);return{copilotToken:n.token,expiresAtMs:n.expires_at*1e3-300*1e3,apiBaseUrl:b(n.token)??`https://api.individual.githubcopilot.com`,githubAccessToken:e}}const S=`github-copilot.models.v1`;function C(e){let t=e.supported_endpoints??[],n=(e.vendor??``).toLowerCase(),r=e.id;return n===`anthropic`&&t.includes(`/v1/messages`)?`anthropic-messages`:n===`openai`&&(/^gpt-5/i.test(r)||/codex/i.test(r)||/^o\d/i.test(r))?`openai-responses`:`openai-completions`}function w(e){if(!e||typeof e!=`object`)return[];let t=e.data;if(!Array.isArray(t))return[];let n=[];for(let e of t)e.capabilities?.type&&e.capabilities.type!==`chat`||e.model_picker_enabled!==!1&&e.id&&n.push({id:e.id,name:e.name??e.id,vendor:e.vendor??``,api:C(e),contextWindow:e.capabilities?.limits?.max_context_window_tokens??e.capabilities?.limits?.max_prompt_tokens??128e3,maxTokens:e.capabilities?.limits?.max_output_tokens??8192,supportsTools:e.capabilities?.supports?.tool_calls===!0,supportsStreaming:e.capabilities?.supports?.streaming!==!1,supportsVision:e.capabilities?.supports?.vision===!0,supportsReasoning:e.capabilities?.supports?.adaptive_thinking===!0||Array.isArray(e.capabilities?.supports?.reasoning_effort),policyState:e.policy?.state??`enabled`});return n}async function T(e){let t=await fetch(`${e.apiBaseUrl}/models`,{headers:{...m,Authorization:`Bearer ${e.copilotToken}`,Accept:`application/json`}});if(!t.ok)throw Error(`Copilot /models returned ${t.status} ${t.statusText}`);return w(await t.json())}function E(){if(typeof localStorage>`u`)return[];try{let e=localStorage.getItem(S);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function D(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(S,JSON.stringify(e))}catch{}}function O(e){return E().find(t=>t.id===e)??null}async function k(e){let t;try{t=await T(e)}catch(e){console.warn(`[github-copilot] Catalog refresh failed; keeping previous cache.`,e instanceof Error?e.message:String(e));return}D(t),await Promise.all(t.filter(e=>e.policyState===`disabled`).map(async t=>{let n=`${e.apiBaseUrl}/models/${encodeURIComponent(t.id)}/policy`;try{let r=await fetch(n,{method:`POST`,headers:{...m,"Content-Type":`application/json`,Authorization:`Bearer ${e.copilotToken}`,"openai-intent":`chat-policy`,"x-interaction-type":`chat-policy`},body:JSON.stringify({state:`enabled`})});r.ok?t.policyState=`enabled`:r.status!==404&&r.status!==400&&console.warn(`[github-copilot] enable policy for ${t.id} returned ${r.status} ${r.statusText}`)}catch(e){console.warn(`[github-copilot] enable policy for ${t.id} failed:`,e instanceof Error?e.message:String(e))}})),D(t)}async function A(t,n){await e({providerId:f,accessToken:t.copilotToken,refreshToken:t.githubAccessToken,tokenExpiresAt:t.expiresAtMs,baseUrl:t.apiBaseUrl,userName:n})}async function j(){let e=g();if(!e?.accessToken||!e.refreshToken)throw Error(`Not logged in to GitHub Copilot — click "Login" in the provider settings`);let t=e.tokenExpiresAt??0;if(Date.now()<t-6e4)return e.accessToken;let n=await x(e.refreshToken);return await A(n,e.userName),n.copilotToken}const M=[`mini`,`nano`,`flash`,`haiku`,`lite`,`embedding`];function N(e){let t=[e.id,e.name??``].flatMap(e=>{let t=e.toLowerCase();return[t,t.replace(/[\s_.:]+/g,`-`)]});return!M.some(e=>t.some(t=>t.includes(e)))}function P(){if(!g()?.accessToken)return[];let e=E();if(e.length>0)return e.filter(e=>!e.policyState.startsWith(`unavailable:`)).filter(e=>N(e)).map(e=>({id:e.id,name:e.name,api:e.api===`anthropic-messages`?`anthropic`:`openai`,context_window:e.contextWindow,max_tokens:e.maxTokens,reasoning:e.supportsReasoning,input:e.supportsVision?[`text`,`image`]:[`text`]}));let t;try{t=d(`github-copilot`)}catch{return[]}return t.filter(e=>N({id:e.id,name:e.name})).map(e=>({id:e.id,name:e.name??e.id,api:e.api===`anthropic-messages`?`anthropic`:`openai`,context_window:e.contextWindow,max_tokens:e.maxTokens,reasoning:e.reasoning,input:e.input}))}function F(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:e.api,provider:f,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}const I={"User-Agent":`GitHubCopilotChat/0.35.0`,"Editor-Version":`vscode/1.107.0`,"Editor-Plugin-Version":`copilot-chat/0.35.0`,"Copilot-Integration-Id":`vscode-chat`};function L(e){let t=g(),n=t?.baseUrl??`https://api.individual.githubcopilot.com`,r=O(e);if(r)return{api:r.api,baseUrl:n,headers:{...I}};try{let n=l(`github-copilot`,e);return{api:n.api,baseUrl:t?.baseUrl??n.baseUrl,headers:{...n.headers??{},...I}}}catch{return null}}function R(e,t){let n=E(),r=n.findIndex(t=>t.id===e);r<0||(n[r]={...n[r],policyState:`unavailable:${t}`},D(n))}function z(e,t){return`GitHub Copilot rejected "${e}" with model_not_supported. This usually means the model isn't included in your Copilot plan (Opus and other premium models require Copilot Pro / Pro+ / Business / Enterprise). Try Claude Sonnet 4.6 or another model that appears in the picker after a fresh login. Original error: ${t}`}function B(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.type!==`error`)return null;if(t.error&&typeof t.error==`object`){let e=t.error.errorMessage;if(typeof e==`string`)return e}return typeof t.errorMessage==`string`?t.errorMessage:null}function V(e){return(t,n,l={})=>{let d=u();return(async()=>{try{let u=await j(),f=L(t.id);if(!f)throw Error(`GitHub Copilot does not recognize "${t.id}" — open the picker (the model list refreshes on login) and pick a current model.`);let p={...t,api:f.api,baseUrl:f.baseUrl,headers:f.headers,provider:`github-copilot`},m={...l,apiKey:u},h;h=f.api===`anthropic-messages`?(e?c:s)(p,n,m):f.api===`openai-responses`?(e?a:i)(p,n,m):(e?o:r)(p,n,m);for await(let e of h){let n=B(e);if(n&&/model_not_supported/i.test(n)){R(t.id,`model_not_supported`);let e=z(t.id,n);console.error(`[github-copilot] Plan-gated model rejection:`,e),d.push(F(t,Error(e))),d.end();return}d.push(e)}d.end()}catch(e){let n=e instanceof Error?e.message:String(e),r=e;/model_not_supported/i.test(n)&&(R(t.id,`model_not_supported`),r=Error(z(t.id,n))),console.error(`[github-copilot] Stream error:`,r instanceof Error?r.message:String(r)),d.push(F(t,r)),d.end()}})(),d}}const H=V(!1),U=V(!0),W=({userCode:e,verificationUrl:t})=>typeof document>`u`?(console.info(`[github-copilot] Device verification code: ${e} — open ${t} in a browser to authorize.`),Promise.resolve(`continue`)):new Promise(t=>{let n=document.createElement(`div`);n.setAttribute(`data-slicc-overlay`,`github-copilot-device`),n.style.cssText=[`position:fixed`,`top:24px`,`right:24px`,`z-index:2147483647`,`background:#0d1117`,`color:#e6edf3`,`border:1px solid #30363d`,`border-radius:10px`,`padding:16px 18px`,`box-shadow:0 8px 32px rgba(0,0,0,0.45)`,`font:13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,`min-width:260px`,`max-width:340px`].join(`;`);let r=document.createElement(`div`);r.textContent=`GitHub Copilot — verification code`,r.style.cssText=`font-weight:600;margin-bottom:8px;color:#7ee787`;let i=document.createElement(`div`);i.textContent=e,i.style.cssText=[`font:600 22px ui-monospace, SFMono-Regular, Menlo, monospace`,`letter-spacing:2px`,`background:#161b22`,`border:1px solid #30363d`,`border-radius:6px`,`padding:10px 12px`,`text-align:center`,`margin-bottom:10px`,`user-select:all`,`cursor:text`].join(`;`);let a=document.createElement(`div`);a.style.cssText=`color:#8b949e;font-size:12px;line-height:1.5`,a.textContent=`Copy the code, then click Continue to open the GitHub authorization page in a new tab.`;let o=document.createElement(`div`);o.style.cssText=`display:flex;gap:8px;margin-top:12px;justify-content:flex-end`;let s=document.createElement(`button`);s.type=`button`,s.textContent=`Cancel`,s.style.cssText=[`background:transparent`,`color:#e6edf3`,`border:1px solid #30363d`,`border-radius:6px`,`padding:6px 12px`,`font:600 12px inherit`,`cursor:pointer`].join(`;`);let c=document.createElement(`button`);c.type=`button`,c.textContent=`Copy & Continue`,c.style.cssText=[`background:#238636`,`color:#fff`,`border:0`,`border-radius:6px`,`padding:6px 12px`,`font:600 12px inherit`,`cursor:pointer`].join(`;`);let l=()=>{try{n.remove()}catch{}};s.addEventListener(`click`,()=>{l(),t(`cancel`)}),c.addEventListener(`click`,()=>{(async()=>{try{let{copyTextToClipboard:t}=await import(`./clipboard-C2cR8flR.js`).then(e=>e.t);await t(e)}catch{}l(),t(`continue`)})()}),o.appendChild(s),o.appendChild(c),n.appendChild(r),n.appendChild(i),n.appendChild(a),n.appendChild(o),document.body.appendChild(n)}),G={id:f,name:`GitHub Copilot`,description:`Use your GitHub Copilot subscription to access Claude, GPT-5, Codex, Gemini, and Grok models. Sign in with the GitHub device-code flow.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`claude-sonnet-4.6`,oauthTokenDomains:[`*.githubcopilot.com`,`api.individual.githubcopilot.com`,`api.business.githubcopilot.com`,`api.enterprise.githubcopilot.com`],getModelIds:P,onOAuthLoginIntercepted:async(e,t,n)=>{let r=await _(),i=new URL(r.verification_uri);if(i.searchParams.set(`user_code`,r.user_code),await(n?.presentDeviceCode??W)({userCode:r.user_code,verificationUrl:i.toString(),expiresInSeconds:r.expires_in})===`cancel`)throw Error(`GitHub Copilot login cancelled`);let a=new AbortController,o=e({authorizeUrl:i.toString(),redirectUriPattern:`https://github.com/login/device/success*`,onCapture:`close`,timeoutMs:r.expires_in*1e3}).catch(e=>(console.warn(`[github-copilot] Launcher failed:`,e instanceof Error?e.message:String(e)),null)),s;try{s=await v(r,a.signal)}catch(e){throw a.abort(),await o,e}await o;let c=await x(s),l;try{let e=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${s}`,Accept:`application/json`}});if(e.ok){let t=await e.json();l=t.name||t.login}}catch{}await A(c,l),await k(c),t()},onOAuthLogout:async()=>{await e({providerId:f,accessToken:``})},onSilentRenew:async()=>{let e=g();if(!e?.refreshToken)return null;try{let t=await x(e.refreshToken);return await A(t,e.userName),await k(t),t.copilotToken}catch(e){return console.warn(`[github-copilot] Silent renew failed:`,e instanceof Error?e.message:String(e)),null}}};function K(){n({api:`github-copilot-anthropic`,stream:H,streamSimple:U}),n({api:`github-copilot-openai`,stream:H,streamSimple:U})}export{G as config,N as isCopilotConeCompatible,K as register};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/clipboard-DgFtRQbq.js","assets/chunk-aKtaBQYM.js"])))=>i.map(i=>d[i]);
2
- import{c as e,f as t,l as n,m as r,o as i,p as a,u as o}from"./bedrock-camp-CWvhREqw.js";import{t as s}from"./preload-helper-zJ_50EbN.js";import{l as c,o as l,u}from"./transform-messages-B3Q-Bwv-.js";import{$ as d,W as f}from"./main-DQNfRwQ_.js";var p=`github-copilot`,m=atob(`SXYxLmI1MDdhMDhjODdlY2ZlOTg=`),h=`https://github.com/login/device/code`,g=`https://github.com/login/oauth/access_token`,_=`https://api.github.com/copilot_internal/v2/token`,v={Accept:`application/json`,"Editor-Version":`vscode/1.107.0`,"Editor-Plugin-Version":`copilot-chat/0.35.0`,"Copilot-Integration-Id":`vscode-chat`},y={Accept:`application/json`,"Content-Type":`application/x-www-form-urlencoded`},b=`https://github.com/login/device/success*`;function x(){return f().find(e=>e.providerId===p)}async function S(){let e=await fetch(h,{method:`POST`,headers:y,body:new URLSearchParams({client_id:m,scope:`read:user`})});if(!e.ok)throw Error(`GitHub device-code request failed: ${e.status} ${e.statusText} — ${await e.text().catch(()=>``)}`);let t=await e.json();if(typeof t.device_code!=`string`||typeof t.user_code!=`string`||typeof t.verification_uri!=`string`||typeof t.expires_in!=`number`||typeof t.interval!=`number`)throw Error(`GitHub device-code response had an unexpected shape`);return t}async function C(e,t){let n=Date.now()+e.expires_in*1e3,r=Math.max(1e3,Math.floor(e.interval*1e3)),i=1.2;for(;Date.now()<n;){if(t.aborted)throw Error(`Copilot login cancelled`);await w(Math.ceil(r*i),t);let n=await fetch(g,{method:`POST`,headers:y,body:new URLSearchParams({client_id:m,device_code:e.device_code,grant_type:`urn:ietf:params:oauth:grant-type:device_code`})});if(!n.ok)throw Error(`GitHub token poll failed: ${n.status} ${n.statusText} — ${await n.text().catch(()=>``)}`);let a=await n.json();if(typeof a.access_token==`string`&&a.access_token.length>0)return a.access_token;if(a.error!==`authorization_pending`){if(a.error===`slow_down`){r=typeof a.interval==`number`?a.interval*1e3:r+5e3,i=1.4;continue}if(a.error){let e=a.error_description?`: ${a.error_description}`:``;throw Error(`Device flow failed (${a.error})${e}`)}}}throw Error(`Copilot device flow timed out (device code expired)`)}function w(e,t){return new Promise((n,r)=>{if(t.aborted){r(Error(`Copilot login cancelled`));return}let i=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Copilot login cancelled`))},{once:!0})})}function T(e){let t=e.match(/proxy-ep=([^;]+)/);return t?`https://${t[1].replace(/^proxy\./,`api.`)}`:null}async function E(e){let t=await fetch(_,{headers:{...v,Authorization:`Bearer ${e}`}});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`Copilot token exchange failed: ${t.status} ${t.statusText} — ${e.slice(0,300)}`)}let n=await t.json();if(typeof n.token!=`string`||typeof n.expires_at!=`number`)throw Error(`Copilot token exchange returned an unexpected payload`);if(n.chat_enabled===!1)throw Error(`GitHub Copilot Chat is disabled for this account (no chat features granted)`);return{copilotToken:n.token,expiresAtMs:n.expires_at*1e3-300*1e3,apiBaseUrl:T(n.token)??`https://api.individual.githubcopilot.com`,githubAccessToken:e}}var D=`github-copilot.models.v1`;function O(e){let t=e.supported_endpoints??[],n=(e.vendor??``).toLowerCase(),r=e.id;return n===`anthropic`&&t.includes(`/v1/messages`)?`anthropic-messages`:n===`openai`&&(/^gpt-5/i.test(r)||/codex/i.test(r)||/^o\d/i.test(r))?`openai-responses`:`openai-completions`}function k(e){if(!e||typeof e!=`object`)return[];let t=e.data;if(!Array.isArray(t))return[];let n=[];for(let e of t)e.capabilities?.type&&e.capabilities.type!==`chat`||e.model_picker_enabled!==!1&&e.id&&n.push({id:e.id,name:e.name??e.id,vendor:e.vendor??``,api:O(e),contextWindow:e.capabilities?.limits?.max_context_window_tokens??e.capabilities?.limits?.max_prompt_tokens??128e3,maxTokens:e.capabilities?.limits?.max_output_tokens??8192,supportsTools:e.capabilities?.supports?.tool_calls===!0,supportsStreaming:e.capabilities?.supports?.streaming!==!1,supportsVision:e.capabilities?.supports?.vision===!0,supportsReasoning:e.capabilities?.supports?.adaptive_thinking===!0||Array.isArray(e.capabilities?.supports?.reasoning_effort),policyState:e.policy?.state??`enabled`});return n}async function A(e){let t=await fetch(`${e.apiBaseUrl}/models`,{headers:{...v,Authorization:`Bearer ${e.copilotToken}`,Accept:`application/json`}});if(!t.ok)throw Error(`Copilot /models returned ${t.status} ${t.statusText}`);return k(await t.json())}function j(){if(typeof localStorage>`u`)return[];try{let e=localStorage.getItem(D);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function M(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(D,JSON.stringify(e))}catch{}}function N(e){return j().find(t=>t.id===e)??null}async function P(e){let t;try{t=await A(e)}catch(e){console.warn(`[github-copilot] Catalog refresh failed; keeping previous cache.`,e instanceof Error?e.message:String(e));return}M(t),await Promise.all(t.filter(e=>e.policyState===`disabled`).map(async t=>{let n=`${e.apiBaseUrl}/models/${encodeURIComponent(t.id)}/policy`;try{let r=await fetch(n,{method:`POST`,headers:{...v,"Content-Type":`application/json`,Authorization:`Bearer ${e.copilotToken}`,"openai-intent":`chat-policy`,"x-interaction-type":`chat-policy`},body:JSON.stringify({state:`enabled`})});r.ok?t.policyState=`enabled`:r.status!==404&&r.status!==400&&console.warn(`[github-copilot] enable policy for ${t.id} returned ${r.status} ${r.statusText}`)}catch(e){console.warn(`[github-copilot] enable policy for ${t.id} failed:`,e instanceof Error?e.message:String(e))}})),M(t)}async function F(e,t){await d({providerId:p,accessToken:e.copilotToken,refreshToken:e.githubAccessToken,tokenExpiresAt:e.expiresAtMs,baseUrl:e.apiBaseUrl,userName:t})}async function I(){let e=x();if(!e?.accessToken||!e.refreshToken)throw Error(`Not logged in to GitHub Copilot — click "Login" in the provider settings`);let t=e.tokenExpiresAt??0;if(Date.now()<t-6e4)return e.accessToken;let n=await E(e.refreshToken);return await F(n,e.userName),n.copilotToken}var L=[`mini`,`nano`,`flash`,`haiku`,`lite`,`embedding`];function R(e){let t=[e.id,e.name??``].flatMap(e=>{let t=e.toLowerCase();return[t,t.replace(/[\s_.:]+/g,`-`)]});return!L.some(e=>t.some(t=>t.includes(e)))}function z(){if(!x()?.accessToken)return[];let e=j();if(e.length>0)return e.filter(e=>!e.policyState.startsWith(`unavailable:`)).filter(e=>R(e)).map(e=>({id:e.id,name:e.name,api:e.api===`anthropic-messages`?`anthropic`:`openai`,context_window:e.contextWindow,max_tokens:e.maxTokens,reasoning:e.supportsReasoning,input:e.supportsVision?[`text`,`image`]:[`text`]}));let t;try{t=u(`github-copilot`)}catch{return[]}return t.filter(e=>R({id:e.id,name:e.name})).map(e=>({id:e.id,name:e.name??e.id,api:e.api===`anthropic-messages`?`anthropic`:`openai`,context_window:e.contextWindow,max_tokens:e.maxTokens,reasoning:e.reasoning,input:e.input}))}function B(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:e.api,provider:p,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}var V={"User-Agent":`GitHubCopilotChat/0.35.0`,"Editor-Version":`vscode/1.107.0`,"Editor-Plugin-Version":`copilot-chat/0.35.0`,"Copilot-Integration-Id":`vscode-chat`};function H(e){let t=x(),n=t?.baseUrl??`https://api.individual.githubcopilot.com`,r=N(e);if(r)return{api:r.api,baseUrl:n,headers:{...V}};try{let n=c(`github-copilot`,e);return{api:n.api,baseUrl:t?.baseUrl??n.baseUrl,headers:{...n.headers??{},...V}}}catch{return null}}function U(e,t){let n=j(),r=n.findIndex(t=>t.id===e);r<0||(n[r]={...n[r],policyState:`unavailable:${t}`},M(n))}function W(e,t){return`GitHub Copilot rejected "${e}" with model_not_supported. This usually means the model isn't included in your Copilot plan (Opus and other premium models require Copilot Pro / Pro+ / Business / Enterprise). Try Claude Sonnet 4.6 or another model that appears in the picker after a fresh login. Original error: ${t}`}function G(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.type!==`error`)return null;if(t.error&&typeof t.error==`object`){let e=t.error.errorMessage;if(typeof e==`string`)return e}return typeof t.errorMessage==`string`?t.errorMessage:null}function K(r){return(s,c,u={})=>{let d=l();return(async()=>{try{let l=await I(),f=H(s.id);if(!f)throw Error(`GitHub Copilot does not recognize "${s.id}" — open the picker (the model list refreshes on login) and pick a current model.`);let p={...s,api:f.api,baseUrl:f.baseUrl,headers:f.headers,provider:`github-copilot`},m={...u,apiKey:l},h;h=f.api===`anthropic-messages`?(r?o:i)(p,c,m):f.api===`openai-responses`?(r?a:n)(p,c,m):(r?t:e)(p,c,m);for await(let e of h){let t=G(e);if(t&&/model_not_supported/i.test(t)){U(s.id,`model_not_supported`);let e=W(s.id,t);console.error(`[github-copilot] Plan-gated model rejection:`,e),d.push(B(s,Error(e))),d.end();return}d.push(e)}d.end()}catch(e){let t=e instanceof Error?e.message:String(e),n=e;/model_not_supported/i.test(t)&&(U(s.id,`model_not_supported`),n=Error(W(s.id,t))),console.error(`[github-copilot] Stream error:`,n instanceof Error?n.message:String(n)),d.push(B(s,n)),d.end()}})(),d}}var q=K(!1),J=K(!0),Y=({userCode:e,verificationUrl:t})=>typeof document>`u`?(console.info(`[github-copilot] Device verification code: ${e} — open ${t} in a browser to authorize.`),Promise.resolve(`continue`)):new Promise(t=>{let n=document.createElement(`div`);n.setAttribute(`data-slicc-overlay`,`github-copilot-device`),n.style.cssText=[`position:fixed`,`top:24px`,`right:24px`,`z-index:2147483647`,`background:#0d1117`,`color:#e6edf3`,`border:1px solid #30363d`,`border-radius:10px`,`padding:16px 18px`,`box-shadow:0 8px 32px rgba(0,0,0,0.45)`,`font:13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,`min-width:260px`,`max-width:340px`].join(`;`);let r=document.createElement(`div`);r.textContent=`GitHub Copilot — verification code`,r.style.cssText=`font-weight:600;margin-bottom:8px;color:#7ee787`;let i=document.createElement(`div`);i.textContent=e,i.style.cssText=[`font:600 22px ui-monospace, SFMono-Regular, Menlo, monospace`,`letter-spacing:2px`,`background:#161b22`,`border:1px solid #30363d`,`border-radius:6px`,`padding:10px 12px`,`text-align:center`,`margin-bottom:10px`,`user-select:all`,`cursor:text`].join(`;`);let a=document.createElement(`div`);a.style.cssText=`color:#8b949e;font-size:12px;line-height:1.5`,a.textContent=`Copy the code, then click Continue to open the GitHub authorization page in a new tab.`;let o=document.createElement(`div`);o.style.cssText=`display:flex;gap:8px;margin-top:12px;justify-content:flex-end`;let c=document.createElement(`button`);c.type=`button`,c.textContent=`Cancel`,c.style.cssText=[`background:transparent`,`color:#e6edf3`,`border:1px solid #30363d`,`border-radius:6px`,`padding:6px 12px`,`font:600 12px inherit`,`cursor:pointer`].join(`;`);let l=document.createElement(`button`);l.type=`button`,l.textContent=`Copy & Continue`,l.style.cssText=[`background:#238636`,`color:#fff`,`border:0`,`border-radius:6px`,`padding:6px 12px`,`font:600 12px inherit`,`cursor:pointer`].join(`;`);let u=()=>{try{n.remove()}catch{}};c.addEventListener(`click`,()=>{u(),t(`cancel`)}),l.addEventListener(`click`,()=>{(async()=>{try{let{copyTextToClipboard:t}=await s(async()=>{let{copyTextToClipboard:e}=await import(`./clipboard-DgFtRQbq.js`).then(e=>e.t);return{copyTextToClipboard:e}},__vite__mapDeps([0,1]));await t(e)}catch{}u(),t(`continue`)})()}),o.appendChild(c),o.appendChild(l),n.appendChild(r),n.appendChild(i),n.appendChild(a),n.appendChild(o),document.body.appendChild(n)}),X={id:p,name:`GitHub Copilot`,description:`Use your GitHub Copilot subscription to access Claude, GPT-5, Codex, Gemini, and Grok models. Sign in with the GitHub device-code flow.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`claude-sonnet-4.6`,oauthTokenDomains:[`*.githubcopilot.com`,`api.individual.githubcopilot.com`,`api.business.githubcopilot.com`,`api.enterprise.githubcopilot.com`],getModelIds:z,onOAuthLoginIntercepted:async(e,t,n)=>{let r=await S(),i=new URL(r.verification_uri);if(i.searchParams.set(`user_code`,r.user_code),await(n?.presentDeviceCode??Y)({userCode:r.user_code,verificationUrl:i.toString(),expiresInSeconds:r.expires_in})===`cancel`)throw Error(`GitHub Copilot login cancelled`);let a=new AbortController,o=e({authorizeUrl:i.toString(),redirectUriPattern:b,onCapture:`close`,timeoutMs:r.expires_in*1e3}).catch(e=>(console.warn(`[github-copilot] Launcher failed:`,e instanceof Error?e.message:String(e)),null)),s;try{s=await C(r,a.signal)}catch(e){throw a.abort(),await o,e}await o;let c=await E(s),l;try{let e=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${s}`,Accept:`application/json`}});if(e.ok){let t=await e.json();l=t.name||t.login}}catch{}await F(c,l),await P(c),t()},onOAuthLogout:async()=>{await d({providerId:p,accessToken:``})},onSilentRenew:async()=>{let e=x();if(!e?.refreshToken)return null;try{let t=await E(e.refreshToken);return await F(t,e.userName),await P(t),t.copilotToken}catch(e){return console.warn(`[github-copilot] Silent renew failed:`,e instanceof Error?e.message:String(e)),null}}};function Z(){r({api:`github-copilot-anthropic`,stream:q,streamSimple:J}),r({api:`github-copilot-openai`,stream:q,streamSimple:J})}export{X as config,R as isCopilotConeCompatible,Z as register};
2
+ import{c as e,f as t,l as n,m as r,o as i,p as a,u as o}from"./bedrock-camp-CWvhREqw.js";import{t as s}from"./preload-helper-zJ_50EbN.js";import{l as c,o as l,u}from"./transform-messages-B3Q-Bwv-.js";import{$ as d,W as f}from"./main-BAt3GJms.js";var p=`github-copilot`,m=atob(`SXYxLmI1MDdhMDhjODdlY2ZlOTg=`),h=`https://github.com/login/device/code`,g=`https://github.com/login/oauth/access_token`,_=`https://api.github.com/copilot_internal/v2/token`,v={Accept:`application/json`,"Editor-Version":`vscode/1.107.0`,"Editor-Plugin-Version":`copilot-chat/0.35.0`,"Copilot-Integration-Id":`vscode-chat`},y={Accept:`application/json`,"Content-Type":`application/x-www-form-urlencoded`},b=`https://github.com/login/device/success*`;function x(){return f().find(e=>e.providerId===p)}async function S(){let e=await fetch(h,{method:`POST`,headers:y,body:new URLSearchParams({client_id:m,scope:`read:user`})});if(!e.ok)throw Error(`GitHub device-code request failed: ${e.status} ${e.statusText} — ${await e.text().catch(()=>``)}`);let t=await e.json();if(typeof t.device_code!=`string`||typeof t.user_code!=`string`||typeof t.verification_uri!=`string`||typeof t.expires_in!=`number`||typeof t.interval!=`number`)throw Error(`GitHub device-code response had an unexpected shape`);return t}async function C(e,t){let n=Date.now()+e.expires_in*1e3,r=Math.max(1e3,Math.floor(e.interval*1e3)),i=1.2;for(;Date.now()<n;){if(t.aborted)throw Error(`Copilot login cancelled`);await w(Math.ceil(r*i),t);let n=await fetch(g,{method:`POST`,headers:y,body:new URLSearchParams({client_id:m,device_code:e.device_code,grant_type:`urn:ietf:params:oauth:grant-type:device_code`})});if(!n.ok)throw Error(`GitHub token poll failed: ${n.status} ${n.statusText} — ${await n.text().catch(()=>``)}`);let a=await n.json();if(typeof a.access_token==`string`&&a.access_token.length>0)return a.access_token;if(a.error!==`authorization_pending`){if(a.error===`slow_down`){r=typeof a.interval==`number`?a.interval*1e3:r+5e3,i=1.4;continue}if(a.error){let e=a.error_description?`: ${a.error_description}`:``;throw Error(`Device flow failed (${a.error})${e}`)}}}throw Error(`Copilot device flow timed out (device code expired)`)}function w(e,t){return new Promise((n,r)=>{if(t.aborted){r(Error(`Copilot login cancelled`));return}let i=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Copilot login cancelled`))},{once:!0})})}function T(e){let t=e.match(/proxy-ep=([^;]+)/);return t?`https://${t[1].replace(/^proxy\./,`api.`)}`:null}async function E(e){let t=await fetch(_,{headers:{...v,Authorization:`Bearer ${e}`}});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`Copilot token exchange failed: ${t.status} ${t.statusText} — ${e.slice(0,300)}`)}let n=await t.json();if(typeof n.token!=`string`||typeof n.expires_at!=`number`)throw Error(`Copilot token exchange returned an unexpected payload`);if(n.chat_enabled===!1)throw Error(`GitHub Copilot Chat is disabled for this account (no chat features granted)`);return{copilotToken:n.token,expiresAtMs:n.expires_at*1e3-300*1e3,apiBaseUrl:T(n.token)??`https://api.individual.githubcopilot.com`,githubAccessToken:e}}var D=`github-copilot.models.v1`;function O(e){let t=e.supported_endpoints??[],n=(e.vendor??``).toLowerCase(),r=e.id;return n===`anthropic`&&t.includes(`/v1/messages`)?`anthropic-messages`:n===`openai`&&(/^gpt-5/i.test(r)||/codex/i.test(r)||/^o\d/i.test(r))?`openai-responses`:`openai-completions`}function k(e){if(!e||typeof e!=`object`)return[];let t=e.data;if(!Array.isArray(t))return[];let n=[];for(let e of t)e.capabilities?.type&&e.capabilities.type!==`chat`||e.model_picker_enabled!==!1&&e.id&&n.push({id:e.id,name:e.name??e.id,vendor:e.vendor??``,api:O(e),contextWindow:e.capabilities?.limits?.max_context_window_tokens??e.capabilities?.limits?.max_prompt_tokens??128e3,maxTokens:e.capabilities?.limits?.max_output_tokens??8192,supportsTools:e.capabilities?.supports?.tool_calls===!0,supportsStreaming:e.capabilities?.supports?.streaming!==!1,supportsVision:e.capabilities?.supports?.vision===!0,supportsReasoning:e.capabilities?.supports?.adaptive_thinking===!0||Array.isArray(e.capabilities?.supports?.reasoning_effort),policyState:e.policy?.state??`enabled`});return n}async function A(e){let t=await fetch(`${e.apiBaseUrl}/models`,{headers:{...v,Authorization:`Bearer ${e.copilotToken}`,Accept:`application/json`}});if(!t.ok)throw Error(`Copilot /models returned ${t.status} ${t.statusText}`);return k(await t.json())}function j(){if(typeof localStorage>`u`)return[];try{let e=localStorage.getItem(D);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function M(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(D,JSON.stringify(e))}catch{}}function N(e){return j().find(t=>t.id===e)??null}async function P(e){let t;try{t=await A(e)}catch(e){console.warn(`[github-copilot] Catalog refresh failed; keeping previous cache.`,e instanceof Error?e.message:String(e));return}M(t),await Promise.all(t.filter(e=>e.policyState===`disabled`).map(async t=>{let n=`${e.apiBaseUrl}/models/${encodeURIComponent(t.id)}/policy`;try{let r=await fetch(n,{method:`POST`,headers:{...v,"Content-Type":`application/json`,Authorization:`Bearer ${e.copilotToken}`,"openai-intent":`chat-policy`,"x-interaction-type":`chat-policy`},body:JSON.stringify({state:`enabled`})});r.ok?t.policyState=`enabled`:r.status!==404&&r.status!==400&&console.warn(`[github-copilot] enable policy for ${t.id} returned ${r.status} ${r.statusText}`)}catch(e){console.warn(`[github-copilot] enable policy for ${t.id} failed:`,e instanceof Error?e.message:String(e))}})),M(t)}async function F(e,t){await d({providerId:p,accessToken:e.copilotToken,refreshToken:e.githubAccessToken,tokenExpiresAt:e.expiresAtMs,baseUrl:e.apiBaseUrl,userName:t})}async function I(){let e=x();if(!e?.accessToken||!e.refreshToken)throw Error(`Not logged in to GitHub Copilot — click "Login" in the provider settings`);let t=e.tokenExpiresAt??0;if(Date.now()<t-6e4)return e.accessToken;let n=await E(e.refreshToken);return await F(n,e.userName),n.copilotToken}var L=[`mini`,`nano`,`flash`,`haiku`,`lite`,`embedding`];function R(e){let t=[e.id,e.name??``].flatMap(e=>{let t=e.toLowerCase();return[t,t.replace(/[\s_.:]+/g,`-`)]});return!L.some(e=>t.some(t=>t.includes(e)))}function z(){if(!x()?.accessToken)return[];let e=j();if(e.length>0)return e.filter(e=>!e.policyState.startsWith(`unavailable:`)).filter(e=>R(e)).map(e=>({id:e.id,name:e.name,api:e.api===`anthropic-messages`?`anthropic`:`openai`,context_window:e.contextWindow,max_tokens:e.maxTokens,reasoning:e.supportsReasoning,input:e.supportsVision?[`text`,`image`]:[`text`]}));let t;try{t=u(`github-copilot`)}catch{return[]}return t.filter(e=>R({id:e.id,name:e.name})).map(e=>({id:e.id,name:e.name??e.id,api:e.api===`anthropic-messages`?`anthropic`:`openai`,context_window:e.contextWindow,max_tokens:e.maxTokens,reasoning:e.reasoning,input:e.input}))}function B(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:e.api,provider:p,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}var V={"User-Agent":`GitHubCopilotChat/0.35.0`,"Editor-Version":`vscode/1.107.0`,"Editor-Plugin-Version":`copilot-chat/0.35.0`,"Copilot-Integration-Id":`vscode-chat`};function H(e){let t=x(),n=t?.baseUrl??`https://api.individual.githubcopilot.com`,r=N(e);if(r)return{api:r.api,baseUrl:n,headers:{...V}};try{let n=c(`github-copilot`,e);return{api:n.api,baseUrl:t?.baseUrl??n.baseUrl,headers:{...n.headers??{},...V}}}catch{return null}}function U(e,t){let n=j(),r=n.findIndex(t=>t.id===e);r<0||(n[r]={...n[r],policyState:`unavailable:${t}`},M(n))}function W(e,t){return`GitHub Copilot rejected "${e}" with model_not_supported. This usually means the model isn't included in your Copilot plan (Opus and other premium models require Copilot Pro / Pro+ / Business / Enterprise). Try Claude Sonnet 4.6 or another model that appears in the picker after a fresh login. Original error: ${t}`}function G(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.type!==`error`)return null;if(t.error&&typeof t.error==`object`){let e=t.error.errorMessage;if(typeof e==`string`)return e}return typeof t.errorMessage==`string`?t.errorMessage:null}function K(r){return(s,c,u={})=>{let d=l();return(async()=>{try{let l=await I(),f=H(s.id);if(!f)throw Error(`GitHub Copilot does not recognize "${s.id}" — open the picker (the model list refreshes on login) and pick a current model.`);let p={...s,api:f.api,baseUrl:f.baseUrl,headers:f.headers,provider:`github-copilot`},m={...u,apiKey:l},h;h=f.api===`anthropic-messages`?(r?o:i)(p,c,m):f.api===`openai-responses`?(r?a:n)(p,c,m):(r?t:e)(p,c,m);for await(let e of h){let t=G(e);if(t&&/model_not_supported/i.test(t)){U(s.id,`model_not_supported`);let e=W(s.id,t);console.error(`[github-copilot] Plan-gated model rejection:`,e),d.push(B(s,Error(e))),d.end();return}d.push(e)}d.end()}catch(e){let t=e instanceof Error?e.message:String(e),n=e;/model_not_supported/i.test(t)&&(U(s.id,`model_not_supported`),n=Error(W(s.id,t))),console.error(`[github-copilot] Stream error:`,n instanceof Error?n.message:String(n)),d.push(B(s,n)),d.end()}})(),d}}var q=K(!1),J=K(!0),Y=({userCode:e,verificationUrl:t})=>typeof document>`u`?(console.info(`[github-copilot] Device verification code: ${e} — open ${t} in a browser to authorize.`),Promise.resolve(`continue`)):new Promise(t=>{let n=document.createElement(`div`);n.setAttribute(`data-slicc-overlay`,`github-copilot-device`),n.style.cssText=[`position:fixed`,`top:24px`,`right:24px`,`z-index:2147483647`,`background:#0d1117`,`color:#e6edf3`,`border:1px solid #30363d`,`border-radius:10px`,`padding:16px 18px`,`box-shadow:0 8px 32px rgba(0,0,0,0.45)`,`font:13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,`min-width:260px`,`max-width:340px`].join(`;`);let r=document.createElement(`div`);r.textContent=`GitHub Copilot — verification code`,r.style.cssText=`font-weight:600;margin-bottom:8px;color:#7ee787`;let i=document.createElement(`div`);i.textContent=e,i.style.cssText=[`font:600 22px ui-monospace, SFMono-Regular, Menlo, monospace`,`letter-spacing:2px`,`background:#161b22`,`border:1px solid #30363d`,`border-radius:6px`,`padding:10px 12px`,`text-align:center`,`margin-bottom:10px`,`user-select:all`,`cursor:text`].join(`;`);let a=document.createElement(`div`);a.style.cssText=`color:#8b949e;font-size:12px;line-height:1.5`,a.textContent=`Copy the code, then click Continue to open the GitHub authorization page in a new tab.`;let o=document.createElement(`div`);o.style.cssText=`display:flex;gap:8px;margin-top:12px;justify-content:flex-end`;let c=document.createElement(`button`);c.type=`button`,c.textContent=`Cancel`,c.style.cssText=[`background:transparent`,`color:#e6edf3`,`border:1px solid #30363d`,`border-radius:6px`,`padding:6px 12px`,`font:600 12px inherit`,`cursor:pointer`].join(`;`);let l=document.createElement(`button`);l.type=`button`,l.textContent=`Copy & Continue`,l.style.cssText=[`background:#238636`,`color:#fff`,`border:0`,`border-radius:6px`,`padding:6px 12px`,`font:600 12px inherit`,`cursor:pointer`].join(`;`);let u=()=>{try{n.remove()}catch{}};c.addEventListener(`click`,()=>{u(),t(`cancel`)}),l.addEventListener(`click`,()=>{(async()=>{try{let{copyTextToClipboard:t}=await s(async()=>{let{copyTextToClipboard:e}=await import(`./clipboard-DgFtRQbq.js`).then(e=>e.t);return{copyTextToClipboard:e}},__vite__mapDeps([0,1]));await t(e)}catch{}u(),t(`continue`)})()}),o.appendChild(c),o.appendChild(l),n.appendChild(r),n.appendChild(i),n.appendChild(a),n.appendChild(o),document.body.appendChild(n)}),X={id:p,name:`GitHub Copilot`,description:`Use your GitHub Copilot subscription to access Claude, GPT-5, Codex, Gemini, and Grok models. Sign in with the GitHub device-code flow.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`claude-sonnet-4.6`,oauthTokenDomains:[`*.githubcopilot.com`,`api.individual.githubcopilot.com`,`api.business.githubcopilot.com`,`api.enterprise.githubcopilot.com`],getModelIds:z,onOAuthLoginIntercepted:async(e,t,n)=>{let r=await S(),i=new URL(r.verification_uri);if(i.searchParams.set(`user_code`,r.user_code),await(n?.presentDeviceCode??Y)({userCode:r.user_code,verificationUrl:i.toString(),expiresInSeconds:r.expires_in})===`cancel`)throw Error(`GitHub Copilot login cancelled`);let a=new AbortController,o=e({authorizeUrl:i.toString(),redirectUriPattern:b,onCapture:`close`,timeoutMs:r.expires_in*1e3}).catch(e=>(console.warn(`[github-copilot] Launcher failed:`,e instanceof Error?e.message:String(e)),null)),s;try{s=await C(r,a.signal)}catch(e){throw a.abort(),await o,e}await o;let c=await E(s),l;try{let e=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${s}`,Accept:`application/json`}});if(e.ok){let t=await e.json();l=t.name||t.login}}catch{}await F(c,l),await P(c),t()},onOAuthLogout:async()=>{await d({providerId:p,accessToken:``})},onSilentRenew:async()=>{let e=x();if(!e?.refreshToken)return null;try{let t=await E(e.refreshToken);return await F(t,e.userName),await P(t),t.copilotToken}catch(e){return console.warn(`[github-copilot] Silent renew failed:`,e instanceof Error?e.message:String(e)),null}}};function Z(){r({api:`github-copilot-anthropic`,stream:q,streamSimple:J}),r({api:`github-copilot-openai`,stream:q,streamSimple:J})}export{X as config,R as isCopilotConeCompatible,Z as register};