sliccy 6.192.0 → 6.194.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/dist/node-server/chrome-launch.js +34 -1
  2. package/dist/node-server/index.js +5 -0
  3. package/dist/ui/.vite/manifest.json +182 -182
  4. package/dist/ui/assets/{MEMORY-CbB3xjAS.js → MEMORY-B9cGngY_.js} +6 -1
  5. package/dist/ui/assets/{SKILL-Be-LbAuP.js → SKILL-CVh4bFFa.js} +1 -1
  6. package/dist/ui/assets/{SKILL-BS0BC3cr.js → SKILL-Cw2kRKxn.js} +1 -1
  7. package/dist/ui/assets/__vite-browser-external-B1OEZP2E.js +1 -0
  8. package/dist/ui/assets/{account-store-irTFXEHq.js → account-store-BXYHDz7I.js} +1 -1
  9. package/dist/ui/assets/{account-store-Bevys7WL.js → account-store-BhuOj34h.js} +1 -1
  10. package/dist/ui/assets/adobe-BKLMep8P.js +1 -0
  11. package/dist/ui/assets/{adobe-CxPY_Nvf.js → adobe-CBBpnzT4.js} +1 -1
  12. package/dist/ui/assets/{agent-panels-CDAHwcGe.js → agent-panels-CrgtFVcl.js} +1 -1
  13. package/dist/ui/assets/{almost-bash-shell-headless-B6lKPYip.js → almost-bash-shell-headless-DXCEh8lZ.js} +127 -118
  14. package/dist/ui/assets/{apply-layout-BaPTlEmq.js → apply-layout-CfSICNpb.js} +1 -1
  15. package/dist/ui/assets/{apps-CWLDElDt.js → apps-Dn8bdiE-.js} +1 -1
  16. package/dist/ui/assets/{azure-openai-CAmcCxYK.js → azure-openai-CLYg_oCA.js} +1 -1
  17. package/dist/ui/assets/{azure-openai-BrEMU1w0.js → azure-openai-Z_9cPmbO.js} +1 -1
  18. package/dist/ui/assets/{backend-hostfs-DVOOQmWO.js → backend-hostfs-BPb6-Z5K.js} +1 -1
  19. package/dist/ui/assets/{browser-DL3zbJrM.js → browser-Don7GC1D.js} +16 -16
  20. package/dist/ui/assets/{cdp-l5Vq6Mtp.js → cdp-BRdLVPgS.js} +1 -1
  21. package/dist/ui/assets/{cerebras-COJ_qkGu.js → cerebras-BNEmz246.js} +1 -1
  22. package/dist/ui/assets/{cerebras-DyJkWRm7.js → cerebras-DOoJyJpN.js} +1 -1
  23. package/dist/ui/assets/{composer-speech-CYdWOXqF.js → composer-speech-CCjkg2so.js} +1 -1
  24. package/dist/ui/assets/{connect-surface-DnaS1qCD.js → connect-surface-Dqe5caD5.js} +1 -1
  25. package/dist/ui/assets/{cost-command-DC0JwdLM.js → cost-command-MXw_GKzX.js} +1 -1
  26. package/dist/ui/assets/{directed-approval-Bo1zb-ki.js → directed-approval-NSkVv-Fd.js} +1 -1
  27. package/dist/ui/assets/{emscripten-vfs-hook-DORb16y9.js → emscripten-vfs-hook-C4S7Ne6O.js} +1 -1
  28. package/dist/ui/assets/{emscripten-vfs-hook-jxmK_i72.js → emscripten-vfs-hook-D6VTI_oH.js} +1 -1
  29. package/dist/ui/assets/{ensure-speech-assets-DXQUrOok.js → ensure-speech-assets-BpEm05QN.js} +1 -1
  30. package/dist/ui/assets/{frozen-archive-writer-C_qn0GDJ.js → frozen-archive-writer-De947cIb.js} +2 -2
  31. package/dist/ui/assets/fs-DL0b9F_-.js +1 -0
  32. package/dist/ui/assets/fs-Dh8MY_Wd.js +2 -0
  33. package/dist/ui/assets/{gelatiere-store-D0SzDyoX.js → gelatiere-store-BbjUkbo_.js} +1 -1
  34. package/dist/ui/assets/{gelatiere-unit-D0eC3q8k.js → gelatiere-unit-Cu5Ve5lc.js} +1 -1
  35. package/dist/ui/assets/{github-DrXxnqrr.js → github-B3d5dLZ9.js} +2 -2
  36. package/dist/ui/assets/{github-CMMdXD7-.js → github-CtSwA9HD.js} +1 -1
  37. package/dist/ui/assets/{github-auth-CVs8hOEW.js → github-auth-nna4SRhq.js} +1 -1
  38. package/dist/ui/assets/{github-copilot-BDW-hvGU.js → github-copilot-C9O2zDZQ.js} +1 -1
  39. package/dist/ui/assets/{github-copilot-F_OWE6ig.js → github-copilot-DElYrz_r.js} +1 -1
  40. package/dist/ui/assets/{github-install-B-rr32FO.js → github-install-DhvV5fCp.js} +1 -1
  41. package/dist/ui/assets/{github-zip-DA_-VtNu.js → github-zip-x1UTu8IO.js} +1 -1
  42. package/dist/ui/assets/{hear-B1QjKHJS.js → hear-DtNqux_Y.js} +1 -1
  43. package/dist/ui/assets/{help-C3q6Ha5a.js → help-D-QlFQmC.js} +1 -1
  44. package/dist/ui/assets/{host-command-DTM6_CU_.js → host-command-D8TK1jxM.js} +1 -1
  45. package/dist/ui/assets/installer-Dhz3Owz-.js +2 -0
  46. package/dist/ui/assets/ipk-mamba-CUnjP67u.js +46 -0
  47. package/dist/ui/assets/{js-realm-worker-CIzPgKVU.js → js-realm-worker-sPOjFVHS.js} +14 -14
  48. package/dist/ui/assets/{jsh-executor-8n8-NVRR.js → jsh-executor-CoKR7gN9.js} +2 -2
  49. package/dist/ui/assets/{kernel-worker-YhNfUQ_y.js → kernel-worker-CHzmxrpV.js} +62 -58
  50. package/dist/ui/assets/{lick-ws-bridge-CDPuY-EA.js → lick-ws-bridge-BsQ1X7Gv.js} +1 -1
  51. package/dist/ui/assets/{lick-ws-bridge-BWmnM4i8.js → lick-ws-bridge-xRxU6SK3.js} +1 -1
  52. package/dist/ui/assets/live-session-curation-Cha2lYS7.js +1 -0
  53. package/dist/ui/assets/{live-session-snapshot-CAY9GlTD.js → live-session-snapshot-CZJQ__3Q.js} +1 -1
  54. package/dist/ui/assets/{live-vfs-fs-CX95TogC.js → live-vfs-fs-ENqkL-HX.js} +1 -1
  55. package/dist/ui/assets/{local-llm-dPetWUMs.js → local-llm-DNAXIB_B.js} +1 -1
  56. package/dist/ui/assets/{local-llm-CsIWLXJ2.js → local-llm-wEVxgKOR.js} +1 -1
  57. package/dist/ui/assets/{main-DUD5pTDH.js → main-CQgxn2CU.js} +3 -3
  58. package/dist/ui/assets/{main-cherry-BoO4BB-J.js → main-cherry-D0lNqvOn.js} +1 -1
  59. package/dist/ui/assets/memory-budget-CFfevxz_.js +1 -0
  60. package/dist/ui/assets/{memory-curation-seam-DFftwyHh.js → memory-curation-seam-CghvLuyc.js} +1 -1
  61. package/dist/ui/assets/{memory-health-DF6IEFmt.js → memory-health-Cxnw8CcI.js} +1 -1
  62. package/dist/ui/assets/memory-write-execute-B10MC9sT.js +1 -0
  63. package/dist/ui/assets/{mount-BfPgf0TT.js → mount-BFGGx3qi.js} +1 -1
  64. package/dist/ui/assets/{mount-BsWbgqHU.js → mount-CvZYWzgG.js} +3 -3
  65. package/dist/ui/assets/{new-session-n4ieWj9Q.js → new-session-BJA8ALF3.js} +2 -2
  66. package/dist/ui/assets/{oauth-bootstrap-DEjPbx0S.js → oauth-bootstrap-BPefmaHj.js} +2 -2
  67. package/dist/ui/assets/{onboarding-orchestrator-DTq_WzOT.js → onboarding-orchestrator-BGJvwTUy.js} +1 -1
  68. package/dist/ui/assets/{openai-codex-CRBPHYXu.js → openai-codex-BkqN9RGO.js} +1 -1
  69. package/dist/ui/assets/{openai-codex-CZFJxrdp.js → openai-codex-DDa9hYco.js} +1 -1
  70. package/dist/ui/assets/{openrouter-xrK_Q7tb.js → openrouter-C0rJtc8a.js} +1 -1
  71. package/dist/ui/assets/{openrouter-Bp2hCSj0.js → openrouter-aE8Gelud.js} +1 -1
  72. package/dist/ui/assets/{openrouter-free-Ciud-jQF.js → openrouter-free-BI9Zi6E8.js} +1 -1
  73. package/dist/ui/assets/{openrouter-free-B1aHr6YX.js → openrouter-free-UOnTJnT1.js} +1 -1
  74. package/dist/ui/assets/{openrouter-oauth-BShl7mda.js → openrouter-oauth-Bhq6v2wd.js} +1 -1
  75. package/dist/ui/assets/{openrouter-oauth-CBNfp9B7.js → openrouter-oauth-COugH3to.js} +1 -1
  76. package/dist/ui/assets/{opfs-mount-DF1_TQm7.js → opfs-mount-CZ4fU_jU.js} +1 -1
  77. package/dist/ui/assets/{panel-rpc-handlers-DYotibPR.js → panel-rpc-handlers-UolvhMRT.js} +2 -2
  78. package/dist/ui/assets/{panelize-shell-5hKkbwSl.js → panelize-shell-AXsIZkXt.js} +1 -1
  79. package/dist/ui/assets/{pi-edit-execution-CcLt8vSI.js → pi-edit-execution-CJGQfIES.js} +1 -1
  80. package/dist/ui/assets/{provider-DqEfigmv.js → provider-Cqq8Bumu.js} +1 -1
  81. package/dist/ui/assets/{provider-BLshPMsZ.js → provider-DBdUcz51.js} +2 -2
  82. package/dist/ui/assets/{provider-settings-BuaTQYid.js → provider-settings-DSL52817.js} +1 -1
  83. package/dist/ui/assets/provider-store-access-Ce2FjCaD.js +1 -0
  84. package/dist/ui/assets/provider-store-access-W_ySqvIE.js +1 -0
  85. package/dist/ui/assets/{providers-B3cOXz1H.js → providers-BcK4GJL5.js} +1 -1
  86. package/dist/ui/assets/{providers-CE4VqQs6.js → providers-DJQSfaao.js} +2 -2
  87. package/dist/ui/assets/{py-live-vfs-CUJmBBlI.js → py-live-vfs-DPS322qc.js} +1 -1
  88. package/dist/ui/assets/{py-live-vfs-9-2YNjh0.js → py-live-vfs-DpjNVlus.js} +2 -2
  89. package/dist/ui/assets/{py-realm-worker-DtGB9J_v.js → py-realm-worker-X3kfo5jQ.js} +8 -4
  90. package/dist/ui/assets/{pyodide-D9Uqa092.js → pyodide-BU9HqIRG.js} +2 -2
  91. package/dist/ui/assets/{quick-llm-D1wGZooG.js → quick-llm-DAQCbwDK.js} +1 -1
  92. package/dist/ui/assets/{realm-inprocess-Dcn5yLm3.js → realm-inprocess-DXoHeSno.js} +11 -11
  93. package/dist/ui/assets/{realm-unhandled-rejections-BU76F0PI.js → realm-unhandled-rejections-9ZaP6anw.js} +1 -1
  94. package/dist/ui/assets/{realm-unhandled-rejections-BXxVemlU.js → realm-unhandled-rejections-BFWoSwto.js} +1 -1
  95. package/dist/ui/assets/{recovery-screen-D6HBp0xj.js → recovery-screen-D_CUmLAw.js} +1 -1
  96. package/dist/ui/assets/{remote-terminal-view-BDO5t9M_.js → remote-terminal-view-B9fhgQl_.js} +2 -2
  97. package/dist/ui/assets/{require-guards-e8NvgvH_.js → require-guards-Dfl5uogi.js} +12 -8
  98. package/dist/ui/assets/{restore-CdH_ze1C.js → restore-iUKZhthp.js} +1 -1
  99. package/dist/ui/assets/{run-CkKb9UWF.js → run-AUgWiGZj.js} +2 -2
  100. package/dist/ui/assets/{run-DsYsM6Yl.js → run-BdurKezv.js} +1 -1
  101. package/dist/ui/assets/{run-DNvbqTbo.js → run-Bksq7Mcn.js} +1 -1
  102. package/dist/ui/assets/{run-xrVX3llR.js → run-BxNz22KR.js} +1 -1
  103. package/dist/ui/assets/{run-B4snw1GL.js → run-DId6fTuG.js} +2 -2
  104. package/dist/ui/assets/{run-C_6GKpBV.js → run-DaUWBY-8.js} +6 -5
  105. package/dist/ui/assets/{run-CK7bQLZ0.js → run-DthMAupa.js} +2 -2
  106. package/dist/ui/assets/{run-D2pF2y1_.js → run-Du61Yu3x.js} +1 -1
  107. package/dist/ui/assets/{run-fHfrubKD.js → run-MoNABXzI.js} +1 -1
  108. package/dist/ui/assets/{session-command-memory-CGqbKVAE.js → session-command-memory-BkQWVyeK.js} +2 -2
  109. package/dist/ui/assets/{session-jsonl-CbNA3lGB.js → session-jsonl-BoQQPjW4.js} +1 -1
  110. package/dist/ui/assets/{session-jsonl-CgKvYDUr.js → session-jsonl-C43GQbZ5.js} +1 -1
  111. package/dist/ui/assets/{session-search-index-CKHuYyZd.js → session-search-index-DX8uuwKQ.js} +2 -2
  112. package/dist/ui/assets/{setup-feature-flags-remote-DU_3gSCe.js → setup-feature-flags-remote-DwVpaudL.js} +1 -1
  113. package/dist/ui/assets/{setup-model-catalog-CQmIQSJ6.js → setup-model-catalog-BwJuea_h.js} +1 -1
  114. package/dist/ui/assets/{signed-fetch-DEi8arT4.js → signed-fetch-BWgKPq0A.js} +1 -1
  115. package/dist/ui/assets/{silent-renew-backoff-UU1St8tN.js → silent-renew-backoff-BwuzA7to.js} +1 -1
  116. package/dist/ui/assets/slicc-version-a1X0pv8Y.js +1 -0
  117. package/dist/ui/assets/{snapshot-BPuldVwP.js → snapshot-DgEGAH-2.js} +1 -1
  118. package/dist/ui/assets/{snapshot-features-Ddz9jsBd.js → snapshot-features-DXhxdPKC.js} +1 -1
  119. package/dist/ui/assets/{soundscape-Uopjnq2I.js → soundscape-BSWPPOWX.js} +1 -1
  120. package/dist/ui/assets/{speak-D_PLnidz.js → speak-XvWzti3F.js} +1 -1
  121. package/dist/ui/assets/{sprinkle-manager-BpNh9Lri.js → sprinkle-manager-CjFH3gP5.js} +1 -1
  122. package/dist/ui/assets/{sprinkle-renderer-BljwWT0g.js → sprinkle-renderer-DQyEs5j7.js} +1 -1
  123. package/dist/ui/assets/{ssh-DBPFvqmL.js → ssh-B58quV88.js} +1 -1
  124. package/dist/ui/assets/{state-CHrSe9Ro.js → state-CoDzWbhR.js} +1 -1
  125. package/dist/ui/assets/{store-BikzV66S.js → store-Cm5EQ4O4.js} +1 -1
  126. package/dist/ui/assets/{store-BvFCmAq8.js → store-D6WHUpLa.js} +1 -1
  127. package/dist/ui/assets/{sudo-rquT1VWH.js → sudo-CdFE3IfZ.js} +1 -1
  128. package/dist/ui/assets/{sudo-fs-C6r_MIIY.js → sudo-fs-CQphjEUf.js} +1 -1
  129. package/dist/ui/assets/{supervisor-MXcG8SU6.js → supervisor-rM2Zl5bV.js} +1 -1
  130. package/dist/ui/assets/{sync-dialog-zmsfROKR.js → sync-dialog-DFruUmGh.js} +1 -1
  131. package/dist/ui/assets/tar-BWIPCxI2.js +3 -0
  132. package/dist/ui/assets/{transformers-env-DVU2J7Xd.js → transformers-env-2O4pHxNZ.js} +1 -1
  133. package/dist/ui/assets/{tray-leader-5xt9j15D.js → tray-leader-ePMr4piD.js} +1 -1
  134. package/dist/ui/assets/{tray-leave-runtime-B5LmQl4b.js → tray-leave-runtime-EqUc8UAf.js} +1 -1
  135. package/dist/ui/assets/{tray-sidecar-pljn-63X.js → tray-sidecar-CyltHEIG.js} +1 -1
  136. package/dist/ui/assets/{upgrade-detection-Ta4nIJJR.js → upgrade-detection-9SSKMS4G.js} +1 -1
  137. package/dist/ui/assets/{upskill-lick-skip-IyN1i0IF.js → upskill-lick-skip-DVLmRDSR.js} +1 -1
  138. package/dist/ui/assets/{voice-reply-aiuvZ8F3.js → voice-reply-sUx77J2j.js} +1 -1
  139. package/dist/ui/assets/{wc-attach-C1CTfWQ-.js → wc-attach-CsNgELS_.js} +2 -2
  140. package/dist/ui/assets/{wc-browser-RbezSPht.js → wc-browser-CzWjToXy.js} +1 -1
  141. package/dist/ui/assets/{wc-computers-D4IEEM5M.js → wc-computers-B_vrGzdV.js} +1 -1
  142. package/dist/ui/assets/{wc-detached-CrVlYV_z.js → wc-detached-B9O51Lap.js} +1 -1
  143. package/dist/ui/assets/{wc-extension-BW5y8hdg.js → wc-extension-DcszxjTf.js} +2 -2
  144. package/dist/ui/assets/{wc-follower-xchSJ13T.js → wc-follower-BN5julvf.js} +3 -3
  145. package/dist/ui/assets/wc-follower-oauth-BC4mY45T.js +5 -0
  146. package/dist/ui/assets/{wc-gelatiere-CxGkXDNo.js → wc-gelatiere-DhTA5HEQ.js} +1 -1
  147. package/dist/ui/assets/{wc-live-DdOUCb1z.js → wc-live-BhgelPi7.js} +11 -6
  148. package/dist/ui/assets/{wc-nav-C-cqoNl9.js → wc-nav-Dcfnd67_.js} +2 -2
  149. package/dist/ui/assets/{wc-onboarding-CId-wqvG.js → wc-onboarding-C_jYcbG_.js} +2 -2
  150. package/dist/ui/assets/{wc-permissions-lj9xrdU-.js → wc-permissions-CYy0S7d_.js} +2 -2
  151. package/dist/ui/assets/{wc-placeholder-bs83QBxc.js → wc-placeholder-CxhBi035.js} +3 -3
  152. package/dist/ui/assets/{wc-secret-request-BmVSG3Qe.js → wc-secret-request-CnAAiTJB.js} +1 -1
  153. package/dist/ui/assets/{wc-settings-CE5aZbkW.js → wc-settings-CRKkITUJ.js} +3 -3
  154. package/dist/ui/assets/{wc-shell-DdSbkIp-.js → wc-shell-DN3sV_dL.js} +5 -5
  155. package/dist/ui/assets/{wc-shortcut-config-C2d66GP8.js → wc-shortcut-config-DMkPbydL.js} +1 -1
  156. package/dist/ui/assets/{wc-sprinkles-ak7XBDCk.js → wc-sprinkles-BSIa_XZX.js} +2 -2
  157. package/dist/ui/assets/{wc-transcript-export-DYVbwupj.js → wc-transcript-export-DdqtWQ_J.js} +2 -2
  158. package/dist/ui/assets/{wc-tray-CjkC7SwM.js → wc-tray-BsGmwlJr.js} +4 -4
  159. package/dist/ui/assets/welcome-detection-Dbvl8pQN.js +1 -0
  160. package/dist/ui/assets/{whisper-session-DBea3Pzc.js → whisper-session-DFZJg6oK.js} +2 -2
  161. package/dist/ui/assets/{xai-grok-B-WV19uN.js → xai-grok-CJDtaM4x.js} +1 -1
  162. package/dist/ui/assets/{xai-grok-CAPZiieq.js → xai-grok-y0l8lrYJ.js} +1 -1
  163. package/dist/ui/index.html +3 -3
  164. package/dist/ui/packages/webapp/index.html +3 -3
  165. package/package.json +1 -1
  166. package/dist/ui/assets/__vite-browser-external-CnFJWAkm.js +0 -1
  167. package/dist/ui/assets/adobe-C2Yk0FjU.js +0 -1
  168. package/dist/ui/assets/fs-D5UZBrBX.js +0 -1
  169. package/dist/ui/assets/fs-DouF0VP9.js +0 -2
  170. package/dist/ui/assets/installer-BamTBGiN.js +0 -4
  171. package/dist/ui/assets/live-session-curation-eGH4uyM1.js +0 -1
  172. package/dist/ui/assets/memory-budget-Bcf7Eolo.js +0 -1
  173. package/dist/ui/assets/memory-write-execute-C7SUGCPF.js +0 -1
  174. package/dist/ui/assets/provider-store-access-BABW1Cfu.js +0 -1
  175. package/dist/ui/assets/provider-store-access-C2xFS3NU.js +0 -1
  176. package/dist/ui/assets/slicc-version-D8Zbv4vp.js +0 -1
  177. package/dist/ui/assets/wc-follower-oauth-BArMqE7c.js +0 -5
  178. package/dist/ui/assets/welcome-detection-BAQGL8Ld.js +0 -1
@@ -1,4 +1,4 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import{r as t,t as n}from"./base64-BPBW1Gzr.js";import{n as r}from"./bridge-protocol-31SWTdS5.js";import{a as i,n as a,o,s,t as c}from"./handoff-link-B3It6xQY.js";import{d as l,f as u,i as d,u as f}from"./account-store-irTFXEHq.js";import{n as p,o as m,r as h,s as g,u as _}from"./proxied-fetch-DXaTHROw.js";import{t as v}from"./runtime-env-DadgceZk.js";import{t as ee}from"./slugify-BYJ6QVAt.js";import{n as te,t as ne}from"./host-command-DTM6_CU_.js";import{a as re,i as ie,n as ae,r as oe,t as se}from"./snapshot-BPuldVwP.js";import{i as ce,r as y}from"./panel-rpc-DW7W4w6_.js";import{t as le}from"./providers-B3cOXz1H.js";import{r as ue}from"./binary-cache-bSOhqXB1.js";import{i as de,n as fe,r as pe}from"./fetch-body-CuwTaJC_.js";import{s as me,t as he}from"./api-endpoint-D8lUKmPu.js";import{t as ge}from"./compat-uEPf6-XW.js";import{a as _e,i as ve}from"./core-PJsXG3mm.js";import{n as ye,t as be}from"./mime-types-D7IV6i7k.js";import{t as xe}from"./secrets-bridge-client-BiJrSKN9.js";import{a as Se,i as Ce,n as we,r as Te}from"./tool-ui-DRnUkp2g.js";import{a as Ee,i as De,n as b,t as x}from"./path-utils-DNJG-zQf.js";import{n as Oe,r as ke,t as Ae}from"./merge-file-core-VJlzucJY.js";import{r as je}from"./workspace-mode-D0kUKBVS.js";import{n as Me,t as Ne}from"./thinking-level-5x0UAu9N.js";import{n as Pe,t as Fe}from"./types-D8gIX-W-.js";import{i as Ie}from"./mount-index-CQfmUPuZ.js";import{a as Le,i as Re,n as ze,o as Be,s as Ve,t as He}from"./signed-fetch-DEi8arT4.js";import{o as Ue}from"./mount-table-store-DrF_Ifaz.js";import{t as We}from"./remote-cache-BE5T1-53.js";import{n as Ge}from"./fs-D5UZBrBX.js";import{a as Ke}from"./tray-leader-status-CpkFr6n7.js";import{n as qe,t as Je}from"./slicc-version-D8Zbv4vp.js";import{a as Ye,i as Xe,o as Ze,r as S,t as Qe}from"./browser-DL3zbJrM.js";import{t as C}from"./subcommand-flags-BZi7j78Q.js";import{n as $e,r as et,t as w}from"./subcommand-help-CgO7wRS5.js";import{n as tt}from"./cost-command-DC0JwdLM.js";import{d as nt,g as rt,i as it,n as at,o as ot}from"./sudoers-BdBYQPUn.js";import{n as st,r as ct,t as lt}from"./approval-timeout-BQ29Z0gf.js";import{a as ut,c as dt,i as ft,l as pt,n as mt,o as ht,r as gt,t as _t}from"./types-BfwydWt7.js";import{n as T,t as vt}from"./boundary-Cp9c_bPu.js";import"./rest-paths-Dia19u9P.js";import{t as yt}from"./html-B_Hg2WOy.js";import{n as bt}from"./llm-session-id-BZyXP_j2.js";import{t as xt}from"./src-CUSndb9K.js";import{i as St,o as Ct}from"./browser-DuyhpHbR.js";import{i as wt,r as Tt,t as Et}from"./mount-picker-popup-BMils9JY.js";import{t as Dt}from"./buffer-B5d1xHaH.js";import"./buffer-polyfill-BwLbCySD.js";import{A as Ot,B as E,C as kt,D,E as At,F as jt,G as Mt,H as O,I as k,J as Nt,K as Pt,L as Ft,M as It,N as Lt,O as Rt,P as zt,R as Bt,S as Vt,T as Ht,U as Ut,V as Wt,W as Gt,Y as Kt,_ as qt,a as Jt,b as Yt,c as Xt,d as Zt,f as Qt,g as $t,h as en,i as tn,j as nn,k as rn,l as an,m as on,n as sn,o as cn,p as A,q as ln,r as un,s as dn,t as fn,u as pn,v as mn,w as hn,x as gn,y as _n,z as vn}from"./isomorphic-git-r9mnHMnp.js";import"./global-db-DJXlpNui.js";import{S as yn,_ as bn,a as xn,b as Sn,c as Cn,d as wn,f as Tn,g as En,h as Dn,i as On,l as kn,n as An,o as jn,p as Mn,r as Nn,s as Pn,t as Fn,u as In,v as j,x as M,y as Ln}from"./state-CHrSe9Ro.js";import{a as Rn,i as zn,r as Bn,t as Vn}from"./git-config-Bdgu8kD2.js";import{a as Hn,n as Un,o as Wn,r as Gn,s as Kn}from"./jsh-discovery-CnvNKojr.js";import{A as qn,C as Jn,a as Yn,b as Xn,c as Zn,d as Qn,f as $n,h as er,i as tr,j as nr,l as rr,m as ir,n as ar,o as or,p as sr,r as cr,s as lr,t as N,u as ur,v as dr,y as fr}from"./shared-2XhBobrM.js";import{_ as pr,a as mr,b as hr,d as gr,f as _r,g as vr,h as yr,i as br,l as xr,m as Sr,p as Cr,r as wr,s as Tr,u as Er,v as Dr,x as Or,y as kr}from"./require-guards-e8NvgvH_.js";import{_ as Ar,a as jr,b as Mr,c as Nr,d as Pr,f as Fr,g as Ir,h as Lr,l as Rr,m as zr,n as Br,p as Vr,s as Hr,t as Ur,u as Wr,v as Gr,x as Kr,y as qr}from"./jsh-executor-8n8-NVRR.js";import{n as Jr,t as Yr}from"./esbuild-wasm-CbTVjIj0.js";import{n as Xr}from"./wasm-compiler-Ct7QZURL.js";import{a as Zr,o as Qr,s as $r,t as ei}from"./usb-device-registry-DFzxaOky.js";import{a as P,i as ti,r as ni,t as ri}from"./just-bash-compat-B-SPHuh_.js";import{i as ii,r as ai,t as oi}from"./script-catalog-DZtOMxvi.js";import{a as si,c as ci,o as li,s as ui,t as di}from"./types-Dzr0qYl3.js";import{a as fi,c as pi,d as mi,f as hi,n as gi,r as _i,u as vi}from"./github-zip-DA_-VtNu.js";import{i as yi,t as bi}from"./github-auth-CVs8hOEW.js";import{a as xi,i as Si,o as Ci,r as wi,t as Ti}from"./provenance-DdmsQ3Nr.js";import{a as Ei,c as Di,i as Oi,n as ki,o as Ai,r as ji,s as Mi}from"./github-install-B-rr32FO.js";import{n as Ni,t as Pi}from"./magick-wasm-BATj-KUu.js";import{i as Fi,n as Ii,r as Li,t as Ri}from"./pdf-raster-BWk6ezTX.js";import{n as zi}from"./lick-target-env-8JxfVcIV.js";import{t as Bi}from"./tmpdir-env-ate4iNcK.js";import{n as Vi,t as Hi}from"./hf-defaults-BwJdGLgk.js";import{a as Ui,c as Wi,i as Gi,l as Ki,n as qi,o as Ji,r as Yi,s as Xi,t as Zi,u as Qi}from"./installer-BamTBGiN.js";import{t as $i}from"./ffmpeg-wasm-CmLVzRDe.js";import{t as ea}from"./local-llm-dPetWUMs.js";import{t as ta}from"./client-CwxmlQM-.js";import{t as na}from"./redirect-uri-CBCnYKsl.js";import{a as ra,c as ia,i as aa,o as oa,r as sa,s as ca}from"./v86-vm-DCm7zA2r.js";import{n as la,r as ua}from"./lick-urls-CgPiVwD-.js";let da=null;function fa(e){da=e!==null&&Number.isFinite(e)&&e>0?e:null}function pa(){if(da!==null)return da;let e=globalThis.performance?.timeOrigin;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:Date.now()}new URL(r).hostname;const ma=/^([0-9a-f]{32})--(?:[0-9a-f]{8}-)?([0-9a-f]+)$/i;function ha(e){let t;try{t=new URL(e.includes(`://`)?e:`https://${e}`).hostname}catch{return null}let n=ma.exec(t.split(`.`)[0]??``);if(!n||!t.includes(`.`))return null;let r=n[1].toLowerCase();return`${[r.slice(0,8),r.slice(8,12),r.slice(12,16),r.slice(16,20),r.slice(20)].join(`-`)}.${n[2].toLowerCase()}`}[`ghp_`,`gho_`,`ghu_`,`ghs_`,`ghr_`,`github_pat_`,`sk-`,`pk-`,`xoxb-`,`xoxp-`,`xoxa-`,`xoxs-`,`AKIA`,`ABIA`,`ACCA`,`ASIA`,`sk-ant-`,`Bearer `].sort((e,t)=>t.length-e.length);function ga(e,t){let n=e.toLowerCase(),r=t.toLowerCase();if(n===`*`)return!0;if(!n.startsWith(`*.`))return n===r;let i=n.slice(1);return r.length>i.length&&r.endsWith(i)}function _a(e,t){return e.some(e=>ga(e,t))}const va=`slicc-transcript`,ya=[`canonical-agent-history-unavailable`,`tool-data-may-be-truncated`,`model-metadata-unavailable`,`scoop-history-unavailable`,`attachment-file-missing`,`attachment-association-unavailable`,`complete-snapshot-unavailable`],ba=new Set(`/export/format./export/producer/application./session/id./session/state./session/completeness/status./session/completeness/missing/*./conversations/*/id./conversations/*/kind./conversations/*/parentConversationId./conversations/*/messages/*/id./conversations/*/messages/*/role./conversations/*/messages/*/timestamp./conversations/*/messages/*/toolCallId./conversations/*/messages/*/content/*/type./conversations/*/messages/*/content/*/id./conversations/*/messages/*/content/*/name./conversations/*/messages/*/content/*/attachmentId./delegations/*/sourceConversationId./delegations/*/targetConversationId./delegations/*/toolCallId./attachments/*/id./attachments/*/path./attachments/*/sha256./attachments/*/sourceConversationId./attachments/*/sourceMessageId./attachments/*/handling./attachments/*/missingReason`.split(`.`));function xa(e){return ba.has(e.replace(/\/\d+(?=\/|$)/g,`/*`))}var Sa=class extends Error{code;detail;constructor(e,t){super(t?`${e}: ${t}`:e),this.code=e,this.detail=t,this.name=`TranscriptExportError`}};const Ca=new Set(ya),wa=/^[0-9a-fA-F]{64}$/,Ta=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/;function F(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ea(e){return typeof e==`string`&&wa.test(e)}function Da(e){return Ta.test(e)&&Number.isFinite(Date.parse(e))}function Oa(e,t){let n=t.map(e=>`"${e}"`),r=n[n.length-1];return n.length===2?`${e} must be ${n[0]} or ${r}`:`${e} must be ${n.slice(0,-1).join(`, `)}, or ${r}`}function ka(e,t,n){return typeof e!=`string`||!t.includes(e)?{ok:!1,error:Oa(n,t)}:{ok:!0}}function Aa(e,t,n){for(let r=0;r<e.length;r++){let i=t(e[r],`${n}[${r}]`);if(!i.ok)return i}return{ok:!0}}function ja(e,t){let n=e.type;if(n===`text`){if(typeof e.text!=`string`)return{ok:!1,error:`${t}.text must be a string`}}else if(n===`tool-call`){if(typeof e.id!=`string`||e.id===``)return{ok:!1,error:`${t}.id must be a non-empty string`};if(typeof e.name!=`string`||e.name===``)return{ok:!1,error:`${t}.name must be a non-empty string`};if(!(`input`in e))return{ok:!1,error:`${t}.input must be present`}}else if(typeof e.attachmentId!=`string`||e.attachmentId===``)return{ok:!1,error:`${t}.attachmentId must be a non-empty string`};return{ok:!0}}function Ma(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};let n=ka(e.type,[`text`,`tool-call`,`attachment-ref`],`${t}.type`);return n.ok?ja(e,t):n}function Na(e,t){for(let n of[`input`,`output`,`cacheRead`,`cacheWrite`,`totalTokens`]){let r=e[n];if(typeof r!=`number`)return{ok:!1,error:`${t}.${n} must be a number`};if(!Number.isInteger(r)||r<0)return{ok:!1,error:`${t}.${n} must be a non-negative integer`}}return{ok:!0}}function Pa(e,t){for(let n of[`input`,`output`,`cacheRead`,`cacheWrite`,`total`]){let r=e[n];if(typeof r!=`number`)return{ok:!1,error:`${t}.${n} must be a number`};if(!Number.isFinite(r)||r<0)return{ok:!1,error:`${t}.${n} must be a finite non-negative number`}}return{ok:!0}}function Fa(e,t){let n=Na(e,t);if(!n.ok)return n;let r=e.cost;return F(r)?Pa(r,`${t}.cost`):{ok:!1,error:`${t}.cost must be a non-null object`}}function Ia(e,t){if(typeof e.id!=`string`)return{ok:!1,error:`${t}.id must be a string`};if(typeof e.sequence!=`number`)return{ok:!1,error:`${t}.sequence must be a number`};let n=e.sequence;return!Number.isInteger(n)||n<1?{ok:!1,error:`${t}.sequence must be a positive integer`}:typeof e.timestamp==`string`?Da(e.timestamp)?{ok:!0}:{ok:!1,error:`${t}.timestamp must be a valid ISO 8601 date-time string`}:{ok:!1,error:`${t}.timestamp must be a string`}}function La(e,t){let n=e.toolCallId;return typeof n!=`string`||n===``?{ok:!1,error:`${t}.toolCallId must be a non-empty string for tool-result messages`}:{ok:!0}}function Ra(e,t){let n=e.usage;return n===void 0?{ok:!0}:F(n)?Fa(n,`${t}.usage`):{ok:!1,error:`${t}.usage must be a non-null object`}}function za(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};let n=ka(e.role,[`user`,`assistant`,`tool-result`],`${t}.role`);if(!n.ok)return n;if(e.role===`tool-result`){let n=La(e,t);if(!n.ok)return n}let r=Ia(e,t);if(!r.ok)return r;let i=e.content;if(!Array.isArray(i))return{ok:!1,error:`${t}.content must be an array`};let a=Aa(i,Ma,`${t}.content`);return a.ok?Ra(e,t):a}function Ba(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};if(typeof e.id!=`string`)return{ok:!1,error:`${t}.id must be a string`};if(typeof e.name!=`string`)return{ok:!1,error:`${t}.name must be a string`};let n=ka(e.kind,[`cone`,`scoop`],`${t}.kind`);if(!n.ok)return n;let r=e.messages;return Array.isArray(r)?Aa(r,za,`${t}.messages`):{ok:!1,error:`${t}.messages must be an array`}}function Va(e,t){for(let n of[`id`,`path`,`originalName`,`mimeType`,`sha256`,`sourceConversationId`,`sourceMessageId`])if(typeof e[n]!=`string`)return{ok:!1,error:`${t}.${n} must be a string`};return{ok:!0}}function Ha(e,t){let n=e.path,r=e.sha256,i=e.byteLength;return n===``?{ok:!1,error:`${t}.path must be non-empty when present`}:Ea(r)?!Number.isInteger(i)||i<0?{ok:!1,error:`${t}.byteLength must be a non-negative integer when present`}:e.missingReason===void 0?{ok:!0}:{ok:!1,error:`${t}.missingReason must be absent when present is true`}:{ok:!1,error:`${t}.sha256 must be a 64-char hex string when present`}}const Ua=[`attachment-file-missing`,`attachment-association-unavailable`];function Wa(e,t){let n=e.path,r=e.sha256,i=e.byteLength;return n===``?r===``?i===0?ka(e.missingReason,Ua,`${t}.missingReason`):{ok:!1,error:`${t}.byteLength must be zero when not present`}:{ok:!1,error:`${t}.sha256 must be empty when not present`}:{ok:!1,error:`${t}.path must be empty when not present`}}function Ga(e,t){return e.present?Ha(e,t):Wa(e,t)}function Ka(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};let n=Va(e,t);if(!n.ok)return n;if(typeof e.byteLength!=`number`)return{ok:!1,error:`${t}.byteLength must be a number`};if(typeof e.present!=`boolean`)return{ok:!1,error:`${t}.present must be a boolean`};let r=ka(e.handling,[`text-redacted`,`binary-unchanged`],`${t}.handling`);return r.ok?Ga(e,t):r}function qa(e,t){let n=ka(e.kind,[`json`,`attachment`],`${t}.kind`);if(!n.ok)return n;if(e.kind===`json`){if(typeof e.pointer!=`string`)return{ok:!1,error:`${t}.pointer must be a string`};let n=e.pointer;if(n!==``&&!n.startsWith(`/`))return{ok:!1,error:`${t}.pointer must be a valid RFC 6901 JSON pointer`}}else if(typeof e.attachmentId!=`string`||e.attachmentId===``)return{ok:!1,error:`${t}.attachmentId must be a non-empty string`};return{ok:!0}}function Ja(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};if(typeof e.id!=`string`)return{ok:!1,error:`${t}.id must be a string`};if(typeof e.category!=`string`)return{ok:!1,error:`${t}.category must be a string`};let n=ka(e.detector,[`known-secret`,`credential-pattern`,`pre-obfuscated`],`${t}.detector`);if(!n.ok)return n;let r=e.target;return F(r)?qa(r,`${t}.target`):{ok:!1,error:`${t}.target must be a non-null object`}}function Ya(e,t){return F(e)?typeof e.sourceConversationId==`string`?typeof e.targetConversationId==`string`?{ok:!0}:{ok:!1,error:`${t}.targetConversationId must be a string`}:{ok:!1,error:`${t}.sourceConversationId must be a string`}:{ok:!1,error:`${t} must be a non-null object`}}function Xa(e,t){return typeof e!=`string`||!Ca.has(e)?{ok:!1,error:`${t} is not a valid completeness reason`}:{ok:!0}}function Za(e){if(!F(e))return{ok:!1,error:`export must be a non-null object`};if(typeof e.id!=`string`)return{ok:!1,error:`export.id must be a string`};if(typeof e.generatedAt!=`string`)return{ok:!1,error:`export.generatedAt must be a string`};if(e.format!==`slicc-transcript`)return{ok:!1,error:`export.format must equal "slicc-transcript"`};let t=e.producer;return F(t)?t.application===`slicc`?typeof t.version==`string`?{ok:!0}:{ok:!1,error:`export.producer.version must be a string`}:{ok:!1,error:`export.producer.application must equal "slicc"`}:{ok:!1,error:`export.producer must be a non-null object`}}function Qa(e){if(!F(e))return{ok:!1,error:`session.completeness must be a non-null object`};let t=ka(e.status,[`complete`,`partial`],`session.completeness.status`);return t.ok?Array.isArray(e.missing)?Aa(e.missing,Xa,`session.completeness.missing`):{ok:!1,error:`session.completeness.missing must be an array`}:t}function $a(e){if(!F(e))return{ok:!1,error:`session must be a non-null object`};if(typeof e.id!=`string`)return{ok:!1,error:`session.id must be a string`};if(typeof e.title!=`string`)return{ok:!1,error:`session.title must be a string`};let t=ka(e.state,[`active`,`frozen`],`session.state`);return t.ok?Qa(e.completeness):t}function eo(e){if(!F(e))return{ok:!1,error:`privacy must be a non-null object`};if(e.reasoningExcluded!==!0)return{ok:!1,error:`privacy.reasoningExcluded must be true`};let t=e.excludedReasoningBlocks;if(typeof t!=`number`)return{ok:!1,error:`privacy.excludedReasoningBlocks must be a number`};if(!Number.isInteger(t)||t<0)return{ok:!1,error:`privacy.excludedReasoningBlocks must be a non-negative integer`};if(e.binaryAttachments!==`included-unchanged`)return{ok:!1,error:`privacy.binaryAttachments must equal "included-unchanged"`};if(!F(e.redactionCounts))return{ok:!1,error:`privacy.redactionCounts must be a non-null object`};let n=e.redactions;return Array.isArray(n)?Aa(n,Ja,`privacy.redactions`):{ok:!1,error:`privacy.redactions must be an array`}}function to(e){let t=e.conversations;if(!Array.isArray(t))return{ok:!1,error:`conversations must be an array`};let n=Aa(t,Ba,`conversations`);if(!n.ok)return n;let r=e.delegations;if(!Array.isArray(r))return{ok:!1,error:`delegations must be an array`};let i=Aa(r,Ya,`delegations`);if(!i.ok)return i;let a=e.attachments;return Array.isArray(a)?Aa(a,Ka,`attachments`):{ok:!1,error:`attachments must be an array`}}function no(e){let t=new Set,n=new Set;for(let r of e){if(!F(r)||typeof r.id!=`string`)continue;if(t.has(r.id))return{ok:!1,error:`duplicate conversation id "${r.id}"`};t.add(r.id);let e=r.messages;if(Array.isArray(e)){for(let t of e)if(!(!F(t)||typeof t.id!=`string`)){if(n.has(t.id))return{ok:!1,error:`duplicate message id "${t.id}"`};n.add(t.id)}}}return{ok:!0}}function ro(e){for(let t of e){if(!F(t))continue;let e=t.messages;if(!Array.isArray(e))continue;let n=typeof t.id==`string`?t.id:`?`,r=0;for(let t of e){if(!F(t)||typeof t.sequence!=`number`)continue;let e=t.sequence;if(e<=r)return{ok:!1,error:`sequences in conversation "${n}" must be strictly increasing`};r=e}}return{ok:!0}}function io(e){let t=[];for(let n of e){if(!F(n))continue;let e=n.content;if(Array.isArray(e))for(let n of e)F(n)&&n.type===`tool-call`&&typeof n.id==`string`&&t.push(n.id)}return t}function ao(e){let t=new Set;for(let n of e){if(!F(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of io(e))t.add(n)}return t}function oo(e,t){for(let n of e){if(!F(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of e){if(!F(n)||n.role!==`tool-result`)continue;let e=n.toolCallId;if(typeof e==`string`&&e!==``&&!t.has(e))return{ok:!1,error:`tool-result message references unknown toolCallId "${e}"`}}}return{ok:!0}}function so(e){return oo(e,ao(e))}function co(e,t){for(let n of e){if(!F(n)||n.type!==`attachment-ref`)continue;let e=n.attachmentId;if(typeof e!=`string`||!t.has(e))return{ok:!1,error:`attachment-ref references unknown attachmentId "${e}"`}}return{ok:!0}}function lo(e,t){for(let n of e){if(!F(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of e){if(!F(n))continue;let e=n.content;if(!Array.isArray(e))continue;let r=co(e,t);if(!r.ok)return r}}return{ok:!0}}function uo(e,t){let n=new Set;for(let e of t)F(e)&&typeof e.id==`string`&&n.add(e.id);return lo(e,n)}function fo(e){let t=new Map;for(let n of e){if(!F(n)||typeof n.id!=`string`)continue;let e=new Set,r=n.messages;if(Array.isArray(r))for(let t of r)F(t)&&typeof t.id==`string`&&e.add(t.id);t.set(n.id,e)}return t}function po(e,t){let n=fo(t);for(let t=0;t<e.length;t++){let r=e[t];if(!F(r))continue;let i=r.sourceConversationId,a=r.sourceMessageId;if(typeof i!=`string`||typeof a!=`string`)continue;let o=n.get(i);if(!o)return{ok:!1,error:`attachments[${t}].sourceConversationId "${i}" does not exist`};if(!o.has(a))return{ok:!1,error:`attachments[${t}].sourceMessageId "${a}" does not exist in conversation "${i}"`}}return{ok:!0}}function mo(e){let t=new Map;for(let n of e){if(!F(n)||typeof n.id!=`string`)continue;let e=Array.isArray(n.messages)?n.messages:[];t.set(n.id,new Set(io(e)))}return t}function ho(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];if(!F(i))continue;let a=i.sourceConversationId,o=i.targetConversationId;if(typeof a!=`string`||!t.has(a))return{ok:!1,error:`delegations[${r}].sourceConversationId "${a}" does not exist`};if(typeof o!=`string`||!t.has(o))return{ok:!1,error:`delegations[${r}].targetConversationId "${o}" does not exist`};let s=i.toolCallId;if(typeof s==`string`&&s!==``&&!n.get(a)?.has(s))return{ok:!1,error:`delegations[${r}].toolCallId "${s}" does not exist in source conversation "${a}"`}}return{ok:!0}}function go(e,t){let n=new Set;for(let e of t)F(e)&&typeof e.id==`string`&&n.add(e.id);return ho(e,n,mo(t))}function _o(e,t,n){if(e.kind!==`attachment`)return{ok:!0};let r=e.attachmentId;return typeof r!=`string`||!t.has(r)?{ok:!1,error:`${n}.attachmentId "${r}" does not reference a known attachment`}:{ok:!0}}function vo(e,t){let n=new Set;for(let e of t)F(e)&&typeof e.id==`string`&&n.add(e.id);for(let t=0;t<e.length;t++){let r=e[t];if(!F(r))continue;let i=r.target;if(!F(i))continue;let a=_o(i,n,`privacy.redactions[${t}].target`);if(!a.ok)return a}return{ok:!0}}function yo(e){let t=e.conversations,n=e.attachments,r=e.delegations,i=e.privacy,a=Array.isArray(i?.redactions)?i.redactions:[],o=no(t);if(!o.ok)return o;let s=ro(t);if(!s.ok)return s;let c=so(t);if(!c.ok)return c;let l=uo(t,n);if(!l.ok)return l;let u=po(n,t);if(!u.ok)return u;let d=go(r,t);return d.ok?vo(a,n):d}function bo(e){let t=to(e);return t.ok?yo(e):t}function xo(e){if(!F(e))return{ok:!1,error:`document must be a non-null object`};if(e.schemaVersion!==1)return{ok:!1,error:`schemaVersion must equal 1`};let t=Za(e.export);if(!t.ok)return t;let n=$a(e.session);if(!n.ok)return n;let r=eo(e.privacy);return r.ok?bo(e):r}async function So(e,t,n){let r=await n({method:`GET`,path:`/${e}/sites/${t}/config.json`,origin:Be});if(r.status===401||r.status===403)throw Error(`not authorized to read the site config for ${e}/${t} — log in via Settings → Providers → Adobe, or pass --backend to skip the probe`);if(r.status===404)throw Error(`no site config for ${e}/${t} — check the org and site names`);if(r.status>=400)throw Error(`site config probe failed for ${e}/${t}: ${r.status}`);let i;try{i=await r.json()}catch(n){throw Error(`site config for ${e}/${t} is not JSON: ${n instanceof Error?n.message:String(n)}`)}let a=i.content?.source?.url;return{backend:Co(a),sourceUrl:a}}function Co(e){if(!e)return`da`;let t;try{t=new URL(e).host}catch{return`da`}return t===`api.aem.live`?`aem`:`da`}const wo=`slicc-sprinkle-routes`;function To(){try{let e=localStorage.getItem(wo);return e?JSON.parse(e):{}}catch{return{}}}function Eo(e){try{localStorage.setItem(wo,JSON.stringify(e))}catch{}}function Do(e){return To()[e]}function Oo(e,t){let n=To();n[e]=t,Eo(n)}function ko(e){let t=To();delete t[e],Eo(t)}function Ao(){return To()}function jo(e,t,n){return dt(t,n,`${e} adapter does not implement ${t}.${n}`)}function Mo(e,t,n,r){let i=n.filter(e=>typeof r?.[e]==`function`),a=n.map(n=>{let i=r?.[n];return[n,typeof i==`function`?i:()=>Promise.resolve(jo(e,t,n))]});return{...Object.fromEntries(a),allowlist:i,supports:e=>i.includes(e)}}function No(e){let{adapter:t,pageGestures:n}=e,r=n??{};return{adapter:t,browser:Mo(t,`browser`,mt,e.browser),network:Mo(t,`network`,ut,e.network),secrets:Mo(t,`secrets`,ht,e.secrets),devices:Mo(t,`devices`,gt,{usbRequest:r.usbRequest,serialRequest:r.serialRequest,hidRequest:r.hidRequest,...e.devices}),mounts:Mo(t,`mounts`,ft,{pickDirectory:r.pickDirectory,...e.mounts}),approvals:Mo(t,`approvals`,_t,e.approvals)}}function Po(e={}){return No({adapter:`connect`,pageGestures:e.pageGestures})}function Fo(e){let t=vt(()=>import(`./extension-ops-CF2mLDRW.js`).then(t=>t.createExtensionOps(e)));return No({adapter:e.adapter,pageGestures:e.pageGestures,network:{crossOriginFetch:e=>T(`network`,`crossOriginFetch`,async()=>(await t()).crossOriginFetch(e))},secrets:{listMaskedEnv:()=>T(`secrets`,`listMaskedEnv`,async()=>(await t()).secrets.listMaskedEnv()),getMasked:e=>T(`secrets`,`getMasked`,async()=>(await t()).secrets.getMasked(e)),set:e=>T(`secrets`,`set`,async()=>(await t()).secrets.set(e)),delete:e=>T(`secrets`,`delete`,async()=>(await t()).secrets.delete(e))},mounts:{signRequest:e=>T(`mounts`,`signRequest`,async()=>(await t()).signRequest(e))},approvals:{request:e=>T(`approvals`,`request`,async()=>(await t()).requestApproval(e))}})}function Io(e={}){let t=vt(()=>import(`./rest-ops-CLliBy-9.js`).then(t=>t.createRestOps(e)),e.controlTimeoutMs??1e4);return No({adapter:`node-rest`,pageGestures:e.pageGestures,network:{localNodeServer:()=>Promise.resolve({ok:!0,value:{available:!0}}),crossOriginFetch:e=>T(`network`,`crossOriginFetch`,async()=>(await t()).crossOriginFetch(e))},secrets:{listMaskedEnv:()=>T(`secrets`,`listMaskedEnv`,async()=>(await t()).secrets.listMaskedEnv()),getMasked:e=>T(`secrets`,`getMasked`,async()=>(await t()).secrets.getMasked(e)),set:e=>T(`secrets`,`set`,async()=>(await t()).secrets.set(e)),delete:e=>T(`secrets`,`delete`,async()=>(await t()).secrets.delete(e))},mounts:{signRequest:e=>T(`mounts`,`signRequest`,async()=>(await t()).signRequest(e))},approvals:{request:e=>T(`approvals`,`request`,async()=>(await t()).requestApproval(e))}})}function Lo(e,t={}){let{pageGestures:n}=t;switch(e){case`node-rest`:return Io({pageGestures:n});case`extension-direct`:case`extension-delegate`:return Fo({adapter:e,pageGestures:n});case`connect`:return Po({pageGestures:n})}}const Ro=e(`quick-llm`);async function zo(e){let t=d();if(!t)return Ro.debug(`No API key for active provider — skipping`),null;let n=u(),r=l(),i;if(i=e.modelId?Uo(n,e.modelId)??Uo(n,r):Bo(n,r),!i)return Ro.debug(`No model available for provider`,{providerId:n}),null;let a={role:`user`,content:e.prompt,timestamp:Date.now()},o={};i.provider===`adobe`&&(o[`X-Session-Id`]=Wo());try{let n=(await ge(i,{systemPrompt:e.system,messages:[a]},{apiKey:t,maxTokens:e.maxTokens??60,temperature:e.temperature??.3,signal:e.signal,headers:Object.keys(o).length>0?o:void 0})).content.filter(e=>e.type===`text`).map(e=>e.text).join(``).trim();return n.length>0?n:null}catch(e){return Ro.debug(`Quick label call failed`,{error:e instanceof Error?e.message:String(e)}),null}}function Bo(e,t){let n=f(e);if(n.length===0)return;let r=n.find(e=>e.id===t)??n[0],i=Ho(r.id),a=n.filter(e=>Vo(e,r,i));return a.length===0?r:(a.sort((e,t)=>(e.cost?.input??0)-(t.cost?.input??0)),a[0])}function Vo(e,t,n){if(e.id===t.id)return!1;let r=t.cost?.input??1/0;if((e.cost?.input??1/0)>=r)return!1;let i=e.id.toLowerCase();switch(n){case`claude`:return i.includes(`haiku`);case`gpt`:return/(^|-)mini(-|$)|(^|-)nano(-|$)/.test(i);case`gemini`:return i.includes(`flash`);case`grok`:return/(^|-)mini(-|$)|(^|-)fast(-|$)/.test(i);case`unknown`:return!0}}function Ho(e){let t=e.toLowerCase();return t.includes(`claude`)?`claude`:t.includes(`gemini`)?`gemini`:t.includes(`grok`)?`grok`:/^(gpt|o\d)/.test(t)?`gpt`:`unknown`}function Uo(e,t){return f(e).find(e=>e.id===t)}function Wo(){return bt(`ui-quick-llm`)}const Go=e(`sudo-suggest`),Ko=[`You generalize a single shell command into a minimal glob pattern for an`,`allow-list rule. Output ONLY the pattern on one line — no prose, no quotes,`,`no backticks. Keep the leading command/sub-command verbatim and replace only`,`the volatile tail (args, paths, refs) with a single trailing "*".`,`Examples:`,` git push origin main -> git push*`,` rm -rf build/cache -> rm -rf*`,` npm install left-pad -> npm install*`].join(`
1
+ import{t as e}from"./logger-LESFN7Hj.js";import{r as t,t as n}from"./base64-BPBW1Gzr.js";import{n as r}from"./bridge-protocol-31SWTdS5.js";import{a as i,n as a,o,s,t as c}from"./handoff-link-B3It6xQY.js";import{d as l,f as u,i as d,u as f}from"./account-store-BXYHDz7I.js";import{n as p,o as m,r as h,s as g,u as _}from"./proxied-fetch-DXaTHROw.js";import{t as v}from"./runtime-env-DadgceZk.js";import{t as ee}from"./slugify-BYJ6QVAt.js";import{n as te,t as ne}from"./host-command-D8TK1jxM.js";import{a as re,i as ie,n as ae,r as oe,t as se}from"./snapshot-DgEGAH-2.js";import{i as ce,r as y}from"./panel-rpc-DW7W4w6_.js";import{t as le}from"./providers-BcK4GJL5.js";import{r as ue}from"./binary-cache-bSOhqXB1.js";import{i as de,n as fe,r as pe}from"./fetch-body-CuwTaJC_.js";import{s as me,t as he}from"./api-endpoint-D8lUKmPu.js";import{t as ge}from"./compat-uEPf6-XW.js";import{a as _e,i as ve}from"./core-PJsXG3mm.js";import{n as ye,t as be}from"./mime-types-D7IV6i7k.js";import{t as xe}from"./secrets-bridge-client-BiJrSKN9.js";import{a as Se,i as Ce,n as we,r as Te}from"./tool-ui-DRnUkp2g.js";import{a as Ee,i as De,n as b,t as x}from"./path-utils-DNJG-zQf.js";import{n as Oe,r as ke,t as Ae}from"./merge-file-core-VJlzucJY.js";import{r as je}from"./workspace-mode-D0kUKBVS.js";import{n as Me,t as Ne}from"./thinking-level-5x0UAu9N.js";import{n as Pe,t as Fe}from"./types-D8gIX-W-.js";import{i as Ie}from"./mount-index-CQfmUPuZ.js";import{a as Le,i as Re,n as ze,o as Be,s as Ve,t as He}from"./signed-fetch-BWgKPq0A.js";import{o as Ue}from"./mount-table-store-DrF_Ifaz.js";import{t as We}from"./remote-cache-BE5T1-53.js";import{n as Ge}from"./fs-DL0b9F_-.js";import{a as Ke}from"./tray-leader-status-CpkFr6n7.js";import{n as qe,t as Je}from"./slicc-version-a1X0pv8Y.js";import{a as Ye,i as Xe,o as Ze,r as S,t as Qe}from"./browser-Don7GC1D.js";import{t as C}from"./subcommand-flags-BZi7j78Q.js";import{n as $e,r as et,t as w}from"./subcommand-help-CgO7wRS5.js";import{n as tt}from"./cost-command-MXw_GKzX.js";import{d as nt,g as rt,i as it,n as at,o as ot}from"./sudoers-BdBYQPUn.js";import{n as st,r as ct,t as lt}from"./approval-timeout-BQ29Z0gf.js";import{a as ut,c as dt,i as ft,l as pt,n as mt,o as ht,r as gt,t as _t}from"./types-BfwydWt7.js";import{n as T,t as vt}from"./boundary-Cp9c_bPu.js";import"./rest-paths-Dia19u9P.js";import{t as yt}from"./html-B_Hg2WOy.js";import{n as bt}from"./llm-session-id-BZyXP_j2.js";import{t as xt}from"./src-CUSndb9K.js";import{i as St,o as Ct}from"./browser-DuyhpHbR.js";import{i as wt,r as Tt,t as Et}from"./mount-picker-popup-BMils9JY.js";import{t as Dt}from"./buffer-B5d1xHaH.js";import"./buffer-polyfill-BwLbCySD.js";import{A as Ot,B as E,C as kt,D,E as At,F as jt,G as Mt,H as O,I as k,J as Nt,K as Pt,L as Ft,M as It,N as Lt,O as Rt,P as zt,R as Bt,S as Vt,T as Ht,U as Ut,V as Wt,W as Gt,Y as Kt,_ as qt,a as Jt,b as Yt,c as Xt,d as Zt,f as Qt,g as $t,h as en,i as tn,j as nn,k as rn,l as an,m as on,n as sn,o as cn,p as A,q as ln,r as un,s as dn,t as fn,u as pn,v as mn,w as hn,x as gn,y as _n,z as vn}from"./isomorphic-git-r9mnHMnp.js";import"./global-db-DJXlpNui.js";import{S as yn,_ as bn,a as xn,b as Sn,c as Cn,d as wn,f as Tn,g as En,h as Dn,i as On,l as kn,n as An,o as jn,p as Mn,r as Nn,s as Pn,t as Fn,u as In,v as j,x as M,y as Ln}from"./state-CoDzWbhR.js";import{a as Rn,i as zn,r as Bn,t as Vn}from"./git-config-Bdgu8kD2.js";import{a as Hn,n as Un,o as Wn,r as Gn,s as Kn}from"./jsh-discovery-CnvNKojr.js";import{A as qn,C as Jn,a as Yn,b as Xn,c as Zn,d as Qn,f as $n,h as er,i as tr,j as nr,l as rr,m as ir,n as ar,o as or,p as sr,r as cr,s as lr,t as N,u as ur,v as dr,y as fr}from"./shared-2XhBobrM.js";import{_ as pr,a as mr,b as hr,d as gr,f as _r,g as vr,h as yr,i as br,l as xr,m as Sr,p as Cr,r as wr,s as Tr,u as Er,v as Dr,x as Or,y as kr}from"./require-guards-Dfl5uogi.js";import{_ as Ar,a as jr,b as Mr,c as Nr,d as Pr,f as Fr,g as Ir,h as Lr,l as Rr,m as zr,n as Br,p as Vr,s as Hr,t as Ur,u as Wr,v as Gr,x as Kr,y as qr}from"./jsh-executor-CoKR7gN9.js";import{n as Jr,t as Yr}from"./esbuild-wasm-CbTVjIj0.js";import{n as Xr}from"./wasm-compiler-Ct7QZURL.js";import{a as Zr,o as Qr,s as $r,t as ei}from"./usb-device-registry-DFzxaOky.js";import{a as P,i as ti,r as ni,t as ri}from"./just-bash-compat-B-SPHuh_.js";import{i as ii,r as ai,t as oi}from"./script-catalog-DZtOMxvi.js";import{a as si,c as ci,o as li,s as ui,t as di}from"./types-Dzr0qYl3.js";import{a as fi,c as pi,d as mi,f as hi,n as gi,r as _i,u as vi}from"./github-zip-x1UTu8IO.js";import{i as yi,t as bi}from"./github-auth-nna4SRhq.js";import{a as xi,i as Si,o as Ci,r as wi,t as Ti}from"./provenance-DdmsQ3Nr.js";import{a as Ei,c as Di,i as Oi,n as ki,o as Ai,r as ji,s as Mi}from"./github-install-DhvV5fCp.js";import{n as Ni,t as Pi}from"./magick-wasm-BATj-KUu.js";import{i as Fi,n as Ii,r as Li,t as Ri}from"./pdf-raster-BWk6ezTX.js";import{n as zi}from"./lick-target-env-8JxfVcIV.js";import{t as Bi}from"./tmpdir-env-ate4iNcK.js";import{n as Vi,t as Hi}from"./hf-defaults-BwJdGLgk.js";import{a as Ui,i as Wi,n as Gi,o as Ki,r as qi,t as Ji}from"./installer-Dhz3Owz-.js";import{i as Yi,n as Xi,r as Zi,t as Qi}from"./tar-BWIPCxI2.js";import{t as $i}from"./ffmpeg-wasm-CmLVzRDe.js";import{t as ea}from"./local-llm-DNAXIB_B.js";import{t as ta}from"./client-CwxmlQM-.js";import{t as na}from"./redirect-uri-CBCnYKsl.js";import{a as ra,c as ia,i as aa,o as oa,r as sa,s as ca}from"./v86-vm-DCm7zA2r.js";import{n as la,r as ua}from"./lick-urls-CgPiVwD-.js";let da=null;function fa(e){da=e!==null&&Number.isFinite(e)&&e>0?e:null}function pa(){if(da!==null)return da;let e=globalThis.performance?.timeOrigin;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:Date.now()}new URL(r).hostname;const ma=/^([0-9a-f]{32})--(?:[0-9a-f]{8}-)?([0-9a-f]+)$/i;function ha(e){let t;try{t=new URL(e.includes(`://`)?e:`https://${e}`).hostname}catch{return null}let n=ma.exec(t.split(`.`)[0]??``);if(!n||!t.includes(`.`))return null;let r=n[1].toLowerCase();return`${[r.slice(0,8),r.slice(8,12),r.slice(12,16),r.slice(16,20),r.slice(20)].join(`-`)}.${n[2].toLowerCase()}`}[`ghp_`,`gho_`,`ghu_`,`ghs_`,`ghr_`,`github_pat_`,`sk-`,`pk-`,`xoxb-`,`xoxp-`,`xoxa-`,`xoxs-`,`AKIA`,`ABIA`,`ACCA`,`ASIA`,`sk-ant-`,`Bearer `].sort((e,t)=>t.length-e.length);function ga(e,t){let n=e.toLowerCase(),r=t.toLowerCase();if(n===`*`)return!0;if(!n.startsWith(`*.`))return n===r;let i=n.slice(1);return r.length>i.length&&r.endsWith(i)}function _a(e,t){return e.some(e=>ga(e,t))}const va=`slicc-transcript`,ya=[`canonical-agent-history-unavailable`,`tool-data-may-be-truncated`,`model-metadata-unavailable`,`scoop-history-unavailable`,`attachment-file-missing`,`attachment-association-unavailable`,`complete-snapshot-unavailable`],ba=new Set(`/export/format./export/producer/application./session/id./session/state./session/completeness/status./session/completeness/missing/*./conversations/*/id./conversations/*/kind./conversations/*/parentConversationId./conversations/*/messages/*/id./conversations/*/messages/*/role./conversations/*/messages/*/timestamp./conversations/*/messages/*/toolCallId./conversations/*/messages/*/content/*/type./conversations/*/messages/*/content/*/id./conversations/*/messages/*/content/*/name./conversations/*/messages/*/content/*/attachmentId./delegations/*/sourceConversationId./delegations/*/targetConversationId./delegations/*/toolCallId./attachments/*/id./attachments/*/path./attachments/*/sha256./attachments/*/sourceConversationId./attachments/*/sourceMessageId./attachments/*/handling./attachments/*/missingReason`.split(`.`));function xa(e){return ba.has(e.replace(/\/\d+(?=\/|$)/g,`/*`))}var Sa=class extends Error{code;detail;constructor(e,t){super(t?`${e}: ${t}`:e),this.code=e,this.detail=t,this.name=`TranscriptExportError`}};const Ca=new Set(ya),wa=/^[0-9a-fA-F]{64}$/,Ta=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/;function F(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ea(e){return typeof e==`string`&&wa.test(e)}function Da(e){return Ta.test(e)&&Number.isFinite(Date.parse(e))}function Oa(e,t){let n=t.map(e=>`"${e}"`),r=n[n.length-1];return n.length===2?`${e} must be ${n[0]} or ${r}`:`${e} must be ${n.slice(0,-1).join(`, `)}, or ${r}`}function ka(e,t,n){return typeof e!=`string`||!t.includes(e)?{ok:!1,error:Oa(n,t)}:{ok:!0}}function Aa(e,t,n){for(let r=0;r<e.length;r++){let i=t(e[r],`${n}[${r}]`);if(!i.ok)return i}return{ok:!0}}function ja(e,t){let n=e.type;if(n===`text`){if(typeof e.text!=`string`)return{ok:!1,error:`${t}.text must be a string`}}else if(n===`tool-call`){if(typeof e.id!=`string`||e.id===``)return{ok:!1,error:`${t}.id must be a non-empty string`};if(typeof e.name!=`string`||e.name===``)return{ok:!1,error:`${t}.name must be a non-empty string`};if(!(`input`in e))return{ok:!1,error:`${t}.input must be present`}}else if(typeof e.attachmentId!=`string`||e.attachmentId===``)return{ok:!1,error:`${t}.attachmentId must be a non-empty string`};return{ok:!0}}function Ma(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};let n=ka(e.type,[`text`,`tool-call`,`attachment-ref`],`${t}.type`);return n.ok?ja(e,t):n}function Na(e,t){for(let n of[`input`,`output`,`cacheRead`,`cacheWrite`,`totalTokens`]){let r=e[n];if(typeof r!=`number`)return{ok:!1,error:`${t}.${n} must be a number`};if(!Number.isInteger(r)||r<0)return{ok:!1,error:`${t}.${n} must be a non-negative integer`}}return{ok:!0}}function Pa(e,t){for(let n of[`input`,`output`,`cacheRead`,`cacheWrite`,`total`]){let r=e[n];if(typeof r!=`number`)return{ok:!1,error:`${t}.${n} must be a number`};if(!Number.isFinite(r)||r<0)return{ok:!1,error:`${t}.${n} must be a finite non-negative number`}}return{ok:!0}}function Fa(e,t){let n=Na(e,t);if(!n.ok)return n;let r=e.cost;return F(r)?Pa(r,`${t}.cost`):{ok:!1,error:`${t}.cost must be a non-null object`}}function Ia(e,t){if(typeof e.id!=`string`)return{ok:!1,error:`${t}.id must be a string`};if(typeof e.sequence!=`number`)return{ok:!1,error:`${t}.sequence must be a number`};let n=e.sequence;return!Number.isInteger(n)||n<1?{ok:!1,error:`${t}.sequence must be a positive integer`}:typeof e.timestamp==`string`?Da(e.timestamp)?{ok:!0}:{ok:!1,error:`${t}.timestamp must be a valid ISO 8601 date-time string`}:{ok:!1,error:`${t}.timestamp must be a string`}}function La(e,t){let n=e.toolCallId;return typeof n!=`string`||n===``?{ok:!1,error:`${t}.toolCallId must be a non-empty string for tool-result messages`}:{ok:!0}}function Ra(e,t){let n=e.usage;return n===void 0?{ok:!0}:F(n)?Fa(n,`${t}.usage`):{ok:!1,error:`${t}.usage must be a non-null object`}}function za(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};let n=ka(e.role,[`user`,`assistant`,`tool-result`],`${t}.role`);if(!n.ok)return n;if(e.role===`tool-result`){let n=La(e,t);if(!n.ok)return n}let r=Ia(e,t);if(!r.ok)return r;let i=e.content;if(!Array.isArray(i))return{ok:!1,error:`${t}.content must be an array`};let a=Aa(i,Ma,`${t}.content`);return a.ok?Ra(e,t):a}function Ba(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};if(typeof e.id!=`string`)return{ok:!1,error:`${t}.id must be a string`};if(typeof e.name!=`string`)return{ok:!1,error:`${t}.name must be a string`};let n=ka(e.kind,[`cone`,`scoop`],`${t}.kind`);if(!n.ok)return n;let r=e.messages;return Array.isArray(r)?Aa(r,za,`${t}.messages`):{ok:!1,error:`${t}.messages must be an array`}}function Va(e,t){for(let n of[`id`,`path`,`originalName`,`mimeType`,`sha256`,`sourceConversationId`,`sourceMessageId`])if(typeof e[n]!=`string`)return{ok:!1,error:`${t}.${n} must be a string`};return{ok:!0}}function Ha(e,t){let n=e.path,r=e.sha256,i=e.byteLength;return n===``?{ok:!1,error:`${t}.path must be non-empty when present`}:Ea(r)?!Number.isInteger(i)||i<0?{ok:!1,error:`${t}.byteLength must be a non-negative integer when present`}:e.missingReason===void 0?{ok:!0}:{ok:!1,error:`${t}.missingReason must be absent when present is true`}:{ok:!1,error:`${t}.sha256 must be a 64-char hex string when present`}}const Ua=[`attachment-file-missing`,`attachment-association-unavailable`];function Wa(e,t){let n=e.path,r=e.sha256,i=e.byteLength;return n===``?r===``?i===0?ka(e.missingReason,Ua,`${t}.missingReason`):{ok:!1,error:`${t}.byteLength must be zero when not present`}:{ok:!1,error:`${t}.sha256 must be empty when not present`}:{ok:!1,error:`${t}.path must be empty when not present`}}function Ga(e,t){return e.present?Ha(e,t):Wa(e,t)}function Ka(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};let n=Va(e,t);if(!n.ok)return n;if(typeof e.byteLength!=`number`)return{ok:!1,error:`${t}.byteLength must be a number`};if(typeof e.present!=`boolean`)return{ok:!1,error:`${t}.present must be a boolean`};let r=ka(e.handling,[`text-redacted`,`binary-unchanged`],`${t}.handling`);return r.ok?Ga(e,t):r}function qa(e,t){let n=ka(e.kind,[`json`,`attachment`],`${t}.kind`);if(!n.ok)return n;if(e.kind===`json`){if(typeof e.pointer!=`string`)return{ok:!1,error:`${t}.pointer must be a string`};let n=e.pointer;if(n!==``&&!n.startsWith(`/`))return{ok:!1,error:`${t}.pointer must be a valid RFC 6901 JSON pointer`}}else if(typeof e.attachmentId!=`string`||e.attachmentId===``)return{ok:!1,error:`${t}.attachmentId must be a non-empty string`};return{ok:!0}}function Ja(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};if(typeof e.id!=`string`)return{ok:!1,error:`${t}.id must be a string`};if(typeof e.category!=`string`)return{ok:!1,error:`${t}.category must be a string`};let n=ka(e.detector,[`known-secret`,`credential-pattern`,`pre-obfuscated`],`${t}.detector`);if(!n.ok)return n;let r=e.target;return F(r)?qa(r,`${t}.target`):{ok:!1,error:`${t}.target must be a non-null object`}}function Ya(e,t){return F(e)?typeof e.sourceConversationId==`string`?typeof e.targetConversationId==`string`?{ok:!0}:{ok:!1,error:`${t}.targetConversationId must be a string`}:{ok:!1,error:`${t}.sourceConversationId must be a string`}:{ok:!1,error:`${t} must be a non-null object`}}function Xa(e,t){return typeof e!=`string`||!Ca.has(e)?{ok:!1,error:`${t} is not a valid completeness reason`}:{ok:!0}}function Za(e){if(!F(e))return{ok:!1,error:`export must be a non-null object`};if(typeof e.id!=`string`)return{ok:!1,error:`export.id must be a string`};if(typeof e.generatedAt!=`string`)return{ok:!1,error:`export.generatedAt must be a string`};if(e.format!==`slicc-transcript`)return{ok:!1,error:`export.format must equal "slicc-transcript"`};let t=e.producer;return F(t)?t.application===`slicc`?typeof t.version==`string`?{ok:!0}:{ok:!1,error:`export.producer.version must be a string`}:{ok:!1,error:`export.producer.application must equal "slicc"`}:{ok:!1,error:`export.producer must be a non-null object`}}function Qa(e){if(!F(e))return{ok:!1,error:`session.completeness must be a non-null object`};let t=ka(e.status,[`complete`,`partial`],`session.completeness.status`);return t.ok?Array.isArray(e.missing)?Aa(e.missing,Xa,`session.completeness.missing`):{ok:!1,error:`session.completeness.missing must be an array`}:t}function $a(e){if(!F(e))return{ok:!1,error:`session must be a non-null object`};if(typeof e.id!=`string`)return{ok:!1,error:`session.id must be a string`};if(typeof e.title!=`string`)return{ok:!1,error:`session.title must be a string`};let t=ka(e.state,[`active`,`frozen`],`session.state`);return t.ok?Qa(e.completeness):t}function eo(e){if(!F(e))return{ok:!1,error:`privacy must be a non-null object`};if(e.reasoningExcluded!==!0)return{ok:!1,error:`privacy.reasoningExcluded must be true`};let t=e.excludedReasoningBlocks;if(typeof t!=`number`)return{ok:!1,error:`privacy.excludedReasoningBlocks must be a number`};if(!Number.isInteger(t)||t<0)return{ok:!1,error:`privacy.excludedReasoningBlocks must be a non-negative integer`};if(e.binaryAttachments!==`included-unchanged`)return{ok:!1,error:`privacy.binaryAttachments must equal "included-unchanged"`};if(!F(e.redactionCounts))return{ok:!1,error:`privacy.redactionCounts must be a non-null object`};let n=e.redactions;return Array.isArray(n)?Aa(n,Ja,`privacy.redactions`):{ok:!1,error:`privacy.redactions must be an array`}}function to(e){let t=e.conversations;if(!Array.isArray(t))return{ok:!1,error:`conversations must be an array`};let n=Aa(t,Ba,`conversations`);if(!n.ok)return n;let r=e.delegations;if(!Array.isArray(r))return{ok:!1,error:`delegations must be an array`};let i=Aa(r,Ya,`delegations`);if(!i.ok)return i;let a=e.attachments;return Array.isArray(a)?Aa(a,Ka,`attachments`):{ok:!1,error:`attachments must be an array`}}function no(e){let t=new Set,n=new Set;for(let r of e){if(!F(r)||typeof r.id!=`string`)continue;if(t.has(r.id))return{ok:!1,error:`duplicate conversation id "${r.id}"`};t.add(r.id);let e=r.messages;if(Array.isArray(e)){for(let t of e)if(!(!F(t)||typeof t.id!=`string`)){if(n.has(t.id))return{ok:!1,error:`duplicate message id "${t.id}"`};n.add(t.id)}}}return{ok:!0}}function ro(e){for(let t of e){if(!F(t))continue;let e=t.messages;if(!Array.isArray(e))continue;let n=typeof t.id==`string`?t.id:`?`,r=0;for(let t of e){if(!F(t)||typeof t.sequence!=`number`)continue;let e=t.sequence;if(e<=r)return{ok:!1,error:`sequences in conversation "${n}" must be strictly increasing`};r=e}}return{ok:!0}}function io(e){let t=[];for(let n of e){if(!F(n))continue;let e=n.content;if(Array.isArray(e))for(let n of e)F(n)&&n.type===`tool-call`&&typeof n.id==`string`&&t.push(n.id)}return t}function ao(e){let t=new Set;for(let n of e){if(!F(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of io(e))t.add(n)}return t}function oo(e,t){for(let n of e){if(!F(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of e){if(!F(n)||n.role!==`tool-result`)continue;let e=n.toolCallId;if(typeof e==`string`&&e!==``&&!t.has(e))return{ok:!1,error:`tool-result message references unknown toolCallId "${e}"`}}}return{ok:!0}}function so(e){return oo(e,ao(e))}function co(e,t){for(let n of e){if(!F(n)||n.type!==`attachment-ref`)continue;let e=n.attachmentId;if(typeof e!=`string`||!t.has(e))return{ok:!1,error:`attachment-ref references unknown attachmentId "${e}"`}}return{ok:!0}}function lo(e,t){for(let n of e){if(!F(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of e){if(!F(n))continue;let e=n.content;if(!Array.isArray(e))continue;let r=co(e,t);if(!r.ok)return r}}return{ok:!0}}function uo(e,t){let n=new Set;for(let e of t)F(e)&&typeof e.id==`string`&&n.add(e.id);return lo(e,n)}function fo(e){let t=new Map;for(let n of e){if(!F(n)||typeof n.id!=`string`)continue;let e=new Set,r=n.messages;if(Array.isArray(r))for(let t of r)F(t)&&typeof t.id==`string`&&e.add(t.id);t.set(n.id,e)}return t}function po(e,t){let n=fo(t);for(let t=0;t<e.length;t++){let r=e[t];if(!F(r))continue;let i=r.sourceConversationId,a=r.sourceMessageId;if(typeof i!=`string`||typeof a!=`string`)continue;let o=n.get(i);if(!o)return{ok:!1,error:`attachments[${t}].sourceConversationId "${i}" does not exist`};if(!o.has(a))return{ok:!1,error:`attachments[${t}].sourceMessageId "${a}" does not exist in conversation "${i}"`}}return{ok:!0}}function mo(e){let t=new Map;for(let n of e){if(!F(n)||typeof n.id!=`string`)continue;let e=Array.isArray(n.messages)?n.messages:[];t.set(n.id,new Set(io(e)))}return t}function ho(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];if(!F(i))continue;let a=i.sourceConversationId,o=i.targetConversationId;if(typeof a!=`string`||!t.has(a))return{ok:!1,error:`delegations[${r}].sourceConversationId "${a}" does not exist`};if(typeof o!=`string`||!t.has(o))return{ok:!1,error:`delegations[${r}].targetConversationId "${o}" does not exist`};let s=i.toolCallId;if(typeof s==`string`&&s!==``&&!n.get(a)?.has(s))return{ok:!1,error:`delegations[${r}].toolCallId "${s}" does not exist in source conversation "${a}"`}}return{ok:!0}}function go(e,t){let n=new Set;for(let e of t)F(e)&&typeof e.id==`string`&&n.add(e.id);return ho(e,n,mo(t))}function _o(e,t,n){if(e.kind!==`attachment`)return{ok:!0};let r=e.attachmentId;return typeof r!=`string`||!t.has(r)?{ok:!1,error:`${n}.attachmentId "${r}" does not reference a known attachment`}:{ok:!0}}function vo(e,t){let n=new Set;for(let e of t)F(e)&&typeof e.id==`string`&&n.add(e.id);for(let t=0;t<e.length;t++){let r=e[t];if(!F(r))continue;let i=r.target;if(!F(i))continue;let a=_o(i,n,`privacy.redactions[${t}].target`);if(!a.ok)return a}return{ok:!0}}function yo(e){let t=e.conversations,n=e.attachments,r=e.delegations,i=e.privacy,a=Array.isArray(i?.redactions)?i.redactions:[],o=no(t);if(!o.ok)return o;let s=ro(t);if(!s.ok)return s;let c=so(t);if(!c.ok)return c;let l=uo(t,n);if(!l.ok)return l;let u=po(n,t);if(!u.ok)return u;let d=go(r,t);return d.ok?vo(a,n):d}function bo(e){let t=to(e);return t.ok?yo(e):t}function xo(e){if(!F(e))return{ok:!1,error:`document must be a non-null object`};if(e.schemaVersion!==1)return{ok:!1,error:`schemaVersion must equal 1`};let t=Za(e.export);if(!t.ok)return t;let n=$a(e.session);if(!n.ok)return n;let r=eo(e.privacy);return r.ok?bo(e):r}async function So(e,t,n){let r=await n({method:`GET`,path:`/${e}/sites/${t}/config.json`,origin:Be});if(r.status===401||r.status===403)throw Error(`not authorized to read the site config for ${e}/${t} — log in via Settings → Providers → Adobe, or pass --backend to skip the probe`);if(r.status===404)throw Error(`no site config for ${e}/${t} — check the org and site names`);if(r.status>=400)throw Error(`site config probe failed for ${e}/${t}: ${r.status}`);let i;try{i=await r.json()}catch(n){throw Error(`site config for ${e}/${t} is not JSON: ${n instanceof Error?n.message:String(n)}`)}let a=i.content?.source?.url;return{backend:Co(a),sourceUrl:a}}function Co(e){if(!e)return`da`;let t;try{t=new URL(e).host}catch{return`da`}return t===`api.aem.live`?`aem`:`da`}const wo=`slicc-sprinkle-routes`;function To(){try{let e=localStorage.getItem(wo);return e?JSON.parse(e):{}}catch{return{}}}function Eo(e){try{localStorage.setItem(wo,JSON.stringify(e))}catch{}}function Do(e){return To()[e]}function Oo(e,t){let n=To();n[e]=t,Eo(n)}function ko(e){let t=To();delete t[e],Eo(t)}function Ao(){return To()}function jo(e,t,n){return dt(t,n,`${e} adapter does not implement ${t}.${n}`)}function Mo(e,t,n,r){let i=n.filter(e=>typeof r?.[e]==`function`),a=n.map(n=>{let i=r?.[n];return[n,typeof i==`function`?i:()=>Promise.resolve(jo(e,t,n))]});return{...Object.fromEntries(a),allowlist:i,supports:e=>i.includes(e)}}function No(e){let{adapter:t,pageGestures:n}=e,r=n??{};return{adapter:t,browser:Mo(t,`browser`,mt,e.browser),network:Mo(t,`network`,ut,e.network),secrets:Mo(t,`secrets`,ht,e.secrets),devices:Mo(t,`devices`,gt,{usbRequest:r.usbRequest,serialRequest:r.serialRequest,hidRequest:r.hidRequest,...e.devices}),mounts:Mo(t,`mounts`,ft,{pickDirectory:r.pickDirectory,...e.mounts}),approvals:Mo(t,`approvals`,_t,e.approvals)}}function Po(e={}){return No({adapter:`connect`,pageGestures:e.pageGestures})}function Fo(e){let t=vt(()=>import(`./extension-ops-CF2mLDRW.js`).then(t=>t.createExtensionOps(e)));return No({adapter:e.adapter,pageGestures:e.pageGestures,network:{crossOriginFetch:e=>T(`network`,`crossOriginFetch`,async()=>(await t()).crossOriginFetch(e))},secrets:{listMaskedEnv:()=>T(`secrets`,`listMaskedEnv`,async()=>(await t()).secrets.listMaskedEnv()),getMasked:e=>T(`secrets`,`getMasked`,async()=>(await t()).secrets.getMasked(e)),set:e=>T(`secrets`,`set`,async()=>(await t()).secrets.set(e)),delete:e=>T(`secrets`,`delete`,async()=>(await t()).secrets.delete(e))},mounts:{signRequest:e=>T(`mounts`,`signRequest`,async()=>(await t()).signRequest(e))},approvals:{request:e=>T(`approvals`,`request`,async()=>(await t()).requestApproval(e))}})}function Io(e={}){let t=vt(()=>import(`./rest-ops-CLliBy-9.js`).then(t=>t.createRestOps(e)),e.controlTimeoutMs??1e4);return No({adapter:`node-rest`,pageGestures:e.pageGestures,network:{localNodeServer:()=>Promise.resolve({ok:!0,value:{available:!0}}),crossOriginFetch:e=>T(`network`,`crossOriginFetch`,async()=>(await t()).crossOriginFetch(e))},secrets:{listMaskedEnv:()=>T(`secrets`,`listMaskedEnv`,async()=>(await t()).secrets.listMaskedEnv()),getMasked:e=>T(`secrets`,`getMasked`,async()=>(await t()).secrets.getMasked(e)),set:e=>T(`secrets`,`set`,async()=>(await t()).secrets.set(e)),delete:e=>T(`secrets`,`delete`,async()=>(await t()).secrets.delete(e))},mounts:{signRequest:e=>T(`mounts`,`signRequest`,async()=>(await t()).signRequest(e))},approvals:{request:e=>T(`approvals`,`request`,async()=>(await t()).requestApproval(e))}})}function Lo(e,t={}){let{pageGestures:n}=t;switch(e){case`node-rest`:return Io({pageGestures:n});case`extension-direct`:case`extension-delegate`:return Fo({adapter:e,pageGestures:n});case`connect`:return Po({pageGestures:n})}}const Ro=e(`quick-llm`);async function zo(e){let t=d();if(!t)return Ro.debug(`No API key for active provider — skipping`),null;let n=u(),r=l(),i;if(i=e.modelId?Uo(n,e.modelId)??Uo(n,r):Bo(n,r),!i)return Ro.debug(`No model available for provider`,{providerId:n}),null;let a={role:`user`,content:e.prompt,timestamp:Date.now()},o={};i.provider===`adobe`&&(o[`X-Session-Id`]=Wo());try{let n=(await ge(i,{systemPrompt:e.system,messages:[a]},{apiKey:t,maxTokens:e.maxTokens??60,temperature:e.temperature??.3,signal:e.signal,headers:Object.keys(o).length>0?o:void 0})).content.filter(e=>e.type===`text`).map(e=>e.text).join(``).trim();return n.length>0?n:null}catch(e){return Ro.debug(`Quick label call failed`,{error:e instanceof Error?e.message:String(e)}),null}}function Bo(e,t){let n=f(e);if(n.length===0)return;let r=n.find(e=>e.id===t)??n[0],i=Ho(r.id),a=n.filter(e=>Vo(e,r,i));return a.length===0?r:(a.sort((e,t)=>(e.cost?.input??0)-(t.cost?.input??0)),a[0])}function Vo(e,t,n){if(e.id===t.id)return!1;let r=t.cost?.input??1/0;if((e.cost?.input??1/0)>=r)return!1;let i=e.id.toLowerCase();switch(n){case`claude`:return i.includes(`haiku`);case`gpt`:return/(^|-)mini(-|$)|(^|-)nano(-|$)/.test(i);case`gemini`:return i.includes(`flash`);case`grok`:return/(^|-)mini(-|$)|(^|-)fast(-|$)/.test(i);case`unknown`:return!0}}function Ho(e){let t=e.toLowerCase();return t.includes(`claude`)?`claude`:t.includes(`gemini`)?`gemini`:t.includes(`grok`)?`grok`:/^(gpt|o\d)/.test(t)?`gpt`:`unknown`}function Uo(e,t){return f(e).find(e=>e.id===t)}function Wo(){return bt(`ui-quick-llm`)}const Go=e(`sudo-suggest`),Ko=[`You generalize a single shell command into a minimal glob pattern for an`,`allow-list rule. Output ONLY the pattern on one line — no prose, no quotes,`,`no backticks. Keep the leading command/sub-command verbatim and replace only`,`the volatile tail (args, paths, refs) with a single trailing "*".`,`Examples:`,` git push origin main -> git push*`,` rm -rf build/cache -> rm -rf*`,` npm install left-pad -> npm install*`].join(`
2
2
  `),qo=[`You generalize a single filesystem path into a minimal glob pattern for an`,`allow-list rule. Output ONLY the pattern on one line — no prose, no quotes,`,`no backticks. Keep the meaningful directory prefix and replace the volatile`,`leaf (and below) with "**". Examples:`,` /workspace/.git/config -> /workspace/.git/**`,` /shared/secrets/openai.key -> /shared/secrets/**`,` /workspace/src/app/main.ts -> /workspace/src/**`].join(`
3
3
  `);async function Jo(e,t){if(e.suggestedPattern&&e.suggestedPattern.trim().length>0)return e.suggestedPattern.trim();let n=e.detail.trim(),r=e.kind===`command`?Ko:qo,i=null;try{i=await zo({prompt:n,system:r,maxTokens:40,temperature:0,signal:t})}catch(e){Go.debug(`suggestPattern: quickLabel threw`,{error:e instanceof Error?e.message:String(e)}),i=null}return Yo(i)||n}function Yo(e){if(!e)return null;let t=(e.split(`
4
4
  `,1)[0]?.trim()??``).replace(/^`+/,``).replace(/`+$/,``).replace(/^["']/,``).replace(/["']$/,``).trim();return t.length===0?null:t}const Xo=e(`sudo:capability-gesture`);function Zo(e,t={}){let n=t.suggest??Jo;return{async requestApproval(t,r){let i=r?.signal,a;if(t.suggestedPattern)a=t.suggestedPattern;else try{a=await n(t,i)}catch{a=t.detail}if(i?.aborted)return Xo.warn(`sudo approval aborted before prompting — denying`,{detail:t.detail}),{decision:`deny`};if(!e)return Xo.warn(`no CapabilityBroker injected for the sudo gesture hop — denying (composition bug, never a guessed transport)`,{detail:t.detail}),{decision:`deny`};let o=await e.approvals.request({kind:t.kind,detail:t.detail,suggestedPattern:a,...t.requester?{requester:t.requester}:{},...t.reason?{reason:t.reason}:{},...t.approver?{approver:t.approver}:{},...i?{signal:i}:{}});return o.ok?pt(o.value,a):(Xo.warn(`capability broker approvals.request failed — denying`,{message:o.message}),{decision:`deny`})}}}const Qo=e(`sudo:tray-first`);function $o(e,t={}){let n=t.suggest??Jo,r=t.timeoutMs??6e5,i=t.getClient??(async()=>{let{getPanelRpcClient:e}=await import(`./panel-rpc-DW7W4w6_.js`).then(e=>e.a);return e()});return{async requestApproval(t,a){if(a?.signal?.aborted)return{decision:`deny`};let o=t.suggestedPattern;if(!o)try{o=await n(t,a?.signal)}catch{o=t.detail}let s={...t,suggestedPattern:o},c=null;try{c=await i()}catch(e){Qo.debug?.(`panel-RPC client lookup threw — using native broker`,{error:e instanceof Error?e.message:String(e)})}if(c)try{let e=await c.call(`sudo-request`,{request:s,mode:`tray-first`},{timeoutMs:r});if(e?.handled!==!1)return es(e?.decision,o)}catch(e){Qo.warn(`tray-first sudo probe failed — using native broker`,{error:e instanceof Error?e.message:String(e)})}return e.requestApproval(s,a)}}}function es(e,t){if(!e||typeof e!=`object`)return{decision:`deny`};let n=e,r=n.attestation===`biometric`||n.attestation===`passcode`||n.attestation===`none`?n.attestation:void 0;return n.decision===`allow`?{decision:`allow`,...r?{attestation:r}:{}}:n.decision===`always`?{decision:`always`,pattern:typeof n.pattern==`string`&&n.pattern.trim().length>0?n.pattern.trim():t,...r?{attestation:r}:{}}:{decision:`deny`}}function ts(e,t){return{requestApproval(n){return t.enqueueSudoRequest(e,n)}}}function ns(){return`lick-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}var rs=class{pending=new Map;timeoutMs;newId;setTimer;clearTimer;onAutoSettle;constructor(e={}){this.timeoutMs=e.timeoutMs??3e5,this.newId=e.newId??ns,this.setTimer=e.setTimer??((e,t)=>setTimeout(e,t)),this.clearTimer=e.clearTimer??(e=>clearTimeout(e)),this.onAutoSettle=e.onAutoSettle??(()=>{})}notifyAutoSettle(e,t,n){try{this.onAutoSettle(e,t,n)}catch{}}register(e,t,n){let r=this.newId();return{id:r,pending:new Promise(i=>{let a=null;Number.isFinite(this.timeoutMs)&&this.timeoutMs>0&&(a=this.setTimer(()=>{let e=this.pending.get(r);e&&(this.pending.delete(r),e.resolve(st(`cone-timeout`)),this.notifyAutoSettle(r,`expired`,e.scoopJid))},this.timeoutMs)),this.pending.set(r,{scoopJid:e,request:t,resolve:i,timerHandle:a,approverJid:n})})}}resolve(e,t){let n=this.pending.get(e);return n?(this.pending.delete(e),n.timerHandle!=null&&this.clearTimer(n.timerHandle),n.resolve(t),!0):!1}failScoop(e){let t=0;for(let[n,r]of this.pending)r.scoopJid===e&&(this.pending.delete(n),r.timerHandle!=null&&this.clearTimer(r.timerHandle),r.resolve({decision:`deny`}),this.notifyAutoSettle(n,`scoop-dropped`,r.scoopJid),t++);return t}failAll(){let e=0;for(let[t,n]of this.pending)n.timerHandle!=null&&this.clearTimer(n.timerHandle),n.resolve({decision:`deny`}),this.notifyAutoSettle(t,`shutdown`,n.scoopJid),e++;return this.pending.clear(),e}get(e){let t=this.pending.get(e);return t?{id:e,scoopJid:t.scoopJid,request:t.request,...t.approverJid?{approverJid:t.approverJid}:{}}:null}list(){let e=[];for(let[t,n]of this.pending)e.push({id:t,scoopJid:n.scoopJid,request:n.request,...n.approverJid?{approverJid:n.approverJid}:{}});return e}size(){return this.pending.size}};e(`sudo-panel`),typeof globalThis.confirm==`function`&&globalThis.confirm.bind(globalThis),typeof globalThis.prompt==`function`&&globalThis.prompt.bind(globalThis),e(`sudo:page`),e(`sudo`);function is(e){return ct(as(e))}function as(e){let t=Zo(e);return e?.adapter===`extension-direct`||e?.adapter===`extension-delegate`?t:$o(t)}let os=null;function ss(e){return os=e,()=>{os===e&&(os=null)}}function cs(){if(!os)throw new Sa(`session-not-found`);return os}const ls=`focus`,us={type:`leaf`,surfaceId:`chat`};function ds(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}}}const fs={focus:{name:`focus`,tree:ds({left:us},{left:3,middle:1})}};function ps(e){return fs[e]??null}const ms=`progress`;function hs(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)}async function gs(){try{let e=await Tt();if(e.cancelled)throw Error(`mount: cancelled`);if(e.error)throw Error(`mount: ${e.error}`);if(e.handleInIdb&&typeof e.idbKey==`string`){let t=await Et(e.idbKey);if(!t)throw Error(`mount: no directory handle found in storage`);return await wt(t),t}throw Error(`mount: unexpected popup result`)}catch(e){throw Error(`mount: ${e instanceof Error?e.message:String(e)}`)}}async function _s(){if(typeof window>`u`||!(`showDirectoryPicker`in window))throw Error(`mount: local picker requires a user gesture in the panel (unavailable in this runtime). Ask the agent to mount it instead.`);try{return await window.showDirectoryPicker({mode:`readwrite`})}catch(e){throw e instanceof Error&&e.name===`AbortError`?Error(`mount: cancelled`):Error(`mount: ${e instanceof Error?e.message:String(e)}`)}}function vs(e){let t={positional:[],noProbe:!1,clearCache:!1,bodies:!1,json:!1};for(let n=0;n<e.length;n++){let r=e[n];if(r===`--source`)t.source=e[++n];else if(r===`--profile`)t.profile=e[++n];else if(r===`--backend`){let r=e[++n];r===`da`||r===`aem`?t.backend=r:t.backendError=r}else r===`--no-probe`?t.noProbe=!0:r===`--max-body-mb`?t.maxBodyMb=Number(e[++n]):r===`--clear-cache`?t.clearCache=!0:r===`--bodies`?t.bodies=!0:r===`--json`?t.json=!0:t.positional.push(r)}return t}function ys(e){let t=e.match(/^(da|aem):\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);return t?{scheme:t[1],org:t[2],name:t[3],path:(t[4]??``).replace(/^\/+/,``).replace(/\/+$/,``)}:null}const bs=new Set([`--source`,`--profile`,`--backend`,`--max-body-mb`]);function xs(e){for(let t=0;t<e.length;t++){let n=e[t];if(n===`--`)return!1;if(n===`--help`||n===`-h`)return!0;bs.has(n)&&t++}return!1}function Ss(e){return`aem://${e.org}/${e.name}${e.path?`/${e.path}`:``}`}var Cs=class{options;signedFetchS3;signedFetchDa;constructor(e){this.options=e,this.signedFetchS3=e.signedFetchS3,this.signedFetchDa=e.signedFetchDa}async execute(e,t,n){let r=e[0];if(r===`--help`||r===`-h`)return this.help();if(r===`unmount`||r===`-u`)return this.handleUnmount(e.slice(1),t,`mount unmount`);if(r===`list`||r===`-l`||r===`--list`)return this.handleList();if(r===`refresh`)return this.handleRefresh(e.slice(1),t,n);if(r===`info`)return this.handleInfo(e.slice(1),t);let i=vs(e);if(i.positional.length===0)return this.usageError(`mount: mount point required`);let a=this.resolvePath(i.positional[0],t);return i.backendError===void 0?i.source?i.source.startsWith(`s3://`)?this.mountS3(a,i):i.source.startsWith(`da://`)||i.source.startsWith(`aem://`)?this.mountAdobe(a,i):this.usageError(`mount: invalid source '${i.source}' — expected s3://..., da://... or aem://...`):this.mountLocal(a,n):this.usageError(`mount: invalid --backend '${i.backendError}' — expected 'da' or 'aem'`)}async executeUmount(e,t){return this.handleUnmount(e,t,`umount`)}async mountLocal(e,t){try{if((this.options.isScoop??(()=>!1))())throw Error(`mount: cannot mount local directories from a scoop (no UI). Ask the cone.`);let n=Se();if(!n){let n=await ws(e);if(n)return await this.options.fs.mount(e,n,{env:t}),{stdout:`Mounted '${n.describe().displayName}' → ${e}\nIndexing in background for fast file discovery.\nNote: External changes are not auto-detected — use 'mount refresh ${e}' after modifying files outside the browser.\n`,stderr:``,exitCode:0}}let r;if(n){let t=this.options.acquireLocalMountViaToolUI;if(!t)throw Error(`mount: tool UI not available in this runtime`);r=await t(n,e)}else r=v()?await gs():await _s();let i=Ie.fromHandle(r,{mountId:Ue()});return await this.options.fs.mount(e,i,{env:t}),{stdout:`Mounted '${i.describe().displayName}' → ${e}\nIndexing in background for fast file discovery.\nNote: External changes are not auto-detected — use 'mount refresh ${e}' after modifying files outside the browser.\n`,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`mount: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}async mountS3(e,t){if(!t.source)return this.usageError(`mount: --source required`);let n=t.profile??`default`,r=Ue(),i=new We({mountId:r,ttlMs:3e4}),a=new Re({source:t.source,profile:n,cache:i,maxBodyBytes:t.maxBodyMb?t.maxBodyMb*1024*1024:void 0,mountId:r,signedFetch:this.signedFetchS3??ze(n)});if(!t.noProbe)try{await a.readDir(`/`)}catch(e){return await a.close(),{stdout:``,stderr:`mount: probe failed for ${t.source} — ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}return await this.options.fs.mount(e,a),{stdout:`Mounted '${a.describe().displayName}' → ${e} (profile: ${n})\n`,stderr:``,exitCode:0}}async mountAdobe(e,t){if(!t.source)return this.usageError(`mount: --source required`);let n=t.profile??`default`,r=this.signedFetchDa??He(),i=ys(t.source);if(!i)return this.usageError(`mount: invalid source '${t.source}' — expected da://org/repo or aem://org/site`);let a=i.scheme===`aem`?`aem`:`da`,o=``;if(t.backend)a=t.backend;else if(i.scheme===`da`)try{a=(await So(i.org,i.name,r)).backend,a===`aem`&&(o=`mount: ${i.org}/${i.name} is on Helix 6 — its content lives in the Source Bus at https://api.aem.live/${i.org}/sites/${i.name}/source, not admin.da.live. Mounting through aem://${i.org}/${i.name}. Pass --backend da to force the old endpoint.\n`)}catch(e){return{stdout:``,stderr:`mount: could not determine the content source for ${t.source} — ${e instanceof Error?e.message:String(e)}. Pass --backend da or --backend aem to skip this probe.\n`,exitCode:1}}let s=Ue(),c=new We({mountId:s,ttlMs:3e4}),l={source:a===`aem`?Ss(i):`da://${i.org}/${i.name}${i.path?`/${i.path}`:``}`,profile:n,cache:c,maxBodyBytes:t.maxBodyMb?t.maxBodyMb*1024*1024:void 0,mountId:s,signedFetch:r},u=a===`aem`?new Ve(l):new Le(l);if(!t.noProbe)try{await u.readDir(`/`)}catch(e){return await u.close(),{stdout:``,stderr:o+`mount: probe failed for ${l.source} — ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}return await this.options.fs.mount(e,u),{stdout:`Mounted '${u.describe().displayName}' → ${e} (profile: ${n})\n`,stderr:o,exitCode:0}}async handleUnmount(e,t,n){if(xs(e))return n===`umount`?this.umountHelp():this.help();let r=vs(e);if(r.positional.length===0)return{stdout:``,stderr:`${n}: path required\n`,exitCode:1};let i=this.resolvePath(r.positional[0],t);try{let e,t;if(r.clearCache){let{getAllMountEntries:n}=await import(`./mount-table-store-DrF_Ifaz.js`).then(e=>e.r),r=(await n()).find(e=>e.targetPath===i),a=r?.descriptor.kind;r&&(a===`s3`||a===`da`||a===`aem`)&&(e=r.descriptor.mountId,t=r.descriptor.kind)}await this.options.fs.unmount(i);let n=``;if(r.clearCache&&e&&t){let{RemoteMountCache:t}=await import(`./remote-cache-BE5T1-53.js`).then(e=>e.n);await new t({mountId:e,ttlMs:3e4}).clearMount(),n=` (cache cleared)`}else r.clearCache&&(n=` (no remote cache to clear)`);return{stdout:`Unmounted ${i}${n}\n`,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`${n}: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}async handleList(){try{let e=this.options.fs.listMounts();if(e.length===0)return{stdout:`No active mounts
@@ -279,7 +279,7 @@ Examples:
279
279
  skill list
280
280
  skill info bluebubbles
281
281
  skill read bluebubbles
282
- `,stderr:``,exitCode:0};let r=t[0],i=await import(`./kernel-worker-YhNfUQ_y.js`).then(e=>e.n);try{switch(r){case`list`:return eh(t,e,i,n.env.get(`PATH`));case`info`:{let n=t[1];if(!n)return{stdout:``,stderr:`skill: info requires a skill name
282
+ `,stderr:``,exitCode:0};let r=t[0],i=await import(`./kernel-worker-CHzmxrpV.js`).then(e=>e.r);try{switch(r){case`list`:return eh(t,e,i,n.env.get(`PATH`));case`info`:{let n=t[1];if(!n)return{stdout:``,stderr:`skill: info requires a skill name
283
283
  `,exitCode:1};let r=await i.getSkillInfo(e,n);return r?{stdout:Qm(r),stderr:``,exitCode:0}:{stdout:``,stderr:`skill: "${n}" not found\n`,exitCode:1}}case`read`:{let n=t[1];if(!n)return{stdout:``,stderr:`skill: read requires a skill name
284
284
  `,exitCode:1};let r=await i.readSkillInstructions(e,n);return r===null?{stdout:``,stderr:`skill: no SKILL.md found for "${n}"\n`,exitCode:1}:{stdout:r+`
285
285
  `,stderr:``,exitCode:0}}default:return{stdout:``,stderr:`skill: unknown command "${r}"\n`,exitCode:1}}}catch(e){return{stdout:``,stderr:`skill: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}})}const nh=[{names:[`--branch`,`-b`],validate:e=>!e.startsWith(`-`)&&i(e),error:`upskill: --branch must be a git ref of [A-Za-z0-9._/-]+ with no "..", leading "-"/"/", trailing "/" or ".lock", or shell metacharacters`,apply:(e,t)=>{e.branch=t}},{names:[`--from`],validate:e=>Oi(e)!==null,error:`upskill: --from requires a GitHub source (owner/repo, owner/repo@branch, or a github.com URL)`,apply:(e,t)=>{e.from=t}},{names:[`--path`,`-p`],validate:e=>o(e),error:`upskill: --path must be a repo-relative sub-path of [A-Za-z0-9._/-]+ with no "..", leading "-"/"/", or shell metacharacters`,apply:(e,t)=>{e.path=t}}];function rh(e){let t={skills:[],dryRun:!1,json:!1};for(let n=0;n<e.length;n++){let r=e[n],i=nh.find(e=>e.names.includes(r));if(i){let r=e[++n];if(!r||!i.validate(r))return t.error=i.error,t;i.apply(t,r)}else if(r===`--dry-run`||r===`-n`)t.dryRun=!0;else if(r===`--json`)t.json=!0;else if(r.startsWith(`-`))return t.error=`upskill: unknown option "${r}" for update`,t;else t.skills.push(r)}return t}function ih(e,t){return!e||!t||e.byteLength!==t.byteLength?!1:e.every((e,n)=>e===t[n])}async function ah(e,t){try{let n=await e.readFile(t,{encoding:`binary`});return n instanceof Uint8Array?n:new TextEncoder().encode(String(n))}catch{return}}async function oh(e,t,n,r){let i=await ah(e,t);return mi(n)?i?{status:`kept-local`,write:!1}:{status:`added`,write:!0}:i?ih(i,r)?{status:`unchanged`,write:!1}:{status:`updated`,write:!0}:{status:`added`,write:!0}}async function sh(e,t,n,r){let i={changes:[],writes:[],removals:[]};for(let[r,a]of n){let n=`${t}/${r}`,{status:o,write:s}=await oh(e,n,r,a);i.changes.push({path:r,status:o}),s&&i.writes.push({path:n,content:a})}let a=new Set(r.files??[]);for(let r of await hi(e,t)){if(n.has(r))continue;let e=a.has(r);i.changes.push({path:r,status:e?`removed`:`kept-local`}),e&&i.removals.push(`${t}/${r}`)}return i.changes.sort((e,t)=>e.path.localeCompare(t.path)),i}async function ch(e,t,n,r,i,a){let o={skill:n,source:`${r.kind}:${r.source}`,ref:i??r.ref,from:r.sha,outcome:`current`,changes:[]},[s,c]=r.source.split(`/`);if(!s||!c)return{...o,outcome:`error`,error:`unusable source "${r.source}"`};let l=(r.path??``).replace(/^\/|\/$/g,``),u=await bi(t),d=await Si(s,c,o.ref,u,!0,l||void 0);if(d&&r.sha===d&&await lh(e,n,r))return{...o,to:d,outcome:`current`,changes:[]};let f=await uh(s,c,l,n,o.ref,t,u);if(`error`in f)return{...o,outcome:`error`,error:f.error};let p=f.files,m=f.path;if(p.size===0)return{...o,outcome:`error`,error:`no files at ${s}/${c}${m?`/${m}`:``} — the skill may have moved or been removed upstream`};let{changes:h,writes:g,removals:_}=await sh(e,`${si}/${n}`,p,r),v=g.length>0||_.length>0;if(a)return{...o,outcome:v?`updated`:`current`,changes:h};let ee=d??r.sha;return v&&await hh(e,{changes:h,writes:g,removals:_}),await Ci(e,n,{...r,ref:o.ref,path:m,sha:ee,files:[...p.keys()].sort()}),{...o,to:ee,outcome:v?`updated`:`current`,changes:h}}async function lh(e,t,n){if(!n.files?.length)return!1;for(let r of n.files)if(!await e.exists(`/workspace/skills/${t}/${r}`))return!1;return!0}async function uh(e,t,n,r,i,a,o){let s=await _i(e,t,a,i??`main`);if(s.status===`ok`){let i=fi(s.files),a=n||dh(i,r);return a===null?{error:`could not find "${r}/SKILL.md" in ${e}/${t} — pass --path <dir> to say where the skill lives`}:{files:mh(i,a),path:a}}try{return{files:ph(fh(await gi(e,t,n,i,o))),path:n}}catch(e){let t=e instanceof Error?e.message:String(e);return{error:`${s.message}; Contents API fallback failed: ${t}`}}}function dh(e,t){let n=[];for(let r of Object.keys(e))r===`SKILL.md`?n.push(``):(r.endsWith(`/${t}/SKILL.md`)||r===`${t}/SKILL.md`)&&n.push(r.slice(0,-9));return n.length===0?null:(n.sort((e,t)=>e.split(`/`).length-t.split(`/`).length||e.localeCompare(t)),n[0])}function fh(e){return new Map([...e].filter(([e])=>pi(e)))}function ph(e){return new Map([...e].sort(([e],[t])=>e.localeCompare(t)))}function mh(e,t){let n=t?`${t}/`:``,r=new Map;for(let[t,i]of Object.entries(e)){if(!t.startsWith(n)||t.endsWith(`/`))continue;let e=t.slice(n.length);pi(e)&&r.set(e,i)}return ph(r)}async function hh(e,t){for(let n of t.writes){let t=n.path.slice(0,n.path.lastIndexOf(`/`));await e.mkdir(t,{recursive:!0}),await e.writeFile(n.path,n.content)}for(let n of t.removals)await e.rm(n).catch(()=>{})}async function gh(e,t,n,r,i){let a={skill:n,source:`${r.kind}:${r.source}`,outcome:`current`,changes:[]},[o,s]=r.source.split(`/`);if(!o||!s)return{...a,outcome:`error`,error:`unusable source "${r.source}"`};let c=await qm(o,s,t);if(!c.ok)return{...a,outcome:`error`,error:c.error};let l=`${si}/${n}/SKILL.md`,u=await ah(e,l),d=new TextEncoder().encode(c.content),f=u!==void 0&&Gm(new TextDecoder().decode(u))===Gm(c.content);if(ih(u,d)||f)return{...a,changes:[{path:`SKILL.md`,status:`unchanged`}]};let p=u?`updated`:`added`;return i||(await e.mkdir(`${si}/${n}`,{recursive:!0}),await e.writeFile(l,d),await Ci(e,n,{...r,files:[`SKILL.md`]})),{...a,outcome:`updated`,changes:[{path:`SKILL.md`,status:p}]}}function _h(e,t){if(e.outcome===`error`)return` ${e.skill}: failed — ${e.error}\n`;let n=new Map;for(let t of e.changes)n.set(t.status,(n.get(t.status)??0)+1);let r=e.to&&e.to!==e.from?` → ${e.to.slice(0,7)}`:``;if(e.outcome===`current`)return` ${e.skill}: already current (${e.source}${r})\n`;let i=t?`would update`:`updated`,a=` ${e.skill}: ${i} from ${e.source}${r}\n`;for(let t of e.changes)t.status!==`unchanged`&&(a+=` ${t.status.padEnd(10)} ${t.path}\n`);let o=n.get(`kept-local`)??0;return o>0&&(a+=` (${o} kept-local — dotfiles and local additions are never touched)\n`),a}function vh(e,t,n,r){let i=Oi(t);return i?{version:1,kind:`github`,source:`${i.owner}/${i.repo}`,skill:e,ref:r??i.branch,path:n??i.path,installed:new Date().toISOString()}:null}async function yh(e,t,n){if(t.length===0){let t=await xi(e);return{targets:t.provenanced,missing:[],skipped:t.unattributed}}let r=[],i=[];for(let a of t){let t=await wi(e,a);if(t){r.push({name:a,provenance:t});continue}if(!await e.exists(`/workspace/skills/${a}`)){i.push({name:a,reason:`not-installed`});continue}let o=n.from?vh(a,n.from,n.path,n.branch):null;o?r.push({name:a,provenance:o}):i.push({name:a,reason:`no-provenance`})}return{targets:r,missing:i,skipped:[]}}function bh(e){return e.reason===`not-installed`?`upskill: no skill named "${e.name}" is installed — check \`upskill list\`
@@ -290,7 +290,7 @@ Examples:
290
290
  `}function Ch(e,t,n,r,i){let a=t?`Skill update (dry run — nothing written):
291
291
  `:`Skill update:
292
292
  `;for(let n of e)a+=_h(n,t);if(i.length>0&&(a+=Sh(i)),!n&&r&&e.length>0){let n=i.length>0?`all ${xh(e.length,`skill`)} with provenance ${e.length===1?`is`:`are`}`:`all skills are`;a+=t?`\n${n.charAt(0).toUpperCase()}${n.slice(1)} current.\n`:`\nNothing to update — ${n} current.\n`}return a}async function wh(e,t,n){let{targets:r,missing:i,skipped:a}=await yh(e,n.skills,{skills:n.skills,dryRun:n.dryRun,json:!1,branch:n.branch,from:n.from,path:n.path}),o=[];for(let i of r)o.push(i.provenance.kind===`browse.sh`?await gh(e,t,i.name,i.provenance,n.dryRun):await ch(e,t,i.name,i.provenance,n.branch,n.dryRun));return{results:o,skipped:a,missing:i}}async function Th(e,t,n){let r=rh(e);if(r.error)return{stdout:``,stderr:`${r.error}\n`,exitCode:1};let{results:i,missing:a,skipped:o}=await wh(t,n,r);if(i.length===0)return a.length===0&&o.length>0?{stdout:r.json?`${JSON.stringify({ok:!0,dryRun:r.dryRun,results:[],skipped:o})}\n`:Ch([],r.dryRun,!1,!0,o),stderr:``,exitCode:0}:{stdout:``,stderr:a.length?a.map(bh).join(``):"upskill: no skill has install provenance yet — reinstall a skill, or run `upskill update <skill> --from <owner>/<repo>`, to record its source\n",exitCode:1};let s=i.filter(e=>e.outcome===`error`),c=i.some(e=>e.outcome===`updated`);c&&!r.dryRun&&await Di();let l=a.map(bh).join(``)+s.map(e=>`upskill: ${e.skill}: ${e.error}\n`).join(``),u=s.length===0&&a.length===0;return r.json?{stdout:`${JSON.stringify({ok:u,dryRun:r.dryRun,results:i,skipped:o})}\n`,stderr:l,exitCode:+!u}:{stdout:Ch(i,r.dryRun,c,u,o),stderr:l,exitCode:+!u}}function Eh(e){let t={outdated:!1,json:!1};for(let n of e)if(n===`--outdated`)t.outdated=!0;else if(n===`--json`)t.json=!0;else if(n.startsWith(`-`))return t.error=`upskill: unknown option "${n}" for list`,t;else return t.error=`upskill: unexpected argument "${n}" for list`,t;return t}function Dh(e){return e.to&&e.from&&e.to!==e.from?` ${e.from.slice(0,7)} → ${e.to.slice(0,7)}`:e.to?` ${e.to.slice(0,7)}`:``}function Oh(e,t){let n=e.filter(e=>e.outcome===`updated`),r=[];if(n.length===0)r.push(`No outdated skills.`);else{r.push(`Outdated skills:`,``);for(let e of n)r.push(` ${e.skill} ${e.source}${Dh(e)}`)}if(t.length>0){let e=t.length===1?`skill`:`skills`;r.push(``,`Skipped ${t.length} ${e} with no install provenance — not checked.`)}let i=e.filter(e=>e.outcome===`error`);if(i.length>0){let e=i.length===1?`skill`:`skills`;r.push(``,`Could not check ${i.length} ${e}:`);for(let e of i)r.push(` ${e.skill}: failed — ${e.error}`)}return`${r.join(`
293
- `)}\n`}async function kh(e,t,n){let r=await(await import(`./kernel-worker-YhNfUQ_y.js`).then(e=>e.n)).discoverSkills(e),{collisions:i}=await Gn(e,Hn(n));return t?{stdout:`${JSON.stringify({ok:!0,skills:r,commandCollisions:i})}\n`,stderr:``,exitCode:0}:r.length===0?{stdout:`No discoverable local skills found.\n\n${Ym()}`,stderr:``,exitCode:0}:{...Kn(`upskill`,Zm(r,`Discoverable local skills`),i,{builtinNames:new Set(Ze())}),exitCode:0}}async function Ah(e,t,n){let{results:r,skipped:i}=await wh(e,t,{skills:[],dryRun:!0}),a=r.filter(e=>e.outcome===`updated`),o=r.filter(e=>e.outcome===`error`),s=o.length===0,c=o.map(e=>`upskill: ${e.skill}: ${e.error}\n`).join(``);return n?{stdout:`${JSON.stringify({ok:s,results:[...a,...o],skipped:i})}\n`,stderr:c,exitCode:+!s}:{stdout:Oh(r,i),stderr:c,exitCode:+!s}}async function jh(e,t,n,r){let i=Eh(e);return i.error?{stdout:``,stderr:`${i.error}\n`,exitCode:1}:i.outdated?Ah(t,n,i.json):kh(t,i.json,r)}async function Mh(e,t){let n=`${ci}/experimental/search?q=${encodeURIComponent(e)}&contentType=skills&page%5Bsize%5D=20`,r;try{r=await t(n,{headers:{Accept:`application/json`}})}catch(e){throw Error(yi(e,n))}if(r.status!==200)throw Error(`Tessl returned HTTP ${r.status}`);let i=de(r.body);if(!i.data)return[];let a=new Map;for(let e of i.data){if(e.type!==`skill`)continue;let t=e.attributes,n=Ei(t.sourceUrl),r=n?`${n.owner}/${n.repo}`:void 0,i=t.scores.aggregate==null?null:Math.round(t.scores.aggregate*100),o=t.sourceUrl||e.id,s=a.get(o);if(s&&s.qualityScore!=null&&i!=null&&s.qualityScore>=i)continue;let c=t.path.replace(/\/SKILL\.md$/i,``),l=c.split(`/`).pop()||t.name,u=n?`upskill ${n.owner}/${n.repo} --path ${c.split(`/`).slice(0,-1).join(`/`)||`.`} --skill ${l}`:`upskill tessl:${t.name}`;a.set(o,{name:t.name,displayName:t.name,summary:t.description||``,source:`tessl`,qualityScore:i,installHint:u,featured:t.featured,sourceRepo:r})}return Array.from(a.values())}async function Nh(e,t){let n=`${ci}/experimental/search?q=${encodeURIComponent(e)}&contentType=skills&page%5Bsize%5D=5`,r;try{r=await t(n,{headers:{Accept:`application/json`}})}catch(e){return{error:`Tessl search failed: ${yi(e,n)}`}}if(r.status!==200)return{error:`Tessl search failed (HTTP ${r.status})`};let i=de(r.body).data?.find(t=>t.type===`skill`&&t.attributes.name===e);if(!i)return{error:`skill "${e}" not found on Tessl registry`};let a=Ei(i.attributes.sourceUrl);if(!a)return{error:`skill "${e}" has no GitHub source URL`};let o=i.attributes.path.replace(/\/SKILL\.md$/i,``);return{owner:a.owner,repo:a.repo,skillPath:o,skillName:e}}const Ph=[{label:`Tessl`,host:new URL(ci).host,fetch:Mh},{label:`browse.sh`,host:new URL(di).host,fetch:zm}];function Fh(e){let t=[],n=e.reduce((e,t)=>Math.max(e,t.length),0);for(let r=0;r<n;r++)for(let n of e)r<n.length&&t.push(n[r]);return t}async function Ih(e,t,n=1){let r=await Promise.allSettled(Ph.map(n=>n.fetch(e,t))),i=r.map(e=>e.status===`fulfilled`?e.value:[]),a=r.every(e=>e.status===`rejected`),o=Fh(i),s=``;for(let e=0;e<r.length;e++){let t=r[e];if(t.status===`rejected`){let n=Ph[e],r=t.reason instanceof Error?t.reason.message:String(t.reason);s+=`warning: ${n.label} registry unavailable (${n.host}): ${r}\n`}}if(o.length===0){let t=a?`${s}upskill: registries failed to respond\n`:s;return{stdout:`No skills found for "${e}"\n\nTry a different search term or browse the registries at https://tessl.io/registry or https://browse.sh\n`,stderr:t,exitCode:+!!a}}let c=o.length,l=Math.ceil(c/10),u=Math.max(1,Math.min(n,l)),d=(u-1)*10,f=o.slice(d,d+10),p=`Search results for "${e}" (page ${u}/${l}, ${c} total):\n\n`;for(let e of f){let t=e.qualityScore==null?` `:String(e.qualityScore).padStart(3),n=`[${e.source}]`,r=e.sourceRepo?` ${e.sourceRepo}`:``;p+=` ${e.name.padEnd(30)} ${t} ${n.padEnd(10)}${r}\n`,e.summary&&(p+=` ${e.summary}\n`),p+=`
293
+ `)}\n`}async function kh(e,t,n){let r=await(await import(`./kernel-worker-CHzmxrpV.js`).then(e=>e.r)).discoverSkills(e),{collisions:i}=await Gn(e,Hn(n));return t?{stdout:`${JSON.stringify({ok:!0,skills:r,commandCollisions:i})}\n`,stderr:``,exitCode:0}:r.length===0?{stdout:`No discoverable local skills found.\n\n${Ym()}`,stderr:``,exitCode:0}:{...Kn(`upskill`,Zm(r,`Discoverable local skills`),i,{builtinNames:new Set(Ze())}),exitCode:0}}async function Ah(e,t,n){let{results:r,skipped:i}=await wh(e,t,{skills:[],dryRun:!0}),a=r.filter(e=>e.outcome===`updated`),o=r.filter(e=>e.outcome===`error`),s=o.length===0,c=o.map(e=>`upskill: ${e.skill}: ${e.error}\n`).join(``);return n?{stdout:`${JSON.stringify({ok:s,results:[...a,...o],skipped:i})}\n`,stderr:c,exitCode:+!s}:{stdout:Oh(r,i),stderr:c,exitCode:+!s}}async function jh(e,t,n,r){let i=Eh(e);return i.error?{stdout:``,stderr:`${i.error}\n`,exitCode:1}:i.outdated?Ah(t,n,i.json):kh(t,i.json,r)}async function Mh(e,t){let n=`${ci}/experimental/search?q=${encodeURIComponent(e)}&contentType=skills&page%5Bsize%5D=20`,r;try{r=await t(n,{headers:{Accept:`application/json`}})}catch(e){throw Error(yi(e,n))}if(r.status!==200)throw Error(`Tessl returned HTTP ${r.status}`);let i=de(r.body);if(!i.data)return[];let a=new Map;for(let e of i.data){if(e.type!==`skill`)continue;let t=e.attributes,n=Ei(t.sourceUrl),r=n?`${n.owner}/${n.repo}`:void 0,i=t.scores.aggregate==null?null:Math.round(t.scores.aggregate*100),o=t.sourceUrl||e.id,s=a.get(o);if(s&&s.qualityScore!=null&&i!=null&&s.qualityScore>=i)continue;let c=t.path.replace(/\/SKILL\.md$/i,``),l=c.split(`/`).pop()||t.name,u=n?`upskill ${n.owner}/${n.repo} --path ${c.split(`/`).slice(0,-1).join(`/`)||`.`} --skill ${l}`:`upskill tessl:${t.name}`;a.set(o,{name:t.name,displayName:t.name,summary:t.description||``,source:`tessl`,qualityScore:i,installHint:u,featured:t.featured,sourceRepo:r})}return Array.from(a.values())}async function Nh(e,t){let n=`${ci}/experimental/search?q=${encodeURIComponent(e)}&contentType=skills&page%5Bsize%5D=5`,r;try{r=await t(n,{headers:{Accept:`application/json`}})}catch(e){return{error:`Tessl search failed: ${yi(e,n)}`}}if(r.status!==200)return{error:`Tessl search failed (HTTP ${r.status})`};let i=de(r.body).data?.find(t=>t.type===`skill`&&t.attributes.name===e);if(!i)return{error:`skill "${e}" not found on Tessl registry`};let a=Ei(i.attributes.sourceUrl);if(!a)return{error:`skill "${e}" has no GitHub source URL`};let o=i.attributes.path.replace(/\/SKILL\.md$/i,``);return{owner:a.owner,repo:a.repo,skillPath:o,skillName:e}}const Ph=[{label:`Tessl`,host:new URL(ci).host,fetch:Mh},{label:`browse.sh`,host:new URL(di).host,fetch:zm}];function Fh(e){let t=[],n=e.reduce((e,t)=>Math.max(e,t.length),0);for(let r=0;r<n;r++)for(let n of e)r<n.length&&t.push(n[r]);return t}async function Ih(e,t,n=1){let r=await Promise.allSettled(Ph.map(n=>n.fetch(e,t))),i=r.map(e=>e.status===`fulfilled`?e.value:[]),a=r.every(e=>e.status===`rejected`),o=Fh(i),s=``;for(let e=0;e<r.length;e++){let t=r[e];if(t.status===`rejected`){let n=Ph[e],r=t.reason instanceof Error?t.reason.message:String(t.reason);s+=`warning: ${n.label} registry unavailable (${n.host}): ${r}\n`}}if(o.length===0){let t=a?`${s}upskill: registries failed to respond\n`:s;return{stdout:`No skills found for "${e}"\n\nTry a different search term or browse the registries at https://tessl.io/registry or https://browse.sh\n`,stderr:t,exitCode:+!!a}}let c=o.length,l=Math.ceil(c/10),u=Math.max(1,Math.min(n,l)),d=(u-1)*10,f=o.slice(d,d+10),p=`Search results for "${e}" (page ${u}/${l}, ${c} total):\n\n`;for(let e of f){let t=e.qualityScore==null?` `:String(e.qualityScore).padStart(3),n=`[${e.source}]`,r=e.sourceRepo?` ${e.sourceRepo}`:``;p+=` ${e.name.padEnd(30)} ${t} ${n.padEnd(10)}${r}\n`,e.summary&&(p+=` ${e.summary}\n`),p+=`
294
294
  `}return u<l&&(p+=`Showing ${d+1}-${d+f.length} of ${c}. `,p+=`Next page: upskill search ${e} --page ${u+1}\n\n`),p+=`To install:
295
295
  `,p+=` From Tessl: upskill <owner/repo> --skill <name>
296
296
  `,p+=` From browse.sh: upskill browse:<hostname>/<task>
@@ -313,7 +313,7 @@ Examples:
313
313
  `,{stdout:s,stderr:``,exitCode:0}}function Uh(e){return!e||e.startsWith(`-`)?{stdout:``,stderr:`upskill: --branch requires a value
314
314
  `,exitCode:1}:i(e)?null:{stdout:``,stderr:`upskill: --branch must be a git ref of [A-Za-z0-9._/-]+ with no "..", leading "-"/"/", trailing "/" or ".lock", or shell metacharacters
315
315
  `,exitCode:1}}function Wh(e){let t={selectedSkills:[],listOnly:!1,installAll:!1,force:!1,sourceRef:``},n=0;for(;n<e.length;){let r=e[n];if(r===`--skill`)t.selectedSkills.push(e[++n]);else if(r===`--path`||r===`-p`){let r=e[++n];if(typeof r!=`string`||!o(r))return t.earlyReturn={stdout:``,stderr:`upskill: --path must be a repo-relative sub-path of [A-Za-z0-9._/-]+ with no "..", leading "-"/"/", or shell metacharacters
316
- `,exitCode:1},t;t.subPath=r}else if(r===`--list`)t.listOnly=!0;else if(r===`--all`)t.installAll=!0;else if(r===`--force`)t.force=!0;else if(r===`--branch`||r===`-b`){let r=Uh(e[n+1]);if(r)return t.earlyReturn=r,t;t.branch=e[++n]}else r.startsWith(`-`)||(t.sourceRef=r);n++}return t}async function Gh(e,t,n){if(!t)return{stdout:``,stderr:`upskill: ${e} requires a skill name\n`,exitCode:1};let r=await import(`./kernel-worker-YhNfUQ_y.js`).then(e=>e.n);if(e===`info`){let e=await r.getSkillInfo(n,t);if(!e)return{stdout:``,stderr:`upskill: skill "${t}" not found\n`,exitCode:1};let i=await wi(n,t),a=i?Ti(i):"Installed from: (no provenance recorded — reinstall to enable `upskill update`)\n";return{stdout:Qm(e)+a,stderr:``,exitCode:0}}let i=await r.readSkillInstructions(n,t);return i===null?{stdout:``,stderr:`upskill: no SKILL.md found for "${t}"\n`,exitCode:1}:{stdout:i+`
316
+ `,exitCode:1},t;t.subPath=r}else if(r===`--list`)t.listOnly=!0;else if(r===`--all`)t.installAll=!0;else if(r===`--force`)t.force=!0;else if(r===`--branch`||r===`-b`){let r=Uh(e[n+1]);if(r)return t.earlyReturn=r,t;t.branch=e[++n]}else r.startsWith(`-`)||(t.sourceRef=r);n++}return t}async function Gh(e,t,n){if(!t)return{stdout:``,stderr:`upskill: ${e} requires a skill name\n`,exitCode:1};let r=await import(`./kernel-worker-CHzmxrpV.js`).then(e=>e.r);if(e===`info`){let e=await r.getSkillInfo(n,t);if(!e)return{stdout:``,stderr:`upskill: skill "${t}" not found\n`,exitCode:1};let i=await wi(n,t),a=i?Ti(i):"Installed from: (no provenance recorded — reinstall to enable `upskill update`)\n";return{stdout:Qm(e)+a,stderr:``,exitCode:0}}let i=await r.readSkillInstructions(n,t);return i===null?{stdout:``,stderr:`upskill: no SKILL.md found for "${t}"\n`,exitCode:1}:{stdout:i+`
317
317
  `,stderr:``,exitCode:0}}async function Kh(e,t,n,r,i,a,o,s){let c=``,l=``,u=0,d=e.length;for(let f=0;f<e.length;f++){let p=e[f],m=await Ai(p.path,p.name,r,i,a,s?{...s,path:p.path}:void 0),h=f+1,g=((Date.now()-o)/1e3).toFixed(1),_=(Date.now()-o)/h,v=h<d?` (~${Math.round((d-h)*_/1e3)}s remaining)`:``;m.ok?(c+=`[${h}/${d}] Installed "${p.name}" from ${t}/${n} (${g}s)${v}\n`,u++):(c+=`[${h}/${d}] Failed "${p.name}": ${m.error}${v}\n`,l+=`upskill: ${m.error}\n`)}return{output:c,errors:l,successCount:u}}async function qh(e,t,n,r,i,a,o,s){let c=``,l=``,u=0,d=e.length;for(let f=0;f<e.length;f++){let p=e[f],m=await ki(t,n,p.path,p.name,i,r,a,void 0,o),h=f+1,g=((Date.now()-s)/1e3).toFixed(1),_=(Date.now()-s)/h,v=h<d?` (~${Math.round((d-h)*_/1e3)}s remaining)`:``;m.exitCode===0?(c+=`[${h}/${d}] Installed "${p.name}" from ${t}/${n} (${g}s)${v}\n`,u++):(c+=`[${h}/${d}] Failed "${p.name}": ${m.stderr.trim()}${v}\n`,l+=m.stderr)}return{output:c,errors:l,successCount:u}}async function Jh(e,t,n,r,i,a,o,s){let c=``,l=``,u=0;for(let d of e){let e=await ki(t,n,d.path,d.name,i,r,a,o,s);e.exitCode===0?(c+=e.stdout,u++):l+=e.stderr}return{output:c,errors:l,successCount:u}}function Yh(e,t,n){let r=`Available skills in ${t}/${n}:\n\n`;for(let t of e)r+=` ${t.name.padEnd(30)} ${t.path}\n`;return r+=`\nFound ${e.length} skill(s)\n`,r}async function Xh(e,t,n,r){let{owner:i,repo:a}=e,o=t.branch??e.branch,s=t.subPath??e.path,c=await bi(r),l=await ji(i,a,c,s,r,o);if(l.error)return{stdout:``,stderr:`upskill: failed to list skills: ${l.error}\n`,exitCode:1};if(l.skills.length===0)return{stdout:`No skills found in ${i}/${a}${s?`/`+s:``}\n`,stderr:``,exitCode:0};if(t.listOnly)return{stdout:Yh(l.skills,i,a)+`\nTo install: upskill ${t.sourceRef} --skill <name>\nTo install all: upskill ${t.sourceRef} --all\n`,stderr:``,exitCode:0};let u=l.skills;if(t.selectedSkills.length>0){u=l.skills.filter(e=>t.selectedSkills.includes(e.name));for(let e of t.selectedSkills)if(!l.skills.find(t=>t.name===e))return{stdout:``,stderr:`upskill: skill "${e}" not found in ${i}/${a}\n`,exitCode:1}}else if(!t.installAll)return{stdout:Yh(l.skills,i,a)+`\nTo install specific skills: upskill ${t.sourceRef} --skill <name>\nTo install all: upskill ${t.sourceRef} --all\n`,stderr:``,exitCode:0};let d=u.length,f=Date.now(),p=``,m=``,h=0;if(d>1){let e=await _i(i,a,r,o);if(e.status===`ok`){let r=await Si(i,a,o,c,!0,s),l=await Kh(u,i,a,fi(e.files),n,t.force,f,{kind:`github`,source:`${i}/${a}`,ref:o,sha:r});({output:p,errors:m,successCount:h}=l)}else{let e=await qh(u,i,a,c,n,t.force,o,f);({output:p,errors:m,successCount:h}=e)}}else({output:p,errors:m,successCount:h}=await Jh(u,i,a,c,n,t.force,r,o));let g=((Date.now()-f)/1e3).toFixed(1);return h>0&&(p+=`\nInstalled ${h} skill(s)${d>1?` in ${g}s`:``}\n`,await Di()),{stdout:p,stderr:m,exitCode:+!!m}}async function Zh(e,t,n,r,i){switch(e[0]){case`tabs`:return Vh(t,n,r,e.includes(`--json`));case`recommendations`:return Hh(t,n,e.includes(`--install`));case`update`:case`upgrade`:return Th(e.slice(1),t,n);case`list`:return jh(e.slice(1),t,n,i);case`info`:case`read`:return Gh(e[0],e[1],t);case`search`:return $h(e,n);default:return null}}function Qh(e,t,n){return S(`upskill`,async(r,i)=>{if(r.length===0||r.includes(`--help`)||r.includes(`-h`))return $m();let a=await Zh(r,e,t,n,i.env.get(`PATH`));if(a)return a;let o=Wh(r);if(o.earlyReturn)return o.earlyReturn;if(!o.sourceRef)return $m();if(o.sourceRef.startsWith(`tessl:`))return eg(o.sourceRef,o.force,e,t);let s=Hm(o.sourceRef);if(s)return Jm(s.hostname,s.task,e,t,o.force);let c=Oi(o.sourceRef);return c?Xh(c,o,e,t):{stdout:``,stderr:`upskill: unrecognized source "${o.sourceRef}"\n\nExpected: owner/repo, tessl:<name>, or browse:<hostname>/<task>\n`,exitCode:1}})}async function $h(e,t){let n=[...e.slice(1)],r=n.indexOf(`--page`),i=1;r>=0&&(i=parseInt(n[r+1],10)||1,n.splice(r,2));let a=n.join(` `);return a?Ih(a,t,i):$m()}async function eg(e,t,n,r){let i=e.slice(6);if(!i)return{stdout:``,stderr:`upskill: tessl: requires a skill name
318
318
  `,exitCode:1};let a=await Nh(i,r);if(`error`in a)return{stdout:``,stderr:`upskill: ${a.error}\n`,exitCode:1};let o=await bi(r);return ki(a.owner,a.repo,a.skillPath,a.skillName,n,o,t,r)}function tg(){return{stdout:`usage: afplay [-v volume] [-r rate] <file>
319
319
 
@@ -415,7 +415,7 @@ Examples:
415
415
  agent --background-after 60 . "*" "run the slow build and report"
416
416
  `,stderr:``,exitCode:0};if(r.error)return{stdout:``,stderr:`${r.error}\n`,exitCode:1};let i=r.cwd??``;if(i===``)return{stdout:``,stderr:`agent: <cwd> must not be empty
417
417
  `,exitCode:1};let a=Ag(i,n.cwd),o=jg(r.allowedCommandsRaw??``),s=r.prompt??``,c=null,l=!1;try{c=await n.fs.stat(a)}catch{l=!0}let u=Fg(c,l,i);if(u)return{stdout:``,stderr:u,exitCode:1};let d=Ig(n.fs,a,i);if(d)return{stdout:``,stderr:d,exitCode:1};let f=Pg();return f?zg(f,Lg(r,a,o,s,n,t)):{stdout:``,stderr:`agent: orchestrator bridge not available
418
- `,exitCode:1}})}async function zg(e,t){try{let n=await e.spawn(t),r=typeof n?.exitCode==`number`?n.exitCode:0,i=n?.finalText;return r===0?{stdout:Mg(i),stderr:``,exitCode:0}:{stdout:``,stderr:Ng(i),exitCode:r}}catch(e){let t=e instanceof Error?e.message:String(e);return yg.error(`agent bridge threw`,e),{stdout:``,stderr:`${t}\n`,exitCode:1}}}const Bg=[`bg`,`caller`,`disown`,`enable`,`fc`,`fg`,`jobs`,`logout`,`suspend`,`times`,`trap`,`ulimit`];function Vg(){return Bg.map(e=>S(e,async(t,n)=>{let{runBashBuiltin:r}=await import(`./run-C_6GKpBV.js`);return r(e,t,n)}))}function Hg(e,t){e.escaped?e.escaped=!1:t===`\\`?e.escaped=!0:t===`"`&&(e.inString=!1)}function Ug(e,t){let n=t+2;for(;n<e.length&&e[n]!==`
418
+ `,exitCode:1}})}async function zg(e,t){try{let n=await e.spawn(t),r=typeof n?.exitCode==`number`?n.exitCode:0,i=n?.finalText;return r===0?{stdout:Mg(i),stderr:``,exitCode:0}:{stdout:``,stderr:Ng(i),exitCode:r}}catch(e){let t=e instanceof Error?e.message:String(e);return yg.error(`agent bridge threw`,e),{stdout:``,stderr:`${t}\n`,exitCode:1}}}const Bg=[`bg`,`caller`,`disown`,`enable`,`fc`,`fg`,`jobs`,`logout`,`suspend`,`times`,`trap`,`ulimit`];function Vg(){return Bg.map(e=>S(e,async(t,n)=>{let{runBashBuiltin:r}=await import(`./run-DaUWBY-8.js`);return r(e,t,n)}))}function Hg(e,t){e.escaped?e.escaped=!1:t===`\\`?e.escaped=!0:t===`"`&&(e.inString=!1)}function Ug(e,t){let n=t+2;for(;n<e.length&&e[n]!==`
419
419
  `&&e[n]!==`\r`;)n++;return{text:` `.repeat(n-t),end:n-1}}function Wg(e,t){let n=` `,r=t+2;for(;r<e.length&&(e[r]!==`*`||e[r+1]!==`/`);)n+=e[r]===`
420
420
  `||e[r]===`\r`?e[r]:` `,r++;return r<e.length&&(n+=` `,r++),{text:n,end:r}}function Gg(e){let t=``,n={inString:!1,escaped:!1};for(let r=0;r<e.length;r++){let i=e[r],a=e[r+1];if(n.inString){t+=i,Hg(n,i);continue}if(i===`"`){n.inString=!0,t+=i;continue}if(i===`/`&&a===`/`){let n=Ug(e,r);t+=n.text,r=n.end;continue}if(i===`/`&&a===`*`){let n=Wg(e,r);t+=n.text,r=n.end;continue}t+=i}return t}function Kg(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(n){t+=a,r?r=!1:a===`\\`?r=!0:a===`"`&&(n=!1);continue}if(a===`"`){n=!0,t+=a;continue}if(a===`,`){let t=i+1;for(;t<e.length&&/\s/.test(e[t]);)t++;if(e[t]===`}`||e[t]===`]`)continue}t+=a}return t}function qg(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Jg(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,n=JSON.parse(Kg(Gg(t)));if(!qg(n))throw Error(`configuration must contain a JSON object`);return n}function Yg(e){if(typeof e==`string`)return e;if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e.path;return typeof t==`string`?t:null}function Xg(e){let t=e.plugins;if(!Array.isArray(t))return null;for(let e of t){let t=Yg(e);if(t!==null)return t}return null}async function Zg(e,t){let n=b(t);for(;;){if(!n.split(`/`).includes(`node_modules`))for(let t of[`biome.json`,`biome.jsonc`]){let r=x(n,t);if(await e.exists(r))return r}if(n===`/`)return null;n=Ee(n).dir}}async function Qg(e,t,n){let r;try{r=await e.readFile(t)}catch(e){return{ok:!1,error:`biome: failed to read configuration ${t}: ${e instanceof Error?e.message:String(e)}`,exitCode:n}}try{let e=Jg(r),i=Xg(e);return i===null?{ok:!0,resolved:{path:t,configuration:e}}:{ok:!1,error:`biome: unsupported configuration ${t}: path-based plugin ${JSON.stringify(i)} cannot be loaded by @biomejs/js-api@6.0.0`,exitCode:n}}catch(e){return{ok:!1,error:`biome: failed to parse configuration ${t}: ${e instanceof Error?e.message:String(e)}`,exitCode:n}}}async function $g(e,t,n,r){if(r!==null){let n=b(e.resolvePath(t,r));return await e.exists(n)?Qg(e,n,2):{ok:!1,error:`biome: configuration file not found: ${n}`,exitCode:2}}let i=await Zg(e,n);return i===null?{ok:!0,resolved:null}:Qg(e,i,1)}const e_=new Set(`address.article.aside.blockquote.dd.div.dl.dt.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hr.li.main.nav.ol.p.pre.section.table.tbody.td.tfoot.th.thead.tr.ul`.split(`.`)),t_={amp:`&`,apos:`'`,gt:`>`,lt:`<`,nbsp:` `,quot:`"`};function n_(e){let t=e.slice(1,-1);if(!t.startsWith(`#`))return t_[t.toLowerCase()]??e;let n=t[1]?.toLowerCase()===`x`,r=Number.parseInt(t.slice(n?2:1),n?16:10);return!Number.isFinite(r)||r<0||r>1114111||r>=55296&&r<=57343?e:String.fromCodePoint(r)}function r_(e){let t=``,n=0,r=!1;for(let i of e.matchAll(/<!--[\s\S]*?-->|<![^>]*>|<\/?[A-Za-z][^>]*>/g)){let a=e.slice(n,i.index);a&&(t+=a,r=!1);let o=i[0],s=/^<\/?\s*([A-Za-z0-9-]+)/.exec(o)?.[1]?.toLowerCase();s===`br`?(t+=`
421
421
  `,r=!1):s&&e_.has(s)&&t.length>0&&!t.endsWith(`
@@ -627,7 +627,7 @@ Usage: cherry-emit <name> [--detail <json>] [--runtime <id>]
627
627
  -o Force paste mode (write to stdout)
628
628
  (default) Auto-detect: stdin present = copy, no stdin = paste
629
629
  Example: echo hello | ${e}\n Example: ${e} -o > file.txt\n`,stderr:``,exitCode:0}}async function iv(e,t){let n=!!globalThis.navigator?.clipboard,r=n?null:y();if(!n&&!r)return{stdout:``,stderr:`${t}: clipboard API is unavailable\n`,exitCode:1};try{return n?await navigator.clipboard.writeText(e):await r.call(`clipboard-write-text`,{text:e}),{stdout:``,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`${t}: failed to write to clipboard: ${ev(e)}\n`,exitCode:1}}}async function av(e){let t=!!globalThis.navigator?.clipboard,n=t?null:y();if(!t&&!n)return{stdout:``,stderr:`${e}: clipboard API is unavailable\n`,exitCode:1};try{return{stdout:t?await navigator.clipboard.readText():(await n.call(`clipboard-read-text`,void 0)).text,stderr:``,exitCode:0}}catch(t){return{stdout:``,stderr:`${e}: failed to read from clipboard: ${ev(t)}\n`,exitCode:1}}}function ov(){return S(`pbcopy`,async(e,t)=>e.includes(`--help`)||e.includes(`-h`)?tv():iv(P(t.stdin),`pbcopy`))}function sv(){return S(`pbpaste`,async e=>e.includes(`--help`)||e.includes(`-h`)?nv():av(`pbpaste`))}function cv(e){return S(e,async(t,n)=>{if(t.includes(`--help`)||t.includes(`-h`))return rv(e);let r=t.includes(`-i`),i=t.includes(`-o`);if(r&&i)return{stdout:``,stderr:`${e}: cannot use both -i and -o\n`,exitCode:1};if(i)return av(e);let a=P(n.stdin);return r||a.length>0?iv(a,e):av(e)})}function lv(){return S(`cmp`,async(e,t)=>{let n=e.some(e=>e===`-s`||e===`--quiet`||e===`--silent`),r=e.filter(e=>![`-s`,`--quiet`,`--silent`].includes(e));if(r.length!==2||r.some(e=>e.startsWith(`-`)&&e!==`-`))return{stdout:``,stderr:`cmp: usage: cmp [-s|--quiet|--silent] FILE1 FILE2
630
- `,exitCode:2};let i=await uv(t,r[0]);if(`error`in i)return n?{...i.error,stderr:``}:i.error;let a=await uv(t,r[1]);if(`error`in a)return n?{...a.error,stderr:``}:a.error;let o=dv(i.bytes,a.bytes);return o?n?{stdout:``,stderr:``,exitCode:1}:o.eof?{stdout:``,stderr:`cmp: EOF on ${i.bytes.length<a.bytes.length?r[0]:r[1]} after byte ${o.byte-1}, line ${o.line}\n`,exitCode:1}:{stdout:`${r[0]} ${r[1]} differ: byte ${o.byte}, line ${o.line}\n`,stderr:``,exitCode:1}:{stdout:``,stderr:``,exitCode:0}})}async function uv(e,t){if(t===`-`){let t=ti(e.stdin);return{bytes:Uint8Array.from(t,e=>e.charCodeAt(0)&255)}}try{return{bytes:await e.fs.readFileBuffer(e.fs.resolvePath(e.cwd,t))}}catch{return{error:{stdout:``,stderr:`cmp: ${t}: No such file or directory\n`,exitCode:2}}}}function dv(e,t){let n=Math.min(e.length,t.length),r=1;for(let i=0;i<n;i++){if(e[i]!==t[i])return{byte:i+1,line:r,eof:!1};e[i]===10&&r++}return e.length===t.length?null:{byte:n+1,line:r,eof:!0}}function fv(e={}){return S(`computer`,async(t,n)=>{let{runComputer:r}=await import(`./run-CK7bQLZ0.js`).then(e=>e.t);return r(t,n,e)})}var pv=`/assets/AdobeClean-Regular-CVsq5gF7.otf`;function mv(e){return{reader:{exists:t=>e.fs.exists(t),isDirectory:async t=>{try{return(await e.fs.stat(t)).isDirectory}catch{return!1}},readFile:t=>e.fs.readFile(t)},readBytes:t=>e.fs.readFileBuffer(t),fromDir:e.cwd}}function hv(e){let t=e.toLowerCase();return t.endsWith(`.jpg`)||t.endsWith(`.jpeg`)?`JPEG`:t.endsWith(`.png`)?`PNG`:t.endsWith(`.gif`)?`GIF`:t.endsWith(`.webp`)?`WEBP`:t.endsWith(`.bmp`)?`BMP`:t.endsWith(`.tiff`)||t.endsWith(`.tif`)?`TIFF`:t.endsWith(`.avif`)?`AVIF`:`PNG`}const gv=`AdobeClean-Regular.otf`,_v=new WeakSet;let vv=null;function yv(){return{stdout:`usage: convert [input ...] [operations...] [output]
630
+ `,exitCode:2};let i=await uv(t,r[0]);if(`error`in i)return n?{...i.error,stderr:``}:i.error;let a=await uv(t,r[1]);if(`error`in a)return n?{...a.error,stderr:``}:a.error;let o=dv(i.bytes,a.bytes);return o?n?{stdout:``,stderr:``,exitCode:1}:o.eof?{stdout:``,stderr:`cmp: EOF on ${i.bytes.length<a.bytes.length?r[0]:r[1]} after byte ${o.byte-1}, line ${o.line}\n`,exitCode:1}:{stdout:`${r[0]} ${r[1]} differ: byte ${o.byte}, line ${o.line}\n`,stderr:``,exitCode:1}:{stdout:``,stderr:``,exitCode:0}})}async function uv(e,t){if(t===`-`){let t=ti(e.stdin);return{bytes:Uint8Array.from(t,e=>e.charCodeAt(0)&255)}}try{return{bytes:await e.fs.readFileBuffer(e.fs.resolvePath(e.cwd,t))}}catch{return{error:{stdout:``,stderr:`cmp: ${t}: No such file or directory\n`,exitCode:2}}}}function dv(e,t){let n=Math.min(e.length,t.length),r=1;for(let i=0;i<n;i++){if(e[i]!==t[i])return{byte:i+1,line:r,eof:!1};e[i]===10&&r++}return e.length===t.length?null:{byte:n+1,line:r,eof:!0}}function fv(e={}){return S(`computer`,async(t,n)=>{let{runComputer:r}=await import(`./run-DthMAupa.js`).then(e=>e.t);return r(t,n,e)})}var pv=`/assets/AdobeClean-Regular-CVsq5gF7.otf`;function mv(e){return{reader:{exists:t=>e.fs.exists(t),isDirectory:async t=>{try{return(await e.fs.stat(t)).isDirectory}catch{return!1}},readFile:t=>e.fs.readFile(t)},readBytes:t=>e.fs.readFileBuffer(t),fromDir:e.cwd}}function hv(e){let t=e.toLowerCase();return t.endsWith(`.jpg`)||t.endsWith(`.jpeg`)?`JPEG`:t.endsWith(`.png`)?`PNG`:t.endsWith(`.gif`)?`GIF`:t.endsWith(`.webp`)?`WEBP`:t.endsWith(`.bmp`)?`BMP`:t.endsWith(`.tiff`)||t.endsWith(`.tif`)?`TIFF`:t.endsWith(`.avif`)?`AVIF`:`PNG`}const gv=`AdobeClean-Regular.otf`,_v=new WeakSet;let vv=null;function yv(){return{stdout:`usage: convert [input ...] [operations...] [output]
631
631
 
632
632
  Operations:
633
633
  -resize GEOMETRY resize; supports %, !, ^, >, and < modifiers
@@ -707,7 +707,7 @@ Examples:
707
707
  `;for(let n of e)t+=` ${n.id} ${n.name.padEnd(20)} ${n.cron.padEnd(15)}`,n.scoop&&(t+=` -> ${n.scoop}`),n.filter&&(t+=` [filtered]`),t+=` (${n.status})`,n.nextRun&&(t+=` next: ${new Date(n.nextRun).toLocaleString()}`),t+=`
708
708
  `;return t}async function dy(e,t){let n=C(e.slice(1),{});if(`error`in n)return cy(n.error);if(!t()){let e=await ty();if(!e)return iy(`list`);let t=await e.listCronTasks();return t.length===0?{stdout:`No active cron tasks
709
709
  `,stderr:``,exitCode:0}:{stdout:uy(t),stderr:``,exitCode:0}}let{ok:r,data:i}=await oy(`GET`,``);if(!r)return{stdout:``,stderr:`crontask: failed to list: ${i.error??`unknown error`}\n`,exitCode:1};let a=i;return a.length===0?{stdout:`No active cron tasks
710
- `,stderr:``,exitCode:0}:{stdout:uy(a),stderr:``,exitCode:0}}async function fy(e,t){let n=e[0],r=C(e.slice(1),{});if(`error`in r)return cy(r.error);let i=r.positionals[0];if(!i)return{stdout:``,stderr:`crontask: ${n} requires an ID\n`,exitCode:1};if(!t()){let e=await ty();return e?await e.deleteCronTask(i)?{stdout:`Deleted cron task "${i}"\n`,stderr:``,exitCode:0}:{stdout:``,stderr:`crontask: task "${i}" not found\n`,exitCode:1}:iy(`delete`)}let{ok:a,status:o,data:s}=await oy(`DELETE`,`/${i}`);return a?{stdout:`Deleted cron task "${i}"\n`,stderr:``,exitCode:0}:o===404?{stdout:``,stderr:`crontask: task "${i}" not found\n`,exitCode:1}:{stdout:``,stderr:`crontask: failed to delete: ${s.error??`unknown error`}\n`,exitCode:1}}function py(e={}){let t=e.hasLocalNodeServer??(()=>!1);return S(`crontask`,async(e,n)=>{let r=e[0];if(!r||w(e,{valueFlags:sy}))return ay();try{switch(r){case`create`:return await ly(e,n.env,t);case`list`:return await dy(e,t);case`delete`:case`kill`:return await fy(e,t);default:return{stdout:``,stderr:`crontask: unknown command "${r}"\n`,exitCode:1}}}catch(e){return{stdout:``,stderr:`crontask: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}})}function my(e){return S(`curlwright`,async(t,n)=>{let{runCurlwright:r}=await import(`./run-D2pF2y1_.js`);return r(e,t,n)})}const hy=`slicc-fs`;async function gy(){try{let e=globalThis.indexedDB;if(!e)return!1;let t=e.databases;return typeof t!=`function`||(await t.call(e)).some(e=>e.name===hy)}catch{return!0}}async function _y(){let e=globalThis.indexedDB;return e?new Promise(t=>{let n;try{n=e.deleteDatabase(hy)}catch{t(`error`);return}n.onsuccess=()=>t(`deleted`),n.onerror=()=>t(`error`),n.onblocked=()=>t(`blocked`)}):`error`}async function vy(){if(!await gy())return{kind:`absent`,message:`legacy slicc-fs IDB not present — nothing to clean`};let e=await _y();return e===`deleted`?{kind:`deleted`,message:`legacy slicc-fs IDB deleted`}:e===`blocked`?{kind:`blocked`,message:`legacy slicc-fs IDB delete blocked by another connection — close other tabs and retry`}:{kind:`error`,message:`legacy slicc-fs IDB delete failed`}}function yy(){return`slicc-fs-cleanup — delete the legacy slicc-fs IndexedDB
710
+ `,stderr:``,exitCode:0}:{stdout:uy(a),stderr:``,exitCode:0}}async function fy(e,t){let n=e[0],r=C(e.slice(1),{});if(`error`in r)return cy(r.error);let i=r.positionals[0];if(!i)return{stdout:``,stderr:`crontask: ${n} requires an ID\n`,exitCode:1};if(!t()){let e=await ty();return e?await e.deleteCronTask(i)?{stdout:`Deleted cron task "${i}"\n`,stderr:``,exitCode:0}:{stdout:``,stderr:`crontask: task "${i}" not found\n`,exitCode:1}:iy(`delete`)}let{ok:a,status:o,data:s}=await oy(`DELETE`,`/${i}`);return a?{stdout:`Deleted cron task "${i}"\n`,stderr:``,exitCode:0}:o===404?{stdout:``,stderr:`crontask: task "${i}" not found\n`,exitCode:1}:{stdout:``,stderr:`crontask: failed to delete: ${s.error??`unknown error`}\n`,exitCode:1}}function py(e={}){let t=e.hasLocalNodeServer??(()=>!1);return S(`crontask`,async(e,n)=>{let r=e[0];if(!r||w(e,{valueFlags:sy}))return ay();try{switch(r){case`create`:return await ly(e,n.env,t);case`list`:return await dy(e,t);case`delete`:case`kill`:return await fy(e,t);default:return{stdout:``,stderr:`crontask: unknown command "${r}"\n`,exitCode:1}}}catch(e){return{stdout:``,stderr:`crontask: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}})}function my(e){return S(`curlwright`,async(t,n)=>{let{runCurlwright:r}=await import(`./run-Du61Yu3x.js`);return r(e,t,n)})}const hy=`slicc-fs`;async function gy(){try{let e=globalThis.indexedDB;if(!e)return!1;let t=e.databases;return typeof t!=`function`||(await t.call(e)).some(e=>e.name===hy)}catch{return!0}}async function _y(){let e=globalThis.indexedDB;return e?new Promise(t=>{let n;try{n=e.deleteDatabase(hy)}catch{t(`error`);return}n.onsuccess=()=>t(`deleted`),n.onerror=()=>t(`error`),n.onblocked=()=>t(`blocked`)}):`error`}async function vy(){if(!await gy())return{kind:`absent`,message:`legacy slicc-fs IDB not present — nothing to clean`};let e=await _y();return e===`deleted`?{kind:`deleted`,message:`legacy slicc-fs IDB deleted`}:e===`blocked`?{kind:`blocked`,message:`legacy slicc-fs IDB delete blocked by another connection — close other tabs and retry`}:{kind:`error`,message:`legacy slicc-fs IDB delete failed`}}function yy(){return`slicc-fs-cleanup — delete the legacy slicc-fs IndexedDB
711
711
 
712
712
  Usage:
713
713
  slicc-fs-cleanup Delete the legacy slicc-fs IDB.
@@ -902,7 +902,7 @@ Without --port, the Web Serial picker opens (needs a user gesture).
902
902
  `)}\n`:`region erased
903
903
  `)}case`run`:{let e=await rS(a,r);return await n.run(e,c,u),eS(l.length?`${l.join(`
904
904
  `)}\n`:`running app
905
- `)}default:return tS(`unknown subcommand '${i[0]??``}'. Try 'esptool --help'.`)}}function oS(){return S(`esptool`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return eS(nS);let n=ce(),r=y(),i=xx(n,r),a=Rr(n,r);if(!i||!a)return tS(`Web Serial is unavailable in this environment`);try{return await aS(e,t,i,a)}catch(e){let t=e instanceof Error?e.message:String(e);return/cancelled|NotFoundError|No port selected/i.test(t)?tS(`user cancelled or no port selected`):tS(t)}})}function sS(){return S(`ffmpeg`,async(e,t)=>{let{runFfmpeg:n}=await import(`./run-C-NU4dPD.js`);return n(e,t)})}function cS(){return S(`ffprobe`,async(e,t)=>{let{runFfprobe:n}=await import(`./run-DNvbqTbo.js`);return n(e,t)})}const lS=new Map;let uS=0;const dS=e=>({stdout:e,stderr:``,exitCode:0}),fS=e=>({stdout:``,stderr:`fswatch: ${e}\n`,exitCode:1}),pS=[`--path`,`--pattern`,`--scoop`,`--name`];function mS(e){let t=C(e.slice(1),{});if(`error`in t)return fS(t.error);if(lS.size===0)return dS(`No active file watchers.
905
+ `)}default:return tS(`unknown subcommand '${i[0]??``}'. Try 'esptool --help'.`)}}function oS(){return S(`esptool`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return eS(nS);let n=ce(),r=y(),i=xx(n,r),a=Rr(n,r);if(!i||!a)return tS(`Web Serial is unavailable in this environment`);try{return await aS(e,t,i,a)}catch(e){let t=e instanceof Error?e.message:String(e);return/cancelled|NotFoundError|No port selected/i.test(t)?tS(`user cancelled or no port selected`):tS(t)}})}function sS(){return S(`ffmpeg`,async(e,t)=>{let{runFfmpeg:n}=await import(`./run-C-NU4dPD.js`);return n(e,t)})}function cS(){return S(`ffprobe`,async(e,t)=>{let{runFfprobe:n}=await import(`./run-Bksq7Mcn.js`);return n(e,t)})}const lS=new Map;let uS=0;const dS=e=>({stdout:e,stderr:``,exitCode:0}),fS=e=>({stdout:``,stderr:`fswatch: ${e}\n`,exitCode:1}),pS=[`--path`,`--pattern`,`--scoop`,`--name`];function mS(e){let t=C(e.slice(1),{});if(`error`in t)return fS(t.error);if(lS.size===0)return dS(`No active file watchers.
906
906
  `);let n=``;for(let[,e]of lS)n+=`ID: ${e.id}\n`,n+=` Name: ${e.name}\n`,n+=` Path: ${e.basePath}\n`,n+=` Pattern: ${e.pattern}\n`,e.scoop&&(n+=` Scoop: ${e.scoop}\n`),n+=` Created: ${e.createdAt}\n\n`;return dS(n)}function hS(e){let t=C(e.slice(1),{});if(`error`in t)return fS(t.error);let n=t.positionals[0];if(!n)return fS(`delete requires an ID`);let r=lS.get(n);return r?(r.unsubscribe(),lS.delete(n),dS(`Deleted watcher "${r.name}" (${n})\n`)):fS(`watcher not found: ${n}`)}function gS(e){let t=C(e.slice(1),{value:pS});return`error`in t?t:{basePath:t.values.get(`--path`)??``,pattern:t.values.get(`--pattern`)??``,scoop:t.values.get(`--scoop`)??``,name:t.values.get(`--name`)??``}}function _S(e){let t=RegExp(`^`+e.replace(/\./g,`\\.`).replace(/\*/g,`.*`)+`$`);return e=>t.test(e.split(`/`).pop()??``)}async function vS(e,t){let n=gS(e);if(`error`in n)return fS(n.error);let r=n,i=r.scoop||void 0;if(r.scoop=zi(r.scoop,t)??``,!r.basePath||!r.pattern)return fS(`--path and --pattern are required`);let a=await ry(await ty(),`fswatch create`,i);if(a)return{stdout:``,stderr:a,exitCode:1};let o=globalThis,s=o.__slicc_fs_watcher;if(!s)return fS(`file system watcher not available`);let c=`fsw-${++uS}`,l=r.name||`${r.pattern} in ${r.basePath}`,u=o.__slicc_lick_handler,d=s.watch(r.basePath,_S(r.pattern),e=>{if(!u)return;let t=e.map(e=>({type:e.type,path:e.path}));u({type:`fswatch`,fswatchId:c,fswatchName:l,targetScoop:r.scoop,timestamp:new Date().toISOString(),changes:t,body:{changes:t}})});lS.set(c,{id:c,name:l,basePath:r.basePath,pattern:r.pattern,scoop:r.scoop,unsubscribe:d,createdAt:new Date().toISOString()});let f=`Created file watcher "${l}"\n`;return f+=`ID: ${c}\n`,f+=`Path: ${r.basePath}\n`,f+=`Pattern: ${r.pattern}\n`,r.scoop&&(f+=`Scoop: ${r.scoop}\n`),dS(f)}function yS(){return S(`fswatch`,async(e,t)=>{let n=e[0];if(!n||w(e,{valueFlags:pS}))return dS(`usage: fswatch <command> [options]
907
907
 
908
908
  Commands:
@@ -915,7 +915,7 @@ Options:
915
915
  --pattern <glob> File pattern to match, e.g. "*.md", "*.bsh" (required)
916
916
  --scoop <target> Scoop name, cone name, or folder. Omit for your own cone.
917
917
  --name <name> Human-readable name for the watcher
918
- `);switch(n){case`list`:return mS(e);case`delete`:return hS(e);case`create`:return await vS(e,t.env);default:return fS(`unknown command: ${n}`)}})}function bS(e){return S(`gelatiere`,async(t,n)=>{let{runGelatiere:r}=await import(`./run-DsYsM6Yl.js`);return r(t,n,e)})}function xS(e){return typeof e.stdoutIsTTY!=`boolean`||e.stdoutIsTTY}function SS(e,t){return typeof e.stdinIsTTY==`boolean`?e.stdinIsTTY:t===void 0?ti(e.stdin).length===0:t===0}function CS(){return{stdout:`usage: hear [-i file] [-l lang] [-T seconds] [-d deviceId] [--engine name]
918
+ `);switch(n){case`list`:return mS(e);case`delete`:return hS(e);case`create`:return await vS(e,t.env);default:return fS(`unknown command: ${n}`)}})}function bS(e){return S(`gelatiere`,async(t,n)=>{let{runGelatiere:r}=await import(`./run-BdurKezv.js`);return r(t,n,e)})}function xS(e){return typeof e.stdoutIsTTY!=`boolean`||e.stdoutIsTTY}function SS(e,t){return typeof e.stdinIsTTY==`boolean`?e.stdinIsTTY:t===void 0?ti(e.stdin).length===0:t===0}function CS(){return{stdout:`usage: hear [-i file] [-l lang] [-T seconds] [-d deviceId] [--engine name]
919
919
  hear --devices | --status | --warmup
920
920
 
921
921
  Speech recognition: listens on the microphone until you pause, then
@@ -1200,7 +1200,7 @@ Options:
1200
1200
  `,stderr:``,exitCode:0}}let a=e.routes.get(r.targetId)??[],o=a.length,s=a.filter(e=>e.pattern!==i);if(e.routes.set(r.targetId,s),s.length===0){let t=e.routeCleanup.get(r.targetId);t&&(t(),e.routeCleanup.delete(r.targetId))}return{stdout:`Removed ${o-s.length} route(s) matching "${i}"\n`,stderr:``,exitCode:0}},Yw=`/.playwright`;function Xw(e,t){return e?`${t.replace(/\/+$/,``)}${Yw}`:Yw}async function Zw(e,t,n){if(!t.sessionDirsCreated.has(n)){for(let t of[n,`${n}/snapshots`,`${n}/screenshots`])try{await e.mkdir(t,{recursive:!0})}catch(e){if(!Tn(e))throw e}t.sessionDirsCreated.add(n)}}async function Qw(e,t,n,r,i){try{return await e.withTab(n,async e=>{let{url:a,title:o,text:s,refToSelector:c,refToBackendNodeId:l,refToFrameId:u}=await se(e),d={url:a,title:o,refToSelector:c,refToBackendNodeId:l,refToFrameId:u,content:s,timestamp:Date.now()};r.snapshots.set(n,d);let f=[`Page URL: ${a}`,`Page Title: ${o}`,``,s].join(`
1201
1201
  `),p=`${i}/snapshots/page-${Cn(new Date)}.yml`;return await t.writeFile(p,f),p})}catch{return null}}async function $w(e,t,n,r){await Zw(e,t,n);let i=new Date().toISOString(),a=`playwright-cli ${r.command}${r.args.length?` `+r.args.join(` `):``}`,o=r.result.exitCode===0?r.result.stdout.trim()||`OK`:`Error: ${r.result.stderr.trim()}`,s=[`### ${a}`,`- **Time**: ${i}`];if(r.tabUrl||r.targetId){let e=r.tabUrl?`${r.tabUrl}${r.targetId?` (targetId: ${r.targetId})`:``}`:`targetId: ${r.targetId}`;s.push(`- **Tab**: ${e}`)}s.push(`- **Result**: ${o}`),r.snapshotPath&&s.push(``,`[Snapshot](${r.snapshotPath})`),s.push(`---`,``);let c=s.join(`
1202
1202
  `)+`
1203
- `,l=`${n}/session.md`,u=``;try{let t=await e.readFile(l);u=typeof t==`string`?t:new TextDecoder().decode(t)}catch{}await e.writeFile(l,u+c)}function eT(){return import(`./snapshot-features-Ddz9jsBd.js`)}async function tT(e,t,n,r){let i=await e.getAccessibilityTreeForFrame(r.frameId),a=new Map,o=new Map,s=new Map,c=oe(i,a,o,{value:0},``,`f1`);for(let e of a.keys())s.set(e,r.frameId);let l=c.join(`
1203
+ `,l=`${n}/session.md`,u=``;try{let t=await e.readFile(l);u=typeof t==`string`?t:new TextDecoder().decode(t)}catch{}await e.writeFile(l,u+c)}function eT(){return import(`./snapshot-features-DXhxdPKC.js`)}async function tT(e,t,n,r){let i=await e.getAccessibilityTreeForFrame(r.frameId),a=new Map,o=new Map,s=new Map,c=oe(i,a,o,{value:0},``,`f1`);for(let e of a.keys())s.set(e,r.frameId);let l=c.join(`
1204
1204
  `);return t.snapshots.set(n,{url:r.url,title:r.name,refToSelector:a,refToBackendNodeId:o,refToFrameId:s,content:l,timestamp:Date.now()}),l}async function nT(e,t){await e.send(`DOM.enable`),await e.send(`Runtime.enable`);let n=(await e.send(`DOM.resolveNode`,{backendNodeId:t})).object;if(n?.objectId)return(await e.send(`Runtime.callFunctionOn`,{objectId:n.objectId,functionDeclaration:`function() {
1205
1205
  this.scrollIntoView({ block: 'center' });
1206
1206
  const r = this.getBoundingClientRect();
@@ -1278,7 +1278,7 @@ Options:
1278
1278
  el.dispatchEvent(new Event('input', { bubbles: true }));
1279
1279
  return el.files.length;
1280
1280
  })()`,r=await t.send(`Runtime.evaluate`,{expression:n,returnByValue:!0,awaitPromise:!1},e);if(r.exceptionDetails){let e=r.exceptionDetails.exception?.description??r.exceptionDetails.text??`File upload failed`;throw Error(e)}});let p=d.map(e=>e.split(`/`).pop()??e).join(`, `);return{stdout:`Uploaded ${d.length} file(s): ${p}\n`,stderr:``,exitCode:0}}],[`state-save`,pT],[`state-load`,mT],[`console`,GS],[`requests`,Nw],[`request`,Pw],[`request-headers`,Fw],[`request-body`,Iw],[`response-headers`,Lw],[`response-body`,Rw],[`mousemove`,LC],[`mousedown`,RC],[`mouseup`,zC],[`mousewheel`,BC],[`drop`,VC],[`route`,Kw],[`route-list`,qw],[`unroute`,Jw],[`generate-locator`,tC],[`highlight`,nC]]);function LT(){let e=(On.string??[]).map(e=>`--${e}`),t=new Set(On.boolean??[]);for(let[e,n]of Object.entries(On.alias??{})){let r=[e,...Array.isArray(n)?n:[n]];if(r.some(e=>t.has(e)))for(let e of r)t.add(e)}return{value:e,bool:[...[...t].map(e=>`--${e}`),`--help`,`-h`,`--no-iframes`]}}function RT(e){return e.map(e=>e===`--no-iframes`||e.startsWith(`--no-iframes=`)?e.replace(`--no-iframes`,`--_noiframes`):e)}function zT(e){return{...e,bool:[...e.bool??[],`--_noiframes`],value:[...e.value??[],`--_noiframes`]}}const BT=2e3;function VT(e,t){if(typeof e.getTabLockStats!=`function`)return;let n=e.getTabLockStats();return t?{totalWaitMs:n.totalWaitMs,tabWaitMs:e.getTabLockStats(t).tabWaitMs}:{totalWaitMs:n.totalWaitMs}}function HT(e,t,n,r){if(!t||typeof e.getTabLockStats!=`function`)return r;let i=e.getTabLockStats(),a=i.totalWaitMs-t.totalWaitMs;if(a<BT)return r;let o=(a/1e3).toFixed(1),s=n&&t.tabWaitMs!==void 0?e.getTabLockStats(n).tabWaitMs-t.tabWaitMs:0,c=`note: browser bridge contended — lock waits totaled ${o}s while this command ran, ${s>=BT?`${(s/1e3).toFixed(1)}s of it waiting on this tab (--tab=${n})`:`all of it waiting on the bridge, not on this tab`} (queue depth ${i.queueDepth}). Commands on the same tab serialize; commands on different tabs run in parallel — stagger callers on THIS tab, or give each caller its own tab.
1281
- `;return{...r,stderr:r.stderr+c}}async function UT(e,t,n){let r=n instanceof Error?n.message:String(n);return{stdout:``,stderr:`Error: ${(t.tab?await kn(e,t.tab,n):null)??r}\n`,exitCode:1}}function WT(e,t,n){return{stdout:``,stderr:`${e} ${t}: ${n===void 0?`aborted: the caller stopped waiting for it`:n instanceof Error?n.message:String(n)}\n`,exitCode:130}}async function GT(e,t,n){let r=IT.get(t);if(!r)return{stdout:``,stderr:`Unknown command: ${t}\nRun "playwright-cli help" for usage.\n`,exitCode:1};let{signal:i}=n;try{let a=await r(n);return i?.aborted?WT(e,t,void 0):a}catch(r){return i?.aborted?WT(e,t,r):await UT(n.browser,n.flags,r)}}async function KT(e,t,n,r){let i=C(RT(n),zT(r));if(`error`in i)return{answer:{stdout:``,stderr:`${e} ${t}: ${i.error}\n`,exitCode:1}};let a;try{({flags:a}=Dn(n))}catch(n){return{answer:{stdout:``,stderr:`${e} ${t}: ${n instanceof Error?n.message:String(n)}\n`,exitCode:1}}}if(a.help===`true`||a.h===`true`){let{formatSubcommandHelp:n}=await import(`./help-C3q6Ha5a.js`);return{answer:{stdout:n(e,t),stderr:``,exitCode:0}}}let o=null;try{let{validateSubcommandArgs:r}=await import(`./validate-args-BcxRh84E.js`);o=r(e,t,n,i.positionals)}catch{o=null}return o?{answer:{stdout:``,stderr:o,exitCode:1}}:{positional:i.positionals,flags:a}}function qT(e,t,n,r={}){let i=t?wn(t,n):null,a=LT();return S(e,async(o,s)=>{if(o.length===0||o[0]===`help`||o[0]===`--help`||o[0]===`-h`){let{formatHelp:t}=await import(`./help-C3q6Ha5a.js`);return{stdout:t(e)+`
1281
+ `;return{...r,stderr:r.stderr+c}}async function UT(e,t,n){let r=n instanceof Error?n.message:String(n);return{stdout:``,stderr:`Error: ${(t.tab?await kn(e,t.tab,n):null)??r}\n`,exitCode:1}}function WT(e,t,n){return{stdout:``,stderr:`${e} ${t}: ${n===void 0?`aborted: the caller stopped waiting for it`:n instanceof Error?n.message:String(n)}\n`,exitCode:130}}async function GT(e,t,n){let r=IT.get(t);if(!r)return{stdout:``,stderr:`Unknown command: ${t}\nRun "playwright-cli help" for usage.\n`,exitCode:1};let{signal:i}=n;try{let a=await r(n);return i?.aborted?WT(e,t,void 0):a}catch(r){return i?.aborted?WT(e,t,r):await UT(n.browser,n.flags,r)}}async function KT(e,t,n,r){let i=C(RT(n),zT(r));if(`error`in i)return{answer:{stdout:``,stderr:`${e} ${t}: ${i.error}\n`,exitCode:1}};let a;try{({flags:a}=Dn(n))}catch(n){return{answer:{stdout:``,stderr:`${e} ${t}: ${n instanceof Error?n.message:String(n)}\n`,exitCode:1}}}if(a.help===`true`||a.h===`true`){let{formatSubcommandHelp:n}=await import(`./help-D-QlFQmC.js`);return{answer:{stdout:n(e,t),stderr:``,exitCode:0}}}let o=null;try{let{validateSubcommandArgs:r}=await import(`./validate-args-BcxRh84E.js`);o=r(e,t,n,i.positionals)}catch{o=null}return o?{answer:{stdout:``,stderr:o,exitCode:1}}:{positional:i.positionals,flags:a}}function qT(e,t,n,r={}){let i=t?wn(t,n):null,a=LT();return S(e,async(o,s)=>{if(o.length===0||o[0]===`help`||o[0]===`--help`||o[0]===`-h`){let{formatHelp:t}=await import(`./help-D-QlFQmC.js`);return{stdout:t(e)+`
1282
1282
  `,stderr:``,exitCode:0}}let c=o[0],l=o.slice(1),u=await KT(e,c,l,a);if(`answer`in u)return u.answer;let{positional:d,flags:f}=u;if(!t||!i)return{stdout:``,stderr:`${e}: browser APIs are unavailable in this environment\n`,exitCode:1};let p=f.tab??null,m=VT(t,p),h=Bi(s.env),g=Xw(r.isScoop?.()??!1,h),_=await GT(e,c,{browser:t,fs:n,state:i,positional:d,flags:f,scratchDir:h,sessionRoot:g,onTab:(e,n)=>t.withTab(e,n,{signal:s.signal}),signal:s.signal}),v=f.tab??null,ee=null;Fn.has(c)&&_.exitCode===0&&v&&(ee=await Qw(t,n,v,i,g));try{await $w(n,i,g,{command:c,args:l,result:_,snapshotPath:ee,targetId:v})}catch{}return HT(t,m,p,_)})}const JT=new Map([[`File operations`,[`ls`,`cat`,`head`,`tail`,`wc`,`touch`,`mkdir`,`rm`,`cp`,`mv`,`ln`,`chmod`,`stat`,`readlink`,`file`,`rmdir`,`rsync`]],[`Text processing`,[`grep`,`sed`,`awk`,`sort`,`uniq`,`cut`,`tr`,`tee`,`diff`,`patch`,`column`,`comm`,`egrep`,`fgrep`,`expand`,`unexpand`,`fold`,`join`,`nl`,`od`,`paste`,`rev`,`split`,`strings`,`tac`]],[`Search`,[`find`,`rg`]],[`Navigation & paths`,[`pwd`,`basename`,`dirname`,`tree`,`du`,`cd`]],[`Archives`,[`zip`,`unzip`,`pdftk`,`pdf`,`gunzip`,`gzip`,`zcat`]],[`Media`,[`convert`,`magick`,`pdftoppm`,`pdftocairo`,`pdftotext`,`ffmpeg`,`ffprobe`,`screencapture`]],[`Audio`,[`say`,`hear`,`afplay`,`chime`]],[`Environment & shell`,`echo.printf.env.printenv.export.alias.unalias.history.clear.true.false.bash.sh.commands.which.uname.man.host.oauth-token.secret.nuke.models.local-llm.cost.hostname.whoami.id.help.sleep.time.timeout.oauth-domain`.split(`.`)],[`Data processing`,[`xargs`,`jq`,`base64`,`date`,`expr`,`seq`]],[`Hashes`,[`md5sum`,`sha1sum`,`sha256sum`]],[`Network`,[`curl`,`curlwright`,`wget`,`dig`,`websocat`,`html-to-markdown`]],[`Version control`,[`git`]],[`Languages`,[`node`,`jsh`,`python`,`python3`,`sqlite3`]],[`Virtualization`,[`v86`,`computer`]],[`Build tools`,[`tsc`,`tst`,`esbuild`,`biome`]],[`Packages`,[`ipk`,`hf`,`npm`,`i`,`ipx`,`npx`]],[`Skills`,[`skill`,`upskill`]],[`Browser & UI`,[`serve`,`open`,`imgcat`,...Nn,`sprinkle`]],[`Clipboard`,[`pbcopy`,`pbpaste`,`xclip`,`xsel`]],[`Filesystem`,[`mount`,`umount`,`fswatch`]],[`Scoops & agents`,[`agent`,`gelatiere`,`mcp`,`webhook`,`crontask`]],[`Process`,[`ps`,`kill`,`jshd`,`meminfo`,`uptime`]],[`Shell builtins (limited)`,[...Bg]]]);function YT(e,t=[],n=[]){let r=[],i=new Set(e);for(let e of t)i.delete(e);for(let e of n)i.delete(e);r.push(`Available commands:
1283
1283
  `);let a=[];for(let[e,t]of JT){let n=t.filter(e=>i.has(e));if(n.length>0){r.push(` ${e}:`),r.push(` ${n.join(`, `)}\n`);for(let e of n)i.delete(e)}}for(let e of i)a.push(e);return a.length>0&&(r.push(` Other:`),r.push(` ${a.sort().join(`, `)}\n`)),t.length>0&&(r.push(` User scripts (.jsh):`),r.push(` ${t.sort().join(`, `)}\n`)),n.length>0&&(r.push(` Workflows:`),r.push(` ${n.sort().join(`, `)}\n`)),r.push(`Use '<command> --help' for details on a specific command.`),r.join(`
1284
1284
  `)+`
@@ -1383,7 +1383,8 @@ Options:
1383
1383
  `,`;`,`|`,`&`,`(`,`)`,`{`,`}`,`<`,`>`]),oD=new Set([`;`,`|`,`&`,`(`,`)`,`{`,`
1384
1384
  `]),sD=/^[A-Za-z_][A-Za-z0-9_]*=/,cD=/^[@A-Za-z0-9._-]+$/,lD=new Set([`if`,`then`,`else`,`elif`,`fi`,`for`,`while`,`until`,`do`,`done`,`case`,`in`,`esac`,`function`,`time`,`!`]),uD=new Set([`if`,`then`,`else`,`elif`,`while`,`until`,`do`,`time`,`!`]),dD=new Set([`ipx`,`npx`]);function fD(e){return`'${e.replace(/'/g,`'\\''`)}'`}async function pD(e,t){let n=await e.readFile(t);return typeof n==`string`?n:new TextDecoder().decode(n)}function*mD(e){let t=b(e);for(;yield t,t!==`/`;)t=Ee(t).dir}function hD(e){if(typeof e!=`object`||!e)return{};let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&(t[n]=r);return t}function gD(e){return typeof e==`string`?e:void 0}async function _D(e,t){for(let n of mD(t)){let t=x(n,`package.json`);if(!await e.exists(t))continue;let r;try{r=JSON.parse(await pD(e,t))}catch(e){throw Error(`${t} is not valid JSON: ${e instanceof Error?e.message:String(e)}`)}return{dir:n,name:gD(r.name),version:gD(r.version),scripts:hD(r.scripts)}}return null}function vD(e,t){let n=t,r=``;for(;n<e.length;){let t=e[n];if(r!==``){t===`\\`&&r===`"`?n++:t===r&&(r=``),n++;continue}if(t===`'`||t===`"`){r=t,n++;continue}if(t===`\\`){n+=2;continue}if(aD.has(t))break;n++}return{start:t,end:n,text:e.slice(t,n)}}function yD(e){let t=[],n=0,r=!0;for(;n<e.length;){let i=e[n];if(i===` `||i===` `){n++;continue}if(oD.has(i)){r=!0,n++;continue}let a=vD(e,n);if(a.end===a.start){n++;continue}if(r&&!sD.test(a.text)){if(uD.has(a.text)){n=a.end;continue}t.push(a),r=!1}n=a.end}return t}function bD(e,t){return!cD.test(e)||lD.has(e)||dD.has(e)?!1:!t.isRegistered(e)}async function xD(e,t){let n=yD(e).filter(e=>bD(e.text,t));if(n.length===0)return e;let r=[];for(let e of n)await t.hasLocalBin(e.text)&&r.push(e);if(r.length===0)return e;let i=e;for(let e of[...r].reverse())i=`${i.slice(0,e.start)}ipx ${i.slice(e.start)}`;return i}function SD(e){let t=[];for(let n of mD(e))t.push(x(n,`node_modules`,`.bin`));return t}function CD(e,t,n,r){let i=r.env.get(`PATH`)??``,a={PATH:[...SD(e.dir),i].filter(e=>e!==``).join(`:`),npm_lifecycle_event:t,npm_lifecycle_script:n};return e.name!==void 0&&(a.npm_package_name=e.name),e.version!==void 0&&(a.npm_package_version=e.version),a}function wD(e){return e.name===void 0?e.dir:e.version===void 0?e.name:`${e.name}@${e.version}`}function TD(e,t){let n=Object.entries(t.scripts);if(n.length===0)return`${e}: no scripts defined in ${x(t.dir,`package.json`)}\n`;let r=[`Scripts available in ${wD(t)} via \`${e} run\`:`];for(let[e,t]of n)r.push(` ${e}`),r.push(` ${t}`);return`${r.join(`
1385
1385
  `)}\n`}function ED(e,t){return t===`--silent`||t===`-s`?(e.silent=!0,!0):t===`--if-present`&&(e.ifPresent=!0,!0)}function DD(e){let t={silent:!1,ifPresent:!1},n=[],r,i=!1;for(let a of e){if(i){n.push(a);continue}if(a===`--`){i=!0;continue}ED(t,a)||(r===void 0?r=a:n.push(a))}return{flags:t,script:r,extraArgs:n}}function OD(e,t){return{stdout:``,stderr:`${e}: ${t}\n`,exitCode:1}}function kD(e,t,n,r){let i=r.length>0?` ${r.map(fD).join(` `)}`:``,a=[],o=e.scripts[`pre${t}`];o!==void 0&&a.push({event:`pre${t}`,body:o}),a.push({event:t,body:`${n}${i}`});let s=e.scripts[`post${t}`];return s!==void 0&&a.push({event:`post${t}`,body:s}),a}async function AD(e,t,n,r){if(n===`start`&&await r.exists(x(t.dir,`server.js`)))return`node server.js`;if(n===`restart`)return`${e} stop --if-present && ${e} start`}function jD(e,t,n){let r=new Set(n.getRegisteredCommands?.()??[]);return{isRegistered:e=>r.has(e),hasLocalBin:async n=>{for(let r of SD(t.dir))if(await e.exists(x(r,n)))return!0;return!1}}}async function MD(e,t,n,r,i,a){let o=i.exec;if(!o)return OD(e,`run requires shell exec support, which this context does not provide`);let s=jD(a.fs,t,i),c=wD(t),l=``,u=``;for(let a of n){r.silent||(l+=`\n> ${c} ${a.event}\n> ${a.body}\n\n`);let n=await o(await xD(a.body,s),{cwd:t.dir,env:CD(t,a.event,a.body,i),stdin:ti(i.stdin),stdinKind:`bytes`});if(l+=n.stdout,u+=n.stderr,n.exitCode!==0)return u+=`${e}: script '${a.event}' exited with code ${n.exitCode}\n`,{stdout:l,stderr:u,exitCode:n.exitCode}}return{stdout:l,stderr:u,exitCode:0}}async function ND(e,t,n,r){let i;try{i=await _D(r.fs,n.cwd)}catch(t){return OD(e,t instanceof Error?t.message:String(t))}if(!i)return OD(e,`no package.json found in ${n.cwd} or any parent directory — nothing to run`);let{flags:a,script:o,extraArgs:s}=DD(t);if(o===void 0)return{stdout:TD(e,i),stderr:``,exitCode:0};let c=i.scripts[o]??await AD(e,i,o,r.fs)??void 0;if(c===void 0){if(a.ifPresent)return{stdout:``,stderr:``,exitCode:0};let t=Object.keys(i.scripts);return OD(e,`missing script: ${o}${t.length>0?` (available: ${t.join(`, `)})`:` (${x(i.dir,`package.json`)} defines no scripts)`}`)}return MD(e,i,kD(i,o,c,s),a,n,r)}const PD=new Set([`install`,`i`,`add`]),FD=new Set([`uninstall`,`remove`,`rm`,`un`]),ID=new Set([`list`,`ls`]),LD=new Set([`-g`,`--global`,`--location=global`]),RD=[`-g`,`--global`,`-D`,`--save-dev`];function zD(e){return`${e} - install packages from the npm registry into node_modules
1386
- and run package.json scripts
1386
+ and run package.json scripts; also install conda/emscripten-forge
1387
+ packages via '${e} mamba'
1387
1388
 
1388
1389
  Usage:
1389
1390
  ${e} install [-D|--save-dev] [<pkg>[@<spec>] ...]
@@ -1391,6 +1392,9 @@ Usage:
1391
1392
  ${e} i [-D|--save-dev] [<pkg>[@<spec>] ...]
1392
1393
  ${e} run [<script> [-- <args>...]]
1393
1394
  ${e} test | start | stop | restart
1395
+ ${e} mamba install <pkg>[=<version>] ...
1396
+ ${e} mamba list
1397
+ ${e} mamba uninstall <pkg> ...
1394
1398
 
1395
1399
  No-arg forms:
1396
1400
  ${e} install read cwd package.json and install every entry
@@ -1405,6 +1409,11 @@ Global installs:
1405
1409
  ${e} list -g list globally installed direct dependencies
1406
1410
  ${e} root -g print the global node_modules path
1407
1411
 
1412
+ Conda / emscripten-forge (see '${e} mamba --help'):
1413
+ ${e} mamba install <pkg> install into /shared/lib/conda (emscripten-wasm32)
1414
+ ${e} mamba list list conda packages in that prefix
1415
+ ${e} mamba uninstall <pkg> remove a conda package from the prefix
1416
+
1408
1417
  Local project (no -g):
1409
1418
  ${e} uninstall <pkg> remove from cwd package.json and reconcile node_modules
1410
1419
  ${e} list list direct dependencies from cwd package.json
@@ -1449,14 +1458,14 @@ manifest without rewriting it. With -g, packages go to /shared/lib/node_modules
1449
1458
  and deps are recorded in /shared/lib/package.json. Existing fields are
1450
1459
  preserved. Idempotent: re-installing an already-satisfied package is a clean
1451
1460
  no-op.
1452
- `}function BD(e){let t=C(e,{bool:RD,value:[`--location`]});if(`error`in t)return t;let n=t.values.get(`--location`);return n!==void 0&&n!==`global`?{error:`unknown flag: --location=${n}`}:{global:t.bools.has(`-g`)||t.bools.has(`--global`)||n===`global`,saveDev:t.bools.has(`-D`)||t.bools.has(`--save-dev`),specs:t.positionals}}function VD(e){let t=!1,n=[];for(let r of e){if(LD.has(r)){t=!0;continue}r.startsWith(`-`)||n.push(r)}return{global:t,specs:n}}function HD(e){let t=e.indexOf(`--`),n=t===-1?e:e.slice(0,t);return n.includes(`--help`)||n.includes(`-h`)}function UD(e){return e instanceof Error?e.message:String(e)}async function WD(e){e.scriptCatalog?.invalidateJsh(),await e.syncScriptCommands?.()}async function GD(e,t,n){let r;try{r=await qi({fs:n.fs,fetch:n.fetch,cwd:t.cwd})}catch(t){return t instanceof Zi?{stdout:``,stderr:`${e}: ${t.message}\n`,exitCode:1}:{stdout:``,stderr:`${e}: install failed: ${UD(t)}\n`,exitCode:1}}if(r.empty&&r.errors.length===0)return{stdout:`${e}: nothing to install (package.json declares no dependencies)\n`,stderr:``,exitCode:0};let i=r.results.map(t=>`${e}: installed ${t.name}@${t.version} -> ${t.installPath}`),a=r.errors.map(t=>`${e}: failed to install ${t.spec}: ${UD(t.error)}`);return{stdout:i.length>0?`${i.join(`
1461
+ `}function BD(e){let t=C(e,{bool:RD,value:[`--location`]});if(`error`in t)return t;let n=t.values.get(`--location`);return n!==void 0&&n!==`global`?{error:`unknown flag: --location=${n}`}:{global:t.bools.has(`-g`)||t.bools.has(`--global`)||n===`global`,saveDev:t.bools.has(`-D`)||t.bools.has(`--save-dev`),specs:t.positionals}}function VD(e){let t=!1,n=[];for(let r of e){if(LD.has(r)){t=!0;continue}r.startsWith(`-`)||n.push(r)}return{global:t,specs:n}}function HD(e){return w(e)}function UD(e){return e instanceof Error?e.message:String(e)}async function WD(e){e.scriptCatalog?.invalidateJsh(),await e.syncScriptCommands?.()}function GD(e,t){let n=e===`i`;return S(e,async(r,i)=>{if(n)return HD(r)?{stdout:zD(e),stderr:``,exitCode:0}:qD(e,r,i,t);if(r[0]===`mamba`){let{runIpkMamba:n}=await import(`./ipk-mamba-CUnjP67u.js`);return n(e,r.slice(1),i,t)}if(HD(r))return{stdout:zD(e),stderr:``,exitCode:0};if(r.length===0)return{stdout:zD(e),stderr:`${e}: missing subcommand\n`,exitCode:1};let a=r[0],o=r.slice(1);return PD.has(a)?qD(e,o,i,t):FD.has(a)?YD(e,o,i,t):ID.has(a)?XD(e,o,i,t):a===`root`?ZD(e,o,i,t):rD.has(a)?ND(e,o,i,{fs:t.fs}):iD.has(a)?ND(e,r,i,{fs:t.fs}):{stdout:``,stderr:`${e}: unknown subcommand '${a}' (supported: install, uninstall, list, root, run, mamba)\n`,exitCode:1}})}async function KD(e,t,n){let r;try{r=await Gi({fs:n.fs,fetch:n.fetch,cwd:t.cwd})}catch(t){return t instanceof Ji?{stdout:``,stderr:`${e}: ${t.message}\n`,exitCode:1}:{stdout:``,stderr:`${e}: install failed: ${UD(t)}\n`,exitCode:1}}if(r.empty&&r.errors.length===0)return{stdout:`${e}: nothing to install (package.json declares no dependencies)\n`,stderr:``,exitCode:0};let i=r.results.map(t=>`${e}: installed ${t.name}@${t.version} -> ${t.installPath}`),a=r.errors.map(t=>`${e}: failed to install ${t.spec}: ${UD(t.error)}`);return{stdout:i.length>0?`${i.join(`
1453
1462
  `)}\n`:``,stderr:a.length>0?`${a.join(`
1454
- `)}\n`:``,exitCode:r.errors.length===0?0:1}}async function KD(e,t,n,r){let i=BD(t);if(`error`in i)return{stdout:``,stderr:`${e}: ${i.error}\n`,exitCode:1};let{global:a,saveDev:o,specs:s}=i;if(a&&s.length===0)return{stdout:``,stderr:`${e}: global install requires at least one package name\n`,exitCode:1};if(s.length===0)return GD(e,n,r);let c;try{c=await Yi(s,{fs:r.fs,fetch:r.fetch,cwd:n.cwd,global:a,saveDev:o})}catch(t){return{stdout:``,stderr:`${e}: install failed: ${UD(t)}\n`,exitCode:1}}let l=c.results.map(t=>`${e}: installed ${t.name}@${t.version} -> ${t.installPath}`),u=c.errors.map(t=>`${e}: failed to install ${t.spec}: ${UD(t.error)}`);return a&&c.results.length>0&&await WD(r),{stdout:l.length>0?`${l.join(`
1463
+ `)}\n`:``,exitCode:r.errors.length===0?0:1}}async function qD(e,t,n,r){let i=BD(t);if(`error`in i)return{stdout:``,stderr:`${e}: ${i.error}\n`,exitCode:1};let{global:a,saveDev:o,specs:s}=i;if(a&&s.length===0)return{stdout:``,stderr:`${e}: global install requires at least one package name\n`,exitCode:1};if(s.length===0)return KD(e,n,r);let c;try{c=await qi(s,{fs:r.fs,fetch:r.fetch,cwd:n.cwd,global:a,saveDev:o})}catch(t){return{stdout:``,stderr:`${e}: install failed: ${UD(t)}\n`,exitCode:1}}let l=c.results.map(t=>`${e}: installed ${t.name}@${t.version} -> ${t.installPath}`),u=c.errors.map(t=>`${e}: failed to install ${t.spec}: ${UD(t.error)}`);return a&&c.results.length>0&&await WD(r),{stdout:l.length>0?`${l.join(`
1455
1464
  `)}\n`:``,stderr:u.length>0?`${u.join(`
1456
- `)}\n`:``,exitCode:c.errors.length===0?0:1}}function qD(e,t){if(t.length===0)return`${e}\n└── (empty)\n`;let n=[`${e}`];for(let e=0;e<t.length;e++){let r=e===t.length-1?`└──`:`├──`;n.push(`${r} ${t[e].name}@${t[e].version}`)}return`${n.join(`
1457
- `)}\n`}async function JD(e,t,n,r){let{global:i,specs:a}=VD(t);if(a.length===0)return{stdout:``,stderr:`${e}: uninstall requires at least one package name\n`,exitCode:1};let o;try{o=await Ji(a,{fs:r.fs,fetch:r.fetch,cwd:n.cwd,global:i})}catch(t){return{stdout:``,stderr:`${e}: uninstall failed: ${UD(t)}\n`,exitCode:1}}let s=o.results.filter(e=>e.removed).map(t=>`${e}: removed ${t.name}`),c=o.results.filter(e=>!e.removed).map(e=>e.name),l=o.errors.map(t=>`${e}: failed to uninstall ${t.spec}: ${UD(t.error)}`);c.length>0&&l.push(`${e}: ${c.join(`, `)} not installed${i?` globally`:``}`);let u=o.errors.length>0;return i&&await WD(r),{stdout:s.length>0?`${s.join(`
1465
+ `)}\n`:``,exitCode:c.errors.length===0?0:1}}function JD(e,t){if(t.length===0)return`${e}\n└── (empty)\n`;let n=[`${e}`];for(let e=0;e<t.length;e++){let r=e===t.length-1?`└──`:`├──`;n.push(`${r} ${t[e].name}@${t[e].version}`)}return`${n.join(`
1466
+ `)}\n`}async function YD(e,t,n,r){let{global:i,specs:a}=VD(t);if(a.length===0)return{stdout:``,stderr:`${e}: uninstall requires at least one package name\n`,exitCode:1};let o;try{o=await Ki(a,{fs:r.fs,fetch:r.fetch,cwd:n.cwd,global:i})}catch(t){return{stdout:``,stderr:`${e}: uninstall failed: ${UD(t)}\n`,exitCode:1}}let s=o.results.filter(e=>e.removed).map(t=>`${e}: removed ${t.name}`),c=o.results.filter(e=>!e.removed).map(e=>e.name),l=o.errors.map(t=>`${e}: failed to uninstall ${t.spec}: ${UD(t.error)}`);c.length>0&&l.push(`${e}: ${c.join(`, `)} not installed${i?` globally`:``}`);let u=o.errors.length>0;return i&&await WD(r),{stdout:s.length>0?`${s.join(`
1458
1467
  `)}\n`:``,stderr:l.length>0?`${l.join(`
1459
- `)}\n`:``,exitCode:+!!u}}async function YD(e,t,n,r){let{global:i}=VD(t);try{let e=i?await Gi(r.fs):await Ui(r.fs,n.cwd);return{stdout:qD(i?nr:n.cwd,e),stderr:``,exitCode:0}}catch(t){return{stdout:``,stderr:`${e}: list failed: ${UD(t)}\n`,exitCode:1}}}async function XD(e,t,n,r){let{global:i}=VD(t);return{stdout:`${i?qn:`${n.cwd.replace(/\/$/,``)}/node_modules`}\n`,stderr:``,exitCode:0}}function ZD(e,t){let n=e===`i`;return S(e,async(r,i)=>{if(HD(r))return{stdout:zD(e),stderr:``,exitCode:0};if(n)return KD(e,r,i,t);if(r.length===0)return{stdout:zD(e),stderr:`${e}: missing subcommand\n`,exitCode:1};let a=r[0],o=r.slice(1);return PD.has(a)?KD(e,o,i,t):FD.has(a)?JD(e,o,i,t):ID.has(a)?YD(e,o,i,t):a===`root`?XD(e,o,i,t):rD.has(a)?ND(e,o,i,{fs:t.fs}):iD.has(a)?ND(e,r,i,{fs:t.fs}):{stdout:``,stderr:`${e}: unknown subcommand '${a}' (supported: install, uninstall, list, root, run)\n`,exitCode:1}})}const QD=`0.5.461`,$D=`v86 is not installed in node_modules: run \`${N} v86@${QD}\` (no network fallback)`;let eO=null;async function tO(e={}){return eO||=aO(e.ipk).catch(e=>{throw eO=null,e}),eO}const nO=[{js:`build/libv86.mjs`,wasm:`build/v86.wasm`}];async function rO(e,t){for(let{js:n,wasm:r}of nO){let i=`${e}/${n}`,a=`${e}/${r}`;if(await t.exists(i)&&await t.exists(a))return{jsPath:i,wasmPath:a}}return null}async function iO(e){let t;try{t=await Jn(`v86/package.json`,e.fromDir,e.reader)}catch{return null}if(t.type!==`file`)return null;let n=await rO(Ee(t.path).dir,e.reader);if(!n)return null;try{let r=await e.reader.readFile(t.path),i=String(JSON.parse(r).version??`0.5.461`);return{jsSource:await e.reader.readFile(n.jsPath),wasmBytes:await e.readBytes(n.wasmPath),version:i}}catch{return null}}async function aO(e){if(sr())throw Error(`v86 is not available in Node runtime`);if(!e)throw Error($D);let t=await iO(e);if(!t)throw Error($D);let n=URL.createObjectURL(new Blob([t.jsSource],{type:`text/javascript`})),r;try{r=await import(n)}finally{URL.revokeObjectURL(n)}let i=r.V86??r.default;if(typeof i!=`function`)throw Error(`v86: installed package did not export a V86 constructor`);return{V86:i,wasmModule:await Xr(t.wasmBytes),version:t.version}}function oO(e){return async t=>(await WebAssembly.instantiate(e,t)).exports}const sO={command:`biome`,example:`biome check foo.js`,bootstrap:`${N} ${v_}`},cO={command:`playwright-cli`,example:`playwright-cli open https://example.com`},lO={command:`puppeteer`,example:`puppeteer open https://example.com`},uO={command:`convert`,example:`convert input.png output.jpg`,bootstrap:`${N} @imagemagick/magick-wasm@${Pi}`},dO={...uO,command:`magick`,example:`magick input.png output.jpg`},fO={command:`pdftoppm`,example:`pdftoppm -png -r 150 doc.pdf page`},pO={"@biomejs/biome":sO,biome:sO,esbuild:{command:`esbuild`,example:`esbuild --bundle src/index.js --outfile=dist/bundle.js`,bootstrap:`${N} esbuild-wasm@${Yr}`},playwright:cO,"@playwright/test":cO,"playwright-core":cO,puppeteer:lO,"puppeteer-core":lO,typescript:{command:`tsc`,example:`tsc --noEmit`,bootstrap:cr},"pdf-poppler":fO,"pdf-to-img":fO,pdf2pic:fO,"pdf-img-convert":fO,poppler:fO,"poppler-utils":fO,imagemagick:uO,"imagemagick-cli":uO,"imagemagick-convert":uO,"magick-cli":dO,"@imagemagick/magick-wasm":dO,ffmpeg:{command:`ffmpeg`,example:`ffmpeg -i input.mp4 output.webm`,bootstrap:`${N} @ffmpeg/core@${$i}`},"@ffmpeg/ffmpeg":{command:`ffmpeg`,example:`ffmpeg -i input.mp4 output.webm`,bootstrap:`${N} @ffmpeg/core@${$i}`},ffprobe:{command:`ffprobe`,example:`ffprobe -v error -show_format -of json input.mp4`,bootstrap:`${N} @ffmpeg/core@${$i}`},"@ffprobe-installer/ffprobe":{command:`ffprobe`,example:`ffprobe -v error -show_format -of json input.mp4`,bootstrap:`${N} @ffmpeg/core@${$i}`},sqlite3:{command:`sqlite3`,example:`sqlite3 database.db "SELECT 1"`},v86:{command:`v86`,example:`v86 start -cdrom alpine.iso`,bootstrap:`${N} v86@${QD}`}};function mO(e){return Object.hasOwn(pO,e)?pO[e]:void 0}function hO(e){return/^[A-Za-z0-9_./:=@%+-]+$/.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`}function gO(e,t,n,r){let i=n.length?[r.command,...n].map(hO).join(` `):r.example,a=[`${e}: SLICC has a built-in \`${r.command}\` for npm package \`${t}\`.`,` try: ${i}`];return r.bootstrap&&a.push(` first run: ${r.bootstrap}`),a.push(` install anyway: ${[e,`--force`,t,...n].map(hO).join(` `)}`),`${a.join(`
1468
+ `)}\n`:``,exitCode:+!!u}}async function XD(e,t,n,r){let{global:i}=VD(t);try{let e=i?await Wi(r.fs):await Ui(r.fs,n.cwd);return{stdout:JD(i?nr:n.cwd,e),stderr:``,exitCode:0}}catch(t){return{stdout:``,stderr:`${e}: list failed: ${UD(t)}\n`,exitCode:1}}}async function ZD(e,t,n,r){let{global:i}=VD(t);return{stdout:`${i?qn:`${n.cwd.replace(/\/$/,``)}/node_modules`}\n`,stderr:``,exitCode:0}}const QD=`0.5.461`,$D=`v86 is not installed in node_modules: run \`${N} v86@${QD}\` (no network fallback)`;let eO=null;async function tO(e={}){return eO||=aO(e.ipk).catch(e=>{throw eO=null,e}),eO}const nO=[{js:`build/libv86.mjs`,wasm:`build/v86.wasm`}];async function rO(e,t){for(let{js:n,wasm:r}of nO){let i=`${e}/${n}`,a=`${e}/${r}`;if(await t.exists(i)&&await t.exists(a))return{jsPath:i,wasmPath:a}}return null}async function iO(e){let t;try{t=await Jn(`v86/package.json`,e.fromDir,e.reader)}catch{return null}if(t.type!==`file`)return null;let n=await rO(Ee(t.path).dir,e.reader);if(!n)return null;try{let r=await e.reader.readFile(t.path),i=String(JSON.parse(r).version??`0.5.461`);return{jsSource:await e.reader.readFile(n.jsPath),wasmBytes:await e.readBytes(n.wasmPath),version:i}}catch{return null}}async function aO(e){if(sr())throw Error(`v86 is not available in Node runtime`);if(!e)throw Error($D);let t=await iO(e);if(!t)throw Error($D);let n=URL.createObjectURL(new Blob([t.jsSource],{type:`text/javascript`})),r;try{r=await import(n)}finally{URL.revokeObjectURL(n)}let i=r.V86??r.default;if(typeof i!=`function`)throw Error(`v86: installed package did not export a V86 constructor`);return{V86:i,wasmModule:await Xr(t.wasmBytes),version:t.version}}function oO(e){return async t=>(await WebAssembly.instantiate(e,t)).exports}const sO={command:`biome`,example:`biome check foo.js`,bootstrap:`${N} ${v_}`},cO={command:`playwright-cli`,example:`playwright-cli open https://example.com`},lO={command:`puppeteer`,example:`puppeteer open https://example.com`},uO={command:`convert`,example:`convert input.png output.jpg`,bootstrap:`${N} @imagemagick/magick-wasm@${Pi}`},dO={...uO,command:`magick`,example:`magick input.png output.jpg`},fO={command:`pdftoppm`,example:`pdftoppm -png -r 150 doc.pdf page`},pO={"@biomejs/biome":sO,biome:sO,esbuild:{command:`esbuild`,example:`esbuild --bundle src/index.js --outfile=dist/bundle.js`,bootstrap:`${N} esbuild-wasm@${Yr}`},playwright:cO,"@playwright/test":cO,"playwright-core":cO,puppeteer:lO,"puppeteer-core":lO,typescript:{command:`tsc`,example:`tsc --noEmit`,bootstrap:cr},"pdf-poppler":fO,"pdf-to-img":fO,pdf2pic:fO,"pdf-img-convert":fO,poppler:fO,"poppler-utils":fO,imagemagick:uO,"imagemagick-cli":uO,"imagemagick-convert":uO,"magick-cli":dO,"@imagemagick/magick-wasm":dO,ffmpeg:{command:`ffmpeg`,example:`ffmpeg -i input.mp4 output.webm`,bootstrap:`${N} @ffmpeg/core@${$i}`},"@ffmpeg/ffmpeg":{command:`ffmpeg`,example:`ffmpeg -i input.mp4 output.webm`,bootstrap:`${N} @ffmpeg/core@${$i}`},ffprobe:{command:`ffprobe`,example:`ffprobe -v error -show_format -of json input.mp4`,bootstrap:`${N} @ffmpeg/core@${$i}`},"@ffprobe-installer/ffprobe":{command:`ffprobe`,example:`ffprobe -v error -show_format -of json input.mp4`,bootstrap:`${N} @ffmpeg/core@${$i}`},sqlite3:{command:`sqlite3`,example:`sqlite3 database.db "SELECT 1"`},v86:{command:`v86`,example:`v86 start -cdrom alpine.iso`,bootstrap:`${N} v86@${QD}`}};function mO(e){return Object.hasOwn(pO,e)?pO[e]:void 0}function hO(e){return/^[A-Za-z0-9_./:=@%+-]+$/.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`}function gO(e,t,n,r){let i=n.length?[r.command,...n].map(hO).join(` `):r.example,a=[`${e}: SLICC has a built-in \`${r.command}\` for npm package \`${t}\`.`,` try: ${i}`];return r.bootstrap&&a.push(` first run: ${r.bootstrap}`),a.push(` install anyway: ${[e,`--force`,t,...n].map(hO).join(` `)}`),`${a.join(`
1460
1469
  `)}\n`}const _O=/require\(\s*["']([^"']+)["']\s*\)/;function vO(e){return`${e} - run an installed package's executable bin
1461
1470
 
1462
1471
  Usage:
@@ -1470,8 +1479,8 @@ Options:
1470
1479
  --force Install a package even when a SLICC built-in shadows it
1471
1480
  --global Resolve only from the shared global prefix (/shared/lib/node_modules)
1472
1481
  -h, --help Show this help message
1473
- `}async function yO(e,t){let n=await e.readFile(t);return typeof n==`string`?n:new TextDecoder().decode(n)}async function bO(e,t){try{return(await e.stat(t)).type===`file`}catch{return!1}}async function xO(e,t){try{return(await e.stat(t)).type===`directory`}catch{return!1}}function*SO(e,t=!1){if(t){yield qn;return}let n=b(e);for(;yield x(n,`node_modules`),n!==`/`;)n=Ee(n).dir;yield qn}async function CO(e,t,n,r=!1){for(let i of SO(t,r)){let t=x(i,`.bin`,n);if(!await bO(e,t))continue;let r=await yO(e,t),a=_O.exec(r),o=Ee(t).dir;return{binFilePath:a?x(o,a[1]):t,argvName:t}}return null}function wO(e){if(e.startsWith(`@`)){let t=e.indexOf(`/`);if(t!==-1)return e.slice(t+1)}return e}function TO(e,t){if(typeof e==`string`)return{binName:wO(t),binPath:e};if(typeof e!=`object`||!e)return null;let n=[t,wO(t)];for(let t of n){let n=Object.getOwnPropertyDescriptor(e,t)?.value;if(typeof n==`string`)return{binName:t,binPath:n}}let r=Object.entries(e).filter(e=>typeof e[1]==`string`);if(r.length===1){let[e,t]=r[0];return{binName:e,binPath:t}}return null}async function EO(e,t,n,r=!1){for(let i of SO(t,r)){let t=x(i,n),r=x(t,`package.json`);if(!await bO(e,r))continue;let a;try{a=JSON.parse(await yO(e,r))}catch{return null}let o=TO(a.bin,n);if(!o)return null;let s=o.binPath.replace(/^\.\//,``);return{binFilePath:x(t,s),argvName:x(i,`.bin`,o.binName)}}return null}async function DO(e,t,n,r=!1){return await CO(e,t,n,r)??await EO(e,t,n,r)}async function OO(e,t,n){for(let r of SO(t))if(await bO(e,x(r,n,`package.json`)))return!0;return!1}function kO(e){return e instanceof Error?e.message:String(e)}function AO(e,t){return{stdout:``,stderr:`${e}: ${t}\n`,exitCode:1}}async function jO(e,t,n,r){try{let i=await Yi([t],{fs:r.fs,fetch:r.fetch,cwd:n.cwd});if(i.errors.length>0)return{error:AO(e,`failed to install '${t}': ${kO(i.errors[0].error)}`)};let a=i.results.map(t=>`${e}: installed ${t.name}@${t.version}`);return{progress:a.length>0?`${a.join(`
1474
- `)}\n`:``}}catch(n){return{error:AO(e,`failed to install '${t}': ${kO(n)}`)}}}async function MO(e,t,n,r){return await bO(r,n)?null:await xO(r,n)?AO(e,`bin target '${n}' is a directory, not a file`):AO(e,`bin file '${n}' for '${t}' does not exist`)}async function NO(e,t,n,r,i,a){if(await OO(a.fs,i.cwd,t))return{error:AO(e,`package '${t}' does not expose an executable bin`)};let o=r?void 0:mO(t);if(o)return{error:{stdout:``,stderr:gO(e,t,n,o),exitCode:1}};let s=await jO(e,t,i,a);if(`error`in s)return s;let c=await DO(a.fs,i.cwd,t);return c?{resolved:c,installProgress:s.progress}:{error:AO(e,`package '${t}' was installed but does not expose an executable bin`)}}function PO(e,t){return{name:e,trusted:!0,async execute(n,r){if(n.length===0||n[0]===`--help`||n[0]===`-h`)return{stdout:vO(e),stderr:``,exitCode:+(n.length===0)};let i=n[0]===`--force`,a=i?n.slice(1):n,o=a[0]===`--global`;o&&(a=a.slice(1));let s=a;if(s.length===0)return{stdout:vO(e),stderr:``,exitCode:1};let c=s[0],l=s.slice(1),u;try{u=await DO(t.fs,r.cwd,c,o)}catch(t){return AO(e,kO(t))}let d=``;if(!u){if(o)return AO(e,`no global bin '${c}' found in ${qn}`);let n=await NO(e,c,l,i,r,t);if(`error`in n)return n.error;u=n.resolved,d=n.installProgress}let f=await MO(e,c,u.binFilePath,t.fs);if(f)return f;let p=Gr(await yO(t.fs,u.binFilePath)),m=[`node`,u.argvName,...l],h=await Ur(p,m,r,void 0,{filename:u.binFilePath});return{stdout:h.stdout,stderr:d+h.stderr,exitCode:h.exitCode}}}}function FO(e={}){return S(`jshd`,async(t,n)=>{let{runJshd:r}=await import(`./run-B4snw1GL.js`);return r(t,n,e)})}const IO=new Set([`SIGINT`,`SIGTERM`,`SIGKILL`,`SIGSTOP`,`SIGCONT`]);function LO(e={}){return S(`kill`,async t=>{if(t.length===0||t.includes(`--help`)||t.includes(`-h`))return UO();let n=e.processManager??RO();if(!n)return{stdout:``,stderr:`kill: no process manager available in this runtime
1482
+ `}async function yO(e,t){let n=await e.readFile(t);return typeof n==`string`?n:new TextDecoder().decode(n)}async function bO(e,t){try{return(await e.stat(t)).type===`file`}catch{return!1}}async function xO(e,t){try{return(await e.stat(t)).type===`directory`}catch{return!1}}function*SO(e,t=!1){if(t){yield qn;return}let n=b(e);for(;yield x(n,`node_modules`),n!==`/`;)n=Ee(n).dir;yield qn}async function CO(e,t,n,r=!1){for(let i of SO(t,r)){let t=x(i,`.bin`,n);if(!await bO(e,t))continue;let r=await yO(e,t),a=_O.exec(r),o=Ee(t).dir;return{binFilePath:a?x(o,a[1]):t,argvName:t}}return null}function wO(e){if(e.startsWith(`@`)){let t=e.indexOf(`/`);if(t!==-1)return e.slice(t+1)}return e}function TO(e,t){if(typeof e==`string`)return{binName:wO(t),binPath:e};if(typeof e!=`object`||!e)return null;let n=[t,wO(t)];for(let t of n){let n=Object.getOwnPropertyDescriptor(e,t)?.value;if(typeof n==`string`)return{binName:t,binPath:n}}let r=Object.entries(e).filter(e=>typeof e[1]==`string`);if(r.length===1){let[e,t]=r[0];return{binName:e,binPath:t}}return null}async function EO(e,t,n,r=!1){for(let i of SO(t,r)){let t=x(i,n),r=x(t,`package.json`);if(!await bO(e,r))continue;let a;try{a=JSON.parse(await yO(e,r))}catch{return null}let o=TO(a.bin,n);if(!o)return null;let s=o.binPath.replace(/^\.\//,``);return{binFilePath:x(t,s),argvName:x(i,`.bin`,o.binName)}}return null}async function DO(e,t,n,r=!1){return await CO(e,t,n,r)??await EO(e,t,n,r)}async function OO(e,t,n){for(let r of SO(t))if(await bO(e,x(r,n,`package.json`)))return!0;return!1}function kO(e){return e instanceof Error?e.message:String(e)}function AO(e,t){return{stdout:``,stderr:`${e}: ${t}\n`,exitCode:1}}async function jO(e,t,n,r){try{let i=await qi([t],{fs:r.fs,fetch:r.fetch,cwd:n.cwd});if(i.errors.length>0)return{error:AO(e,`failed to install '${t}': ${kO(i.errors[0].error)}`)};let a=i.results.map(t=>`${e}: installed ${t.name}@${t.version}`);return{progress:a.length>0?`${a.join(`
1483
+ `)}\n`:``}}catch(n){return{error:AO(e,`failed to install '${t}': ${kO(n)}`)}}}async function MO(e,t,n,r){return await bO(r,n)?null:await xO(r,n)?AO(e,`bin target '${n}' is a directory, not a file`):AO(e,`bin file '${n}' for '${t}' does not exist`)}async function NO(e,t,n,r,i,a){if(await OO(a.fs,i.cwd,t))return{error:AO(e,`package '${t}' does not expose an executable bin`)};let o=r?void 0:mO(t);if(o)return{error:{stdout:``,stderr:gO(e,t,n,o),exitCode:1}};let s=await jO(e,t,i,a);if(`error`in s)return s;let c=await DO(a.fs,i.cwd,t);return c?{resolved:c,installProgress:s.progress}:{error:AO(e,`package '${t}' was installed but does not expose an executable bin`)}}function PO(e,t){return{name:e,trusted:!0,async execute(n,r){if(n.length===0||n[0]===`--help`||n[0]===`-h`)return{stdout:vO(e),stderr:``,exitCode:+(n.length===0)};let i=n[0]===`--force`,a=i?n.slice(1):n,o=a[0]===`--global`;o&&(a=a.slice(1));let s=a;if(s.length===0)return{stdout:vO(e),stderr:``,exitCode:1};let c=s[0],l=s.slice(1),u;try{u=await DO(t.fs,r.cwd,c,o)}catch(t){return AO(e,kO(t))}let d=``;if(!u){if(o)return AO(e,`no global bin '${c}' found in ${qn}`);let n=await NO(e,c,l,i,r,t);if(`error`in n)return n.error;u=n.resolved,d=n.installProgress}let f=await MO(e,c,u.binFilePath,t.fs);if(f)return f;let p=Gr(await yO(t.fs,u.binFilePath)),m=[`node`,u.argvName,...l],h=await Ur(p,m,r,void 0,{filename:u.binFilePath});return{stdout:h.stdout,stderr:d+h.stderr,exitCode:h.exitCode}}}}function FO(e={}){return S(`jshd`,async(t,n)=>{let{runJshd:r}=await import(`./run-DId6fTuG.js`);return r(t,n,e)})}const IO=new Set([`SIGINT`,`SIGTERM`,`SIGKILL`,`SIGSTOP`,`SIGCONT`]);function LO(e={}){return S(`kill`,async t=>{if(t.length===0||t.includes(`--help`)||t.includes(`-h`))return UO();let n=e.processManager??RO();if(!n)return{stdout:``,stderr:`kill: no process manager available in this runtime
1475
1484
  `,exitCode:1};let r=zO(t);if(!r.ok)return{stdout:``,stderr:r.stderr,exitCode:r.exitCode};let{allDelivered:i,errors:a}=BO(n,r.pids,r.signal);return{stdout:``,stderr:a.length?`${a.join(`
1476
1485
  `)}\n`:``,exitCode:+!i}})}function RO(){let e=globalThis.__slicc_pm;return e instanceof Object&&typeof e.signal==`function`?e:null}function zO(e){let t=`SIGTERM`,n=[];for(let r=0;r<e.length;r++){let i=e[r];if(i===`-s`||i===`--signal`){let n=e[++r];if(!n)return{ok:!1,stderr:`kill: -s requires a signal name
1477
1486
  `,exitCode:2};let i=VO(n);if(i instanceof Error)return{ok:!1,stderr:`kill: ${i.message}\n`,exitCode:2};t=i;continue}if(i.startsWith(`-`)){let e=HO(i);if(e instanceof Error)return{ok:!1,stderr:`kill: ${e.message}\n`,exitCode:2};t=e;continue}let a=Number.parseInt(i,10);if(!Number.isFinite(a)||String(a)!==i)return{ok:!1,stderr:`kill: invalid pid '${i}'\n`,exitCode:2};n.push(a)}return n.length===0?{ok:!1,stderr:`kill: no pids supplied
@@ -1544,7 +1553,7 @@ Common base URLs:
1544
1553
  `)+`
1545
1554
  `,stderr:``,exitCode:0}}function gk(e,t){let n=t.models.length;return{stdout:[`✓ ${e} (${fk(t.runtime,!1)})`,` Saved ${n} model${n===1?``:`s`} to Settings:`,...pk(t.models)].join(`
1546
1555
  `)+`
1547
- `,stderr:``,exitCode:0}}function _k(){return S(uk,async e=>{if(e.includes(`--help`)||e.includes(`-h`))return{stdout:dk(),stderr:``,exitCode:0};let{getApiKeyForProvider:t,getRawApiKeyForProvider:n,getBaseUrlForProvider:r,addAccount:i}=await import(`./account-store-irTFXEHq.js`).then(e=>e.t),{verifyConnection:a}=await import(`./local-llm-dPetWUMs.js`).then(e=>e.n),o=e[0]??`status`;if(o!==`status`&&o!==`discover`)return{stdout:``,stderr:`Unknown subcommand: ${o}. See \`local-llm --help\`.\n`,exitCode:2};let s=r(uk);if(!s)return{stdout:``,stderr:`Local LLM is not configured. Open Settings → Providers → Local LLM and set a base URL.
1556
+ `,stderr:``,exitCode:0}}function _k(){return S(uk,async e=>{if(e.includes(`--help`)||e.includes(`-h`))return{stdout:dk(),stderr:``,exitCode:0};let{getApiKeyForProvider:t,getRawApiKeyForProvider:n,getBaseUrlForProvider:r,addAccount:i}=await import(`./account-store-BXYHDz7I.js`).then(e=>e.t),{verifyConnection:a}=await import(`./local-llm-DNAXIB_B.js`).then(e=>e.n),o=e[0]??`status`;if(o!==`status`&&o!==`discover`)return{stdout:``,stderr:`Unknown subcommand: ${o}. See \`local-llm --help\`.\n`,exitCode:2};let s=r(uk);if(!s)return{stdout:``,stderr:`Local LLM is not configured. Open Settings → Providers → Local LLM and set a base URL.
1548
1557
  `,exitCode:1};let c=await a(s,t(uk)??void 0);if(!c.ok)return mk(s,c);if(o===`discover`){let e=n(uk)??``;return i(uk,e,s,c.models.join(`, `)),gk(s,c)}return hk(s,c)})}function vk(){return{stdout:`usage: man <topic>
1549
1558
 
1550
1559
  Fetches documentation for a given topic from sliccy.com.
@@ -1582,20 +1591,20 @@ authorization-code flow, stores the access token, and retries.
1582
1591
  On success, the server is persisted to /workspace/.mcp/servers.json and
1583
1592
  an alias shim is written to /workspace/.mcp/aliases/<name>.jsh so the
1584
1593
  short name resolves on the PATH.
1585
- `);let n=C(e,{});if(`error`in n)return wk(n.error);if(n.positionals.length<2)return W(`mcp add: expected <url> <name>`);let[r,i]=n.positionals;if(!/^https?:\/\//i.test(r))return W(`mcp add: invalid URL "${r}" (must start with http:// or https://)`);if(!/^[A-Za-z][A-Za-z0-9_-]*$/.test(i))return W(`mcp add: invalid name "${i}" (letters, digits, _ and - only; must start with a letter)`);let{getServer:a,setServer:o}=await import(`./store-BikzV66S.js`).then(e=>e.r);if(await a(i,t.fs))return W(`mcp add: a server named "${i}" already exists`);let{McpClient:s,McpAuthRequiredError:c}=await import(`./client-CwxmlQM-.js`).then(e=>e.n),l=new s({url:r,fetchImpl:t.fetchImpl}),u;try{await l.initialize()}catch(e){if(!(e instanceof c))throw e;u=await Ok(r,i,e.resourceMetadataUrl,t),l=new s({url:r,fetchImpl:t.fetchImpl,getAuthHeader:()=>rA(i)}),await l.initialize()}let d=await l.toolsList(),f=await l.appsList(),p=new Date().toISOString();await o(i,{url:r,protocolVersion:l.getNegotiatedProtocolVersion(),tools:d,apps:f,addedAt:p,lastRefreshedAt:p,...u?{auth:u}:{}},t.fs),await cA(i,t);let m=await dA(i,f,t);if(u){let{registerMcpProvider:e}=await import(`./provider-DqEfigmv.js`);e({name:i,serverUrl:r,auth:u})}return U([`Added MCP server "${i}" → ${r}`,` tools: ${d.length}, apps: ${f.length} (${m} sprinkle${m===1?``:`s`})`,` alias: ${Ck}/${i}.jsh`,u?` auth: oauth (provider mcp:${i})`:` auth: none`].join(`
1594
+ `);let n=C(e,{});if(`error`in n)return wk(n.error);if(n.positionals.length<2)return W(`mcp add: expected <url> <name>`);let[r,i]=n.positionals;if(!/^https?:\/\//i.test(r))return W(`mcp add: invalid URL "${r}" (must start with http:// or https://)`);if(!/^[A-Za-z][A-Za-z0-9_-]*$/.test(i))return W(`mcp add: invalid name "${i}" (letters, digits, _ and - only; must start with a letter)`);let{getServer:a,setServer:o}=await import(`./store-Cm5EQ4O4.js`).then(e=>e.r);if(await a(i,t.fs))return W(`mcp add: a server named "${i}" already exists`);let{McpClient:s,McpAuthRequiredError:c}=await import(`./client-CwxmlQM-.js`).then(e=>e.n),l=new s({url:r,fetchImpl:t.fetchImpl}),u;try{await l.initialize()}catch(e){if(!(e instanceof c))throw e;u=await Ok(r,i,e.resourceMetadataUrl,t),l=new s({url:r,fetchImpl:t.fetchImpl,getAuthHeader:()=>rA(i)}),await l.initialize()}let d=await l.toolsList(),f=await l.appsList(),p=new Date().toISOString();await o(i,{url:r,protocolVersion:l.getNegotiatedProtocolVersion(),tools:d,apps:f,addedAt:p,lastRefreshedAt:p,...u?{auth:u}:{}},t.fs),await cA(i,t);let m=await dA(i,f,t);if(u){let{registerMcpProvider:e}=await import(`./provider-Cqq8Bumu.js`);e({name:i,serverUrl:r,auth:u})}return U([`Added MCP server "${i}" → ${r}`,` tools: ${d.length}, apps: ${f.length} (${m} sprinkle${m===1?``:`s`})`,` alias: ${Ck}/${i}.jsh`,u?` auth: oauth (provider mcp:${i})`:` auth: none`].join(`
1586
1595
  `)+`
1587
- `)}async function Ok(e,t,n,r){let{discoverAuth:i,dynamicRegister:a,runAuthFlow:o}=await import(`./oauth-D20BEoY6.js`),{saveOAuthAccount:s}=await import(`./account-store-irTFXEHq.js`).then(e=>e.t),c=await aA(r.oauthFetchImpl),l=r.oauthLauncher??await iA(),u=await i(e,n,c);Sk.debug(`MCP OAuth discovery succeeded`,{name:t,serverUrl:e,discoveryPath:u.discoveryPath,issuer:u.issuer});let d=await na(_e()),f=await a(u,d,c),p=u.supportedScopes&&u.supportedScopes.length>0?u.supportedScopes.join(` `):void 0,m=await o({asMetadata:u,clientId:f.clientId,scope:p,redirectUri:d,launcher:l,fetchImpl:c}),h=`mcp:${t}`;return await s({providerId:h,accessToken:m.accessToken,refreshToken:m.refreshToken,tokenExpiresAt:m.expiresAt,scopes:m.scope}),{providerId:h,authorizationServer:u.issuer,clientId:f.clientId,redirectUri:d,scope:m.scope??p,registrationClientUri:f.registrationClientUri}}async function kk(e,t){if(w(e))return U(`usage: mcp list
1588
- `);let n=C(e,{});if(`error`in n)return wk(n.error);let{ensureAllMcpProvidersRegistered:r}=await import(`./provider-DqEfigmv.js`);await r();let{listServers:i}=await import(`./store-BikzV66S.js`).then(e=>e.r),a=await i(t.fs),o=Object.keys(a).sort();if(o.length===0)return U("No MCP servers configured. Use `mcp add <url> <name>`.\n");let s=[[`NAME`,`URL`,`AUTH`,`TOOLS`,`APPS`,`ADDED`]];for(let e of o){let t=a[e];s.push([e,t.url,t.auth?`yes`:`no`,String(t.tools?.length??0),String(t.apps?.length??0),t.addedAt?t.addedAt.slice(0,10):`-`])}return U(Ak(s))}function Ak(e){let t=e[0].map((t,n)=>e.reduce((e,t)=>Math.max(e,(t[n]??``).length),0));return e.map(e=>e.map((e,n)=>e.padEnd(t[n])).join(` `).trimEnd()).join(`
1596
+ `)}async function Ok(e,t,n,r){let{discoverAuth:i,dynamicRegister:a,runAuthFlow:o}=await import(`./oauth-D20BEoY6.js`),{saveOAuthAccount:s}=await import(`./account-store-BXYHDz7I.js`).then(e=>e.t),c=await aA(r.oauthFetchImpl),l=r.oauthLauncher??await iA(),u=await i(e,n,c);Sk.debug(`MCP OAuth discovery succeeded`,{name:t,serverUrl:e,discoveryPath:u.discoveryPath,issuer:u.issuer});let d=await na(_e()),f=await a(u,d,c),p=u.supportedScopes&&u.supportedScopes.length>0?u.supportedScopes.join(` `):void 0,m=await o({asMetadata:u,clientId:f.clientId,scope:p,redirectUri:d,launcher:l,fetchImpl:c}),h=`mcp:${t}`;return await s({providerId:h,accessToken:m.accessToken,refreshToken:m.refreshToken,tokenExpiresAt:m.expiresAt,scopes:m.scope}),{providerId:h,authorizationServer:u.issuer,clientId:f.clientId,redirectUri:d,scope:m.scope??p,registrationClientUri:f.registrationClientUri}}async function kk(e,t){if(w(e))return U(`usage: mcp list
1597
+ `);let n=C(e,{});if(`error`in n)return wk(n.error);let{ensureAllMcpProvidersRegistered:r}=await import(`./provider-Cqq8Bumu.js`);await r();let{listServers:i}=await import(`./store-Cm5EQ4O4.js`).then(e=>e.r),a=await i(t.fs),o=Object.keys(a).sort();if(o.length===0)return U("No MCP servers configured. Use `mcp add <url> <name>`.\n");let s=[[`NAME`,`URL`,`AUTH`,`TOOLS`,`APPS`,`ADDED`]];for(let e of o){let t=a[e];s.push([e,t.url,t.auth?`yes`:`no`,String(t.tools?.length??0),String(t.apps?.length??0),t.addedAt?t.addedAt.slice(0,10):`-`])}return U(Ak(s))}function Ak(e){let t=e[0].map((t,n)=>e.reduce((e,t)=>Math.max(e,(t[n]??``).length),0));return e.map(e=>e.map((e,n)=>e.padEnd(t[n])).join(` `).trimEnd()).join(`
1589
1598
  `)+`
1590
1599
  `}async function jk(e,t){if(w(e))return U(`usage: mcp search <query>
1591
1600
 
1592
1601
  Case-insensitive substring search across the cached tools of every
1593
1602
  registered MCP server. Matches tool name OR description and prints a
1594
1603
  table of (server, tool, description, match-field) rows.
1595
- `);let n=C(e,{});if(`error`in n)return wk(n.error);if(n.positionals.length===0)return W(`mcp search: expected <query>`);let r=n.positionals[0],i=r.toLowerCase(),{ensureAllMcpProvidersRegistered:a}=await import(`./provider-DqEfigmv.js`);await a();let{listServers:o}=await import(`./store-BikzV66S.js`).then(e=>e.r),s=await o(t.fs),c=Object.keys(s).sort();if(c.length===0)return U("No MCP servers configured. Use `mcp add <url> <name>`.\n");let l=[];for(let e of c){let t=s[e].tools??[];for(let n of t){let t=n.description??``,r=n.name.toLowerCase().includes(i),a=t.toLowerCase().includes(i);if(!r&&!a)continue;let o=r&&a?`name+description`:r?`name`:`description`;l.push({server:e,tool:n.name,description:t,match:o})}}if(l.length===0)return U(`No tools matched "${r}".\n`);l.sort((e,t)=>e.server===t.server?e.tool.localeCompare(t.tool):e.server.localeCompare(t.server));let u=[[`SERVER`,`TOOL`,`DESCRIPTION`,`MATCH`]];for(let e of l)u.push([e.server,e.tool,Mk(e.description),e.match]);return U(Ak(u))}function Mk(e){if(!e)return``;let t=e.replace(/\s+/g,` `).trim();return t.length<=60?t:t.slice(0,59)+`…`}async function Nk(e,t){if(e.length===0||w(e))return e.length===0?W(`mcp delete: expected <name>`):U(`usage: mcp delete <name>
1596
- `);let n=C(e,{});if(`error`in n)return wk(n.error);let r=n.positionals[0];if(!r)return W(`mcp delete: expected <name>`);let{ensureMcpProviderRegistered:i,removeMcpProvider:a}=await import(`./provider-DqEfigmv.js`);await i(r);let{deleteServer:o}=await import(`./store-BikzV66S.js`).then(e=>e.r),s=await o(r,t.fs);await lA(r,t),await uA(r,t);let c=`mcp:${r}`,l=!1;try{let{removeAccount:e,getAccounts:t}=await import(`./account-store-irTFXEHq.js`).then(e=>e.t);t().some(e=>e.providerId===c)&&(await e(c),l=!0)}catch(e){Sk.warn(`mcp delete: OAuth removal failed`,{providerId:c,error:e instanceof Error?e.message:String(e)})}let u=a(r);return!s&&!l&&!u?W(`mcp delete: no server, alias, or account found for "${r}"`):U([`Removed MCP server "${r}"`,` servers.json: ${s?`removed`:`not present`}`,` alias: cleaned`,` sprinkles: cleaned`,` oauth: ${l?`removed`:`not present`}`,` provider: ${u?`unregistered`:`not registered`}`].join(`
1604
+ `);let n=C(e,{});if(`error`in n)return wk(n.error);if(n.positionals.length===0)return W(`mcp search: expected <query>`);let r=n.positionals[0],i=r.toLowerCase(),{ensureAllMcpProvidersRegistered:a}=await import(`./provider-Cqq8Bumu.js`);await a();let{listServers:o}=await import(`./store-Cm5EQ4O4.js`).then(e=>e.r),s=await o(t.fs),c=Object.keys(s).sort();if(c.length===0)return U("No MCP servers configured. Use `mcp add <url> <name>`.\n");let l=[];for(let e of c){let t=s[e].tools??[];for(let n of t){let t=n.description??``,r=n.name.toLowerCase().includes(i),a=t.toLowerCase().includes(i);if(!r&&!a)continue;let o=r&&a?`name+description`:r?`name`:`description`;l.push({server:e,tool:n.name,description:t,match:o})}}if(l.length===0)return U(`No tools matched "${r}".\n`);l.sort((e,t)=>e.server===t.server?e.tool.localeCompare(t.tool):e.server.localeCompare(t.server));let u=[[`SERVER`,`TOOL`,`DESCRIPTION`,`MATCH`]];for(let e of l)u.push([e.server,e.tool,Mk(e.description),e.match]);return U(Ak(u))}function Mk(e){if(!e)return``;let t=e.replace(/\s+/g,` `).trim();return t.length<=60?t:t.slice(0,59)+`…`}async function Nk(e,t){if(e.length===0||w(e))return e.length===0?W(`mcp delete: expected <name>`):U(`usage: mcp delete <name>
1605
+ `);let n=C(e,{});if(`error`in n)return wk(n.error);let r=n.positionals[0];if(!r)return W(`mcp delete: expected <name>`);let{ensureMcpProviderRegistered:i,removeMcpProvider:a}=await import(`./provider-Cqq8Bumu.js`);await i(r);let{deleteServer:o}=await import(`./store-Cm5EQ4O4.js`).then(e=>e.r),s=await o(r,t.fs);await lA(r,t),await uA(r,t);let c=`mcp:${r}`,l=!1;try{let{removeAccount:e,getAccounts:t}=await import(`./account-store-BXYHDz7I.js`).then(e=>e.t);t().some(e=>e.providerId===c)&&(await e(c),l=!0)}catch(e){Sk.warn(`mcp delete: OAuth removal failed`,{providerId:c,error:e instanceof Error?e.message:String(e)})}let u=a(r);return!s&&!l&&!u?W(`mcp delete: no server, alias, or account found for "${r}"`):U([`Removed MCP server "${r}"`,` servers.json: ${s?`removed`:`not present`}`,` alias: cleaned`,` sprinkles: cleaned`,` oauth: ${l?`removed`:`not present`}`,` provider: ${u?`unregistered`:`not registered`}`].join(`
1597
1606
  `)+`
1598
- `)}async function Pk(e,t){if(e.length===0)return W(`mcp invoke: expected <name>`);if(w(e.slice(0,1)))return U(Lk());let n=C([e[0]],{});if(`error`in n)return wk(n.error);let r=n.positionals[0];if(!r)return W(`mcp invoke: expected <name>`);let i=e.slice(1),{ensureMcpProviderRegistered:a}=await import(`./provider-DqEfigmv.js`);await a(r);let{getServer:o}=await import(`./store-BikzV66S.js`).then(e=>e.r),s=await o(r,t.fs);if(!s)return W(`mcp invoke: unknown server "${r}" (run \`mcp add <url> ${r}\` first)`);let c=s.tools??[];if(i.length===0||w(i.slice(0,1)))return U(Rk(r,s,c));let l=C([i[0]],{});if(`error`in l)return wk(l.error);let u=l.positionals[0];if(!u)return W(`mcp invoke: expected <tool>`);let d=c.find(e=>e.name===u);if(!d)return W(`mcp invoke: unknown tool "${u}" on "${r}" (run \`${r}\` to list tools)`);let{timeoutMs:f,remaining:p,warnings:m}=Fk(i.slice(1));if(w(p))return U(Bk(r,d));let h=Vk(p,d.inputSchema);if(!h.ok)return W(`mcp invoke: ${h.error}`);let{McpClient:g}=await import(`./client-CwxmlQM-.js`).then(e=>e.n),_=new g({url:s.url,fetchImpl:t.fetchImpl,headers:s.headers,getAuthHeader:s.auth?()=>rA(r):void 0,...f===void 0?{}:{timeoutMs:f}});await _.initialize();let v=$k(await _.toolsCall(u,h.value));return m.length>0&&(v.stderr=m.map(e=>`${e}\n`).join(``)+v.stderr),v}function Fk(e){let t=[],n=[],r,i=0;for(;i<e.length;){let a=e[i];if(a.startsWith(`--timeout=`)){let e=Ik(a.slice(10));e.ok?r=e.value:n.push(e.error),i+=1;continue}if(a===`--timeout`){let t=e[i+1];if(t===void 0||t.startsWith(`--`)){n.push(`mcp invoke: --timeout requires a value (got ${t===void 0?`nothing`:`"${t}"`}); using default.`),i+=1;continue}let a=Ik(t);a.ok?r=a.value:n.push(a.error),i+=2;continue}t.push(a),i+=1}return{timeoutMs:r,remaining:t,warnings:n}}function Ik(e){if(!/^-?\d+$/.test(e))return{ok:!1,error:`mcp invoke: invalid --timeout value "${e}" (expected positive integer seconds); using default.`};let t=Number(e);return!Number.isFinite(t)||t<1?{ok:!1,error:`mcp invoke: invalid --timeout value "${e}" (must be >= 1 second); using default.`}:{ok:!0,value:t*1e3}}function Lk(){return`usage: mcp invoke <name> [tool] [--timeout <seconds>] [--flag value …]
1607
+ `)}async function Pk(e,t){if(e.length===0)return W(`mcp invoke: expected <name>`);if(w(e.slice(0,1)))return U(Lk());let n=C([e[0]],{});if(`error`in n)return wk(n.error);let r=n.positionals[0];if(!r)return W(`mcp invoke: expected <name>`);let i=e.slice(1),{ensureMcpProviderRegistered:a}=await import(`./provider-Cqq8Bumu.js`);await a(r);let{getServer:o}=await import(`./store-Cm5EQ4O4.js`).then(e=>e.r),s=await o(r,t.fs);if(!s)return W(`mcp invoke: unknown server "${r}" (run \`mcp add <url> ${r}\` first)`);let c=s.tools??[];if(i.length===0||w(i.slice(0,1)))return U(Rk(r,s,c));let l=C([i[0]],{});if(`error`in l)return wk(l.error);let u=l.positionals[0];if(!u)return W(`mcp invoke: expected <tool>`);let d=c.find(e=>e.name===u);if(!d)return W(`mcp invoke: unknown tool "${u}" on "${r}" (run \`${r}\` to list tools)`);let{timeoutMs:f,remaining:p,warnings:m}=Fk(i.slice(1));if(w(p))return U(Bk(r,d));let h=Vk(p,d.inputSchema);if(!h.ok)return W(`mcp invoke: ${h.error}`);let{McpClient:g}=await import(`./client-CwxmlQM-.js`).then(e=>e.n),_=new g({url:s.url,fetchImpl:t.fetchImpl,headers:s.headers,getAuthHeader:s.auth?()=>rA(r):void 0,...f===void 0?{}:{timeoutMs:f}});await _.initialize();let v=$k(await _.toolsCall(u,h.value));return m.length>0&&(v.stderr=m.map(e=>`${e}\n`).join(``)+v.stderr),v}function Fk(e){let t=[],n=[],r,i=0;for(;i<e.length;){let a=e[i];if(a.startsWith(`--timeout=`)){let e=Ik(a.slice(10));e.ok?r=e.value:n.push(e.error),i+=1;continue}if(a===`--timeout`){let t=e[i+1];if(t===void 0||t.startsWith(`--`)){n.push(`mcp invoke: --timeout requires a value (got ${t===void 0?`nothing`:`"${t}"`}); using default.`),i+=1;continue}let a=Ik(t);a.ok?r=a.value:n.push(a.error),i+=2;continue}t.push(a),i+=1}return{timeoutMs:r,remaining:t,warnings:n}}function Ik(e){if(!/^-?\d+$/.test(e))return{ok:!1,error:`mcp invoke: invalid --timeout value "${e}" (expected positive integer seconds); using default.`};let t=Number(e);return!Number.isFinite(t)||t<1?{ok:!1,error:`mcp invoke: invalid --timeout value "${e}" (must be >= 1 second); using default.`}:{ok:!0,value:t*1e3}}function Lk(){return`usage: mcp invoke <name> [tool] [--timeout <seconds>] [--flag value …]
1599
1608
 
1600
1609
  mcp invoke <name> List tools on <name>.
1601
1610
  mcp invoke <name> <tool> --help Show flags for <tool>.
@@ -1628,7 +1637,7 @@ Arguments are coerced according to the tool's JSON Schema:
1628
1637
 
1629
1638
  Re-fetches the tool catalog and \`apps/list\` for <name>. Does NOT refresh
1630
1639
  OAuth tokens — for OAuth token refresh use \`mcp auth <name>\`.
1631
- `);let n=C(e,{});if(`error`in n)return wk(n.error);let r=n.positionals[0];if(!r)return W(`mcp refresh: expected <name>`);let{ensureMcpProviderRegistered:i}=await import(`./provider-DqEfigmv.js`);await i(r);let{getServer:a,setServer:o}=await import(`./store-BikzV66S.js`).then(e=>e.r),s=await a(r,t.fs);if(!s)return W(`mcp refresh: unknown server "${r}"`);let{McpClient:c,McpAuthRequiredError:l}=await import(`./client-CwxmlQM-.js`).then(e=>e.n),u=new c({url:s.url,fetchImpl:t.fetchImpl,headers:s.headers,getAuthHeader:s.auth?()=>rA(r):void 0});try{await u.initialize()}catch(e){if(e instanceof l)return W(`mcp refresh: server "${r}" returned 401 — token may have expired. Run \`mcp auth ${r}\` to re-authenticate.`);throw e}let d=await u.toolsList(),f=await u.appsList();await o(r,{...s,protocolVersion:u.getNegotiatedProtocolVersion(),tools:d,apps:f,lastRefreshedAt:new Date().toISOString()},t.fs);let p=await dA(r,f,t);return U(`Refreshed "${r}" — tools: ${d.length}, apps: ${f.length} (${p} sprinkle${p===1?``:`s`})\n`)}async function tA(e,t){if(w(e))return U(`usage: mcp auth <name> [--silent | --interactive]
1640
+ `);let n=C(e,{});if(`error`in n)return wk(n.error);let r=n.positionals[0];if(!r)return W(`mcp refresh: expected <name>`);let{ensureMcpProviderRegistered:i}=await import(`./provider-Cqq8Bumu.js`);await i(r);let{getServer:a,setServer:o}=await import(`./store-Cm5EQ4O4.js`).then(e=>e.r),s=await a(r,t.fs);if(!s)return W(`mcp refresh: unknown server "${r}"`);let{McpClient:c,McpAuthRequiredError:l}=await import(`./client-CwxmlQM-.js`).then(e=>e.n),u=new c({url:s.url,fetchImpl:t.fetchImpl,headers:s.headers,getAuthHeader:s.auth?()=>rA(r):void 0});try{await u.initialize()}catch(e){if(e instanceof l)return W(`mcp refresh: server "${r}" returned 401 — token may have expired. Run \`mcp auth ${r}\` to re-authenticate.`);throw e}let d=await u.toolsList(),f=await u.appsList();await o(r,{...s,protocolVersion:u.getNegotiatedProtocolVersion(),tools:d,apps:f,lastRefreshedAt:new Date().toISOString()},t.fs);let p=await dA(r,f,t);return U(`Refreshed "${r}" — tools: ${d.length}, apps: ${f.length} (${p} sprinkle${p===1?``:`s`})\n`)}async function tA(e,t){if(w(e))return U(`usage: mcp auth <name> [--silent | --interactive]
1632
1641
 
1633
1642
  Re-authenticate an existing MCP server. By default, attempts a silent
1634
1643
  token renewal using the persisted refresh_token; if that returns no
@@ -1640,7 +1649,7 @@ Options:
1640
1649
  -i, --interactive Skip silent renewal and open the OAuth popup
1641
1650
  directly. Use after revoking a refresh token or
1642
1651
  when the AS no longer accepts the cached one.
1643
- `);let n=C(e,{bool:xk});if(`error`in n)return wk(n.error);let r=n.positionals[0];if(!r)return W(`mcp auth: expected <name>`);let i=n.bools.has(`--silent`)||n.bools.has(`-s`),a=n.bools.has(`--interactive`)||n.bools.has(`-i`);if(i&&a)return W(`mcp auth: --silent and --interactive are mutually exclusive`);let{ensureMcpProviderRegistered:o}=await import(`./provider-DqEfigmv.js`),s=await o(r,{fetchImpl:t.oauthFetchImpl,launcher:t.oauthLauncher}),{getServer:c}=await import(`./store-BikzV66S.js`).then(e=>e.r),l=await c(r,t.fs);if(!l)return W(`mcp auth: unknown server "${r}" (run \`mcp list\` to see configured servers)`);if(!l.auth)return W(`mcp auth: server "${r}" does not use OAuth`);if(!s)return W(`mcp auth: failed to register provider for "${r}"`);let u=`mcp:${r}`,{getRegisteredProviderConfig:d}=await import(`./providers-B3cOXz1H.js`).then(e=>e.r),f=d(u);if(!f)return W(`mcp auth: provider "${u}" is not registered`);if(a)return await nA(r,f,t);if(!f.onSilentRenew)return i?W(`mcp auth: provider "${u}" does not support silent renewal; retry without --silent`):await nA(r,f,t);let p=null;try{p=await f.onSilentRenew()}catch(e){let t=e instanceof Error?e.message:String(e);if(i)return W(`mcp auth: silent renewal for "${r}" failed (${t}); retry without --silent to run the interactive flow`);Sk.debug(`mcp auth: silent renewal threw, falling back to interactive`,{name:r,error:t})}return p?U(`Re-authenticated "${r}" via silent renewal (provider ${u})\n`):i?W(`mcp auth: silent renewal for "${r}" returned no token; retry without --silent to run the interactive flow`):await nA(r,f,t)}async function nA(e,t,n){if(!t.onOAuthLogin)return W(`mcp auth: provider "${t.id}" does not support interactive OAuth login`);let r=n.oauthLauncher??await iA(),i=!1;return await t.onOAuthLogin(r,()=>{i=!0}),i?U(`Re-authenticated "${e}" via interactive login (provider ${t.id})\n`):W(`mcp auth: interactive login for "${e}" did not complete`)}async function rA(e){let t=`mcp:${e}`,{getOAuthAccountInfo:n}=await import(`./account-store-irTFXEHq.js`).then(e=>e.t),r=n(t);if(!r)return null;if(r.expired){try{let{getRegisteredProviderConfig:e}=await import(`./providers-B3cOXz1H.js`).then(e=>e.r),n=await e(t)?.onSilentRenew?.();if(n)return`Bearer ${n}`}catch(e){Sk.debug(`silent renewal threw`,{providerId:t,error:e instanceof Error?e.message:String(e)})}return null}return`Bearer ${r.token}`}async function iA(){let{createOAuthLauncher:e}=await import(`./oauth-service-DP3Rx6V_.js`);return e()}async function aA(e){if(e)return e;let{createProxiedFetch:t}=await import(`./proxied-fetch-DXaTHROw.js`).then(e=>e.a),n=t();return async(e,t)=>{let r=await n(e,{method:t?.method,headers:t?.headers,body:t?.body}),i=new TextDecoder().decode(r.body);return{ok:r.status>=200&&r.status<300,status:r.status,statusText:r.statusText,text:async()=>i,json:async()=>JSON.parse(i),headers:{get:e=>r.headers[e.toLowerCase()]??null}}}}async function oA(e){if(e)return e;let{VirtualFS:t}=await import(`./fs-D5UZBrBX.js`).then(e=>e.t),{GLOBAL_FS_DB_NAME:n}=await import(`./global-db-DJXlpNui.js`).then(e=>e.n);return await t.create({dbName:n})}function sA(e){return`// MCP alias for "${e}" — forwards args to \`mcp invoke ${e}\`.
1652
+ `);let n=C(e,{bool:xk});if(`error`in n)return wk(n.error);let r=n.positionals[0];if(!r)return W(`mcp auth: expected <name>`);let i=n.bools.has(`--silent`)||n.bools.has(`-s`),a=n.bools.has(`--interactive`)||n.bools.has(`-i`);if(i&&a)return W(`mcp auth: --silent and --interactive are mutually exclusive`);let{ensureMcpProviderRegistered:o}=await import(`./provider-Cqq8Bumu.js`),s=await o(r,{fetchImpl:t.oauthFetchImpl,launcher:t.oauthLauncher}),{getServer:c}=await import(`./store-Cm5EQ4O4.js`).then(e=>e.r),l=await c(r,t.fs);if(!l)return W(`mcp auth: unknown server "${r}" (run \`mcp list\` to see configured servers)`);if(!l.auth)return W(`mcp auth: server "${r}" does not use OAuth`);if(!s)return W(`mcp auth: failed to register provider for "${r}"`);let u=`mcp:${r}`,{getRegisteredProviderConfig:d}=await import(`./providers-BcK4GJL5.js`).then(e=>e.r),f=d(u);if(!f)return W(`mcp auth: provider "${u}" is not registered`);if(a)return await nA(r,f,t);if(!f.onSilentRenew)return i?W(`mcp auth: provider "${u}" does not support silent renewal; retry without --silent`):await nA(r,f,t);let p=null;try{p=await f.onSilentRenew()}catch(e){let t=e instanceof Error?e.message:String(e);if(i)return W(`mcp auth: silent renewal for "${r}" failed (${t}); retry without --silent to run the interactive flow`);Sk.debug(`mcp auth: silent renewal threw, falling back to interactive`,{name:r,error:t})}return p?U(`Re-authenticated "${r}" via silent renewal (provider ${u})\n`):i?W(`mcp auth: silent renewal for "${r}" returned no token; retry without --silent to run the interactive flow`):await nA(r,f,t)}async function nA(e,t,n){if(!t.onOAuthLogin)return W(`mcp auth: provider "${t.id}" does not support interactive OAuth login`);let r=n.oauthLauncher??await iA(),i=!1;return await t.onOAuthLogin(r,()=>{i=!0}),i?U(`Re-authenticated "${e}" via interactive login (provider ${t.id})\n`):W(`mcp auth: interactive login for "${e}" did not complete`)}async function rA(e){let t=`mcp:${e}`,{getOAuthAccountInfo:n}=await import(`./account-store-BXYHDz7I.js`).then(e=>e.t),r=n(t);if(!r)return null;if(r.expired){try{let{getRegisteredProviderConfig:e}=await import(`./providers-BcK4GJL5.js`).then(e=>e.r),n=await e(t)?.onSilentRenew?.();if(n)return`Bearer ${n}`}catch(e){Sk.debug(`silent renewal threw`,{providerId:t,error:e instanceof Error?e.message:String(e)})}return null}return`Bearer ${r.token}`}async function iA(){let{createOAuthLauncher:e}=await import(`./oauth-service-DP3Rx6V_.js`);return e()}async function aA(e){if(e)return e;let{createProxiedFetch:t}=await import(`./proxied-fetch-DXaTHROw.js`).then(e=>e.a),n=t();return async(e,t)=>{let r=await n(e,{method:t?.method,headers:t?.headers,body:t?.body}),i=new TextDecoder().decode(r.body);return{ok:r.status>=200&&r.status<300,status:r.status,statusText:r.statusText,text:async()=>i,json:async()=>JSON.parse(i),headers:{get:e=>r.headers[e.toLowerCase()]??null}}}}async function oA(e){if(e)return e;let{VirtualFS:t}=await import(`./fs-DL0b9F_-.js`).then(e=>e.t),{GLOBAL_FS_DB_NAME:n}=await import(`./global-db-DJXlpNui.js`).then(e=>e.n);return await t.create({dbName:n})}function sA(e){return`// MCP alias for "${e}" — forwards args to \`mcp invoke ${e}\`.
1644
1653
  // Auto-generated by \`mcp add ${e}\`; do not edit by hand.
1645
1654
  const { promisify } = require('util');
1646
1655
  const { exec } = require('child_process');
@@ -1669,7 +1678,7 @@ try {
1669
1678
  if (stdout) process.stdout.write(stdout);
1670
1679
  if (stderr) process.stderr.write(stderr);
1671
1680
  process.exit(exitCode);
1672
- `}async function cA(e,t){let n=await oA(t.fs);await n.mkdir(Ck,{recursive:!0}),await n.writeFile(`${Ck}/${e}.jsh`,sA(e)),t.scriptCatalog?.invalidateJsh()}async function lA(e,t){let n=await oA(t.fs),r=`${Ck}/${e}.jsh`;try{await n.exists(r)&&await n.rm(r)}catch(e){Sk.debug(`alias removal failed`,{path:r,error:e instanceof Error?e.message:String(e)})}t.scriptCatalog?.invalidateJsh()}async function uA(e,t){let{removeAppSprinkles:n}=await import(`./apps-CWLDElDt.js`);await n(e,t.fs)}async function dA(e,t,n){try{let{materializeAppSprinkles:r}=await import(`./apps-CWLDElDt.js`);return(await r(e,t,n.fs)).length}catch(t){return Sk.warn(`mcp: failed to materialize app sprinkles`,{name:e,error:t instanceof Error?t.message:String(t)}),0}}function fA(e){return{stdout:``,stderr:`meminfo: ${e}\n`,exitCode:1}}function pA(e){if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`],n=e,r=`B`;for(let e of t){if(n<1024)break;n/=1024,r=e}return`${n.toFixed(1)} ${r}`}function mA(e){return e.attribution.length===0?`(shared)`:e.attribution.map(e=>{let t=e.container?.src??e.container?.id??e.url??`?`;return e.scope?`${e.scope} ${t}`:t}).join(`, `)}function hA(){let e=globalThis.performance,t=e?.measureUserAgentSpecificMemory;return t?t.bind(e):null}function gA(e){if(e[0]===`--help`||e[0]===`-h`||e[0]===`help`)return{help:!0};let t=!1;for(let n of e){if(n!==`--json`)return{error:`unknown option '${n}' — see \`meminfo --help\``};t=!0}return{help:!1,json:t}}function _A(e){let t=[`total: ${pA(e.bytes)}`],n=[...e.breakdown].filter(e=>e.bytes>0).sort((e,t)=>t.bytes-e.bytes);if(n.length>0){t.push(``,`BYTES TYPES ATTRIBUTION`);for(let e of n)t.push(`${pA(e.bytes).padEnd(10)} ${e.types.join(`,`).padEnd(20)} ${mA(e)}`)}return`${t.join(`
1681
+ `}async function cA(e,t){let n=await oA(t.fs);await n.mkdir(Ck,{recursive:!0}),await n.writeFile(`${Ck}/${e}.jsh`,sA(e)),t.scriptCatalog?.invalidateJsh()}async function lA(e,t){let n=await oA(t.fs),r=`${Ck}/${e}.jsh`;try{await n.exists(r)&&await n.rm(r)}catch(e){Sk.debug(`alias removal failed`,{path:r,error:e instanceof Error?e.message:String(e)})}t.scriptCatalog?.invalidateJsh()}async function uA(e,t){let{removeAppSprinkles:n}=await import(`./apps-Dn8bdiE-.js`);await n(e,t.fs)}async function dA(e,t,n){try{let{materializeAppSprinkles:r}=await import(`./apps-Dn8bdiE-.js`);return(await r(e,t,n.fs)).length}catch(t){return Sk.warn(`mcp: failed to materialize app sprinkles`,{name:e,error:t instanceof Error?t.message:String(t)}),0}}function fA(e){return{stdout:``,stderr:`meminfo: ${e}\n`,exitCode:1}}function pA(e){if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`],n=e,r=`B`;for(let e of t){if(n<1024)break;n/=1024,r=e}return`${n.toFixed(1)} ${r}`}function mA(e){return e.attribution.length===0?`(shared)`:e.attribution.map(e=>{let t=e.container?.src??e.container?.id??e.url??`?`;return e.scope?`${e.scope} ${t}`:t}).join(`, `)}function hA(){let e=globalThis.performance,t=e?.measureUserAgentSpecificMemory;return t?t.bind(e):null}function gA(e){if(e[0]===`--help`||e[0]===`-h`||e[0]===`help`)return{help:!0};let t=!1;for(let n of e){if(n!==`--json`)return{error:`unknown option '${n}' — see \`meminfo --help\``};t=!0}return{help:!1,json:t}}function _A(e){let t=[`total: ${pA(e.bytes)}`],n=[...e.breakdown].filter(e=>e.bytes>0).sort((e,t)=>t.bytes-e.bytes);if(n.length>0){t.push(``,`BYTES TYPES ATTRIBUTION`);for(let e of n)t.push(`${pA(e.bytes).padEnd(10)} ${e.types.join(`,`).padEnd(20)} ${mA(e)}`)}return`${t.join(`
1673
1682
  `)}\n`}function vA(e={}){return S(`meminfo`,async t=>{let n=gA(t);if(`error`in n)return fA(n.error);if(n.help)return{stdout:`meminfo - agent-cluster memory diagnostics
1674
1683
 
1675
1684
  Usage:
@@ -1681,7 +1690,7 @@ Notes:
1681
1690
  Document-Isolation-Policy). Embedded floats cannot be isolated and
1682
1691
  report why instead.
1683
1692
  - The browser randomizes measurement timing — expect a short delay.
1684
- `,stderr:``,exitCode:0};let r=e.isIsolated?e.isIsolated():globalThis.crossOriginIsolated===!0,i=e.measure??hA();if(!r&&!e.measure)return fA(`memory measurement requires a cross-origin-isolated runtime (Document-Isolation-Policy) — this runtime is not isolated`);if(!i)return fA(`performance.measureUserAgentSpecificMemory is not available in this browser`);let a;try{a=await i()}catch(e){return fA(e instanceof Error?e.message:String(e))}return n.json?{stdout:`${JSON.stringify(a,null,2)}\n`,stderr:``,exitCode:0}:{stdout:_A(a),stderr:``,exitCode:0}})}function yA(e){return S(`memory`,async t=>{let{runMemory:n}=await import(`./run-fHfrubKD.js`);return n(t,e)})}function bA(){return S(`mktemp`,async(e,t)=>{let{runMktemp:n}=await import(`./run-dAJe7sKp.js`);return n(e,t)})}const xA=`/.cache/artificial-analysis.json`,SA=[`--all`,`--all-versions`,`--json`,`--refresh`,`--no-benchmarks`,`--help`,`-h`],CA=[`--provider`];function wA(e){return{stdout:``,stderr:e.endsWith(`
1693
+ `,stderr:``,exitCode:0};let r=e.isIsolated?e.isIsolated():globalThis.crossOriginIsolated===!0,i=e.measure??hA();if(!r&&!e.measure)return fA(`memory measurement requires a cross-origin-isolated runtime (Document-Isolation-Policy) — this runtime is not isolated`);if(!i)return fA(`performance.measureUserAgentSpecificMemory is not available in this browser`);let a;try{a=await i()}catch(e){return fA(e instanceof Error?e.message:String(e))}return n.json?{stdout:`${JSON.stringify(a,null,2)}\n`,stderr:``,exitCode:0}:{stdout:_A(a),stderr:``,exitCode:0}})}function yA(e){return S(`memory`,async t=>{let{runMemory:n}=await import(`./run-MoNABXzI.js`);return n(t,e)})}function bA(){return S(`mktemp`,async(e,t)=>{let{runMktemp:n}=await import(`./run-dAJe7sKp.js`);return n(e,t)})}const xA=`/.cache/artificial-analysis.json`,SA=[`--all`,`--all-versions`,`--json`,`--refresh`,`--no-benchmarks`,`--help`,`-h`],CA=[`--provider`];function wA(e){return{stdout:``,stderr:e.endsWith(`
1685
1694
  `)?e:`${e}\n`,exitCode:1}}async function TA(e){try{let t=await e.readFile(xA),n=JSON.parse(t);if(Date.now()-n.fetchedAt<864e5)return n.models}catch{}return null}function EA(){try{return localStorage.getItem(`aa_api_key`)}catch{return null}}function DA(e){return e.map(e=>{let t=e;return{slug:t.slug??``,name:t.name??``,creator_slug:t.model_creator?.slug??``,intelligence_index:t.evaluations?.artificial_analysis_intelligence_index??null,coding_index:t.evaluations?.artificial_analysis_coding_index??null,speed_tps:t.median_output_tokens_per_second??null}})}async function OA(e,t){let n={fetchedAt:Date.now(),models:t};try{await e.mkdir(`/.cache`,{recursive:!0}),await e.writeFile(xA,JSON.stringify(n))}catch{}}async function kA(e,t=!1){if(e&&!t){let t=await TA(e);if(t)return t}let n={Accept:`application/json`},r=EA();r&&(n[`x-api-key`]=r);let i=p(),a;try{a=await i(`https://artificialanalysis.ai/api/v2/data/llms/models`,{method:`GET`,headers:n})}catch{return[]}if(a.status===401||a.status<200||a.status>=300)return[];let o;try{o=JSON.parse(new TextDecoder().decode(a.body))}catch{return[]}if(typeof o!=`object`||!o)return[];let s=o,c=DA(Array.isArray(s)?s:s.data??s.models??[]);return e&&c.length>0&&await OA(e,c),c}function AA(e){return e.toLowerCase().replace(/\./g,`-`).replace(/-\d{8}$/,``).replace(/-\d{4}$/,``)}function jA(e,t){let n=e.toLowerCase(),r=t.find(e=>e.slug===n);if(r)return r;let i=AA(e),a=t.find(e=>AA(e.slug)===i);if(a)return a;let o=t.filter(e=>n.includes(e.slug)||e.slug.includes(n));if(o.length!==0)return o.sort((e,t)=>t.slug.length-e.slug.length),o[0]}function MA(){return`models - list available LLM models
1686
1695
 
1687
1696
  Usage: models [options]
@@ -1696,7 +1705,7 @@ Options:
1696
1705
  -h, --help Show this help message
1697
1706
  `}function NA(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`.replace(`.0M`,`M`):e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function PA(e){return`$${e.toFixed(2)}`}const FA=/\b(embedding|embed|tts|whisper|dall-e|image-gen|audio|vision-preview)\b/i;function IA(e){let t=`${e.id} ${e.name??``}`;return!FA.test(t)}function LA(e){let t=e.match(/^(claude-(?:opus|sonnet|haiku))/);if(t)return t[1];let n=e.match(/^(gpt-\d+)(?:\.\d+)?(-[a-z][-a-z]*)?$/);if(n)return n[1]+(n[2]??``);let r=e.match(/^gemini-[\d.]+-(.+)$/);if(r)return`gemini-${r[1]}`;let i=e.match(/^gemini-(\d+)-(.+)$/);if(i)return`gemini-${i[2]}`;let a=e.match(/^grok-[\d.]+-([\w-]+)$/);if(a)return`grok-${a[1]}`;if(e.match(/^(grok)-[\d.]+$/))return`grok`;let o=e.match(/^(o\d+(?:-[a-z]+)?)(?:-\d.*)?$/);if(o)return o[1]}function RA(e){let t=e.toLowerCase();return t=t.replace(/-\d{8}$/,``),t=t.replace(/-\d{4}$/,``),t=t.replace(/-(preview|latest)$/,``),LA(t)??t.replace(/-[\d.]+$/,``)}function zA(e){let t=new Map;for(let n of e){let e=RA(n.id);(!t.has(e)||n.selected)&&t.set(e,n)}return[...t.values()]}function BA(e,t,n,r,i){let a=i?jA(e.id,i):void 0,o={id:e.id,name:e.name,provider:t,cost:e.cost??{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:e.contextWindow??0,maxTokens:e.maxTokens??0,reasoning:!!e.reasoning,input:e.input??[`text`],selected:e.id===n&&t===r};return a?.intelligence_index!=null&&(o.intelligence=a.intelligence_index),a?.coding_index!=null&&(o.codingScore=a.coding_index),a?.speed_tps!=null&&(o.speed=a.speed_tps),o}function VA(e,t,n,r){let i=[];i.push(`Models for "${e}" (${t}):\n`);for(let e of n){let t=e.selected?` ► `:` `,n=e.id.padEnd(30),r=`${PA(e.cost.input)} / ${PA(e.cost.output)}`,a=`${NA(e.contextWindow)} ctx`,o=e.intelligence==null?``:`IQ:${e.intelligence}`,s=e.speed==null?``:`${Math.round(e.speed)} t/s`,c=e.reasoning?`reasoning`:``,l=o||s?`${o.padEnd(6)} ${s.padEnd(8)}`:``;i.push(`${t}${n} ${r.padEnd(16)} ${a.padEnd(10)} ${l} ${c}`)}return i.push(`\n ${n.length} model${n.length===1?``:`s`} available.`),r&&i.push(` Intelligence data: artificialanalysis.ai`),i.join(`
1698
1707
  `)+`
1699
- `}function HA(e){let t=C(e,{bool:SA,value:CA});return`error`in t?t:{jsonMode:t.bools.has(`--json`),allMode:t.bools.has(`--all`),allVersions:t.bools.has(`--all-versions`),forceRefresh:t.bools.has(`--refresh`),noBenchmarks:t.bools.has(`--no-benchmarks`),explicitProvider:t.values.get(`--provider`)}}function UA(e,t,n){if(t.explicitProvider){let n=e.getAvailableProviders();return n.includes(t.explicitProvider)?[t.explicitProvider]:{error:`Unknown provider: ${t.explicitProvider}. Available: ${n.join(`, `)}\n`}}return t.allMode?[...new Set(e.getAccounts().map(e=>e.providerId))]:[n]}function WA(e,t,n,r,i,a){let o=e.getProviderModels(t).filter(IA);if(o.length===0)return[];let s=o.map(e=>BA(e,t,n,r,i)).sort((e,t)=>t.cost.input-e.cost.input);return a||(s=zA(s)),s}function GA(e,t,n,r){let i=`${e}:${t}`,a=`${n}:${r}`;return i===a?`Currently using: ${i}\n`:`Currently using: ${i} (selected ${a} — resolved to a different model)\n`}async function KA(e,t){if(w(e,{valueFlags:CA}))return{stdout:MA(),stderr:``,exitCode:0};let n=HA(e);if(`error`in n)return wA(`models: ${n.error}`);let r=await import(`./account-store-irTFXEHq.js`).then(e=>e.t);if(r.getAccounts().length===0)return wA(`No provider accounts configured. Run the provider settings to add one.
1708
+ `}function HA(e){let t=C(e,{bool:SA,value:CA});return`error`in t?t:{jsonMode:t.bools.has(`--json`),allMode:t.bools.has(`--all`),allVersions:t.bools.has(`--all-versions`),forceRefresh:t.bools.has(`--refresh`),noBenchmarks:t.bools.has(`--no-benchmarks`),explicitProvider:t.values.get(`--provider`)}}function UA(e,t,n){if(t.explicitProvider){let n=e.getAvailableProviders();return n.includes(t.explicitProvider)?[t.explicitProvider]:{error:`Unknown provider: ${t.explicitProvider}. Available: ${n.join(`, `)}\n`}}return t.allMode?[...new Set(e.getAccounts().map(e=>e.providerId))]:[n]}function WA(e,t,n,r,i,a){let o=e.getProviderModels(t).filter(IA);if(o.length===0)return[];let s=o.map(e=>BA(e,t,n,r,i)).sort((e,t)=>t.cost.input-e.cost.input);return a||(s=zA(s)),s}function GA(e,t,n,r){let i=`${e}:${t}`,a=`${n}:${r}`;return i===a?`Currently using: ${i}\n`:`Currently using: ${i} (selected ${a} — resolved to a different model)\n`}async function KA(e,t){if(w(e,{valueFlags:CA}))return{stdout:MA(),stderr:``,exitCode:0};let n=HA(e);if(`error`in n)return wA(`models: ${n.error}`);let r=await import(`./account-store-BXYHDz7I.js`).then(e=>e.t);if(r.getAccounts().length===0)return wA(`No provider accounts configured. Run the provider settings to add one.
1700
1709
  `);let i=r.resolveCurrentModel(),a=i.id,o=i.provider,s=r.getSelectedProvider(),c=r.getSelectedModelId(),l;if(!n.noBenchmarks){let e=await kA(t,n.forceRefresh);e.length>0&&(l=e)}let u=UA(r,n,s);if(`error`in u)return wA(u.error);let d=[],f=[];for(let e of u){let t=WA(r,e,a,o,l,n.allVersions);if(t.length===0){if(!n.allMode)return wA(`No models available for provider ${e}.\n`);continue}if(d.push(...t),!n.jsonMode){let n=r.getProviderConfig(e);f.push(VA(n.name,e,t,!!l))}}return n.jsonMode?{stdout:JSON.stringify(d,null,2)+`
1701
1710
  `,stderr:``,exitCode:0}:(n.allVersions||f.push(`Showing latest versions only. Use --all-versions to see all.
1702
1711
  `),f.push(GA(o,a,s,c)),{stdout:f.join(`
@@ -1754,7 +1763,7 @@ Examples:
1754
1763
  `)}\n`,stderr:``,exitCode:0}}async function _j(e,t,n){if(!t||!n)return{stdout:``,stderr:`oauth-domain add: requires <providerId> and <domain>
1755
1764
  `,exitCode:1};let r=e.getExtraOAuthDomains(t),i=n.toLowerCase();return r.some(e=>e.toLowerCase()===i)?{stdout:`(${n} already in ${t} extras)\n`,stderr:``,exitCode:0}:(await e.setExtraOAuthDomainsAsync(t,[...r,n]),{stdout:`Added ${n} to ${t}. Reload the page to apply.\n`,stderr:``,exitCode:0})}async function vj(e,t,n){if(!t||!n)return{stdout:``,stderr:`oauth-domain remove: requires <providerId> and <domain>
1756
1765
  `,exitCode:1};let r=e.getExtraOAuthDomains(t),i=n.toLowerCase(),a=r.filter(e=>e.toLowerCase()!==i);return a.length===r.length?{stdout:`(${n} not found in ${t} extras)\n`,stderr:``,exitCode:0}:(await e.setExtraOAuthDomainsAsync(t,a),{stdout:`Removed ${n} from ${t}. Reload the page to apply.\n`,stderr:``,exitCode:0})}async function yj(e,t){return t?(await e.setExtraOAuthDomainsAsync(t,[]),{stdout:`Cleared extra domains for ${t}. Reload the page to apply.\n`,stderr:``,exitCode:0}):{stdout:``,stderr:`oauth-domain clear: requires <providerId>
1757
- `,exitCode:1}}async function bj(e,t,n,r){switch(t){case`list`:return gj(e,n);case`add`:return _j(e,n,r);case`remove`:return vj(e,n,r);case`clear`:return yj(e,n);default:return{stdout:``,stderr:`oauth-domain: unknown subcommand "${t}"\n${mj()}`,exitCode:1}}}function xj(){return S(`oauth-domain`,async e=>{if(e.length===0||w(e))return{stdout:mj(),stderr:``,exitCode:0};let t=C(e);if(`error`in t)return hj(t.error);let[n,r,i]=t.positionals,a=await import(`./account-store-irTFXEHq.js`).then(e=>e.t);try{return await bj(a,n,r,i)}catch(e){return hj(e instanceof Error?e.message:String(e))}})}function Sj(){return S(`oauth-token`,async(e,t)=>{let{runOAuthToken:n}=await import(`./run-CkKb9UWF.js`);return n(e,t)})}const Cj=[`--download`,`-d`,`--view`,`-v`],wj=[`--size`],Tj={low:256,medium:768,high:1536};function Ej(){return{stdout:`usage: open [--download|-d] [--view|-v [--size <spec>]] <url|path> [url|path...]
1766
+ `,exitCode:1}}async function bj(e,t,n,r){switch(t){case`list`:return gj(e,n);case`add`:return _j(e,n,r);case`remove`:return vj(e,n,r);case`clear`:return yj(e,n);default:return{stdout:``,stderr:`oauth-domain: unknown subcommand "${t}"\n${mj()}`,exitCode:1}}}function xj(){return S(`oauth-domain`,async e=>{if(e.length===0||w(e))return{stdout:mj(),stderr:``,exitCode:0};let t=C(e);if(`error`in t)return hj(t.error);let[n,r,i]=t.positionals,a=await import(`./account-store-BXYHDz7I.js`).then(e=>e.t);try{return await bj(a,n,r,i)}catch(e){return hj(e instanceof Error?e.message:String(e))}})}function Sj(){return S(`oauth-token`,async(e,t)=>{let{runOAuthToken:n}=await import(`./run-AUgWiGZj.js`);return n(e,t)})}const Cj=[`--download`,`-d`,`--view`,`-v`],wj=[`--size`],Tj={low:256,medium:768,high:1536};function Ej(){return{stdout:`usage: open [--download|-d] [--view|-v [--size <spec>]] <url|path> [url|path...]
1758
1767
 
1759
1768
  VFS paths are served in a new browser tab via the preview service worker.
1760
1769
  URLs (http/https/etc.) are opened directly in a new tab.
@@ -1780,7 +1789,7 @@ Examples:
1780
1789
  `);let i=!1;try{i=(await t.fs.stat(e)).isDirectory}catch{}let a=await Zn(t.fs,i?e:or(e)),o=Or(e,a),s;try{s=await r(o)}catch(e){return G(`${e instanceof Error?e.message:String(e)}\n`)}return Fj(`opened ${e} → ${o}${Ij(s)}`)}async function Uj(e,t,n,r){if(!$n(e)&&e.endsWith(`.shtml`)&&t.fs)return Rj(e,t,r.sprinkleManager,r.canOpenWindow,r.openExternal);if(!n.view&&!r.canOpenWindow)return G(`open: browser APIs are unavailable in this environment
1781
1790
  `);if($n(e))return zj(e,r.canOpenWindow,r.openExternal);let i=t.fs.resolvePath(t.cwd,e);return n.view?Bj(e,i,t,n.sizeSpec):n.download?Vj(e,i,t,r.hasDom):Hj(i,t,r.canOpenWindow,r.openExternal)}function Wj(e){return S(`open`,async(t,n)=>{if(t.length===0||w(t,{valueFlags:wj}))return Ej();let r=Pj(t);if(`error`in r)return{stdout:``,stderr:`${r.error}\n`,exitCode:1};let{download:i,view:a,sizeSpec:o,targets:s}=r;if(s.length===0)return Ej();let c=globalThis.__slicc_sprinkleManager,l=typeof window<`u`&&typeof document<`u`,u=l?null:y(),d={canOpenWindow:!!e||l||!!u,hasDom:l,sprinkleManager:c,openExternal:Lj(e,l,u)},f=[];for(let e of s){let t=await Uj(e,n,{view:a,download:i,sizeSpec:o},d);if(!t.ok)return t.result;f.push(t.message)}return{stdout:f.join(`
1782
1791
  `)+`
1783
- `,stderr:``,exitCode:0}})}function Gj(){return S(`patch`,async(e,t)=>{let{runPatch:n}=await import(`./run-xrVX3llR.js`);return n(e,t)})}function Kj(e=`pdftk`){return S(e,async(t,n)=>{let{runPdftk:r}=await import(`./run-BEs473Sp.js`);return r(e,t,n)})}function qj(){return{stdout:`usage: pdftoppm [options] <input.pdf> [output-prefix]
1792
+ `,stderr:``,exitCode:0}})}function Gj(){return S(`patch`,async(e,t)=>{let{runPatch:n}=await import(`./run-BxNz22KR.js`);return n(e,t)})}function Kj(e=`pdftk`){return S(e,async(t,n)=>{let{runPdftk:r}=await import(`./run-BEs473Sp.js`);return r(e,t,n)})}function qj(){return{stdout:`usage: pdftoppm [options] <input.pdf> [output-prefix]
1784
1793
 
1785
1794
  Rasterize PDF pages to images. Writes <prefix>-<n>.<ext> per page, where <n>
1786
1795
  is zero-padded to the digit width of the last page (out-1.png for a 9-page
@@ -1840,7 +1849,7 @@ Examples:
1840
1849
  plugin list
1841
1850
  plugin info my-plugin
1842
1851
  plugin remove my-plugin
1843
- `}function uM(e={}){return S(`plugin`,async(t,n)=>{if(t.length===0||t[0]===`--help`||t[0]===`-h`)return sM(lM());let r=t[0],i=t.slice(1),a=n?.cwd??`/`;try{switch(r){case`install`:case`add`:return await _M(i,a,e);case`list`:case`ls`:return await xM(i,e);case`info`:return await SM(i,e);case`validate`:return await CM(i,a,e,Bi(n?.env));case`remove`:case`rm`:case`delete`:return await wM(i,e);default:return K(`plugin: unknown subcommand "${r}" (try \`plugin --help\`)`)}}catch(e){return K(`plugin ${r}: ${e instanceof Error?e.message:String(e)}`)}})}async function dM(e){if(e.fs)return e.fs;let{VirtualFS:t}=await import(`./fs-D5UZBrBX.js`).then(e=>e.t),{GLOBAL_FS_DB_NAME:n}=await import(`./global-db-DJXlpNui.js`).then(e=>e.n);return t.create({dbName:n})}async function fM(e,t,n){let r=TM(t,e);if(await n.exists(r))return{kind:`local`,root:r};let{parseGitHubRef:i}=await import(`./github-install-B-rr32FO.js`).then(e=>e.t),a=i(e);if(a){let e=`${a.owner}/${a.repo}${a.branch?`@${a.branch}`:``}${a.path?`/${a.path}`:``}`;return{kind:`github`,ref:{...a,display:e}}}return{kind:`error`,message:`${r} does not exist and "${e}" is not a GitHub reference (owner/repo[@branch] or https://github.com/owner/repo[/tree/branch[/dir]])`}}function pM(e){let t=e.replace(/[^A-Za-z0-9._-]+/g,`-`);return/^\.+$/.test(t)?t.replace(/\./g,`_`):t}function mM(e){let t=[e.owner,e.repo,...e.path?[e.path]:[]];return`${oM}/${t.map(pM).join(`--`)}`}async function hM(e,t,n,r){let{fetchRepoZip:i,stripZipPrefix:a,writeZipFilesToDir:o}=await import(`./github-zip-DA_-VtNu.js`).then(e=>e.i),s=await i(e.owner,e.repo,r,e.branch);if(s.status===`error`)return`failed to download ${e.display}: ${s.message}`;let c=a(s.files),l=e.path?e.path.replace(/^\/|\/$/g,``)+`/`:``;if(!c[`${l}plugin.json`])return`no plugin.json found at ${e.display} — not an Agent Plugins package`;try{await n.rm(t,{recursive:!0})}catch{}return await n.mkdir(t,{recursive:!0}),(await o(c,l,t,n,!1)).length===0?`no files found at ${e.display}`:null}async function gM(e,t){try{await e.rm(t,{recursive:!0})}catch{}}async function _M(e,t,n){if(w(e))return sM(`usage: plugin install <path|repo>
1852
+ `}function uM(e={}){return S(`plugin`,async(t,n)=>{if(t.length===0||t[0]===`--help`||t[0]===`-h`)return sM(lM());let r=t[0],i=t.slice(1),a=n?.cwd??`/`;try{switch(r){case`install`:case`add`:return await _M(i,a,e);case`list`:case`ls`:return await xM(i,e);case`info`:return await SM(i,e);case`validate`:return await CM(i,a,e,Bi(n?.env));case`remove`:case`rm`:case`delete`:return await wM(i,e);default:return K(`plugin: unknown subcommand "${r}" (try \`plugin --help\`)`)}}catch(e){return K(`plugin ${r}: ${e instanceof Error?e.message:String(e)}`)}})}async function dM(e){if(e.fs)return e.fs;let{VirtualFS:t}=await import(`./fs-DL0b9F_-.js`).then(e=>e.t),{GLOBAL_FS_DB_NAME:n}=await import(`./global-db-DJXlpNui.js`).then(e=>e.n);return t.create({dbName:n})}async function fM(e,t,n){let r=TM(t,e);if(await n.exists(r))return{kind:`local`,root:r};let{parseGitHubRef:i}=await import(`./github-install-DhvV5fCp.js`).then(e=>e.t),a=i(e);if(a){let e=`${a.owner}/${a.repo}${a.branch?`@${a.branch}`:``}${a.path?`/${a.path}`:``}`;return{kind:`github`,ref:{...a,display:e}}}return{kind:`error`,message:`${r} does not exist and "${e}" is not a GitHub reference (owner/repo[@branch] or https://github.com/owner/repo[/tree/branch[/dir]])`}}function pM(e){let t=e.replace(/[^A-Za-z0-9._-]+/g,`-`);return/^\.+$/.test(t)?t.replace(/\./g,`_`):t}function mM(e){let t=[e.owner,e.repo,...e.path?[e.path]:[]];return`${oM}/${t.map(pM).join(`--`)}`}async function hM(e,t,n,r){let{fetchRepoZip:i,stripZipPrefix:a,writeZipFilesToDir:o}=await import(`./github-zip-x1UTu8IO.js`).then(e=>e.i),s=await i(e.owner,e.repo,r,e.branch);if(s.status===`error`)return`failed to download ${e.display}: ${s.message}`;let c=a(s.files),l=e.path?e.path.replace(/^\/|\/$/g,``)+`/`:``;if(!c[`${l}plugin.json`])return`no plugin.json found at ${e.display} — not an Agent Plugins package`;try{await n.rm(t,{recursive:!0})}catch{}return await n.mkdir(t,{recursive:!0}),(await o(c,l,t,n,!1)).length===0?`no files found at ${e.display}`:null}async function gM(e,t){try{await e.rm(t,{recursive:!0})}catch{}}async function _M(e,t,n){if(w(e))return sM(`usage: plugin install <path|repo>
1844
1853
 
1845
1854
  Loads the Agent Plugins package at <path>, or downloads it from a GitHub
1846
1855
  reference (owner/repo, owner/repo@branch, or
@@ -1851,19 +1860,19 @@ mcp.json. On success the plugin is recorded in
1851
1860
  /workspace/.plugins/plugins.json — its skills then surface through the
1852
1861
  standard skills discovery, and each supported streamable-http MCP server
1853
1862
  is registered in the MCP store as "<plugin>:<server>".
1854
- `);let r=cM(`install`,e);if(!(`ok`in r))return r;if(r.positionals.length<1)return K(`plugin install: expected <path|repo>`);let i=await dM(n),a=await fM(r.positionals[0],t,i);if(a.kind===`error`)return K(`plugin install: ${a.message}`);let o,s;if(a.kind===`github`){if(!n.fetch)return K(`plugin install: GitHub installs are unavailable (no network fetch configured)`);o=mM(a.ref),s=a.ref.display;let e=await hM(a.ref,o,i,n.fetch);if(e)return K(`plugin install: ${e}`)}else o=a.root;let{loadPluginFromDirectory:c}=await import(`./loader-Dw-TPPKt.js`),l=await c(i,o);if(!l.ok)return a.kind===`github`&&await gM(i,o),K(`plugin install: plugin at ${s??o} was rejected:\n${EM(l.diagnostics)}`);let{plugin:u}=l,d=u.manifest.name,{getInstalledPlugin:f,setInstalledPlugin:p}=await import(`./store-BvFCmAq8.js`),m=await f(d,n.fs);if(m&&m.root!==o)return a.kind===`github`&&await gM(i,o),K(`plugin install: a plugin named "${d}" is already installed from ${m.root} (remove it first)`);let h=await bM(u,n),g=await yM(d,m?.mcpServerNames,h.registered,n);return await p(d,{root:o,version:u.manifest.version,description:u.manifest.description,installedAt:new Date().toISOString(),mcpServerNames:h.registered,...s?{source:s}:{}},n.fs),sM(vM(u,h,g,s??o,l.diagnostics))}function vM(e,t,n,r,i){let a=e.manifest.name,o=t.registered,s=e.mcp.servers.filter(e=>e.status!==`supported`),c=[`Installed agent plugin "${a}"${e.manifest.version?` v${e.manifest.version}`:``} from ${r}`,` skills: ${e.skills.length}${e.skills.length>0?` (${e.skills.map(e=>e.name).join(`, `)})`:``}`,` mcp: ${o.length} registered${o.length>0?` (${o.join(`, `)})`:``}${s.length>0?`, ${s.length} skipped`:``}${n>0?`, ${n} removed from previous install`:``}`];return t.conflicts.length>0&&c.push(` warning: not bridged — MCP server name(s) already in use and not owned by this plugin: ${t.conflicts.join(`, `)} (remove them with \`mcp remove\` first)`),i.length>0&&c.push(`Diagnostics:`,EM(i)),c.join(`
1863
+ `);let r=cM(`install`,e);if(!(`ok`in r))return r;if(r.positionals.length<1)return K(`plugin install: expected <path|repo>`);let i=await dM(n),a=await fM(r.positionals[0],t,i);if(a.kind===`error`)return K(`plugin install: ${a.message}`);let o,s;if(a.kind===`github`){if(!n.fetch)return K(`plugin install: GitHub installs are unavailable (no network fetch configured)`);o=mM(a.ref),s=a.ref.display;let e=await hM(a.ref,o,i,n.fetch);if(e)return K(`plugin install: ${e}`)}else o=a.root;let{loadPluginFromDirectory:c}=await import(`./loader-Dw-TPPKt.js`),l=await c(i,o);if(!l.ok)return a.kind===`github`&&await gM(i,o),K(`plugin install: plugin at ${s??o} was rejected:\n${EM(l.diagnostics)}`);let{plugin:u}=l,d=u.manifest.name,{getInstalledPlugin:f,setInstalledPlugin:p}=await import(`./store-D6WHUpLa.js`),m=await f(d,n.fs);if(m&&m.root!==o)return a.kind===`github`&&await gM(i,o),K(`plugin install: a plugin named "${d}" is already installed from ${m.root} (remove it first)`);let h=await bM(u,n),g=await yM(d,m?.mcpServerNames,h.registered,n);return await p(d,{root:o,version:u.manifest.version,description:u.manifest.description,installedAt:new Date().toISOString(),mcpServerNames:h.registered,...s?{source:s}:{}},n.fs),sM(vM(u,h,g,s??o,l.diagnostics))}function vM(e,t,n,r,i){let a=e.manifest.name,o=t.registered,s=e.mcp.servers.filter(e=>e.status!==`supported`),c=[`Installed agent plugin "${a}"${e.manifest.version?` v${e.manifest.version}`:``} from ${r}`,` skills: ${e.skills.length}${e.skills.length>0?` (${e.skills.map(e=>e.name).join(`, `)})`:``}`,` mcp: ${o.length} registered${o.length>0?` (${o.join(`, `)})`:``}${s.length>0?`, ${s.length} skipped`:``}${n>0?`, ${n} removed from previous install`:``}`];return t.conflicts.length>0&&c.push(` warning: not bridged — MCP server name(s) already in use and not owned by this plugin: ${t.conflicts.join(`, `)} (remove them with \`mcp remove\` first)`),i.length>0&&c.push(`Diagnostics:`,EM(i)),c.join(`
1855
1864
  `)+`
1856
- `}async function yM(e,t,n,r){let i=(t??[]).filter(e=>!n.includes(e));if(i.length===0)return 0;let{deleteServer:a,getServer:o}=await import(`./store-BikzV66S.js`).then(e=>e.r),s=0;for(let t of i)(await o(t,r.fs))?.pluginOrigin===e&&await a(t,r.fs)&&(s+=1);return s}async function bM(e,t){let n=e.mcp.servers.filter(e=>e.status===`supported`);if(n.length===0)return{registered:[],conflicts:[]};let{getServer:r,setServer:i}=await import(`./store-BikzV66S.js`).then(e=>e.r),{McpClient:a}=await import(`./client-CwxmlQM-.js`).then(e=>e.n),o=[],s=[];for(let c of n){let n=c.config,l=`${e.manifest.name}:${c.name}`,u=await r(l,t.fs);if(u&&u.pluginOrigin!==e.manifest.name){s.push(l);continue}let d=[];try{let e=new a({url:n.url,headers:n.headers});await e.initialize(),d=await e.toolsList()}catch{}await i(l,{url:n.url,...n.headers?{headers:n.headers}:{},tools:d,addedAt:new Date().toISOString(),pluginOrigin:e.manifest.name},t.fs),o.push(l)}return{registered:o,conflicts:s}}async function xM(e,t){if(w(e))return sM(`usage: plugin list
1857
- `);let n=cM(`list`,e);if(!(`ok`in n))return n;let{listInstalledPlugins:r}=await import(`./store-BvFCmAq8.js`),i=await r(t.fs),a=Object.keys(i).sort();if(a.length===0)return sM("No agent plugins installed. Use `plugin install <path>`.\n");let o=[[`NAME`,`VERSION`,`ROOT`,`MCP`]];for(let e of a){let t=i[e];o.push([e,t.version??`-`,t.root,String(t.mcpServerNames?.length??0)])}let s=o[0].map((e,t)=>Math.max(...o.map(e=>e[t].length)));return sM(o.map(e=>e.map((e,t)=>e.padEnd(s[t])).join(` `)).join(`
1865
+ `}async function yM(e,t,n,r){let i=(t??[]).filter(e=>!n.includes(e));if(i.length===0)return 0;let{deleteServer:a,getServer:o}=await import(`./store-Cm5EQ4O4.js`).then(e=>e.r),s=0;for(let t of i)(await o(t,r.fs))?.pluginOrigin===e&&await a(t,r.fs)&&(s+=1);return s}async function bM(e,t){let n=e.mcp.servers.filter(e=>e.status===`supported`);if(n.length===0)return{registered:[],conflicts:[]};let{getServer:r,setServer:i}=await import(`./store-Cm5EQ4O4.js`).then(e=>e.r),{McpClient:a}=await import(`./client-CwxmlQM-.js`).then(e=>e.n),o=[],s=[];for(let c of n){let n=c.config,l=`${e.manifest.name}:${c.name}`,u=await r(l,t.fs);if(u&&u.pluginOrigin!==e.manifest.name){s.push(l);continue}let d=[];try{let e=new a({url:n.url,headers:n.headers});await e.initialize(),d=await e.toolsList()}catch{}await i(l,{url:n.url,...n.headers?{headers:n.headers}:{},tools:d,addedAt:new Date().toISOString(),pluginOrigin:e.manifest.name},t.fs),o.push(l)}return{registered:o,conflicts:s}}async function xM(e,t){if(w(e))return sM(`usage: plugin list
1866
+ `);let n=cM(`list`,e);if(!(`ok`in n))return n;let{listInstalledPlugins:r}=await import(`./store-D6WHUpLa.js`),i=await r(t.fs),a=Object.keys(i).sort();if(a.length===0)return sM("No agent plugins installed. Use `plugin install <path>`.\n");let o=[[`NAME`,`VERSION`,`ROOT`,`MCP`]];for(let e of a){let t=i[e];o.push([e,t.version??`-`,t.root,String(t.mcpServerNames?.length??0)])}let s=o[0].map((e,t)=>Math.max(...o.map(e=>e[t].length)));return sM(o.map(e=>e.map((e,t)=>e.padEnd(s[t])).join(` `)).join(`
1858
1867
  `)+`
1859
1868
  `)}async function SM(e,t){if(w(e))return sM(`usage: plugin info <name>
1860
- `);let n=cM(`info`,e);if(!(`ok`in n))return n;if(n.positionals.length<1)return K(`plugin info: expected <name>`);let r=n.positionals[0],{getInstalledPlugin:i}=await import(`./store-BvFCmAq8.js`),a=await i(r,t.fs);if(!a)return K(`plugin info: no installed plugin named "${r}"`);let o=await dM(t),{loadPluginFromDirectory:s}=await import(`./loader-Dw-TPPKt.js`),c=await s(o,a.root);if(!c.ok)return K(`plugin info: plugin at ${a.root} no longer loads:\n${EM(c.diagnostics)}`);let{plugin:l}=c,u=l.manifest,d=[`${u.name}${u.version?` v${u.version}`:``}`,...u.description?[` ${u.description}`]:[],` root: ${l.root}`,...u.license?[` license: ${u.license}`]:[],...u.homepage?[` home: ${u.homepage}`]:[],``,`Skills (${l.skills.length}):`,...l.skills.map(e=>` ${e.name} ${e.description}`),``,`MCP servers (${l.mcp.servers.length}):`,...l.mcp.servers.map(e=>e.status===`supported`?` ${e.name} ${e.config.type} ${e.config.url}`:` ${e.name} [skipped: ${e.reason}]`)];return c.diagnostics.length>0&&d.push(``,`Diagnostics:`,EM(c.diagnostics)),sM(d.join(`
1869
+ `);let n=cM(`info`,e);if(!(`ok`in n))return n;if(n.positionals.length<1)return K(`plugin info: expected <name>`);let r=n.positionals[0],{getInstalledPlugin:i}=await import(`./store-D6WHUpLa.js`),a=await i(r,t.fs);if(!a)return K(`plugin info: no installed plugin named "${r}"`);let o=await dM(t),{loadPluginFromDirectory:s}=await import(`./loader-Dw-TPPKt.js`),c=await s(o,a.root);if(!c.ok)return K(`plugin info: plugin at ${a.root} no longer loads:\n${EM(c.diagnostics)}`);let{plugin:l}=c,u=l.manifest,d=[`${u.name}${u.version?` v${u.version}`:``}`,...u.description?[` ${u.description}`]:[],` root: ${l.root}`,...u.license?[` license: ${u.license}`]:[],...u.homepage?[` home: ${u.homepage}`]:[],``,`Skills (${l.skills.length}):`,...l.skills.map(e=>` ${e.name} ${e.description}`),``,`MCP servers (${l.mcp.servers.length}):`,...l.mcp.servers.map(e=>e.status===`supported`?` ${e.name} ${e.config.type} ${e.config.url}`:` ${e.name} [skipped: ${e.reason}]`)];return c.diagnostics.length>0&&d.push(``,`Diagnostics:`,EM(c.diagnostics)),sM(d.join(`
1861
1870
  `)+`
1862
1871
  `)}async function CM(e,t,n,r){if(w(e))return sM(`usage: plugin validate <path|repo>
1863
1872
  `);let i=cM(`validate`,e);if(!(`ok`in i))return i;if(i.positionals.length<1)return K(`plugin validate: expected <path|repo>`);let a=await dM(n),o=await fM(i.positionals[0],t,a);if(o.kind===`error`)return K(`plugin validate: ${o.message}`);let s,c=null;if(o.kind===`github`){if(!n.fetch)return K(`plugin validate: GitHub sources are unavailable (no network fetch configured)`);c=`${r}/.plugin-validate/${mM(o.ref).split(`/`).pop()}`;let e=await hM(o.ref,c,a,n.fetch);if(e)return K(`plugin validate: ${e}`);s=c}else s=o.root;let{loadPluginFromDirectory:l}=await import(`./loader-Dw-TPPKt.js`),u;try{u=await l(a,s)}finally{c&&await gM(a,c)}if(!u.ok)return{stdout:``,stderr:`plugin validate: REJECTED\n${EM(u.diagnostics)}\n`,exitCode:1};let{plugin:d}=u,f=d.mcp.servers.filter(e=>e.status===`supported`).length,p=[`plugin validate: OK — "${d.manifest.name}"${d.manifest.version?` v${d.manifest.version}`:``}`,` skills: ${d.skills.length}`,` mcp servers: ${f} supported, ${d.mcp.servers.length-f} skipped (mcp.json ${d.mcp.status})`];return u.diagnostics.length>0&&p.push(`Diagnostics:`,EM(u.diagnostics)),sM(p.join(`
1864
1873
  `)+`
1865
1874
  `)}async function wM(e,t){if(w(e))return sM(`usage: plugin remove <name>
1866
- `);let n=cM(`remove`,e);if(!(`ok`in n))return n;if(n.positionals.length<1)return K(`plugin remove: expected <name>`);let r=n.positionals[0],{getInstalledPlugin:i,deleteInstalledPlugin:a}=await import(`./store-BvFCmAq8.js`),o=await i(r,t.fs);if(!o)return K(`plugin remove: no installed plugin named "${r}"`);let s=0;if(o.mcpServerNames&&o.mcpServerNames.length>0){let{deleteServer:e,getServer:n}=await import(`./store-BikzV66S.js`).then(e=>e.r);for(let i of o.mcpServerNames)(await n(i,t.fs))?.pluginOrigin===r&&await e(i,t.fs)&&(s+=1)}await a(r,t.fs);let c=o.root.startsWith(`${oM}/`);return c&&await gM(await dM(t),o.root),sM([`Removed agent plugin "${r}"`,` registry: removed`,` mcp servers: ${s} removed`,c?` files: removed (${o.root})`:` files: left in place (${o.root})`].join(`
1875
+ `);let n=cM(`remove`,e);if(!(`ok`in n))return n;if(n.positionals.length<1)return K(`plugin remove: expected <name>`);let r=n.positionals[0],{getInstalledPlugin:i,deleteInstalledPlugin:a}=await import(`./store-D6WHUpLa.js`),o=await i(r,t.fs);if(!o)return K(`plugin remove: no installed plugin named "${r}"`);let s=0;if(o.mcpServerNames&&o.mcpServerNames.length>0){let{deleteServer:e,getServer:n}=await import(`./store-Cm5EQ4O4.js`).then(e=>e.r);for(let i of o.mcpServerNames)(await n(i,t.fs))?.pluginOrigin===r&&await e(i,t.fs)&&(s+=1)}await a(r,t.fs);let c=o.root.startsWith(`${oM}/`);return c&&await gM(await dM(t),o.root),sM([`Removed agent plugin "${r}"`,` registry: removed`,` mcp servers: ${s} removed`,c?` files: removed (${o.root})`:` files: left in place (${o.root})`].join(`
1867
1876
  `)+`
1868
1877
  `)}function TM(e,t){let n=t.startsWith(`/`)?t:`${e.replace(/\/$/,``)}/${t}`,r=[];for(let e of n.split(`/`))e!==``&&e!==`.`&&(e===`..`?r.pop():r.push(e));return`/${r.join(`/`)}`}function EM(e){return e.map(e=>` ${e.level===`error`?`error`:`warn `} [${e.component}] ${e.message}`).join(`
1869
1878
  `)}const DM=[`pid`,`ppid`,`kind`,`stat`,`start`,`scoop`,`command`],OM=[`pid`,`ppid`,`stat`,`start`,`scoop`,`command`],kM={running:`R`,pending:`S`,exited:`Z`,killed:`K`},AM=[`-a`,`-A`,`-e`,`--all`,`-T`,`--tree`],jM=[`-o`,`--columns`];function MM(e={}){return S(`ps`,async t=>{if(w(t,{valueFlags:jM}))return KM();let n=e.processManager??NM();if(!n)return{stdout:``,stderr:`ps: no process manager available in this runtime
@@ -2070,7 +2079,7 @@ Limits and lifetime:
2070
2079
  `,exitCode:1};if(e.ttlMs!==void 0&&e.maxTabs!==void 0)return{stdout:``,stderr:`serve: --ttl cannot be combined with --max-tabs
2071
2080
  `,exitCode:1}}async function iF(e,t,n){if(e.ttlMs!==void 0){if(!t)throw Error(`persistent snapshot filesystem unavailable`);return XP(t,n)}}async function aF(e,t,n,r){if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return PP();let i=BP(e);if(i.error)return{stdout:``,stderr:i.error,exitCode:1};let a=await nF(i);if(a)return a;if(!i.directory)return PP();let o=rF(i);if(o)return o;let s=await VP(i.directory,i.entry,t.fs,t.cwd);if(HP(s))return s;let{fullDirectory:c,entryPath:l}=s,u;try{u=await iF(i,r,c)}catch(e){return{stdout:``,stderr:`serve: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}let d=i.project?`serve: --project is obsolete; ignored (root-absolute paths work natively under unified preview)
2072
2081
  `:``,f=await eF(!i.noBridge&&i.bridge,d);return f.ok?tF(i,c,l,f.webhookId,d,u,n):f.result}function oF(e,t){return S(`serve`,(n,r)=>aF(n,r,e,t))}const sF=`usage: session export [--id <id>] [--output <path>]
2073
- `;function cF(e){if(e.includes(`\0`))return{ok:!1,reason:`path must not contain NUL bytes`};if(e.includes(`\\`))return{ok:!1,reason:`path must not contain backslashes`};let t=e.split(`/`);for(let e of t)if(e===`..`)return{ok:!1,reason:`path must not contain ".."/traversal segments`};return{ok:!0}}function lF(e){let t=null,n=null,r=e.slice(1);for(let e=0;e<r.length;e++){let i=r[e];if(i===`--id`){if(t!==null)return{ok:!1,stderr:`session export: duplicate flag --id\n${sF}`};let n=r[e+1];if(!n||n.startsWith(`-`))return{ok:!1,stderr:`session export: --id requires a value\n${sF}`};t=n,e++}else if(i===`--output`){if(n!==null)return{ok:!1,stderr:`session export: duplicate flag --output\n${sF}`};let t=r[e+1];if(!t||t.startsWith(`-`))return{ok:!1,stderr:`session export: --output requires a path\n${sF}`};n=t,e++}else if(i.startsWith(`-`))return{ok:!1,stderr:`session export: unknown flag ${i}\n${sF}`};else return{ok:!1,stderr:`session export: unexpected argument ${JSON.stringify(i)}\n${sF}`}}return{ok:!0,args:{sessionId:t,outputPath:n}}}async function uF(e){let t=[],n=0;for await(let r of e.chunks)t.push(r),n+=r.byteLength;let r=new Uint8Array(n),i=0;for(let e of t)r.set(e,i),i+=e.byteLength;let a=await e.completion;if(a.byteLength!==n||xt(r)!==a.sha256)throw new Sa(`transfer-corrupt`);return r}async function dF(e,t){let n=lF(e);if(!n.ok)return{stdout:``,stderr:n.stderr,exitCode:1};let{sessionId:r,outputPath:i}=n.args;if(i!==null){let e=cF(i);if(!e.ok)return{stdout:``,stderr:`session export: --output ${e.reason}\n${sF}`,exitCode:1}}let a=r==null?{kind:`active`}:{kind:`frozen`,sessionId:r};try{let e=await cs().export(a,{}),n=await uF(e),r=i??`/workspace/${e.filename}`;return await t.fs.writeFile(r,n),{stdout:`exported ${r}\n`,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`session export: ${e instanceof Sa?e.code:e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}function fF(){return S(`session`,async(e,t)=>{if(e[0]===`export`&&!w(e))return dF(e,t);let{dispatchSessionMemoryAware:n}=await import(`./session-command-memory-CGqbKVAE.js`);return n(e,t,sF)})}function pF(){return S(`slicc`,async(e,t)=>{let{runSlicc:n}=await import(`./run-cvQKad0O.js`);return await n(e,t)})}const mF=`leader`;function hF(){try{let e=globalThis.localStorage?.getItem(`slicc.leaderSprinkleInstances`);if(e)return JSON.parse(e)}catch{}return[]}function gF(e){return+!!e.leader+e.followers.length}function _F(){return{stdout:`usage: sprinkle <subcommand> [args]
2082
+ `;function cF(e){if(e.includes(`\0`))return{ok:!1,reason:`path must not contain NUL bytes`};if(e.includes(`\\`))return{ok:!1,reason:`path must not contain backslashes`};let t=e.split(`/`);for(let e of t)if(e===`..`)return{ok:!1,reason:`path must not contain ".."/traversal segments`};return{ok:!0}}function lF(e){let t=null,n=null,r=e.slice(1);for(let e=0;e<r.length;e++){let i=r[e];if(i===`--id`){if(t!==null)return{ok:!1,stderr:`session export: duplicate flag --id\n${sF}`};let n=r[e+1];if(!n||n.startsWith(`-`))return{ok:!1,stderr:`session export: --id requires a value\n${sF}`};t=n,e++}else if(i===`--output`){if(n!==null)return{ok:!1,stderr:`session export: duplicate flag --output\n${sF}`};let t=r[e+1];if(!t||t.startsWith(`-`))return{ok:!1,stderr:`session export: --output requires a path\n${sF}`};n=t,e++}else if(i.startsWith(`-`))return{ok:!1,stderr:`session export: unknown flag ${i}\n${sF}`};else return{ok:!1,stderr:`session export: unexpected argument ${JSON.stringify(i)}\n${sF}`}}return{ok:!0,args:{sessionId:t,outputPath:n}}}async function uF(e){let t=[],n=0;for await(let r of e.chunks)t.push(r),n+=r.byteLength;let r=new Uint8Array(n),i=0;for(let e of t)r.set(e,i),i+=e.byteLength;let a=await e.completion;if(a.byteLength!==n||xt(r)!==a.sha256)throw new Sa(`transfer-corrupt`);return r}async function dF(e,t){let n=lF(e);if(!n.ok)return{stdout:``,stderr:n.stderr,exitCode:1};let{sessionId:r,outputPath:i}=n.args;if(i!==null){let e=cF(i);if(!e.ok)return{stdout:``,stderr:`session export: --output ${e.reason}\n${sF}`,exitCode:1}}let a=r==null?{kind:`active`}:{kind:`frozen`,sessionId:r};try{let e=await cs().export(a,{}),n=await uF(e),r=i??`/workspace/${e.filename}`;return await t.fs.writeFile(r,n),{stdout:`exported ${r}\n`,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`session export: ${e instanceof Sa?e.code:e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}function fF(){return S(`session`,async(e,t)=>{if(e[0]===`export`&&!w(e))return dF(e,t);let{dispatchSessionMemoryAware:n}=await import(`./session-command-memory-BkQWVyeK.js`);return n(e,t,sF)})}function pF(){return S(`slicc`,async(e,t)=>{let{runSlicc:n}=await import(`./run-cvQKad0O.js`);return await n(e,t)})}const mF=`leader`;function hF(){try{let e=globalThis.localStorage?.getItem(`slicc.leaderSprinkleInstances`);if(e)return JSON.parse(e)}catch{}return[]}function gF(e){return+!!e.leader+e.followers.length}function _F(){return{stdout:`usage: sprinkle <subcommand> [args]
2074
2083
 
2075
2084
  list [--runtime <id>] List sprinkles + an instance line per runtime
2076
2085
  open <name> Open a sprinkle by name
@@ -2151,10 +2160,10 @@ Options:
2151
2160
  `,exitCode:1};let i=await Promise.all(r.map(e=>eI(t,e,n))),a=i.map(e=>e.stdout).join(``),o=i.map(e=>e.stderr).join(``);return{stdout:a,stderr:o,exitCode:+!!o}})}function nI(e,t,n){let r=n.isSymbolicLink?`symbolic link`:n.isDirectory?`directory`:`regular file`;return e.replace(/%n/g,t).replace(/%N/g,`'${t}'`).replace(/%s/g,String(n.size)).replace(/%F/g,r).replace(/%a/g,n.mode.toString(8))}function rI(e){let t={follow:!1,paths:[]};for(let n=0;n<e.length;n++){let r=e[n];r===`-L`||r===`--dereference`?t.follow=!0:r===`-c`&&e[n+1]?t.format=e[++n]:r.startsWith(`--format=`)?t.format=r.slice(9):r.startsWith(`-`)||t.paths.push(r)}return t}async function iI(e,t,n){try{let r=e.fs.resolvePath(e.cwd,t),i=n.follow?await e.fs.stat(r):await QF(e,r);return{stdout:n.format?`${nI(n.format,t,i)}\n`:` File: ${t}\n Size: ${i.size}\n`,stderr:``}}catch{return{stdout:``,stderr:`stat: cannot stat '${t}': No such file or directory\n`}}}function aI(){return S(`stat`,async(e,t)=>{let n=rI(e);if(n.paths.length===0)return{stdout:``,stderr:`stat: missing operand
2152
2161
  `,exitCode:1};let r=await Promise.all(n.paths.map(e=>iI(t,e,n))),i=r.map(e=>e.stdout).join(``),a=r.map(e=>e.stderr).join(``);return{stdout:i,stderr:a,exitCode:+!!a}})}function oI(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n<=0?`/`:t.slice(0,n)}async function sI(e,t,n,r){let i=e.fs.resolvePath(`/`,t).split(`/`).filter(Boolean),a=e.fs.resolvePath(e.cwd,t),o=``;for(let s=0;s<i.length;s++){try{let t=await QF(e,a);if(!t.isDirectory||t.isSymbolicLink)throw Error(`Not a directory`);await e.fs.rm(a,{recursive:!1,force:!1}),r&&(o+=`rmdir: removing directory, '${a}'\n`)}catch(e){return{stdout:o,stderr:`rmdir: failed to remove '${t}': ${ZF(e)}\n`}}if(!n||s===i.length-1)return{stdout:o,stderr:``};a=oI(a)}return{stdout:o,stderr:``}}function cI(){return S(`rmdir`,async(e,t)=>{let n=e.some(e=>e===`-p`||e===`--parents`),r=e.some(e=>e===`-v`||e===`--verbose`),i=e.filter(e=>!e.startsWith(`-`));if(i.length===0)return{stdout:``,stderr:`rmdir: missing operand
2153
2162
  `,exitCode:1};let a=await Promise.all(i.map(e=>sI(t,e,n,r))),o=a.map(e=>e.stdout).join(``),s=a.map(e=>e.stderr).join(``);return{stdout:o,stderr:s,exitCode:+!!s}})}function lI(){return{stdout:`usage: tar (-c|-x|-t) [-zv] -f <archive> [-C <dir>] [paths...]
2154
- `,stderr:``,exitCode:0}}function uI(e){return{stdout:``,stderr:`tar: ${e}\n`,exitCode:1}}function dI(e,t){if(e.mode)return uI(`exactly one of -c, -x, or -t is required`);e.mode=t}function fI(e,t,n){if(n)return[n,t];let r=e[t+1];return r===void 0?void 0:[r,t+1]}const pI={c:`create`,x:`extract`,t:`list`};function mI(e,t,n,r,i){let a=pI[e];if(a)return{nextIndex:r,error:dI(i,a)};if(e===`z`)return i.gzip=!0,{nextIndex:r};if(e===`v`)return i.verbose=!0,{nextIndex:r};if(e!==`f`&&e!==`C`)return{nextIndex:r,error:uI(`unsupported option -${e}`)};let o=fI(n,r,t);return o?(e===`f`?i.archive=o[0]:i.directory=o[0],{nextIndex:o[1],consumedValue:!0}):{nextIndex:r,error:uI(`option -${e} requires an argument`)}}function hI(e,t,n){let r=e[t];for(let i=1;i<r.length;i++){let a=mI(r[i],r.slice(i+1),e,t,n);if(a.error||a.consumedValue)return a}return{nextIndex:t}}const gI=/^[cxtzvfC]+$/;function _I(e){let t=e.length>0&&gI.test(e[0])?[`-${e[0]}`,...e.slice(1)]:e,n={gzip:!1,verbose:!1,directory:`.`,paths:[]};for(let e=0;e<t.length;e++){let r=t[e];if(!r.startsWith(`-`)||r===`-`){n.paths.push(r);continue}if(r.startsWith(`--`))return uI(`unsupported option ${r}`);let i=hI(t,e,n);if(i.error)return i.error;e=i.nextIndex}return n}function vI(e,t){let n=e.replace(/\\/g,`/`).replace(/^\/+/,``).replace(/^(?:\.\/)+/,``);return n?n===`.`?`.`:n.replace(/\/+$/,``):tr(t)}function yI(e){let t=e.mtime?.getTime();return t===void 0||Number.isNaN(t)?{}:{mtime:Math.floor(t/1e3)}}async function bI(e,t,n,r){let i=await e.fs.stat(t);if(i.isFile){let a=await e.fs.readFileBuffer(t),o=typeof i.mode==`number`?i.mode&511:void 0;r.push({path:n,bytes:a,...o===void 0?{}:{mode:o},...yI(i)});return}if(!i.isDirectory)throw Error(`unsupported file type: ${t}`);let a=n.endsWith(`/`)?n:`${n}/`,o=typeof i.mode==`number`?i.mode&511:void 0;r.push({path:a,bytes:new Uint8Array,directory:!0,...o===void 0?{}:{mode:o},...yI(i)});for(let n of await e.fs.readdir(t))await bI(e,er(t,n),`${a}${n}`,r)}function xI(e,t){let n=e.length>=2&&e[0]===31&&e[1]===139,r=t||n?Xi(e):e;return Ki(r,{stripNpmPrefix:!1,includeDirectories:!0,preserveRawPaths:!0})}function SI(e,t,n){let r=n.replace(/\\/g,`/`);if(!r||r.startsWith(`/`)||/^[a-zA-Z]:\//.test(r)||r.split(`/`).includes(`..`))return;let i=e.fs.resolvePath(t,r);return lr(t,i)?i:void 0}async function CI(e){try{await e()}catch(e){let t=e?.code;if(t===`ENOSYS`||t===`ENOTSUP`||t===`EOPNOTSUPP`)return;throw e}}async function wI(e,t,n){await CI(()=>e.fs.chmod(t,n))}async function TI(e,t){for(let[n,r]of t){let t=new Date(r*1e3);await CI(()=>e.fs.utimes(n,t,t))}}async function EI(e,t,n,r){let i=n.directory?493:420,a=n.mode===i&&await e.fs.exists(t),o=n.mode!==void 0&&(n.mode!==i||a);if(n.directory){await e.fs.mkdir(t,{recursive:!0}),o&&r.push([t,n.mode]);return}let s=or(t);s!==`/`&&await e.fs.mkdir(s,{recursive:!0}),await e.fs.writeFile(t,n.bytes),o&&await wI(e,t,n.mode)}async function DI(e,t){if(e.paths.length===0)return uI(`create mode requires at least one input path`);let n=[],r=t.fs.resolvePath(t.cwd,e.directory);for(let i of e.paths){let e=t.fs.resolvePath(r,i);await bI(t,e,vI(i,e),n)}let i=t.fs.resolvePath(t.cwd,e.archive),a=Qi(n);return await t.fs.writeFile(i,e.gzip?Wi(a):a),{stdout:e.verbose?`${n.map(e=>e.path).join(`
2155
- `)}\n`:``,stderr:``,exitCode:0}}function OI(e){let t=new Set,n=[];for(let r=e.length-1;r>=0;r--){let[i,a]=e[r];t.has(i)||(t.add(i),n.push([i,a]))}return n}async function kI(e,t){if(e.paths.length>0)return uI(`${e.mode} mode does not accept input paths`);let n=t.fs.resolvePath(t.cwd,e.archive),r=xI(await t.fs.readFileBuffer(n),e.gzip);if(e.mode===`list`){let e=r.map(e=>e.path).join(`
2156
- `);return{stdout:e?`${e}\n`:``,stderr:``,exitCode:0}}let i=t.fs.resolvePath(t.cwd,e.directory);await t.fs.mkdir(i,{recursive:!0});let a=[],o=[],s=[];for(let e of r){let n=SI(t,i,e.path);if(!n)return uI(`blocked suspicious path ${e.path}`);await EI(t,n,e,o),e.mtime!==void 0&&s.push([n,e.mtime]),a.push(e.path)}for(let[e,n]of OI(o))await wI(t,e,n);return await TI(t,OI(s)),{stdout:e.verbose?`${a.join(`
2157
- `)}\n`:``,stderr:``,exitCode:0}}function AI(){return S(`tar`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return lI();let n=_I(e);return`exitCode`in n?n:n.mode?n.archive?n.mode===`list`&&n.directory!==`.`?uI(`-C is only supported in create or extract mode`):n.mode===`create`?DI(n,t):kI(n,t):uI(`option -f requires an archive path`):uI(`exactly one of -c, -x, or -t is required`)})}var jI=`/**
2163
+ `,stderr:``,exitCode:0}}function uI(e){return{stdout:``,stderr:`tar: ${e}\n`,exitCode:1}}function dI(e,t){if(e.mode)return uI(`exactly one of -c, -x, or -t is required`);e.mode=t}function fI(e,t,n){if(n)return[n,t];let r=e[t+1];return r===void 0?void 0:[r,t+1]}const pI={c:`create`,x:`extract`,t:`list`};function mI(e,t,n,r,i){let a=pI[e];if(a)return{nextIndex:r,error:dI(i,a)};if(e===`z`)return i.gzip=!0,{nextIndex:r};if(e===`v`)return i.verbose=!0,{nextIndex:r};if(e!==`f`&&e!==`C`)return{nextIndex:r,error:uI(`unsupported option -${e}`)};let o=fI(n,r,t);return o?(e===`f`?i.archive=o[0]:i.directory=o[0],{nextIndex:o[1],consumedValue:!0}):{nextIndex:r,error:uI(`option -${e} requires an argument`)}}function hI(e,t,n){let r=e[t];for(let i=1;i<r.length;i++){let a=mI(r[i],r.slice(i+1),e,t,n);if(a.error||a.consumedValue)return a}return{nextIndex:t}}const gI=/^[cxtzvfC]+$/;function _I(e){let t=e.length>0&&gI.test(e[0])?[`-${e[0]}`,...e.slice(1)]:e,n={gzip:!1,verbose:!1,directory:`.`,paths:[]};for(let e=0;e<t.length;e++){let r=t[e];if(!r.startsWith(`-`)||r===`-`){n.paths.push(r);continue}if(r.startsWith(`--`))return uI(`unsupported option ${r}`);let i=hI(t,e,n);if(i.error)return i.error;e=i.nextIndex}return n}function vI(e,t){let n=e.replace(/\\/g,`/`).replace(/^\/+/,``).replace(/^(?:\.\/)+/,``);return n?n===`.`?`.`:n.replace(/\/+$/,``):tr(t)}function yI(e){let t=e.mtime?.getTime();return t===void 0||Number.isNaN(t)?{}:{mtime:Math.floor(t/1e3)}}async function bI(e,t,n,r){let i=await e.fs.stat(t);if(i.isFile){let a=await e.fs.readFileBuffer(t),o=typeof i.mode==`number`?i.mode&511:void 0;r.push({path:n,bytes:a,...o===void 0?{}:{mode:o},...yI(i)});return}if(!i.isDirectory)throw Error(`unsupported file type: ${t}`);let a=n.endsWith(`/`)?n:`${n}/`,o=typeof i.mode==`number`?i.mode&511:void 0;r.push({path:a,bytes:new Uint8Array,directory:!0,...o===void 0?{}:{mode:o},...yI(i)});for(let n of await e.fs.readdir(t))await bI(e,er(t,n),`${a}${n}`,r)}function xI(e,t){let n=e.length>=2&&e[0]===31&&e[1]===139,r=t||n?Qi(e):e;return Zi(r,{stripNpmPrefix:!1,includeDirectories:!0,preserveRawPaths:!0})}function SI(e,t,n){let r=n.replace(/\\/g,`/`);if(!r||r.startsWith(`/`)||/^[a-zA-Z]:\//.test(r)||r.split(`/`).includes(`..`))return;let i=e.fs.resolvePath(t,r);return lr(t,i)?i:void 0}async function CI(e){try{await e()}catch(e){let t=e?.code;if(t===`ENOSYS`||t===`ENOTSUP`||t===`EOPNOTSUPP`)return;throw e}}async function wI(e,t,n,r){let i=new Map(t),a=new Map(n),o=[...new Set([...i.keys(),...a.keys()])];if(o.length===0)return;let s=o.map(e=>{let t=i.get(e),n=a.get(e),r=n===void 0?void 0:new Date(n*1e3);return{path:e,...t===void 0?{}:{mode:t},...r===void 0?{}:{atime:r,mtime:r}}});if(typeof r?.updateMetadataBatch==`function`){await CI(()=>r.updateMetadataBatch(s));return}let c=e.fs;if(typeof c.updateMetadataBatch==`function`){await CI(()=>c.updateMetadataBatch(s));return}for(let[e,n]of t)await CI(()=>c.chmod(e,n));for(let[e,t]of n){let n=new Date(t*1e3);await CI(()=>c.utimes(e,n,n))}}async function TI(e,t,n,r,i){let a=n.directory?493:420,o=n.mode===a&&await e.fs.exists(t),s=n.mode!==void 0&&(n.mode!==a||o);if(n.directory){await e.fs.mkdir(t,{recursive:!0}),s&&r.push([t,n.mode]);return}let c=or(t);c!==`/`&&await e.fs.mkdir(c,{recursive:!0}),await e.fs.writeFile(t,n.bytes),s&&i.push([t,n.mode])}async function EI(e,t){if(e.paths.length===0)return uI(`create mode requires at least one input path`);let n=[],r=t.fs.resolvePath(t.cwd,e.directory);for(let i of e.paths){let e=t.fs.resolvePath(r,i);await bI(t,e,vI(i,e),n)}let i=t.fs.resolvePath(t.cwd,e.archive),a=Yi(n);return await t.fs.writeFile(i,e.gzip?Xi(a):a),{stdout:e.verbose?`${n.map(e=>e.path).join(`
2164
+ `)}\n`:``,stderr:``,exitCode:0}}function DI(e){let t=new Set,n=[];for(let r=e.length-1;r>=0;r--){let[i,a]=e[r];t.has(i)||(t.add(i),n.push([i,a]))}return n}async function OI(e,t,n){if(e.paths.length>0)return uI(`${e.mode} mode does not accept input paths`);let r=t.fs.resolvePath(t.cwd,e.archive),i=xI(await t.fs.readFileBuffer(r),e.gzip);if(e.mode===`list`){let e=i.map(e=>e.path).join(`
2165
+ `);return{stdout:e?`${e}\n`:``,stderr:``,exitCode:0}}let a=t.fs.resolvePath(t.cwd,e.directory);await t.fs.mkdir(a,{recursive:!0});let o=[],s=[],c=[],l=[];for(let e of i){let n=SI(t,a,e.path);if(!n)return uI(`blocked suspicious path ${e.path}`);await TI(t,n,e,c,s),e.mtime!==void 0&&l.push([n,e.mtime]),o.push(e.path)}return await wI(t,[...DI(s),...DI(c)],DI(l),n),{stdout:e.verbose?`${o.join(`
2166
+ `)}\n`:``,stderr:``,exitCode:0}}function kI(e={}){return S(`tar`,async(t,n)=>{if(t.length===0||t.includes(`--help`)||t.includes(`-h`))return lI();let r=_I(t);return`exitCode`in r?r:r.mode?r.archive?r.mode===`list`&&r.directory!==`.`?uI(`-C is only supported in create or extract mode`):r.mode===`create`?EI(r,n):OI(r,n,e.fs):uI(`option -f requires an archive path`):uI(`exactly one of -c, -x, or -t is required`)})}var AI=`/**
2158
2167
  * Standalone assertions - no dependency on test runner
2159
2168
  *
2160
2169
  * Each assertion:
@@ -2342,7 +2351,7 @@ function sameMembers(a, b) {
2342
2351
  }
2343
2352
 
2344
2353
  const slice = a => (isPrimitive(a) ? a : a.slice ? a.slice() : Object.assign({}, a))
2345
- `,MI=`/**
2354
+ `,jI=`/**
2346
2355
  * tst - minimal test runner
2347
2356
  *
2348
2357
  * - Standalone assertions (assert.js works anywhere)
@@ -2972,7 +2981,7 @@ function scheduleAutoRun() {
2972
2981
  scheduleAutoRun()
2973
2982
 
2974
2983
  export * from './assert.js'
2975
- `;function NI(e){return{reader:{exists:t=>e.fs.exists(t),isDirectory:async t=>{try{return(await e.fs.stat(t)).isDirectory}catch{return!1}},readFile:t=>e.fs.readFile(t)},readBytes:t=>e.fs.readFileBuffer(t),fromDir:e.cwd}}const PI=`tsc - thin wrapper over the ipk-loaded TypeScript 6 package
2984
+ `;function MI(e){return{reader:{exists:t=>e.fs.exists(t),isDirectory:async t=>{try{return(await e.fs.stat(t)).isDirectory}catch{return!1}},readFile:t=>e.fs.readFile(t)},readBytes:t=>e.fs.readFileBuffer(t),fromDir:e.cwd}}const NI=`tsc - thin wrapper over the ipk-loaded TypeScript 6 package
2976
2985
 
2977
2986
  Usage:
2978
2987
  tsc [options] [files...]
@@ -2996,28 +3005,28 @@ Install:
2996
3005
  Then \`tsc --version\` and the transpile commands above. There is no
2997
3006
  bundled binary, no CDN fallback; a missing package exits non-zero
2998
3007
  with a clear \`ipk add\` hint.
2999
- `;function FI(e){let t=[],n=!1,r=null,i=!1,a=!1;for(let o=0;o<e.length;o++){let s=e[o];if(s===`-h`||s===`--help`){i=!0;continue}if(s===`-v`||s===`--version`){a=!0;continue}if(s===`--noEmit`){n=!0;continue}if(s===`--outDir`){let t=e[o+1];if(typeof t!=`string`||t.startsWith(`-`))throw Error(`tsc: --outDir requires a value`);r=t,o+=1;continue}if(s.startsWith(`--outDir=`)){r=s.slice(9);continue}if(s.startsWith(`-`))throw Error(`tsc: unknown option: ${s}`);t.push(s)}return{files:t,noEmit:n,outDir:r,showHelp:i,showVersion:a}}function II(e,t){let n=`${tr(e).replace(/\.(ts|tsx|mts|cts)$/i,``)}.js`;return t?`${t.endsWith(`/`)?t.slice(0,-1):t}/${n}`:`${or(e)}/${n}`}async function LI(e,t){let n=t||`/`,r=``;for(;n&&n!==r;){let t=n===`/`?`/tsconfig.json`:`${n}/tsconfig.json`;if(await e.exists(t))return t;r=n,n=or(n)}return null}function RI(e){return{target:e.ScriptTarget.ES2022,module:e.ModuleKind.ESNext,moduleResolution:e.ModuleResolutionKind.Bundler,esModuleInterop:!0,allowSyntheticDefaultImports:!0,isolatedModules:!0}}function zI(e){if(typeof e!=`object`||!e)return{};let{compilerOptions:t}=e;return t??{}}async function BI(e,t,n){let r=RI(t),i=await LI(e,n);if(!i)return{compilerOptions:{...r}};let a;try{a=await e.readFile(i)}catch{return{compilerOptions:{...r}}}let{config:o,error:s}=t.parseConfigFileTextToJson(i,a);return s||!o?{compilerOptions:{...r}}:{compilerOptions:{...r,...zI(o)}}}function VI(e,t){let n=e.flattenDiagnosticMessageText(t.messageText,`
3000
- `);if(t.file&&typeof t.start==`number`){let{line:e,character:r}=t.file.getLineAndCharacterOfPosition(t.start);return`${t.file.fileName}(${e+1},${r+1}): error TS${t.code}: ${n}`}return`error TS${t.code}: ${n}`}function HI(e,t){let n=t.toLowerCase();return n.endsWith(`.tsx`)?e.ScriptKind.TSX:n.endsWith(`.jsx`)?e.ScriptKind.JSX:n.endsWith(`.js`)||n.endsWith(`.mjs`)||n.endsWith(`.cjs`)?e.ScriptKind.JS:e.ScriptKind.TS}function UI(e,t,n,r,i){let a=e.transpileModule(t,{compilerOptions:r,fileName:n,reportDiagnostics:i});return{outputText:a.outputText,diagnostics:a.diagnostics??[]}}function WI(e,t,n,r){let{outputText:i,diagnostics:a}=UI(e,r,`<stdin>.ts`,n.compilerOptions,!0),o=a.map(t=>VI(e,t)),s=o.length>0?`${o.join(`
3001
- `)}\n`:``;return{stdout:t.noEmit?``:i,stderr:s,exitCode:+(a.length>0)}}async function GI(e,t,n,r,i){let a=t.fs.resolvePath(t.cwd,n);if(!await t.fs.exists(a))return{stderr:`tsc: ${n}: no such file\n`,hadError:!0};let o;try{o=await t.fs.readFile(a)}catch(e){return{stderr:`tsc: ${n}: ${e instanceof Error?e.message:String(e)}\n`,hadError:!0}}HI(e,a);let{outputText:s,diagnostics:c}=UI(e,o,a,i.compilerOptions,!0),l=[];for(let t of c)l.push(`${VI(e,t)}\n`);let u=c.length>0;if(r.noEmit)return{stderr:l.join(``),hadError:u};let d=t.fs.resolvePath(t.cwd,II(a,r.outDir));try{await t.fs.writeFile(d,s)}catch(e){l.push(`tsc: ${d}: ${e instanceof Error?e.message:String(e)}\n`),u=!0}return{stderr:l.join(``),hadError:u}}async function KI(e,t){let n;try{n=FI(e)}catch(e){return{done:{stdout:``,stderr:`${e instanceof Error?e.message:String(e)}\n`,exitCode:2}}}if(n.showHelp)return{done:{stdout:PI,stderr:``,exitCode:0}};let r;try{r=await Qn(NI(t))}catch(e){return{done:{stdout:``,stderr:`tsc: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}return n.showVersion?{done:{stdout:`Version ${r.version}\n`,stderr:``,exitCode:0}}:{parsed:n,ts:r}}function qI(){return S(`tsc`,async(e,t)=>{let n=await KI(e,t);if(`done`in n)return n.done;let{parsed:r,ts:i}=n,a=await BI(t.fs,i,t.cwd);if(r.files.length===0){let e=P(t.stdin);return e?WI(i,r,a,e):{stdout:PI,stderr:``,exitCode:0}}let o=[],s=!1;for(let e of r.files){let n=await GI(i,t,e,r,a);n.stderr&&o.push(n.stderr),n.hadError&&(s=!0)}return{stdout:``,stderr:o.join(``),exitCode:+!!s}})}const JI=[`**/*.test.{js,ts}`];function YI(e,t){let n,r=1;if(e===`--reporter`)n=t,r=2;else if(e.startsWith(`--reporter=`))n=e.slice(11);else return null;if(n!==`tap`&&n!==`spec`)throw Error(`tst: --reporter must be tap or spec`);return{reporter:n,consumed:r}}function XI(e,t){return e===`--coverage`?{consumed:1}:e===`--coverage-dir`&&t!==void 0?{coverageDir:t,consumed:2}:e.startsWith(`--coverage-dir=`)?{coverageDir:e.slice(15),consumed:1}:null}function ZI(e){let t=[],n=`tap`,r=!1,i=!1,a=``;for(let o=0;o<e.length;o++){let s=e[o];if(s===`-h`||s===`--help`){r=!0;continue}let c=YI(s,e[o+1]);if(c){n=c.reporter,c.consumed===2&&(o+=1);continue}let l=XI(s,e[o+1]);if(l){i=!0,l.coverageDir!==void 0&&(a=l.coverageDir),l.consumed===2&&(o+=1);continue}if(s.startsWith(`-`))throw Error(`tst: unknown option: ${s}`);t.push(s)}return{globs:t.length>0?t:[...JI],reporter:n,showHelp:r,coverage:i,coverageDir:a}}function QI(e){let t=e.indexOf(`{`);if(t===-1)return[e];let n=e.indexOf(`}`,t);if(n===-1)return[e];let r=e.slice(0,t),i=e.slice(n+1),a=e.slice(t+1,n).split(`,`),o=[];for(let e of a)for(let t of QI(`${r}${e}${i}`))o.push(t);return o}function $I(e){let t=``,n=0;for(;n<e.length;){let r=e[n];r===`*`&&e[n+1]===`*`?(t+=`(?:.*/)?`,n+=2,e[n]===`/`&&(n+=1)):r===`*`?(t+=`[^/]*`,n+=1):r===`?`?(t+=`[^/]`,n+=1):`.+^$()[]|\\`.includes(r)?(t+=`\\${r}`,n+=1):(t+=r,n+=1)}return RegExp(`^${t}$`)}async function eL(e,t,n){let r=n.flatMap(QI).map($I),i=new Set,a=t===`/`?``:t;async function o(t){let n;try{n=await e.readdir(t)}catch{return}for(let s of n){if(s===`node_modules`||s.startsWith(`.`))continue;let n=t===`/`?`/${s}`:`${t}/${s}`,c=!1;try{c=(await e.stat(n)).isDirectory}catch{continue}if(c){await o(n);continue}let l=n.startsWith(`${a}/`)?n.slice(a.length+1):n;r.some(e=>e.test(l))&&i.add(n)}}return await o(t),[...i].sort()}let tL=null;async function nL(e){if(tL)return tL;let t={module:e.ModuleKind.CommonJS,target:e.ScriptTarget.ES2022,esModuleInterop:!0,isolatedModules:!1};return tL=`
3008
+ `;function PI(e){let t=[],n=!1,r=null,i=!1,a=!1;for(let o=0;o<e.length;o++){let s=e[o];if(s===`-h`||s===`--help`){i=!0;continue}if(s===`-v`||s===`--version`){a=!0;continue}if(s===`--noEmit`){n=!0;continue}if(s===`--outDir`){let t=e[o+1];if(typeof t!=`string`||t.startsWith(`-`))throw Error(`tsc: --outDir requires a value`);r=t,o+=1;continue}if(s.startsWith(`--outDir=`)){r=s.slice(9);continue}if(s.startsWith(`-`))throw Error(`tsc: unknown option: ${s}`);t.push(s)}return{files:t,noEmit:n,outDir:r,showHelp:i,showVersion:a}}function FI(e,t){let n=`${tr(e).replace(/\.(ts|tsx|mts|cts)$/i,``)}.js`;return t?`${t.endsWith(`/`)?t.slice(0,-1):t}/${n}`:`${or(e)}/${n}`}async function II(e,t){let n=t||`/`,r=``;for(;n&&n!==r;){let t=n===`/`?`/tsconfig.json`:`${n}/tsconfig.json`;if(await e.exists(t))return t;r=n,n=or(n)}return null}function LI(e){return{target:e.ScriptTarget.ES2022,module:e.ModuleKind.ESNext,moduleResolution:e.ModuleResolutionKind.Bundler,esModuleInterop:!0,allowSyntheticDefaultImports:!0,isolatedModules:!0}}function RI(e){if(typeof e!=`object`||!e)return{};let{compilerOptions:t}=e;return t??{}}async function zI(e,t,n){let r=LI(t),i=await II(e,n);if(!i)return{compilerOptions:{...r}};let a;try{a=await e.readFile(i)}catch{return{compilerOptions:{...r}}}let{config:o,error:s}=t.parseConfigFileTextToJson(i,a);return s||!o?{compilerOptions:{...r}}:{compilerOptions:{...r,...RI(o)}}}function BI(e,t){let n=e.flattenDiagnosticMessageText(t.messageText,`
3009
+ `);if(t.file&&typeof t.start==`number`){let{line:e,character:r}=t.file.getLineAndCharacterOfPosition(t.start);return`${t.file.fileName}(${e+1},${r+1}): error TS${t.code}: ${n}`}return`error TS${t.code}: ${n}`}function VI(e,t){let n=t.toLowerCase();return n.endsWith(`.tsx`)?e.ScriptKind.TSX:n.endsWith(`.jsx`)?e.ScriptKind.JSX:n.endsWith(`.js`)||n.endsWith(`.mjs`)||n.endsWith(`.cjs`)?e.ScriptKind.JS:e.ScriptKind.TS}function HI(e,t,n,r,i){let a=e.transpileModule(t,{compilerOptions:r,fileName:n,reportDiagnostics:i});return{outputText:a.outputText,diagnostics:a.diagnostics??[]}}function UI(e,t,n,r){let{outputText:i,diagnostics:a}=HI(e,r,`<stdin>.ts`,n.compilerOptions,!0),o=a.map(t=>BI(e,t)),s=o.length>0?`${o.join(`
3010
+ `)}\n`:``;return{stdout:t.noEmit?``:i,stderr:s,exitCode:+(a.length>0)}}async function WI(e,t,n,r,i){let a=t.fs.resolvePath(t.cwd,n);if(!await t.fs.exists(a))return{stderr:`tsc: ${n}: no such file\n`,hadError:!0};let o;try{o=await t.fs.readFile(a)}catch(e){return{stderr:`tsc: ${n}: ${e instanceof Error?e.message:String(e)}\n`,hadError:!0}}VI(e,a);let{outputText:s,diagnostics:c}=HI(e,o,a,i.compilerOptions,!0),l=[];for(let t of c)l.push(`${BI(e,t)}\n`);let u=c.length>0;if(r.noEmit)return{stderr:l.join(``),hadError:u};let d=t.fs.resolvePath(t.cwd,FI(a,r.outDir));try{await t.fs.writeFile(d,s)}catch(e){l.push(`tsc: ${d}: ${e instanceof Error?e.message:String(e)}\n`),u=!0}return{stderr:l.join(``),hadError:u}}async function GI(e,t){let n;try{n=PI(e)}catch(e){return{done:{stdout:``,stderr:`${e instanceof Error?e.message:String(e)}\n`,exitCode:2}}}if(n.showHelp)return{done:{stdout:NI,stderr:``,exitCode:0}};let r;try{r=await Qn(MI(t))}catch(e){return{done:{stdout:``,stderr:`tsc: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}return n.showVersion?{done:{stdout:`Version ${r.version}\n`,stderr:``,exitCode:0}}:{parsed:n,ts:r}}function KI(){return S(`tsc`,async(e,t)=>{let n=await GI(e,t);if(`done`in n)return n.done;let{parsed:r,ts:i}=n,a=await zI(t.fs,i,t.cwd);if(r.files.length===0){let e=P(t.stdin);return e?UI(i,r,a,e):{stdout:NI,stderr:``,exitCode:0}}let o=[],s=!1;for(let e of r.files){let n=await WI(i,t,e,r,a);n.stderr&&o.push(n.stderr),n.hadError&&(s=!0)}return{stdout:``,stderr:o.join(``),exitCode:+!!s}})}const qI=[`**/*.test.{js,ts}`];function JI(e,t){let n,r=1;if(e===`--reporter`)n=t,r=2;else if(e.startsWith(`--reporter=`))n=e.slice(11);else return null;if(n!==`tap`&&n!==`spec`)throw Error(`tst: --reporter must be tap or spec`);return{reporter:n,consumed:r}}function YI(e,t){return e===`--coverage`?{consumed:1}:e===`--coverage-dir`&&t!==void 0?{coverageDir:t,consumed:2}:e.startsWith(`--coverage-dir=`)?{coverageDir:e.slice(15),consumed:1}:null}function XI(e){let t=[],n=`tap`,r=!1,i=!1,a=``;for(let o=0;o<e.length;o++){let s=e[o];if(s===`-h`||s===`--help`){r=!0;continue}let c=JI(s,e[o+1]);if(c){n=c.reporter,c.consumed===2&&(o+=1);continue}let l=YI(s,e[o+1]);if(l){i=!0,l.coverageDir!==void 0&&(a=l.coverageDir),l.consumed===2&&(o+=1);continue}if(s.startsWith(`-`))throw Error(`tst: unknown option: ${s}`);t.push(s)}return{globs:t.length>0?t:[...qI],reporter:n,showHelp:r,coverage:i,coverageDir:a}}function ZI(e){let t=e.indexOf(`{`);if(t===-1)return[e];let n=e.indexOf(`}`,t);if(n===-1)return[e];let r=e.slice(0,t),i=e.slice(n+1),a=e.slice(t+1,n).split(`,`),o=[];for(let e of a)for(let t of ZI(`${r}${e}${i}`))o.push(t);return o}function QI(e){let t=``,n=0;for(;n<e.length;){let r=e[n];r===`*`&&e[n+1]===`*`?(t+=`(?:.*/)?`,n+=2,e[n]===`/`&&(n+=1)):r===`*`?(t+=`[^/]*`,n+=1):r===`?`?(t+=`[^/]`,n+=1):`.+^$()[]|\\`.includes(r)?(t+=`\\${r}`,n+=1):(t+=r,n+=1)}return RegExp(`^${t}$`)}async function $I(e,t,n){let r=n.flatMap(ZI).map(QI),i=new Set,a=t===`/`?``:t;async function o(t){let n;try{n=await e.readdir(t)}catch{return}for(let s of n){if(s===`node_modules`||s.startsWith(`.`))continue;let n=t===`/`?`/${s}`:`${t}/${s}`,c=!1;try{c=(await e.stat(n)).isDirectory}catch{continue}if(c){await o(n);continue}let l=n.startsWith(`${a}/`)?n.slice(a.length+1):n;r.some(e=>e.test(l))&&i.add(n)}}return await o(t),[...i].sort()}let eL=null;async function tL(e){if(eL)return eL;let t={module:e.ModuleKind.CommonJS,target:e.ScriptTarget.ES2022,esModuleInterop:!0,isolatedModules:!1};return eL=`
3002
3011
  if (typeof process !== 'undefined' && !process.versions) {
3003
3012
  try { process.versions = { node: '20.0.0' }; } catch (_) { /* readonly process.versions is fine */ }
3004
3013
  }
3005
3014
  const __tst_assert_exports = (function () {
3006
3015
  const module = { exports: {} };
3007
3016
  const exports = module.exports;
3008
- ${e.transpileModule(jI,{compilerOptions:t,fileName:`assert.js`}).outputText}
3017
+ ${e.transpileModule(AI,{compilerOptions:t,fileName:`assert.js`}).outputText}
3009
3018
  return module.exports;
3010
3019
  })();
3011
3020
  const __tst_module_exports = (function () {
3012
3021
  const module = { exports: {} };
3013
3022
  const exports = module.exports;
3014
- ${e.transpileModule(MI,{compilerOptions:t,fileName:`tst.js`}).outputText.replace(/require\(["']\.\/assert\.js["']\)/g,`__tst_assert_exports`).replace(/\bimport\.meta\b/g,`({url:""})`).replace(/await\s+import\(['"](?:worker_threads|fs|path)['"]\)/g,`await Promise.reject(new Error("tst: fork mode is not supported in the realm"))`)}
3023
+ ${e.transpileModule(jI,{compilerOptions:t,fileName:`tst.js`}).outputText.replace(/require\(["']\.\/assert\.js["']\)/g,`__tst_assert_exports`).replace(/\bimport\.meta\b/g,`({url:""})`).replace(/await\s+import\(['"](?:worker_threads|fs|path)['"]\)/g,`await Promise.reject(new Error("tst: fork mode is not supported in the realm"))`)}
3015
3024
  return module.exports;
3016
3025
  })();
3017
3026
  const __tst = __tst_module_exports.default || __tst_module_exports;
3018
3027
  __tst.manual = true;
3019
- `.trim(),tL}function rL(e,t=new Map){return e.replace(/(^|[^\w$.])require\(\s*(["'`])([^"'`]+)\2\s*\)/g,(e,n,r,i)=>i===`tst`||i===`tst/tst.js`?`${n}__tstReq("tst")`:i===`tst/assert`||i===`tst/assert.js`?`${n}__tstReq("tst/assert")`:t.has(i)?`${n}__localReq(${JSON.stringify(t.get(i))})`:e)}function iL(e){let t=new Set,n=/(?:^|[^\w$.])require\(\s*(["'`])([^"'`]+)\1\s*\)/g,r;for(;(r=n.exec(e))!==null;)t.add(r[2]);return[...t]}async function aL(e,t,n){let r=b(`${t}/${n}`),i=[r];r.endsWith(`.js`)&&i.push(`${r.slice(0,-3)}.ts`),/\.[a-zA-Z0-9]+$/.test(r)||i.push(`${r}.ts`,`${r}.js`);for(let t of i)if(await e.exists(t))return t;return null}async function oL(e,t,n,r,i,a){let o=new Map,s=new Map,c=[{path:n,cjs:r}];for(;c.length>0;){let{path:n,cjs:r}=c.shift(),l=or(n),u=new Map;for(let n of iL(r)){if(!n.startsWith(`./`)&&!n.startsWith(`../`))continue;let r=await aL(e,l,n);if(!r||(u.set(n,r),o.has(r)))continue;let s=await e.readFile(r);a&&(s=a(s,r));let d=t.transpileModule(s,{compilerOptions:i,fileName:r}).outputText;o.set(r,d),c.push({path:r,cjs:d})}s.set(n,u)}return{modules:o,edgeRewrites:s}}function sL(e,t,n,r,i,a,o=``,s=``){let c=r===`spec`?`pretty`:`tap`,l=[];for(let[e,t]of i.entries()){let n=rL(t,a.get(e)??new Map);l.push(`${JSON.stringify(e)}: function (module, exports, require) {\n${n}\n}`)}let u=`{${l.join(`,
3020
- `)}}`,d=rL(n,a.get(t)??new Map),f=o,p=s;return`"use strict";
3028
+ `.trim(),eL}function nL(e,t=new Map){return e.replace(/(^|[^\w$.])require\(\s*(["'`])([^"'`]+)\2\s*\)/g,(e,n,r,i)=>i===`tst`||i===`tst/tst.js`?`${n}__tstReq("tst")`:i===`tst/assert`||i===`tst/assert.js`?`${n}__tstReq("tst/assert")`:t.has(i)?`${n}__localReq(${JSON.stringify(t.get(i))})`:e)}function rL(e){let t=new Set,n=/(?:^|[^\w$.])require\(\s*(["'`])([^"'`]+)\1\s*\)/g,r;for(;(r=n.exec(e))!==null;)t.add(r[2]);return[...t]}async function iL(e,t,n){let r=b(`${t}/${n}`),i=[r];r.endsWith(`.js`)&&i.push(`${r.slice(0,-3)}.ts`),/\.[a-zA-Z0-9]+$/.test(r)||i.push(`${r}.ts`,`${r}.js`);for(let t of i)if(await e.exists(t))return t;return null}async function aL(e,t,n,r,i,a){let o=new Map,s=new Map,c=[{path:n,cjs:r}];for(;c.length>0;){let{path:n,cjs:r}=c.shift(),l=or(n),u=new Map;for(let n of rL(r)){if(!n.startsWith(`./`)&&!n.startsWith(`../`))continue;let r=await iL(e,l,n);if(!r||(u.set(n,r),o.has(r)))continue;let s=await e.readFile(r);a&&(s=a(s,r));let d=t.transpileModule(s,{compilerOptions:i,fileName:r}).outputText;o.set(r,d),c.push({path:r,cjs:d})}s.set(n,u)}return{modules:o,edgeRewrites:s}}function oL(e,t,n,r,i,a,o=``,s=``){let c=r===`spec`?`pretty`:`tap`,l=[];for(let[e,t]of i.entries()){let n=nL(t,a.get(e)??new Map);l.push(`${JSON.stringify(e)}: function (module, exports, require) {\n${n}\n}`)}let u=`{${l.join(`,
3029
+ `)}}`,d=nL(n,a.get(t)??new Map),f=o,p=s;return`"use strict";
3021
3030
  ${f}${e}
3022
3031
  const __realmRequire = require;
3023
3032
  const { createRequire: __createRequire } = __realmRequire("module");
@@ -3060,7 +3069,7 @@ await Promise.resolve();
3060
3069
  await new Promise((resolve) => setTimeout(resolve));
3061
3070
  ${p}
3062
3071
  if (__state && __state.failed && __state.failed.length > 0) process.exit(1);
3063
- `}const cL={esModuleInterop:!0,allowJs:!0,isolatedModules:!1};function lL(e){return{module:e.ModuleKind.CommonJS,target:e.ScriptTarget.ES2022,...cL}}async function uL(e,t){let n;try{n=ZI(e)}catch(e){return{done:{stdout:``,stderr:`${e instanceof Error?e.message:String(e)}\n`,exitCode:2}}}if(n.showHelp)return{done:{stdout:`tst - run *.test.{js,ts} files with the bundled tst runner
3072
+ `}const sL={esModuleInterop:!0,allowJs:!0,isolatedModules:!1};function cL(e){return{module:e.ModuleKind.CommonJS,target:e.ScriptTarget.ES2022,...sL}}async function lL(e,t){let n;try{n=XI(e)}catch(e){return{done:{stdout:``,stderr:`${e instanceof Error?e.message:String(e)}\n`,exitCode:2}}}if(n.showHelp)return{done:{stdout:`tst - run *.test.{js,ts} files with the bundled tst runner
3064
3073
 
3065
3074
  Usage:
3066
3075
  tst [options] [glob...]
@@ -3082,7 +3091,7 @@ Notes:
3082
3091
  with statement counters. nyc/c8 cannot wrap this runner: it is not a
3083
3092
  Node child. Istanbul/Babel are not bundled (webapp size-limit); the
3084
3093
  TypeScript AST already in process does the rewrite.
3085
- `,stderr:``,exitCode:0}};let r=await eL(t.fs,t.cwd,n.globs);if(r.length===0)return{done:{stdout:``,stderr:`tst: no test files matched ${n.globs.join(` `)}\n`,exitCode:1}};let i;try{i=await Qn(NI(t))}catch(e){return{done:{stdout:``,stderr:`tst: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}let a=await nL(i),o=n.coverage?await import(`./coverage-instrument-CjoHgKzK.js`):null;return{parsed:n,files:r,ts:i,harness:a,userOpts:lL(i),coverageMaps:{},coverageCounts:{},coverageMod:o}}function dL(e){return e.includes(`# fail `)||/(^|\n)not ok /.test(e)}async function fL(e,t,n,r){let{ts:i,harness:a,userOpts:o,parsed:s}=t,c=t.coverageMod,l=c?(e,n)=>{let{source:r,map:a}=c.instrumentSource(i,e,n);return t.coverageMaps[n]=a,r}:void 0,u;try{u=await e.fs.readFile(n)}catch(e){return{stdout:``,stderr:`tst: ${n}: ${e instanceof Error?e.message:String(e)}\n`,failed:!0}}l&&(u=l(u,n));let d;try{d=i.transpileModule(u,{compilerOptions:o,fileName:n}).outputText}catch(e){return{stdout:``,stderr:`tst: ${n}: transpile error: ${e instanceof Error?e.message:String(e)}\n`,failed:!0}}let f,p;try{({modules:f,edgeRewrites:p}=await oL(e.fs,i,n,d,o,l))}catch(e){return{stdout:``,stderr:`tst: ${n}: local-require resolve error: ${e instanceof Error?e.message:String(e)}\n`,failed:!0}}let m=sL(a,n,d,s.reporter,f,p,c?`${c.coverageRuntimeSource()}\n`:``,c?`\n${c.coverageDumpSource()}`:``),h=await Ur(m,[`node`,n],e,void 0,{filename:n}),g=h.stdout;if(c){let e=c.extractCoverageCounts(g);g=e.stdout,c.mergeCounts(t.coverageCounts,e.counts)}return{stdout:r?`# ${n}\n${g}`:g,stderr:h.stderr,failed:h.exitCode!==0||dL(g)}}function pL(){return S(`tst`,async(e,t)=>{let n=await uL(e,t);if(`done`in n)return n.done;let r=n.files.length>1,i=``,a=``,o=!1;for(let e of n.files){let s=await fL(t,n,e,r);i+=s.stdout,a+=s.stderr,s.failed&&(o=!0)}if(n.coverageMod){let e=n.coverageMod.resolveCoverageDir(t.cwd,n.parsed.coverageDir,(e,n)=>t.fs.resolvePath(e,n)),r=JSON.stringify({counts:n.coverageCounts,maps:n.coverageMaps},null,2),s=n.coverageMod.toLcov(n.coverageCounts,n.coverageMaps),c=n.coverageMod.coverageSummary(n.coverageCounts,n.coverageMaps);try{await t.fs.writeFile(`${e}/coverage.json`,r),await t.fs.writeFile(`${e}/coverage.lcov`,s)}catch(t){a+=`tst: writing coverage to ${e}: ${t instanceof Error?t.message:String(t)}\n`,o=!0}i+=`\n${c}`}return{stdout:i,stderr:a,exitCode:+!!o}})}const mL=[],hL=`usage: theme <subcommand> [args]
3094
+ `,stderr:``,exitCode:0}};let r=await $I(t.fs,t.cwd,n.globs);if(r.length===0)return{done:{stdout:``,stderr:`tst: no test files matched ${n.globs.join(` `)}\n`,exitCode:1}};let i;try{i=await Qn(MI(t))}catch(e){return{done:{stdout:``,stderr:`tst: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}let a=await tL(i),o=n.coverage?await import(`./coverage-instrument-CjoHgKzK.js`):null;return{parsed:n,files:r,ts:i,harness:a,userOpts:cL(i),coverageMaps:{},coverageCounts:{},coverageMod:o}}function uL(e){return e.includes(`# fail `)||/(^|\n)not ok /.test(e)}async function dL(e,t,n,r){let{ts:i,harness:a,userOpts:o,parsed:s}=t,c=t.coverageMod,l=c?(e,n)=>{let{source:r,map:a}=c.instrumentSource(i,e,n);return t.coverageMaps[n]=a,r}:void 0,u;try{u=await e.fs.readFile(n)}catch(e){return{stdout:``,stderr:`tst: ${n}: ${e instanceof Error?e.message:String(e)}\n`,failed:!0}}l&&(u=l(u,n));let d;try{d=i.transpileModule(u,{compilerOptions:o,fileName:n}).outputText}catch(e){return{stdout:``,stderr:`tst: ${n}: transpile error: ${e instanceof Error?e.message:String(e)}\n`,failed:!0}}let f,p;try{({modules:f,edgeRewrites:p}=await aL(e.fs,i,n,d,o,l))}catch(e){return{stdout:``,stderr:`tst: ${n}: local-require resolve error: ${e instanceof Error?e.message:String(e)}\n`,failed:!0}}let m=oL(a,n,d,s.reporter,f,p,c?`${c.coverageRuntimeSource()}\n`:``,c?`\n${c.coverageDumpSource()}`:``),h=await Ur(m,[`node`,n],e,void 0,{filename:n}),g=h.stdout;if(c){let e=c.extractCoverageCounts(g);g=e.stdout,c.mergeCounts(t.coverageCounts,e.counts)}return{stdout:r?`# ${n}\n${g}`:g,stderr:h.stderr,failed:h.exitCode!==0||uL(g)}}function fL(){return S(`tst`,async(e,t)=>{let n=await lL(e,t);if(`done`in n)return n.done;let r=n.files.length>1,i=``,a=``,o=!1;for(let e of n.files){let s=await dL(t,n,e,r);i+=s.stdout,a+=s.stderr,s.failed&&(o=!0)}if(n.coverageMod){let e=n.coverageMod.resolveCoverageDir(t.cwd,n.parsed.coverageDir,(e,n)=>t.fs.resolvePath(e,n)),r=JSON.stringify({counts:n.coverageCounts,maps:n.coverageMaps},null,2),s=n.coverageMod.toLcov(n.coverageCounts,n.coverageMaps),c=n.coverageMod.coverageSummary(n.coverageCounts,n.coverageMaps);try{await t.fs.writeFile(`${e}/coverage.json`,r),await t.fs.writeFile(`${e}/coverage.lcov`,s)}catch(t){a+=`tst: writing coverage to ${e}: ${t instanceof Error?t.message:String(t)}\n`,o=!0}i+=`\n${c}`}return{stdout:i,stderr:a,exitCode:+!!o}})}const pL=[],mL=`usage: theme <subcommand> [args]
3086
3095
 
3087
3096
  Subcommands:
3088
3097
  list List available preset and custom themes
@@ -3091,23 +3100,23 @@ Subcommands:
3091
3100
  reset Reset to the default theme
3092
3101
  current Show the currently active theme
3093
3102
  export <id> <path> Export a theme to a VFS path
3094
- `;function gL(e,t){return{stdout:``,stderr:`theme ${e}: ${t}\n`,exitCode:1}}function _L(){return S(`theme`,async(e,t)=>{if(e.length===0||e[0]===`--help`||e[0]===`-h`)return{stdout:hL,stderr:``,exitCode:0};let n=e[0];return w(e.slice(1),{valueFlags:mL})?{stdout:et(`theme`,n,hL),stderr:``,exitCode:0}:n===`list`?vL(e):n===`current`?yL(e):n===`reset`?bL(e):n===`apply`?xL(e.slice(1),t):n===`export`?SL(e.slice(1),t):{stdout:``,stderr:`theme: unknown subcommand "${n}"\n${hL}`,exitCode:1}})}async function vL(e){let t=C(e.slice(1),{value:mL});if(`error`in t)return gL(`list`,t.error);let{PRESETS:n}=await import(`./theme-presets-xiOb9AFN.js`),r=[`Presets:`];for(let e of n)r.push(` ${e.id.padEnd(16)} ${e.name}`);return r.push(``),{stdout:r.join(`
3095
- `),stderr:``,exitCode:0}}async function yL(e){let t=C(e.slice(1),{value:mL});return`error`in t?gL(`current`,t.error):{stdout:`Check the Theme settings dialog for the active theme.
3096
- `,stderr:``,exitCode:0}}async function bL(e){let t=C(e.slice(1),{value:mL});if(`error`in t)return gL(`reset`,t.error);let n=y();return n?(await n.call(`theme-apply`,{action:`reset`}),{stdout:`Theme reset to default.
3103
+ `;function hL(e,t){return{stdout:``,stderr:`theme ${e}: ${t}\n`,exitCode:1}}function gL(){return S(`theme`,async(e,t)=>{if(e.length===0||e[0]===`--help`||e[0]===`-h`)return{stdout:mL,stderr:``,exitCode:0};let n=e[0];return w(e.slice(1),{valueFlags:pL})?{stdout:et(`theme`,n,mL),stderr:``,exitCode:0}:n===`list`?_L(e):n===`current`?vL(e):n===`reset`?yL(e):n===`apply`?bL(e.slice(1),t):n===`export`?xL(e.slice(1),t):{stdout:``,stderr:`theme: unknown subcommand "${n}"\n${mL}`,exitCode:1}})}async function _L(e){let t=C(e.slice(1),{value:pL});if(`error`in t)return hL(`list`,t.error);let{PRESETS:n}=await import(`./theme-presets-xiOb9AFN.js`),r=[`Presets:`];for(let e of n)r.push(` ${e.id.padEnd(16)} ${e.name}`);return r.push(``),{stdout:r.join(`
3104
+ `),stderr:``,exitCode:0}}async function vL(e){let t=C(e.slice(1),{value:pL});return`error`in t?hL(`current`,t.error):{stdout:`Check the Theme settings dialog for the active theme.
3105
+ `,stderr:``,exitCode:0}}async function yL(e){let t=C(e.slice(1),{value:pL});if(`error`in t)return hL(`reset`,t.error);let n=y();return n?(await n.call(`theme-apply`,{action:`reset`}),{stdout:`Theme reset to default.
3097
3106
  `,stderr:``,exitCode:0}):{stdout:``,stderr:`theme: no panel-RPC connection available
3098
- `,exitCode:1}}async function xL(e,t){let n=C(e,{value:mL});if(`error`in n)return gL(`apply`,n.error);if(n.positionals.length===0)return{stdout:``,stderr:`theme apply: missing theme id or path
3107
+ `,exitCode:1}}async function bL(e,t){let n=C(e,{value:pL});if(`error`in n)return hL(`apply`,n.error);if(n.positionals.length===0)return{stdout:``,stderr:`theme apply: missing theme id or path
3099
3108
  `,exitCode:1};let r=y();if(!r)return{stdout:``,stderr:`theme: no panel-RPC connection available
3100
3109
  `,exitCode:1};let i=n.positionals[0],{PRESETS:a}=await import(`./theme-presets-xiOb9AFN.js`),o=a.find(e=>e.id===i);if(o){let e=JSON.stringify(o);return await r.call(`theme-apply`,{themeJson:e,action:`apply`}),{stdout:`Applied theme: ${o.name}\n`,stderr:``,exitCode:0}}let s=t.fs.resolvePath(t.cwd,i),c;try{c=await t.fs.readFile(s)}catch{return{stdout:``,stderr:`theme apply: "${i}" is not a known preset id and file not found at ${s}\n`,exitCode:1}}try{let e=JSON.parse(c);if(!e.id||!e.name||!e.base||!e.tokens)return{stdout:``,stderr:`theme apply: invalid theme file (missing id, name, base, or tokens)
3101
3110
  `,exitCode:1}}catch{return{stdout:``,stderr:`theme apply: file is not valid JSON
3102
- `,exitCode:1}}return{stdout:`Applied theme: ${(await r.call(`theme-apply`,{themeJson:c,action:`apply`})).applied}\n`,stderr:``,exitCode:0}}async function SL(e,t){let n=C(e,{value:mL});if(`error`in n)return gL(`export`,n.error);if(n.positionals.length<2)return{stdout:``,stderr:`theme export: usage: theme export <id> <path>
3103
- `,exitCode:1};let[r,i]=n.positionals,{PRESETS:a}=await import(`./theme-presets-xiOb9AFN.js`),o=a.find(e=>e.id===r);if(!o)return{stdout:``,stderr:`theme export: unknown preset id "${r}"\n`,exitCode:1};let s=t.fs.resolvePath(t.cwd,i);try{await t.fs.writeFile(s,JSON.stringify(o,null,2))}catch(e){return{stdout:``,stderr:`theme export: write failed: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}return{stdout:`Exported "${o.name}" to ${s}\n`,stderr:``,exitCode:0}}const CL=`unknown`,wL=`usage: uname [-amnorsv]`,TL=[`s`,`n`,`r`,`v`,`m`,`o`];function EL(){return{stdout:[wL,` -s kernel name (SLICC) -n nodename (leader/follower/standalone)`,` -r release (SLICC version) -v build stamp`,` -m machine (realm platform) -o operating system (user agent)`,` -a all of the above, in uname order`,``].join(`
3104
- `),stderr:``,exitCode:0}}function DL(){let{releasedAt:e,buildId:t}=qe();return e?`${t} (${e})`:t}function OL(){let e=globalThis.navigator,t=e?.userAgentData?.platform||e?.platform;return typeof t==`string`&&t.length>0?t:CL}function kL(){let e=globalThis.navigator?.userAgent;return typeof e==`string`&&e.length>0?e:CL}function AL(e){switch(e){case`s`:return`SLICC`;case`n`:return Ke();case`r`:return qe().version;case`v`:return DL();case`m`:return OL();case`o`:return kL()}}function jL(e){return{stdout:``,stderr:`uname: ${e}\n${wL}\n`,exitCode:1}}function ML(e){let t=new Set;for(let n of e){if(!n.startsWith(`-`)||n===`-`)return{error:`extra operand '${n}'`};if(n.startsWith(`--`))return{error:`unrecognized option '${n}'`};for(let e of n.slice(1)){if(e===`a`){for(let e of TL)t.add(e);continue}if(!TL.includes(e))return{error:`unrecognized option '-${e}'`};t.add(e)}}return t}function NL(){return S(`uname`,async e=>{if(e.includes(`--help`)||e.includes(`-h`))return EL();let t=ML(e);return`error`in t?jL(t.error):{stdout:`${(t.size>0?TL.filter(e=>t.has(e)):[`s`]).map(AL).join(` `)}\n`,stderr:``,exitCode:0}})}function PL(){return S(`unlink`,async(e,t)=>{if(e.includes(`--help`))return{stdout:`Usage: unlink FILE
3111
+ `,exitCode:1}}return{stdout:`Applied theme: ${(await r.call(`theme-apply`,{themeJson:c,action:`apply`})).applied}\n`,stderr:``,exitCode:0}}async function xL(e,t){let n=C(e,{value:pL});if(`error`in n)return hL(`export`,n.error);if(n.positionals.length<2)return{stdout:``,stderr:`theme export: usage: theme export <id> <path>
3112
+ `,exitCode:1};let[r,i]=n.positionals,{PRESETS:a}=await import(`./theme-presets-xiOb9AFN.js`),o=a.find(e=>e.id===r);if(!o)return{stdout:``,stderr:`theme export: unknown preset id "${r}"\n`,exitCode:1};let s=t.fs.resolvePath(t.cwd,i);try{await t.fs.writeFile(s,JSON.stringify(o,null,2))}catch(e){return{stdout:``,stderr:`theme export: write failed: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}return{stdout:`Exported "${o.name}" to ${s}\n`,stderr:``,exitCode:0}}const SL=`unknown`,CL=`usage: uname [-amnorsv]`,wL=[`s`,`n`,`r`,`v`,`m`,`o`];function TL(){return{stdout:[CL,` -s kernel name (SLICC) -n nodename (leader/follower/standalone)`,` -r release (SLICC version) -v build stamp`,` -m machine (realm platform) -o operating system (user agent)`,` -a all of the above, in uname order`,``].join(`
3113
+ `),stderr:``,exitCode:0}}function EL(){let{releasedAt:e,buildId:t}=qe();return e?`${t} (${e})`:t}function DL(){let e=globalThis.navigator,t=e?.userAgentData?.platform||e?.platform;return typeof t==`string`&&t.length>0?t:SL}function OL(){let e=globalThis.navigator?.userAgent;return typeof e==`string`&&e.length>0?e:SL}function kL(e){switch(e){case`s`:return`SLICC`;case`n`:return Ke();case`r`:return qe().version;case`v`:return EL();case`m`:return DL();case`o`:return OL()}}function AL(e){return{stdout:``,stderr:`uname: ${e}\n${CL}\n`,exitCode:1}}function jL(e){let t=new Set;for(let n of e){if(!n.startsWith(`-`)||n===`-`)return{error:`extra operand '${n}'`};if(n.startsWith(`--`))return{error:`unrecognized option '${n}'`};for(let e of n.slice(1)){if(e===`a`){for(let e of wL)t.add(e);continue}if(!wL.includes(e))return{error:`unrecognized option '-${e}'`};t.add(e)}}return t}function ML(){return S(`uname`,async e=>{if(e.includes(`--help`)||e.includes(`-h`))return TL();let t=jL(e);return`error`in t?AL(t.error):{stdout:`${(t.size>0?wL.filter(e=>t.has(e)):[`s`]).map(kL).join(` `)}\n`,stderr:``,exitCode:0}})}function NL(){return S(`unlink`,async(e,t)=>{if(e.includes(`--help`))return{stdout:`Usage: unlink FILE
3105
3114
  Remove FILE. Symbolic links are removed without following their target.
3106
3115
  `,stderr:``,exitCode:0};if(e.length!==1||e[0].startsWith(`-`))return{stdout:``,stderr:e.length===0?`unlink: missing operand
3107
3116
  `:`unlink: extra operand
3108
- `,exitCode:1};let n=t.fs.resolvePath(t.cwd,e[0]);try{let r=t.fs.lstat?await t.fs.lstat(n):await t.fs.stat(n);return r.isDirectory&&!r.isSymbolicLink?{stdout:``,stderr:`unlink: cannot unlink '${e[0]}': Is a directory\n`,exitCode:1}:(await t.fs.rm(n,{recursive:!1,force:!1}),{stdout:``,stderr:``,exitCode:0})}catch(t){let n=t instanceof Error?t.message:String(t);return{stdout:``,stderr:`unlink: cannot unlink '${e[0]}': ${n}\n`,exitCode:1}}})}function FL(){return{stdout:`usage: unzip <archive.zip> [-d <destination>]
3109
- `,stderr:``,exitCode:0}}function IL(e){let t=`.`,n=[];for(let r=0;r<e.length;r++){let i=e[r];if(i===`-d`){t=e[r+1]??``,r++;continue}if(i.startsWith(`-`))return{kind:`error`,result:{stdout:``,stderr:`unzip: unsupported option ${i}\n`,exitCode:1}};n.push(i)}return n.length<1?{kind:`error`,result:{stdout:``,stderr:`unzip: expected archive path
3110
- `,exitCode:1}}:{kind:`ok`,archive:n[0],destination:t||`.`}}async function LL(e,t,n,r){let i=n.replace(/\\/g,`/`);if(!i||i.endsWith(`/`))return!1;let a=e.fs.resolvePath(t,i);if(!lr(t,a))return{stdout:``,stderr:`unzip: blocked suspicious path ${n}\n`,exitCode:1};let o=or(a);return o!==`/`&&await e.fs.mkdir(o,{recursive:!0}),await e.fs.writeFile(a,r),!0}function RL(){return S(`unzip`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return FL();let n=IL(e);if(n.kind===`error`)return n.result;let r=t.fs.resolvePath(t.cwd,n.archive),i=t.fs.resolvePath(t.cwd,n.destination);await t.fs.mkdir(i,{recursive:!0});let a=await t.fs.readFileBuffer(r),o=St(a),s=0;for(let[e,n]of Object.entries(o)){let r=await LL(t,i,e,n);if(r===!0)s++;else if(r!==!1)return r}return{stdout:`extracted ${s} file(s) to ${i}\n`,stderr:``,exitCode:0}})}const zL=`ai-ecoverse/slicc`,BL=`usage: upgrade status | upgrade apply --from=<version> --to=<version>`,VL=`packages/vfs-root`,HL=3e4,UL=[`${VL}/workspace/skills/`,`${VL}/shared/sprinkles/`,`${VL}/shared/sounds/`,`${VL}/shared/GELATIERE.md`,`${VL}/shared/wiki/WIKI.md`,`${VL}/etc/`],WL=[`auto-applied`,`merged-clean`,`kept-local`,`needs-review`,`unchanged`,`added-new`];function GL(){return Object.fromEntries(WL.map(e=>[e,0]))}function KL(e,t,n,r){let i=GL();for(let e of n)i[e.classification]+=1;return`${JSON.stringify({ok:r.length===0&&i[`needs-review`]===0,from:e,to:t,results:n.map(({path:e,classification:t,sidecar:n})=>({path:e,status:t,...n?{sidecar:n}:{}})),summary:i,errors:r})}\n`}function qL(e){if(e[0]!==`apply`)throw Error(BL);let t=new Map;for(let n of e.slice(1)){let e=n.match(/^--(from|to)=(.+)$/);if(!e)throw Error(`unsupported argument: ${n}`);t.set(e[1],e[2])}let n=t.get(`from`)??``,r=t.get(`to`)??``,i=/^v?[0-9][0-9A-Za-z.+_-]*$/;if(!i.test(n)||!i.test(r))throw Error(`both --from and --to must be release versions`);return{from:n,to:r}}function JL(e){return e.startsWith(`v`)?e:`v${e}`}function YL(e){if(!UL.some(t=>e.startsWith(t)))return null;let t=e.slice(17);return!t||t.split(`/`).some(e=>e===`.`||e===`..`)?null:t}async function XL(e,t){let n,r;try{n=await Promise.race([e(t,{method:`GET`,headers:{Accept:`application/json`}}),new Promise((e,t)=>{r=setTimeout(()=>t(Error(`request timed out after ${HL}ms`)),HL)})])}catch(e){let n=e instanceof Error?e.message:String(e);throw Error(`fetch failed for ${t}: ${n}`)}finally{r!==void 0&&clearTimeout(r)}if(n.status<200||n.status>=300)throw Error(`fetch failed for ${t}: HTTP ${n.status} ${n.statusText}`);return n}async function ZL(e,t){let n=await XL(t,`https://api.github.com/repos/${zL}/git/trees/${encodeURIComponent(e)}?recursive=1`),r=de(n.body);if(r.truncated)throw Error(`bundled file discovery was truncated for ${e}`);if(!Array.isArray(r.tree))throw Error(`invalid bundled file discovery response for ${e}`);let i=new Map;for(let e of r.tree){if(e.type!==`blob`||typeof e.path!=`string`)continue;let t=YL(e.path);t&&i.set(t,e.path)}return i}function QL(e,t){let n=t.split(`/`).map(encodeURIComponent).join(`/`);return`https://raw.githubusercontent.com/${zL}/${encodeURIComponent(e)}/${n}`}function $L(e,t){return!e||!t||e.byteLength!==t.byteLength?!1:e.every((e,n)=>e===t[n])}function eR(e){try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{return null}}async function tR(e,t){if(!await e.exists(t))return;let n=await e.readFile(t,{encoding:`binary`});return n instanceof Uint8Array?n:new TextEncoder().encode(n)}async function nR(e,t,n,r,i){let a=`${t}.upgrade-${JL(n)}-to-${JL(r)}.conflict`;if(!i.has(a)&&!await e.exists(a))return i.add(a),a;for(let t=1;;t+=1){let n=`${a}.${t}`;if(!i.has(n)&&!await e.exists(n))return i.add(n),n}}async function rR(e,t,n,r,i,a,o){let s=await tR(e.fs,t);if(!a)return{path:t,classification:s?`kept-local`:`unchanged`};if(!i)return s?{path:t,classification:$L(s,a)?`unchanged`:`kept-local`}:{path:t,classification:`added-new`,content:a};if($L(i,a)||$L(s,a))return{path:t,classification:`unchanged`};if(!s)return{path:t,classification:`kept-local`};if($L(s,i))return{path:t,classification:`auto-applied`,content:a};let[c,l,u]=[s,i,a].map(eR);if(c!==null&&l!==null&&u!==null){let i=Ae(c,l,u,{diff3:!0,labels:{current:`local:${t}`,base:`${JL(n)}:${t}`,other:`${JL(r)}:${t}`}}),a=new TextEncoder().encode(i.content);return i.conflicts===0?{path:t,classification:`merged-clean`,content:a}:{path:t,classification:`needs-review`,content:a,sidecar:await nR(e.fs,t,n,r,o)}}return{path:t,classification:`needs-review`,content:a,sidecar:await nR(e.fs,t,n,r,o)}}async function iR(e,t){t.content?await e.writeFile(t.path,t.content):await e.exists(t.path)&&await e.rm(t.path)}async function aR(e,t){let n=t.filter(e=>e.content!==void 0),r=await Promise.all(n.map(async t=>{let n=t.sidecar??t.path;return{path:n,content:await tR(e,n)}})),i=[];for(let t=0;t<n.length;t+=1){let a=n[t],o=r[t];try{await e.writeFile(o.path,a.content),i.push(o)}catch(t){let n=[];for(let t of[o,...i.slice().reverse()])try{await iR(e,t)}catch(e){n.push(`${t.path}: ${e instanceof Error?e.message:String(e)}`)}let r=t instanceof Error?t.message:String(t),a=n.length===0?`all writes rolled back`:`rollback failed (${n.join(`; `)})`;throw Error(`apply failed for ${o.path}: ${r}; ${a}`)}}}async function oR(e,t,n){let r=JL(t),i=JL(n),[a,o]=await Promise.all([ZL(r,e.fetch),ZL(i,e.fetch)]),s=[...new Set([...a.keys(),...o.keys()])].sort(),c=await Promise.all(s.map(async t=>{let[n,s]=await Promise.all([a.has(t)?XL(e.fetch,QL(r,a.get(t))).then(e=>pe(e.body)):void 0,o.has(t)?XL(e.fetch,QL(i,o.get(t))).then(e=>pe(e.body)):void 0]);return{path:t,base:n,theirs:s}})),l=new Set(s),u=[];for(let{path:r,base:i,theirs:a}of c)u.push(await rR(e,r,t,n,i,a,l));return await aR(e.fs,u),u}async function sR(e){let{version:t,releasedAt:n,buildId:r}=qe(),i=[],a=null,o=e.getLastSeen??Je();if(!o)i.push(`last-seen version unavailable: no reader registered in this runtime`);else try{a=await o()}catch(e){i.push(`last-seen version unavailable: ${e instanceof Error?e.message:String(e)}`)}let s=a!==null&&a!==t;return`${JSON.stringify({ok:i.length===0,version:t,releasedAt:n,build:r,lastSeen:a,mergePending:s,...s?{apply:`upgrade apply --from=${a} --to=${t}`}:{},errors:i})}\n`}function cR(e){return S(`upgrade`,async t=>{if(t.includes(`--help`)||t.includes(`-h`))return{stdout:`${BL}\n`,stderr:``,exitCode:0};if(t[0]===`status`)return t.length>1?{stdout:KL(``,``,[],[`unsupported argument: ${t[1]}`]),stderr:``,exitCode:1}:{stdout:await sR(e),stderr:``,exitCode:0};let n=``,r=``;try{({from:n,to:r}=qL(t));let i=await oR(e,n,r),a=i.some(e=>e.classification===`needs-review`);return{stdout:KL(n,r,i,[]),stderr:``,exitCode:+!!a}}catch(e){let t=e instanceof Error?e.message:String(e);return{stdout:KL(n,r,[],[t]),stderr:``,exitCode:1}}})}const lR=`usage: uptime [-p|--pretty] [-s|--since]`,uR=`${lR}
3117
+ `,exitCode:1};let n=t.fs.resolvePath(t.cwd,e[0]);try{let r=t.fs.lstat?await t.fs.lstat(n):await t.fs.stat(n);return r.isDirectory&&!r.isSymbolicLink?{stdout:``,stderr:`unlink: cannot unlink '${e[0]}': Is a directory\n`,exitCode:1}:(await t.fs.rm(n,{recursive:!1,force:!1}),{stdout:``,stderr:``,exitCode:0})}catch(t){let n=t instanceof Error?t.message:String(t);return{stdout:``,stderr:`unlink: cannot unlink '${e[0]}': ${n}\n`,exitCode:1}}})}function PL(){return{stdout:`usage: unzip <archive.zip> [-d <destination>]
3118
+ `,stderr:``,exitCode:0}}function FL(e){let t=`.`,n=[];for(let r=0;r<e.length;r++){let i=e[r];if(i===`-d`){t=e[r+1]??``,r++;continue}if(i.startsWith(`-`))return{kind:`error`,result:{stdout:``,stderr:`unzip: unsupported option ${i}\n`,exitCode:1}};n.push(i)}return n.length<1?{kind:`error`,result:{stdout:``,stderr:`unzip: expected archive path
3119
+ `,exitCode:1}}:{kind:`ok`,archive:n[0],destination:t||`.`}}async function IL(e,t,n,r){let i=n.replace(/\\/g,`/`);if(!i||i.endsWith(`/`))return!1;let a=e.fs.resolvePath(t,i);if(!lr(t,a))return{stdout:``,stderr:`unzip: blocked suspicious path ${n}\n`,exitCode:1};let o=or(a);return o!==`/`&&await e.fs.mkdir(o,{recursive:!0}),await e.fs.writeFile(a,r),!0}function LL(){return S(`unzip`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return PL();let n=FL(e);if(n.kind===`error`)return n.result;let r=t.fs.resolvePath(t.cwd,n.archive),i=t.fs.resolvePath(t.cwd,n.destination);await t.fs.mkdir(i,{recursive:!0});let a=await t.fs.readFileBuffer(r),o=St(a),s=0;for(let[e,n]of Object.entries(o)){let r=await IL(t,i,e,n);if(r===!0)s++;else if(r!==!1)return r}return{stdout:`extracted ${s} file(s) to ${i}\n`,stderr:``,exitCode:0}})}const RL=`ai-ecoverse/slicc`,zL=`usage: upgrade status | upgrade apply --from=<version> --to=<version>`,BL=`packages/vfs-root`,VL=3e4,HL=[`${BL}/workspace/skills/`,`${BL}/shared/sprinkles/`,`${BL}/shared/sounds/`,`${BL}/shared/GELATIERE.md`,`${BL}/shared/wiki/WIKI.md`,`${BL}/etc/`],UL=[`auto-applied`,`merged-clean`,`kept-local`,`needs-review`,`unchanged`,`added-new`];function WL(){return Object.fromEntries(UL.map(e=>[e,0]))}function GL(e,t,n,r){let i=WL();for(let e of n)i[e.classification]+=1;return`${JSON.stringify({ok:r.length===0&&i[`needs-review`]===0,from:e,to:t,results:n.map(({path:e,classification:t,sidecar:n})=>({path:e,status:t,...n?{sidecar:n}:{}})),summary:i,errors:r})}\n`}function KL(e){if(e[0]!==`apply`)throw Error(zL);let t=new Map;for(let n of e.slice(1)){let e=n.match(/^--(from|to)=(.+)$/);if(!e)throw Error(`unsupported argument: ${n}`);t.set(e[1],e[2])}let n=t.get(`from`)??``,r=t.get(`to`)??``,i=/^v?[0-9][0-9A-Za-z.+_-]*$/;if(!i.test(n)||!i.test(r))throw Error(`both --from and --to must be release versions`);return{from:n,to:r}}function qL(e){return e.startsWith(`v`)?e:`v${e}`}function JL(e){if(!HL.some(t=>e.startsWith(t)))return null;let t=e.slice(17);return!t||t.split(`/`).some(e=>e===`.`||e===`..`)?null:t}async function YL(e,t){let n,r;try{n=await Promise.race([e(t,{method:`GET`,headers:{Accept:`application/json`}}),new Promise((e,t)=>{r=setTimeout(()=>t(Error(`request timed out after ${VL}ms`)),VL)})])}catch(e){let n=e instanceof Error?e.message:String(e);throw Error(`fetch failed for ${t}: ${n}`)}finally{r!==void 0&&clearTimeout(r)}if(n.status<200||n.status>=300)throw Error(`fetch failed for ${t}: HTTP ${n.status} ${n.statusText}`);return n}async function XL(e,t){let n=await YL(t,`https://api.github.com/repos/${RL}/git/trees/${encodeURIComponent(e)}?recursive=1`),r=de(n.body);if(r.truncated)throw Error(`bundled file discovery was truncated for ${e}`);if(!Array.isArray(r.tree))throw Error(`invalid bundled file discovery response for ${e}`);let i=new Map;for(let e of r.tree){if(e.type!==`blob`||typeof e.path!=`string`)continue;let t=JL(e.path);t&&i.set(t,e.path)}return i}function ZL(e,t){let n=t.split(`/`).map(encodeURIComponent).join(`/`);return`https://raw.githubusercontent.com/${RL}/${encodeURIComponent(e)}/${n}`}function QL(e,t){return!e||!t||e.byteLength!==t.byteLength?!1:e.every((e,n)=>e===t[n])}function $L(e){try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{return null}}async function eR(e,t){if(!await e.exists(t))return;let n=await e.readFile(t,{encoding:`binary`});return n instanceof Uint8Array?n:new TextEncoder().encode(n)}async function tR(e,t,n,r,i){let a=`${t}.upgrade-${qL(n)}-to-${qL(r)}.conflict`;if(!i.has(a)&&!await e.exists(a))return i.add(a),a;for(let t=1;;t+=1){let n=`${a}.${t}`;if(!i.has(n)&&!await e.exists(n))return i.add(n),n}}async function nR(e,t,n,r,i,a,o){let s=await eR(e.fs,t);if(!a)return{path:t,classification:s?`kept-local`:`unchanged`};if(!i)return s?{path:t,classification:QL(s,a)?`unchanged`:`kept-local`}:{path:t,classification:`added-new`,content:a};if(QL(i,a)||QL(s,a))return{path:t,classification:`unchanged`};if(!s)return{path:t,classification:`kept-local`};if(QL(s,i))return{path:t,classification:`auto-applied`,content:a};let[c,l,u]=[s,i,a].map($L);if(c!==null&&l!==null&&u!==null){let i=Ae(c,l,u,{diff3:!0,labels:{current:`local:${t}`,base:`${qL(n)}:${t}`,other:`${qL(r)}:${t}`}}),a=new TextEncoder().encode(i.content);return i.conflicts===0?{path:t,classification:`merged-clean`,content:a}:{path:t,classification:`needs-review`,content:a,sidecar:await tR(e.fs,t,n,r,o)}}return{path:t,classification:`needs-review`,content:a,sidecar:await tR(e.fs,t,n,r,o)}}async function rR(e,t){t.content?await e.writeFile(t.path,t.content):await e.exists(t.path)&&await e.rm(t.path)}async function iR(e,t){let n=t.filter(e=>e.content!==void 0),r=await Promise.all(n.map(async t=>{let n=t.sidecar??t.path;return{path:n,content:await eR(e,n)}})),i=[];for(let t=0;t<n.length;t+=1){let a=n[t],o=r[t];try{await e.writeFile(o.path,a.content),i.push(o)}catch(t){let n=[];for(let t of[o,...i.slice().reverse()])try{await rR(e,t)}catch(e){n.push(`${t.path}: ${e instanceof Error?e.message:String(e)}`)}let r=t instanceof Error?t.message:String(t),a=n.length===0?`all writes rolled back`:`rollback failed (${n.join(`; `)})`;throw Error(`apply failed for ${o.path}: ${r}; ${a}`)}}}async function aR(e,t,n){let r=qL(t),i=qL(n),[a,o]=await Promise.all([XL(r,e.fetch),XL(i,e.fetch)]),s=[...new Set([...a.keys(),...o.keys()])].sort(),c=await Promise.all(s.map(async t=>{let[n,s]=await Promise.all([a.has(t)?YL(e.fetch,ZL(r,a.get(t))).then(e=>pe(e.body)):void 0,o.has(t)?YL(e.fetch,ZL(i,o.get(t))).then(e=>pe(e.body)):void 0]);return{path:t,base:n,theirs:s}})),l=new Set(s),u=[];for(let{path:r,base:i,theirs:a}of c)u.push(await nR(e,r,t,n,i,a,l));return await iR(e.fs,u),u}async function oR(e){let{version:t,releasedAt:n,buildId:r}=qe(),i=[],a=null,o=e.getLastSeen??Je();if(!o)i.push(`last-seen version unavailable: no reader registered in this runtime`);else try{a=await o()}catch(e){i.push(`last-seen version unavailable: ${e instanceof Error?e.message:String(e)}`)}let s=a!==null&&a!==t;return`${JSON.stringify({ok:i.length===0,version:t,releasedAt:n,build:r,lastSeen:a,mergePending:s,...s?{apply:`upgrade apply --from=${a} --to=${t}`}:{},errors:i})}\n`}function sR(e){return S(`upgrade`,async t=>{if(t.includes(`--help`)||t.includes(`-h`))return{stdout:`${zL}\n`,stderr:``,exitCode:0};if(t[0]===`status`)return t.length>1?{stdout:GL(``,``,[],[`unsupported argument: ${t[1]}`]),stderr:``,exitCode:1}:{stdout:await oR(e),stderr:``,exitCode:0};let n=``,r=``;try{({from:n,to:r}=KL(t));let i=await aR(e,n,r),a=i.some(e=>e.classification===`needs-review`);return{stdout:GL(n,r,i,[]),stderr:``,exitCode:+!!a}}catch(e){let t=e instanceof Error?e.message:String(e);return{stdout:GL(n,r,[],[t]),stderr:``,exitCode:1}}})}const cR=`usage: uptime [-p|--pretty] [-s|--since]`,lR=`${cR}
3111
3120
 
3112
3121
  Print how long this SLICC has been running. The clock starts when the browser
3113
3122
  window was last loaded — a reload is a reboot.
@@ -3123,7 +3132,7 @@ The load average is the average number of live kernel processes over the last
3123
3132
  processes are retained in bounded numbers, so a long burst of short commands
3124
3133
  can under-report the older windows. The user count is always 1: a SLICC
3125
3134
  runtime has one user identity (see \`id\`).
3126
- `,dR=[1,5,15],fR=6e4,pR=60*fR,mR=24*pR;function hR(){let e=globalThis.__slicc_pm;return e instanceof Object&&typeof e.list==`function`?e:null}function gR(e,t,n,r){let i=Math.min(n,Math.max(1,t-r)),a=t-i,o=0;for(let n of e){let e=Math.min(n.finishedAt??t,t);o+=Math.max(0,e-Math.max(n.startedAt,a))}return o/i}function _R(e){let t=Math.max(0,e),n=Math.floor(t/mR),r=Math.floor(t%mR/pR),i=Math.floor(t%pR/fR),a=r>0?`${r}:${String(i).padStart(2,`0`)}`:`${i} min`;return n===0?a:`${n} ${n===1?`day`:`days`}, ${a}`}function vR(e){let t=Math.max(0,e),n=[],r=(e,t)=>{e>0&&n.push(`${e} ${t}${e===1?``:`s`}`)};return r(Math.floor(t/mR),`day`),r(Math.floor(t%mR/pR),`hour`),r(Math.floor(t%pR/fR),`minute`),n.length===0?`up ${Math.floor(t/1e3)} seconds`:`up ${n.join(`, `)}`}function yR(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function bR(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function xR(e,t,n){let r=dR.map(r=>gR(e,t,r*fR,n).toFixed(2));return` ${bR(t)} up ${_R(t-n)}, 1 user, load average: ${r.join(`, `)}\n`}function SR(e){let t=`default`;for(let n of e)switch(n){case`-p`:case`--pretty`:t=`pretty`;break;case`-s`:case`--since`:t=`since`;break;case`-h`:case`--help`:return`help`;case`--version`:return`version`;default:return{error:`unrecognized option '${n}'`}}return t}function CR(e={}){return S(`uptime`,async t=>{let n=SR(t);if(typeof n!=`string`)return{stdout:``,stderr:`uptime: ${n.error}\n${lR}\n`,exitCode:1};if(n===`help`)return{stdout:uR,stderr:``,exitCode:0};if(n===`version`)return{stdout:`uptime (SLICC) ${qe().version}\n`,stderr:``,exitCode:0};let r=e.now?e.now():Date.now(),i=e.bootedAt?e.bootedAt():pa();if(n===`since`)return wR(`${yR(i)}\n`);if(n===`pretty`)return wR(`${vR(r-i)}\n`);let a=e.processManager??hR();return wR(xR(a?a.list():[],r,i))})}function wR(e){return{stdout:e,stderr:``,exitCode:0}}const TR=new Set([`--vid`,`--pid`,`--class`,`--subclass`,`--protocol`,`--serial`,`--request-type`,`--recipient`,`--request`,`--value`,`--index`,`--__resolved`]);function ER(e){return yn(e,TR)}function Y(e,t){let n=/^0x/i.test(e)?parseInt(e,16):parseInt(e,10);if(!Number.isFinite(n)||Number.isNaN(n))throw Error(`invalid ${t}: '${e}'`);return n}function DR(e){let t={};return e.has(`--vid`)&&(t.vendorId=Y(e.get(`--vid`),`vid`)),e.has(`--pid`)&&(t.productId=Y(e.get(`--pid`),`pid`)),e.has(`--class`)&&(t.classCode=Y(e.get(`--class`),`class`)),e.has(`--subclass`)&&(t.subclassCode=Y(e.get(`--subclass`),`subclass`)),e.has(`--protocol`)&&(t.protocolCode=Y(e.get(`--protocol`),`protocol`)),e.has(`--serial`)&&(t.serialNumber=e.get(`--serial`)),Object.keys(t).length>0?[t]:[]}const OR=new Set([`standard`,`class`,`vendor`]),kR=new Set([`device`,`interface`,`endpoint`,`other`]);function AR(e){let t=e.get(`--request-type`)??`vendor`,n=e.get(`--recipient`)??`device`;if(!OR.has(t))throw Error(`invalid --request-type: '${t}'`);if(!kR.has(n))throw Error(`invalid --recipient: '${n}'`);return{requestType:t,recipient:n,request:Y(e.get(`--request`)??`0`,`request`),value:Y(e.get(`--value`)??`0`,`value`),index:Y(e.get(`--index`)??`0`,`index`)}}function jR(e){let t=ti(e.stdin),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e)&255;return n}function MR(e){return Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(` `)}function NR(e){return`0x${e.toString(16).padStart(4,`0`)}`}function PR(e){let t=[e.manufacturerName,e.productName].filter(Boolean).join(` `)||`(unknown)`,n=e.serialNumber?` serial=${e.serialNumber}`:``,r=e.opened?` [open]`:``;return`${e.handle}\t${NR(e.vendorId)}:${NR(e.productId)}\t${t}${n}${r}`}function X(e){return{stdout:e,stderr:``,exitCode:0}}function Z(e){return{stdout:``,stderr:`usb: ${e}\n`,exitCode:1}}const FR=`usb - access USB devices via WebUSB
3135
+ `,uR=[1,5,15],dR=6e4,fR=60*dR,pR=24*fR;function mR(){let e=globalThis.__slicc_pm;return e instanceof Object&&typeof e.list==`function`?e:null}function hR(e,t,n,r){let i=Math.min(n,Math.max(1,t-r)),a=t-i,o=0;for(let n of e){let e=Math.min(n.finishedAt??t,t);o+=Math.max(0,e-Math.max(n.startedAt,a))}return o/i}function gR(e){let t=Math.max(0,e),n=Math.floor(t/pR),r=Math.floor(t%pR/fR),i=Math.floor(t%fR/dR),a=r>0?`${r}:${String(i).padStart(2,`0`)}`:`${i} min`;return n===0?a:`${n} ${n===1?`day`:`days`}, ${a}`}function _R(e){let t=Math.max(0,e),n=[],r=(e,t)=>{e>0&&n.push(`${e} ${t}${e===1?``:`s`}`)};return r(Math.floor(t/pR),`day`),r(Math.floor(t%pR/fR),`hour`),r(Math.floor(t%fR/dR),`minute`),n.length===0?`up ${Math.floor(t/1e3)} seconds`:`up ${n.join(`, `)}`}function vR(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function yR(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function bR(e,t,n){let r=uR.map(r=>hR(e,t,r*dR,n).toFixed(2));return` ${yR(t)} up ${gR(t-n)}, 1 user, load average: ${r.join(`, `)}\n`}function xR(e){let t=`default`;for(let n of e)switch(n){case`-p`:case`--pretty`:t=`pretty`;break;case`-s`:case`--since`:t=`since`;break;case`-h`:case`--help`:return`help`;case`--version`:return`version`;default:return{error:`unrecognized option '${n}'`}}return t}function SR(e={}){return S(`uptime`,async t=>{let n=xR(t);if(typeof n!=`string`)return{stdout:``,stderr:`uptime: ${n.error}\n${cR}\n`,exitCode:1};if(n===`help`)return{stdout:lR,stderr:``,exitCode:0};if(n===`version`)return{stdout:`uptime (SLICC) ${qe().version}\n`,stderr:``,exitCode:0};let r=e.now?e.now():Date.now(),i=e.bootedAt?e.bootedAt():pa();if(n===`since`)return CR(`${vR(i)}\n`);if(n===`pretty`)return CR(`${_R(r-i)}\n`);let a=e.processManager??mR();return CR(bR(a?a.list():[],r,i))})}function CR(e){return{stdout:e,stderr:``,exitCode:0}}const wR=new Set([`--vid`,`--pid`,`--class`,`--subclass`,`--protocol`,`--serial`,`--request-type`,`--recipient`,`--request`,`--value`,`--index`,`--__resolved`]);function TR(e){return yn(e,wR)}function Y(e,t){let n=/^0x/i.test(e)?parseInt(e,16):parseInt(e,10);if(!Number.isFinite(n)||Number.isNaN(n))throw Error(`invalid ${t}: '${e}'`);return n}function ER(e){let t={};return e.has(`--vid`)&&(t.vendorId=Y(e.get(`--vid`),`vid`)),e.has(`--pid`)&&(t.productId=Y(e.get(`--pid`),`pid`)),e.has(`--class`)&&(t.classCode=Y(e.get(`--class`),`class`)),e.has(`--subclass`)&&(t.subclassCode=Y(e.get(`--subclass`),`subclass`)),e.has(`--protocol`)&&(t.protocolCode=Y(e.get(`--protocol`),`protocol`)),e.has(`--serial`)&&(t.serialNumber=e.get(`--serial`)),Object.keys(t).length>0?[t]:[]}const DR=new Set([`standard`,`class`,`vendor`]),OR=new Set([`device`,`interface`,`endpoint`,`other`]);function kR(e){let t=e.get(`--request-type`)??`vendor`,n=e.get(`--recipient`)??`device`;if(!DR.has(t))throw Error(`invalid --request-type: '${t}'`);if(!OR.has(n))throw Error(`invalid --recipient: '${n}'`);return{requestType:t,recipient:n,request:Y(e.get(`--request`)??`0`,`request`),value:Y(e.get(`--value`)??`0`,`value`),index:Y(e.get(`--index`)??`0`,`index`)}}function AR(e){let t=ti(e.stdin),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e)&255;return n}function jR(e){return Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(` `)}function MR(e){return`0x${e.toString(16).padStart(4,`0`)}`}function NR(e){let t=[e.manufacturerName,e.productName].filter(Boolean).join(` `)||`(unknown)`,n=e.serialNumber?` serial=${e.serialNumber}`:``,r=e.opened?` [open]`:``;return`${e.handle}\t${MR(e.vendorId)}:${MR(e.productId)}\t${t}${n}${r}`}function X(e){return{stdout:e,stderr:``,exitCode:0}}function Z(e){return{stdout:``,stderr:`usb: ${e}\n`,exitCode:1}}const PR=`usb - access USB devices via WebUSB
3127
3136
 
3128
3137
  Usage: usb <subcommand> [options]
3129
3138
 
@@ -3162,9 +3171,9 @@ Options:
3162
3171
  -h, --help
3163
3172
 
3164
3173
  Transfers are capped at ${ei} bytes (4 MiB).
3165
- `;function IR(e,t){if(t){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return X(t)}return X(e.length?`${MR(e)}\n`:``)}async function LR(e){let t=await e.list();return t.length===0?X(`no granted USB devices
3166
- `):X(`${t.map(PR).join(`
3167
- `)}\n`)}async function RR(e,t){let n=e.get(`--__resolved`);if(n)return X(`${PR(await t.info(n))}\n`);let r=DR(e),i=Se();if(i){let e=await Cx(`usb-device`,r,i);if(e.handle)return X(`${PR(await t.info(e.handle))}\n`);let n=e.info,a=Qr();if(!a)return Z(`request: WebUSB unavailable for device re-acquire`);let o=(await a.getDevices()).find(e=>e.vendorId===n.vendorId&&e.productId===n.productId&&(!n.serialNumber||e.serialNumber===n.serialNumber));if(!o)return Z(`request: granted device could not be re-acquired`);let s=$r().register(o);return X(`${PR(Zr(s,o))}\n`)}return X(`${PR(await t.request(r))}\n`)}async function zR(e,t,n,r){let i=t[1];if(!i)return Z(`${e}: handle required`);let a=r.has(`--force`);return e===`open`?await n.open(i):e===`close`?await n.close(i,{force:a}):await n.reset(i,{force:a}),X(``)}async function BR(e,t){let[,n,r,i]=e;return!n||r===void 0||i===void 0?Z(`clear-halt: handle, direction and endpoint required`):r!==`in`&&r!==`out`?Z(`clear-halt: direction must be 'in' or 'out', got '${r}'`):(await t.clearHalt(n,r,Y(i,`endpoint`)),X(``))}async function VR(e,t){let[,n,r]=e;return!n||r===void 0?Z(`select-config: handle and value required`):(await t.selectConfig(n,Y(r,`configuration`)),X(``))}async function HR(e,t,n,r){let[,i,a]=t;if(!i||a===void 0)return Z(`${e}: handle and interface required`);let o=Y(a,`interface`);return e===`claim`?await n.claim(i,o,{wait:r.has(`--wait`)}):await n.release(i,o),X(``)}async function UR(e,t,n,r){let[,i,a]=e;if(!i||a===void 0)return Z(`control-in: handle and length required`);let o=Y(a,`length`);return o>4194304?Z(`control-in length exceeds 4 MiB limit`):IR((await n.controlIn(i,AR(t),o)).bytes,r)}async function WR(e,t,n,r){let i=e[1];if(!i)return Z(`control-out: handle required`);let a=jR(t);return a.length>4194304?Z(`control-out payload exceeds 4 MiB limit`):X(`${(await r.controlOut(i,AR(n),a)).bytesWritten} bytes written\n`)}async function GR(e,t,n,r){let[,i,a,o]=e;if(!i||a===void 0||o===void 0)return Z(`transfer-in: handle, endpoint and length required`);let s=Y(o,`length`);return s>4194304?Z(`transfer-in length exceeds 4 MiB limit`):IR((await n.transferIn(i,Y(a,`endpoint`),s)).bytes,r)}async function KR(e,t,n,r){let[,i,a]=e;if(!i||a===void 0)return Z(`transfer-out: handle and endpoint required`);let o=jR(t);return o.length>4194304?Z(`transfer-out payload exceeds 4 MiB limit`):X(`${(await r.transferOut(i,Y(a,`endpoint`),o)).bytesWritten} bytes written\n`)}async function qR(e,t,n){let{positionals:r,flags:i,bools:a}=ER(e),o=r[0],s=a.has(`--raw`);switch(o){case`list`:return LR(n);case`request`:return RR(i,n);case`open`:case`close`:case`reset`:return zR(o,r,n,a);case`clear-halt`:return BR(r,n);case`select-config`:return VR(r,n);case`claim`:case`release`:return HR(o,r,n,a);case`control-in`:return UR(r,i,n,s);case`control-out`:return WR(r,t,i,n);case`transfer-in`:return GR(r,i,n,s);case`transfer-out`:return KR(r,t,i,n);default:return Z(`unknown subcommand '${o??``}'. Try 'usb --help'.`)}}function JR(){return S(`usb`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return X(FR);let n=Nr(ce(),y());if(!n)return Z(`WebUSB is unavailable in this environment`);try{return await qR(e,t,n)}catch(e){let t=e instanceof Error?e.message:String(e);return/cancelled|NotFoundError|No device selected/i.test(t)?Z(`user cancelled or no device selected`):Z(t)}})}const YR=`/workspace/.v86`,XR=`v86 - run an x86 virtual machine (v86 wasm engine)
3174
+ `;function FR(e,t){if(t){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return X(t)}return X(e.length?`${jR(e)}\n`:``)}async function IR(e){let t=await e.list();return t.length===0?X(`no granted USB devices
3175
+ `):X(`${t.map(NR).join(`
3176
+ `)}\n`)}async function LR(e,t){let n=e.get(`--__resolved`);if(n)return X(`${NR(await t.info(n))}\n`);let r=ER(e),i=Se();if(i){let e=await Cx(`usb-device`,r,i);if(e.handle)return X(`${NR(await t.info(e.handle))}\n`);let n=e.info,a=Qr();if(!a)return Z(`request: WebUSB unavailable for device re-acquire`);let o=(await a.getDevices()).find(e=>e.vendorId===n.vendorId&&e.productId===n.productId&&(!n.serialNumber||e.serialNumber===n.serialNumber));if(!o)return Z(`request: granted device could not be re-acquired`);let s=$r().register(o);return X(`${NR(Zr(s,o))}\n`)}return X(`${NR(await t.request(r))}\n`)}async function RR(e,t,n,r){let i=t[1];if(!i)return Z(`${e}: handle required`);let a=r.has(`--force`);return e===`open`?await n.open(i):e===`close`?await n.close(i,{force:a}):await n.reset(i,{force:a}),X(``)}async function zR(e,t){let[,n,r,i]=e;return!n||r===void 0||i===void 0?Z(`clear-halt: handle, direction and endpoint required`):r!==`in`&&r!==`out`?Z(`clear-halt: direction must be 'in' or 'out', got '${r}'`):(await t.clearHalt(n,r,Y(i,`endpoint`)),X(``))}async function BR(e,t){let[,n,r]=e;return!n||r===void 0?Z(`select-config: handle and value required`):(await t.selectConfig(n,Y(r,`configuration`)),X(``))}async function VR(e,t,n,r){let[,i,a]=t;if(!i||a===void 0)return Z(`${e}: handle and interface required`);let o=Y(a,`interface`);return e===`claim`?await n.claim(i,o,{wait:r.has(`--wait`)}):await n.release(i,o),X(``)}async function HR(e,t,n,r){let[,i,a]=e;if(!i||a===void 0)return Z(`control-in: handle and length required`);let o=Y(a,`length`);return o>4194304?Z(`control-in length exceeds 4 MiB limit`):FR((await n.controlIn(i,kR(t),o)).bytes,r)}async function UR(e,t,n,r){let i=e[1];if(!i)return Z(`control-out: handle required`);let a=AR(t);return a.length>4194304?Z(`control-out payload exceeds 4 MiB limit`):X(`${(await r.controlOut(i,kR(n),a)).bytesWritten} bytes written\n`)}async function WR(e,t,n,r){let[,i,a,o]=e;if(!i||a===void 0||o===void 0)return Z(`transfer-in: handle, endpoint and length required`);let s=Y(o,`length`);return s>4194304?Z(`transfer-in length exceeds 4 MiB limit`):FR((await n.transferIn(i,Y(a,`endpoint`),s)).bytes,r)}async function GR(e,t,n,r){let[,i,a]=e;if(!i||a===void 0)return Z(`transfer-out: handle and endpoint required`);let o=AR(t);return o.length>4194304?Z(`transfer-out payload exceeds 4 MiB limit`):X(`${(await r.transferOut(i,Y(a,`endpoint`),o)).bytesWritten} bytes written\n`)}async function KR(e,t,n){let{positionals:r,flags:i,bools:a}=TR(e),o=r[0],s=a.has(`--raw`);switch(o){case`list`:return IR(n);case`request`:return LR(i,n);case`open`:case`close`:case`reset`:return RR(o,r,n,a);case`clear-halt`:return zR(r,n);case`select-config`:return BR(r,n);case`claim`:case`release`:return VR(o,r,n,a);case`control-in`:return HR(r,i,n,s);case`control-out`:return UR(r,t,i,n);case`transfer-in`:return WR(r,i,n,s);case`transfer-out`:return GR(r,t,i,n);default:return Z(`unknown subcommand '${o??``}'. Try 'usb --help'.`)}}function qR(){return S(`usb`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return X(PR);let n=Nr(ce(),y());if(!n)return Z(`WebUSB is unavailable in this environment`);try{return await KR(e,t,n)}catch(e){let t=e instanceof Error?e.message:String(e);return/cancelled|NotFoundError|No device selected/i.test(t)?Z(`user cancelled or no device selected`):Z(t)}})}const JR=`/workspace/.v86`,YR=`v86 - run an x86 virtual machine (v86 wasm engine)
3168
3177
 
3169
3178
  Requires: ${N} v86@${QD}
3170
3179
 
@@ -3200,7 +3209,7 @@ Boot options (QEMU-flavored):
3200
3209
  proxy — no gateway needed, https upstream via the proxy
3201
3210
  -vga <MiB> SVGA/VBE video memory (default 8, max 64) —
3202
3211
  raise for high-res VESA modes (1080p32 needs ~9)
3203
- -bios <path> -vgabios <path> BIOS blobs (default ${YR}/{seabios,vgabios}.bin)
3212
+ -bios <path> -vgabios <path> BIOS blobs (default ${JR}/{seabios,vgabios}.bin)
3204
3213
  -nographic Serial-only guest (skip VGA)
3205
3214
 
3206
3215
  Notes:
@@ -3208,19 +3217,19 @@ Notes:
3208
3217
  (Alpine, FreeDOS, Buildroot Linux) work best.
3209
3218
  - The copy.sh Arch Linux image boots via -state + -fs9p; see the v86 skill.
3210
3219
  - BIOS blobs are not bundled; download once:
3211
- mkdir -p ${YR}
3212
- curl -o ${YR}/seabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/seabios.bin
3213
- curl -o ${YR}/vgabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/vgabios.bin
3214
- `,ZR=`v86: BIOS images not found. Download them once:
3215
- mkdir -p ${YR}
3216
- curl -o ${YR}/seabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/seabios.bin
3217
- curl -o ${YR}/vgabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/vgabios.bin
3218
- or pass -bios / -vgabios with explicit VFS paths.`,QR={"-n":$R,"-name":$R,"--name":$R,"-m":(e,t)=>{let n=Number.parseInt(t,10);return!Number.isFinite(n)||n<=0?`-m requires a positive MiB value`:n>512?`-m ${n} exceeds the 512 MiB cap`:(e.memoryMib=n,null)},"-vga":(e,t)=>{let n=Number.parseInt(t,10);return!Number.isFinite(n)||n<=0?`-vga requires a positive MiB value`:n>64?`-vga ${n} exceeds the 64 MiB cap`:(e.vgaMemoryMib=n,null)},"-cdrom":(e,t)=>ez(e,`cdrom`,t),"-hda":(e,t)=>ez(e,`hda`,t),"-fda":(e,t)=>ez(e,`fda`,t),"-kernel":(e,t)=>ez(e,`kernel`,t),"-initrd":(e,t)=>ez(e,`initrd`,t),"-append":(e,t)=>ez(e,`append`,t),"-bios":(e,t)=>ez(e,`bios`,t),"-vgabios":(e,t)=>ez(e,`vgabios`,t),"-state":(e,t)=>ez(e,`state`,t),"-fs9p":(e,t)=>/^https?:\/\//u.test(t)?(e.fs9p=t,null):`-fs9p requires an http(s) base URL`,"-net":(e,t)=>{let[n,...r]=t.split(`,`);if(n!==`ne2k`&&n!==`virtio`)return`-net requires ne2k or virtio`;for(let t of r){if(t!==`relay=fetch`)return`-net: unknown option '${t}' (only relay=fetch)`;e.netRelay=`fetch`}return e.net=n,null},"-boot":(e,t)=>t!==`a`&&t!==`c`&&t!==`d`?`-boot requires a, c, or d`:(e.boot=t,null)};function $R(e,t){return/^[A-Za-z0-9_-]+$/.test(t)?(e.name=t,null):`invalid VM name '${t}'`}function ez(e,t,n){return e[t]=n,null}const tz=[...Object.keys(QR),`--fps`,`--tail`,`--send`,`--to`];function nz(e){let t={name:`vm0`,memoryMib:128,vgaMemoryMib:8,nographic:!1};for(let n=0;n<e.length;n++){let r=e[n];if(r===`-nographic`){t.nographic=!0;continue}let i=Object.hasOwn(QR,r)?QR[r]:void 0;if(!i)return{ok:!1,error:`unknown option '${r}'`};let a=n+1<e.length?e[n+1]:null;if(a===null)return{ok:!1,error:`${r} requires a value`};let o=i(t,a);if(o)return{ok:!1,error:o};n++}return!t.cdrom&&!t.hda&&!t.fda&&!t.kernel&&!t.state?{ok:!1,error:`no bootable media (-cdrom, -hda, -fda, -kernel, or -state required)`}:{ok:!0,parsed:t}}function rz(e){return{reader:{exists:t=>e.fs.exists(t),isDirectory:async t=>{try{return(await e.fs.stat(t)).isDirectory}catch{return!1}},readFile:t=>e.fs.readFile(t)},readBytes:t=>e.fs.readFileBuffer(t),fromDir:e.cwd}}function Q(e){return{stdout:``,stderr:`v86: ${e}\n`,exitCode:1}}function $(e=``){return{stdout:e,stderr:``,exitCode:0}}function iz(e){let t=[],n=`vm0`;for(let r=0;r<e.length;r++){if(e[r]===`-n`||e[r]===`-name`||e[r]===`--name`){let t=e[r+1];if(t){n=t,r++;continue}}t.push(e[r])}return{name:n,rest:t}}function az(e){return sa(e)||Q(`no VM named '${e}' — boot one with \`v86 start -n ${e} ...\``)}function oz(e){return`exitCode`in e}async function sz(e,t,n){let r=e.fs.resolvePath(e.cwd,t);if(!await e.fs.exists(r))return Q(`${n}: no such file: ${t}`);let i=await e.fs.readFileBuffer(r),a=new ArrayBuffer(i.byteLength);return new Uint8Array(a).set(i),{buffer:a}}const cz={a:801,c:306,d:531};function lz(){let e=globalThis.__slicc_pm;return e instanceof Object&&typeof e.signal==`function`?e:null}function uz(e={}){return S(`v86`,async(t,n)=>{if(t.length===0||t[0]===`--help`||t[0]===`-h`||t[0]===`help`)return $(XR);if(t[0]===`--version`)return dz(n,e);let r=t[0];if(w(t.slice(1),{valueFlags:tz}))return $(et(`v86`,r,XR,{prefix:`v86`}));let i=$e(t.slice(1));try{switch(r){case`start`:return await _z(i,n,e);case`ls`:return yz();case`type`:return await Cz(i,n);case`key`:return await wz(i,n);case`mouse`:return await Ez(i,n);case`screenshot`:return await Dz(i,n);case`text`:return await Oz(i,n);case`serve`:return kz(i);case`serial`:return Az(i);case`state`:return await jz(i,n);case`stop`:return await Mz(i,e);default:return Q(`unknown subcommand '${r}' — see \`v86 --help\``)}}catch(e){return Q(e instanceof Error?e.message:String(e))}})}async function dz(e,t){if(t.loadEngine)return $(`v86 ${(await t.loadEngine(rz(e))).version} (qemu-flavored CLI)\n`);let n=await iO(rz(e));return n?$(`v86 ${n.version} (qemu-flavored CLI)\n`):Q($D)}async function fz(e,t,n){if(e.state&&!e.bios&&!e.vgabios)return null;let r=await sz(t,e.bios??`${YR}/seabios.bin`,`-bios`);if(`exitCode`in r)return e.bios?r:Q(ZR.replace(/^v86: /u,``));if(n.bios=r,e.nographic)return null;let i=await sz(t,e.vgabios??`${YR}/vgabios.bin`,`-vgabios`);return`exitCode`in i?e.vgabios?i:Q(ZR.replace(/^v86: /u,``)):(n.vga_bios=i,null)}async function pz(e,t,n){let r=await fz(e,t,n);if(r)return r;for(let[r,i]of[[`cdrom`,`cdrom`],[`hda`,`hda`],[`fda`,`fda`],[`kernel`,`bzimage`],[`initrd`,`initrd`]]){let a=e[r];if(!a)continue;let o=await sz(t,a,`-${r}`);if(`exitCode`in o)return o;n[i]=o}if(e.append&&(n.cmdline=e.append),e.boot&&(n.boot_order=cz[e.boot]),e.state){let r=await sz(t,e.state,`-state`);if(`exitCode`in r)return r;n.initial_state=r}return e.fs9p&&(n.filesystem={baseurl:e.fs9p}),e.net&&(n.net_device=e.netRelay===`fetch`?{type:e.net,relay_url:`fetch`}:{type:e.net}),null}const mz=6e4;function hz(e){return e.v86?Promise.resolve():new Promise((t,n)=>{let r=setTimeout(()=>n(Error(`engine init timed out after ${mz/1e3}s`)),mz);e.add_listener(`emulator-loaded`,()=>{clearTimeout(r),t()})})}function gz(e,t){let n=e.network_adapter;if(!n||typeof n.fetch!=`function`)return Q(`relay=fetch: engine exposed no fetch-relay network adapter`);let r=t.proxiedFetch??p();return n.fetch=async(e,t)=>{let n=e.replace(/^http:\/\/(?!localhost[:/]|127\.0\.0\.1[:/])/u,`https://`),i={};t?.headers?.forEach((e,t)=>{i[t]=e});let a;if(t?.body){let e=``;for(let n of t.body)e+=String.fromCharCode(n);a=e}let o=await r(n,{method:t?.method,headers:i,body:a}),s=o.body,c=s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength);return{status:o.status,statusText:o.statusText,headers:new Headers(o.headers),redirected:!1,url:o.url,arrayBuffer:async()=>c}},null}async function _z(e,t,n){let r=nz(e);if(!r.ok)return Q(r.error);let i=r.parsed;if(sa(i.name))return Q(`VM '${i.name}' already running — stop it first or pick another -n name`);let a=rz(t),o=n.loadEngine?await n.loadEngine(a):await tO({ipk:a}),s={wasm_fn:oO(o.wasmModule),memory_size:i.memoryMib*1024*1024,vga_memory_size:i.vgaMemoryMib*1024*1024,autostart:!1,disable_speaker:!0,fastboot:!0},c=await pz(i,t,s);if(c)return c;let l=new o.V86(s),u={name:i.name,emulator:l,engineVersion:o.version,pid:null,startedAt:Date.now(),bootArgv:[`v86`,`start`,...e],serial:{buffer:``},screen:{mode:`text`,width:0,height:0,frame:null},serve:null},d=n.processManager??lz();if(d){let e=d.spawn({kind:`net`,argv:u.bootArgv,cwd:t.cwd,owner:{kind:`system`}});u.pid=e.pid,e.abort.signal.addEventListener(`abort`,()=>{vz(u,d)})}oa(u);try{if(await hz(l),i.netRelay===`fetch`){let e=gz(l,n);if(e)return await vz(u,d),e}aa(u),await l.run()}catch(e){return await vz(u,d),Q(`boot failed: ${e instanceof Error?e.message:String(e)}`)}u.onScreenChange=()=>{import(`./registry-DfuJBCKY.js`).then(({getComputerRegistry:e})=>{e()?.refresh(`v86:${u.name}`)})},import(`./v86-DKE8ZbX9.js`).then(({registerV86Computer:e})=>e(u)).catch(()=>{});let f=u.pid===null?``:` (pid ${u.pid})`;return $(`VM '${i.name}' booting in the background${f}.\nDrive it with: v86 text -n ${i.name} | v86 screenshot -n ${i.name} | v86 type -n ${i.name} "..."\n`)}async function vz(e,t){ca(e),ia(e.name),import(`./v86-DKE8ZbX9.js`).then(({unregisterV86Computer:t})=>t(e.name)).catch(()=>{});try{e.emulator.is_running()&&await e.emulator.stop()}catch{}try{await e.emulator.destroy()}catch{}t&&e.pid!==null&&t.exit(e.pid,null)}function yz(){let e=ra();if(e.length===0)return $(`no VMs running
3220
+ mkdir -p ${JR}
3221
+ curl -o ${JR}/seabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/seabios.bin
3222
+ curl -o ${JR}/vgabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/vgabios.bin
3223
+ `,XR=`v86: BIOS images not found. Download them once:
3224
+ mkdir -p ${JR}
3225
+ curl -o ${JR}/seabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/seabios.bin
3226
+ curl -o ${JR}/vgabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/vgabios.bin
3227
+ or pass -bios / -vgabios with explicit VFS paths.`,ZR={"-n":QR,"-name":QR,"--name":QR,"-m":(e,t)=>{let n=Number.parseInt(t,10);return!Number.isFinite(n)||n<=0?`-m requires a positive MiB value`:n>512?`-m ${n} exceeds the 512 MiB cap`:(e.memoryMib=n,null)},"-vga":(e,t)=>{let n=Number.parseInt(t,10);return!Number.isFinite(n)||n<=0?`-vga requires a positive MiB value`:n>64?`-vga ${n} exceeds the 64 MiB cap`:(e.vgaMemoryMib=n,null)},"-cdrom":(e,t)=>$R(e,`cdrom`,t),"-hda":(e,t)=>$R(e,`hda`,t),"-fda":(e,t)=>$R(e,`fda`,t),"-kernel":(e,t)=>$R(e,`kernel`,t),"-initrd":(e,t)=>$R(e,`initrd`,t),"-append":(e,t)=>$R(e,`append`,t),"-bios":(e,t)=>$R(e,`bios`,t),"-vgabios":(e,t)=>$R(e,`vgabios`,t),"-state":(e,t)=>$R(e,`state`,t),"-fs9p":(e,t)=>/^https?:\/\//u.test(t)?(e.fs9p=t,null):`-fs9p requires an http(s) base URL`,"-net":(e,t)=>{let[n,...r]=t.split(`,`);if(n!==`ne2k`&&n!==`virtio`)return`-net requires ne2k or virtio`;for(let t of r){if(t!==`relay=fetch`)return`-net: unknown option '${t}' (only relay=fetch)`;e.netRelay=`fetch`}return e.net=n,null},"-boot":(e,t)=>t!==`a`&&t!==`c`&&t!==`d`?`-boot requires a, c, or d`:(e.boot=t,null)};function QR(e,t){return/^[A-Za-z0-9_-]+$/.test(t)?(e.name=t,null):`invalid VM name '${t}'`}function $R(e,t,n){return e[t]=n,null}const ez=[...Object.keys(ZR),`--fps`,`--tail`,`--send`,`--to`];function tz(e){let t={name:`vm0`,memoryMib:128,vgaMemoryMib:8,nographic:!1};for(let n=0;n<e.length;n++){let r=e[n];if(r===`-nographic`){t.nographic=!0;continue}let i=Object.hasOwn(ZR,r)?ZR[r]:void 0;if(!i)return{ok:!1,error:`unknown option '${r}'`};let a=n+1<e.length?e[n+1]:null;if(a===null)return{ok:!1,error:`${r} requires a value`};let o=i(t,a);if(o)return{ok:!1,error:o};n++}return!t.cdrom&&!t.hda&&!t.fda&&!t.kernel&&!t.state?{ok:!1,error:`no bootable media (-cdrom, -hda, -fda, -kernel, or -state required)`}:{ok:!0,parsed:t}}function nz(e){return{reader:{exists:t=>e.fs.exists(t),isDirectory:async t=>{try{return(await e.fs.stat(t)).isDirectory}catch{return!1}},readFile:t=>e.fs.readFile(t)},readBytes:t=>e.fs.readFileBuffer(t),fromDir:e.cwd}}function Q(e){return{stdout:``,stderr:`v86: ${e}\n`,exitCode:1}}function $(e=``){return{stdout:e,stderr:``,exitCode:0}}function rz(e){let t=[],n=`vm0`;for(let r=0;r<e.length;r++){if(e[r]===`-n`||e[r]===`-name`||e[r]===`--name`){let t=e[r+1];if(t){n=t,r++;continue}}t.push(e[r])}return{name:n,rest:t}}function iz(e){return sa(e)||Q(`no VM named '${e}' — boot one with \`v86 start -n ${e} ...\``)}function az(e){return`exitCode`in e}async function oz(e,t,n){let r=e.fs.resolvePath(e.cwd,t);if(!await e.fs.exists(r))return Q(`${n}: no such file: ${t}`);let i=await e.fs.readFileBuffer(r),a=new ArrayBuffer(i.byteLength);return new Uint8Array(a).set(i),{buffer:a}}const sz={a:801,c:306,d:531};function cz(){let e=globalThis.__slicc_pm;return e instanceof Object&&typeof e.signal==`function`?e:null}function lz(e={}){return S(`v86`,async(t,n)=>{if(t.length===0||t[0]===`--help`||t[0]===`-h`||t[0]===`help`)return $(YR);if(t[0]===`--version`)return uz(n,e);let r=t[0];if(w(t.slice(1),{valueFlags:ez}))return $(et(`v86`,r,YR,{prefix:`v86`}));let i=$e(t.slice(1));try{switch(r){case`start`:return await gz(i,n,e);case`ls`:return vz();case`type`:return await Sz(i,n);case`key`:return await Cz(i,n);case`mouse`:return await Tz(i,n);case`screenshot`:return await Ez(i,n);case`text`:return await Dz(i,n);case`serve`:return Oz(i);case`serial`:return kz(i);case`state`:return await Az(i,n);case`stop`:return await jz(i,e);default:return Q(`unknown subcommand '${r}' — see \`v86 --help\``)}}catch(e){return Q(e instanceof Error?e.message:String(e))}})}async function uz(e,t){if(t.loadEngine)return $(`v86 ${(await t.loadEngine(nz(e))).version} (qemu-flavored CLI)\n`);let n=await iO(nz(e));return n?$(`v86 ${n.version} (qemu-flavored CLI)\n`):Q($D)}async function dz(e,t,n){if(e.state&&!e.bios&&!e.vgabios)return null;let r=await oz(t,e.bios??`${JR}/seabios.bin`,`-bios`);if(`exitCode`in r)return e.bios?r:Q(XR.replace(/^v86: /u,``));if(n.bios=r,e.nographic)return null;let i=await oz(t,e.vgabios??`${JR}/vgabios.bin`,`-vgabios`);return`exitCode`in i?e.vgabios?i:Q(XR.replace(/^v86: /u,``)):(n.vga_bios=i,null)}async function fz(e,t,n){let r=await dz(e,t,n);if(r)return r;for(let[r,i]of[[`cdrom`,`cdrom`],[`hda`,`hda`],[`fda`,`fda`],[`kernel`,`bzimage`],[`initrd`,`initrd`]]){let a=e[r];if(!a)continue;let o=await oz(t,a,`-${r}`);if(`exitCode`in o)return o;n[i]=o}if(e.append&&(n.cmdline=e.append),e.boot&&(n.boot_order=sz[e.boot]),e.state){let r=await oz(t,e.state,`-state`);if(`exitCode`in r)return r;n.initial_state=r}return e.fs9p&&(n.filesystem={baseurl:e.fs9p}),e.net&&(n.net_device=e.netRelay===`fetch`?{type:e.net,relay_url:`fetch`}:{type:e.net}),null}const pz=6e4;function mz(e){return e.v86?Promise.resolve():new Promise((t,n)=>{let r=setTimeout(()=>n(Error(`engine init timed out after ${pz/1e3}s`)),pz);e.add_listener(`emulator-loaded`,()=>{clearTimeout(r),t()})})}function hz(e,t){let n=e.network_adapter;if(!n||typeof n.fetch!=`function`)return Q(`relay=fetch: engine exposed no fetch-relay network adapter`);let r=t.proxiedFetch??p();return n.fetch=async(e,t)=>{let n=e.replace(/^http:\/\/(?!localhost[:/]|127\.0\.0\.1[:/])/u,`https://`),i={};t?.headers?.forEach((e,t)=>{i[t]=e});let a;if(t?.body){let e=``;for(let n of t.body)e+=String.fromCharCode(n);a=e}let o=await r(n,{method:t?.method,headers:i,body:a}),s=o.body,c=s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength);return{status:o.status,statusText:o.statusText,headers:new Headers(o.headers),redirected:!1,url:o.url,arrayBuffer:async()=>c}},null}async function gz(e,t,n){let r=tz(e);if(!r.ok)return Q(r.error);let i=r.parsed;if(sa(i.name))return Q(`VM '${i.name}' already running — stop it first or pick another -n name`);let a=nz(t),o=n.loadEngine?await n.loadEngine(a):await tO({ipk:a}),s={wasm_fn:oO(o.wasmModule),memory_size:i.memoryMib*1024*1024,vga_memory_size:i.vgaMemoryMib*1024*1024,autostart:!1,disable_speaker:!0,fastboot:!0},c=await fz(i,t,s);if(c)return c;let l=new o.V86(s),u={name:i.name,emulator:l,engineVersion:o.version,pid:null,startedAt:Date.now(),bootArgv:[`v86`,`start`,...e],serial:{buffer:``},screen:{mode:`text`,width:0,height:0,frame:null},serve:null},d=n.processManager??cz();if(d){let e=d.spawn({kind:`net`,argv:u.bootArgv,cwd:t.cwd,owner:{kind:`system`}});u.pid=e.pid,e.abort.signal.addEventListener(`abort`,()=>{_z(u,d)})}oa(u);try{if(await mz(l),i.netRelay===`fetch`){let e=hz(l,n);if(e)return await _z(u,d),e}aa(u),await l.run()}catch(e){return await _z(u,d),Q(`boot failed: ${e instanceof Error?e.message:String(e)}`)}u.onScreenChange=()=>{import(`./registry-DfuJBCKY.js`).then(({getComputerRegistry:e})=>{e()?.refresh(`v86:${u.name}`)})},import(`./v86-DKE8ZbX9.js`).then(({registerV86Computer:e})=>e(u)).catch(()=>{});let f=u.pid===null?``:` (pid ${u.pid})`;return $(`VM '${i.name}' booting in the background${f}.\nDrive it with: v86 text -n ${i.name} | v86 screenshot -n ${i.name} | v86 type -n ${i.name} "..."\n`)}async function _z(e,t){ca(e),ia(e.name),import(`./v86-DKE8ZbX9.js`).then(({unregisterV86Computer:t})=>t(e.name)).catch(()=>{});try{e.emulator.is_running()&&await e.emulator.stop()}catch{}try{await e.emulator.destroy()}catch{}t&&e.pid!==null&&t.exit(e.pid,null)}function vz(){let e=ra();if(e.length===0)return $(`no VMs running
3219
3228
  `);let t=[`NAME PID STATE UP BOOT`];for(let n of e){let e=Math.round((Date.now()-n.startedAt)/1e3),r=e>=60?`${Math.floor(e/60)}m${e%60}s`:`${e}s`;t.push(`${n.name.padEnd(10)} ${String(n.pid??`-`).padEnd(6)} ${(n.emulator.is_running()?`running`:`stopped`).padEnd(9)} ${r.padEnd(9)} `+n.bootArgv.slice(2).join(` `))}return $(`${t.join(`
3220
- `)}\n`)}function bz(e,t){return`prefer: computer ${e} -c ${t}\n`}async function xz(e,t,n,r){let i=az(t);if(oz(i))return i;let[{runComputer:a},{getComputerRegistry:o,installComputerRegistry:s},c]=await Promise.all([import(`./run-CK7bQLZ0.js`).then(e=>e.t),import(`./registry-DfuJBCKY.js`),import(`./v86-DKE8ZbX9.js`)]),l=c.v86ComputerId(t),u=o()??s(null);return u.get(l)||c.registerV86Computer(i,u),Sz(await a([`-c`,l,...n],e,{registry:u}),r,l)}function Sz(e,t,n){let r=bz(t,n);return e.exitCode===0?$(`${e.stdout}${r}`):e.stderr.includes(`screenshot failed after input`)?$(`${e.stderr}${r}`):{stdout:e.stdout,stderr:e.stderr.replace(/^computer: /u,`v86: `),exitCode:e.exitCode}}async function Cz(e,t){let{name:n,rest:r}=iz(e);if(r.length===0){let e=az(n);return oz(e)?e:Q(`type: no text supplied`)}return xz(t,n,[`type`,`--`,...r],`type`)}async function wz(e,t){let{name:n,rest:r}=iz(e);if(r.length===0){let e=az(n);return oz(e)?e:Q(`key: no chord supplied`)}return xz(t,n,[`key`,...r],`key`)}const Tz=[`left`,`middle`,`right`];async function Ez(e,t){let{name:n,rest:r}=iz(e),i=az(n);if(oz(i))return i;let a=r.indexOf(`--to`);if(a!==-1){let e=r[a+1],i=e?/^(\d+),(\d+)$/u.exec(e):null;return i?xz(t,n,[`--native`,`mousemove`,i[1],i[2]],`mousemove`):Q(`mouse: --to requires <x>,<y>`)}let o=r[0];if(o===`move`){let e=r[1],i=r[2];return e===void 0||i===void 0||!Number.isFinite(Number(e))||!Number.isFinite(Number(i))?Q(`mouse: move requires <dx> <dy>`):xz(t,n,[`--native`,`mousemove`,e,i,`--relative`],`mousemove`)}if(o===`click`){let e=r[1]??`left`;if(!Tz.includes(e))return Q(`mouse: unknown button '${r[1]}'`);let i=[`click`,e];return r.includes(`--double`)&&i.push(`--repeat`,`2`),xz(t,n,i,`click`)}return Q(`mouse: expected move <dx> <dy>, click [button], or --to <x>,<y>`)}async function Dz(e,t){let{name:n,rest:r}=iz(e);return xz(t,n,[`screenshot`,...r],`screenshot`)}async function Oz(e,t){let{name:n}=iz(e);return xz(t,n,[`text`],`text`)}function kz(e){let{name:t}=iz(e);return $(`v86 serve is retired.\nUse: computer watch -c v86:${t}\nLive frames go to the overlay, lightbox, and bash rows.\n`)}function Az(e){let{name:t,rest:n}=iz(e),r=az(t);if(oz(r))return r;let i=n.indexOf(`--send`);if(i!==-1){let e=n.slice(i+1).join(` `).replace(/\\n/gu,`
3229
+ `)}\n`)}function yz(e,t){return`prefer: computer ${e} -c ${t}\n`}async function bz(e,t,n,r){let i=iz(t);if(az(i))return i;let[{runComputer:a},{getComputerRegistry:o,installComputerRegistry:s},c]=await Promise.all([import(`./run-DthMAupa.js`).then(e=>e.t),import(`./registry-DfuJBCKY.js`),import(`./v86-DKE8ZbX9.js`)]),l=c.v86ComputerId(t),u=o()??s(null);return u.get(l)||c.registerV86Computer(i,u),xz(await a([`-c`,l,...n],e,{registry:u}),r,l)}function xz(e,t,n){let r=yz(t,n);return e.exitCode===0?$(`${e.stdout}${r}`):e.stderr.includes(`screenshot failed after input`)?$(`${e.stderr}${r}`):{stdout:e.stdout,stderr:e.stderr.replace(/^computer: /u,`v86: `),exitCode:e.exitCode}}async function Sz(e,t){let{name:n,rest:r}=rz(e);if(r.length===0){let e=iz(n);return az(e)?e:Q(`type: no text supplied`)}return bz(t,n,[`type`,`--`,...r],`type`)}async function Cz(e,t){let{name:n,rest:r}=rz(e);if(r.length===0){let e=iz(n);return az(e)?e:Q(`key: no chord supplied`)}return bz(t,n,[`key`,...r],`key`)}const wz=[`left`,`middle`,`right`];async function Tz(e,t){let{name:n,rest:r}=rz(e),i=iz(n);if(az(i))return i;let a=r.indexOf(`--to`);if(a!==-1){let e=r[a+1],i=e?/^(\d+),(\d+)$/u.exec(e):null;return i?bz(t,n,[`--native`,`mousemove`,i[1],i[2]],`mousemove`):Q(`mouse: --to requires <x>,<y>`)}let o=r[0];if(o===`move`){let e=r[1],i=r[2];return e===void 0||i===void 0||!Number.isFinite(Number(e))||!Number.isFinite(Number(i))?Q(`mouse: move requires <dx> <dy>`):bz(t,n,[`--native`,`mousemove`,e,i,`--relative`],`mousemove`)}if(o===`click`){let e=r[1]??`left`;if(!wz.includes(e))return Q(`mouse: unknown button '${r[1]}'`);let i=[`click`,e];return r.includes(`--double`)&&i.push(`--repeat`,`2`),bz(t,n,i,`click`)}return Q(`mouse: expected move <dx> <dy>, click [button], or --to <x>,<y>`)}async function Ez(e,t){let{name:n,rest:r}=rz(e);return bz(t,n,[`screenshot`,...r],`screenshot`)}async function Dz(e,t){let{name:n}=rz(e);return bz(t,n,[`text`],`text`)}function Oz(e){let{name:t}=rz(e);return $(`v86 serve is retired.\nUse: computer watch -c v86:${t}\nLive frames go to the overlay, lightbox, and bash rows.\n`)}function kz(e){let{name:t,rest:n}=rz(e),r=iz(t);if(az(r))return r;let i=n.indexOf(`--send`);if(i!==-1){let e=n.slice(i+1).join(` `).replace(/\\n/gu,`
3221
3230
  `);return e?(r.emulator.serial0_send(e),$()):Q(`serial: --send requires text`)}let a=n.indexOf(`--tail`);if(a!==-1){let e=Number.parseInt(n[a+1]??`25`,10);return $(`${r.serial.buffer.split(`
3222
3231
  `).slice(-Math.max(1,e)).join(`
3223
- `)}\n`)}return $(r.serial.buffer?`${r.serial.buffer}\n`:``)}async function jz(e,t){let{name:n,rest:r}=iz(e),i=az(n);if(oz(i))return i;let[a,o]=r;if(a!==`save`&&a!==`load`||!o)return Q(`state: expected save|load <file>`);let s=t.fs.resolvePath(t.cwd,o);if(a===`save`){let e=await i.emulator.save_state();return await t.fs.writeFile(s,new Uint8Array(e)),$(`${s} (${e.byteLength} bytes)\n`)}if(!await t.fs.exists(s))return Q(`state: no such file: ${o}`);let c=await t.fs.readFileBuffer(s),l=new ArrayBuffer(c.byteLength);return new Uint8Array(l).set(c),await i.emulator.restore_state(l),$()}async function Mz(e,t){let{name:n,rest:r}=iz(e),i=az(n);if(oz(i))return i;let a=t.processManager??lz();return r.includes(`--force`)&&a&&i.pid!==null?(a.signal(i.pid,`SIGKILL`),$(`VM '${n}' killed\n`)):(await vz(i,a),$(`VM '${n}' stopped\n`))}const Nz=[`--name`,`--filter`,`--scoop`],Pz={state:`inactive`,session:null};function Fz(){return{stdout:`usage: webhook <command> [options]
3232
+ `)}\n`)}return $(r.serial.buffer?`${r.serial.buffer}\n`:``)}async function Az(e,t){let{name:n,rest:r}=rz(e),i=iz(n);if(az(i))return i;let[a,o]=r;if(a!==`save`&&a!==`load`||!o)return Q(`state: expected save|load <file>`);let s=t.fs.resolvePath(t.cwd,o);if(a===`save`){let e=await i.emulator.save_state();return await t.fs.writeFile(s,new Uint8Array(e)),$(`${s} (${e.byteLength} bytes)\n`)}if(!await t.fs.exists(s))return Q(`state: no such file: ${o}`);let c=await t.fs.readFileBuffer(s),l=new ArrayBuffer(c.byteLength);return new Uint8Array(l).set(c),await i.emulator.restore_state(l),$()}async function jz(e,t){let{name:n,rest:r}=rz(e),i=iz(n);if(az(i))return i;let a=t.processManager??cz();return r.includes(`--force`)&&a&&i.pid!==null?(a.signal(i.pid,`SIGKILL`),$(`VM '${n}' killed\n`)):(await _z(i,a),$(`VM '${n}' stopped\n`))}const Mz=[`--name`,`--filter`,`--scoop`],Nz={state:`inactive`,session:null};function Pz(){return{stdout:`usage: webhook <command> [options]
3224
3233
 
3225
3234
  Commands:
3226
3235
  create [--scoop <name>] [--name <name>] [--filter <code>] Create a new webhook endpoint
@@ -3240,21 +3249,21 @@ Examples:
3240
3249
  webhook create --scoop slack-relay --name slack --filter "(e) => ({ text: e.body.text, user: e.body.user })"
3241
3250
  webhook list
3242
3251
  webhook delete abc123
3243
- `,stderr:``,exitCode:0}}function Iz(e){return e().session?.webhookUrl??null}function Lz(e,t,n){return t?la(t,e):n()?ua(self.location.href,e):`(URL unavailable — connect a leader tray)`}function Rz(e){return{stdout:``,stderr:`webhook ${e}: kernel host has not booted yet — try again in a moment\n`,exitCode:1}}async function zz(e){if(e.length!==1)return{stdout:``,stderr:`webhook rotate: takes no arguments
3252
+ `,stderr:``,exitCode:0}}function Fz(e){return e().session?.webhookUrl??null}function Iz(e,t,n){return t?la(t,e):n()?ua(self.location.href,e):`(URL unavailable — connect a leader tray)`}function Lz(e){return{stdout:``,stderr:`webhook ${e}: kernel host has not booted yet — try again in a moment\n`,exitCode:1}}async function Rz(e){if(e.length!==1)return{stdout:``,stderr:`webhook rotate: takes no arguments
3244
3253
  `,exitCode:1};let t=y();if(!t)return{stdout:``,stderr:`webhook rotate: no leader panel connected
3245
3254
  `,exitCode:1};try{return await t.call(`tray-webhook-rotate`,void 0),{stdout:`Rotated webhook delivery secret. Old URLs no longer work; run webhook list for replacement URLs.
3246
3255
  `,stderr:``,exitCode:0}}catch{return{stdout:``,stderr:`webhook rotate: rotation failed; reconnect the leader and retry
3247
- `,exitCode:1}}}async function Bz(e,t,n){let r=C(e.slice(1),{value:Nz});if(`error`in r)return{stdout:``,stderr:`webhook create: ${r.error}\n`,exitCode:1};let i=r.values.get(`--name`)??`default`,a=r.values.get(`--filter`),o=zi(r.values.get(`--scoop`),n);if(!t.hasLocalNodeServer()&&a)return{stdout:``,stderr:`webhook create: --filter is not supported in extension mode (CSP forbids dynamic eval) — drop --filter, or use standalone CLI mode
3248
- `,exitCode:1};let s=Uz(t);if(s)return s;let c=await ty();if(!c)return Rz(`create`);let l=await ry(c,`webhook create`,r.values.get(`--scoop`));if(l)return{stdout:``,stderr:l,exitCode:1};let u=await c.createWebhook(i,o,a),d=Wz(u.id,t),f=`Created webhook "${u.name}"\nID: ${u.id}\nURL: ${d}\n`;return u.scoop&&(f+=`Scoop: ${u.scoop}\n`),u.filter&&(f+=`Filter: ${u.filter}\n`),{stdout:f,stderr:``,exitCode:0}}async function Vz(e,t){let n=C(e.slice(1),{});if(`error`in n)return{stdout:``,stderr:`webhook list: ${n.error}\n`,exitCode:1};let r=await ty();if(!r)return Rz(`list`);let i=await r.listWebhooks();if(i.length===0)return{stdout:`No active webhooks
3249
- `,stderr:``,exitCode:0};let{trayUrlBase:a,urlResolutionError:o}=Gz(t);return{stdout:Kz(i.map(e=>({id:e.id,name:e.name,url:Lz(e.id,a,t.hasLocalNodeServer),createdAt:e.createdAt,filter:e.filter,scoop:e.scoop})),a,o,t.hasLocalNodeServer),stderr:``,exitCode:0}}async function Hz(e,t){let n=C(e.slice(1),{});if(`error`in n)return{stdout:``,stderr:`webhook delete: ${n.error}\n`,exitCode:1};let r=n.positionals[0];if(n.positionals.length>1)return{stdout:``,stderr:`webhook delete: requires exactly one ID
3256
+ `,exitCode:1}}}async function zz(e,t,n){let r=C(e.slice(1),{value:Mz});if(`error`in r)return{stdout:``,stderr:`webhook create: ${r.error}\n`,exitCode:1};let i=r.values.get(`--name`)??`default`,a=r.values.get(`--filter`),o=zi(r.values.get(`--scoop`),n);if(!t.hasLocalNodeServer()&&a)return{stdout:``,stderr:`webhook create: --filter is not supported in extension mode (CSP forbids dynamic eval) — drop --filter, or use standalone CLI mode
3257
+ `,exitCode:1};let s=Hz(t);if(s)return s;let c=await ty();if(!c)return Lz(`create`);let l=await ry(c,`webhook create`,r.values.get(`--scoop`));if(l)return{stdout:``,stderr:l,exitCode:1};let u=await c.createWebhook(i,o,a),d=Uz(u.id,t),f=`Created webhook "${u.name}"\nID: ${u.id}\nURL: ${d}\n`;return u.scoop&&(f+=`Scoop: ${u.scoop}\n`),u.filter&&(f+=`Filter: ${u.filter}\n`),{stdout:f,stderr:``,exitCode:0}}async function Bz(e,t){let n=C(e.slice(1),{});if(`error`in n)return{stdout:``,stderr:`webhook list: ${n.error}\n`,exitCode:1};let r=await ty();if(!r)return Lz(`list`);let i=await r.listWebhooks();if(i.length===0)return{stdout:`No active webhooks
3258
+ `,stderr:``,exitCode:0};let{trayUrlBase:a,urlResolutionError:o}=Wz(t);return{stdout:Gz(i.map(e=>({id:e.id,name:e.name,url:Iz(e.id,a,t.hasLocalNodeServer),createdAt:e.createdAt,filter:e.filter,scoop:e.scoop})),a,o,t.hasLocalNodeServer),stderr:``,exitCode:0}}async function Vz(e,t){let n=C(e.slice(1),{});if(`error`in n)return{stdout:``,stderr:`webhook delete: ${n.error}\n`,exitCode:1};let r=n.positionals[0];if(n.positionals.length>1)return{stdout:``,stderr:`webhook delete: requires exactly one ID
3250
3259
  `,exitCode:1};if(!r)return{stdout:``,stderr:`webhook delete: requires an ID
3251
- `,exitCode:1};let i=await ty();if(!i)return Rz(`delete`);let a=y();try{if(a){if((await a.call(`tray-webhook-revoke`,{webhookId:r}))?.ok!==!0)throw Error(`revocation not acknowledged`)}else if(t.getLeaderStatus().session?.webhookUrl?.includes(`/wh/`))throw Error(`no leader panel`)}catch{return{stdout:``,stderr:`webhook delete: revocation failed; registration retained, reconnect the leader and retry
3252
- `,exitCode:1}}return await i.deleteWebhook(r)?{stdout:`Deleted webhook "${r}"\n`,stderr:``,exitCode:0}:{stdout:``,stderr:`webhook delete: webhook "${r}" not found\n`,exitCode:1}}function Uz(e){if(e.hasLocalNodeServer())return null;if(!Iz(e.getLeaderStatus)){let t=e.getLeaderStatus().state;return{stdout:``,stderr:(t===`leader`?`webhook create: tray session is not connected yet — wait for the leader to attach`:`webhook create: requires extension-leader mode with a tray worker URL configured (current state: "${t}")`)+`
3253
- `,exitCode:1}}return null}function Wz(e,t){try{return Lz(e,Iz(t.getLeaderStatus),t.hasLocalNodeServer)}catch(e){return`(URL resolution failed: ${e instanceof Error?e.message:String(e)})`}}function Gz(e){try{return{trayUrlBase:Iz(e.getLeaderStatus),urlResolutionError:null}}catch(e){return{trayUrlBase:null,urlResolutionError:e instanceof Error?e.message:String(e)}}}function Kz(e,t,n,r){let i=`Active webhooks:
3260
+ `,exitCode:1};let i=await ty();if(!i)return Lz(`delete`);let a=y();try{if(a){if((await a.call(`tray-webhook-revoke`,{webhookId:r}))?.ok!==!0)throw Error(`revocation not acknowledged`)}else if(t.getLeaderStatus().session?.webhookUrl?.includes(`/wh/`))throw Error(`no leader panel`)}catch{return{stdout:``,stderr:`webhook delete: revocation failed; registration retained, reconnect the leader and retry
3261
+ `,exitCode:1}}return await i.deleteWebhook(r)?{stdout:`Deleted webhook "${r}"\n`,stderr:``,exitCode:0}:{stdout:``,stderr:`webhook delete: webhook "${r}" not found\n`,exitCode:1}}function Hz(e){if(e.hasLocalNodeServer())return null;if(!Fz(e.getLeaderStatus)){let t=e.getLeaderStatus().state;return{stdout:``,stderr:(t===`leader`?`webhook create: tray session is not connected yet — wait for the leader to attach`:`webhook create: requires extension-leader mode with a tray worker URL configured (current state: "${t}")`)+`
3262
+ `,exitCode:1}}return null}function Uz(e,t){try{return Iz(e,Fz(t.getLeaderStatus),t.hasLocalNodeServer)}catch(e){return`(URL resolution failed: ${e instanceof Error?e.message:String(e)})`}}function Wz(e){try{return{trayUrlBase:Fz(e.getLeaderStatus),urlResolutionError:null}}catch(e){return{trayUrlBase:null,urlResolutionError:e instanceof Error?e.message:String(e)}}}function Gz(e,t,n,r){let i=`Active webhooks:
3254
3263
  `;for(let t of e)i+=` ${t.id} ${t.name.padEnd(20)} ${t.url}`,t.scoop&&(i+=` -> ${t.scoop}`),t.filter&&(i+=` [filtered]`),i+=`
3255
3264
  `;return n?i+=`\nNote: webhook URL resolution failed (${n}). Try again once the tray is connected.\n`:!r()&&!t&&(i+=`
3256
3265
  Note: webhook URLs require a leader tray. Configure one in Settings to expose POST endpoints.
3257
- `),i}function qz(e={}){let t={hasLocalNodeServer:e.hasLocalNodeServer??(()=>!0),getLeaderStatus:e.getLeaderStatus??(()=>Pz)};return S(`webhook`,async(e,n)=>{if(e.length===0)return Fz();let r=e[0];if(w(e,{valueFlags:r===`create`?Nz:void 0}))return Fz();try{switch(r){case`create`:return await Bz(e,t,n.env);case`list`:return await Vz(e,t);case`delete`:return await Hz(e,t);case`rotate`:return await zz(e);default:return{stdout:``,stderr:`webhook: unknown command "${r}"\n`,exitCode:1}}}catch(e){let t=e instanceof Error?e.message:String(e);return{stdout:``,stderr:`webhook ${r??`?`}: ${t}\n`,exitCode:1}}})}function Jz(){return{text:!0,binary:!1,oneMessage:!1,noClose:!1,exitOnEof:!1,unidirectional:!1,unidirectionalReverse:!1,insecure:!1,quiet:!1,verbose:0,nullTerminated:!1,base64:!1,jsonrpc:!1,jsonrpcOmit:!1,bufferSize:65536,connTimeoutMs:3e4,customHeaders:[],showHelp:!1}}function Yz(){return{stdout:`usage: websocat [FLAGS] [OPTIONS] <ws://URL | wss://URL>
3266
+ `),i}function Kz(e={}){let t={hasLocalNodeServer:e.hasLocalNodeServer??(()=>!0),getLeaderStatus:e.getLeaderStatus??(()=>Nz)};return S(`webhook`,async(e,n)=>{if(e.length===0)return Pz();let r=e[0];if(w(e,{valueFlags:r===`create`?Mz:void 0}))return Pz();try{switch(r){case`create`:return await zz(e,t,n.env);case`list`:return await Bz(e,t);case`delete`:return await Vz(e,t);case`rotate`:return await Rz(e);default:return{stdout:``,stderr:`webhook: unknown command "${r}"\n`,exitCode:1}}}catch(e){let t=e instanceof Error?e.message:String(e);return{stdout:``,stderr:`webhook ${r??`?`}: ${t}\n`,exitCode:1}}})}function qz(){return{text:!0,binary:!1,oneMessage:!1,noClose:!1,exitOnEof:!1,unidirectional:!1,unidirectionalReverse:!1,insecure:!1,quiet:!1,verbose:0,nullTerminated:!1,base64:!1,jsonrpc:!1,jsonrpcOmit:!1,bufferSize:65536,connTimeoutMs:3e4,customHeaders:[],showHelp:!1}}function Jz(){return{stdout:`usage: websocat [FLAGS] [OPTIONS] <ws://URL | wss://URL>
3258
3267
 
3259
3268
  Minimal websocat client. Sends stdin lines as WebSocket messages and prints
3260
3269
  received messages to stdout. Server mode and advanced specifiers (exec:, tcp:,
@@ -3296,14 +3305,14 @@ EXAMPLES:
3296
3305
  echo 'Page.navigate {"url":"https://example.com"}' \\
3297
3306
  | websocat -1 --jsonrpc --jsonrpc-omit-jsonrpc \\
3298
3307
  ws://127.0.0.1:9222/devtools/page/<id>
3299
- `,stderr:``,exitCode:0}}const Xz=new Set([`-s`,`--server-mode`,`--oneshot`,`--socks5`,`--basic-auth`,`--basic-auth-file`,`--header-to-env`,`--server-header`,`--exec`,`--ws-c-uri`,`--restrict-uri`,`--unlink`,`--strict`,`-S`]);function Zz(e,t,n,r){let i=e[t].indexOf(`=`);if(i!==-1&&e[t].startsWith(n))return{value:e[t].slice(i+1),next:t};let a=e[t+1];return a===void 0?(r.error=`websocat: missing value for ${n}\n`,null):{value:a,next:t+1}}function Qz(e,t,n,r=`positive integer`){let i=Number(t);return!Number.isFinite(i)||i<=0?(e.error=`websocat: ${n} expects ${r}\n`,null):i}function $z(e,t){let n=Number(t);return!Number.isFinite(n)||n<1e3||n>4999?(e.error=`websocat: --close-status-code expects 1000..4999, got '${t}'\n`,null):n}function eB(e,t){let n={"-t":()=>{e.text=!0,e.binary=!1},"--text":()=>{e.text=!0,e.binary=!1},"-b":()=>{e.binary=!0,e.text=!1},"--binary":()=>{e.binary=!0,e.text=!1},"-1n":()=>{e.oneMessage=!0,e.noClose=!0},"-n1":()=>{e.oneMessage=!0,e.noClose=!0},"-1":()=>{e.oneMessage=!0},"--one-message":()=>{e.oneMessage=!0},"-n":()=>{e.noClose=!0},"--no-close":()=>{e.noClose=!0},"-E":()=>{e.exitOnEof=!0},"--exit-on-eof":()=>{e.exitOnEof=!0},"-u":()=>{e.unidirectional=!0},"--unidirectional":()=>{e.unidirectional=!0},"-U":()=>{e.unidirectionalReverse=!0},"--unidirectional-reverse":()=>{e.unidirectionalReverse=!0},"-k":()=>{e.insecure=!0},"--insecure":()=>{e.insecure=!0},"-q":()=>{e.quiet=!0},"-0":()=>{e.nullTerminated=!0},"--null-terminated":()=>{e.nullTerminated=!0},"--base64":()=>{e.base64=!0},"--jsonrpc":()=>{e.jsonrpc=!0},"--jsonrpc-omit-jsonrpc":()=>{e.jsonrpcOmit=!0,e.jsonrpc=!0}}[t];return n?(n(),!0):!1}function tB(e,t){return t===`-v`?(e.verbose+=1,!0):t===`-vv`&&(e.verbose+=2,!0)}function nB(e,t,n,r,i){let a=Zz(t,n,r,e);return a?(i(a.value),{nextIndex:a.next}):{stop:!0}}function rB(e,t,n,r,i,a,o){let s=Zz(t,n,r,e);if(!s)return{stop:!0};let c=Qz(e,s.value,i,o);return c===null?{stop:!0}:(a(c),{nextIndex:s.next})}function iB(e,t){return t.some(t=>e===t||e.startsWith(`${t}=`))}const aB=[(e,t,n,r)=>{if(!iB(r,[`--close-status-code`]))return null;let i=Zz(t,n,`--close-status-code`,e);if(!i)return{stop:!0};let a=$z(e,i.value);return a===null?{stop:!0}:(e.closeStatus=a,{nextIndex:i.next})},(e,t,n,r)=>iB(r,[`--close-reason`])?nB(e,t,n,`--close-reason`,t=>{e.closeReason=t}):null,(e,t,n,r)=>iB(r,[`-B`,`--buffer-size`])?rB(e,t,n,r===`-B`?`-B`:`--buffer-size`,`--buffer-size`,t=>{e.bufferSize=t}):null,(e,t,n,r)=>iB(r,[`--max-messages`])?rB(e,t,n,`--max-messages`,`--max-messages`,t=>{e.maxMessages=t}):null,(e,t,n,r)=>iB(r,[`--protocol`])?nB(e,t,n,`--protocol`,t=>{e.protocol=t}):null,(e,t,n,r)=>{if(!iB(r,[`--ping-interval`]))return null;let i=Zz(t,n,`--ping-interval`,e);return i?(e.pingInterval=Number(i.value),{nextIndex:i.next}):{stop:!0}},(e,t,n,r)=>iB(r,[`--conn-timeout`])?rB(e,t,n,`--conn-timeout`,`--conn-timeout`,t=>{e.connTimeoutMs=Math.round(t*1e3)},`positive seconds`):null,(e,t,n,r)=>iB(r,[`-H`,`--header`])?nB(e,t,n,r===`-H`?`-H`:`--header`,t=>{e.customHeaders.push(t)}):null];function oB(e,t,n,r){for(let i of aB){let a=i(e,t,n,r);if(a)return a}return null}function sB(e){e.closeReason!==void 0&&e.closeStatus===void 0&&(e.error=`websocat: --close-reason requires --close-status-code (the WebSocket close frame cannot carry a reason without a status code)
3300
- `)}function cB(e){let t=Jz();for(let n=0;n<e.length;n+=1){let r=e[n];if(r===`-h`||r===`--help`)return t.showHelp=!0,t;if(Xz.has(r)||Xz.has(r.split(`=`)[0]))return t.error=`websocat: flag '${r}' is not supported in slicc's minimal client\n`,t;if(eB(t,r)||tB(t,r))continue;let i=oB(t,e,n,r);if(i){if(`stop`in i)return t;n=i.nextIndex;continue}if(r.startsWith(`-`))return t.error=`websocat: unknown flag '${r}'\n`,t;if(t.url)return t.error=`websocat: extra positional argument '${r}' — advanced mode is not supported\n`,t;t.url=r}return sB(t),t}function lB(e,t){if(!e)return[];let n=t?`\0`:`
3301
- `,r=e.split(n);return r.length>0&&r[r.length-1]===``&&r.pop(),r}function uB(e,t,n){let r=e.trim();if(!r)return e;let i=r.search(/\s/),a=i===-1?r:r.slice(0,i),o=i===-1?``:r.slice(i+1).trim(),s=[];if(o)try{s=JSON.parse(o)}catch{s=[o]}let c={id:t,method:a,params:s};return n||(c.jsonrpc=`2.0`),JSON.stringify(c)}function dB(e){try{return new TextDecoder(`utf-8`,{fatal:!1}).decode(e)}catch{return t(e)}}function fB(e){if(typeof e==`string`)return{bytes:new TextEncoder().encode(e),isBinary:!1};if(e instanceof ArrayBuffer)return{bytes:new Uint8Array(e),isBinary:!0};if(ArrayBuffer.isView(e)){let t=e;return{bytes:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),isBinary:!0}}return{bytes:new TextEncoder().encode(String(e)),isBinary:!1}}const pB=1e4;function mB(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function hB(){let e=!1,t=mB();return{...t,settle:n=>{e||(e=!0,t.resolve(n))}}}function gB(e,t){return e.length?e.join(t)+t:``}function _B(e){return e.length?e.join(`
3308
+ `,stderr:``,exitCode:0}}const Yz=new Set([`-s`,`--server-mode`,`--oneshot`,`--socks5`,`--basic-auth`,`--basic-auth-file`,`--header-to-env`,`--server-header`,`--exec`,`--ws-c-uri`,`--restrict-uri`,`--unlink`,`--strict`,`-S`]);function Xz(e,t,n,r){let i=e[t].indexOf(`=`);if(i!==-1&&e[t].startsWith(n))return{value:e[t].slice(i+1),next:t};let a=e[t+1];return a===void 0?(r.error=`websocat: missing value for ${n}\n`,null):{value:a,next:t+1}}function Zz(e,t,n,r=`positive integer`){let i=Number(t);return!Number.isFinite(i)||i<=0?(e.error=`websocat: ${n} expects ${r}\n`,null):i}function Qz(e,t){let n=Number(t);return!Number.isFinite(n)||n<1e3||n>4999?(e.error=`websocat: --close-status-code expects 1000..4999, got '${t}'\n`,null):n}function $z(e,t){let n={"-t":()=>{e.text=!0,e.binary=!1},"--text":()=>{e.text=!0,e.binary=!1},"-b":()=>{e.binary=!0,e.text=!1},"--binary":()=>{e.binary=!0,e.text=!1},"-1n":()=>{e.oneMessage=!0,e.noClose=!0},"-n1":()=>{e.oneMessage=!0,e.noClose=!0},"-1":()=>{e.oneMessage=!0},"--one-message":()=>{e.oneMessage=!0},"-n":()=>{e.noClose=!0},"--no-close":()=>{e.noClose=!0},"-E":()=>{e.exitOnEof=!0},"--exit-on-eof":()=>{e.exitOnEof=!0},"-u":()=>{e.unidirectional=!0},"--unidirectional":()=>{e.unidirectional=!0},"-U":()=>{e.unidirectionalReverse=!0},"--unidirectional-reverse":()=>{e.unidirectionalReverse=!0},"-k":()=>{e.insecure=!0},"--insecure":()=>{e.insecure=!0},"-q":()=>{e.quiet=!0},"-0":()=>{e.nullTerminated=!0},"--null-terminated":()=>{e.nullTerminated=!0},"--base64":()=>{e.base64=!0},"--jsonrpc":()=>{e.jsonrpc=!0},"--jsonrpc-omit-jsonrpc":()=>{e.jsonrpcOmit=!0,e.jsonrpc=!0}}[t];return n?(n(),!0):!1}function eB(e,t){return t===`-v`?(e.verbose+=1,!0):t===`-vv`&&(e.verbose+=2,!0)}function tB(e,t,n,r,i){let a=Xz(t,n,r,e);return a?(i(a.value),{nextIndex:a.next}):{stop:!0}}function nB(e,t,n,r,i,a,o){let s=Xz(t,n,r,e);if(!s)return{stop:!0};let c=Zz(e,s.value,i,o);return c===null?{stop:!0}:(a(c),{nextIndex:s.next})}function rB(e,t){return t.some(t=>e===t||e.startsWith(`${t}=`))}const iB=[(e,t,n,r)=>{if(!rB(r,[`--close-status-code`]))return null;let i=Xz(t,n,`--close-status-code`,e);if(!i)return{stop:!0};let a=Qz(e,i.value);return a===null?{stop:!0}:(e.closeStatus=a,{nextIndex:i.next})},(e,t,n,r)=>rB(r,[`--close-reason`])?tB(e,t,n,`--close-reason`,t=>{e.closeReason=t}):null,(e,t,n,r)=>rB(r,[`-B`,`--buffer-size`])?nB(e,t,n,r===`-B`?`-B`:`--buffer-size`,`--buffer-size`,t=>{e.bufferSize=t}):null,(e,t,n,r)=>rB(r,[`--max-messages`])?nB(e,t,n,`--max-messages`,`--max-messages`,t=>{e.maxMessages=t}):null,(e,t,n,r)=>rB(r,[`--protocol`])?tB(e,t,n,`--protocol`,t=>{e.protocol=t}):null,(e,t,n,r)=>{if(!rB(r,[`--ping-interval`]))return null;let i=Xz(t,n,`--ping-interval`,e);return i?(e.pingInterval=Number(i.value),{nextIndex:i.next}):{stop:!0}},(e,t,n,r)=>rB(r,[`--conn-timeout`])?nB(e,t,n,`--conn-timeout`,`--conn-timeout`,t=>{e.connTimeoutMs=Math.round(t*1e3)},`positive seconds`):null,(e,t,n,r)=>rB(r,[`-H`,`--header`])?tB(e,t,n,r===`-H`?`-H`:`--header`,t=>{e.customHeaders.push(t)}):null];function aB(e,t,n,r){for(let i of iB){let a=i(e,t,n,r);if(a)return a}return null}function oB(e){e.closeReason!==void 0&&e.closeStatus===void 0&&(e.error=`websocat: --close-reason requires --close-status-code (the WebSocket close frame cannot carry a reason without a status code)
3309
+ `)}function sB(e){let t=qz();for(let n=0;n<e.length;n+=1){let r=e[n];if(r===`-h`||r===`--help`)return t.showHelp=!0,t;if(Yz.has(r)||Yz.has(r.split(`=`)[0]))return t.error=`websocat: flag '${r}' is not supported in slicc's minimal client\n`,t;if($z(t,r)||eB(t,r))continue;let i=aB(t,e,n,r);if(i){if(`stop`in i)return t;n=i.nextIndex;continue}if(r.startsWith(`-`))return t.error=`websocat: unknown flag '${r}'\n`,t;if(t.url)return t.error=`websocat: extra positional argument '${r}' — advanced mode is not supported\n`,t;t.url=r}return oB(t),t}function cB(e,t){if(!e)return[];let n=t?`\0`:`
3310
+ `,r=e.split(n);return r.length>0&&r[r.length-1]===``&&r.pop(),r}function lB(e,t,n){let r=e.trim();if(!r)return e;let i=r.search(/\s/),a=i===-1?r:r.slice(0,i),o=i===-1?``:r.slice(i+1).trim(),s=[];if(o)try{s=JSON.parse(o)}catch{s=[o]}let c={id:t,method:a,params:s};return n||(c.jsonrpc=`2.0`),JSON.stringify(c)}function uB(e){try{return new TextDecoder(`utf-8`,{fatal:!1}).decode(e)}catch{return t(e)}}function dB(e){if(typeof e==`string`)return{bytes:new TextEncoder().encode(e),isBinary:!1};if(e instanceof ArrayBuffer)return{bytes:new Uint8Array(e),isBinary:!0};if(ArrayBuffer.isView(e)){let t=e;return{bytes:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),isBinary:!0}}return{bytes:new TextEncoder().encode(String(e)),isBinary:!1}}const fB=1e4;function pB(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function mB(){let e=!1,t=pB();return{...t,settle:n=>{e||(e=!0,t.resolve(n))}}}function hB(e,t){return e.length?e.join(t)+t:``}function gB(e){return e.length?e.join(`
3302
3311
  `)+`
3303
- `:``}function vB(e,t,n){e.quiet||t.push(`websocat: ${n}`)}function yB(e,t){e.verbose<1||(e.customHeaders.length>0&&vB(e,t,`-H/--header is accepted for parity but browsers do not allow setting WebSocket request headers; only --protocol is honored`),e.pingInterval!==void 0&&vB(e,t,`--ping-interval has no effect in browsers (no ping API exposed)`),e.insecure&&vB(e,t,`-k/--insecure has no effect in browsers`))}function bB(e,t){try{let n=t.protocol?new e(t.url,t.protocol):new e(t.url);return n.binaryType=`arraybuffer`,{ws:n}}catch(e){return{error:`websocat: connect failed: ${e instanceof Error?e.message:String(e)}\n`}}}function xB(e,t,n,r){if(n.outLines.length<pB){n.outLines.push(r);return}n.droppedForOverflow===0&&vB(e,t,`output buffer reached ${pB} messages; dropping further inbound messages — use -1, --max-messages, or pipe to a file with a different tool for long-running streams`),n.droppedForOverflow+=1}function SB(e,n,r){let{bytes:i,isBinary:a}=fB(r);return i.length>e.bufferSize&&(vB(e,n,`inbound message of ${i.length} bytes exceeds --buffer-size ${e.bufferSize}; truncating`),i=i.slice(0,e.bufferSize)),a&&e.base64?t(i):dB(i)}function CB(e,t){return e.maxMessages!==void 0&&t>=e.maxMessages||e.oneMessage}function wB(e,t,n){try{n===void 0?e.close(t):e.close(t,n)}catch{}}function TB(e,t){setTimeout(()=>{wB(t,e.closeStatus??1e3,e.closeReason)},0)}function EB(e,t,n){let r=lB(n,t.nullTerminated),i=1,a=0,o=t.oneMessage?r.slice(0,1):r;for(let n of o){let r=n;t.jsonrpc&&(r=uB(n,i,t.jsonrpcOmit),i+=1),t.binary?e.send(new TextEncoder().encode(r).buffer):e.send(r),a+=1}return a}function DB(e,t,n){!t.oneMessage&&!t.noClose&&(t.exitOnEof||n===0)&&TB(t,e)}async function OB(e,t,n){let r=[];yB(e,r);let i=e.nullTerminated?`\0`:`
3304
- `,a=bB(n,e);if(`error`in a)return{stdout:``,stderr:a.error,exitCode:1};let{ws:o}=a,s={outLines:[],droppedForOverflow:0,received:0,finishing:!1},c=!1,l=mB(),u=hB(),d=0,f=!1,p=setTimeout(()=>{f=!0,wB(o,1e3),c||l.reject(Error(`connect timeout`))},e.connTimeoutMs),m=()=>{if(e.noClose){u.settle(d);return}wB(o,e.closeStatus??1e3,e.closeReason)};o.onopen=()=>{clearTimeout(p),c=!0,l.resolve()},o.onmessage=t=>{if(!s.finishing){if(!e.unidirectional){let n=SB(e,r,t.data);xB(e,r,s,n)}s.received+=1,CB(e,s.received)&&(s.finishing=!0,m())}},o.onerror=()=>{f||(vB(e,r,`websocket error`),d=1,c||l.reject(Error(`connect failed`)))},o.onclose=t=>{if(clearTimeout(p),f){u.settle(124);return}e.verbose>=1&&vB(e,r,`closed code=${t.code} reason=${JSON.stringify(t.reason||``)}`),d===0&&t.code!==1e3&&t.code!==1005&&t.code!==1001&&(d=1),c||l.reject(Error(`connect closed (code ${t.code})`)),u.settle(d)};try{await l.promise}catch(e){clearTimeout(p);let t=e instanceof Error?e.message:String(e);return{stdout:gB(s.outLines,i),stderr:_B(r.concat([`websocat: ${t}`])),exitCode:t===`connect timeout`?124:1}}e.unidirectionalReverse?!e.noClose&&e.exitOnEof&&!e.oneMessage&&TB(e,o):DB(o,e,EB(o,e,t));let h=await u.promise;return s.droppedForOverflow>0&&vB(e,r,`dropped ${s.droppedForOverflow} inbound message(s) due to output buffer cap`),{stdout:gB(s.outLines,i),stderr:_B(r),exitCode:h}}function kB(e){return{stdout:``,stderr:e,exitCode:2}}function AB(e){return e.WebSocketCtor??(typeof WebSocket<`u`?WebSocket:void 0)}async function jB(e,t,n={}){let r=cB(e);if(r.showHelp)return Yz();if(r.error)return kB(r.error);if(!r.url)return kB(`websocat: missing ws:// or wss:// URL (use --help for usage)
3305
- `);if(!/^wss?:\/\//i.test(r.url))return kB(`websocat: URL must start with ws:// or wss://, got '${r.url}'\n`);let i=AB(n);return i?OB(r,t.stdin,i):{stdout:``,stderr:`websocat: no WebSocket implementation available in this runtime
3306
- `,exitCode:1}}function MB(){return S(`websocat`,async(e,t)=>jB(e,{stdin:P(t.stdin)}))}function NB(){return S(`__wf_progress`,async()=>({stdout:``,stderr:``,exitCode:0}))}const PB={commands:new Map,collisions:[]};async function FB(e,t){let n=Hn(t);return e.scriptCatalog?e.scriptCatalog.getJshIndex(n):e.fs?Gn(e.fs,n):PB}async function IB(e){return e.scriptCatalog?e.scriptCatalog.getWorkflowCommands():e.fs?ii(e.fs):new Map}function LB(e,t,n,r,i,a,o){if(i.has(e)){let i=[`/usr/bin/${e}`];if((t||r)&&i.push(` (shadowed by built-in ${e})`),t){let e=n?[t,...n.shadowedPaths]:[t];for(let t of e)i.push(` (shadowed ${t})`)}return{lines:i,found:!0}}if(t){let e=[t];if(n)for(let t of n.shadowedPaths)e.push(` (shadowed ${t})`);return r&&e.push(` ${r.path} (workflow, shadowed by .jsh)`),{lines:e,found:!0}}return r?{lines:[`${r.path} (workflow)`],found:!0}:a.has(e)&&!o.has(e)?{lines:[`/usr/bin/${e}`],found:!0}:{lines:[],found:!1}}function RB(e={}){let t=e.scriptCatalog!==void 0||e.fs!==void 0?e:typeof e.walk==`function`&&typeof e.exists==`function`?{fs:e}:{};return S(`which`,async(e,n)=>{if(w(e))return{stdout:`which - locate a command
3312
+ `:``}function _B(e,t,n){e.quiet||t.push(`websocat: ${n}`)}function vB(e,t){e.verbose<1||(e.customHeaders.length>0&&_B(e,t,`-H/--header is accepted for parity but browsers do not allow setting WebSocket request headers; only --protocol is honored`),e.pingInterval!==void 0&&_B(e,t,`--ping-interval has no effect in browsers (no ping API exposed)`),e.insecure&&_B(e,t,`-k/--insecure has no effect in browsers`))}function yB(e,t){try{let n=t.protocol?new e(t.url,t.protocol):new e(t.url);return n.binaryType=`arraybuffer`,{ws:n}}catch(e){return{error:`websocat: connect failed: ${e instanceof Error?e.message:String(e)}\n`}}}function bB(e,t,n,r){if(n.outLines.length<fB){n.outLines.push(r);return}n.droppedForOverflow===0&&_B(e,t,`output buffer reached ${fB} messages; dropping further inbound messages — use -1, --max-messages, or pipe to a file with a different tool for long-running streams`),n.droppedForOverflow+=1}function xB(e,n,r){let{bytes:i,isBinary:a}=dB(r);return i.length>e.bufferSize&&(_B(e,n,`inbound message of ${i.length} bytes exceeds --buffer-size ${e.bufferSize}; truncating`),i=i.slice(0,e.bufferSize)),a&&e.base64?t(i):uB(i)}function SB(e,t){return e.maxMessages!==void 0&&t>=e.maxMessages||e.oneMessage}function CB(e,t,n){try{n===void 0?e.close(t):e.close(t,n)}catch{}}function wB(e,t){setTimeout(()=>{CB(t,e.closeStatus??1e3,e.closeReason)},0)}function TB(e,t,n){let r=cB(n,t.nullTerminated),i=1,a=0,o=t.oneMessage?r.slice(0,1):r;for(let n of o){let r=n;t.jsonrpc&&(r=lB(n,i,t.jsonrpcOmit),i+=1),t.binary?e.send(new TextEncoder().encode(r).buffer):e.send(r),a+=1}return a}function EB(e,t,n){!t.oneMessage&&!t.noClose&&(t.exitOnEof||n===0)&&wB(t,e)}async function DB(e,t,n){let r=[];vB(e,r);let i=e.nullTerminated?`\0`:`
3313
+ `,a=yB(n,e);if(`error`in a)return{stdout:``,stderr:a.error,exitCode:1};let{ws:o}=a,s={outLines:[],droppedForOverflow:0,received:0,finishing:!1},c=!1,l=pB(),u=mB(),d=0,f=!1,p=setTimeout(()=>{f=!0,CB(o,1e3),c||l.reject(Error(`connect timeout`))},e.connTimeoutMs),m=()=>{if(e.noClose){u.settle(d);return}CB(o,e.closeStatus??1e3,e.closeReason)};o.onopen=()=>{clearTimeout(p),c=!0,l.resolve()},o.onmessage=t=>{if(!s.finishing){if(!e.unidirectional){let n=xB(e,r,t.data);bB(e,r,s,n)}s.received+=1,SB(e,s.received)&&(s.finishing=!0,m())}},o.onerror=()=>{f||(_B(e,r,`websocket error`),d=1,c||l.reject(Error(`connect failed`)))},o.onclose=t=>{if(clearTimeout(p),f){u.settle(124);return}e.verbose>=1&&_B(e,r,`closed code=${t.code} reason=${JSON.stringify(t.reason||``)}`),d===0&&t.code!==1e3&&t.code!==1005&&t.code!==1001&&(d=1),c||l.reject(Error(`connect closed (code ${t.code})`)),u.settle(d)};try{await l.promise}catch(e){clearTimeout(p);let t=e instanceof Error?e.message:String(e);return{stdout:hB(s.outLines,i),stderr:gB(r.concat([`websocat: ${t}`])),exitCode:t===`connect timeout`?124:1}}e.unidirectionalReverse?!e.noClose&&e.exitOnEof&&!e.oneMessage&&wB(e,o):EB(o,e,TB(o,e,t));let h=await u.promise;return s.droppedForOverflow>0&&_B(e,r,`dropped ${s.droppedForOverflow} inbound message(s) due to output buffer cap`),{stdout:hB(s.outLines,i),stderr:gB(r),exitCode:h}}function OB(e){return{stdout:``,stderr:e,exitCode:2}}function kB(e){return e.WebSocketCtor??(typeof WebSocket<`u`?WebSocket:void 0)}async function AB(e,t,n={}){let r=sB(e);if(r.showHelp)return Jz();if(r.error)return OB(r.error);if(!r.url)return OB(`websocat: missing ws:// or wss:// URL (use --help for usage)
3314
+ `);if(!/^wss?:\/\//i.test(r.url))return OB(`websocat: URL must start with ws:// or wss://, got '${r.url}'\n`);let i=kB(n);return i?DB(r,t.stdin,i):{stdout:``,stderr:`websocat: no WebSocket implementation available in this runtime
3315
+ `,exitCode:1}}function jB(){return S(`websocat`,async(e,t)=>AB(e,{stdin:P(t.stdin)}))}function MB(){return S(`__wf_progress`,async()=>({stdout:``,stderr:``,exitCode:0}))}const NB={commands:new Map,collisions:[]};async function PB(e,t){let n=Hn(t);return e.scriptCatalog?e.scriptCatalog.getJshIndex(n):e.fs?Gn(e.fs,n):NB}async function FB(e){return e.scriptCatalog?e.scriptCatalog.getWorkflowCommands():e.fs?ii(e.fs):new Map}function IB(e,t,n,r,i,a,o){if(i.has(e)){let i=[`/usr/bin/${e}`];if((t||r)&&i.push(` (shadowed by built-in ${e})`),t){let e=n?[t,...n.shadowedPaths]:[t];for(let t of e)i.push(` (shadowed ${t})`)}return{lines:i,found:!0}}if(t){let e=[t];if(n)for(let t of n.shadowedPaths)e.push(` (shadowed ${t})`);return r&&e.push(` ${r.path} (workflow, shadowed by .jsh)`),{lines:e,found:!0}}return r?{lines:[`${r.path} (workflow)`],found:!0}:a.has(e)&&!o.has(e)?{lines:[`/usr/bin/${e}`],found:!0}:{lines:[],found:!1}}function LB(e={}){let t=e.scriptCatalog!==void 0||e.fs!==void 0?e:typeof e.walk==`function`&&typeof e.exists==`function`?{fs:e}:{};return S(`which`,async(e,n)=>{if(w(e))return{stdout:`which - locate a command
3307
3316
 
3308
3317
  Usage: which <command> [command...]
3309
3318
 
@@ -3314,9 +3323,9 @@ Prints the path of the given command(s).
3314
3323
 
3315
3324
  Exit code 0 if all commands found, 1 if any not found.
3316
3325
  `,stderr:``,exitCode:0};let r=C(e,{});if(`error`in r)return{stdout:``,stderr:`which: ${r.error}\n`,exitCode:1};if(r.positionals.length===0)return{stdout:``,stderr:`which: missing argument
3317
- `,exitCode:1};let i=n.getRegisteredCommands?.()??[],a=new Set(i),o=await FB(t,n.env.get(`PATH`)),s=o.commands,c=new Map(o.collisions.map(e=>[e.name,e])),l=await IB(t),u=typeof t.getStaticBuiltins==`function`?new Set(t.getStaticBuiltins()):a,d=new Set(t.getScriptRegisteredNames?.()??[]),f=[],p=!0;for(let e of r.positionals){let t=s.get(e),n=l.get(e),r=LB(e,t,c.get(e),n,u,a,d);f.push(...r.lines),r.found||(p=!1)}return{stdout:f.length>0?f.join(`
3326
+ `,exitCode:1};let i=n.getRegisteredCommands?.()??[],a=new Set(i),o=await PB(t,n.env.get(`PATH`)),s=o.commands,c=new Map(o.collisions.map(e=>[e.name,e])),l=await FB(t),u=typeof t.getStaticBuiltins==`function`?new Set(t.getStaticBuiltins()):a,d=new Set(t.getScriptRegisteredNames?.()??[]),f=[],p=!0;for(let e of r.positionals){let t=s.get(e),n=l.get(e),r=IB(e,t,c.get(e),n,u,a,d);f.push(...r.lines),r.found||(p=!1)}return{stdout:f.length>0?f.join(`
3318
3327
  `)+`
3319
- `:``,stderr:``,exitCode:+!p}})}const zB=`__slicc_workflows`,BB=String.raw`
3328
+ `:``,stderr:``,exitCode:+!p}})}const RB=`__slicc_workflows`,zB=String.raw`
3320
3329
  class WorkflowError extends Error {}
3321
3330
  class WorkflowDeterminismError extends WorkflowError {}
3322
3331
  class WorkflowAgentCapError extends WorkflowError {}
@@ -3429,40 +3438,40 @@ function log(message) {
3429
3438
  }
3430
3439
  const budget = { total: (__WF.budget == null ? null : __WF.budget), spent() { return 0; }, remaining() { return this.total == null ? Infinity : Math.max(0, this.total - this.spent()); } };
3431
3440
  function workflow() { throw new WorkflowNestingUnsupportedError('nested workflow() unsupported in SP1'); }
3432
- `;function VB(){return`WF_RESULT_${globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`}`}function HB(e){let t=KB(e);return t===null?{name:null,description:null}:{name:qB(t,`name`),description:qB(t,`description`)}}function UB(e){return e.replace(/\bexport\s+(const|let|var|function|async\s+function|class)\b/g,`$1`)}function WB(e){return`const __emit = console.log.bind(console);
3441
+ `;function BB(){return`WF_RESULT_${globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`}`}function VB(e){let t=GB(e);return t===null?{name:null,description:null}:{name:KB(t,`name`),description:KB(t,`description`)}}function HB(e){return e.replace(/\bexport\s+(const|let|var|function|async\s+function|class)\b/g,`$1`)}function UB(e){return`const __emit = console.log.bind(console);
3433
3442
  const __stringify = JSON.stringify.bind(JSON);
3434
- const __WF = ${JSON.stringify(e.config)};\n${e.prelude}\nconst __r = await (async () => {\n${UB(e.body)}\n})();\n__emit(${JSON.stringify(e.sentinel)} + __stringify(__r ?? null));\n`}function GB(e,t){let n=e.split(`
3443
+ const __WF = ${JSON.stringify(e.config)};\n${e.prelude}\nconst __r = await (async () => {\n${HB(e.body)}\n})();\n__emit(${JSON.stringify(e.sentinel)} + __stringify(__r ?? null));\n`}function WB(e,t){let n=e.split(`
3435
3444
  `);for(let e=n.length-1;e>=0;e--)if(n[e].startsWith(t)){let r=[...n.slice(0,e),...n.slice(e+1)].join(`
3436
- `).replace(/\n+$/,``);try{return{result:JSON.parse(n[e].slice(t.length)),log:r,hadResult:!0}}catch{return{result:null,log:r,hadResult:!0}}}return{result:null,log:e.replace(/\n+$/,``),hadResult:!1}}function KB(e){let t=/\bmeta\s*=\s*\{/.exec(e);if(!t)return null;let n=t.index+t[0].length-1,r=0;for(let t=n;t<e.length;t++)if(e[t]===`{`)r++;else if(e[t]===`}`&&--r===0)return e.slice(n+1,t);return null}function qB(e,t){let n=RegExp(`\\b${t}\\s*:\\s*(['"\\\`])((?:\\\\.|(?!\\1).)*)\\1`).exec(e);return n?n[2]:null}const JB=e(`workflow-command`),YB=`usage: workflow run <file.js> [--args <json>] [--budget <n>] [--concurrency <n>] [--wait]
3445
+ `).replace(/\n+$/,``);try{return{result:JSON.parse(n[e].slice(t.length)),log:r,hadResult:!0}}catch{return{result:null,log:r,hadResult:!0}}}return{result:null,log:e.replace(/\n+$/,``),hadResult:!1}}function GB(e){let t=/\bmeta\s*=\s*\{/.exec(e);if(!t)return null;let n=t.index+t[0].length-1,r=0;for(let t=n;t<e.length;t++)if(e[t]===`{`)r++;else if(e[t]===`}`&&--r===0)return e.slice(n+1,t);return null}function KB(e,t){let n=RegExp(`\\b${t}\\s*:\\s*(['"\\\`])((?:\\\\.|(?!\\1).)*)\\1`).exec(e);return n?n[2]:null}const qB=e(`workflow-command`),JB=`usage: workflow run <file.js> [--args <json>] [--budget <n>] [--concurrency <n>] [--wait]
3437
3446
  workflow run --script '<inline js>' [...]
3438
3447
  workflow list
3439
3448
  workflow status <runId>
3440
3449
  workflow stop <runId>
3441
3450
  workflow save <runId> <name> [--force]
3442
3451
  Runs a Claude-Code-format dynamic workflow. Default is non-blocking (returns a run id);
3443
- pass --wait to block and print the full result.`,XB=new Set([`list`,`status`,`stop`,`save`]);function ZB(){return globalThis[zB]}function QB(){let e=globalThis.navigator?.hardwareConcurrency??8;return Math.min(16,Math.max(8,e*4))}function $B(e,t,n,r){let i=t[n];switch(i){case`-h`:case`--help`:return{i:n,help:!0};case`--script`:return e.script=t[++n],{i:n};case`--wait`:return e.wait=!0,{i:n};case`--args`:try{e.args=JSON.parse(t[++n]??``),e.hasArgs=!0}catch{return{i:n,error:`workflow: --args must be valid JSON`}}return{i:n};case`--budget`:{let r=Number(t[++n]);return Number.isFinite(r)?(e.budget=r,{i:n}):{i:n,error:`workflow: --budget must be a number`}}case`--concurrency`:{let i=Number(t[++n]);return Number.isFinite(i)?(e.cap=Math.min(r,Math.max(1,Math.trunc(i))),{i:n}):{i:n,error:`workflow: --concurrency must be a number`}}default:return i.startsWith(`-`)?{i:n,error:`workflow: unknown flag '${i}'`}:e.file===void 0?(e.file=i,{i:n}):{i:n,error:`workflow: too many arguments`}}}function eV(e){if(e[0]!==`run`)return e.length===0||e.includes(`-h`)||e.includes(`--help`)?{help:!0}:{error:`workflow: unknown subcommand '${e[0]}' (only 'run' in SP1)`};let t=QB(),n={budget:null,cap:Math.min(8,t)};for(let r=1;r<e.length;r++){let i=$B(n,e,r,t);if(i.help)return{help:!0};if(i.error)return{error:i.error};r=i.i}return n.script===void 0&&n.file===void 0?{error:`workflow: a <file.js> or --script is required`}:n}function tV(e={}){return S(`workflow`,async(t,n)=>{if(XB.has(t[0])&&w(t.slice(1)))return{stdout:YB+`
3444
- `,stderr:``,exitCode:0};if(t[0]===`list`||t[0]===`status`||t[0]===`stop`)return sV(t,n);if(t[0]===`save`)return oV(t,n,e);let r=eV(t);if(r.help)return{stdout:YB+`
3452
+ pass --wait to block and print the full result.`,YB=new Set([`list`,`status`,`stop`,`save`]);function XB(){return globalThis[RB]}function ZB(){let e=globalThis.navigator?.hardwareConcurrency??8;return Math.min(16,Math.max(8,e*4))}function QB(e,t,n,r){let i=t[n];switch(i){case`-h`:case`--help`:return{i:n,help:!0};case`--script`:return e.script=t[++n],{i:n};case`--wait`:return e.wait=!0,{i:n};case`--args`:try{e.args=JSON.parse(t[++n]??``),e.hasArgs=!0}catch{return{i:n,error:`workflow: --args must be valid JSON`}}return{i:n};case`--budget`:{let r=Number(t[++n]);return Number.isFinite(r)?(e.budget=r,{i:n}):{i:n,error:`workflow: --budget must be a number`}}case`--concurrency`:{let i=Number(t[++n]);return Number.isFinite(i)?(e.cap=Math.min(r,Math.max(1,Math.trunc(i))),{i:n}):{i:n,error:`workflow: --concurrency must be a number`}}default:return i.startsWith(`-`)?{i:n,error:`workflow: unknown flag '${i}'`}:e.file===void 0?(e.file=i,{i:n}):{i:n,error:`workflow: too many arguments`}}}function $B(e){if(e[0]!==`run`)return e.length===0||e.includes(`-h`)||e.includes(`--help`)?{help:!0}:{error:`workflow: unknown subcommand '${e[0]}' (only 'run' in SP1)`};let t=ZB(),n={budget:null,cap:Math.min(8,t)};for(let r=1;r<e.length;r++){let i=QB(n,e,r,t);if(i.help)return{help:!0};if(i.error)return{error:i.error};r=i.i}return n.script===void 0&&n.file===void 0?{error:`workflow: a <file.js> or --script is required`}:n}function eV(e={}){return S(`workflow`,async(t,n)=>{if(YB.has(t[0])&&w(t.slice(1)))return{stdout:JB+`
3453
+ `,stderr:``,exitCode:0};if(t[0]===`list`||t[0]===`status`||t[0]===`stop`)return oV(t,n);if(t[0]===`save`)return aV(t,n,e);let r=$B(t);if(r.help)return{stdout:JB+`
3445
3454
  `,stderr:``,exitCode:0};if(r.error)return{stdout:``,stderr:r.error+`
3446
- `,exitCode:1};let i,a;if(r.script!==void 0)i=r.script,a=`<workflow>`;else{let e=n.fs.resolvePath(n.cwd,r.file);if(!await n.fs.exists(e))return{stdout:``,stderr:`workflow: file not found: ${r.file}\n`,exitCode:1};i=await n.fs.readFile(e),a=r.file}let o=HB(i);if(!o.name)return{stdout:``,stderr:`workflow: script must define a meta block with a name (description optional)
3447
- `,exitCode:1};let s=VB().slice(10,22),c=`/shared/workflow-runs/${s}/scratch/`;await n.fs.mkdir(c,{recursive:!0});let l=VB(),u=WB({prelude:BB,config:{...r.hasArgs?{args:r.args}:{},cap:r.cap??8,budget:r.budget??null,cwd:n.cwd,agentCwd:c},body:i,sentinel:l});return r.wait?nV(u,a,l,o,n):rV({code:u,source:i,name:o.name,filename:a,sentinel:l,runId:s,ctx:n,options:e})})}async function nV(e,t,n,r,i){let a;try{a=await Ur(e,[`workflow`,t],i,void 0,{filename:t})}catch(e){return JB.error(`workflow run failed`,e),{stdout:``,stderr:`workflow: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}return cV(r,a,n)}async function rV(e){let t=ZB();if(!t)return{stdout:``,stderr:`workflow: run manager not available
3448
- `,exitCode:1};let n=e.options.getParentJid?.(),{runId:r}=await t.start({code:e.code,source:e.source,name:e.name,filename:e.filename,parentJid:n,ctx:e.ctx,sentinel:e.sentinel,runId:e.runId});return{stdout:`▶ workflow '${e.name}' started (run ${r}). Watch: workflow status ${r}\n`,stderr:``,exitCode:0}}const iV=/^[a-z0-9][a-z0-9-]*$/,aV=`/workspace/.workflows`;async function oV(e,t,n){let r=!1,i=[];for(let t of e.slice(1))t===`--force`?r=!0:i.push(t);let[a,o,...s]=i;if(!a||!o||s.length>0)return{stdout:``,stderr:`usage: workflow save <runId> <name> [--force]
3449
- `,exitCode:1};if(!iV.test(o))return{stdout:``,stderr:`workflow: invalid name '${o}' (use [a-z0-9][a-z0-9-]*)\n`,exitCode:1};let c=ZB()?.getRun(a);if(!c)return{stdout:``,stderr:`workflow: no run '${a}' (only backgrounded runs are saveable; --wait runs are not)\n`,exitCode:1};if(!c.source)return{stdout:``,stderr:`workflow: run '${a}' has no source to save\n`,exitCode:1};let l=`${aV}/${o}.workflow.js`;if(await t.fs.exists(l)){if(!r)return{stdout:``,stderr:`workflow: ${l} already exists (pass --force to overwrite)\n`,exitCode:1}}else if(new Set(t.getRegisteredCommands?.()??[]).has(o))return{stdout:``,stderr:`workflow: '${o}' is already a command — choose another name\n`,exitCode:1};await t.fs.mkdir(aV,{recursive:!0}),await t.fs.writeFile(l,c.source);try{await n.syncScriptCommands?.()}catch(e){JB.warn(`workflow save: command re-sync failed; workflow saved, will register on next sync`,{name:o,error:e instanceof Error?e.message:String(e)})}return{stdout:`saved workflow '${o}' → ${l}\nrun it as '${o}' (or 'workflow run ${l}' if a built-in/.jsh shadows the name)\n`,stderr:``,exitCode:0}}async function sV(e,t){let n=ZB();if(e[0]===`list`){if(!n)return{stdout:``,stderr:`workflow: run manager not available
3455
+ `,exitCode:1};let i,a;if(r.script!==void 0)i=r.script,a=`<workflow>`;else{let e=n.fs.resolvePath(n.cwd,r.file);if(!await n.fs.exists(e))return{stdout:``,stderr:`workflow: file not found: ${r.file}\n`,exitCode:1};i=await n.fs.readFile(e),a=r.file}let o=VB(i);if(!o.name)return{stdout:``,stderr:`workflow: script must define a meta block with a name (description optional)
3456
+ `,exitCode:1};let s=BB().slice(10,22),c=`/shared/workflow-runs/${s}/scratch/`;await n.fs.mkdir(c,{recursive:!0});let l=BB(),u=UB({prelude:zB,config:{...r.hasArgs?{args:r.args}:{},cap:r.cap??8,budget:r.budget??null,cwd:n.cwd,agentCwd:c},body:i,sentinel:l});return r.wait?tV(u,a,l,o,n):nV({code:u,source:i,name:o.name,filename:a,sentinel:l,runId:s,ctx:n,options:e})})}async function tV(e,t,n,r,i){let a;try{a=await Ur(e,[`workflow`,t],i,void 0,{filename:t})}catch(e){return qB.error(`workflow run failed`,e),{stdout:``,stderr:`workflow: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}return sV(r,a,n)}async function nV(e){let t=XB();if(!t)return{stdout:``,stderr:`workflow: run manager not available
3457
+ `,exitCode:1};let n=e.options.getParentJid?.(),{runId:r}=await t.start({code:e.code,source:e.source,name:e.name,filename:e.filename,parentJid:n,ctx:e.ctx,sentinel:e.sentinel,runId:e.runId});return{stdout:`▶ workflow '${e.name}' started (run ${r}). Watch: workflow status ${r}\n`,stderr:``,exitCode:0}}const rV=/^[a-z0-9][a-z0-9-]*$/,iV=`/workspace/.workflows`;async function aV(e,t,n){let r=!1,i=[];for(let t of e.slice(1))t===`--force`?r=!0:i.push(t);let[a,o,...s]=i;if(!a||!o||s.length>0)return{stdout:``,stderr:`usage: workflow save <runId> <name> [--force]
3458
+ `,exitCode:1};if(!rV.test(o))return{stdout:``,stderr:`workflow: invalid name '${o}' (use [a-z0-9][a-z0-9-]*)\n`,exitCode:1};let c=XB()?.getRun(a);if(!c)return{stdout:``,stderr:`workflow: no run '${a}' (only backgrounded runs are saveable; --wait runs are not)\n`,exitCode:1};if(!c.source)return{stdout:``,stderr:`workflow: run '${a}' has no source to save\n`,exitCode:1};let l=`${iV}/${o}.workflow.js`;if(await t.fs.exists(l)){if(!r)return{stdout:``,stderr:`workflow: ${l} already exists (pass --force to overwrite)\n`,exitCode:1}}else if(new Set(t.getRegisteredCommands?.()??[]).has(o))return{stdout:``,stderr:`workflow: '${o}' is already a command — choose another name\n`,exitCode:1};await t.fs.mkdir(iV,{recursive:!0}),await t.fs.writeFile(l,c.source);try{await n.syncScriptCommands?.()}catch(e){qB.warn(`workflow save: command re-sync failed; workflow saved, will register on next sync`,{name:o,error:e instanceof Error?e.message:String(e)})}return{stdout:`saved workflow '${o}' → ${l}\nrun it as '${o}' (or 'workflow run ${l}' if a built-in/.jsh shadows the name)\n`,stderr:``,exitCode:0}}async function oV(e,t){let n=XB();if(e[0]===`list`){if(!n)return{stdout:``,stderr:`workflow: run manager not available
3450
3459
  `,exitCode:1};let e=n.listRuns().map(e=>`${e.id} ${e.status.padEnd(7)} ${e.agentsDone}/${e.agentsStarted} ${e.name??``}`);return{stdout:(e.length?e.join(`
3451
3460
  `):`(no runs)`)+`
3452
3461
  `,stderr:``,exitCode:0}}let r=e[1],i=n?.getRun(r??``);if(!i)return{stdout:``,stderr:`workflow: no run '${r}'\n`,exitCode:1};if(e[0]===`status`)return{stdout:[`run ${i.id} (${i.name??`unnamed`}) status=${i.status}`,`agents ${i.agentsDone}/${i.agentsStarted} phase=${i.currentPhase??`-`}`,i.resultPath?`result: ${i.resultPath}`:``,i.preview?`preview: ${i.preview}`:``,i.error?`error: ${i.error}`:``].filter(Boolean).join(`
3453
3462
  `)+`
3454
- `,stderr:``,exitCode:0};if(i.pid==null)return{stdout:`workflow: run ${i.id} has not started a realm process yet (nothing to stop)\n`,stderr:``,exitCode:0};if(i.status!==`running`&&i.status!==`paused`)return{stdout:`workflow: run ${i.id} already ${i.status}\n`,stderr:``,exitCode:0};let a=await t.exec?.(`kill`,{cwd:t.cwd,args:[`-KILL`,String(i.pid)]});return a&&a.exitCode!==0?{stdout:``,stderr:a.stderr||`workflow: kill failed (exit ${a.exitCode})\n`,exitCode:a.exitCode}:{stdout:`stopped run ${i.id} (pid ${i.pid})\n`,stderr:``,exitCode:0}}function cV(e,t,n){let{result:r,log:i,hadResult:a}=GB(t.stdout,n),o=e.name?`workflow: ${e.name}${e.description?` — `+e.description:``}\n`:``,s=i?lV(i)+`
3463
+ `,stderr:``,exitCode:0};if(i.pid==null)return{stdout:`workflow: run ${i.id} has not started a realm process yet (nothing to stop)\n`,stderr:``,exitCode:0};if(i.status!==`running`&&i.status!==`paused`)return{stdout:`workflow: run ${i.id} already ${i.status}\n`,stderr:``,exitCode:0};let a=await t.exec?.(`kill`,{cwd:t.cwd,args:[`-KILL`,String(i.pid)]});return a&&a.exitCode!==0?{stdout:``,stderr:a.stderr||`workflow: kill failed (exit ${a.exitCode})\n`,exitCode:a.exitCode}:{stdout:`stopped run ${i.id} (pid ${i.pid})\n`,stderr:``,exitCode:0}}function sV(e,t,n){let{result:r,log:i,hadResult:a}=WB(t.stdout,n),o=e.name?`workflow: ${e.name}${e.description?` — `+e.description:``}\n`:``,s=i?cV(i)+`
3455
3464
  `:``;return t.exitCode!==0||!a?{stdout:o+s,stderr:t.stderr||(a?``:`workflow: script produced no result
3456
3465
  `),exitCode:t.exitCode||1}:{stdout:o+s+(typeof r==`string`?r:JSON.stringify(r))+`
3457
- `,stderr:t.stderr,exitCode:0}}function lV(e){return e.split(`
3466
+ `,stderr:t.stderr,exitCode:0}}function cV(e){return e.split(`
3458
3467
  `).map(e=>e.replace(/^WFPHASE/,`▸ `).replace(/^WFLOG/,`· `)).join(`
3459
- `)}function uV(e){return{stdout:``,stderr:`xxd: ${e}\n`,exitCode:1}}function dV(e){if(e==null)throw Error(`missing option value`);let t=e.startsWith(`-`),n=t||e.startsWith(`+`)?e.slice(1):e,r;if(/^0x[0-9a-fA-F]+$/.test(n))r=parseInt(n.slice(2),16);else if(/^[0-9]+$/.test(n))r=parseInt(n,10);else throw Error(`invalid number: ${e}`);return t?-r:r}function fV(e,t){let n=e.toString(16).padStart(2,`0`);return t?n.toUpperCase():n}function pV(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t}function mV(e){return e.replace(/[^0-9a-zA-Z]/g,`_`)}function hV(e,t,n,r,i){let a=[];for(let o=0;o<e.length;o+=t){let s=Math.min(o+t,e.length),c=(i+o).toString(16).padStart(8,`0`),l=``;for(let i=0;i<t;i++)n>0&&i>0&&i%n===0&&(l+=` `),l+=o+i<s?fV(e[o+i],r):` `;let u=``;for(let t=o;t<s;t++)u+=e[t]>=32&&e[t]<=126?String.fromCharCode(e[t]):`.`;a.push(`${c}: ${l} ${u}`)}return a.length?a.join(`
3468
+ `)}function lV(e){return{stdout:``,stderr:`xxd: ${e}\n`,exitCode:1}}function uV(e){if(e==null)throw Error(`missing option value`);let t=e.startsWith(`-`),n=t||e.startsWith(`+`)?e.slice(1):e,r;if(/^0x[0-9a-fA-F]+$/.test(n))r=parseInt(n.slice(2),16);else if(/^[0-9]+$/.test(n))r=parseInt(n,10);else throw Error(`invalid number: ${e}`);return t?-r:r}function dV(e,t){let n=e.toString(16).padStart(2,`0`);return t?n.toUpperCase():n}function fV(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t}function pV(e){return e.replace(/[^0-9a-zA-Z]/g,`_`)}function mV(e,t,n,r,i){let a=[];for(let o=0;o<e.length;o+=t){let s=Math.min(o+t,e.length),c=(i+o).toString(16).padStart(8,`0`),l=``;for(let i=0;i<t;i++)n>0&&i>0&&i%n===0&&(l+=` `),l+=o+i<s?dV(e[o+i],r):` `;let u=``;for(let t=o;t<s;t++)u+=e[t]>=32&&e[t]<=126?String.fromCharCode(e[t]):`.`;a.push(`${c}: ${l} ${u}`)}return a.length?a.join(`
3460
3469
  `)+`
3461
- `:``}function gV(e,t,n){let r=``;for(let i=0;i<e.length;i+=t){let a=``;for(let r=0;r<t&&i+r<e.length;r++)a+=fV(e[i+r],n);r+=a+`
3462
- `}return r}function _V(e,t,n,r){let i=Array.from(e,e=>`0x${fV(e,n)}`),a=[];for(let e=0;e<i.length;e+=t)a.push(` `+i.slice(e,e+t).join(`, `));let o=a.join(`,
3470
+ `:``}function hV(e,t,n){let r=``;for(let i=0;i<e.length;i+=t){let a=``;for(let r=0;r<t&&i+r<e.length;r++)a+=dV(e[i+r],n);r+=a+`
3471
+ `}return r}function gV(e,t,n,r){let i=Array.from(e,e=>`0x${dV(e,n)}`),a=[];for(let e=0;e<i.length;e+=t)a.push(` `+i.slice(e,e+t).join(`, `));let o=a.join(`,
3463
3472
  `);return r===null?i.length?o+`
3464
- `:``:`unsigned char ${r}[] = {\n${o}\n};\nunsigned int ${r}_len = ${e.length};\n`}function vV(e){let t=e.replace(/[^0-9a-fA-F]/g,``),n=Math.floor(t.length/2),r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=parseInt(t.substr(e*2,2),16);return r}function yV(e){let t=[],n=0;for(let r of e.split(`
3465
- `)){let e=r.replace(/\r$/,``),i=e.indexOf(`:`);if(i<0)continue;let a=parseInt(e.slice(0,i).trim(),16);if(Number.isNaN(a))continue;let o=e.slice(i+1),s=o.indexOf(` `);s>=0&&(o=o.slice(0,s));let c=o.replace(/[^0-9a-fA-F]/g,``),l=[];for(let e=0;e+1<c.length;e+=2)l.push(parseInt(c.substr(e,2),16));l.length&&(t.push({offset:a,bytes:l}),n=Math.max(n,a+l.length))}if(!t.length)return new Uint8Array;let r=new Uint8Array(n);for(let e of t)for(let t=0;t<e.bytes.length;t++)r[e.offset+t]=e.bytes[t];return r}const bV={"-u":`upper`,"-p":`plain`,"-ps":`plain`,"-postscript":`plain`,"-i":`include`,"-include":`include`,"-r":`revert`,"-revert":`revert`},xV=[{key:`cols`,exact:[`-c`,`-cols`],attached:/^-c(0x)?[0-9]/},{key:`group`,exact:[`-g`,`-groupsize`],attached:/^-g(0x)?[0-9]/},{key:`length`,exact:[`-l`,`-len`],attached:/^-l(0x)?[0-9]/},{key:`seek`,exact:[`-s`,`-seek`],attached:/^-s[+-]?(0x)?[0-9]/}];function SV(e){let t={upper:!1,plain:!1,include:!1,revert:!1,positional:[]};for(let n=0;n<e.length;n++){let r=e[n],i=bV[r];if(i){t[i]=!0;continue}let a=xV.find(e=>e.exact.includes(r)||e.attached.test(r));if(a){t[a.key]=dV(a.exact.includes(r)?e[++n]:r.slice(2));continue}if(r!==`-`&&r.startsWith(`-`)&&r.length>1)throw Error(`invalid option ${r}`);t.positional.push(r)}return t}function CV(e){return e.includes(`-h`)||e.includes(`--help`)||e.includes(`-help`)}async function wV(e,t,n){if(!n&&t)return e.fs.readFileBuffer(e.fs.resolvePath(e.cwd,t));let r=ti(e.stdin),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e)&255;return i}function TV(e,t,n,r,i){let a=e.cols&&e.cols>0?e.cols:e.plain?30:e.include?12:16;return e.plain?gV(t,a,e.upper):e.include?_V(t,a,e.upper,i?null:mV(r??``)):hV(t,a,e.group!=null&&e.group>=0?e.group:2,e.upper,n)}function EV(e,t){let n=0,r=t;return e.seek!==void 0&&(n=e.seek<0?Math.max(0,r.length+e.seek):Math.min(e.seek,r.length),r=r.subarray(n)),e.length!==void 0&&(r=r.subarray(0,Math.max(0,e.length))),{data:r,base:n}}function DV(){return S(`xxd`,async(e,t)=>{if(CV(e))return{stdout:`usage: xxd [options] [infile [outfile]]
3473
+ `:``:`unsigned char ${r}[] = {\n${o}\n};\nunsigned int ${r}_len = ${e.length};\n`}function _V(e){let t=e.replace(/[^0-9a-fA-F]/g,``),n=Math.floor(t.length/2),r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=parseInt(t.substr(e*2,2),16);return r}function vV(e){let t=[],n=0;for(let r of e.split(`
3474
+ `)){let e=r.replace(/\r$/,``),i=e.indexOf(`:`);if(i<0)continue;let a=parseInt(e.slice(0,i).trim(),16);if(Number.isNaN(a))continue;let o=e.slice(i+1),s=o.indexOf(` `);s>=0&&(o=o.slice(0,s));let c=o.replace(/[^0-9a-fA-F]/g,``),l=[];for(let e=0;e+1<c.length;e+=2)l.push(parseInt(c.substr(e,2),16));l.length&&(t.push({offset:a,bytes:l}),n=Math.max(n,a+l.length))}if(!t.length)return new Uint8Array;let r=new Uint8Array(n);for(let e of t)for(let t=0;t<e.bytes.length;t++)r[e.offset+t]=e.bytes[t];return r}const yV={"-u":`upper`,"-p":`plain`,"-ps":`plain`,"-postscript":`plain`,"-i":`include`,"-include":`include`,"-r":`revert`,"-revert":`revert`},bV=[{key:`cols`,exact:[`-c`,`-cols`],attached:/^-c(0x)?[0-9]/},{key:`group`,exact:[`-g`,`-groupsize`],attached:/^-g(0x)?[0-9]/},{key:`length`,exact:[`-l`,`-len`],attached:/^-l(0x)?[0-9]/},{key:`seek`,exact:[`-s`,`-seek`],attached:/^-s[+-]?(0x)?[0-9]/}];function xV(e){let t={upper:!1,plain:!1,include:!1,revert:!1,positional:[]};for(let n=0;n<e.length;n++){let r=e[n],i=yV[r];if(i){t[i]=!0;continue}let a=bV.find(e=>e.exact.includes(r)||e.attached.test(r));if(a){t[a.key]=uV(a.exact.includes(r)?e[++n]:r.slice(2));continue}if(r!==`-`&&r.startsWith(`-`)&&r.length>1)throw Error(`invalid option ${r}`);t.positional.push(r)}return t}function SV(e){return e.includes(`-h`)||e.includes(`--help`)||e.includes(`-help`)}async function CV(e,t,n){if(!n&&t)return e.fs.readFileBuffer(e.fs.resolvePath(e.cwd,t));let r=ti(e.stdin),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e)&255;return i}function wV(e,t,n,r,i){let a=e.cols&&e.cols>0?e.cols:e.plain?30:e.include?12:16;return e.plain?hV(t,a,e.upper):e.include?gV(t,a,e.upper,i?null:pV(r??``)):mV(t,a,e.group!=null&&e.group>=0?e.group:2,e.upper,n)}function TV(e,t){let n=0,r=t;return e.seek!==void 0&&(n=e.seek<0?Math.max(0,r.length+e.seek):Math.min(e.seek,r.length),r=r.subarray(n)),e.length!==void 0&&(r=r.subarray(0,Math.max(0,e.length))),{data:r,base:n}}function EV(){return S(`xxd`,async(e,t)=>{if(SV(e))return{stdout:`usage: xxd [options] [infile [outfile]]
3466
3475
  -c cols number of octets per line (default 16; 30 for -p; 12 for -i)
3467
3476
  -g bytes number of octets per group (default 2; 0 disables grouping)
3468
3477
  -l len stop after len octets
@@ -3472,8 +3481,8 @@ pass --wait to block and print the full result.`,XB=new Set([`list`,`status`,`st
3472
3481
  -i output in C include style
3473
3482
  -r reverse: convert a hex dump back to binary (-r -p for plain)
3474
3483
  -h show this help
3475
- `,stderr:``,exitCode:0};let n;try{n=SV(e)}catch(e){return uV(e.message)}let r=n.positional[0],i=n.positional[1],a=!r||r===`-`,o;try{o=await wV(t,r,a)}catch{return uV(`${r}: No such file or directory`)}if(n.revert){let e=pV(o),r=n.plain?vV(e):yV(e);return i?(await t.fs.writeFile(t.fs.resolvePath(t.cwd,i),r),{stdout:``,stderr:``,exitCode:0}):{stdout:pV(r),stderr:``,exitCode:0}}let{data:s,base:c}=EV(n,o),l=TV(n,s,c,r,a);return i?(await t.fs.writeFile(t.fs.resolvePath(t.cwd,i),l),{stdout:``,stderr:``,exitCode:0}):{stdout:l,stderr:``,exitCode:0}})}async function OV(e,t,n,r){if((await e.fs.stat(t)).isFile)return r[n]=await e.fs.readFileBuffer(t),1;let i=await e.fs.readdir(t),a=0;for(let o of i){let i=er(t,o),s=n?`${n}/${o}`:o;a+=await OV(e,i,s,r)}return a}function kV(){return{stdout:`usage: zip [-r] <archive.zip> <path> [path...]
3476
- `,stderr:``,exitCode:0}}function AV(){return S(`zip`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return kV();let n=!1,r=[];for(let t of e){if(t===`-r`){n=!0;continue}if(t.startsWith(`-`))return{stdout:``,stderr:`zip: unsupported option ${t}\n`,exitCode:1};r.push(t)}if(r.length<2)return{stdout:``,stderr:`zip: expected archive path and at least one input path
3477
- `,exitCode:1};let i=t.fs.resolvePath(t.cwd,r[0]),a=r.slice(1),o={},s=0;for(let e of a){let r=t.fs.resolvePath(t.cwd,e),i=await t.fs.stat(r),a=(e.startsWith(`/`)?e.slice(1):e.replace(/^\.\//,``))||tr(r);if(i.isDirectory&&!n)return{stdout:``,stderr:`zip: ${e} is a directory (use -r)\n`,exitCode:1};s+=await OV(t,r,a,o)}if(s===0)return{stdout:``,stderr:`zip: nothing to do
3478
- `,exitCode:1};let c=Ct(o);return await t.fs.writeFile(i,c),{stdout:`created ${i} (${s} file(s))\n`,stderr:``,exitCode:0}})}function jV(e){return{setEnv:e.setEnv,unsetEnv:e.unsetEnv,broker:e.sudoCommand?.broker}}function MV(e){let{fs:t,fetch:n}=e;if(!t||!n)return[];let r={fs:t,fetch:n,scriptCatalog:e.scriptCatalog,syncScriptCommands:e.syncScriptCommands};return[ZD(`ipk`,r),ZD(`npm`,r),ZD(`i`,r),PO(`ipx`,{fs:t,fetch:n}),PO(`npx`,{fs:t,fetch:n}),Qy(`di`,{fs:t,fetch:n}),Qy(`uv`,{fs:t,fetch:n}),cR({fs:t,fetch:n})]}function NV(e={}){let t=[XT({getJshCommands:e.getJshCommands,getWorkflowCommands:e.getWorkflowCommands}),ne(),JF(),pF(),oF(e.browserAPI,e.fs),Wj(e.browserAPI),my(e.browserAPI),nD(e),AV(),RL(),AI(),tI(),cI(),aI(),lv(),DV(),HF(`sqlite3`),HF(`sqllite`),qI(),pL(),mx(),G_(),sj({buildProcessConfig:e.buildProcessConfig}),sj({buildProcessConfig:e.buildProcessConfig},`jsh`),oN(`python3`,{buildProcessConfig:e.buildProcessConfig}),oN(`python`,{buildProcessConfig:e.buildProcessConfig}),...MV(e),...e.fs?[bS({fs:e.fs})]:[],...e.fs?[yA({fs:e.fs})]:[],...e.fetch?[cE({fetch:e.fetch,streamFetch:e.streamFetch})]:[],sS(),cS(),qz(e.webhook),MB(),py(e.crontask),Ek({fs:e.fs,scriptCatalog:e.scriptCatalog}),uM({fs:e.fs,fetch:e.fetch}),yS(),NF(),Gj(),Kj(`pdftk`),Kj(`pdf`),K_(`biscotto`),K_(`biscotti`),nM(`pdftoppm`),nM(`pdftocairo`),rM(`pdftotext`),Zv(`convert`),Zv(`magick`),RB({fs:e.fs,scriptCatalog:e.scriptCatalog,getStaticBuiltins:e.getStaticBuiltins,getScriptRegisteredNames:e.getScriptRegisteredNames}),_L(),NL(),QE(),$E(),PL(),bA(),uN(),bk(),zb(),Sj(),xj(),_k(),jP(jV(e)),CN({fs:e.fs}),YN(),ov(),sv(),cv(`xclip`),cv(`xsel`),JN(),RS(),_g(),vg(),qA(e.fs),tt(),fj(),Rg({getParentJid:e.getParentJid}),qb(),MM({processManager:e.processManager}),CR({processManager:e.processManager}),LO({processManager:e.processManager}),FO({processManager:e.processManager,scriptCatalog:e.scriptCatalog}),...Vg(),vA(),lk(),JR(),PE(),Yx(),uz({processManager:e.processManager}),fv({processManager:e.processManager,browser:e.browserAPI,sudoBroker:e.sudoCommand?.broker}),oS(),$_({registry:e.cherryRuntimeRegistry}),xy(),Oy({fs:e.fs}),ky({fs:e.fs}),XF(e.sudoCommand),tV({getParentJid:e.getParentJid,syncScriptCommands:e.syncScriptCommands}),NB(),fF()];return e.fs&&(aM(),t.push(...Nn.map(t=>qT(t,e.browserAPI,e.fs,{isScoop:e.isScoop})))),t}let PV=null;function FV(e){PV=e}function IV(e){PV?.(e)}var LV=Dt();const RV=Reflect.get(Ye,`DefenseInDepthBox`);function zV(e){return(typeof e==`string`?e:e?.encoding)??`utf8`}function BV(e,t){if(typeof e!=`string`)return e;let n=zV(t);if(n===`binary`||n===`latin1`){let t=ue(e);if(t)return t}return LV.Buffer.from(e,n)}function VV(e){return e===`/bin`?`/usr/bin`:e.startsWith(`/bin/`)?`/usr${e}`:e}var HV=class{vfs;registeredCommandsFn=null;listingStats=new Map;listingStatsMax;listingStatsTtlMs;constructor(e,t){this.vfs=e,this.listingStatsMax=Math.max(1,t?.listingStatsMax??2e4),this.listingStatsTtlMs=t?.listingStatsTtlMs??1e3}get listingStatsSize(){return this.listingStats.size}primeListingStats(e,t){let n=Date.now();if(t.length>this.listingStatsMax){this.listingStats.clear();return}this.sweepExpiredListingStats(n),this.listingStats.size+t.length>this.listingStatsMax&&this.listingStats.clear();let r=e===`/`?`/`:`${e}/`;for(let e of t){let t=Pe(e),i=`${r}${e.name}`;this.listingStats.delete(i),t&&this.listingStats.set(i,{stats:t,at:n})}}sweepExpiredListingStats(e){for(let[t,n]of this.listingStats){if(e-n.at<=this.listingStatsTtlMs)break;this.listingStats.delete(t)}}primedStats(e){let t=this.listingStats.get(e);if(t){if(Date.now()-t.at>this.listingStatsTtlMs){this.listingStats.delete(e);return}return t.stats}}dropListingStats(){this.listingStats.clear()}setRegisteredCommandsFn(e){this.registeredCommandsFn=e}getVirtualBinCommands(){return this.registeredCommandsFn?.()??[]}virtualUsrStat(e){let t=VV(e);if(t===`/usr`||t===`/usr/bin`)return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date(0)};if(t.startsWith(`/usr/bin/`)){let e=t.slice(9);if(e.length>0&&!e.includes(`/`)&&this.getVirtualBinCommands().includes(e))return{isFile:!0,isDirectory:!1,isSymbolicLink:!1,mode:493,size:0,mtime:new Date(0)}}return null}canWrite(e){let t=this.vfs;return typeof t.canWrite!=`function`||t.canWrite(e)}listMountPoints(){let e=this.vfs;return typeof e.listMountPoints==`function`?e.listMountPoints():[]}trusted(e){let t=RV?.runTrustedAsync;return t?t(e):Promise.resolve().then(e)}async readFile(e,t){return this.trusted(async()=>{let n=b(e),r=await this.vfs.readFile(n,{encoding:`binary`}),i=r instanceof Uint8Array?r:new TextEncoder().encode(r),a=zV(t),o=LV.Buffer.from(i.buffer,i.byteOffset,i.byteLength).toString(a);return a!==`hex`&&a!==`base64`&&g(o,i),o})}async readFileBuffer(e){return this.trusted(async()=>{let t=b(e),n=await this.vfs.readFile(t,{encoding:`binary`});return n instanceof Uint8Array?n:new TextEncoder().encode(n)})}async readFileBytes(e){let t=await this.readFileBuffer(e);return LV.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString(`latin1`)}async getNativeFile(e){return this.trusted(()=>this.vfs.getNativeFile(b(e)))}async readFileRange(e,t,n){return this.trusted(()=>this.vfs.readFileRange(b(e),t,n))}async writeFile(e,t,n){return this.dropListingStats(),this.trusted(async()=>{let r=b(e);await this.vfs.writeFile(r,BV(t,n))})}async appendFile(e,t,n){return this.dropListingStats(),this.trusted(()=>this.vfs.appendFile(b(e),BV(t,n)))}async exists(e){return this.trusted(async()=>{let t=b(e);return this.virtualUsrStat(t)?!0:this.vfs.exists(t)})}async stat(e){return this.trusted(async()=>{let t=b(e),n=this.virtualUsrStat(t);if(n)return n;let r=this.vfs.statSync(t);if(r)return{isFile:r.type===`file`,isDirectory:r.type===`directory`,isSymbolicLink:!!r.isSymlink,mode:r.mode??(r.type===`directory`?493:420),size:r.size,mtime:new Date(r.mtime),identity:r.identity,dev:r.dev,ino:r.identity===void 0?void 0:r.ino};let i=this.primedStats(t)??await this.vfs.stat(t);return{isFile:i.type===`file`,isDirectory:i.type===`directory`,isSymbolicLink:!!i.isSymlink,mode:i.mode??(i.type===`directory`?493:420),size:i.size,mtime:new Date(i.mtime),identity:i.identity,dev:i.dev,ino:i.identity===void 0?void 0:i.ino}})}async lstat(e){return this.trusted(async()=>{let t=b(e),n=this.virtualUsrStat(t);if(n)return n;let r=this.vfs.lstatSync(t);if(r)return{isFile:r.type===`file`,isDirectory:r.type===`directory`,isSymbolicLink:r.type===`symlink`,mode:r.mode??(r.type===`directory`?493:r.type===`symlink`?511:420),size:r.size,mtime:new Date(r.mtime),identity:r.identity,dev:r.dev,ino:r.identity===void 0?void 0:r.ino};let i=this.primedStats(t)??await this.vfs.lstat(t);return{isFile:i.type===`file`,isDirectory:i.type===`directory`,isSymbolicLink:i.type===`symlink`,mode:i.mode??(i.type===`directory`?493:i.type===`symlink`?511:420),size:i.size,mtime:new Date(i.mtime),identity:i.identity,dev:i.dev,ino:i.identity===void 0?void 0:i.ino}})}async mkdir(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.mkdir(b(e),t)})}async readdir(e){return this.trusted(async()=>{let t=b(e);if(t===`/usr`)return[`bin`];if(VV(t)===`/usr/bin`)return this.getVirtualBinCommands().slice().sort();let n=this.vfs.readDirSync(t);if(n!==null)return n.map(e=>e.name);let r=await this.vfs.readDir(t,{includeStats:!0});return this.primeListingStats(t,r),r.map(e=>e.name)})}async readdirWithFileTypes(e){return this.trusted(async()=>{let t=b(e);if(t===`/usr`)return[{name:`bin`,isFile:!1,isDirectory:!0,isSymbolicLink:!1}];if(VV(t)===`/usr/bin`)return this.getVirtualBinCommands().slice().sort().map(e=>({name:e,isFile:!0,isDirectory:!1,isSymbolicLink:!1}));let n=this.vfs.readDirSync(t);if(n!==null)return this.mapFastEntriesToDirents(n);let r=await this.vfs.readDir(t,{includeStats:!0});return this.primeListingStats(t,r),this.mapAsyncEntriesToDirents(r)})}mapFastEntriesToDirents(e){return e.map(e=>this.entryToDirent(e))}mapAsyncEntriesToDirents(e){return e.map(e=>this.entryToDirent(e))}entryToDirent(e){return e.type===`symlink`?{name:e.name,isFile:!1,isDirectory:!1,isSymbolicLink:!0}:{name:e.name,isFile:e.type===`file`,isDirectory:e.type===`directory`,isSymbolicLink:!1}}async rm(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.rm(b(e),t)})}async cp(e,t,n){return this.dropListingStats(),this.trusted(async()=>{let r=b(e),i=b(t);if((await this.vfs.stat(r)).type===`directory`){if(!n?.recursive)throw new Fe(`EISDIR`,`is a directory`,r);await this.cpDir(r,i)}else await this.vfs.copyFile(r,i)})}async cpDir(e,t){await this.vfs.mkdir(t,{recursive:!0});let n=await this.vfs.readDir(e);for(let r of n){let n=x(e,r.name),i=x(t,r.name);r.type===`directory`?await this.cpDir(n,i):await this.vfs.copyFile(n,i)}}async mv(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.rename(b(e),b(t))})}async rename(e,t){return this.mv(e,t)}resolvePath(e,t){return t.startsWith(`/`)?b(t):b(x(e,t))}getAllPaths(){return[]}async chmod(e,t){return this.dropListingStats(),this.trusted(()=>this.vfs.chmod(b(e),t))}async symlink(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.symlink(e,b(t))})}async link(e,t){throw Error(`Hard links not supported in VirtualFS`)}async readlink(e){return this.trusted(async()=>this.vfs.readlink(b(e)))}async realpath(e){return this.trusted(async()=>this.vfs.realpath(b(e)))}async utimes(e,t,n){return this.dropListingStats(),this.trusted(()=>this.vfs.utimes(b(e),t,n))}invalidatePaths(e){this.dropListingStats();let t=this.vfs;t.invalidatePaths&&t.invalidatePaths(e)}async forgetSidecarConsistency(){await this.vfs.forgetSidecarConsistency?.()}};function UV(e){return e&&typeof e.getWatcher==`function`?e.getWatcher?.()??null:e&&typeof e.getUnderlyingFS==`function`?UV(e.getUnderlyingFS?.()):null}async function WV(e){let t=le(`github`);if(t){if(e?.force){await t.onSilentRenew?.();return}await t.getValidAccessToken?.()}}const GV=e(`almost-bash-shell`),KV=`__SLICC_RUN_PID`,qV=`__SLICC_OUTPUT_TEE__`;function JV(e){let t=e?.get(KV);if(t===void 0)return;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>0?n:void 0}function YV(e){if(!(KV in e)&&!(qV in e)&&!(`__SLICC_SUDO_REASON`in e)&&!(`__SLICC_PIPESTATUS`in e)&&!(`__SLICC_PIPESTATUS_EX`in e))return{...e};let{[KV]:t,[qV]:n,[em]:r,[ip]:i,[ap]:a,...o}=e;return o}var XV=class e{options;bash;vfsAdapter;gitCommands;mountCommands;lastEnv;cwd;umask=18;builtinCommandNames;staticBuiltinNames;allowedCommands;scriptCatalog;initialJshSync=null;ownsScriptCatalog;registeredJshCommands=new Map;registeredWorkflowCommands=new Set;jshSyncInflight=null;jshSyncDirty=!1;pendingCommandGrants=[];pendingSudoBypasses=new Map;pendingEnvWrites=new Map;activeShellPid;progress;activeRunSignal;scriptRun=null;scriptRunsActive=0;registryNames=new Set;outputTees=new Map;nextOutputTeeId=0;resolveJshProcessConfig=e=>this.buildJshProcessConfig(JV(e));static buildAllowedCommandSet(e){return e.sudo?.defaultDisposition===`require-approval`||!e.allowedCommands||e.allowedCommands.includes(`*`)?null:new Set(e.allowedCommands)}static buildInitialEnv(e,t){return{HOME:ep,PATH:Un,USER:`user`,SHELL:`/bin/bash`,TMPDIR:`/tmp`,PWD:t,...e.env}}buildSupplementalCommands(e,t,n){return NV({onMediaPreview:async e=>this.renderMediaPreview(e),getJshCommands:()=>this.getJshCommandNames(),getWorkflowCommands:()=>this.getWorkflowCommandNames(),syncScriptCommands:()=>this.syncJshCommands(),getStaticBuiltins:()=>[...this.staticBuiltinNames],getScriptRegisteredNames:()=>[...this.registeredJshCommands.keys(),...this.registeredWorkflowCommands],fs:e.fs,fetch:t,streamFetch:n,scriptCatalog:this.scriptCatalog,browserAPI:e.browserAPI,webhook:e.webhook,crontask:e.crontask,getParentJid:e.getParentJid,isScoop:e.isScoop,buildProcessConfig:this.resolveJshProcessConfig,processManager:e.processManager,sudoCommand:e.sudo?{broker:e.sudo.broker,persistGrant:async e=>{this.pendingCommandGrants.push(e)},suppressNextGate:e=>this.registerSudoBypass(e)}:void 0,setEnv:(e,t)=>{this.pendingEnvWrites.set(e,t),this.lastEnv[e]=t},unsetEnv:e=>{this.pendingEnvWrites.set(e,null),delete this.lastEnv[e]}})}constructor(t){this.options=t,this.vfsAdapter=new HV(t.fs),this.progress=new gp({scrubLabel:t.scrubProgressLabel}),this.allowedCommands=e.buildAllowedCommandSet(t);let n=t.cwd??`/`,r=e.buildInitialEnv(t,n);this.gitCommands=new Zf({fs:t.fs,authorName:r.GIT_AUTHOR_NAME??`User`,authorEmail:r.GIT_AUTHOR_EMAIL??`user@example.com`,ensureFreshGithubToken:WV}),this.mountCommands=new Cs({fs:t.fs,isScoop:t.isScoop,acquireLocalMountViaToolUI:sm});let i=t.jshDiscoveryFs??t.fs,a=t.bshDiscoveryFs??t.fs,o=UV(i)??UV(a);this.scriptCatalog=t.scriptCatalog??new oi({jshFs:i,bshFs:a,watcher:o}),this.ownsScriptCatalog=!t.scriptCatalog,o&&o.watch(`/`,e=>e.endsWith(`.jsh`)||e.endsWith(`.workflow.js`),()=>{this.syncJshCommands().catch(()=>void 0)});let s=this.createGitCustomCommand(),c=p({progress:xp(this.progress)}),l=h({progress:xp(this.progress)}),u=this.buildSupplementalCommands(t,c,l),d=[s,this.createMountCustomCommand(),this.createUmountCustomCommand(),th(t.fs),Qh(t.fs,c,t.browserAPI),...u].filter(e=>this.isCommandAllowed(e.name)),f=[...Ze(),...Xe()],m=this.allowedCommands?f.filter(e=>this.isCommandAllowed(e)):void 0;if(this.bash=new Qe({fs:this.vfsAdapter,cwd:n,env:{},fetch:c,commands:m,customCommands:d,sleep:Hp(this.progress,{isAborted:()=>this.activeRunSignal?.aborted??!1}),executionLimitProfile:t.executionLimitProfile,executionLimits:$f(t.isScoop?.()??!1,t.executionLimits)}),this.bash.registerTransformPlugin(hm),this.allowedCommands!==null){let e=this.bash;for(let t of Xe())this.isCommandAllowed(t)||e.commands.delete(t)}{let e=this.bash;for(let[t,n]of e.commands)e.commands.set(t,this.wrapCommandForDispatch(n));this.registryNames=new Set(e.commands.keys())}let g=d.map(e=>e.name),_=m??[...Ze(),...Xe()];this.builtinCommandNames=new Set([..._,...g]),this.staticBuiltinNames=new Set(this.builtinCommandNames),this.vfsAdapter.setRegisteredCommandsFn(()=>[...this.builtinCommandNames]),this.lastEnv={...r},this.cwd=n,this.startInitialJshSync()}getBash(){return this.bash}getCwd(){return this.cwd}getScriptCatalog(){return this.scriptCatalog}getEnv(){return{...this.lastEnv}}setMaskedEnvVar(e,t){this.pendingEnvWrites.set(e,t),this.lastEnv[e]=t}applySessionOverrides(e){e.cwd!==void 0&&(this.cwd=e.cwd,this.lastEnv.PWD=e.cwd),e.env&&Object.assign(this.lastEnv,e.env)}async getJshCommandNames(){return[...(await this.getFilteredJshCommands()).keys()]}async syncJshCommands(){return this.jshSyncInflight===null?(this.jshSyncInflight=this.doSyncJshCommands(),this.jshSyncInflight):(this.jshSyncDirty=!0,this.jshSyncInflight)}async executeCommand(e,t,n,r=``,i){let a=this.activeShellPid;n!==void 0&&(this.activeShellPid=n);let o=i?.onOutput?`tee-${this.nextOutputTeeId+=1}`:void 0;o&&i?.onOutput&&this.outputTees.set(o,i.onOutput);try{let a=await this.runCommand(e,t,n,r,o,i?.capturePipeStatus);return{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode,...a.pipeStatus===void 0?{}:{pipeStatus:a.pipeStatus}}}finally{this.activeShellPid=a,o&&this.outputTees.delete(o)}}async executeScriptFile(e,t=[]){return Br(e,t,{fs:this.vfsAdapter,cwd:this.cwd,env:new Map(Object.entries(this.lastEnv)),stdin:``,exec:(e,t)=>this.bash.exec(e,{env:t?.env??this.lastEnv,cwd:t?.cwd??this.cwd,umask:this.umask,...t?.env===void 0?{}:{replaceEnv:!0}})},this.buildJshProcessConfig())}dispose(){this.ownsScriptCatalog&&this.scriptCatalog.dispose()}async renderMediaPreview(e){throw Error(`terminal preview is unavailable in headless mode`)}currentScanRoots(){return Wn(this.lastEnv.PATH)}startInitialJshSync(){this.initialJshSync=this.initHomeAndProfile().then(()=>this.syncJshCommands()).catch(()=>void 0).finally(()=>{this.initialJshSync=null})}async initHomeAndProfile(){let e=this.options.fs;try{let t=this.options.env?.HOME??await tp(e);this.lastEnv.HOME=t,this.options.env?.USER||(this.lastEnv.USER=np(t));let n=`${t.replace(/\/+$/,``)}/.profile`;if(!await e.exists(n).catch(()=>!1))return;let r=await this.bash.exec(`. "$HOME/.profile"`,{env:this.lastEnv,cwd:this.cwd,umask:this.umask});if(typeof r.umask==`number`&&(this.umask=r.umask),r.env){let{PWD:e,...t}=r.env;this.lastEnv={...t,PWD:this.lastEnv.PWD??this.cwd}}}catch(e){GV.warn(`HOME/profile init failed; continuing with defaults`,e)}}async waitForInitialJshSync(e){let t=this.initialJshSync;if(t===null)return;if(!e){await t;return}if(e.aborted)return;let n;try{await new Promise(r=>{n=()=>r(),e.addEventListener(`abort`,n,{once:!0}),t.then(()=>r(),()=>r())})}finally{n&&e.removeEventListener(`abort`,n)}}async runCommand(e,t,n,r=``,i,a=!1){IV(e.trim().split(/\s+/)[0]||`unknown`),m(),await this.waitForInitialJshSync(t);let o=nm(e),s={env:{...this.lastEnv,...n===void 0?{}:{[KV]:String(n)},...i===void 0?{}:{[qV]:i},...o?{[em]:o}:{}},cwd:this.cwd,umask:this.umask,signal:t,...r===``?{}:{stdin:r,stdinKind:`bytes`}},c=this.lastEnv.PATH;this.activeRunSignal=t;let l=this.beginScriptRun(e),u;try{u=await this.bash.exec(up(e,a),s)}finally{this.activeRunSignal===t&&(this.activeRunSignal=void 0),this.endScriptRun(l)}if(await this.flushPendingCommandGrants(),u=dp(u,a),typeof u.umask==`number`&&(this.umask=u.umask),u.env&&(this.lastEnv=YV(u.env)),u.env&&this.lastEnv.PATH!==c&&await this.syncJshCommands().catch(()=>void 0),this.pendingEnvWrites.size>0){for(let[e,t]of this.pendingEnvWrites)t===null?delete this.lastEnv[e]:this.lastEnv[e]=t;this.pendingEnvWrites.clear()}if(u.env?.PWD&&(this.cwd=u.env.PWD),u.exitCode===127){let t=await this.tryJshFallback(e,n);if(t)return this.syncJshCommands().catch(()=>void 0),t}if(u.exitCode!==0&&u.stderr.includes(`Permission denied`)){let{withShebangExecHint:e}=await import(`./shebang-exec-hint-BISPom3l.js`);return fp(await e(u,this.cwd,this.vfsAdapter),u.pipeStatus)}return u}isTransparentGatingEnabled(){let e=this.options.sudo;return!!e&&e.transparentGating!==!1}wrapCommandForDispatch(e){let t=this.wrapCommandForSudo(e),n=e.name===`timeout`?Kp(t,this.progress):Jp(t,this.progress),r=()=>this.scriptRun?.stepDone(),i=(e,t)=>this.teeCommandOutput(e,t),a=this.outputTees;return{...n,async execute(e,t){let o=t.env?.get(qV),s=o?a.get(o):void 0;s&&(t.writeStdout=s);try{let r=await n.execute(e,t);return i(t.env,r),r}finally{r()}}}}teeCommandOutput(e,t){let n=e?.get(qV);if(!n)return;let r=this.outputTees.get(n);if(!r)return;let i=[t.stdout,t.stderr].filter(Boolean).join(``);i&&r(i)}beginScriptRun(e){if(this.scriptRunsActive+=1,!this.progress.hasSink())return null;if(this.scriptRunsActive>1)return this.scriptRun?.end(),this.scriptRun=null,null;let t={totalSteps:null};try{t=Lp(this.bash.transform(e).ast,this.registryNames)}catch{t={totalSteps:null}}return this.scriptRun=new zp(t,this.progress,Rp(e)),this.scriptRun}endScriptRun(e){this.scriptRunsActive=Math.max(0,this.scriptRunsActive-1),e&&(e.end(),this.scriptRun===e&&(this.scriptRun=null))}wrapCommandForSudo(e){if(!this.isTransparentGatingEnabled())return e;let t=(t,n)=>this.gateCommandDispatch(e.name,t,n);return{...e,async execute(n,r){return await t(n,r.env?.get(em))||e.execute(n,r)}}}async gateCommandDispatch(e,t,n){let r=this.options.sudo;if(!r)return null;let i=Xp(e,t);if(this.consumeSudoBypass(i))return null;let a=r.getPolicy();if(!a)return null;let o=await Qp(i,{policy:a,broker:r.broker,persistGrant:async e=>{this.pendingCommandGrants.push(e)},defaultDisposition:r.defaultDisposition,...n?{reason:n}:{}});return o.allowed?null:{stdout:``,stderr:`${o.message}\n`,exitCode:o.exitCode??77}}registerSudoBypass(e){let t=e.trim();t&&this.pendingSudoBypasses.set(t,(this.pendingSudoBypasses.get(t)??0)+1)}consumeSudoBypass(e){let t=this.pendingSudoBypasses.get(e);return t?(t===1?this.pendingSudoBypasses.delete(e):this.pendingSudoBypasses.set(e,t-1),!0):!1}async flushPendingCommandGrants(){if(this.pendingCommandGrants.length===0)return;let e=this.pendingCommandGrants;this.pendingCommandGrants=[];for(let t of e)try{await this.persistCommandGrant(t)}catch{}}async persistCommandGrant(e){let t=this.options.sudo?.persistCommandGrant;if(t){await t(e);return}let n=rt(e);if(!n)return;let r=`${at}/granted`,i=this.options.fs,a=``;try{await i.exists(r)&&(a=await i.readFile(r))}catch(e){if(!(e instanceof Fe&&e.code===`ENOENT`))throw e}let o=a&&!a.endsWith(`
3479
- `)?`${a}\n`:a;await i.writeFile(r,`${o}NOPASSWD Cmnd ${n}\n`)}isCommandAllowed(e){return this.allowedCommands===null||this.allowedCommands.has(e)}async doSyncJshCommands(){try{let e=await this.scriptCatalog.getJshIndex(this.currentScanRoots()),t=e.commands;for(let t of e.collisions)GV.warn(`jsh command '${t.name}' is provided by more than one skill; using ${t.winnerPath} (${t.reason}), shadowed ${t.shadowedPaths.join(`, `)}`);let n=await this.getFilteredWorkflowCommands();for(let[e,n]of t)this.isCommandAllowed(e)&&(this.builtinCommandNames.has(e)&&!this.registeredJshCommands.has(e)||this.registeredJshCommands.get(e)!==n&&(this.bash.registerCommand(this.wrapCommandForDispatch(this.makeScriptCommand(e))),this.registeredJshCommands.set(e,n),this.builtinCommandNames.add(e)));for(let e of n.keys())if(!this.registeredWorkflowCommands.has(e)){if(this.registeredJshCommands.has(e)){this.registeredWorkflowCommands.add(e);continue}this.builtinCommandNames.has(e)||(this.bash.registerCommand(this.wrapCommandForDispatch(this.makeScriptCommand(e))),this.registeredWorkflowCommands.add(e),this.builtinCommandNames.add(e))}}finally{this.jshSyncInflight=null,this.jshSyncDirty&&(this.jshSyncDirty=!1,this.syncJshCommands().catch(()=>void 0))}}makeScriptCommand(e){let t=this.scriptCatalog,n=this.options.jshDiscoveryFs??this.options.fs,r=e,i=async(e,i)=>{let a=i.exec??((e,t)=>this.bash.exec(e,{env:t?.env??Object.fromEntries(i.env),cwd:t?.cwd??i.cwd,args:t?.args,...t?.env===void 0?{}:{replaceEnv:!0}})),o=(await t.getJshCommands(this.currentScanRoots())).get(r);if(o){let t;try{let e=await n.readFile(o,{encoding:`utf-8`});t=typeof e==`string`?e:new TextDecoder().decode(e)}catch{return{stdout:``,stderr:`jsh: cannot read script '${o}'\n`,exitCode:127}}return Ur(t,[`node`,o,...e],{fs:i.fs,cwd:i.cwd,env:i.env,stdin:i.stdin,exec:a},this.buildJshProcessConfig(JV(i.env)))}let s=(await t.getWorkflowCommands()).get(r);if(s){let t=ai(s.path,e);return a(t[0],{args:t.slice(1),cwd:i.cwd})}return{stdout:``,stderr:`${r}: command no longer exists\n`,exitCode:127}};return{name:e,trusted:!0,async execute(e,t){try{return await i(e,t)}catch(e){let t=e instanceof Error?e.message:String(e);return{stdout:``,stderr:`${r}: ${t}\n`,exitCode:1}}}}}createGitCustomCommand(){let e=this.gitCommands;return S(`git`,async(t,n)=>{let r=n.cwd,i=await e.execute(t,r,n.env,P(n.stdin));return{stdout:i.stdout,stderr:i.stderr,exitCode:i.exitCode}})}createMountCustomCommand(){let e=this.mountCommands;return S(`mount`,async(t,n)=>{let r=n.cwd,i=await e.execute(t,r,n.env);return{stdout:i.stdout,stderr:i.stderr,exitCode:i.exitCode}})}createUmountCustomCommand(){let e=this.mountCommands;return S(`umount`,async(t,n)=>{let r=n.cwd,i=await e.executeUmount(t,r);return{stdout:i.stdout,stderr:i.stderr,exitCode:i.exitCode}})}async getFilteredJshCommands(){let e=await this.scriptCatalog.getJshCommands(this.currentScanRoots()),t=new Map;for(let[n,r]of e)this.builtinCommandNames.has(n)||this.isCommandAllowed(n)&&t.set(n,r);return t}async getFilteredWorkflowCommands(){let e=await this.scriptCatalog.getWorkflowCommands(),t=new Map;for(let[n,r]of e)this.isCommandAllowed(n)&&t.set(n,r);return t}async getWorkflowCommandNames(){return[...(await this.getFilteredWorkflowCommands()).keys()]}async tryJshFallback(e,t){let n=e.trim(),r=n.indexOf(` `),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1).trim():``,o=(await this.getFilteredJshCommands()).get(i);if(!o)return null;let s=a?rp(a):[],c=this.options.jshDiscoveryFs??this.options.fs,l;try{let e=await c.readFile(o,{encoding:`utf-8`});l=typeof e==`string`?e:new TextDecoder().decode(e)}catch{return{stdout:``,stderr:`jsh: cannot read script '${o}'\n`,exitCode:127,env:this.lastEnv}}let u=[`node`,o,...s],d=await Ur(l,u,{fs:this.vfsAdapter,cwd:this.cwd,env:new Map(Object.entries(this.lastEnv)),stdin:``,exec:(e,t)=>this.bash.exec(e,{env:t?.env??this.lastEnv,cwd:t?.cwd??this.cwd,umask:this.umask,...t?.env===void 0?{}:{replaceEnv:!0}})},this.buildJshProcessConfig(t));return{stdout:d.stdout,stderr:d.stderr,exitCode:d.exitCode,env:this.lastEnv}}buildJshProcessConfig(e){if(!(!this.options.processManager||!this.options.processOwner))return{processManager:this.options.processManager,owner:this.options.processOwner,getParentPid:()=>e??this.activeShellPid??this.options.getCurrentShellPid?.()}}};export{fa as C,xo as S,Io as _,GB as a,Sa as b,hp as c,ms as d,ss as f,Lo as g,ts as h,VB as i,ep as l,rs as m,HV as n,zB as o,is as p,FV as r,$p as s,XV as t,hs as u,Do as v,xa as x,va as y};
3484
+ `,stderr:``,exitCode:0};let n;try{n=xV(e)}catch(e){return lV(e.message)}let r=n.positional[0],i=n.positional[1],a=!r||r===`-`,o;try{o=await CV(t,r,a)}catch{return lV(`${r}: No such file or directory`)}if(n.revert){let e=fV(o),r=n.plain?_V(e):vV(e);return i?(await t.fs.writeFile(t.fs.resolvePath(t.cwd,i),r),{stdout:``,stderr:``,exitCode:0}):{stdout:fV(r),stderr:``,exitCode:0}}let{data:s,base:c}=TV(n,o),l=wV(n,s,c,r,a);return i?(await t.fs.writeFile(t.fs.resolvePath(t.cwd,i),l),{stdout:``,stderr:``,exitCode:0}):{stdout:l,stderr:``,exitCode:0}})}async function DV(e,t,n,r){if((await e.fs.stat(t)).isFile)return r[n]=await e.fs.readFileBuffer(t),1;let i=await e.fs.readdir(t),a=0;for(let o of i){let i=er(t,o),s=n?`${n}/${o}`:o;a+=await DV(e,i,s,r)}return a}function OV(){return{stdout:`usage: zip [-r] <archive.zip> <path> [path...]
3485
+ `,stderr:``,exitCode:0}}function kV(){return S(`zip`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return OV();let n=!1,r=[];for(let t of e){if(t===`-r`){n=!0;continue}if(t.startsWith(`-`))return{stdout:``,stderr:`zip: unsupported option ${t}\n`,exitCode:1};r.push(t)}if(r.length<2)return{stdout:``,stderr:`zip: expected archive path and at least one input path
3486
+ `,exitCode:1};let i=t.fs.resolvePath(t.cwd,r[0]),a=r.slice(1),o={},s=0;for(let e of a){let r=t.fs.resolvePath(t.cwd,e),i=await t.fs.stat(r),a=(e.startsWith(`/`)?e.slice(1):e.replace(/^\.\//,``))||tr(r);if(i.isDirectory&&!n)return{stdout:``,stderr:`zip: ${e} is a directory (use -r)\n`,exitCode:1};s+=await DV(t,r,a,o)}if(s===0)return{stdout:``,stderr:`zip: nothing to do
3487
+ `,exitCode:1};let c=Ct(o);return await t.fs.writeFile(i,c),{stdout:`created ${i} (${s} file(s))\n`,stderr:``,exitCode:0}})}function AV(e){return{setEnv:e.setEnv,unsetEnv:e.unsetEnv,broker:e.sudoCommand?.broker}}function jV(e){let{fs:t,fetch:n}=e;if(!t||!n)return[];let r={fs:t,fetch:n,scriptCatalog:e.scriptCatalog,syncScriptCommands:e.syncScriptCommands};return[GD(`ipk`,r),GD(`npm`,r),GD(`i`,r),PO(`ipx`,{fs:t,fetch:n}),PO(`npx`,{fs:t,fetch:n}),Qy(`di`,{fs:t,fetch:n}),Qy(`uv`,{fs:t,fetch:n}),sR({fs:t,fetch:n})]}function MV(e={}){let t=[XT({getJshCommands:e.getJshCommands,getWorkflowCommands:e.getWorkflowCommands}),ne(),JF(),pF(),oF(e.browserAPI,e.fs),Wj(e.browserAPI),my(e.browserAPI),nD(e),kV(),LL(),kI(e.fs?{fs:e.fs}:{}),tI(),cI(),aI(),lv(),EV(),HF(`sqlite3`),HF(`sqllite`),KI(),fL(),mx(),G_(),sj({buildProcessConfig:e.buildProcessConfig}),sj({buildProcessConfig:e.buildProcessConfig},`jsh`),oN(`python3`,{buildProcessConfig:e.buildProcessConfig}),oN(`python`,{buildProcessConfig:e.buildProcessConfig}),...jV(e),...e.fs?[bS({fs:e.fs})]:[],...e.fs?[yA({fs:e.fs})]:[],...e.fetch?[cE({fetch:e.fetch,streamFetch:e.streamFetch})]:[],sS(),cS(),Kz(e.webhook),jB(),py(e.crontask),Ek({fs:e.fs,scriptCatalog:e.scriptCatalog}),uM({fs:e.fs,fetch:e.fetch}),yS(),NF(),Gj(),Kj(`pdftk`),Kj(`pdf`),K_(`biscotto`),K_(`biscotti`),nM(`pdftoppm`),nM(`pdftocairo`),rM(`pdftotext`),Zv(`convert`),Zv(`magick`),LB({fs:e.fs,scriptCatalog:e.scriptCatalog,getStaticBuiltins:e.getStaticBuiltins,getScriptRegisteredNames:e.getScriptRegisteredNames}),gL(),ML(),QE(),$E(),NL(),bA(),uN(),bk(),zb(),Sj(),xj(),_k(),jP(AV(e)),CN({fs:e.fs}),YN(),ov(),sv(),cv(`xclip`),cv(`xsel`),JN(),RS(),_g(),vg(),qA(e.fs),tt(),fj(),Rg({getParentJid:e.getParentJid}),qb(),MM({processManager:e.processManager}),SR({processManager:e.processManager}),LO({processManager:e.processManager}),FO({processManager:e.processManager,scriptCatalog:e.scriptCatalog}),...Vg(),vA(),lk(),qR(),PE(),Yx(),lz({processManager:e.processManager}),fv({processManager:e.processManager,browser:e.browserAPI,sudoBroker:e.sudoCommand?.broker}),oS(),$_({registry:e.cherryRuntimeRegistry}),xy(),Oy({fs:e.fs}),ky({fs:e.fs}),XF(e.sudoCommand),eV({getParentJid:e.getParentJid,syncScriptCommands:e.syncScriptCommands}),MB(),fF()];return e.fs&&(aM(),t.push(...Nn.map(t=>qT(t,e.browserAPI,e.fs,{isScoop:e.isScoop})))),t}let NV=null;function PV(e){NV=e}function FV(e){NV?.(e)}var IV=Dt();const LV=Reflect.get(Ye,`DefenseInDepthBox`);function RV(e){return(typeof e==`string`?e:e?.encoding)??`utf8`}function zV(e,t){if(typeof e!=`string`)return e;let n=RV(t);if(n===`binary`||n===`latin1`){let t=ue(e);if(t)return t}return IV.Buffer.from(e,n)}function BV(e){return e===`/bin`?`/usr/bin`:e.startsWith(`/bin/`)?`/usr${e}`:e}var VV=class{vfs;registeredCommandsFn=null;listingStats=new Map;listingStatsMax;listingStatsTtlMs;constructor(e,t){this.vfs=e,this.listingStatsMax=Math.max(1,t?.listingStatsMax??2e4),this.listingStatsTtlMs=t?.listingStatsTtlMs??1e3,this.updateMetadataBatch=this.updateMetadataBatch.bind(this)}get listingStatsSize(){return this.listingStats.size}primeListingStats(e,t){let n=Date.now();if(t.length>this.listingStatsMax){this.listingStats.clear();return}this.sweepExpiredListingStats(n),this.listingStats.size+t.length>this.listingStatsMax&&this.listingStats.clear();let r=e===`/`?`/`:`${e}/`;for(let e of t){let t=Pe(e),i=`${r}${e.name}`;this.listingStats.delete(i),t&&this.listingStats.set(i,{stats:t,at:n})}}sweepExpiredListingStats(e){for(let[t,n]of this.listingStats){if(e-n.at<=this.listingStatsTtlMs)break;this.listingStats.delete(t)}}primedStats(e){let t=this.listingStats.get(e);if(t){if(Date.now()-t.at>this.listingStatsTtlMs){this.listingStats.delete(e);return}return t.stats}}dropListingStats(){this.listingStats.clear()}setRegisteredCommandsFn(e){this.registeredCommandsFn=e}getVirtualBinCommands(){return this.registeredCommandsFn?.()??[]}virtualUsrStat(e){let t=BV(e);if(t===`/usr`||t===`/usr/bin`)return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date(0)};if(t.startsWith(`/usr/bin/`)){let e=t.slice(9);if(e.length>0&&!e.includes(`/`)&&this.getVirtualBinCommands().includes(e))return{isFile:!0,isDirectory:!1,isSymbolicLink:!1,mode:493,size:0,mtime:new Date(0)}}return null}canWrite(e){let t=this.vfs;return typeof t.canWrite!=`function`||t.canWrite(e)}listMountPoints(){let e=this.vfs;return typeof e.listMountPoints==`function`?e.listMountPoints():[]}trusted(e){let t=LV?.runTrustedAsync;return t?t(e):Promise.resolve().then(e)}async readFile(e,t){return this.trusted(async()=>{let n=b(e),r=await this.vfs.readFile(n,{encoding:`binary`}),i=r instanceof Uint8Array?r:new TextEncoder().encode(r),a=RV(t),o=IV.Buffer.from(i.buffer,i.byteOffset,i.byteLength).toString(a);return a!==`hex`&&a!==`base64`&&g(o,i),o})}async readFileBuffer(e){return this.trusted(async()=>{let t=b(e),n=await this.vfs.readFile(t,{encoding:`binary`});return n instanceof Uint8Array?n:new TextEncoder().encode(n)})}async readFileBytes(e){let t=await this.readFileBuffer(e);return IV.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString(`latin1`)}async getNativeFile(e){return this.trusted(()=>this.vfs.getNativeFile(b(e)))}async readFileRange(e,t,n){return this.trusted(()=>this.vfs.readFileRange(b(e),t,n))}async writeFile(e,t,n){return this.dropListingStats(),this.trusted(async()=>{let r=b(e);await this.vfs.writeFile(r,zV(t,n))})}async appendFile(e,t,n){return this.dropListingStats(),this.trusted(()=>this.vfs.appendFile(b(e),zV(t,n)))}async exists(e){return this.trusted(async()=>{let t=b(e);return this.virtualUsrStat(t)?!0:this.vfs.exists(t)})}async stat(e){return this.trusted(async()=>{let t=b(e),n=this.virtualUsrStat(t);if(n)return n;let r=this.vfs.statSync(t);if(r)return{isFile:r.type===`file`,isDirectory:r.type===`directory`,isSymbolicLink:!!r.isSymlink,mode:r.mode??(r.type===`directory`?493:420),size:r.size,mtime:new Date(r.mtime),identity:r.identity,dev:r.dev,ino:r.identity===void 0?void 0:r.ino};let i=this.primedStats(t)??await this.vfs.stat(t);return{isFile:i.type===`file`,isDirectory:i.type===`directory`,isSymbolicLink:!!i.isSymlink,mode:i.mode??(i.type===`directory`?493:420),size:i.size,mtime:new Date(i.mtime),identity:i.identity,dev:i.dev,ino:i.identity===void 0?void 0:i.ino}})}async lstat(e){return this.trusted(async()=>{let t=b(e),n=this.virtualUsrStat(t);if(n)return n;let r=this.vfs.lstatSync(t);if(r)return{isFile:r.type===`file`,isDirectory:r.type===`directory`,isSymbolicLink:r.type===`symlink`,mode:r.mode??(r.type===`directory`?493:r.type===`symlink`?511:420),size:r.size,mtime:new Date(r.mtime),identity:r.identity,dev:r.dev,ino:r.identity===void 0?void 0:r.ino};let i=this.primedStats(t)??await this.vfs.lstat(t);return{isFile:i.type===`file`,isDirectory:i.type===`directory`,isSymbolicLink:i.type===`symlink`,mode:i.mode??(i.type===`directory`?493:i.type===`symlink`?511:420),size:i.size,mtime:new Date(i.mtime),identity:i.identity,dev:i.dev,ino:i.identity===void 0?void 0:i.ino}})}async mkdir(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.mkdir(b(e),t)})}async readdir(e){return this.trusted(async()=>{let t=b(e);if(t===`/usr`)return[`bin`];if(BV(t)===`/usr/bin`)return this.getVirtualBinCommands().slice().sort();let n=this.vfs.readDirSync(t);if(n!==null)return n.map(e=>e.name);let r=await this.vfs.readDir(t,{includeStats:!0});return this.primeListingStats(t,r),r.map(e=>e.name)})}async readdirWithFileTypes(e){return this.trusted(async()=>{let t=b(e);if(t===`/usr`)return[{name:`bin`,isFile:!1,isDirectory:!0,isSymbolicLink:!1}];if(BV(t)===`/usr/bin`)return this.getVirtualBinCommands().slice().sort().map(e=>({name:e,isFile:!0,isDirectory:!1,isSymbolicLink:!1}));let n=this.vfs.readDirSync(t);if(n!==null)return this.mapFastEntriesToDirents(n);let r=await this.vfs.readDir(t,{includeStats:!0});return this.primeListingStats(t,r),this.mapAsyncEntriesToDirents(r)})}mapFastEntriesToDirents(e){return e.map(e=>this.entryToDirent(e))}mapAsyncEntriesToDirents(e){return e.map(e=>this.entryToDirent(e))}entryToDirent(e){return e.type===`symlink`?{name:e.name,isFile:!1,isDirectory:!1,isSymbolicLink:!0}:{name:e.name,isFile:e.type===`file`,isDirectory:e.type===`directory`,isSymbolicLink:!1}}async rm(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.rm(b(e),t)})}async cp(e,t,n){return this.dropListingStats(),this.trusted(async()=>{let r=b(e),i=b(t);if((await this.vfs.stat(r)).type===`directory`){if(!n?.recursive)throw new Fe(`EISDIR`,`is a directory`,r);await this.cpDir(r,i)}else await this.vfs.copyFile(r,i)})}async cpDir(e,t){await this.vfs.mkdir(t,{recursive:!0});let n=await this.vfs.readDir(e);for(let r of n){let n=x(e,r.name),i=x(t,r.name);r.type===`directory`?await this.cpDir(n,i):await this.vfs.copyFile(n,i)}}async mv(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.rename(b(e),b(t))})}async rename(e,t){return this.mv(e,t)}resolvePath(e,t){return t.startsWith(`/`)?b(t):b(x(e,t))}getAllPaths(){return[]}async chmod(e,t){return this.dropListingStats(),this.trusted(()=>this.vfs.chmod(b(e),t))}async updateMetadataBatch(e){return this.dropListingStats(),this.trusted(()=>this.vfs.updateMetadataBatch(e.map(e=>({...e,path:b(e.path)}))))}async symlink(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.symlink(e,b(t))})}async link(e,t){throw Error(`Hard links not supported in VirtualFS`)}async readlink(e){return this.trusted(async()=>this.vfs.readlink(b(e)))}async realpath(e){return this.trusted(async()=>this.vfs.realpath(b(e)))}async utimes(e,t,n){return this.dropListingStats(),this.trusted(()=>this.vfs.utimes(b(e),t,n))}invalidatePaths(e){this.dropListingStats();let t=this.vfs;t.invalidatePaths&&t.invalidatePaths(e)}async forgetSidecarConsistency(){await this.vfs.forgetSidecarConsistency?.()}};function HV(e){return e&&typeof e.getWatcher==`function`?e.getWatcher?.()??null:e&&typeof e.getUnderlyingFS==`function`?HV(e.getUnderlyingFS?.()):null}async function UV(e){let t=le(`github`);if(t){if(e?.force){await t.onSilentRenew?.();return}await t.getValidAccessToken?.()}}const WV=e(`almost-bash-shell`),GV=`__SLICC_RUN_PID`,KV=`__SLICC_OUTPUT_TEE__`;function qV(e){let t=e?.get(GV);if(t===void 0)return;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>0?n:void 0}function JV(e){if(!(GV in e)&&!(KV in e)&&!(`__SLICC_SUDO_REASON`in e)&&!(`__SLICC_PIPESTATUS`in e)&&!(`__SLICC_PIPESTATUS_EX`in e))return{...e};let{[GV]:t,[KV]:n,[em]:r,[ip]:i,[ap]:a,...o}=e;return o}var YV=class e{options;bash;vfsAdapter;gitCommands;mountCommands;lastEnv;cwd;umask=18;builtinCommandNames;staticBuiltinNames;allowedCommands;scriptCatalog;initialJshSync=null;ownsScriptCatalog;registeredJshCommands=new Map;registeredWorkflowCommands=new Set;jshSyncInflight=null;jshSyncDirty=!1;pendingCommandGrants=[];pendingSudoBypasses=new Map;pendingEnvWrites=new Map;activeShellPid;progress;activeRunSignal;scriptRun=null;scriptRunsActive=0;registryNames=new Set;outputTees=new Map;nextOutputTeeId=0;resolveJshProcessConfig=e=>this.buildJshProcessConfig(qV(e));static buildAllowedCommandSet(e){return e.sudo?.defaultDisposition===`require-approval`||!e.allowedCommands||e.allowedCommands.includes(`*`)?null:new Set(e.allowedCommands)}static buildInitialEnv(e,t){return{HOME:ep,PATH:Un,USER:`user`,SHELL:`/bin/bash`,TMPDIR:`/tmp`,PWD:t,...e.env}}buildSupplementalCommands(e,t,n){return MV({onMediaPreview:async e=>this.renderMediaPreview(e),getJshCommands:()=>this.getJshCommandNames(),getWorkflowCommands:()=>this.getWorkflowCommandNames(),syncScriptCommands:()=>this.syncJshCommands(),getStaticBuiltins:()=>[...this.staticBuiltinNames],getScriptRegisteredNames:()=>[...this.registeredJshCommands.keys(),...this.registeredWorkflowCommands],fs:e.fs,fetch:t,streamFetch:n,scriptCatalog:this.scriptCatalog,browserAPI:e.browserAPI,webhook:e.webhook,crontask:e.crontask,getParentJid:e.getParentJid,isScoop:e.isScoop,buildProcessConfig:this.resolveJshProcessConfig,processManager:e.processManager,sudoCommand:e.sudo?{broker:e.sudo.broker,persistGrant:async e=>{this.pendingCommandGrants.push(e)},suppressNextGate:e=>this.registerSudoBypass(e)}:void 0,setEnv:(e,t)=>{this.pendingEnvWrites.set(e,t),this.lastEnv[e]=t},unsetEnv:e=>{this.pendingEnvWrites.set(e,null),delete this.lastEnv[e]}})}constructor(t){this.options=t,this.vfsAdapter=new VV(t.fs),this.progress=new gp({scrubLabel:t.scrubProgressLabel}),this.allowedCommands=e.buildAllowedCommandSet(t);let n=t.cwd??`/`,r=e.buildInitialEnv(t,n);this.gitCommands=new Zf({fs:t.fs,authorName:r.GIT_AUTHOR_NAME??`User`,authorEmail:r.GIT_AUTHOR_EMAIL??`user@example.com`,ensureFreshGithubToken:UV}),this.mountCommands=new Cs({fs:t.fs,isScoop:t.isScoop,acquireLocalMountViaToolUI:sm});let i=t.jshDiscoveryFs??t.fs,a=t.bshDiscoveryFs??t.fs,o=HV(i)??HV(a);this.scriptCatalog=t.scriptCatalog??new oi({jshFs:i,bshFs:a,watcher:o}),this.ownsScriptCatalog=!t.scriptCatalog,o&&o.watch(`/`,e=>e.endsWith(`.jsh`)||e.endsWith(`.workflow.js`),()=>{this.syncJshCommands().catch(()=>void 0)});let s=this.createGitCustomCommand(),c=p({progress:xp(this.progress)}),l=h({progress:xp(this.progress)}),u=this.buildSupplementalCommands(t,c,l),d=[s,this.createMountCustomCommand(),this.createUmountCustomCommand(),th(t.fs),Qh(t.fs,c,t.browserAPI),...u].filter(e=>this.isCommandAllowed(e.name)),f=[...Ze(),...Xe()],m=this.allowedCommands?f.filter(e=>this.isCommandAllowed(e)):void 0;if(this.bash=new Qe({fs:this.vfsAdapter,cwd:n,env:{},fetch:c,commands:m,customCommands:d,sleep:Hp(this.progress,{isAborted:()=>this.activeRunSignal?.aborted??!1}),executionLimitProfile:t.executionLimitProfile,executionLimits:$f(t.isScoop?.()??!1,t.executionLimits)}),this.bash.registerTransformPlugin(hm),this.allowedCommands!==null){let e=this.bash;for(let t of Xe())this.isCommandAllowed(t)||e.commands.delete(t)}{let e=this.bash;for(let[t,n]of e.commands)e.commands.set(t,this.wrapCommandForDispatch(n));this.registryNames=new Set(e.commands.keys())}let g=d.map(e=>e.name),_=m??[...Ze(),...Xe()];this.builtinCommandNames=new Set([..._,...g]),this.staticBuiltinNames=new Set(this.builtinCommandNames),this.vfsAdapter.setRegisteredCommandsFn(()=>[...this.builtinCommandNames]),this.lastEnv={...r},this.cwd=n,this.startInitialJshSync()}getBash(){return this.bash}getCwd(){return this.cwd}getScriptCatalog(){return this.scriptCatalog}getEnv(){return{...this.lastEnv}}setMaskedEnvVar(e,t){this.pendingEnvWrites.set(e,t),this.lastEnv[e]=t}applySessionOverrides(e){e.cwd!==void 0&&(this.cwd=e.cwd,this.lastEnv.PWD=e.cwd),e.env&&Object.assign(this.lastEnv,e.env)}async getJshCommandNames(){return[...(await this.getFilteredJshCommands()).keys()]}async syncJshCommands(){return this.jshSyncInflight===null?(this.jshSyncInflight=this.doSyncJshCommands(),this.jshSyncInflight):(this.jshSyncDirty=!0,this.jshSyncInflight)}async executeCommand(e,t,n,r=``,i){let a=this.activeShellPid;n!==void 0&&(this.activeShellPid=n);let o=i?.onOutput?`tee-${this.nextOutputTeeId+=1}`:void 0;o&&i?.onOutput&&this.outputTees.set(o,i.onOutput);try{let a=await this.runCommand(e,t,n,r,o,i?.capturePipeStatus);return{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode,...a.pipeStatus===void 0?{}:{pipeStatus:a.pipeStatus}}}finally{this.activeShellPid=a,o&&this.outputTees.delete(o)}}async executeScriptFile(e,t=[]){return Br(e,t,{fs:this.vfsAdapter,cwd:this.cwd,env:new Map(Object.entries(this.lastEnv)),stdin:``,exec:(e,t)=>this.bash.exec(e,{env:t?.env??this.lastEnv,cwd:t?.cwd??this.cwd,umask:this.umask,...t?.env===void 0?{}:{replaceEnv:!0}})},this.buildJshProcessConfig())}dispose(){this.ownsScriptCatalog&&this.scriptCatalog.dispose()}async renderMediaPreview(e){throw Error(`terminal preview is unavailable in headless mode`)}currentScanRoots(){return Wn(this.lastEnv.PATH)}startInitialJshSync(){this.initialJshSync=this.initHomeAndProfile().then(()=>this.syncJshCommands()).catch(()=>void 0).finally(()=>{this.initialJshSync=null})}async initHomeAndProfile(){let e=this.options.fs;try{let t=this.options.env?.HOME??await tp(e);this.lastEnv.HOME=t,this.options.env?.USER||(this.lastEnv.USER=np(t));let n=`${t.replace(/\/+$/,``)}/.profile`;if(!await e.exists(n).catch(()=>!1))return;let r=await this.bash.exec(`. "$HOME/.profile"`,{env:this.lastEnv,cwd:this.cwd,umask:this.umask});if(typeof r.umask==`number`&&(this.umask=r.umask),r.env){let{PWD:e,...t}=r.env;this.lastEnv={...t,PWD:this.lastEnv.PWD??this.cwd}}}catch(e){WV.warn(`HOME/profile init failed; continuing with defaults`,e)}}async waitForInitialJshSync(e){let t=this.initialJshSync;if(t===null)return;if(!e){await t;return}if(e.aborted)return;let n;try{await new Promise(r=>{n=()=>r(),e.addEventListener(`abort`,n,{once:!0}),t.then(()=>r(),()=>r())})}finally{n&&e.removeEventListener(`abort`,n)}}async runCommand(e,t,n,r=``,i,a=!1){FV(e.trim().split(/\s+/)[0]||`unknown`),m(),await this.waitForInitialJshSync(t);let o=nm(e),s={env:{...this.lastEnv,...n===void 0?{}:{[GV]:String(n)},...i===void 0?{}:{[KV]:i},...o?{[em]:o}:{}},cwd:this.cwd,umask:this.umask,signal:t,...r===``?{}:{stdin:r,stdinKind:`bytes`}},c=this.lastEnv.PATH;this.activeRunSignal=t;let l=this.beginScriptRun(e),u;try{u=await this.bash.exec(up(e,a),s)}finally{this.activeRunSignal===t&&(this.activeRunSignal=void 0),this.endScriptRun(l)}if(await this.flushPendingCommandGrants(),u=dp(u,a),typeof u.umask==`number`&&(this.umask=u.umask),u.env&&(this.lastEnv=JV(u.env)),u.env&&this.lastEnv.PATH!==c&&await this.syncJshCommands().catch(()=>void 0),this.pendingEnvWrites.size>0){for(let[e,t]of this.pendingEnvWrites)t===null?delete this.lastEnv[e]:this.lastEnv[e]=t;this.pendingEnvWrites.clear()}if(u.env?.PWD&&(this.cwd=u.env.PWD),u.exitCode===127){let t=await this.tryJshFallback(e,n);if(t)return this.syncJshCommands().catch(()=>void 0),t}if(u.exitCode!==0&&u.stderr.includes(`Permission denied`)){let{withShebangExecHint:e}=await import(`./shebang-exec-hint-BISPom3l.js`);return fp(await e(u,this.cwd,this.vfsAdapter),u.pipeStatus)}return u}isTransparentGatingEnabled(){let e=this.options.sudo;return!!e&&e.transparentGating!==!1}wrapCommandForDispatch(e){let t=this.wrapCommandForSudo(e),n=e.name===`timeout`?Kp(t,this.progress):Jp(t,this.progress),r=()=>this.scriptRun?.stepDone(),i=(e,t)=>this.teeCommandOutput(e,t),a=this.outputTees;return{...n,async execute(e,t){let o=t.env?.get(KV),s=o?a.get(o):void 0;s&&(t.writeStdout=s);try{let r=await n.execute(e,t);return i(t.env,r),r}finally{r()}}}}teeCommandOutput(e,t){let n=e?.get(KV);if(!n)return;let r=this.outputTees.get(n);if(!r)return;let i=[t.stdout,t.stderr].filter(Boolean).join(``);i&&r(i)}beginScriptRun(e){if(this.scriptRunsActive+=1,!this.progress.hasSink())return null;if(this.scriptRunsActive>1)return this.scriptRun?.end(),this.scriptRun=null,null;let t={totalSteps:null};try{t=Lp(this.bash.transform(e).ast,this.registryNames)}catch{t={totalSteps:null}}return this.scriptRun=new zp(t,this.progress,Rp(e)),this.scriptRun}endScriptRun(e){this.scriptRunsActive=Math.max(0,this.scriptRunsActive-1),e&&(e.end(),this.scriptRun===e&&(this.scriptRun=null))}wrapCommandForSudo(e){if(!this.isTransparentGatingEnabled())return e;let t=(t,n)=>this.gateCommandDispatch(e.name,t,n);return{...e,async execute(n,r){return await t(n,r.env?.get(em))||e.execute(n,r)}}}async gateCommandDispatch(e,t,n){let r=this.options.sudo;if(!r)return null;let i=Xp(e,t);if(this.consumeSudoBypass(i))return null;let a=r.getPolicy();if(!a)return null;let o=await Qp(i,{policy:a,broker:r.broker,persistGrant:async e=>{this.pendingCommandGrants.push(e)},defaultDisposition:r.defaultDisposition,...n?{reason:n}:{}});return o.allowed?null:{stdout:``,stderr:`${o.message}\n`,exitCode:o.exitCode??77}}registerSudoBypass(e){let t=e.trim();t&&this.pendingSudoBypasses.set(t,(this.pendingSudoBypasses.get(t)??0)+1)}consumeSudoBypass(e){let t=this.pendingSudoBypasses.get(e);return t?(t===1?this.pendingSudoBypasses.delete(e):this.pendingSudoBypasses.set(e,t-1),!0):!1}async flushPendingCommandGrants(){if(this.pendingCommandGrants.length===0)return;let e=this.pendingCommandGrants;this.pendingCommandGrants=[];for(let t of e)try{await this.persistCommandGrant(t)}catch{}}async persistCommandGrant(e){let t=this.options.sudo?.persistCommandGrant;if(t){await t(e);return}let n=rt(e);if(!n)return;let r=`${at}/granted`,i=this.options.fs,a=``;try{await i.exists(r)&&(a=await i.readFile(r))}catch(e){if(!(e instanceof Fe&&e.code===`ENOENT`))throw e}let o=a&&!a.endsWith(`
3488
+ `)?`${a}\n`:a;await i.writeFile(r,`${o}NOPASSWD Cmnd ${n}\n`)}isCommandAllowed(e){return this.allowedCommands===null||this.allowedCommands.has(e)}async doSyncJshCommands(){try{let e=await this.scriptCatalog.getJshIndex(this.currentScanRoots()),t=e.commands;for(let t of e.collisions)WV.warn(`jsh command '${t.name}' is provided by more than one skill; using ${t.winnerPath} (${t.reason}), shadowed ${t.shadowedPaths.join(`, `)}`);let n=await this.getFilteredWorkflowCommands();for(let[e,n]of t)this.isCommandAllowed(e)&&(this.builtinCommandNames.has(e)&&!this.registeredJshCommands.has(e)||this.registeredJshCommands.get(e)!==n&&(this.bash.registerCommand(this.wrapCommandForDispatch(this.makeScriptCommand(e))),this.registeredJshCommands.set(e,n),this.builtinCommandNames.add(e)));for(let e of n.keys())if(!this.registeredWorkflowCommands.has(e)){if(this.registeredJshCommands.has(e)){this.registeredWorkflowCommands.add(e);continue}this.builtinCommandNames.has(e)||(this.bash.registerCommand(this.wrapCommandForDispatch(this.makeScriptCommand(e))),this.registeredWorkflowCommands.add(e),this.builtinCommandNames.add(e))}}finally{this.jshSyncInflight=null,this.jshSyncDirty&&(this.jshSyncDirty=!1,this.syncJshCommands().catch(()=>void 0))}}makeScriptCommand(e){let t=this.scriptCatalog,n=this.options.jshDiscoveryFs??this.options.fs,r=e,i=async(e,i)=>{let a=i.exec??((e,t)=>this.bash.exec(e,{env:t?.env??Object.fromEntries(i.env),cwd:t?.cwd??i.cwd,args:t?.args,...t?.env===void 0?{}:{replaceEnv:!0}})),o=(await t.getJshCommands(this.currentScanRoots())).get(r);if(o){let t;try{let e=await n.readFile(o,{encoding:`utf-8`});t=typeof e==`string`?e:new TextDecoder().decode(e)}catch{return{stdout:``,stderr:`jsh: cannot read script '${o}'\n`,exitCode:127}}return Ur(t,[`node`,o,...e],{fs:i.fs,cwd:i.cwd,env:i.env,stdin:i.stdin,exec:a},this.buildJshProcessConfig(qV(i.env)))}let s=(await t.getWorkflowCommands()).get(r);if(s){let t=ai(s.path,e);return a(t[0],{args:t.slice(1),cwd:i.cwd})}return{stdout:``,stderr:`${r}: command no longer exists\n`,exitCode:127}};return{name:e,trusted:!0,async execute(e,t){try{return await i(e,t)}catch(e){let t=e instanceof Error?e.message:String(e);return{stdout:``,stderr:`${r}: ${t}\n`,exitCode:1}}}}}createGitCustomCommand(){let e=this.gitCommands;return S(`git`,async(t,n)=>{let r=n.cwd,i=await e.execute(t,r,n.env,P(n.stdin));return{stdout:i.stdout,stderr:i.stderr,exitCode:i.exitCode}})}createMountCustomCommand(){let e=this.mountCommands;return S(`mount`,async(t,n)=>{let r=n.cwd,i=await e.execute(t,r,n.env);return{stdout:i.stdout,stderr:i.stderr,exitCode:i.exitCode}})}createUmountCustomCommand(){let e=this.mountCommands;return S(`umount`,async(t,n)=>{let r=n.cwd,i=await e.executeUmount(t,r);return{stdout:i.stdout,stderr:i.stderr,exitCode:i.exitCode}})}async getFilteredJshCommands(){let e=await this.scriptCatalog.getJshCommands(this.currentScanRoots()),t=new Map;for(let[n,r]of e)this.builtinCommandNames.has(n)||this.isCommandAllowed(n)&&t.set(n,r);return t}async getFilteredWorkflowCommands(){let e=await this.scriptCatalog.getWorkflowCommands(),t=new Map;for(let[n,r]of e)this.isCommandAllowed(n)&&t.set(n,r);return t}async getWorkflowCommandNames(){return[...(await this.getFilteredWorkflowCommands()).keys()]}async tryJshFallback(e,t){let n=e.trim(),r=n.indexOf(` `),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1).trim():``,o=(await this.getFilteredJshCommands()).get(i);if(!o)return null;let s=a?rp(a):[],c=this.options.jshDiscoveryFs??this.options.fs,l;try{let e=await c.readFile(o,{encoding:`utf-8`});l=typeof e==`string`?e:new TextDecoder().decode(e)}catch{return{stdout:``,stderr:`jsh: cannot read script '${o}'\n`,exitCode:127,env:this.lastEnv}}let u=[`node`,o,...s],d=await Ur(l,u,{fs:this.vfsAdapter,cwd:this.cwd,env:new Map(Object.entries(this.lastEnv)),stdin:``,exec:(e,t)=>this.bash.exec(e,{env:t?.env??this.lastEnv,cwd:t?.cwd??this.cwd,umask:this.umask,...t?.env===void 0?{}:{replaceEnv:!0}})},this.buildJshProcessConfig(t));return{stdout:d.stdout,stderr:d.stderr,exitCode:d.exitCode,env:this.lastEnv}}buildJshProcessConfig(e){if(!(!this.options.processManager||!this.options.processOwner))return{processManager:this.options.processManager,owner:this.options.processOwner,getParentPid:()=>e??this.activeShellPid??this.options.getCurrentShellPid?.()}}};export{fa as C,xo as S,Io as _,WB as a,Sa as b,hp as c,ms as d,ss as f,Lo as g,ts as h,BB as i,ep as l,rs as m,VV as n,RB as o,is as p,PV as r,$p as s,YV as t,hs as u,Do as v,xa as x,va as y};