sliccy 6.227.0 → 6.229.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 (178) hide show
  1. package/dist/ui/.vite/manifest.json +186 -186
  2. package/dist/ui/assets/{account-store-BFb2UO2K.js → account-store-BkmYrtWh.js} +1 -1
  3. package/dist/ui/assets/account-store-DaI3pV_q.js +1 -0
  4. package/dist/ui/assets/adobe-ByGGniSc.js +1 -0
  5. package/dist/ui/assets/{adobe-CN7urDKo.js → adobe-CK5jIUgh.js} +1 -1
  6. package/dist/ui/assets/{agent-panels-C6MuWyzH.js → agent-panels-4N8lgLlB.js} +1 -1
  7. package/dist/ui/assets/{agent-tools-BL9-Zw2C.js → agent-tools-CbAMai1C.js} +1 -1
  8. package/dist/ui/assets/{almost-bash-shell-headless-DQhRonH_.js → almost-bash-shell-headless-D4lkL1PE.js} +511 -633
  9. package/dist/ui/assets/{apply-layout-DWiLhm8Y.js → apply-layout-C3Hxv2wc.js} +1 -1
  10. package/dist/ui/assets/{apps-F56LSkNx.js → apps-CSLecGgW.js} +1 -1
  11. package/dist/ui/assets/{azure-openai-85x5L6_B.js → azure-openai-41jp9LC_.js} +1 -1
  12. package/dist/ui/assets/{azure-openai-CY4c1Ugr.js → azure-openai-D_87yjUR.js} +1 -1
  13. package/dist/ui/assets/{backend-hostfs-uVp10KM9.js → backend-hostfs-CCcqzP0i.js} +1 -1
  14. package/dist/ui/assets/{cdp-BJooT_YW.js → cdp-BkKwqz1e.js} +1 -1
  15. package/dist/ui/assets/{cerebras-CZd9VG3E.js → cerebras-BDO-kvE5.js} +1 -1
  16. package/dist/ui/assets/{cerebras-B7CuTW7B.js → cerebras-U5nzA51c.js} +1 -1
  17. package/dist/ui/assets/client-DWx5wn8j.js +4 -0
  18. package/dist/ui/assets/{codemode-tool-wGfb8DBp.js → codemode-tool-BQX4yxNo.js} +1 -1
  19. package/dist/ui/assets/{composer-speech-CIFv7pMq.js → composer-speech-srkAxUbm.js} +1 -1
  20. package/dist/ui/assets/{connect-surface-B2N6LdiO.js → connect-surface-DDMjzUVa.js} +1 -1
  21. package/dist/ui/assets/connection-manager-DiSK2DFK.js +1 -0
  22. package/dist/ui/assets/core-IQSnHO6h.js +36 -0
  23. package/dist/ui/assets/{directed-approval-ALHdAvDT.js → directed-approval-DoAqSdwX.js} +1 -1
  24. package/dist/ui/assets/{emscripten-vfs-hook-BWjaiiFG.js → emscripten-vfs-hook-Btn8bhm3.js} +1 -1
  25. package/dist/ui/assets/{ensure-speech-assets-yt0EoyNf.js → ensure-speech-assets-CGY0yb53.js} +1 -1
  26. package/dist/ui/assets/float-topology-DIH6ujZe.js +1 -0
  27. package/dist/ui/assets/frontmatter-Dcb90b9Y.js +4 -0
  28. package/dist/ui/assets/{frozen-archive-writer-BBnxV-Sw.js → frozen-archive-writer-Bx7lDD-y.js} +1 -1
  29. package/dist/ui/assets/{fs-DdDYEgE4.js → fs-CmMyV0R2.js} +2 -2
  30. package/dist/ui/assets/{fs-Bhw5j0eY.js → fs-HVEpoBdl.js} +1 -1
  31. package/dist/ui/assets/gelatiere-constants-BYJlhm8R.js +1 -0
  32. package/dist/ui/assets/gelatiere-store-DGJAZYRR.js +1 -0
  33. package/dist/ui/assets/gelatiere-unit-B45hU9Qp.js +1 -0
  34. package/dist/ui/assets/{github-DzMMdXju.js → github-CHlD9DnD.js} +1 -1
  35. package/dist/ui/assets/{github-C06K6hM6.js → github-D5pRwutP.js} +2 -2
  36. package/dist/ui/assets/{github-auth-DcTBaLFg.js → github-auth-CbquPMGV.js} +1 -1
  37. package/dist/ui/assets/{github-copilot-BCxu-JOH.js → github-copilot-CKYs3zD6.js} +1 -1
  38. package/dist/ui/assets/{github-copilot-DMzWgULe.js → github-copilot-ah3fINw0.js} +1 -1
  39. package/dist/ui/assets/{github-install-BiHV37oT.js → github-install-BCW6YENq.js} +1 -1
  40. package/dist/ui/assets/{github-zip-CHlzswro.js → github-zip-DBBIH7pC.js} +1 -1
  41. package/dist/ui/assets/{go-driver-DqgTG9N6.js → go-driver--cdxNvov.js} +1 -1
  42. package/dist/ui/assets/{guest-tool-gate-Df5NH2fw.js → guest-tool-gate-oF9u91qg.js} +1 -1
  43. package/dist/ui/assets/{hear-RPJIER3w.js → hear-7ll-c37k.js} +1 -1
  44. package/dist/ui/assets/{help-BA8Xystm.js → help-BufsEGnU.js} +1 -1
  45. package/dist/ui/assets/installer-DSzRazpo.js +2 -0
  46. package/dist/ui/assets/{interrupted-work-recovery-DUcRwxv3.js → interrupted-work-recovery-BvaORnO5.js} +1 -1
  47. package/dist/ui/assets/ipk-mamba-DT6fHMa9.js +46 -0
  48. package/dist/ui/assets/{js-realm-worker-BZ9Q6ni5.js → js-realm-worker-_lsydYvZ.js} +2 -2
  49. package/dist/ui/assets/{jsh-executor-Iaq-AOjA.js → jsh-executor--J3zbaof.js} +2 -2
  50. package/dist/ui/assets/{kernel-worker-CTxRZxWy.js → kernel-worker-D8RoqWtJ.js} +54 -57
  51. package/dist/ui/assets/{lick-ws-bridge-C_yTWgQK.js → lick-ws-bridge-DAHpKRdr.js} +1 -1
  52. package/dist/ui/assets/{lick-ws-bridge-DEXhaOXo.js → lick-ws-bridge-DnebioSV.js} +1 -1
  53. package/dist/ui/assets/{live-session-curation-CBWOt4Na.js → live-session-curation-BwBWvDgr.js} +1 -1
  54. package/dist/ui/assets/{live-session-snapshot-2ANcFmFa.js → live-session-snapshot-CWLRm7ap.js} +1 -1
  55. package/dist/ui/assets/loader-D4Fuki1u.js +1 -0
  56. package/dist/ui/assets/{local-llm-BY58x8Yq.js → local-llm-Bkn90yGM.js} +1 -1
  57. package/dist/ui/assets/{local-llm-Brt8sjwN.js → local-llm-C2ZxUpDd.js} +1 -1
  58. package/dist/ui/assets/{main-DFwN1I9-.js → main-CYO-QAwq.js} +3 -3
  59. package/dist/ui/assets/{main-cherry-CKnVoCvo.js → main-cherry-inPsecSV.js} +1 -1
  60. package/dist/ui/assets/mcp-command-g-QpCeTS.js +170 -0
  61. package/dist/ui/assets/{memory-curation-seam-CRQovNy0.js → memory-curation-seam-D7fqn714.js} +1 -1
  62. package/dist/ui/assets/{memory-health-CWV9igFz.js → memory-health-Bqo_UDWF.js} +1 -1
  63. package/dist/ui/assets/{memory-write-execute-F74nkaOx.js → memory-write-execute-r0RBk_wW.js} +1 -1
  64. package/dist/ui/assets/{merge-folded-cost-into-frozen-CNbJWFVZ.js → merge-folded-cost-into-frozen-jP6pVzid.js} +1 -1
  65. package/dist/ui/assets/{mount-CVw88Sae.js → mount-BNrwlTED.js} +1 -1
  66. package/dist/ui/assets/{mount-Cd5d-dGq.js → mount-DxWl9Cgn.js} +3 -3
  67. package/dist/ui/assets/{new-session-BCLo3JwP.js → new-session-PLmNdqPO.js} +2 -2
  68. package/dist/ui/assets/{oauth-bootstrap-m4oJyeeN.js → oauth-bootstrap-CYR02wc0.js} +2 -2
  69. package/dist/ui/assets/{onboarding-orchestrator-CYaAfyzh.js → onboarding-orchestrator-Ch_OZygn.js} +1 -1
  70. package/dist/ui/assets/{openai-codex-D-KswPCn.js → openai-codex-BFffUCUE.js} +1 -1
  71. package/dist/ui/assets/{openai-codex-CCVnXN_Y.js → openai-codex-ChaMaxfV.js} +1 -1
  72. package/dist/ui/assets/{openrouter-BMACqhZg.js → openrouter-BTbtL_IF.js} +1 -1
  73. package/dist/ui/assets/{openrouter-DDIS0gu8.js → openrouter-C-dZ1sGw.js} +1 -1
  74. package/dist/ui/assets/{openrouter-free-CxENTZRZ.js → openrouter-free-7huO0Drj.js} +1 -1
  75. package/dist/ui/assets/{openrouter-free-CQM2VJ2h.js → openrouter-free-CK4afGP8.js} +1 -1
  76. package/dist/ui/assets/{openrouter-oauth-DeZmK_PC.js → openrouter-oauth-CpPi4YSa.js} +1 -1
  77. package/dist/ui/assets/{openrouter-oauth-BTRrF814.js → openrouter-oauth-DkEePt5s.js} +1 -1
  78. package/dist/ui/assets/{opfs-mount-CH8xFjB1.js → opfs-mount-B2b-t0EF.js} +1 -1
  79. package/dist/ui/assets/{panel-rpc-handlers-DEV3O6Nf.js → panel-rpc-handlers-BfUW4als.js} +2 -2
  80. package/dist/ui/assets/{panelize-shell-wTRIeRfk.js → panelize-shell-C1kr0BTJ.js} +1 -1
  81. package/dist/ui/assets/{pi-edit-execution-CsYSVIy6.js → pi-edit-execution-Cb2xBqsc.js} +1 -1
  82. package/dist/ui/assets/{process-worker-COJhrHY2.js → process-worker-C_p81ZZU.js} +1 -1
  83. package/dist/ui/assets/{provider-DQlGI3wV.js → provider-CG1KqExL.js} +2 -2
  84. package/dist/ui/assets/provider-Dq9zABZQ.js +1 -0
  85. package/dist/ui/assets/{provider-settings-CI1NmuB7.js → provider-settings-CkyKYIkj.js} +1 -1
  86. package/dist/ui/assets/provider-store-access-Dn58QaFC.js +1 -0
  87. package/dist/ui/assets/provider-store-access-yQUMGoIb.js +1 -0
  88. package/dist/ui/assets/{providers-DWJgLVLG.js → providers-BbxGRCK7.js} +2 -2
  89. package/dist/ui/assets/{providers-DvzQAoZe.js → providers-DOjMgMU6.js} +1 -1
  90. package/dist/ui/assets/{quick-llm-CIeq8HDn.js → quick-llm-BMJBs7-S.js} +1 -1
  91. package/dist/ui/assets/{realm-inprocess-Ct0UTeSZ.js → realm-inprocess-DMdQOjDm.js} +2 -2
  92. package/dist/ui/assets/{realm-unhandled-rejections-But1_r5U.js → realm-unhandled-rejections-Be1sIIgh.js} +1 -1
  93. package/dist/ui/assets/{realm-unhandled-rejections-XCowEiz5.js → realm-unhandled-rejections-D6_73CJl.js} +1 -1
  94. package/dist/ui/assets/reason-l_1I9RdR.js +5 -0
  95. package/dist/ui/assets/{recovery-screen-2KkMuDJk.js → recovery-screen-CPI_iXWK.js} +1 -1
  96. package/dist/ui/assets/{remote-terminal-view-BsBi-Jq-.js → remote-terminal-view-DXtNRrbr.js} +2 -2
  97. package/dist/ui/assets/{restore-BxWnVMjS.js → restore-CAHvRjUh.js} +1 -1
  98. package/dist/ui/assets/{run-8y7BhTkZ.js → run-9c55NzaM.js} +1 -1
  99. package/dist/ui/assets/{run-dJaEQuBZ.js → run-AtPs8A5o.js} +1 -1
  100. package/dist/ui/assets/{run-V-yf2BVO.js → run-B_EzD3y6.js} +2 -2
  101. package/dist/ui/assets/{run-DI8sQ-UX.js → run-Blcmnnqa.js} +1 -1
  102. package/dist/ui/assets/{run-5o2ADtPK.js → run-Cz1-std9.js} +2 -2
  103. package/dist/ui/assets/{run-B1b6--PA.js → run-DFVjtIie.js} +1 -1
  104. package/dist/ui/assets/{run-Dp8o0HDu.js → run-ZVh0R1Qb.js} +1 -1
  105. package/dist/ui/assets/{session-command-memory-Da1Ay0IK.js → session-command-memory--pxt-rWi.js} +2 -2
  106. package/dist/ui/assets/{session-jsonl-CisoFWdV.js → session-jsonl-Bl-_Ke5m.js} +1 -1
  107. package/dist/ui/assets/{session-jsonl-BT08KJtu.js → session-jsonl-DIe9RcuQ.js} +1 -1
  108. package/dist/ui/assets/{session-search-index-C9dq-YnZ.js → session-search-index-DXYard0w.js} +1 -1
  109. package/dist/ui/assets/{setup-feature-flags-remote-C-QrDDap.js → setup-feature-flags-remote-DpryLi4X.js} +1 -1
  110. package/dist/ui/assets/{setup-model-catalog-DQFqjnfG.js → setup-model-catalog-C0SmDaKF.js} +1 -1
  111. package/dist/ui/assets/{signed-fetch-B_zCsTF6.js → signed-fetch-BP6r0_WD.js} +1 -1
  112. package/dist/ui/assets/{silent-renew-backoff-DZMNobI2.js → silent-renew-backoff-BINyAdDo.js} +1 -1
  113. package/dist/ui/assets/slicc-version-jWg-8NKA.js +1 -0
  114. package/dist/ui/assets/{snapshot-Qi7uJgTK.js → snapshot-C-tqP5Vd.js} +1 -1
  115. package/dist/ui/assets/{snapshot-features-ko4zNFx_.js → snapshot-features-My_1CrXJ.js} +1 -1
  116. package/dist/ui/assets/{soundscape-CSNoiZFC.js → soundscape-Dr7onmG-.js} +1 -1
  117. package/dist/ui/assets/{speak-aAmw1Lv4.js → speak-1Zw3IWIU.js} +1 -1
  118. package/dist/ui/assets/{sprinkle-manager-BcUAmBKL.js → sprinkle-manager-BpCI8aCf.js} +1 -1
  119. package/dist/ui/assets/{sprinkle-renderer-a99oRJ5K.js → sprinkle-renderer-BFoYTPNh.js} +1 -1
  120. package/dist/ui/assets/{state-B8wLxLGq.js → state-BZmhbSgZ.js} +1 -1
  121. package/dist/ui/assets/{store-D8XRrwq1.js → store-D_3UY4Hq.js} +1 -1
  122. package/dist/ui/assets/{store-CBtTB-Y7.js → store-ioAs8Ofc.js} +1 -1
  123. package/dist/ui/assets/{sudo-CvMjZIh6.js → sudo-BUiJRaDN.js} +1 -1
  124. package/dist/ui/assets/{supervisor-CNcjK1gk.js → supervisor-CV95FP1l.js} +1 -1
  125. package/dist/ui/assets/{sync-dialog-D0C6RJ1r.js → sync-dialog-DbP2JDY5.js} +1 -1
  126. package/dist/ui/assets/{transformers-env-BWgCzqFy.js → transformers-env-CeRpgv4u.js} +1 -1
  127. package/dist/ui/assets/{tray-leader-anPCnjI3.js → tray-leader-B84Al9zk.js} +1 -1
  128. package/dist/ui/assets/{tray-leave-runtime-DTq8BTG1.js → tray-leave-runtime-Ck9jPDeB.js} +1 -1
  129. package/dist/ui/assets/{tray-sidecar-Dk-gNNOa.js → tray-sidecar-CrCOCbAy.js} +1 -1
  130. package/dist/ui/assets/{turn-journal-B-yFOK6T.js → turn-journal-DJcMfuEK.js} +1 -1
  131. package/dist/ui/assets/{upgrade-detection-BofecB7v.js → upgrade-detection-Bi7vIh9b.js} +1 -1
  132. package/dist/ui/assets/{upskill-lick-skip-3qGDA07K.js → upskill-lick-skip-DdtxmzSe.js} +1 -1
  133. package/dist/ui/assets/{voice-reply-C1P_wamT.js → voice-reply-Cn39TVu-.js} +1 -1
  134. package/dist/ui/assets/wasi-runtime-BMVXeT_F.js +3 -0
  135. package/dist/ui/assets/{wc-attach-dgMJ26XT.js → wc-attach-IDr8eMKS.js} +2 -2
  136. package/dist/ui/assets/{wc-browser-B-COerUp.js → wc-browser-DyMZIHWZ.js} +1 -1
  137. package/dist/ui/assets/{wc-computers-_JxYl2wr.js → wc-computers-lVdM5Q0C.js} +1 -1
  138. package/dist/ui/assets/{wc-detached-D2pbuUgz.js → wc-detached-r0tNzoI0.js} +1 -1
  139. package/dist/ui/assets/{wc-extension-CllXRrrB.js → wc-extension-C3cTiHOK.js} +2 -2
  140. package/dist/ui/assets/{wc-follower-BJoxJGJc.js → wc-follower-C3Ssv3pH.js} +3 -3
  141. package/dist/ui/assets/{wc-follower-oauth-CRVfRh9S.js → wc-follower-oauth-DjHjHKJ7.js} +1 -1
  142. package/dist/ui/assets/{wc-gelatiere-oTqfeOtw.js → wc-gelatiere-Dh5Mn9bA.js} +1 -1
  143. package/dist/ui/assets/{wc-live-lanuGtCH.js → wc-live-D0928vE7.js} +5 -5
  144. package/dist/ui/assets/{wc-nav-CxTE5nNk.js → wc-nav-B_z2mlYb.js} +2 -2
  145. package/dist/ui/assets/{wc-onboarding-CTHTCQRn.js → wc-onboarding-rgJJv4BS.js} +2 -2
  146. package/dist/ui/assets/{wc-permissions-DsdMkMR_.js → wc-permissions-9m7YrmL2.js} +2 -2
  147. package/dist/ui/assets/{wc-placeholder-BW3O9G-1.js → wc-placeholder-Cp-j-cTq.js} +3 -3
  148. package/dist/ui/assets/{wc-secret-request-CYprt2E3.js → wc-secret-request-CJqEUR2V.js} +1 -1
  149. package/dist/ui/assets/{wc-settings-BpOWAvNP.js → wc-settings-4EfpkMeU.js} +3 -3
  150. package/dist/ui/assets/{wc-shell-ublv7ZL8.js → wc-shell-DMHh-A41.js} +116 -116
  151. package/dist/ui/assets/{wc-shortcut-config-I0L9ZRfk.js → wc-shortcut-config-HMWkdwIV.js} +1 -1
  152. package/dist/ui/assets/{wc-sprinkles-BZFWrQuP.js → wc-sprinkles-9kl4n4Ve.js} +2 -2
  153. package/dist/ui/assets/{wc-transcript-export-Camv8Krm.js → wc-transcript-export-D2mq6DII.js} +2 -2
  154. package/dist/ui/assets/{wc-tray-D50mlMs8.js → wc-tray-BuuLiPV3.js} +4 -4
  155. package/dist/ui/assets/welcome-detection-CO83xvwE.js +1 -0
  156. package/dist/ui/assets/{whisper-session-Myw3zk-W.js → whisper-session-D--IlXLT.js} +2 -2
  157. package/dist/ui/assets/{xai-grok-BVM_XcYa.js → xai-grok-DDHu18Wf.js} +1 -1
  158. package/dist/ui/assets/{xai-grok-D4iOI1_b.js → xai-grok-DMet3e54.js} +1 -1
  159. package/dist/ui/index.html +3 -3
  160. package/dist/ui/packages/webapp/index.html +3 -3
  161. package/package.json +2 -2
  162. package/dist/ui/assets/account-store-p9YkaR-j.js +0 -1
  163. package/dist/ui/assets/adobe-BnfgTqEQ.js +0 -1
  164. package/dist/ui/assets/client-C4_ggaf5.js +0 -4
  165. package/dist/ui/assets/connection-manager-SNYTz_SX.js +0 -1
  166. package/dist/ui/assets/core-E6pC-3NP.js +0 -36
  167. package/dist/ui/assets/gelatiere-store-DNMjj5xM.js +0 -1
  168. package/dist/ui/assets/gelatiere-unit-BEnRKsg5.js +0 -1
  169. package/dist/ui/assets/installer-3ARo1i86.js +0 -2
  170. package/dist/ui/assets/ipk-mamba-BEORgiAj.js +0 -46
  171. package/dist/ui/assets/loader-Dw-TPPKt.js +0 -4
  172. package/dist/ui/assets/provider-DiPmyduk.js +0 -1
  173. package/dist/ui/assets/provider-store-access-CC-Qd6Js.js +0 -1
  174. package/dist/ui/assets/provider-store-access-R5OLCz2u.js +0 -1
  175. package/dist/ui/assets/redirect-uri-31pXIMS9.js +0 -1
  176. package/dist/ui/assets/slicc-version-DwNEsrEc.js +0 -1
  177. package/dist/ui/assets/wasi-runtime-CelptKxl.js +0 -3
  178. package/dist/ui/assets/welcome-detection-BtHni7N4.js +0 -1
@@ -1 +1 @@
1
- import{CHAT_SURFACE_ID as e}from"./wc-sprinkles-BZFWrQuP.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-9kl4n4Ve.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-Bhw5j0eY.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-HVEpoBdl.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{a as e}from"./diagnostics-Cag7MsZI.js";import{t}from"./models-Xc0Gclrk.js";import{a as n}from"./compat-DpI6NrfX.js";import{S as r,v as i}from"./account-store-BFb2UO2K.js";import{r as a,t as o}from"./transform-messages-k2mfzJwY.js";import{n as s,t as c}from"./pi-transcript-context-miZCMig3.js";function l(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 u(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 d=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return d=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 f(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var p=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)},m=class extends Error{},h=class e extends m{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 _({message:r,cause:p(n)});let a=n?.error;return t===400?new y(t,a,r,i):t===401?new b(t,a,r,i):t===403?new x(t,a,r,i):t===404?new ee(t,a,r,i):t===409?new te(t,a,r,i):t===422?new ne(t,a,r,i):t===429?new re(t,a,r,i):t>=500?new ie(t,a,r,i):new e(t,a,r,i)}},g=class extends h{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},_=class extends h{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},v=class extends _{constructor({message:e}={}){super({message:e??`Request timed out.`})}},y=class extends h{},b=class extends h{},x=class extends h{},ee=class extends h{},te=class extends h{},ne=class extends h{},re=class extends h{},ie=class extends h{},ae=class extends m{constructor(){super(`Could not parse response content as the length limit was reached`)}},oe=class extends m{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},se=class extends Error{constructor(e){super(e)}},ce=class extends h{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}},le=class extends m{constructor(e,t,n){super(e),this.provider=t,this.cause=n}},ue=/^[a-z][a-z0-9+.-]*:/i,de=e=>ue.test(e),S=e=>(S=Array.isArray,S(e)),fe=S;function pe(e){return typeof e==`object`?e??{}:{}}function me(e){if(!e)return!0;for(let t in e)return!1;return!0}function he(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ge=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new m(`${e} must be an integer`);if(t<0)throw new m(`${e} must be a positive integer`);return t},_e=e=>{try{return JSON.parse(e)}catch{return}},ve=e=>new Promise(t=>setTimeout(t,e));function ye(){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 be(...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 xe(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return be({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function Se(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 Ce(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 we;function w(e){let t;return(we??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}var Te;function Ee(e){let t;return(Te??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var De,T,E,D,O,Oe,ke,Ae=65536,je=class{constructor(){De.add(this),T.set(this,void 0),E.set(this,void 0),D.set(this,void 0),O.set(this,void 0),Oe.set(this,void 0),l(this,T,new Uint8Array,`f`),l(this,E,0,`f`),l(this,D,0,`f`),l(this,O,0,`f`),l(this,Oe,!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||u(this,Oe,`f`)&&(l(this,Oe,!1,`f`),t[0]===10&&(t=t.subarray(1)),t.length===0))return[];u(this,De,`m`,ke).call(this,t);let n=[],r;for(;(r=Me(u(this,T,`f`),u(this,O,`f`),u(this,D,`f`)))!=null;){let e=Ee(u(this,T,`f`).subarray(u(this,E,`f`),r.preceding));n.push(e),l(this,E,r.index,`f`),r.carriage&&(u(this,E,`f`)<u(this,D,`f`)&&u(this,T,`f`)[u(this,E,`f`)]===10?l(this,E,u(this,E,`f`)+1,`f`):u(this,E,`f`)===u(this,D,`f`)&&l(this,Oe,!0,`f`)),l(this,O,u(this,E,`f`),`f`)}if(l(this,O,u(this,D,`f`),`f`),u(this,E,`f`)===u(this,D,`f`))l(this,E,0,`f`),l(this,D,0,`f`),l(this,O,0,`f`),u(this,T,`f`).length>Ae&&l(this,T,new Uint8Array,`f`);else if(n.length>0&&u(this,T,`f`).length>Ae){let e=u(this,D,`f`)-u(this,E,`f`);if(e<=Ae||u(this,T,`f`).length>e*4){let t=e<=Ae?Math.min(Math.max(e*2,256),Ae):e*2,n=new Uint8Array(t);n.set(u(this,T,`f`).subarray(u(this,E,`f`),u(this,D,`f`))),l(this,T,n,`f`),l(this,E,0,`f`),l(this,D,e,`f`),l(this,O,e,`f`)}}return n}flush(){return l(this,Oe,!1,`f`),u(this,E,`f`)===u(this,D,`f`)?[]:this.decode(`
1
+ import{a as e}from"./diagnostics-Cag7MsZI.js";import{t}from"./models-Xc0Gclrk.js";import{a as n}from"./compat-DpI6NrfX.js";import{S as r,v as i}from"./account-store-BkmYrtWh.js";import{r as a,t as o}from"./transform-messages-k2mfzJwY.js";import{n as s,t as c}from"./pi-transcript-context-miZCMig3.js";function l(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 u(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 d=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return d=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 f(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var p=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)},m=class extends Error{},h=class e extends m{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 _({message:r,cause:p(n)});let a=n?.error;return t===400?new y(t,a,r,i):t===401?new b(t,a,r,i):t===403?new x(t,a,r,i):t===404?new ee(t,a,r,i):t===409?new te(t,a,r,i):t===422?new ne(t,a,r,i):t===429?new re(t,a,r,i):t>=500?new ie(t,a,r,i):new e(t,a,r,i)}},g=class extends h{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},_=class extends h{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},v=class extends _{constructor({message:e}={}){super({message:e??`Request timed out.`})}},y=class extends h{},b=class extends h{},x=class extends h{},ee=class extends h{},te=class extends h{},ne=class extends h{},re=class extends h{},ie=class extends h{},ae=class extends m{constructor(){super(`Could not parse response content as the length limit was reached`)}},oe=class extends m{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},se=class extends Error{constructor(e){super(e)}},ce=class extends h{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}},le=class extends m{constructor(e,t,n){super(e),this.provider=t,this.cause=n}},ue=/^[a-z][a-z0-9+.-]*:/i,de=e=>ue.test(e),S=e=>(S=Array.isArray,S(e)),fe=S;function pe(e){return typeof e==`object`?e??{}:{}}function me(e){if(!e)return!0;for(let t in e)return!1;return!0}function he(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ge=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new m(`${e} must be an integer`);if(t<0)throw new m(`${e} must be a positive integer`);return t},_e=e=>{try{return JSON.parse(e)}catch{return}},ve=e=>new Promise(t=>setTimeout(t,e));function ye(){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 be(...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 xe(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return be({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function Se(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 Ce(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 we;function w(e){let t;return(we??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}var Te;function Ee(e){let t;return(Te??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var De,T,E,D,O,Oe,ke,Ae=65536,je=class{constructor(){De.add(this),T.set(this,void 0),E.set(this,void 0),D.set(this,void 0),O.set(this,void 0),Oe.set(this,void 0),l(this,T,new Uint8Array,`f`),l(this,E,0,`f`),l(this,D,0,`f`),l(this,O,0,`f`),l(this,Oe,!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||u(this,Oe,`f`)&&(l(this,Oe,!1,`f`),t[0]===10&&(t=t.subarray(1)),t.length===0))return[];u(this,De,`m`,ke).call(this,t);let n=[],r;for(;(r=Me(u(this,T,`f`),u(this,O,`f`),u(this,D,`f`)))!=null;){let e=Ee(u(this,T,`f`).subarray(u(this,E,`f`),r.preceding));n.push(e),l(this,E,r.index,`f`),r.carriage&&(u(this,E,`f`)<u(this,D,`f`)&&u(this,T,`f`)[u(this,E,`f`)]===10?l(this,E,u(this,E,`f`)+1,`f`):u(this,E,`f`)===u(this,D,`f`)&&l(this,Oe,!0,`f`)),l(this,O,u(this,E,`f`),`f`)}if(l(this,O,u(this,D,`f`),`f`),u(this,E,`f`)===u(this,D,`f`))l(this,E,0,`f`),l(this,D,0,`f`),l(this,O,0,`f`),u(this,T,`f`).length>Ae&&l(this,T,new Uint8Array,`f`);else if(n.length>0&&u(this,T,`f`).length>Ae){let e=u(this,D,`f`)-u(this,E,`f`);if(e<=Ae||u(this,T,`f`).length>e*4){let t=e<=Ae?Math.min(Math.max(e*2,256),Ae):e*2,n=new Uint8Array(t);n.set(u(this,T,`f`).subarray(u(this,E,`f`),u(this,D,`f`))),l(this,T,n,`f`),l(this,E,0,`f`),l(this,D,e,`f`),l(this,O,e,`f`)}}return n}flush(){return l(this,Oe,!1,`f`),u(this,E,`f`)===u(this,D,`f`)?[]:this.decode(`
2
2
  `)}};T=new WeakMap,E=new WeakMap,D=new WeakMap,O=new WeakMap,Oe=new WeakMap,De=new WeakSet,ke=function(e){if(u(this,D,`f`)+e.length>u(this,T,`f`).length){let t=u(this,D,`f`)-u(this,E,`f`);if(u(this,E,`f`)>=u(this,T,`f`).length/2&&t+e.length<=u(this,T,`f`).length)u(this,T,`f`).copyWithin(0,u(this,E,`f`),u(this,D,`f`));else{let n=Math.max(u(this,T,`f`).length*2,t+e.length,256),r=new Uint8Array(n);r.set(u(this,T,`f`).subarray(u(this,E,`f`),u(this,D,`f`))),l(this,T,r,`f`)}l(this,O,u(this,O,`f`)-u(this,E,`f`),`f`),l(this,D,t,`f`),l(this,E,0,`f`)}u(this,T,`f`).set(e,u(this,D,`f`)),l(this,D,u(this,D,`f`)+e.length,`f`)},je.NEWLINE_CHARS=new Set([`
3
3
  `,`\r`]),je.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Me(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 Ne(e){for(let t=0;t<e.length-1;t++){let n=Pe(e,t);if(n>0){let r=t+n,i=Pe(e,r);if(i>0)return r+i}}return-1}function Pe(e,t){return e[t]===10?1:e[t]===13?e[t+1]===10?2:1:0}var Fe={off:0,error:200,warn:300,info:400,debug:500},Ie=(e,t,n)=>{if(e){if(he(Fe,e))return e;k(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Fe))}`)}};function Le(){}function Re(e,t,n){return!t||Fe[e]>Fe[n]?Le:t[e].bind(t)}var ze={error:Le,warn:Le,info:Le,debug:Le},Be=new WeakMap;function k(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return ze;let r=Be.get(t);if(r&&r[0]===n)return r[1];let i={error:Re(`error`,t,n),warn:Re(`warn`,t,n),info:Re(`info`,t,n),debug:Re(`debug`,t,n)};return Be.set(t,[n,i]),i}var Ve=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),He,Ue=class e{constructor(e,t,n){He.set(this,void 0),this.iterator=e,this.controller=t,l(this,He,n,`f`)}static fromSSEResponse(t,n,r,i){let a=!1,o=r?k(r):console;async function*s(){if(a)throw new m("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 We(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 h(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 h(void 0,t.error,t.message,void 0);yield{event:e.event,data:t}}}e=!0}catch(e){if(r||f(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 je,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 m("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||f(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}[(He=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,u(this,He,`f`)),new e(()=>i(n),this.controller,u(this,He,`f`))]}toReadableStream(){let e;return be({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*We(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new m(`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 m(`Attempted to iterate over a response with no body`);let n=new qe,r=new je,i=Se(e.body);for await(let e of Ke(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 Ge=3;async function*Ke(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=Ne(t.subarray(i,r)))!==-1;)o+=i,yield t.slice(n,o),n=o,i=n;i=Math.max(n,r-Ge)}r>n&&(yield t.slice(n,r))}var qe=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{c as e,o as t}from"./account-store-p9YkaR-j.js";import{a as n}from"./diagnostics-Cag7MsZI.js";import{t as r}from"./models-CET5SEuw.js";import{a as i}from"./compat-CGK4SwF8.js";import{n as a,t as o}from"./pi-transcript-context-4pjVPiVC.js";import{r as s,t as c}from"./transform-messages-BeurHGV0.js";function l(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 u(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 d=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return d=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 f(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}const p=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 m=class extends Error{},h=class e extends m{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 _({message:r,cause:p(n)});let a=n?.error;return t===400?new y(t,a,r,i):t===401?new b(t,a,r,i):t===403?new x(t,a,r,i):t===404?new ee(t,a,r,i):t===409?new te(t,a,r,i):t===422?new ne(t,a,r,i):t===429?new re(t,a,r,i):t>=500?new ie(t,a,r,i):new e(t,a,r,i)}},g=class extends h{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},_=class extends h{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},v=class extends _{constructor({message:e}={}){super({message:e??`Request timed out.`})}},y=class extends h{},b=class extends h{},x=class extends h{},ee=class extends h{},te=class extends h{},ne=class extends h{},re=class extends h{},ie=class extends h{},ae=class extends m{constructor(){super(`Could not parse response content as the length limit was reached`)}},oe=class extends m{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},se=class extends Error{constructor(e){super(e)}},ce=class extends h{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}},le=class extends m{constructor(e,t,n){super(e),this.provider=t,this.cause=n}};const ue=/^[a-z][a-z0-9+.-]*:/i,de=e=>ue.test(e);let S=e=>(S=Array.isArray,S(e)),fe=S;function pe(e){return typeof e==`object`?e??{}:{}}function me(e){if(!e)return!0;for(let t in e)return!1;return!0}function he(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const ge=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new m(`${e} must be an integer`);if(t<0)throw new m(`${e} must be a positive integer`);return t},_e=e=>{try{return JSON.parse(e)}catch{return}},ve=e=>new Promise(t=>setTimeout(t,e));function ye(){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 be(...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 xe(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return be({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function Se(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 Ce(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 we;function w(e){let t;return(we??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}let Te;function Ee(e){let t;return(Te??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var De,T,E,D,Oe,ke,Ae;const je=65536;var Me=class{constructor(){De.add(this),T.set(this,void 0),E.set(this,void 0),D.set(this,void 0),Oe.set(this,void 0),ke.set(this,void 0),l(this,T,new Uint8Array,`f`),l(this,E,0,`f`),l(this,D,0,`f`),l(this,Oe,0,`f`),l(this,ke,!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||u(this,ke,`f`)&&(l(this,ke,!1,`f`),t[0]===10&&(t=t.subarray(1)),t.length===0))return[];u(this,De,`m`,Ae).call(this,t);let n=[],r;for(;(r=Ne(u(this,T,`f`),u(this,Oe,`f`),u(this,D,`f`)))!=null;){let e=Ee(u(this,T,`f`).subarray(u(this,E,`f`),r.preceding));n.push(e),l(this,E,r.index,`f`),r.carriage&&(u(this,E,`f`)<u(this,D,`f`)&&u(this,T,`f`)[u(this,E,`f`)]===10?l(this,E,u(this,E,`f`)+1,`f`):u(this,E,`f`)===u(this,D,`f`)&&l(this,ke,!0,`f`)),l(this,Oe,u(this,E,`f`),`f`)}if(l(this,Oe,u(this,D,`f`),`f`),u(this,E,`f`)===u(this,D,`f`))l(this,E,0,`f`),l(this,D,0,`f`),l(this,Oe,0,`f`),u(this,T,`f`).length>je&&l(this,T,new Uint8Array,`f`);else if(n.length>0&&u(this,T,`f`).length>je){let e=u(this,D,`f`)-u(this,E,`f`);if(e<=je||u(this,T,`f`).length>e*4){let t=e<=je?Math.min(Math.max(e*2,256),je):e*2,n=new Uint8Array(t);n.set(u(this,T,`f`).subarray(u(this,E,`f`),u(this,D,`f`))),l(this,T,n,`f`),l(this,E,0,`f`),l(this,D,e,`f`),l(this,Oe,e,`f`)}}return n}flush(){return l(this,ke,!1,`f`),u(this,E,`f`)===u(this,D,`f`)?[]:this.decode(`
1
+ import{c as e,o as t}from"./account-store-DaI3pV_q.js";import{a as n}from"./diagnostics-Cag7MsZI.js";import{t as r}from"./models-CET5SEuw.js";import{a as i}from"./compat-CGK4SwF8.js";import{n as a,t as o}from"./pi-transcript-context-4pjVPiVC.js";import{r as s,t as c}from"./transform-messages-BeurHGV0.js";function l(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 u(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 d=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return d=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 f(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}const p=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 m=class extends Error{},h=class e extends m{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 _({message:r,cause:p(n)});let a=n?.error;return t===400?new y(t,a,r,i):t===401?new b(t,a,r,i):t===403?new x(t,a,r,i):t===404?new ee(t,a,r,i):t===409?new te(t,a,r,i):t===422?new ne(t,a,r,i):t===429?new re(t,a,r,i):t>=500?new ie(t,a,r,i):new e(t,a,r,i)}},g=class extends h{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},_=class extends h{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},v=class extends _{constructor({message:e}={}){super({message:e??`Request timed out.`})}},y=class extends h{},b=class extends h{},x=class extends h{},ee=class extends h{},te=class extends h{},ne=class extends h{},re=class extends h{},ie=class extends h{},ae=class extends m{constructor(){super(`Could not parse response content as the length limit was reached`)}},oe=class extends m{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},se=class extends Error{constructor(e){super(e)}},ce=class extends h{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}},le=class extends m{constructor(e,t,n){super(e),this.provider=t,this.cause=n}};const ue=/^[a-z][a-z0-9+.-]*:/i,de=e=>ue.test(e);let S=e=>(S=Array.isArray,S(e)),fe=S;function pe(e){return typeof e==`object`?e??{}:{}}function me(e){if(!e)return!0;for(let t in e)return!1;return!0}function he(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const ge=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new m(`${e} must be an integer`);if(t<0)throw new m(`${e} must be a positive integer`);return t},_e=e=>{try{return JSON.parse(e)}catch{return}},ve=e=>new Promise(t=>setTimeout(t,e));function ye(){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 be(...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 xe(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return be({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function Se(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 Ce(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 we;function w(e){let t;return(we??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}let Te;function Ee(e){let t;return(Te??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var De,T,E,D,Oe,ke,Ae;const je=65536;var Me=class{constructor(){De.add(this),T.set(this,void 0),E.set(this,void 0),D.set(this,void 0),Oe.set(this,void 0),ke.set(this,void 0),l(this,T,new Uint8Array,`f`),l(this,E,0,`f`),l(this,D,0,`f`),l(this,Oe,0,`f`),l(this,ke,!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||u(this,ke,`f`)&&(l(this,ke,!1,`f`),t[0]===10&&(t=t.subarray(1)),t.length===0))return[];u(this,De,`m`,Ae).call(this,t);let n=[],r;for(;(r=Ne(u(this,T,`f`),u(this,Oe,`f`),u(this,D,`f`)))!=null;){let e=Ee(u(this,T,`f`).subarray(u(this,E,`f`),r.preceding));n.push(e),l(this,E,r.index,`f`),r.carriage&&(u(this,E,`f`)<u(this,D,`f`)&&u(this,T,`f`)[u(this,E,`f`)]===10?l(this,E,u(this,E,`f`)+1,`f`):u(this,E,`f`)===u(this,D,`f`)&&l(this,ke,!0,`f`)),l(this,Oe,u(this,E,`f`),`f`)}if(l(this,Oe,u(this,D,`f`),`f`),u(this,E,`f`)===u(this,D,`f`))l(this,E,0,`f`),l(this,D,0,`f`),l(this,Oe,0,`f`),u(this,T,`f`).length>je&&l(this,T,new Uint8Array,`f`);else if(n.length>0&&u(this,T,`f`).length>je){let e=u(this,D,`f`)-u(this,E,`f`);if(e<=je||u(this,T,`f`).length>e*4){let t=e<=je?Math.min(Math.max(e*2,256),je):e*2,n=new Uint8Array(t);n.set(u(this,T,`f`).subarray(u(this,E,`f`),u(this,D,`f`))),l(this,T,n,`f`),l(this,E,0,`f`),l(this,D,e,`f`),l(this,Oe,e,`f`)}}return n}flush(){return l(this,ke,!1,`f`),u(this,E,`f`)===u(this,D,`f`)?[]:this.decode(`
2
2
  `)}};T=new WeakMap,E=new WeakMap,D=new WeakMap,Oe=new WeakMap,ke=new WeakMap,De=new WeakSet,Ae=function(e){if(u(this,D,`f`)+e.length>u(this,T,`f`).length){let t=u(this,D,`f`)-u(this,E,`f`);if(u(this,E,`f`)>=u(this,T,`f`).length/2&&t+e.length<=u(this,T,`f`).length)u(this,T,`f`).copyWithin(0,u(this,E,`f`),u(this,D,`f`));else{let n=Math.max(u(this,T,`f`).length*2,t+e.length,256),r=new Uint8Array(n);r.set(u(this,T,`f`).subarray(u(this,E,`f`),u(this,D,`f`))),l(this,T,r,`f`)}l(this,Oe,u(this,Oe,`f`)-u(this,E,`f`),`f`),l(this,D,t,`f`),l(this,E,0,`f`)}u(this,T,`f`).set(e,u(this,D,`f`)),l(this,D,u(this,D,`f`)+e.length,`f`)},Me.NEWLINE_CHARS=new Set([`
3
3
  `,`\r`]),Me.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Ne(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 Pe(e){for(let t=0;t<e.length-1;t++){let n=Fe(e,t);if(n>0){let r=t+n,i=Fe(e,r);if(i>0)return r+i}}return-1}function Fe(e,t){return e[t]===10?1:e[t]===13?e[t+1]===10?2:1:0}const Ie={off:0,error:200,warn:300,info:400,debug:500},Le=(e,t,n)=>{if(e){if(he(Ie,e))return e;O(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Ie))}`)}};function Re(){}function ze(e,t,n){return!t||Ie[e]>Ie[n]?Re:t[e].bind(t)}const Be={error:Re,warn:Re,info:Re,debug:Re};let Ve=new WeakMap;function O(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return Be;let r=Ve.get(t);if(r&&r[0]===n)return r[1];let i={error:ze(`error`,t,n),warn:ze(`warn`,t,n),info:ze(`info`,t,n),debug:ze(`debug`,t,n)};return Ve.set(t,[n,i]),i}const He=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 Ue,We=class e{constructor(e,t,n){Ue.set(this,void 0),this.iterator=e,this.controller=t,l(this,Ue,n,`f`)}static fromSSEResponse(t,n,r,i){let a=!1,o=r?O(r):console;async function*s(){if(a)throw new m("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 Ge(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 h(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 h(void 0,t.error,t.message,void 0);yield{event:e.event,data:t}}}e=!0}catch(e){if(r||f(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 Me,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 m("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||f(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}[(Ue=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,u(this,Ue,`f`)),new e(()=>i(n),this.controller,u(this,Ue,`f`))]}toReadableStream(){let e;return be({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*Ge(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new m(`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 m(`Attempted to iterate over a response with no body`);let n=new qe,r=new Me,i=Se(e.body);for await(let e of Ke(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*Ke(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=Pe(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 qe=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-DdDYEgE4.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-CmMyV0R2.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,4 +1,4 @@
1
- import{t as e}from"./logger-DDBAeTLF.js";import"./navigation-watcher-CPcnZL9l.js";import"./wc-follower-oauth-CRVfRh9S.js";import{d as t,l as n,u as r}from"./main-DFwN1I9-.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-DjHjHKJ7.js";import{d as t,l as n,u as r}from"./main-CYO-QAwq.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-p9YkaR-j.js";import{a as t}from"./diagnostics-Cag7MsZI.js";import{a as n}from"./compat-CGK4SwF8.js";import{r,s as i}from"./legacy-api-aliases-DvlNmb0H.js";import{n as a}from"./pi-transcript-context-4pjVPiVC.js";const o=`cerebras`,s=`https://api.cerebras.ai/v1`,c=`openai-completions`,l=`${o}-openai`,u=`slicc-cerebras-models`;let d=[];const f=[{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 p(e){try{localStorage.setItem(u,JSON.stringify(e))}catch{}}function m(){try{let e=localStorage.getItem(u);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function h(e){let t=e.id??``,n=f.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 g(e){let t=await fetch(`${s}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(h).filter(e=>e.id.length>0);n.length>0&&(d=n,p(n))}function _(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:l,provider:o,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 v(e){console.error(`[cerebras] Stream error:`,e instanceof Error?e.message:String(e))}const y=(e,n,r={})=>{let i=t();return b(i,e,n,r).catch(v),i};async function b(e,t,n,i){try{let o={...t,baseUrl:s,api:c},l=r(o,a(n),i);for await(let t of l)e.push(t);e.end()}catch(n){v(n),e.push(_(t,n)),e.end()}}const x=(e,n,r)=>{let i=t();return S(i,e,n,r).catch(v),i};async function S(e,t,n,r){try{let o={...t,baseUrl:s,api:c},l=i(o,a(n),r);for await(let t of l)e.push(t);e.end()}catch(n){v(n),e.push(_(t,n)),e.end()}}const C={id:o,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(d.length>0)return d;let e=m();return e.length>0?e:f},refreshModels:async t=>{let n=t??e(o)??``;if(n)try{await g(n)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function w(){n({api:l,stream:y,streamSimple:x})}export{C as config,w as register};
1
+ import{a as e}from"./account-store-DaI3pV_q.js";import{a as t}from"./diagnostics-Cag7MsZI.js";import{a as n}from"./compat-CGK4SwF8.js";import{r,s as i}from"./legacy-api-aliases-DvlNmb0H.js";import{n as a}from"./pi-transcript-context-4pjVPiVC.js";const o=`cerebras`,s=`https://api.cerebras.ai/v1`,c=`openai-completions`,l=`${o}-openai`,u=`slicc-cerebras-models`;let d=[];const f=[{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 p(e){try{localStorage.setItem(u,JSON.stringify(e))}catch{}}function m(){try{let e=localStorage.getItem(u);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function h(e){let t=e.id??``,n=f.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 g(e){let t=await fetch(`${s}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(h).filter(e=>e.id.length>0);n.length>0&&(d=n,p(n))}function _(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:l,provider:o,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 v(e){console.error(`[cerebras] Stream error:`,e instanceof Error?e.message:String(e))}const y=(e,n,r={})=>{let i=t();return b(i,e,n,r).catch(v),i};async function b(e,t,n,i){try{let o={...t,baseUrl:s,api:c},l=r(o,a(n),i);for await(let t of l)e.push(t);e.end()}catch(n){v(n),e.push(_(t,n)),e.end()}}const x=(e,n,r)=>{let i=t();return S(i,e,n,r).catch(v),i};async function S(e,t,n,r){try{let o={...t,baseUrl:s,api:c},l=i(o,a(n),r);for await(let t of l)e.push(t);e.end()}catch(n){v(n),e.push(_(t,n)),e.end()}}const C={id:o,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(d.length>0)return d;let e=m();return e.length>0?e:f},refreshModels:async t=>{let n=t??e(o)??``;if(n)try{await g(n)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function w(){n({api:l,stream:y,streamSimple:x})}export{C as config,w as register};
@@ -1 +1 @@
1
- import{a as e}from"./diagnostics-Cag7MsZI.js";import{a as t}from"./compat-DpI6NrfX.js";import{r as n,s as r}from"./legacy-api-aliases-C3FCSzcU.js";import{_ as i}from"./account-store-BFb2UO2K.js";import{n as a}from"./pi-transcript-context-miZCMig3.js";var o=`cerebras`,s=`https://api.cerebras.ai/v1`,c=`openai-completions`,l=`${o}-openai`,u=`slicc-cerebras-models`,d=[],f=[{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 p(e){try{localStorage.setItem(u,JSON.stringify(e))}catch{}}function m(){try{let e=localStorage.getItem(u);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function h(e){let t=e.id??``,n=f.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 g(e){let t=await fetch(`${s}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(h).filter(e=>e.id.length>0);n.length>0&&(d=n,p(n))}function _(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:l,provider:o,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 v(e){console.error(`[cerebras] Stream error:`,e instanceof Error?e.message:String(e))}var y=(t,n,r={})=>{let i=e();return b(i,t,n,r).catch(v),i};async function b(e,t,r,i){try{let o={...t,baseUrl:s,api:c},l=n(o,a(r),i);for await(let t of l)e.push(t);e.end()}catch(n){v(n),e.push(_(t,n)),e.end()}}var x=(t,n,r)=>{let i=e();return S(i,t,n,r).catch(v),i};async function S(e,t,n,i){try{let o={...t,baseUrl:s,api:c},l=r(o,a(n),i);for await(let t of l)e.push(t);e.end()}catch(n){v(n),e.push(_(t,n)),e.end()}}var C={id:o,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(d.length>0)return d;let e=m();return e.length>0?e:f},refreshModels:async e=>{let t=e??i(o)??``;if(t)try{await g(t)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function w(){t({api:l,stream:y,streamSimple:x})}export{C as config,w as register};
1
+ import{a as e}from"./diagnostics-Cag7MsZI.js";import{a as t}from"./compat-DpI6NrfX.js";import{r as n,s as r}from"./legacy-api-aliases-C3FCSzcU.js";import{_ as i}from"./account-store-BkmYrtWh.js";import{n as a}from"./pi-transcript-context-miZCMig3.js";var o=`cerebras`,s=`https://api.cerebras.ai/v1`,c=`openai-completions`,l=`${o}-openai`,u=`slicc-cerebras-models`,d=[],f=[{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 p(e){try{localStorage.setItem(u,JSON.stringify(e))}catch{}}function m(){try{let e=localStorage.getItem(u);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function h(e){let t=e.id??``,n=f.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 g(e){let t=await fetch(`${s}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(h).filter(e=>e.id.length>0);n.length>0&&(d=n,p(n))}function _(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:l,provider:o,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 v(e){console.error(`[cerebras] Stream error:`,e instanceof Error?e.message:String(e))}var y=(t,n,r={})=>{let i=e();return b(i,t,n,r).catch(v),i};async function b(e,t,r,i){try{let o={...t,baseUrl:s,api:c},l=n(o,a(r),i);for await(let t of l)e.push(t);e.end()}catch(n){v(n),e.push(_(t,n)),e.end()}}var x=(t,n,r)=>{let i=e();return S(i,t,n,r).catch(v),i};async function S(e,t,n,i){try{let o={...t,baseUrl:s,api:c},l=r(o,a(n),i);for await(let t of l)e.push(t);e.end()}catch(n){v(n),e.push(_(t,n)),e.end()}}var C={id:o,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(d.length>0)return d;let e=m();return e.length>0?e:f},refreshModels:async e=>{let t=e??i(o)??``;if(t)try{await g(t)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function w(){t({api:l,stream:y,streamSimple:x})}export{C as config,w as register};
@@ -0,0 +1,4 @@
1
+ import{t as e}from"./logger-LESFN7Hj.js";const t=e(`mcp-client`),n=[`2026-07-28`,`2025-06-18`],r=n[0],i=n[1];var a=class extends Error{status;resourceMetadataUrl;wwwAuthenticate;constructor(e){super(`MCP server requires authentication (HTTP ${e.status})`),this.name=`McpAuthRequiredError`,this.status=e.status,this.resourceMetadataUrl=e.resourceMetadataUrl,this.wwwAuthenticate=e.wwwAuthenticate}},o=class extends Error{rpcError;constructor(e){super(`MCP RPC error ${e.code}: ${e.message}`),this.name=`McpRpcFailure`,this.rpcError=e}},s=class extends Error{method;timeoutMs;constructor(e){super(`MCP request timed out after ${e.timeoutMs}ms (${e.method})`),this.name=`McpTimeoutError`,this.method=e.method,this.timeoutMs=e.timeoutMs}},c=class extends Error{status;rpcError;constructor(e){super(`MCP HTTP ${e.status} ${e.statusText} for ${e.method}: ${e.snippet||`(empty body)`}`),this.name=`McpHttpError`,this.status=e.status,this.rpcError=e.rpcError}};function l(e){if(!e)return;let t=/resource_metadata="([^"]+)"/i.exec(e);return t?t[1]:/resource_metadata=([^,\s]+)/i.exec(e)?.[1]}function u(e,t){let n=new TextDecoder(`utf-8`).decode(e).replace(/\r\n/g,`
2
+ `).split(/\n\n/);for(let e of n){if(!e.trim())continue;let n=[];for(let t of e.split(`
3
+ `))t.startsWith(`data:`)&&n.push(t.slice(5).trimStart());if(n.length===0)continue;let r=n.join(`
4
+ `),i;try{i=JSON.parse(r)}catch{continue}if(i.id!==void 0&&i.id!==null&&i.id===t)return i}throw Error(`MCP SSE stream ended without a response for request id ${String(t)}`)}function d(e,t){let n=t.toLowerCase();for(let[t,r]of Object.entries(e))if(t.toLowerCase()===n)return r}function f(e){if(e instanceof c||e instanceof o)return e.rpcError}function p(e){return new o(e)}function m(e,t,n){let r=e.id===t||n?.allowNullId===!0&&e.id===null;if(e.jsonrpc!==`2.0`||!r||Object.hasOwn(e,`result`))return;let i=e.error;return i&&typeof i.code==`number`&&typeof i.message==`string`?i:void 0}function h(e,t){try{return m(JSON.parse(e),t,{allowNullId:!0})}catch{return}}function g(e,t){if(e instanceof s)return!0;if(!t)return!1;let n=e instanceof c?e.status:void 0;return t.code===-32601?n===400||e instanceof o:t.code===-32e3&&n===400&&t.message.toLowerCase().includes(`mcp-session-id`)}function _(e){if(!e.data||typeof e.data!=`object`)return[];let t=e.data.supported;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function v(e){return async(t,n)=>{let r=await e(t,{method:n?.method,headers:n?.headers,body:n?.body,signal:n?.signal});return{status:r.status,statusText:r.statusText,headers:r.headers,body:r.body}}}async function y(){let{createProxiedFetch:e}=await import(`./proxied-fetch-CoZ8jHud.js`).then(e=>e.o);return v(e())}var b=class{url;staticHeaders;timeoutMs;getAuthHeader;preferredProtocolVersion;clientInfo;fetchImpl;fetchImplLoader=null;sessionId;negotiatedProtocolVersion;nextId=1;constructor(e){this.url=e.url,this.staticHeaders=e.headers??{},this.timeoutMs=e.timeoutMs??6e4,this.getAuthHeader=e.getAuthHeader,this.preferredProtocolVersion=e.protocolVersion??r,this.clientInfo=e.clientInfo??{name:`SLICC`,version:`0.0.0`},this.fetchImpl=e.fetchImpl??null,this.sessionId=e.sessionId}getSessionId(){return this.sessionId}getNegotiatedProtocolVersion(){return this.negotiatedProtocolVersion}async initialize(){if(this.preferredProtocolVersion===i)return this.initializeLegacy();try{return await this.discoverModern(this.preferredProtocolVersion)}catch(e){let r=f(e);if(r?.code===-32022){let e=_(r),t=n.find(t=>t!==i&&e.includes(t));if(!t)throw Error(`MCP server does not support a compatible modern protocol version (supported: ${e.join(`, `)||`none`})`);return this.discoverModern(t)}if(g(e,r))return t.debug(`server/discover identified a legacy server; using initialize`,{error:e instanceof Error?e.message:String(e)}),this.initializeLegacy();throw e}}async discoverModern(e){let t=await this.request(`server/discover`,{protocolVersion:e}),r=Array.isArray(t?.supportedVersions)?t.supportedVersions.filter(e=>typeof e==`string`):[],a=n.find(e=>e!==i&&r.includes(e));if(!a)throw Error(`MCP server discovery did not advertise a compatible modern protocol version (advertised: ${r.join(`, `)||`none`})`);return this.negotiatedProtocolVersion=a,this.sessionId=void 0,t}async toolsList(){return(await this.request(`tools/list`,{}))?.tools??[]}async toolsCall(e,t){return this.request(`tools/call`,{name:e,arguments:t})}async appsList(){try{return(await this.request(`apps/list`,{}))?.apps??[]}catch(e){if(e instanceof a)throw e;return t.debug(`apps/list not supported by server`,{error:e instanceof Error?e.message:String(e)}),[]}}async request(e,t){let n=this.nextId++,r=await this.resolveFetchImpl(),o={"Content-Type":`application/json`,Accept:`application/json, text/event-stream`,...this.staticHeaders};if(this.negotiatedProtocolVersion===i&&this.sessionId&&e!==`initialize`&&(o[`Mcp-Session-Id`]=this.sessionId),this.getAuthHeader){let e=await this.getAuthHeader();e&&(o.Authorization=e)}let f=JSON.stringify({jsonrpc:`2.0`,id:n,method:e,params:t}),g=new AbortController,_=!1,v,y=new Promise((t,n)=>{v=setTimeout(()=>{_=!0,n(new s({method:e,timeoutMs:this.timeoutMs})),g.abort()},this.timeoutMs)}),b,x=r(this.url,{method:`POST`,headers:o,body:f,signal:g.signal});try{b=await Promise.race([x,y])}catch(t){throw _?(x.catch(()=>void 0),new s({method:e,timeoutMs:this.timeoutMs})):t}finally{v&&clearTimeout(v)}if(b.status===401){let e=d(b.headers,`www-authenticate`);throw new a({status:401,wwwAuthenticate:e,resourceMetadataUrl:l(e)})}if(this.negotiatedProtocolVersion===i){let e=d(b.headers,`mcp-session-id`);e&&(this.sessionId=e)}if(b.status>=400){let t=new TextDecoder(`utf-8`).decode(b.body);throw new c({status:b.status,statusText:b.statusText,method:e,snippet:t.slice(0,512),rpcError:h(t,n)})}let S=(d(b.headers,`content-type`)??``).toLowerCase().includes(`text/event-stream`)?u(b.body,n):JSON.parse(new TextDecoder(`utf-8`).decode(b.body));if(S.error){let e=m(S,n);throw e?p(e):Error(`MCP invalid JSON-RPC error response for request id ${String(n)}`)}return S.result}async resolveFetchImpl(){return this.fetchImpl?this.fetchImpl:(this.fetchImplLoader||=y().then(e=>(this.fetchImpl=e,e)),this.fetchImplLoader)}async initializeLegacy(){return this.negotiatedProtocolVersion=i,this.request(`initialize`,{protocolVersion:i,capabilities:{},clientInfo:this.clientInfo})}};export{a as McpAuthRequiredError,b as McpClient,s as McpTimeoutError,v as wrapProxiedFetchAsMcpFetch};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import{mcpAgentToolName as t,resolveToolExposure as n}from"./connection-manager-SNYTz_SX.js";const r=e(`mcp-codemode`);let i=null;async function a(){if(i)return i;let{CodemodeSandbox:e,loadQuickJSWasm:t}=await import(`./dist-Cu98pw2t.js`);o();let n=new URL(`../kernel/codemode-worker.ts`,``+import.meta.url);return i=new e({timeoutMs:3e5,memoryLimitBytes:268435456,wasm:t(),workerUrl:n}),i}function o(){typeof SharedArrayBuffer!=`function`&&(globalThis.SharedArrayBuffer=ArrayBuffer)}function s(e){let{serverName:i,tools:o,connection:s,exposure:l,toolExposure:u}=e,d=o.filter(e=>{let t=n(e.name,l,u);return t===`codemode`||t===`codemode-deferred`});if(d.length===0)return null;let f=`Run JavaScript to orchestrate MCP tool calls from server "${i}".
1
+ import{t as e}from"./logger-LESFN7Hj.js";import{mcpAgentToolName as t,resolveToolExposure as n}from"./connection-manager-DiSK2DFK.js";const r=e(`mcp-codemode`);let i=null;async function a(){if(i)return i;let{CodemodeSandbox:e,loadQuickJSWasm:t}=await import(`./dist-Cu98pw2t.js`);o();let n=new URL(`../kernel/codemode-worker.ts`,``+import.meta.url);return i=new e({timeoutMs:3e5,memoryLimitBytes:268435456,wasm:t(),workerUrl:n}),i}function o(){typeof SharedArrayBuffer!=`function`&&(globalThis.SharedArrayBuffer=ArrayBuffer)}function s(e){let{serverName:i,tools:o,connection:s,exposure:l,toolExposure:u}=e,d=o.filter(e=>{let t=n(e.name,l,u);return t===`codemode`||t===`codemode-deferred`});if(d.length===0)return null;let f=`Run JavaScript to orchestrate MCP tool calls from server "${i}".
2
2
  Scripts run in a QuickJS sandbox with access to the following tools via \`tools.<name>(args)\`:
3
3
  ${d.map(e=>`- \`${e.name}\`: ${e.description??`(no description)`}`).join(`
4
4
  `)}
@@ -1 +1 @@
1
- import{t as e}from"./logger-DDBAeTLF.js";import{st as t}from"./wc-shell-ublv7ZL8.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-BWgCzqFy.js";import{i as o,t as s}from"./whisper-session-Myw3zk-W.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-DMHh-A41.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-CeRpgv4u.js";import{i as o,t as s}from"./whisper-session-D--IlXLT.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-BFb2UO2K.js";import{a as i}from"./main-DFwN1I9-.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-BkmYrtWh.js";import{a as i}from"./main-CYO-QAwq.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;
@@ -0,0 +1 @@
1
+ import{t as e}from"./logger-LESFN7Hj.js";const t=e(`mcp-connection-manager`);var n=class{connections=new Map;toolsChangedListeners=new Set;options;constructor(e={}){this.options=e}onToolsChanged(e){return this.toolsChangedListeners.add(e),()=>this.toolsChangedListeners.delete(e)}emitToolsChanged(e){for(let n of this.toolsChangedListeners)try{n(e)}catch(n){t.warn(`tools-changed listener threw`,{serverName:e,error:n instanceof Error?n.message:String(n)})}}get(e){return this.connections.get(e)}has(e){return this.connections.has(e)}async connect(e,t){let n=this.connections.get(e);if(n)return{connection:n,transport:t.transport??`slicc`};let r=t.transport??await this.probeTransport(e,t),i;return i=r===`pi`?await this.createPiConnection(e,t):await this.createSliccConnection(e,t),this.connections.set(e,i),{connection:i,transport:r}}async disconnect(e){let n=this.connections.get(e);if(n){this.connections.delete(e);try{await n.close()}catch(n){t.warn(`disconnect failed`,{serverName:e,error:n instanceof Error?n.message:String(n)})}this.emitToolsChanged(e)}}async reconnect(e,t){await this.disconnect(e);let{connection:n}=await this.connect(e,t);return this.emitToolsChanged(e),n}notifyToolsChanged(e){this.emitToolsChanged(e)}async disconnectAll(){let e=[...this.connections.keys()];await Promise.all(e.map(e=>this.disconnect(e)))}async probeTransport(e,n){let r=this.options.getMcpFetchLike?await this.options.getMcpFetchLike():await i(),{McpClient:a}=await import(`./client-DWx5wn8j.js`),o=new a({url:n.url,fetchImpl:r,headers:n.headers,getAuthHeader:n.auth?()=>this.options.getAuthHeader?this.options.getAuthHeader(e):Promise.resolve(null):void 0});try{await o.initialize();let n=o.getNegotiatedProtocolVersion();return n===`2026-07-28`?(t.debug(`transport probe: slicc modern protocol`,{serverName:e,version:n}),`slicc`):(t.debug(`transport probe: legacy protocol, using pi-mcp for GET stream + notifications`,{serverName:e,version:n}),`pi`)}catch(n){return t.debug(`transport probe: slicc error, defaulting to pi-mcp`,{serverName:e,error:n instanceof Error?n.message:String(n)}),`pi`}}async createPiConnection(e,t){let{McpClient:n,StreamableHttpTransport:r}=await import(`./dist-Qk32KIeB.js`),i=await this.createMcpFetch(e,t),a=new r({url:t.url,headers:t.headers,fetch:i,...t.auth?{authProvider:{token:async()=>{let t=this.options.getAuthHeader?await this.options.getAuthHeader(e):null;return t?.startsWith(`Bearer `)?t.slice(7):void 0}}}:{}}),o=new n({name:`SLICC`,version:`0.0.0`});await o.connect(a);let s=o.onNotification(`notifications/tools/list_changed`,()=>{this.emitToolsChanged(e)});return{serverName:e,serverUrl:t.url,async listTools(){return o.listTools()},async callTool(e,t,n){return await o.callTool(e,t,{signal:n?.signal})},async close(){s(),await o.close()}}}async createSliccConnection(e,t){let{McpClient:n}=await import(`./client-DWx5wn8j.js`),a=this.options.getMcpFetchLike?await this.options.getMcpFetchLike():await i(),o=new n({url:t.url,fetchImpl:a,headers:t.headers,getAuthHeader:t.auth?()=>this.options.getAuthHeader?this.options.getAuthHeader(e):Promise.resolve(null):void 0});return await o.initialize(),{serverName:e,serverUrl:t.url,async listTools(){return o.toolsList()},async callTool(e,t,n){if(n?.signal?.aborted)throw new DOMException(`Aborted`,`AbortError`);let i=o.toolsCall(e,t),a=n?.signal;return r(a?await Promise.race([i,new Promise((e,t)=>{if(a.aborted){t(new DOMException(`Aborted`,`AbortError`));return}a.addEventListener(`abort`,()=>t(new DOMException(`Aborted`,`AbortError`)),{once:!0})})]):await i)},async listApps(){return o.appsList()},async close(){}}}async createMcpFetch(e,t){let n=this.options.getMcpFetchLike?await this.options.getMcpFetchLike():await i();return async(e,t)=>{let r=typeof e==`string`?e:e.toString(),i={};if(t?.headers){if(t.headers instanceof Headers)t.headers.forEach((e,t)=>{i[t]=e});else if(Array.isArray(t.headers))for(let[e,n]of t.headers)i[e]=n;else Object.assign(i,t.headers)}let a=await n(r,{method:t?.method,headers:i,body:typeof t?.body==`string`?t.body:void 0,signal:t?.signal??void 0});return new Response(new Uint8Array(a.body).buffer,{status:a.status,statusText:a.statusText,headers:new Headers(a.headers)})}}};function r(e){if(!e||typeof e!=`object`)return{content:[{type:`text`,text:String(e??``)}]};let t=e;return{content:Array.isArray(t.content)?t.content:[],structuredContent:t.structuredContent,isError:typeof t.isError==`boolean`?t.isError:void 0}}async function i(){let{createProxiedFetch:e}=await import(`./proxied-fetch-CoZ8jHud.js`).then(e=>e.o),{wrapProxiedFetchAsMcpFetch:t}=await import(`./client-DWx5wn8j.js`);return t(e())}function a(e,t,n){if(n){let t,r=Object.entries(n);for(let n=0;n<r.length;n++){let[i,a]=r[n],s=o(i,e);s<0||(!t||s>t.specificity||s===t.specificity&&n>t.index)&&(t={specificity:s,index:n,mode:a})}if(t)return t.mode}return t??`codemode`}function o(e,t){return e===t?2:e===`*`?0:e.endsWith(`*`)&&t.startsWith(e.slice(0,-1))?1:-1}const s=/[^A-Za-z0-9_-]/g;function c(e,t){let n=`mcp__${e}__${t}`.replace(s,`_`);return n.length<=64?n:n.slice(0,64)}export{n as McpConnectionManager,c as mcpAgentToolName,a as resolveToolExposure};
@@ -0,0 +1,36 @@
1
+ import{t as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./logger-LESFN7Hj.js";import{r as n,t as r}from"./base64-BPBW1Gzr.js";import"./proxied-fetch-CoZ8jHud.js";import{i}from"./feature-flags-QlgHaQc1.js";import{s as a,t as o}from"./api-endpoint-D8lUKmPu.js";import{$ as s,G as c,S as l,U as u,y as d}from"./build-Dnkjpm_v.js";import{i as f,n as p,r as m}from"./compat-CGK4SwF8.js";import"./context-CrZ58_Xy.js";import"./libesm-CTQYxJIv.js";import"./context-compaction-BwnPiNO2.js";import{n as h}from"./float-topology-DIH6ujZe.js";import{t as g}from"./secrets-bridge-client-EgBSROu5.js";import{r as _,t as v}from"./image-markers-CwM1dvoI.js";import{o as y,s as b}from"./tool-ui-DRnUkp2g.js";const x={"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`}},S={"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`}};({...x}),{...S},{...x},{...S},{...x},{...S};function ee(e,t){if(e.length===0)throw TypeError(`Value namespace must not be empty`);if(e.includes(`\0`))throw TypeError(`Value namespace must not contain \\u0000`);if(t.includes(`\0`))throw TypeError(`Value key must not contain \\u0000`)}function te(e,t=``){return ee(e,t),Object.freeze({namespace:e,key:t,kind:`value`})}te(`pi.session.name`);const ne=Symbol.for(`yaml.alias`),re=Symbol.for(`yaml.document`),C=Symbol.for(`yaml.map`),ie=Symbol.for(`yaml.pair`),w=Symbol.for(`yaml.scalar`),T=Symbol.for(`yaml.seq`),E=Symbol.for(`yaml.node.type`),D=e=>!!e&&typeof e==`object`&&e[E]===ne,O=e=>!!e&&typeof e==`object`&&e[E]===re,ae=e=>!!e&&typeof e==`object`&&e[E]===C,k=e=>!!e&&typeof e==`object`&&e[E]===ie,A=e=>!!e&&typeof e==`object`&&e[E]===w,j=e=>!!e&&typeof e==`object`&&e[E]===T;function M(e){if(e&&typeof e==`object`)switch(e[E]){case C:case T:return!0}return!1}function N(e){if(e&&typeof e==`object`)switch(e[E]){case ne:case C:case w:case T:return!0}return!1}const oe=e=>(A(e)||M(e))&&!!e.anchor,P=Symbol(`break visit`),se=Symbol(`skip children`),F=Symbol(`remove node`);function I(e,t){let n=ce(t);O(e)?L(null,e.contents,n,Object.freeze([e]))===F&&(e.contents=null):L(null,e,n,Object.freeze([]))}I.BREAK=P,I.SKIP=se,I.REMOVE=F;function L(e,t,n,r){let i=le(e,t,n,r);if(N(i)||k(i))return ue(e,r,i),L(e,i,n,r);if(typeof i!=`symbol`){if(M(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=L(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===P)return P;else i===F&&(t.items.splice(e,1),--e)}}else if(k(t)){r=Object.freeze(r.concat(t));let e=L(`key`,t.key,n,r);if(e===P)return P;e===F&&(t.key=null);let i=L(`value`,t.value,n,r);if(i===P)return P;i===F&&(t.value=null)}}return i}function ce(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function le(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(ae(t))return n.Map?.(e,t,r);if(j(t))return n.Seq?.(e,t,r);if(k(t))return n.Pair?.(e,t,r);if(A(t))return n.Scalar?.(e,t,r);if(D(t))return n.Alias?.(e,t,r)}function ue(e,t,n){let r=t[t.length-1];if(M(r))r.items[e]=n;else if(k(r))e===`key`?r.key=n:r.value=n;else if(O(r))r.contents=n;else{let e=D(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}function de(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function R(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=R(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=R(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=R(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=R(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function z(e,t,n){if(Array.isArray(e))return e.map((e,t)=>z(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!oe(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var fe=class{constructor(e){Object.defineProperty(this,E,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!O(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=z(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?R(i,{"":o},``,o):o}},pe=class extends fe{constructor(e){super(ne),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],I(e,{Node:(e,t)=>{(D(t)||oe(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}return r}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,a=this.resolve(r,t);if(!a){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let o=n.get(a);if(o||=(z(a,null,t),n.get(a)),o?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=me(r,a,n)),o.count*o.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return o.res}toString(e,t,n){let r=`*${this.source}`;if(e){if(de(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function me(e,t,n){if(D(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(M(t)){let r=0;for(let i of t.items){let t=me(e,i,n);t>r&&(r=t)}return r}if(k(t)){let r=me(e,t.key,n),i=me(e,t.value,n);return Math.max(r,i)}return 1}const he=e=>!e||typeof e!=`function`&&typeof e!=`object`;var B=class extends fe{constructor(e){super(w),this.value=e}toJSON(e,t){return t?.keep?this.value:z(this.value,e,t)}toString(){return String(this.value)}};B.BLOCK_FOLDED=`BLOCK_FOLDED`,B.BLOCK_LITERAL=`BLOCK_LITERAL`,B.PLAIN=`PLAIN`,B.QUOTE_DOUBLE=`QUOTE_DOUBLE`,B.QUOTE_SINGLE=`QUOTE_SINGLE`;function ge(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function _e(e,t,n){if(O(e)&&(e=e.contents),N(e))return e;if(k(e)){let t=n.schema[C].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??(c.anchor=i(e)),new pe(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=`tag:yaml.org,2002:`+t.slice(2));let l=ge(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new B(e);return c&&(c.node=t),t}l=e instanceof Map?o[C]:Symbol.iterator in Object(e)?o[T]:o[C]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new B(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function ve(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return _e(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}const ye=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;var be=class extends fe{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>N(t)||k(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(ye(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(M(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,ve(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(M(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&A(i)?i.value:i:M(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!k(t))return!1;let n=t.value;return n==null||e&&A(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return M(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if(M(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,ve(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}};const xe=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function V(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}const H=(e,t,n)=>e.endsWith(`
2
+ `)?V(n,t):n.includes(`
3
+ `)?`
4
+ `+V(n,t):(e.endsWith(` `)?``:` `)+n,Se=`flow`;function Ce(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=we(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
5
+ `)n===`block`&&(h=we(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
6
+ `&&p!==` `){let t=e[h+1];t&&t!==` `&&t!==`
7
+ `&&t!==` `&&(f=h)}if(h>=d){if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function we(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
8
+ `);r=t,i=t+1,a=e[i]}return r}const Te=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Ee=e=>/^(%|---|\.\.\.)/m.test(e);function De(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
9
+ `){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function U(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(Ee(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
10
+
11
+ `;n[e+2]===`\\`&&n[e+3]===`n`&&n[e+4]!==`"`;)o+=`
12
+ `,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:Ce(o,a,`quoted`,Te(t,!1))}function Oe(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
13
+ `)||/[ \t]\n|\n[ \t]/.test(e))return U(e,t);let n=t.indent||(Ee(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:Ce(r,n,Se,Te(t,!1))}function W(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=U;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?Oe:i&&!t?U:n?Oe:U}return r(e,t)}let ke;try{ke=RegExp(`(^|(?<!
14
+ ))
15
+ +(?!
16
+ |$)`,`g`)}catch{ke=/\n+(?!\n|$)/g}function Ae({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return W(n,r);let l=r.indent||(r.forceBlockIndent||Ee(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===B.BLOCK_FOLDED?!1:t===B.BLOCK_LITERAL||!De(n,c,l.length);if(!n)return u?`|
17
+ `:`>
18
+ `;let d,f;for(f=n.length;f>0;--f){let e=n[f-1];if(e!==`
19
+ `&&e!==` `&&e!==` `)break}let p=n.substring(f),m=p.indexOf(`
20
+ `);m===-1?d=`-`:n===p||m!==p.length-1?(d=`+`,a&&a()):d=``,p&&=(n=n.slice(0,-p.length),p[p.length-1]===`
21
+ `&&(p=p.slice(0,-1)),p.replace(ke,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
22
+ `)_=g;else break}let v=n.substring(0,_<g?_+1:g);v&&=(n=n.substring(v.length),v.replace(/\n+/g,`$&${l}`));let y=(h?l?`2`:`1`:``)+d;if(e&&(y+=` `+s(e.replace(/ ?[\r\n]+/g,` `)),i&&i()),!u){let e=n.replace(/\n+/g,`
23
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=Te(r,!0);o!==`folded`&&t!==B.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=Ce(`${v}${e}${p}`,l,`block`,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function je(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
24
+ `)||u&&/[[\]{},]/.test(a))return W(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
25
+ `)?W(a,t):Ae(e,t,n,r);if(!s&&!u&&i!==B.PLAIN&&a.includes(`
26
+ `))return Ae(e,t,n,r);if(Ee(a)){if(c===``)return t.forceBlockIndent=!0,Ae(e,t,n,r);if(s&&c===l)return W(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return W(a,t)}return s?d:Ce(d,c,Se,Te(t,!1))}function Me(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==B.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=B.QUOTE_DOUBLE);let c=e=>{switch(e){case B.BLOCK_FOLDED:case B.BLOCK_LITERAL:return i||a?W(o.value,t):Ae(o,t,n,r);case B.QUOTE_DOUBLE:return U(o.value,t);case B.QUOTE_SINGLE:return Oe(o.value,t);case B.PLAIN:return je(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function Ne(e,t){let n=Object.assign({blockQuote:!0,commentString:xe,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function Pe(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(A(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function Fe(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(A(e)||M(e))&&e.anchor;a&&de(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function Ie(e,t,n,r){if(k(e))return e.toString(t,n,r);if(D(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=N(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=Pe(t.doc.schema.tags,a);let o=Fe(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):A(a)?Me(a,t,n,r):a.toString(t,n,r);return o?A(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function Le({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=N(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(M(e)||!N(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||M(e)||(A(e)?e.type===B.BLOCK_FOLDED||e.type===B.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=Ie(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=H(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=H(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=H(g,n.indent,l(f))));let _,v,y;N(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&A(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&j(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=Ie(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?`
27
+ `:``,v){let e=l(v);S+=`\n${V(e,n.indent)}`}x===``&&!n.inFlow?S===`
28
+ `&&y&&(S=`
29
+
30
+ `):S+=`\n${n.indent}`}else if(!p&&M(t)){let e=x[0],r=x.indexOf(`
31
+ `),i=r!==-1,a=n.inFlow??t.flow??t.items.length===0;if(i||!a){let t=!1;if(i&&(e===`&`||e===`!`)){let n=x.indexOf(` `);e===`&`&&n!==-1&&n<r&&x[n+1]===`!`&&(n=x.indexOf(` `,n+1)),(n===-1||r<n)&&(t=!0)}t||(S=`\n${n.indent}`)}}else(x===``||x[0]===`
32
+ `)&&(S=``);return g+=S+x,n.inFlow?b&&r&&r():y&&!b?g+=H(g,n.indent,l(y)):h&&i&&i(),g}function Re(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}const ze={identify:e=>e===`<<`||typeof e==`symbol`&&e.description===`<<`,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new B(Symbol(`<<`)),{addToJSMap:Ve}),stringify:()=>`<<`},Be=(e,t)=>(ze.identify(t)||A(t)&&(!t.type||t.type===B.PLAIN)&&ze.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===ze.tag&&e.default);function Ve(e,t,n){let r=Ue(e,n);if(j(r))for(let n of r.items)He(e,t,n);else if(Array.isArray(r))for(let n of r)He(e,t,n);else He(e,t,r)}function He(e,t,n){let r=Ue(e,n);if(!ae(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function Ue(e,t){return e&&D(t)?t.resolve(e.doc,e):t}function We(e,t,{key:n,value:r}){if(N(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(Be(e,n))Ve(e,t,r);else{let i=z(n,``,e);if(t instanceof Map)t.set(i,z(r,i,e));else if(t instanceof Set)t.add(i);else{let a=Ge(n,i,e),o=z(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function Ge(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(N(e)&&n?.doc){let t=Ne(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),Re(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function Ke(e,t,n){return new G(_e(e,void 0,n),_e(t,void 0,n))}var G=class e{constructor(e,t=null){Object.defineProperty(this,E,{value:ie}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return N(n)&&(n=n.clone(t)),N(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return We(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?Le(this,e,t,n):JSON.stringify(this)}};function qe(e,t,n){return(t.inFlow??e.flow?Ye:Je)(e,t,n)}function Je({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(N(i))!d&&i.spaceBefore&&f.push(``),Xe(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(k(i)){let e=N(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),Xe(n,f,e.commentBefore,d))}d=!1;let s=Ie(i,u,()=>o=null,()=>d=!0);o&&(s+=H(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
33
+ `}}return e?(p+=`
34
+ `+V(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(k(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
+ `),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+=H(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=V(t(r),e);n.push(i.trimStart())}}function K(e,t){let n=A(t)?t.value:t;for(let r of e)if(k(r)&&(r.key===t||r.key===n||A(r.key)&&r.key.value===n))return r}var q=class extends be{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(C,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=k(e)?e:!e||typeof e!=`object`||!(`key`in e)?new G(e,e?.value):new G(e.key,e.value);let r=K(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);A(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=K(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=K(this.items,e)?.value;return(!t&&A(n)?n.value:n)??void 0}has(e){return!!K(this.items,e)}set(e,t){this.add(new G(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(!k(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:q,tag:`tag:yaml.org,2002:map`,resolve(e,t){return ae(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>q.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&&A(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];A(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(z(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=A(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 j(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 B(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=q.prototype.add.bind(this),this.delete=q.prototype.delete.bind(this),this.get=q.prototype.get.bind(this),this.has=q.prototype.has.bind(this),this.set=q.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(k(e)?(r=z(e.key,``,t),i=z(e.value,r,t)):r=z(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 q{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=k(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new G(e.key,null):new G(e,null),K(this.items,t.key)||this.items.push(t)}get(e,t){let n=K(this.items,e);return!t&&k(n)?A(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=K(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new G(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 J(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),ut(Object.freeze([]),e,t)}J.BREAK=st,J.SKIP=ct,J.REMOVE=lt,J.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},J.parentCollection=(e,t)=>{let n=J.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=/[.*+?()[\]{}^$|\\/]/,i=/^ +$/,a=/(?:[^\\]|^)\\$/,o=/^\\!/,s=/^\\#/,c=/\r?\n/g,l=`node-ignore`;typeof Symbol<`u`&&(l=Symbol.for(`node-ignore`));let u=l,d=(e,t,n)=>(Object.defineProperty(e,t,{value:n}),n),f=()=>!1,p=e=>{let{length:t}=e;return e.slice(0,t-t%2)},m={alnum:`0-9A-Za-z`,alpha:`A-Za-z`,blank:` \\t`,cntrl:`\\x00-\\x1f\\x7f`,digit:`0-9`,graph:`!-.0-~`,lower:`a-z`,print:` -.0-~`,punct:"!-.:-@\\[-`{-~",space:` \\t\\n\\r`,upper:`A-Z`,xdigit:`0-9A-Fa-f`},h=e=>`\\]^-[`.indexOf(e)<0?e:`\\`+e,g=(e,t)=>{if(e)return`[^\\/${t}]`;let n=`[${t}]`;return new RegExp(n).test(`/`)?`(?!\\/)`+n:n},_=(e,t)=>{let{length:n}=e,r=t+1,i=``,a=e[r];(a===`!`||a===`^`)&&(i=`^`,r++);let o=``,s=``;for(;;){let t=e[r];if(t===void 0)return null;if(t===`\\`){let t=e[r+1];if(t===void 0)return null;o+=h(t),s=t,r++}else if(t===`-`&&s&&r+1<n&&e[r+1]!==`]`){r++;let t=e[r];t===`\\`&&(t=e[r+=1]),s<=t&&(o+=`-${h(t)}`),s=``}else if(t===`[`&&e[r+1]===`:`){let t=r+2,i=t;for(;i<n&&e[i]!==`]`;)i++;if(i===n)return null;if(i>t&&e[i-1]===`:`){let n=m[e.slice(t,i-1)];if(n===void 0)return null;o+=n,s=``,r=i}else o+=h(`[`),s=`[`,r=t-2}else o+=h(t),s=t;if(r++,e[r]===`]`)return{end:r,source:g(i,o)}}},v=RegExp(`\0(\\d+)\0`,`g`),y=e=>{let t=[],n=e=>`${t.push(e)-1}`,{length:i}=e,a=``,o=0;for(;o<i;){let t=e[o];if(t===`\\`){let t=e[o+1];a+=t===`*`||t===`[`||t===` `||t===`\\`?e.slice(o,o+2):n(r.test(t)?`\\`+t:t),o+=2}else if(t===`\0`)a+=n(`[\0]`),o++;else if(t===`[`){let t=_(e,o);t===null?(a+=n(`[]`),o=i):(a+=n(t.source),o=t.end+1)}else a+=t,o++}return{source:a,sources:t}},b=/\/(?!$)/,x=[[/^\uFEFF/,()=>``,``],[/[\r\n]+$/,()=>``],[/((?:\\\\)*?)(\\? +)$/,(e,t,n)=>t+(n.indexOf(`\\`)===0?` `:``)],[/(\\+?) /g,(e,t)=>{let{length:n}=t;return t.slice(0,n-n%2)+` `}],[/[\\$.|*+(){^]/g,e=>`\\${e}`],[/(?!\\)\?/g,()=>`[^/]`,`?`],[/^\//,()=>`^`,`/`],[/\//g,()=>`\\/`,`/`],[/^\^*(?:\\\*\\\*\\\/)+/,()=>`^(?:.*\\/)?`,`*`],[null,(e,t)=>!e||e[0]===`^`?e:(b.test(t)?`^`:`(?:^|\\/)`)+e],[/\\\/\\\*\\\*(?=\\\/|$)/g,(e,t,n)=>t+6<n.length?n.slice(t+6)===`\\/`?`(?:\\/[^\\/]+)+`:`(?:\\/[^\\/]+)*`:`\\/.+`,`*`],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(e,t,n)=>t+n.replace(/\\\*/g,`[^\\/]*`),`*`],[/(^|[^\\])((?:\\\\)*)\\\*$/,(e,t,n)=>n.length/2%2==0?t+n+``:e,`*`],[/\\\\\\(?=[$.|*+(){^])/g,()=>`\\`,`\\\\`],[/\\\\/g,()=>`\\`,`\\\\`],[/\\\[([^\]/]*?)(\\*)($|\])/g,(e,t,n,r)=>`\\[${t}${p(n)}${r}`,`[`],[null,e=>{let t=e[e.length-1];return!t||t===``?e:t===`/`?`${e}$`:`${e}(?=$|\\/$)`}]],S=/(^|\\\/)?\uE000$/,ee=`regex`,te=`checkRegex`,ne={[ee](e,t){return`${t?`${t}[^/]+`:`[^/]*`}(?=$|\\/$)`},[te](e,t){return`${t?`${t}[^/]*`:`[^/]*`}(?=$|\\/$)`}},re=`[^\\/]*`,C=e=>{if(e.indexOf(re)<0)return e;let t=[],{length:n}=e,r=0;for(;r<n;){let i=e[r];if(e.startsWith(re,r))t.push({wildcard:!0}),r+=6;else if(i===`[`){let i=r+1;for(e[i]===`^`&&i++,e[i]===`]`&&i++;i<n&&e[i]!==`]`;)i+=e[i]===`\\`?2:1;i++,t.push({single:e.slice(r,i)}),r=i}else if(i===`\\`)t.push({single:e.slice(r,r+2)}),r+=2;else if(i===`(`){let i=0,a=r;do e[a]===`\\`?a++:e[a]===`(`?i++:e[a]===`)`&&i--,a++;while(a<n&&i>0);`*+?`.indexOf(e[a])>=0&&a++,t.push({boundary:e.slice(r,a)}),r=a}else i===`^`||i===`$`?(t.push({boundary:i}),r++):(t.push({single:i}),r++)}let i=``,a=[],o=()=>{let e;a.forEach((t,n)=>{t.wildcard&&(e=n)}),a.forEach((t,n)=>{if(!t.wildcard){i+=t.single;return}i+=n===e?re:`(?:(?!${a[n+1].single})[^\\/])*`}),a=[]};return t.forEach(e=>{if(e.boundary===void 0){a.push(e);return}o(),i+=e.boundary}),o(),i},ie=e=>{let{source:t,sources:n}=y(e),r=x.reduce((t,[n,r,i])=>n===null?r(t,e):i!==void 0&&t.indexOf(i)<0?t:n.test(t)?t.replace(n,r.bind(e)):t,t);return n.length?r.replace(v,(e,t)=>n[t]):r},w=e=>{let t=e.indexOf(`/`);return t<0||t===e.length-1},T=e=>{let t=e.length-1,n=e.lastIndexOf(`/`,e[t]===`/`?t-1:t);return n<0?e:e.slice(n+1)},E=e=>{if(e.charCodeAt(0)===47||e.indexOf(`//`)>=0){let t=e.split(`/`).filter(Boolean);return t.pop(),t.length?t.join(`/`)+`/`:``}let t=e.length-1,n=e.lastIndexOf(`/`,e.charCodeAt(t)===47?t-1:t);return n<0?``:e.slice(0,n+1)},D=e=>typeof e==`string`,O=e=>e&&D(e)&&!i.test(e)&&!a.test(e)&&e.indexOf(`#`)!==0,ae=e=>e.split(c).filter(Boolean);var k=class{constructor(e,t,n,r,i,a){this.pattern=e,this.mark=t,this.negative=i,d(this,`body`,n),d(this,`ignoreCase`,r),d(this,`regexPrefix`,a)}get _basenameOnly(){return d(this,`_basenameOnly`,w(this.body))}get regex(){let e=`_regex`;return this[e]?this[e]:this._make(ee,e)}get checkRegex(){let e=`_checkRegex`;return this[e]?this[e]:this._make(te,e)}_make(e,t){let n=C(this.regexPrefix.replace(S,ne[e])),r=this.ignoreCase?new RegExp(n,`i`):new RegExp(n);return d(this,t,r)}};let A=({pattern:e,mark:t},n)=>{let r=!1,i=e;i.indexOf(`!`)===0&&(r=!0,i=i.substr(1)),i=i.replace(o,`!`).replace(s,`#`);let a=ie(i);return new k(e,t,i,n,r,a)};var j=class{constructor(e){this._ignoreCase=e,this._rules=[],this._basenameCount=0}_add(e){if(e&&e[u]){this._rules=this._rules.concat(e._rules._rules),this._basenameCount+=e._rules._basenameCount,this._added=!0;return}if(D(e)&&(e={pattern:e}),O(e.pattern)){let t=A(e,this._ignoreCase);this._added=!0,this._rules.push(t),w(t.body)&&this._basenameCount++}}add(e){return this._added=!1,n(D(e)?ae(e):e).forEach(this._add,this),this._added}test(e,t,n){let r=!1,i=!1,a,o=this._rules,{length:s}=o,c=this._basenameCount*2>=s,l=c?T(e):e;for(let u=0;u<s;u++){let s=o[u],{negative:d}=s;!(i===d&&r!==i||d&&!r&&!i&&!t)&&s[n].test(c&&s._basenameOnly?l:e)&&(r=!d,i=d,a=d?void 0:s)}let u={ignored:r,unignored:i};return a&&(u.rule=a),u}};let M=(e,t)=>{throw new t(e)},N=(e,t,n)=>D(e)?e?!N.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),oe=e=>{let t=e.charCodeAt(0);if(t===47)return!0;if(t!==46)return!1;if(e.length===1)return!0;let n=e.charCodeAt(1);return n===47?!0:n===46?e.length===2||e.charCodeAt(2)===47:!1};N.isNotRelative=oe,N.convert=e=>e;var P=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){d(this,u,!0),this._rules=new j(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){let r=e&&N.convert(e);return N(r,e,this._strictPathCheck?M:f),this._t(r,t,n)}checkIgnore(e){if(e.charCodeAt(e.length-1)!==47)return this.test(e);let t=E(e);if(t){let e=this._t(t,this._testCache,!0);if(e.ignored)return e}return this._rules.test(e,!1,te)}_t(e,t,n){if(e in t)return t[e];let r=E(e),i=r?this._t(r,t,n):void 0;return t[e]=i&&i.ignored?i:this._rules.test(e,n,ee)}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 se=e=>new P(e),F=e=>N(e&&N.convert(e),e,f),I=()=>{N.convert=e=>/^\\\\\?\\/.test(e)||/["<>|\u0000-\u001F]+/u.test(e)?e:e.replace(/\\/g,`/`);let e=/^[a-z]:\//i;N.isNotRelative=t=>e.test(t)||oe(t)};typeof process<`u`&&process.platform===`win32`&&I(),t.exports=se,se.default=se,t.exports.isPathValid=F,d(t.exports,Symbol.for(`setupWindows`),I)}))(),globalThis.Buffer,new TextEncoder,new TextDecoder,u({command:d({description:`Bash command to execute`}),timeout:c(l({description:`Timeout in seconds (optional, no default timeout)`}))});const dt=u({oldText:d({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:d({description:`Replacement text for this targeted edit.`})},{});u({path:d({description:`Path to the file to edit (relative or absolute)`}),edits:s(dt,{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.`})},{}),u({path:d({description:`Path to the file to read (relative or absolute)`}),offset:c(l({description:`Line number to start reading from (1-indexed)`})),limit:c(l({description:`Maximum number of lines to read`}))}),u({path:d({description:`Path to the file to write (relative or absolute)`}),content:d({description:`Content to write to the file`})});function ft(){try{return globalThis.localStorage??null}catch{return null}}function pt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e,t){return Reflect.get(e,t)}function mt(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:pt(e)?e:{}}}catch{return{raw:t,store:{}}}}function X(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0}function ht(e){if(!pt(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 gt(e){return!Array.isArray(e)||e.length===0||!e.every(e=>e===`text`||e===`image`)?null:[...e]}function _t(e){if(e===void 0)return;if(!pt(e))return null;let t=Object.entries(e);return t.every(([,e])=>e===null||typeof e==`string`)?Object.fromEntries(t):null}function vt(e){return{apis:new Set(e.map(e=>e.api)),baseUrls:new Set(e.map(e=>e.baseUrl))}}function yt(e,t,n){if(!pt(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=ht(Y(t,`cost`)),d=gt(Y(t,`input`)),f=_t(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),pt(p)&&(m.compat={...p}),m}function bt(){return 1790705440924}let xt,St=new Map;function Ct(e){try{return m(e)}catch{return[]}}function wt(e){if(!e||!Array.isArray(e.models)||e.models.length===0)return!1;let t=bt();return t===null||typeof e.lastModified==`number`&&e.lastModified>t}const Tt=new Set([`id`,`name`,`api`,`provider`,`baseUrl`,`reasoning`,`input`,`cost`,`contextWindow`,`maxTokens`,`thinkingLevelMap`,`compat`]);function Et(e,t,n){if(t)return{...Object.fromEntries(Object.entries(t).filter(([e])=>!Tt.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 Dt(e,t){let n=Ct(e);if(n.length===0)return n;let r=vt(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=yt(e,s,r);if(!t)continue;let c=a.get(t.id),l=Et(t,o.get(t.id),n);c===void 0?(a.set(l.id,i.length),i.push(l)):i[c]=l}return i}function Ot(e,t){if(!i(`live-model-catalog`))return Ct(e);let{raw:n,store:r}=mt(t),a=r[e];if(!wt(a))return Ct(e);n!==xt&&(xt=n,St=new Map);let o=St.get(e);return o||(o=Dt(e,a),St.set(e,o)),o}function kt(e){return[...Ot(e,ft())]}function At(e,t){return Ot(e,ft()).find(e=>e.id===t)||p(e,t)}const jt=f,Z=t(`secret-scrub`),Q=`[tool output withheld: secret scrub unavailable]`,Mt=async e=>e;function Nt(){let e=h();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 g(`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`?Mt:async e=>{if(!e)return e;try{let t=await fetch(a(`/api/secrets/scrub`),{method:`POST`,headers:o({"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`),Pt=3932160;function Ft(e){let t=e.replace(/[\t\n\f\r ]/g,``),n=t.length%4;return n===2?`${t}==`:n===3?`${t}=`:t}function It(e,t){let n=r(Ft(e.slice(0,t)));return new DataView(n.buffer,n.byteOffset,n.byteLength)}function Lt(e,t){return e>0&&t>0?{width:e,height:t}:null}function Rt(e){if(e.length<32)return null;let t=It(e,32);return Lt(t.getUint32(16,!1),t.getUint32(20,!1))}function zt(e){if(e.length<16)return null;let t=It(e,16);return Lt(t.getUint16(6,!0),t.getUint16(8,!0))}function Bt(e){let t=It(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 Lt(t.getUint16(e+7,!1),t.getUint16(e+5,!1))}return null}function Vt(e,t){try{let n=Ft(e);if(t===`image/png`)return Rt(n);if(t===`image/gif`)return zt(n);if(t===`image/jpeg`)return Bt(n)}catch{}return null}async function Ht(e){if(!_(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=Vt(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-BbnwhVj1.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(Ft(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>Pt&&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>Pt&&($.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>Pt)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 Ut=t(`tool-adapter`);function Wt(e){let t=[],n=0;for(let r of v(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 Gt(e){let t=Wt(e),n=[];for(let e of t)e.type===`image`?n.push(await Ht(e)):n.push(e);return n}function Kt(e,t,n,r){if(!r)return{tracked:null,effectiveSignal:n};let i=r.processManager.spawn({kind:`tool`,argv:[e.name,...$t(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 qt(e,t){e&&e.manager.exit(e.record.pid,t)}async function Jt(e,t,n){if(!n||typeof e!=`string`||e.length===0)return e;try{return await n.scrubToolResult(e)}catch(n){return Ut.warn(`Tool-result scrub failed, falling back to unscrubbed content`,{tool:t,error:n instanceof Error?n.message:String(n)}),e}}async function Yt(e,t){try{return await Gt(e)}catch(n){return Ut.warn(`Image processing failed, falling back to raw content`,{tool:t,error:n instanceof Error?n.message:String(n)}),Wt(e)}}async function Xt(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 Ut.warn(`Tool-call gate threw — refusing the call`,{tool:e.name,error:t instanceof Error?t.message:String(t)}),!1}}function Zt(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=b({onUpdate:s,toolName:e.name,toolCallId:i})),!await Xt(e,a,r,o))return c&&y(c),{content:[{type:`text`,text:`${e.name}: not approved (guest-caused turn).`}],details:{isError:!0}};let l=Kt(e,a,o,t);try{let t=await e.execute(a??{},l.effectiveSignal),r=await Yt(await Jt(t.content,e.name,n),e.name);return qt(l.tracked,+!!t.isError),{content:r,details:{isError:t.isError}}}catch(e){throw qt(l.tracked,l.tracked?.record.abort.signal.aborted?null:1),e}finally{c&&y(c),l.tracked?.unsubscribeKill()}}}}function Qt(e,t,n,r){return e.map(e=>Zt(e,t,n,r))}function $t(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{kt as a,At as i,$t as n,jt as o,Nt as r,Qt 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-CTxRZxWy.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`},s={decision:`deny`,reason:`unavailable`};async function c(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`),s;let{approverRunnerFor:c}=await import(`./approver-agent-CivzfuZ7.js`),l=t.getSharedFs(),u=await c({spawn:e=>i.spawn(e),readSharedFile:async e=>{if(!l)return null;try{let t=await l.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:u.decision,reason:u.reason}),u.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}):s}return t.approveAsUser(e)}export{c as runDirectedApproval};
1
+ import{t as e}from"./logger-LESFN7Hj.js";import{S as t}from"./record-COQlaFL1.js";import{d as n}from"./kernel-worker-D8RoqWtJ.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`},s={decision:`deny`,reason:`unavailable`};async function c(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`),s;let{approverRunnerFor:c}=await import(`./approver-agent-CivzfuZ7.js`),l=t.getSharedFs(),u=await c({spawn:e=>i.spawn(e),readSharedFile:async e=>{if(!l)return null;try{let t=await l.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:u.decision,reason:u.reason}),u.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}):s}return t.approveAsUser(e)}export{c as runDirectedApproval};
@@ -1 +1 @@
1
- import{n as e}from"./js-realm-worker-BZ9Q6ni5.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=3735928559,n=1103547991;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);t=Math.imul(t^i,2654435761),n=Math.imul(n^i,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)||1}function o(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 s(e){if(e!=null)return e instanceof Date?e.getTime():e}function c(e,n){let a=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 a=e.createNode(t,r,o(i),0);return a.node_ops=n.node,a.stream_ops=n.stream,a.live=l(i),a}function d(e){if(e.live.orphan)return{...e.live.stat,size:e.live.len};if(!e.live.stat){let t=s(()=>a(e).lstat(i(e)));e.live.stat=t,e.mode=o(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(()=>a(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(()=>a(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),o=new Uint8Array(t);if(t>0){let n=s(()=>a(e).readFile(r));o.set(n.subarray(0,Math.min(t,n.length)))}s(()=>a(e).writeFile(r,o)),n.stat=void 0}return{Fs:e,bridgeOf:a,call:s,metadataCall:c,makeNode:u,statOf:d,childPath:f,ensureLoaded:p,ensureCapacity:m,flushNode:h,truncate:g}}function l(e){let{Fs:r,bridgeOf:o,call:c,metadataCall:l,makeNode:u,statOf:d,childPath:f,flushNode:p,truncate:m}=e,{ensureLoaded:h}=e;return{getattr(e){let t=d(e),n=e.live,o=r.isDir(e.mode)?4096:n.loaded?n.len:t.size,s=new Date(t.mtimeMs??0);return{dev:1,ino:t.ino??a(i(e)),mode:e.mode,nlink:1,uid:0,gid:0,rdev:0,size:o,atime:s,mtime:s,ctime:s,blksize:4096,blocks:Math.ceil(o/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&&m(e,t.size);return}let a=i(e);if(t.mode!==void 0&&t.mode!==null){let r=t.mode&n;r!==(e.mode&n)&&(l(()=>o(e).chmod(a,r)),e.mode=e.mode&-4096|r)}t.size!==void 0&&t.size!==null&&r.isFile(e.mode)&&m(e,t.size);let c=s(t.mtime)??t.timestamp;if(c!==void 0){let n=s(t.atime)??c;p(e),l(()=>o(e).utimes(a,n,c))}e.live.stat=void 0},lookup(e,t){let n=c(()=>o(e).lstat(f(e,t)));return u(e,t,n)},mknod(e,n,i){let a=f(e,n);if(r.isDir(i))c(()=>o(e).mkdir(a));else if(r.isFile(i))c(()=>o(e).writeFile(a,new Uint8Array));else throw new r.ErrnoError(t.EPERM);let s=u(e,n,{isFile:r.isFile(i),isDirectory:r.isDir(i),isSymbolicLink:!1,size:0,mode:i,mtimeMs:Date.now()});return s.live.stat=void 0,s},rename(e,t,n){let a=i(e),s=f(t,n);p(e),c(()=>o(e).rename(a,s));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&&(d(n),h(n)),c(()=>o(e).unlink(f(e,t))),n&&(n.live.orphan=!0)},rmdir(e,t){c(()=>o(e).rmdir(f(e,t)))},readdir(e){return[`.`,`..`,...c(()=>o(e).readdir(i(e)))]},symlink(e,t,n){let r=f(e,t);return c(()=>o(e).symlink(n,r)),u(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 c(()=>o(e).readlink(i(e)))}}}function u(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 d(e){let n=new Set,r={},i=c(e,r),a=l(i),o=u(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 f(e,t){return!!t&&e.mounts.has(t.mount)}function p(e,t){for(let n of e.nameTable??[])for(let a=n;a;a=a.name_next??null)if(!(!f(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 m(e,t){let n=e.nameTable??[],r=[];for(let e of n)for(let n=e;n;n=n.name_next??null){if(!f(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 h(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 g(e){if(e instanceof Error)return e.message;let t=e?.errno;return typeof t==`number`?`errno ${t}`:String(e)}function _(e,t,n,r){let i=e.filesystems.SLICC_LIVE_FS??d(e);e.filesystems.SLICC_LIVE_FS=i;let a=[];for(let o of h(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: ${g(e)}`)}return{plugin:i,mounted:a}}const v=new Set([`dev`,`proc`]),y=[`/usr`,`/bin`],b=[`writeFile`,`mkdir`,`rm`,`rename`,`unlink`,`rmdir`,`symlink`,`chmod`,`utimes`];function x(t,n){let r={...t};for(let i of b){let a=t[i];r[i]=(...r)=>{n.wasUsed()&&e(n,t);try{a.apply(t,r)}finally{n.invalidate()}}}return r}function S(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(`/`)&&!v.has(e)).map(e=>`/${e}`);for(let e of y)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 C(t,n,r={}){let{bridge:i,syncFs:a,warn:o}=n;a.wasUsed()&&e(a,i);let{plugin:s,mounted:c}=_(t,x(i,a),S(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:()=>p(t,s),invalidate:()=>m(t,s)}}export{C as mountVfsIntoEmscripten};
1
+ import{n as e}from"./js-realm-worker-_lsydYvZ.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=3735928559,n=1103547991;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);t=Math.imul(t^i,2654435761),n=Math.imul(n^i,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)||1}function o(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 s(e){if(e!=null)return e instanceof Date?e.getTime():e}function c(e,n){let a=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 a=e.createNode(t,r,o(i),0);return a.node_ops=n.node,a.stream_ops=n.stream,a.live=l(i),a}function d(e){if(e.live.orphan)return{...e.live.stat,size:e.live.len};if(!e.live.stat){let t=s(()=>a(e).lstat(i(e)));e.live.stat=t,e.mode=o(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(()=>a(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(()=>a(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),o=new Uint8Array(t);if(t>0){let n=s(()=>a(e).readFile(r));o.set(n.subarray(0,Math.min(t,n.length)))}s(()=>a(e).writeFile(r,o)),n.stat=void 0}return{Fs:e,bridgeOf:a,call:s,metadataCall:c,makeNode:u,statOf:d,childPath:f,ensureLoaded:p,ensureCapacity:m,flushNode:h,truncate:g}}function l(e){let{Fs:r,bridgeOf:o,call:c,metadataCall:l,makeNode:u,statOf:d,childPath:f,flushNode:p,truncate:m}=e,{ensureLoaded:h}=e;return{getattr(e){let t=d(e),n=e.live,o=r.isDir(e.mode)?4096:n.loaded?n.len:t.size,s=new Date(t.mtimeMs??0);return{dev:1,ino:t.ino??a(i(e)),mode:e.mode,nlink:1,uid:0,gid:0,rdev:0,size:o,atime:s,mtime:s,ctime:s,blksize:4096,blocks:Math.ceil(o/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&&m(e,t.size);return}let a=i(e);if(t.mode!==void 0&&t.mode!==null){let r=t.mode&n;r!==(e.mode&n)&&(l(()=>o(e).chmod(a,r)),e.mode=e.mode&-4096|r)}t.size!==void 0&&t.size!==null&&r.isFile(e.mode)&&m(e,t.size);let c=s(t.mtime)??t.timestamp;if(c!==void 0){let n=s(t.atime)??c;p(e),l(()=>o(e).utimes(a,n,c))}e.live.stat=void 0},lookup(e,t){let n=c(()=>o(e).lstat(f(e,t)));return u(e,t,n)},mknod(e,n,i){let a=f(e,n);if(r.isDir(i))c(()=>o(e).mkdir(a));else if(r.isFile(i))c(()=>o(e).writeFile(a,new Uint8Array));else throw new r.ErrnoError(t.EPERM);let s=u(e,n,{isFile:r.isFile(i),isDirectory:r.isDir(i),isSymbolicLink:!1,size:0,mode:i,mtimeMs:Date.now()});return s.live.stat=void 0,s},rename(e,t,n){let a=i(e),s=f(t,n);p(e),c(()=>o(e).rename(a,s));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&&(d(n),h(n)),c(()=>o(e).unlink(f(e,t))),n&&(n.live.orphan=!0)},rmdir(e,t){c(()=>o(e).rmdir(f(e,t)))},readdir(e){return[`.`,`..`,...c(()=>o(e).readdir(i(e)))]},symlink(e,t,n){let r=f(e,t);return c(()=>o(e).symlink(n,r)),u(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 c(()=>o(e).readlink(i(e)))}}}function u(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 d(e){let n=new Set,r={},i=c(e,r),a=l(i),o=u(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 f(e,t){return!!t&&e.mounts.has(t.mount)}function p(e,t){for(let n of e.nameTable??[])for(let a=n;a;a=a.name_next??null)if(!(!f(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 m(e,t){let n=e.nameTable??[],r=[];for(let e of n)for(let n=e;n;n=n.name_next??null){if(!f(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 h(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 g(e){if(e instanceof Error)return e.message;let t=e?.errno;return typeof t==`number`?`errno ${t}`:String(e)}function _(e,t,n,r){let i=e.filesystems.SLICC_LIVE_FS??d(e);e.filesystems.SLICC_LIVE_FS=i;let a=[];for(let o of h(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: ${g(e)}`)}return{plugin:i,mounted:a}}const v=new Set([`dev`,`proc`]),y=[`/usr`,`/bin`],b=[`writeFile`,`mkdir`,`rm`,`rename`,`unlink`,`rmdir`,`symlink`,`chmod`,`utimes`];function x(t,n){let r={...t};for(let i of b){let a=t[i];r[i]=(...r)=>{n.wasUsed()&&e(n,t);try{a.apply(t,r)}finally{n.invalidate()}}}return r}function S(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(`/`)&&!v.has(e)).map(e=>`/${e}`);for(let e of y)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 C(t,n,r={}){let{bridge:i,syncFs:a,warn:o}=n;a.wasUsed()&&e(a,i);let{plugin:s,mounted:c}=_(t,x(i,a),S(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:()=>p(t,s),invalidate:()=>m(t,s)}}export{C as mountVfsIntoEmscripten};