sliccy 6.210.1 → 6.211.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/dist/ui/.vite/manifest.json +186 -186
  2. package/dist/ui/assets/SKILL-lcwLWMKp.js +1 -0
  3. package/dist/ui/assets/{account-store-BXs7YUd1.js → account-store-CwNcf5Wq.js} +1 -1
  4. package/dist/ui/assets/{account-store-Bj2sWuL9.js → account-store-nlKbTUhJ.js} +1 -1
  5. package/dist/ui/assets/{adobe-F-IKKOJO.js → adobe-D7sqH2X_.js} +1 -1
  6. package/dist/ui/assets/{adobe-DtoNpFL2.js → adobe-DBVa9oOG.js} +1 -1
  7. package/dist/ui/assets/{agent-panels-CVsqg2-h.js → agent-panels-B0VuA3mU.js} +1 -1
  8. package/dist/ui/assets/{almost-bash-shell-headless-CH7VDHBB.js → almost-bash-shell-headless-C0x2DyFh.js} +508 -508
  9. package/dist/ui/assets/{apply-layout-FFHCB9bO.js → apply-layout-fciODM2t.js} +1 -1
  10. package/dist/ui/assets/{apps-BJzl3RZW.js → apps-RVxpwEfn.js} +1 -1
  11. package/dist/ui/assets/{azure-openai-CpRQdIQb.js → azure-openai-JxdRj-Iq.js} +1 -1
  12. package/dist/ui/assets/{azure-openai-BLEG5MlZ.js → azure-openai-QS8TU-7m.js} +1 -1
  13. package/dist/ui/assets/{backend-hostfs-DZyH5GFZ.js → backend-hostfs-CITljQVo.js} +1 -1
  14. package/dist/ui/assets/bedrock-camp-extra-models-BTmBqN9L.js +1 -0
  15. package/dist/ui/assets/bedrock-camp-extra-models-Dg0hblqu.js +1 -0
  16. package/dist/ui/assets/{bsh-watchdog-CqfihC2k.js → bsh-watchdog-BTB0exmo.js} +1 -1
  17. package/dist/ui/assets/{cdp-DwsDXLhg.js → cdp-Djm-AVXd.js} +1 -1
  18. package/dist/ui/assets/{cerebras-gnXcXmk7.js → cerebras-Czq0QoYg.js} +1 -1
  19. package/dist/ui/assets/{cerebras-CnpcT2_8.js → cerebras-DvIFsdoW.js} +1 -1
  20. package/dist/ui/assets/{composer-speech-BURN-dPW.js → composer-speech-DgLXFFNQ.js} +1 -1
  21. package/dist/ui/assets/{connect-surface-D0BfSkwe.js → connect-surface-YjzKwUub.js} +1 -1
  22. package/dist/ui/assets/{core-Dj0t7hQO.js → core-C7UGykIC.js} +1 -1
  23. package/dist/ui/assets/{directed-approval-BWqIdB9e.js → directed-approval-BMnSWjrJ.js} +1 -1
  24. package/dist/ui/assets/{emscripten-vfs-hook-Boy5xq-Z.js → emscripten-vfs-hook-CwbQLP-I.js} +1 -1
  25. package/dist/ui/assets/ensure-speech-assets-Bqf-swhU.js +1 -0
  26. package/dist/ui/assets/{esbuild-wasm-C-mKofIl.js → esbuild-wasm-DIcMVR3g.js} +1 -1
  27. package/dist/ui/assets/ffmpeg-wasm-B5jofhIa.js +1 -0
  28. package/dist/ui/assets/{frozen-archive-writer-o7ImcSbe.js → frozen-archive-writer-BV51qDTg.js} +1 -1
  29. package/dist/ui/assets/{fs-C7Qh7l0E.js → fs-ZnsLbva1.js} +1 -1
  30. package/dist/ui/assets/{fs-BaM5oYgh.js → fs-pBJBtnUm.js} +2 -2
  31. package/dist/ui/assets/{gelatiere-store-BkPyZ5mV.js → gelatiere-store-B-PMFWOJ.js} +1 -1
  32. package/dist/ui/assets/{gelatiere-unit-BYlMZ2v4.js → gelatiere-unit-B7YUbTOe.js} +1 -1
  33. package/dist/ui/assets/{github-N-Ega4Po.js → github-CRKKUq6c.js} +1 -1
  34. package/dist/ui/assets/{github-auth-DvbRhyIc.js → github-auth-DPBopdHy.js} +1 -1
  35. package/dist/ui/assets/{github-copilot-C2Lk0xfw.js → github-copilot-BOqjn_pA.js} +1 -1
  36. package/dist/ui/assets/{github-copilot-CCvuY9BS.js → github-copilot-Cn5WeEVQ.js} +1 -1
  37. package/dist/ui/assets/{github-install-DPTw6LV_.js → github-install-Dlx1x9oP.js} +1 -1
  38. package/dist/ui/assets/{github-D0VXVUSM.js → github-q7aLpavT.js} +2 -2
  39. package/dist/ui/assets/{github-zip-Bbft7vZj.js → github-zip-BKesEE7T.js} +1 -1
  40. package/dist/ui/assets/{guest-tool-gate-C3mMUKtL.js → guest-tool-gate-DbuM_BFG.js} +1 -1
  41. package/dist/ui/assets/{hear-l_e8vu4Q.js → hear-BAlAHUln.js} +1 -1
  42. package/dist/ui/assets/{help-C5uNreTt.js → help-MPD6QjSi.js} +1 -1
  43. package/dist/ui/assets/installer-DR7izkMG.js +2 -0
  44. package/dist/ui/assets/{interrupted-work-recovery-D5TFE2JG.js → interrupted-work-recovery-DKlfO3Dk.js} +1 -1
  45. package/dist/ui/assets/{ipk-mamba-CvGbcFF_.js → ipk-mamba-B7DsVAHB.js} +1 -1
  46. package/dist/ui/assets/{js-realm-worker-BFJHUvlI.js → js-realm-worker-Dj6E7cem.js} +2 -2
  47. package/dist/ui/assets/jsh-executor-DOTwZy5W.js +18 -0
  48. package/dist/ui/assets/{kernel-worker-BzcdrkzF.js → kernel-worker-C6evRbt8.js} +53 -53
  49. package/dist/ui/assets/{lick-ws-bridge-B248zI2U.js → lick-ws-bridge-DEO3vHuX.js} +1 -1
  50. package/dist/ui/assets/{lick-ws-bridge-CodIkT51.js → lick-ws-bridge-cpYoem5_.js} +1 -1
  51. package/dist/ui/assets/{live-session-curation-vrJYxCgm.js → live-session-curation-BM8tZX-r.js} +1 -1
  52. package/dist/ui/assets/{live-session-snapshot-lJ3w4rOH.js → live-session-snapshot-C2NMVRMF.js} +1 -1
  53. package/dist/ui/assets/{local-llm-vgDCJvkZ.js → local-llm-Cfh9VuPq.js} +1 -1
  54. package/dist/ui/assets/{local-llm-dkgrXktX.js → local-llm-z-cBJlKf.js} +1 -1
  55. package/dist/ui/assets/{magick-wasm-qrxQJP5k.js → magick-wasm-agWGi-e0.js} +1 -1
  56. package/dist/ui/assets/{main-cherry-sfCt3gLL.js → main-cherry-CbQUCau8.js} +1 -1
  57. package/dist/ui/assets/{main-CXeU8DQz.js → main-tEtVPbXh.js} +3 -3
  58. package/dist/ui/assets/{memory-curation-seam-T4WRfl1n.js → memory-curation-seam-CjBglHNa.js} +1 -1
  59. package/dist/ui/assets/{memory-health-EXXqHw1x.js → memory-health-CPzWzT1P.js} +1 -1
  60. package/dist/ui/assets/{memory-write-execute-DIYIwJKg.js → memory-write-execute-DqWqBfwf.js} +1 -1
  61. package/dist/ui/assets/{merge-folded-cost-into-frozen-bDakT1WR.js → merge-folded-cost-into-frozen-DCuPhNTk.js} +1 -1
  62. package/dist/ui/assets/{mount-C7dlV4rl.js → mount-4dZRjkrQ.js} +1 -1
  63. package/dist/ui/assets/{mount-BABm_hJd.js → mount-ydk0WHgG.js} +3 -3
  64. package/dist/ui/assets/{new-session-D2rtUiOZ.js → new-session-C5MEP_cK.js} +2 -2
  65. package/dist/ui/assets/{oauth-bootstrap-3P5XkiLD.js → oauth-bootstrap-BVUK3GEs.js} +2 -2
  66. package/dist/ui/assets/{onboarding-orchestrator-CYP3TBxO.js → onboarding-orchestrator-DftSEsKa.js} +1 -1
  67. package/dist/ui/assets/{openai-codex-CUa5FPoQ.js → openai-codex-Cwz1FT-z.js} +1 -1
  68. package/dist/ui/assets/{openai-codex-DvxYitk6.js → openai-codex-fJtQGV69.js} +1 -1
  69. package/dist/ui/assets/{openrouter-BxUHkfTR.js → openrouter-DmEz5WxK.js} +1 -1
  70. package/dist/ui/assets/{openrouter-free-nn_h_WC_.js → openrouter-free-C5O97xvy.js} +1 -1
  71. package/dist/ui/assets/{openrouter-free-BCIYdkt3.js → openrouter-free-DRw-DHQn.js} +1 -1
  72. package/dist/ui/assets/{openrouter-oauth-Bba1qXT3.js → openrouter-oauth-C4uIzDcA.js} +1 -1
  73. package/dist/ui/assets/{openrouter-oauth-8cwBPqX7.js → openrouter-oauth-Csq32wt2.js} +1 -1
  74. package/dist/ui/assets/{openrouter-Btmqh3ZY.js → openrouter-rcqoBXaw.js} +1 -1
  75. package/dist/ui/assets/{opfs-mount-DbON63F4.js → opfs-mount-C0Lus0Cz.js} +1 -1
  76. package/dist/ui/assets/{panel-rpc-handlers-aqHjP3Jn.js → panel-rpc-handlers-B9LenTR0.js} +2 -2
  77. package/dist/ui/assets/{panelize-shell-CjtBTrHH.js → panelize-shell-Dzogbbfc.js} +1 -1
  78. package/dist/ui/assets/{pi-edit-execution-DFk-ThoQ.js → pi-edit-execution-D9D4FDIQ.js} +1 -1
  79. package/dist/ui/assets/{provider-DFROVc_U.js → provider-CTPdODd7.js} +1 -1
  80. package/dist/ui/assets/{provider-B7Epu3fA.js → provider-Do-gc4OB.js} +2 -2
  81. package/dist/ui/assets/{provider-settings-WmZqlEWG.js → provider-settings-DzDdkFMx.js} +1 -1
  82. package/dist/ui/assets/provider-store-access-BbvRUwZT.js +1 -0
  83. package/dist/ui/assets/provider-store-access-CrrW9eCi.js +1 -0
  84. package/dist/ui/assets/{providers-CUOgmyqw.js → providers-1_CCXdq3.js} +2 -2
  85. package/dist/ui/assets/{providers-CnFwVWZQ.js → providers-BdG-aC29.js} +1 -1
  86. package/dist/ui/assets/{quick-llm-TyBh96Nl.js → quick-llm-B07QXQ0s.js} +1 -1
  87. package/dist/ui/assets/{realm-inprocess-DtJhD5Fl.js → realm-inprocess-wC9VuVQf.js} +2 -2
  88. package/dist/ui/assets/{realm-unhandled-rejections-DgtQR_nu.js → realm-unhandled-rejections-CEAHL08q.js} +1 -1
  89. package/dist/ui/assets/{realm-unhandled-rejections-vs4_4-j5.js → realm-unhandled-rejections-CuAh-NpD.js} +1 -1
  90. package/dist/ui/assets/{recovery-screen-DCebt00Y.js → recovery-screen-mPjIBgPH.js} +1 -1
  91. package/dist/ui/assets/{remote-terminal-view-hFKpOJq6.js → remote-terminal-view-DTmUlQlW.js} +2 -2
  92. package/dist/ui/assets/{require-guards-Bo27pPOL.js → require-guards-CyhsDWYg.js} +1 -1
  93. package/dist/ui/assets/resolver-BjX48SSL.js +4 -0
  94. package/dist/ui/assets/{restore-zcvXidEG.js → restore-BSMRZD-l.js} +1 -1
  95. package/dist/ui/assets/{run-D_M6FYKF.js → run-BSt_FVlm.js} +2 -2
  96. package/dist/ui/assets/{run-CuBHWlsa.js → run-BoxCVicT.js} +2 -2
  97. package/dist/ui/assets/{run-CS2W694M.js → run-C8OfqJcF.js} +2 -2
  98. package/dist/ui/assets/{run-Q7BN7qk3.js → run-CJfA-Obt.js} +1 -1
  99. package/dist/ui/assets/{run-UiQipOb7.js → run-CM8a7Cc3.js} +1 -1
  100. package/dist/ui/assets/{run-Cd_VCcVf.js → run-CjBpwwpL.js} +1 -1
  101. package/dist/ui/assets/{run-DjxRQ23G.js → run-CyMKLTKU.js} +1 -1
  102. package/dist/ui/assets/{run-C2DCKniQ.js → run-DMO7-CuA.js} +1 -1
  103. package/dist/ui/assets/{run-BV9MB7ra.js → run-KLXVoIYy.js} +1 -1
  104. package/dist/ui/assets/run-Y1uUJvV7.js +14 -0
  105. package/dist/ui/assets/{screencapture-run-CBm4TDjf.js → screencapture-run-C3Y7V44Z.js} +1 -1
  106. package/dist/ui/assets/{session-command-memory-CcaZsaLQ.js → session-command-memory-D9pTlYAY.js} +2 -2
  107. package/dist/ui/assets/{session-jsonl-DmxnjLdx.js → session-jsonl-AoJrx9pb.js} +1 -1
  108. package/dist/ui/assets/{session-jsonl-BmGkCWUz.js → session-jsonl-CJzYIghQ.js} +1 -1
  109. package/dist/ui/assets/{session-search-index-KJ0_eoRM.js → session-search-index-qOmoZUJy.js} +1 -1
  110. package/dist/ui/assets/{setup-feature-flags-remote-C803V0VC.js → setup-feature-flags-remote-BKACONdE.js} +1 -1
  111. package/dist/ui/assets/{setup-model-catalog-bxrNmkOq.js → setup-model-catalog-WWCUCy79.js} +1 -1
  112. package/dist/ui/assets/shared-Crk4gYF8.js +1 -0
  113. package/dist/ui/assets/{signed-fetch-CK_GPwxJ.js → signed-fetch-CwZ1-qSJ.js} +1 -1
  114. package/dist/ui/assets/{silent-renew-backoff-CWJs245J.js → silent-renew-backoff-L4eA7UKO.js} +1 -1
  115. package/dist/ui/assets/slicc-version-jRBuHQmT.js +1 -0
  116. package/dist/ui/assets/{snapshot-CcXAgR24.js → snapshot-D4DlVVCr.js} +1 -1
  117. package/dist/ui/assets/{snapshot-features-Bb6rt3T9.js → snapshot-features-Cp2XSvVD.js} +1 -1
  118. package/dist/ui/assets/{soundscape-DWkIHoSH.js → soundscape-CcHroDUu.js} +1 -1
  119. package/dist/ui/assets/{speak-bIrefGJW.js → speak-5UMXEj6t.js} +1 -1
  120. package/dist/ui/assets/{sprinkle-manager-HaLL6TAH.js → sprinkle-manager-ByfWs52B.js} +1 -1
  121. package/dist/ui/assets/{sprinkle-renderer-CH7z9LWi.js → sprinkle-renderer-Dw0Oo-mB.js} +1 -1
  122. package/dist/ui/assets/{ssh-HG-JzaxD.js → ssh-ChyTtRdf.js} +1 -1
  123. package/dist/ui/assets/{state-y36olpuJ.js → state-BPcLy39T.js} +1 -1
  124. package/dist/ui/assets/{store-DI5uS3CV.js → store-BA5jRQLQ.js} +1 -1
  125. package/dist/ui/assets/{store-Dy2vvTSi.js → store-BCOFBOmf.js} +1 -1
  126. package/dist/ui/assets/{sudo-7nF2-79o.js → sudo-CZL3U0lj.js} +1 -1
  127. package/dist/ui/assets/{supervisor-CEG_pawR.js → supervisor-n5AQXVdz.js} +1 -1
  128. package/dist/ui/assets/{sync-dialog-B28jW7rW.js → sync-dialog-CLv-AjS5.js} +1 -1
  129. package/dist/ui/assets/{transformers-env-G9ZvPj4i.js → transformers-env-DuP48CFD.js} +1 -1
  130. package/dist/ui/assets/{tray-leader-CxQceUY8.js → tray-leader-oK24Tenu.js} +1 -1
  131. package/dist/ui/assets/{tray-leave-runtime-B7ePnPKy.js → tray-leave-runtime-BtmhGDJl.js} +1 -1
  132. package/dist/ui/assets/{tray-sidecar-BlpsBLlK.js → tray-sidecar-x9PQcB2n.js} +1 -1
  133. package/dist/ui/assets/{turn-journal-aW8ez41d.js → turn-journal-CScxev4H.js} +1 -1
  134. package/dist/ui/assets/{upgrade-detection-BpdjDhSG.js → upgrade-detection-DS5evAII.js} +1 -1
  135. package/dist/ui/assets/{upskill-lick-skip-DLAifByM.js → upskill-lick-skip-DsgHyVv5.js} +1 -1
  136. package/dist/ui/assets/{voice-reply-DERl1Bi0.js → voice-reply-ebSU1_qk.js} +1 -1
  137. package/dist/ui/assets/{wc-attach-DTYFvNFe.js → wc-attach-525SvDTY.js} +2 -2
  138. package/dist/ui/assets/{wc-browser-CfT_4eXt.js → wc-browser-BWykEy-8.js} +1 -1
  139. package/dist/ui/assets/{wc-computers-CZzSDuty.js → wc-computers-D3Avqz55.js} +1 -1
  140. package/dist/ui/assets/{wc-detached-C-E9uOpQ.js → wc-detached-Cy1E6He4.js} +1 -1
  141. package/dist/ui/assets/{wc-extension-dtGYhAVK.js → wc-extension-CVhWXV2w.js} +2 -2
  142. package/dist/ui/assets/{wc-follower-gU-qxutC.js → wc-follower-C1kJ0lF_.js} +3 -3
  143. package/dist/ui/assets/{wc-follower-oauth-BGkJQhXu.js → wc-follower-oauth-qqfI5zJ5.js} +1 -1
  144. package/dist/ui/assets/{wc-gelatiere-Bwy-mfMy.js → wc-gelatiere-DFV5mBJW.js} +1 -1
  145. package/dist/ui/assets/{wc-live-DOg7ifPs.js → wc-live-Eu6ghZAo.js} +5 -5
  146. package/dist/ui/assets/{wc-nav-Dwr_mhPy.js → wc-nav-BJ1Fg_hB.js} +2 -2
  147. package/dist/ui/assets/{wc-onboarding-BE9A-Amw.js → wc-onboarding-D_k6jMGA.js} +2 -2
  148. package/dist/ui/assets/{wc-permissions-BloJ3nhv.js → wc-permissions-CbwZeya-.js} +2 -2
  149. package/dist/ui/assets/{wc-placeholder-C4vxqDp9.js → wc-placeholder-DzHKpyEK.js} +3 -3
  150. package/dist/ui/assets/{wc-secret-request-BgFU3Vv4.js → wc-secret-request-bOcP6m9U.js} +1 -1
  151. package/dist/ui/assets/{wc-settings-D4tUKiOo.js → wc-settings-BNekAbpv.js} +3 -3
  152. package/dist/ui/assets/{wc-shell-DWs7UK-n.js → wc-shell-DdE40qZj.js} +3 -3
  153. package/dist/ui/assets/{wc-shortcut-config-DVN2gtoP.js → wc-shortcut-config-KdvTJp27.js} +1 -1
  154. package/dist/ui/assets/{wc-sprinkles-DKpkBiOU.js → wc-sprinkles-Bnnb88mU.js} +2 -2
  155. package/dist/ui/assets/{wc-transcript-export-BIr7xQ8r.js → wc-transcript-export-DWOEgP2-.js} +2 -2
  156. package/dist/ui/assets/{wc-tray-CPoilaMn.js → wc-tray-Dpx-EoMd.js} +4 -4
  157. package/dist/ui/assets/welcome-detection-BdEfH_d7.js +1 -0
  158. package/dist/ui/assets/{whisper-session-CjnOyfPM.js → whisper-session-CB6rG-eD.js} +2 -2
  159. package/dist/ui/assets/{xai-grok-CKBHF5WO.js → xai-grok-BGPDFi9z.js} +1 -1
  160. package/dist/ui/assets/{xai-grok-CsjlfFq3.js → xai-grok-CuIlQYpM.js} +1 -1
  161. package/dist/ui/index.html +4 -4
  162. package/dist/ui/packages/webapp/index.html +4 -4
  163. package/package.json +1 -1
  164. package/dist/ui/assets/SKILL-BmcnfP14.js +0 -1
  165. package/dist/ui/assets/bedrock-camp-extra-models-D9acqHGZ.js +0 -1
  166. package/dist/ui/assets/bedrock-camp-extra-models-DdOiIiaZ.js +0 -1
  167. package/dist/ui/assets/ensure-speech-assets-CzLCdx9h.js +0 -1
  168. package/dist/ui/assets/ffmpeg-wasm-DsXD0tX2.js +0 -1
  169. package/dist/ui/assets/installer-BidZuNnC.js +0 -2
  170. package/dist/ui/assets/jsh-executor-B4ySdjop.js +0 -18
  171. package/dist/ui/assets/provider-store-access-XxfYiVq-.js +0 -1
  172. package/dist/ui/assets/provider-store-access-bqTWCaz8.js +0 -1
  173. package/dist/ui/assets/run-2WVtdZpl.js +0 -8
  174. package/dist/ui/assets/shared-De1sMYMX.js +0 -4
  175. package/dist/ui/assets/slicc-version-Da6sXKjo.js +0 -1
  176. package/dist/ui/assets/welcome-detection-B8xTkXMq.js +0 -1
@@ -1 +1 @@
1
- import{CHAT_SURFACE_ID as e}from"./wc-sprinkles-DKpkBiOU.js";var t=`focus`,n={type:`leaf`,surfaceId:`chat`};function r(e,t={},n={}){return{zones:{top:null,left:null,middle:null,right:null,bottom:null,...e},rowFr:{top:1,center:1,bottom:1,...n},colFr:{left:1,middle:1,right:1,...t}}}var i={focus:{name:`focus`,tree:r({left:n},{left:3,middle:1})}};function a(e){return i[e]??null}function o(n,r){switch(r.kind){case`set`:n.applyLayout(r.tree);break;case`reset`:{let e=a(t);e&&n.applyLayout(e.tree);break}case`chat`:n.moveSurfaceToZone(e,r.zone);break;case`open`:n.placeSurface(r.zone,r.surfaceId);break;case`close`:n.removeSurface(r.surfaceId);break;case`move`:n.moveSurfaceToZone(r.surfaceId,r.zone);break;case`size`:n.setSurfaceSize(r.surfaceId,r.size)}}export{o as applyLayout};
1
+ import{CHAT_SURFACE_ID as e}from"./wc-sprinkles-Bnnb88mU.js";var t=`focus`,n={type:`leaf`,surfaceId:`chat`};function r(e,t={},n={}){return{zones:{top:null,left:null,middle:null,right:null,bottom:null,...e},rowFr:{top:1,center:1,bottom:1,...n},colFr:{left:1,middle:1,right:1,...t}}}var i={focus:{name:`focus`,tree:r({left:n},{left:3,middle:1})}};function a(e){return i[e]??null}function o(n,r){switch(r.kind){case`set`:n.applyLayout(r.tree);break;case`reset`:{let e=a(t);e&&n.applyLayout(e.tree);break}case`chat`:n.moveSurfaceToZone(e,r.zone);break;case`open`:n.placeSurface(r.zone,r.surfaceId);break;case`close`:n.removeSurface(r.surfaceId);break;case`move`:n.moveSurfaceToZone(r.surfaceId,r.zone);break;case`size`:n.setSurfaceSize(r.surfaceId,r.size)}}export{o as applyLayout};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import{t}from"./slugify-BYJ6QVAt.js";import{t as n}from"./types-D8gIX-W-.js";import{t as r}from"./html-B_Hg2WOy.js";import{t as i}from"./global-db-DJXlpNui.js";const a=e(`mcp-apps`),o=`/workspace/.mcp/sprinkles`;async function s(e){if(e)return e;let{VirtualFS:t}=await import(`./fs-C7Qh7l0E.js`).then(e=>e.t);return await t.create({dbName:i})}function c(e){return t(e,{maxLen:64,fallback:`app`})}function l(e,t){let n=r(t.title??t.name),i=t.description?r(t.description):``,a=r(t.templateUri??`about:blank`),o=JSON.stringify(e),s=JSON.stringify(t.name);return`<div class="mcp-app" data-sprinkle-title="${n}" style="display:flex;flex-direction:column;height:100%;min-height:0;">
1
+ import{t as e}from"./logger-LESFN7Hj.js";import{t}from"./slugify-BYJ6QVAt.js";import{t as n}from"./types-D8gIX-W-.js";import{t as r}from"./html-B_Hg2WOy.js";import{t as i}from"./global-db-DJXlpNui.js";const a=e(`mcp-apps`),o=`/workspace/.mcp/sprinkles`;async function s(e){if(e)return e;let{VirtualFS:t}=await import(`./fs-ZnsLbva1.js`).then(e=>e.t);return await t.create({dbName:i})}function c(e){return t(e,{maxLen:64,fallback:`app`})}function l(e,t){let n=r(t.title??t.name),i=t.description?r(t.description):``,a=r(t.templateUri??`about:blank`),o=JSON.stringify(e),s=JSON.stringify(t.name);return`<div class="mcp-app" data-sprinkle-title="${n}" style="display:flex;flex-direction:column;height:100%;min-height:0;">
2
2
  <header class="mcp-app__header" style="padding:8px 12px;border-bottom:1px solid var(--s2-border-subtle,#3a3a3a);">
3
3
  <h2 style="font-size:14px;font-weight:600;margin:0;">${n}</h2>${i?`\n <p style="font-size:12px;margin:4px 0 0;color:var(--s2-content-secondary,#a0a0a0);">${i}</p>`:``}
4
4
  </header>
@@ -1,4 +1,4 @@
1
- import{c as e,o as t}from"./account-store-BXs7YUd1.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{t as r}from"./models-4WTk3EBD.js";import{a as i}from"./compat-uEPf6-XW.js";import{r as a,t as o}from"./transform-messages-Jn8bw4-u.js";function s(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function c(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}let l=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return l=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function u(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}const d=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};var f=class extends Error{},p=class e extends f{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`x-request-id`),this.error=n;let a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new h({message:r,cause:d(n)});let a=n?.error;return t===400?new _(t,a,r,i):t===401?new v(t,a,r,i):t===403?new y(t,a,r,i):t===404?new b(t,a,r,i):t===409?new x(t,a,r,i):t===422?new ee(t,a,r,i):t===429?new te(t,a,r,i):t>=500?new ne(t,a,r,i):new e(t,a,r,i)}},m=class extends p{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},h=class extends p{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},g=class extends h{constructor({message:e}={}){super({message:e??`Request timed out.`})}},_=class extends p{},v=class extends p{},y=class extends p{},b=class extends p{},x=class extends p{},ee=class extends p{},te=class extends p{},ne=class extends p{},re=class extends f{constructor(){super(`Could not parse response content as the length limit was reached`)}},ie=class extends f{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},ae=class extends Error{constructor(e){super(e)}},oe=class extends p{constructor(e,t,n){let r=`OAuth2 authentication error`,i;if(t&&typeof t==`object`){let e=t;i=e.error;let n=e.error_description;n&&typeof n==`string`?r=n:i&&(r=i)}super(e,t,r,n),this.error_code=i}},se=class extends f{constructor(e,t,n){super(e),this.provider=t,this.cause=n}};const ce=/^[a-z][a-z0-9+.-]*:/i,le=e=>ce.test(e);let S=e=>(S=Array.isArray,S(e)),ue=S;function de(e){return typeof e==`object`?e??{}:{}}function fe(e){if(!e)return!0;for(let t in e)return!1;return!0}function pe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const me=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new f(`${e} must be an integer`);if(t<0)throw new f(`${e} must be a positive integer`);return t},he=e=>{try{return JSON.parse(e)}catch{return}},ge=e=>new Promise(t=>setTimeout(t,e));function _e(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function ve(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function ye(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return ve({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function be(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function xe(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}let Se;function w(e){let t;return(Se??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}let Ce;function we(e){let t;return(Ce??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var Te,T,E,D,O,Ee,De;const Oe=65536;var ke=class{constructor(){Te.add(this),T.set(this,void 0),E.set(this,void 0),D.set(this,void 0),O.set(this,void 0),Ee.set(this,void 0),s(this,T,new Uint8Array,`f`),s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),s(this,Ee,!1,`f`)}decode(e){if(e==null)return[];let t;if(t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?w(e):e,t.length===0||c(this,Ee,`f`)&&(s(this,Ee,!1,`f`),t[0]===10&&(t=t.subarray(1)),t.length===0))return[];c(this,Te,`m`,De).call(this,t);let n=[],r;for(;(r=Ae(c(this,T,`f`),c(this,O,`f`),c(this,D,`f`)))!=null;){let e=we(c(this,T,`f`).subarray(c(this,E,`f`),r.preceding));n.push(e),s(this,E,r.index,`f`),r.carriage&&(c(this,E,`f`)<c(this,D,`f`)&&c(this,T,`f`)[c(this,E,`f`)]===10?s(this,E,c(this,E,`f`)+1,`f`):c(this,E,`f`)===c(this,D,`f`)&&s(this,Ee,!0,`f`)),s(this,O,c(this,E,`f`),`f`)}if(s(this,O,c(this,D,`f`),`f`),c(this,E,`f`)===c(this,D,`f`))s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),c(this,T,`f`).length>Oe&&s(this,T,new Uint8Array,`f`);else if(n.length>0&&c(this,T,`f`).length>Oe){let e=c(this,D,`f`)-c(this,E,`f`);if(e<=Oe||c(this,T,`f`).length>e*4){let t=e<=Oe?Math.min(Math.max(e*2,256),Oe):e*2,n=new Uint8Array(t);n.set(c(this,T,`f`).subarray(c(this,E,`f`),c(this,D,`f`))),s(this,T,n,`f`),s(this,E,0,`f`),s(this,D,e,`f`),s(this,O,e,`f`)}}return n}flush(){return s(this,Ee,!1,`f`),c(this,E,`f`)===c(this,D,`f`)?[]:this.decode(`
1
+ import{c as e,o as t}from"./account-store-CwNcf5Wq.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{t as r}from"./models-4WTk3EBD.js";import{a as i}from"./compat-uEPf6-XW.js";import{r as a,t as o}from"./transform-messages-Jn8bw4-u.js";function s(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function c(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}let l=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return l=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function u(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}const d=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};var f=class extends Error{},p=class e extends f{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`x-request-id`),this.error=n;let a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new h({message:r,cause:d(n)});let a=n?.error;return t===400?new _(t,a,r,i):t===401?new v(t,a,r,i):t===403?new y(t,a,r,i):t===404?new b(t,a,r,i):t===409?new x(t,a,r,i):t===422?new ee(t,a,r,i):t===429?new te(t,a,r,i):t>=500?new ne(t,a,r,i):new e(t,a,r,i)}},m=class extends p{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},h=class extends p{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},g=class extends h{constructor({message:e}={}){super({message:e??`Request timed out.`})}},_=class extends p{},v=class extends p{},y=class extends p{},b=class extends p{},x=class extends p{},ee=class extends p{},te=class extends p{},ne=class extends p{},re=class extends f{constructor(){super(`Could not parse response content as the length limit was reached`)}},ie=class extends f{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},ae=class extends Error{constructor(e){super(e)}},oe=class extends p{constructor(e,t,n){let r=`OAuth2 authentication error`,i;if(t&&typeof t==`object`){let e=t;i=e.error;let n=e.error_description;n&&typeof n==`string`?r=n:i&&(r=i)}super(e,t,r,n),this.error_code=i}},se=class extends f{constructor(e,t,n){super(e),this.provider=t,this.cause=n}};const ce=/^[a-z][a-z0-9+.-]*:/i,le=e=>ce.test(e);let S=e=>(S=Array.isArray,S(e)),ue=S;function de(e){return typeof e==`object`?e??{}:{}}function fe(e){if(!e)return!0;for(let t in e)return!1;return!0}function pe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const me=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new f(`${e} must be an integer`);if(t<0)throw new f(`${e} must be a positive integer`);return t},he=e=>{try{return JSON.parse(e)}catch{return}},ge=e=>new Promise(t=>setTimeout(t,e));function _e(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function ve(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function ye(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return ve({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function be(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function xe(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}let Se;function w(e){let t;return(Se??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}let Ce;function we(e){let t;return(Ce??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var Te,T,E,D,O,Ee,De;const Oe=65536;var ke=class{constructor(){Te.add(this),T.set(this,void 0),E.set(this,void 0),D.set(this,void 0),O.set(this,void 0),Ee.set(this,void 0),s(this,T,new Uint8Array,`f`),s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),s(this,Ee,!1,`f`)}decode(e){if(e==null)return[];let t;if(t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?w(e):e,t.length===0||c(this,Ee,`f`)&&(s(this,Ee,!1,`f`),t[0]===10&&(t=t.subarray(1)),t.length===0))return[];c(this,Te,`m`,De).call(this,t);let n=[],r;for(;(r=Ae(c(this,T,`f`),c(this,O,`f`),c(this,D,`f`)))!=null;){let e=we(c(this,T,`f`).subarray(c(this,E,`f`),r.preceding));n.push(e),s(this,E,r.index,`f`),r.carriage&&(c(this,E,`f`)<c(this,D,`f`)&&c(this,T,`f`)[c(this,E,`f`)]===10?s(this,E,c(this,E,`f`)+1,`f`):c(this,E,`f`)===c(this,D,`f`)&&s(this,Ee,!0,`f`)),s(this,O,c(this,E,`f`),`f`)}if(s(this,O,c(this,D,`f`),`f`),c(this,E,`f`)===c(this,D,`f`))s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),c(this,T,`f`).length>Oe&&s(this,T,new Uint8Array,`f`);else if(n.length>0&&c(this,T,`f`).length>Oe){let e=c(this,D,`f`)-c(this,E,`f`);if(e<=Oe||c(this,T,`f`).length>e*4){let t=e<=Oe?Math.min(Math.max(e*2,256),Oe):e*2,n=new Uint8Array(t);n.set(c(this,T,`f`).subarray(c(this,E,`f`),c(this,D,`f`))),s(this,T,n,`f`),s(this,E,0,`f`),s(this,D,e,`f`),s(this,O,e,`f`)}}return n}flush(){return s(this,Ee,!1,`f`),c(this,E,`f`)===c(this,D,`f`)?[]:this.decode(`
2
2
  `)}};T=new WeakMap,E=new WeakMap,D=new WeakMap,O=new WeakMap,Ee=new WeakMap,Te=new WeakSet,De=function(e){if(c(this,D,`f`)+e.length>c(this,T,`f`).length){let t=c(this,D,`f`)-c(this,E,`f`);if(c(this,E,`f`)>=c(this,T,`f`).length/2&&t+e.length<=c(this,T,`f`).length)c(this,T,`f`).copyWithin(0,c(this,E,`f`),c(this,D,`f`));else{let n=Math.max(c(this,T,`f`).length*2,t+e.length,256),r=new Uint8Array(n);r.set(c(this,T,`f`).subarray(c(this,E,`f`),c(this,D,`f`))),s(this,T,r,`f`)}s(this,O,c(this,O,`f`)-c(this,E,`f`),`f`),s(this,D,t,`f`),s(this,E,0,`f`)}c(this,T,`f`).set(e,c(this,D,`f`)),s(this,D,c(this,D,`f`)+e.length,`f`)},ke.NEWLINE_CHARS=new Set([`
3
3
  `,`\r`]),ke.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Ae(e,t,n){for(let r=t;r<n;r++){if(e[r]===10)return{preceding:r,index:r+1,carriage:!1};if(e[r]===13)return{preceding:r,index:r+1,carriage:!0}}return null}function je(e){for(let t=0;t<e.length-1;t++){let n=Me(e,t);if(n>0){let r=t+n,i=Me(e,r);if(i>0)return r+i}}return-1}function Me(e,t){return e[t]===10?1:e[t]===13?e[t+1]===10?2:1:0}const Ne={off:0,error:200,warn:300,info:400,debug:500},Pe=(e,t,n)=>{if(e){if(pe(Ne,e))return e;k(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Ne))}`)}};function Fe(){}function Ie(e,t,n){return!t||Ne[e]>Ne[n]?Fe:t[e].bind(t)}const Le={error:Fe,warn:Fe,info:Fe,debug:Fe};let Re=new WeakMap;function k(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return Le;let r=Re.get(t);if(r&&r[0]===n)return r[1];let i={error:Ie(`error`,t,n),warn:Ie(`warn`,t,n),info:Ie(`info`,t,n),debug:Ie(`debug`,t,n)};return Re.set(t,[n,i]),i}const ze=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`authorization`||e.toLowerCase()===`api-key`||e.toLowerCase()===`x-api-key`||e.toLowerCase()===`x-amz-security-token`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t])),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);var Be,Ve=class e{constructor(e,t,n){Be.set(this,void 0),this.iterator=e,this.controller=t,s(this,Be,n,`f`)}static fromSSEResponse(t,n,r,i){let a=!1,o=r?k(r):console;async function*s(){if(a)throw new f("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");a=!0;let e=!1,r=!1;try{for await(let e of He(t,n)){if(e.data.startsWith(`[DONE]`)){r=!0;break}if(e.event===null||!e.event.startsWith(`thread.`)){let n;try{n=JSON.parse(e.data)}catch(t){throw o.error(`Could not parse message into JSON:`,e.data),o.error(`From chunk:`,e.raw),t}if(n&&n.error)throw new p(void 0,n.error,void 0,t.headers);yield i?{event:e.event,data:n}:n}else{let t;try{t=JSON.parse(e.data)}catch(t){throw console.error(`Could not parse message into JSON:`,e.data),console.error(`From chunk:`,e.raw),t}if(e.event===`error`)throw new p(void 0,t.error,t.message,void 0);yield{event:e.event,data:t}}}e=!0}catch(e){if(r||u(e)||n.signal.aborted&&e===n.signal.reason)return;throw e}finally{e||n.abort()}}return new e(s,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*a(){let e=new ke,r=t.getReader(),i=!1,a,o=()=>{a??=r.cancel(),a.catch(()=>void 0)};n.signal.addEventListener(`abort`,o,{once:!0});try{if(n.signal.aborted){o();return}for(;;){let{value:t,done:a}=await r.read();if(a){i=!0;break}if(n.signal.aborted)return;for(let r of e.decode(t)){if(n.signal.aborted)return;yield r}}if(n.signal.aborted)return;for(let t of e.flush()){if(n.signal.aborted)return;yield t}}finally{n.signal.removeEventListener(`abort`,o),i||o(),r.releaseLock()}}async function*o(){if(i)throw new f("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let t of a())e||t&&(yield JSON.parse(t));e=!0}catch(e){if(n.signal.aborted||u(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}[(Be=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=e=>({next:()=>{if(e.length===0){let e=r.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>i(t),this.controller,c(this,Be,`f`)),new e(()=>i(n),this.controller,c(this,Be,`f`))]}toReadableStream(){let e;return ve({start:async()=>{e=this[Symbol.asyncIterator]()},async pull(t){try{let{value:n,done:r}=await e.next();if(r)return t.close();let i=w(JSON.stringify(n)+`
4
4
  `);t.enqueue(i)}catch(e){t.error(e)}},async cancel(){await e.return?.()}})}};async function*He(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new f(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new f(`Attempted to iterate over a response with no body`);let n=new We,r=new ke,i=be(e.body);for await(let e of Ue(i))for(let t of r.decode(e)){let e=n.decode(t);e&&(yield e)}for(let e of r.flush()){let t=n.decode(e);t&&(yield t)}}async function*Ue(e){let t=new Uint8Array,n=0,r=0,i=0;for await(let a of e){if(a==null)continue;let e;if(e=a instanceof ArrayBuffer?new Uint8Array(a):typeof a==`string`?w(a):a,r+e.length>t.length){let a=r-n;if(n>=t.length/2&&a+e.length<=t.length)t.copyWithin(0,n,r);else{let i=new Uint8Array(Math.max(t.length*2,a+e.length));i.set(t.subarray(n,r)),t=i}i-=n,n=0,r=a}t.set(e,r),r+=e.length;let o;for(;(o=je(t.subarray(i,r)))!==-1;)o+=i,yield t.slice(n,o),n=o,i=n;i=Math.max(n,r-3)}r>n&&(yield t.slice(n,r))}var We=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.slice(0,-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(`
@@ -1,4 +1,4 @@
1
- import{a as e}from"./diagnostics-DN_idNHx.js";import{t}from"./models-YdybRRvT.js";import{a as n}from"./compat-Dy2zIWAW.js";import{S as r,v as i}from"./account-store-Bj2sWuL9.js";import{r as a,t as o}from"./transform-messages-BsQjTIEJ.js";function s(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function c(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var l=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return l=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function u(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var d=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)},f=class extends Error{},p=class e extends f{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`x-request-id`),this.error=n;let a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new h({message:r,cause:d(n)});let a=n?.error;return t===400?new _(t,a,r,i):t===401?new v(t,a,r,i):t===403?new y(t,a,r,i):t===404?new b(t,a,r,i):t===409?new x(t,a,r,i):t===422?new ee(t,a,r,i):t===429?new te(t,a,r,i):t>=500?new ne(t,a,r,i):new e(t,a,r,i)}},m=class extends p{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},h=class extends p{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},g=class extends h{constructor({message:e}={}){super({message:e??`Request timed out.`})}},_=class extends p{},v=class extends p{},y=class extends p{},b=class extends p{},x=class extends p{},ee=class extends p{},te=class extends p{},ne=class extends p{},re=class extends f{constructor(){super(`Could not parse response content as the length limit was reached`)}},ie=class extends f{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},ae=class extends Error{constructor(e){super(e)}},oe=class extends p{constructor(e,t,n){let r=`OAuth2 authentication error`,i;if(t&&typeof t==`object`){let e=t;i=e.error;let n=e.error_description;n&&typeof n==`string`?r=n:i&&(r=i)}super(e,t,r,n),this.error_code=i}},se=class extends f{constructor(e,t,n){super(e),this.provider=t,this.cause=n}},ce=/^[a-z][a-z0-9+.-]*:/i,le=e=>ce.test(e),S=e=>(S=Array.isArray,S(e)),ue=S;function de(e){return typeof e==`object`?e??{}:{}}function fe(e){if(!e)return!0;for(let t in e)return!1;return!0}function pe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var me=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new f(`${e} must be an integer`);if(t<0)throw new f(`${e} must be a positive integer`);return t},he=e=>{try{return JSON.parse(e)}catch{return}},ge=e=>new Promise(t=>setTimeout(t,e));function _e(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function ve(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function ye(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return ve({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function be(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function xe(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var Se;function w(e){let t;return(Se??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}var Ce;function we(e){let t;return(Ce??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var Te,T,E,D,O,Ee,De,Oe=65536,ke=class{constructor(){Te.add(this),T.set(this,void 0),E.set(this,void 0),D.set(this,void 0),O.set(this,void 0),Ee.set(this,void 0),s(this,T,new Uint8Array,`f`),s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),s(this,Ee,!1,`f`)}decode(e){if(e==null)return[];let t;if(t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?w(e):e,t.length===0||c(this,Ee,`f`)&&(s(this,Ee,!1,`f`),t[0]===10&&(t=t.subarray(1)),t.length===0))return[];c(this,Te,`m`,De).call(this,t);let n=[],r;for(;(r=Ae(c(this,T,`f`),c(this,O,`f`),c(this,D,`f`)))!=null;){let e=we(c(this,T,`f`).subarray(c(this,E,`f`),r.preceding));n.push(e),s(this,E,r.index,`f`),r.carriage&&(c(this,E,`f`)<c(this,D,`f`)&&c(this,T,`f`)[c(this,E,`f`)]===10?s(this,E,c(this,E,`f`)+1,`f`):c(this,E,`f`)===c(this,D,`f`)&&s(this,Ee,!0,`f`)),s(this,O,c(this,E,`f`),`f`)}if(s(this,O,c(this,D,`f`),`f`),c(this,E,`f`)===c(this,D,`f`))s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),c(this,T,`f`).length>Oe&&s(this,T,new Uint8Array,`f`);else if(n.length>0&&c(this,T,`f`).length>Oe){let e=c(this,D,`f`)-c(this,E,`f`);if(e<=Oe||c(this,T,`f`).length>e*4){let t=e<=Oe?Math.min(Math.max(e*2,256),Oe):e*2,n=new Uint8Array(t);n.set(c(this,T,`f`).subarray(c(this,E,`f`),c(this,D,`f`))),s(this,T,n,`f`),s(this,E,0,`f`),s(this,D,e,`f`),s(this,O,e,`f`)}}return n}flush(){return s(this,Ee,!1,`f`),c(this,E,`f`)===c(this,D,`f`)?[]:this.decode(`
1
+ import{a as e}from"./diagnostics-DN_idNHx.js";import{t}from"./models-YdybRRvT.js";import{a as n}from"./compat-Dy2zIWAW.js";import{S as r,v as i}from"./account-store-nlKbTUhJ.js";import{r as a,t as o}from"./transform-messages-BsQjTIEJ.js";function s(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function c(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var l=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return l=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function u(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var d=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)},f=class extends Error{},p=class e extends f{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`x-request-id`),this.error=n;let a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new h({message:r,cause:d(n)});let a=n?.error;return t===400?new _(t,a,r,i):t===401?new v(t,a,r,i):t===403?new y(t,a,r,i):t===404?new b(t,a,r,i):t===409?new x(t,a,r,i):t===422?new ee(t,a,r,i):t===429?new te(t,a,r,i):t>=500?new ne(t,a,r,i):new e(t,a,r,i)}},m=class extends p{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},h=class extends p{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},g=class extends h{constructor({message:e}={}){super({message:e??`Request timed out.`})}},_=class extends p{},v=class extends p{},y=class extends p{},b=class extends p{},x=class extends p{},ee=class extends p{},te=class extends p{},ne=class extends p{},re=class extends f{constructor(){super(`Could not parse response content as the length limit was reached`)}},ie=class extends f{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},ae=class extends Error{constructor(e){super(e)}},oe=class extends p{constructor(e,t,n){let r=`OAuth2 authentication error`,i;if(t&&typeof t==`object`){let e=t;i=e.error;let n=e.error_description;n&&typeof n==`string`?r=n:i&&(r=i)}super(e,t,r,n),this.error_code=i}},se=class extends f{constructor(e,t,n){super(e),this.provider=t,this.cause=n}},ce=/^[a-z][a-z0-9+.-]*:/i,le=e=>ce.test(e),S=e=>(S=Array.isArray,S(e)),ue=S;function de(e){return typeof e==`object`?e??{}:{}}function fe(e){if(!e)return!0;for(let t in e)return!1;return!0}function pe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var me=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new f(`${e} must be an integer`);if(t<0)throw new f(`${e} must be a positive integer`);return t},he=e=>{try{return JSON.parse(e)}catch{return}},ge=e=>new Promise(t=>setTimeout(t,e));function _e(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function ve(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function ye(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return ve({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function be(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function xe(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var Se;function w(e){let t;return(Se??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}var Ce;function we(e){let t;return(Ce??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var Te,T,E,D,O,Ee,De,Oe=65536,ke=class{constructor(){Te.add(this),T.set(this,void 0),E.set(this,void 0),D.set(this,void 0),O.set(this,void 0),Ee.set(this,void 0),s(this,T,new Uint8Array,`f`),s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),s(this,Ee,!1,`f`)}decode(e){if(e==null)return[];let t;if(t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?w(e):e,t.length===0||c(this,Ee,`f`)&&(s(this,Ee,!1,`f`),t[0]===10&&(t=t.subarray(1)),t.length===0))return[];c(this,Te,`m`,De).call(this,t);let n=[],r;for(;(r=Ae(c(this,T,`f`),c(this,O,`f`),c(this,D,`f`)))!=null;){let e=we(c(this,T,`f`).subarray(c(this,E,`f`),r.preceding));n.push(e),s(this,E,r.index,`f`),r.carriage&&(c(this,E,`f`)<c(this,D,`f`)&&c(this,T,`f`)[c(this,E,`f`)]===10?s(this,E,c(this,E,`f`)+1,`f`):c(this,E,`f`)===c(this,D,`f`)&&s(this,Ee,!0,`f`)),s(this,O,c(this,E,`f`),`f`)}if(s(this,O,c(this,D,`f`),`f`),c(this,E,`f`)===c(this,D,`f`))s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),c(this,T,`f`).length>Oe&&s(this,T,new Uint8Array,`f`);else if(n.length>0&&c(this,T,`f`).length>Oe){let e=c(this,D,`f`)-c(this,E,`f`);if(e<=Oe||c(this,T,`f`).length>e*4){let t=e<=Oe?Math.min(Math.max(e*2,256),Oe):e*2,n=new Uint8Array(t);n.set(c(this,T,`f`).subarray(c(this,E,`f`),c(this,D,`f`))),s(this,T,n,`f`),s(this,E,0,`f`),s(this,D,e,`f`),s(this,O,e,`f`)}}return n}flush(){return s(this,Ee,!1,`f`),c(this,E,`f`)===c(this,D,`f`)?[]:this.decode(`
2
2
  `)}};T=new WeakMap,E=new WeakMap,D=new WeakMap,O=new WeakMap,Ee=new WeakMap,Te=new WeakSet,De=function(e){if(c(this,D,`f`)+e.length>c(this,T,`f`).length){let t=c(this,D,`f`)-c(this,E,`f`);if(c(this,E,`f`)>=c(this,T,`f`).length/2&&t+e.length<=c(this,T,`f`).length)c(this,T,`f`).copyWithin(0,c(this,E,`f`),c(this,D,`f`));else{let n=Math.max(c(this,T,`f`).length*2,t+e.length,256),r=new Uint8Array(n);r.set(c(this,T,`f`).subarray(c(this,E,`f`),c(this,D,`f`))),s(this,T,r,`f`)}s(this,O,c(this,O,`f`)-c(this,E,`f`),`f`),s(this,D,t,`f`),s(this,E,0,`f`)}c(this,T,`f`).set(e,c(this,D,`f`)),s(this,D,c(this,D,`f`)+e.length,`f`)},ke.NEWLINE_CHARS=new Set([`
3
3
  `,`\r`]),ke.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Ae(e,t,n){for(let r=t;r<n;r++){if(e[r]===10)return{preceding:r,index:r+1,carriage:!1};if(e[r]===13)return{preceding:r,index:r+1,carriage:!0}}return null}function je(e){for(let t=0;t<e.length-1;t++){let n=Me(e,t);if(n>0){let r=t+n,i=Me(e,r);if(i>0)return r+i}}return-1}function Me(e,t){return e[t]===10?1:e[t]===13?e[t+1]===10?2:1:0}var Ne={off:0,error:200,warn:300,info:400,debug:500},Pe=(e,t,n)=>{if(e){if(pe(Ne,e))return e;k(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Ne))}`)}};function Fe(){}function Ie(e,t,n){return!t||Ne[e]>Ne[n]?Fe:t[e].bind(t)}var Le={error:Fe,warn:Fe,info:Fe,debug:Fe},Re=new WeakMap;function k(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return Le;let r=Re.get(t);if(r&&r[0]===n)return r[1];let i={error:Ie(`error`,t,n),warn:Ie(`warn`,t,n),info:Ie(`info`,t,n),debug:Ie(`debug`,t,n)};return Re.set(t,[n,i]),i}var ze=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`authorization`||e.toLowerCase()===`api-key`||e.toLowerCase()===`x-api-key`||e.toLowerCase()===`x-amz-security-token`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t])),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e),Be,Ve=class e{constructor(e,t,n){Be.set(this,void 0),this.iterator=e,this.controller=t,s(this,Be,n,`f`)}static fromSSEResponse(t,n,r,i){let a=!1,o=r?k(r):console;async function*s(){if(a)throw new f("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");a=!0;let e=!1,r=!1;try{for await(let e of He(t,n)){if(e.data.startsWith(`[DONE]`)){r=!0;break}if(e.event===null||!e.event.startsWith(`thread.`)){let n;try{n=JSON.parse(e.data)}catch(t){throw o.error(`Could not parse message into JSON:`,e.data),o.error(`From chunk:`,e.raw),t}if(n&&n.error)throw new p(void 0,n.error,void 0,t.headers);yield i?{event:e.event,data:n}:n}else{let t;try{t=JSON.parse(e.data)}catch(t){throw console.error(`Could not parse message into JSON:`,e.data),console.error(`From chunk:`,e.raw),t}if(e.event===`error`)throw new p(void 0,t.error,t.message,void 0);yield{event:e.event,data:t}}}e=!0}catch(e){if(r||u(e)||n.signal.aborted&&e===n.signal.reason)return;throw e}finally{e||n.abort()}}return new e(s,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*a(){let e=new ke,r=t.getReader(),i=!1,a,o=()=>{a??=r.cancel(),a.catch(()=>void 0)};n.signal.addEventListener(`abort`,o,{once:!0});try{if(n.signal.aborted){o();return}for(;;){let{value:t,done:a}=await r.read();if(a){i=!0;break}if(n.signal.aborted)return;for(let r of e.decode(t)){if(n.signal.aborted)return;yield r}}if(n.signal.aborted)return;for(let t of e.flush()){if(n.signal.aborted)return;yield t}}finally{n.signal.removeEventListener(`abort`,o),i||o(),r.releaseLock()}}async function*o(){if(i)throw new f("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let t of a())e||t&&(yield JSON.parse(t));e=!0}catch(e){if(n.signal.aborted||u(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}[(Be=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=e=>({next:()=>{if(e.length===0){let e=r.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>i(t),this.controller,c(this,Be,`f`)),new e(()=>i(n),this.controller,c(this,Be,`f`))]}toReadableStream(){let e;return ve({start:async()=>{e=this[Symbol.asyncIterator]()},async pull(t){try{let{value:n,done:r}=await e.next();if(r)return t.close();let i=w(JSON.stringify(n)+`
4
4
  `);t.enqueue(i)}catch(e){t.error(e)}},async cancel(){await e.return?.()}})}};async function*He(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new f(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new f(`Attempted to iterate over a response with no body`);let n=new Ge,r=new ke,i=be(e.body);for await(let e of We(i))for(let t of r.decode(e)){let e=n.decode(t);e&&(yield e)}for(let e of r.flush()){let t=n.decode(e);t&&(yield t)}}var Ue=3;async function*We(e){let t=new Uint8Array,n=0,r=0,i=0;for await(let a of e){if(a==null)continue;let e;if(e=a instanceof ArrayBuffer?new Uint8Array(a):typeof a==`string`?w(a):a,r+e.length>t.length){let a=r-n;if(n>=t.length/2&&a+e.length<=t.length)t.copyWithin(0,n,r);else{let i=new Uint8Array(Math.max(t.length*2,a+e.length));i.set(t.subarray(n,r)),t=i}i-=n,n=0,r=a}t.set(e,r),r+=e.length;let o;for(;(o=je(t.subarray(i,r)))!==-1;)o+=i,yield t.slice(n,o),n=o,i=n;i=Math.max(n,r-Ue)}r>n&&(yield t.slice(n,r))}var Ge=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.slice(0,-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(`
@@ -1 +1 @@
1
- import{s as e,t}from"./api-endpoint-DuEQRZ4g.js";import{t as n}from"./types-D8gIX-W-.js";import{n as r}from"./fs-BaM5oYgh.js";import{t as i}from"./remote-cache-CuIV6-dC.js";function a(e){if(!Number.isFinite(e))return{run:e=>e(),get active(){return 0}};let t=Math.max(1,Math.floor(e)),n=[],r=0,i=()=>{let e=n.shift();if(e){e();return}--r};return{async run(e){r>=t?await new Promise(e=>n.push(e)):r+=1;try{return await e()}finally{i()}},get active(){return r}}}var o=104857600,s=new Set([`list`,`stat`,`mkdir`,`rename`,`remove`]),c=`/api/hostfs`,l=new Set([`ENOENT`,`EEXIST`,`ENOTDIR`,`EISDIR`,`ENOTEMPTY`,`EINVAL`,`EACCES`,`ELOOP`,`EBUSY`,`EFBIG`,`EBADF`,`EIO`]),u=new Set([`list`,`stat`,`read`,`mkdir`]),d=3,f=25,p=24,m=3e4,h=4194304,g=`no-store`;function _(e,t){return`hostfs:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}var v=e=>e.json(),y=async e=>({partial:e.status===206,body:await e.arrayBuffer()}),b=async e=>{await e.arrayBuffer()},x=e=>e>0?new Promise(t=>setTimeout(t,e)):Promise.resolve();function S(e,t,r,i,a){let o=r instanceof Error?r.message:String(r),s=a?` after ${i} attempt${i===1?``:`s`}`:` (not retried: non-idempotent op)`;return new n(`EIO`,`hostfs ${e} failed${s}: transient bridge error: ${o}`,t)}function C(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function w(t){let n={},i=C(t.ctime);i!==void 0&&(n.ctime=i);let a=C(t.ino);a!==void 0&&(n.ino=a);let o=C(t.dev);o!==void 0&&Number.isSafeInteger(o)&&o>=0&&(n.dev=o,n.identity=r(`hostfs:${e(c)}`,a,o));let s=C(t.uid);s!==void 0&&(n.uid=s);let l=C(t.gid);l!==void 0&&(n.gid=l);let u=C(t.mode);return u!==void 0&&(n.mode=u),n}var T=class{kind=`hostfs`;listingStatsMatchStat=!0;source;mountId;targetPath;hostPath;fetchImpl;limiter;maxAttempts;retryDelayMs;cache;maxCachedBodyBytes;cacheGeneration=0;closed=!1;stableEndpoint=!0;constructor(e){this.targetPath=e.targetPath,this.hostPath=e.hostPath,this.source=`hostfs://${e.hostPath}`,this.mountId=e.mountId??_(e.targetPath,e.hostPath),this.fetchImpl=e.fetchImpl??fetch,this.limiter=a(e.maxInflight??p),this.maxAttempts=Math.max(1,e.maxAttempts??d),this.retryDelayMs=e.retryDelayMs??f,this.maxCachedBodyBytes=Math.max(0,e.maxCachedBodyBytes??h),this.cache=e.cache??new i({mountId:this.mountId,ttlMs:e.cacheTtlMs??m})}assertOpen(e){if(this.closed)throw new n(`EBADF`,`mount closed`,e)}bodyKey(e){return e.replace(/^\/+/,``)}async invalidateCachePrefixes(e){this.cacheGeneration+=1,await this.cache.invalidatePrefixes(e)}async cacheBodyIfCurrent(e,t,n,r){e!==this.cacheGeneration||n.byteLength>this.maxCachedBodyBytes||(await this.cache.putBody(t,n,r),e!==this.cacheGeneration&&await this.cache.invalidateBody(t))}async applyHostInvalidation(e){if(e.length===0){await this.invalidateCachePrefixes([]);return}let t=e.map(e=>e.replace(/^\/+/,``));if(t.some(e=>e.length===0||e===`.`)){await this.invalidateCachePrefixes([]);return}await this.invalidateCachePrefixes(t)}getCache(){return this.cache}url(t,n,r){let i=new URLSearchParams({mount:this.targetPath,path:n.replace(/^\/+/,``)});for(let[e,t]of Object.entries(r??{}))i.set(e,t);return e(`/api/hostfs/${t}?${i.toString()}`)}buildRequest(n,r,i){let a=t(i?.headers);if(this.stableEndpoint&&s.has(n))return{url:e(c),init:{method:`POST`,headers:{...a,"Content-Type":`application/json`},body:JSON.stringify({op:n,mount:this.targetPath,path:r.replace(/^\/+/,``),...i?.extra??{}})}};let{extra:o,...l}=i??{};return{url:this.url(n,r,i?.extra),init:{...l,headers:a}}}async request(e,t,n,r){return this.assertOpen(t),this.limiter.run(()=>this.attemptRequest(e,t,n,r))}async attemptRequest(e,t,r,i){let a=u.has(e)?this.maxAttempts:1,o=0,s;for(;o<a;){o+=1;try{return await this.routeAndConsume(e,t,r,i)}catch(e){if(e instanceof n)throw e;if(s=e,this.closed)break;o<a&&await x(this.retryDelayMs*o)}}throw S(e,t,s,o,a>1)}async routeAndConsume(e,t,n,r){let i=this.stableEndpoint&&s.has(e),a=this.buildRequest(e,t,r),o=await this.fetchImpl(a.url,a.init);if(o.ok||o.status===304)return await n(o);let{error:c,rawCode:l}=await this.errorFromResponse(e,t,o);if(i&&l===null&&(o.status===404||o.status===405))return this.stableEndpoint=!1,await this.routeAndConsume(e,t,n,r);throw c}async errorFromResponse(e,t,r){let i=`EIO`,a=null,o=`hostfs ${e} failed with HTTP ${r.status}`;try{let e=await r.json();typeof e.code==`string`&&(a=e.code,l.has(e.code)&&(i=e.code)),typeof e.message==`string`&&(o=e.message)}catch{}return{error:new n(i,o,t),rawCode:a}}async readDir(e){let t=await this.request(`list`,e,v);if(!Array.isArray(t.entries))return[];let n=[];for(let e of t.entries){let t=e;typeof t.name!=`string`||t.kind!==`file`&&t.kind!==`directory`||n.push({name:t.name,kind:t.kind,...typeof t.size==`number`?{size:t.size}:{},...typeof t.lastModified==`number`?{lastModified:t.lastModified}:{},...w(t)})}return n}async readFile(e){this.assertOpen(e);let t=this.cacheGeneration,r=this.bodyKey(e),i=await this.cache.getBody(r);if(i&&!this.cache.isStale(i.cachedAt))return i.body;let a={};i?.etag&&(a[`If-None-Match`]=i.etag);let s=await this.request(`read`,e,async e=>e.status===304?{kind:`not-modified`}:{kind:`body`,bytes:new Uint8Array(await e.arrayBuffer()),etag:e.headers.get(`etag`)??``},{cache:g,headers:a});if(s.kind===`not-modified`){if(!i)throw new n(`EIO`,`hostfs read got 304 without a cached body`,e);return await this.cacheBodyIfCurrent(t,r,i.body,i.etag),i.body}if(s.bytes.byteLength>o)throw new n(`EFBIG`,`file exceeds the hostfs body cap`,e);return await this.cacheBodyIfCurrent(t,r,s.bytes,s.etag),s.bytes}async readFileRange(e,t,r){if(!Number.isInteger(t)||!Number.isInteger(r)||t<0||r<t)throw new n(`EINVAL`,`invalid byte range ${t}-${r}`,e);if(r===t)return new Uint8Array;if(r-t>o)throw new n(`EFBIG`,`byte range exceeds the hostfs body cap`,e);let{partial:i,body:a}=await this.request(`read`,e,y,{cache:g,headers:{Range:`bytes=${t}-${r-1}`}});return i?new Uint8Array(a):new Uint8Array(a).slice(t,r)}async writeFile(e,t){if(t.byteLength>o)throw new n(`EFBIG`,`body exceeds the hostfs body cap`,e);await this.request(`write`,e,b,{method:`PUT`,headers:{"Content-Type":`application/octet-stream`},body:new Uint8Array(t)});let r=this.bodyKey(e),i=++this.cacheGeneration;t.byteLength<=this.maxCachedBodyBytes?await this.cacheBodyIfCurrent(i,r,new Uint8Array(t),``):await this.cache.invalidateBody(r)}async stat(e){let t=await this.request(`stat`,e,v);return{kind:t.kind===`directory`?`directory`:`file`,size:typeof t.size==`number`?t.size:0,mtime:typeof t.mtime==`number`?t.mtime:0,...w(t)}}async mkdir(e){await this.request(`mkdir`,e,b,{method:`POST`})}async rename(e,t){let n=await this.request(`rename`,e,v,{method:`POST`,extra:{to:t.replace(/^\/+/,``)}}),r=this.bodyKey(e),i=this.bodyKey(t);return await this.invalidateCachePrefixes([r,i]),n.noop===!0?{noop:!0}:{}}async remove(e,t){await this.request(`remove`,e,b,{method:`DELETE`,extra:t?.recursive?{recursive:`1`}:void 0});let n=this.bodyKey(e);t?.recursive?await this.invalidateCachePrefixes([n]):(this.cacheGeneration+=1,await this.cache.invalidateBody(n))}async refresh(e){this.assertOpen(this.targetPath);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=new Set,r=new Set;try{let e=await this.stat(``),t=this.dirIdentity(e,``);t&&r.add(t)}catch{}let i=[``];for(;i.length>0;){let e=i.pop();try{await this.refreshDir(e,t,i,r,n)}catch(n){t.errors.push({path:e||`/`,message:n instanceof Error?n.message:String(n)})}}return await this.purgeAbsentBodies(n,t),e?.bodies&&await this.refreshBodies(t),t}etagsFromListing(e){if(typeof e.size!=`number`||typeof e.lastModified!=`number`||typeof e.ino!=`number`)return;let t=e.size.toString(16),n=e.ino.toString(16),r=`"${t}-${e.lastModified.toString(16)}-${n}"`,i=`"${t}-${Math.floor(Math.max(0,e.lastModified*1e3)).toString(16)}-${n}"`;return r===i?[r]:[r,i]}dirIdentity(e,t){return typeof e.dev==`number`&&typeof e.ino==`number`?`${e.dev}:${e.ino}`:t===``?void 0:`path:${t}`}async markChanged(e,t){this.cacheGeneration+=1,await this.cache.invalidateBody(e),t.changed.push(e)}async classifyFile(e,t,n){let r=await this.cache.getBody(e),i=this.etagsFromListing(t);if(r&&!i?.includes(r.etag)){await this.markChanged(e,n);return}n.unchanged++}async refreshDir(e,t,n,r,i){let a=await this.readDir(e);for(let o of a){let a=e?`${e}/${o.name}`:o.name;if(o.kind===`directory`)try{let e=await this.stat(a),t=this.dirIdentity(e,a);if(t&&r.has(t))continue;t&&r.add(t),n.push(a)}catch(e){t.errors.push({path:a,message:e instanceof Error?e.message:String(e)})}else i.add(a),await this.classifyFile(a,o,t)}}async purgeAbsentBodies(e,t){let n=await this.cache.listBodyPaths(),r=!1;for(let i of n)e.has(i)||(r||=(this.cacheGeneration+=1,!0),await this.cache.invalidateBody(i),t.removed.push(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.hostPath.split(`/`).filter(Boolean).at(-1)??this.hostPath,source:this.source,extra:`configured via mount table (auto-mounted, live host view)`}}async close(){this.closed=!0}getHostPath(){return this.hostPath}getTargetPath(){return this.targetPath}};export{T as HostFsMountBackend};
1
+ import{s as e,t}from"./api-endpoint-DuEQRZ4g.js";import{t as n}from"./types-D8gIX-W-.js";import{n as r}from"./fs-pBJBtnUm.js";import{t as i}from"./remote-cache-CuIV6-dC.js";function a(e){if(!Number.isFinite(e))return{run:e=>e(),get active(){return 0}};let t=Math.max(1,Math.floor(e)),n=[],r=0,i=()=>{let e=n.shift();if(e){e();return}--r};return{async run(e){r>=t?await new Promise(e=>n.push(e)):r+=1;try{return await e()}finally{i()}},get active(){return r}}}var o=104857600,s=new Set([`list`,`stat`,`mkdir`,`rename`,`remove`]),c=`/api/hostfs`,l=new Set([`ENOENT`,`EEXIST`,`ENOTDIR`,`EISDIR`,`ENOTEMPTY`,`EINVAL`,`EACCES`,`ELOOP`,`EBUSY`,`EFBIG`,`EBADF`,`EIO`]),u=new Set([`list`,`stat`,`read`,`mkdir`]),d=3,f=25,p=24,m=3e4,h=4194304,g=`no-store`;function _(e,t){return`hostfs:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}var v=e=>e.json(),y=async e=>({partial:e.status===206,body:await e.arrayBuffer()}),b=async e=>{await e.arrayBuffer()},x=e=>e>0?new Promise(t=>setTimeout(t,e)):Promise.resolve();function S(e,t,r,i,a){let o=r instanceof Error?r.message:String(r),s=a?` after ${i} attempt${i===1?``:`s`}`:` (not retried: non-idempotent op)`;return new n(`EIO`,`hostfs ${e} failed${s}: transient bridge error: ${o}`,t)}function C(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function w(t){let n={},i=C(t.ctime);i!==void 0&&(n.ctime=i);let a=C(t.ino);a!==void 0&&(n.ino=a);let o=C(t.dev);o!==void 0&&Number.isSafeInteger(o)&&o>=0&&(n.dev=o,n.identity=r(`hostfs:${e(c)}`,a,o));let s=C(t.uid);s!==void 0&&(n.uid=s);let l=C(t.gid);l!==void 0&&(n.gid=l);let u=C(t.mode);return u!==void 0&&(n.mode=u),n}var T=class{kind=`hostfs`;listingStatsMatchStat=!0;source;mountId;targetPath;hostPath;fetchImpl;limiter;maxAttempts;retryDelayMs;cache;maxCachedBodyBytes;cacheGeneration=0;closed=!1;stableEndpoint=!0;constructor(e){this.targetPath=e.targetPath,this.hostPath=e.hostPath,this.source=`hostfs://${e.hostPath}`,this.mountId=e.mountId??_(e.targetPath,e.hostPath),this.fetchImpl=e.fetchImpl??fetch,this.limiter=a(e.maxInflight??p),this.maxAttempts=Math.max(1,e.maxAttempts??d),this.retryDelayMs=e.retryDelayMs??f,this.maxCachedBodyBytes=Math.max(0,e.maxCachedBodyBytes??h),this.cache=e.cache??new i({mountId:this.mountId,ttlMs:e.cacheTtlMs??m})}assertOpen(e){if(this.closed)throw new n(`EBADF`,`mount closed`,e)}bodyKey(e){return e.replace(/^\/+/,``)}async invalidateCachePrefixes(e){this.cacheGeneration+=1,await this.cache.invalidatePrefixes(e)}async cacheBodyIfCurrent(e,t,n,r){e!==this.cacheGeneration||n.byteLength>this.maxCachedBodyBytes||(await this.cache.putBody(t,n,r),e!==this.cacheGeneration&&await this.cache.invalidateBody(t))}async applyHostInvalidation(e){if(e.length===0){await this.invalidateCachePrefixes([]);return}let t=e.map(e=>e.replace(/^\/+/,``));if(t.some(e=>e.length===0||e===`.`)){await this.invalidateCachePrefixes([]);return}await this.invalidateCachePrefixes(t)}getCache(){return this.cache}url(t,n,r){let i=new URLSearchParams({mount:this.targetPath,path:n.replace(/^\/+/,``)});for(let[e,t]of Object.entries(r??{}))i.set(e,t);return e(`/api/hostfs/${t}?${i.toString()}`)}buildRequest(n,r,i){let a=t(i?.headers);if(this.stableEndpoint&&s.has(n))return{url:e(c),init:{method:`POST`,headers:{...a,"Content-Type":`application/json`},body:JSON.stringify({op:n,mount:this.targetPath,path:r.replace(/^\/+/,``),...i?.extra??{}})}};let{extra:o,...l}=i??{};return{url:this.url(n,r,i?.extra),init:{...l,headers:a}}}async request(e,t,n,r){return this.assertOpen(t),this.limiter.run(()=>this.attemptRequest(e,t,n,r))}async attemptRequest(e,t,r,i){let a=u.has(e)?this.maxAttempts:1,o=0,s;for(;o<a;){o+=1;try{return await this.routeAndConsume(e,t,r,i)}catch(e){if(e instanceof n)throw e;if(s=e,this.closed)break;o<a&&await x(this.retryDelayMs*o)}}throw S(e,t,s,o,a>1)}async routeAndConsume(e,t,n,r){let i=this.stableEndpoint&&s.has(e),a=this.buildRequest(e,t,r),o=await this.fetchImpl(a.url,a.init);if(o.ok||o.status===304)return await n(o);let{error:c,rawCode:l}=await this.errorFromResponse(e,t,o);if(i&&l===null&&(o.status===404||o.status===405))return this.stableEndpoint=!1,await this.routeAndConsume(e,t,n,r);throw c}async errorFromResponse(e,t,r){let i=`EIO`,a=null,o=`hostfs ${e} failed with HTTP ${r.status}`;try{let e=await r.json();typeof e.code==`string`&&(a=e.code,l.has(e.code)&&(i=e.code)),typeof e.message==`string`&&(o=e.message)}catch{}return{error:new n(i,o,t),rawCode:a}}async readDir(e){let t=await this.request(`list`,e,v);if(!Array.isArray(t.entries))return[];let n=[];for(let e of t.entries){let t=e;typeof t.name!=`string`||t.kind!==`file`&&t.kind!==`directory`||n.push({name:t.name,kind:t.kind,...typeof t.size==`number`?{size:t.size}:{},...typeof t.lastModified==`number`?{lastModified:t.lastModified}:{},...w(t)})}return n}async readFile(e){this.assertOpen(e);let t=this.cacheGeneration,r=this.bodyKey(e),i=await this.cache.getBody(r);if(i&&!this.cache.isStale(i.cachedAt))return i.body;let a={};i?.etag&&(a[`If-None-Match`]=i.etag);let s=await this.request(`read`,e,async e=>e.status===304?{kind:`not-modified`}:{kind:`body`,bytes:new Uint8Array(await e.arrayBuffer()),etag:e.headers.get(`etag`)??``},{cache:g,headers:a});if(s.kind===`not-modified`){if(!i)throw new n(`EIO`,`hostfs read got 304 without a cached body`,e);return await this.cacheBodyIfCurrent(t,r,i.body,i.etag),i.body}if(s.bytes.byteLength>o)throw new n(`EFBIG`,`file exceeds the hostfs body cap`,e);return await this.cacheBodyIfCurrent(t,r,s.bytes,s.etag),s.bytes}async readFileRange(e,t,r){if(!Number.isInteger(t)||!Number.isInteger(r)||t<0||r<t)throw new n(`EINVAL`,`invalid byte range ${t}-${r}`,e);if(r===t)return new Uint8Array;if(r-t>o)throw new n(`EFBIG`,`byte range exceeds the hostfs body cap`,e);let{partial:i,body:a}=await this.request(`read`,e,y,{cache:g,headers:{Range:`bytes=${t}-${r-1}`}});return i?new Uint8Array(a):new Uint8Array(a).slice(t,r)}async writeFile(e,t){if(t.byteLength>o)throw new n(`EFBIG`,`body exceeds the hostfs body cap`,e);await this.request(`write`,e,b,{method:`PUT`,headers:{"Content-Type":`application/octet-stream`},body:new Uint8Array(t)});let r=this.bodyKey(e),i=++this.cacheGeneration;t.byteLength<=this.maxCachedBodyBytes?await this.cacheBodyIfCurrent(i,r,new Uint8Array(t),``):await this.cache.invalidateBody(r)}async stat(e){let t=await this.request(`stat`,e,v);return{kind:t.kind===`directory`?`directory`:`file`,size:typeof t.size==`number`?t.size:0,mtime:typeof t.mtime==`number`?t.mtime:0,...w(t)}}async mkdir(e){await this.request(`mkdir`,e,b,{method:`POST`})}async rename(e,t){let n=await this.request(`rename`,e,v,{method:`POST`,extra:{to:t.replace(/^\/+/,``)}}),r=this.bodyKey(e),i=this.bodyKey(t);return await this.invalidateCachePrefixes([r,i]),n.noop===!0?{noop:!0}:{}}async remove(e,t){await this.request(`remove`,e,b,{method:`DELETE`,extra:t?.recursive?{recursive:`1`}:void 0});let n=this.bodyKey(e);t?.recursive?await this.invalidateCachePrefixes([n]):(this.cacheGeneration+=1,await this.cache.invalidateBody(n))}async refresh(e){this.assertOpen(this.targetPath);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=new Set,r=new Set;try{let e=await this.stat(``),t=this.dirIdentity(e,``);t&&r.add(t)}catch{}let i=[``];for(;i.length>0;){let e=i.pop();try{await this.refreshDir(e,t,i,r,n)}catch(n){t.errors.push({path:e||`/`,message:n instanceof Error?n.message:String(n)})}}return await this.purgeAbsentBodies(n,t),e?.bodies&&await this.refreshBodies(t),t}etagsFromListing(e){if(typeof e.size!=`number`||typeof e.lastModified!=`number`||typeof e.ino!=`number`)return;let t=e.size.toString(16),n=e.ino.toString(16),r=`"${t}-${e.lastModified.toString(16)}-${n}"`,i=`"${t}-${Math.floor(Math.max(0,e.lastModified*1e3)).toString(16)}-${n}"`;return r===i?[r]:[r,i]}dirIdentity(e,t){return typeof e.dev==`number`&&typeof e.ino==`number`?`${e.dev}:${e.ino}`:t===``?void 0:`path:${t}`}async markChanged(e,t){this.cacheGeneration+=1,await this.cache.invalidateBody(e),t.changed.push(e)}async classifyFile(e,t,n){let r=await this.cache.getBody(e),i=this.etagsFromListing(t);if(r&&!i?.includes(r.etag)){await this.markChanged(e,n);return}n.unchanged++}async refreshDir(e,t,n,r,i){let a=await this.readDir(e);for(let o of a){let a=e?`${e}/${o.name}`:o.name;if(o.kind===`directory`)try{let e=await this.stat(a),t=this.dirIdentity(e,a);if(t&&r.has(t))continue;t&&r.add(t),n.push(a)}catch(e){t.errors.push({path:a,message:e instanceof Error?e.message:String(e)})}else i.add(a),await this.classifyFile(a,o,t)}}async purgeAbsentBodies(e,t){let n=await this.cache.listBodyPaths(),r=!1;for(let i of n)e.has(i)||(r||=(this.cacheGeneration+=1,!0),await this.cache.invalidateBody(i),t.removed.push(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.hostPath.split(`/`).filter(Boolean).at(-1)??this.hostPath,source:this.source,extra:`configured via mount table (auto-mounted, live host view)`}}async close(){this.closed=!0}getHostPath(){return this.hostPath}getTargetPath(){return this.targetPath}};export{T as HostFsMountBackend};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t,t as n}from"./bedrock-camp-compat-DC2y4xqC.js";var r=e({BEDROCK_CAMP_EXTRA_MODELS:()=>u,mergeBedrockCampCatalogue:()=>p});const i=e=>Math.round(e*1e6)/1e6;function a(e,t){return{input:i(e.input*t),output:i(e.output*t),cacheRead:i(e.cacheRead*t),cacheWrite:i(e.cacheWrite*t)}}function o(e,t){let n=a(e,t);return e.tiers&&(n.tiers=e.tiers.map(e=>({...a(e,t),inputTokensAbove:e.inputTokensAbove}))),n}const s={global:`Global`,us:`US`,eu:`EU`,jp:`JP`,au:`AU`},c=[{baseId:`anthropic.claude-opus-5-5`,name:`Claude Opus 5.5`,profiles:[`global`,`us`,`eu`,`jp`,`au`],globalCost:{input:4,output:20,cacheRead:.2,cacheWrite:5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:`xhigh`,max:`max`}},{baseId:`anthropic.claude-sonnet-5-5`,name:`Claude Sonnet 5.5`,profiles:[`global`],globalCost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:`xhigh`,max:`max`}},{baseId:`anthropic.claude-fable-5-1`,name:`Claude Fable 5.1`,profiles:[`global`,`us`],globalCost:{input:10,output:50,cacheRead:.25,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:`xhigh`,max:`max`}},{baseId:`openai.gpt-6-sol`,name:`GPT-6 Sol`,profiles:[`global`,`us`],globalCost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5,tiers:[{inputTokensAbove:272e3,input:4,output:15,cacheRead:.4,cacheWrite:5}]},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:t},{baseId:`openai.gpt-6-luna`,name:`GPT-6 Luna`,profiles:[`global`,`us`],globalCost:{input:.1,output:.5,cacheRead:.01,cacheWrite:.125,tiers:[{inputTokensAbove:272e3,input:.2,output:.75,cacheRead:.02,cacheWrite:.25}]},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:t},{baseId:`openai.gpt-6-astra`,name:`GPT-6 Astra`,profiles:[`global`,`us`],globalCost:{input:10,output:50,cacheRead:1,cacheWrite:12.5,tiers:[{inputTokensAbove:272e3,input:20,output:75,cacheRead:2,cacheWrite:25}]},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:n},{baseId:`moonshotai.kimi-k3`,name:`Kimi K3`,profiles:[`global`,`us`],globalCost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1048576,maxTokens:128e3}];function l(e){return e.profiles.map(t=>({id:`${t}.${e.baseId}`,name:`${e.name} (${s[t]})`,api:`bedrock-converse-stream`,provider:`amazon-bedrock`,baseUrl:`https://bedrock-runtime.us-east-1.amazonaws.com`,reasoning:!0,input:[`text`,`image`],cost:o(e.globalCost,t===`global`?1:1.1),contextWindow:e.contextWindow,maxTokens:e.maxTokens,...e.thinkingLevelMap?{thinkingLevelMap:{...e.thinkingLevelMap}}:{}}))}const u=c.flatMap(l);function d(e,t){return e.input===t.input&&e.output===t.output&&e.cacheRead===t.cacheRead&&e.cacheWrite===t.cacheWrite}function f(e,t){let n=t?.cost;return!n?.tiers||!e.cost||e.cost.tiers||!d(e.cost,n)?e:{...e,cost:{...e.cost,tiers:n.tiers.map(e=>({...e}))}}}function p(e,t){let n=new Map(t.map(e=>[e.id,e])),r=new Set(e.map(e=>e.id));return[...e.map(e=>f(e,n.get(e.id))),...t.filter(e=>!r.has(e.id))]}export{r as n,p as r,u as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t,t as n}from"./bedrock-camp-compat-C64_Hwco.js";var r=e({BEDROCK_CAMP_EXTRA_MODELS:()=>d,mergeBedrockCampCatalogue:()=>m}),i=1.1,a=e=>Math.round(e*1e6)/1e6;function o(e,t){return{input:a(e.input*t),output:a(e.output*t),cacheRead:a(e.cacheRead*t),cacheWrite:a(e.cacheWrite*t)}}function s(e,t){let n=o(e,t);return e.tiers&&(n.tiers=e.tiers.map(e=>({...o(e,t),inputTokensAbove:e.inputTokensAbove}))),n}var c={global:`Global`,us:`US`,eu:`EU`,jp:`JP`,au:`AU`},l=[{baseId:`anthropic.claude-opus-5-5`,name:`Claude Opus 5.5`,profiles:[`global`,`us`,`eu`,`jp`,`au`],globalCost:{input:4,output:20,cacheRead:.2,cacheWrite:5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:`xhigh`,max:`max`}},{baseId:`anthropic.claude-sonnet-5-5`,name:`Claude Sonnet 5.5`,profiles:[`global`],globalCost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{xhigh:`xhigh`,max:`max`}},{baseId:`anthropic.claude-fable-5-1`,name:`Claude Fable 5.1`,profiles:[`global`,`us`],globalCost:{input:10,output:50,cacheRead:.25,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,thinkingLevelMap:{off:null,xhigh:`xhigh`,max:`max`}},{baseId:`openai.gpt-6-sol`,name:`GPT-6 Sol`,profiles:[`global`,`us`],globalCost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5,tiers:[{inputTokensAbove:272e3,input:4,output:15,cacheRead:.4,cacheWrite:5}]},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:t},{baseId:`openai.gpt-6-luna`,name:`GPT-6 Luna`,profiles:[`global`,`us`],globalCost:{input:.1,output:.5,cacheRead:.01,cacheWrite:.125,tiers:[{inputTokensAbove:272e3,input:.2,output:.75,cacheRead:.02,cacheWrite:.25}]},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:t},{baseId:`openai.gpt-6-astra`,name:`GPT-6 Astra`,profiles:[`global`,`us`],globalCost:{input:10,output:50,cacheRead:1,cacheWrite:12.5,tiers:[{inputTokensAbove:272e3,input:20,output:75,cacheRead:2,cacheWrite:25}]},contextWindow:105e4,maxTokens:128e3,thinkingLevelMap:n},{baseId:`moonshotai.kimi-k3`,name:`Kimi K3`,profiles:[`global`,`us`],globalCost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1048576,maxTokens:128e3}];function u(e){return e.profiles.map(t=>({id:`${t}.${e.baseId}`,name:`${e.name} (${c[t]})`,api:`bedrock-converse-stream`,provider:`amazon-bedrock`,baseUrl:`https://bedrock-runtime.us-east-1.amazonaws.com`,reasoning:!0,input:[`text`,`image`],cost:s(e.globalCost,t===`global`?1:i),contextWindow:e.contextWindow,maxTokens:e.maxTokens,...e.thinkingLevelMap?{thinkingLevelMap:{...e.thinkingLevelMap}}:{}}))}var d=l.flatMap(u);function f(e,t){return e.input===t.input&&e.output===t.output&&e.cacheRead===t.cacheRead&&e.cacheWrite===t.cacheWrite}function p(e,t){let n=t?.cost;return!n?.tiers||!e.cost||e.cost.tiers||!f(e.cost,n)?e:{...e,cost:{...e.cost,tiers:n.tiers.map(e=>({...e}))}}}function m(e,t){let n=new Map(t.map(e=>[e.id,e])),r=new Set(e.map(e=>e.id));return[...e.map(e=>p(e,n.get(e.id))),...t.filter(e=>!r.has(e.id))]}export{r as n,m as r,d as t};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import{t}from"./esbuild-wasm-C-mKofIl.js";const n=e(`bsh-watchdog`),r=`.bsh scripts must be pre-bundled. Install deps via \`ipk add <pkg>\`, then bootstrap esbuild via \`ipk add esbuild-wasm@${t}\` and bundle with \`esbuild --bundle <script>.bsh --outfile=<script>.bundled.bsh\`. Drop the bundled file in place. There is no runtime resolver in the target page.`;var i=class{transport;browserAPI;fs;scriptCatalog;running=!1;executing=new Set;constructor(e){if(!e.transport&&!e.browserAPI)throw Error(`BshWatchdog requires either transport or browserAPI`);if(!e.scriptCatalog)throw Error(`BshWatchdog requires a ScriptCatalog`);this.browserAPI=e.browserAPI,this.transport=e.transport??e.browserAPI.getTransport(),this.fs=e.fs,this.scriptCatalog=e.scriptCatalog}async start(){if(this.running)return;this.running=!0,this.transport.on(`Page.frameNavigated`,this.onFrameNavigated),this.browserAPI&&this.browserAPI.setSessionChangeCallback((e,t)=>{t!==this.transport&&this.setTransport(t)});let e;try{e=(await this.scriptCatalog.getBshEntries()).length}catch(e){n.warn(`BSH watchdog startup discovery failed`,{error:e instanceof Error?e.message:String(e)})}n.info(`BSH watchdog started`,e===void 0?void 0:{scriptCount:e})}stop(){this.running&&(this.running=!1,this.transport.off(`Page.frameNavigated`,this.onFrameNavigated),this.browserAPI&&this.browserAPI.setSessionChangeCallback(void 0),this.executing.clear(),n.info(`BSH watchdog stopped`))}setTransport(e){e!==this.transport&&(this.transport.off(`Page.frameNavigated`,this.onFrameNavigated),this.transport=e,this.running&&this.transport.on(`Page.frameNavigated`,this.onFrameNavigated),n.info(`BSH watchdog transport swapped`))}async discover(){this.scriptCatalog.invalidateBsh(),await this.scriptCatalog.getBshEntries()}async getEntries(){return this.scriptCatalog.getBshEntries()}onFrameNavigated=e=>{let t=e.frame;if(t?.parentId||!t?.url)return;let r=t.url,i=e.sessionId;if(!(!r.startsWith(`http://`)&&!r.startsWith(`https://`))){if(!i){n.warn(`BSH watchdog: no sessionId in Page.frameNavigated params, skipping`,{url:r});return}this.scriptCatalog.findMatchingBshScripts(r).then(e=>{if(e.length!==0)for(let t of e){let e=`${t.path}::${r}`;this.executing.has(e)||(this.executing.add(e),n.info(`BSH watchdog executing script`,{script:t.path,url:r}),this.executeInTargetPage(t.path,r,i).then(()=>{n.info(`BSH script completed`,{script:t.path,url:r})}).catch(e=>{n.error(`BSH script execution error`,{script:t.path,url:r,error:e instanceof Error?e.message:String(e)})}).finally(()=>{this.executing.delete(e)}))}}).catch(e=>{n.error(`BSH discovery failed`,{url:r,error:e instanceof Error?e.message:String(e)})})}};async executeInTargetPage(e,t,i){let a=await this.fs.readFile(e),o=typeof a==`string`?a:new TextDecoder().decode(a),s=`(async () => {
1
+ import{t as e}from"./logger-LESFN7Hj.js";import{t}from"./esbuild-wasm-DIcMVR3g.js";const n=e(`bsh-watchdog`),r=`.bsh scripts must be pre-bundled. Install deps via \`ipk add <pkg>\`, then bootstrap esbuild via \`ipk add esbuild-wasm@${t}\` and bundle with \`esbuild --bundle <script>.bsh --outfile=<script>.bundled.bsh\`. Drop the bundled file in place. There is no runtime resolver in the target page.`;var i=class{transport;browserAPI;fs;scriptCatalog;running=!1;executing=new Set;constructor(e){if(!e.transport&&!e.browserAPI)throw Error(`BshWatchdog requires either transport or browserAPI`);if(!e.scriptCatalog)throw Error(`BshWatchdog requires a ScriptCatalog`);this.browserAPI=e.browserAPI,this.transport=e.transport??e.browserAPI.getTransport(),this.fs=e.fs,this.scriptCatalog=e.scriptCatalog}async start(){if(this.running)return;this.running=!0,this.transport.on(`Page.frameNavigated`,this.onFrameNavigated),this.browserAPI&&this.browserAPI.setSessionChangeCallback((e,t)=>{t!==this.transport&&this.setTransport(t)});let e;try{e=(await this.scriptCatalog.getBshEntries()).length}catch(e){n.warn(`BSH watchdog startup discovery failed`,{error:e instanceof Error?e.message:String(e)})}n.info(`BSH watchdog started`,e===void 0?void 0:{scriptCount:e})}stop(){this.running&&(this.running=!1,this.transport.off(`Page.frameNavigated`,this.onFrameNavigated),this.browserAPI&&this.browserAPI.setSessionChangeCallback(void 0),this.executing.clear(),n.info(`BSH watchdog stopped`))}setTransport(e){e!==this.transport&&(this.transport.off(`Page.frameNavigated`,this.onFrameNavigated),this.transport=e,this.running&&this.transport.on(`Page.frameNavigated`,this.onFrameNavigated),n.info(`BSH watchdog transport swapped`))}async discover(){this.scriptCatalog.invalidateBsh(),await this.scriptCatalog.getBshEntries()}async getEntries(){return this.scriptCatalog.getBshEntries()}onFrameNavigated=e=>{let t=e.frame;if(t?.parentId||!t?.url)return;let r=t.url,i=e.sessionId;if(!(!r.startsWith(`http://`)&&!r.startsWith(`https://`))){if(!i){n.warn(`BSH watchdog: no sessionId in Page.frameNavigated params, skipping`,{url:r});return}this.scriptCatalog.findMatchingBshScripts(r).then(e=>{if(e.length!==0)for(let t of e){let e=`${t.path}::${r}`;this.executing.has(e)||(this.executing.add(e),n.info(`BSH watchdog executing script`,{script:t.path,url:r}),this.executeInTargetPage(t.path,r,i).then(()=>{n.info(`BSH script completed`,{script:t.path,url:r})}).catch(e=>{n.error(`BSH script execution error`,{script:t.path,url:r,error:e instanceof Error?e.message:String(e)})}).finally(()=>{this.executing.delete(e)}))}}).catch(e=>{n.error(`BSH discovery failed`,{url:r,error:e instanceof Error?e.message:String(e)})})}};async executeInTargetPage(e,t,i){let a=await this.fs.readFile(e),o=typeof a==`string`?a:new TextDecoder().decode(a),s=`(async () => {
2
2
  const __requireSpecifiers = (function() {
3
3
  const re = /require\\s*\\(\\s*['"]([^'"]+)['"]\\s*\\)/g;
4
4
  const code = ${JSON.stringify(o)};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./logger-DDBAeTLF.js";import"./navigation-watcher-CPcnZL9l.js";import"./wc-follower-oauth-BGkJQhXu.js";import{d as t,l as n,u as r}from"./main-CXeU8DQz.js";import{n as i,t as a}from"./pending-request-table-k-D7ZZsL.js";var o=e(`cdp`);function s(e){return e===4001?`CDP connection superseded by another SLICC tab/window on this instance`:e===4002?`CDP connection reset by proxy (upstream Chrome connection was re-established)`:`CDP connection closed`}var c=class{ws=null;nextId=1;_superseded=!1;pending=new a;listeners=new Map;_state=`disconnected`;stateListeners=new Set;lastNotifiedState=`disconnected`;lastNotifiedReason;get state(){return this._state}onStateChange(e){return this.stateListeners.add(e),()=>{this.stateListeners.delete(e)}}get superseded(){return this._superseded}async connect(e){if(this._state!==`disconnected`)throw Error(`Cannot connect: state is ${this._state}`);if(!e?.url)throw Error(`CDPClient.connect() requires a WebSocket URL`);let{url:t,timeout:n=5e3,protocols:r}=e;return this._state=`connecting`,new Promise((e,i)=>{let a=setTimeout(()=>{this.cleanup(),i(Error(`CDP connection timed out after ${n}ms`))},n);try{this.ws=r===void 0?new WebSocket(t):new WebSocket(t,r)}catch(e){clearTimeout(a),this._state=`disconnected`,i(e);return}this.ws.onopen=()=>{clearTimeout(a),this._state=`connected`,this._superseded=!1,o.info(`Connected`,{url:t}),this.notifyState(`connected`),e()},this.ws.onerror=e=>{clearTimeout(a),this._state===`connecting`&&(o.error(`Connection failed`,{url:t}),this.cleanup(),i(Error(`CDP WebSocket connection failed`)))},this.ws.onmessage=e=>{this.handleMessage(e.data)},this.ws.onclose=e=>{this.handleClose(e?.code)}})}disconnect(){this.ws&&(this.ws.onclose=null,this.ws.close()),this._superseded=!1,this.cleanup(),o.info(`Disconnected`)}async send(e,t,n,r=3e4){if(this._state!==`connected`||!this.ws)throw Error(`CDP client is not connected`);let i=this.nextId++,a={id:i,method:e};t&&(a.params=t),n&&(a.sessionId=n),o.debug(`Send`,{method:e,id:i,sessionId:n});let s=this.pending.issue(i,r,`CDP command timed out after ${r}ms: ${e}`);return this.ws.send(JSON.stringify(a)),s}on(e,t){let n=this.listeners.get(e);n||(n=new Set,this.listeners.set(e,n)),n.add(t)}off(e,t){let n=this.listeners.get(e);n&&(n.delete(t),n.size===0&&this.listeners.delete(e))}once(e,t=3e4){return i(t=>(this.on(e,t),()=>this.off(e,t)),t,`Timed out waiting for event: ${e}`)}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}if(`id`in t&&typeof t.id==`number`){let e=t;o.debug(`Response`,{id:e.id,hasError:!!e.error}),e.error?(o.error(`Command error`,{id:e.id,code:e.error.code,message:e.error.message}),this.pending.reject(e.id,Error(`CDP error: ${e.error.message} (${e.error.code})`))):this.pending.resolve(e.id,e.result??{});return}if(`method`in t){let e=t;o.debug(`Event`,{method:e.method,sessionId:e.sessionId});let n=this.listeners.get(e.method);if(n){let t=e.sessionId?{...e.params,sessionId:e.sessionId}:e.params??{};for(let e of n)try{e(t)}catch{}}}}handleClose(e){e===4001?(this._superseded=!0,o.warn(`CDP slot superseded by another SLICC tab/window on this instance`,{code:e})):e===4002?o.warn(`CDP proxy reset its upstream Chrome connection — sessions dropped`,{code:e,pendingCommands:this.pending.size}):o.error(`Connection closed unexpectedly`,{pendingCommands:this.pending.size}),this.cleanup(s(e))}cleanup(e=`CDP client disconnected`){this.ws=null,this._state=`disconnected`,this.pending.rejectAll(e),this.notifyState(`disconnected`,e)}notifyState(e,t){if(e!==this.lastNotifiedState||t!==this.lastNotifiedReason){this.lastNotifiedState=e,this.lastNotifiedReason=t;for(let n of this.stateListeners)try{n(e,t)}catch{}}}},l=`ws://localhost:5710/cdp`;function u(e=typeof window<`u`?window.location:null){return e?.host?`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}/cdp`:l}var d=class{lastConnectOptions=null;supersededHandler=null;supersededNotified=!1;reconnectAttempt=0;reconnectNotBefore=0;bridgeRejection=null;bridgeRejectedHandler=null;bridgeRejectedNotified=!1;classifyConnectFailure=async()=>`transient`;primeConnectOptions(e){this.lastConnectOptions=e?{...e}:{}}setSupersededHandler(e){this.supersededHandler=e}setBridgeRejectedHandler(e){this.bridgeRejectedHandler=e}setConnectFailureClassifier(e){this.classifyConnectFailure=e}async connect(e,t){if(this.bridgeRejection)throw this.notifyBridgeRejected(),new n(this.bridgeRejection);this.lastConnectOptions=t?{...t}:{};try{await e.connect({url:t?.url??u(),timeout:t?.timeout,...t?.protocols===void 0?{}:{protocols:t.protocols}})}catch(e){throw await this.noteReconnectFailure(t),this.bridgeRejection?new n(this.bridgeRejection):e}this.noteReconnectSuccess()}async ensureLocalConnected(e){if(e.superseded===!0){this.notifySuperseded();return}if(e.state===`disconnected`){this.throwIfReconnectPaused();let t=this.lastConnectOptions;try{await e.connect({url:t?.url??u(),...t?.timeout===void 0?{}:{timeout:t.timeout},...t?.protocols===void 0?{}:{protocols:t.protocols}})}catch(e){throw await this.noteReconnectFailure(t??void 0),this.bridgeRejection?new n(this.bridgeRejection):e}this.noteReconnectSuccess()}}async ensureConnected(e){if(e.client.superseded===!0){this.notifySuperseded();return}if(e.client.state===`disconnected`){this.throwIfReconnectPaused();let t=e.client;e.restoreLocalAfterRemoteDrop(),e.clearSessionsForTransport(t),e.getClient().state===`disconnected`&&await this.connect(e.getClient(),this.lastConnectOptions??void 0)}}throwIfReconnectPaused(){if(this.bridgeRejection)throw this.notifyBridgeRejected(),new n(this.bridgeRejection);if(Date.now()<this.reconnectNotBefore)throw new r}noteReconnectSuccess(){this.reconnectAttempt=0,this.reconnectNotBefore=0,this.supersededNotified=!1}async noteReconnectFailure(e){if(await this.classifyConnectFailure({url:e?.url??``,...e?.protocols===void 0?{}:{protocols:e.protocols}})===`terminal`){this.bridgeRejection=new n().message,this.notifyBridgeRejected();return}let r=t(this.reconnectAttempt);this.reconnectAttempt+=1,this.reconnectNotBefore=Date.now()+r}notifyBridgeRejected(){if(!this.bridgeRejectedNotified){this.bridgeRejectedNotified=!0;try{this.bridgeRejectedHandler?.()}catch{}}}notifySuperseded(){if(!this.supersededNotified){this.supersededNotified=!0;try{this.supersededHandler?.()}catch{}}}},f=class extends Error{step;name=`CommandAbortedError`;constructor(e){super(`Browser command aborted while ${e}. A CDP round trip already in flight cannot be cancelled, so it may still have been applied to the page; nothing after it was started.`),this.step=e}};function p(e,t){if(e?.aborted)throw new f(t)}function m(e,t){return e?{signal:e,error:()=>new f(t)}:void 0}function h(e,t,n){return new Promise((r,i)=>{if(t?.aborted){i(new f(n));return}let a=()=>{clearTimeout(o),i(new f(n))},o=setTimeout(()=>{t?.removeEventListener(`abort`,a),r()},e);t?.addEventListener(`abort`,a,{once:!0})})}function g(e,t,n){return t?t.aborted?Promise.reject(new f(n)):new Promise((r,i)=>{let a=()=>i(new f(n));t.addEventListener(`abort`,a,{once:!0}),e.then(()=>{t.removeEventListener(`abort`,a),r()},e=>{t.removeEventListener(`abort`,a),i(e instanceof Error?e:Error(String(e)))})}):e}var _=class{contexts=new Map;for(e,t){let n=`${t}:${e}`,r=this.contexts.get(n);return r||(r=new Map,this.contexts.set(n,r)),r}peek(e,t){return this.contexts.get(`${t}:${e}`)}drop(e){this.contexts.delete(`main:${e}`),this.contexts.delete(`isolated:${e}`)}get size(){return this.contexts.size}},v=e(`har-recorder`),y=class{recordings=new Map;client;fs;eventCleanup=new Map;constructor(e,t){this.client=e,this.fs=t}async startRecording(e,t,n,r){let i=`rec-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;p(r,`about to enable Network on tab ${e}`),await this.client.send(`Network.enable`,{},t),p(r,`about to enable Page on tab ${e}`),await this.client.send(`Page.enable`,{},t),p(r,`about to read the URL of tab ${e}`);let a=(await this.client.send(`Runtime.evaluate`,{expression:`location.href`,returnByValue:!0},t)).result?.value??`about:blank`,o={id:i,targetId:e,sessionId:t,filterCode:n,pendingRequests:new Map,entries:[],startTime:Date.now(),currentUrl:a,snapshotCount:0};return this.recordings.set(i,o),this.setupEventListeners(o),await this.ensureDir(`/recordings/${i}`),v.debug(`Started recording`,{recordingId:i,targetId:e,currentUrl:a}),i}setupEventListeners(e){let{sessionId:t,id:n}=e,r=n=>{let r=n;r.sessionId===t&&this.handleRequestWillBeSent(e,r)},i=n=>{let r=n;r.sessionId===t&&this.handleResponseReceived(e,r)},a=r=>{let i=r;i.sessionId===t&&this.handleLoadingFinished(e,i).catch(e=>{v.error(`Failed to process loadingFinished event`,{recordingId:n,requestId:i.requestId,error:e instanceof Error?e.message:String(e)})})},o=n=>{let r=n;r.sessionId===t&&this.handleLoadingFailed(e,r)},s=r=>{let i=r;if(i.sessionId!==t)return;let a=i.frame;if(!a?.parentId&&a?.url){let t=[...e.entries],r=e.currentUrl;e.currentUrl=a.url,e.entries=[],e.pendingRequests.clear(),this.saveSnapshotWithEntries(e,`navigation`,t,r).catch(e=>{v.error(`Failed to save navigation snapshot`,{recordingId:n,error:e instanceof Error?e.message:String(e)})})}};this.client.on(`Network.requestWillBeSent`,r),this.client.on(`Network.responseReceived`,i),this.client.on(`Network.loadingFinished`,a),this.client.on(`Network.loadingFailed`,o),this.client.on(`Page.frameNavigated`,s),this.eventCleanup.set(n,()=>{this.client.off(`Network.requestWillBeSent`,r),this.client.off(`Network.responseReceived`,i),this.client.off(`Network.loadingFinished`,a),this.client.off(`Network.loadingFailed`,o),this.client.off(`Page.frameNavigated`,s)})}handleRequestWillBeSent(e,t){let{requestId:n,request:r,timestamp:i}=t;!n||!r||i==null||e.pendingRequests.set(n,{requestId:n,startTime:i*1e3,request:{method:r.method,url:r.url,headers:r.headers,postData:r.postData}})}handleResponseReceived(e,t){let{requestId:n,response:r}=t;if(!n||!r)return;let i=e.pendingRequests.get(n);i&&(i.response={status:r.status,statusText:r.statusText,headers:r.headers,mimeType:r.mimeType},i.timing=r.timing)}async handleLoadingFinished(e,t){let{requestId:n,timestamp:r}=t;if(!n||r==null)return;let i=e.pendingRequests.get(n);if(!i)return;i.endTime=r*1e3;try{let t=await this.client.send(`Network.getResponseBody`,{requestId:n},e.sessionId);i.responseBody=t.body,i.responseBodyBase64=t.base64Encoded===!0}catch{}let a=this.buildHarEntry(i);a&&e.entries.push(a),e.pendingRequests.delete(n)}handleLoadingFailed(e,t){let{requestId:n}=t;n&&e.pendingRequests.delete(n)}buildHarEntry(e){if(!e.response)return null;let{request:t,response:n,timing:r,startTime:i,endTime:a,responseBody:o,responseBodyBase64:s}=e,c=a?a-i:0,l=[];try{let e=new URL(t.url);l=Array.from(e.searchParams.entries()).map(([e,t])=>({name:e,value:t}))}catch{}let u=r?(()=>{let e=(e,t)=>{if(e==null||t==null||e<0||t<0)return-1;let n=t-e;return n>=0?n:-1},t=r.dnsStart>=0?r.dnsStart:r.connectStart>=0?r.connectStart:0;return{blocked:t>0?t:-1,dns:e(r.dnsStart,r.dnsEnd),connect:e(r.connectStart,r.connectEnd),ssl:e(r.sslStart,r.sslEnd),send:e(r.sendStart,r.sendEnd),wait:e(r.sendEnd,r.receiveHeadersStart),receive:e(r.receiveHeadersStart,r.receiveHeadersEnd)}})():{blocked:-1,dns:-1,connect:-1,ssl:-1,send:0,wait:c,receive:0},d={size:o?.length??0,mimeType:n.mimeType??`application/octet-stream`};o&&(d.text=o,s&&(d.encoding=`base64`));let f;return t.postData&&(f={mimeType:t.headers[`content-type`]??t.headers[`Content-Type`]??`text/plain`,text:t.postData}),{startedDateTime:new Date(i).toISOString(),time:c,request:{method:t.method,url:t.url,httpVersion:`HTTP/1.1`,cookies:[],headers:Object.entries(t.headers).map(([e,t])=>({name:e,value:t})),queryString:l,postData:f,headersSize:-1,bodySize:t.postData?.length??0},response:{status:n.status,statusText:n.statusText,httpVersion:`HTTP/1.1`,cookies:[],headers:Object.entries(n.headers).map(([e,t])=>({name:e,value:t})),content:d,redirectURL:n.headers.location??n.headers.Location??``,headersSize:-1,bodySize:d.size},cache:{},timings:u}}async saveSnapshot(e,t){return this.saveSnapshotWithEntries(e,t,e.entries,e.currentUrl)}async applyFilter(e,t){return b(e,t)}async saveSnapshotWithEntries(e,t,n,r){if(n.length===0)return v.debug(`No entries to save`,{recordingId:e.id,trigger:t}),null;let i=e.filterCode?await this.applyFilter(n,e.filterCode):n;if(i.length===0)return v.debug(`All entries filtered out`,{recordingId:e.id,trigger:t}),null;e.snapshotCount++;let a=new Date().toISOString().replace(/[:.]/g,`-`),o=this.urlToSlug(r),s=`${e.snapshotCount.toString().padStart(3,`0`)}-${a}-${t}-${o}.har`,c=`/recordings/${e.id}/${s}`,l={log:{version:`1.2`,creator:{name:`SLICC HAR Recorder`,version:`1.0.0`},entries:i}};return await this.fs.writeFile(c,JSON.stringify(l,null,2)),v.debug(`Saved HAR snapshot`,{recordingId:e.id,path:c,entryCount:i.length}),c}urlToSlug(e){try{let t=new URL(e);return`${t.hostname}${t.pathname}`.replace(/[^a-zA-Z0-9]/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``).slice(0,50)||`page`}catch{return`page`}}async stopRecording(e){let t=this.recordings.get(e);if(!t)throw Error(`Recording not found: ${e}`);await this.saveSnapshot(t,`close`);let n=this.eventCleanup.get(e);n&&(n(),this.eventCleanup.delete(e));try{await this.client.send(`Network.disable`,{},t.sessionId)}catch{}this.recordings.delete(e);let r=`/recordings/${e}`;return v.debug(`Stopped recording`,{recordingId:e,snapshotCount:t.snapshotCount}),r}getRecording(e){return this.recordings.get(e)}getRecordingByTarget(e){for(let[t,n]of this.recordings)if(n.targetId===e)return t}async ensureDir(e){await this.fs.mkdir(e,{recursive:!0})}};function b(e,t){try{let n=Function(`entry`,`return (${t})(entry);`),r=[];for(let t of e)try{let e=n(t);if(e===!1)continue;typeof e==`object`&&e?r.push(e):r.push(t)}catch(e){v.error(`Filter function error on entry, keeping it`,{error:e instanceof Error?e.message:String(e)}),r.push(t)}return r}catch(t){return v.error(`Failed to compile filter, returning unfiltered`,{error:t instanceof Error?t.message:String(t)}),e}}var x=class{maxSessions;onEvict;sessions=new Map;pinnedTargets=new Map;appliedSends=new Map;constructor(e=32,t){this.maxSessions=e,this.onEvict=t}get size(){return this.sessions.size}get(e){return this.sessions.get(e)}has(e){return this.sessions.has(e)}values(){return this.sessions.values()}entries(){return this.sessions.entries()}snapshot(){return[...this.sessions]}remember(e,t){this.pruneAppliedSends(),this.sessions.set(e,t),this.enforceCap(e)}touch(e,t){this.sessions.delete(e),this.sessions.set(e,t)}take(e){let t=this.sessions.get(e);return t&&this.sessions.delete(e),t}delete(e){this.sessions.delete(e)}clear(){this.sessions.clear()}pin(e){this.pinnedTargets.set(e,(this.pinnedTargets.get(e)??0)+1);let t=!1;return()=>{if(t)return;t=!0;let n=(this.pinnedTargets.get(e)??1)-1;n>0?this.pinnedTargets.set(e,n):this.pinnedTargets.delete(e),this.enforceCap()}}isPinned(e){return this.pinnedTargets.has(e)}enforceCap(e){for(;this.sessions.size>this.maxSessions;){let t;for(let n of this.sessions.keys())if(!(n===e||this.pinnedTargets.has(n))){t=n;break}if(t===void 0)return;let n=this.sessions.get(t);this.sessions.delete(t),n&&this.onEvict?.(t,n)}}noteApplied(e){this.appliedSends.set(e,(this.appliedSends.get(e)??0)+1)}appliedCount(e){return this.appliedSends.get(e)??0}pruneAppliedSends(){if(this.appliedSends.size<=this.maxSessions*4)return;let e=new Set([...this.sessions.values()].map(e=>e.sessionId));for(let t of[...this.appliedSends.keys()])e.has(t)||this.appliedSends.delete(t)}findBySessionId(e){for(let[t,n]of this.sessions)if(n.sessionId===e)return[t,n]}findByTargetOrLocalId(e){let t=[];for(let[n,r]of this.sessions)(n===e||r.remote?.localTargetId===e)&&t.push([n,r]);return t}anyOnTransport(e){for(let t of this.sessions.values())if(t.transport===e)return!0;return!1}anyMatchingRemote(e,t){for(let n of this.sessions.values())if(n.remote?.runtimeId===e&&n.remote.localTargetId===t)return!0;return!1}},S=`(function() {
1
+ import{t as e}from"./logger-DDBAeTLF.js";import"./navigation-watcher-CPcnZL9l.js";import"./wc-follower-oauth-qqfI5zJ5.js";import{d as t,l as n,u as r}from"./main-tEtVPbXh.js";import{n as i,t as a}from"./pending-request-table-k-D7ZZsL.js";var o=e(`cdp`);function s(e){return e===4001?`CDP connection superseded by another SLICC tab/window on this instance`:e===4002?`CDP connection reset by proxy (upstream Chrome connection was re-established)`:`CDP connection closed`}var c=class{ws=null;nextId=1;_superseded=!1;pending=new a;listeners=new Map;_state=`disconnected`;stateListeners=new Set;lastNotifiedState=`disconnected`;lastNotifiedReason;get state(){return this._state}onStateChange(e){return this.stateListeners.add(e),()=>{this.stateListeners.delete(e)}}get superseded(){return this._superseded}async connect(e){if(this._state!==`disconnected`)throw Error(`Cannot connect: state is ${this._state}`);if(!e?.url)throw Error(`CDPClient.connect() requires a WebSocket URL`);let{url:t,timeout:n=5e3,protocols:r}=e;return this._state=`connecting`,new Promise((e,i)=>{let a=setTimeout(()=>{this.cleanup(),i(Error(`CDP connection timed out after ${n}ms`))},n);try{this.ws=r===void 0?new WebSocket(t):new WebSocket(t,r)}catch(e){clearTimeout(a),this._state=`disconnected`,i(e);return}this.ws.onopen=()=>{clearTimeout(a),this._state=`connected`,this._superseded=!1,o.info(`Connected`,{url:t}),this.notifyState(`connected`),e()},this.ws.onerror=e=>{clearTimeout(a),this._state===`connecting`&&(o.error(`Connection failed`,{url:t}),this.cleanup(),i(Error(`CDP WebSocket connection failed`)))},this.ws.onmessage=e=>{this.handleMessage(e.data)},this.ws.onclose=e=>{this.handleClose(e?.code)}})}disconnect(){this.ws&&(this.ws.onclose=null,this.ws.close()),this._superseded=!1,this.cleanup(),o.info(`Disconnected`)}async send(e,t,n,r=3e4){if(this._state!==`connected`||!this.ws)throw Error(`CDP client is not connected`);let i=this.nextId++,a={id:i,method:e};t&&(a.params=t),n&&(a.sessionId=n),o.debug(`Send`,{method:e,id:i,sessionId:n});let s=this.pending.issue(i,r,`CDP command timed out after ${r}ms: ${e}`);return this.ws.send(JSON.stringify(a)),s}on(e,t){let n=this.listeners.get(e);n||(n=new Set,this.listeners.set(e,n)),n.add(t)}off(e,t){let n=this.listeners.get(e);n&&(n.delete(t),n.size===0&&this.listeners.delete(e))}once(e,t=3e4){return i(t=>(this.on(e,t),()=>this.off(e,t)),t,`Timed out waiting for event: ${e}`)}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}if(`id`in t&&typeof t.id==`number`){let e=t;o.debug(`Response`,{id:e.id,hasError:!!e.error}),e.error?(o.error(`Command error`,{id:e.id,code:e.error.code,message:e.error.message}),this.pending.reject(e.id,Error(`CDP error: ${e.error.message} (${e.error.code})`))):this.pending.resolve(e.id,e.result??{});return}if(`method`in t){let e=t;o.debug(`Event`,{method:e.method,sessionId:e.sessionId});let n=this.listeners.get(e.method);if(n){let t=e.sessionId?{...e.params,sessionId:e.sessionId}:e.params??{};for(let e of n)try{e(t)}catch{}}}}handleClose(e){e===4001?(this._superseded=!0,o.warn(`CDP slot superseded by another SLICC tab/window on this instance`,{code:e})):e===4002?o.warn(`CDP proxy reset its upstream Chrome connection — sessions dropped`,{code:e,pendingCommands:this.pending.size}):o.error(`Connection closed unexpectedly`,{pendingCommands:this.pending.size}),this.cleanup(s(e))}cleanup(e=`CDP client disconnected`){this.ws=null,this._state=`disconnected`,this.pending.rejectAll(e),this.notifyState(`disconnected`,e)}notifyState(e,t){if(e!==this.lastNotifiedState||t!==this.lastNotifiedReason){this.lastNotifiedState=e,this.lastNotifiedReason=t;for(let n of this.stateListeners)try{n(e,t)}catch{}}}},l=`ws://localhost:5710/cdp`;function u(e=typeof window<`u`?window.location:null){return e?.host?`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}/cdp`:l}var d=class{lastConnectOptions=null;supersededHandler=null;supersededNotified=!1;reconnectAttempt=0;reconnectNotBefore=0;bridgeRejection=null;bridgeRejectedHandler=null;bridgeRejectedNotified=!1;classifyConnectFailure=async()=>`transient`;primeConnectOptions(e){this.lastConnectOptions=e?{...e}:{}}setSupersededHandler(e){this.supersededHandler=e}setBridgeRejectedHandler(e){this.bridgeRejectedHandler=e}setConnectFailureClassifier(e){this.classifyConnectFailure=e}async connect(e,t){if(this.bridgeRejection)throw this.notifyBridgeRejected(),new n(this.bridgeRejection);this.lastConnectOptions=t?{...t}:{};try{await e.connect({url:t?.url??u(),timeout:t?.timeout,...t?.protocols===void 0?{}:{protocols:t.protocols}})}catch(e){throw await this.noteReconnectFailure(t),this.bridgeRejection?new n(this.bridgeRejection):e}this.noteReconnectSuccess()}async ensureLocalConnected(e){if(e.superseded===!0){this.notifySuperseded();return}if(e.state===`disconnected`){this.throwIfReconnectPaused();let t=this.lastConnectOptions;try{await e.connect({url:t?.url??u(),...t?.timeout===void 0?{}:{timeout:t.timeout},...t?.protocols===void 0?{}:{protocols:t.protocols}})}catch(e){throw await this.noteReconnectFailure(t??void 0),this.bridgeRejection?new n(this.bridgeRejection):e}this.noteReconnectSuccess()}}async ensureConnected(e){if(e.client.superseded===!0){this.notifySuperseded();return}if(e.client.state===`disconnected`){this.throwIfReconnectPaused();let t=e.client;e.restoreLocalAfterRemoteDrop(),e.clearSessionsForTransport(t),e.getClient().state===`disconnected`&&await this.connect(e.getClient(),this.lastConnectOptions??void 0)}}throwIfReconnectPaused(){if(this.bridgeRejection)throw this.notifyBridgeRejected(),new n(this.bridgeRejection);if(Date.now()<this.reconnectNotBefore)throw new r}noteReconnectSuccess(){this.reconnectAttempt=0,this.reconnectNotBefore=0,this.supersededNotified=!1}async noteReconnectFailure(e){if(await this.classifyConnectFailure({url:e?.url??``,...e?.protocols===void 0?{}:{protocols:e.protocols}})===`terminal`){this.bridgeRejection=new n().message,this.notifyBridgeRejected();return}let r=t(this.reconnectAttempt);this.reconnectAttempt+=1,this.reconnectNotBefore=Date.now()+r}notifyBridgeRejected(){if(!this.bridgeRejectedNotified){this.bridgeRejectedNotified=!0;try{this.bridgeRejectedHandler?.()}catch{}}}notifySuperseded(){if(!this.supersededNotified){this.supersededNotified=!0;try{this.supersededHandler?.()}catch{}}}},f=class extends Error{step;name=`CommandAbortedError`;constructor(e){super(`Browser command aborted while ${e}. A CDP round trip already in flight cannot be cancelled, so it may still have been applied to the page; nothing after it was started.`),this.step=e}};function p(e,t){if(e?.aborted)throw new f(t)}function m(e,t){return e?{signal:e,error:()=>new f(t)}:void 0}function h(e,t,n){return new Promise((r,i)=>{if(t?.aborted){i(new f(n));return}let a=()=>{clearTimeout(o),i(new f(n))},o=setTimeout(()=>{t?.removeEventListener(`abort`,a),r()},e);t?.addEventListener(`abort`,a,{once:!0})})}function g(e,t,n){return t?t.aborted?Promise.reject(new f(n)):new Promise((r,i)=>{let a=()=>i(new f(n));t.addEventListener(`abort`,a,{once:!0}),e.then(()=>{t.removeEventListener(`abort`,a),r()},e=>{t.removeEventListener(`abort`,a),i(e instanceof Error?e:Error(String(e)))})}):e}var _=class{contexts=new Map;for(e,t){let n=`${t}:${e}`,r=this.contexts.get(n);return r||(r=new Map,this.contexts.set(n,r)),r}peek(e,t){return this.contexts.get(`${t}:${e}`)}drop(e){this.contexts.delete(`main:${e}`),this.contexts.delete(`isolated:${e}`)}get size(){return this.contexts.size}},v=e(`har-recorder`),y=class{recordings=new Map;client;fs;eventCleanup=new Map;constructor(e,t){this.client=e,this.fs=t}async startRecording(e,t,n,r){let i=`rec-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;p(r,`about to enable Network on tab ${e}`),await this.client.send(`Network.enable`,{},t),p(r,`about to enable Page on tab ${e}`),await this.client.send(`Page.enable`,{},t),p(r,`about to read the URL of tab ${e}`);let a=(await this.client.send(`Runtime.evaluate`,{expression:`location.href`,returnByValue:!0},t)).result?.value??`about:blank`,o={id:i,targetId:e,sessionId:t,filterCode:n,pendingRequests:new Map,entries:[],startTime:Date.now(),currentUrl:a,snapshotCount:0};return this.recordings.set(i,o),this.setupEventListeners(o),await this.ensureDir(`/recordings/${i}`),v.debug(`Started recording`,{recordingId:i,targetId:e,currentUrl:a}),i}setupEventListeners(e){let{sessionId:t,id:n}=e,r=n=>{let r=n;r.sessionId===t&&this.handleRequestWillBeSent(e,r)},i=n=>{let r=n;r.sessionId===t&&this.handleResponseReceived(e,r)},a=r=>{let i=r;i.sessionId===t&&this.handleLoadingFinished(e,i).catch(e=>{v.error(`Failed to process loadingFinished event`,{recordingId:n,requestId:i.requestId,error:e instanceof Error?e.message:String(e)})})},o=n=>{let r=n;r.sessionId===t&&this.handleLoadingFailed(e,r)},s=r=>{let i=r;if(i.sessionId!==t)return;let a=i.frame;if(!a?.parentId&&a?.url){let t=[...e.entries],r=e.currentUrl;e.currentUrl=a.url,e.entries=[],e.pendingRequests.clear(),this.saveSnapshotWithEntries(e,`navigation`,t,r).catch(e=>{v.error(`Failed to save navigation snapshot`,{recordingId:n,error:e instanceof Error?e.message:String(e)})})}};this.client.on(`Network.requestWillBeSent`,r),this.client.on(`Network.responseReceived`,i),this.client.on(`Network.loadingFinished`,a),this.client.on(`Network.loadingFailed`,o),this.client.on(`Page.frameNavigated`,s),this.eventCleanup.set(n,()=>{this.client.off(`Network.requestWillBeSent`,r),this.client.off(`Network.responseReceived`,i),this.client.off(`Network.loadingFinished`,a),this.client.off(`Network.loadingFailed`,o),this.client.off(`Page.frameNavigated`,s)})}handleRequestWillBeSent(e,t){let{requestId:n,request:r,timestamp:i}=t;!n||!r||i==null||e.pendingRequests.set(n,{requestId:n,startTime:i*1e3,request:{method:r.method,url:r.url,headers:r.headers,postData:r.postData}})}handleResponseReceived(e,t){let{requestId:n,response:r}=t;if(!n||!r)return;let i=e.pendingRequests.get(n);i&&(i.response={status:r.status,statusText:r.statusText,headers:r.headers,mimeType:r.mimeType},i.timing=r.timing)}async handleLoadingFinished(e,t){let{requestId:n,timestamp:r}=t;if(!n||r==null)return;let i=e.pendingRequests.get(n);if(!i)return;i.endTime=r*1e3;try{let t=await this.client.send(`Network.getResponseBody`,{requestId:n},e.sessionId);i.responseBody=t.body,i.responseBodyBase64=t.base64Encoded===!0}catch{}let a=this.buildHarEntry(i);a&&e.entries.push(a),e.pendingRequests.delete(n)}handleLoadingFailed(e,t){let{requestId:n}=t;n&&e.pendingRequests.delete(n)}buildHarEntry(e){if(!e.response)return null;let{request:t,response:n,timing:r,startTime:i,endTime:a,responseBody:o,responseBodyBase64:s}=e,c=a?a-i:0,l=[];try{let e=new URL(t.url);l=Array.from(e.searchParams.entries()).map(([e,t])=>({name:e,value:t}))}catch{}let u=r?(()=>{let e=(e,t)=>{if(e==null||t==null||e<0||t<0)return-1;let n=t-e;return n>=0?n:-1},t=r.dnsStart>=0?r.dnsStart:r.connectStart>=0?r.connectStart:0;return{blocked:t>0?t:-1,dns:e(r.dnsStart,r.dnsEnd),connect:e(r.connectStart,r.connectEnd),ssl:e(r.sslStart,r.sslEnd),send:e(r.sendStart,r.sendEnd),wait:e(r.sendEnd,r.receiveHeadersStart),receive:e(r.receiveHeadersStart,r.receiveHeadersEnd)}})():{blocked:-1,dns:-1,connect:-1,ssl:-1,send:0,wait:c,receive:0},d={size:o?.length??0,mimeType:n.mimeType??`application/octet-stream`};o&&(d.text=o,s&&(d.encoding=`base64`));let f;return t.postData&&(f={mimeType:t.headers[`content-type`]??t.headers[`Content-Type`]??`text/plain`,text:t.postData}),{startedDateTime:new Date(i).toISOString(),time:c,request:{method:t.method,url:t.url,httpVersion:`HTTP/1.1`,cookies:[],headers:Object.entries(t.headers).map(([e,t])=>({name:e,value:t})),queryString:l,postData:f,headersSize:-1,bodySize:t.postData?.length??0},response:{status:n.status,statusText:n.statusText,httpVersion:`HTTP/1.1`,cookies:[],headers:Object.entries(n.headers).map(([e,t])=>({name:e,value:t})),content:d,redirectURL:n.headers.location??n.headers.Location??``,headersSize:-1,bodySize:d.size},cache:{},timings:u}}async saveSnapshot(e,t){return this.saveSnapshotWithEntries(e,t,e.entries,e.currentUrl)}async applyFilter(e,t){return b(e,t)}async saveSnapshotWithEntries(e,t,n,r){if(n.length===0)return v.debug(`No entries to save`,{recordingId:e.id,trigger:t}),null;let i=e.filterCode?await this.applyFilter(n,e.filterCode):n;if(i.length===0)return v.debug(`All entries filtered out`,{recordingId:e.id,trigger:t}),null;e.snapshotCount++;let a=new Date().toISOString().replace(/[:.]/g,`-`),o=this.urlToSlug(r),s=`${e.snapshotCount.toString().padStart(3,`0`)}-${a}-${t}-${o}.har`,c=`/recordings/${e.id}/${s}`,l={log:{version:`1.2`,creator:{name:`SLICC HAR Recorder`,version:`1.0.0`},entries:i}};return await this.fs.writeFile(c,JSON.stringify(l,null,2)),v.debug(`Saved HAR snapshot`,{recordingId:e.id,path:c,entryCount:i.length}),c}urlToSlug(e){try{let t=new URL(e);return`${t.hostname}${t.pathname}`.replace(/[^a-zA-Z0-9]/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``).slice(0,50)||`page`}catch{return`page`}}async stopRecording(e){let t=this.recordings.get(e);if(!t)throw Error(`Recording not found: ${e}`);await this.saveSnapshot(t,`close`);let n=this.eventCleanup.get(e);n&&(n(),this.eventCleanup.delete(e));try{await this.client.send(`Network.disable`,{},t.sessionId)}catch{}this.recordings.delete(e);let r=`/recordings/${e}`;return v.debug(`Stopped recording`,{recordingId:e,snapshotCount:t.snapshotCount}),r}getRecording(e){return this.recordings.get(e)}getRecordingByTarget(e){for(let[t,n]of this.recordings)if(n.targetId===e)return t}async ensureDir(e){await this.fs.mkdir(e,{recursive:!0})}};function b(e,t){try{let n=Function(`entry`,`return (${t})(entry);`),r=[];for(let t of e)try{let e=n(t);if(e===!1)continue;typeof e==`object`&&e?r.push(e):r.push(t)}catch(e){v.error(`Filter function error on entry, keeping it`,{error:e instanceof Error?e.message:String(e)}),r.push(t)}return r}catch(t){return v.error(`Failed to compile filter, returning unfiltered`,{error:t instanceof Error?t.message:String(t)}),e}}var x=class{maxSessions;onEvict;sessions=new Map;pinnedTargets=new Map;appliedSends=new Map;constructor(e=32,t){this.maxSessions=e,this.onEvict=t}get size(){return this.sessions.size}get(e){return this.sessions.get(e)}has(e){return this.sessions.has(e)}values(){return this.sessions.values()}entries(){return this.sessions.entries()}snapshot(){return[...this.sessions]}remember(e,t){this.pruneAppliedSends(),this.sessions.set(e,t),this.enforceCap(e)}touch(e,t){this.sessions.delete(e),this.sessions.set(e,t)}take(e){let t=this.sessions.get(e);return t&&this.sessions.delete(e),t}delete(e){this.sessions.delete(e)}clear(){this.sessions.clear()}pin(e){this.pinnedTargets.set(e,(this.pinnedTargets.get(e)??0)+1);let t=!1;return()=>{if(t)return;t=!0;let n=(this.pinnedTargets.get(e)??1)-1;n>0?this.pinnedTargets.set(e,n):this.pinnedTargets.delete(e),this.enforceCap()}}isPinned(e){return this.pinnedTargets.has(e)}enforceCap(e){for(;this.sessions.size>this.maxSessions;){let t;for(let n of this.sessions.keys())if(!(n===e||this.pinnedTargets.has(n))){t=n;break}if(t===void 0)return;let n=this.sessions.get(t);this.sessions.delete(t),n&&this.onEvict?.(t,n)}}noteApplied(e){this.appliedSends.set(e,(this.appliedSends.get(e)??0)+1)}appliedCount(e){return this.appliedSends.get(e)??0}pruneAppliedSends(){if(this.appliedSends.size<=this.maxSessions*4)return;let e=new Set([...this.sessions.values()].map(e=>e.sessionId));for(let t of[...this.appliedSends.keys()])e.has(t)||this.appliedSends.delete(t)}findBySessionId(e){for(let[t,n]of this.sessions)if(n.sessionId===e)return[t,n]}findByTargetOrLocalId(e){let t=[];for(let[n,r]of this.sessions)(n===e||r.remote?.localTargetId===e)&&t.push([n,r]);return t}anyOnTransport(e){for(let t of this.sessions.values())if(t.transport===e)return!0;return!1}anyMatchingRemote(e,t){for(let n of this.sessions.values())if(n.remote?.runtimeId===e&&n.remote.localTargetId===t)return!0;return!1}},S=`(function() {
2
2
  'use strict';
3
3
 
4
4
  // ===== DOM Utilities =====
@@ -1 +1 @@
1
- import{a as e}from"./account-store-BXs7YUd1.js";import{a as t}from"./diagnostics-DN_idNHx.js";import{a as n}from"./compat-uEPf6-XW.js";import{r,s as i}from"./legacy-api-aliases-jKEvBgOL.js";const a=`cerebras`,o=`https://api.cerebras.ai/v1`,s=`openai-completions`,c=`${a}-openai`,l=`slicc-cerebras-models`;let u=[];const d=[{id:`gpt-oss-120b`,name:`GPT OSS 120B`,api:`openai`,reasoning:!0,input:[`text`],context_window:131072,max_tokens:40960},{id:`gemma-4-31b`,name:`Gemma 4 31B`,api:`openai`,reasoning:!1,input:[`text`,`image`],context_window:131072,max_tokens:40960},{id:`zai-glm-4.7`,name:`Z.AI GLM-4.7`,api:`openai`,reasoning:!1,input:[`text`],context_window:131072,max_tokens:40960}];function f(e){try{localStorage.setItem(l,JSON.stringify(e))}catch{}}function p(){try{let e=localStorage.getItem(l);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function m(e){let t=e.id??``,n=d.find(e=>e.id===t);return{id:t,name:e.name??n?.name??t,api:`openai`,reasoning:e.capabilities?.reasoning??n?.reasoning??!1,input:e.capabilities?.vision?[`text`,`image`]:n?.input??[`text`],context_window:e.limits?.max_context_length??n?.context_window??8192,max_tokens:e.limits?.max_completion_tokens??n?.max_tokens??4096}}async function h(e){let t=await fetch(`${o}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(m).filter(e=>e.id.length>0);n.length>0&&(u=n,f(n))}function g(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:c,provider:a,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){console.error(`[cerebras] Stream error:`,e instanceof Error?e.message:String(e))}const v=(e,n,r={})=>{let i=t();return y(i,e,n,r).catch(_),i};async function y(e,t,n,i){try{let a={...t,baseUrl:o,api:s},c=r(a,n,i);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}const b=(e,n,r)=>{let i=t();return x(i,e,n,r).catch(_),i};async function x(e,t,n,r){try{let a={...t,baseUrl:o,api:s},c=i(a,n,r);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}const S={id:a,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(u.length>0)return u;let e=p();return e.length>0?e:d},refreshModels:async t=>{let n=t??e(a)??``;if(n)try{await h(n)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function C(){n({api:c,stream:v,streamSimple:b})}export{S as config,C as register};
1
+ import{a as e}from"./account-store-CwNcf5Wq.js";import{a as t}from"./diagnostics-DN_idNHx.js";import{a as n}from"./compat-uEPf6-XW.js";import{r,s as i}from"./legacy-api-aliases-jKEvBgOL.js";const a=`cerebras`,o=`https://api.cerebras.ai/v1`,s=`openai-completions`,c=`${a}-openai`,l=`slicc-cerebras-models`;let u=[];const d=[{id:`gpt-oss-120b`,name:`GPT OSS 120B`,api:`openai`,reasoning:!0,input:[`text`],context_window:131072,max_tokens:40960},{id:`gemma-4-31b`,name:`Gemma 4 31B`,api:`openai`,reasoning:!1,input:[`text`,`image`],context_window:131072,max_tokens:40960},{id:`zai-glm-4.7`,name:`Z.AI GLM-4.7`,api:`openai`,reasoning:!1,input:[`text`],context_window:131072,max_tokens:40960}];function f(e){try{localStorage.setItem(l,JSON.stringify(e))}catch{}}function p(){try{let e=localStorage.getItem(l);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function m(e){let t=e.id??``,n=d.find(e=>e.id===t);return{id:t,name:e.name??n?.name??t,api:`openai`,reasoning:e.capabilities?.reasoning??n?.reasoning??!1,input:e.capabilities?.vision?[`text`,`image`]:n?.input??[`text`],context_window:e.limits?.max_context_length??n?.context_window??8192,max_tokens:e.limits?.max_completion_tokens??n?.max_tokens??4096}}async function h(e){let t=await fetch(`${o}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(m).filter(e=>e.id.length>0);n.length>0&&(u=n,f(n))}function g(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:c,provider:a,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){console.error(`[cerebras] Stream error:`,e instanceof Error?e.message:String(e))}const v=(e,n,r={})=>{let i=t();return y(i,e,n,r).catch(_),i};async function y(e,t,n,i){try{let a={...t,baseUrl:o,api:s},c=r(a,n,i);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}const b=(e,n,r)=>{let i=t();return x(i,e,n,r).catch(_),i};async function x(e,t,n,r){try{let a={...t,baseUrl:o,api:s},c=i(a,n,r);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}const S={id:a,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(u.length>0)return u;let e=p();return e.length>0?e:d},refreshModels:async t=>{let n=t??e(a)??``;if(n)try{await h(n)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function C(){n({api:c,stream:v,streamSimple:b})}export{S as config,C as register};
@@ -1 +1 @@
1
- import{a as e}from"./diagnostics-DN_idNHx.js";import{a as t}from"./compat-Dy2zIWAW.js";import{r as n,s as r}from"./legacy-api-aliases-DoI0tM7F.js";import{_ as i}from"./account-store-Bj2sWuL9.js";var a=`cerebras`,o=`https://api.cerebras.ai/v1`,s=`openai-completions`,c=`${a}-openai`,l=`slicc-cerebras-models`,u=[],d=[{id:`gpt-oss-120b`,name:`GPT OSS 120B`,api:`openai`,reasoning:!0,input:[`text`],context_window:131072,max_tokens:40960},{id:`gemma-4-31b`,name:`Gemma 4 31B`,api:`openai`,reasoning:!1,input:[`text`,`image`],context_window:131072,max_tokens:40960},{id:`zai-glm-4.7`,name:`Z.AI GLM-4.7`,api:`openai`,reasoning:!1,input:[`text`],context_window:131072,max_tokens:40960}];function f(e){try{localStorage.setItem(l,JSON.stringify(e))}catch{}}function p(){try{let e=localStorage.getItem(l);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function m(e){let t=e.id??``,n=d.find(e=>e.id===t);return{id:t,name:e.name??n?.name??t,api:`openai`,reasoning:e.capabilities?.reasoning??n?.reasoning??!1,input:e.capabilities?.vision?[`text`,`image`]:n?.input??[`text`],context_window:e.limits?.max_context_length??n?.context_window??8192,max_tokens:e.limits?.max_completion_tokens??n?.max_tokens??4096}}async function h(e){let t=await fetch(`${o}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(m).filter(e=>e.id.length>0);n.length>0&&(u=n,f(n))}function g(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:c,provider:a,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){console.error(`[cerebras] Stream error:`,e instanceof Error?e.message:String(e))}var v=(t,n,r={})=>{let i=e();return y(i,t,n,r).catch(_),i};async function y(e,t,r,i){try{let a={...t,baseUrl:o,api:s},c=n(a,r,i);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}var b=(t,n,r)=>{let i=e();return x(i,t,n,r).catch(_),i};async function x(e,t,n,i){try{let a={...t,baseUrl:o,api:s},c=r(a,n,i);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}var S={id:a,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(u.length>0)return u;let e=p();return e.length>0?e:d},refreshModels:async e=>{let t=e??i(a)??``;if(t)try{await h(t)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function C(){t({api:c,stream:v,streamSimple:b})}export{S as config,C as register};
1
+ import{a as e}from"./diagnostics-DN_idNHx.js";import{a as t}from"./compat-Dy2zIWAW.js";import{r as n,s as r}from"./legacy-api-aliases-DoI0tM7F.js";import{_ as i}from"./account-store-nlKbTUhJ.js";var a=`cerebras`,o=`https://api.cerebras.ai/v1`,s=`openai-completions`,c=`${a}-openai`,l=`slicc-cerebras-models`,u=[],d=[{id:`gpt-oss-120b`,name:`GPT OSS 120B`,api:`openai`,reasoning:!0,input:[`text`],context_window:131072,max_tokens:40960},{id:`gemma-4-31b`,name:`Gemma 4 31B`,api:`openai`,reasoning:!1,input:[`text`,`image`],context_window:131072,max_tokens:40960},{id:`zai-glm-4.7`,name:`Z.AI GLM-4.7`,api:`openai`,reasoning:!1,input:[`text`],context_window:131072,max_tokens:40960}];function f(e){try{localStorage.setItem(l,JSON.stringify(e))}catch{}}function p(){try{let e=localStorage.getItem(l);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function m(e){let t=e.id??``,n=d.find(e=>e.id===t);return{id:t,name:e.name??n?.name??t,api:`openai`,reasoning:e.capabilities?.reasoning??n?.reasoning??!1,input:e.capabilities?.vision?[`text`,`image`]:n?.input??[`text`],context_window:e.limits?.max_context_length??n?.context_window??8192,max_tokens:e.limits?.max_completion_tokens??n?.max_tokens??4096}}async function h(e){let t=await fetch(`${o}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(m).filter(e=>e.id.length>0);n.length>0&&(u=n,f(n))}function g(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:c,provider:a,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){console.error(`[cerebras] Stream error:`,e instanceof Error?e.message:String(e))}var v=(t,n,r={})=>{let i=e();return y(i,t,n,r).catch(_),i};async function y(e,t,r,i){try{let a={...t,baseUrl:o,api:s},c=n(a,r,i);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}var b=(t,n,r)=>{let i=e();return x(i,t,n,r).catch(_),i};async function x(e,t,n,i){try{let a={...t,baseUrl:o,api:s},c=r(a,n,i);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}var S={id:a,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(u.length>0)return u;let e=p();return e.length>0?e:d},refreshModels:async e=>{let t=e??i(a)??``;if(t)try{await h(t)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function C(){t({api:c,stream:v,streamSimple:b})}export{S as config,C as register};
@@ -1 +1 @@
1
- import{t as e}from"./logger-DDBAeTLF.js";import{st as t}from"./wc-shell-DWs7UK-n.js";import{n}from"./runtime-env-Dlaokqg1.js";import{t as r}from"./permissions-surface-registry-CilCRwhh.js";import{t as i}from"./speech-assets-bridge-CFYafE89.js";import{o as a}from"./transformers-env-G9ZvPj4i.js";import{i as o,t as s}from"./whisper-session-CjnOyfPM.js";var c=e(`speech:composer`),l=5e3,u=(e,t,n)=>new Promise((r,i)=>{let a=setTimeout(()=>i(Error(`${n} timed out after ${t}ms`)),t);e.then(e=>{clearTimeout(a),r(e)},e=>{clearTimeout(a),i(e)})}),d=class{#e;#t;#n;#r;#i;#a=null;#o=!1;#s={engine:`builtin`,state:`idle`};#c=a();#l=new Set;#u=null;constructor(e={}){this.#e=e.builtin??t(),this.#t=e.loadWhisper??o,this.#n=e.startSession??s,this.#r=e.getPermissionSurface??f,this.#i=e.ensureAssets??v}permission(){return this.#e.permission()}async requestPermission(){let e=this.#r();if(e)try{let t=await e.request(`microphone`);return t?(this.#p(t.stream),!0):!1}catch(e){return c.warn(`permission surface microphone request failed`,e),!1}return this.#e.requestPermission()}microphones(){return this.#e.microphones()}status(){return this.#s}onStatus(e){return this.#l.add(e),e(this.#s),()=>this.#l.delete(e)}warmup(){this.#o||(this.#o=!0,this.#c=a(),this.#_({engine:`builtin`,state:`downloading`}),this.#d().then(e=>{this.#a=e,this.#_({engine:`enhanced`,state:`ready`})},e=>{this.#o=!1,this.#_({engine:`builtin`,state:`unavailable`,message:m(e)}),c.warn(`enhanced speech engine unavailable`,e)}))}async#d(){let e=null;try{await this.#i(e=>this.#h(e))}catch(t){e=t,c.warn(`speech asset staging failed; trying already-present assets`,t)}try{return await this.#t(e=>this.#g(e))}catch(t){throw e??t}}async start(e){let t=this.#a;if(t){let n=null;try{return n=await this.#f(e.deviceId),await this.#n(t,{deviceId:e.deviceId,lang:e.lang,onPartial:e.onPartial,onError:e.onError,stream:n??void 0})}catch(e){if(n)for(let e of n.getTracks())e.stop();c.warn(`whisper session failed to start; falling back to builtin`,e)}}return this.#e.start(e)}async#f(e){let t=e&&e!=="default"?e:void 0,n=this.#m();if(n){if(!t&&p(n))return n;for(let e of n.getTracks())e.stop()}let r=this.#r();if(!r)return null;let i={audio:!t||{deviceId:{exact:t}}},a=await u(r.request(`microphone`,{constraints:i}),l,`microphone capture`);if(!a)throw Error(`microphone permission denied`);return a.stream}#p(e){if(this.#u&&this.#u!==e)for(let e of this.#u.getTracks())e.stop();this.#u=e}#m(){let e=this.#u;return this.#u=null,e}get enhancedReady(){return this.#a!==null}#h(e){if(this.#s.state!==`downloading`)return;(e.bytesTotal!=null||e.bytesLoaded!=null)&&this.#c.update(e.asset,e.bytesLoaded??0,e.bytesTotal??0);let t=this.#c.snapshot();t.total<=0||this.#_({engine:`builtin`,state:`downloading`,download:{loaded:t.loaded,total:t.total,etaSeconds:t.etaSeconds}})}#g(e){this.#s.state===`downloading`&&this.#_({engine:`builtin`,state:`downloading`,download:{loaded:e.loaded,total:e.total,etaSeconds:e.etaSeconds}})}#_(e){this.#s=e;for(let t of this.#l)t(e)}};function f(){let e=r();return e?{async request(t,n){let r=await e.request(t,n);return r?.kind===`microphone`?{kind:`microphone`,stream:r.stream}:null}}:null}function p(e){let t=e.getTracks();return t.length>0&&t.some(e=>e.readyState!==`ended`)}function m(e){return`Enhanced speech unavailable: ${e instanceof Error?e.message:String(e)}`}var h=n,g;function _(e){g=e}function v(e){return h()?Promise.resolve():i({instanceId:g,onProgress:e})}var y=null;function b(){return y??=new d,y}export{b as getComposerSpeech,_ as setComposerSpeechInstanceId};
1
+ import{t as e}from"./logger-DDBAeTLF.js";import{st as t}from"./wc-shell-DdE40qZj.js";import{n}from"./runtime-env-Dlaokqg1.js";import{t as r}from"./permissions-surface-registry-CilCRwhh.js";import{t as i}from"./speech-assets-bridge-CFYafE89.js";import{o as a}from"./transformers-env-DuP48CFD.js";import{i as o,t as s}from"./whisper-session-CB6rG-eD.js";var c=e(`speech:composer`),l=5e3,u=(e,t,n)=>new Promise((r,i)=>{let a=setTimeout(()=>i(Error(`${n} timed out after ${t}ms`)),t);e.then(e=>{clearTimeout(a),r(e)},e=>{clearTimeout(a),i(e)})}),d=class{#e;#t;#n;#r;#i;#a=null;#o=!1;#s={engine:`builtin`,state:`idle`};#c=a();#l=new Set;#u=null;constructor(e={}){this.#e=e.builtin??t(),this.#t=e.loadWhisper??o,this.#n=e.startSession??s,this.#r=e.getPermissionSurface??f,this.#i=e.ensureAssets??v}permission(){return this.#e.permission()}async requestPermission(){let e=this.#r();if(e)try{let t=await e.request(`microphone`);return t?(this.#p(t.stream),!0):!1}catch(e){return c.warn(`permission surface microphone request failed`,e),!1}return this.#e.requestPermission()}microphones(){return this.#e.microphones()}status(){return this.#s}onStatus(e){return this.#l.add(e),e(this.#s),()=>this.#l.delete(e)}warmup(){this.#o||(this.#o=!0,this.#c=a(),this.#_({engine:`builtin`,state:`downloading`}),this.#d().then(e=>{this.#a=e,this.#_({engine:`enhanced`,state:`ready`})},e=>{this.#o=!1,this.#_({engine:`builtin`,state:`unavailable`,message:m(e)}),c.warn(`enhanced speech engine unavailable`,e)}))}async#d(){let e=null;try{await this.#i(e=>this.#h(e))}catch(t){e=t,c.warn(`speech asset staging failed; trying already-present assets`,t)}try{return await this.#t(e=>this.#g(e))}catch(t){throw e??t}}async start(e){let t=this.#a;if(t){let n=null;try{return n=await this.#f(e.deviceId),await this.#n(t,{deviceId:e.deviceId,lang:e.lang,onPartial:e.onPartial,onError:e.onError,stream:n??void 0})}catch(e){if(n)for(let e of n.getTracks())e.stop();c.warn(`whisper session failed to start; falling back to builtin`,e)}}return this.#e.start(e)}async#f(e){let t=e&&e!=="default"?e:void 0,n=this.#m();if(n){if(!t&&p(n))return n;for(let e of n.getTracks())e.stop()}let r=this.#r();if(!r)return null;let i={audio:!t||{deviceId:{exact:t}}},a=await u(r.request(`microphone`,{constraints:i}),l,`microphone capture`);if(!a)throw Error(`microphone permission denied`);return a.stream}#p(e){if(this.#u&&this.#u!==e)for(let e of this.#u.getTracks())e.stop();this.#u=e}#m(){let e=this.#u;return this.#u=null,e}get enhancedReady(){return this.#a!==null}#h(e){if(this.#s.state!==`downloading`)return;(e.bytesTotal!=null||e.bytesLoaded!=null)&&this.#c.update(e.asset,e.bytesLoaded??0,e.bytesTotal??0);let t=this.#c.snapshot();t.total<=0||this.#_({engine:`builtin`,state:`downloading`,download:{loaded:t.loaded,total:t.total,etaSeconds:t.etaSeconds}})}#g(e){this.#s.state===`downloading`&&this.#_({engine:`builtin`,state:`downloading`,download:{loaded:e.loaded,total:e.total,etaSeconds:e.etaSeconds}})}#_(e){this.#s=e;for(let t of this.#l)t(e)}};function f(){let e=r();return e?{async request(t,n){let r=await e.request(t,n);return r?.kind===`microphone`?{kind:`microphone`,stream:r.stream}:null}}:null}function p(e){let t=e.getTracks();return t.length>0&&t.some(e=>e.readyState!==`ended`)}function m(e){return`Enhanced speech unavailable: ${e instanceof Error?e.message:String(e)}`}var h=n,g;function _(e){g=e}function v(e){return h()?Promise.resolve():i({instanceId:g,onProgress:e})}var y=null;function b(){return y??=new d,y}export{b as getComposerSpeech,_ as setComposerSpeechInstanceId};
@@ -1,4 +1,4 @@
1
- import{B as e,E as t,f as n,p as r}from"./account-store-Bj2sWuL9.js";import{a as i}from"./main-CXeU8DQz.js";var a=`slicc_cloud_model_catalog`,o=`adobe`;function s(e){if(e===o)return!1;let n=t(e);return!(n.hidden||n.onOAuthLoginIntercepted)}function c(){try{let e=r().map(e=>({providerId:e.providerId,providerName:e.providerName,models:e.models.map(e=>({id:e.id,name:e.name}))}));localStorage.setItem(a,JSON.stringify(e))}catch{}}async function l(r){for(;r.firstChild;)r.removeChild(r.firstChild);r.className=`connect-surface`;let a=document.createElement(`h1`);a.className=`connect-surface__title`,a.textContent=`Connect providers`,r.appendChild(a);let l=document.createElement(`p`);l.className=`connect-surface__desc`,l.textContent=`Log in or add API keys for the providers your cone should use, then click Done to return to the dashboard.`,r.appendChild(l);let u=document.createElement(`div`);u.className=`connect-surface__accounts`,r.appendChild(u);function d(){for(;u.firstChild;)u.removeChild(u.firstChild);let r=n().filter(e=>e.providerId!==o);if(r.length===0){let e=document.createElement(`div`);e.className=`connect-surface__empty`,e.textContent=`No providers connected yet.`,u.appendChild(e)}else{let n=document.createElement(`div`);n.className=`connect-surface__accounts-list`;for(let i of r){let r=t(i.providerId),a=document.createElement(`div`);a.className=`connect-surface__account-row`;let o=document.createElement(`div`);o.className=`connect-surface__account-info`;let s=document.createElement(`div`);s.className=`connect-surface__account-name`,s.textContent=r.name,o.appendChild(s);let l=document.createElement(`div`);l.className=`connect-surface__account-detail`,l.textContent=i.userName?i.userName:i.accessToken?`Logged in`:i.apiKey?`API key set`:`No credentials`,o.appendChild(l),a.appendChild(o);let u=document.createElement(`button`);u.className=`connect-surface__remove-btn`,u.textContent=`Remove`,u.onclick=async()=>{await e(i.providerId),c(),d()},a.appendChild(u),n.appendChild(a)}u.appendChild(n)}let a=document.createElement(`button`);a.className=`connect-surface__add-btn`,a.textContent=r.length===0?`Add provider`:`Manage providers`,a.onclick=async()=>{await i({startInAddAccount:!0,providerFilter:s})&&(c(),d())},u.appendChild(a)}d(),c();let f=document.createElement(`div`);f.className=`connect-surface__footer`;let p=document.createElement(`button`);if(p.className=`connect-surface__done-btn`,p.textContent=`Done — return to dashboard`,p.onclick=()=>{c(),window.close()},f.appendChild(p),r.appendChild(f),!document.getElementById(`connect-surface-style`)){let e=document.createElement(`style`);e.id=`connect-surface-style`,e.textContent=`
1
+ import{B as e,E as t,f as n,p as r}from"./account-store-nlKbTUhJ.js";import{a as i}from"./main-tEtVPbXh.js";var a=`slicc_cloud_model_catalog`,o=`adobe`;function s(e){if(e===o)return!1;let n=t(e);return!(n.hidden||n.onOAuthLoginIntercepted)}function c(){try{let e=r().map(e=>({providerId:e.providerId,providerName:e.providerName,models:e.models.map(e=>({id:e.id,name:e.name}))}));localStorage.setItem(a,JSON.stringify(e))}catch{}}async function l(r){for(;r.firstChild;)r.removeChild(r.firstChild);r.className=`connect-surface`;let a=document.createElement(`h1`);a.className=`connect-surface__title`,a.textContent=`Connect providers`,r.appendChild(a);let l=document.createElement(`p`);l.className=`connect-surface__desc`,l.textContent=`Log in or add API keys for the providers your cone should use, then click Done to return to the dashboard.`,r.appendChild(l);let u=document.createElement(`div`);u.className=`connect-surface__accounts`,r.appendChild(u);function d(){for(;u.firstChild;)u.removeChild(u.firstChild);let r=n().filter(e=>e.providerId!==o);if(r.length===0){let e=document.createElement(`div`);e.className=`connect-surface__empty`,e.textContent=`No providers connected yet.`,u.appendChild(e)}else{let n=document.createElement(`div`);n.className=`connect-surface__accounts-list`;for(let i of r){let r=t(i.providerId),a=document.createElement(`div`);a.className=`connect-surface__account-row`;let o=document.createElement(`div`);o.className=`connect-surface__account-info`;let s=document.createElement(`div`);s.className=`connect-surface__account-name`,s.textContent=r.name,o.appendChild(s);let l=document.createElement(`div`);l.className=`connect-surface__account-detail`,l.textContent=i.userName?i.userName:i.accessToken?`Logged in`:i.apiKey?`API key set`:`No credentials`,o.appendChild(l),a.appendChild(o);let u=document.createElement(`button`);u.className=`connect-surface__remove-btn`,u.textContent=`Remove`,u.onclick=async()=>{await e(i.providerId),c(),d()},a.appendChild(u),n.appendChild(a)}u.appendChild(n)}let a=document.createElement(`button`);a.className=`connect-surface__add-btn`,a.textContent=r.length===0?`Add provider`:`Manage providers`,a.onclick=async()=>{await i({startInAddAccount:!0,providerFilter:s})&&(c(),d())},u.appendChild(a)}d(),c();let f=document.createElement(`div`);f.className=`connect-surface__footer`;let p=document.createElement(`button`);if(p.className=`connect-surface__done-btn`,p.textContent=`Done — return to dashboard`,p.onclick=()=>{c(),window.close()},f.appendChild(p),r.appendChild(f),!document.getElementById(`connect-surface-style`)){let e=document.createElement(`style`);e.id=`connect-surface-style`,e.textContent=`
2
2
  .connect-surface {
3
3
  padding: 2rem;
4
4
  max-width: 560px;
@@ -33,4 +33,4 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
33
33
  `}}return e?(p+=`
34
34
  `+B(l(e),c),s&&s()):d&&o&&o(),p}function Ye({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(N(i))i.spaceBefore&&d.push(``),Xe(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(A(i)){let e=N(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),Xe(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=N(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=Ie(i,c,()=>a=null);l||=d.length>u||o.includes(`
35
35
  `),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=V(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
36
- `;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function Xe({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=B(t(r),e);n.push(i.trimStart())}}function G(e,t){let n=j(t)?t.value:t;for(let r of e)if(A(r)&&(r.key===t||r.key===n||j(r.key)&&r.key.value===n))return r}var K=class extends be{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(w,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(Ke(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=A(e)?e:!e||typeof e!=`object`||!(`key`in e)?new W(e,e?.value):new W(e.key,e.value);let r=G(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);j(r.value)&&he(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=G(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=G(this.items,e)?.value;return(!t&&j(n)?n.value:n)??void 0}has(e){return!!G(this.items,e)}set(e,t){this.add(new W(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)We(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!A(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),qe(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}};const Ze={collection:`map`,default:!0,nodeClass:K,tag:`tag:yaml.org,2002:map`,resolve(e,t){return k(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>K.from(e,t,n)};var Qe=class extends be{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(T,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=$e(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=$e(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&j(r)?r.value:r}has(e){let t=$e(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=$e(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];j(r)&&he(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(R(e,String(r++),t));return n}toString(e,t,n){return e?qe(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(_e(a,void 0,n))}}return i}};function $e(e){let t=j(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}const et={collection:`seq`,default:!0,nodeClass:Qe,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return ie(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>Qe.from(e,t,n)};function tt(e){return typeof e==`bigint`||Number.isInteger(e)}const nt=({value:e})=>JSON.stringify(e),rt=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:nt},{identify:e=>e==null,createNode:()=>new z(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:nt},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:nt},{identify:tt,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>tt(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:nt}];[Ze,et].concat(rt,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}});function it(e,t,n){let{replacer:r}=n,i=new Qe(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(Ke(o,s,n))}return i}var at=class e extends Qe{constructor(){super(),this.add=K.prototype.add.bind(this),this.delete=K.prototype.delete.bind(this),this.get=K.prototype.get.bind(this),this.has=K.prototype.has.bind(this),this.set=K.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(A(e)?(r=R(e.key,``,t),i=R(e.value,r,t)):r=R(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=it(e,t,n),i=new this;return i.items=r.items,i}};at.tag=`tag:yaml.org,2002:omap`;var ot=class e extends K{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=A(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new W(e.key,null):new W(e,null),G(this.items,t.key)||this.items.push(t)}get(e,t){let n=G(this.items,e);return!t&&A(n)?j(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=G(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new W(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(Ke(e,null,n));return i}};ot.tag=`tag:yaml.org,2002:set`;const st=Symbol(`break visit`),ct=Symbol(`skip children`),lt=Symbol(`remove item`);function q(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),ut(Object.freeze([]),e,t)}q.BREAK=st,q.SKIP=ct,q.REMOVE=lt,q.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},q.parentCollection=(e,t)=>{let n=q.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function ut(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=ut(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===st)return st;else r===lt&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}e(((e,t)=>{function n(e){return Array.isArray(e)?e:[e]}let r=/^\s+$/,i=/(?:[^\\]|^)\\$/,a=/^\\!/,o=/^\\#/,s=/\r?\n/g,c=/^\.{0,2}\/|^\.{1,2}$/,l=/\/$/,u=`node-ignore`;typeof Symbol<`u`&&(u=Symbol.for(`node-ignore`));let d=u,f=(e,t,n)=>(Object.defineProperty(e,t,{value:n}),n),p=/([0-z])-([0-z])/g,m=()=>!1,h=e=>e.replace(p,(e,t,n)=>t.charCodeAt(0)<=n.charCodeAt(0)?e:``),g=e=>{let{length:t}=e;return e.slice(0,t-t%2)},_=[[/^\uFEFF/,()=>``],[/((?:\\\\)*?)(\\?\s+)$/,(e,t,n)=>t+(n.indexOf(`\\`)===0?` `:``)],[/(\\+?)\s/g,(e,t)=>{let{length:n}=t;return t.slice(0,n-n%2)+` `}],[/[\\$.|*+(){^]/g,e=>`\\${e}`],[/(?!\\)\?/g,()=>`[^/]`],[/^\//,()=>`^`],[/\//g,()=>`\\/`],[/^\^*\\\*\\\*\\\//,()=>`^(?:.*\\/)?`],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?`^`:`(?:^|\\/)`}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(e,t,n)=>t+6<n.length?`(?:\\/[^\\/]+)*`:`\\/.+`],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(e,t,n)=>t+n.replace(/\\\*/g,`[^\\/]*`)],[/\\\\\\(?=[$.|*+(){^])/g,()=>`\\`],[/\\\\/g,()=>`\\`],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(e,t,n,r,i)=>t===`\\`?`\\[${n}${g(r)}${i}`:i===`]`&&r.length%2==0?`[${h(n)}${r}]`:`[]`],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`]],v=/(^|\\\/)?\\\*$/,y=`regex`,b=`checkRegex`,x={[y](e,t){return`${t?`${t}[^/]+`:`[^/]*`}(?=$|\\/$)`},[b](e,t){return`${t?`${t}[^/]*`:`[^/]*`}(?=$|\\/$)`}},S=e=>_.reduce((t,[n,r])=>t.replace(n,r.bind(e)),e),C=e=>typeof e==`string`,ee=e=>e&&C(e)&&!r.test(e)&&!i.test(e)&&e.indexOf(`#`)!==0,te=e=>e.split(s).filter(Boolean);var w=class{constructor(e,t,n,r,i,a){this.pattern=e,this.mark=t,this.negative=i,f(this,`body`,n),f(this,`ignoreCase`,r),f(this,`regexPrefix`,a)}get regex(){let e=`_regex`;return this[e]?this[e]:this._make(y,e)}get checkRegex(){let e=`_checkRegex`;return this[e]?this[e]:this._make(b,e)}_make(e,t){let n=this.regexPrefix.replace(v,x[e]),r=this.ignoreCase?new RegExp(n,`i`):new RegExp(n);return f(this,t,r)}};let ne=({pattern:e,mark:t},n)=>{let r=!1,i=e;i.indexOf(`!`)===0&&(r=!0,i=i.substr(1)),i=i.replace(a,`!`).replace(o,`#`);let s=S(i);return new w(e,t,i,n,r,s)};var re=class{constructor(e){this._ignoreCase=e,this._rules=[]}_add(e){if(e&&e[d]){this._rules=this._rules.concat(e._rules._rules),this._added=!0;return}if(C(e)&&(e={pattern:e}),ee(e.pattern)){let t=ne(e,this._ignoreCase);this._added=!0,this._rules.push(t)}}add(e){return this._added=!1,n(C(e)?te(e):e).forEach(this._add,this),this._added}test(e,t,n){let r=!1,i=!1,a;this._rules.forEach(o=>{let{negative:s}=o;i===s&&r!==i||s&&!r&&!i&&!t||o[n].test(e)&&(r=!s,i=s,a=s?void 0:o)});let o={ignored:r,unignored:i};return a&&(o.rule=a),o}};let T=(e,t)=>{throw new t(e)},E=(e,t,n)=>C(e)?e?!E.isNotRelative(e)||n(`path should be a \`path.relative()\`d string, but got "${t}"`,RangeError):n(`path must not be empty`,TypeError):n(`path must be a string, but got \`${t}\``,TypeError),D=e=>c.test(e);E.isNotRelative=D,E.convert=e=>e;var O=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){f(this,d,!0),this._rules=new re(t),this._strictPathCheck=!n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(e){return this._rules.add(e)&&this._initCache(),this}addPattern(e){return this.add(e)}_test(e,t,n,r){let i=e&&E.convert(e);return E(i,e,this._strictPathCheck?T:m),this._t(i,t,n,r)}checkIgnore(e){if(!l.test(e))return this.test(e);let t=e.split(`/`).filter(Boolean);if(t.pop(),t.length){let e=this._t(t.join(`/`)+`/`,this._testCache,!0,t);if(e.ignored)return e}return this._rules.test(e,!1,b)}_t(e,t,n,r){if(e in t)return t[e];if(r||=e.split(`/`).filter(Boolean),r.pop(),!r.length)return t[e]=this._rules.test(e,n,y);let i=this._t(r.join(`/`)+`/`,t,n,r);return t[e]=i.ignored?i:this._rules.test(e,n,y)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return n(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}};let k=e=>new O(e),A=e=>E(e&&E.convert(e),e,m),j=()=>{E.convert=e=>/^\\\\\?\\/.test(e)||/["<>|\u0000-\u001F]+/u.test(e)?e:e.replace(/\\/g,`/`);let e=/^[a-z]:\//i;E.isNotRelative=t=>e.test(t)||D(t)};typeof process<`u`&&process.platform===`win32`&&j(),t.exports=k,k.default=k,t.exports.isPathValid=A,f(t.exports,Symbol.for(`setupWindows`),j)}))();const dt={"pi.session.id":{type:`string`,required:!0,cardinality:`high`,description:`Session id`},"pi.lane.name":{type:`string`,required:!0,cardinality:`high`,description:`Lane name`},"pi.operation.id":{type:`string`,required:!0,cardinality:`high`,description:`Durable operation id`},"pi.operation.recovery":{type:`boolean`,required:!0,description:`Whether this invocation resumes durable work`}},ft={"pi.error.code":{type:`string`,cardinality:`low`,description:`Stable operation error code`},"pi.error.type":{type:`string`,cardinality:`low`,description:`Low-cardinality operation error class`}};({...dt}),{...ft},{...dt},{...ft},{...dt},{...ft},globalThis.Buffer,f({command:p({description:`Bash command to execute`}),timeout:u(d({description:`Timeout in seconds (optional, no default timeout)`}))});const pt=f({oldText:p({description:`Exact text for one targeted replacement. It must be unique in the original file and must not overlap with any other edits[].oldText in the same call.`}),newText:p({description:`Replacement text for this targeted edit.`})},{});f({path:p({description:`Path to the file to edit (relative or absolute)`}),edits:l(pt,{description:`One or more targeted replacements. Each edit is matched against the original file, not incrementally. Do not include overlapping or nested edits. If two changes touch the same block or nearby lines, merge them into one edit instead.`})},{}),f({path:p({description:`Path to the file to read (relative or absolute)`}),offset:u(d({description:`Line number to start reading from (1-indexed)`})),limit:u(d({description:`Maximum number of lines to read`}))}),f({path:p({description:`Path to the file to write (relative or absolute)`}),content:p({description:`Content to write to the file`})});function mt(){try{return globalThis.localStorage??null}catch{return null}}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e,t){return Reflect.get(e,t)}function ht(e){let t=null;try{t=e?.getItem(`slicc_model_catalog`)??null}catch{return{raw:null,store:{}}}if(!t)return{raw:t,store:{}};try{let e=JSON.parse(t);return{raw:t,store:J(e)?e:{}}}catch{return{raw:t,store:{}}}}function X(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0}function gt(e){if(!J(e))return null;let t=Y(e,`input`),n=Y(e,`output`),r=Y(e,`cacheRead`),i=Y(e,`cacheWrite`);return!X(t)||!X(n)||!X(r)||!X(i)?null:{input:t,output:n,cacheRead:r,cacheWrite:i}}function _t(e){return!Array.isArray(e)||e.length===0||!e.every(e=>e===`text`||e===`image`)?null:[...e]}function vt(e){if(e===void 0)return;if(!J(e))return null;let t=Object.entries(e);return t.every(([,e])=>e===null||typeof e==`string`)?Object.fromEntries(t):null}function yt(e){return{apis:new Set(e.map(e=>e.api)),baseUrls:new Set(e.map(e=>e.baseUrl))}}function bt(e,t,n){if(!J(t))return null;let r=Y(t,`id`),i=Y(t,`name`),a=Y(t,`api`),o=Y(t,`baseUrl`),s=Y(t,`reasoning`),c=Y(t,`contextWindow`),l=Y(t,`maxTokens`);if(typeof r!=`string`||r.length===0||r.length>200||typeof i!=`string`||i.length===0||typeof a!=`string`||!n.apis.has(a)||typeof o!=`string`||!n.baseUrls.has(o)||typeof s!=`boolean`||!X(c)||c===0||!X(l)||l===0)return null;let u=gt(Y(t,`cost`)),d=_t(Y(t,`input`)),f=vt(Y(t,`thinkingLevelMap`));if(!u||!d||f===null)return null;let p=Y(t,`compat`),m={id:r,name:i,api:a,provider:e,baseUrl:o,reasoning:s,input:d,cost:u,contextWindow:c,maxTokens:l};return f&&(m.thinkingLevelMap=f),J(p)&&(m.compat={...p}),m}function xt(){return 1787954402569}let St,Ct=new Map;function wt(e){try{return g(e)}catch{return[]}}function Tt(e){if(!e||!Array.isArray(e.models)||e.models.length===0)return!1;let t=xt();return t===null||typeof e.lastModified==`number`&&e.lastModified>t}const Et=new Set([`id`,`name`,`api`,`provider`,`baseUrl`,`reasoning`,`input`,`cost`,`contextWindow`,`maxTokens`,`thinkingLevelMap`,`compat`]);function Dt(e,t,n){if(t)return{...Object.fromEntries(Object.entries(t).filter(([e])=>!Et.has(e))),...e};let r=n.find(t=>t.headers&&t.api===e.api&&t.baseUrl===e.baseUrl);return r?.headers?{...e,headers:{...r.headers}}:e}function Ot(e,t){let n=wt(e);if(n.length===0)return n;let r=yt(n),i=[...n],a=new Map(i.map((e,t)=>[e.id,t])),o=new Map(n.map(e=>[e.id,e]));for(let s of t.models){let t=bt(e,s,r);if(!t)continue;let c=a.get(t.id),l=Dt(t,o.get(t.id),n);c===void 0?(a.set(l.id,i.length),i.push(l)):i[c]=l}return i}function kt(e,t){if(!a(`live-model-catalog`))return wt(e);let{raw:n,store:r}=ht(t),i=r[e];if(!Tt(i))return wt(e);n!==St&&(St=n,Ct=new Map);let o=Ct.get(e);return o||(o=Ot(e,i),Ct.set(e,o)),o}function At(e){return[...kt(e,mt())]}function jt(e,t){return kt(e,mt()).find(e=>e.id===t)||h(e,t)}const Mt=m;function Nt(){return i()?`extension-direct`:o()?`extension-delegate`:globalThis.__slicc_connect_mode?`connect`:`node-rest`}function Pt(){return Nt()===`node-rest`}const Z=t(`secret-scrub`),Q=`[tool output withheld: secret scrub unavailable]`,Ft=async e=>e;function It(){let e=Nt();return e===`extension-direct`?async e=>{if(!e)return e;try{let t=await new Promise(t=>{chrome.runtime.sendMessage({type:`secrets.scrub-tool-result`,text:e},e=>t(e??{}))});return t.error?(Z.debug(`SW scrub-tool-result returned error`),Q):typeof t.text==`string`?t.text:Q}catch{return Z.debug(`SW scrub-tool-result failed`),Q}}:e===`extension-delegate`?async e=>{if(!e)return e;try{let t=await _(`secrets.scrub-tool-result`,{text:e});return t?.error?(Z.debug(`Bridge scrub-tool-result returned error`),Q):typeof t?.text==`string`?t.text:Q}catch{return Z.debug(`Bridge scrub-tool-result failed`),Q}}:e===`connect`?Ft:async e=>{if(!e)return e;try{let t=await fetch(s(`/api/secrets/scrub`),{method:`POST`,headers:c({"content-type":`application/json`}),body:JSON.stringify({text:e})});if(!t.ok)return Z.debug(`Server scrub-tool-result returned non-ok`,{status:t.status}),e;let n=await t.json();return typeof n.text==`string`?n.text:e}catch(t){return Z.debug(`Server scrub-tool-result failed`,{error:t instanceof Error?t.message:String(t)}),e}}}const $=t(`image-processor`),Lt=3932160;function Rt(e){let t=e.replace(/[\t\n\f\r ]/g,``),n=t.length%4;return n===2?`${t}==`:n===3?`${t}=`:t}function zt(e,t){let n=r(Rt(e.slice(0,t)));return new DataView(n.buffer,n.byteOffset,n.byteLength)}function Bt(e,t){return e>0&&t>0?{width:e,height:t}:null}function Vt(e){if(e.length<32)return null;let t=zt(e,32);return Bt(t.getUint32(16,!1),t.getUint32(20,!1))}function Ht(e){if(e.length<16)return null;let t=zt(e,16);return Bt(t.getUint16(6,!0),t.getUint16(8,!0))}function Ut(e){let t=zt(e,Math.min(87384,e.length));for(let e=0;e<t.byteLength-8;e++){if(t.getUint8(e)!==255)continue;let n=t.getUint8(e+1);if(n===192||n===194)return Bt(t.getUint16(e+7,!1),t.getUint16(e+5,!1))}return null}function Wt(e,t){try{let n=Rt(e);if(t===`image/png`)return Vt(n);if(t===`image/gif`)return Ht(n);if(t===`image/jpeg`)return Ut(n)}catch{}return null}async function Gt(e){if(!v(e.mimeType))return $.warn(`Unsupported image format`,{mimeType:e.mimeType}),{type:`text`,text:`[Image removed: unsupported format "${e.mimeType}". Supported: JPEG, PNG, GIF, WebP]`};let t=e.data.length,i=Wt(e.data,e.mimeType);if(!(t>5242880||i!==null&&(i.width>8e3||i.height>8e3)||i!==null&&Math.max(i.width,i.height)>1568))return e;$.info(`Image needs processing`,{base64Size:t,dimensions:i?`${i.width}x${i.height}`:`unknown`,reason:t>5242880?`size`:`dimensions`});let a,o;try{let e=await import(`./magick-wasm-qrxQJP5k.js`).then(e=>e.r);a=e.getMagick,o=e.MIME_TO_MAGICK_FORMAT}catch(e){return $.error(`ImageMagick WASM module unavailable`,{error:e instanceof Error?e.message:String(e)}),{type:`text`,text:`[Image removed: resize service unavailable (ImageMagick WASM could not be loaded)]`}}let s;try{s=await a()}catch(e){return $.error(`ImageMagick WASM initialization failed`,{error:e instanceof Error?e.message:String(e)}),{type:`text`,text:`[Image removed: resize service unavailable (WASM init failed)]`}}try{let i=r(Rt(e.data)),a={data:null,mime:e.mimeType};if(await s.ImageMagick.read(i,async t=>{let n=t.width,r=t.height,i=Math.max(n,r);if(i>1568){let e=1568/i,a=Math.round(n*e),o=Math.round(r*e);t.resize(a,o),$.info(`Resized image`,{from:`${n}x${r}`,to:`${a}x${o}`})}let s=o[e.mimeType]||`JPEG`;t.write(s,e=>{a.data=new Uint8Array(e)}),a.data&&a.data.length>Lt&&s!==`JPEG`?($.info(`Still over 5MB, compressing to JPEG q80`),t.quality=80,t.write(`JPEG`,e=>{a.data=new Uint8Array(e)}),a.mime=`image/jpeg`):a.data&&a.data.length>Lt&&($.info(`Still over 5MB as JPEG, reducing quality to 60`),t.quality=60,t.write(`JPEG`,e=>{a.data=new Uint8Array(e)}))}),!a.data)return $.warn(`ImageMagick produced no output`),{type:`text`,text:`[Image removed: could not be processed (empty output from resize)]`};if(a.data.length>Lt)return $.warn(`Image still over 5MB after resize+compress`,{size:a.data.length}),{type:`text`,text:`[Image removed: still ${Math.round(a.data.length/1024/1024*10)/10}MB after resize and compression, exceeds 5MB API limit]`};let c=n(a.data);return $.info(`Image processed successfully`,{originalBase64:t,newBase64:c.length,mimeType:a.mime}),{type:`image`,data:c,mimeType:a.mime}}catch(n){return $.error(`Image data processing failed (corrupt or unreadable)`,{mimeType:e.mimeType,estimatedBytes:t,error:n instanceof Error?n.message:String(n)}),{type:`text`,text:`[Image removed: image data could not be processed (${n instanceof Error?n.message:`corrupt or unreadable`})]`}}}const Kt=t(`tool-adapter`);function qt(e){let t=[],n=0;for(let r of y(e)){if(r.kind===`inert`||!r.parsed)continue;let i=e.slice(n,r.index);i.trim()&&t.push({type:`text`,text:i.trimEnd()}),t.push({type:`image`,mimeType:r.parsed.mimeType,data:r.parsed.data}),n=r.index+r.marker.length}let r=e.slice(n);return(r.trim()||t.length===0)&&t.push({type:`text`,text:r||e}),t}async function Jt(e){let t=qt(e),n=[];for(let e of t)e.type===`image`?n.push(await Gt(e)):n.push(e);return n}function Yt(e,t,n,r){if(!r)return{tracked:null,effectiveSignal:n};let i=r.processManager.spawn({kind:`tool`,argv:[e.name,...nn(t)],owner:r.owner,ppid:r.getParentPid?.()});n?.aborted?r.processManager.signal(i.pid,`SIGINT`):n&&n.addEventListener(`abort`,()=>r.processManager.signal(i.pid,`SIGINT`),{once:!0});let a=r.processManager.onSignal((e,t)=>{e.pid===i.pid&&t===`SIGKILL`&&r.processManager.exit(i.pid,null)});return{tracked:{record:i,manager:r.processManager,unsubscribeKill:a},effectiveSignal:i.abort.signal}}function Xt(e,t){e&&e.manager.exit(e.record.pid,t)}async function Zt(e,t,n){if(!n||typeof e!=`string`||e.length===0)return e;try{return await n.scrubToolResult(e)}catch(n){return Kt.warn(`Tool-result scrub failed, falling back to unscrubbed content`,{tool:t,error:n instanceof Error?n.message:String(n)}),e}}async function Qt(e,t){try{return await Jt(e)}catch(n){return Kt.warn(`Image processing failed, falling back to raw content`,{tool:t,error:n instanceof Error?n.message:String(n)}),qt(e)}}async function $t(e,t,n,r){let i=n?.currentGate();if(!i)return!0;if(r?.aborted)return!1;try{return await i.approve(e.name,t)&&r?.aborted!==!0}catch(t){return Kt.warn(`Tool-call gate threw — refusing the call`,{tool:e.name,error:t instanceof Error?t.message:String(t)}),!1}}function en(e,t,n,r){return{name:e.name,label:e.name,description:e.description,parameters:e.inputSchema,prepareArguments:e.prepareArguments,async execute(i,a,o,s){let c;if(s&&(c=x({onUpdate:s,toolName:e.name,toolCallId:i})),!await $t(e,a,r,o))return c&&b(c),{content:[{type:`text`,text:`${e.name}: not approved (guest-caused turn).`}],details:{isError:!0}};let l=Yt(e,a,o,t);try{let t=await e.execute(a??{},l.effectiveSignal),r=await Qt(await Zt(t.content,e.name,n),e.name);return Xt(l.tracked,+!!t.isError),{content:r,details:{isError:t.isError}}}catch(e){throw Xt(l.tracked,l.tracked?.record.abort.signal.aborted?null:1),e}finally{c&&b(c),l.tracked?.unsubscribeKill()}}}}function tn(e,t,n,r){return e.map(e=>en(e,t,n,r))}function nn(e){if(typeof e!=`object`||!e)return[];let t=e;for(let e of[`command`,`file_path`,`path`,`pattern`,`url`,`key`,`name`,`query`,`message`]){let n=t[e];if(typeof n==`string`&&n.length>0)return[n]}for(let e of Object.values(t))if(typeof e==`string`&&e.length>0)return[e];return[]}export{Nt as a,Mt as c,Pt as i,nn as n,jt as o,It as r,At as s,tn as t};
36
+ `;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function Xe({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=B(t(r),e);n.push(i.trimStart())}}function G(e,t){let n=j(t)?t.value:t;for(let r of e)if(A(r)&&(r.key===t||r.key===n||j(r.key)&&r.key.value===n))return r}var K=class extends be{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(w,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(Ke(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=A(e)?e:!e||typeof e!=`object`||!(`key`in e)?new W(e,e?.value):new W(e.key,e.value);let r=G(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);j(r.value)&&he(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=G(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=G(this.items,e)?.value;return(!t&&j(n)?n.value:n)??void 0}has(e){return!!G(this.items,e)}set(e,t){this.add(new W(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)We(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!A(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),qe(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}};const Ze={collection:`map`,default:!0,nodeClass:K,tag:`tag:yaml.org,2002:map`,resolve(e,t){return k(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>K.from(e,t,n)};var Qe=class extends be{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(T,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=$e(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=$e(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&j(r)?r.value:r}has(e){let t=$e(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=$e(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];j(r)&&he(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(R(e,String(r++),t));return n}toString(e,t,n){return e?qe(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(_e(a,void 0,n))}}return i}};function $e(e){let t=j(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}const et={collection:`seq`,default:!0,nodeClass:Qe,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return ie(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>Qe.from(e,t,n)};function tt(e){return typeof e==`bigint`||Number.isInteger(e)}const nt=({value:e})=>JSON.stringify(e),rt=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:nt},{identify:e=>e==null,createNode:()=>new z(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:nt},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:nt},{identify:tt,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>tt(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:nt}];[Ze,et].concat(rt,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}});function it(e,t,n){let{replacer:r}=n,i=new Qe(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(Ke(o,s,n))}return i}var at=class e extends Qe{constructor(){super(),this.add=K.prototype.add.bind(this),this.delete=K.prototype.delete.bind(this),this.get=K.prototype.get.bind(this),this.has=K.prototype.has.bind(this),this.set=K.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(A(e)?(r=R(e.key,``,t),i=R(e.value,r,t)):r=R(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=it(e,t,n),i=new this;return i.items=r.items,i}};at.tag=`tag:yaml.org,2002:omap`;var ot=class e extends K{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=A(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new W(e.key,null):new W(e,null),G(this.items,t.key)||this.items.push(t)}get(e,t){let n=G(this.items,e);return!t&&A(n)?j(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=G(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new W(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(Ke(e,null,n));return i}};ot.tag=`tag:yaml.org,2002:set`;const st=Symbol(`break visit`),ct=Symbol(`skip children`),lt=Symbol(`remove item`);function q(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),ut(Object.freeze([]),e,t)}q.BREAK=st,q.SKIP=ct,q.REMOVE=lt,q.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},q.parentCollection=(e,t)=>{let n=q.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function ut(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=ut(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===st)return st;else r===lt&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}e(((e,t)=>{function n(e){return Array.isArray(e)?e:[e]}let r=/^\s+$/,i=/(?:[^\\]|^)\\$/,a=/^\\!/,o=/^\\#/,s=/\r?\n/g,c=/^\.{0,2}\/|^\.{1,2}$/,l=/\/$/,u=`node-ignore`;typeof Symbol<`u`&&(u=Symbol.for(`node-ignore`));let d=u,f=(e,t,n)=>(Object.defineProperty(e,t,{value:n}),n),p=/([0-z])-([0-z])/g,m=()=>!1,h=e=>e.replace(p,(e,t,n)=>t.charCodeAt(0)<=n.charCodeAt(0)?e:``),g=e=>{let{length:t}=e;return e.slice(0,t-t%2)},_=[[/^\uFEFF/,()=>``],[/((?:\\\\)*?)(\\?\s+)$/,(e,t,n)=>t+(n.indexOf(`\\`)===0?` `:``)],[/(\\+?)\s/g,(e,t)=>{let{length:n}=t;return t.slice(0,n-n%2)+` `}],[/[\\$.|*+(){^]/g,e=>`\\${e}`],[/(?!\\)\?/g,()=>`[^/]`],[/^\//,()=>`^`],[/\//g,()=>`\\/`],[/^\^*\\\*\\\*\\\//,()=>`^(?:.*\\/)?`],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?`^`:`(?:^|\\/)`}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(e,t,n)=>t+6<n.length?`(?:\\/[^\\/]+)*`:`\\/.+`],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(e,t,n)=>t+n.replace(/\\\*/g,`[^\\/]*`)],[/\\\\\\(?=[$.|*+(){^])/g,()=>`\\`],[/\\\\/g,()=>`\\`],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(e,t,n,r,i)=>t===`\\`?`\\[${n}${g(r)}${i}`:i===`]`&&r.length%2==0?`[${h(n)}${r}]`:`[]`],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`]],v=/(^|\\\/)?\\\*$/,y=`regex`,b=`checkRegex`,x={[y](e,t){return`${t?`${t}[^/]+`:`[^/]*`}(?=$|\\/$)`},[b](e,t){return`${t?`${t}[^/]*`:`[^/]*`}(?=$|\\/$)`}},S=e=>_.reduce((t,[n,r])=>t.replace(n,r.bind(e)),e),C=e=>typeof e==`string`,ee=e=>e&&C(e)&&!r.test(e)&&!i.test(e)&&e.indexOf(`#`)!==0,te=e=>e.split(s).filter(Boolean);var w=class{constructor(e,t,n,r,i,a){this.pattern=e,this.mark=t,this.negative=i,f(this,`body`,n),f(this,`ignoreCase`,r),f(this,`regexPrefix`,a)}get regex(){let e=`_regex`;return this[e]?this[e]:this._make(y,e)}get checkRegex(){let e=`_checkRegex`;return this[e]?this[e]:this._make(b,e)}_make(e,t){let n=this.regexPrefix.replace(v,x[e]),r=this.ignoreCase?new RegExp(n,`i`):new RegExp(n);return f(this,t,r)}};let ne=({pattern:e,mark:t},n)=>{let r=!1,i=e;i.indexOf(`!`)===0&&(r=!0,i=i.substr(1)),i=i.replace(a,`!`).replace(o,`#`);let s=S(i);return new w(e,t,i,n,r,s)};var re=class{constructor(e){this._ignoreCase=e,this._rules=[]}_add(e){if(e&&e[d]){this._rules=this._rules.concat(e._rules._rules),this._added=!0;return}if(C(e)&&(e={pattern:e}),ee(e.pattern)){let t=ne(e,this._ignoreCase);this._added=!0,this._rules.push(t)}}add(e){return this._added=!1,n(C(e)?te(e):e).forEach(this._add,this),this._added}test(e,t,n){let r=!1,i=!1,a;this._rules.forEach(o=>{let{negative:s}=o;i===s&&r!==i||s&&!r&&!i&&!t||o[n].test(e)&&(r=!s,i=s,a=s?void 0:o)});let o={ignored:r,unignored:i};return a&&(o.rule=a),o}};let T=(e,t)=>{throw new t(e)},E=(e,t,n)=>C(e)?e?!E.isNotRelative(e)||n(`path should be a \`path.relative()\`d string, but got "${t}"`,RangeError):n(`path must not be empty`,TypeError):n(`path must be a string, but got \`${t}\``,TypeError),D=e=>c.test(e);E.isNotRelative=D,E.convert=e=>e;var O=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){f(this,d,!0),this._rules=new re(t),this._strictPathCheck=!n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(e){return this._rules.add(e)&&this._initCache(),this}addPattern(e){return this.add(e)}_test(e,t,n,r){let i=e&&E.convert(e);return E(i,e,this._strictPathCheck?T:m),this._t(i,t,n,r)}checkIgnore(e){if(!l.test(e))return this.test(e);let t=e.split(`/`).filter(Boolean);if(t.pop(),t.length){let e=this._t(t.join(`/`)+`/`,this._testCache,!0,t);if(e.ignored)return e}return this._rules.test(e,!1,b)}_t(e,t,n,r){if(e in t)return t[e];if(r||=e.split(`/`).filter(Boolean),r.pop(),!r.length)return t[e]=this._rules.test(e,n,y);let i=this._t(r.join(`/`)+`/`,t,n,r);return t[e]=i.ignored?i:this._rules.test(e,n,y)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return n(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}};let k=e=>new O(e),A=e=>E(e&&E.convert(e),e,m),j=()=>{E.convert=e=>/^\\\\\?\\/.test(e)||/["<>|\u0000-\u001F]+/u.test(e)?e:e.replace(/\\/g,`/`);let e=/^[a-z]:\//i;E.isNotRelative=t=>e.test(t)||D(t)};typeof process<`u`&&process.platform===`win32`&&j(),t.exports=k,k.default=k,t.exports.isPathValid=A,f(t.exports,Symbol.for(`setupWindows`),j)}))();const dt={"pi.session.id":{type:`string`,required:!0,cardinality:`high`,description:`Session id`},"pi.lane.name":{type:`string`,required:!0,cardinality:`high`,description:`Lane name`},"pi.operation.id":{type:`string`,required:!0,cardinality:`high`,description:`Durable operation id`},"pi.operation.recovery":{type:`boolean`,required:!0,description:`Whether this invocation resumes durable work`}},ft={"pi.error.code":{type:`string`,cardinality:`low`,description:`Stable operation error code`},"pi.error.type":{type:`string`,cardinality:`low`,description:`Low-cardinality operation error class`}};({...dt}),{...ft},{...dt},{...ft},{...dt},{...ft},globalThis.Buffer,f({command:p({description:`Bash command to execute`}),timeout:u(d({description:`Timeout in seconds (optional, no default timeout)`}))});const pt=f({oldText:p({description:`Exact text for one targeted replacement. It must be unique in the original file and must not overlap with any other edits[].oldText in the same call.`}),newText:p({description:`Replacement text for this targeted edit.`})},{});f({path:p({description:`Path to the file to edit (relative or absolute)`}),edits:l(pt,{description:`One or more targeted replacements. Each edit is matched against the original file, not incrementally. Do not include overlapping or nested edits. If two changes touch the same block or nearby lines, merge them into one edit instead.`})},{}),f({path:p({description:`Path to the file to read (relative or absolute)`}),offset:u(d({description:`Line number to start reading from (1-indexed)`})),limit:u(d({description:`Maximum number of lines to read`}))}),f({path:p({description:`Path to the file to write (relative or absolute)`}),content:p({description:`Content to write to the file`})});function mt(){try{return globalThis.localStorage??null}catch{return null}}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e,t){return Reflect.get(e,t)}function ht(e){let t=null;try{t=e?.getItem(`slicc_model_catalog`)??null}catch{return{raw:null,store:{}}}if(!t)return{raw:t,store:{}};try{let e=JSON.parse(t);return{raw:t,store:J(e)?e:{}}}catch{return{raw:t,store:{}}}}function X(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0}function gt(e){if(!J(e))return null;let t=Y(e,`input`),n=Y(e,`output`),r=Y(e,`cacheRead`),i=Y(e,`cacheWrite`);return!X(t)||!X(n)||!X(r)||!X(i)?null:{input:t,output:n,cacheRead:r,cacheWrite:i}}function _t(e){return!Array.isArray(e)||e.length===0||!e.every(e=>e===`text`||e===`image`)?null:[...e]}function vt(e){if(e===void 0)return;if(!J(e))return null;let t=Object.entries(e);return t.every(([,e])=>e===null||typeof e==`string`)?Object.fromEntries(t):null}function yt(e){return{apis:new Set(e.map(e=>e.api)),baseUrls:new Set(e.map(e=>e.baseUrl))}}function bt(e,t,n){if(!J(t))return null;let r=Y(t,`id`),i=Y(t,`name`),a=Y(t,`api`),o=Y(t,`baseUrl`),s=Y(t,`reasoning`),c=Y(t,`contextWindow`),l=Y(t,`maxTokens`);if(typeof r!=`string`||r.length===0||r.length>200||typeof i!=`string`||i.length===0||typeof a!=`string`||!n.apis.has(a)||typeof o!=`string`||!n.baseUrls.has(o)||typeof s!=`boolean`||!X(c)||c===0||!X(l)||l===0)return null;let u=gt(Y(t,`cost`)),d=_t(Y(t,`input`)),f=vt(Y(t,`thinkingLevelMap`));if(!u||!d||f===null)return null;let p=Y(t,`compat`),m={id:r,name:i,api:a,provider:e,baseUrl:o,reasoning:s,input:d,cost:u,contextWindow:c,maxTokens:l};return f&&(m.thinkingLevelMap=f),J(p)&&(m.compat={...p}),m}function xt(){return 1787954402569}let St,Ct=new Map;function wt(e){try{return g(e)}catch{return[]}}function Tt(e){if(!e||!Array.isArray(e.models)||e.models.length===0)return!1;let t=xt();return t===null||typeof e.lastModified==`number`&&e.lastModified>t}const Et=new Set([`id`,`name`,`api`,`provider`,`baseUrl`,`reasoning`,`input`,`cost`,`contextWindow`,`maxTokens`,`thinkingLevelMap`,`compat`]);function Dt(e,t,n){if(t)return{...Object.fromEntries(Object.entries(t).filter(([e])=>!Et.has(e))),...e};let r=n.find(t=>t.headers&&t.api===e.api&&t.baseUrl===e.baseUrl);return r?.headers?{...e,headers:{...r.headers}}:e}function Ot(e,t){let n=wt(e);if(n.length===0)return n;let r=yt(n),i=[...n],a=new Map(i.map((e,t)=>[e.id,t])),o=new Map(n.map(e=>[e.id,e]));for(let s of t.models){let t=bt(e,s,r);if(!t)continue;let c=a.get(t.id),l=Dt(t,o.get(t.id),n);c===void 0?(a.set(l.id,i.length),i.push(l)):i[c]=l}return i}function kt(e,t){if(!a(`live-model-catalog`))return wt(e);let{raw:n,store:r}=ht(t),i=r[e];if(!Tt(i))return wt(e);n!==St&&(St=n,Ct=new Map);let o=Ct.get(e);return o||(o=Ot(e,i),Ct.set(e,o)),o}function At(e){return[...kt(e,mt())]}function jt(e,t){return kt(e,mt()).find(e=>e.id===t)||h(e,t)}const Mt=m;function Nt(){return i()?`extension-direct`:o()?`extension-delegate`:globalThis.__slicc_connect_mode?`connect`:`node-rest`}function Pt(){return Nt()===`node-rest`}const Z=t(`secret-scrub`),Q=`[tool output withheld: secret scrub unavailable]`,Ft=async e=>e;function It(){let e=Nt();return e===`extension-direct`?async e=>{if(!e)return e;try{let t=await new Promise(t=>{chrome.runtime.sendMessage({type:`secrets.scrub-tool-result`,text:e},e=>t(e??{}))});return t.error?(Z.debug(`SW scrub-tool-result returned error`),Q):typeof t.text==`string`?t.text:Q}catch{return Z.debug(`SW scrub-tool-result failed`),Q}}:e===`extension-delegate`?async e=>{if(!e)return e;try{let t=await _(`secrets.scrub-tool-result`,{text:e});return t?.error?(Z.debug(`Bridge scrub-tool-result returned error`),Q):typeof t?.text==`string`?t.text:Q}catch{return Z.debug(`Bridge scrub-tool-result failed`),Q}}:e===`connect`?Ft:async e=>{if(!e)return e;try{let t=await fetch(s(`/api/secrets/scrub`),{method:`POST`,headers:c({"content-type":`application/json`}),body:JSON.stringify({text:e})});if(!t.ok)return Z.debug(`Server scrub-tool-result returned non-ok`,{status:t.status}),e;let n=await t.json();return typeof n.text==`string`?n.text:e}catch(t){return Z.debug(`Server scrub-tool-result failed`,{error:t instanceof Error?t.message:String(t)}),e}}}const $=t(`image-processor`),Lt=3932160;function Rt(e){let t=e.replace(/[\t\n\f\r ]/g,``),n=t.length%4;return n===2?`${t}==`:n===3?`${t}=`:t}function zt(e,t){let n=r(Rt(e.slice(0,t)));return new DataView(n.buffer,n.byteOffset,n.byteLength)}function Bt(e,t){return e>0&&t>0?{width:e,height:t}:null}function Vt(e){if(e.length<32)return null;let t=zt(e,32);return Bt(t.getUint32(16,!1),t.getUint32(20,!1))}function Ht(e){if(e.length<16)return null;let t=zt(e,16);return Bt(t.getUint16(6,!0),t.getUint16(8,!0))}function Ut(e){let t=zt(e,Math.min(87384,e.length));for(let e=0;e<t.byteLength-8;e++){if(t.getUint8(e)!==255)continue;let n=t.getUint8(e+1);if(n===192||n===194)return Bt(t.getUint16(e+7,!1),t.getUint16(e+5,!1))}return null}function Wt(e,t){try{let n=Rt(e);if(t===`image/png`)return Vt(n);if(t===`image/gif`)return Ht(n);if(t===`image/jpeg`)return Ut(n)}catch{}return null}async function Gt(e){if(!v(e.mimeType))return $.warn(`Unsupported image format`,{mimeType:e.mimeType}),{type:`text`,text:`[Image removed: unsupported format "${e.mimeType}". Supported: JPEG, PNG, GIF, WebP]`};let t=e.data.length,i=Wt(e.data,e.mimeType);if(!(t>5242880||i!==null&&(i.width>8e3||i.height>8e3)||i!==null&&Math.max(i.width,i.height)>1568))return e;$.info(`Image needs processing`,{base64Size:t,dimensions:i?`${i.width}x${i.height}`:`unknown`,reason:t>5242880?`size`:`dimensions`});let a,o;try{let e=await import(`./magick-wasm-agWGi-e0.js`).then(e=>e.r);a=e.getMagick,o=e.MIME_TO_MAGICK_FORMAT}catch(e){return $.error(`ImageMagick WASM module unavailable`,{error:e instanceof Error?e.message:String(e)}),{type:`text`,text:`[Image removed: resize service unavailable (ImageMagick WASM could not be loaded)]`}}let s;try{s=await a()}catch(e){return $.error(`ImageMagick WASM initialization failed`,{error:e instanceof Error?e.message:String(e)}),{type:`text`,text:`[Image removed: resize service unavailable (WASM init failed)]`}}try{let i=r(Rt(e.data)),a={data:null,mime:e.mimeType};if(await s.ImageMagick.read(i,async t=>{let n=t.width,r=t.height,i=Math.max(n,r);if(i>1568){let e=1568/i,a=Math.round(n*e),o=Math.round(r*e);t.resize(a,o),$.info(`Resized image`,{from:`${n}x${r}`,to:`${a}x${o}`})}let s=o[e.mimeType]||`JPEG`;t.write(s,e=>{a.data=new Uint8Array(e)}),a.data&&a.data.length>Lt&&s!==`JPEG`?($.info(`Still over 5MB, compressing to JPEG q80`),t.quality=80,t.write(`JPEG`,e=>{a.data=new Uint8Array(e)}),a.mime=`image/jpeg`):a.data&&a.data.length>Lt&&($.info(`Still over 5MB as JPEG, reducing quality to 60`),t.quality=60,t.write(`JPEG`,e=>{a.data=new Uint8Array(e)}))}),!a.data)return $.warn(`ImageMagick produced no output`),{type:`text`,text:`[Image removed: could not be processed (empty output from resize)]`};if(a.data.length>Lt)return $.warn(`Image still over 5MB after resize+compress`,{size:a.data.length}),{type:`text`,text:`[Image removed: still ${Math.round(a.data.length/1024/1024*10)/10}MB after resize and compression, exceeds 5MB API limit]`};let c=n(a.data);return $.info(`Image processed successfully`,{originalBase64:t,newBase64:c.length,mimeType:a.mime}),{type:`image`,data:c,mimeType:a.mime}}catch(n){return $.error(`Image data processing failed (corrupt or unreadable)`,{mimeType:e.mimeType,estimatedBytes:t,error:n instanceof Error?n.message:String(n)}),{type:`text`,text:`[Image removed: image data could not be processed (${n instanceof Error?n.message:`corrupt or unreadable`})]`}}}const Kt=t(`tool-adapter`);function qt(e){let t=[],n=0;for(let r of y(e)){if(r.kind===`inert`||!r.parsed)continue;let i=e.slice(n,r.index);i.trim()&&t.push({type:`text`,text:i.trimEnd()}),t.push({type:`image`,mimeType:r.parsed.mimeType,data:r.parsed.data}),n=r.index+r.marker.length}let r=e.slice(n);return(r.trim()||t.length===0)&&t.push({type:`text`,text:r||e}),t}async function Jt(e){let t=qt(e),n=[];for(let e of t)e.type===`image`?n.push(await Gt(e)):n.push(e);return n}function Yt(e,t,n,r){if(!r)return{tracked:null,effectiveSignal:n};let i=r.processManager.spawn({kind:`tool`,argv:[e.name,...nn(t)],owner:r.owner,ppid:r.getParentPid?.()});n?.aborted?r.processManager.signal(i.pid,`SIGINT`):n&&n.addEventListener(`abort`,()=>r.processManager.signal(i.pid,`SIGINT`),{once:!0});let a=r.processManager.onSignal((e,t)=>{e.pid===i.pid&&t===`SIGKILL`&&r.processManager.exit(i.pid,null)});return{tracked:{record:i,manager:r.processManager,unsubscribeKill:a},effectiveSignal:i.abort.signal}}function Xt(e,t){e&&e.manager.exit(e.record.pid,t)}async function Zt(e,t,n){if(!n||typeof e!=`string`||e.length===0)return e;try{return await n.scrubToolResult(e)}catch(n){return Kt.warn(`Tool-result scrub failed, falling back to unscrubbed content`,{tool:t,error:n instanceof Error?n.message:String(n)}),e}}async function Qt(e,t){try{return await Jt(e)}catch(n){return Kt.warn(`Image processing failed, falling back to raw content`,{tool:t,error:n instanceof Error?n.message:String(n)}),qt(e)}}async function $t(e,t,n,r){let i=n?.currentGate();if(!i)return!0;if(r?.aborted)return!1;try{return await i.approve(e.name,t)&&r?.aborted!==!0}catch(t){return Kt.warn(`Tool-call gate threw — refusing the call`,{tool:e.name,error:t instanceof Error?t.message:String(t)}),!1}}function en(e,t,n,r){return{name:e.name,label:e.name,description:e.description,parameters:e.inputSchema,prepareArguments:e.prepareArguments,async execute(i,a,o,s){let c;if(s&&(c=x({onUpdate:s,toolName:e.name,toolCallId:i})),!await $t(e,a,r,o))return c&&b(c),{content:[{type:`text`,text:`${e.name}: not approved (guest-caused turn).`}],details:{isError:!0}};let l=Yt(e,a,o,t);try{let t=await e.execute(a??{},l.effectiveSignal),r=await Qt(await Zt(t.content,e.name,n),e.name);return Xt(l.tracked,+!!t.isError),{content:r,details:{isError:t.isError}}}catch(e){throw Xt(l.tracked,l.tracked?.record.abort.signal.aborted?null:1),e}finally{c&&b(c),l.tracked?.unsubscribeKill()}}}}function tn(e,t,n,r){return e.map(e=>en(e,t,n,r))}function nn(e){if(typeof e!=`object`||!e)return[];let t=e;for(let e of[`command`,`file_path`,`path`,`pattern`,`url`,`key`,`name`,`query`,`message`]){let n=t[e];if(typeof n==`string`&&n.length>0)return[n]}for(let e of Object.values(t))if(typeof e==`string`&&e.length>0)return[e];return[]}export{Nt as a,Mt as c,Pt as i,nn as n,jt as o,It as r,At as s,tn as t};
@@ -1 +1 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import{S as t}from"./record-COQlaFL1.js";import{g as n}from"./kernel-worker-BzcdrkzF.js";const r=e(`directed-approval`);function i(e,n){if(e.kind===`user`)return a(`the user tier is not a directed approval`);if(e.kind===`agent`)return a(`agent approvals are not enqueued to a unit`);let r=e.unitJid;if(!n.scoops.has(r))return a(`the requesting unit is not registered`);let i=n.ownerRootOf(r);if(!i)return a(`no owning cone for the requesting unit`);let o=e.kind===`cone`?i:[...n.scoops.values()].find(t=>t.parentJid===i.jid&&(t.name===e.scoopName||t.folder===e.scoopName));return o?t(o).canResolveApprovals?{ok:!0,requesterJid:r,approver:o}:a(`the named approver cannot resolve approvals`):a(`delegated approver not found under this cone`)}function a(e){return r.warn(`Directed approval failing closed`,{reason:e}),{ok:!1,reason:e}}const o={decision:`deny`};async function s(e,t){let a=e.approver;if(a?.kind===`agent`){let i=globalThis[n];if(!i)return r.warn(`No agent bridge available for an approver agent — denying`),o;let{approverRunnerFor:s}=await import(`./approver-agent-CivzfuZ7.js`),c=t.getSharedFs(),l=await s({spawn:e=>i.spawn(e),readSharedFile:async e=>{if(!c)return null;try{let t=await c.readFile(e,{encoding:`utf-8`});return typeof t==`string`?t:null}catch{return null}},findUnit:e=>{let n=t.scoops.get(e);return n?{workspace:t.workspaceFor(n),folder:n.folder}:void 0}})({kind:e.kind===`guest-tool`?`guest-tool`:`guest-message`,requester:e.requester??`an unidentified requester`,detail:e.detail},a.unitJid);return r.info(`Approver agent verdict`,{decision:l.decision,reason:l.reason}),l.decision===`allow`?{decision:`allow`}:o}if(a&&a.kind!==`user`){let n=i(a,t);return n.ok?t.enqueue(n.requesterJid,e,{approver:n.approver}):o}return t.approveAsUser(e)}export{s as runDirectedApproval};
1
+ import{t as e}from"./logger-LESFN7Hj.js";import{S as t}from"./record-COQlaFL1.js";import{g as n}from"./kernel-worker-C6evRbt8.js";const r=e(`directed-approval`);function i(e,n){if(e.kind===`user`)return a(`the user tier is not a directed approval`);if(e.kind===`agent`)return a(`agent approvals are not enqueued to a unit`);let r=e.unitJid;if(!n.scoops.has(r))return a(`the requesting unit is not registered`);let i=n.ownerRootOf(r);if(!i)return a(`no owning cone for the requesting unit`);let o=e.kind===`cone`?i:[...n.scoops.values()].find(t=>t.parentJid===i.jid&&(t.name===e.scoopName||t.folder===e.scoopName));return o?t(o).canResolveApprovals?{ok:!0,requesterJid:r,approver:o}:a(`the named approver cannot resolve approvals`):a(`delegated approver not found under this cone`)}function a(e){return r.warn(`Directed approval failing closed`,{reason:e}),{ok:!1,reason:e}}const o={decision:`deny`};async function s(e,t){let a=e.approver;if(a?.kind===`agent`){let i=globalThis[n];if(!i)return r.warn(`No agent bridge available for an approver agent — denying`),o;let{approverRunnerFor:s}=await import(`./approver-agent-CivzfuZ7.js`),c=t.getSharedFs(),l=await s({spawn:e=>i.spawn(e),readSharedFile:async e=>{if(!c)return null;try{let t=await c.readFile(e,{encoding:`utf-8`});return typeof t==`string`?t:null}catch{return null}},findUnit:e=>{let n=t.scoops.get(e);return n?{workspace:t.workspaceFor(n),folder:n.folder}:void 0}})({kind:e.kind===`guest-tool`?`guest-tool`:`guest-message`,requester:e.requester??`an unidentified requester`,detail:e.detail},a.unitJid);return r.info(`Approver agent verdict`,{decision:l.decision,reason:l.reason}),l.decision===`allow`?{decision:`allow`}:o}if(a&&a.kind!==`user`){let n=i(a,t);return n.ok?t.enqueue(n.requesterJid,e,{approver:n.approver}):o}return t.approveAsUser(e)}export{s as runDirectedApproval};
@@ -1 +1 @@
1
- import{n as e}from"./js-realm-worker-BFJHUvlI.js";const t={EACCES:2,EBADF:8,EBUSY:10,EEXIST:20,EINVAL:28,EIO:29,EISDIR:31,ELOOP:32,ENAMETOOLONG:37,ENOENT:44,ENOSPC:51,ENOSYS:52,ENOTDIR:54,ENOTEMPTY:55,EPERM:63,EROFS:69,ETIMEDOUT:73,EXDEV:75},n=4095;function r(e,n){if(n?.errno!==void 0&&n instanceof e.ErrnoError)return n;let r=n?.code,i=typeof r==`string`?t[r]??29:29;return new e.ErrnoError(i)}function i(e){let t=[],n=e;for(;n!==n.mount.root;)t.push(n.name),n=n.parent;let r=e.mount.opts.root.replace(/\/+$/,``);return t.length===0?r||`/`:`${r}/${t.reverse().join(`/`)}`}function a(e){let t=e.isSymbolicLink?40960:e.isDirectory?16384:32768,r=e.isDirectory||e.isSymbolicLink?511:438;return t|((e.mode??r)&n||r)}function o(e){if(e!=null)return e instanceof Date?e.getTime():e}function s(e,n){let o=e=>e.mount.opts.bridge;function s(t){try{return t()}catch(t){throw r(e,t)}}function c(e){try{s(e)}catch(e){if(e.errno!==t.ENOSYS)throw e}}function l(e){return{...e?{stat:e}:{},len:0,loaded:!1,dirty:!1,openCount:0}}function u(t,r,i){let o=e.createNode(t,r,a(i),0);return o.node_ops=n.node,o.stream_ops=n.stream,o.live=l(i),o}function d(e){if(e.live.orphan)return{...e.live.stat,size:e.live.len};if(!e.live.stat){let t=s(()=>o(e).lstat(i(e)));e.live.stat=t,e.mode=a(t)}return e.live.stat}function f(e,t){let n=i(e);return n===`/`?`/${t}`:`${n}/${t}`}function p(e){let t=e.live;if(t.loaded)return;let n=s(()=>o(e).readFile(i(e)));t.data=n,t.len=n.length,t.loaded=!0}function m(e,t){let n=e.live,r=n.data??new Uint8Array;if(r.length>=t)return r;let i=new Uint8Array(Math.max(t,r.length*2,256));return i.set(r.subarray(0,n.len)),n.data=i,i}function h(e){let t=e.live;if(!t.dirty||!t.data||t.orphan)return;let n=t.data.slice(0,t.len);s(()=>o(e).writeFile(i(e),n)),t.dirty=!1,t.stat=void 0}function g(e,t){let n=e.live;if(n.openCount>0){t>0?p(e):n.loaded=!0;let r=m(e,t);t>n.len&&r.fill(0,n.len,t),n.len=t,n.dirty=!0;return}let r=i(e),a=new Uint8Array(t);if(t>0){let n=s(()=>o(e).readFile(r));a.set(n.subarray(0,Math.min(t,n.length)))}s(()=>o(e).writeFile(r,a)),n.stat=void 0}return{Fs:e,bridgeOf:o,call:s,metadataCall:c,makeNode:u,statOf:d,childPath:f,ensureLoaded:p,ensureCapacity:m,flushNode:h,truncate:g}}function c(e){let{Fs:r,bridgeOf:a,call:s,metadataCall:c,makeNode:l,statOf:u,childPath:d,flushNode:f,truncate:p}=e,{ensureLoaded:m}=e;return{getattr(e){let t=u(e),n=e.live,i=r.isDir(e.mode)?4096:n.loaded?n.len:t.size,a=new Date(t.mtimeMs??0);return{dev:1,ino:e.id,mode:e.mode,nlink:1,uid:0,gid:0,rdev:0,size:i,atime:a,mtime:a,ctime:a,blksize:4096,blocks:Math.ceil(i/4096)}},setattr(e,t){if(e.live.orphan){t.mode!==void 0&&t.mode!==null&&(e.mode=e.mode&-4096|t.mode&n),t.size!==void 0&&t.size!==null&&p(e,t.size);return}let s=i(e);if(t.mode!==void 0&&t.mode!==null){let r=t.mode&n;r!==(e.mode&n)&&(c(()=>a(e).chmod(s,r)),e.mode=e.mode&-4096|r)}t.size!==void 0&&t.size!==null&&r.isFile(e.mode)&&p(e,t.size);let l=o(t.mtime)??t.timestamp;if(l!==void 0){let n=o(t.atime)??l;f(e),c(()=>a(e).utimes(s,n,l))}e.live.stat=void 0},lookup(e,t){let n=s(()=>a(e).lstat(d(e,t)));return l(e,t,n)},mknod(e,n,i){let o=d(e,n);if(r.isDir(i))s(()=>a(e).mkdir(o));else if(r.isFile(i))s(()=>a(e).writeFile(o,new Uint8Array));else throw new r.ErrnoError(t.EPERM);let c=l(e,n,{isFile:r.isFile(i),isDirectory:r.isDir(i),isSymbolicLink:!1,size:0,mode:i,mtimeMs:Date.now()});return c.live.stat=void 0,c},rename(e,t,n){let o=i(e),c=d(t,n);f(e),s(()=>a(e).rename(o,c));try{let i=r.lookupNode?.(t,n);i&&i!==e&&r.hashRemoveNode?.(i)}catch{}e.name=n,e.live.stat=void 0},unlink(e,t){let n;try{let i=r.lookupNode?.(e,t);i&&i.live?.openCount>0&&r.isFile(i.mode)&&(n=i)}catch{}n&&(u(n),m(n)),s(()=>a(e).unlink(d(e,t))),n&&(n.live.orphan=!0)},rmdir(e,t){s(()=>a(e).rmdir(d(e,t)))},readdir(e){return[`.`,`..`,...s(()=>a(e).readdir(i(e)))]},symlink(e,t,n){let r=d(e,t);return s(()=>a(e).symlink(n,r)),l(e,t,{isFile:!1,isDirectory:!1,isSymbolicLink:!0,size:n.length})},readlink(e){if(!r.isLink(e.mode))throw new r.ErrnoError(t.EINVAL);return s(()=>a(e).readlink(i(e)))}}}function l(e){let{Fs:n,statOf:r,ensureLoaded:i,ensureCapacity:a,flushNode:o}=e;return{open(e){n.isFile(e.node.mode)&&e.node.live.openCount++},dup(e){n.isFile(e.node.mode)&&e.node.live.openCount++},close(e){let t=e.node;if(!n.isFile(t.mode))return;let r=t.live;if(r.openCount=Math.max(0,r.openCount-1),!(r.openCount>0))try{o(t)}finally{r.data=void 0,r.len=0,r.loaded=!1}},read(e,r,a,o,s){let c=e.node;if(n.isDir(c.mode))throw new n.ErrnoError(t.EISDIR);i(c);let l=c.live;if(s>=l.len||o<=0)return 0;let u=Math.min(o,l.len-s);return new Uint8Array(r.buffer,r.byteOffset+a,u).set(l.data.subarray(s,s+u)),u},write(e,r,o,s,c){let l=e.node;if(n.isDir(l.mode))throw new n.ErrnoError(t.EISDIR);if(s<=0)return 0;i(l);let u=l.live,d=c+s,f=a(l,d);return c>u.len&&f.fill(0,u.len,c),f.set(new Uint8Array(r.buffer,r.byteOffset+o,s),c),u.len=Math.max(u.len,d),u.dirty=!0,s},llseek(e,i,a){let o=i;if(a===1)o+=e.position;else if(a===2&&n.isFile(e.node.mode)){let t=e.node.live;o+=t.loaded?t.len:r(e.node).size}if(o<0)throw new n.ErrnoError(t.EINVAL);return o},fsync(e){o(e.node)}}}function u(e){let n=new Set,r={},i=s(e,r),a=c(i),o=l(i);return r.node=a,r.stream=o,{mounts:n,node_ops:a,stream_ops:o,mount(r){let a=i.call(()=>r.opts.bridge.stat(r.opts.root));if(!a.isDirectory)throw new e.ErrnoError(t.ENOTDIR);let o=i.makeNode(null,`/`,a);return n.add(r),o}}}function d(e,t){return!!t&&e.mounts.has(t.mount)}function f(e,t){for(let n of e.nameTable??[])for(let a=n;a;a=a.name_next??null)if(!(!d(t,a)||!a.live.dirty||!a.live.data))try{let e=a.live.data.slice(0,a.live.len);a.mount.opts.bridge.writeFile(i(a),e),a.live.dirty=!1}catch(t){throw r(e,t)}}function p(e,t){let n=e.nameTable??[],r=[];for(let e of n)for(let n=e;n;n=n.name_next??null){if(!d(t,n))continue;let e=n.live;e.stat=void 0,e.openCount===0?n!==n.mount.root&&r.push(n):e.loaded&&!e.dirty&&(e.data=void 0,e.len=0,e.loaded=!1)}if(e.hashRemoveNode)for(let t of r)e.hashRemoveNode(t)}function m(e){let t=[...new Set(e.map(e=>e.replace(/\/+$/,``)||`/`))].sort();return t.filter(e=>!t.some(t=>t!==e&&(t===`/`||e.startsWith(`${t}/`))))}function h(e){if(e instanceof Error)return e.message;let t=e?.errno;return typeof t==`number`?`errno ${t}`:String(e)}function g(e,t,n,r){let i=e.filesystems.SLICC_LIVE_FS??u(e);e.filesystems.SLICC_LIVE_FS=i;let a=[];for(let o of m(n))if(o!==`/`)try{e.mkdirTree(o),e.mount(i,{root:o,bridge:t},o),a.push(o)}catch(e){r(`live VFS mount of ${o} failed: ${h(e)}`)}return{plugin:i,mounted:a}}const _=new Set([`dev`,`proc`]),v=[`/usr`,`/bin`],y=[`writeFile`,`mkdir`,`rm`,`rename`,`unlink`,`rmdir`,`symlink`,`chmod`,`utimes`];function b(t,n){let r={...t};for(let i of y){let a=t[i];r[i]=(...r)=>{n.wasUsed()&&e(n,t);try{a.apply(t,r)}finally{n.invalidate()}}}return r}function x(e,t){let n;try{n=e.readdir(`/`)}catch(e){return t(`cannot list the VFS root, nothing mounted: ${String(e)}`),[]}let r=n.filter(e=>e&&!e.includes(`/`)&&!_.has(e)).map(e=>`/${e}`);for(let e of v)r.includes(e)||r.push(e);let i=[];for(let t of r)try{e.stat(t).isDirectory&&i.push(t)}catch{}return i}function S(t,n,r={}){let{bridge:i,syncFs:a,warn:o}=n;a.wasUsed()&&e(a,i);let{plugin:s,mounted:c}=g(t,b(i,a),x(i,o),o);try{t.chdir(r.cwd??n.cwd)}catch(e){o(`cannot chdir to ${r.cwd??n.cwd}: ${String(e)}`)}return{mounted:c,flush:()=>f(t,s),invalidate:()=>p(t,s)}}export{S as mountVfsIntoEmscripten};
1
+ import{n as e}from"./js-realm-worker-Dj6E7cem.js";const t={EACCES:2,EBADF:8,EBUSY:10,EEXIST:20,EINVAL:28,EIO:29,EISDIR:31,ELOOP:32,ENAMETOOLONG:37,ENOENT:44,ENOSPC:51,ENOSYS:52,ENOTDIR:54,ENOTEMPTY:55,EPERM:63,EROFS:69,ETIMEDOUT:73,EXDEV:75},n=4095;function r(e,n){if(n?.errno!==void 0&&n instanceof e.ErrnoError)return n;let r=n?.code,i=typeof r==`string`?t[r]??29:29;return new e.ErrnoError(i)}function i(e){let t=[],n=e;for(;n!==n.mount.root;)t.push(n.name),n=n.parent;let r=e.mount.opts.root.replace(/\/+$/,``);return t.length===0?r||`/`:`${r}/${t.reverse().join(`/`)}`}function a(e){let t=e.isSymbolicLink?40960:e.isDirectory?16384:32768,r=e.isDirectory||e.isSymbolicLink?511:438;return t|((e.mode??r)&n||r)}function o(e){if(e!=null)return e instanceof Date?e.getTime():e}function s(e,n){let o=e=>e.mount.opts.bridge;function s(t){try{return t()}catch(t){throw r(e,t)}}function c(e){try{s(e)}catch(e){if(e.errno!==t.ENOSYS)throw e}}function l(e){return{...e?{stat:e}:{},len:0,loaded:!1,dirty:!1,openCount:0}}function u(t,r,i){let o=e.createNode(t,r,a(i),0);return o.node_ops=n.node,o.stream_ops=n.stream,o.live=l(i),o}function d(e){if(e.live.orphan)return{...e.live.stat,size:e.live.len};if(!e.live.stat){let t=s(()=>o(e).lstat(i(e)));e.live.stat=t,e.mode=a(t)}return e.live.stat}function f(e,t){let n=i(e);return n===`/`?`/${t}`:`${n}/${t}`}function p(e){let t=e.live;if(t.loaded)return;let n=s(()=>o(e).readFile(i(e)));t.data=n,t.len=n.length,t.loaded=!0}function m(e,t){let n=e.live,r=n.data??new Uint8Array;if(r.length>=t)return r;let i=new Uint8Array(Math.max(t,r.length*2,256));return i.set(r.subarray(0,n.len)),n.data=i,i}function h(e){let t=e.live;if(!t.dirty||!t.data||t.orphan)return;let n=t.data.slice(0,t.len);s(()=>o(e).writeFile(i(e),n)),t.dirty=!1,t.stat=void 0}function g(e,t){let n=e.live;if(n.openCount>0){t>0?p(e):n.loaded=!0;let r=m(e,t);t>n.len&&r.fill(0,n.len,t),n.len=t,n.dirty=!0;return}let r=i(e),a=new Uint8Array(t);if(t>0){let n=s(()=>o(e).readFile(r));a.set(n.subarray(0,Math.min(t,n.length)))}s(()=>o(e).writeFile(r,a)),n.stat=void 0}return{Fs:e,bridgeOf:o,call:s,metadataCall:c,makeNode:u,statOf:d,childPath:f,ensureLoaded:p,ensureCapacity:m,flushNode:h,truncate:g}}function c(e){let{Fs:r,bridgeOf:a,call:s,metadataCall:c,makeNode:l,statOf:u,childPath:d,flushNode:f,truncate:p}=e,{ensureLoaded:m}=e;return{getattr(e){let t=u(e),n=e.live,i=r.isDir(e.mode)?4096:n.loaded?n.len:t.size,a=new Date(t.mtimeMs??0);return{dev:1,ino:e.id,mode:e.mode,nlink:1,uid:0,gid:0,rdev:0,size:i,atime:a,mtime:a,ctime:a,blksize:4096,blocks:Math.ceil(i/4096)}},setattr(e,t){if(e.live.orphan){t.mode!==void 0&&t.mode!==null&&(e.mode=e.mode&-4096|t.mode&n),t.size!==void 0&&t.size!==null&&p(e,t.size);return}let s=i(e);if(t.mode!==void 0&&t.mode!==null){let r=t.mode&n;r!==(e.mode&n)&&(c(()=>a(e).chmod(s,r)),e.mode=e.mode&-4096|r)}t.size!==void 0&&t.size!==null&&r.isFile(e.mode)&&p(e,t.size);let l=o(t.mtime)??t.timestamp;if(l!==void 0){let n=o(t.atime)??l;f(e),c(()=>a(e).utimes(s,n,l))}e.live.stat=void 0},lookup(e,t){let n=s(()=>a(e).lstat(d(e,t)));return l(e,t,n)},mknod(e,n,i){let o=d(e,n);if(r.isDir(i))s(()=>a(e).mkdir(o));else if(r.isFile(i))s(()=>a(e).writeFile(o,new Uint8Array));else throw new r.ErrnoError(t.EPERM);let c=l(e,n,{isFile:r.isFile(i),isDirectory:r.isDir(i),isSymbolicLink:!1,size:0,mode:i,mtimeMs:Date.now()});return c.live.stat=void 0,c},rename(e,t,n){let o=i(e),c=d(t,n);f(e),s(()=>a(e).rename(o,c));try{let i=r.lookupNode?.(t,n);i&&i!==e&&r.hashRemoveNode?.(i)}catch{}e.name=n,e.live.stat=void 0},unlink(e,t){let n;try{let i=r.lookupNode?.(e,t);i&&i.live?.openCount>0&&r.isFile(i.mode)&&(n=i)}catch{}n&&(u(n),m(n)),s(()=>a(e).unlink(d(e,t))),n&&(n.live.orphan=!0)},rmdir(e,t){s(()=>a(e).rmdir(d(e,t)))},readdir(e){return[`.`,`..`,...s(()=>a(e).readdir(i(e)))]},symlink(e,t,n){let r=d(e,t);return s(()=>a(e).symlink(n,r)),l(e,t,{isFile:!1,isDirectory:!1,isSymbolicLink:!0,size:n.length})},readlink(e){if(!r.isLink(e.mode))throw new r.ErrnoError(t.EINVAL);return s(()=>a(e).readlink(i(e)))}}}function l(e){let{Fs:n,statOf:r,ensureLoaded:i,ensureCapacity:a,flushNode:o}=e;return{open(e){n.isFile(e.node.mode)&&e.node.live.openCount++},dup(e){n.isFile(e.node.mode)&&e.node.live.openCount++},close(e){let t=e.node;if(!n.isFile(t.mode))return;let r=t.live;if(r.openCount=Math.max(0,r.openCount-1),!(r.openCount>0))try{o(t)}finally{r.data=void 0,r.len=0,r.loaded=!1}},read(e,r,a,o,s){let c=e.node;if(n.isDir(c.mode))throw new n.ErrnoError(t.EISDIR);i(c);let l=c.live;if(s>=l.len||o<=0)return 0;let u=Math.min(o,l.len-s);return new Uint8Array(r.buffer,r.byteOffset+a,u).set(l.data.subarray(s,s+u)),u},write(e,r,o,s,c){let l=e.node;if(n.isDir(l.mode))throw new n.ErrnoError(t.EISDIR);if(s<=0)return 0;i(l);let u=l.live,d=c+s,f=a(l,d);return c>u.len&&f.fill(0,u.len,c),f.set(new Uint8Array(r.buffer,r.byteOffset+o,s),c),u.len=Math.max(u.len,d),u.dirty=!0,s},llseek(e,i,a){let o=i;if(a===1)o+=e.position;else if(a===2&&n.isFile(e.node.mode)){let t=e.node.live;o+=t.loaded?t.len:r(e.node).size}if(o<0)throw new n.ErrnoError(t.EINVAL);return o},fsync(e){o(e.node)}}}function u(e){let n=new Set,r={},i=s(e,r),a=c(i),o=l(i);return r.node=a,r.stream=o,{mounts:n,node_ops:a,stream_ops:o,mount(r){let a=i.call(()=>r.opts.bridge.stat(r.opts.root));if(!a.isDirectory)throw new e.ErrnoError(t.ENOTDIR);let o=i.makeNode(null,`/`,a);return n.add(r),o}}}function d(e,t){return!!t&&e.mounts.has(t.mount)}function f(e,t){for(let n of e.nameTable??[])for(let a=n;a;a=a.name_next??null)if(!(!d(t,a)||!a.live.dirty||!a.live.data))try{let e=a.live.data.slice(0,a.live.len);a.mount.opts.bridge.writeFile(i(a),e),a.live.dirty=!1}catch(t){throw r(e,t)}}function p(e,t){let n=e.nameTable??[],r=[];for(let e of n)for(let n=e;n;n=n.name_next??null){if(!d(t,n))continue;let e=n.live;e.stat=void 0,e.openCount===0?n!==n.mount.root&&r.push(n):e.loaded&&!e.dirty&&(e.data=void 0,e.len=0,e.loaded=!1)}if(e.hashRemoveNode)for(let t of r)e.hashRemoveNode(t)}function m(e){let t=[...new Set(e.map(e=>e.replace(/\/+$/,``)||`/`))].sort();return t.filter(e=>!t.some(t=>t!==e&&(t===`/`||e.startsWith(`${t}/`))))}function h(e){if(e instanceof Error)return e.message;let t=e?.errno;return typeof t==`number`?`errno ${t}`:String(e)}function g(e,t,n,r){let i=e.filesystems.SLICC_LIVE_FS??u(e);e.filesystems.SLICC_LIVE_FS=i;let a=[];for(let o of m(n))if(o!==`/`)try{e.mkdirTree(o),e.mount(i,{root:o,bridge:t},o),a.push(o)}catch(e){r(`live VFS mount of ${o} failed: ${h(e)}`)}return{plugin:i,mounted:a}}const _=new Set([`dev`,`proc`]),v=[`/usr`,`/bin`],y=[`writeFile`,`mkdir`,`rm`,`rename`,`unlink`,`rmdir`,`symlink`,`chmod`,`utimes`];function b(t,n){let r={...t};for(let i of y){let a=t[i];r[i]=(...r)=>{n.wasUsed()&&e(n,t);try{a.apply(t,r)}finally{n.invalidate()}}}return r}function x(e,t){let n;try{n=e.readdir(`/`)}catch(e){return t(`cannot list the VFS root, nothing mounted: ${String(e)}`),[]}let r=n.filter(e=>e&&!e.includes(`/`)&&!_.has(e)).map(e=>`/${e}`);for(let e of v)r.includes(e)||r.push(e);let i=[];for(let t of r)try{e.stat(t).isDirectory&&i.push(t)}catch{}return i}function S(t,n,r={}){let{bridge:i,syncFs:a,warn:o}=n;a.wasUsed()&&e(a,i);let{plugin:s,mounted:c}=g(t,b(i,a),x(i,o),o);try{t.chdir(r.cwd??n.cwd)}catch(e){o(`cannot chdir to ${r.cwd??n.cwd}: ${String(e)}`)}return{mounted:c,flush:()=>f(t,s),invalidate:()=>p(t,s)}}export{S as mountVfsIntoEmscripten};
@@ -0,0 +1 @@
1
+ import{t as e}from"./logger-LESFN7Hj.js";import"./proxied-fetch-DXaTHROw.js";import{t}from"./runtime-env-DadgceZk.js";import"./shared-Crk4gYF8.js";import{n}from"./hf-defaults-BwJdGLgk.js";import{installPackages as r}from"./installer-DR7izkMG.js";import{downloadHfRepo as i}from"./hf-download-CNg2vD63.js";e(`speech:espeak`);const a=[`ort-wasm-simd-threaded.jsep.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort-wasm-simd-threaded.jsep.wasm`,`ort-wasm-simd-threaded.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort.wasm`,`ort-wasm-simd-threaded.asyncify.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort-wasm-simd-threaded.asyncify.wasm`,`ort-wasm-simd-threaded.jspi.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort-wasm-simd-threaded.jspi.wasm`],o=e(`speech:ensure-assets`),s=`onnxruntime-web`,c=`${s}@1.31.0-dev.20260914-8d85527a0`,l=`espeak-ng`,u=[`espeak-ng.js`,`espeak-ng.wasm`],d=`/workspace`,f=t,p=a.filter(e=>!/\.(asyncify|jspi)\./.test(e));async function m(e){try{let t=await e.readFile(`/workspace/node_modules/onnxruntime-web/package.json`,{encoding:`utf-8`}),n=typeof t==`string`?t:new TextDecoder().decode(t),r=JSON.parse(n);if(r&&typeof r==`object`&&`version`in r&&typeof r.version==`string`)return r.version}catch{}return null}async function h(e,t){let n=await Promise.all(p.map(t=>e.fs.exists(`/workspace/node_modules/onnxruntime-web/dist/${t}`))),i=await m(e.fs);if(n.every(Boolean)&&i===`1.31.0-dev.20260914-8d85527a0`)return t?.({asset:s,phase:`present`}),!1;t?.({asset:s,phase:`staging`});let{errors:a}=await r([c],{fs:e.fs,fetch:e.fetch,cwd:d});if(a.length>0)throw Error(`failed to stage ${s} wasm runtime: ${a[0].error.message}`);return t?.({asset:s,phase:`done`}),!0}async function g(e,t){if((await Promise.all(u.map(t=>e.fs.exists(`/workspace/node_modules/espeak-ng/dist/${t}`)))).every(Boolean))return t?.({asset:l,phase:`present`}),!1;t?.({asset:l,phase:`staging`});let{errors:n}=await r([l],{fs:e.fs,fetch:e.fetch,cwd:d});if(n.length>0)throw Error(`failed to stage ${l} wasm: ${n[0].error.message}`);return t?.({asset:l,phase:`done`}),!0}async function _(e,t){try{return await g(e,t)}catch(e){return o.warn(`optional espeak-ng staging failed; non-English Kokoro voices may fall back`,e),!1}}async function v(e,t,r){let a=n(t,null,d),o=0,s=await i({fetch:e.fetch,fs:e.fs,repo:t,targetDir:a,progress:{onListed:({files:e,totalBytes:n})=>r?.({asset:t,phase:`listing`,filesLoaded:0,filesTotal:e.length,bytesLoaded:0,bytesTotal:n}),onFile:e=>{o+=e.bytes,r?.({asset:t,phase:e.status,file:e.file,filesLoaded:e.index,filesTotal:e.total,bytesLoaded:o})}}});return r?.({asset:t,phase:`done`,filesLoaded:s.files.length,filesTotal:s.files.length,bytesLoaded:o,bytesTotal:o}),{repo:t,downloaded:s.downloaded,skipped:s.skipped}}async function y(e,t){if(f())return{skipped:!0,ortStaged:!1,espeakStaged:!1,repos:[]};let n=await h(e,t),r=e.repos??[`onnx-community/whisper-tiny`,`onnx-community/Kokoro-82M-v1.0-ONNX`],i=[];for(let n of r)i.push(await v(e,n,t));let a=await _(e,t);return o.info(`speech assets staged`,{ortStaged:n,espeakStaged:a,repos:i.length}),{skipped:!1,ortStaged:n,espeakStaged:a,repos:i}}export{y as ensureSpeechAssetsStaged};
@@ -1,4 +1,4 @@
1
- import{i as e,t}from"./rolldown-runtime-Dd_uD5pT.js";import{a as n}from"./path-utils-DNJG-zQf.js";import{C as r,S as i,p as a,t as o}from"./shared-De1sMYMX.js";import{n as s}from"./wasm-compiler-Ct7QZURL.js";var c=e(t(((e,t)=>{(e=>{var t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,a=(e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})},o=(e,a,o,s)=>{if(a&&typeof a==`object`||typeof a==`function`)for(let c of r(a))!i.call(e,c)&&c!==o&&t(e,c,{get:()=>a[c],enumerable:!(s=n(a,c))||s.enumerable});return e},s=e=>o(t({},`__esModule`,{value:!0}),e),c=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),l={};a(l,{analyzeMetafile:()=>xe,analyzeMetafileSync:()=>Te,build:()=>_e,buildSync:()=>Se,context:()=>ve,default:()=>je,formatMessages:()=>be,formatMessagesSync:()=>we,initialize:()=>ke,stop:()=>Ee,transform:()=>ye,transformSync:()=>Ce,version:()=>ge}),e.exports=s(l);function u(e){let t=e=>{if(e===null)n.write8(0);else if(typeof e==`boolean`)n.write8(1),n.write8(+e);else if(typeof e==`number`)n.write8(2),n.write32(e|0);else if(typeof e==`string`)n.write8(3),n.write(p(e));else if(e instanceof Uint8Array)n.write8(4),n.write(e);else if(e instanceof Array){n.write8(5),n.write32(e.length);for(let n of e)t(n)}else{let r=Object.keys(e);n.write8(6),n.write32(r.length);for(let i of r)n.write(p(i)),t(e[i])}},n=new f;return n.write32(0),n.write32(e.id<<1|!e.isRequest),t(e.value),_(n.buf,n.len-4,0),n.buf.subarray(0,n.len)}function d(e){let t=()=>{switch(n.read8()){case 0:return null;case 1:return!!n.read8();case 2:return n.read32();case 3:return m(n.read());case 4:return n.read();case 5:{let e=n.read32(),r=[];for(let n=0;n<e;n++)r.push(t());return r}case 6:{let e=n.read32(),r={};for(let i=0;i<e;i++)r[m(n.read())]=t();return r}default:throw Error(`Invalid packet`)}},n=new f(e),r=n.read32(),i=!(r&1);r>>>=1;let a=t();if(n.ptr!==e.length)throw Error(`Invalid packet`);return{id:r,isRequest:i,value:a}}var f=class{constructor(e=new Uint8Array(1024)){this.buf=e,this.len=0,this.ptr=0}_write(e){if(this.len+e>this.buf.length){let t=new Uint8Array((this.len+e)*2);t.set(this.buf),this.buf=t}return this.len+=e,this.len-e}write8(e){let t=this._write(1);this.buf[t]=e}write32(e){let t=this._write(4);_(this.buf,e,t)}write(e){let t=this._write(4+e.length);_(this.buf,e.length,t),this.buf.set(e,t+4)}_read(e){if(this.ptr+e>this.buf.length)throw Error(`Invalid packet`);return this.ptr+=e,this.ptr-e}read8(){return this.buf[this._read(1)]}read32(){return g(this.buf,this._read(4))}read(){let e=this.read32(),t=new Uint8Array(e),n=this._read(t.length);return t.set(this.buf.subarray(n,n+e)),t}},p,m,h;if(typeof TextEncoder<`u`&&typeof TextDecoder<`u`){let e=new TextEncoder,t=new TextDecoder;p=t=>e.encode(t),m=e=>t.decode(e),h=`new TextEncoder().encode("")`}else if(typeof Buffer<`u`)p=e=>Buffer.from(e),m=e=>{let{buffer:t,byteOffset:n,byteLength:r}=e;return Buffer.from(t,n,r).toString()},h=`Buffer.from("")`;else throw Error(`No UTF-8 codec found`);if(!(p(``)instanceof Uint8Array))throw Error(`Invariant violation: "${h} instanceof Uint8Array" is incorrectly false
1
+ import{i as e,t}from"./rolldown-runtime-Dd_uD5pT.js";import{a as n}from"./path-utils-DNJG-zQf.js";import{a as r,i}from"./resolver-BjX48SSL.js";import{p as a,t as o}from"./shared-Crk4gYF8.js";import{n as s}from"./wasm-compiler-Ct7QZURL.js";var c=e(t(((e,t)=>{(e=>{var t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,a=(e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})},o=(e,a,o,s)=>{if(a&&typeof a==`object`||typeof a==`function`)for(let c of r(a))!i.call(e,c)&&c!==o&&t(e,c,{get:()=>a[c],enumerable:!(s=n(a,c))||s.enumerable});return e},s=e=>o(t({},`__esModule`,{value:!0}),e),c=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),l={};a(l,{analyzeMetafile:()=>xe,analyzeMetafileSync:()=>Te,build:()=>_e,buildSync:()=>Se,context:()=>ve,default:()=>je,formatMessages:()=>be,formatMessagesSync:()=>we,initialize:()=>ke,stop:()=>Ee,transform:()=>ye,transformSync:()=>Ce,version:()=>ge}),e.exports=s(l);function u(e){let t=e=>{if(e===null)n.write8(0);else if(typeof e==`boolean`)n.write8(1),n.write8(+e);else if(typeof e==`number`)n.write8(2),n.write32(e|0);else if(typeof e==`string`)n.write8(3),n.write(p(e));else if(e instanceof Uint8Array)n.write8(4),n.write(e);else if(e instanceof Array){n.write8(5),n.write32(e.length);for(let n of e)t(n)}else{let r=Object.keys(e);n.write8(6),n.write32(r.length);for(let i of r)n.write(p(i)),t(e[i])}},n=new f;return n.write32(0),n.write32(e.id<<1|!e.isRequest),t(e.value),_(n.buf,n.len-4,0),n.buf.subarray(0,n.len)}function d(e){let t=()=>{switch(n.read8()){case 0:return null;case 1:return!!n.read8();case 2:return n.read32();case 3:return m(n.read());case 4:return n.read();case 5:{let e=n.read32(),r=[];for(let n=0;n<e;n++)r.push(t());return r}case 6:{let e=n.read32(),r={};for(let i=0;i<e;i++)r[m(n.read())]=t();return r}default:throw Error(`Invalid packet`)}},n=new f(e),r=n.read32(),i=!(r&1);r>>>=1;let a=t();if(n.ptr!==e.length)throw Error(`Invalid packet`);return{id:r,isRequest:i,value:a}}var f=class{constructor(e=new Uint8Array(1024)){this.buf=e,this.len=0,this.ptr=0}_write(e){if(this.len+e>this.buf.length){let t=new Uint8Array((this.len+e)*2);t.set(this.buf),this.buf=t}return this.len+=e,this.len-e}write8(e){let t=this._write(1);this.buf[t]=e}write32(e){let t=this._write(4);_(this.buf,e,t)}write(e){let t=this._write(4+e.length);_(this.buf,e.length,t),this.buf.set(e,t+4)}_read(e){if(this.ptr+e>this.buf.length)throw Error(`Invalid packet`);return this.ptr+=e,this.ptr-e}read8(){return this.buf[this._read(1)]}read32(){return g(this.buf,this._read(4))}read(){let e=this.read32(),t=new Uint8Array(e),n=this._read(t.length);return t.set(this.buf.subarray(n,n+e)),t}},p,m,h;if(typeof TextEncoder<`u`&&typeof TextDecoder<`u`){let e=new TextEncoder,t=new TextDecoder;p=t=>e.encode(t),m=e=>t.decode(e),h=`new TextEncoder().encode("")`}else if(typeof Buffer<`u`)p=e=>Buffer.from(e),m=e=>{let{buffer:t,byteOffset:n,byteLength:r}=e;return Buffer.from(t,n,r).toString()},h=`Buffer.from("")`;else throw Error(`No UTF-8 codec found`);if(!(p(``)instanceof Uint8Array))throw Error(`Invariant violation: "${h} instanceof Uint8Array" is incorrectly false
2
2
 
3
3
  This indicates that your JavaScript environment is broken. You cannot use
4
4
  esbuild in this environment because esbuild relies on this invariant. This