sliccy 6.141.7 → 6.141.8

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 (165) hide show
  1. package/dist/ui/.vite/manifest.json +247 -247
  2. package/dist/ui/assets/{SKILL-B-lyKDjk.js → SKILL-Cr7egSCS.js} +1 -1
  3. package/dist/ui/assets/__vite-browser-external-CCBdZzAl.js +1 -0
  4. package/dist/ui/assets/{account-store-CFMsGuVj.js → account-store-CEAZoLNK.js} +1 -1
  5. package/dist/ui/assets/{account-store-CXfDPizG.js → account-store-Cwl8IuHt.js} +3 -3
  6. package/dist/ui/assets/{adobe-DJwX7Ux6.js → adobe-D80Ie-ed.js} +1 -1
  7. package/dist/ui/assets/{adobe-fxqV4K1R.js → adobe-DaUh3W2w.js} +2 -2
  8. package/dist/ui/assets/{agent-bridge-CB8iy1j4.js → agent-bridge-DEU7ELu7.js} +1 -1
  9. package/dist/ui/assets/{agent-panels-BnckKLfE.js → agent-panels-TDJXaiL5.js} +1 -1
  10. package/dist/ui/assets/{apply-layout-BW4itefy.js → apply-layout-CwJHKjB_.js} +1 -1
  11. package/dist/ui/assets/{apps-oKciElq1.js → apps-CcjRpjnv.js} +1 -1
  12. package/dist/ui/assets/{azure-openai-Lwlqe7S7.js → azure-openai-3ZzRqF-3.js} +1 -1
  13. package/dist/ui/assets/{azure-openai-BUTMNYnz.js → azure-openai-DKAVo2dS.js} +1 -1
  14. package/dist/ui/assets/{bsh-watchdog-DqSIi75u.js → bsh-watchdog-DBtF-C4h.js} +1 -1
  15. package/dist/ui/assets/{budget-usage-source-DqMSBfUL.js → budget-usage-source-BMZHvYRp.js} +1 -1
  16. package/dist/ui/assets/{capability-CTDMHYYU.js → capability-DQ10DnFn.js} +2 -2
  17. package/dist/ui/assets/{cdp-BD-FxIuV.js → cdp-C7br8bwu.js} +1 -1
  18. package/dist/ui/assets/{cerebras-COloh8TC.js → cerebras-BANRLPiQ.js} +1 -1
  19. package/dist/ui/assets/{cerebras-C5prRYSO.js → cerebras-Bij3KK98.js} +1 -1
  20. package/dist/ui/assets/{client-C6Cmi9c4.js → client-BOKSI80x.js} +1 -1
  21. package/dist/ui/assets/{composer-speech-DAs0XFi-.js → composer-speech-Dc4t4MKw.js} +1 -1
  22. package/dist/ui/assets/{connect-surface-CuCNpB5y.js → connect-surface-BLBrlSOL.js} +1 -1
  23. package/dist/ui/assets/{core-BkHMrXyn.js → core-D59qaXEb.js} +2 -2
  24. package/dist/ui/assets/{directed-approval-BTY3OSJr.js → directed-approval-CW-FQtZe.js} +1 -1
  25. package/dist/ui/assets/{discovery-preference-B9KlkVuR.js → discovery-preference-Bw3Fi0jd.js} +1 -1
  26. package/dist/ui/assets/{ensure-speech-assets-B14FEqf-.js → ensure-speech-assets-uGHvkmNC.js} +1 -1
  27. package/dist/ui/assets/{esbuild-wasm-CY2jFm-D.js → esbuild-wasm-DS_YG2EY.js} +1 -1
  28. package/dist/ui/assets/{extension-media-capture-BwxRQ-WA.js → extension-media-capture-tkRa9U5Y.js} +1 -1
  29. package/dist/ui/assets/{extension-ops-owOXVncP.js → extension-ops-B9_1VB7W.js} +1 -1
  30. package/dist/ui/assets/fetch-body-1l9I58Vk.js +1 -0
  31. package/dist/ui/assets/fetch-body-CuwTaJC_.js +1 -0
  32. package/dist/ui/assets/{float-topology-hfgMx1Yq.js → float-topology-YtctpJaG.js} +1 -1
  33. package/dist/ui/assets/{follower-navigate-watcher-CwdJv8y0.js → follower-navigate-watcher-DnnHgZbM.js} +1 -1
  34. package/dist/ui/assets/{fs-VBwrIPDY.js → fs-BKexOyag.js} +1 -1
  35. package/dist/ui/assets/{fs-B_BrUO51.js → fs-CU96-HV6.js} +2 -2
  36. package/dist/ui/assets/{github-DTv9ErU0.js → github-BhDXzWL_.js} +2 -2
  37. package/dist/ui/assets/{github-BbvYTiSW.js → github-DF7sr_VH.js} +1 -1
  38. package/dist/ui/assets/{github-copilot-Bs2h0Rb4.js → github-copilot-Du5BHggd.js} +1 -1
  39. package/dist/ui/assets/{github-copilot-DgKMUhj5.js → github-copilot-UZhYRLwj.js} +1 -1
  40. package/dist/ui/assets/{github-install-BNVjef29.js → github-install-QwJ9NPPu.js} +1 -1
  41. package/dist/ui/assets/{github-zip-DrqYcr27.js → github-zip-CrArqxl7.js} +1 -1
  42. package/dist/ui/assets/{guest-tool-gate-CwWcQt6s.js → guest-tool-gate-6uzbOlEb.js} +1 -1
  43. package/dist/ui/assets/{hear-BBEfbrDS.js → hear-CFOMeYid.js} +1 -1
  44. package/dist/ui/assets/{help-DEuaW0kP.js → help-CWKmQYm5.js} +1 -1
  45. package/dist/ui/assets/{installer-CTX50_zb.js → installer-D4WxHb-C.js} +1 -1
  46. package/dist/ui/assets/{js-realm-worker-C7fJqlVb.js → js-realm-worker-_CPOUT7t.js} +1 -1
  47. package/dist/ui/assets/{kernel-worker-DJjEdjJ-.js → kernel-worker-qkoRau88.js} +648 -648
  48. package/dist/ui/assets/{lick-urls-BX4Jyu_T.js → lick-urls-CadwTNxP.js} +1 -1
  49. package/dist/ui/assets/{lick-ws-bridge-RFOSPq0w.js → lick-ws-bridge-BbfNnO1f.js} +1 -1
  50. package/dist/ui/assets/{lick-ws-bridge-Bb2eVADZ.js → lick-ws-bridge-kNThwPRX.js} +1 -1
  51. package/dist/ui/assets/{local-llm-fsN28EfF.js → local-llm-BeWeLoIk.js} +1 -1
  52. package/dist/ui/assets/{local-llm-CxvKVF0S.js → local-llm-CgXFWHeJ.js} +1 -1
  53. package/dist/ui/assets/{magick-wasm-DrHkiveP.js → magick-wasm-DCNZhAyd.js} +1 -1
  54. package/dist/ui/assets/{main-DHBCUrMc.js → main-DVxB5Z8n.js} +3 -3
  55. package/dist/ui/assets/{main-cherry-5uSsQZRp.js → main-cherry-Pp7ujtqs.js} +1 -1
  56. package/dist/ui/assets/{mount-CpBS4aby.js → mount-D7qvr-ge.js} +1 -1
  57. package/dist/ui/assets/{mount-bridge-client-BejrWSrL.js → mount-bridge-client-B5qLR9Xe.js} +1 -1
  58. package/dist/ui/assets/{mount-bridge-client-DGJyqEPG.js → mount-bridge-client-DQaM1wCj.js} +1 -1
  59. package/dist/ui/assets/{mount-recovery-C9bvv149.js → mount-recovery-CVrJKl5B.js} +1 -1
  60. package/dist/ui/assets/{mount-CW-V6Cm4.js → mount-y0UfiDsh.js} +3 -3
  61. package/dist/ui/assets/{new-session-D3chDI33.js → new-session-CJk1rMVG.js} +2 -2
  62. package/dist/ui/assets/{oauth-bootstrap-CKus9F8c.js → oauth-bootstrap-BmOIy_7z.js} +2 -2
  63. package/dist/ui/assets/{oauth-service-Bconf2Pz.js → oauth-service-BZl-9EoE.js} +1 -1
  64. package/dist/ui/assets/{oauth-service-t2taQm3p.js → oauth-service-BsW9nY_u.js} +1 -1
  65. package/dist/ui/assets/{onboarding-orchestrator-DGE_bETH.js → onboarding-orchestrator-Bq-rXwpx.js} +1 -1
  66. package/dist/ui/assets/{openai-codex-CmnEIPtZ.js → openai-codex-BddTNepd.js} +1 -1
  67. package/dist/ui/assets/{openai-codex-esFMx96Q.js → openai-codex-CQwv0zox.js} +1 -1
  68. package/dist/ui/assets/{openrouter-nUYSbr_8.js → openrouter-23Yevrn0.js} +1 -1
  69. package/dist/ui/assets/{openrouter-Ch8udESK.js → openrouter-Bw0xzSk-.js} +1 -1
  70. package/dist/ui/assets/{openrouter-free-BINVRaE3.js → openrouter-free-DKJd2ua1.js} +1 -1
  71. package/dist/ui/assets/{openrouter-free-BP8X4BrJ.js → openrouter-free-DZOMkxtc.js} +1 -1
  72. package/dist/ui/assets/{openrouter-oauth-DfPhmOUG.js → openrouter-oauth-Do9q3Xgz.js} +1 -1
  73. package/dist/ui/assets/{openrouter-oauth-C711G__3.js → openrouter-oauth-lNzzIZx6.js} +1 -1
  74. package/dist/ui/assets/{page-approval-service-IZdlRu-_.js → page-approval-service-BXlCsull.js} +1 -1
  75. package/dist/ui/assets/{panel-rpc-handlers-gxDDQEXH.js → panel-rpc-handlers-DaLBBnwR.js} +2 -2
  76. package/dist/ui/assets/{panelize-shell-Dae2JiOo.js → panelize-shell-DHMvaJBW.js} +1 -1
  77. package/dist/ui/assets/{port-bridge-client-CN1cFP4D.js → port-bridge-client-CzOd_VUf.js} +1 -1
  78. package/dist/ui/assets/{port-bridge-client-C1tBBqwu.js → port-bridge-client-Dn8JtUyP.js} +1 -1
  79. package/dist/ui/assets/{provider-CyvoATKb.js → provider-8TZBqQOE.js} +1 -1
  80. package/dist/ui/assets/{provider-THUQ7opK.js → provider-BXf5XZr2.js} +2 -2
  81. package/dist/ui/assets/provider-settings-D724hVOu.js +1 -0
  82. package/dist/ui/assets/provider-store-access-BhjM7PKW.js +1 -0
  83. package/dist/ui/assets/provider-store-access-CZ9WDFkY.js +1 -0
  84. package/dist/ui/assets/{providers-BSRKK3d0.js → providers-B5rOY1a1.js} +2 -2
  85. package/dist/ui/assets/{providers-CL5YW5L_.js → providers-Bw8qthsB.js} +1 -1
  86. package/dist/ui/assets/proxied-fetch-B57RqgUb.js +1 -0
  87. package/dist/ui/assets/proxied-fetch-DyBveeCl.js +2 -0
  88. package/dist/ui/assets/{py-realm-worker-CMUAG309.js → py-realm-worker-BRyQamcA.js} +2 -2
  89. package/dist/ui/assets/{pyodide-BIBsaAI1.js → pyodide-DwR4k6wB.js} +2 -2
  90. package/dist/ui/assets/{quick-llm-DmqGayab.js → quick-llm-C6qo7XyB.js} +1 -1
  91. package/dist/ui/assets/{recovery-screen-DsiidcGL.js → recovery-screen-CH3zhPDh.js} +1 -1
  92. package/dist/ui/assets/{redirect-uri-BKkf61lT.js → redirect-uri-C6BjkDE0.js} +1 -1
  93. package/dist/ui/assets/{request-body-DWn6QJ_H.js → request-body-DkfS6k_a.js} +1 -1
  94. package/dist/ui/assets/{rest-ops-B8ZocTVM.js → rest-ops-BqrLSIci.js} +1 -1
  95. package/dist/ui/assets/rest-ops-CB2up_K0.js +1 -0
  96. package/dist/ui/assets/{run-BQYuITED.js → run-BFajL-AN.js} +1 -1
  97. package/dist/ui/assets/{run-dSobJ2Jl.js → run-CIBH4srb.js} +1 -1
  98. package/dist/ui/assets/{run-BwvikZU9.js → run-CwaUjx8V.js} +3 -3
  99. package/dist/ui/assets/{run-BXS2Xb9z.js → run-SyWvtuJ2.js} +1 -1
  100. package/dist/ui/assets/{run-DcJO0Q_l.js → run-pRmaVv6J.js} +1 -1
  101. package/dist/ui/assets/{secret-env-CtpVPUh5.js → secret-env-CDLWFhsq.js} +1 -1
  102. package/dist/ui/assets/secret-topology-DLJBhHOi.js +1 -0
  103. package/dist/ui/assets/{secrets-bridge-client-BVl0YuB2.js → secrets-bridge-client--VZ3E0yk.js} +1 -1
  104. package/dist/ui/assets/{secrets-bridge-client-C3MaYf_O.js → secrets-bridge-client-DBeju3mP.js} +1 -1
  105. package/dist/ui/assets/{setup-feature-flags-remote-CCVURhOa.js → setup-feature-flags-remote-BkpPhC1Z.js} +1 -1
  106. package/dist/ui/assets/{shared-pVZLJOGO.js → shared-C_68vn79.js} +1 -1
  107. package/dist/ui/assets/{shared-f0tP2HLX.js → shared-mBEktoxE.js} +1 -1
  108. package/dist/ui/assets/sidecar-repair-BvU5BUMN.js +1 -0
  109. package/dist/ui/assets/{silent-renew-backoff-NUOsvkhU.js → silent-renew-backoff-CZ1TwMLl.js} +1 -1
  110. package/dist/ui/assets/{skills-_XzqiacK.js → skills-ClBlzj1u.js} +1 -1
  111. package/dist/ui/assets/slicc-version-DbFQKRyB.js +1 -0
  112. package/dist/ui/assets/{snapshot-xiU8QrQ6.js → snapshot-DUgMkmOh.js} +1 -1
  113. package/dist/ui/assets/{snapshot-features-DPtV-_xm.js → snapshot-features-CkPFKX69.js} +1 -1
  114. package/dist/ui/assets/{soundscape-3h8lfb4F.js → soundscape-CCcYOlZU.js} +1 -1
  115. package/dist/ui/assets/{speak-Di-lhbDO.js → speak-BNmjkd_v.js} +1 -1
  116. package/dist/ui/assets/{sprinkle-manager-D_07OoJ5.js → sprinkle-manager-Fu8L5PDi.js} +1 -1
  117. package/dist/ui/assets/{sprinkle-renderer-DYrPWp4H.js → sprinkle-renderer-DjdEnymN.js} +1 -1
  118. package/dist/ui/assets/{state-DtlUsAUL.js → state-y3jlrpur.js} +1 -1
  119. package/dist/ui/assets/{store-CEAWKc4S.js → store-D0T2s0HF.js} +1 -1
  120. package/dist/ui/assets/{store-nXeqSGx4.js → store-qly_SAEJ.js} +1 -1
  121. package/dist/ui/assets/{sudo-DIHWn-Pe.js → sudo-Csjb1cVU.js} +1 -1
  122. package/dist/ui/assets/{sync-dialog-DUd6zSQg.js → sync-dialog-D43hIGeZ.js} +1 -1
  123. package/dist/ui/assets/{transformers-env-DNRJ-G4q.js → transformers-env-DScC-DG4.js} +1 -1
  124. package/dist/ui/assets/{tray-leader-DaLUK8LB.js → tray-leader-DxB_xkTl.js} +1 -1
  125. package/dist/ui/assets/{tray-leave-runtime-VfTj-MHR.js → tray-leave-runtime-R-KcYamc.js} +1 -1
  126. package/dist/ui/assets/{tray-runtime-config-C3Ti4Pik.js → tray-runtime-config--rtR6Gxd.js} +1 -1
  127. package/dist/ui/assets/{tray-runtime-config-BQL-GPqt.js → tray-runtime-config-DB2KZRBg.js} +1 -1
  128. package/dist/ui/assets/{tray-sidecar-ArFM9pOi.js → tray-sidecar-y_fgamIf.js} +1 -1
  129. package/dist/ui/assets/{upgrade-detection-BjJjmfFd.js → upgrade-detection-QpnKhp2v.js} +1 -1
  130. package/dist/ui/assets/{voice-reply-FKlkYh03.js → voice-reply-DXkbvJlN.js} +1 -1
  131. package/dist/ui/assets/{wc-attach-B7RX6mE5.js → wc-attach-mC-QT5Ic.js} +2 -2
  132. package/dist/ui/assets/{wc-extension-Ci5u-uK_.js → wc-extension-DBBpY_Lc.js} +2 -2
  133. package/dist/ui/assets/{wc-follower-oauth-BaLZ9QSi.js → wc-follower-oauth-Cf8TRGD4.js} +1 -1
  134. package/dist/ui/assets/{wc-follower-B18VFqGM.js → wc-follower-pIAMC7qM.js} +3 -3
  135. package/dist/ui/assets/{wc-live-hpN3rKpB.js → wc-live-dLGR7yx7.js} +6 -6
  136. package/dist/ui/assets/{wc-nav-BvxczmXD.js → wc-nav-DMUSwyOi.js} +2 -2
  137. package/dist/ui/assets/{wc-onboarding-BPzCWMO7.js → wc-onboarding-P8IAA7id.js} +2 -2
  138. package/dist/ui/assets/{wc-placeholder-fTSa0JGY.js → wc-placeholder-DnhIIUcc.js} +3 -3
  139. package/dist/ui/assets/{wc-settings-CAm6-S98.js → wc-settings-4L7TTUTW.js} +3 -3
  140. package/dist/ui/assets/{wc-shell-g3CK7mcS.js → wc-shell-dKirRlx7.js} +3 -3
  141. package/dist/ui/assets/{wc-shortcut-config-CQ8zNq7I.js → wc-shortcut-config-Brdl48c-.js} +1 -1
  142. package/dist/ui/assets/{wc-shortcuts-wUfu4tws.js → wc-shortcuts-aNLhXJiJ.js} +1 -1
  143. package/dist/ui/assets/{wc-sprinkles-4S6BP00c.js → wc-sprinkles-Drv2R5zb.js} +2 -2
  144. package/dist/ui/assets/{wc-transcript-export-B13Xi-JT.js → wc-transcript-export-BMaOQhg5.js} +2 -2
  145. package/dist/ui/assets/{wc-tray-BIo-L8fM.js → wc-tray-CQt_EQqF.js} +4 -4
  146. package/dist/ui/assets/welcome-detection-Cc5hkELZ.js +1 -0
  147. package/dist/ui/assets/{whisper-session-DNd6_52M.js → whisper-session-kbe8kYgx.js} +2 -2
  148. package/dist/ui/assets/{xai-grok-Cw1yK3lP.js → xai-grok-B7VsCt4B.js} +1 -1
  149. package/dist/ui/assets/{xai-grok-kHDQcaaw.js → xai-grok-CyxuRI90.js} +1 -1
  150. package/dist/ui/index.html +10 -10
  151. package/dist/ui/packages/webapp/index.html +10 -10
  152. package/package.json +1 -1
  153. package/dist/ui/assets/__vite-browser-external-oXcxoO19.js +0 -1
  154. package/dist/ui/assets/fetch-body-COdvQyTD.js +0 -1
  155. package/dist/ui/assets/fetch-body-D2PwksUW.js +0 -1
  156. package/dist/ui/assets/provider-settings-6sXphFYx.js +0 -1
  157. package/dist/ui/assets/provider-store-access-DWa5TbP8.js +0 -1
  158. package/dist/ui/assets/provider-store-access-mgYIDF7e.js +0 -1
  159. package/dist/ui/assets/proxied-fetch-CiijUcSt.js +0 -2
  160. package/dist/ui/assets/proxied-fetch-DUC7X0GS.js +0 -1
  161. package/dist/ui/assets/rest-ops-D2ig8qfG.js +0 -1
  162. package/dist/ui/assets/secret-topology-Yt0aO4Gz.js +0 -1
  163. package/dist/ui/assets/sidecar-repair-D_pxqfwf.js +0 -1
  164. package/dist/ui/assets/slicc-version-C0lVFO4A.js +0 -1
  165. package/dist/ui/assets/welcome-detection-etqz9LPK.js +0 -1
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-CXfDPizG.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-CSATLzrT.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/base64-DJRlyqZu.js","assets/proxied-fetch-CiijUcSt.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-DGxXvrur.js","assets/runtime-env-Dlaokqg1.js","assets/float-topology-hfgMx1Yq.js","assets/secret-topology-Yt0aO4Gz.js","assets/secrets-bridge-client-BVl0YuB2.js","assets/port-bridge-client-C1tBBqwu.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-BSRKK3d0.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-BeCSBUrZ.js"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-Czpn1I53.js";import{n as t}from"./mime-types-D0xZwlMO.js";import{r as n,t as r}from"./base64-DJRlyqZu.js";import{t as i}from"./types-Dgm4REV3.js";import"./mount-table-store-dY2IfQ5S.js";import"./fs-B_BrUO51.js";import{t as a}from"./remote-cache-3KNT1gsp.js";var o=`https://api.aem.live`,s=`application/folder`,c=5242880;function l(e){let t=e.match(/^aem:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid AEM source '${e}' — expected aem://org/site[/path]`);return{org:t[1],site:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}function u(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function d(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function f(e){return e.map(e=>e[`content-type`]===s||e.name.endsWith(`/`)?{name:e.name.replace(/\/+$/,``),kind:`directory`}:{name:e.name,kind:`file`,size:e.size,etag:u(e[`last-modified`]),lastModified:d(e[`last-modified`])})}var p=class{kind=`aem`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=l(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??c,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`),r=`/${this.parsed.org}/sites/${this.parsed.site}/source`;return n?`${r}/${n}`:r}toListPath(e){return`${this.toSourcePath(e)}/`}request(e,t,n){return this.transport({method:e,path:t,origin:o,headers:n?.headers,body:n?.body})}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r=await this.request(`GET`,this.toSourcePath(t));if(r.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new i(`EIO`,`aem readFile failed: ${r.status}`,e);let a=new Uint8Array(await r.arrayBuffer());if(a.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,a,u(r.headers.get(`last-modified`))),a}async assertUnchanged(e,t,n){if(!n)return;let r=await this.request(`HEAD`,this.toSourcePath(t));if(r.status===404)return;if(r.status>=400)throw new i(`EIO`,`aem precondition HEAD failed: ${r.status}`,e);let a=u(r.headers.get(`last-modified`));if(a&&a!==n)throw await this.cache.invalidateBody(t),new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);await this.assertUnchanged(e,n,r?.etag??``);let a=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(a.status===401||a.status===403)throw new i(`EACCES`,`aem write denied`,e);if(a.status>=400)throw new i(`EIO`,`aem writeFile failed: ${a.status}`,e);await this.cache.invalidateBody(n);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.request(`GET`,this.toListPath(t));if(r.status===404)throw new i(`ENOENT`,`no such directory`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new i(`EIO`,`aem list failed: ${r.status}`,e);let a=f(await r.json());return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e);if(t===``)return{kind:`directory`,size:0,mtime:0};let n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o),c=(s&&!this.cache.isStale(s.cachedAt)?s.entries:await this.readDirQuietly(o))?.find(e=>e.name===a);if(!c)throw new i(`ENOENT`,`no such file or directory`,e);return c.kind===`directory`?{kind:`directory`,size:0,mtime:c.lastModified??0}:{kind:`file`,size:c.size??0,mtime:c.lastModified??0,etag:c.etag??``}}async readDirQuietly(e){try{return await this.readDir(e)}catch{return null}}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.request(`DELETE`,this.toSourcePath(t));if(n.status===404)throw new i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new i(`EIO`,`aem delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.request(`GET`,this.toListPath(e));if(r.status===404){await this.cache.putListing(e,[]);return}if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=f(await r.json());for(let r of i){let i=e?`${e}/${r.name}`:r.name;r.kind===`directory`?n.push(i):await this.classifyFile(i,r.etag??``,t)}await this.cache.putListing(e,i)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.site}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},m=`\r
3
- `;function h(){let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<e.length;t+=1)e[t]=Math.floor(Math.random()*256);let t=``;for(let n of e)t+=n.toString(16).padStart(2,`0`);return`----SliccFormBoundary${t}`}function g(e,t=h()){let n=new TextEncoder,r=[];for(let i of e){let e=v(_(i.name));if(`file`in i){let a=v(i.file.filename),o=y(i.file.contentType)||`application/octet-stream`;r.push(n.encode(`--${t}${m}Content-Disposition: form-data; name="${e}"; filename="${a}"${m}Content-Type: ${o}${m}${m}`)),r.push(i.file.bytes),r.push(n.encode(m))}else r.push(n.encode(`--${t}${m}Content-Disposition: form-data; name="${e}"${m}${m}${_(i.value)}${m}`))}return r.push(n.encode(`--${t}--${m}`)),{bytes:b(r),contentType:`multipart/form-data; boundary=${t}`,boundary:t}}function _(e){return e.replace(/\r\n|\r|\n/g,m)}function v(e){return e.replace(/\r/g,`%0D`).replace(/\n/g,`%0A`).replace(/"/g,`%22`)}function y(e){return(e??``).replace(/[\r\n]/g,``).trim()}function b(e){let t=0;for(let n of e)t+=n.byteLength;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}function x(e,t,n){let r=g([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function S(e){return e.split(`/`).pop()||`data`}function C(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var w=5242880,T=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=C(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??w,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`da access denied`,e);if(a.status>=400)throw new i(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),a=await this.cache.getBody(r),o=x(S(e),t(e),n),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a?.etag?s[`if-match`]=a.etag.startsWith(`W/`)?a.etag.slice(2):a.etag:a||(s[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:s,body:o.body}),l,u=1;try{l=await c()}catch{u=2,l=await c()}if(l.status===412){if(u===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new i(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let a=t.headers.get(`etag`)??``;await this.cache.putBody(r,n,a);let o=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new i(`EACCES`,`da write denied`,e);if(l.status>=400)throw new i(`EIO`,`da writeFile failed: ${l.status}`,e);let d=l.headers.get(`etag`)??``;await this.cache.putBody(r,n,d);let f=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(f)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.transport({method:`GET`,path:this.toListPath(t)});if(r.status===404)throw new i(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new i(`EIO`,`da list failed: ${r.status}`,e);let a=(await r.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new i(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new i(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function E(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var D=26214400,O=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=E(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??D,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new i(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?a[`if-match`]=r.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:a,body:t}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new i(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let a=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new i(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new i(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let r=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(r.status>=400)throw new i(`EIO`,`s3 list failed: ${r.status}`,`/`);let a=await r.text(),o=this.parseListingXml(a);e.push(...o.contents),t=o.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new i(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new i(`EINVAL`,`recursive remove not yet supported on S3`,e);let r=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status===404)throw new i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new i(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},k=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function A(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-CXfDPizG.js`).then(e=>e.r);return{getAccounts:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new k(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var j=r,M=n,N=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),P=new Set([101,103,204,205,304]);function F(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new i(`EACCES`,e.error):e.errorCode===`invalid_request`?new i(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||N.has(String(e.errorCode))?new i(`EIO`,e.error):new i(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=j(e.bodyBase64)}catch(e){throw new i(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=P.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function I(e){throw new i(`EIO`,`mount transport unavailable: setMountCapabilityBroker was never called for this float (composition bug — refusing to guess a transport for a privileged sign-and-forward request)`)}function L(e){return async t=>F(await I({backend:`s3`,envelope:{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?M(t.body):void 0}}))}function R(e){let t=e?.getImsToken??(async()=>(await A()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new i(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return F(await I({backend:`da`,envelope:{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?M(e.body):void 0}}))}}export{p as AemMountBackend,T as DaMountBackend,a as RemoteMountCache,O as S3MountBackend,R as makeSignedFetchDa,L as makeSignedFetchS3};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-Cwl8IuHt.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-CSATLzrT.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/base64-DJRlyqZu.js","assets/proxied-fetch-DyBveeCl.js","assets/fetch-body-1l9I58Vk.js","assets/api-endpoint-DGxXvrur.js","assets/runtime-env-Dlaokqg1.js","assets/float-topology-YtctpJaG.js","assets/secret-topology-DLJBhHOi.js","assets/secrets-bridge-client--VZ3E0yk.js","assets/port-bridge-client-Dn8JtUyP.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-B5rOY1a1.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-BeCSBUrZ.js"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./preload-helper-Czpn1I53.js";import{n as t}from"./mime-types-D0xZwlMO.js";import{r as n,t as r}from"./base64-DJRlyqZu.js";import{t as i}from"./types-Dgm4REV3.js";import"./mount-table-store-dY2IfQ5S.js";import"./fs-CU96-HV6.js";import{t as a}from"./remote-cache-3KNT1gsp.js";var o=`https://api.aem.live`,s=`application/folder`,c=5242880;function l(e){let t=e.match(/^aem:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid AEM source '${e}' — expected aem://org/site[/path]`);return{org:t[1],site:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}function u(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function d(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function f(e){return e.map(e=>e[`content-type`]===s||e.name.endsWith(`/`)?{name:e.name.replace(/\/+$/,``),kind:`directory`}:{name:e.name,kind:`file`,size:e.size,etag:u(e[`last-modified`]),lastModified:d(e[`last-modified`])})}var p=class{kind=`aem`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=l(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??c,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`),r=`/${this.parsed.org}/sites/${this.parsed.site}/source`;return n?`${r}/${n}`:r}toListPath(e){return`${this.toSourcePath(e)}/`}request(e,t,n){return this.transport({method:e,path:t,origin:o,headers:n?.headers,body:n?.body})}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r=await this.request(`GET`,this.toSourcePath(t));if(r.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new i(`EIO`,`aem readFile failed: ${r.status}`,e);let a=new Uint8Array(await r.arrayBuffer());if(a.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,a,u(r.headers.get(`last-modified`))),a}async assertUnchanged(e,t,n){if(!n)return;let r=await this.request(`HEAD`,this.toSourcePath(t));if(r.status===404)return;if(r.status>=400)throw new i(`EIO`,`aem precondition HEAD failed: ${r.status}`,e);let a=u(r.headers.get(`last-modified`));if(a&&a!==n)throw await this.cache.invalidateBody(t),new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);await this.assertUnchanged(e,n,r?.etag??``);let a=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(a.status===401||a.status===403)throw new i(`EACCES`,`aem write denied`,e);if(a.status>=400)throw new i(`EIO`,`aem writeFile failed: ${a.status}`,e);await this.cache.invalidateBody(n);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.request(`GET`,this.toListPath(t));if(r.status===404)throw new i(`ENOENT`,`no such directory`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new i(`EIO`,`aem list failed: ${r.status}`,e);let a=f(await r.json());return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e);if(t===``)return{kind:`directory`,size:0,mtime:0};let n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o),c=(s&&!this.cache.isStale(s.cachedAt)?s.entries:await this.readDirQuietly(o))?.find(e=>e.name===a);if(!c)throw new i(`ENOENT`,`no such file or directory`,e);return c.kind===`directory`?{kind:`directory`,size:0,mtime:c.lastModified??0}:{kind:`file`,size:c.size??0,mtime:c.lastModified??0,etag:c.etag??``}}async readDirQuietly(e){try{return await this.readDir(e)}catch{return null}}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.request(`DELETE`,this.toSourcePath(t));if(n.status===404)throw new i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new i(`EIO`,`aem delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.request(`GET`,this.toListPath(e));if(r.status===404){await this.cache.putListing(e,[]);return}if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=f(await r.json());for(let r of i){let i=e?`${e}/${r.name}`:r.name;r.kind===`directory`?n.push(i):await this.classifyFile(i,r.etag??``,t)}await this.cache.putListing(e,i)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.site}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},m=`\r
3
+ `;function h(){let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<e.length;t+=1)e[t]=Math.floor(Math.random()*256);let t=``;for(let n of e)t+=n.toString(16).padStart(2,`0`);return`----SliccFormBoundary${t}`}function g(e,t=h()){let n=new TextEncoder,r=[];for(let i of e){let e=v(_(i.name));if(`file`in i){let a=v(i.file.filename),o=y(i.file.contentType)||`application/octet-stream`;r.push(n.encode(`--${t}${m}Content-Disposition: form-data; name="${e}"; filename="${a}"${m}Content-Type: ${o}${m}${m}`)),r.push(i.file.bytes),r.push(n.encode(m))}else r.push(n.encode(`--${t}${m}Content-Disposition: form-data; name="${e}"${m}${m}${_(i.value)}${m}`))}return r.push(n.encode(`--${t}--${m}`)),{bytes:b(r),contentType:`multipart/form-data; boundary=${t}`,boundary:t}}function _(e){return e.replace(/\r\n|\r|\n/g,m)}function v(e){return e.replace(/\r/g,`%0D`).replace(/\n/g,`%0A`).replace(/"/g,`%22`)}function y(e){return(e??``).replace(/[\r\n]/g,``).trim()}function b(e){let t=0;for(let n of e)t+=n.byteLength;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}function x(e,t,n){let r=g([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function S(e){return e.split(`/`).pop()||`data`}function C(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var w=5242880,T=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=C(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??w,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`da access denied`,e);if(a.status>=400)throw new i(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),a=await this.cache.getBody(r),o=x(S(e),t(e),n),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a?.etag?s[`if-match`]=a.etag.startsWith(`W/`)?a.etag.slice(2):a.etag:a||(s[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:s,body:o.body}),l,u=1;try{l=await c()}catch{u=2,l=await c()}if(l.status===412){if(u===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new i(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let a=t.headers.get(`etag`)??``;await this.cache.putBody(r,n,a);let o=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new i(`EACCES`,`da write denied`,e);if(l.status>=400)throw new i(`EIO`,`da writeFile failed: ${l.status}`,e);let d=l.headers.get(`etag`)??``;await this.cache.putBody(r,n,d);let f=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(f)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.transport({method:`GET`,path:this.toListPath(t)});if(r.status===404)throw new i(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new i(`EIO`,`da list failed: ${r.status}`,e);let a=(await r.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new i(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new i(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function E(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var D=26214400,O=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=E(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??D,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new i(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?a[`if-match`]=r.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:a,body:t}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new i(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let a=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new i(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new i(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let r=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(r.status>=400)throw new i(`EIO`,`s3 list failed: ${r.status}`,`/`);let a=await r.text(),o=this.parseListingXml(a);e.push(...o.contents),t=o.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new i(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new i(`EINVAL`,`recursive remove not yet supported on S3`,e);let r=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status===404)throw new i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new i(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},k=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function A(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-Cwl8IuHt.js`).then(e=>e.r);return{getAccounts:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new k(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var j=r,M=n,N=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),P=new Set([101,103,204,205,304]);function F(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new i(`EACCES`,e.error):e.errorCode===`invalid_request`?new i(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||N.has(String(e.errorCode))?new i(`EIO`,e.error):new i(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=j(e.bodyBase64)}catch(e){throw new i(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=P.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function I(e){throw new i(`EIO`,`mount transport unavailable: setMountCapabilityBroker was never called for this float (composition bug — refusing to guess a transport for a privileged sign-and-forward request)`)}function L(e){return async t=>F(await I({backend:`s3`,envelope:{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?M(t.body):void 0}}))}function R(e){let t=e?.getImsToken??(async()=>(await A()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new i(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return F(await I({backend:`da`,envelope:{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?M(e.body):void 0}}))}}export{p as AemMountBackend,T as DaMountBackend,a as RemoteMountCache,O as S3MountBackend,R as makeSignedFetchDa,L as makeSignedFetchS3};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/quick-llm-DmqGayab.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/account-store-CXfDPizG.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-CSATLzrT.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/base64-DJRlyqZu.js","assets/proxied-fetch-CiijUcSt.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-DGxXvrur.js","assets/runtime-env-Dlaokqg1.js","assets/float-topology-hfgMx1Yq.js","assets/secret-topology-Yt0aO4Gz.js","assets/secrets-bridge-client-BVl0YuB2.js","assets/port-bridge-client-C1tBBqwu.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-BSRKK3d0.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-BeCSBUrZ.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-BXcp4CBT.js"])))=>i.map(i=>d[i]);
2
- import{B as e,g as t}from"./account-store-CXfDPizG.js";import{t as n}from"./preload-helper-Czpn1I53.js";import{t as r}from"./logger-DDBAeTLF.js";import{B as i,F as a,I as o,M as s,N as c,P as l}from"./wc-live-hpN3rKpB.js";import{r as u}from"./feature-flags-DaSRRz0w.js";import"./main-DHBCUrMc.js";import{t as d}from"./llm-session-id-bZQs6gBN.js";var f=r(`new-session`),p=`ui-new-session`,m=2e4,h=250;async function g(n){try{let r=await n.openVfs(),i=t()??void 0;if(!i)return;let a;try{a=e()}catch{return}let s=a.provider===`adobe`?{"X-Session-Id":d(p)}:void 0;await o({vfs:r,model:a,apiKey:i,headers:s}),n.onComplete?.()}catch(e){f.warn(`Pending session catch-up failed (boot continues)`,{error:e instanceof Error?e.message:String(e)})}}function _(e){(e.schedule??v)(()=>{g(e)})}function v(e){if(typeof globalThis.requestIdleCallback==`function`){globalThis.requestIdleCallback(e,{timeout:5e3});return}setTimeout(e,0)}function y(e){if(u(`agentic-memory`)){if(!e.agenticMemorySpawn){f.info(`Agentic memory enabled but agent bridge unavailable — using legacy enrichment`);return}return e.agenticMemorySpawn}}async function b(e,t,n,r,i,o){let s=await l({sessionStore:t,vfs:e.vfs,mode:`quick`,agenticMemorySpawn:o,cone:e.cone});if(!s)return null;if(e.captureCompleteSnapshot)try{await e.captureCompleteSnapshot(s)}catch(t){let n=t?.code??`unknown`;f.warn(`captureCompleteSnapshot failed`,{code:n}),s.completeSnapshotUnavailable=!0;try{await a(e.vfs,s.filename)}catch{}}return x(e,t,n,r,i,o,s),s}async function x(e,t,r,i,a,o,l){let u=l;try{let t=await c(e.vfs,l,{model:r,apiKey:i,headers:a,skipMemory:!0,pickIcon:e=>n(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-DmqGayab.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26])).then(({pickLucideIcon:t})=>t(e))});t&&(u={...t,archive:l.archive},e.onBackgroundEnriched?.(t))}catch(e){f.warn(`Agentic title enrichment threw (draft stays pending)`,{filename:l.filename,error:e instanceof Error?e.message:String(e)})}let d=await s({sessionStore:t,vfs:e.vfs,mode:`full`,model:r,apiKey:i,headers:a,agenticMemorySpawn:o,cone:e.cone},u).catch(e=>(f.warn(`Agentic memory curator threw (entry stays pending)`,{filename:u.filename,error:e instanceof Error?e.message:String(e)}),null));f.info(`Agentic memory curator finished`,{filename:u.filename,memoryPending:!d||d.memoryPending===!0}),e.onBackgroundEnriched?.(d)}function S(e){return e?.code===`ENOENT`}function C(e,t){return e===t||t.startsWith(e.endsWith(`/`)?e:`${e}/`)}async function w(e,t,n,r){for(let i of n){let n=`${t}/${i.name}`;if(!r.has(n)){if(i.type===`directory`){let t;try{t=await e.readDir(n)}catch(e){if(S(e))continue;throw e}if(await w(e,n,t,r),[...r].some(e=>e.startsWith(`${n}/`)))continue}try{await e.rm(n)}catch(e){if(!S(e))throw e}}}}async function T(e,t){let n=(await e.listMountPoints()).map(({path:e})=>e);if(n.some(e=>C(e,t)))return;let r=new Set(n.filter(e=>e.startsWith(`${t}/`))),i;try{i=await e.readDir(t)}catch(n){if(n?.code!==`ENOENT`)throw n;await e.mkdir(t,{recursive:!0});return}await w(e,t,i,r),await e.mkdir(t,{recursive:!0})}async function E(r){let o=r.enrichmentRaceMs??m,s=t()??void 0,u;try{u=e()}catch(e){f.info(`No active model — freezing without LLM enrichment`,{error:e instanceof Error?e.message:String(e)})}let h=u?.provider===`adobe`?{"X-Session-Id":d(p)}:void 0,g=new i;try{await g.init()}catch(e){return f.warn(`SessionStore init failed — cannot freeze`,{error:e instanceof Error?e.message:String(e)}),null}let _=s&&u?y(r):void 0;if(_)return await b(r,g,u,s,h,_);let v=await l({sessionStore:g,vfs:r.vfs,mode:`quick`,cone:r.cone});if(!v)return null;if(r.captureCompleteSnapshot)try{await r.captureCompleteSnapshot(v)}catch(e){let t=e?.code??`unknown`;f.warn(`captureCompleteSnapshot failed`,{code:t}),v.completeSnapshotUnavailable=!0;try{await a(r.vfs,v.filename)}catch{}}if(!s||!u)return f.info(`Frozen without enrichment (no LLM credentials) — left pending`,{filename:v.filename}),v;let x=u,S=c(r.vfs,v,{model:x,apiKey:s,headers:h,pickIcon:e=>n(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-DmqGayab.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26])).then(({pickLucideIcon:t})=>t(e))}).catch(e=>(f.warn(`Single-click enrichment threw (entry stays pending)`,{filename:v.filename,error:e instanceof Error?e.message:String(e)}),null)),C=await D(S,o,r.onProgress);return C.kind===`llm`?C.updated?{...C.updated,archive:v.archive}:v:(S.then(e=>{f.info(`Background enrichment resolved after race window`,{filename:v.filename,enriched:e?.filename??null}),r.onBackgroundEnriched?.(e)}),v)}async function D(e,t,n){let r=Date.now(),i,a;n?.(0),n&&(i=setInterval(()=>{n(Math.min(1,(Date.now()-r)/t))},h));let o=new Promise(e=>{a=setTimeout(()=>e({kind:`timer`}),t)}),s=e.then(e=>({kind:`llm`,updated:e}));try{return await Promise.race([s,o])}finally{i&&clearInterval(i),a&&clearTimeout(a),n?.(null)}}async function O(e){return A(e,void 0)}async function k(e){return A(e,`skip`)}async function A(e,t){let n=new i;try{await n.init()}catch(e){return f.warn(`SessionStore init failed — cannot quick-freeze`,{error:e instanceof Error?e.message:String(e)}),null}let r=await l({sessionStore:n,vfs:e.vfs,mode:`quick`,cone:e.cone,...t?{memory:t}:{}});if(r&&e.captureCompleteSnapshot)try{await e.captureCompleteSnapshot(r)}catch(t){let n=t?.code??`unknown`;f.warn(`captureCompleteSnapshot failed (quick-freeze)`,{code:n}),r.completeSnapshotUnavailable=!0;try{await a(e.vfs,r.filename)}catch{}}return r}export{T as resetNewSessionTmp,k as runNewSessionArchiveOnly,E as runNewSessionFreeze,O as runNewSessionFreezeQuick,_ as schedulePendingSessionCatchup};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/quick-llm-C6qo7XyB.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/account-store-Cwl8IuHt.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-CSATLzrT.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/base64-DJRlyqZu.js","assets/proxied-fetch-DyBveeCl.js","assets/fetch-body-1l9I58Vk.js","assets/api-endpoint-DGxXvrur.js","assets/runtime-env-Dlaokqg1.js","assets/float-topology-YtctpJaG.js","assets/secret-topology-DLJBhHOi.js","assets/secrets-bridge-client--VZ3E0yk.js","assets/port-bridge-client-Dn8JtUyP.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-B5rOY1a1.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-BeCSBUrZ.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-BXcp4CBT.js"])))=>i.map(i=>d[i]);
2
+ import{B as e,g as t}from"./account-store-Cwl8IuHt.js";import{t as n}from"./preload-helper-Czpn1I53.js";import{t as r}from"./logger-DDBAeTLF.js";import{B as i,F as a,I as o,M as s,N as c,P as l}from"./wc-live-dLGR7yx7.js";import{r as u}from"./feature-flags-DaSRRz0w.js";import"./main-DVxB5Z8n.js";import{t as d}from"./llm-session-id-bZQs6gBN.js";var f=r(`new-session`),p=`ui-new-session`,m=2e4,h=250;async function g(n){try{let r=await n.openVfs(),i=t()??void 0;if(!i)return;let a;try{a=e()}catch{return}let s=a.provider===`adobe`?{"X-Session-Id":d(p)}:void 0;await o({vfs:r,model:a,apiKey:i,headers:s}),n.onComplete?.()}catch(e){f.warn(`Pending session catch-up failed (boot continues)`,{error:e instanceof Error?e.message:String(e)})}}function _(e){(e.schedule??v)(()=>{g(e)})}function v(e){if(typeof globalThis.requestIdleCallback==`function`){globalThis.requestIdleCallback(e,{timeout:5e3});return}setTimeout(e,0)}function y(e){if(u(`agentic-memory`)){if(!e.agenticMemorySpawn){f.info(`Agentic memory enabled but agent bridge unavailable — using legacy enrichment`);return}return e.agenticMemorySpawn}}async function b(e,t,n,r,i,o){let s=await l({sessionStore:t,vfs:e.vfs,mode:`quick`,agenticMemorySpawn:o,cone:e.cone});if(!s)return null;if(e.captureCompleteSnapshot)try{await e.captureCompleteSnapshot(s)}catch(t){let n=t?.code??`unknown`;f.warn(`captureCompleteSnapshot failed`,{code:n}),s.completeSnapshotUnavailable=!0;try{await a(e.vfs,s.filename)}catch{}}return x(e,t,n,r,i,o,s),s}async function x(e,t,r,i,a,o,l){let u=l;try{let t=await c(e.vfs,l,{model:r,apiKey:i,headers:a,skipMemory:!0,pickIcon:e=>n(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-C6qo7XyB.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26])).then(({pickLucideIcon:t})=>t(e))});t&&(u={...t,archive:l.archive},e.onBackgroundEnriched?.(t))}catch(e){f.warn(`Agentic title enrichment threw (draft stays pending)`,{filename:l.filename,error:e instanceof Error?e.message:String(e)})}let d=await s({sessionStore:t,vfs:e.vfs,mode:`full`,model:r,apiKey:i,headers:a,agenticMemorySpawn:o,cone:e.cone},u).catch(e=>(f.warn(`Agentic memory curator threw (entry stays pending)`,{filename:u.filename,error:e instanceof Error?e.message:String(e)}),null));f.info(`Agentic memory curator finished`,{filename:u.filename,memoryPending:!d||d.memoryPending===!0}),e.onBackgroundEnriched?.(d)}function S(e){return e?.code===`ENOENT`}function C(e,t){return e===t||t.startsWith(e.endsWith(`/`)?e:`${e}/`)}async function w(e,t,n,r){for(let i of n){let n=`${t}/${i.name}`;if(!r.has(n)){if(i.type===`directory`){let t;try{t=await e.readDir(n)}catch(e){if(S(e))continue;throw e}if(await w(e,n,t,r),[...r].some(e=>e.startsWith(`${n}/`)))continue}try{await e.rm(n)}catch(e){if(!S(e))throw e}}}}async function T(e,t){let n=(await e.listMountPoints()).map(({path:e})=>e);if(n.some(e=>C(e,t)))return;let r=new Set(n.filter(e=>e.startsWith(`${t}/`))),i;try{i=await e.readDir(t)}catch(n){if(n?.code!==`ENOENT`)throw n;await e.mkdir(t,{recursive:!0});return}await w(e,t,i,r),await e.mkdir(t,{recursive:!0})}async function E(r){let o=r.enrichmentRaceMs??m,s=t()??void 0,u;try{u=e()}catch(e){f.info(`No active model — freezing without LLM enrichment`,{error:e instanceof Error?e.message:String(e)})}let h=u?.provider===`adobe`?{"X-Session-Id":d(p)}:void 0,g=new i;try{await g.init()}catch(e){return f.warn(`SessionStore init failed — cannot freeze`,{error:e instanceof Error?e.message:String(e)}),null}let _=s&&u?y(r):void 0;if(_)return await b(r,g,u,s,h,_);let v=await l({sessionStore:g,vfs:r.vfs,mode:`quick`,cone:r.cone});if(!v)return null;if(r.captureCompleteSnapshot)try{await r.captureCompleteSnapshot(v)}catch(e){let t=e?.code??`unknown`;f.warn(`captureCompleteSnapshot failed`,{code:t}),v.completeSnapshotUnavailable=!0;try{await a(r.vfs,v.filename)}catch{}}if(!s||!u)return f.info(`Frozen without enrichment (no LLM credentials) — left pending`,{filename:v.filename}),v;let x=u,S=c(r.vfs,v,{model:x,apiKey:s,headers:h,pickIcon:e=>n(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-C6qo7XyB.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26])).then(({pickLucideIcon:t})=>t(e))}).catch(e=>(f.warn(`Single-click enrichment threw (entry stays pending)`,{filename:v.filename,error:e instanceof Error?e.message:String(e)}),null)),C=await D(S,o,r.onProgress);return C.kind===`llm`?C.updated?{...C.updated,archive:v.archive}:v:(S.then(e=>{f.info(`Background enrichment resolved after race window`,{filename:v.filename,enriched:e?.filename??null}),r.onBackgroundEnriched?.(e)}),v)}async function D(e,t,n){let r=Date.now(),i,a;n?.(0),n&&(i=setInterval(()=>{n(Math.min(1,(Date.now()-r)/t))},h));let o=new Promise(e=>{a=setTimeout(()=>e({kind:`timer`}),t)}),s=e.then(e=>({kind:`llm`,updated:e}));try{return await Promise.race([s,o])}finally{i&&clearInterval(i),a&&clearTimeout(a),n?.(null)}}async function O(e){return A(e,void 0)}async function k(e){return A(e,`skip`)}async function A(e,t){let n=new i;try{await n.init()}catch(e){return f.warn(`SessionStore init failed — cannot quick-freeze`,{error:e instanceof Error?e.message:String(e)}),null}let r=await l({sessionStore:n,vfs:e.vfs,mode:`quick`,cone:e.cone,...t?{memory:t}:{}});if(r&&e.captureCompleteSnapshot)try{await e.captureCompleteSnapshot(r)}catch(t){let n=t?.code??`unknown`;f.warn(`captureCompleteSnapshot failed (quick-freeze)`,{code:n}),r.completeSnapshotUnavailable=!0;try{await a(e.vfs,r.filename)}catch{}}return r}export{T as resetNewSessionTmp,k as runNewSessionArchiveOnly,E as runNewSessionFreeze,O as runNewSessionFreezeQuick,_ as schedulePendingSessionCatchup};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/provider-THUQ7opK.js","assets/account-store-CXfDPizG.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-CSATLzrT.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/base64-DJRlyqZu.js","assets/proxied-fetch-CiijUcSt.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-DGxXvrur.js","assets/runtime-env-Dlaokqg1.js","assets/float-topology-hfgMx1Yq.js","assets/secret-topology-Yt0aO4Gz.js","assets/secrets-bridge-client-BVl0YuB2.js","assets/port-bridge-client-C1tBBqwu.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-BSRKK3d0.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-BeCSBUrZ.js","assets/global-db-CbuLl-zx.js","assets/pkce-hGf_TEnP.js","assets/types-Dgm4REV3.js"])))=>i.map(i=>d[i]);
2
- import{G as e,f as t}from"./account-store-CXfDPizG.js";import{t as n}from"./preload-helper-Czpn1I53.js";import{t as r}from"./logger-DDBAeTLF.js";import{t as i}from"./providers-BSRKK3d0.js";import"./main-DHBCUrMc.js";import"./logger-BoSvu4mW.js";var a=r(`oauth-bootstrap`),o=6e4;function s(e){return e instanceof Error?e.message:String(e)}async function c(){try{let{ensureAllMcpProvidersRegistered:e}=await n(async()=>{let{ensureAllMcpProvidersRegistered:e}=await import(`./provider-THUQ7opK.js`);return{ensureAllMcpProvidersRegistered:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27])),t=await e();t.length>0&&a.debug(`Pre-registered MCP providers for OAuth bootstrap`,{count:t.length})}catch(e){a.warn(`Failed to pre-register MCP providers for OAuth bootstrap`,{error:s(e)})}}function l(e){return(e.tokenExpiresAt??1/0)-Date.now()<=o}async function u(e){let t=i(e.providerId);if(!t?.onSilentRenew){a.debug(`Skipping expired account (no silent-renew hook)`,{providerId:e.providerId});return}try{if(await t.onSilentRenew()){a.info(`Silently renewed OAuth token`,{providerId:e.providerId});return}a.warn(`Silent renewal yielded no token; user must re-authenticate`,{providerId:e.providerId})}catch(t){a.warn(`Silent renewal failed`,{providerId:e.providerId,error:s(t)})}}async function d(t,n){try{await e({providerId:t.providerId,accessToken:n,refreshToken:t.refreshToken,tokenExpiresAt:t.tokenExpiresAt,userName:t.userName,userAvatar:t.userAvatar}),a.debug(`Bootstrapped OAuth replica`,{providerId:t.providerId})}catch(e){a.error(`OAuth bootstrap failed`,{providerId:t.providerId,error:s(e)})}}async function f(e){let t=e.accessToken;if(!t){a.debug(`Skipping account without token`,{providerId:e.providerId});return}if(l(e)){await u(e);return}await d(e,t)}async function p(){await c();let e=t();a.info(`Bootstrap OAuth replicas`,{count:e.length});for(let t of e)await f(t)}export{p as bootstrapOAuthReplicas};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/provider-BXf5XZr2.js","assets/account-store-Cwl8IuHt.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-CSATLzrT.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/base64-DJRlyqZu.js","assets/proxied-fetch-DyBveeCl.js","assets/fetch-body-1l9I58Vk.js","assets/api-endpoint-DGxXvrur.js","assets/runtime-env-Dlaokqg1.js","assets/float-topology-YtctpJaG.js","assets/secret-topology-DLJBhHOi.js","assets/secrets-bridge-client--VZ3E0yk.js","assets/port-bridge-client-Dn8JtUyP.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-B5rOY1a1.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-BeCSBUrZ.js","assets/global-db-CbuLl-zx.js","assets/pkce-hGf_TEnP.js","assets/types-Dgm4REV3.js"])))=>i.map(i=>d[i]);
2
+ import{G as e,f as t}from"./account-store-Cwl8IuHt.js";import{t as n}from"./preload-helper-Czpn1I53.js";import{t as r}from"./logger-DDBAeTLF.js";import{t as i}from"./providers-B5rOY1a1.js";import"./main-DVxB5Z8n.js";import"./logger-BoSvu4mW.js";var a=r(`oauth-bootstrap`),o=6e4;function s(e){return e instanceof Error?e.message:String(e)}async function c(){try{let{ensureAllMcpProvidersRegistered:e}=await n(async()=>{let{ensureAllMcpProvidersRegistered:e}=await import(`./provider-BXf5XZr2.js`);return{ensureAllMcpProvidersRegistered:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27])),t=await e();t.length>0&&a.debug(`Pre-registered MCP providers for OAuth bootstrap`,{count:t.length})}catch(e){a.warn(`Failed to pre-register MCP providers for OAuth bootstrap`,{error:s(e)})}}function l(e){return(e.tokenExpiresAt??1/0)-Date.now()<=o}async function u(e){let t=i(e.providerId);if(!t?.onSilentRenew){a.debug(`Skipping expired account (no silent-renew hook)`,{providerId:e.providerId});return}try{if(await t.onSilentRenew()){a.info(`Silently renewed OAuth token`,{providerId:e.providerId});return}a.warn(`Silent renewal yielded no token; user must re-authenticate`,{providerId:e.providerId})}catch(t){a.warn(`Silent renewal failed`,{providerId:e.providerId,error:s(t)})}}async function d(t,n){try{await e({providerId:t.providerId,accessToken:n,refreshToken:t.refreshToken,tokenExpiresAt:t.tokenExpiresAt,userName:t.userName,userAvatar:t.userAvatar}),a.debug(`Bootstrapped OAuth replica`,{providerId:t.providerId})}catch(e){a.error(`OAuth bootstrap failed`,{providerId:t.providerId,error:s(e)})}}async function f(e){let t=e.accessToken;if(!t){a.debug(`Skipping account without token`,{providerId:e.providerId});return}if(l(e)){await u(e);return}await d(e,t)}async function p(){await c();let e=t();a.info(`Bootstrap OAuth replicas`,{count:e.length});for(let t of e)await f(t)}export{p as bootstrapOAuthReplicas};
@@ -1 +1 @@
1
- import{n as e}from"./panel-rpc-BPwAqRch.js";import"./proxied-fetch-DUC7X0GS.js";import{t}from"./runtime-env-DadgceZk.js";import{a as n,t as r}from"./api-endpoint-Lx_FU5cP.js";import{t as i}from"./permissions-surface-registry-BqPdUk9w.js";import{t as a}from"./intercepted-oauth-B0tP4D7f.js";const o=t();var s=class extends Error{constructor(e){super(e),this.name=`OAuthLaunchError`}};async function c(){if(typeof window<`u`)return!1;let t=e();if(!t)return!1;try{return(await t.call(`oauth-route`,{},{timeoutMs:5e3})).delegate===!0}catch{return!1}}function l(){return o?y:typeof window>`u`?p:m}async function u(){let e=await d();return e?a(e):null}async function d(){try{let{getActiveCdpTransport:e}=await import(`./active-transport-BIjzxdwv.js`);return await e()}catch(e){return console.warn(`[oauth-service] could not resolve active CDP transport:`,e instanceof Error?e.message:String(e)),null}}async function f(){if(typeof window<`u`)return{origin:window.location.origin,href:window.location.href};let t=e();if(!t)throw Error(`OAuth from worker context requires the panel-RPC bridge (no page-info available)`);let n=await t.call(`page-info`,void 0);return{origin:n.origin,href:n.href}}async function p(t){let n=e();if(!n)return console.error(`[oauth-service] panel-RPC client unavailable in worker`),null;try{let e=await n.call(`oauth-popup`,{url:t},{timeoutMs:13e4});if(!e.redirectUrl&&e.error)throw new s(e.error);return e.redirectUrl}catch(e){if(e instanceof s)throw e;return console.error(`[oauth-service] oauth-popup RPC failed:`,e instanceof Error?e.message:String(e)),null}}async function m(e){if(h())return g(window.open(e,`_blank`,`width=500,height=700,popup=yes`));let t=i();if(t){let n=await _(t,e);return n===void 0?null:g(n)}return g(window.open(e,`_blank`,`width=500,height=700,popup=yes`))}function h(){return(typeof navigator<`u`?navigator.userActivation:void 0)?.isActive===!0}function g(e){return new Promise(t=>{let i=!1,a=null,o=null,s=()=>{i||(i=!0,window.removeEventListener(`message`,c),clearTimeout(l),a&&clearInterval(a),o&&clearInterval(o))},c=n=>{if(n.data?.type!==`oauth-callback`||n.origin!==window.location.origin||e&&n.source!==e)return;if(s(),n.data.error){console.error(`[oauth-service] CLI OAuth error:`,n.data.error),t(null);return}let r=n.data.redirectUrl;(typeof r==`string`||r==null)&&t(r??null)};window.addEventListener(`message`,c),a=setInterval(async()=>{if(!i)try{let e=await fetch(n(`/api/oauth-result`),{headers:r()});if(e.status===204||!e.ok)return;let a=await e.json();if(i)return;if(s(),a.error){console.error(`[oauth-service] Server relay OAuth error:`,a.error),t(null);return}t(a.redirectUrl??null)}catch(e){console.warn(`[oauth-service] Poll failed:`,e instanceof Error?e.message:String(e))}},1e3),e&&(o=setInterval(()=>{e.closed&&(clearInterval(o),o=null,setTimeout(()=>{i||(s(),t(null))},1500))},500));let l=setTimeout(()=>{s();try{e?.close()}catch{}t(null)},12e4)})}async function _(e,t){let n=await e.prompt({kinds:[`popup`],description:`Continue to sign in. A new window will open to the provider.`,grantLabel:`Continue`,requestOptions:{popup:{url:t}}});if(n.status!==`granted`)return;let r=n.grants.find(e=>e.kind===`popup`);return r&&r.kind===`popup`?r.window:null}async function v(e,t=18e4){if(typeof window>`u`||o)return;let n=window.open(e,`_blank`,`width=500,height=600,popup=yes`);if(!n){console.warn(`[oauth-service] Could not open IdP logout popup — popups may be blocked`);return}await new Promise(e=>{let r=setTimeout(()=>{clearInterval(i);try{n.close()}catch{}e()},t),i=setInterval(()=>{n.closed&&(clearTimeout(r),clearInterval(i),e())},500)})}async function y(e,t){let n=chrome.runtime;return new Promise(r=>{let i=!1,a=()=>{i||(i=!0,n.onMessage.removeListener(o),clearTimeout(s))},o=e=>{if(typeof e!=`object`||!e)return;let t=e;if(t.source===`service-worker`&&t.payload?.type===`oauth-result`){if(a(),t.payload.error){console.error(`[oauth-service] Extension OAuth error:`,t.payload.error),r(null);return}r(t.payload.redirectUrl??null)}};n.onMessage.addListener(o),n.sendMessage({source:`panel`,payload:{type:`oauth-request`,providerId:`oauth`,authorizeUrl:e,interactive:t?.interactive??!0}}).catch(e=>{console.error(`[oauth-service] Failed to send OAuth request to service worker:`,e)});let s=setTimeout(()=>{a(),r(null)},12e4)})}export{u as createInterceptingOAuthLauncherForCurrentRuntime,l as createOAuthLauncher,f as getOAuthPageOrigin,v as openIdpLogoutUrl,c as resolveOAuthDelegation};
1
+ import{n as e}from"./panel-rpc-BPwAqRch.js";import"./proxied-fetch-B57RqgUb.js";import{t}from"./runtime-env-DadgceZk.js";import{a as n,t as r}from"./api-endpoint-Lx_FU5cP.js";import{t as i}from"./permissions-surface-registry-BqPdUk9w.js";import{t as a}from"./intercepted-oauth-B0tP4D7f.js";const o=t();var s=class extends Error{constructor(e){super(e),this.name=`OAuthLaunchError`}};async function c(){if(typeof window<`u`)return!1;let t=e();if(!t)return!1;try{return(await t.call(`oauth-route`,{},{timeoutMs:5e3})).delegate===!0}catch{return!1}}function l(){return o?y:typeof window>`u`?p:m}async function u(){let e=await d();return e?a(e):null}async function d(){try{let{getActiveCdpTransport:e}=await import(`./active-transport-BIjzxdwv.js`);return await e()}catch(e){return console.warn(`[oauth-service] could not resolve active CDP transport:`,e instanceof Error?e.message:String(e)),null}}async function f(){if(typeof window<`u`)return{origin:window.location.origin,href:window.location.href};let t=e();if(!t)throw Error(`OAuth from worker context requires the panel-RPC bridge (no page-info available)`);let n=await t.call(`page-info`,void 0);return{origin:n.origin,href:n.href}}async function p(t){let n=e();if(!n)return console.error(`[oauth-service] panel-RPC client unavailable in worker`),null;try{let e=await n.call(`oauth-popup`,{url:t},{timeoutMs:13e4});if(!e.redirectUrl&&e.error)throw new s(e.error);return e.redirectUrl}catch(e){if(e instanceof s)throw e;return console.error(`[oauth-service] oauth-popup RPC failed:`,e instanceof Error?e.message:String(e)),null}}async function m(e){if(h())return g(window.open(e,`_blank`,`width=500,height=700,popup=yes`));let t=i();if(t){let n=await _(t,e);return n===void 0?null:g(n)}return g(window.open(e,`_blank`,`width=500,height=700,popup=yes`))}function h(){return(typeof navigator<`u`?navigator.userActivation:void 0)?.isActive===!0}function g(e){return new Promise(t=>{let i=!1,a=null,o=null,s=()=>{i||(i=!0,window.removeEventListener(`message`,c),clearTimeout(l),a&&clearInterval(a),o&&clearInterval(o))},c=n=>{if(n.data?.type!==`oauth-callback`||n.origin!==window.location.origin||e&&n.source!==e)return;if(s(),n.data.error){console.error(`[oauth-service] CLI OAuth error:`,n.data.error),t(null);return}let r=n.data.redirectUrl;(typeof r==`string`||r==null)&&t(r??null)};window.addEventListener(`message`,c),a=setInterval(async()=>{if(!i)try{let e=await fetch(n(`/api/oauth-result`),{headers:r()});if(e.status===204||!e.ok)return;let a=await e.json();if(i)return;if(s(),a.error){console.error(`[oauth-service] Server relay OAuth error:`,a.error),t(null);return}t(a.redirectUrl??null)}catch(e){console.warn(`[oauth-service] Poll failed:`,e instanceof Error?e.message:String(e))}},1e3),e&&(o=setInterval(()=>{e.closed&&(clearInterval(o),o=null,setTimeout(()=>{i||(s(),t(null))},1500))},500));let l=setTimeout(()=>{s();try{e?.close()}catch{}t(null)},12e4)})}async function _(e,t){let n=await e.prompt({kinds:[`popup`],description:`Continue to sign in. A new window will open to the provider.`,grantLabel:`Continue`,requestOptions:{popup:{url:t}}});if(n.status!==`granted`)return;let r=n.grants.find(e=>e.kind===`popup`);return r&&r.kind===`popup`?r.window:null}async function v(e,t=18e4){if(typeof window>`u`||o)return;let n=window.open(e,`_blank`,`width=500,height=600,popup=yes`);if(!n){console.warn(`[oauth-service] Could not open IdP logout popup — popups may be blocked`);return}await new Promise(e=>{let r=setTimeout(()=>{clearInterval(i);try{n.close()}catch{}e()},t),i=setInterval(()=>{n.closed&&(clearTimeout(r),clearInterval(i),e())},500)})}async function y(e,t){let n=chrome.runtime;return new Promise(r=>{let i=!1,a=()=>{i||(i=!0,n.onMessage.removeListener(o),clearTimeout(s))},o=e=>{if(typeof e!=`object`||!e)return;let t=e;if(t.source===`service-worker`&&t.payload?.type===`oauth-result`){if(a(),t.payload.error){console.error(`[oauth-service] Extension OAuth error:`,t.payload.error),r(null);return}r(t.payload.redirectUrl??null)}};n.onMessage.addListener(o),n.sendMessage({source:`panel`,payload:{type:`oauth-request`,providerId:`oauth`,authorizeUrl:e,interactive:t?.interactive??!0}}).catch(e=>{console.error(`[oauth-service] Failed to send OAuth request to service worker:`,e)});let s=setTimeout(()=>{a(),r(null)},12e4)})}export{u as createInterceptingOAuthLauncherForCurrentRuntime,l as createOAuthLauncher,f as getOAuthPageOrigin,v as openIdpLogoutUrl,c as resolveOAuthDelegation};
@@ -1 +1 @@
1
- import{t as e}from"./preload-helper-Czpn1I53.js";import"./proxied-fetch-CiijUcSt.js";import{n as t}from"./runtime-env-Dlaokqg1.js";import{a as n,t as r}from"./api-endpoint-DGxXvrur.js";import{t as i}from"./panel-rpc-B3MSVImO.js";import{t as a}from"./permissions-surface-registry-CilCRwhh.js";var o=12e4;function s(e){let t=e.requestId,n=e.request;if(typeof t!=`string`||typeof n!=`object`||!n||Array.isArray(n))return null;let r=n;if(typeof r.url!=`string`||typeof r.method!=`string`)return null;let i=typeof r.headers==`object`&&r.headers!==null&&!Array.isArray(r.headers)?r.headers:{};return{requestId:t,request:{url:r.url,method:r.method,headers:i},resourceType:typeof e.resourceType==`string`?e.resourceType:void 0,frameId:typeof e.frameId==`string`?e.frameId:void 0}}function c(e,t){return t.endsWith(`*`)?e.startsWith(t.slice(0,-1)):e===t||e.startsWith(`${t}?`)||e.startsWith(`${t}#`)}function l(e){return e.endsWith(`*`)?e:`${e}*`}function u(e,t){if(!t||t.length===0)return e;let n=e;for(let e of t)if(n.includes(e.match)){if(e.replaceUrl){n=e.replaceUrl;continue}if(e.appendParams)try{let t=new URL(n);for(let[n,r]of Object.entries(e.appendParams))t.searchParams.set(n,r);n=t.toString()}catch{}}return n}function d(e){return async t=>{let n=t.timeoutMs??o,r=t.rewrite??[],i=t.onCapture??`close`,a,d,f=!1,p=null,m=async()=>{if(d){try{await e.send(`Fetch.disable`,{},d)}catch{}try{await e.send(`Target.detachFromTarget`,{sessionId:d})}catch{}}if(a&&i===`close`)try{await e.send(`Target.closeTarget`,{targetId:a})}catch{}};return await new Promise(i=>{let o=async t=>{f||(f=!0,clearTimeout(g),e.off(`Fetch.requestPaused`,h),await m(),i(t))},h=n=>{let i=s(n);if(!i?.request.url||!d||(typeof n.sessionId==`string`?n.sessionId:void 0)!==d)return;if(c(i.request.url,t.redirectUriPattern)){p=i.request.url,e.send(`Fetch.failRequest`,{requestId:i.requestId,errorReason:`Aborted`},d).catch(()=>{}),o(p).catch(()=>{});return}let a=u(i.request.url,r);if(a!==i.request.url){e.send(`Fetch.continueRequest`,{requestId:i.requestId,url:a},d).catch(e=>{console.warn(`[intercepted-oauth] continueRequest (rewrite) failed:`,e instanceof Error?e.message:String(e))});return}e.send(`Fetch.continueRequest`,{requestId:i.requestId},d).catch(()=>{})},g=setTimeout(()=>{o(null).catch(()=>{})},n);(async()=>{a=(await e.send(`Target.createTarget`,{url:`about:blank`})).targetId,d=(await e.send(`Target.attachToTarget`,{targetId:a,flatten:!0})).sessionId,e.on(`Fetch.requestPaused`,h),await e.send(`Fetch.enable`,{patterns:[{urlPattern:l(t.redirectUriPattern),requestStage:`Request`},...r.map(e=>({urlPattern:`*${e.match}*`,requestStage:`Request`}))]},d),await e.send(`Page.navigate`,{url:t.authorizeUrl},d)})().catch(e=>{console.error(`[intercepted-oauth] setup failed:`,e instanceof Error?e.message:String(e)),o(null).catch(()=>{})})})}}var f=t(),p=class extends Error{constructor(e){super(e),this.name=`OAuthLaunchError`}};async function m(){if(typeof window<`u`)return!1;let e=i();if(!e)return!1;try{return(await e.call(`oauth-route`,{},{timeoutMs:5e3})).delegate===!0}catch{return!1}}function h(){return f?T:typeof window>`u`?y:b}async function g(){let e=await _();return e?d(e):null}async function _(){try{let{getActiveCdpTransport:t}=await e(async()=>{let{getActiveCdpTransport:e}=await import(`./active-transport-BIjzxdwv.js`);return{getActiveCdpTransport:e}},[]);return await t()}catch(e){return console.warn(`[oauth-service] could not resolve active CDP transport:`,e instanceof Error?e.message:String(e)),null}}async function v(){if(typeof window<`u`)return{origin:window.location.origin,href:window.location.href};let e=i();if(!e)throw Error(`OAuth from worker context requires the panel-RPC bridge (no page-info available)`);let t=await e.call(`page-info`,void 0);return{origin:t.origin,href:t.href}}async function y(e){let t=i();if(!t)return console.error(`[oauth-service] panel-RPC client unavailable in worker`),null;try{let n=await t.call(`oauth-popup`,{url:e},{timeoutMs:13e4});if(!n.redirectUrl&&n.error)throw new p(n.error);return n.redirectUrl}catch(e){if(e instanceof p)throw e;return console.error(`[oauth-service] oauth-popup RPC failed:`,e instanceof Error?e.message:String(e)),null}}async function b(e){if(x())return S(window.open(e,`_blank`,`width=500,height=700,popup=yes`));let t=a();if(t){let n=await C(t,e);return n===void 0?null:S(n)}return S(window.open(e,`_blank`,`width=500,height=700,popup=yes`))}function x(){return(typeof navigator<`u`?navigator.userActivation:void 0)?.isActive===!0}function S(e){return new Promise(t=>{let i=!1,a=null,o=null,s=()=>{i||(i=!0,window.removeEventListener(`message`,c),clearTimeout(l),a&&clearInterval(a),o&&clearInterval(o))},c=n=>{if(n.data?.type!==`oauth-callback`||n.origin!==window.location.origin||e&&n.source!==e)return;if(s(),n.data.error){console.error(`[oauth-service] CLI OAuth error:`,n.data.error),t(null);return}let r=n.data.redirectUrl;(typeof r==`string`||r==null)&&t(r??null)};window.addEventListener(`message`,c),a=setInterval(async()=>{if(!i)try{let e=await fetch(n(`/api/oauth-result`),{headers:r()});if(e.status===204||!e.ok)return;let a=await e.json();if(i)return;if(s(),a.error){console.error(`[oauth-service] Server relay OAuth error:`,a.error),t(null);return}t(a.redirectUrl??null)}catch(e){console.warn(`[oauth-service] Poll failed:`,e instanceof Error?e.message:String(e))}},1e3),e&&(o=setInterval(()=>{e.closed&&(clearInterval(o),o=null,setTimeout(()=>{i||(s(),t(null))},1500))},500));let l=setTimeout(()=>{s();try{e?.close()}catch{}t(null)},12e4)})}async function C(e,t){let n=await e.prompt({kinds:[`popup`],description:`Continue to sign in. A new window will open to the provider.`,grantLabel:`Continue`,requestOptions:{popup:{url:t}}});if(n.status!==`granted`)return;let r=n.grants.find(e=>e.kind===`popup`);return r&&r.kind===`popup`?r.window:null}async function w(e,t=18e4){if(typeof window>`u`||f)return;let n=window.open(e,`_blank`,`width=500,height=600,popup=yes`);if(!n){console.warn(`[oauth-service] Could not open IdP logout popup — popups may be blocked`);return}await new Promise(e=>{let r=setTimeout(()=>{clearInterval(i);try{n.close()}catch{}e()},t),i=setInterval(()=>{n.closed&&(clearTimeout(r),clearInterval(i),e())},500)})}async function T(e,t){let n=chrome.runtime;return new Promise(r=>{let i=!1,a=()=>{i||(i=!0,n.onMessage.removeListener(o),clearTimeout(s))},o=e=>{if(typeof e!=`object`||!e)return;let t=e;if(t.source===`service-worker`&&t.payload?.type===`oauth-result`){if(a(),t.payload.error){console.error(`[oauth-service] Extension OAuth error:`,t.payload.error),r(null);return}r(t.payload.redirectUrl??null)}};n.onMessage.addListener(o),n.sendMessage({source:`panel`,payload:{type:`oauth-request`,providerId:`oauth`,authorizeUrl:e,interactive:t?.interactive??!0}}).catch(e=>{console.error(`[oauth-service] Failed to send OAuth request to service worker:`,e)});let s=setTimeout(()=>{a(),r(null)},12e4)})}export{g as createInterceptingOAuthLauncherForCurrentRuntime,h as createOAuthLauncher,v as getOAuthPageOrigin,w as openIdpLogoutUrl,m as resolveOAuthDelegation};
1
+ import{t as e}from"./preload-helper-Czpn1I53.js";import"./proxied-fetch-DyBveeCl.js";import{n as t}from"./runtime-env-Dlaokqg1.js";import{a as n,t as r}from"./api-endpoint-DGxXvrur.js";import{t as i}from"./panel-rpc-B3MSVImO.js";import{t as a}from"./permissions-surface-registry-CilCRwhh.js";var o=12e4;function s(e){let t=e.requestId,n=e.request;if(typeof t!=`string`||typeof n!=`object`||!n||Array.isArray(n))return null;let r=n;if(typeof r.url!=`string`||typeof r.method!=`string`)return null;let i=typeof r.headers==`object`&&r.headers!==null&&!Array.isArray(r.headers)?r.headers:{};return{requestId:t,request:{url:r.url,method:r.method,headers:i},resourceType:typeof e.resourceType==`string`?e.resourceType:void 0,frameId:typeof e.frameId==`string`?e.frameId:void 0}}function c(e,t){return t.endsWith(`*`)?e.startsWith(t.slice(0,-1)):e===t||e.startsWith(`${t}?`)||e.startsWith(`${t}#`)}function l(e){return e.endsWith(`*`)?e:`${e}*`}function u(e,t){if(!t||t.length===0)return e;let n=e;for(let e of t)if(n.includes(e.match)){if(e.replaceUrl){n=e.replaceUrl;continue}if(e.appendParams)try{let t=new URL(n);for(let[n,r]of Object.entries(e.appendParams))t.searchParams.set(n,r);n=t.toString()}catch{}}return n}function d(e){return async t=>{let n=t.timeoutMs??o,r=t.rewrite??[],i=t.onCapture??`close`,a,d,f=!1,p=null,m=async()=>{if(d){try{await e.send(`Fetch.disable`,{},d)}catch{}try{await e.send(`Target.detachFromTarget`,{sessionId:d})}catch{}}if(a&&i===`close`)try{await e.send(`Target.closeTarget`,{targetId:a})}catch{}};return await new Promise(i=>{let o=async t=>{f||(f=!0,clearTimeout(g),e.off(`Fetch.requestPaused`,h),await m(),i(t))},h=n=>{let i=s(n);if(!i?.request.url||!d||(typeof n.sessionId==`string`?n.sessionId:void 0)!==d)return;if(c(i.request.url,t.redirectUriPattern)){p=i.request.url,e.send(`Fetch.failRequest`,{requestId:i.requestId,errorReason:`Aborted`},d).catch(()=>{}),o(p).catch(()=>{});return}let a=u(i.request.url,r);if(a!==i.request.url){e.send(`Fetch.continueRequest`,{requestId:i.requestId,url:a},d).catch(e=>{console.warn(`[intercepted-oauth] continueRequest (rewrite) failed:`,e instanceof Error?e.message:String(e))});return}e.send(`Fetch.continueRequest`,{requestId:i.requestId},d).catch(()=>{})},g=setTimeout(()=>{o(null).catch(()=>{})},n);(async()=>{a=(await e.send(`Target.createTarget`,{url:`about:blank`})).targetId,d=(await e.send(`Target.attachToTarget`,{targetId:a,flatten:!0})).sessionId,e.on(`Fetch.requestPaused`,h),await e.send(`Fetch.enable`,{patterns:[{urlPattern:l(t.redirectUriPattern),requestStage:`Request`},...r.map(e=>({urlPattern:`*${e.match}*`,requestStage:`Request`}))]},d),await e.send(`Page.navigate`,{url:t.authorizeUrl},d)})().catch(e=>{console.error(`[intercepted-oauth] setup failed:`,e instanceof Error?e.message:String(e)),o(null).catch(()=>{})})})}}var f=t(),p=class extends Error{constructor(e){super(e),this.name=`OAuthLaunchError`}};async function m(){if(typeof window<`u`)return!1;let e=i();if(!e)return!1;try{return(await e.call(`oauth-route`,{},{timeoutMs:5e3})).delegate===!0}catch{return!1}}function h(){return f?T:typeof window>`u`?y:b}async function g(){let e=await _();return e?d(e):null}async function _(){try{let{getActiveCdpTransport:t}=await e(async()=>{let{getActiveCdpTransport:e}=await import(`./active-transport-BIjzxdwv.js`);return{getActiveCdpTransport:e}},[]);return await t()}catch(e){return console.warn(`[oauth-service] could not resolve active CDP transport:`,e instanceof Error?e.message:String(e)),null}}async function v(){if(typeof window<`u`)return{origin:window.location.origin,href:window.location.href};let e=i();if(!e)throw Error(`OAuth from worker context requires the panel-RPC bridge (no page-info available)`);let t=await e.call(`page-info`,void 0);return{origin:t.origin,href:t.href}}async function y(e){let t=i();if(!t)return console.error(`[oauth-service] panel-RPC client unavailable in worker`),null;try{let n=await t.call(`oauth-popup`,{url:e},{timeoutMs:13e4});if(!n.redirectUrl&&n.error)throw new p(n.error);return n.redirectUrl}catch(e){if(e instanceof p)throw e;return console.error(`[oauth-service] oauth-popup RPC failed:`,e instanceof Error?e.message:String(e)),null}}async function b(e){if(x())return S(window.open(e,`_blank`,`width=500,height=700,popup=yes`));let t=a();if(t){let n=await C(t,e);return n===void 0?null:S(n)}return S(window.open(e,`_blank`,`width=500,height=700,popup=yes`))}function x(){return(typeof navigator<`u`?navigator.userActivation:void 0)?.isActive===!0}function S(e){return new Promise(t=>{let i=!1,a=null,o=null,s=()=>{i||(i=!0,window.removeEventListener(`message`,c),clearTimeout(l),a&&clearInterval(a),o&&clearInterval(o))},c=n=>{if(n.data?.type!==`oauth-callback`||n.origin!==window.location.origin||e&&n.source!==e)return;if(s(),n.data.error){console.error(`[oauth-service] CLI OAuth error:`,n.data.error),t(null);return}let r=n.data.redirectUrl;(typeof r==`string`||r==null)&&t(r??null)};window.addEventListener(`message`,c),a=setInterval(async()=>{if(!i)try{let e=await fetch(n(`/api/oauth-result`),{headers:r()});if(e.status===204||!e.ok)return;let a=await e.json();if(i)return;if(s(),a.error){console.error(`[oauth-service] Server relay OAuth error:`,a.error),t(null);return}t(a.redirectUrl??null)}catch(e){console.warn(`[oauth-service] Poll failed:`,e instanceof Error?e.message:String(e))}},1e3),e&&(o=setInterval(()=>{e.closed&&(clearInterval(o),o=null,setTimeout(()=>{i||(s(),t(null))},1500))},500));let l=setTimeout(()=>{s();try{e?.close()}catch{}t(null)},12e4)})}async function C(e,t){let n=await e.prompt({kinds:[`popup`],description:`Continue to sign in. A new window will open to the provider.`,grantLabel:`Continue`,requestOptions:{popup:{url:t}}});if(n.status!==`granted`)return;let r=n.grants.find(e=>e.kind===`popup`);return r&&r.kind===`popup`?r.window:null}async function w(e,t=18e4){if(typeof window>`u`||f)return;let n=window.open(e,`_blank`,`width=500,height=600,popup=yes`);if(!n){console.warn(`[oauth-service] Could not open IdP logout popup — popups may be blocked`);return}await new Promise(e=>{let r=setTimeout(()=>{clearInterval(i);try{n.close()}catch{}e()},t),i=setInterval(()=>{n.closed&&(clearTimeout(r),clearInterval(i),e())},500)})}async function T(e,t){let n=chrome.runtime;return new Promise(r=>{let i=!1,a=()=>{i||(i=!0,n.onMessage.removeListener(o),clearTimeout(s))},o=e=>{if(typeof e!=`object`||!e)return;let t=e;if(t.source===`service-worker`&&t.payload?.type===`oauth-result`){if(a(),t.payload.error){console.error(`[oauth-service] Extension OAuth error:`,t.payload.error),r(null);return}r(t.payload.redirectUrl??null)}};n.onMessage.addListener(o),n.sendMessage({source:`panel`,payload:{type:`oauth-request`,providerId:`oauth`,authorizeUrl:e,interactive:t?.interactive??!0}}).catch(e=>{console.error(`[oauth-service] Failed to send OAuth request to service worker:`,e)});let s=setTimeout(()=>{a(),r(null)},12e4)})}export{g as createInterceptingOAuthLauncherForCurrentRuntime,h as createOAuthLauncher,v as getOAuthPageOrigin,w as openIdpLogoutUrl,m as resolveOAuthDelegation};
@@ -1 +1 @@
1
- import{t as e}from"./logger-DDBAeTLF.js";import{t}from"./slugify-BYJ6QVAt.js";import{i as n}from"./wc-onboarding-BPzCWMO7.js";var r={openai:{url:e=>`${(e??`https://api.openai.com`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},anthropic:{url:e=>`${(e??`https://api.anthropic.com`).replace(/\/$/,``)}/v1/models`,headers:e=>({"x-api-key":e,"anthropic-version":`2023-06-01`})},groq:{url:e=>`${(e??`https://api.groq.com/openai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},cerebras:{url:e=>`${(e??`https://api.cerebras.ai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},mistral:{url:e=>`${(e??`https://api.mistral.ai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},"x-ai":{url:e=>`${(e??`https://api.x.ai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},deepseek:{url:e=>`${(e??`https://api.deepseek.com`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},openrouter:{url:e=>`${(e??`https://openrouter.ai/api`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},google:{url:e=>`${(e??`https://generativelanguage.googleapis.com`).replace(/\/$/,``)}/v1beta/models`,headers:()=>({})}};function i(e,t){if(e===401||e===403)return`Authentication failed — the key was rejected by the provider.`;if(e===404)return`Endpoint not found — check the base URL.`;if(e===429)return`Rate-limited — try again in a moment.`;if(e>=500)return`Provider returned a server error.`;let n=t.trim();return n?`${e}: ${n.slice(0,160)}`:`Provider responded with HTTP ${e}.`}async function a(e){let{provider:t,apiKey:n,baseUrl:a,signal:o}=e,s=e.fetchImpl??fetch,c=n.trim();if(!c)return{kind:`failed`,status:null,message:`API key is empty.`};let l=r[t];if(!l)return{kind:`skipped`,reason:`No live validation available for "${t}" — saving without testing.`};let u=l.url(a);if(t===`google`){let e=u.includes(`?`)?`&`:`?`;u=`${u}${e}key=${encodeURIComponent(c)}`}try{let e=await s(u,{method:`GET`,headers:l.headers(c),signal:o});if(e.ok)return{kind:`ok`};let t=``;try{t=await e.text()}catch{}return e.status===401||e.status,{kind:`failed`,status:e.status,message:i(e.status,t)}}catch(e){if(e?.name===`AbortError`)throw e;return{kind:`skipped`,reason:`Couldn't reach the provider (${e instanceof Error?e.message:String(e)}). Saving without live test — you can retry from Settings.`}}}var o=[e=>`Nice to meet you, ${e}.`,e=>`Hello ${e} — glad you stopped by.`,e=>`Hey ${e}, welcome aboard.`,e=>`${e}! Pleasure to make your acquaintance.`],s=[`Nice to meet you, mysterious stranger — I'll respect the incognito.`,`Hello, anonymous traveler. You can always tell me your name later if you change your mind.`,`An unnamed visitor — intriguing. Whenever you'd like to introduce yourself, just say the word.`,`Hey there, ghost — happy to keep things first-name-optional. The door's always open if you decide to drop the cloak.`],c={work:[`Work mode — let's make today productive.`,`On the clock? Same. Let's chip away at it.`],school:[`School business — I love a good study session.`,`Hitting the books? Glad to ride along.`],personal:[`Personal project energy is the best kind.`,`Tinkering for yourself is how the good stuff happens.`],"side-project":[`Side projects keep the lights on creatively.`,`Two-job life — respect.`],exploring:[`Just poking around? Excellent. The best discoveries start there.`,`Exploration mode — no agenda, no pressure.`]},l={developer:[`I can write code, run shell commands, drive a real browser, and ship pages.`,`Code, terminals, browsers, repos — I live in all of them.`],designer:[`I can prototype layouts, generate assets, and walk page editors with you.`,`Pixels, components, screenshots — design ops are my jam.`],"content-creator":[`I can draft copy, edit, scrape references, and stitch publish-ready pages.`,`Words, structure, SEO, polish — say the topic and I'll get moving.`],marketer:[`I can audit funnels, scrape competitors, and stand up landing pages quickly.`,`Campaigns, analytics, creatives — plug me in and I'll go.`],"product-pm":[`I can summarise research, draft specs, and crunch competitive intel.`,`Briefs, roadmaps, comparisons — I take the boring half off your plate.`],founder:[`I can prototype landing pages, automate ops, and prep investor decks.`,`Idea → MVP → repeat. I'll do the legwork between coffee refills.`],student:[`I can read papers with you, draft notes, and turn lectures into outlines.`,`Studying together makes it bearable — let me handle the busywork.`],researcher:[`I can scrape sources, summarise findings, and keep a running bibliography.`,`Lit reviews, datasets, write-ups — I'm all in.`],other:[`I'm flexible — give me a task and I'll figure out the right tools.`,`Whatever the role, I can probably help. Tell me what's on the docket.`]},u=[`I can browse the web, run commands, write code, and automate the boring parts.`,`I'm comfortable with terminals, browsers, files, and a long backlog of skills.`],d=[`But to be honest, I'm not really an AI yet — I'm an empty shell. You'll need to help me become intelligent. Pick a model and I'll wake up:`,`Confession time: I can't actually think yet. Wire me up to an LLM and I'll start earning my keep:`,`Plot twist — there's no brain in here. Choose a provider so I can do more than read this script:`,`Truthfully? I'm a very polite placeholder until you give me a model. Help me out:`];function f(e,t){return e[Math.floor(t()*e.length)%e.length]}function p(e){return e.replace(/-/g,` `)}function m(e){if(e.length===0)return``;if(e.length===1)return e[0];if(e.length===2)return`${e[0]} and ${e[1]}`;let t=e[e.length-1];return`${e.slice(0,-1).join(`, `)}, and ${t}`}function h(e,t=Math.random){let n=(e.name||``).trim(),r=e.purpose?c[e.purpose]:void 0;return n?`${f(o,t)(n)}${r?` ${f(r,t)}`:``}`:`${f(s,t)}${r?` ${f(r,t)}`:``}`}function g(e,t=Math.random){let n=e.role&&l[e.role]?e.role:``,r=f(n?l[n]:u,t),i=(e.tasks??[]).slice(0,3).map(p);return`I'm sliccy. ${r}${i.length>0?` Especially handy for ${m(i)}.`:``} I'm an AI agent.`}function _(e,t=Math.random){return f(d,t)}function v(e,t=Math.random){return[h(e,t),g(e,t),_(e,t)]}var y=e(`onboarding-orchestrator`),b=class{deps;stage=`idle`;profile={};constructor(e){this.deps=e}getStage(){return this.stage}getProfile(){return{...this.profile}}handleFirstRun(){this.stage===`idle`&&(this.stage=`collect-profile`,this.deps.postDipReference(`Welcome to SLICC — let's get you set up.`),this.deps.postDipReference(`![Welcome](/shared/sprinkles/welcome/welcome.shtml)`))}async handleOnboardingComplete(e){if(this.stage!==`idle`&&this.stage!==`collect-profile`)return y.debug(`Ignoring duplicate onboarding-complete`,{stage:this.stage}),!0;this.profile=e??{},this.stage=`awaiting-connect`,n(this.deps.fs).catch(e=>y.warn(`recordWelcomed failed`,e)),this.persistProfile(this.profile).catch(e=>y.warn(`persistProfile failed`,e));let t=v(this.profile,this.deps.rand);for(let e of t)this.deps.postSystemMessage(e);return this.deps.postDipReference(`![Connect a model](/shared/sprinkles/welcome/connect-llm.shtml)`),!0}handleConnectReady(){if(this.stage===`complete`)return;let e=this.deps.getProviderCatalogue();this.deps.broadcastToDip({type:`slicc-providers`,providers:e.providers,models:e.models})}async handleConnectAttempt(e){if(this.stage===`complete`)return;this.stage=`connecting`;let{provider:t,apiKey:n,baseUrl:r,deployment:i,apiVersion:o,model:s}=e;if(!t||typeof n!=`string`||!n.trim()){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`Provider and API key are required.`}),this.stage=`awaiting-connect`;return}let c=this.validateProviderRequiredFields(t,r,i);if(c){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:c}),this.stage=`awaiting-connect`;return}let l;try{l=await a({provider:t,apiKey:n.trim(),baseUrl:r??void 0,fetchImpl:this.deps.fetchImpl})}catch(e){y.warn(`validateApiKey threw`,e),this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`Validation request was aborted.`}),this.stage=`awaiting-connect`;return}if(l.kind===`failed`){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:l.message}),this.stage=`awaiting-connect`;return}let u=s||null;if(!u)try{let e=this.deps.getProviderCatalogue().models?.[t]?.[0]?.id;e&&(u=e)}catch(e){y.warn(`Failed to resolve fallback model for provider`,{provider:t,err:e})}try{this.deps.saveAccount(t,n.trim(),r?.trim()||void 0,i?.trim()||void 0,o?.trim()||void 0),u&&this.deps.setSelectedModel(x(t,u))}catch(e){y.warn(`saveAccount failed`,e),this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`Failed to save credentials locally.`}),this.stage=`awaiting-connect`;return}try{this.deps.onAccountsChanged?.()}catch(e){y.warn(`onAccountsChanged threw`,e)}let d=l.kind===`skipped`?`Saved — ${l.reason}`:`Validated against the provider. Ready when you are.`;this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!0,kind:l.kind,note:d});let f=u&&this.deps.resolveModelLabel?.(t,u)?this.deps.resolveModelLabel?.(t,u):u||null;this.stage=`complete`,this.deps.fireFinalLick({action:`onboarding-complete-with-provider`,data:{profile:this.profile,provider:t,model:u??null,modelLabel:f,validation:l.kind}})}async handleOAuthAttempt(e){if(this.stage===`complete`)return;if(!this.deps.launchOAuth){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`OAuth login is not available in this runtime.`});return}this.stage=`connecting`;let t;try{t=await this.deps.launchOAuth(e.provider,e.baseUrl??null)}catch(e){y.warn(`launchOAuth threw`,e),this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:e instanceof Error?e.message:`Login was cancelled.`}),this.stage=`awaiting-connect`;return}if(!t.ok){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:t.message||`Login was cancelled.`}),this.stage=`awaiting-connect`;return}if(t.model)try{this.deps.setSelectedModel(x(e.provider,t.model))}catch(e){y.warn(`setSelectedModel after OAuth failed`,e)}try{this.deps.onAccountsChanged?.()}catch(e){y.warn(`onAccountsChanged threw`,e)}this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!0,kind:`ok`,note:t.message||`Logged in.`});let n=t.model&&this.deps.resolveModelLabel?.(e.provider,t.model)?this.deps.resolveModelLabel?.(e.provider,t.model):t.model??null;this.stage=`complete`,this.deps.fireFinalLick({action:`onboarding-complete-with-provider`,data:{profile:this.profile,provider:e.provider,model:t.model??null,modelLabel:n,validation:`oauth`}})}validateProviderRequiredFields(e,t,n){let r;try{r=this.deps.getProviderCatalogue().providers.find(t=>t.id===e)}catch(e){return y.warn(`getProviderCatalogue threw during required-field gate`,e),`Could not load provider requirements. Please try again.`}return r?.requiresDeployment&&!n?.trim()?`${r.name} requires a deployment name.`:r?.requiresBaseUrl&&!t?.trim()?`${r.name} requires a base URL.`:null}async persistProfile(e){let n=t(e.name||`user`,{fallback:`user`});await this.deps.fs.writeFile(`/home/${n}/.welcome.json`,JSON.stringify(e,null,2))}};function x(e,t){return t.startsWith(`${e}:`)?t:`${e}:${t}`}export{b as OnboardingOrchestrator};
1
+ import{t as e}from"./logger-DDBAeTLF.js";import{t}from"./slugify-BYJ6QVAt.js";import{i as n}from"./wc-onboarding-P8IAA7id.js";var r={openai:{url:e=>`${(e??`https://api.openai.com`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},anthropic:{url:e=>`${(e??`https://api.anthropic.com`).replace(/\/$/,``)}/v1/models`,headers:e=>({"x-api-key":e,"anthropic-version":`2023-06-01`})},groq:{url:e=>`${(e??`https://api.groq.com/openai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},cerebras:{url:e=>`${(e??`https://api.cerebras.ai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},mistral:{url:e=>`${(e??`https://api.mistral.ai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},"x-ai":{url:e=>`${(e??`https://api.x.ai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},deepseek:{url:e=>`${(e??`https://api.deepseek.com`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},openrouter:{url:e=>`${(e??`https://openrouter.ai/api`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},google:{url:e=>`${(e??`https://generativelanguage.googleapis.com`).replace(/\/$/,``)}/v1beta/models`,headers:()=>({})}};function i(e,t){if(e===401||e===403)return`Authentication failed — the key was rejected by the provider.`;if(e===404)return`Endpoint not found — check the base URL.`;if(e===429)return`Rate-limited — try again in a moment.`;if(e>=500)return`Provider returned a server error.`;let n=t.trim();return n?`${e}: ${n.slice(0,160)}`:`Provider responded with HTTP ${e}.`}async function a(e){let{provider:t,apiKey:n,baseUrl:a,signal:o}=e,s=e.fetchImpl??fetch,c=n.trim();if(!c)return{kind:`failed`,status:null,message:`API key is empty.`};let l=r[t];if(!l)return{kind:`skipped`,reason:`No live validation available for "${t}" — saving without testing.`};let u=l.url(a);if(t===`google`){let e=u.includes(`?`)?`&`:`?`;u=`${u}${e}key=${encodeURIComponent(c)}`}try{let e=await s(u,{method:`GET`,headers:l.headers(c),signal:o});if(e.ok)return{kind:`ok`};let t=``;try{t=await e.text()}catch{}return e.status===401||e.status,{kind:`failed`,status:e.status,message:i(e.status,t)}}catch(e){if(e?.name===`AbortError`)throw e;return{kind:`skipped`,reason:`Couldn't reach the provider (${e instanceof Error?e.message:String(e)}). Saving without live test — you can retry from Settings.`}}}var o=[e=>`Nice to meet you, ${e}.`,e=>`Hello ${e} — glad you stopped by.`,e=>`Hey ${e}, welcome aboard.`,e=>`${e}! Pleasure to make your acquaintance.`],s=[`Nice to meet you, mysterious stranger — I'll respect the incognito.`,`Hello, anonymous traveler. You can always tell me your name later if you change your mind.`,`An unnamed visitor — intriguing. Whenever you'd like to introduce yourself, just say the word.`,`Hey there, ghost — happy to keep things first-name-optional. The door's always open if you decide to drop the cloak.`],c={work:[`Work mode — let's make today productive.`,`On the clock? Same. Let's chip away at it.`],school:[`School business — I love a good study session.`,`Hitting the books? Glad to ride along.`],personal:[`Personal project energy is the best kind.`,`Tinkering for yourself is how the good stuff happens.`],"side-project":[`Side projects keep the lights on creatively.`,`Two-job life — respect.`],exploring:[`Just poking around? Excellent. The best discoveries start there.`,`Exploration mode — no agenda, no pressure.`]},l={developer:[`I can write code, run shell commands, drive a real browser, and ship pages.`,`Code, terminals, browsers, repos — I live in all of them.`],designer:[`I can prototype layouts, generate assets, and walk page editors with you.`,`Pixels, components, screenshots — design ops are my jam.`],"content-creator":[`I can draft copy, edit, scrape references, and stitch publish-ready pages.`,`Words, structure, SEO, polish — say the topic and I'll get moving.`],marketer:[`I can audit funnels, scrape competitors, and stand up landing pages quickly.`,`Campaigns, analytics, creatives — plug me in and I'll go.`],"product-pm":[`I can summarise research, draft specs, and crunch competitive intel.`,`Briefs, roadmaps, comparisons — I take the boring half off your plate.`],founder:[`I can prototype landing pages, automate ops, and prep investor decks.`,`Idea → MVP → repeat. I'll do the legwork between coffee refills.`],student:[`I can read papers with you, draft notes, and turn lectures into outlines.`,`Studying together makes it bearable — let me handle the busywork.`],researcher:[`I can scrape sources, summarise findings, and keep a running bibliography.`,`Lit reviews, datasets, write-ups — I'm all in.`],other:[`I'm flexible — give me a task and I'll figure out the right tools.`,`Whatever the role, I can probably help. Tell me what's on the docket.`]},u=[`I can browse the web, run commands, write code, and automate the boring parts.`,`I'm comfortable with terminals, browsers, files, and a long backlog of skills.`],d=[`But to be honest, I'm not really an AI yet — I'm an empty shell. You'll need to help me become intelligent. Pick a model and I'll wake up:`,`Confession time: I can't actually think yet. Wire me up to an LLM and I'll start earning my keep:`,`Plot twist — there's no brain in here. Choose a provider so I can do more than read this script:`,`Truthfully? I'm a very polite placeholder until you give me a model. Help me out:`];function f(e,t){return e[Math.floor(t()*e.length)%e.length]}function p(e){return e.replace(/-/g,` `)}function m(e){if(e.length===0)return``;if(e.length===1)return e[0];if(e.length===2)return`${e[0]} and ${e[1]}`;let t=e[e.length-1];return`${e.slice(0,-1).join(`, `)}, and ${t}`}function h(e,t=Math.random){let n=(e.name||``).trim(),r=e.purpose?c[e.purpose]:void 0;return n?`${f(o,t)(n)}${r?` ${f(r,t)}`:``}`:`${f(s,t)}${r?` ${f(r,t)}`:``}`}function g(e,t=Math.random){let n=e.role&&l[e.role]?e.role:``,r=f(n?l[n]:u,t),i=(e.tasks??[]).slice(0,3).map(p);return`I'm sliccy. ${r}${i.length>0?` Especially handy for ${m(i)}.`:``} I'm an AI agent.`}function _(e,t=Math.random){return f(d,t)}function v(e,t=Math.random){return[h(e,t),g(e,t),_(e,t)]}var y=e(`onboarding-orchestrator`),b=class{deps;stage=`idle`;profile={};constructor(e){this.deps=e}getStage(){return this.stage}getProfile(){return{...this.profile}}handleFirstRun(){this.stage===`idle`&&(this.stage=`collect-profile`,this.deps.postDipReference(`Welcome to SLICC — let's get you set up.`),this.deps.postDipReference(`![Welcome](/shared/sprinkles/welcome/welcome.shtml)`))}async handleOnboardingComplete(e){if(this.stage!==`idle`&&this.stage!==`collect-profile`)return y.debug(`Ignoring duplicate onboarding-complete`,{stage:this.stage}),!0;this.profile=e??{},this.stage=`awaiting-connect`,n(this.deps.fs).catch(e=>y.warn(`recordWelcomed failed`,e)),this.persistProfile(this.profile).catch(e=>y.warn(`persistProfile failed`,e));let t=v(this.profile,this.deps.rand);for(let e of t)this.deps.postSystemMessage(e);return this.deps.postDipReference(`![Connect a model](/shared/sprinkles/welcome/connect-llm.shtml)`),!0}handleConnectReady(){if(this.stage===`complete`)return;let e=this.deps.getProviderCatalogue();this.deps.broadcastToDip({type:`slicc-providers`,providers:e.providers,models:e.models})}async handleConnectAttempt(e){if(this.stage===`complete`)return;this.stage=`connecting`;let{provider:t,apiKey:n,baseUrl:r,deployment:i,apiVersion:o,model:s}=e;if(!t||typeof n!=`string`||!n.trim()){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`Provider and API key are required.`}),this.stage=`awaiting-connect`;return}let c=this.validateProviderRequiredFields(t,r,i);if(c){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:c}),this.stage=`awaiting-connect`;return}let l;try{l=await a({provider:t,apiKey:n.trim(),baseUrl:r??void 0,fetchImpl:this.deps.fetchImpl})}catch(e){y.warn(`validateApiKey threw`,e),this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`Validation request was aborted.`}),this.stage=`awaiting-connect`;return}if(l.kind===`failed`){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:l.message}),this.stage=`awaiting-connect`;return}let u=s||null;if(!u)try{let e=this.deps.getProviderCatalogue().models?.[t]?.[0]?.id;e&&(u=e)}catch(e){y.warn(`Failed to resolve fallback model for provider`,{provider:t,err:e})}try{this.deps.saveAccount(t,n.trim(),r?.trim()||void 0,i?.trim()||void 0,o?.trim()||void 0),u&&this.deps.setSelectedModel(x(t,u))}catch(e){y.warn(`saveAccount failed`,e),this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`Failed to save credentials locally.`}),this.stage=`awaiting-connect`;return}try{this.deps.onAccountsChanged?.()}catch(e){y.warn(`onAccountsChanged threw`,e)}let d=l.kind===`skipped`?`Saved — ${l.reason}`:`Validated against the provider. Ready when you are.`;this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!0,kind:l.kind,note:d});let f=u&&this.deps.resolveModelLabel?.(t,u)?this.deps.resolveModelLabel?.(t,u):u||null;this.stage=`complete`,this.deps.fireFinalLick({action:`onboarding-complete-with-provider`,data:{profile:this.profile,provider:t,model:u??null,modelLabel:f,validation:l.kind}})}async handleOAuthAttempt(e){if(this.stage===`complete`)return;if(!this.deps.launchOAuth){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`OAuth login is not available in this runtime.`});return}this.stage=`connecting`;let t;try{t=await this.deps.launchOAuth(e.provider,e.baseUrl??null)}catch(e){y.warn(`launchOAuth threw`,e),this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:e instanceof Error?e.message:`Login was cancelled.`}),this.stage=`awaiting-connect`;return}if(!t.ok){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:t.message||`Login was cancelled.`}),this.stage=`awaiting-connect`;return}if(t.model)try{this.deps.setSelectedModel(x(e.provider,t.model))}catch(e){y.warn(`setSelectedModel after OAuth failed`,e)}try{this.deps.onAccountsChanged?.()}catch(e){y.warn(`onAccountsChanged threw`,e)}this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!0,kind:`ok`,note:t.message||`Logged in.`});let n=t.model&&this.deps.resolveModelLabel?.(e.provider,t.model)?this.deps.resolveModelLabel?.(e.provider,t.model):t.model??null;this.stage=`complete`,this.deps.fireFinalLick({action:`onboarding-complete-with-provider`,data:{profile:this.profile,provider:e.provider,model:t.model??null,modelLabel:n,validation:`oauth`}})}validateProviderRequiredFields(e,t,n){let r;try{r=this.deps.getProviderCatalogue().providers.find(t=>t.id===e)}catch(e){return y.warn(`getProviderCatalogue threw during required-field gate`,e),`Could not load provider requirements. Please try again.`}return r?.requiresDeployment&&!n?.trim()?`${r.name} requires a deployment name.`:r?.requiresBaseUrl&&!t?.trim()?`${r.name} requires a base URL.`:null}async persistProfile(e){let n=t(e.name||`user`,{fallback:`user`});await this.deps.fs.writeFile(`/home/${n}/.welcome.json`,JSON.stringify(e,null,2))}};function x(e,t){return t.startsWith(`${e}:`)?t:`${e}:${t}`}export{b as OnboardingOrchestrator};
@@ -1 +1 @@
1
- import{G as e,f as t}from"./account-store-CXfDPizG.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{d as r}from"./claude-model-version-CSATLzrT.js";import{n as i,o as a}from"./legacy-api-aliases-bAJ0Klzq.js";import"./main-DHBCUrMc.js";import{n as o,r as s,t as c}from"./pkce-hGf_TEnP.js";var l=`openai-codex`,u=`app_EMoamEEZ73f0CkXaXp7hrann`,d=`https://auth.openai.com/oauth/authorize`,f=`https://auth.openai.com/oauth/token`,p=`openid profile email offline_access`,m=`http://localhost:1455/auth/callback`,h=`http://localhost:1455/auth/callback*`,g=`https://chatgpt.com/backend-api`,_=`openai-codex-responses`,v=`${l}-openai`,y={xhigh:`xhigh`,minimal:`low`},b=[{id:`gpt-5.5`,name:`GPT-5.5`,input:[`text`,`image`]},{id:`gpt-5.4`,name:`GPT-5.4`,input:[`text`,`image`]},{id:`gpt-5.4-mini`,name:`GPT-5.4 mini`,input:[`text`,`image`]},{id:`gpt-5.3-codex`,name:`GPT-5.3 Codex`,input:[`text`,`image`]},{id:`gpt-5.3-codex-spark`,name:`GPT-5.3 Codex Spark`,input:[`text`]},{id:`gpt-5.2`,name:`GPT-5.2`,input:[`text`,`image`]}].map(e=>({...e,api:`openai`,reasoning:!0,context_window:272e3,max_tokens:128e3,thinkingLevelMap:y}));async function x(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,client_id:u,code:e,code_verifier:t,redirect_uri:m}),r=await fetch(f,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw Error(`OpenAI Codex token exchange failed: ${r.status} ${await r.text()}`);let i=await r.json();if(!i.access_token)throw Error(`OpenAI Codex token exchange did not return access_token.`);return i}async function S(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:u}),n=await fetch(f,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});return n.ok?await n.json():(console.error(`[openai-codex] refresh failed:`,n.status,await n.text()),null)}catch(e){return console.error(`[openai-codex] refresh error:`,e instanceof Error?e.message:String(e)),null}}function C(e){try{let t=e.split(`.`);if(t.length!==3)return;let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`);return n.length%4&&(n+=`=`.repeat(4-n.length%4)),JSON.parse(atob(n))}catch{return}}function w(e){let t=C(e)?.[`https://api.openai.com/profile`]?.email;return typeof t==`string`?t:void 0}function T(e){let t=C(e)?.[`https://api.openai.com/auth`],n=w(e),r=typeof t?.chatgpt_plan_type==`string`?t.chatgpt_plan_type:void 0,i=r?r.charAt(0).toUpperCase()+r.slice(1):void 0;if(n&&i)return`${n} (${i})`;if(n)return n;if(i)return`ChatGPT ${i}`}async function E(e){let t=w(e);if(t)try{let e=t.trim().toLowerCase(),n=new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)));return`https://www.gravatar.com/avatar/${Array.from(n).map(e=>e.toString(16).padStart(2,`0`)).join(``)}?s=128&d=404`}catch{return}}function D(){return t().find(e=>e.providerId===l)}async function O(){let t=D();if(!t?.accessToken)throw Error("Not signed in to OpenAI Codex — run `oauth-token openai-codex` or /login");let n=t.tokenExpiresAt??0;if(n&&Date.now()+6e4<n)return t.accessToken;if(t.refreshToken){let n=await S(t.refreshToken);if(n?.access_token)return await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:g,userName:T(n.access_token),userAvatar:await E(n.access_token),scopes:n.scope??t.scopes}),n.access_token}return t.accessToken}function k(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:v,provider:l,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()}}}function A(e){console.error(`[openai-codex] Stream error:`,e instanceof Error?e.message:String(e))}async function j(e,t,n,r){try{let a=await O(),o={...t,baseUrl:g,api:_},s=i(o,n,{...r,apiKey:a,transport:`sse`});for await(let t of s)e.push(t);e.end()}catch(n){A(n),e.push(k(t,n)),e.end()}}async function M(e,t,n,r){try{let i=await O(),o={...t,baseUrl:g,api:_},s=a(o,n,{...r,apiKey:i,transport:`sse`});for await(let t of s)e.push(t);e.end()}catch(n){A(n),e.push(k(t,n)),e.end()}}var N=(e,t,r={})=>{let i=n();return j(i,e,t,r).catch(A),i},P=(e,t,r)=>{let i=n();return M(i,e,t,r).catch(A),i},F={id:l,name:`OpenAI Codex (ChatGPT Subscription)`,description:`GPT-5 Codex via your ChatGPT Plus/Pro/Business subscription — OAuth login, no API key needed. Default model is GPT-5.5.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`gpt-5.5`,oauthTokenDomains:[`chatgpt.com`,`*.chatgpt.com`,`auth.openai.com`,`api.openai.com`],getModelIds:()=>b,onOAuthLoginIntercepted:async(t,n,r)=>{let i=o(),a=await c(i),f=s(),_=new URL(d);_.searchParams.set(`response_type`,`code`),_.searchParams.set(`client_id`,u),_.searchParams.set(`redirect_uri`,m),_.searchParams.set(`scope`,r?.scopes??p),_.searchParams.set(`code_challenge`,a),_.searchParams.set(`code_challenge_method`,`S256`),_.searchParams.set(`state`,f),_.searchParams.set(`id_token_add_organizations`,`true`),_.searchParams.set(`codex_cli_simplified_flow`,`true`),_.searchParams.set(`originator`,`pi`);let v=await t({authorizeUrl:_.toString(),redirectUriPattern:h,onCapture:`close`});if(!v)throw Error(`OpenAI Codex OAuth login was cancelled or timed out`);let y=new URL(v),b=y.searchParams.get(`code`),S=y.searchParams.get(`state`);if(!b)throw Error(`OpenAI Codex OAuth redirect did not include a code`);if(S!==f)throw Error(`OpenAI Codex OAuth state mismatch — possible CSRF, aborting`);let C=await x(b,i);await e({providerId:l,accessToken:C.access_token,refreshToken:C.refresh_token,tokenExpiresAt:Date.now()+(C.expires_in??3600)*1e3,baseUrl:g,userName:T(C.access_token),userAvatar:await E(C.access_token),scopes:C.scope}),n()},onOAuthLogout:async()=>{await e({providerId:l,accessToken:``})},onSilentRenew:async()=>{let t=D();if(!t?.refreshToken)return null;let n=await S(t.refreshToken);return n?.access_token?(await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:g,userName:T(n.access_token),userAvatar:await E(n.access_token),scopes:n.scope??t.scopes}),n.access_token):null}};function I(){r({api:v,stream:N,streamSimple:P})}export{F as config,I as register};
1
+ import{G as e,f as t}from"./account-store-Cwl8IuHt.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{d as r}from"./claude-model-version-CSATLzrT.js";import{n as i,o as a}from"./legacy-api-aliases-bAJ0Klzq.js";import"./main-DVxB5Z8n.js";import{n as o,r as s,t as c}from"./pkce-hGf_TEnP.js";var l=`openai-codex`,u=`app_EMoamEEZ73f0CkXaXp7hrann`,d=`https://auth.openai.com/oauth/authorize`,f=`https://auth.openai.com/oauth/token`,p=`openid profile email offline_access`,m=`http://localhost:1455/auth/callback`,h=`http://localhost:1455/auth/callback*`,g=`https://chatgpt.com/backend-api`,_=`openai-codex-responses`,v=`${l}-openai`,y={xhigh:`xhigh`,minimal:`low`},b=[{id:`gpt-5.5`,name:`GPT-5.5`,input:[`text`,`image`]},{id:`gpt-5.4`,name:`GPT-5.4`,input:[`text`,`image`]},{id:`gpt-5.4-mini`,name:`GPT-5.4 mini`,input:[`text`,`image`]},{id:`gpt-5.3-codex`,name:`GPT-5.3 Codex`,input:[`text`,`image`]},{id:`gpt-5.3-codex-spark`,name:`GPT-5.3 Codex Spark`,input:[`text`]},{id:`gpt-5.2`,name:`GPT-5.2`,input:[`text`,`image`]}].map(e=>({...e,api:`openai`,reasoning:!0,context_window:272e3,max_tokens:128e3,thinkingLevelMap:y}));async function x(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,client_id:u,code:e,code_verifier:t,redirect_uri:m}),r=await fetch(f,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw Error(`OpenAI Codex token exchange failed: ${r.status} ${await r.text()}`);let i=await r.json();if(!i.access_token)throw Error(`OpenAI Codex token exchange did not return access_token.`);return i}async function S(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:u}),n=await fetch(f,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});return n.ok?await n.json():(console.error(`[openai-codex] refresh failed:`,n.status,await n.text()),null)}catch(e){return console.error(`[openai-codex] refresh error:`,e instanceof Error?e.message:String(e)),null}}function C(e){try{let t=e.split(`.`);if(t.length!==3)return;let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`);return n.length%4&&(n+=`=`.repeat(4-n.length%4)),JSON.parse(atob(n))}catch{return}}function w(e){let t=C(e)?.[`https://api.openai.com/profile`]?.email;return typeof t==`string`?t:void 0}function T(e){let t=C(e)?.[`https://api.openai.com/auth`],n=w(e),r=typeof t?.chatgpt_plan_type==`string`?t.chatgpt_plan_type:void 0,i=r?r.charAt(0).toUpperCase()+r.slice(1):void 0;if(n&&i)return`${n} (${i})`;if(n)return n;if(i)return`ChatGPT ${i}`}async function E(e){let t=w(e);if(t)try{let e=t.trim().toLowerCase(),n=new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)));return`https://www.gravatar.com/avatar/${Array.from(n).map(e=>e.toString(16).padStart(2,`0`)).join(``)}?s=128&d=404`}catch{return}}function D(){return t().find(e=>e.providerId===l)}async function O(){let t=D();if(!t?.accessToken)throw Error("Not signed in to OpenAI Codex — run `oauth-token openai-codex` or /login");let n=t.tokenExpiresAt??0;if(n&&Date.now()+6e4<n)return t.accessToken;if(t.refreshToken){let n=await S(t.refreshToken);if(n?.access_token)return await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:g,userName:T(n.access_token),userAvatar:await E(n.access_token),scopes:n.scope??t.scopes}),n.access_token}return t.accessToken}function k(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:v,provider:l,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()}}}function A(e){console.error(`[openai-codex] Stream error:`,e instanceof Error?e.message:String(e))}async function j(e,t,n,r){try{let a=await O(),o={...t,baseUrl:g,api:_},s=i(o,n,{...r,apiKey:a,transport:`sse`});for await(let t of s)e.push(t);e.end()}catch(n){A(n),e.push(k(t,n)),e.end()}}async function M(e,t,n,r){try{let i=await O(),o={...t,baseUrl:g,api:_},s=a(o,n,{...r,apiKey:i,transport:`sse`});for await(let t of s)e.push(t);e.end()}catch(n){A(n),e.push(k(t,n)),e.end()}}var N=(e,t,r={})=>{let i=n();return j(i,e,t,r).catch(A),i},P=(e,t,r)=>{let i=n();return M(i,e,t,r).catch(A),i},F={id:l,name:`OpenAI Codex (ChatGPT Subscription)`,description:`GPT-5 Codex via your ChatGPT Plus/Pro/Business subscription — OAuth login, no API key needed. Default model is GPT-5.5.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`gpt-5.5`,oauthTokenDomains:[`chatgpt.com`,`*.chatgpt.com`,`auth.openai.com`,`api.openai.com`],getModelIds:()=>b,onOAuthLoginIntercepted:async(t,n,r)=>{let i=o(),a=await c(i),f=s(),_=new URL(d);_.searchParams.set(`response_type`,`code`),_.searchParams.set(`client_id`,u),_.searchParams.set(`redirect_uri`,m),_.searchParams.set(`scope`,r?.scopes??p),_.searchParams.set(`code_challenge`,a),_.searchParams.set(`code_challenge_method`,`S256`),_.searchParams.set(`state`,f),_.searchParams.set(`id_token_add_organizations`,`true`),_.searchParams.set(`codex_cli_simplified_flow`,`true`),_.searchParams.set(`originator`,`pi`);let v=await t({authorizeUrl:_.toString(),redirectUriPattern:h,onCapture:`close`});if(!v)throw Error(`OpenAI Codex OAuth login was cancelled or timed out`);let y=new URL(v),b=y.searchParams.get(`code`),S=y.searchParams.get(`state`);if(!b)throw Error(`OpenAI Codex OAuth redirect did not include a code`);if(S!==f)throw Error(`OpenAI Codex OAuth state mismatch — possible CSRF, aborting`);let C=await x(b,i);await e({providerId:l,accessToken:C.access_token,refreshToken:C.refresh_token,tokenExpiresAt:Date.now()+(C.expires_in??3600)*1e3,baseUrl:g,userName:T(C.access_token),userAvatar:await E(C.access_token),scopes:C.scope}),n()},onOAuthLogout:async()=>{await e({providerId:l,accessToken:``})},onSilentRenew:async()=>{let t=D();if(!t?.refreshToken)return null;let n=await S(t.refreshToken);return n?.access_token?(await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:g,userName:T(n.access_token),userAvatar:await E(n.access_token),scopes:n.scope??t.scopes}),n.access_token):null}};function I(){r({api:v,stream:N,streamSimple:P})}export{F as config,I as register};
@@ -1 +1 @@
1
- import{_ as e,r as t}from"./account-store-CFMsGuVj.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{a as r}from"./compat-uEPf6-XW.js";import{n as i,o as a}from"./legacy-api-aliases-jKEvBgOL.js";import"./provider-settings-6sXphFYx.js";import{n as o,r as s,t as c}from"./pkce-hGf_TEnP.js";const l=`openai-codex`,u=`app_EMoamEEZ73f0CkXaXp7hrann`,d=`https://auth.openai.com/oauth/token`,f=`http://localhost:1455/auth/callback`,p=`https://chatgpt.com/backend-api`,m=`openai-codex-responses`,h=`${l}-openai`,g={xhigh:`xhigh`,minimal:`low`},_=[{id:`gpt-5.5`,name:`GPT-5.5`,input:[`text`,`image`]},{id:`gpt-5.4`,name:`GPT-5.4`,input:[`text`,`image`]},{id:`gpt-5.4-mini`,name:`GPT-5.4 mini`,input:[`text`,`image`]},{id:`gpt-5.3-codex`,name:`GPT-5.3 Codex`,input:[`text`,`image`]},{id:`gpt-5.3-codex-spark`,name:`GPT-5.3 Codex Spark`,input:[`text`]},{id:`gpt-5.2`,name:`GPT-5.2`,input:[`text`,`image`]}].map(e=>({...e,api:`openai`,reasoning:!0,context_window:272e3,max_tokens:128e3,thinkingLevelMap:g}));async function v(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,client_id:u,code:e,code_verifier:t,redirect_uri:f}),r=await fetch(d,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw Error(`OpenAI Codex token exchange failed: ${r.status} ${await r.text()}`);let i=await r.json();if(!i.access_token)throw Error(`OpenAI Codex token exchange did not return access_token.`);return i}async function y(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:u}),n=await fetch(d,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});return n.ok?await n.json():(console.error(`[openai-codex] refresh failed:`,n.status,await n.text()),null)}catch(e){return console.error(`[openai-codex] refresh error:`,e instanceof Error?e.message:String(e)),null}}function b(e){try{let t=e.split(`.`);if(t.length!==3)return;let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`);return n.length%4&&(n+=`=`.repeat(4-n.length%4)),JSON.parse(atob(n))}catch{return}}function x(e){let t=b(e)?.[`https://api.openai.com/profile`]?.email;return typeof t==`string`?t:void 0}function S(e){let t=b(e)?.[`https://api.openai.com/auth`],n=x(e),r=typeof t?.chatgpt_plan_type==`string`?t.chatgpt_plan_type:void 0,i=r?r.charAt(0).toUpperCase()+r.slice(1):void 0;if(n&&i)return`${n} (${i})`;if(n)return n;if(i)return`ChatGPT ${i}`}async function C(e){let t=x(e);if(t)try{let e=t.trim().toLowerCase(),n=new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)));return`https://www.gravatar.com/avatar/${Array.from(n).map(e=>e.toString(16).padStart(2,`0`)).join(``)}?s=128&d=404`}catch{return}}function w(){return t().find(e=>e.providerId===l)}async function T(){let t=w();if(!t?.accessToken)throw Error("Not signed in to OpenAI Codex — run `oauth-token openai-codex` or /login");let n=t.tokenExpiresAt??0;if(n&&Date.now()+6e4<n)return t.accessToken;if(t.refreshToken){let n=await y(t.refreshToken);if(n?.access_token)return await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:p,userName:S(n.access_token),userAvatar:await C(n.access_token),scopes:n.scope??t.scopes}),n.access_token}return t.accessToken}function E(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:h,provider:l,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()}}}function D(e){console.error(`[openai-codex] Stream error:`,e instanceof Error?e.message:String(e))}async function O(e,t,n,r){try{let a=await T(),o={...t,baseUrl:p,api:m},s=i(o,n,{...r,apiKey:a,transport:`sse`});for await(let t of s)e.push(t);e.end()}catch(n){D(n),e.push(E(t,n)),e.end()}}async function k(e,t,n,r){try{let i=await T(),o={...t,baseUrl:p,api:m},s=a(o,n,{...r,apiKey:i,transport:`sse`});for await(let t of s)e.push(t);e.end()}catch(n){D(n),e.push(E(t,n)),e.end()}}const A=(e,t,r={})=>{let i=n();return O(i,e,t,r).catch(D),i},j=(e,t,r)=>{let i=n();return k(i,e,t,r).catch(D),i},M={id:l,name:`OpenAI Codex (ChatGPT Subscription)`,description:`GPT-5 Codex via your ChatGPT Plus/Pro/Business subscription — OAuth login, no API key needed. Default model is GPT-5.5.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`gpt-5.5`,oauthTokenDomains:[`chatgpt.com`,`*.chatgpt.com`,`auth.openai.com`,`api.openai.com`],getModelIds:()=>_,onOAuthLoginIntercepted:async(t,n,r)=>{let i=o(),a=await c(i),d=s(),m=new URL(`https://auth.openai.com/oauth/authorize`);m.searchParams.set(`response_type`,`code`),m.searchParams.set(`client_id`,u),m.searchParams.set(`redirect_uri`,f),m.searchParams.set(`scope`,r?.scopes??`openid profile email offline_access`),m.searchParams.set(`code_challenge`,a),m.searchParams.set(`code_challenge_method`,`S256`),m.searchParams.set(`state`,d),m.searchParams.set(`id_token_add_organizations`,`true`),m.searchParams.set(`codex_cli_simplified_flow`,`true`),m.searchParams.set(`originator`,`pi`);let h=await t({authorizeUrl:m.toString(),redirectUriPattern:`http://localhost:1455/auth/callback*`,onCapture:`close`});if(!h)throw Error(`OpenAI Codex OAuth login was cancelled or timed out`);let g=new URL(h),_=g.searchParams.get(`code`),y=g.searchParams.get(`state`);if(!_)throw Error(`OpenAI Codex OAuth redirect did not include a code`);if(y!==d)throw Error(`OpenAI Codex OAuth state mismatch — possible CSRF, aborting`);let b=await v(_,i);await e({providerId:l,accessToken:b.access_token,refreshToken:b.refresh_token,tokenExpiresAt:Date.now()+(b.expires_in??3600)*1e3,baseUrl:p,userName:S(b.access_token),userAvatar:await C(b.access_token),scopes:b.scope}),n()},onOAuthLogout:async()=>{await e({providerId:l,accessToken:``})},onSilentRenew:async()=>{let t=w();if(!t?.refreshToken)return null;let n=await y(t.refreshToken);return n?.access_token?(await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:p,userName:S(n.access_token),userAvatar:await C(n.access_token),scopes:n.scope??t.scopes}),n.access_token):null}};function N(){r({api:h,stream:A,streamSimple:j})}export{M as config,N as register};
1
+ import{_ as e,r as t}from"./account-store-CEAZoLNK.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{a as r}from"./compat-uEPf6-XW.js";import{n as i,o as a}from"./legacy-api-aliases-jKEvBgOL.js";import"./provider-settings-D724hVOu.js";import{n as o,r as s,t as c}from"./pkce-hGf_TEnP.js";const l=`openai-codex`,u=`app_EMoamEEZ73f0CkXaXp7hrann`,d=`https://auth.openai.com/oauth/token`,f=`http://localhost:1455/auth/callback`,p=`https://chatgpt.com/backend-api`,m=`openai-codex-responses`,h=`${l}-openai`,g={xhigh:`xhigh`,minimal:`low`},_=[{id:`gpt-5.5`,name:`GPT-5.5`,input:[`text`,`image`]},{id:`gpt-5.4`,name:`GPT-5.4`,input:[`text`,`image`]},{id:`gpt-5.4-mini`,name:`GPT-5.4 mini`,input:[`text`,`image`]},{id:`gpt-5.3-codex`,name:`GPT-5.3 Codex`,input:[`text`,`image`]},{id:`gpt-5.3-codex-spark`,name:`GPT-5.3 Codex Spark`,input:[`text`]},{id:`gpt-5.2`,name:`GPT-5.2`,input:[`text`,`image`]}].map(e=>({...e,api:`openai`,reasoning:!0,context_window:272e3,max_tokens:128e3,thinkingLevelMap:g}));async function v(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,client_id:u,code:e,code_verifier:t,redirect_uri:f}),r=await fetch(d,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw Error(`OpenAI Codex token exchange failed: ${r.status} ${await r.text()}`);let i=await r.json();if(!i.access_token)throw Error(`OpenAI Codex token exchange did not return access_token.`);return i}async function y(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:u}),n=await fetch(d,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});return n.ok?await n.json():(console.error(`[openai-codex] refresh failed:`,n.status,await n.text()),null)}catch(e){return console.error(`[openai-codex] refresh error:`,e instanceof Error?e.message:String(e)),null}}function b(e){try{let t=e.split(`.`);if(t.length!==3)return;let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`);return n.length%4&&(n+=`=`.repeat(4-n.length%4)),JSON.parse(atob(n))}catch{return}}function x(e){let t=b(e)?.[`https://api.openai.com/profile`]?.email;return typeof t==`string`?t:void 0}function S(e){let t=b(e)?.[`https://api.openai.com/auth`],n=x(e),r=typeof t?.chatgpt_plan_type==`string`?t.chatgpt_plan_type:void 0,i=r?r.charAt(0).toUpperCase()+r.slice(1):void 0;if(n&&i)return`${n} (${i})`;if(n)return n;if(i)return`ChatGPT ${i}`}async function C(e){let t=x(e);if(t)try{let e=t.trim().toLowerCase(),n=new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)));return`https://www.gravatar.com/avatar/${Array.from(n).map(e=>e.toString(16).padStart(2,`0`)).join(``)}?s=128&d=404`}catch{return}}function w(){return t().find(e=>e.providerId===l)}async function T(){let t=w();if(!t?.accessToken)throw Error("Not signed in to OpenAI Codex — run `oauth-token openai-codex` or /login");let n=t.tokenExpiresAt??0;if(n&&Date.now()+6e4<n)return t.accessToken;if(t.refreshToken){let n=await y(t.refreshToken);if(n?.access_token)return await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:p,userName:S(n.access_token),userAvatar:await C(n.access_token),scopes:n.scope??t.scopes}),n.access_token}return t.accessToken}function E(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:h,provider:l,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()}}}function D(e){console.error(`[openai-codex] Stream error:`,e instanceof Error?e.message:String(e))}async function O(e,t,n,r){try{let a=await T(),o={...t,baseUrl:p,api:m},s=i(o,n,{...r,apiKey:a,transport:`sse`});for await(let t of s)e.push(t);e.end()}catch(n){D(n),e.push(E(t,n)),e.end()}}async function k(e,t,n,r){try{let i=await T(),o={...t,baseUrl:p,api:m},s=a(o,n,{...r,apiKey:i,transport:`sse`});for await(let t of s)e.push(t);e.end()}catch(n){D(n),e.push(E(t,n)),e.end()}}const A=(e,t,r={})=>{let i=n();return O(i,e,t,r).catch(D),i},j=(e,t,r)=>{let i=n();return k(i,e,t,r).catch(D),i},M={id:l,name:`OpenAI Codex (ChatGPT Subscription)`,description:`GPT-5 Codex via your ChatGPT Plus/Pro/Business subscription — OAuth login, no API key needed. Default model is GPT-5.5.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`gpt-5.5`,oauthTokenDomains:[`chatgpt.com`,`*.chatgpt.com`,`auth.openai.com`,`api.openai.com`],getModelIds:()=>_,onOAuthLoginIntercepted:async(t,n,r)=>{let i=o(),a=await c(i),d=s(),m=new URL(`https://auth.openai.com/oauth/authorize`);m.searchParams.set(`response_type`,`code`),m.searchParams.set(`client_id`,u),m.searchParams.set(`redirect_uri`,f),m.searchParams.set(`scope`,r?.scopes??`openid profile email offline_access`),m.searchParams.set(`code_challenge`,a),m.searchParams.set(`code_challenge_method`,`S256`),m.searchParams.set(`state`,d),m.searchParams.set(`id_token_add_organizations`,`true`),m.searchParams.set(`codex_cli_simplified_flow`,`true`),m.searchParams.set(`originator`,`pi`);let h=await t({authorizeUrl:m.toString(),redirectUriPattern:`http://localhost:1455/auth/callback*`,onCapture:`close`});if(!h)throw Error(`OpenAI Codex OAuth login was cancelled or timed out`);let g=new URL(h),_=g.searchParams.get(`code`),y=g.searchParams.get(`state`);if(!_)throw Error(`OpenAI Codex OAuth redirect did not include a code`);if(y!==d)throw Error(`OpenAI Codex OAuth state mismatch — possible CSRF, aborting`);let b=await v(_,i);await e({providerId:l,accessToken:b.access_token,refreshToken:b.refresh_token,tokenExpiresAt:Date.now()+(b.expires_in??3600)*1e3,baseUrl:p,userName:S(b.access_token),userAvatar:await C(b.access_token),scopes:b.scope}),n()},onOAuthLogout:async()=>{await e({providerId:l,accessToken:``})},onSilentRenew:async()=>{let t=w();if(!t?.refreshToken)return null;let n=await y(t.refreshToken);return n?.access_token?(await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:p,userName:S(n.access_token),userAvatar:await C(n.access_token),scopes:n.scope??t.scopes}),n.access_token):null}};function N(){r({api:h,stream:A,streamSimple:j})}export{M as config,N as register};
@@ -1 +1 @@
1
- import{G as e,_ as t}from"./account-store-CXfDPizG.js";import{d as n}from"./claude-model-version-CSATLzrT.js";import{r,s as i}from"./legacy-api-aliases-bAJ0Klzq.js";import"./main-DHBCUrMc.js";import{fetchModels as a,getCatalog as o}from"./openrouter-models-Cfi7qjq5.js";import{loginIntercepted as s}from"./openrouter-oauth-C711G__3.js";var c=`openrouter`,l=`https://openrouter.ai/api/v1`,u=`openai-completions`,d=`${c}-openai`,f={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function p(e){return{...e,baseUrl:l,api:u}}function m(e){return{...e??{},...f}}var h=(e,n,i={})=>r(p(e),n,{...i,apiKey:t(c)??i.apiKey,headers:m(i.headers)}),g=(e,n,r={})=>i(p(e),n,{...r,apiKey:t(c)??r.apiKey,headers:m(r.headers)}),_={id:c,name:`OpenRouter`,description:`Access OpenRouter models with one-click PKCE login. No pasted API key is required.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`anthropic/claude-sonnet-4.6`,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:o,refreshModels:async()=>{await a()},onOAuthLoginIntercepted:async(e,t,n)=>{await s(e,()=>void 0,n),await a().catch(()=>void 0),t()},onOAuthLogout:async()=>{await e({providerId:c,accessToken:``})}};function v(){n({api:d,stream:h,streamSimple:g})}export{_ as config,v as register};
1
+ import{G as e,_ as t}from"./account-store-Cwl8IuHt.js";import{d as n}from"./claude-model-version-CSATLzrT.js";import{r,s as i}from"./legacy-api-aliases-bAJ0Klzq.js";import"./main-DVxB5Z8n.js";import{fetchModels as a,getCatalog as o}from"./openrouter-models-Cfi7qjq5.js";import{loginIntercepted as s}from"./openrouter-oauth-lNzzIZx6.js";var c=`openrouter`,l=`https://openrouter.ai/api/v1`,u=`openai-completions`,d=`${c}-openai`,f={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function p(e){return{...e,baseUrl:l,api:u}}function m(e){return{...e??{},...f}}var h=(e,n,i={})=>r(p(e),n,{...i,apiKey:t(c)??i.apiKey,headers:m(i.headers)}),g=(e,n,r={})=>i(p(e),n,{...r,apiKey:t(c)??r.apiKey,headers:m(r.headers)}),_={id:c,name:`OpenRouter`,description:`Access OpenRouter models with one-click PKCE login. No pasted API key is required.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`anthropic/claude-sonnet-4.6`,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:o,refreshModels:async()=>{await a()},onOAuthLoginIntercepted:async(e,t,n)=>{await s(e,()=>void 0,n),await a().catch(()=>void 0),t()},onOAuthLogout:async()=>{await e({providerId:c,accessToken:``})}};function v(){n({api:d,stream:h,streamSimple:g})}export{_ as config,v as register};
@@ -1 +1 @@
1
- import{_ as e,a as t}from"./account-store-CFMsGuVj.js";import{a as n}from"./compat-uEPf6-XW.js";import{r,s as i}from"./legacy-api-aliases-jKEvBgOL.js";import"./provider-settings-6sXphFYx.js";import{fetchModels as a,getCatalog as o}from"./openrouter-models-DyyLIGVe.js";import{loginIntercepted as s}from"./openrouter-oauth-DfPhmOUG.js";const c=`openrouter`,l=`${c}-openai`,u={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function d(e){return{...e,baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`}}function f(e){return{...e??{},...u}}const p=(e,n,i={})=>r(d(e),n,{...i,apiKey:t(c)??i.apiKey,headers:f(i.headers)}),m=(e,n,r={})=>i(d(e),n,{...r,apiKey:t(c)??r.apiKey,headers:f(r.headers)}),h={id:c,name:`OpenRouter`,description:`Access OpenRouter models with one-click PKCE login. No pasted API key is required.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`anthropic/claude-sonnet-4.6`,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:o,refreshModels:async()=>{await a()},onOAuthLoginIntercepted:async(e,t,n)=>{await s(e,()=>void 0,n),await a().catch(()=>void 0),t()},onOAuthLogout:async()=>{await e({providerId:c,accessToken:``})}};function g(){n({api:l,stream:p,streamSimple:m})}export{h as config,g as register};
1
+ import{_ as e,a as t}from"./account-store-CEAZoLNK.js";import{a as n}from"./compat-uEPf6-XW.js";import{r,s as i}from"./legacy-api-aliases-jKEvBgOL.js";import"./provider-settings-D724hVOu.js";import{fetchModels as a,getCatalog as o}from"./openrouter-models-DyyLIGVe.js";import{loginIntercepted as s}from"./openrouter-oauth-Do9q3Xgz.js";const c=`openrouter`,l=`${c}-openai`,u={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function d(e){return{...e,baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`}}function f(e){return{...e??{},...u}}const p=(e,n,i={})=>r(d(e),n,{...i,apiKey:t(c)??i.apiKey,headers:f(i.headers)}),m=(e,n,r={})=>i(d(e),n,{...r,apiKey:t(c)??r.apiKey,headers:f(r.headers)}),h={id:c,name:`OpenRouter`,description:`Access OpenRouter models with one-click PKCE login. No pasted API key is required.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`anthropic/claude-sonnet-4.6`,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:o,refreshModels:async()=>{await a()},onOAuthLoginIntercepted:async(e,t,n)=>{await s(e,()=>void 0,n),await a().catch(()=>void 0),t()},onOAuthLogout:async()=>{await e({providerId:c,accessToken:``})}};function g(){n({api:l,stream:p,streamSimple:m})}export{h as config,g as register};
@@ -1 +1 @@
1
- import{G as e,_ as t}from"./account-store-CXfDPizG.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{d as r}from"./claude-model-version-CSATLzrT.js";import{r as i,s as a}from"./legacy-api-aliases-bAJ0Klzq.js";import"./main-DHBCUrMc.js";import{FREE_ROUTER_FALLBACK as o,fetchModels as s,getFreeCatalog as c,isModelInFreeCatalog as l}from"./openrouter-models-Cfi7qjq5.js";import{loginIntercepted as u}from"./openrouter-oauth-C711G__3.js";var d=`openrouter-free`,f=`https://openrouter.ai/api/v1`,p=`openai-completions`,m=`${d}-openai`,h={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function g(e){return{...e,baseUrl:f,api:p}}function _(e){return{...e??{},...h}}function v(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:m,provider:d,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()}}}function y(e){let t=n(),r=Error(`OpenRouter (Free) refused "${e.id}" — it is not in the current free catalog. Choose another free model or refresh the catalog.`);return queueMicrotask(()=>{t.push(v(e,r)),t.end()}),t}var b=(e,n,r={})=>l(e.id)?i(g(e),n,{...r,apiKey:t(d)??r.apiKey,headers:_(r.headers)}):y(e),x=(e,n,r={})=>l(e.id)?a(g(e),n,{...r,apiKey:t(d)??r.apiKey,headers:_(r.headers)}):y(e),S={id:d,name:`OpenRouter (Free)`,description:`Currently free OpenRouter models that support vision and tools. Catalog refreshes from OpenRouter; paid models are excluded.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:o.id,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:c,refreshModels:async()=>{await s()},onOAuthLoginIntercepted:async(e,t,n)=>{await u(e,()=>void 0,{...n,providerId:d}),await s().catch(()=>void 0),t()},onOAuthLogout:async()=>{await e({providerId:d,accessToken:``})}};function C(){r({api:m,stream:b,streamSimple:x})}export{S as config,C as register};
1
+ import{G as e,_ as t}from"./account-store-Cwl8IuHt.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{d as r}from"./claude-model-version-CSATLzrT.js";import{r as i,s as a}from"./legacy-api-aliases-bAJ0Klzq.js";import"./main-DVxB5Z8n.js";import{FREE_ROUTER_FALLBACK as o,fetchModels as s,getFreeCatalog as c,isModelInFreeCatalog as l}from"./openrouter-models-Cfi7qjq5.js";import{loginIntercepted as u}from"./openrouter-oauth-lNzzIZx6.js";var d=`openrouter-free`,f=`https://openrouter.ai/api/v1`,p=`openai-completions`,m=`${d}-openai`,h={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function g(e){return{...e,baseUrl:f,api:p}}function _(e){return{...e??{},...h}}function v(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:m,provider:d,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()}}}function y(e){let t=n(),r=Error(`OpenRouter (Free) refused "${e.id}" — it is not in the current free catalog. Choose another free model or refresh the catalog.`);return queueMicrotask(()=>{t.push(v(e,r)),t.end()}),t}var b=(e,n,r={})=>l(e.id)?i(g(e),n,{...r,apiKey:t(d)??r.apiKey,headers:_(r.headers)}):y(e),x=(e,n,r={})=>l(e.id)?a(g(e),n,{...r,apiKey:t(d)??r.apiKey,headers:_(r.headers)}):y(e),S={id:d,name:`OpenRouter (Free)`,description:`Currently free OpenRouter models that support vision and tools. Catalog refreshes from OpenRouter; paid models are excluded.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:o.id,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:c,refreshModels:async()=>{await s()},onOAuthLoginIntercepted:async(e,t,n)=>{await u(e,()=>void 0,{...n,providerId:d}),await s().catch(()=>void 0),t()},onOAuthLogout:async()=>{await e({providerId:d,accessToken:``})}};function C(){r({api:m,stream:b,streamSimple:x})}export{S as config,C as register};
@@ -1 +1 @@
1
- import{_ as e,a as t}from"./account-store-CFMsGuVj.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{a as r}from"./compat-uEPf6-XW.js";import{r as i,s as a}from"./legacy-api-aliases-jKEvBgOL.js";import"./provider-settings-6sXphFYx.js";import{FREE_ROUTER_FALLBACK as o,fetchModels as s,getFreeCatalog as c,isModelInFreeCatalog as l}from"./openrouter-models-DyyLIGVe.js";import{loginIntercepted as u}from"./openrouter-oauth-DfPhmOUG.js";const d=`openrouter-free`,f=`${d}-openai`,p={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function m(e){return{...e,baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`}}function h(e){return{...e??{},...p}}function g(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:f,provider:d,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()}}}function _(e){let t=n(),r=Error(`OpenRouter (Free) refused "${e.id}" — it is not in the current free catalog. Choose another free model or refresh the catalog.`);return queueMicrotask(()=>{t.push(g(e,r)),t.end()}),t}const v=(e,n,r={})=>l(e.id)?i(m(e),n,{...r,apiKey:t(d)??r.apiKey,headers:h(r.headers)}):_(e),y=(e,n,r={})=>l(e.id)?a(m(e),n,{...r,apiKey:t(d)??r.apiKey,headers:h(r.headers)}):_(e),b={id:d,name:`OpenRouter (Free)`,description:`Currently free OpenRouter models that support vision and tools. Catalog refreshes from OpenRouter; paid models are excluded.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:o.id,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:c,refreshModels:async()=>{await s()},onOAuthLoginIntercepted:async(e,t,n)=>{await u(e,()=>void 0,{...n,providerId:d}),await s().catch(()=>void 0),t()},onOAuthLogout:async()=>{await e({providerId:d,accessToken:``})}};function x(){r({api:f,stream:v,streamSimple:y})}export{b as config,x as register};
1
+ import{_ as e,a as t}from"./account-store-CEAZoLNK.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{a as r}from"./compat-uEPf6-XW.js";import{r as i,s as a}from"./legacy-api-aliases-jKEvBgOL.js";import"./provider-settings-D724hVOu.js";import{FREE_ROUTER_FALLBACK as o,fetchModels as s,getFreeCatalog as c,isModelInFreeCatalog as l}from"./openrouter-models-DyyLIGVe.js";import{loginIntercepted as u}from"./openrouter-oauth-Do9q3Xgz.js";const d=`openrouter-free`,f=`${d}-openai`,p={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function m(e){return{...e,baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`}}function h(e){return{...e??{},...p}}function g(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:f,provider:d,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()}}}function _(e){let t=n(),r=Error(`OpenRouter (Free) refused "${e.id}" — it is not in the current free catalog. Choose another free model or refresh the catalog.`);return queueMicrotask(()=>{t.push(g(e,r)),t.end()}),t}const v=(e,n,r={})=>l(e.id)?i(m(e),n,{...r,apiKey:t(d)??r.apiKey,headers:h(r.headers)}):_(e),y=(e,n,r={})=>l(e.id)?a(m(e),n,{...r,apiKey:t(d)??r.apiKey,headers:h(r.headers)}):_(e),b={id:d,name:`OpenRouter (Free)`,description:`Currently free OpenRouter models that support vision and tools. Catalog refreshes from OpenRouter; paid models are excluded.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:o.id,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:c,refreshModels:async()=>{await s()},onOAuthLoginIntercepted:async(e,t,n)=>{await u(e,()=>void 0,{...n,providerId:d}),await s().catch(()=>void 0),t()},onOAuthLogout:async()=>{await e({providerId:d,accessToken:``})}};function x(){r({api:f,stream:v,streamSimple:y})}export{b as config,x as register};
@@ -1 +1 @@
1
- import{_ as e}from"./account-store-CFMsGuVj.js";import"./provider-settings-6sXphFYx.js";import{n as t,t as n}from"./pkce-hGf_TEnP.js";const r=`http://127.0.0.1:3000/callback`,i=`http://127.0.0.1:3000/*`;function a(e,t){let n=new URL(`https://openrouter.ai/auth`);return n.searchParams.set(`callback_url`,e),n.searchParams.set(`code_challenge`,t),n.searchParams.set(`code_challenge_method`,`S256`),n.toString()}function o(e){if(!e)throw Error(`OpenRouter OAuth login was cancelled or timed out`);let t;try{t=new URL(e)}catch{throw Error(`OpenRouter OAuth returned an invalid callback URL`)}let n=t.searchParams.get(`code`);if(!n)throw Error(`OpenRouter OAuth redirect did not include an authorization code`);return n}async function s(e,t,n=fetch){let r=await n(`https://openrouter.ai/api/v1/auth/keys`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:e,code_verifier:t,code_challenge_method:`S256`}),signal:AbortSignal.timeout(3e4)});if(!r.ok){let e=await r.text();throw Error(`OpenRouter key exchange failed (${r.status}): ${e||`(empty response body)`}`)}let i;try{i=await r.json()}catch{throw Error(`OpenRouter key exchange returned invalid JSON`)}let a=i&&typeof i==`object`&&typeof i.key==`string`?i.key.trim():``;if(!a)throw Error(`OpenRouter key exchange returned an empty or invalid API key`);return a}async function c(c,l,u){let d=u?.providerId??`openrouter`,f=t(),p=await n(f),m=await s(o(await c({authorizeUrl:a(r,p),redirectUriPattern:i,onCapture:`close`})),f);await e({providerId:d,accessToken:m,tokenExpiresAt:2**53-1,baseUrl:`https://openrouter.ai/api/v1`}),l()}export{r as OPENROUTER_CALLBACK_URL,i as OPENROUTER_REDIRECT_URI_PATTERN,a as buildAuthorizeUrl,n as deriveCodeChallenge,s as exchangeCodeForKey,t as generateCodeVerifier,c as loginIntercepted,o as parseCallbackCode};
1
+ import{_ as e}from"./account-store-CEAZoLNK.js";import"./provider-settings-D724hVOu.js";import{n as t,t as n}from"./pkce-hGf_TEnP.js";const r=`http://127.0.0.1:3000/callback`,i=`http://127.0.0.1:3000/*`;function a(e,t){let n=new URL(`https://openrouter.ai/auth`);return n.searchParams.set(`callback_url`,e),n.searchParams.set(`code_challenge`,t),n.searchParams.set(`code_challenge_method`,`S256`),n.toString()}function o(e){if(!e)throw Error(`OpenRouter OAuth login was cancelled or timed out`);let t;try{t=new URL(e)}catch{throw Error(`OpenRouter OAuth returned an invalid callback URL`)}let n=t.searchParams.get(`code`);if(!n)throw Error(`OpenRouter OAuth redirect did not include an authorization code`);return n}async function s(e,t,n=fetch){let r=await n(`https://openrouter.ai/api/v1/auth/keys`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:e,code_verifier:t,code_challenge_method:`S256`}),signal:AbortSignal.timeout(3e4)});if(!r.ok){let e=await r.text();throw Error(`OpenRouter key exchange failed (${r.status}): ${e||`(empty response body)`}`)}let i;try{i=await r.json()}catch{throw Error(`OpenRouter key exchange returned invalid JSON`)}let a=i&&typeof i==`object`&&typeof i.key==`string`?i.key.trim():``;if(!a)throw Error(`OpenRouter key exchange returned an empty or invalid API key`);return a}async function c(c,l,u){let d=u?.providerId??`openrouter`,f=t(),p=await n(f),m=await s(o(await c({authorizeUrl:a(r,p),redirectUriPattern:i,onCapture:`close`})),f);await e({providerId:d,accessToken:m,tokenExpiresAt:2**53-1,baseUrl:`https://openrouter.ai/api/v1`}),l()}export{r as OPENROUTER_CALLBACK_URL,i as OPENROUTER_REDIRECT_URI_PATTERN,a as buildAuthorizeUrl,n as deriveCodeChallenge,s as exchangeCodeForKey,t as generateCodeVerifier,c as loginIntercepted,o as parseCallbackCode};
@@ -1 +1 @@
1
- import{G as e}from"./account-store-CXfDPizG.js";import"./main-DHBCUrMc.js";import{n as t,t as n}from"./pkce-hGf_TEnP.js";var r=`https://openrouter.ai/auth`,i=`https://openrouter.ai/api/v1/auth/keys`,a=`https://openrouter.ai/api/v1`,o=`http://127.0.0.1:3000/callback`,s=`http://127.0.0.1:3000/*`;function c(e,t){let n=new URL(r);return n.searchParams.set(`callback_url`,e),n.searchParams.set(`code_challenge`,t),n.searchParams.set(`code_challenge_method`,`S256`),n.toString()}function l(e){if(!e)throw Error(`OpenRouter OAuth login was cancelled or timed out`);let t;try{t=new URL(e)}catch{throw Error(`OpenRouter OAuth returned an invalid callback URL`)}let n=t.searchParams.get(`code`);if(!n)throw Error(`OpenRouter OAuth redirect did not include an authorization code`);return n}async function u(e,t,n=fetch){let r=await n(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:e,code_verifier:t,code_challenge_method:`S256`}),signal:AbortSignal.timeout(3e4)});if(!r.ok){let e=await r.text();throw Error(`OpenRouter key exchange failed (${r.status}): ${e||`(empty response body)`}`)}let a;try{a=await r.json()}catch{throw Error(`OpenRouter key exchange returned invalid JSON`)}let o=a&&typeof a==`object`&&typeof a.key==`string`?a.key.trim():``;if(!o)throw Error(`OpenRouter key exchange returned an empty or invalid API key`);return o}async function d(r,i,d){let f=d?.providerId??`openrouter`,p=t(),m=await u(l(await r({authorizeUrl:c(o,await n(p)),redirectUriPattern:s,onCapture:`close`})),p);await e({providerId:f,accessToken:m,tokenExpiresAt:2**53-1,baseUrl:a}),i()}export{o as OPENROUTER_CALLBACK_URL,s as OPENROUTER_REDIRECT_URI_PATTERN,c as buildAuthorizeUrl,n as deriveCodeChallenge,u as exchangeCodeForKey,t as generateCodeVerifier,d as loginIntercepted,l as parseCallbackCode};
1
+ import{G as e}from"./account-store-Cwl8IuHt.js";import"./main-DVxB5Z8n.js";import{n as t,t as n}from"./pkce-hGf_TEnP.js";var r=`https://openrouter.ai/auth`,i=`https://openrouter.ai/api/v1/auth/keys`,a=`https://openrouter.ai/api/v1`,o=`http://127.0.0.1:3000/callback`,s=`http://127.0.0.1:3000/*`;function c(e,t){let n=new URL(r);return n.searchParams.set(`callback_url`,e),n.searchParams.set(`code_challenge`,t),n.searchParams.set(`code_challenge_method`,`S256`),n.toString()}function l(e){if(!e)throw Error(`OpenRouter OAuth login was cancelled or timed out`);let t;try{t=new URL(e)}catch{throw Error(`OpenRouter OAuth returned an invalid callback URL`)}let n=t.searchParams.get(`code`);if(!n)throw Error(`OpenRouter OAuth redirect did not include an authorization code`);return n}async function u(e,t,n=fetch){let r=await n(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:e,code_verifier:t,code_challenge_method:`S256`}),signal:AbortSignal.timeout(3e4)});if(!r.ok){let e=await r.text();throw Error(`OpenRouter key exchange failed (${r.status}): ${e||`(empty response body)`}`)}let a;try{a=await r.json()}catch{throw Error(`OpenRouter key exchange returned invalid JSON`)}let o=a&&typeof a==`object`&&typeof a.key==`string`?a.key.trim():``;if(!o)throw Error(`OpenRouter key exchange returned an empty or invalid API key`);return o}async function d(r,i,d){let f=d?.providerId??`openrouter`,p=t(),m=await u(l(await r({authorizeUrl:c(o,await n(p)),redirectUriPattern:s,onCapture:`close`})),p);await e({providerId:f,accessToken:m,tokenExpiresAt:2**53-1,baseUrl:a}),i()}export{o as OPENROUTER_CALLBACK_URL,s as OPENROUTER_REDIRECT_URI_PATTERN,c as buildAuthorizeUrl,n as deriveCodeChallenge,u as exchangeCodeForKey,t as generateCodeVerifier,d as loginIntercepted,l as parseCallbackCode};
@@ -1 +1 @@
1
- import{t as e}from"./logger-DDBAeTLF.js";import{t}from"./float-topology-hfgMx1Yq.js";var n=`sudo-request`,r=e(`sudo-panel`),i=typeof globalThis.confirm==`function`?globalThis.confirm.bind(globalThis):void 0,a=typeof globalThis.prompt==`function`?globalThis.prompt.bind(globalThis):void 0;function o(e,t={}){let n=t.confirm??i,o=t.prompt??a;if(!n)return r.warn(`no native confirm available in this realm — denying`),{decision:`deny`};let s=e.requester?`Requested by: ${e.requester}\n\n`:``;if(!n(`Approve ${e.kind}:\n\n${s}${e.detail}\n\nOK = allow · Cancel = deny`))return{decision:`deny`};let c=e.suggestedPattern?.trim()||e.detail.trim();if(!n(`Always allow actions matching:\n\n${c}\n\nOK = always · Cancel = just this once`))return{decision:`allow`};let l=o?.(`Edit the "Always" allow pattern:`,c);return{decision:`always`,pattern:l&&l.trim().length>0?l.trim():c}}function s(e={}){let t=globalThis.chrome?.runtime?.onMessage;return!t||typeof t.addListener!=`function`?!1:(t.addListener((t,n,i)=>{if(!c(t))return;let a=t.payload.request;try{i({ok:!0,decision:o(a,e)})}catch(e){r.warn(`panel responder threw — denying`,{error:e instanceof Error?e.message:String(e)}),i({ok:!1,decision:{decision:`deny`},error:`panel responder error`})}return!1}),!0)}function c(e){if(!e||typeof e!=`object`)return!1;let t=e;if(t.source!==`offscreen`)return!1;let n=t.payload;if(!n||n.type!==`sudo-request`)return!1;let r=n.request;return!!r&&typeof r.kind==`string`&&typeof r.detail==`string`}var l=e(`sudo:page`),u=null;function d(e){u=e}async function f(e){let t=u;if(!t)return null;let n=!1;try{n=t.shouldDelegate()}catch(e){l.warn(`tray delegate probe threw — treating as not delegable`,{error:e instanceof Error?e.message:String(e)})}if(!n)return null;try{return{decision:await t.requestApproval(e),handled:!0}}catch(e){return l.warn(`tray-delegated sudo approval threw — denying`,{error:e instanceof Error?e.message:String(e)}),{decision:{decision:`deny`},handled:!0}}}async function p(e,t){try{return{decision:t(e),handled:!0}}catch(e){return l.warn(`in-page sudo prompt threw — denying`,{error:e instanceof Error?e.message:String(e)}),{decision:{decision:`deny`},handled:!0}}}async function m(e,n=`resolve`,r={}){let i=await f(e);if(i)return i;let a=r.hasLocalNodeServer??t;return n===`tray-first`&&a()?{decision:{decision:`deny`},handled:!1}:p(e,r.nativeResolve??o)}export{o as n,n as r,m as resolveSudoApprovalInPage,d as setSudoTrayDelegate,s as t};
1
+ import{t as e}from"./logger-DDBAeTLF.js";import{t}from"./float-topology-YtctpJaG.js";var n=`sudo-request`,r=e(`sudo-panel`),i=typeof globalThis.confirm==`function`?globalThis.confirm.bind(globalThis):void 0,a=typeof globalThis.prompt==`function`?globalThis.prompt.bind(globalThis):void 0;function o(e,t={}){let n=t.confirm??i,o=t.prompt??a;if(!n)return r.warn(`no native confirm available in this realm — denying`),{decision:`deny`};let s=e.requester?`Requested by: ${e.requester}\n\n`:``;if(!n(`Approve ${e.kind}:\n\n${s}${e.detail}\n\nOK = allow · Cancel = deny`))return{decision:`deny`};let c=e.suggestedPattern?.trim()||e.detail.trim();if(!n(`Always allow actions matching:\n\n${c}\n\nOK = always · Cancel = just this once`))return{decision:`allow`};let l=o?.(`Edit the "Always" allow pattern:`,c);return{decision:`always`,pattern:l&&l.trim().length>0?l.trim():c}}function s(e={}){let t=globalThis.chrome?.runtime?.onMessage;return!t||typeof t.addListener!=`function`?!1:(t.addListener((t,n,i)=>{if(!c(t))return;let a=t.payload.request;try{i({ok:!0,decision:o(a,e)})}catch(e){r.warn(`panel responder threw — denying`,{error:e instanceof Error?e.message:String(e)}),i({ok:!1,decision:{decision:`deny`},error:`panel responder error`})}return!1}),!0)}function c(e){if(!e||typeof e!=`object`)return!1;let t=e;if(t.source!==`offscreen`)return!1;let n=t.payload;if(!n||n.type!==`sudo-request`)return!1;let r=n.request;return!!r&&typeof r.kind==`string`&&typeof r.detail==`string`}var l=e(`sudo:page`),u=null;function d(e){u=e}async function f(e){let t=u;if(!t)return null;let n=!1;try{n=t.shouldDelegate()}catch(e){l.warn(`tray delegate probe threw — treating as not delegable`,{error:e instanceof Error?e.message:String(e)})}if(!n)return null;try{return{decision:await t.requestApproval(e),handled:!0}}catch(e){return l.warn(`tray-delegated sudo approval threw — denying`,{error:e instanceof Error?e.message:String(e)}),{decision:{decision:`deny`},handled:!0}}}async function p(e,t){try{return{decision:t(e),handled:!0}}catch(e){return l.warn(`in-page sudo prompt threw — denying`,{error:e instanceof Error?e.message:String(e)}),{decision:{decision:`deny`},handled:!0}}}async function m(e,n=`resolve`,r={}){let i=await f(e);if(i)return i;let a=r.hasLocalNodeServer??t;return n===`tray-first`&&a()?{decision:{decision:`deny`},handled:!1}:p(e,r.nativeResolve??o)}export{o as n,n as r,m as resolveSudoApprovalInPage,d as setSudoTrayDelegate,s as t};