sliccy 6.226.4 → 6.227.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 (154) hide show
  1. package/dist/ui/.vite/manifest.json +186 -186
  2. package/dist/ui/assets/{account-store-CqKfWDow.js → account-store-BFb2UO2K.js} +1 -1
  3. package/dist/ui/assets/{account-store-DtP5_zcC.js → account-store-p9YkaR-j.js} +1 -1
  4. package/dist/ui/assets/{adobe-Csub1Mq2.js → adobe-BnfgTqEQ.js} +1 -1
  5. package/dist/ui/assets/{adobe-CakRZi3Z.js → adobe-CN7urDKo.js} +1 -1
  6. package/dist/ui/assets/{agent-panels-BsbSd_Bc.js → agent-panels-C6MuWyzH.js} +1 -1
  7. package/dist/ui/assets/agent-tools-BL9-Zw2C.js +6 -0
  8. package/dist/ui/assets/{almost-bash-shell-headless-B9L2TCmL.js → almost-bash-shell-headless-DQhRonH_.js} +36 -36
  9. package/dist/ui/assets/{apply-layout-BxoXOQwo.js → apply-layout-DWiLhm8Y.js} +1 -1
  10. package/dist/ui/assets/{apps-CWQK35id.js → apps-F56LSkNx.js} +1 -1
  11. package/dist/ui/assets/{azure-openai-B1BILILZ.js → azure-openai-85x5L6_B.js} +1 -1
  12. package/dist/ui/assets/{azure-openai-C8_duqKu.js → azure-openai-CY4c1Ugr.js} +1 -1
  13. package/dist/ui/assets/{backend-hostfs-BmwQZTgH.js → backend-hostfs-uVp10KM9.js} +1 -1
  14. package/dist/ui/assets/{cdp-Be3yJaZS.js → cdp-BJooT_YW.js} +1 -1
  15. package/dist/ui/assets/{cerebras-CnBXxZAk.js → cerebras-B7CuTW7B.js} +1 -1
  16. package/dist/ui/assets/{cerebras-G8UhkZcQ.js → cerebras-CZd9VG3E.js} +1 -1
  17. package/dist/ui/assets/codemode-tool-wGfb8DBp.js +8 -0
  18. package/dist/ui/assets/{composer-speech-CO-U-3PP.js → composer-speech-CIFv7pMq.js} +1 -1
  19. package/dist/ui/assets/{connect-surface-xpPAUM1h.js → connect-surface-B2N6LdiO.js} +1 -1
  20. package/dist/ui/assets/connection-manager-SNYTz_SX.js +1 -0
  21. package/dist/ui/assets/{directed-approval-BBOfwL7o.js → directed-approval-ALHdAvDT.js} +1 -1
  22. package/dist/ui/assets/dist-Cu98pw2t.js +9 -0
  23. package/dist/ui/assets/dist-Qk32KIeB.js +4 -0
  24. package/dist/ui/assets/{emscripten-vfs-hook-gFKvX0SY.js → emscripten-vfs-hook-BWjaiiFG.js} +1 -1
  25. package/dist/ui/assets/{ensure-speech-assets-Cv5w_6Cs.js → ensure-speech-assets-yt0EoyNf.js} +1 -1
  26. package/dist/ui/assets/{frozen-archive-writer-DKdMEKnu.js → frozen-archive-writer-BBnxV-Sw.js} +1 -1
  27. package/dist/ui/assets/{fs-DjMlnfEu.js → fs-Bhw5j0eY.js} +1 -1
  28. package/dist/ui/assets/{fs-Dh2iUJ-I.js → fs-DdDYEgE4.js} +2 -2
  29. package/dist/ui/assets/{gelatiere-store-QDXLhcIh.js → gelatiere-store-DNMjj5xM.js} +1 -1
  30. package/dist/ui/assets/{gelatiere-unit-cDv5RtM9.js → gelatiere-unit-BEnRKsg5.js} +1 -1
  31. package/dist/ui/assets/{github-nzjWzA2U.js → github-C06K6hM6.js} +2 -2
  32. package/dist/ui/assets/{github-CBim-rA9.js → github-DzMMdXju.js} +1 -1
  33. package/dist/ui/assets/{github-auth-Cy2cTRMV.js → github-auth-DcTBaLFg.js} +1 -1
  34. package/dist/ui/assets/{github-copilot-I2nKVzpw.js → github-copilot-BCxu-JOH.js} +1 -1
  35. package/dist/ui/assets/{github-copilot-BQhAeZoY.js → github-copilot-DMzWgULe.js} +1 -1
  36. package/dist/ui/assets/{github-install-C77mWn6S.js → github-install-BiHV37oT.js} +1 -1
  37. package/dist/ui/assets/{github-zip-UZeZ-voR.js → github-zip-CHlzswro.js} +1 -1
  38. package/dist/ui/assets/{go-driver-CYR67gv1.js → go-driver-DqgTG9N6.js} +1 -1
  39. package/dist/ui/assets/{hear-CLBz15R3.js → hear-RPJIER3w.js} +1 -1
  40. package/dist/ui/assets/{help-Da2S8Plv.js → help-BA8Xystm.js} +1 -1
  41. package/dist/ui/assets/{installer-ZC2UV-cH.js → installer-3ARo1i86.js} +1 -1
  42. package/dist/ui/assets/{ipk-mamba-BDqOegY1.js → ipk-mamba-BEORgiAj.js} +1 -1
  43. package/dist/ui/assets/{js-realm-worker-BP3b2BW6.js → js-realm-worker-BZ9Q6ni5.js} +2 -2
  44. package/dist/ui/assets/{jsh-executor-BnG9duV7.js → jsh-executor-Iaq-AOjA.js} +2 -2
  45. package/dist/ui/assets/{kernel-worker-Dt0qVVA4.js → kernel-worker-CTxRZxWy.js} +14 -14
  46. package/dist/ui/assets/{lick-ws-bridge-DSv0KPA7.js → lick-ws-bridge-C_yTWgQK.js} +1 -1
  47. package/dist/ui/assets/{lick-ws-bridge-CNZGtU-G.js → lick-ws-bridge-DEXhaOXo.js} +1 -1
  48. package/dist/ui/assets/{live-session-curation-C8ic_T_L.js → live-session-curation-CBWOt4Na.js} +1 -1
  49. package/dist/ui/assets/{live-session-snapshot-BfgdULN4.js → live-session-snapshot-2ANcFmFa.js} +1 -1
  50. package/dist/ui/assets/{local-llm-BIA90YgO.js → local-llm-BY58x8Yq.js} +1 -1
  51. package/dist/ui/assets/{local-llm-BEhlvNyE.js → local-llm-Brt8sjwN.js} +1 -1
  52. package/dist/ui/assets/{main-CcsDAmx4.js → main-DFwN1I9-.js} +3 -3
  53. package/dist/ui/assets/{main-cherry-wVsCzmMd.js → main-cherry-CKnVoCvo.js} +1 -1
  54. package/dist/ui/assets/{memory-curation-seam-CKuRq6kM.js → memory-curation-seam-CRQovNy0.js} +1 -1
  55. package/dist/ui/assets/{memory-health-DPNqb4XW.js → memory-health-CWV9igFz.js} +1 -1
  56. package/dist/ui/assets/{memory-write-execute-Ddchxax4.js → memory-write-execute-F74nkaOx.js} +1 -1
  57. package/dist/ui/assets/{merge-folded-cost-into-frozen-W9HxDZuw.js → merge-folded-cost-into-frozen-CNbJWFVZ.js} +1 -1
  58. package/dist/ui/assets/{mount-BSXUu8ny.js → mount-CVw88Sae.js} +1 -1
  59. package/dist/ui/assets/{mount-BJ6v5c1U.js → mount-Cd5d-dGq.js} +3 -3
  60. package/dist/ui/assets/{new-session-Bi-WSHjF.js → new-session-BCLo3JwP.js} +2 -2
  61. package/dist/ui/assets/{oauth-bootstrap-C7l4ahaH.js → oauth-bootstrap-m4oJyeeN.js} +2 -2
  62. package/dist/ui/assets/{onboarding-orchestrator-CXG_pKvN.js → onboarding-orchestrator-CYaAfyzh.js} +1 -1
  63. package/dist/ui/assets/{openai-codex-BxSwMCUp.js → openai-codex-CCVnXN_Y.js} +1 -1
  64. package/dist/ui/assets/{openai-codex-BmCp3jbS.js → openai-codex-D-KswPCn.js} +1 -1
  65. package/dist/ui/assets/{openrouter-CSg8e6bc.js → openrouter-BMACqhZg.js} +1 -1
  66. package/dist/ui/assets/{openrouter-CzE_jMo1.js → openrouter-DDIS0gu8.js} +1 -1
  67. package/dist/ui/assets/{openrouter-free-DCnJbpR6.js → openrouter-free-CQM2VJ2h.js} +1 -1
  68. package/dist/ui/assets/{openrouter-free-C6j87AW6.js → openrouter-free-CxENTZRZ.js} +1 -1
  69. package/dist/ui/assets/{openrouter-oauth-BicjWPKx.js → openrouter-oauth-BTRrF814.js} +1 -1
  70. package/dist/ui/assets/{openrouter-oauth-_hLJp2xE.js → openrouter-oauth-DeZmK_PC.js} +1 -1
  71. package/dist/ui/assets/{opfs-mount-mh0nq9w9.js → opfs-mount-CH8xFjB1.js} +1 -1
  72. package/dist/ui/assets/{panel-rpc-handlers-Dxfsk5di.js → panel-rpc-handlers-DEV3O6Nf.js} +2 -2
  73. package/dist/ui/assets/{panelize-shell-Dv9wG2yx.js → panelize-shell-wTRIeRfk.js} +1 -1
  74. package/dist/ui/assets/{pi-edit-execution-CPQR1_rI.js → pi-edit-execution-CsYSVIy6.js} +1 -1
  75. package/dist/ui/assets/{provider-C6A_QvgY.js → provider-DQlGI3wV.js} +2 -2
  76. package/dist/ui/assets/{provider-DKLBs-rm.js → provider-DiPmyduk.js} +1 -1
  77. package/dist/ui/assets/{provider-settings-B10w9vry.js → provider-settings-CI1NmuB7.js} +1 -1
  78. package/dist/ui/assets/provider-store-access-CC-Qd6Js.js +1 -0
  79. package/dist/ui/assets/provider-store-access-R5OLCz2u.js +1 -0
  80. package/dist/ui/assets/{providers-C32V1tu8.js → providers-DWJgLVLG.js} +2 -2
  81. package/dist/ui/assets/{providers-CSGLxatZ.js → providers-DvzQAoZe.js} +1 -1
  82. package/dist/ui/assets/{quick-llm-C55s80C1.js → quick-llm-CIeq8HDn.js} +1 -1
  83. package/dist/ui/assets/{realm-inprocess-R-7UQxWy.js → realm-inprocess-Ct0UTeSZ.js} +2 -2
  84. package/dist/ui/assets/{realm-unhandled-rejections-CcTUfDlL.js → realm-unhandled-rejections-But1_r5U.js} +1 -1
  85. package/dist/ui/assets/{realm-unhandled-rejections-MJQ577ZB.js → realm-unhandled-rejections-XCowEiz5.js} +1 -1
  86. package/dist/ui/assets/{recovery-screen-CjvEqRSh.js → recovery-screen-2KkMuDJk.js} +1 -1
  87. package/dist/ui/assets/{remote-terminal-view-B9Iehf9R.js → remote-terminal-view-BsBi-Jq-.js} +2 -2
  88. package/dist/ui/assets/{restore-ClVrGUO_.js → restore-BxWnVMjS.js} +1 -1
  89. package/dist/ui/assets/{run-BhUNOe2w.js → run-5o2ADtPK.js} +2 -2
  90. package/dist/ui/assets/{run-CGZiR3xh.js → run-8y7BhTkZ.js} +11 -11
  91. package/dist/ui/assets/{run-BedH4wf2.js → run-B1b6--PA.js} +1 -1
  92. package/dist/ui/assets/{run-DVSJbV2i.js → run-DI8sQ-UX.js} +1 -1
  93. package/dist/ui/assets/{run-CmnvjepF.js → run-Dp8o0HDu.js} +1 -1
  94. package/dist/ui/assets/{run-DiYNywB4.js → run-V-yf2BVO.js} +2 -2
  95. package/dist/ui/assets/{run-CpuIjsuc.js → run-dJaEQuBZ.js} +1 -1
  96. package/dist/ui/assets/{session-command-memory-CVBwVZ62.js → session-command-memory-Da1Ay0IK.js} +2 -2
  97. package/dist/ui/assets/{session-jsonl-BccYkSi6.js → session-jsonl-BT08KJtu.js} +1 -1
  98. package/dist/ui/assets/{session-jsonl-CY233b8_.js → session-jsonl-CisoFWdV.js} +1 -1
  99. package/dist/ui/assets/{session-search-index-Ch3pCEwc.js → session-search-index-C9dq-YnZ.js} +1 -1
  100. package/dist/ui/assets/{setup-feature-flags-remote-CODtZG_r.js → setup-feature-flags-remote-C-QrDDap.js} +1 -1
  101. package/dist/ui/assets/{setup-model-catalog-B3nHaQyu.js → setup-model-catalog-DQFqjnfG.js} +1 -1
  102. package/dist/ui/assets/{signed-fetch-BScOrFAI.js → signed-fetch-B_zCsTF6.js} +1 -1
  103. package/dist/ui/assets/{silent-renew-backoff-Du_Xl4_2.js → silent-renew-backoff-DZMNobI2.js} +1 -1
  104. package/dist/ui/assets/slicc-version-DwNEsrEc.js +1 -0
  105. package/dist/ui/assets/{snapshot-DOjH_Br5.js → snapshot-Qi7uJgTK.js} +1 -1
  106. package/dist/ui/assets/{snapshot-features-Ha3qZYi5.js → snapshot-features-ko4zNFx_.js} +1 -1
  107. package/dist/ui/assets/{soundscape-DZdmw_5a.js → soundscape-CSNoiZFC.js} +1 -1
  108. package/dist/ui/assets/{speak-OzKJ4LDt.js → speak-aAmw1Lv4.js} +1 -1
  109. package/dist/ui/assets/{sprinkle-manager-CdstazgG.js → sprinkle-manager-BcUAmBKL.js} +1 -1
  110. package/dist/ui/assets/{sprinkle-renderer-Bs6XZuJN.js → sprinkle-renderer-a99oRJ5K.js} +1 -1
  111. package/dist/ui/assets/{state-CvCDVCdM.js → state-B8wLxLGq.js} +1 -1
  112. package/dist/ui/assets/{store-Ci5uqDiF.js → store-CBtTB-Y7.js} +1 -1
  113. package/dist/ui/assets/{store-vMYCG7nS.js → store-D8XRrwq1.js} +1 -1
  114. package/dist/ui/assets/{sudo-omGZ62M-.js → sudo-CvMjZIh6.js} +1 -1
  115. package/dist/ui/assets/{supervisor-gHwvuVqr.js → supervisor-CNcjK1gk.js} +1 -1
  116. package/dist/ui/assets/{sync-dialog-BuomvIrD.js → sync-dialog-D0C6RJ1r.js} +1 -1
  117. package/dist/ui/assets/{transformers-env-DK81KZ-_.js → transformers-env-BWgCzqFy.js} +1 -1
  118. package/dist/ui/assets/{tray-leader-4bul7Ct2.js → tray-leader-anPCnjI3.js} +1 -1
  119. package/dist/ui/assets/{tray-leave-runtime-B4WKKash.js → tray-leave-runtime-DTq8BTG1.js} +1 -1
  120. package/dist/ui/assets/{tray-sidecar-BJwCQVGH.js → tray-sidecar-Dk-gNNOa.js} +1 -1
  121. package/dist/ui/assets/{upgrade-detection-Df_g87L1.js → upgrade-detection-BofecB7v.js} +1 -1
  122. package/dist/ui/assets/{upskill-lick-skip-BqQyWVKm.js → upskill-lick-skip-3qGDA07K.js} +1 -1
  123. package/dist/ui/assets/{voice-reply-BehdeJ03.js → voice-reply-C1P_wamT.js} +1 -1
  124. package/dist/ui/assets/{wc-attach-3a4N2dfx.js → wc-attach-dgMJ26XT.js} +2 -2
  125. package/dist/ui/assets/{wc-browser-lL-L_txI.js → wc-browser-B-COerUp.js} +1 -1
  126. package/dist/ui/assets/{wc-computers-B9-zQ4JW.js → wc-computers-_JxYl2wr.js} +1 -1
  127. package/dist/ui/assets/{wc-detached-BlMowfY3.js → wc-detached-D2pbuUgz.js} +1 -1
  128. package/dist/ui/assets/{wc-extension-BeNvD6FE.js → wc-extension-CllXRrrB.js} +2 -2
  129. package/dist/ui/assets/{wc-follower-EFSJs2OJ.js → wc-follower-BJoxJGJc.js} +3 -3
  130. package/dist/ui/assets/{wc-follower-oauth-bXKWVQGm.js → wc-follower-oauth-CRVfRh9S.js} +1 -1
  131. package/dist/ui/assets/{wc-gelatiere-EOAqp9kU.js → wc-gelatiere-oTqfeOtw.js} +1 -1
  132. package/dist/ui/assets/{wc-live-CZeagRhy.js → wc-live-lanuGtCH.js} +5 -5
  133. package/dist/ui/assets/{wc-nav-DAH24DXh.js → wc-nav-CxTE5nNk.js} +2 -2
  134. package/dist/ui/assets/{wc-onboarding-CcKDzrfa.js → wc-onboarding-CTHTCQRn.js} +2 -2
  135. package/dist/ui/assets/{wc-permissions-J-xSpeyH.js → wc-permissions-DsdMkMR_.js} +2 -2
  136. package/dist/ui/assets/{wc-placeholder-Bu4ryZw7.js → wc-placeholder-BW3O9G-1.js} +3 -3
  137. package/dist/ui/assets/{wc-secret-request-BSxQu1_l.js → wc-secret-request-CYprt2E3.js} +1 -1
  138. package/dist/ui/assets/{wc-settings-C2GmNXu1.js → wc-settings-BpOWAvNP.js} +3 -3
  139. package/dist/ui/assets/{wc-shell-D1w_xNlG.js → wc-shell-ublv7ZL8.js} +3 -3
  140. package/dist/ui/assets/{wc-shortcut-config-C7N1oz-m.js → wc-shortcut-config-I0L9ZRfk.js} +1 -1
  141. package/dist/ui/assets/{wc-sprinkles-C1i11O8r.js → wc-sprinkles-BZFWrQuP.js} +2 -2
  142. package/dist/ui/assets/{wc-transcript-export-CZRr6hcJ.js → wc-transcript-export-Camv8Krm.js} +2 -2
  143. package/dist/ui/assets/{wc-tray-xbj9CuSO.js → wc-tray-D50mlMs8.js} +4 -4
  144. package/dist/ui/assets/welcome-detection-BtHni7N4.js +1 -0
  145. package/dist/ui/assets/{whisper-session-xb1YrAUl.js → whisper-session-Myw3zk-W.js} +2 -2
  146. package/dist/ui/assets/{xai-grok-bN_nbILL.js → xai-grok-BVM_XcYa.js} +1 -1
  147. package/dist/ui/assets/{xai-grok-B8X1-rs-.js → xai-grok-D4iOI1_b.js} +1 -1
  148. package/dist/ui/index.html +3 -3
  149. package/dist/ui/packages/webapp/index.html +3 -3
  150. package/package.json +2 -2
  151. package/dist/ui/assets/provider-store-access-B1aRkFuC.js +0 -1
  152. package/dist/ui/assets/provider-store-access-DJ_XxgCD.js +0 -1
  153. package/dist/ui/assets/slicc-version-CTGV3KxX.js +0 -1
  154. package/dist/ui/assets/welcome-detection-C0csMKau.js +0 -1
@@ -1 +1 @@
1
- import{CHAT_SURFACE_ID as e}from"./wc-sprinkles-C1i11O8r.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-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,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-DjMlnfEu.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-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;">
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-CqKfWDow.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-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(`
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-DtP5_zcC.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-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(`
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-Dh2iUJ-I.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-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,4 +1,4 @@
1
- import{t as e}from"./logger-DDBAeTLF.js";import"./navigation-watcher-CPcnZL9l.js";import"./wc-follower-oauth-bXKWVQGm.js";import{d as t,l as n,u as r}from"./main-CcsDAmx4.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-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() {
2
2
  'use strict';
3
3
 
4
4
  // ===== DOM Utilities =====
@@ -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-CqKfWDow.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-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 +1 @@
1
- import{a as e}from"./account-store-DtP5_zcC.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-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};
@@ -0,0 +1,8 @@
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}".
2
+ Scripts run in a QuickJS sandbox with access to the following tools via \`tools.<name>(args)\`:
3
+ ${d.map(e=>`- \`${e.name}\`: ${e.description??`(no description)`}`).join(`
4
+ `)}
5
+
6
+ Top-level \`await\` and \`return\` work. No fetch, no filesystem, no timers — only tool calls.`;return{name:t(i,`codemode`),label:`mcp:${i}/codemode`,description:f,parameters:{type:`object`,properties:{code:{type:`string`,description:`JavaScript source to execute in the sandbox.`}},required:[`code`]},async execute(e,t,n){let o=(t??{}).code??``;try{let e=await a(),t=d.map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema,async execute(t,n){let r=t??{},i=await s.callTool(e.name,r,{signal:n.signal});if(i.isError){let t=i.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
7
+ `);throw Error(t||`Tool "${e.name}" failed`)}return i.structuredContent?i.structuredContent:i.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
8
+ `)}}));for(let n of t)e.registerTool(n);let r;try{r=await e.execute(o,{signal:n})}finally{for(let n of t)e.unregisterTool(n.name)}return c(r)}catch(e){return r.warn(`codemode execution failed`,{server:i,error:e instanceof Error?e.message:String(e)}),{content:[{type:`text`,text:`Codemode error: ${e instanceof Error?e.message:String(e)}`}],details:void 0,isError:!0}}}}}function c(e){let t=e.output.map(e=>e.type===`text`?{type:`text`,text:e.text}:{type:`image`,data:e.data,mimeType:e.mimeType});if(e.ok&&e.value!==void 0&&t.push({type:`text`,text:typeof e.value==`string`?e.value:JSON.stringify(e.value)}),!e.ok){let{error:n}=e,r=n.kind===`script`?n.stack??`${n.name??`Error`}: ${n.message}`:`${n.kind}: ${n.message}`;t.push({type:`text`,text:`Script error:\n${r}`})}let n=e.calls.map(e=>`${e.name} (${e.status}, ${e.durationMs.toFixed(0)}ms)`).join(`, `),r=`${e.ok?`Script completed`:`Script failed`}${e.calls.length>0?`\nTool calls: ${n}`:``}\n`;return t.length===0&&t.push({type:`text`,text:`(empty result)`}),{content:[{type:`text`,text:r},...t],details:void 0,...e.ok?{}:{isError:!0}}}export{s as createCodemodeAgentTool};
@@ -1 +1 @@
1
- import{t as e}from"./logger-DDBAeTLF.js";import{st as t}from"./wc-shell-D1w_xNlG.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-DK81KZ-_.js";import{i as o,t as s}from"./whisper-session-xb1YrAUl.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-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,4 +1,4 @@
1
- import{B as e,E as t,f as n,p as r}from"./account-store-CqKfWDow.js";import{a as i}from"./main-CcsDAmx4.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-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=`
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}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-C4_ggaf5.js`).then(e=>e.n),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-C4_ggaf5.js`).then(e=>e.n),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`);return r(await o.toolsCall(e,t))},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-C4_ggaf5.js`).then(e=>e.n);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};
@@ -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-Dt0qVVA4.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{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};
@@ -0,0 +1,9 @@
1
+ function e(e){let t=``;for(let n of e){let e=t===``?/^[A-Za-z_$]$/.test(n):/^[A-Za-z0-9_$]$/.test(n);t+=e?n:`_`}return t===``?`_`:t}var t=class{worker;listeners=new Map;exited=!1;constructor(e,t){this.worker=new globalThis.Worker(e,{type:`module`}),this.worker.onmessage=e=>{this.emit(`message`,e.data)},this.worker.onerror=e=>{let t=Error(e.message??`Worker error`);this.emit(`error`,t)},t?.workerData!==void 0&&this.worker.postMessage(t.workerData)}on(e,t){let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),this}postMessage(e){this.worker.postMessage(e)}async terminate(){return this.exited||(this.exited=!0,this.worker.terminate(),this.emit(`exit`,0)),0}emit(e,...t){let n=this.listeners.get(e);if(n)for(let e of n)try{e(...t)}catch{}}};let n;function r(){return n||(n=WebAssembly.compileStreaming(fetch(`https://cdn.jsdelivr.net/npm/quickjs-wasi@3.6.2/quickjs.wasm`)).catch(e=>{throw n=void 0,e}),n)}function i(e){if(typeof e!=`object`||!e)return!1;let t=e.type;return t===`call`||t===`output`||t===`done`||t===`crash`}const a=/^[A-Za-z_$][A-Za-z0-9_$]*$/,o=new Set([`tools`,`ALL_TOOLS`,`console`,`text`,`image`,`exit`,`globalThis`,`store`,`load`]);function s(e){return e instanceof Error?e.message:String(e)}function c(e){let t={};for(let[n,r]of Object.entries(e??{})){let e=JSON.stringify(r);e!==void 0&&(t[n]=e)}return t}function l(e){let t={set:{},delete:[]};for(let[n,r]of JSON.parse(e))r===void 0?t.delete.push(n):t.set[n]=JSON.parse(r);return t}function u(){return new URL(import.meta.url.endsWith(`.ts`)?`./worker.ts`:`./worker.js`,import.meta.url)}var d=class{promise;resolveResult;worker;interrupt=new SharedArrayBuffer(4);tools;globals;signal;timer;output=[];calls=[];pending=new Map;finished=!1;constructor(e){this.promise=new Promise(e=>{this.resolveResult=e}),this.tools=e.tools,this.globals=e.globals,this.signal=e.signal,Number.isFinite(e.timeoutMs)&&(this.timer=setTimeout(()=>{this.finish({kind:`timeout`,message:`Execution timed out after ${e.timeoutMs} ms`})},e.timeoutMs)),e.signal&&(e.signal.aborted?this.onAbort():e.signal.addEventListener(`abort`,this.onAbort,{once:!0})),e.wasm.then(t=>this.start(e,t),e=>{this.finish({kind:`sandbox`,message:`Failed to load QuickJS: ${s(e)}`})})}abort(e){return this.finish({kind:`aborted`,message:e}),this.promise}start(n,r){if(this.finished)return;let i={code:n.code,tools:[...n.tools.values()].map(t=>({name:t.name,jsName:e(t.name),description:t.description??``})),globals:[...n.globals.values()].map(e=>({name:e.name,spread:e.spread===!0})),wasm:r,memoryLimitBytes:n.memoryLimitBytes,store:n.store,interrupt:this.interrupt},a;try{a=new t(n.workerUrl,{workerData:i})}catch(e){this.finish({kind:`sandbox`,message:`Failed to start worker: ${s(e)}`});return}this.worker=a,a.on(`message`,e=>this.handleMessage(e)),a.on(`error`,e=>{this.finish({kind:`sandbox`,name:e instanceof Error?e.name:void 0,message:s(e)})}),a.on(`exit`,e=>{this.finish({kind:`sandbox`,message:`Worker exited with code ${e} before the script settled`})})}onAbort=()=>{let e=this.signal?.reason;this.finish({kind:`aborted`,message:e instanceof Error?e.message:`Execution aborted`})};post(e){this.worker?.postMessage(e)}handleMessage(e){if(!(this.finished||!i(e)))switch(e.type){case`output`:this.output.push(e.item);break;case`call`:this.handleCall(e);break;case`done`:this.handleDone(e);break;case`crash`:this.finish({kind:`sandbox`,message:e.message})}}handleDone(e){if(!e.ok){let t=JSON.parse(e.error);this.finish({kind:`script`,...t});return}this.finish(void 0,e.value===void 0?void 0:JSON.parse(e.value),e.writes)}async handleCall(e){let{id:t,name:n}=e,r=e.target===`tool`,i=r?{name:n,status:`cancelled`,durationMs:0}:void 0;i&&this.calls.push(i);let a={record:i,startedAt:performance.now(),controller:new AbortController};this.pending.set(t,a);let o,c;try{let i=(r?this.tools:this.globals).get(n);if(!i)throw Error(`Unknown ${r?`tool`:`global`} "${n}"`);let s=e.args===void 0?void 0:JSON.parse(e.args),l=await i.execute(s,{signal:a.controller.signal});c={type:`result`,id:t,ok:!0,payload:l===void 0?void 0:JSON.stringify(l)},o=`ok`}catch(e){c={type:`result`,id:t,ok:!1,payload:s(e)},o=`error`}this.pending.delete(t)&&(i&&(i.status=o,i.durationMs=performance.now()-a.startedAt),this.post(c))}finish(e,t,n){if(this.finished)return;this.finished=!0,clearTimeout(this.timer),this.signal?.removeEventListener(`abort`,this.onAbort);let r=performance.now();for(let e of this.pending.values())e.record&&(e.record.durationMs=r-e.startedAt),e.controller.abort();this.pending.clear();let i=e?{ok:!1,error:e,output:this.output,calls:this.calls}:{ok:!0,value:t,output:this.output,calls:this.calls,storeWrites:n===void 0?{set:{},delete:[]}:l(n)};if(!this.worker){this.resolveResult(i);return}Atomics.store(new Int32Array(this.interrupt),0,1),this.worker.terminate().catch(()=>void 0).then(()=>this.resolveResult(i))}},f=class{toolsByName=new Map;globalsByName=new Map;timeoutMs;memoryLimitBytes;wasm;workerUrl;running=new Set;closed=!1;constructor(e={}){this.timeoutMs=e.timeoutMs??3e5,this.memoryLimitBytes=e.memoryLimitBytes,this.wasm=e.wasm,this.workerUrl=e.workerUrl??u();for(let t of e.tools??[])this.registerTool(t);let t=new Set;for(let n of e.globals??[]){let e=n.name.split(`.`);if(e.length>2||!e.every(e=>a.test(e))||o.has(e[0]))throw Error(`Invalid global name "${n.name}"`);if(this.globalsByName.has(n.name))throw Error(`Global "${n.name}" is already registered`);e.length===2&&t.add(e[0]),this.globalsByName.set(n.name,n)}for(let e of t)if(this.globalsByName.has(e))throw Error(`Global "${e}" conflicts with the namespace "${e}"`)}registerTool(e){if(this.toolsByName.has(e.name))throw Error(`Tool "${e.name}" is already registered`);this.toolsByName.set(e.name,e)}unregisterTool(e){return this.toolsByName.delete(e)}get tools(){return[...this.toolsByName.values()]}get globals(){return[...this.globalsByName.values()]}execute(e,t={}){if(this.closed)return Promise.reject(Error(`Sandbox is closed`));let n=new d({code:e,tools:new Map(this.toolsByName),globals:this.globalsByName,timeoutMs:t.timeoutMs??this.timeoutMs,signal:t.signal,memoryLimitBytes:this.memoryLimitBytes,store:c(t.store),wasm:this.wasm===void 0?r():Promise.resolve(this.wasm),workerUrl:this.workerUrl});return this.running.add(n),n.promise.finally(()=>this.running.delete(n))}async close(){this.closed=!0,await Promise.all([...this.running].map(e=>e.abort(`Sandbox closed`)))}};const p=`image expects a non-empty image URL string, an object with image_url, or a raw MCP image block`;`${JSON.stringify(p)}${JSON.stringify(p)}${JSON.stringify(p)}${JSON.stringify(p)}`,String.raw`
2
+ start: options_source | plain_source
3
+ options_source: OPTIONS_LINE NEWLINE SOURCE
4
+ plain_source: SOURCE
5
+
6
+ OPTIONS_LINE: /[ \t]*\/\/ @options:[^\r\n]*/
7
+ NEWLINE: /\r?\n/
8
+ SOURCE: /[\s\S]+/
9
+ `;export{f as CodemodeSandbox,r as loadQuickJSWasm};
@@ -0,0 +1,4 @@
1
+ const e={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603};var t=class extends Error{code;data;constructor(e,t,n){super(t),this.name=`McpError`,this.code=e,this.data=n}},n=class extends Error{constructor(e=`MCP connection closed`){super(e),this.name=`McpConnectionClosedError`}},r=class extends Error{timeoutMs;constructor(e){super(`MCP request timed out after ${e}ms`),this.name=`McpTimeoutError`,this.timeoutMs=e}},i=class extends Error{constructor(e=`MCP request aborted`){super(e),this.name=`AbortError`}};function a(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function o(e){return e instanceof Error?e:Error(String(e))}function s(e){return typeof e==`string`||typeof e==`number`&&Number.isFinite(e)}function c(e){return a(e)&&e.jsonrpc===`2.0`&&s(e.id)&&typeof e.method==`string`}function l(e){return a(e)&&e.jsonrpc===`2.0`&&!(`id`in e)&&typeof e.method==`string`}function u(e){return!a(e)||e.jsonrpc!==`2.0`||!s(e.id)?!1:`result`in e?!(`error`in e):!(`error`in e)||!a(e.error)?!1:typeof e.error.code==`number`&&typeof e.error.message==`string`}function d(n){if(c(n)||l(n)||u(n))return n;throw new t(e.invalidRequest,`Invalid JSON-RPC message`)}const f=[`2025-11-25`,`2025-06-18`,`2025-03-26`,`2024-11-05`],p=1e3;function m(n){if(!a(n)||typeof n.protocolVersion!=`string`||!a(n.capabilities)||!a(n.serverInfo)||typeof n.serverInfo.name!=`string`||typeof n.serverInfo.version!=`string`||n.instructions!==void 0&&typeof n.instructions!=`string`)throw new t(e.invalidRequest,`Invalid MCP initialize result`);return n}function h(n){return new t(e.invalidRequest,n)}function g(e,t,n,r){let i=a(n)?n[t]:void 0;if(!a(n)||!Array.isArray(i))throw h(`Invalid MCP ${e} result`);for(let t of i)if(!a(t)||!r(t))throw h(`Invalid entry in MCP ${e} result`);if(n.nextCursor!==void 0&&typeof n.nextCursor!=`string`)throw h(`Invalid MCP ${e} cursor`);return{items:i,...n.nextCursor===void 0?{}:{nextCursor:n.nextCursor}}}const _=e=>typeof e.name==`string`&&a(e.inputSchema),v=e=>typeof e.uri==`string`&&(e.name===void 0||typeof e.name==`string`),y=e=>typeof e.uriTemplate==`string`&&(e.name===void 0||typeof e.name==`string`);function b(e){return{...e,name:e.name??e.uri}}function x(e){return{...e,name:e.name??e.uriTemplate}}function S(e){return e.nextCursor===void 0?{}:{nextCursor:e.nextCursor}}function C(e){if(!a(e)||!Array.isArray(e.contents))throw h(`Invalid MCP resources/read result`);for(let t of e.contents)if(!a(t)||typeof t.uri!=`string`||typeof t.text!=`string`&&typeof t.blob!=`string`)throw h(`Invalid contents in MCP resources/read result`);return e}function w(n){if(!a(n)||n.content!==void 0&&!Array.isArray(n.content))throw new t(e.invalidRequest,`Invalid MCP tools/call result`);if(n.structuredContent!==void 0&&!a(n.structuredContent))throw new t(e.invalidRequest,`Invalid MCP tools/call structured content`);return n.content===void 0?{...n,content:[]}:n}var T=class{options;state=`idle`;transport;nextRequestId=1;serverInfoValue;serverCapabilitiesValue;instructionsValue;protocolVersionValue;pending=new Map;progressRequests=new Map;incoming=new Map;requestHandlers=new Map;notificationListeners=new Map;errorListeners=new Set;closeListeners=new Set;disposers=[];constructor(e){this.options=Object.freeze({...e}),this.requestHandlers.set(`ping`,()=>({}));let t=e.roots;t&&this.requestHandlers.set(`roots/list`,async()=>({roots:[...typeof t==`function`?await t():t]}))}get connectionState(){return this.state}get serverInfo(){return this.serverInfoValue}get serverCapabilities(){return this.serverCapabilitiesValue}get instructions(){return this.instructionsValue}get protocolVersion(){return this.protocolVersionValue}async connect(e){if(this.state!==`idle`)throw Error(`Cannot connect MCP client in ${this.state} state`);this.state=`connecting`,this.transport=e,this.disposers=[e.onMessage(e=>this.handleMessage(e)),e.onError(e=>this.emitError(e)),e.onClose(()=>this.handleTransportClose())];try{await e.start();let t={...this.options.capabilities};this.options.roots&&t.roots===void 0&&(t.roots={});let n=m(await this.requestInternal(`initialize`,{protocolVersion:this.options.protocolVersion??`2025-11-25`,capabilities:t,clientInfo:{name:this.options.name,version:this.options.version,...this.options.title===void 0?{}:{title:this.options.title}}},{},!0));if(!f.includes(n.protocolVersion))throw Error(`MCP server selected unsupported protocol version ${n.protocolVersion}`);return this.protocolVersionValue=n.protocolVersion,this.serverInfoValue=n.serverInfo,this.serverCapabilitiesValue=n.capabilities,this.instructionsValue=n.instructions,e.setProtocolVersion?.(n.protocolVersion),await this.notifyInternal(`notifications/initialized`,void 0,!0),this.state=`connected`,n}catch(e){throw await this.close().catch(()=>{}),e}}request(e,t,n={}){return this.requestInternal(e,t,n,!1)}notify(e,t){return this.notifyInternal(e,t,!1)}setRequestHandler(e,t){return this.requestHandlers.set(e,t),()=>{this.requestHandlers.get(e)===t&&this.requestHandlers.delete(e)}}onNotification(e,t){let n=this.notificationListeners.get(e)??new Set;return this.notificationListeners.set(e,n),n.add(t),()=>{n.delete(t),n.size===0&&this.notificationListeners.delete(e)}}onError(e){return this.errorListeners.add(e),()=>this.errorListeners.delete(e)}onClose(e){return this.closeListeners.add(e),()=>this.closeListeners.delete(e)}async ping(e={}){await this.request(`ping`,void 0,e)}async listTools(e={}){return await this.listAll(`tools/list`,`tools`,_,e)}async listResources(e={}){return(await this.listAll(`resources/list`,`resources`,v,e)).map(b)}async listResourcesPage(e,t={}){let n=await this.listPage(`resources/list`,`resources`,v,e,t);return{resources:n.items.map(b),...S(n)}}async listResourceTemplates(e={}){return(await this.listAll(`resources/templates/list`,`resourceTemplates`,y,e)).map(x)}async listResourceTemplatesPage(e,t={}){let n=await this.listPage(`resources/templates/list`,`resourceTemplates`,y,e,t);return{resourceTemplates:n.items.map(x),...S(n)}}async readResource(e,t={}){return C(await this.request(`resources/read`,{uri:e},t))}async listPage(e,t,n,r,i){return g(e,t,await this.request(e,r===void 0?void 0:{cursor:r},i),n)}async listAll(e,t,n,r){let i=[],a=new Set,o;for(let s=0;s<p;s++){let s=await this.listPage(e,t,n,o,r);if(i.push(...s.items),s.nextCursor===void 0)return i;if(a.has(s.nextCursor))throw Error(`MCP ${e} returned duplicate cursor: ${s.nextCursor}`);a.add(s.nextCursor),o=s.nextCursor}throw Error(`MCP ${e} exceeded ${p} pages`)}async callTool(e,t,n={}){return w(await this.request(`tools/call`,{name:e,...t===void 0?{}:{arguments:t}},n))}async close(){let e=this.transport;this.transport=void 0,this.disposeTransportListeners(),this.markClosed(new n),await e?.close()}async requestInternal(e,t,n,r){let o=this.requireTransport(r);if(n.signal?.aborted)throw new i;let s=this.nextRequestId++,c=n.onProgress?s:void 0,l=c===void 0?t:{...t,_meta:{...a(t?._meta)?t._meta:{},progressToken:c}},u={jsonrpc:`2.0`,id:s,method:e,...l===void 0?{}:{params:l}};return new Promise((t,r)=>{let a={resolve:t,reject:r,timeoutMs:n.timeoutMs??this.options.requestTimeoutMs??3e4,timer:void 0,signal:n.signal,onAbort:()=>this.cancelPending(s,new i,e!==`initialize`,String(n.signal?.reason??`Aborted`)),cancellable:e!==`initialize`,onProgress:n.onProgress,progressToken:c};this.pending.set(s,a),c!==void 0&&this.progressRequests.set(c,s),n.signal?.addEventListener(`abort`,a.onAbort,{once:!0}),this.armTimeout(s,a),o.send(u).catch(e=>this.cancelPending(s,e,!1))})}async notifyInternal(e,t,n){await this.requireTransport(n).send({jsonrpc:`2.0`,method:e,...t===void 0?{}:{params:t}})}requireTransport(e){if(this.transport&&(this.state===`connected`||e&&this.state===`connecting`))return this.transport;throw new n(`MCP client is ${this.state}`)}handleMessage(n){if(u(n)){this.handleResponse(n);return}if(c(n)){this.handleRequest(n);return}if(l(n)){this.handleNotification(n.method,n.params);return}this.emitError(new t(e.invalidRequest,`Received invalid JSON-RPC message`))}handleResponse(e){let n=this.pending.get(e.id);if(!n){this.emitError(Error(`Received response for unknown MCP request ${String(e.id)}`));return}this.removePending(e.id,n),`error`in e?n.reject(new t(e.error.code,e.error.message,e.error.data)):n.resolve(e.result)}async handleRequest(n){let r=this.transport;if(!r)return;let i=this.requestHandlers.get(n.method);if(!i){await r.send({jsonrpc:`2.0`,id:n.id,error:{code:e.methodNotFound,message:`Method not found: ${n.method}`}}).catch(e=>this.emitError(e));return}let a=new AbortController;this.incoming.set(n.id,a);try{let e=await i(n.params,{signal:a.signal});await r.send({jsonrpc:`2.0`,id:n.id,result:e??{}})}catch(i){let a=i instanceof t?{code:i.code,message:i.message,data:i.data}:{code:e.internalError,message:o(i).message};await r.send({jsonrpc:`2.0`,id:n.id,error:a}).catch(e=>this.emitError(e))}finally{this.incoming.delete(n.id)}}handleNotification(e,t){e===`notifications/progress`?this.handleProgress(t):e===`notifications/cancelled`&&this.handleCancelled(t);for(let n of this.notificationListeners.get(e)??[])try{n(t)}catch(e){this.emitError(e)}}handleProgress(e){if(!a(e)||!s(e.progressToken)||typeof e.progress!=`number`)return;let t=this.progressRequests.get(e.progressToken),n=t===void 0?void 0:this.pending.get(t);if(!(t===void 0||!n)){this.armTimeout(t,n);try{n.onProgress?.(e)}catch(e){this.emitError(e)}}}handleCancelled(e){a(e)&&s(e.requestId)&&this.incoming.get(e.requestId)?.abort(e.reason)}armTimeout(e,t){t.timer&&clearTimeout(t.timer),!(!Number.isFinite(t.timeoutMs)||t.timeoutMs<=0)&&(t.timer=setTimeout(()=>{this.cancelPending(e,new r(t.timeoutMs),t.cancellable,`Request timed out`)},t.timeoutMs))}cancelPending(e,t,n,r){let i=this.pending.get(e);i&&(this.removePending(e,i),i.reject(t),n&&this.transport&&this.transport.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:e,...r?{reason:r}:{}}}).catch(e=>this.emitError(e)))}removePending(e,t){this.pending.delete(e),t.timer&&clearTimeout(t.timer),t.progressToken!==void 0&&this.progressRequests.delete(t.progressToken),t.signal?.removeEventListener(`abort`,t.onAbort)}rejectPending(e){for(let[t,n]of this.pending)this.removePending(t,n),n.reject(e)}handleTransportClose(){this.markClosed(new n)}markClosed(e){let t=this.state===`closed`;this.state=`closed`,this.rejectPending(e);for(let t of this.incoming.values())t.abort(e);if(this.incoming.clear(),!t)for(let e of[...this.closeListeners])try{e()}catch(e){this.emitError(e)}}emitError(e){let t=o(e);for(let e of this.errorListeners)e(t)}disposeTransportListeners(){for(let e of this.disposers.splice(0))e()}},E=class{messageListeners=new Set;errorListeners=new Set;closeListeners=new Set;closeEmitted=!1;onMessage(e){return this.messageListeners.add(e),()=>this.messageListeners.delete(e)}onError(e){return this.errorListeners.add(e),()=>this.errorListeners.delete(e)}onClose(e){return this.closeListeners.add(e),()=>this.closeListeners.delete(e)}emitMessage(e){for(let t of this.messageListeners)t(e)}emitError(e){let t=o(e);for(let e of this.errorListeners)e(t)}emitClose(){if(!this.closeEmitted){this.closeEmitted=!0;for(let e of this.closeListeners)e()}}};async function D(e,t){let n=e.getReader(),r=new TextDecoder,i=``,a,o,s=[],c=0,l=t.maxEventBytes??16777216,u=()=>{if(s.length===0){a=void 0,o=void 0;return}let e=s.join(`
2
+ `);t.onEvent({...a?{event:a}:{},data:e,...o?{id:o}:{}}),a=void 0,o=void 0,s=[],c=0},d=e=>{let n=e.endsWith(`\r`)?e.slice(0,-1):e;if(n===``){u();return}if(n.startsWith(`:`))return;let r=n.indexOf(`:`),i=r<0?n:n.slice(0,r),d=r<0?``:n.slice(r+1);if(d.startsWith(` `)&&(d=d.slice(1)),i===`data`){if(c+=Buffer.byteLength(d)+ +(s.length>0),c>l)throw Error(`MCP SSE event exceeds ${l} bytes`);s.push(d)}else i===`event`?a=d:i===`id`&&!d.includes(`\0`)?(o=d,t.onId?.(d)):i===`retry`&&/^\d+$/.test(d)&&t.onRetry?.(Number(d))};try{for(;;){let{done:e,value:t}=await n.read();if(e)break;i+=r.decode(t,{stream:!0});let a=i.indexOf(`
3
+ `);for(;a>=0;)d(i.slice(0,a)),i=i.slice(a+1),a=i.indexOf(`
4
+ `);if(Buffer.byteLength(i)>l)throw Error(`MCP SSE event exceeds ${l} bytes`)}i+=r.decode(),i&&d(i),u()}finally{n.releaseLock()}}var O=class extends Error{status;body;constructor(e,t,n=``){super(t),this.name=`McpHttpError`,this.status=e,this.body=n}},k=class extends O{wwwAuthenticate;constructor(e,t=``){super(401,`MCP server requires authentication`,t),this.name=`McpAuthRequiredError`,this.wwwAuthenticate=e.headers.get(`www-authenticate`)}},A=class extends O{constructor(e=``){super(404,`MCP session expired`,e),this.name=`McpSessionExpiredError`}};function j(e){return e.headers.get(`content-type`)?.split(`;`,1)[0]?.trim().toLowerCase()}function M(e){return e.status===401||e.status===403&&/(?:^|[\s,])error="?insufficient_scope"?/i.test(e.headers.get(`www-authenticate`)??``)}function N(e){return e===408||e===429||e>=500}function P(e){return e.body?.cancel().catch(()=>{})??Promise.resolve()}function F(e,t){let n=t.trim(),r=n.length>500?`${n.slice(0,497)}...`:n;return`MCP HTTP request failed with status ${e}${r?`: ${r}`:``}`}var I=class extends E{url;options;fetch;controller=new AbortController;started=!1;closed=!1;sessionIdValue;protocolVersion;getStreamStarted=!1;constructor(e){super(),this.options=Object.freeze({...e,headers:e.headers?{...e.headers}:void 0}),this.url=new URL(e.url),this.fetch=e.fetch??globalThis.fetch}get sessionId(){return this.sessionIdValue}async start(){if(this.started)throw Error(`MCP Streamable HTTP transport already started`);if(this.closed)throw new n;this.started=!0}setProtocolVersion(e){this.protocolVersion=e}async send(e){if(!this.started||this.closed)throw new n;let t=await this.authorizedFetch(`POST`,{headers:{accept:`application/json, text/event-stream`,"content-type":`application/json`},body:JSON.stringify(e)});if(await this.checkResponse(t),this.captureSession(t),!c(e)){await P(t),`method`in e&&e.method===`notifications/initialized`&&this.startGetStream();return}if(t.status===202||t.status===204)throw new O(t.status,`MCP server accepted request ${e.method} without a response`);let r=j(t);if(r===`application/json`){let e=await t.json();for(let t of Array.isArray(e)?e:[e])this.emitMessage(d(t));return}if(r===`text/event-stream`&&t.body){this.consumeResponseStream(t.body,e.id);return}throw await P(t),new O(t.status,`Unsupported MCP response content type: ${r??`missing`}`)}async close(){if(!this.closed){if(this.closed=!0,this.controller.abort(),this.started&&this.sessionIdValue){let e=new AbortController,t=setTimeout(()=>e.abort(),1e3);try{let{headers:t}=await this.headers();await this.fetch(this.url,{method:`DELETE`,headers:t,signal:e.signal}).then(P).catch(()=>void 0)}catch{}finally{clearTimeout(t)}}this.emitClose()}}async authorizedFetch(e,t){let n=this.options.authProvider?.onUnauthorized?.bind(this.options.authProvider);for(let r=0;;r++){let{headers:i,token:a}=await this.headers(t.headers),o=await this.fetch(this.url,{method:e,headers:i,body:t.body,signal:this.controller.signal});if(r>0||!n||!M(o))return o;try{await n({response:o,serverUrl:this.url,fetch:this.fetch,token:a})}finally{await P(o)}}}async headers(e={}){let t=new Headers(this.options.headers);for(let[n,r]of Object.entries(e))t.set(n,r);this.sessionIdValue&&t.set(`Mcp-Session-Id`,this.sessionIdValue),this.protocolVersion&&t.set(`MCP-Protocol-Version`,this.protocolVersion);let n=await this.options.authProvider?.token();return n&&t.set(`Authorization`,`Bearer ${n}`),{headers:t,...n?{token:n}:{}}}captureSession(e){let t=e.headers.get(`mcp-session-id`);t&&(this.sessionIdValue=t)}async checkResponse(e){if(e.ok)return;let t=(await e.text().catch(()=>``)).slice(0,8192);throw e.status===401?new k(e,t):e.status===404&&this.sessionIdValue?new A(t):new O(e.status,F(e.status,t),t)}async consumeSse(e,t,n){await D(e,{maxEventBytes:this.options.maxMessageBytes??16777216,onId:e=>{t.lastEventId=e},onRetry:e=>{t.retryMs=e},onEvent:e=>{if(t.received=!0,!e.data.trim()||e.event!==void 0&&e.event!==`message`)return;let r;try{r=d(JSON.parse(e.data))}catch(e){this.emitError(e);return}n?.(r),this.emitMessage(r)}})}async consumeResponseStream(t,n){let r={lastEventId:void 0,retryMs:void 0,received:!1},i=!1,a=e=>{u(e)&&e.id===n&&(i=!0)},s=t,c;for(let e=0;;){if(s)try{await this.consumeSse(s,r,a),c=void 0}catch(e){c=e}if(i||this.closed)return;if(c!==void 0&&!this.isRetryable(c)||r.lastEventId===void 0||e>=this.maxRetries())break;if(r.received&&(e=0),r.received=!1,!await this.sleep(this.reconnectDelay(e++,r.retryMs)))return;try{s=await this.openSseStream(r.lastEventId)}catch(e){if(c=e,!this.isRetryable(e))break;s=void 0}}if(this.closed)return;let l=c===void 0?`stream ended without a response`:o(c).message;this.emitMessage({jsonrpc:`2.0`,id:n,error:{code:e.internalError,message:`MCP response stream failed: ${l}`}})}startGetStream(){this.options.openGetStream===!1||this.getStreamStarted||this.closed||(this.getStreamStarted=!0,this.runGetStream())}async runGetStream(){let e={lastEventId:void 0,retryMs:void 0,received:!1};for(let t=0;!this.closed;){try{let n=await this.openSseStream(e.lastEventId);if(!n)return;let r=Date.now();await this.consumeSse(n,e),(e.received||Date.now()-r>this.maxDelay())&&(t=0)}catch(e){if(this.closed)return;if(!this.isRetryable(e)){this.emitError(e);return}}if(e.received=!1,t>=this.maxRetries()){this.emitError(Error(`MCP server-to-client stream dropped and could not be reopened`));return}if(!await this.sleep(this.reconnectDelay(t++,e.retryMs)))return}}async openSseStream(e){let t=await this.authorizedFetch(`GET`,{headers:{accept:`text/event-stream`,...e===void 0?{}:{"last-event-id":e}}});if(t.status===405){await P(t);return}await this.checkResponse(t),this.captureSession(t);let n=j(t);if(n!==`text/event-stream`||!t.body)throw await P(t),new O(t.status,`Unsupported MCP GET response content type: ${n??`missing`}`);return t.body}isRetryable(e){if(e instanceof O)return N(e.status);if(e instanceof TypeError)return!0;let t=e?.code;return typeof t==`string`&&(t.startsWith(`E`)||t.startsWith(`UND_ERR`))}reconnectDelay(e,t){if(t!==void 0)return t;let n=this.options.reconnect?.initialDelayMs??1e3;return Math.min(n*2**e,this.maxDelay())}maxDelay(){return this.options.reconnect?.maxDelayMs??3e4}maxRetries(){return this.options.reconnect?.maxRetries??5}sleep(e){let t=this.controller.signal;return t.aborted?Promise.resolve(!1):new Promise(n=>{let r=()=>{clearTimeout(i),n(!1)},i=setTimeout(()=>{t.removeEventListener(`abort`,r),n(!0)},e);i.unref?.(),t.addEventListener(`abort`,r,{once:!0})})}};export{T as McpClient,I as StreamableHttpTransport};
@@ -1 +1 @@
1
- import{n as e}from"./js-realm-worker-BP3b2BW6.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-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 +1 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import"./proxied-fetch-CoZ8jHud.js";import{t}from"./runtime-env-DadgceZk.js";import"./shared-D-ZRFYou.js";import{n}from"./hf-defaults-BwJdGLgk.js";import{installPackages as r}from"./installer-ZC2UV-cH.js";import{downloadHfRepo as i}from"./hf-download-CNg2vD63.js";e(`speech:espeak`);const a=[`ort-wasm-simd-threaded.jsep.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort-wasm-simd-threaded.jsep.wasm`,`ort-wasm-simd-threaded.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort.wasm`,`ort-wasm-simd-threaded.asyncify.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort-wasm-simd-threaded.asyncify.wasm`,`ort-wasm-simd-threaded.jspi.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort-wasm-simd-threaded.jspi.wasm`],o=e(`speech:ensure-assets`),s=`onnxruntime-web`,c=`${s}@1.31.0-dev.20260914-8d85527a0`,l=`espeak-ng`,u=[`espeak-ng.js`,`espeak-ng.wasm`],d=`/workspace`,f=t,p=a.filter(e=>!/\.(asyncify|jspi)\./.test(e));async function m(e){try{let t=await e.readFile(`/workspace/node_modules/onnxruntime-web/package.json`,{encoding:`utf-8`}),n=typeof t==`string`?t:new TextDecoder().decode(t),r=JSON.parse(n);if(r&&typeof r==`object`&&`version`in r&&typeof r.version==`string`)return r.version}catch{}return null}async function h(e,t){let n=await Promise.all(p.map(t=>e.fs.exists(`/workspace/node_modules/onnxruntime-web/dist/${t}`))),i=await m(e.fs);if(n.every(Boolean)&&i===`1.31.0-dev.20260914-8d85527a0`)return t?.({asset:s,phase:`present`}),!1;t?.({asset:s,phase:`staging`});let{errors:a}=await r([c],{fs:e.fs,fetch:e.fetch,cwd:d});if(a.length>0)throw Error(`failed to stage ${s} wasm runtime: ${a[0].error.message}`);return t?.({asset:s,phase:`done`}),!0}async function g(e,t){if((await Promise.all(u.map(t=>e.fs.exists(`/workspace/node_modules/espeak-ng/dist/${t}`)))).every(Boolean))return t?.({asset:l,phase:`present`}),!1;t?.({asset:l,phase:`staging`});let{errors:n}=await r([l],{fs:e.fs,fetch:e.fetch,cwd:d});if(n.length>0)throw Error(`failed to stage ${l} wasm: ${n[0].error.message}`);return t?.({asset:l,phase:`done`}),!0}async function _(e,t){try{return await g(e,t)}catch(e){return o.warn(`optional espeak-ng staging failed; non-English Kokoro voices may fall back`,e),!1}}async function v(e,t,r){let a=n(t,null,d),o=0,s=await i({fetch:e.fetch,fs:e.fs,repo:t,targetDir:a,progress:{onListed:({files:e,totalBytes:n})=>r?.({asset:t,phase:`listing`,filesLoaded:0,filesTotal:e.length,bytesLoaded:0,bytesTotal:n}),onFile:e=>{o+=e.bytes,r?.({asset:t,phase:e.status,file:e.file,filesLoaded:e.index,filesTotal:e.total,bytesLoaded:o})}}});return r?.({asset:t,phase:`done`,filesLoaded:s.files.length,filesTotal:s.files.length,bytesLoaded:o,bytesTotal:o}),{repo:t,downloaded:s.downloaded,skipped:s.skipped}}async function y(e,t){if(f())return{skipped:!0,ortStaged:!1,espeakStaged:!1,repos:[]};let n=await h(e,t),r=e.repos??[`onnx-community/whisper-tiny`,`onnx-community/Kokoro-82M-v1.0-ONNX`],i=[];for(let n of r)i.push(await v(e,n,t));let a=await _(e,t);return o.info(`speech assets staged`,{ortStaged:n,espeakStaged:a,repos:i.length}),{skipped:!1,ortStaged:n,espeakStaged:a,repos:i}}export{y as ensureSpeechAssetsStaged};
1
+ import{t as e}from"./logger-LESFN7Hj.js";import"./proxied-fetch-CoZ8jHud.js";import{t}from"./runtime-env-DadgceZk.js";import"./shared-D-ZRFYou.js";import{n}from"./hf-defaults-BwJdGLgk.js";import{installPackages as r}from"./installer-3ARo1i86.js";import{downloadHfRepo as i}from"./hf-download-CNg2vD63.js";e(`speech:espeak`);const a=[`ort-wasm-simd-threaded.jsep.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort-wasm-simd-threaded.jsep.wasm`,`ort-wasm-simd-threaded.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort.wasm`,`ort-wasm-simd-threaded.asyncify.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort-wasm-simd-threaded.asyncify.wasm`,`ort-wasm-simd-threaded.jspi.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort-wasm-simd-threaded.jspi.wasm`],o=e(`speech:ensure-assets`),s=`onnxruntime-web`,c=`${s}@1.31.0-dev.20260914-8d85527a0`,l=`espeak-ng`,u=[`espeak-ng.js`,`espeak-ng.wasm`],d=`/workspace`,f=t,p=a.filter(e=>!/\.(asyncify|jspi)\./.test(e));async function m(e){try{let t=await e.readFile(`/workspace/node_modules/onnxruntime-web/package.json`,{encoding:`utf-8`}),n=typeof t==`string`?t:new TextDecoder().decode(t),r=JSON.parse(n);if(r&&typeof r==`object`&&`version`in r&&typeof r.version==`string`)return r.version}catch{}return null}async function h(e,t){let n=await Promise.all(p.map(t=>e.fs.exists(`/workspace/node_modules/onnxruntime-web/dist/${t}`))),i=await m(e.fs);if(n.every(Boolean)&&i===`1.31.0-dev.20260914-8d85527a0`)return t?.({asset:s,phase:`present`}),!1;t?.({asset:s,phase:`staging`});let{errors:a}=await r([c],{fs:e.fs,fetch:e.fetch,cwd:d});if(a.length>0)throw Error(`failed to stage ${s} wasm runtime: ${a[0].error.message}`);return t?.({asset:s,phase:`done`}),!0}async function g(e,t){if((await Promise.all(u.map(t=>e.fs.exists(`/workspace/node_modules/espeak-ng/dist/${t}`)))).every(Boolean))return t?.({asset:l,phase:`present`}),!1;t?.({asset:l,phase:`staging`});let{errors:n}=await r([l],{fs:e.fs,fetch:e.fetch,cwd:d});if(n.length>0)throw Error(`failed to stage ${l} wasm: ${n[0].error.message}`);return t?.({asset:l,phase:`done`}),!0}async function _(e,t){try{return await g(e,t)}catch(e){return o.warn(`optional espeak-ng staging failed; non-English Kokoro voices may fall back`,e),!1}}async function v(e,t,r){let a=n(t,null,d),o=0,s=await i({fetch:e.fetch,fs:e.fs,repo:t,targetDir:a,progress:{onListed:({files:e,totalBytes:n})=>r?.({asset:t,phase:`listing`,filesLoaded:0,filesTotal:e.length,bytesLoaded:0,bytesTotal:n}),onFile:e=>{o+=e.bytes,r?.({asset:t,phase:e.status,file:e.file,filesLoaded:e.index,filesTotal:e.total,bytesLoaded:o})}}});return r?.({asset:t,phase:`done`,filesLoaded:s.files.length,filesTotal:s.files.length,bytesLoaded:o,bytesTotal:o}),{repo:t,downloaded:s.downloaded,skipped:s.skipped}}async function y(e,t){if(f())return{skipped:!0,ortStaged:!1,espeakStaged:!1,repos:[]};let n=await h(e,t),r=e.repos??[`onnx-community/whisper-tiny`,`onnx-community/Kokoro-82M-v1.0-ONNX`],i=[];for(let n of r)i.push(await v(e,n,t));let a=await _(e,t);return o.info(`speech assets staged`,{ortStaged:n,espeakStaged:a,repos:i.length}),{skipped:!1,ortStaged:n,espeakStaged:a,repos:i}}export{y as ensureSpeechAssetsStaged};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./slugify-BYJ6QVAt.js";import{n as t,r as n,t as r}from"./archive-redaction-ByV7X5fs.js";import{t as i}from"./types-D8gIX-W-.js";import{a,b as o,i as s}from"./kernel-worker-Dt0qVVA4.js";const c=/\uD83C\uDF99\uFE0F?/g,l=/\u25C1[\s\S]*?\u25B7/g;function u(e){return e.replace(l,``).replace(c,``).replace(/[ \t]+$/g,``).trimEnd()}function d(e){let t=``;for(let n of e){let e=n.role===`user`?`User`:`Assistant`,r=n.role===`user`?u(n.content):n.content;if(t+=`## ${e}\n${r}\n\n`,n.attachments?.length&&(t+=`Attachments:\n${n.attachments.map(e=>`- ${o(e)}`).join(`
1
+ import{t as e}from"./slugify-BYJ6QVAt.js";import{n as t,r as n,t as r}from"./archive-redaction-ByV7X5fs.js";import{t as i}from"./types-D8gIX-W-.js";import{a,b as o,i as s}from"./kernel-worker-CTxRZxWy.js";const c=/\uD83C\uDF99\uFE0F?/g,l=/\u25C1[\s\S]*?\u25B7/g;function u(e){return e.replace(l,``).replace(c,``).replace(/[ \t]+$/g,``).trimEnd()}function d(e){let t=``;for(let n of e){let e=n.role===`user`?`User`:`Assistant`,r=n.role===`user`?u(n.content):n.content;if(t+=`## ${e}\n${r}\n\n`,n.attachments?.length&&(t+=`Attachments:\n${n.attachments.map(e=>`- ${o(e)}`).join(`
2
2
  `)}\n\n`),n.toolCalls)for(let e of n.toolCalls)t+=`### Tool: ${e.name}\nInput: ${JSON.stringify(e.input,null,2)}\nResult: ${e.result??``}\n\n`}return t}function f(e){return`live-${h(e)}-${m()}.md`}function p(e,t){return e.find(e=>e.live===!0&&(e.cone??`cone`)===t)}function m(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`}function h(t){return e(t,{maxLen:48,fallback:`session`})}const g=`untitled-session`,_=RegExp(`^(?:_Forwarded from .+?\\._\\s*)*(?:\\[@\\S+ (?:completed|idle|sudo-request|FAILED)\\b|\\[scoop_wait\\b|\\[(?:${[`Webhook Event`,`Sprinkle Event`,`File Watch Event`,`Session Reload`,`Navigate Event`,`Upgrade Event`,`Cherry Event`,`Workflow Event`,`Background Command`,`jshd Unit`,`Cron Event`,`Scoop Access Request`,`Preview Event`,`Preview event`,`Discovery Event`].join(`|`)})\\b|Preview tab (?:connected|disconnected) from |<context-summary\\b)`);function v(e){return e.slice(0,480).trim().replace(/\s+/g,` `).slice(0,240)}function y(e){let t=v(e);return t.length>0&&_.test(t)}function b(e){return e===g||y(e)}function x(e){return e.role!==`user`||!e.content?.trim()||e.source===`lick`||e.channel?!1:!y(e.content)}function S(e){let t=e.find(x);if(!t?.content)return g;let n=t.content.trim().replace(/\s+/g,` `);return n.length>60?`${n.slice(0,60)}…`:n||g}function C(e){return e.map(e=>{let t={id:e.id,role:e.role,content:e.content,timestamp:e.timestamp};return e.attachments?.length&&(t.attachments=e.attachments),e.toolCalls?.length&&(t.toolCalls=e.toolCalls.map(e=>({id:e.id,name:e.name,input:e.input,...e.result===void 0?{}:{result:e.result},...e.isError?{isError:e.isError}:{}}))),e.source&&(t.source=e.source),e.channel&&(t.channel=e.channel),e.compaction&&(t.compaction=e.compaction),t})}function w(e){let i=r(),a={...e,title:t(e.title,i),messages:n(e.messages,i)},o=(a.cost?`cost: ${JSON.stringify(a.cost)}\n`:``)+(a.models?`models: ${JSON.stringify(a.models)}\n`:``),s=(a.cone?`cone: ${a.cone}\n`:``)+(a.coneLabel?`coneLabel: ${JSON.stringify(a.coneLabel)}\n`:``)+(a.memorySkipped?`memorySkipped: true
3
3
  `:``)+(a.live?`live: true
4
4
  `:``)+(a.live&&a.liveThrough?`liveThrough: ${a.liveThrough}\n`:``)+(a.live&&a.compactions?`compactions: ${a.compactions}\n`:``)+(a.curatedThrough?`curatedThrough: ${a.curatedThrough}\n`:``),c=`---\nid: ${a.id}\ntitle: ${JSON.stringify(a.title)}\nfrozenAt: ${a.frozenAt}\ncreatedAt: ${a.createdAt}\nupdatedAt: ${a.updatedAt}\nmessageCount: ${a.messageCount}\n`+o+s+`---