sliccy 6.131.0 → 6.131.2

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 (94) hide show
  1. package/dist/ui/.vite/manifest.json +140 -140
  2. package/dist/ui/assets/{account-store-DsMvFZgS.js → account-store-BcQeOBmj.js} +1 -1
  3. package/dist/ui/assets/{account-store-naVgJKHe.js → account-store-ChQLfZgz.js} +1 -1
  4. package/dist/ui/assets/{adobe-BhZB46bT.js → adobe-D10Mg1h_.js} +1 -1
  5. package/dist/ui/assets/{adobe-sRIQnDEl.js → adobe-DEKdi3oD.js} +1 -1
  6. package/dist/ui/assets/{agent-bridge-DVqU5-sn.js → agent-bridge-Bvzfs8rB.js} +1 -1
  7. package/dist/ui/assets/{apply-layout-dNkV0TEv.js → apply-layout-wFAir12c.js} +1 -1
  8. package/dist/ui/assets/{apps-tzFQ7_KO.js → apps-B97sfmxi.js} +1 -1
  9. package/dist/ui/assets/{azure-openai-B9ZeZZ0T.js → azure-openai-CBu-puRS.js} +1 -1
  10. package/dist/ui/assets/{azure-openai-DsmgiFlX.js → azure-openai-DY2D8FBl.js} +1 -1
  11. package/dist/ui/assets/{cerebras-CsdnfQnc.js → cerebras-C18SmUxs.js} +1 -1
  12. package/dist/ui/assets/{cerebras-Mux-1Uqj.js → cerebras-DRjpuHAs.js} +1 -1
  13. package/dist/ui/assets/{connect-surface-DgrjdeR5.js → connect-surface-DHUhaoge.js} +1 -1
  14. package/dist/ui/assets/{directed-approval-BDO2wdC5.js → directed-approval-fA2Km1F9.js} +1 -1
  15. package/dist/ui/assets/{dist-iMxkf8fm.js → dist-BPZbDBP1.js} +1 -1
  16. package/dist/ui/assets/{dist-DHO9E-gl.js → dist-DOnCyc4g.js} +1 -1
  17. package/dist/ui/assets/{fs-CBaQR8Xc.js → fs-DWYk-XaG.js} +2 -2
  18. package/dist/ui/assets/{fs-CDaCMxrL.js → fs-DWgVdrZr.js} +1 -1
  19. package/dist/ui/assets/{github-B7uOq9Q1.js → github-C5jWaC1B.js} +1 -1
  20. package/dist/ui/assets/{github-qhOhjD2Q.js → github-D0NGzYdm.js} +2 -2
  21. package/dist/ui/assets/{github-copilot-BeWJoZwD.js → github-copilot-7nHjLcI7.js} +1 -1
  22. package/dist/ui/assets/{github-copilot-DwKSI23j.js → github-copilot-Ci9xf6YE.js} +1 -1
  23. package/dist/ui/assets/{github-install-DE7dF6r8.js → github-install-aoLT8eLh.js} +1 -1
  24. package/dist/ui/assets/{github-zip-CuwUOO-U.js → github-zip-q8IzoiWD.js} +1 -1
  25. package/dist/ui/assets/{help-D66VHlYj.js → help-BDi4nJVZ.js} +1 -1
  26. package/dist/ui/assets/icons-ClfjE6Ij.js +1 -0
  27. package/dist/ui/assets/{js-realm-worker-Bsb6rmK5.js → js-realm-worker-BTzYdudb.js} +1 -1
  28. package/dist/ui/assets/{kernel-worker-CkZd8Enf.js → kernel-worker-mpO2ngRI.js} +30 -30
  29. package/dist/ui/assets/{local-llm-B-qS5oNT.js → local-llm-CQkvkABD.js} +1 -1
  30. package/dist/ui/assets/{local-llm-COCS88AU.js → local-llm-DOTvMYuW.js} +1 -1
  31. package/dist/ui/assets/{main-CAXbdHY8.js → main-EFFZWAZj.js} +3 -3
  32. package/dist/ui/assets/{mount-BbUBqN71.js → mount-B9qMwVml.js} +1 -1
  33. package/dist/ui/assets/{mount-ysOnJBjr.js → mount-DXpXq69M.js} +3 -3
  34. package/dist/ui/assets/{mount-recovery-OxgGejDC.js → mount-recovery-DwetnkcN.js} +1 -1
  35. package/dist/ui/assets/{new-session-JIL4tJ1I.js → new-session-D3H9k43E.js} +2 -2
  36. package/dist/ui/assets/{oauth-bootstrap-DP5y5Dy8.js → oauth-bootstrap-BZdvwVda.js} +2 -2
  37. package/dist/ui/assets/{openai-codex-BZDYkVh6.js → openai-codex-BGFoQXPR.js} +1 -1
  38. package/dist/ui/assets/{openai-codex-DlFMWNVB.js → openai-codex-CqCN43Vp.js} +1 -1
  39. package/dist/ui/assets/{openrouter-Dn_iX45f.js → openrouter-CyO_8clr.js} +1 -1
  40. package/dist/ui/assets/{openrouter-BrS9XpJS.js → openrouter-CyuFwjSD.js} +1 -1
  41. package/dist/ui/assets/{openrouter-oauth-D9gZVt7e.js → openrouter-oauth-Bl5DUyyK.js} +1 -1
  42. package/dist/ui/assets/{openrouter-oauth-CioQlp0x.js → openrouter-oauth-ukqAIszR.js} +1 -1
  43. package/dist/ui/assets/{panel-rpc-handlers-DUN0E_f8.js → panel-rpc-handlers-q48hKE-j.js} +2 -2
  44. package/dist/ui/assets/{panelize-shell-KNX1XTnq.js → panelize-shell-n4cz4LHX.js} +1 -1
  45. package/dist/ui/assets/{provider-BfGyOQHs.js → provider-BJTW8Inb.js} +2 -2
  46. package/dist/ui/assets/{provider-DnIZJQjl.js → provider-BiFOaUnO.js} +1 -1
  47. package/dist/ui/assets/provider-settings-D3GCdjWv.js +1 -0
  48. package/dist/ui/assets/{provider-settings-DrWv51sQ.js → provider-settings-DxvegOPb.js} +1 -1
  49. package/dist/ui/assets/{provider-store-access-BqErJhmB.js → provider-store-access-P8QylrtO.js} +2 -2
  50. package/dist/ui/assets/provider-store-access-tUb6KDi9.js +1 -0
  51. package/dist/ui/assets/{providers-CqZKx9qW.js → providers-BvcoVwoV.js} +2 -2
  52. package/dist/ui/assets/{providers-CF2FF0H2.js → providers-nRNq_HqB.js} +1 -1
  53. package/dist/ui/assets/{quick-llm-B9NubAhJ.js → quick-llm-vmNyLwWF.js} +1 -1
  54. package/dist/ui/assets/{recovery-screen-cHPORxsj.js → recovery-screen-D3feoocF.js} +1 -1
  55. package/dist/ui/assets/{run-DZh-18uA.js → run-CAXyjr03.js} +2 -2
  56. package/dist/ui/assets/{run-BOu4zIOZ.js → run-D5UZFh8p.js} +1 -1
  57. package/dist/ui/assets/{run-D5Va_gO8.js → run-R83PHioW.js} +1 -1
  58. package/dist/ui/assets/{session-freezer-Bltt6zUt.js → session-freezer-ChfPSkjG.js} +3 -3
  59. package/dist/ui/assets/{setup-feature-flags-remote-BkP-HRZt.js → setup-feature-flags-remote-B7YsGX1C.js} +1 -1
  60. package/dist/ui/assets/{setup-standalone-prelude-C2tPUGcI.js → setup-standalone-prelude-DMtkl-2o.js} +1 -1
  61. package/dist/ui/assets/{setup-sudo-BSw__xoN.js → setup-sudo-BbqNoR1S.js} +2 -2
  62. package/dist/ui/assets/{skills-wzno5Tj5.js → skills-BkBm2fAz.js} +1 -1
  63. package/dist/ui/assets/slicc-version-B55cSOI0.js +1 -0
  64. package/dist/ui/assets/{snapshot-Bi6QabWh.js → snapshot-CLXWXjqM.js} +1 -1
  65. package/dist/ui/assets/{snapshot-features-BEPdcWF6.js → snapshot-features-qD3Jv7eK.js} +1 -1
  66. package/dist/ui/assets/{src-Bex_z_yH.js → src-CWTsG5Zz.js} +1 -1
  67. package/dist/ui/assets/{state-DIwkpIaB.js → state-Du90LXhH.js} +1 -1
  68. package/dist/ui/assets/{store-i7XHN1Er.js → store-BW6jwedj.js} +1 -1
  69. package/dist/ui/assets/{store-CFx1fIZL.js → store-G_IzwEbI.js} +1 -1
  70. package/dist/ui/assets/{sudo-r7OrTMGT.js → sudo-CiGYbddr.js} +1 -1
  71. package/dist/ui/assets/{sync-dialog-D7Wg49Up.js → sync-dialog-Bpp9Sloe.js} +1 -1
  72. package/dist/ui/assets/{upgrade-detection-Cz0eOMYf.js → upgrade-detection-qaPo2iNP.js} +1 -1
  73. package/dist/ui/assets/{wc-attach-BbT2famN.js → wc-attach-Bmy0D7zx.js} +2 -2
  74. package/dist/ui/assets/{wc-extension-CJ6cvLnw.js → wc-extension-HpEFmEaM.js} +2 -2
  75. package/dist/ui/assets/{wc-float-label-CnFnKVLC.js → wc-float-label-D-EfJUCy.js} +1 -1
  76. package/dist/ui/assets/{wc-follower-CkrdiOKN.js → wc-follower-CaCmbsFC.js} +3 -3
  77. package/dist/ui/assets/{wc-live-CxoqWHpR.js → wc-live-nJl674nq.js} +3 -3
  78. package/dist/ui/assets/{wc-nav-Bnd_bEYw.js → wc-nav-Bnfi20v0.js} +2 -2
  79. package/dist/ui/assets/{wc-onboarding-FeHr2fj5.js → wc-onboarding-yJakorfA.js} +2 -2
  80. package/dist/ui/assets/{wc-placeholder-C79lmtig.js → wc-placeholder-BIs0O5Tv.js} +2 -2
  81. package/dist/ui/assets/{wc-settings-DdAeaZhQ.js → wc-settings-C4sBkTAZ.js} +2 -2
  82. package/dist/ui/assets/{wc-shell-BP3biEU1.js → wc-shell-D0eljkIj.js} +3 -3
  83. package/dist/ui/assets/{wc-sprinkles-ChlcnDD2.js → wc-sprinkles-Dxi8ZWGE.js} +2 -2
  84. package/dist/ui/assets/{wc-tray-BfoqEbBg.js → wc-tray-bViGindn.js} +4 -4
  85. package/dist/ui/assets/{xai-grok-3L0LL1R8.js → xai-grok-BfUF5UgI.js} +1 -1
  86. package/dist/ui/assets/{xai-grok-CKevFY8L.js → xai-grok-BxzPJBhW.js} +1 -1
  87. package/dist/ui/index.html +6 -6
  88. package/dist/ui/lucide-icons.js +190 -186
  89. package/dist/ui/packages/webapp/index.html +6 -6
  90. package/package.json +2 -2
  91. package/dist/ui/assets/icons-BJsliYCh.js +0 -1
  92. package/dist/ui/assets/provider-settings-C6uIHjd4.js +0 -1
  93. package/dist/ui/assets/provider-store-access-BuQzycZu.js +0 -1
  94. package/dist/ui/assets/slicc-version-HwuyIZfW.js +0 -1
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/fs-CBaQR8Xc.js","assets/preload-helper-Czpn1I53.js","assets/logger-DDBAeTLF.js","assets/path-utils-DNJG-zQf.js","assets/bounded-walk-BjxKWNqp.js","assets/types-Dgm4REV3.js","assets/virtual-device-paths-D45tpPP6.js","assets/mount-table-store-dY2IfQ5S.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/sidecar-repair-431vRT2V.js"])))=>i.map(i=>d[i]);
2
- import{H as e,S as t,d as n}from"./account-store-DsMvFZgS.js";import{t as r}from"./preload-helper-Czpn1I53.js";import"./proxied-fetch-CiijUcSt.js";import{r as i,t as a}from"./silent-renew-backoff-SSzHR-oP.js";import{m as o,t as s}from"./tray-runtime-config-BQL-GPqt.js";import{i as c}from"./api-endpoint-DGxXvrur.js";import"./provider-settings-DrWv51sQ.js";import{getOAuthPageOrigin as l,resolveOAuthDelegation as u}from"./oauth-service-t2taQm3p.js";import{t as d}from"./global-db-CbuLl-zx.js";var f={clientId:``,scopes:`repo,read:user,user:email`};function p(){try{let e=localStorage.getItem(o);if(e)return e.replace(/\/$/,``)}catch{}return s}function m(e){return{access_token:e.access_token,token_type:e.token_type,scope:e.scope,refresh_token:e.refresh_token,expires_in:e.expires_in}}async function h(e){let t;try{t=await e.json()}catch{throw Error(`Token exchange failed (HTTP ${e.status}): non-JSON response`)}if(!e.ok&&e.status!==200){let n=t.error_description??t.error??`Token exchange failed (HTTP ${e.status})`;throw Error(n)}if(t.error){let e=t.error_description??t.error;throw Error(e)}return m(t)}async function g(e){let t=`${p()}/oauth/token`;return h(await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,code:e.code,redirect_uri:e.redirectUri})}))}async function _(e){let t=`${p()}/oauth/token`;return h(await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,refresh_token:e.refreshToken})}))}async function v(e){let t=`${p()}/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 y=Object.assign({"/packages/webapp/providers/github-config.json":f})[`/packages/webapp/providers/github-config.json`]??{clientId:``,scopes:`repo,read:user,user:email`},b=null,x=null;function S(e){let{isExtension:t,isConnectMode:n,workerBaseUrl:r,pageOrigin:a,pageHref:o,bridgeApiBaseUrl:s,extensionId:c,nonce:l}=e;if(t)return{redirectUri:`${r}/auth/callback`,state:{source:`extension`,extensionId:c,path:`/github`,nonce:l}};if(e.delegated)return{redirectUri:`${e.runtimeWorkerBaseUrl??r}/auth/callback`,state:{source:`opener`,path:`/auth/callback`,nonce:l}};if(n){let e=a??``;if(/^https?:\/\/(localhost|127\.0\.0\.1):\d+$/.test(e)){let t=parseInt(new URL(o??e).port||`8790`,10);return{redirectUri:`${r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:l}}}return{redirectUri:`${r}/auth/callback`,state:{source:`remote`,origin:e,path:`/auth/callback`,nonce:l}}}if(s&&o&&i(o)){let t=null;try{let e=new URL(s);(e.hostname===`localhost`||e.hostname===`127.0.0.1`)&&(t=parseInt(e.port||`5710`,10))}catch{t=null}if(t!==null&&!Number.isNaN(t))return{redirectUri:`${e.runtimeWorkerBaseUrl??r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:l}}}return{redirectUri:`${e.runtimeWorkerBaseUrl??a??``}/auth/callback`,state:{port:parseInt(new URL(o??a??`http://localhost:5710`).port||`5710`,10),path:`/auth/callback`,nonce:l}}}async function C(){if(b)return b;if(w){try{let e=await fetch(`${p()}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return b=t.oauth.github,b}}catch{}return y.clientId}try{let e=await fetch(`/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return b=t.oauth.github,t.trayWorkerBaseUrl&&(x=t.trayWorkerBaseUrl),b;if(t.trayWorkerBaseUrl){x=t.trayWorkerBaseUrl;let e=await fetch(`${t.trayWorkerBaseUrl}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return b=t.oauth.github,b}}}}catch{}return y.clientId}var w=typeof globalThis<`u`&&typeof globalThis.chrome?.runtime?.id==`string`;function T(){return n().find(e=>e.providerId===`github`)}function E(e){try{return new URL(e).searchParams.get(`code`)}catch{return null}}async function D(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 O(e,t){return`${e}+${t}@users.noreply.github.com`}async function k(e){try{let{VirtualFS:t}=await r(async()=>{let{VirtualFS:e}=await import(`./fs-CBaQR8Xc.js`);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));await(await t.create({dbName:d})).writeFile(`/workspace/.git/github-token`,e),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 A(){try{let{VirtualFS:e}=await r(async()=>{let{VirtualFS:e}=await import(`./fs-CBaQR8Xc.js`);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));await(await e.create({dbName:d})).rm(`/workspace/.git/github-token`),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch{}}async function j(e){if(!(!e.login||e.id===void 0))try{let{VirtualFS:t}=await r(async()=>{let{VirtualFS:e}=await import(`./fs-CBaQR8Xc.js`);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),{readGlobalGitConfigValue:n,writeGlobalGitConfigValue:i}=await r(async()=>{let{readGlobalGitConfigValue:e,writeGlobalGitConfigValue:t}=await import(`./git-config-D2u6LGfT.js`);return{readGlobalGitConfigValue:e,writeGlobalGitConfigValue:t}},[]),a=await t.create({dbName:d}),o=e.name||e.login,s=O(e.id,e.login);!await n(a,`user.name`)&&o&&await i(a,`user.name`,o),await n(a,`user.email`)||await i(a,`user.email`,s)}catch(e){console.warn(`[github] Failed to seed git identity:`,e instanceof Error?e.message:String(e))}}var M=a();async function N(){try{let n=T();if(!n?.refreshToken)return null;let r=await _({provider:`github`,refreshToken:n.refreshToken});await e({providerId:`github`,accessToken:r.access_token,refreshToken:r.refresh_token,tokenExpiresAt:r.expires_in?Date.now()+r.expires_in*1e3:void 0,userName:n.userName,userAvatar:n.userAvatar,scopes:r.scope??n.scopes});let i=t(`github`)?.maskedValue;return i?await k(i):await A(),r.access_token}catch(e){return console.warn(`[github] Silent renewal failed:`,e instanceof Error?e.message:String(e)),null}}var P=1e4;async function F(){let e=T()?.accessToken;if(!e)return{status:`unknown`,detail:`no stored token`};try{let t=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${e}`,Accept:`application/vnd.github+json`},signal:AbortSignal.timeout(P)});if(t.ok){let e=await t.json().catch(()=>({}));return{status:`accepted`,userName:e.name||e.login}}return I(t)}catch(e){return{status:`unknown`,detail:e instanceof Error?e.message:String(e)}}}function I(e){let t=`HTTP ${e.status}${e.statusText?` ${e.statusText}`:``}`;return e.status===401?{status:`rejected`,detail:t}:e.status===403&&L(e)?{status:`unknown`,detail:`${t} (rate limited)`}:{status:`unknown`,detail:t}}function L(e){return e.headers.get(`x-ratelimit-remaining`)===`0`||e.headers.has(`retry-after`)}async function R(){let e=t(`github`)?.maskedValue;e&&await k(e)}async function z(){let e=T();if(!e?.accessToken)throw Error(`Not logged in to GitHub — please log in first`);if((e.tokenExpiresAt??1/0)-Date.now()>6e4)return await R(),e.accessToken;let t=await M.run(()=>N());if(t)return t;let n=T();if((n?.tokenExpiresAt??1/0)-Date.now()>0&&n?.accessToken)return await R(),n.accessToken;throw Error(`GitHub session expired — please log in again`)}var B={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(n,r,i)=>{let a=await C();if(!a)throw Error(`GitHub OAuth not configured — no client ID available`);let o=i?.scopes??y.scopes,s=w?null:await l(),d=!w&&await u(),f=crypto.randomUUID(),m=w?chrome.runtime.id:``,{redirectUri:h,state:_}=S({isExtension:w,isConnectMode:!!globalThis.__slicc_connect_mode,workerBaseUrl:p(),runtimeWorkerBaseUrl:x,pageOrigin:s?.origin??null,pageHref:s?.href??null,bridgeApiBaseUrl:c(),delegated:d,extensionId:m,nonce:f}),v=btoa(JSON.stringify(_)),b=f,T=new URLSearchParams({client_id:a,scope:o,redirect_uri:h});v&&T.set(`state`,v);let O=await n(`https://github.com/login/oauth/authorize?${T}`);if(!O)return;if(b)try{if(new URL(O).searchParams.get(`nonce`)!==b){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 M=E(O);if(!M){console.error(`[github] Could not extract authorization code from redirect URL`);return}let N=await g({provider:`github`,code:M,redirectUri:h}),P=await D(N.access_token);await e({providerId:`github`,accessToken:N.access_token,refreshToken:N.refresh_token,tokenExpiresAt:N.expires_in?Date.now()+N.expires_in*1e3:void 0,userName:P.name,userAvatar:P.avatar,scopes:N.scope});let F=t(`github`)?.maskedValue;F?await k(F):await A(),await j(P),r()},onSilentRenew:N,onValidateToken:F,getValidAccessToken:z,onOAuthLogout:async()=>{let t=T();t?.accessToken&&await v({provider:`github`,accessToken:t.accessToken}).catch(e=>console.warn(`[github] Token revocation failed:`,e instanceof Error?e.message:String(e))),await A(),await e({providerId:`github`,accessToken:``})},getOAuthLogoutUrl:e=>`https://github.com/logout`};export{O as buildNoreplyEmail,B as config,E as extractCodeFromUrl,z as getValidAccessToken,S as resolveGithubOAuthRedirect,j as syncGitIdentityFromGitHub};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/fs-DWYk-XaG.js","assets/preload-helper-Czpn1I53.js","assets/logger-DDBAeTLF.js","assets/path-utils-DNJG-zQf.js","assets/bounded-walk-BjxKWNqp.js","assets/types-Dgm4REV3.js","assets/virtual-device-paths-D45tpPP6.js","assets/mount-table-store-dY2IfQ5S.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/sidecar-repair-431vRT2V.js"])))=>i.map(i=>d[i]);
2
+ import{H as e,S as t,d as n}from"./account-store-BcQeOBmj.js";import{t as r}from"./preload-helper-Czpn1I53.js";import"./proxied-fetch-CiijUcSt.js";import{r as i,t as a}from"./silent-renew-backoff-SSzHR-oP.js";import{m as o,t as s}from"./tray-runtime-config-BQL-GPqt.js";import{i as c}from"./api-endpoint-DGxXvrur.js";import"./provider-settings-DxvegOPb.js";import{getOAuthPageOrigin as l,resolveOAuthDelegation as u}from"./oauth-service-t2taQm3p.js";import{t as d}from"./global-db-CbuLl-zx.js";var f={clientId:``,scopes:`repo,read:user,user:email`};function p(){try{let e=localStorage.getItem(o);if(e)return e.replace(/\/$/,``)}catch{}return s}function m(e){return{access_token:e.access_token,token_type:e.token_type,scope:e.scope,refresh_token:e.refresh_token,expires_in:e.expires_in}}async function h(e){let t;try{t=await e.json()}catch{throw Error(`Token exchange failed (HTTP ${e.status}): non-JSON response`)}if(!e.ok&&e.status!==200){let n=t.error_description??t.error??`Token exchange failed (HTTP ${e.status})`;throw Error(n)}if(t.error){let e=t.error_description??t.error;throw Error(e)}return m(t)}async function g(e){let t=`${p()}/oauth/token`;return h(await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,code:e.code,redirect_uri:e.redirectUri})}))}async function _(e){let t=`${p()}/oauth/token`;return h(await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,refresh_token:e.refreshToken})}))}async function v(e){let t=`${p()}/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 y=Object.assign({"/packages/webapp/providers/github-config.json":f})[`/packages/webapp/providers/github-config.json`]??{clientId:``,scopes:`repo,read:user,user:email`},b=null,x=null;function S(e){let{isExtension:t,isConnectMode:n,workerBaseUrl:r,pageOrigin:a,pageHref:o,bridgeApiBaseUrl:s,extensionId:c,nonce:l}=e;if(t)return{redirectUri:`${r}/auth/callback`,state:{source:`extension`,extensionId:c,path:`/github`,nonce:l}};if(e.delegated)return{redirectUri:`${e.runtimeWorkerBaseUrl??r}/auth/callback`,state:{source:`opener`,path:`/auth/callback`,nonce:l}};if(n){let e=a??``;if(/^https?:\/\/(localhost|127\.0\.0\.1):\d+$/.test(e)){let t=parseInt(new URL(o??e).port||`8790`,10);return{redirectUri:`${r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:l}}}return{redirectUri:`${r}/auth/callback`,state:{source:`remote`,origin:e,path:`/auth/callback`,nonce:l}}}if(s&&o&&i(o)){let t=null;try{let e=new URL(s);(e.hostname===`localhost`||e.hostname===`127.0.0.1`)&&(t=parseInt(e.port||`5710`,10))}catch{t=null}if(t!==null&&!Number.isNaN(t))return{redirectUri:`${e.runtimeWorkerBaseUrl??r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:l}}}return{redirectUri:`${e.runtimeWorkerBaseUrl??a??``}/auth/callback`,state:{port:parseInt(new URL(o??a??`http://localhost:5710`).port||`5710`,10),path:`/auth/callback`,nonce:l}}}async function C(){if(b)return b;if(w){try{let e=await fetch(`${p()}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return b=t.oauth.github,b}}catch{}return y.clientId}try{let e=await fetch(`/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return b=t.oauth.github,t.trayWorkerBaseUrl&&(x=t.trayWorkerBaseUrl),b;if(t.trayWorkerBaseUrl){x=t.trayWorkerBaseUrl;let e=await fetch(`${t.trayWorkerBaseUrl}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return b=t.oauth.github,b}}}}catch{}return y.clientId}var w=typeof globalThis<`u`&&typeof globalThis.chrome?.runtime?.id==`string`;function T(){return n().find(e=>e.providerId===`github`)}function E(e){try{return new URL(e).searchParams.get(`code`)}catch{return null}}async function D(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 O(e,t){return`${e}+${t}@users.noreply.github.com`}async function k(e){try{let{VirtualFS:t}=await r(async()=>{let{VirtualFS:e}=await import(`./fs-DWYk-XaG.js`);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));await(await t.create({dbName:d})).writeFile(`/workspace/.git/github-token`,e),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 A(){try{let{VirtualFS:e}=await r(async()=>{let{VirtualFS:e}=await import(`./fs-DWYk-XaG.js`);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));await(await e.create({dbName:d})).rm(`/workspace/.git/github-token`),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch{}}async function j(e){if(!(!e.login||e.id===void 0))try{let{VirtualFS:t}=await r(async()=>{let{VirtualFS:e}=await import(`./fs-DWYk-XaG.js`);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),{readGlobalGitConfigValue:n,writeGlobalGitConfigValue:i}=await r(async()=>{let{readGlobalGitConfigValue:e,writeGlobalGitConfigValue:t}=await import(`./git-config-D2u6LGfT.js`);return{readGlobalGitConfigValue:e,writeGlobalGitConfigValue:t}},[]),a=await t.create({dbName:d}),o=e.name||e.login,s=O(e.id,e.login);!await n(a,`user.name`)&&o&&await i(a,`user.name`,o),await n(a,`user.email`)||await i(a,`user.email`,s)}catch(e){console.warn(`[github] Failed to seed git identity:`,e instanceof Error?e.message:String(e))}}var M=a();async function N(){try{let n=T();if(!n?.refreshToken)return null;let r=await _({provider:`github`,refreshToken:n.refreshToken});await e({providerId:`github`,accessToken:r.access_token,refreshToken:r.refresh_token,tokenExpiresAt:r.expires_in?Date.now()+r.expires_in*1e3:void 0,userName:n.userName,userAvatar:n.userAvatar,scopes:r.scope??n.scopes});let i=t(`github`)?.maskedValue;return i?await k(i):await A(),r.access_token}catch(e){return console.warn(`[github] Silent renewal failed:`,e instanceof Error?e.message:String(e)),null}}var P=1e4;async function F(){let e=T()?.accessToken;if(!e)return{status:`unknown`,detail:`no stored token`};try{let t=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${e}`,Accept:`application/vnd.github+json`},signal:AbortSignal.timeout(P)});if(t.ok){let e=await t.json().catch(()=>({}));return{status:`accepted`,userName:e.name||e.login}}return I(t)}catch(e){return{status:`unknown`,detail:e instanceof Error?e.message:String(e)}}}function I(e){let t=`HTTP ${e.status}${e.statusText?` ${e.statusText}`:``}`;return e.status===401?{status:`rejected`,detail:t}:e.status===403&&L(e)?{status:`unknown`,detail:`${t} (rate limited)`}:{status:`unknown`,detail:t}}function L(e){return e.headers.get(`x-ratelimit-remaining`)===`0`||e.headers.has(`retry-after`)}async function R(){let e=t(`github`)?.maskedValue;e&&await k(e)}async function z(){let e=T();if(!e?.accessToken)throw Error(`Not logged in to GitHub — please log in first`);if((e.tokenExpiresAt??1/0)-Date.now()>6e4)return await R(),e.accessToken;let t=await M.run(()=>N());if(t)return t;let n=T();if((n?.tokenExpiresAt??1/0)-Date.now()>0&&n?.accessToken)return await R(),n.accessToken;throw Error(`GitHub session expired — please log in again`)}var B={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(n,r,i)=>{let a=await C();if(!a)throw Error(`GitHub OAuth not configured — no client ID available`);let o=i?.scopes??y.scopes,s=w?null:await l(),d=!w&&await u(),f=crypto.randomUUID(),m=w?chrome.runtime.id:``,{redirectUri:h,state:_}=S({isExtension:w,isConnectMode:!!globalThis.__slicc_connect_mode,workerBaseUrl:p(),runtimeWorkerBaseUrl:x,pageOrigin:s?.origin??null,pageHref:s?.href??null,bridgeApiBaseUrl:c(),delegated:d,extensionId:m,nonce:f}),v=btoa(JSON.stringify(_)),b=f,T=new URLSearchParams({client_id:a,scope:o,redirect_uri:h});v&&T.set(`state`,v);let O=await n(`https://github.com/login/oauth/authorize?${T}`);if(!O)return;if(b)try{if(new URL(O).searchParams.get(`nonce`)!==b){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 M=E(O);if(!M){console.error(`[github] Could not extract authorization code from redirect URL`);return}let N=await g({provider:`github`,code:M,redirectUri:h}),P=await D(N.access_token);await e({providerId:`github`,accessToken:N.access_token,refreshToken:N.refresh_token,tokenExpiresAt:N.expires_in?Date.now()+N.expires_in*1e3:void 0,userName:P.name,userAvatar:P.avatar,scopes:N.scope});let F=t(`github`)?.maskedValue;F?await k(F):await A(),await j(P),r()},onSilentRenew:N,onValidateToken:F,getValidAccessToken:z,onOAuthLogout:async()=>{let t=T();t?.accessToken&&await v({provider:`github`,accessToken:t.accessToken}).catch(e=>console.warn(`[github] Token revocation failed:`,e instanceof Error?e.message:String(e))),await A(),await e({providerId:`github`,accessToken:``})},getOAuthLogoutUrl:e=>`https://github.com/logout`};export{O as buildNoreplyEmail,B as config,E as extractCodeFromUrl,z as getValidAccessToken,S as resolveGithubOAuthRedirect,j as syncGitIdentityFromGitHub};
@@ -1 +1 @@
1
- import{g as e,n as t}from"./account-store-naVgJKHe.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{a as r,n as i,r as a}from"./compat-uEPf6-XW.js";import{a as o,c as s,i as c,r as l,s as u,t as d}from"./legacy-api-aliases-jKEvBgOL.js";import"./provider-settings-C6uIHjd4.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-3e5,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=a(`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=i(`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,t){return e===`anthropic-messages`?t?o:d:e===`openai-responses`?t?s:c:t?u:l}function H(e,t,n){let r=B(n);if(r&&/model_not_supported/i.test(r)){R(t.id,`model_not_supported`);let n=z(t.id,r);return console.error(`[github-copilot] Plan-gated model rejection:`,n),e.push(F(t,Error(n))),e.end(),!0}return e.push(n),!1}function U(e,t,n){let r=n instanceof Error?n.message:String(n),i=n;/model_not_supported/i.test(r)&&(R(t.id,`model_not_supported`),i=Error(z(t.id,r))),console.error(`[github-copilot] Stream error:`,i instanceof Error?i.message:String(i)),e.push(F(t,i)),e.end()}async function W(e,t,n,r,i){try{let a=await j(),o=L(t.id);if(!o)throw Error(`GitHub Copilot does not recognize "${t.id}" — open the picker (the model list refreshes on login) and pick a current model.`);let s={...t,api:o.api,baseUrl:o.baseUrl,headers:o.headers,provider:`github-copilot`},c={...r,apiKey:a},l=V(o.api,i)(s,n,c);for await(let n of l)if(H(e,t,n))return;e.end()}catch(n){U(e,t,n)}}function G(e){return(t,r,i={})=>{let a=n();return W(a,t,r,i,e),a}}const K=G(!1),q=G(!0),J=({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-CknViQHB.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)}),Y={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??J)({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 X(){r({api:`github-copilot-anthropic`,stream:K,streamSimple:q}),r({api:`github-copilot-openai`,stream:K,streamSimple:q})}export{Y as config,N as isCopilotConeCompatible,X as register};
1
+ import{g as e,n as t}from"./account-store-ChQLfZgz.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{a as r,n as i,r as a}from"./compat-uEPf6-XW.js";import{a as o,c as s,i as c,r as l,s as u,t as d}from"./legacy-api-aliases-jKEvBgOL.js";import"./provider-settings-D3GCdjWv.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-3e5,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=a(`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=i(`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,t){return e===`anthropic-messages`?t?o:d:e===`openai-responses`?t?s:c:t?u:l}function H(e,t,n){let r=B(n);if(r&&/model_not_supported/i.test(r)){R(t.id,`model_not_supported`);let n=z(t.id,r);return console.error(`[github-copilot] Plan-gated model rejection:`,n),e.push(F(t,Error(n))),e.end(),!0}return e.push(n),!1}function U(e,t,n){let r=n instanceof Error?n.message:String(n),i=n;/model_not_supported/i.test(r)&&(R(t.id,`model_not_supported`),i=Error(z(t.id,r))),console.error(`[github-copilot] Stream error:`,i instanceof Error?i.message:String(i)),e.push(F(t,i)),e.end()}async function W(e,t,n,r,i){try{let a=await j(),o=L(t.id);if(!o)throw Error(`GitHub Copilot does not recognize "${t.id}" — open the picker (the model list refreshes on login) and pick a current model.`);let s={...t,api:o.api,baseUrl:o.baseUrl,headers:o.headers,provider:`github-copilot`},c={...r,apiKey:a},l=V(o.api,i)(s,n,c);for await(let n of l)if(H(e,t,n))return;e.end()}catch(n){U(e,t,n)}}function G(e){return(t,r,i={})=>{let a=n();return W(a,t,r,i,e),a}}const K=G(!1),q=G(!0),J=({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-CknViQHB.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)}),Y={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??J)({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 X(){r({api:`github-copilot-anthropic`,stream:K,streamSimple:q}),r({api:`github-copilot-openai`,stream:K,streamSimple:q})}export{Y as config,N as isCopilotConeCompatible,X as register};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/clipboard-eqmn97SP.js","assets/rolldown-runtime-Dd_uD5pT.js"])))=>i.map(i=>d[i]);
2
- import{H as e,d as t}from"./account-store-DsMvFZgS.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{c as i,s as a,u as o}from"./claude-model-version-BJLrDjmH.js";import{a as s,c,i as l,r as u,s as d,t as f}from"./legacy-api-aliases-45zvHmpJ.js";import"./provider-settings-DrWv51sQ.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 t().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-3e5,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(t,n){await e({providerId:p,accessToken:t.copilotToken,refreshToken:t.githubAccessToken,tokenExpiresAt:t.expiresAtMs,baseUrl:t.apiBaseUrl,userName:n})}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=i(`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=a(`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(e,t){return e===`anthropic-messages`?t?s:f:e===`openai-responses`?t?c:l:t?d:u}function q(e,t,n){let r=G(n);if(r&&/model_not_supported/i.test(r)){U(t.id,`model_not_supported`);let n=W(t.id,r);return console.error(`[github-copilot] Plan-gated model rejection:`,n),e.push(B(t,Error(n))),e.end(),!0}return e.push(n),!1}function J(e,t,n){let r=n instanceof Error?n.message:String(n),i=n;/model_not_supported/i.test(r)&&(U(t.id,`model_not_supported`),i=Error(W(t.id,r))),console.error(`[github-copilot] Stream error:`,i instanceof Error?i.message:String(i)),e.push(B(t,i)),e.end()}async function Y(e,t,n,r,i){try{let a=await I(),o=H(t.id);if(!o)throw Error(`GitHub Copilot does not recognize "${t.id}" — open the picker (the model list refreshes on login) and pick a current model.`);let s={...t,api:o.api,baseUrl:o.baseUrl,headers:o.headers,provider:`github-copilot`},c={...r,apiKey:a},l=K(o.api,i)(s,n,c);for await(let n of l)if(q(e,t,n))return;e.end()}catch(n){J(e,t,n)}}function X(e){return(t,r,i={})=>{let a=n();return Y(a,t,r,i,e),a}}var Z=X(!1),Q=X(!0),$=({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 i=document.createElement(`div`);i.textContent=`GitHub Copilot — verification code`,i.style.cssText=`font-weight:600;margin-bottom:8px;color:#7ee787`;let a=document.createElement(`div`);a.textContent=e,a.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 o=document.createElement(`div`);o.style.cssText=`color:#8b949e;font-size:12px;line-height:1.5`,o.textContent=`Copy the code, then click Continue to open the GitHub authorization page in a new tab.`;let s=document.createElement(`div`);s.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 r(async()=>{let{copyTextToClipboard:e}=await import(`./clipboard-eqmn97SP.js`).then(e=>e.t);return{copyTextToClipboard:e}},__vite__mapDeps([0,1]));await t(e)}catch{}u(),t(`continue`)})()}),s.appendChild(c),s.appendChild(l),n.appendChild(i),n.appendChild(a),n.appendChild(o),n.appendChild(s),document.body.appendChild(n)}),ee={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??$)({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 e({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 te(){o({api:`github-copilot-anthropic`,stream:Z,streamSimple:Q}),o({api:`github-copilot-openai`,stream:Z,streamSimple:Q})}export{ee as config,R as isCopilotConeCompatible,te as register};
2
+ import{H as e,d as t}from"./account-store-BcQeOBmj.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{c as i,s as a,u as o}from"./claude-model-version-BJLrDjmH.js";import{a as s,c,i as l,r as u,s as d,t as f}from"./legacy-api-aliases-45zvHmpJ.js";import"./provider-settings-DxvegOPb.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 t().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-3e5,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(t,n){await e({providerId:p,accessToken:t.copilotToken,refreshToken:t.githubAccessToken,tokenExpiresAt:t.expiresAtMs,baseUrl:t.apiBaseUrl,userName:n})}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=i(`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=a(`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(e,t){return e===`anthropic-messages`?t?s:f:e===`openai-responses`?t?c:l:t?d:u}function q(e,t,n){let r=G(n);if(r&&/model_not_supported/i.test(r)){U(t.id,`model_not_supported`);let n=W(t.id,r);return console.error(`[github-copilot] Plan-gated model rejection:`,n),e.push(B(t,Error(n))),e.end(),!0}return e.push(n),!1}function J(e,t,n){let r=n instanceof Error?n.message:String(n),i=n;/model_not_supported/i.test(r)&&(U(t.id,`model_not_supported`),i=Error(W(t.id,r))),console.error(`[github-copilot] Stream error:`,i instanceof Error?i.message:String(i)),e.push(B(t,i)),e.end()}async function Y(e,t,n,r,i){try{let a=await I(),o=H(t.id);if(!o)throw Error(`GitHub Copilot does not recognize "${t.id}" — open the picker (the model list refreshes on login) and pick a current model.`);let s={...t,api:o.api,baseUrl:o.baseUrl,headers:o.headers,provider:`github-copilot`},c={...r,apiKey:a},l=K(o.api,i)(s,n,c);for await(let n of l)if(q(e,t,n))return;e.end()}catch(n){J(e,t,n)}}function X(e){return(t,r,i={})=>{let a=n();return Y(a,t,r,i,e),a}}var Z=X(!1),Q=X(!0),$=({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 i=document.createElement(`div`);i.textContent=`GitHub Copilot — verification code`,i.style.cssText=`font-weight:600;margin-bottom:8px;color:#7ee787`;let a=document.createElement(`div`);a.textContent=e,a.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 o=document.createElement(`div`);o.style.cssText=`color:#8b949e;font-size:12px;line-height:1.5`,o.textContent=`Copy the code, then click Continue to open the GitHub authorization page in a new tab.`;let s=document.createElement(`div`);s.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 r(async()=>{let{copyTextToClipboard:e}=await import(`./clipboard-eqmn97SP.js`).then(e=>e.t);return{copyTextToClipboard:e}},__vite__mapDeps([0,1]));await t(e)}catch{}u(),t(`continue`)})()}),s.appendChild(c),s.appendChild(l),n.appendChild(i),n.appendChild(a),n.appendChild(o),n.appendChild(s),document.body.appendChild(n)}),ee={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??$)({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 e({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 te(){o({api:`github-copilot-anthropic`,stream:Z,streamSimple:Q}),o({api:`github-copilot-openai`,stream:Z,streamSimple:Q})}export{ee as config,R as isCopilotConeCompatible,te as register};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{i as t}from"./fetch-body-COdvQyTD.js";import{a as n,c as r,d as i,f as a,g as o,o as s,r as c,s as l,t as u}from"./github-zip-CuwUOO-U.js";function d(e){return`${o}/${e}/.upskill`}async function f(e,t){try{let n=await e.readTextFile(d(t)),r=JSON.parse(n);return!r||typeof r!=`object`||!r.kind||!r.source?null:r}catch{return null}}async function p(e,t,n){try{let r={...n,version:1,installed:new Date().toISOString()};await e.writeFile(d(t),`${JSON.stringify(r,null,2)}\n`)}catch{}}async function m(e){let t;try{t=await e.readDir(o)}catch{return{provenanced:[],unattributed:[]}}let n={provenanced:[],unattributed:[]};for(let r of t.sort((e,t)=>e.name.localeCompare(t.name))){if(r.type!==`directory`)continue;let t=await f(e,r.name);t?n.provenanced.push({name:r.name,provenance:t}):n.unattributed.push(r.name)}return n}async function h(e,n,r,i,a=!1){if(!(!i.hasToken&&!a))try{let a=r||`HEAD`,o=await i.request(`https://api.github.com/repos/${e}/${n}/commits/${encodeURIComponent(a)}`);if(o.status!==200)return;let s=t(o.body);return typeof s.sha==`string`?s.sha:void 0}catch{return}}function g(e){let t=`Installed from: ${e.kind}:${e.source}\n`;return e.ref&&(t+=`Ref: ${e.ref}\n`),e.path&&(t+=`Upstream path: ${e.path}\n`),e.sha&&(t+=`Commit: ${e.sha}\n`),t+=`Installed at: ${e.installed}\n`,t}async function _(){try{let e=(typeof window<`u`?window:globalThis).__slicc_reloadSkills;if(typeof e==`function`){await e();return}typeof chrome<`u`&&chrome?.runtime?.sendMessage&&chrome.runtime.sendMessage({source:`panel`,payload:{type:`reload-skills`}})}catch{}}async function v(){try{let e=globalThis.__slicc_sprinkleManager;typeof e?.openNewAutoOpenSprinkles==`function`&&await e.openNewAutoOpenSprinkles()}catch{}}async function y(){await v(),await _()}async function b(e,t,n,s,c=!1,l){let u=`${o}/${t}`,d=!1;try{if(await s.stat(u),!c)return{ok:!1,error:`skill "${t}" already exists (use --force to overwrite)`};d=!0,await a(s,u,await x(s,t))}catch{}let f=e.replace(/^\/|\/$/g,``),m=f?f+`/`:``;await s.mkdir(u,{recursive:!0});let h=0,g=[];try{for(let[e,t]of Object.entries(n)){if(!e.startsWith(m))continue;let n=e.slice(m.length);if(!n||e.endsWith(`/`)||!await i(s,u,n)||!r(n))continue;let a=`${u}/${n}`,o=a.substring(0,a.lastIndexOf(`/`));o!==u&&await s.mkdir(o,{recursive:!0}),await s.writeFile(a,t),g.push(n),h++}}catch(e){throw await S(s,u,d),e}return h===0?(await S(s,u,d),{ok:!1,error:`no files found for skill "${t}" in ZIP`}):(l&&await p(s,t,{...l,skill:t,files:g.sort()}),{ok:!0})}async function x(e,t){let n=await f(e,t);return n?.files?.length?new Set(n.files):void 0}async function S(e,t,n){if(n){await a(e,t).catch(()=>!1);return}await e.rm(t,{recursive:!0}).catch(()=>{})}var C=e({installFromGitHub:()=>D,listGitHubSkills:()=>T,parseGitHubRef:()=>O,parseGitHubUrl:()=>w});function w(e){let t=e.match(/github\.com\/([^/?#]+)\/([^/?#]+)/);return t?{owner:t[1],repo:t[2].replace(/\.git$/,``)}:null}async function T(e,r,i,a,o,s){if(o){let t=await c(e,r,o,s);if(t.status===`ok`){let e=n(t.files),r=[],i=a?a.replace(/^\/|\/$/g,``)+`/`:``;for(let t of Object.keys(e))if(t.startsWith(i)&&(t.split(`/`).pop()||``)===`SKILL.md`){let e=t.replace(/\/SKILL\.md$/,``),n=e.split(`/`).pop()||e;r.push({name:n,path:e})}return{skills:r}}}let u=[];async function d(n){let a=`https://api.github.com/repos/${e}/${r}/contents/${n}`,o=s?`${a}?ref=${encodeURIComponent(s)}`:a,c=await i.request(o);if(c.status!==200)throw Error(l(c,`${e}/${r}${n?`/${n}`:``}`,i.hasToken));let f=t(c.body);for(let e of f)if(e.type===`file`&&e.name===`SKILL.md`){let t=e.path.replace(`/SKILL.md`,``),n=t.split(`/`).pop()||t;u.push({name:n,path:t})}else e.type===`dir`&&await d(e.path)}try{return await d(a||``),{skills:u}}catch(e){return{skills:[],error:e instanceof Error?e.message:String(e)}}}async function E(e,t,n,r,i,a,o,s){let c=await h(t,n,a,o);await p(e,i,{kind:`github`,source:`${t}/${n}`,skill:i,ref:a,path:r.replace(/^\/|\/$/g,``),sha:c,files:s})}async function D(e,r,i,d,f,p,m=!1,h,g){let b=!1;try{let C=`${o}/${d}`;try{if(await f.stat(C),!m)return{stdout:``,stderr:`upskill: skill "${d}" already exists (use --force to overwrite)\n`,exitCode:1};b=!0,await a(f,C,await x(f,d))}catch{}if(h){let t=await c(e,r,h,g);if(t.status===`ok`){let a=n(t.files),o=i.replace(/^\/|\/$/g,``)+`/`;await f.mkdir(C,{recursive:!0});let c=await s(a,o,C,f);if(c.length>0)return await E(f,e,r,i,d,g,p,c),await v(),await _(),{stdout:`Installed skill "${d}" from ${e}/${r}\n`,stderr:``,exitCode:0}}}let w=`https://api.github.com/repos/${e}/${r}/contents/${i}`,T=g?`${w}?ref=${encodeURIComponent(g)}`:w,D=await p.request(T);if(D.status!==200)return{stdout:``,stderr:`upskill: ${l(D,`${e}/${r}/${i}`,p.hasToken)}\n`,exitCode:1};let O=t(D.body);await f.mkdir(C,{recursive:!0});let k;try{k=await u(O,C,e,r,g,f,p)}catch(e){throw await S(f,C,b),e}return await E(f,e,r,i,d,g,p,k),await y(),{stdout:`Installed skill "${d}" from ${e}/${r}\n`,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`upskill: failed to install from GitHub: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}function O(e){let t=e.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?(?:\/tree\/([^/]+?)(?:\/(.+?))?)?\/?$/);if(t)return{owner:t[1],repo:t[2],branch:t[3],path:t[4]};let n=e.match(/^([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+)(?:@([a-zA-Z0-9_./-]+))?$/);return n?{owner:n[1],repo:n[2],branch:n[3]}:null}export{w as a,y as c,h as d,m as f,O as i,g as l,D as n,b as o,p,T as r,x as s,C as t,f as u};
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{i as t}from"./fetch-body-COdvQyTD.js";import{a as n,c as r,d as i,f as a,g as o,o as s,r as c,s as l,t as u}from"./github-zip-q8IzoiWD.js";function d(e){return`${o}/${e}/.upskill`}async function f(e,t){try{let n=await e.readTextFile(d(t)),r=JSON.parse(n);return!r||typeof r!=`object`||!r.kind||!r.source?null:r}catch{return null}}async function p(e,t,n){try{let r={...n,version:1,installed:new Date().toISOString()};await e.writeFile(d(t),`${JSON.stringify(r,null,2)}\n`)}catch{}}async function m(e){let t;try{t=await e.readDir(o)}catch{return{provenanced:[],unattributed:[]}}let n={provenanced:[],unattributed:[]};for(let r of t.sort((e,t)=>e.name.localeCompare(t.name))){if(r.type!==`directory`)continue;let t=await f(e,r.name);t?n.provenanced.push({name:r.name,provenance:t}):n.unattributed.push(r.name)}return n}async function h(e,n,r,i,a=!1){if(!(!i.hasToken&&!a))try{let a=r||`HEAD`,o=await i.request(`https://api.github.com/repos/${e}/${n}/commits/${encodeURIComponent(a)}`);if(o.status!==200)return;let s=t(o.body);return typeof s.sha==`string`?s.sha:void 0}catch{return}}function g(e){let t=`Installed from: ${e.kind}:${e.source}\n`;return e.ref&&(t+=`Ref: ${e.ref}\n`),e.path&&(t+=`Upstream path: ${e.path}\n`),e.sha&&(t+=`Commit: ${e.sha}\n`),t+=`Installed at: ${e.installed}\n`,t}async function _(){try{let e=(typeof window<`u`?window:globalThis).__slicc_reloadSkills;if(typeof e==`function`){await e();return}typeof chrome<`u`&&chrome?.runtime?.sendMessage&&chrome.runtime.sendMessage({source:`panel`,payload:{type:`reload-skills`}})}catch{}}async function v(){try{let e=globalThis.__slicc_sprinkleManager;typeof e?.openNewAutoOpenSprinkles==`function`&&await e.openNewAutoOpenSprinkles()}catch{}}async function y(){await v(),await _()}async function b(e,t,n,s,c=!1,l){let u=`${o}/${t}`,d=!1;try{if(await s.stat(u),!c)return{ok:!1,error:`skill "${t}" already exists (use --force to overwrite)`};d=!0,await a(s,u,await x(s,t))}catch{}let f=e.replace(/^\/|\/$/g,``),m=f?f+`/`:``;await s.mkdir(u,{recursive:!0});let h=0,g=[];try{for(let[e,t]of Object.entries(n)){if(!e.startsWith(m))continue;let n=e.slice(m.length);if(!n||e.endsWith(`/`)||!await i(s,u,n)||!r(n))continue;let a=`${u}/${n}`,o=a.substring(0,a.lastIndexOf(`/`));o!==u&&await s.mkdir(o,{recursive:!0}),await s.writeFile(a,t),g.push(n),h++}}catch(e){throw await S(s,u,d),e}return h===0?(await S(s,u,d),{ok:!1,error:`no files found for skill "${t}" in ZIP`}):(l&&await p(s,t,{...l,skill:t,files:g.sort()}),{ok:!0})}async function x(e,t){let n=await f(e,t);return n?.files?.length?new Set(n.files):void 0}async function S(e,t,n){if(n){await a(e,t).catch(()=>!1);return}await e.rm(t,{recursive:!0}).catch(()=>{})}var C=e({installFromGitHub:()=>D,listGitHubSkills:()=>T,parseGitHubRef:()=>O,parseGitHubUrl:()=>w});function w(e){let t=e.match(/github\.com\/([^/?#]+)\/([^/?#]+)/);return t?{owner:t[1],repo:t[2].replace(/\.git$/,``)}:null}async function T(e,r,i,a,o,s){if(o){let t=await c(e,r,o,s);if(t.status===`ok`){let e=n(t.files),r=[],i=a?a.replace(/^\/|\/$/g,``)+`/`:``;for(let t of Object.keys(e))if(t.startsWith(i)&&(t.split(`/`).pop()||``)===`SKILL.md`){let e=t.replace(/\/SKILL\.md$/,``),n=e.split(`/`).pop()||e;r.push({name:n,path:e})}return{skills:r}}}let u=[];async function d(n){let a=`https://api.github.com/repos/${e}/${r}/contents/${n}`,o=s?`${a}?ref=${encodeURIComponent(s)}`:a,c=await i.request(o);if(c.status!==200)throw Error(l(c,`${e}/${r}${n?`/${n}`:``}`,i.hasToken));let f=t(c.body);for(let e of f)if(e.type===`file`&&e.name===`SKILL.md`){let t=e.path.replace(`/SKILL.md`,``),n=t.split(`/`).pop()||t;u.push({name:n,path:t})}else e.type===`dir`&&await d(e.path)}try{return await d(a||``),{skills:u}}catch(e){return{skills:[],error:e instanceof Error?e.message:String(e)}}}async function E(e,t,n,r,i,a,o,s){let c=await h(t,n,a,o);await p(e,i,{kind:`github`,source:`${t}/${n}`,skill:i,ref:a,path:r.replace(/^\/|\/$/g,``),sha:c,files:s})}async function D(e,r,i,d,f,p,m=!1,h,g){let b=!1;try{let C=`${o}/${d}`;try{if(await f.stat(C),!m)return{stdout:``,stderr:`upskill: skill "${d}" already exists (use --force to overwrite)\n`,exitCode:1};b=!0,await a(f,C,await x(f,d))}catch{}if(h){let t=await c(e,r,h,g);if(t.status===`ok`){let a=n(t.files),o=i.replace(/^\/|\/$/g,``)+`/`;await f.mkdir(C,{recursive:!0});let c=await s(a,o,C,f);if(c.length>0)return await E(f,e,r,i,d,g,p,c),await v(),await _(),{stdout:`Installed skill "${d}" from ${e}/${r}\n`,stderr:``,exitCode:0}}}let w=`https://api.github.com/repos/${e}/${r}/contents/${i}`,T=g?`${w}?ref=${encodeURIComponent(g)}`:w,D=await p.request(T);if(D.status!==200)return{stdout:``,stderr:`upskill: ${l(D,`${e}/${r}/${i}`,p.hasToken)}\n`,exitCode:1};let O=t(D.body);await f.mkdir(C,{recursive:!0});let k;try{k=await u(O,C,e,r,g,f,p)}catch(e){throw await S(f,C,b),e}return await E(f,e,r,i,d,g,p,k),await y(),{stdout:`Installed skill "${d}" from ${e}/${r}\n`,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`upskill: failed to install from GitHub: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}function O(e){let t=e.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?(?:\/tree\/([^/]+?)(?:\/(.+?))?)?\/?$/);if(t)return{owner:t[1],repo:t[2],branch:t[3],path:t[4]};let n=e.match(/^([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+)(?:@([a-zA-Z0-9_./-]+))?$/);return n?{owner:n[1],repo:n[2],branch:n[3]}:null}export{w as a,y as c,h as d,m as f,O as i,g as l,D as n,b as o,p,T as r,x as s,C as t,f as u};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{i as t}from"./binary-cache-bSOhqXB1.js";import{i as n,n as r,r as i}from"./fetch-body-COdvQyTD.js";import{n as a}from"./fs-CDaCMxrL.js";import{r as o}from"./browser-2rCVqcqy.js";import{t as s}from"./global-db-DJXlpNui.js";const c=`https://api.tessl.io`,l=`https://browse.sh/api/skills`,u=`/workspace/skills`,d=s,f=`application/vnd.github.v3+json`,p=`https://www.sliccy.com/skills/`,m=`${p}catalog.json`;function h(e){return e.split(`/`).some(e=>e.startsWith(`.`))}async function g(e,t,n){return!h(n)||!await e.exists(`${t}/${n}`)}async function _(e,t,n,r=``){let i;try{i=await e.readDir(t)}catch{return!1}let a=!1;for(let o of i){let i=`${t}/${o.name}`,s=r?`${r}/${o.name}`:o.name;if(o.name.startsWith(`.`)){a=!0;continue}o.type===`directory`?await _(e,i,n,s)?a=!0:await e.rm(i,{recursive:!0}):n&&!n.has(s)?a=!0:await e.rm(i)}return a}async function v(e,t,n=!1,r=``){let i;try{i=await e.readDir(t)}catch{return[]}let a=[];for(let o of i){if(!n&&o.name.startsWith(`.`))continue;let i=r?`${r}/${o.name}`:o.name;o.type===`directory`?a.push(...await v(e,`${t}/${o.name}`,n,i)):a.push(i)}return a.sort()}function y(e,t){let n=e instanceof Error?e.message:String(e),r;try{r=new URL(t).host}catch{return n}return!r||n.includes(r)?n:`${n} (host: ${r} — network or CORS error)`}let b;function x(){return b||=a.create({dbName:d}),b}async function S(){try{return(await(await x()).readTextFile(`/workspace/.git/github-token`)).trim()||void 0}catch{return}}function C(e,t=f){let n={Accept:t,"User-Agent":`slicc-upskill`};return e&&(n.Authorization=`Bearer ${e}`),n}async function w(e){let t=await S();return{hasToken:!!t,request:async(n,r=f)=>{try{return await e(n,{headers:C(t,r)})}catch(e){throw Error(y(e,n))}}}}function T(e,t){if(!e)return;let n=t.toLowerCase();for(let[t,r]of Object.entries(e))if(t.toLowerCase()===n)return r}function E(e){return!e||e.startsWith(`/`)||e.includes(`\0`)||e.includes(`\\`)||/^[A-Za-z]:/.test(e)?!1:!e.split(`/`).some(e=>e===``||e===`.`||e===`..`)}function D(e){let t=r(e);if(!t)return;try{let e=JSON.parse(t);if(typeof e.message==`string`&&e.message.trim())return e.message.trim()}catch{}let n=t.trim();if(n)return n.slice(0,200)}function O(e,t,n){let r=D(e.body),i=r?` GitHub said: ${r}`:``,a=T(e.headers,`retry-after`),o=T(e.headers,`x-ratelimit-remaining`),s=r?.toLowerCase()??``;if(e.status===429||o===`0`||s.includes(`rate limit`))return n?`GitHub rate-limited access to ${t} (HTTP ${e.status}). The configured github.token was used, so retry later${a?` after about ${a} seconds`:``}.${i}`:`GitHub rate-limited anonymous access to ${t} (HTTP ${e.status}). This often happens on shared VPNs or corporate egress IPs because unauthenticated GitHub API requests are limited per IP. Configure a token with: git config github.token <PAT>, then retry. You can also retry off VPN or later.${i}`;if(e.status===401)return n?`GitHub rejected the configured github.token while accessing ${t} (HTTP 401). Update it with: git config github.token <PAT>, then retry.${i}`:`GitHub requires authentication to access ${t} (HTTP 401). Configure a token with: git config github.token <PAT>, then retry.${i}`;if(e.status===404)return`GitHub could not find ${t} (HTTP 404). Check the repository, path, and permissions.${i}`;if(e.status===403)return n?`GitHub denied access to ${t} (HTTP 403). Check that your github.token can access this repository or retry later if GitHub is throttling requests.${i}`:`GitHub denied anonymous access to ${t} (HTTP 403). If this repo is public on a shared VPN, you may have hit GitHub's shared IP limit; otherwise the repository or path may require authentication. Configure a token with: git config github.token <PAT>, then retry.${i}`;let c=e.statusText?` ${e.statusText}`:``;return`GitHub request for ${t} failed (HTTP ${e.status}${c}).${i}`}var k=e({downloadGitHubDir:()=>P,fetchGitHubDirFiles:()=>N,fetchRepoZip:()=>A,stripZipPrefix:()=>j,writeZipFilesToDir:()=>M});async function A(e,n,r,a=`main`){let s=`https://codeload.github.com/${e}/${n}/zip/refs/heads/${a}`,c;try{c=await r(s,{headers:{"User-Agent":`slicc-upskill`}})}catch(e){return{status:`error`,message:y(e,s)}}if(c.status===404)return a===`main`?A(e,n,r,`master`):{status:`error`,message:`codeload returned HTTP 404`};if(c.status!==200)return{status:`error`,message:`codeload returned HTTP ${c.status}`};let l=t(s);l||=i(c.body);try{return{status:`ok`,files:o(l)}}catch(e){return{status:`error`,message:`failed to unzip: ${e instanceof Error?e.message:String(e)}`}}}function j(e){let t={};for(let[n,r]of Object.entries(e)){let e=n.indexOf(`/`);if(e<0)continue;let i=n.slice(e+1);i&&(t[i]=r)}return t}async function M(e,t,n,r,i=!0){let a=[];for(let[o,s]of Object.entries(e)){if(!o.startsWith(t))continue;let e=o.slice(t.length);if(o.endsWith(`/`)||!E(e)||i&&!await g(r,n,e))continue;let c=`${n}/${e}`,l=c.substring(0,c.lastIndexOf(`/`));l!==n&&await r.mkdir(l,{recursive:!0}),await r.writeFile(c,s),a.push(e)}return a.sort()}async function N(e,r,a,o,s,c=new Map,l=``){let u=`https://api.github.com/repos/${e}/${r}/contents/${a}`,d=o?`${u}?ref=${encodeURIComponent(o)}`:u,f=await s.request(d);if(f.status!==200)throw Error(O(f,`${e}/${r}${a?`/${a}`:``}`,s.hasToken));for(let a of n(f.body)){let n=l?`${l}/${a.name}`:a.name;if(E(n)){if(a.type===`file`&&a.download_url){let o=await s.request(a.download_url,`*/*`);if(o.status!==200)throw Error(O(o,`${e}/${r}/${a.path}`,s.hasToken));let l=t(a.download_url);c.set(n,l??i(o.body))}else a.type===`dir`&&await N(e,r,a.path,o,s,c,n)}}return c}async function P(e,r,i,a,o,s,c,l=[],u=``){for(let d of e){let e=u?`${u}/${d.name}`:d.name;if(E(e)){if(d.type===`file`&&d.download_url){if(h(e)&&await s.exists(`${r}/${d.name}`))continue;let n=await c.request(d.download_url,`*/*`);if(n.status!==200)throw Error(O(n,`${i}/${a}/${d.path}`,c.hasToken));let o=t(d.download_url);await s.writeFile(`${r}/${d.name}`,o??n.body),l.push(e)}else if(d.type===`dir`){let t=`https://api.github.com/repos/${i}/${a}/contents/${d.path}`,u=o?`${t}?ref=${encodeURIComponent(o)}`:t,f=await c.request(u);if(f.status!==200)throw Error(O(f,`${i}/${a}/${d.path}`,c.hasToken));let p=n(f.body);await s.mkdir(`${r}/${d.name}`,{recursive:!0}),await P(p,`${r}/${d.name}`,i,a,o,s,c,l,e)}}}return l.sort()}export{p as _,j as a,E as c,g as d,_ as f,u as g,l as h,k as i,w as l,v as m,N as n,M as o,h as p,A as r,O as s,P as t,y as u,m as v,c as y};
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{i as t}from"./binary-cache-bSOhqXB1.js";import{i as n,n as r,r as i}from"./fetch-body-COdvQyTD.js";import{n as a}from"./fs-DWgVdrZr.js";import{r as o}from"./browser-2rCVqcqy.js";import{t as s}from"./global-db-DJXlpNui.js";const c=`https://api.tessl.io`,l=`https://browse.sh/api/skills`,u=`/workspace/skills`,d=s,f=`application/vnd.github.v3+json`,p=`https://www.sliccy.com/skills/`,m=`${p}catalog.json`;function h(e){return e.split(`/`).some(e=>e.startsWith(`.`))}async function g(e,t,n){return!h(n)||!await e.exists(`${t}/${n}`)}async function _(e,t,n,r=``){let i;try{i=await e.readDir(t)}catch{return!1}let a=!1;for(let o of i){let i=`${t}/${o.name}`,s=r?`${r}/${o.name}`:o.name;if(o.name.startsWith(`.`)){a=!0;continue}o.type===`directory`?await _(e,i,n,s)?a=!0:await e.rm(i,{recursive:!0}):n&&!n.has(s)?a=!0:await e.rm(i)}return a}async function v(e,t,n=!1,r=``){let i;try{i=await e.readDir(t)}catch{return[]}let a=[];for(let o of i){if(!n&&o.name.startsWith(`.`))continue;let i=r?`${r}/${o.name}`:o.name;o.type===`directory`?a.push(...await v(e,`${t}/${o.name}`,n,i)):a.push(i)}return a.sort()}function y(e,t){let n=e instanceof Error?e.message:String(e),r;try{r=new URL(t).host}catch{return n}return!r||n.includes(r)?n:`${n} (host: ${r} — network or CORS error)`}let b;function x(){return b||=a.create({dbName:d}),b}async function S(){try{return(await(await x()).readTextFile(`/workspace/.git/github-token`)).trim()||void 0}catch{return}}function C(e,t=f){let n={Accept:t,"User-Agent":`slicc-upskill`};return e&&(n.Authorization=`Bearer ${e}`),n}async function w(e){let t=await S();return{hasToken:!!t,request:async(n,r=f)=>{try{return await e(n,{headers:C(t,r)})}catch(e){throw Error(y(e,n))}}}}function T(e,t){if(!e)return;let n=t.toLowerCase();for(let[t,r]of Object.entries(e))if(t.toLowerCase()===n)return r}function E(e){return!e||e.startsWith(`/`)||e.includes(`\0`)||e.includes(`\\`)||/^[A-Za-z]:/.test(e)?!1:!e.split(`/`).some(e=>e===``||e===`.`||e===`..`)}function D(e){let t=r(e);if(!t)return;try{let e=JSON.parse(t);if(typeof e.message==`string`&&e.message.trim())return e.message.trim()}catch{}let n=t.trim();if(n)return n.slice(0,200)}function O(e,t,n){let r=D(e.body),i=r?` GitHub said: ${r}`:``,a=T(e.headers,`retry-after`),o=T(e.headers,`x-ratelimit-remaining`),s=r?.toLowerCase()??``;if(e.status===429||o===`0`||s.includes(`rate limit`))return n?`GitHub rate-limited access to ${t} (HTTP ${e.status}). The configured github.token was used, so retry later${a?` after about ${a} seconds`:``}.${i}`:`GitHub rate-limited anonymous access to ${t} (HTTP ${e.status}). This often happens on shared VPNs or corporate egress IPs because unauthenticated GitHub API requests are limited per IP. Configure a token with: git config github.token <PAT>, then retry. You can also retry off VPN or later.${i}`;if(e.status===401)return n?`GitHub rejected the configured github.token while accessing ${t} (HTTP 401). Update it with: git config github.token <PAT>, then retry.${i}`:`GitHub requires authentication to access ${t} (HTTP 401). Configure a token with: git config github.token <PAT>, then retry.${i}`;if(e.status===404)return`GitHub could not find ${t} (HTTP 404). Check the repository, path, and permissions.${i}`;if(e.status===403)return n?`GitHub denied access to ${t} (HTTP 403). Check that your github.token can access this repository or retry later if GitHub is throttling requests.${i}`:`GitHub denied anonymous access to ${t} (HTTP 403). If this repo is public on a shared VPN, you may have hit GitHub's shared IP limit; otherwise the repository or path may require authentication. Configure a token with: git config github.token <PAT>, then retry.${i}`;let c=e.statusText?` ${e.statusText}`:``;return`GitHub request for ${t} failed (HTTP ${e.status}${c}).${i}`}var k=e({downloadGitHubDir:()=>P,fetchGitHubDirFiles:()=>N,fetchRepoZip:()=>A,stripZipPrefix:()=>j,writeZipFilesToDir:()=>M});async function A(e,n,r,a=`main`){let s=`https://codeload.github.com/${e}/${n}/zip/refs/heads/${a}`,c;try{c=await r(s,{headers:{"User-Agent":`slicc-upskill`}})}catch(e){return{status:`error`,message:y(e,s)}}if(c.status===404)return a===`main`?A(e,n,r,`master`):{status:`error`,message:`codeload returned HTTP 404`};if(c.status!==200)return{status:`error`,message:`codeload returned HTTP ${c.status}`};let l=t(s);l||=i(c.body);try{return{status:`ok`,files:o(l)}}catch(e){return{status:`error`,message:`failed to unzip: ${e instanceof Error?e.message:String(e)}`}}}function j(e){let t={};for(let[n,r]of Object.entries(e)){let e=n.indexOf(`/`);if(e<0)continue;let i=n.slice(e+1);i&&(t[i]=r)}return t}async function M(e,t,n,r,i=!0){let a=[];for(let[o,s]of Object.entries(e)){if(!o.startsWith(t))continue;let e=o.slice(t.length);if(o.endsWith(`/`)||!E(e)||i&&!await g(r,n,e))continue;let c=`${n}/${e}`,l=c.substring(0,c.lastIndexOf(`/`));l!==n&&await r.mkdir(l,{recursive:!0}),await r.writeFile(c,s),a.push(e)}return a.sort()}async function N(e,r,a,o,s,c=new Map,l=``){let u=`https://api.github.com/repos/${e}/${r}/contents/${a}`,d=o?`${u}?ref=${encodeURIComponent(o)}`:u,f=await s.request(d);if(f.status!==200)throw Error(O(f,`${e}/${r}${a?`/${a}`:``}`,s.hasToken));for(let a of n(f.body)){let n=l?`${l}/${a.name}`:a.name;if(E(n)){if(a.type===`file`&&a.download_url){let o=await s.request(a.download_url,`*/*`);if(o.status!==200)throw Error(O(o,`${e}/${r}/${a.path}`,s.hasToken));let l=t(a.download_url);c.set(n,l??i(o.body))}else a.type===`dir`&&await N(e,r,a.path,o,s,c,n)}}return c}async function P(e,r,i,a,o,s,c,l=[],u=``){for(let d of e){let e=u?`${u}/${d.name}`:d.name;if(E(e)){if(d.type===`file`&&d.download_url){if(h(e)&&await s.exists(`${r}/${d.name}`))continue;let n=await c.request(d.download_url,`*/*`);if(n.status!==200)throw Error(O(n,`${i}/${a}/${d.path}`,c.hasToken));let o=t(d.download_url);await s.writeFile(`${r}/${d.name}`,o??n.body),l.push(e)}else if(d.type===`dir`){let t=`https://api.github.com/repos/${i}/${a}/contents/${d.path}`,u=o?`${t}?ref=${encodeURIComponent(o)}`:t,f=await c.request(u);if(f.status!==200)throw Error(O(f,`${i}/${a}/${d.path}`,c.hasToken));let p=n(f.body);await s.mkdir(`${r}/${d.name}`,{recursive:!0}),await P(p,`${r}/${d.name}`,i,a,o,s,c,l,e)}}}return l.sort()}export{p as _,j as a,E as c,g as d,_ as f,u as g,l as h,k as i,w as l,v as m,N as n,M as o,h as p,A as r,O as s,P as t,y as u,m as v,c as y};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./subcommand-help-CgO7wRS5.js";import{r as t}from"./state-DIwkpIaB.js";function n(e){return`Usage: ${e} <command> [args...]
1
+ import{r as e}from"./subcommand-help-CgO7wRS5.js";import{r as t}from"./state-Du90LXhH.js";function n(e){return`Usage: ${e} <command> [args...]
2
2
 
3
3
  Most commands operate on a tab and REQUIRE --tab=<targetId>. There is no
4
4
  implicit "current tab" — run "${e} tab-list" to get tab IDs.