sliccy 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/dist/ui/assets/__vite-browser-external-C7iut881.js +1 -0
  2. package/dist/ui/assets/account-store-BcAPWTGv.js +38 -0
  3. package/dist/ui/assets/account-store-CiB6cAel.js +99 -0
  4. package/dist/ui/assets/adobe-B-oaNVGg.js +1 -0
  5. package/dist/ui/assets/adobe-CrAdS9SD.js +2 -0
  6. package/dist/ui/assets/{agent-message-to-chat-ChcTjd5F.js → agent-message-to-chat-BAWaR5C4.js} +1 -1
  7. package/dist/ui/assets/{anthropic-CltEkzGo.js → anthropic-DVpFSsKH.js} +2 -2
  8. package/dist/ui/assets/{apps-vzxUl8nN.js → apps-BHERTKiO.js} +1 -1
  9. package/dist/ui/assets/azure-openai-C-826Dlw.js +1 -0
  10. package/dist/ui/assets/azure-openai-DvGwGsI1.js +1 -0
  11. package/dist/ui/assets/azure-openai-responses-BPLbXfA6.js +1 -0
  12. package/dist/ui/assets/bedrock-camp-D64i9rke.js +1 -0
  13. package/dist/ui/assets/{bsh-watchdog-B1TPqoBQ.js → bsh-watchdog-ClOjddgN.js} +1 -1
  14. package/dist/ui/assets/{cdp-CujGeIJU.js → cdp-Cbi5Katl.js} +3 -3
  15. package/dist/ui/assets/{clipboard-C2cR8flR.js → clipboard-DgFtRQbq.js} +1 -1
  16. package/dist/ui/assets/composer-speech-BuzPv_Yy.js +1 -0
  17. package/dist/ui/assets/{connect-surface-jUsi5PyQ.js → connect-surface-D6ECkvh5.js} +1 -1
  18. package/dist/ui/assets/context-compaction-DJF_qJZJ.js +27 -0
  19. package/dist/ui/assets/diagnostics-mI-AnKx_.js +1 -0
  20. package/dist/ui/assets/dip-ilEHW-Zu.js +1 -0
  21. package/dist/ui/assets/dist-CSwuvPa6.js +4 -0
  22. package/dist/ui/assets/{dist-DwJ61hEj.js → dist-CvzfEfDj2.js} +1 -1
  23. package/dist/ui/assets/{dist-CBvnVOEd.js → dist-Dejj5eGe.js} +1 -1
  24. package/dist/ui/assets/{dist-dBl5PjGe.js → dist-l3FWXCp1.js} +1 -1
  25. package/dist/ui/assets/{es-CnYi0fp5.js → es-BxwKdh2y.js} +1 -1
  26. package/dist/ui/assets/esp8266-BPLrOmN4.js +1 -0
  27. package/dist/ui/assets/{esptool-operations-CfNLR8qu.js → esptool-operations-CiX8mbpu.js} +2 -2
  28. package/dist/ui/assets/event-stream-Cs43PhOB.js +1 -0
  29. package/dist/ui/assets/{fs-DXM6_XIF.js → fs-BDe3kEbh.js} +1 -1
  30. package/dist/ui/assets/fs-D2X8IzCo.js +2 -0
  31. package/dist/ui/assets/github-BAqz3bbU.js +1 -0
  32. package/dist/ui/assets/github-BPoxioKX.js +2 -0
  33. package/dist/ui/assets/github-copilot-C7kttkXK.js +1 -0
  34. package/dist/ui/assets/github-copilot-Colai-cF.js +2 -0
  35. package/dist/ui/assets/google-shared-CVRDRmWo.js +11 -0
  36. package/dist/ui/assets/google-syj0sMxL.js +1 -0
  37. package/dist/ui/assets/google-vertex-CzAYHmbM.js +1 -0
  38. package/dist/ui/assets/hear-W4qlQvtc.js +1 -0
  39. package/dist/ui/assets/{hear-D7LjCnnn.js → hear-lee28_gN.js} +1 -1
  40. package/dist/ui/assets/hosted-config-apply-uAym2aS5.js +1 -0
  41. package/dist/ui/assets/json-parse-BUunmmNl.js +3 -0
  42. package/dist/ui/assets/{kernel-worker-B2ABxAEr.js → kernel-worker-ic1QU0mg.js} +1056 -1056
  43. package/dist/ui/assets/kokoro-IuvgZkZk.js +4 -0
  44. package/dist/ui/assets/kokoro-engine-B330eLPz.js +2 -0
  45. package/dist/ui/assets/{kokoro-engine-yfBASo8d.js → kokoro-engine-C5c0LOmY.js} +1 -1
  46. package/dist/ui/assets/legacy-styles-4PP74ISo.js +2 -0
  47. package/dist/ui/assets/{lick-ws-bridge-Ct6u2TbW.js → lick-ws-bridge-C0dPnE8i.js} +1 -1
  48. package/dist/ui/assets/{local-llm-Dq1pfvQ-.js → local-llm-DzOVooE9.js} +2 -2
  49. package/dist/ui/assets/logger-DDBAeTLF.js +1 -0
  50. package/dist/ui/assets/magick-wasm-BvNy9LFP.js +1 -0
  51. package/dist/ui/assets/main-DqjICHRh.js +22 -0
  52. package/dist/ui/assets/main-cherry-Bap_NTtV.js +1 -0
  53. package/dist/ui/assets/mime-types-ugOWOUZ9.js +1 -0
  54. package/dist/ui/assets/{mistral-DVlL8TT7.js → mistral-pCZ0Zm3T.js} +2 -2
  55. package/dist/ui/assets/mount-CCmhX5cE.js +2 -0
  56. package/dist/ui/assets/{mount-B0bCtsNy.js → mount-DqjQTDCU.js} +1 -1
  57. package/dist/ui/assets/mount-id-DtHfwjbZ.js +1 -0
  58. package/dist/ui/assets/mount-picker-popup-BORxgnGu.js +1 -0
  59. package/dist/ui/assets/new-session-DeH2bC1U.js +1 -0
  60. package/dist/ui/assets/oauth-bootstrap-B6wP6zi_.js +2 -0
  61. package/dist/ui/assets/oauth-service-CTlktxVj.js +1 -0
  62. package/dist/ui/assets/onboarding-orchestrator-MNoD_6wi.js +1 -0
  63. package/dist/ui/assets/openai-codex-C_G8kpA8.js +1 -0
  64. package/dist/ui/assets/openai-codex-DKhn8od8.js +1 -0
  65. package/dist/ui/assets/{openai-codex-responses-Cw7sZSKi.js → openai-codex-responses-C8xgMZBo.js} +3 -3
  66. package/dist/ui/assets/openai-completions-Dry_mhhJ.js +5 -0
  67. package/dist/ui/assets/openai-responses-Bmov8oh7.js +1 -0
  68. package/dist/ui/assets/{openai-responses-shared-Bf0GVnxb.js → openai-responses-shared-Ct3FUe7d.js} +4 -4
  69. package/dist/ui/assets/panel-rpc-DqT2FG7c.js +1 -0
  70. package/dist/ui/assets/panel-rpc-handlers-CEpB4s-n.js +2 -0
  71. package/dist/ui/assets/{picker-approval-ZlSNf9XH.js → picker-approval-tzbkMw-e.js} +1 -1
  72. package/dist/ui/assets/preload-helper-zJ_50EbN.js +1 -0
  73. package/dist/ui/assets/provider-Bu84IJif.js +1 -0
  74. package/dist/ui/assets/provider-CkWZObGz.js +2 -0
  75. package/dist/ui/assets/provider-store-access-6diGA3zc.js +1 -0
  76. package/dist/ui/assets/provider-store-access-KstUmZ39.js +1 -0
  77. package/dist/ui/assets/{providers-BkYhxKu6.js → providers-Dqi1y25H.js} +1 -1
  78. package/dist/ui/assets/quick-llm-7TCMcdio.js +1 -0
  79. package/dist/ui/assets/remote-cdp-transport-Cf0sDZ5N.js +1 -0
  80. package/dist/ui/assets/{remote-terminal-view-CAspkbd0.js → remote-terminal-view-FVcjc7kw.js} +1 -1
  81. package/dist/ui/assets/secret-env-DcfTe28K.js +1 -0
  82. package/dist/ui/assets/session-freezer-1L0xsBeg.js +1 -0
  83. package/dist/ui/assets/setup-sprinkle-exec-BGXT8k4k.js +1 -0
  84. package/dist/ui/assets/setup-sudo-_cBqLWHH.js +1 -0
  85. package/dist/ui/assets/slicc-editor-BdfBeQCF.js +12 -0
  86. package/dist/ui/assets/speak-C8nGyR-z.js +1 -0
  87. package/dist/ui/assets/{speak-BP4kRSob.js → speak-lc1xl5Fy.js} +1 -1
  88. package/dist/ui/assets/sprinkle-manager-Pfbc1BH8.js +1 -0
  89. package/dist/ui/assets/{sprinkle-renderer-VEg0Lrdb.js → sprinkle-renderer-GiRRbdBx.js} +3 -3
  90. package/dist/ui/assets/src-DlEHAkLd.js +1 -0
  91. package/dist/ui/assets/{store-CwrBveMa.js → store-B3VfUVG6.js} +1 -1
  92. package/dist/ui/assets/{sudo-zQotxIxd.js → sudo-CZTI9OeD.js} +1 -1
  93. package/dist/ui/assets/sync-dialog-BFKWO6DT.js +1 -0
  94. package/dist/ui/assets/tool-ui-YOPqzMmL.js +1 -0
  95. package/dist/ui/assets/transform-messages-DzB_lMo-.js +1 -0
  96. package/dist/ui/assets/{transformers-env-BpvHTeJT.js → transformers-env-CCpYiaIa.js} +1 -1
  97. package/dist/ui/assets/{transformers.web-CZmmPdTH.js → transformers.web-C9_H_wuQ.js} +1 -1
  98. package/dist/ui/assets/{tray-leave-runtime-LeLWNjL3.js → tray-leave-runtime-CdAgBa02.js} +1 -1
  99. package/dist/ui/assets/{upgrade-detection-CG244vbe.js → upgrade-detection--E7KkpNj.js} +1 -1
  100. package/dist/ui/assets/voice-reply-BdYE1gSs.js +1 -0
  101. package/dist/ui/assets/wc-attach-DAWHF0q6.js +13 -0
  102. package/dist/ui/assets/{wc-detached-CaTkd06a.js → wc-detached-DaE992Vl.js} +1 -1
  103. package/dist/ui/assets/wc-extension-CI60x7Bm.js +2 -0
  104. package/dist/ui/assets/{wc-live-D-74QVkK.js → wc-live-C_qPXh6O.js} +11 -11
  105. package/dist/ui/assets/wc-nav-Fk2p4da7.js +2 -0
  106. package/dist/ui/assets/wc-onboarding-CKZm1pcF.js +2 -0
  107. package/dist/ui/assets/wc-placeholder-DcxEXlT1.js +4 -0
  108. package/dist/ui/assets/{wc-settings-FThSal5a.js → wc-settings-CrD6Tm6Z.js} +3 -3
  109. package/dist/ui/assets/{wc-shell-DZWnmdP6.js → wc-shell-DPYESGkK.js} +4 -4
  110. package/dist/ui/assets/wc-sprinkles-DEfLhO36.js +2 -0
  111. package/dist/ui/assets/wc-tray-CP8sez4_.js +5 -0
  112. package/dist/ui/assets/wc-voice-erm0EtRv.js +1 -0
  113. package/dist/ui/assets/welcome-detection-Cr8mNEkt.js +1 -0
  114. package/dist/ui/assets/whisper-session-DwkDWttW.js +2 -0
  115. package/dist/ui/assets/xai-grok-BpmkOGg0.js +1 -0
  116. package/dist/ui/assets/xai-grok-CUqytO26.js +1 -0
  117. package/dist/ui/index.html +15 -1
  118. package/dist/ui/packages/webapp/index.html +15 -1
  119. package/package.json +1 -1
  120. package/dist/ui/assets/adobe-BwRrpnWQ.js +0 -2
  121. package/dist/ui/assets/adobe-YCqMd4M8.js +0 -1
  122. package/dist/ui/assets/azure-openai-5Rfc0X5i.js +0 -1
  123. package/dist/ui/assets/azure-openai-aAwJc4Fa.js +0 -1
  124. package/dist/ui/assets/azure-openai-responses-DESC-gcX.js +0 -1
  125. package/dist/ui/assets/composer-speech-DfnD3xcC.js +0 -1
  126. package/dist/ui/assets/dip-Dggx_orS.js +0 -1
  127. package/dist/ui/assets/esp8266-CMGB5YBw.js +0 -1
  128. package/dist/ui/assets/fs-CYeTnPI-.js +0 -2
  129. package/dist/ui/assets/github-BSPJYOw7.js +0 -1
  130. package/dist/ui/assets/github-DU8PC7nW.js +0 -2
  131. package/dist/ui/assets/github-copilot-BFJtAP76.js +0 -2
  132. package/dist/ui/assets/github-copilot-DRgOjqUh.js +0 -1
  133. package/dist/ui/assets/google-SsK6qdQk.js +0 -1
  134. package/dist/ui/assets/google-shared-CZRDSncd.js +0 -11
  135. package/dist/ui/assets/google-vertex-Cmb8gKhI.js +0 -1
  136. package/dist/ui/assets/hear-CCWbFt5_.js +0 -1
  137. package/dist/ui/assets/hosted-config-apply-DsUClJCf.js +0 -1
  138. package/dist/ui/assets/kokoro-ZxnO-aOl.js +0 -4
  139. package/dist/ui/assets/kokoro-engine-DyvWt6FN.js +0 -2
  140. package/dist/ui/assets/legacy-styles-BgH6AX8T.js +0 -2
  141. package/dist/ui/assets/magick-wasm-C5I4sRv-.js +0 -1
  142. package/dist/ui/assets/main-VDVlW6vJ.js +0 -88
  143. package/dist/ui/assets/main-cherry-DoViGBUI.js +0 -1
  144. package/dist/ui/assets/mount-CqEOKmto.js +0 -2
  145. package/dist/ui/assets/mount-id-BL7k4LOS.js +0 -1
  146. package/dist/ui/assets/mount-picker-popup-L-IvOEYc.js +0 -1
  147. package/dist/ui/assets/new-session-BCfdkRT4.js +0 -1
  148. package/dist/ui/assets/oauth-bootstrap-05gVzJH7.js +0 -2
  149. package/dist/ui/assets/oauth-service-CPXp6Df0.js +0 -1
  150. package/dist/ui/assets/onboarding-orchestrator-D86cOg_Y.js +0 -1
  151. package/dist/ui/assets/openai-codex-Ce9D8qSi.js +0 -1
  152. package/dist/ui/assets/openai-codex-WUlFTC7l.js +0 -1
  153. package/dist/ui/assets/openai-completions-BANj7Zwf.js +0 -5
  154. package/dist/ui/assets/openai-responses-Bdz_r-35.js +0 -1
  155. package/dist/ui/assets/panel-rpc-handlers-D9E1NuOF.js +0 -2
  156. package/dist/ui/assets/provider-BD44wd5M.js +0 -2
  157. package/dist/ui/assets/provider-DchdZ_iY.js +0 -1
  158. package/dist/ui/assets/provider-settings-Bpero1dy.js +0 -99
  159. package/dist/ui/assets/provider-store-access-BRsxr8aG.js +0 -1
  160. package/dist/ui/assets/provider-store-access-CXH2pv7H.js +0 -1
  161. package/dist/ui/assets/quick-llm-C7qsNQ23.js +0 -1
  162. package/dist/ui/assets/remote-cdp-transport-CY4HCHMt.js +0 -1
  163. package/dist/ui/assets/secret-env-ClpNQz5E.js +0 -1
  164. package/dist/ui/assets/session-freezer-CDJ0LMDM.js +0 -1
  165. package/dist/ui/assets/setup-sprinkle-exec-3Ce8eZIO.js +0 -1
  166. package/dist/ui/assets/setup-sudo-DvCouRbU.js +0 -1
  167. package/dist/ui/assets/slicc-editor-3x24ubXG.js +0 -12
  168. package/dist/ui/assets/speak-ClR2IFMA.js +0 -1
  169. package/dist/ui/assets/sprinkle-manager-CnY6ywkn.js +0 -1
  170. package/dist/ui/assets/sync-dialog-Du9ou3tH.js +0 -1
  171. package/dist/ui/assets/tray-runtime-config-BRnpyDNS.js +0 -1
  172. package/dist/ui/assets/voice-reply-DKjUm-gK.js +0 -1
  173. package/dist/ui/assets/wc-attach-BhTWbr7A.js +0 -13
  174. package/dist/ui/assets/wc-extension-CBhrd25w.js +0 -2
  175. package/dist/ui/assets/wc-nav-sEwx5MmG.js +0 -2
  176. package/dist/ui/assets/wc-onboarding-B8ix1fhH.js +0 -2
  177. package/dist/ui/assets/wc-placeholder-CxOC717D.js +0 -4
  178. package/dist/ui/assets/wc-sprinkles-DBsp5Mxm.js +0 -2
  179. package/dist/ui/assets/wc-tray-6hyXFRhO.js +0 -5
  180. package/dist/ui/assets/wc-voice-DWqHH3C5.js +0 -1
  181. package/dist/ui/assets/welcome-detection-DDhgn9wj.js +0 -1
  182. package/dist/ui/assets/whisper-session-D6m7AmYy.js +0 -2
  183. package/dist/ui/assets/xai-grok-BmiypN03.js +0 -1
  184. package/dist/ui/assets/xai-grok-sUSfoNvO.js +0 -1
  185. /package/dist/ui/assets/{dist-C6lFkA1A.js → dist-C6lFkA1A2.js} +0 -0
@@ -1 +0,0 @@
1
- import{i as e,p as t,t as n}from"./provider-settings-Bpero1dy.js";import{a as r,b as i,f as a,g as o,i as s,m as c,o as l,s as u,v as d}from"./bedrock-camp-wxdDcDkR.js";import{d as f,o as p,u as m}from"./transform-messages-C1X1O3BY.js";import{m as h}from"./kernel-worker-B2ABxAEr.js";import{getOAuthPageOrigin as ee}from"./oauth-service-DQVciyk_.js";var g={proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`};function te(e,t){return r(e,t)}function _(e,t,n){return e!==`xhigh`||!t?e:u(t,n)?`xhigh`:l(t,n)?`max`:`high`}function ne(e,t){let n=e?t?.thinkingLevelMap?.[e]:void 0;return _((()=>{if(typeof n==`string`)return n;switch(e){case`minimal`:case`low`:return`low`;case`medium`:return`medium`;case`xhigh`:return`xhigh`;default:return`high`}})(),t?.id,t?.name)}function v(e,t){return async(n,r)=>{let i=t?await t(n,r)??n:n,a=i.thinking;return a&&a.type===`enabled`&&(i.thinking={type:`adaptive`,...a.display===void 0?{}:{display:a.display}},i.output_config={...i.output_config??{},effort:e}),i}}function y(e,t){if(!te(e.id,e.name))return t;let n=t,r=_(n.effort??ne(n.reasoning,e),e.id,e.name);return{...t,onPayload:v(r,n.onPayload)}}function b(e,t){let n={id:e.id,name:e.name??e.id},r=t?.api??e.api,i=t?.context_window??e.context_window,a=t?.max_tokens??e.max_tokens,o=t?.reasoning??e.reasoning,s=t?.input??e.input;return r&&(n.api=r),i!==void 0&&(n.context_window=i),a!==void 0&&(n.max_tokens=a),o!==void 0&&(n.reasoning=o),s&&(n.input=s),/haiku/i.test(e.id)&&(n.compat={supportsEagerToolInputStreaming:!1}),n}function x(e=3e5){let t=0;return{async run(n,r=Date.now()){if(r<t)return null;let i=null;try{i=await n()}catch(e){console.debug(`[silent-renew-backoff] renew threw:`,e instanceof Error?e.message:String(e)),i=null}return t=i?0:r+e,i},inCooldown(e=Date.now()){return e<t}}}const S=Object.assign({"/packages/webapp/providers/adobe-config.json":g})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function C(){let t=e(`adobe`);if(t)return t.replace(/\/$/,``);if(S.proxyEndpoint)return S.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}const w=new Map,T=new Map,E=`slicc-adobe-models`;function D(e){try{localStorage.setItem(E,JSON.stringify(e))}catch{}}async function O(e){let t=w.get(e);if(t)return t;try{let t=await fetch(`${e}/v1/config`,{headers:{[U]:`4.1.0`}});if(t.ok){let n=await t.json();return w.set(e,n),n}console.warn(`[adobe] Proxy /v1/config returned ${t.status}, falling back to build-time config`)}catch(e){console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e))}let n={};return w.set(e,n),n}function k(e){let t=e.clientId||S.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function A(e){return e.scopes||S.scopes}function j(e){return e.imsEnvironment||S.imsEnvironment||`prod`}const M={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function N(e){return M[e??S.imsEnvironment??`prod`]??M.prod}const P=typeof chrome<`u`&&!!chrome?.runtime?.id;function F(){return n().find(e=>e.providerId===`adobe`)}async function I(e,t){try{let n=await fetch(`${N(t)}/ims/userinfo/v2`,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){let e=await n.json();return{name:e.displayName||e.name||e.email,avatar:e.picture||e.avatar_url}}console.warn(`[adobe] User profile fetch returned ${n.status}, account will have no display name`)}catch(e){console.warn(`[adobe] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function L(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10)}:null}const R={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!S.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`,`admin.hlx.page`,`admin.hlx.live`,`admin.aem.page`,`admin.aem.live`],getModelIds:()=>{let e=e=>b(e,T.get(e.id));for(let t of Q.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id}));return D(n),n}for(let t of w.values())if(t.models?.length)return t.models.map(t=>e(t));try{let e=localStorage.getItem(E);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(e,n,r)=>{let i=C(),a=await O(i),o=k(a),s=A(a),c=j(a),l=P?null:await ee(),u=P?S.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:S.redirectUri??`${l.origin}/auth/callback`,d=P?void 0:btoa(JSON.stringify({port:parseInt(new URL(l.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),f=d?JSON.parse(atob(d)).nonce:null,p=new URLSearchParams({client_id:o,scope:s,response_type:`token`,redirect_uri:u});d&&p.set(`state`,d),r?.forceReauth&&p.set(`prompt`,`login`);let m=await e(`${N(c)}/ims/authorize/v2?${p}`);if(!m)return;if(f&&m)try{if(new URL(m).searchParams.get(`nonce`)!==f){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let h=L(m);if(!h){console.error(`[adobe] Could not extract token from redirect URL`);return}let g=await I(h.accessToken,c);await t({providerId:`adobe`,accessToken:h.accessToken,tokenExpiresAt:Date.now()+h.expiresIn*1e3,userName:g.name,userAvatar:g.avatar,baseUrl:S.proxyEndpoint?void 0:i}),await $().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),n()},onOAuthLogout:async()=>{let e=F();if(e?.accessToken)try{let t=w.values().next().value??{},n=t.clientId||S.clientId,r=j(t);if(n){let t=await fetch(`${N(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:e.accessToken,token_type_hint:`access_token`,client_id:n})});t.ok||console.warn(`[adobe] Token revocation returned ${t.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await t({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>F()?.accessToken?H():null,refreshModels:async e=>{await $(e);let t=R.getModelIds?.();t?.length&&D(t)}};let z=null;const B=x();async function V(){let e=F();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);let t=await B.run(()=>H());if(t)return t;let n=F();if((n?.tokenExpiresAt??0)-Date.now()>0&&n?.accessToken)return n.accessToken;throw Error(`Adobe session expired — please log in again`)}function re(){let e=F();return e?.tokenExpiresAt?Date.now()>e.tokenExpiresAt-6e4:!0}async function H(){return typeof window>`u`?null:z||(z=(async()=>{try{let e=C(),n=await O(e),r=k(n),i=A(n),a=j(n),o=P?S.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:S.redirectUri??`${window.location.origin}/auth/callback`,s=P?void 0:btoa(JSON.stringify({port:parseInt(new URL(window.location.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),c=s?JSON.parse(atob(s)).nonce:null,l=new URLSearchParams({client_id:r,scope:i,response_type:`token`,redirect_uri:o,prompt:`none`});s&&l.set(`state`,s);let u=`${N(a)}/ims/authorize/v2?${l}`,{createOAuthLauncher:d}=await import(`./oauth-service-DQVciyk_.js`),f=await d()(u,{interactive:!1});if(!f)return null;if(c&&f)try{if(new URL(f).searchParams.get(`nonce`)!==c)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),null}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let p=L(f);if(!p)return null;let m=F();return await t({providerId:`adobe`,accessToken:p.accessToken,tokenExpiresAt:Date.now()+p.expiresIn*1e3,userName:m?.userName,userAvatar:m?.userAvatar,baseUrl:S.proxyEndpoint?void 0:e}),console.log(`[adobe] Token renewed silently`),await $().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),p.accessToken}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}finally{z=null}})(),z)}const U=`X-Slicc-Version`;function W(e){let t={};if(e.headers)for(let[n,r]of Object.entries(e.headers))n.toLowerCase()!==`x-slicc-version`&&(t[n]=r);return t[U]=`4.1.0`,{...e,headers:t}}const G=new Set;function K(e,t){if(e.headers){for(let t of Object.keys(e.headers))if(t.toLowerCase()===`x-session-id`)return e}return G.has(t)||(G.add(t),console.warn(`[adobe] Missing X-Session-Id from ${t} — using daily fallback. Attach an X-Session-Id header at the call site (see scoop-context.ts streamWithSessionId or docs/pitfalls.md).`)),{...e,headers:{...e.headers??{},"X-Session-Id":h(`adobe-provider-fallback`)}}}function q(){G.clear()}function J(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,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 Y=(e,t,n={})=>{let r=p();return(async()=>{try{let i=await V();if(String(e.api).includes(`openai`)){let a=c({...e,baseUrl:`${C()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,W(K({...n,apiKey:i},`streamAdobe[openai]`)));for await(let e of a)r.push(e)}else{let o=a({...e,baseUrl:C(),api:`anthropic-messages`},t,W(K(y(e,s(e.id,e.name,{...n,apiKey:i})),`streamAdobe[anthropic]`)));for await(let e of o)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(J(e,t)),r.end()}})(),r},X=(e,t,n)=>{let r=p();return(async()=>{try{let i=await V();if(String(e.api).includes(`openai`)){let a=d({...e,baseUrl:`${C()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,W(K({...n,apiKey:i},`streamSimpleAdobe[openai]`)));for await(let e of a)r.push(e)}else{let a=o({...e,baseUrl:C(),api:`anthropic-messages`},t,W(K(y(e,s(e.id,e.name,{...n,apiKey:i})),`streamSimpleAdobe[anthropic]`)));for await(let e of a)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(J(e,t)),r.end()}})(),r};async function Z(e){try{let t=e??await V(),n=C(),r=await fetch(`${n}/v1/models`,{headers:{Authorization:`Bearer ${t}`,[U]:`4.1.0`}});if(r.ok){let e=await r.json();if(e.data?.length){for(let t of e.data){let e={id:t.id,name:t.name};t.api!==void 0&&(e.api=t.api),t.context_window!==void 0&&(e.context_window=t.context_window),t.max_tokens!==void 0&&(e.max_tokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),T.set(t.id,e)}let t=new Map;for(let e of f())try{for(let n of m(e))t.set(n.id,n)}catch{}return e.data.map(e=>{let r=t.get(e.id),i=`adobe-${e.api===`openai`?`openai`:`anthropic`}`;return r?{...r,provider:`adobe`,api:i}:{id:e.id,name:e.name??e.id,provider:`adobe`,api:i,baseUrl:n,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},inputCost:0,outputCost:0,cacheReadCost:0,cacheWriteCost:0,reasoning:!0}})}}else console.warn(`[adobe] Proxy /v1/models returned ${r.status}, falling back to Anthropic models`)}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return null}const Q=new Map;function ie(){return m(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}async function $(e){let t=C(),n=Q.get(t);if(n)return n;let r=await Z(e);return r?(Q.set(t,r),r):ie()}function ae(){i({api:`adobe-anthropic`,stream:Y,streamSimple:X}),i({api:`adobe-openai`,stream:Y,streamSimple:X})}export{q as __resetAdobeSessionIdWarningCacheForTests,R as config,$ as getAdobeModels,V as getValidAccessToken,re as isTokenExpired,ae as register};
@@ -1 +0,0 @@
1
- import{F as e,L as t,St as n,kt as r,l as i,s as a,xt as o}from"./main-VDVlW6vJ.js";import{t as s}from"./openai-Cn5LRPCm.js";var c=`azure-openai`,l=`2024-12-01-preview`,u={id:c,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:l,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let e=i(c);if(!e)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return t.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:t.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function d(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function f(t,n){let r=e(t.messages,n,d),i=[];for(let e of r)if(e.role===`user`)if(typeof e.content==`string`)i.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});i.push({role:`user`,content:t})}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),r=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));r.length?i.push({role:`assistant`,content:n||null,tool_calls:r}):i.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;i.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return i}function p(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function m(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function h(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}var g=(e,t,r={})=>{let i=o();return(async()=>{let o={role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:c,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:`stop`,timestamp:Date.now()};try{let u=r.apiKey;if(!u)throw Error(`Azure API key is required`);let d=e.baseUrl;if(!d)throw Error(`Azure endpoint is required`);let g=e.id,_={};e.headers&&Object.assign(_,e.headers),r.headers&&Object.assign(_,r.headers);let v=a(c)||l,y=new s({endpoint:d.replace(/\/+$/,``),apiKey:u,deployment:g,apiVersion:v,dangerouslyAllowBrowser:!0,defaultHeaders:_}),b=[...t.systemPrompt?[{role:`system`,content:t.systemPrompt}]:[],...f(t,e)],x=p(t.tools),S=await y.chat.completions.create({model:g,messages:b,stream:!0,stream_options:{include_usage:!0},...r.maxTokens?{max_completion_tokens:r.maxTokens}:{},...r.temperature===void 0?{}:{temperature:r.temperature},...x?{tools:x}:{}});i.push({type:`start`,partial:o});for await(let t of S){t.usage&&(o.usage.input=t.usage.prompt_tokens??0,o.usage.output=t.usage.completion_tokens??0,o.usage.totalTokens=t.usage.total_tokens??0,n(e,o.usage));for(let e of t.choices??[]){let t=e.delta;if(t){if(t.content){let{block:e,index:n}=m(o);e.text===``&&i.push({type:`text_start`,contentIndex:n,partial:o}),e.text+=t.content,i.push({type:`text_delta`,contentIndex:n,delta:t.content,partial:o})}if(t.tool_calls)for(let e of t.tool_calls){let t=e.id?h(o,e.id):void 0;if(!t&&e.id&&(t={type:`toolCall`,id:e.id,name:e.function?.name??``,arguments:{},_partialJson:``},o.content.push(t),i.push({type:`toolcall_start`,contentIndex:o.content.length-1,partial:o})),t&&e.function?.arguments){t._partialJson+=e.function.arguments;try{t.arguments=JSON.parse(t._partialJson)}catch{}i.push({type:`toolcall_delta`,contentIndex:o.content.indexOf(t),delta:e.function.arguments,partial:o})}}e.finish_reason&&(o.stopReason=e.finish_reason===`tool_calls`?`toolUse`:e.finish_reason===`length`?`length`:`stop`)}}}for(let e of o.content){let t=o.content.indexOf(e);if(e.type===`toolCall`){let n=e;try{n.arguments=JSON.parse(n._partialJson||`{}`)}catch{}delete n._partialJson,i.push({type:`toolcall_end`,contentIndex:t,toolCall:e,partial:o})}else e.type===`text`&&i.push({type:`text_end`,contentIndex:t,content:e.text,partial:o})}i.push({type:`done`,reason:o.stopReason,message:o}),i.end()}catch(e){o.stopReason=r.signal?.aborted?`aborted`:`error`,o.errorMessage=e instanceof Error?e.message:JSON.stringify(e),i.push({type:`error`,reason:o.stopReason,error:o}),i.end()}})(),i},_=(e,n,r)=>{let i=r?.apiKey;if(!i)throw Error(`Azure API key is required`);return g(e,n,{...t(e,r,i)})};function v(){r({api:`azure-openai-anthropic`,stream:g,streamSimple:_})}export{u as config,v as register};
@@ -1 +0,0 @@
1
- import{a as e,r as t}from"./provider-settings-Bpero1dy.js";import{b as n}from"./bedrock-camp-wxdDcDkR.js";import{o as r,r as i,s as a,t as o}from"./transform-messages-C1X1O3BY.js";import{t as s}from"./openai-i4HWKCeW.js";const c=`azure-openai`,l=`2024-12-01-preview`,u={id:c,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:l,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let t=e(c);if(!t)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let n=t.split(`,`).map(e=>e.trim()).filter(Boolean);return n.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:n.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function d(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function f(e,t){let n=o(e.messages,t,d),r=[];for(let e of n)if(e.role===`user`)if(typeof e.content==`string`)r.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});r.push({role:`user`,content:t})}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),i=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));i.length?r.push({role:`assistant`,content:n||null,tool_calls:i}):r.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;r.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return r}function p(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function m(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function h(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}const g=(e,n,i={})=>{let o=r();return(async()=>{let r={role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:c,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:`stop`,timestamp:Date.now()};try{let u=i.apiKey;if(!u)throw Error(`Azure API key is required`);let d=e.baseUrl;if(!d)throw Error(`Azure endpoint is required`);let g=e.id,_={};e.headers&&Object.assign(_,e.headers),i.headers&&Object.assign(_,i.headers);let v=t(c)||l,y=new s({endpoint:d.replace(/\/+$/,``),apiKey:u,deployment:g,apiVersion:v,dangerouslyAllowBrowser:!0,defaultHeaders:_}),b=[...n.systemPrompt?[{role:`system`,content:n.systemPrompt}]:[],...f(n,e)],x=p(n.tools),S=await y.chat.completions.create({model:g,messages:b,stream:!0,stream_options:{include_usage:!0},...i.maxTokens?{max_completion_tokens:i.maxTokens}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...x?{tools:x}:{}});o.push({type:`start`,partial:r});for await(let t of S){t.usage&&(r.usage.input=t.usage.prompt_tokens??0,r.usage.output=t.usage.completion_tokens??0,r.usage.totalTokens=t.usage.total_tokens??0,a(e,r.usage));for(let e of t.choices??[]){let t=e.delta;if(t){if(t.content){let{block:e,index:n}=m(r);e.text===``&&o.push({type:`text_start`,contentIndex:n,partial:r}),e.text+=t.content,o.push({type:`text_delta`,contentIndex:n,delta:t.content,partial:r})}if(t.tool_calls)for(let e of t.tool_calls){let t=e.id?h(r,e.id):void 0;if(!t&&e.id&&(t={type:`toolCall`,id:e.id,name:e.function?.name??``,arguments:{},_partialJson:``},r.content.push(t),o.push({type:`toolcall_start`,contentIndex:r.content.length-1,partial:r})),t&&e.function?.arguments){t._partialJson+=e.function.arguments;try{t.arguments=JSON.parse(t._partialJson)}catch{}o.push({type:`toolcall_delta`,contentIndex:r.content.indexOf(t),delta:e.function.arguments,partial:r})}}e.finish_reason&&(r.stopReason=e.finish_reason===`tool_calls`?`toolUse`:e.finish_reason===`length`?`length`:`stop`)}}}for(let e of r.content){let t=r.content.indexOf(e);if(e.type===`toolCall`){let n=e;try{n.arguments=JSON.parse(n._partialJson||`{}`)}catch{}delete n._partialJson,o.push({type:`toolcall_end`,contentIndex:t,toolCall:e,partial:r})}else e.type===`text`&&o.push({type:`text_end`,contentIndex:t,content:e.text,partial:r})}o.push({type:`done`,reason:r.stopReason,message:r}),o.end()}catch(e){r.stopReason=i.signal?.aborted?`aborted`:`error`,r.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:`error`,reason:r.stopReason,error:r}),o.end()}})(),o},_=(e,t,n)=>{let r=n?.apiKey;if(!r)throw Error(`Azure API key is required`);return g(e,t,{...i(e,n,r)})};function v(){n({api:`azure-openai-anthropic`,stream:g,streamSimple:_})}export{u as config,v as register};
@@ -1 +0,0 @@
1
- import{Ct as e,L as t,bt as n}from"./main-VDVlW6vJ.js";import{t as r}from"./headers-DO1UzNKu.js";import{t as i}from"./openai-Cn5LRPCm.js";import{t as a}from"./openai-prompt-cache-DXo9f3w5.js";import{n as o,r as s,t as c}from"./openai-responses-shared-Bf0GVnxb.js";var l=`v1`,u=new Set([`openai`,`openai-codex`,`opencode`,`azure-openai-responses`]);function d(e){let t=new Map;if(!e)return t;for(let n of e.split(`,`)){let e=n.trim();if(!e)continue;let[r,i]=e.split(`=`,2);!r||!i||t.set(r.trim(),i.trim())}return t}function f(e,t){return t?.azureDeploymentName?t.azureDeploymentName:d({}.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(e.id)||e.id}function p(e){if(e instanceof Error){let t=e.status,n=typeof t==`number`?t:void 0;return n===void 0?e.message:`Azure OpenAI API error (${n}): ${e.message}`}try{return JSON.stringify(e)}catch{return String(e)}}var m=(e,t,i)=>{let a=new n;return(async()=>{let n=f(e,i),o={role:`assistant`,content:[],api:`azure-openai-responses`,provider:e.provider,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:`stop`,timestamp:Date.now()};try{let c=i?.apiKey;if(!c)throw Error(`No API key for provider: ${e.provider}`);let l=y(e,c,i),u=b(e,t,i,n),d=await i?.onPayload?.(u,e);d!==void 0&&(u=d);let f={...i?.signal?{signal:i.signal}:{},...i?.timeoutMs===void 0?{}:{timeout:i.timeoutMs},maxRetries:i?.maxRetries??0},{data:p,response:m}=await l.responses.create(u,f).withResponse();if(await i?.onResponse?.({status:m.status,headers:r(m.headers)},e),a.push({type:`start`,partial:o}),await s(p,o,a,e),i?.signal?.aborted)throw Error(`Request was aborted`);if(o.stopReason===`aborted`||o.stopReason===`error`)throw Error(`An unknown error occurred`);a.push({type:`done`,reason:o.stopReason,message:o}),a.end()}catch(e){for(let e of o.content)delete e.index,delete e.partialJson;o.stopReason=i?.signal?.aborted?`aborted`:`error`,o.errorMessage=p(e),a.push({type:`error`,reason:o.stopReason,error:o}),a.end()}})(),a},h=(n,r,i)=>{let a=i?.apiKey;if(!a)throw Error(`No API key for provider: ${n.provider}`);let o=t(n,i,a),s=i?.reasoning?e(n,i.reasoning):void 0,c=s===`off`?void 0:s;return m(n,r,{...o,reasoningEffort:c})};function g(e){let t=e.trim().replace(/\/+$/,``),n;try{n=new URL(t)}catch{throw Error(`Invalid Azure OpenAI base URL: ${e}`)}let r=n.hostname.endsWith(`.openai.azure.com`)||n.hostname.endsWith(`.cognitiveservices.azure.com`),i=n.pathname.replace(/\/+$/,``);return r&&(i===``||i===`/`||i===`/openai`)&&(n.pathname=`/openai/v1`,n.search=``),n.toString().replace(/\/+$/,``)}function _(e){return`https://${e}.openai.azure.com/openai/v1`}function v(e,t){let n=t?.azureApiVersion||{}.AZURE_OPENAI_API_VERSION||l,r=t?.azureBaseUrl?.trim()||{}.AZURE_OPENAI_BASE_URL?.trim()||void 0,i=t?.azureResourceName||{}.AZURE_OPENAI_RESOURCE_NAME,a=r;if(!a&&i&&(a=_(i)),!a&&e.baseUrl&&(a=e.baseUrl),!a)throw Error(`Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.`);return{baseUrl:g(a),apiVersion:n}}function y(e,t,n){let r={...e.headers};n?.headers&&Object.assign(r,n.headers);let{baseUrl:a,apiVersion:o}=v(e,n);return new i({apiKey:t,apiVersion:o,dangerouslyAllowBrowser:!0,defaultHeaders:r,baseURL:a})}function b(e,t,n,r){let i={model:r,input:c(e,t,u),stream:!0,prompt_cache_key:a(n?.sessionId)};return n?.maxTokens&&(i.max_output_tokens=n?.maxTokens),n?.temperature!==void 0&&(i.temperature=n?.temperature),t.tools&&t.tools.length>0&&(i.tools=o(t.tools)),e.reasoning&&(n?.reasoningEffort||n?.reasoningSummary?(i.reasoning={effort:n?.reasoningEffort?e.thinkingLevelMap?.[n.reasoningEffort]??n.reasoningEffort:`medium`,summary:n?.reasoningSummary||`auto`},i.include=[`reasoning.encrypted_content`]):e.thinkingLevelMap?.off!==null&&(i.reasoning={effort:e.thinkingLevelMap?.off??`none`})),i}export{m as streamAzureOpenAIResponses,h as streamSimpleAzureOpenAIResponses};
@@ -1 +0,0 @@
1
- import{nt as e}from"./main-VDVlW6vJ.js";import{t}from"./speech-GZe1rUoJ.js";import{i as n,t as r}from"./whisper-session-D6m7AmYy.js";var i=e(`speech:composer`),a=class{#e;#t;#n;#r=null;#i=!1;#a={engine:`builtin`,state:`idle`};#o=new Set;constructor(e={}){this.#e=e.builtin??t(),this.#t=e.loadWhisper??n,this.#n=e.startSession??r}permission(){return this.#e.permission()}requestPermission(){return this.#e.requestPermission()}microphones(){return this.#e.microphones()}status(){return this.#a}onStatus(e){return this.#o.add(e),e(this.#a),()=>this.#o.delete(e)}warmup(){this.#i||(this.#i=!0,this.#c({engine:`builtin`,state:`downloading`}),this.#t(e=>this.#s(e)).then(e=>{this.#r=e,this.#c({engine:`enhanced`,state:`ready`})},e=>{this.#i=!1,this.#c({engine:`builtin`,state:`unavailable`}),i.warn(`enhanced speech engine unavailable`,e)}))}async start(e){let t=this.#r;if(t)try{return await this.#n(t,{deviceId:e.deviceId,lang:e.lang,onPartial:e.onPartial,onError:e.onError})}catch(e){i.warn(`whisper session failed to start; falling back to builtin`,e)}return this.#e.start(e)}get enhancedReady(){return this.#r!==null}#s(e){this.#a.state===`downloading`&&this.#c({engine:`builtin`,state:`downloading`,download:{loaded:e.loaded,total:e.total,etaSeconds:e.etaSeconds}})}#c(e){this.#a=e;for(let t of this.#o)t(e)}},o=null;function s(){return o??=new a,o}export{s as getComposerSpeech};
@@ -1 +0,0 @@
1
- import{m as e}from"./wc-live-D-74QVkK.js";export{e as setDipExecHandler};
@@ -1 +0,0 @@
1
- import{t as e}from"./esptool-operations-CfNLR8qu.js";export{e as ESP8266ROM};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-C6lFkA1A.js","assets/chunk-aKtaBQYM.js","assets/dist-DwJ61hEj.js","assets/mount-CqEOKmto.js","assets/main-VDVlW6vJ.js","assets/modulepreload-polyfill-Dezn_h7o.js","assets/mount-id-BL7k4LOS.js","assets/mount-picker-popup-L-IvOEYc.js","assets/types-idfTVsM8.js","assets/picker-approval-ZlSNf9XH.js"])))=>i.map(i=>d[i]);
2
- import{Ot as e,nt as t}from"./main-VDVlW6vJ.js";import{i as n,n as r,r as i,t as a}from"./path-utils-DU6QhF_k.js";import{t as o}from"./types-idfTVsM8.js";import{n as s,t as c}from"./mount-id-BL7k4LOS.js";var l=t(`fs-watcher`),u=0;function d(e,t){return t===`/`||e===t||e.startsWith(t+`/`)}var f=class{registrations=new Map;watch(e,t,n){let r=`fsw-${++u}`;return this.registrations.set(r,{id:r,basePath:e,filter:t,callback:n}),l.debug(`Watch registered`,{id:r,basePath:e}),()=>{this.registrations.delete(r),l.debug(`Watch unregistered`,{id:r})}}notify(e){if(e.length!==0)for(let[,t]of this.registrations){let n=e.filter(e=>d(e.path,t.basePath)&&t.filter(e.path));if(n.length>0)try{t.callback(n)}catch(e){l.error(`Watch callback error`,{id:t.id,error:e instanceof Error?e.message:String(e)})}}}dispose(){this.registrations.clear(),l.debug(`All watchers disposed`)}get size(){return this.registrations.size}},p=t(`mount-index`),m=class{mounts=new Map;listeners=new Set;registerMount(e,t){this.mounts.get(e)?.abortController?.abort();let n=new AbortController,r={handle:t,state:{status:`pending`,indexed:0},files:new Set,directories:new Set,abortController:n};this.mounts.set(e,r),this.notifyListeners(),this.indexMount(e,r,n.signal)}unregisterMount(e){let t=this.mounts.get(e);t&&(t.abortController?.abort(),this.mounts.delete(e),this.notifyListeners())}async refreshMount(e){let t=this.mounts.get(e);if(!t)throw Error(`No mount at ${e}`);t.abortController?.abort();let n=new AbortController;t.abortController=n,t.state={status:`pending`,indexed:0},t.files.clear(),t.directories.clear(),this.notifyListeners(),await this.indexMount(e,t,n.signal)}isReady(e){return this.mounts.get(e)?.state.status===`ready`}isAnyIndexing(){for(let e of this.mounts.values())if(e.state.status===`indexing`||e.state.status===`pending`)return!0;return!1}dispose(){for(let e of this.mounts.values())e.abortController?.abort();this.mounts.clear(),this.listeners.clear()}getState(e){return this.mounts.get(e)?.state}getFiles(e,t){let n=this.mounts.get(e);if(n?.state.status!==`ready`)return;if(!t)return[...n.files];let r=[];for(let e of n.files)t(e)&&r.push(e);return r}getDirectoryEntries(e,t){let n=this.mounts.get(e);if(n?.state.status!==`ready`)return;let r=t===`/`?`/`:t+`/`,i=new Map;for(let e of n.files){if(!e.startsWith(r))continue;let t=e.slice(r.length);t.includes(`/`)||i.set(t,`file`)}for(let e of n.directories){if(!e.startsWith(r))continue;let t=e.slice(r.length);t.includes(`/`)||i.set(t,`directory`)}return[...i.entries()].map(([e,t])=>({name:e,type:t}))}hasPath(e,t){let n=this.mounts.get(e);if(n?.state.status===`ready`)return n.files.has(t)||n.directories.has(t)}notifyWrite(e){let t=this.findMountForPath(e);if(!t)return;let n=this.mounts.get(t);if(n?.state.status!==`ready`)return;n.files.add(e);let r=e;for(;r!==t;){let e=r.lastIndexOf(`/`);if(e<=0)break;r=r.slice(0,e)||`/`,r.length>=t.length&&n.directories.add(r)}}notifyDelete(e){let t=this.findMountForPath(e);if(!t)return;let n=this.mounts.get(t);if(n?.state.status!==`ready`)return;n.files.delete(e),n.directories.delete(e);let r=e+`/`;for(let e of n.files)e.startsWith(r)&&n.files.delete(e);for(let e of n.directories)e.startsWith(r)&&n.directories.delete(e)}notifyRename(e,t){let n=this.findMountForPath(e);if(!n)return;let r=this.mounts.get(n);if(r?.state.status===`ready`){if(r.files.has(e)){r.files.delete(e),r.files.add(t);return}if(r.directories.has(e)){r.directories.delete(e),r.directories.add(t);let n=e+`/`,i=t+`/`;for(let e of[...r.files])e.startsWith(n)&&(r.files.delete(e),r.files.add(i+e.slice(n.length)));for(let e of[...r.directories])e.startsWith(n)&&(r.directories.delete(e),r.directories.add(i+e.slice(n.length)))}}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}findMountForPath(e){let t;for(let n of this.mounts.keys())(e===n||e.startsWith(n+`/`))&&(!t||n.length>t.length)&&(t=n);return t}notifyListeners(){for(let e of this.listeners)try{e()}catch{}}async indexMount(e,t,n){t.state={status:`indexing`,indexed:0},this.notifyListeners();try{if(await this.walkHandle(e,t.handle,t,n),n.aborted)return;t.state={status:`ready`,indexed:t.files.size+t.directories.size,total:t.files.size+t.directories.size},t.abortController=null,p.info(`Mount indexed`,{path:e,files:t.files.size,directories:t.directories.size})}catch(r){if(n.aborted)return;let i=r instanceof Error?r.message:String(r);t.state={status:`error`,indexed:0,error:i},p.error(`Mount indexing failed`,{path:e,error:i})}this.notifyListeners()}async walkHandle(e,t,n,r){if(r.aborted)return;n.directories.add(e);let i=t;for await(let[t,a]of i){if(r.aborted)return;let i=e===`/`?`/${t}`:`${e}/${t}`;a.kind===`file`?(n.files.add(i),n.state.indexed++):a.kind===`directory`&&await this.walkHandle(i,a,n,r),n.state.indexed%500==0&&(this.notifyListeners(),await new Promise(e=>setTimeout(e,0)))}}},h=class{vfs;allowedPrefixes;readOnlyPrefixes;constructor(e,t,n=[]){this.vfs=e;let i=e=>{let t=r(e);return t.endsWith(`/`)?t:t+`/`};this.allowedPrefixes=t.map(i),this.readOnlyPrefixes=n.map(i)}getAllPrefixes(){let e=this.vfs.listMounts().map(e=>e.endsWith(`/`)?e:e+`/`);return[...this.allowedPrefixes,...this.readOnlyPrefixes,...e]}isAllowed(e){let t=r(e);return this.getAllPrefixes().some(e=>t===e.slice(0,-1)||t.startsWith(e)||t===`/`||e.startsWith(t+`/`))}isAllowedStrict(e){let t=r(e);return this.getAllPrefixes().some(e=>t===e.slice(0,-1)||t.startsWith(e))}isWritable(e){let t=r(e);return this.allowedPrefixes.some(e=>t===e.slice(0,-1)||t.startsWith(e))}canWrite(e){return this.isWritable(e)}checkWrite(e){if(!this.isWritable(e))throw new o(`EACCES`,`permission denied`,r(e))}async resolveAndCheckRead(e){try{let t=await this.vfs.realpath(e);if(!this.isAllowedStrict(t))throw new o(`ENOENT`,`no such file or directory`,r(e));return t}catch(t){throw t instanceof o?t:new o(`ENOENT`,`no such file or directory`,r(e))}}async resolveAndCheckWrite(e){try{let t=await this.vfs.realpath(e);if(!this.isWritable(t))throw new o(`EACCES`,`permission denied`,r(e));return t}catch(t){throw t instanceof o?t:new o(`EACCES`,`permission denied`,r(e))}}getUnderlyingFS(){return this.vfs}invalidatePaths(e){this.vfs.invalidatePaths(e)}isPathUnderMount(e){return this.vfs.isPathUnderMount(e)}async readFile(e,t){if(!this.isAllowedStrict(e))throw new o(`ENOENT`,`no such file or directory`,r(e));let n=await this.resolveAndCheckRead(e);return this.vfs.readFile(n,t)}async readDir(e){if(!this.isAllowed(e))return[];let t=e;if(this.isAllowedStrict(e))try{t=await this.resolveAndCheckRead(e)}catch{return[]}let n=await this.vfs.readDir(t);if(!this.isAllowedStrict(e)){let t=r(e);return n.filter(e=>{let n=t===`/`?`/${e.name}`:`${t}/${e.name}`;return this.isAllowed(n)})}return n}async stat(e){if(!this.isAllowed(e))throw new o(`ENOENT`,`no such file or directory`,r(e));if(this.isAllowedStrict(e)){let t=await this.resolveAndCheckRead(e);return this.vfs.stat(t)}return this.vfs.stat(e)}scanPathForSymlinks(e,t){let n=r(e);if(n===`/`)return!1;let i=n.slice(1).split(`/`),a=t?i.length:i.length-1,o=``;for(let e=0;e<a;e++){o=o+`/`+i[e];let t=this.vfs.lstatSync(o);if(t===null)return null;if(t.type===`symlink`)return!0}return!1}statSync(e){return!this.isAllowedStrict(e)||this.scanPathForSymlinks(e,!0)!==!1?null:this.vfs.statSync(e)}lstatSync(e){return!this.isAllowed(e)||this.scanPathForSymlinks(e,!1)!==!1?null:this.vfs.lstatSync(e)}readDirSync(e){if(!this.isAllowed(e)||this.scanPathForSymlinks(e,!0)!==!1)return null;let t=this.vfs.readDirSync(e);if(t===null)return null;if(this.isAllowedStrict(e))return t;let n=r(e);return t.filter(e=>{let t=n===`/`?`/${e.name}`:`${n}/${e.name}`;return this.isAllowed(t)})}async realpath(e){let t;try{t=await this.vfs.realpath(e)}catch(t){throw t instanceof o?t:new o(`ENOENT`,`no such file or directory`,r(e))}if(!this.isAllowedStrict(t))throw new o(`ENOENT`,`no such file or directory`,r(e));return t}async exists(e){if(!this.isAllowed(e))return!1;if(this.isAllowedStrict(e))try{await this.resolveAndCheckRead(e)}catch{return!1}return this.vfs.exists(e)}async readTextFile(e){if(!this.isAllowedStrict(e))throw new o(`ENOENT`,`no such file or directory`,r(e));let t=await this.resolveAndCheckRead(e);return this.vfs.readTextFile(t)}async*walk(e){if(!this.isAllowed(e))return;let t=e;if(this.isAllowedStrict(e))try{t=await this.resolveAndCheckRead(e)}catch{return}for await(let e of this.vfs.walk(t))this.isAllowed(e)&&(yield e)}async writeFile(e,t,n){this.checkWrite(e);let i=this.vfs.dirname(e),a=this.vfs.basename(e);try{let t=await this.vfs.realpath(i);if(!this.isWritable(t+`/`+a))throw new o(`EACCES`,`permission denied`,r(e))}catch(e){if(e instanceof o&&e.code===`EACCES`)throw e}try{(await this.vfs.lstat(e)).type===`symlink`&&await this.resolveAndCheckWrite(e)}catch(e){if(e instanceof o&&e.code===`EACCES`)throw e}return this.vfs.writeFile(e,t,n)}async mkdir(e,t){this.checkWrite(e);let n=this.vfs.dirname(e),i=this.vfs.basename(e);try{let t=await this.vfs.realpath(n);if(!this.isWritable(t+`/`+i))throw new o(`EACCES`,`permission denied`,r(e))}catch(e){if(e instanceof o&&e.code===`EACCES`)throw e}return this.vfs.mkdir(e,t)}async rm(e,t){this.checkWrite(e);try{(await this.vfs.lstat(e)).type===`symlink`||await this.resolveAndCheckWrite(e)}catch(e){if(e instanceof o&&e.code===`EACCES`)throw e}return this.vfs.rm(e,t)}async rename(e,t){this.checkWrite(e),this.checkWrite(t),await this.resolveAndCheckWrite(e);let n=this.vfs.dirname(t),i=this.vfs.basename(t);try{let e=await this.vfs.realpath(n);if(!this.isWritable(e+`/`+i))throw new o(`EACCES`,`permission denied`,r(t))}catch(e){if(e instanceof o&&e.code===`EACCES`)throw e}return this.vfs.rename(e,t)}async copyFile(e,t){if(!this.isAllowed(e))throw new o(`ENOENT`,`no such file or directory`,r(e));this.checkWrite(t);let n=await this.resolveAndCheckRead(e),i=this.vfs.dirname(t),a=this.vfs.basename(t);try{let e=await this.vfs.realpath(i);if(!this.isWritable(e+`/`+a))throw new o(`EACCES`,`permission denied`,r(t))}catch(e){if(e instanceof o&&e.code===`EACCES`)throw e}try{(await this.vfs.lstat(t)).type===`symlink`&&await this.resolveAndCheckWrite(t)}catch(e){if(e instanceof o&&e.code===`EACCES`)throw e}return this.vfs.copyFile(n,t)}async symlink(e,t){this.checkWrite(t);let n=this.vfs.dirname(t),i=this.vfs.basename(t);try{let e=await this.vfs.realpath(n);if(!this.isWritable(e+`/`+i))throw new o(`EACCES`,`permission denied`,r(t))}catch(e){if(e instanceof o&&e.code===`EACCES`)throw e}return this.vfs.symlink(e,t)}async readlink(e){if(!this.isAllowedStrict(e))throw new o(`ENOENT`,`no such file or directory`,r(e));let t=await this.vfs.readlink(e),n;if(n=t.startsWith(`/`)?r(t):r(this.vfs.dirname(e)+`/`+t),!this.isAllowedStrict(n))throw new o(`ENOENT`,`no such file or directory`,r(e));return t}async lstat(e){if(!this.isAllowed(e))throw new o(`ENOENT`,`no such file or directory`,r(e));let t=r(e),n=this.vfs.dirname(t),i=this.vfs.basename(t),a;if(n===t)a=n;else try{a=await this.vfs.realpath(n)}catch{throw new o(`ENOENT`,`no such file or directory`,t)}let s=a===`/`?`/${i}`:`${a}/${i}`;if(!this.isAllowed(s))throw new o(`ENOENT`,`no such file or directory`,t);return this.vfs.lstat(s)}watch(e,t,n){if(!this.isAllowed(e))throw new o(`EACCES`,`permission denied`,r(e));let i=this.vfs.getWatcher();if(!i)throw new o(`EINVAL`,`no watcher configured`);return i.watch(r(e),t,n)}dirname(e){return this.vfs.dirname(e)}basename(e){return this.vfs.basename(e)}async dispose(){await this.vfs.dispose()}},g=`slicc-mount-table`,_=2,v=`mounts`,y=`mount-entries`;function b(){return new Promise((e,t)=>{let n=indexedDB.open(g,_);n.onupgradeneeded=e=>{let t=n.result,r=e.oldVersion;if(t.objectStoreNames.contains(v)||t.createObjectStore(v),t.objectStoreNames.contains(y)||t.createObjectStore(y),r<2){let e=n.transaction,t=e.objectStore(v),r=e.objectStore(y),i=t.getAllKeys();i.onsuccess=()=>{for(let e of i.result){if(typeof e!=`string`)continue;let t={targetPath:e,descriptor:{kind:`local`,mountId:c(),idbHandleKey:e},createdAt:Date.now()};r.put(t,e)}}}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function x(e,t){let n=await b();try{let r=e.descriptor.kind===`local`&&t?[v,y]:[y],i=n.transaction(r,`readwrite`);i.objectStore(y).put(e,e.targetPath),e.descriptor.kind===`local`&&t&&i.objectStore(v).put(t,e.descriptor.idbHandleKey),await new Promise((e,t)=>{i.oncomplete=()=>e(),i.onerror=()=>t(i.error),i.onabort=()=>t(i.error??new DOMException(`IndexedDB transaction aborted`,`AbortError`))})}finally{n.close()}}async function S(e){let t=await b();try{let n=t.transaction([v,y],`readwrite`);n.objectStore(y).delete(e),n.objectStore(v).delete(e),await new Promise((e,t)=>{n.oncomplete=()=>e(),n.onerror=()=>t(n.error),n.onabort=()=>t(n.error??new DOMException(`IndexedDB transaction aborted`,`AbortError`))})}finally{t.close()}}async function C(e){let t=await b();try{return await new Promise((n,r)=>{let i=t.transaction(v,`readonly`).objectStore(v).get(e);i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}finally{t.close()}}async function w(){let e=await b();try{let t=e.transaction([v,y],`readwrite`);t.objectStore(v).clear(),t.objectStore(y).clear(),await new Promise((e,n)=>{t.oncomplete=()=>e(),t.onerror=()=>n(t.error),t.onabort=()=>n(t.error??new DOMException(`IndexedDB transaction aborted`,`AbortError`))})}finally{e.close()}}var T=10;function E(){try{if(typeof globalThis.navigator?.storage?.getDirectory==`function`)return`opfs`}catch{}return`memory`}var D=class t{lfs;lfsSync;rawLfs=null;rawLfsSync=null;_ready;_readyResolved=!1;backend;mountPoints=new Map;opfsBackendFs=null;opfsHandle=null;mountRoot=``;internalMounts=new Set;watcher=null;dbName;mountSyncChannel=null;mountIndex=new m;constructor(e,n,r,i){if(this.dbName=e,this.backend=r===`opfs`?`opfs`:`memory`,this.lfs=this.makeDeferredLfs(),this.lfsSync=this.makeDeferredLfsSync(),this._ready=this.backend===`opfs`?t.initOpfsBackend(this,i,n===!0):t.initMemoryBackend(this,e,n===!0),this._ready.then(()=>{this._readyResolved=!0},()=>{}),typeof BroadcastChannel<`u`)try{this.mountSyncChannel=new BroadcastChannel(`vfs-mount-sync:${e}`),this.mountSyncChannel.onmessage=e=>{let{type:t,path:n,descriptor:r}=e.data??{};if(t===`mount`&&typeof n==`string`&&r)this.reconstructBackendFromDescriptor(r).then(e=>{this.mountPoints.set(n,e),e.kind===`local`&&this.mountIndex.registerMount(n,e.getHandle()),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}])}).catch(()=>{});else if(t===`unmount`&&typeof n==`string`){let e=this.mountPoints.get(n);this.mountPoints.delete(n),this.mountIndex.unregisterMount(n),e?.close(),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}])}}}catch{}}static async initOpfsBackend(n,r,i){let a=r??await t.acquireOpfsHandle(n.dbName,i);await t.seedOpfsMetadataSidecarIfMissing(a);let[o,{WebAccess:s}]=await Promise.all([e(()=>import(`./dist-C6lFkA1A.js`).then(e=>e.t),__vite__mapDeps([0,1])),e(()=>import(`./dist-DwJ61hEj.js`),__vite__mapDeps([2,0,1]))]);await t.ensureRootMount(o);let c=`/__opfs__/${n.dbName}`,l=t.opfsBackends.get(n.dbName);if(l&&i){try{o.umount(c)}catch{}t.opfsBackends.delete(n.dbName),l=void 0}if(!l){let e=await o.resolveMountConfig({backend:s,handle:a,metadata:`/.metadata.json`});try{o.mount(c,e)}catch{}l={backendFs:e,refs:0},t.opfsBackends.set(n.dbName,l)}l.refs+=1,n.opfsBackendFs=l.backendFs.index?l.backendFs:null,n.opfsHandle=a,n.mountRoot=c,n.rawLfs=o.promises,n.rawLfsSync=o}static async initMemoryBackend(n,r,i){let a=await e(()=>import(`./dist-C6lFkA1A.js`).then(e=>e.t),__vite__mapDeps([0,1]));await t.ensureRootMount(a);let o=`/__zenfs__/${r}`,s=t.memoryBackends.get(r);if(s&&i){try{a.umount(o)}catch{}t.memoryBackends.delete(r),s=void 0}s||(s={store:a.InMemory.create({label:r}),refs:0},t.memoryBackends.set(r,s)),s.refs+=1;try{a.mount(o,s.store)}catch{}n.mountRoot=o,n.rawLfs=a.promises,n.rawLfsSync=a,n.opfsBackendFs=null,n.opfsHandle=null}static rootMountReady=null;static memoryBackends=new Map;static opfsBackends=new Map;static async ensureRootMount(e){return t.rootMountReady||=(async()=>{await e.configureSingle({backend:e.InMemory,label:`__vfs_root__`})})(),t.rootMountReady}prefix(e){return this.mountRoot?e===`/`?this.mountRoot:this.mountRoot+e:e}unprefix(e){return!this.mountRoot||!e.startsWith(this.mountRoot)?e:e.slice(this.mountRoot.length)||`/`}makeDeferredLfs(){let e=e=>this.prefix(e),t=e=>this.unprefix(e),n=()=>{if(!this.rawLfs)throw Error(`VirtualFS used before init resolved`);return this.rawLfs};return{readFile:(t,r)=>this._readyResolved?n().readFile(e(t),r):this._ready.then(()=>n().readFile(e(t),r)),writeFile:(t,r,i)=>this._readyResolved?n().writeFile(e(t),r,i):this._ready.then(()=>n().writeFile(e(t),r,i)),readdir:t=>this._readyResolved?n().readdir(e(t)):this._ready.then(()=>n().readdir(e(t))),mkdir:(t,r)=>this._readyResolved?n().mkdir(e(t),r):this._ready.then(()=>n().mkdir(e(t),r)),rmdir:t=>this._readyResolved?n().rmdir(e(t)):this._ready.then(()=>n().rmdir(e(t))),unlink:t=>this._readyResolved?n().unlink(e(t)):this._ready.then(()=>n().unlink(e(t))),rename:(t,r)=>this._readyResolved?n().rename(e(t),e(r)):this._ready.then(()=>n().rename(e(t),e(r))),stat:t=>this._readyResolved?n().stat(e(t)):this._ready.then(()=>n().stat(e(t))),lstat:t=>this._readyResolved?n().lstat(e(t)):this._ready.then(()=>n().lstat(e(t))),symlink:(t,r)=>{let i=t.startsWith(`/`)?e(t):t;return this._readyResolved?n().symlink(i,e(r)):this._ready.then(()=>n().symlink(i,e(r)))},readlink:async r=>(this._readyResolved||await this._ready,t(await n().readlink(e(r)))),truncate:async(t,r)=>{this._readyResolved||await this._ready;let i=n();typeof i.truncate==`function`&&await i.truncate(e(t),r)},realpath:async r=>{this._readyResolved||await this._ready;let i=n();return typeof i.realpath==`function`?t(await i.realpath(e(r))):e(r)}}}makeDeferredLfsSync(){let e=e=>this.prefix(e),t=e=>this.unprefix(e);return{readdirSync:t=>{let n=this.rawLfsSync;return n?.readdirSync?n.readdirSync(e(t)):void 0},statSync:t=>{let n=this.rawLfsSync;return n?.statSync?n.statSync(e(t)):void 0},lstatSync:t=>{let n=this.rawLfsSync;return n?.lstatSync?n.lstatSync(e(t)):void 0},readlinkSync:n=>{let r=this.rawLfsSync;return r?.readlinkSync?t(r.readlinkSync(e(n))):void 0}}}static async seedOpfsMetadataSidecarIfMissing(e){let t=`.metadata.json`;try{await e.getFileHandle(t);return}catch(e){if(e?.name!==`NotFoundError`)throw e}let n=await(await e.getFileHandle(t,{create:!0})).createWritable(),r=JSON.stringify({version:1,maxSize:4294967295,entries:{}});await n.write(r),await n.close()}static async acquireOpfsHandle(e,t){let n=navigator.storage;if(!n?.getDirectory)throw new o(`EINVAL`,`OPFS is not available in this environment`);let r=await n.getDirectory();if(t)try{await r.removeEntry(e,{recursive:!0})}catch{}return r.getDirectoryHandle(e,{create:!0})}static async create(e){let n=e?.dbName??`browser-fs`,r=e?.wipe===!0,i=new t(n,r,e?.backend??E());return await i._ready,r&&await w().catch(()=>{}),i}async flush(){await this.writeOpfsMetadataSidecar()}async writeOpfsMetadataSidecar(){if(this.backend!==`opfs`)return;let e=this.opfsBackendFs,t=this.opfsHandle;if(!e||!t)return;let n=JSON.stringify(e.index.toJSON()),r=await(await t.getFileHandle(`.metadata.json`,{create:!0})).createWritable();await r.write(n),await r.close()}invalidatePaths(e){if(this.backend!==`opfs`||!this.opfsBackendFs)return;let t=this.opfsBackendFs;for(let n of e){let e=r(n);t.index.delete(e),t._handles?.delete(e)}}canWrite(e){return!0}setWatcher(e){this.watcher=e}getWatcher(){return this.watcher}async dispose(){if(this.mountSyncChannel?.close(),this.mountSyncChannel=null,this.watcher?.dispose(),this.watcher=null,this.mountIndex.dispose(),await this.writeOpfsMetadataSidecar(),this.mountRoot){let n=this.backend===`opfs`?t.opfsBackends:t.memoryBackends,r=n.get(this.dbName);if(r&&(--r.refs,r.refs<=0)){n.delete(this.dbName);try{(await e(()=>import(`./dist-C6lFkA1A.js`).then(e=>e.t),__vite__mapDeps([0,1]))).umount(this.mountRoot)}catch{}}}}readDirSync(e){let t=r(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.readdirSync!=`function`||typeof n.lstatSync!=`function`)return null;try{let e=n.readdirSync(t),r=[];for(let i of e){let e=t===`/`?`/${i}`:`${t}/${i}`;try{let t=n.lstatSync(e),a=t.isSymbolicLink()?`symlink`:t.isDirectory()?`directory`:`file`;r.push({name:i,type:a})}catch{}}return r}catch{return null}}statSync(e){let t=r(e);if(this.findMount(t))return null;let i=this.lfsSync;if(typeof i.statSync!=`function`||typeof i.lstatSync!=`function`||typeof i.readlinkSync!=`function`)return null;let o=t;for(let e=0;e<=T;e++){let e;try{e=i.lstatSync(o)}catch{return null}if(!e.isSymbolicLink())return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs};let t;try{t=i.readlinkSync(o)}catch{return null}o=t.startsWith(`/`)?r(t):r(a(n(o).dir,t))}return null}lstatSync(e){let t=r(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.lstatSync!=`function`)return null;try{let e=n.lstatSync(t);if(e.isSymbolicLink()){let r=n.readlinkSync?n.readlinkSync(t):``;return{type:`symlink`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,isSymlink:!0,symlinkTarget:r}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch{return null}}async mount(e,t){let i=r(e);if(this.mountPoints.has(i))throw new o(`EEXIST`,`mount point is already mounted`,i);try{if((await this.lstat(i)).type!==`directory`)throw new o(`ENOTDIR`,`mount point must be a directory`,i);if((await this.readDir(i)).length>0)throw new o(`ENOTEMPTY`,`mount point must be empty to avoid shadowing existing files`,i)}catch(e){if(!(e instanceof o)||e.code!==`ENOENT`)throw e}let{dir:a}=n(i);a!==`/`&&await this.mkdir(a,{recursive:!0});try{await this.lfs.mkdir(i)}catch{}this.mountPoints.set(i,t),t.kind===`local`&&this.mountIndex.registerMount(i,t.getHandle());let s=t.kind===`local`?{kind:`local`,mountId:t.mountId,idbHandleKey:i}:t.kind===`s3`?{kind:`s3`,mountId:t.mountId,source:t.source,profile:t.profile??`default`}:{kind:`da`,mountId:t.mountId,source:t.source,profile:t.profile??`default`};try{this.mountSyncChannel?.postMessage({type:`mount`,path:i,descriptor:s})}catch{}this.watcher?.notify([{type:`modify`,path:i,entryType:`directory`}]);try{await x({targetPath:i,descriptor:s,createdAt:Date.now()},t.kind===`local`?t.getHandle():void 0)}catch{}}async unmount(e){let t=r(e),n=this.mountPoints.get(t);this.mountPoints.delete(t),this.mountIndex.unregisterMount(t);try{this.mountSyncChannel?.postMessage({type:`unmount`,path:t})}catch{}this.watcher?.notify([{type:`modify`,path:t,entryType:`directory`}]),await n?.close();try{await S(t)}catch{}}async reconstructBackendFromDescriptor(t){switch(t.kind){case`local`:{let e=await C(t.idbHandleKey);if(!e)throw Error(`no handle stored for ${t.idbHandleKey}`);return s.fromHandle(e,{mountId:t.mountId})}case`s3`:{let{S3MountBackend:n,RemoteMountCache:r,makeSignedFetchS3:i}=await e(async()=>{let{S3MountBackend:e,RemoteMountCache:t,makeSignedFetchS3:n}=await import(`./mount-CqEOKmto.js`);return{S3MountBackend:e,RemoteMountCache:t,makeSignedFetchS3:n}},__vite__mapDeps([3,4,1,5,6,7,8,9])),a=new r({mountId:t.mountId,ttlMs:3e4});return new n({source:t.source,profile:t.profile,cache:a,mountId:t.mountId,signedFetch:i(t.profile)})}case`da`:{let{DaMountBackend:n,RemoteMountCache:r,makeSignedFetchDa:i}=await e(async()=>{let{DaMountBackend:e,RemoteMountCache:t,makeSignedFetchDa:n}=await import(`./mount-CqEOKmto.js`);return{DaMountBackend:e,RemoteMountCache:t,makeSignedFetchDa:n}},__vite__mapDeps([3,4,1,5,6,7,8,9])),a=new r({mountId:t.mountId,ttlMs:3e4});return new n({source:t.source,profile:t.profile,cache:a,mountId:t.mountId,signedFetch:i()})}}}listMounts(){let e=[];for(let t of this.mountPoints.keys())this.internalMounts.has(t)||e.push(t);return e}listInternalMounts(){return[...this.internalMounts]}listMountPoints(){let e=[];for(let[t,n]of this.mountPoints)this.internalMounts.has(t)||e.push({path:t,kind:n.kind});return e}async mountInternal(e,t){let i=r(e);if(this.mountPoints.has(i))throw new o(`EEXIST`,`mount point is already mounted`,i);let{dir:a}=n(i);a!==`/`&&await this.mkdir(a,{recursive:!0});try{await this.lfs.mkdir(i)}catch{}this.mountPoints.set(i,t),this.internalMounts.add(i),this.watcher?.notify([{type:`modify`,path:i,entryType:`directory`}])}async unmountInternal(e){let t=r(e);if(!this.internalMounts.has(t))throw new o(`ENOENT`,`not an internal mount point`,t);let n=this.mountPoints.get(t);this.mountPoints.delete(t),this.internalMounts.delete(t),this.watcher?.notify([{type:`modify`,path:t,entryType:`directory`}]),await n?.close()}getMountIndex(){return this.mountIndex}async refreshMount(e,t){let n=r(e),i=this.mountPoints.get(n);if(!i)throw new o(`ENOENT`,`not a mount point`,n);let a=await i.refresh(t);return i.kind===`local`&&await this.mountIndex.refreshMount(n),a}isPathUnderMount(e){for(let t of this.mountPoints.keys())if(e===t||e.startsWith(t+`/`))return!0;return!1}static rebrandFsError(e,t){if(e instanceof o){let n=`${e.code}: `,r=e.message;throw r.startsWith(n)&&(r=r.slice(n.length)),e.path&&r.endsWith(` '${e.path}'`)&&(r=r.slice(0,r.length-` '${e.path}'`.length)),new o(e.code,r,t)}throw e}findMount(e){let t=null;for(let[n,r]of this.mountPoints)(e===n||e.startsWith(n+`/`))&&(!t||n.length>t.mountPath.length)&&(t={mountPath:n,backend:r});return t?e===t.mountPath?{path:t.mountPath,backend:t.backend,relParts:[]}:{path:t.mountPath,backend:t.backend,relParts:e.slice(t.mountPath.length+1).split(`/`).filter(Boolean)}:null}async readFile(e,n){let i=r(e),a=this.findMount(i);if(a){if(a.relParts.length===0)throw new o(`EISDIR`,`is a directory`,i);let e=a.relParts.join(`/`);try{let t=await a.backend.readFile(e);return(n?.encoding??`utf-8`)===`utf-8`?new TextDecoder(`utf-8`).decode(t):t}catch(e){t.rebrandFsError(e,i)}}let s=await this.resolveSymlinks(i);try{return(n?.encoding??`utf-8`)===`utf-8`?await this.lfs.readFile(s,{encoding:`utf8`}):await this.lfs.readFile(s)}catch(e){throw this.convertError(e,i)}}async writeFile(e,i,a){let s=r(e),c=this.findMount(s);if(c){if(c.relParts.length===0)throw new o(`EISDIR`,`is a directory`,s);let e=c.relParts.join(`/`),n=!1;try{await this.stat(s),n=!0}catch{}let r=typeof i==`string`?new TextEncoder().encode(i):i instanceof Uint8Array?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i);try{await c.backend.writeFile(e,r)}catch(e){t.rebrandFsError(e,s)}this.watcher?.notify([{type:n?`modify`:`create`,path:s,entryType:`file`}]),this.mountIndex.notifyWrite(s);return}let l;try{l=await this.resolveSymlinks(s)}catch{l=s}let u=!1;try{await this.lfs.stat(l),u=!0}catch{}let{dir:d}=n(l);d!==`/`&&await this.mkdir(d,{recursive:!0});try{await this.lfs.writeFile(l,i);let e=typeof i==`string`?new TextEncoder().encode(i).byteLength:(i instanceof Uint8Array,i.byteLength);await this.lfs.truncate?.(l,e)}catch(e){throw this.convertError(e,s)}this.watcher?.notify([{type:u?`modify`:`create`,path:l,entryType:`file`}])}async readDir(e){let t=r(e),n=this.findMount(t);return n?this.readDirMounted(t,n):this.readDirLocal(t)}async readDirMounted(e,n){let r=this.mountIndex.getDirectoryEntries(n.path,e);if(r!==void 0){let t=new Map;for(let e of r)t.set(e.name,{name:e.name,type:e.type});return this.addNestedMountEntries(t,e),[...t.values()]}let i=n.relParts.join(`/`)||`/`,a;try{a=await n.backend.readDir(i)}catch(n){t.rebrandFsError(n,e)}let o=new Map;for(let e of a)o.set(e.name,{name:e.name,type:e.kind===`directory`?`directory`:`file`});return this.addNestedMountEntries(o,e),[...o.values()]}async readDirLocal(e){let t=await this.resolveSymlinks(e);try{let e=await this.lfs.readdir(t),n=[];for(let r of e){let e=await this.statDirEntry(t,r);e&&n.push(e)}return n}catch(t){throw this.convertError(t,e)}}async statDirEntry(e,t){let n=e===`/`?`/${t}`:`${e}/${t}`;try{let e=await this.lfs.lstat(n);return e.isSymbolicLink()?{name:t,type:`symlink`}:{name:t,type:e.isDirectory()?`directory`:`file`}}catch{return null}}addNestedMountEntries(e,t){let n=t===`/`?`/`:`${t}/`;for(let r of this.mountPoints.keys()){if(r===t||!r.startsWith(n))continue;let i=r.slice(n.length);!i||i.includes(`/`)||e.has(i)||e.set(i,{name:i,type:`directory`})}}async mkdir(e,n){let i=r(e);if(i===`/`)return;let a=this.findMount(i);if(a){if(a.relParts.length===0)return;let e=a.relParts.join(`/`),n=await this.exists(i);try{await a.backend.mkdir(e)}catch(e){t.rebrandFsError(e,i)}n||this.watcher?.notify([{type:`create`,path:i,entryType:`directory`}]);return}if(n?.recursive){let e=i.split(`/`).filter(Boolean),t=``;for(let n of e){t+=`/`+n;try{await this.lfs.mkdir(t)}catch(e){if(e instanceof Error&&!e.message.includes(`EEXIST`))throw this.convertError(e,t)}}}else{try{await this.lfs.mkdir(i)}catch(e){throw this.convertError(e,i)}this.watcher?.notify([{type:`create`,path:i,entryType:`directory`}])}}async rm(e,n){let i=r(e),a=this.findMount(i);if(a){if(a.relParts.length===0)throw new o(`EINVAL`,`cannot remove a mount point — use unmount`,i);let e;try{e=(await this.stat(i)).type}catch{}let r=a.relParts.join(`/`);try{await a.backend.remove(r,{recursive:n?.recursive})}catch(e){t.rebrandFsError(e,i)}this.watcher?.notify([{type:`delete`,path:i,entryType:e}]),this.mountIndex.notifyDelete(i);return}try{let e=await this.lfs.lstat(i);e.isSymbolicLink()?await this.lfs.unlink(i):e.isDirectory()?n?.recursive?await this.rmRecursive(i):await this.lfs.rmdir(i):await this.lfs.unlink(i)}catch(e){throw this.convertError(e,i)}this.watcher?.notify([{type:`delete`,path:i}])}async rmRecursive(e){let t=await this.lfs.readdir(e);for(let n of t){let t=e===`/`?`/${n}`:`${e}/${n}`;(await this.lfs.stat(t)).isDirectory()?await this.rmRecursive(t):await this.lfs.unlink(t)}await this.lfs.rmdir(e)}async stat(e){let n=r(e),i=this.findMount(n);if(i){if(i.relParts.length===0)try{let e=await this.lfs.stat(n);return{type:`directory`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch{return{type:`directory`,size:0,mtime:Date.now(),ctime:Date.now()}}let e=i.relParts.join(`/`);try{let t=await i.backend.stat(e);return{type:t.kind===`directory`?`directory`:`file`,size:t.size,mtime:t.mtime,ctime:t.mtime}}catch(e){t.rebrandFsError(e,n)}}let a=await this.resolveSymlinks(n);try{let e=await this.lfs.stat(a);return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch(e){throw this.convertError(e,n)}}async exists(e){let t=r(e),n=this.findMount(t);if(n){if(n.relParts.length===0)return!0;try{return await this.stat(t),!0}catch{return!1}}try{return await this.stat(t),!0}catch{try{return await this.lfs.lstat(t),!0}catch{return!1}}}async rename(e,t){let n=r(e),i=r(t),a;try{a=(await this.lstat(n)).type}catch{}try{await this.lfs.rename(n,i)}catch(e){throw this.convertError(e,n)}this.watcher?.notify([{type:`delete`,path:n,entryType:a},{type:`create`,path:i,entryType:a}]),this.mountIndex.notifyRename(n,i)}async readTextFile(e){return await this.readFile(e,{encoding:`utf-8`})}async*walk(e,t){let n=r(e);if(this.canUseWalkFastPath(n)){let e=this.mountIndex.getFiles(n);if(e){for(let t of e)yield t;return}}let i=t??new Set,a=await this.safeRealpath(n);if(i.has(a))return;i.add(a);let o=await this.readDir(n);for(let e of o){let t=n===`/`?`/${e.name}`:`${n}/${e.name}`;yield*this.walkEntry(e,t,i)}}canUseWalkFastPath(e){return this.mountPoints.size===0||!this.mountPoints.has(e)||!this.mountIndex.isReady(e)?!1:![...this.mountPoints.keys()].some(t=>t!==e&&t.startsWith(e+`/`))}async safeRealpath(e){try{return await this.realpath(e)}catch{return e}}async*walkEntry(e,t,n){if(e.type===`file`){yield t;return}if(e.type===`symlink`){yield*this.walkSymlink(t,n);return}yield*this.walk(t,n)}async*walkSymlink(e,t){try{let n=await this.stat(e);n.type===`file`?yield e:n.type===`directory`&&(yield*this.walk(e,t))}catch{}}async copyFile(e,t){if((await this.stat(e)).type===`directory`)throw new o(`EISDIR`,`is a directory`,e);let n=await this.readFile(e,{encoding:`binary`});await this.writeFile(t,n)}dirname(e){return n(r(e)).dir}basename(e){return n(r(e)).base}async symlink(e,t){let i=r(t);if(this.findMount(i))throw new o(`EINVAL`,`symlinks not supported on mounted filesystems`,i);let{dir:a}=n(i);a!==`/`&&await this.mkdir(a,{recursive:!0});try{await this.lfs.symlink(e,i)}catch(e){throw this.convertError(e,i)}this.watcher?.notify([{type:`create`,path:i,entryType:`symlink`}])}async readlink(e){let t=r(e);try{return await this.lfs.readlink(t)}catch(e){throw this.convertError(e,t)}}async lstat(e){let t=r(e);if(this.findMount(t))return this.stat(t);try{let e=await this.lfs.lstat(t);if(e.isSymbolicLink()){let n=await this.lfs.readlink(t);return{type:`symlink`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,isSymlink:!0,symlinkTarget:n}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch(e){throw this.convertError(e,t)}}async realpath(e){let t=r(e);if(this.findMount(t))return t;let n=t.split(`/`).filter(Boolean),i=`/`,a=0;for(let e=0;e<n.length;e++){let r=await this.resolveRealpathComponent(i,n[e],e===n.length-1,t,a);i=r.resolved,a=r.hops}return i}async resolveRealpathComponent(e,t,n,r,i){let a=e===`/`?`/${t}`:`${e}/${t}`;for(;;){let e=await this.lstatOrThrow(a,n,r);if(e===null||!e.isSymbolicLink())return{resolved:a,hops:i};if(++i>T)throw new o(`ELOOP`,`too many symbolic links encountered`,r);a=await this.readAndResolveLink(a,r)}}async lstatOrThrow(e,t,n){try{return await this.lfs.lstat(e)}catch(e){let r=this.convertError(e,n);if(r.code===`ENOENT`&&t)return null;throw r}}async readAndResolveLink(e,t){let i;try{i=await this.lfs.readlink(e)}catch(e){throw this.convertError(e,t)}return i.startsWith(`/`)?r(i):r(a(n(e).dir,i))}async resolveSymlinks(e){return this.findMount(e)?e:this.realpath(e)}convertError(e,t){if(e instanceof o)return e;let n=e?.code;if(typeof n==`string`){let r=n;if([`ENOENT`,`EEXIST`,`ENOTDIR`,`EISDIR`,`ENOTEMPTY`,`EINVAL`,`EACCES`,`ELOOP`,`EBUSY`,`EFBIG`,`EBADF`,`EIO`].includes(r))return new o(r,(e instanceof Error?e.message:String(e))||r,t)}let r=e instanceof Error?e.message:String(e);return r.includes(`ENOENT`)?new o(`ENOENT`,`no such file or directory`,t):r.includes(`EEXIST`)?new o(`EEXIST`,`file already exists`,t):r.includes(`ENOTDIR`)?new o(`ENOTDIR`,`not a directory`,t):r.includes(`EISDIR`)?new o(`EISDIR`,`is a directory`,t):r.includes(`ENOTEMPTY`)?new o(`ENOTEMPTY`,`directory not empty`,t):r.includes(`ELOOP`)?new o(`ELOOP`,`too many levels of symbolic links`,t):new o(`EINVAL`,r,t)}};export{o as FsError,f as FsWatcher,m as MountIndex,h as RestrictedFS,D as VirtualFS,a as joinPath,r as normalizePath,i as pathSegments,E as resolveVfsBackendFromEnv,n as splitPath};
@@ -1 +0,0 @@
1
- import{o as e,p as t,t as n}from"./provider-settings-Bpero1dy.js";import{r,t as i}from"./tray-runtime-config-BRnpyDNS.js";import{l as a}from"./kernel-worker-B2ABxAEr.js";import{getOAuthPageOrigin as o}from"./oauth-service-DQVciyk_.js";var s={clientId:``,scopes:`repo,read:user,user:email`};function c(){try{let e=localStorage.getItem(r);if(e)return e.replace(/\/$/,``)}catch{}return i}async function l(e){let t=`${c()}/oauth/token`,n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,code:e.code,redirect_uri:e.redirectUri})}),r;try{r=await n.json()}catch{throw Error(`Token exchange failed (HTTP ${n.status}): non-JSON response`)}if(!n.ok&&n.status!==200){let e=r.error_description??r.error??`Token exchange failed (HTTP ${n.status})`;throw Error(e)}if(r.error){let e=r.error_description??r.error;throw Error(e)}return r}async function u(e){let t=`${c()}/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})`)}}const d=Object.assign({"/packages/webapp/providers/github-config.json":s})[`/packages/webapp/providers/github-config.json`]??{clientId:``,scopes:`repo,read:user,user:email`};let f=null,p=null;function m(e){let{isExtension:t,isConnectMode:n,workerBaseUrl:r,pageOrigin:i,pageHref:a,extensionId:o,nonce:s}=e;if(t)return{redirectUri:`${r}/auth/callback`,state:{source:`extension`,extensionId:o,path:`/github`,nonce:s}};if(n){let e=i??``;if(/^https?:\/\/(localhost|127\.0\.0\.1):\d+$/.test(e)){let t=parseInt(new URL(a??e).port||`8790`,10);return{redirectUri:`${r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:s}}}return{redirectUri:`${r}/auth/callback`,state:{source:`remote`,origin:e,path:`/auth/callback`,nonce:s}}}return{redirectUri:`${e.runtimeWorkerBaseUrl??i??``}/auth/callback`,state:{port:parseInt(new URL(a??i??`http://localhost:5710`).port||`5710`,10),path:`/auth/callback`,nonce:s}}}async function h(){if(f)return f;if(g){try{let e=await fetch(`${c()}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return f=t.oauth.github,f}}catch{}return d.clientId}try{let e=await fetch(`/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return f=t.oauth.github,f;if(t.trayWorkerBaseUrl){p=t.trayWorkerBaseUrl;let e=await fetch(`${t.trayWorkerBaseUrl}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return f=t.oauth.github,f}}}}catch{}return d.clientId}const g=typeof chrome<`u`&&!!chrome?.runtime?.id;function _(){return n().find(e=>e.providerId===`github`)}function v(e){try{return new URL(e).searchParams.get(`code`)}catch{return null}}async function y(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 b(e,t){return`${e}+${t}@users.noreply.github.com`}async function x(e){try{let{VirtualFS:t}=await import(`./fs-DXM6_XIF.js`).then(e=>e.t);await(await t.create({dbName:a})).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 S(){try{let{VirtualFS:e}=await import(`./fs-DXM6_XIF.js`).then(e=>e.t);await(await e.create({dbName:a})).rm(`/workspace/.git/github-token`),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch{}}async function C(e){if(!(!e.login||e.id===void 0))try{let{VirtualFS:t}=await import(`./fs-DXM6_XIF.js`).then(e=>e.t),{readGlobalGitConfigValue:n,writeGlobalGitConfigValue:r}=await import(`./kernel-worker-B2ABxAEr.js`).then(e=>e.c),i=await t.create({dbName:a}),o=e.name||e.login,s=b(e.id,e.login);!await n(i,`user.name`)&&o&&await r(i,`user.name`,o),await n(i,`user.email`)||await r(i,`user.email`,s)}catch(e){console.warn(`[github] Failed to seed git identity:`,e instanceof Error?e.message:String(e))}}async function w(){let e=_();if(!e?.accessToken)throw Error(`Not logged in to GitHub — please log in first`);return e.accessToken}const T={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 h();if(!a)throw Error(`GitHub OAuth not configured — no client ID available`);let s=i?.scopes??d.scopes,u=g?null:await o(),f=crypto.randomUUID(),_=g?chrome.runtime.id:``,{redirectUri:b,state:w}=m({isExtension:g,isConnectMode:!!globalThis.__slicc_connect_mode,workerBaseUrl:c(),runtimeWorkerBaseUrl:p,pageOrigin:u?.origin??null,pageHref:u?.href??null,extensionId:_,nonce:f}),T=btoa(JSON.stringify(w)),E=f,D=new URLSearchParams({client_id:a,scope:s,redirect_uri:b});T&&D.set(`state`,T);let O=await n(`https://github.com/login/oauth/authorize?${D}`);if(!O)return;if(E)try{if(new URL(O).searchParams.get(`nonce`)!==E){console.error(`[github] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[github] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let k=v(O);if(!k){console.error(`[github] Could not extract authorization code from redirect URL`);return}let A=await l({provider:`github`,code:k,redirectUri:b}),j=await y(A.access_token);await t({providerId:`github`,accessToken:A.access_token,userName:j.name,userAvatar:j.avatar});let M=e(`github`)?.maskedValue;M?await x(M):await S(),await C(j),r()},onOAuthLogout:async()=>{let e=_();e?.accessToken&&await u({provider:`github`,accessToken:e.accessToken}).catch(e=>console.warn(`[github] Token revocation failed:`,e instanceof Error?e.message:String(e))),await S(),await t({providerId:`github`,accessToken:``})},getOAuthLogoutUrl:e=>`https://github.com/logout`};export{b as buildNoreplyEmail,T as config,v as extractCodeFromUrl,w as getValidAccessToken,m as resolveGithubOAuthRedirect,C as syncGitIdentityFromGitHub};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/fs-CYeTnPI-.js","assets/main-VDVlW6vJ.js","assets/chunk-aKtaBQYM.js","assets/modulepreload-polyfill-Dezn_h7o.js","assets/mount-id-BL7k4LOS.js","assets/mount-picker-popup-L-IvOEYc.js","assets/types-idfTVsM8.js","assets/picker-approval-ZlSNf9XH.js","assets/path-utils-DU6QhF_k.js"])))=>i.map(i=>d[i]);
2
- import{Ot as e,V as t,r as n,u as r,v as i,z as a}from"./main-VDVlW6vJ.js";import{getOAuthPageOrigin as o}from"./oauth-service-CPXp6Df0.js";import{t as s}from"./global-db-CbuLl-zx.js";var c={clientId:``,scopes:`repo,read:user,user:email`};function l(){try{let e=localStorage.getItem(t);if(e)return e.replace(/\/$/,``)}catch{}return a}async function u(e){let t=`${l()}/oauth/token`,n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,code:e.code,redirect_uri:e.redirectUri})}),r;try{r=await n.json()}catch{throw Error(`Token exchange failed (HTTP ${n.status}): non-JSON response`)}if(!n.ok&&n.status!==200){let e=r.error_description??r.error??`Token exchange failed (HTTP ${n.status})`;throw Error(e)}if(r.error){let e=r.error_description??r.error;throw Error(e)}return r}async function d(e){let t=`${l()}/oauth/revoke`,n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,access_token:e.accessToken})});if(!(n.status===204||n.ok)){if(n.status===400)try{if((await n.json()).error===`unsupported`)return}catch{}throw Error(`Token revocation failed (HTTP ${n.status})`)}}var f=Object.assign({"/packages/webapp/providers/github-config.json":c})[`/packages/webapp/providers/github-config.json`]??{clientId:``,scopes:`repo,read:user,user:email`},p=null,m=null;function h(e){let{isExtension:t,isConnectMode:n,workerBaseUrl:r,pageOrigin:i,pageHref:a,extensionId:o,nonce:s}=e;if(t)return{redirectUri:`${r}/auth/callback`,state:{source:`extension`,extensionId:o,path:`/github`,nonce:s}};if(n){let e=i??``;if(/^https?:\/\/(localhost|127\.0\.0\.1):\d+$/.test(e)){let t=parseInt(new URL(a??e).port||`8790`,10);return{redirectUri:`${r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:s}}}return{redirectUri:`${r}/auth/callback`,state:{source:`remote`,origin:e,path:`/auth/callback`,nonce:s}}}return{redirectUri:`${e.runtimeWorkerBaseUrl??i??``}/auth/callback`,state:{port:parseInt(new URL(a??i??`http://localhost:5710`).port||`5710`,10),path:`/auth/callback`,nonce:s}}}async function g(){if(p)return p;if(_){try{let e=await fetch(`${l()}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return p=t.oauth.github,p}}catch{}return f.clientId}try{let e=await fetch(`/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return p=t.oauth.github,p;if(t.trayWorkerBaseUrl){m=t.trayWorkerBaseUrl;let e=await fetch(`${t.trayWorkerBaseUrl}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return p=t.oauth.github,p}}}}catch{}return f.clientId}var _=typeof chrome<`u`&&!!chrome?.runtime?.id;function v(){return n().find(e=>e.providerId===`github`)}function y(e){try{return new URL(e).searchParams.get(`code`)}catch{return null}}async function b(e){try{let t=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${e}`,Accept:`application/vnd.github+json`}});if(t.ok){let e=await t.json();return{name:e.name||e.login,avatar:e.avatar_url,login:e.login,id:e.id}}}catch(e){console.warn(`[github] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function x(e,t){return`${e}+${t}@users.noreply.github.com`}async function S(t){try{let{VirtualFS:n}=await e(async()=>{let{VirtualFS:e}=await import(`./fs-CYeTnPI-.js`);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));await(await n.create({dbName:s})).writeFile(`/workspace/.git/github-token`,t),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch(e){console.warn(`[github] Failed to write git token:`,e instanceof Error?e.message:String(e))}}async function C(){try{let{VirtualFS:t}=await e(async()=>{let{VirtualFS:e}=await import(`./fs-CYeTnPI-.js`);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));await(await t.create({dbName:s})).rm(`/workspace/.git/github-token`),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch{}}async function w(t){if(!(!t.login||t.id===void 0))try{let{VirtualFS:n}=await e(async()=>{let{VirtualFS:e}=await import(`./fs-CYeTnPI-.js`);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])),{readGlobalGitConfigValue:r,writeGlobalGitConfigValue:i}=await e(async()=>{let{readGlobalGitConfigValue:e,writeGlobalGitConfigValue:t}=await import(`./git-config-DLJIrKjL.js`);return{readGlobalGitConfigValue:e,writeGlobalGitConfigValue:t}},[]),a=await n.create({dbName:s}),o=t.name||t.login,c=x(t.id,t.login);!await r(a,`user.name`)&&o&&await i(a,`user.name`,o),await r(a,`user.email`)||await i(a,`user.email`,c)}catch(e){console.warn(`[github] Failed to seed git identity:`,e instanceof Error?e.message:String(e))}}async function T(){let e=v();if(!e?.accessToken)throw Error(`Not logged in to GitHub — please log in first`);return e.accessToken}var E={id:`github`,name:`GitHub`,description:"Sign in with GitHub for git authentication (push/pull/clone) and the `oauth-token github` shell command. Does not expose LLM models — use the GitHub Copilot provider for those.",requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,oauthTokenDomains:[`github.com`,`*.github.com`,`api.github.com`,`raw.githubusercontent.com`],getModelIds:()=>[],onOAuthLogin:async(e,t,n)=>{let a=await g();if(!a)throw Error(`GitHub OAuth not configured — no client ID available`);let s=n?.scopes??f.scopes,c=_?null:await o(),d=crypto.randomUUID(),p=_?chrome.runtime.id:``,{redirectUri:v,state:x}=h({isExtension:_,isConnectMode:!!globalThis.__slicc_connect_mode,workerBaseUrl:l(),runtimeWorkerBaseUrl:m,pageOrigin:c?.origin??null,pageHref:c?.href??null,extensionId:p,nonce:d}),T=btoa(JSON.stringify(x)),E=d,D=new URLSearchParams({client_id:a,scope:s,redirect_uri:v});T&&D.set(`state`,T);let O=await e(`https://github.com/login/oauth/authorize?${D}`);if(!O)return;if(E)try{if(new URL(O).searchParams.get(`nonce`)!==E){console.error(`[github] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[github] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let k=y(O);if(!k){console.error(`[github] Could not extract authorization code from redirect URL`);return}let A=await u({provider:`github`,code:k,redirectUri:v}),j=await b(A.access_token);await i({providerId:`github`,accessToken:A.access_token,userName:j.name,userAvatar:j.avatar});let M=r(`github`)?.maskedValue;M?await S(M):await C(),await w(j),t()},onOAuthLogout:async()=>{let e=v();e?.accessToken&&await d({provider:`github`,accessToken:e.accessToken}).catch(e=>console.warn(`[github] Token revocation failed:`,e instanceof Error?e.message:String(e))),await C(),await i({providerId:`github`,accessToken:``})},getOAuthLogoutUrl:e=>`https://github.com/logout`};export{x as buildNoreplyEmail,E as config,y as extractCodeFromUrl,T as getValidAccessToken,h as resolveGithubOAuthRedirect,w as syncGitIdentityFromGitHub};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/main-VDVlW6vJ.js","assets/chunk-aKtaBQYM.js","assets/modulepreload-polyfill-Dezn_h7o.js"])))=>i.map(i=>d[i]);
2
- import{Ot as e,Tt as t,ft as n,gt as r,ht as i,kt as a,mt as o,r as s,v as c,vt as l,wt as u,xt as d,yt as f}from"./main-VDVlW6vJ.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 s().find(e=>e.providerId===p)}async function S(){let e=await fetch(h,{method:`POST`,headers:y,body:new URLSearchParams({client_id:m,scope:`read:user`})});if(!e.ok)throw Error(`GitHub device-code request failed: ${e.status} ${e.statusText} — ${await e.text().catch(()=>``)}`);let t=await e.json();if(typeof t.device_code!=`string`||typeof t.user_code!=`string`||typeof t.verification_uri!=`string`||typeof t.expires_in!=`number`||typeof t.interval!=`number`)throw Error(`GitHub device-code response had an unexpected shape`);return t}async function C(e,t){let n=Date.now()+e.expires_in*1e3,r=Math.max(1e3,Math.floor(e.interval*1e3)),i=1.2;for(;Date.now()<n;){if(t.aborted)throw Error(`Copilot login cancelled`);await w(Math.ceil(r*i),t);let n=await fetch(g,{method:`POST`,headers:y,body:new URLSearchParams({client_id:m,device_code:e.device_code,grant_type:`urn:ietf:params:oauth:grant-type:device_code`})});if(!n.ok)throw Error(`GitHub token poll failed: ${n.status} ${n.statusText} — ${await n.text().catch(()=>``)}`);let a=await n.json();if(typeof a.access_token==`string`&&a.access_token.length>0)return a.access_token;if(a.error!==`authorization_pending`){if(a.error===`slow_down`){r=typeof a.interval==`number`?a.interval*1e3:r+5e3,i=1.4;continue}if(a.error){let e=a.error_description?`: ${a.error_description}`:``;throw Error(`Device flow failed (${a.error})${e}`)}}}throw Error(`Copilot device flow timed out (device code expired)`)}function w(e,t){return new Promise((n,r)=>{if(t.aborted){r(Error(`Copilot login cancelled`));return}let i=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Copilot login cancelled`))},{once:!0})})}function T(e){let t=e.match(/proxy-ep=([^;]+)/);return t?`https://${t[1].replace(/^proxy\./,`api.`)}`:null}async function E(e){let t=await fetch(_,{headers:{...v,Authorization:`Bearer ${e}`}});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`Copilot token exchange failed: ${t.status} ${t.statusText} — ${e.slice(0,300)}`)}let n=await t.json();if(typeof n.token!=`string`||typeof n.expires_at!=`number`)throw Error(`Copilot token exchange returned an unexpected payload`);if(n.chat_enabled===!1)throw Error(`GitHub Copilot Chat is disabled for this account (no chat features granted)`);return{copilotToken:n.token,expiresAtMs:n.expires_at*1e3-300*1e3,apiBaseUrl:T(n.token)??`https://api.individual.githubcopilot.com`,githubAccessToken:e}}var D=`github-copilot.models.v1`;function O(e){let t=e.supported_endpoints??[],n=(e.vendor??``).toLowerCase(),r=e.id;return n===`anthropic`&&t.includes(`/v1/messages`)?`anthropic-messages`:n===`openai`&&(/^gpt-5/i.test(r)||/codex/i.test(r)||/^o\d/i.test(r))?`openai-responses`:`openai-completions`}function k(e){if(!e||typeof e!=`object`)return[];let t=e.data;if(!Array.isArray(t))return[];let n=[];for(let e of t)e.capabilities?.type&&e.capabilities.type!==`chat`||e.model_picker_enabled!==!1&&e.id&&n.push({id:e.id,name:e.name??e.id,vendor:e.vendor??``,api:O(e),contextWindow:e.capabilities?.limits?.max_context_window_tokens??e.capabilities?.limits?.max_prompt_tokens??128e3,maxTokens:e.capabilities?.limits?.max_output_tokens??8192,supportsTools:e.capabilities?.supports?.tool_calls===!0,supportsStreaming:e.capabilities?.supports?.streaming!==!1,supportsVision:e.capabilities?.supports?.vision===!0,supportsReasoning:e.capabilities?.supports?.adaptive_thinking===!0||Array.isArray(e.capabilities?.supports?.reasoning_effort),policyState:e.policy?.state??`enabled`});return n}async function A(e){let t=await fetch(`${e.apiBaseUrl}/models`,{headers:{...v,Authorization:`Bearer ${e.copilotToken}`,Accept:`application/json`}});if(!t.ok)throw Error(`Copilot /models returned ${t.status} ${t.statusText}`);return k(await t.json())}function j(){if(typeof localStorage>`u`)return[];try{let e=localStorage.getItem(D);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function M(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(D,JSON.stringify(e))}catch{}}function N(e){return j().find(t=>t.id===e)??null}async function P(e){let t;try{t=await A(e)}catch(e){console.warn(`[github-copilot] Catalog refresh failed; keeping previous cache.`,e instanceof Error?e.message:String(e));return}M(t),await Promise.all(t.filter(e=>e.policyState===`disabled`).map(async t=>{let n=`${e.apiBaseUrl}/models/${encodeURIComponent(t.id)}/policy`;try{let r=await fetch(n,{method:`POST`,headers:{...v,"Content-Type":`application/json`,Authorization:`Bearer ${e.copilotToken}`,"openai-intent":`chat-policy`,"x-interaction-type":`chat-policy`},body:JSON.stringify({state:`enabled`})});r.ok?t.policyState=`enabled`:r.status!==404&&r.status!==400&&console.warn(`[github-copilot] enable policy for ${t.id} returned ${r.status} ${r.statusText}`)}catch(e){console.warn(`[github-copilot] enable policy for ${t.id} failed:`,e instanceof Error?e.message:String(e))}})),M(t)}async function F(e,t){await c({providerId:p,accessToken:e.copilotToken,refreshToken:e.githubAccessToken,tokenExpiresAt:e.expiresAtMs,baseUrl:e.apiBaseUrl,userName:t})}async function I(){let e=x();if(!e?.accessToken||!e.refreshToken)throw Error(`Not logged in to GitHub Copilot — click "Login" in the provider settings`);let t=e.tokenExpiresAt??0;if(Date.now()<t-6e4)return e.accessToken;let n=await E(e.refreshToken);return await F(n,e.userName),n.copilotToken}var L=[`mini`,`nano`,`flash`,`haiku`,`lite`,`embedding`];function R(e){let t=[e.id,e.name??``].flatMap(e=>{let t=e.toLowerCase();return[t,t.replace(/[\s_.:]+/g,`-`)]});return!L.some(e=>t.some(t=>t.includes(e)))}function z(){if(!x()?.accessToken)return[];let e=j();if(e.length>0)return e.filter(e=>!e.policyState.startsWith(`unavailable:`)).filter(e=>R(e)).map(e=>({id:e.id,name:e.name,api:e.api===`anthropic-messages`?`anthropic`:`openai`,context_window:e.contextWindow,max_tokens:e.maxTokens,reasoning:e.supportsReasoning,input:e.supportsVision?[`text`,`image`]:[`text`]}));let n;try{n=t(`github-copilot`)}catch{return[]}return n.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=u(`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){return(t,a,s={})=>{let c=d();return(async()=>{try{let u=await I(),d=H(t.id);if(!d)throw Error(`GitHub Copilot does not recognize "${t.id}" — open the picker (the model list refreshes on login) and pick a current model.`);let p={...t,api:d.api,baseUrl:d.baseUrl,headers:d.headers,provider:`github-copilot`},m={...s,apiKey:u},h;h=d.api===`anthropic-messages`?(e?r:n)(p,a,m):d.api===`openai-responses`?(e?f:i)(p,a,m):(e?l:o)(p,a,m);for await(let e of h){let n=G(e);if(n&&/model_not_supported/i.test(n)){U(t.id,`model_not_supported`);let e=W(t.id,n);console.error(`[github-copilot] Plan-gated model rejection:`,e),c.push(B(t,Error(e))),c.end();return}c.push(e)}c.end()}catch(e){let n=e instanceof Error?e.message:String(e),r=e;/model_not_supported/i.test(n)&&(U(t.id,`model_not_supported`),r=Error(W(t.id,n))),console.error(`[github-copilot] Stream error:`,r instanceof Error?r.message:String(r)),c.push(B(t,r)),c.end()}})(),c}}var q=K(!1),J=K(!0),Y=({userCode:t,verificationUrl:n})=>typeof document>`u`?(console.info(`[github-copilot] Device verification code: ${t} — open ${n} in a browser to authorize.`),Promise.resolve(`continue`)):new Promise(n=>{let r=document.createElement(`div`);r.setAttribute(`data-slicc-overlay`,`github-copilot-device`),r.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=t,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{r.remove()}catch{}};c.addEventListener(`click`,()=>{u(),n(`cancel`)}),l.addEventListener(`click`,()=>{(async()=>{try{let{copyTextToClipboard:n}=await e(async()=>{let{copyTextToClipboard:e}=await import(`./main-VDVlW6vJ.js`).then(e=>e.E);return{copyTextToClipboard:e}},__vite__mapDeps([0,1,2]));await n(t)}catch{}u(),n(`continue`)})()}),s.appendChild(c),s.appendChild(l),r.appendChild(i),r.appendChild(a),r.appendChild(o),r.appendChild(s),document.body.appendChild(r)}),X={id:p,name:`GitHub Copilot`,description:`Use your GitHub Copilot subscription to access Claude, GPT-5, Codex, Gemini, and Grok models. Sign in with the GitHub device-code flow.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`claude-sonnet-4.6`,oauthTokenDomains:[`*.githubcopilot.com`,`api.individual.githubcopilot.com`,`api.business.githubcopilot.com`,`api.enterprise.githubcopilot.com`],getModelIds:z,onOAuthLoginIntercepted:async(e,t,n)=>{let r=await S(),i=new URL(r.verification_uri);if(i.searchParams.set(`user_code`,r.user_code),await(n?.presentDeviceCode??Y)({userCode:r.user_code,verificationUrl:i.toString(),expiresInSeconds:r.expires_in})===`cancel`)throw Error(`GitHub Copilot login cancelled`);let a=new AbortController,o=e({authorizeUrl:i.toString(),redirectUriPattern:b,onCapture:`close`,timeoutMs:r.expires_in*1e3}).catch(e=>(console.warn(`[github-copilot] Launcher failed:`,e instanceof Error?e.message:String(e)),null)),s;try{s=await C(r,a.signal)}catch(e){throw a.abort(),await o,e}await o;let c=await E(s),l;try{let e=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${s}`,Accept:`application/json`}});if(e.ok){let t=await e.json();l=t.name||t.login}}catch{}await F(c,l),await P(c),t()},onOAuthLogout:async()=>{await c({providerId:p,accessToken:``})},onSilentRenew:async()=>{let e=x();if(!e?.refreshToken)return null;try{let t=await E(e.refreshToken);return await F(t,e.userName),await P(t),t.copilotToken}catch(e){return console.warn(`[github-copilot] Silent renew failed:`,e instanceof Error?e.message:String(e)),null}}};function Z(){a({api:`github-copilot-anthropic`,stream:q,streamSimple:J}),a({api:`github-copilot-openai`,stream:q,streamSimple:J})}export{X as config,R as isCopilotConeCompatible,Z as register};
@@ -1 +0,0 @@
1
- import{p as e,t}from"./provider-settings-Bpero1dy.js";import{b as n,f as r,g as i,h as a,m as o,v as s,y as c}from"./bedrock-camp-wxdDcDkR.js";import{l,o as u,u as d}from"./transform-messages-C1X1O3BY.js";const f=`github-copilot`,p=atob(`SXYxLmI1MDdhMDhjODdlY2ZlOTg=`),m={Accept:`application/json`,"Editor-Version":`vscode/1.107.0`,"Editor-Plugin-Version":`copilot-chat/0.35.0`,"Copilot-Integration-Id":`vscode-chat`},h={Accept:`application/json`,"Content-Type":`application/x-www-form-urlencoded`};function g(){return t().find(e=>e.providerId===f)}async function _(){let e=await fetch(`https://github.com/login/device/code`,{method:`POST`,headers:h,body:new URLSearchParams({client_id:p,scope:`read:user`})});if(!e.ok)throw Error(`GitHub device-code request failed: ${e.status} ${e.statusText} — ${await e.text().catch(()=>``)}`);let t=await e.json();if(typeof t.device_code!=`string`||typeof t.user_code!=`string`||typeof t.verification_uri!=`string`||typeof t.expires_in!=`number`||typeof t.interval!=`number`)throw Error(`GitHub device-code response had an unexpected shape`);return t}async function v(e,t){let n=Date.now()+e.expires_in*1e3,r=Math.max(1e3,Math.floor(e.interval*1e3)),i=1.2;for(;Date.now()<n;){if(t.aborted)throw Error(`Copilot login cancelled`);await y(Math.ceil(r*i),t);let n=await fetch(`https://github.com/login/oauth/access_token`,{method:`POST`,headers:h,body:new URLSearchParams({client_id:p,device_code:e.device_code,grant_type:`urn:ietf:params:oauth:grant-type:device_code`})});if(!n.ok)throw Error(`GitHub token poll failed: ${n.status} ${n.statusText} — ${await n.text().catch(()=>``)}`);let a=await n.json();if(typeof a.access_token==`string`&&a.access_token.length>0)return a.access_token;if(a.error!==`authorization_pending`){if(a.error===`slow_down`){r=typeof a.interval==`number`?a.interval*1e3:r+5e3,i=1.4;continue}if(a.error){let e=a.error_description?`: ${a.error_description}`:``;throw Error(`Device flow failed (${a.error})${e}`)}}}throw Error(`Copilot device flow timed out (device code expired)`)}function y(e,t){return new Promise((n,r)=>{if(t.aborted){r(Error(`Copilot login cancelled`));return}let i=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Copilot login cancelled`))},{once:!0})})}function b(e){let t=e.match(/proxy-ep=([^;]+)/);return t?`https://${t[1].replace(/^proxy\./,`api.`)}`:null}async function x(e){let t=await fetch(`https://api.github.com/copilot_internal/v2/token`,{headers:{...m,Authorization:`Bearer ${e}`}});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`Copilot token exchange failed: ${t.status} ${t.statusText} — ${e.slice(0,300)}`)}let n=await t.json();if(typeof n.token!=`string`||typeof n.expires_at!=`number`)throw Error(`Copilot token exchange returned an unexpected payload`);if(n.chat_enabled===!1)throw Error(`GitHub Copilot Chat is disabled for this account (no chat features granted)`);return{copilotToken:n.token,expiresAtMs:n.expires_at*1e3-300*1e3,apiBaseUrl:b(n.token)??`https://api.individual.githubcopilot.com`,githubAccessToken:e}}const S=`github-copilot.models.v1`;function C(e){let t=e.supported_endpoints??[],n=(e.vendor??``).toLowerCase(),r=e.id;return n===`anthropic`&&t.includes(`/v1/messages`)?`anthropic-messages`:n===`openai`&&(/^gpt-5/i.test(r)||/codex/i.test(r)||/^o\d/i.test(r))?`openai-responses`:`openai-completions`}function w(e){if(!e||typeof e!=`object`)return[];let t=e.data;if(!Array.isArray(t))return[];let n=[];for(let e of t)e.capabilities?.type&&e.capabilities.type!==`chat`||e.model_picker_enabled!==!1&&e.id&&n.push({id:e.id,name:e.name??e.id,vendor:e.vendor??``,api:C(e),contextWindow:e.capabilities?.limits?.max_context_window_tokens??e.capabilities?.limits?.max_prompt_tokens??128e3,maxTokens:e.capabilities?.limits?.max_output_tokens??8192,supportsTools:e.capabilities?.supports?.tool_calls===!0,supportsStreaming:e.capabilities?.supports?.streaming!==!1,supportsVision:e.capabilities?.supports?.vision===!0,supportsReasoning:e.capabilities?.supports?.adaptive_thinking===!0||Array.isArray(e.capabilities?.supports?.reasoning_effort),policyState:e.policy?.state??`enabled`});return n}async function T(e){let t=await fetch(`${e.apiBaseUrl}/models`,{headers:{...m,Authorization:`Bearer ${e.copilotToken}`,Accept:`application/json`}});if(!t.ok)throw Error(`Copilot /models returned ${t.status} ${t.statusText}`);return w(await t.json())}function E(){if(typeof localStorage>`u`)return[];try{let e=localStorage.getItem(S);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function D(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(S,JSON.stringify(e))}catch{}}function O(e){return E().find(t=>t.id===e)??null}async function k(e){let t;try{t=await T(e)}catch(e){console.warn(`[github-copilot] Catalog refresh failed; keeping previous cache.`,e instanceof Error?e.message:String(e));return}D(t),await Promise.all(t.filter(e=>e.policyState===`disabled`).map(async t=>{let n=`${e.apiBaseUrl}/models/${encodeURIComponent(t.id)}/policy`;try{let r=await fetch(n,{method:`POST`,headers:{...m,"Content-Type":`application/json`,Authorization:`Bearer ${e.copilotToken}`,"openai-intent":`chat-policy`,"x-interaction-type":`chat-policy`},body:JSON.stringify({state:`enabled`})});r.ok?t.policyState=`enabled`:r.status!==404&&r.status!==400&&console.warn(`[github-copilot] enable policy for ${t.id} returned ${r.status} ${r.statusText}`)}catch(e){console.warn(`[github-copilot] enable policy for ${t.id} failed:`,e instanceof Error?e.message:String(e))}})),D(t)}async function A(t,n){await e({providerId:f,accessToken:t.copilotToken,refreshToken:t.githubAccessToken,tokenExpiresAt:t.expiresAtMs,baseUrl:t.apiBaseUrl,userName:n})}async function j(){let e=g();if(!e?.accessToken||!e.refreshToken)throw Error(`Not logged in to GitHub Copilot — click "Login" in the provider settings`);let t=e.tokenExpiresAt??0;if(Date.now()<t-6e4)return e.accessToken;let n=await x(e.refreshToken);return await A(n,e.userName),n.copilotToken}const M=[`mini`,`nano`,`flash`,`haiku`,`lite`,`embedding`];function N(e){let t=[e.id,e.name??``].flatMap(e=>{let t=e.toLowerCase();return[t,t.replace(/[\s_.:]+/g,`-`)]});return!M.some(e=>t.some(t=>t.includes(e)))}function P(){if(!g()?.accessToken)return[];let e=E();if(e.length>0)return e.filter(e=>!e.policyState.startsWith(`unavailable:`)).filter(e=>N(e)).map(e=>({id:e.id,name:e.name,api:e.api===`anthropic-messages`?`anthropic`:`openai`,context_window:e.contextWindow,max_tokens:e.maxTokens,reasoning:e.supportsReasoning,input:e.supportsVision?[`text`,`image`]:[`text`]}));let t;try{t=d(`github-copilot`)}catch{return[]}return t.filter(e=>N({id:e.id,name:e.name})).map(e=>({id:e.id,name:e.name??e.id,api:e.api===`anthropic-messages`?`anthropic`:`openai`,context_window:e.contextWindow,max_tokens:e.maxTokens,reasoning:e.reasoning,input:e.input}))}function F(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:e.api,provider:f,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}const I={"User-Agent":`GitHubCopilotChat/0.35.0`,"Editor-Version":`vscode/1.107.0`,"Editor-Plugin-Version":`copilot-chat/0.35.0`,"Copilot-Integration-Id":`vscode-chat`};function L(e){let t=g(),n=t?.baseUrl??`https://api.individual.githubcopilot.com`,r=O(e);if(r)return{api:r.api,baseUrl:n,headers:{...I}};try{let n=l(`github-copilot`,e);return{api:n.api,baseUrl:t?.baseUrl??n.baseUrl,headers:{...n.headers??{},...I}}}catch{return null}}function R(e,t){let n=E(),r=n.findIndex(t=>t.id===e);r<0||(n[r]={...n[r],policyState:`unavailable:${t}`},D(n))}function z(e,t){return`GitHub Copilot rejected "${e}" with model_not_supported. This usually means the model isn't included in your Copilot plan (Opus and other premium models require Copilot Pro / Pro+ / Business / Enterprise). Try Claude Sonnet 4.6 or another model that appears in the picker after a fresh login. Original error: ${t}`}function B(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.type!==`error`)return null;if(t.error&&typeof t.error==`object`){let e=t.error.errorMessage;if(typeof e==`string`)return e}return typeof t.errorMessage==`string`?t.errorMessage:null}function V(e){return(t,n,l={})=>{let d=u();return(async()=>{try{let u=await j(),f=L(t.id);if(!f)throw Error(`GitHub Copilot does not recognize "${t.id}" — open the picker (the model list refreshes on login) and pick a current model.`);let p={...t,api:f.api,baseUrl:f.baseUrl,headers:f.headers,provider:`github-copilot`},m={...l,apiKey:u},h;h=f.api===`anthropic-messages`?(e?i:r)(p,n,m):f.api===`openai-responses`?(e?c:a)(p,n,m):(e?s:o)(p,n,m);for await(let e of h){let n=B(e);if(n&&/model_not_supported/i.test(n)){R(t.id,`model_not_supported`);let e=z(t.id,n);console.error(`[github-copilot] Plan-gated model rejection:`,e),d.push(F(t,Error(e))),d.end();return}d.push(e)}d.end()}catch(e){let n=e instanceof Error?e.message:String(e),r=e;/model_not_supported/i.test(n)&&(R(t.id,`model_not_supported`),r=Error(z(t.id,n))),console.error(`[github-copilot] Stream error:`,r instanceof Error?r.message:String(r)),d.push(F(t,r)),d.end()}})(),d}}const H=V(!1),U=V(!0),W=({userCode:e,verificationUrl:t})=>typeof document>`u`?(console.info(`[github-copilot] Device verification code: ${e} — open ${t} in a browser to authorize.`),Promise.resolve(`continue`)):new Promise(t=>{let n=document.createElement(`div`);n.setAttribute(`data-slicc-overlay`,`github-copilot-device`),n.style.cssText=[`position:fixed`,`top:24px`,`right:24px`,`z-index:2147483647`,`background:#0d1117`,`color:#e6edf3`,`border:1px solid #30363d`,`border-radius:10px`,`padding:16px 18px`,`box-shadow:0 8px 32px rgba(0,0,0,0.45)`,`font:13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,`min-width:260px`,`max-width:340px`].join(`;`);let r=document.createElement(`div`);r.textContent=`GitHub Copilot — verification code`,r.style.cssText=`font-weight:600;margin-bottom:8px;color:#7ee787`;let i=document.createElement(`div`);i.textContent=e,i.style.cssText=[`font:600 22px ui-monospace, SFMono-Regular, Menlo, monospace`,`letter-spacing:2px`,`background:#161b22`,`border:1px solid #30363d`,`border-radius:6px`,`padding:10px 12px`,`text-align:center`,`margin-bottom:10px`,`user-select:all`,`cursor:text`].join(`;`);let a=document.createElement(`div`);a.style.cssText=`color:#8b949e;font-size:12px;line-height:1.5`,a.textContent=`Copy the code, then click Continue to open the GitHub authorization page in a new tab.`;let o=document.createElement(`div`);o.style.cssText=`display:flex;gap:8px;margin-top:12px;justify-content:flex-end`;let s=document.createElement(`button`);s.type=`button`,s.textContent=`Cancel`,s.style.cssText=[`background:transparent`,`color:#e6edf3`,`border:1px solid #30363d`,`border-radius:6px`,`padding:6px 12px`,`font:600 12px inherit`,`cursor:pointer`].join(`;`);let c=document.createElement(`button`);c.type=`button`,c.textContent=`Copy & Continue`,c.style.cssText=[`background:#238636`,`color:#fff`,`border:0`,`border-radius:6px`,`padding:6px 12px`,`font:600 12px inherit`,`cursor:pointer`].join(`;`);let l=()=>{try{n.remove()}catch{}};s.addEventListener(`click`,()=>{l(),t(`cancel`)}),c.addEventListener(`click`,()=>{(async()=>{try{let{copyTextToClipboard:t}=await import(`./clipboard-C2cR8flR.js`).then(e=>e.t);await t(e)}catch{}l(),t(`continue`)})()}),o.appendChild(s),o.appendChild(c),n.appendChild(r),n.appendChild(i),n.appendChild(a),n.appendChild(o),document.body.appendChild(n)}),G={id:f,name:`GitHub Copilot`,description:`Use your GitHub Copilot subscription to access Claude, GPT-5, Codex, Gemini, and Grok models. Sign in with the GitHub device-code flow.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`claude-sonnet-4.6`,oauthTokenDomains:[`*.githubcopilot.com`,`api.individual.githubcopilot.com`,`api.business.githubcopilot.com`,`api.enterprise.githubcopilot.com`],getModelIds:P,onOAuthLoginIntercepted:async(e,t,n)=>{let r=await _(),i=new URL(r.verification_uri);if(i.searchParams.set(`user_code`,r.user_code),await(n?.presentDeviceCode??W)({userCode:r.user_code,verificationUrl:i.toString(),expiresInSeconds:r.expires_in})===`cancel`)throw Error(`GitHub Copilot login cancelled`);let a=new AbortController,o=e({authorizeUrl:i.toString(),redirectUriPattern:`https://github.com/login/device/success*`,onCapture:`close`,timeoutMs:r.expires_in*1e3}).catch(e=>(console.warn(`[github-copilot] Launcher failed:`,e instanceof Error?e.message:String(e)),null)),s;try{s=await v(r,a.signal)}catch(e){throw a.abort(),await o,e}await o;let c=await x(s),l;try{let e=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${s}`,Accept:`application/json`}});if(e.ok){let t=await e.json();l=t.name||t.login}}catch{}await A(c,l),await k(c),t()},onOAuthLogout:async()=>{await e({providerId:f,accessToken:``})},onSilentRenew:async()=>{let e=g();if(!e?.refreshToken)return null;try{let t=await x(e.refreshToken);return await A(t,e.userName),await k(t),t.copilotToken}catch(e){return console.warn(`[github-copilot] Silent renew failed:`,e instanceof Error?e.message:String(e)),null}}};function K(){n({api:`github-copilot-anthropic`,stream:H,streamSimple:U}),n({api:`github-copilot-openai`,stream:H,streamSimple:U})}export{G as config,N as isCopilotConeCompatible,K as register};
@@ -1 +0,0 @@
1
- import{Ct as e,L as t,St as n,bt as r}from"./main-VDVlW6vJ.js";import{t as i}from"./sanitize-unicode-DmIE6hZJ.js";import{a,i as o,n as s,o as c,r as l,s as u,t as d}from"./google-shared-CZRDSncd.js";var f=0,p=(e,t,i)=>{let a=new r;return(async()=>{let r={role:`assistant`,content:[],api:`google-generative-ai`,provider:e.provider,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:`stop`,timestamp:Date.now()};try{let s=i?.apiKey;if(!s)throw Error(`No API key for provider: ${e.provider}`);let u=h(e,s,i?.headers),d=g(e,t,i),p=await i?.onPayload?.(d,e);p!==void 0&&(d=p);let m=await u.models.generateContentStream(d);a.push({type:`start`,partial:r});let _=null,v=r.content,y=()=>v.length-1;for await(let t of m){r.responseId||=t.responseId;let i=t.candidates?.[0];if(i?.content?.parts)for(let e of i.content.parts){if(e.text!==void 0){let t=l(e);(!_||t&&_.type!==`thinking`||!t&&_.type!==`text`)&&(_&&(_.type===`text`?a.push({type:`text_end`,contentIndex:v.length-1,content:_.text,partial:r}):a.push({type:`thinking_end`,contentIndex:y(),content:_.thinking,partial:r})),t?(_={type:`thinking`,thinking:``,thinkingSignature:void 0},r.content.push(_),a.push({type:`thinking_start`,contentIndex:y(),partial:r})):(_={type:`text`,text:``},r.content.push(_),a.push({type:`text_start`,contentIndex:y(),partial:r}))),_.type===`thinking`?(_.thinking+=e.text,_.thinkingSignature=c(_.thinkingSignature,e.thoughtSignature),a.push({type:`thinking_delta`,contentIndex:y(),delta:e.text,partial:r})):(_.text+=e.text,_.textSignature=c(_.textSignature,e.thoughtSignature),a.push({type:`text_delta`,contentIndex:y(),delta:e.text,partial:r}))}if(e.functionCall){_&&=(_.type===`text`?a.push({type:`text_end`,contentIndex:y(),content:_.text,partial:r}):a.push({type:`thinking_end`,contentIndex:y(),content:_.thinking,partial:r}),null);let t=e.functionCall.id,n={type:`toolCall`,id:!t||r.content.some(e=>e.type===`toolCall`&&e.id===t)?`${e.functionCall.name}_${Date.now()}_${++f}`:t,name:e.functionCall.name||``,arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};r.content.push(n),a.push({type:`toolcall_start`,contentIndex:y(),partial:r}),a.push({type:`toolcall_delta`,contentIndex:y(),delta:JSON.stringify(n.arguments),partial:r}),a.push({type:`toolcall_end`,contentIndex:y(),toolCall:n,partial:r})}}i?.finishReason&&(r.stopReason=o(i.finishReason),r.content.some(e=>e.type===`toolCall`)&&(r.stopReason=`toolUse`)),t.usageMetadata&&(r.usage={input:(t.usageMetadata.promptTokenCount||0)-(t.usageMetadata.cachedContentTokenCount||0),output:(t.usageMetadata.candidatesTokenCount||0)+(t.usageMetadata.thoughtsTokenCount||0),cacheRead:t.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:t.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},n(e,r.usage))}if(_&&(_.type===`text`?a.push({type:`text_end`,contentIndex:y(),content:_.text,partial:r}):a.push({type:`thinking_end`,contentIndex:y(),content:_.thinking,partial:r})),i?.signal?.aborted)throw Error(`Request was aborted`);if(r.stopReason===`aborted`||r.stopReason===`error`)throw Error(`An unknown error occurred`);a.push({type:`done`,reason:r.stopReason,message:r}),a.end()}catch(e){for(let e of r.content)`index`in e&&delete e.index;r.stopReason=i?.signal?.aborted?`aborted`:`error`,r.errorMessage=e instanceof Error?e.message:JSON.stringify(e),a.push({type:`error`,reason:r.stopReason,error:r}),a.end()}})(),a},m=(n,r,i)=>{let a=i?.apiKey;if(!a)throw Error(`No API key for provider: ${n.provider}`);let o=t(n,i,a);if(!i?.reasoning)return p(n,r,{...o,thinking:{enabled:!1}});let s=e(n,i.reasoning),c=s===`off`?`high`:s,l=n;return v(l)||y(l)||_(l)?p(n,r,{...o,thinking:{enabled:!0,level:x(c,l)}}):p(n,r,{...o,thinking:{enabled:!0,budgetTokens:S(l,c,i.thinkingBudgets)}})};function h(e,t,n){let r={};return e.baseUrl&&(r.baseUrl=e.baseUrl,r.apiVersion=``),(e.headers||n)&&(r.headers={...e.headers,...n}),new u({apiKey:t,httpOptions:Object.keys(r).length>0?r:void 0})}function g(e,t,n={}){let r=d(e,t),o={};n.temperature!==void 0&&(o.temperature=n.temperature),n.maxTokens!==void 0&&(o.maxOutputTokens=n.maxTokens);let c={...Object.keys(o).length>0&&o,...t.systemPrompt&&{systemInstruction:i(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:s(t.tools)}};if(t.tools&&t.tools.length>0&&n.toolChoice?c.toolConfig={functionCallingConfig:{mode:a(n.toolChoice)}}:c.toolConfig=void 0,n.thinking?.enabled&&e.reasoning){let e={includeThoughts:!0};n.thinking.level===void 0?n.thinking.budgetTokens!==void 0&&(e.thinkingBudget=n.thinking.budgetTokens):e.thinkingLevel=n.thinking.level,c.thinkingConfig=e}else e.reasoning&&n.thinking&&!n.thinking.enabled&&(c.thinkingConfig=b(e));if(n.signal){if(n.signal.aborted)throw Error(`Request aborted`);c.abortSignal=n.signal}return{model:e.id,contents:r,config:c}}function _(e){return/gemma-?4/.test(e.id.toLowerCase())}function v(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function y(e){return/gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase())}function b(e){return v(e)?{thinkingLevel:`LOW`}:y(e)||_(e)?{thinkingLevel:`MINIMAL`}:{thinkingBudget:0}}function x(e,t){if(v(t))switch(e){case`minimal`:case`low`:return`LOW`;case`medium`:case`high`:return`HIGH`}if(_(t))switch(e){case`minimal`:case`low`:return`MINIMAL`;case`medium`:case`high`:return`HIGH`}switch(e){case`minimal`:return`MINIMAL`;case`low`:return`LOW`;case`medium`:return`MEDIUM`;case`high`:return`HIGH`}}function S(e,t,n){return n?.[t]===void 0?e.id.includes(`2.5-pro`)?{minimal:128,low:2048,medium:8192,high:32768}[t]:e.id.includes(`2.5-flash-lite`)?{minimal:512,low:2048,medium:8192,high:24576}[t]:e.id.includes(`2.5-flash`)?{minimal:128,low:2048,medium:8192,high:24576}[t]:-1:n[t]}export{p as streamGoogle,m as streamSimpleGoogle};