sliccy 6.255.5 → 6.256.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 (146) hide show
  1. package/dist/ui/.vite/manifest.json +197 -197
  2. package/dist/ui/assets/SKILL-VuC_p7ei.js +1 -0
  3. package/dist/ui/assets/{account-store-WwkvRyt8.js → account-store-DRK_jfiB.js} +1 -1
  4. package/dist/ui/assets/{account-store-BsPvuHqg.js → account-store-QxWo48Y1.js} +1 -1
  5. package/dist/ui/assets/{adobe-OZZX1bUj.js → adobe-BwSa2oAU.js} +1 -1
  6. package/dist/ui/assets/{adobe-CWiVGTr_.js → adobe-XnlO8IOa.js} +1 -1
  7. package/dist/ui/assets/{agent-panels-QqI8RnS-.js → agent-panels-DLsxOOjW.js} +1 -1
  8. package/dist/ui/assets/{almost-bash-shell-headless-B2HJCRwC.js → almost-bash-shell-headless-YXVG1DPI.js} +100 -95
  9. package/dist/ui/assets/{apply-layout-CZRsgtD9.js → apply-layout-BtzT4Jrn.js} +1 -1
  10. package/dist/ui/assets/{azure-openai-NOckheh1.js → azure-openai-BH03ks5Y.js} +1 -1
  11. package/dist/ui/assets/{azure-openai-BGV5eDqL.js → azure-openai-BiTykqg3.js} +1 -1
  12. package/dist/ui/assets/{cdp-C8P_VuCx.js → cdp-Dm3JXxCN.js} +1 -1
  13. package/dist/ui/assets/{cerebras-BaKz2azc.js → cerebras-B5dFzZuU.js} +1 -1
  14. package/dist/ui/assets/{cerebras-CZffTsa_.js → cerebras-Cj-dhgCb.js} +1 -1
  15. package/dist/ui/assets/{composer-speech-BtkuLtwT.js → composer-speech-0uRgiL71.js} +1 -1
  16. package/dist/ui/assets/{connect-surface-BNaL4HXW.js → connect-surface-BQgwhG8d.js} +1 -1
  17. package/dist/ui/assets/{directed-approval-8EV8ESSH.js → directed-approval-BxWIFFqA.js} +1 -1
  18. package/dist/ui/assets/{emscripten-vfs-hook-BihSiIMh.js → emscripten-vfs-hook-C73xuKfz.js} +1 -1
  19. package/dist/ui/assets/{ensure-speech-assets-Cv28XxlO.js → ensure-speech-assets-C0sTcSO2.js} +1 -1
  20. package/dist/ui/assets/{exporter-deps-84yTrW5d.js → exporter-deps-Dv-Y3bF7.js} +1 -1
  21. package/dist/ui/assets/{frozen-archive-writer-Cmw3eIW9.js → frozen-archive-writer-Cr1_j3pp.js} +1 -1
  22. package/dist/ui/assets/{frozen-session-delete-DI7gtRJm.js → frozen-session-delete-CpcHR1XS.js} +1 -1
  23. package/dist/ui/assets/{frozen-session-identity-DsQI6nWd.js → frozen-session-identity-dpueujl9.js} +1 -1
  24. package/dist/ui/assets/{gelatiere-unit-CVRF4erA.js → gelatiere-unit-PHQc3WNq.js} +1 -1
  25. package/dist/ui/assets/{github-O7WrbTST.js → github-Bj8suNGU.js} +1 -1
  26. package/dist/ui/assets/{github-71_7aQqL.js → github-Dvjydy3P.js} +1 -1
  27. package/dist/ui/assets/{github-copilot-rHFfvvbg.js → github-copilot-CpJKXWfn.js} +1 -1
  28. package/dist/ui/assets/{github-copilot-BvCq8hoy.js → github-copilot-D8DdUlya.js} +1 -1
  29. package/dist/ui/assets/{hear-Dt0qxqrD.js → hear-DDr5S4Od.js} +1 -1
  30. package/dist/ui/assets/icons-G2O19FaS.js +1 -0
  31. package/dist/ui/assets/installer-CZYG64aH.js +5 -0
  32. package/dist/ui/assets/ipk-mamba-_UczwftL.js +46 -0
  33. package/dist/ui/assets/{js-realm-worker-CCWU1NGF.js → js-realm-worker-CXD4SmqZ.js} +2 -2
  34. package/dist/ui/assets/{jsh-executor-p0b2gPaG.js → jsh-executor-BFwK2t97.js} +3 -3
  35. package/dist/ui/assets/{kernel-worker-D39FXX2x.js → kernel-worker-DadD3ayk.js} +9 -9
  36. package/dist/ui/assets/{lick-ws-bridge-tfvg197_.js → lick-ws-bridge-Bq9kUe4V.js} +1 -1
  37. package/dist/ui/assets/{lick-ws-bridge-CL2JBgfX.js → lick-ws-bridge-DMNf8klz.js} +1 -1
  38. package/dist/ui/assets/{live-session-curation-CceSftxs.js → live-session-curation-CNk-iYCa.js} +1 -1
  39. package/dist/ui/assets/{live-session-curation-C04Hpmdj.js → live-session-curation-CSJCW_xQ.js} +1 -1
  40. package/dist/ui/assets/{live-session-snapshot-DPBV7Vpb.js → live-session-snapshot-BedjttIR.js} +1 -1
  41. package/dist/ui/assets/{local-llm-DtDE4ic6.js → local-llm-NE-qI2cb.js} +1 -1
  42. package/dist/ui/assets/{local-llm-CD1ViZGA.js → local-llm-qPIX8NMO.js} +1 -1
  43. package/dist/ui/assets/{main-DM_6cn_s.js → main-DVD6CfWm.js} +3 -3
  44. package/dist/ui/assets/{main-cherry-BRMd3VoB.js → main-cherry-ByF5f6AT.js} +1 -1
  45. package/dist/ui/assets/{mcp-command-Ck-K7dGv.js → mcp-command-n1wIw393.js} +10 -10
  46. package/dist/ui/assets/{memory-curation-seam-CuZzxZTL.js → memory-curation-seam-CjYHWDBt.js} +1 -1
  47. package/dist/ui/assets/{memory-health-ZerqpTrD.js → memory-health-DnbzPxqU.js} +1 -1
  48. package/dist/ui/assets/{memory-write-execute-DDtFPt3o.js → memory-write-execute-BQg4KGxO.js} +1 -1
  49. package/dist/ui/assets/{merge-folded-cost-into-frozen-BC4WZlzM.js → merge-folded-cost-into-frozen-DA0swiNk.js} +1 -1
  50. package/dist/ui/assets/{new-session-CaFA4OWF.js → new-session-BHvzb7bp.js} +2 -2
  51. package/dist/ui/assets/{oauth-bootstrap-B8bj-zEl.js → oauth-bootstrap-CqivQ7HA.js} +2 -2
  52. package/dist/ui/assets/{onboarding-orchestrator-Dp07_rlE.js → onboarding-orchestrator-C6UC6cTM.js} +1 -1
  53. package/dist/ui/assets/{openai-codex-qPvp4ySz.js → openai-codex-B7A6dTqN.js} +1 -1
  54. package/dist/ui/assets/{openai-codex-CAxspsK3.js → openai-codex-xtvQmRuH.js} +1 -1
  55. package/dist/ui/assets/{openrouter-DcPxymVn.js → openrouter-CQeyGGEy.js} +1 -1
  56. package/dist/ui/assets/{openrouter-BRoYeQDM.js → openrouter-_6zsj8-6.js} +1 -1
  57. package/dist/ui/assets/{openrouter-free-UZjKk4wE.js → openrouter-free-BM772ovL.js} +1 -1
  58. package/dist/ui/assets/{openrouter-free-CjCZ_UlR.js → openrouter-free-Du1No0Z_.js} +1 -1
  59. package/dist/ui/assets/{openrouter-oauth-C1m7DmRE.js → openrouter-oauth-BSSNY_G1.js} +1 -1
  60. package/dist/ui/assets/{openrouter-oauth-6WlmsFWX.js → openrouter-oauth-D9dklyIn.js} +1 -1
  61. package/dist/ui/assets/{panel-rpc-handlers-C1PsIK-h.js → panel-rpc-handlers-rMOPHOSf.js} +2 -2
  62. package/dist/ui/assets/{panelize-shell-DpTilnU0.js → panelize-shell-DLm7AfDp.js} +1 -1
  63. package/dist/ui/assets/{pi-edit-execution-C827WJzE.js → pi-edit-execution-dq5caQ-R.js} +1 -1
  64. package/dist/ui/assets/{profile-export-deps-Cmfc-0t5.js → profile-export-deps-D5nPKaA7.js} +2 -2
  65. package/dist/ui/assets/{provider-CfqlxJuU.js → provider-4M0-Za9p.js} +1 -1
  66. package/dist/ui/assets/{provider-DzmjiH7H.js → provider-C6V5bKb2.js} +1 -1
  67. package/dist/ui/assets/{provider-settings-D84CQmkE.js → provider-settings-C46VEmp7.js} +1 -1
  68. package/dist/ui/assets/provider-store-access-CgaKC7rB.js +1 -0
  69. package/dist/ui/assets/provider-store-access-DgrYdKML.js +1 -0
  70. package/dist/ui/assets/{providers-CWnzzPFZ.js → providers-B5VMaUWX.js} +2 -2
  71. package/dist/ui/assets/{providers-BkZUaOFx.js → providers-Bw0birsa.js} +1 -1
  72. package/dist/ui/assets/{quick-llm-BHSRhAQq.js → quick-llm-D5hmdHQQ.js} +1 -1
  73. package/dist/ui/assets/read-back-DsW7lsRQ.js +1 -0
  74. package/dist/ui/assets/{realm-inprocess-Dah8hZOx.js → realm-inprocess-DsBZtVOH.js} +2 -2
  75. package/dist/ui/assets/{realm-unhandled-rejections-2eSbJjgG.js → realm-unhandled-rejections-BDHLlsLp.js} +1 -1
  76. package/dist/ui/assets/{realm-unhandled-rejections-As1gNoCS.js → realm-unhandled-rejections-BDnl84l4.js} +1 -1
  77. package/dist/ui/assets/{remote-terminal-view-wVjW-Rct.js → remote-terminal-view-DYm18AE3.js} +2 -2
  78. package/dist/ui/assets/{restore-D4kFsicX.js → restore-CKcu1P_Z.js} +1 -1
  79. package/dist/ui/assets/{run-BnHQKxit.js → run-BV4IO7_J.js} +1 -1
  80. package/dist/ui/assets/{run-SjFQcoLt.js → run-C4x_nui1.js} +2 -2
  81. package/dist/ui/assets/{run-DvZAY3-G.js → run-CRGyQPIr.js} +1 -1
  82. package/dist/ui/assets/{run-B-qC-Qkv.js → run-DS9gNHJH.js} +2 -2
  83. package/dist/ui/assets/{serve-command-Dqtflq8i.js → serve-command-Dxu0zqDl.js} +2 -2
  84. package/dist/ui/assets/{serve-runtime-D9dTP7zY.js → serve-runtime-CEmOBSkh.js} +1 -1
  85. package/dist/ui/assets/{session-command-memory-ckzD8HGJ.js → session-command-memory-CZZ78BU8.js} +2 -2
  86. package/dist/ui/assets/{session-jsonl-BtOoGpgO.js → session-jsonl-kHYH-7Ib.js} +1 -1
  87. package/dist/ui/assets/{session-search-index-Ct1m_Xy8.js → session-search-index-eJnlwzC6.js} +1 -1
  88. package/dist/ui/assets/{setup-feature-flags-remote-CNUOjp_d.js → setup-feature-flags-remote-Ci3nvXGY.js} +1 -1
  89. package/dist/ui/assets/{setup-model-catalog-DItd3hG1.js → setup-model-catalog-DWI-pcXH.js} +1 -1
  90. package/dist/ui/assets/{silent-renew-backoff-BNqGHP4G.js → silent-renew-backoff-2lMvXpiU.js} +1 -1
  91. package/dist/ui/assets/{skills-Buu7GuOS.js → skills-DA38Ccn7.js} +1 -1
  92. package/dist/ui/assets/slicc-version-ComMn6Xo.js +1 -0
  93. package/dist/ui/assets/{soundscape-B4oUSa0w.js → soundscape-DK8vzDpK.js} +1 -1
  94. package/dist/ui/assets/{speak-CZVR5H_w.js → speak-D_AKrPu0.js} +1 -1
  95. package/dist/ui/assets/{sprinkle-manager-CvJfIIwN.js → sprinkle-manager-CJGReRLz.js} +1 -1
  96. package/dist/ui/assets/{sprinkle-renderer-1dR5Wy0b.js → sprinkle-renderer-CcWhSBfB.js} +1 -1
  97. package/dist/ui/assets/{sudo-CmyRbjc9.js → sudo-CSzJTCd9.js} +1 -1
  98. package/dist/ui/assets/{supervisor-BT9YHtZM.js → supervisor-DBofbxjT.js} +1 -1
  99. package/dist/ui/assets/{sync-dialog-CmsgHXVd.js → sync-dialog-FwBEmm7W.js} +1 -1
  100. package/dist/ui/assets/{transformers-env-CezVU-DO.js → transformers-env-DfuTpXXR.js} +1 -1
  101. package/dist/ui/assets/{tray-leader-BPAYVkdw.js → tray-leader-1ntSUEXa.js} +1 -1
  102. package/dist/ui/assets/{tray-leave-runtime-DBiVMKry.js → tray-leave-runtime-BoVSKaCt.js} +1 -1
  103. package/dist/ui/assets/{tray-sidecar-PAl6F8v5.js → tray-sidecar-CYuPitKs.js} +1 -1
  104. package/dist/ui/assets/{upgrade-detection-CZq64CrV.js → upgrade-detection-B8TZhKUa.js} +1 -1
  105. package/dist/ui/assets/{upgrade-to-seven-eT7Bazyd.js → upgrade-to-seven-B2H6KnlF.js} +2 -2
  106. package/dist/ui/assets/{voice-reply-cS0esNfA.js → voice-reply-BKaB8Asb.js} +1 -1
  107. package/dist/ui/assets/{wc-attach-DoogubUF.js → wc-attach-CoR9zN1R.js} +2 -2
  108. package/dist/ui/assets/{wc-browser-BryugynY.js → wc-browser-D2k3tkR-.js} +1 -1
  109. package/dist/ui/assets/{wc-computers-CtW_Ik03.js → wc-computers-CPX2x6Th.js} +1 -1
  110. package/dist/ui/assets/{wc-detached-CSDoMqKo.js → wc-detached-BHiC5h-Y.js} +1 -1
  111. package/dist/ui/assets/{wc-extension-YI5H0Elb.js → wc-extension-DnJc8F1P.js} +2 -2
  112. package/dist/ui/assets/{wc-follower-D4ZMD4Ku.js → wc-follower-CpqjednQ.js} +3 -3
  113. package/dist/ui/assets/{wc-follower-oauth-BfR355Ty.js → wc-follower-oauth-CjMFLgHd.js} +1 -1
  114. package/dist/ui/assets/{wc-gelatiere-BpGfaPoZ.js → wc-gelatiere-B1UhGGlW.js} +1 -1
  115. package/dist/ui/assets/{wc-live-C-LRxSXs.js → wc-live-MMV5wx1F.js} +5 -5
  116. package/dist/ui/assets/{wc-nav-D_uYnRGi.js → wc-nav-BLmah4u4.js} +2 -2
  117. package/dist/ui/assets/{wc-onboarding-DLkNe9zb.js → wc-onboarding-BLjMaifw.js} +2 -2
  118. package/dist/ui/assets/{wc-permissions-B8P7pVj4.js → wc-permissions-BH_pyjzt.js} +2 -2
  119. package/dist/ui/assets/{wc-placeholder-Cn2oBNAp.js → wc-placeholder-B5m9keHf.js} +2 -2
  120. package/dist/ui/assets/{wc-profile-export-UuZaS14H.js → wc-profile-export-CUSnMx4l.js} +3 -3
  121. package/dist/ui/assets/{wc-secret-request-C8NXcGAf.js → wc-secret-request-COrsGNVO.js} +1 -1
  122. package/dist/ui/assets/{wc-settings-C23FqhfM.js → wc-settings-DbOCHvQA.js} +3 -3
  123. package/dist/ui/assets/{wc-shell-C6uxXUte.js → wc-shell-Xrw2Q_l-.js} +239 -239
  124. package/dist/ui/assets/{wc-shortcut-config-DJcVyQU4.js → wc-shortcut-config-BQBPwMA2.js} +1 -1
  125. package/dist/ui/assets/{wc-sprinkles-8EOEvTZN.js → wc-sprinkles-D752QtPV.js} +2 -2
  126. package/dist/ui/assets/{wc-transcript-export-CdiadUUR.js → wc-transcript-export-DvAF0rPF.js} +2 -2
  127. package/dist/ui/assets/{wc-tray-C6D5Ab_0.js → wc-tray-QWpxQYLb.js} +4 -4
  128. package/dist/ui/assets/welcome-detection-Ny04c6Rd.js +1 -0
  129. package/dist/ui/assets/{whisper-session-C2PSRzHA.js → whisper-session-CExf0vBt.js} +2 -2
  130. package/dist/ui/assets/{xai-grok-D_Ri6OhN.js → xai-grok-Cfob0nrx.js} +1 -1
  131. package/dist/ui/assets/{xai-grok-Cz--0x3o.js → xai-grok-iOYIBxH8.js} +1 -1
  132. package/dist/ui/index.html +3 -3
  133. package/dist/ui/lucide-icons.js +284 -283
  134. package/dist/ui/packages/webapp/index.html +3 -3
  135. package/dist/ui/packages/webapp/upgrade-to-seven.html +1 -1
  136. package/dist/ui/upgrade-to-seven.html +1 -1
  137. package/package.json +2 -2
  138. package/dist/ui/assets/SKILL-BsfbaE8W.js +0 -1
  139. package/dist/ui/assets/file-modes-BkEydFQE.js +0 -1
  140. package/dist/ui/assets/icons-D1QuzCd5.js +0 -1
  141. package/dist/ui/assets/installer-c3P1y6c8.js +0 -5
  142. package/dist/ui/assets/ipk-mamba-VDJ25teM.js +0 -46
  143. package/dist/ui/assets/provider-store-access-BG2uF5Td.js +0 -1
  144. package/dist/ui/assets/provider-store-access-DkyHEm5m.js +0 -1
  145. package/dist/ui/assets/slicc-version-uitI64MK.js +0 -1
  146. package/dist/ui/assets/welcome-detection-CPzEtseb.js +0 -1
@@ -1,4 +1,4 @@
1
- import{t as e}from"./logger-Cx6Y120U.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,w as p}from"./account-store-BsPvuHqg.js";import{c as m,d as h,n as g,r as _,s as v}from"./proxied-fetch-1DfC_94U.js";import{t as ee}from"./sha256-DynDhwRL.js";import{t as te}from"./runtime-env-DadgceZk.js";import{t as ne}from"./slugify-BYJ6QVAt.js";import{i as re,n as ie,r as ae,t as oe}from"./host-command-CkJyrXy3.js";import{a as se,c as ce,d as y,f as le,i as ue,l as de,m as fe,n as pe,o as me,p as he,r as ge,s as _e,t as ve,u as ye}from"./snapshot-BqARfI1v.js";import{n as be,t as b}from"./panel-rpc-accessor-B4BfPLSo.js";import{a as xe,c as Se,n as Ce,o as we,s as Te,t as Ee}from"./feature-flags-CoR3q8DD.js";import{t as De}from"./providers-BkZUaOFx.js";import{r as Oe}from"./binary-cache-HVfvmwmL.js";import{i as ke,n as Ae,r as je}from"./fetch-body-CuwTaJC_.js";import{s as Me,t as Ne}from"./api-endpoint-D8lUKmPu.js";import{t as Pe}from"./compat-CuWVDYYO.js";import{t as Fe}from"./utf16-clip-Dcxt-q1C.js";import{n as Ie,t as Le}from"./mime-types-D7IV6i7k.js";import"./core-TaEErdII.js";import{n as Re,t as ze}from"./float-topology-87nCRxRw.js";import{t as Be}from"./secrets-bridge-client-DlJPW3h4.js";import{a as Ve,i as He,n as Ue,r as We}from"./tool-ui-blvQ8qgI.js";import{a as Ge,i as Ke,n as x,t as S}from"./path-utils-DNJG-zQf.js";import{n as qe,r as Je,t as Ye}from"./merge-file-core-YFxa1Gy8.js";import{n as Xe,t as Ze}from"./types-D8gIX-W-.js";import{i as Qe}from"./mount-index-LvDi_MEB.js";import{a as $e,i as et,n as tt,o as nt,s as rt,t as it}from"./signed-fetch-B4_syuGv.js";import{o as at}from"./mount-table-store-xM3U8UHg.js";import{t as ot}from"./remote-cache-MMXYpOmA.js";import{n as st}from"./fs-DNsJRW_E.js";import{a as ct}from"./tray-leader-status-BPM2zVsj.js";import{n as lt,t as ut}from"./slicc-version-uitI64MK.js";import{a as dt,i as C,n as ft,r as pt,t as mt}from"./browser-4sjVvKih.js";import{t as w}from"./subcommand-flags-RpCj0auy.js";import{n as ht,r as gt,t as T}from"./subcommand-help-CgO7wRS5.js";import{n as _t}from"./cost-command-CG3mKA1r.js";import{d as vt,g as yt,i as bt,n as xt,o as St}from"./sudoers-2C-BpgXh.js";import{t as Ct}from"./sudo-refusal-DVwTXFRE.js";import{n as wt}from"./types-Dj5TU-Qg.js";import{a as Tt,c as Et,i as Dt,l as Ot,n as kt,o as At,r as jt,t as Mt}from"./types-JfhqX7lD.js";import{n as E,t as Nt}from"./boundary-DjgipyWT.js";import"./rest-paths-Dia19u9P.js";import{t as Pt}from"./html-B_Hg2WOy.js";import{n as Ft}from"./llm-session-id-BkEQhxBR.js";import{t as It}from"./src-SFACrjnb.js";import{i as Lt,o as Rt}from"./browser-DKcnER7J.js";import{a as zt,c as Bt,i as Vt,n as Ht,o as Ut,s as Wt,t as Gt}from"./pipe-status-BBrT3VeG.js";import{i as Kt,r as qt,t as Jt}from"./mount-picker-popup-DdbRdPNA.js";import{t as Yt}from"./buffer-C6ncbtB_.js";import"./buffer-polyfill-CaN2liDv.js";import{A as Xt,B as D,C as Zt,D as O,E as Qt,F as $t,G as en,H as k,I as A,J as tn,K as nn,L as rn,M as an,N as on,O as sn,P as cn,R as ln,S as un,T as dn,U as fn,V as pn,W as mn,Y as hn,_ as gn,a as _n,b as vn,c as yn,d as bn,f as xn,g as Sn,h as Cn,i as wn,j as Tn,k as En,l as Dn,m as On,n as kn,o as An,p as j,q as jn,r as Mn,s as Nn,t as Pn,u as Fn,v as In,w as Ln,x as Rn,y as zn,z as Bn}from"./isomorphic-git-Cmlj4OJW.js";import"./global-db-Bfy_NRtT.js";import{C as Vn,S as M,a as Hn,b as Un,c as Wn,d as Gn,f as Kn,g as qn,i as Jn,l as Yn,m as Xn,n as Zn,o as Qn,p as $n,r as er,s as tr,t as nr,u as rr,x as ir,y as N}from"./state-BEkTZ8Wn.js";import{a as ar,i as or,r as sr,t as cr}from"./git-config-CnzJWs4a.js";import{a as lr,i as ur,o as P,t as dr}from"./just-bash-compat-DWUHpp9U.js";import{h as fr,i as pr,r as mr}from"./stdio-tty-DhcdDEsf.js";import{i as hr,r as gr,t as _r}from"./home-dir-DAXEFyny.js";import{i as vr,r as yr}from"./global-prefix-DqCuANmV.js";import{t as br}from"./wasm-programs-BUEs4fiZ.js";import{a as xr,c as Sr,n as Cr,r as wr,s as Tr}from"./jsh-discovery-D7D5iKYT.js";import{C as Er,a as Dr,b as Or,c as kr,d as Ar,f as jr,h as Mr,i as Nr,l as Pr,m as Fr,n as Ir,o as Lr,p as Rr,r as zr,s as Br,t as F,u as Vr,v as Hr,y as Ur}from"./shared-DPVU7o5t.js";import{_ as Wr,a as Gr,b as Kr,d as qr,f as Jr,g as Yr,h as Xr,i as Zr,l as Qr,m as $r,p as ei,r as ti,s as ni,u as ri,v as ii,y as ai}from"./require-guards-CnSYqjDO.js";import{S as oi,_ as si,b as ci,c as li,d as ui,f as di,g as fi,h as pi,l as mi,m as hi,n as gi,o as _i,p as vi,t as yi,u as bi,v as xi,x as Si,y as Ci}from"./jsh-executor-p0b2gPaG.js";import{n as wi,t as Ti}from"./esbuild-wasm-D-czepwO.js";import{n as Ei}from"./wasm-compiler-Ct7QZURL.js";import{a as Di,o as Oi,s as ki,t as Ai}from"./usb-device-registry-DEKs171n.js";import{i as ji,r as Mi,t as Ni}from"./script-catalog-DDeMaTU_.js";import{a as Pi,c as Fi,o as Ii,s as Li,t as Ri}from"./types-BR5TkXSs.js";import{a as zi,c as Bi,d as Vi,f as Hi,n as Ui,r as Wi,u as Gi}from"./github-zip-BSEJCt49.js";import{i as Ki,t as qi}from"./github-auth-CkLbjC-d.js";import{a as Ji,i as Yi,o as Xi,r as Zi,t as Qi}from"./provenance-C7BfNno_.js";import{a as $i,c as ea,i as ta,n as na,o as ra,r as ia,s as aa}from"./github-install-VgcR2-6K.js";import{n as oa,t as sa}from"./magick-wasm-BItevhnv.js";import{i as ca,n as la,r as ua,t as da}from"./pdf-raster-D30vfUF_.js";import{n as fa}from"./lick-target-env-8JxfVcIV.js";import{t as pa}from"./tmpdir-env-ate4iNcK.js";import{n as ma,t as ha}from"./keyboard-TcuVIW9F.js";import{n as ga,t as _a}from"./hf-defaults-BwJdGLgk.js";import{t as va}from"./ffmpeg-wasm-xaOnfsRx.js";import{t as ya}from"./local-llm-DtDE4ic6.js";import{i as ba,n as xa,r as Sa,t as Ca}from"./tar-BjnO16Uf.js";import{a as wa,c as Ta,i as Ea,o as Da,r as Oa,s as ka}from"./v86-vm-BlgIo0B_.js";import{n as Aa,r as ja}from"./lick-urls-CgPiVwD-.js";let Ma=null;function Na(e){Ma=e!==null&&Number.isFinite(e)&&e>0?e:null}function Pa(){if(Ma!==null)return Ma;let e=globalThis.performance?.timeOrigin;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:Date.now()}new URL(r).hostname;const Fa=/^([0-9a-f]{32})--(?:[0-9a-f]{8}-)?([0-9a-f]+)$/i;function Ia(e){let t;try{t=new URL(e.includes(`://`)?e:`https://${e}`).hostname}catch{return null}let n=Fa.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 La(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 Ra(e,t){return e.some(e=>La(e,t))}const za=`slicc-transcript`,Ba=[`canonical-agent-history-unavailable`,`tool-data-may-be-truncated`,`model-metadata-unavailable`,`scoop-history-unavailable`,`attachment-file-missing`,`attachment-association-unavailable`,`complete-snapshot-unavailable`],Va=/* @__PURE__ */ new Set(/* @__PURE__ */ `/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 Ha(e){return Va.has(e.replace(/\/\d+(?=\/|$)/g,`/*`))}var Ua=class extends Error{code;detail;constructor(e,t){super(t?`${e}: ${t}`:e),this.code=e,this.detail=t,this.name=`TranscriptExportError`}};const Wa=new Set(Ba),Ga=/^[0-9a-fA-F]{64}$/,Ka=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/;function I(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qa(e){return typeof e==`string`&&Ga.test(e)}function Ja(e){return Ka.test(e)&&Number.isFinite(Date.parse(e))}function Ya(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 Xa(e,t,n){return typeof e!=`string`||!t.includes(e)?{ok:!1,error:Ya(n,t)}:{ok:!0}}function Za(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 Qa(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 $a(e,t){if(!I(e))return{ok:!1,error:`${t} must be a non-null object`};let n=Xa(e.type,[`text`,`tool-call`,`attachment-ref`],`${t}.type`);return n.ok?Qa(e,t):n}function eo(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 to(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 no(e,t){let n=eo(e,t);if(!n.ok)return n;let r=e.cost;return I(r)?to(r,`${t}.cost`):{ok:!1,error:`${t}.cost must be a non-null object`}}function ro(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`?Ja(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 io(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 ao(e,t){let n=e.usage;return n===void 0?{ok:!0}:I(n)?no(n,`${t}.usage`):{ok:!1,error:`${t}.usage must be a non-null object`}}function oo(e,t){if(!I(e))return{ok:!1,error:`${t} must be a non-null object`};let n=Xa(e.role,[`user`,`assistant`,`tool-result`],`${t}.role`);if(!n.ok)return n;if(e.role===`tool-result`){let n=io(e,t);if(!n.ok)return n}let r=ro(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=Za(i,$a,`${t}.content`);return a.ok?ao(e,t):a}function so(e,t){if(!I(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=Xa(e.kind,[`cone`,`scoop`],`${t}.kind`);if(!n.ok)return n;let r=e.messages;return Array.isArray(r)?Za(r,oo,`${t}.messages`):{ok:!1,error:`${t}.messages must be an array`}}function co(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 lo(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`}:qa(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 uo=[`attachment-file-missing`,`attachment-association-unavailable`];function fo(e,t){let n=e.path,r=e.sha256,i=e.byteLength;return n===``?r===``?i===0?Xa(e.missingReason,uo,`${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 po(e,t){return e.present?lo(e,t):fo(e,t)}function mo(e,t){if(!I(e))return{ok:!1,error:`${t} must be a non-null object`};let n=co(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=Xa(e.handling,[`text-redacted`,`binary-unchanged`],`${t}.handling`);return r.ok?po(e,t):r}function ho(e,t){let n=Xa(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 go(e,t){if(!I(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=Xa(e.detector,[`known-secret`,`credential-pattern`,`pre-obfuscated`],`${t}.detector`);if(!n.ok)return n;let r=e.target;return I(r)?ho(r,`${t}.target`):{ok:!1,error:`${t}.target must be a non-null object`}}function _o(e,t){return I(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 vo(e,t){return typeof e!=`string`||!Wa.has(e)?{ok:!1,error:`${t} is not a valid completeness reason`}:{ok:!0}}function yo(e){if(!I(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 I(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 bo(e){if(!I(e))return{ok:!1,error:`session.completeness must be a non-null object`};let t=Xa(e.status,[`complete`,`partial`],`session.completeness.status`);return t.ok?Array.isArray(e.missing)?Za(e.missing,vo,`session.completeness.missing`):{ok:!1,error:`session.completeness.missing must be an array`}:t}function xo(e){if(!I(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=Xa(e.state,[`active`,`frozen`],`session.state`);return t.ok?bo(e.completeness):t}function So(e){if(!I(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(!I(e.redactionCounts))return{ok:!1,error:`privacy.redactionCounts must be a non-null object`};let n=e.redactions;return Array.isArray(n)?Za(n,go,`privacy.redactions`):{ok:!1,error:`privacy.redactions must be an array`}}function Co(e){let t=e.conversations;if(!Array.isArray(t))return{ok:!1,error:`conversations must be an array`};let n=Za(t,so,`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=Za(r,_o,`delegations`);if(!i.ok)return i;let a=e.attachments;return Array.isArray(a)?Za(a,mo,`attachments`):{ok:!1,error:`attachments must be an array`}}function wo(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let r of e){if(!I(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(I(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 To(e){for(let t of e){if(!I(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(!I(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 Eo(e){let t=[];for(let n of e){if(!I(n))continue;let e=n.content;if(Array.isArray(e))for(let n of e)I(n)&&n.type===`tool-call`&&typeof n.id==`string`&&t.push(n.id)}return t}function Do(e){let t=/* @__PURE__ */ new Set;for(let n of e){if(!I(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of Eo(e))t.add(n)}return t}function Oo(e,t){for(let n of e){if(!I(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of e){if(!I(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 ko(e){return Oo(e,Do(e))}function Ao(e,t){for(let n of e){if(!I(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 jo(e,t){for(let n of e){if(!I(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of e){if(!I(n))continue;let e=n.content;if(!Array.isArray(e))continue;let r=Ao(e,t);if(!r.ok)return r}}return{ok:!0}}function Mo(e,t){let n=/* @__PURE__ */ new Set;for(let e of t)I(e)&&typeof e.id==`string`&&n.add(e.id);return jo(e,n)}function No(e){let t=/* @__PURE__ */ new Map;for(let n of e){if(!I(n)||typeof n.id!=`string`)continue;let e=/* @__PURE__ */ new Set,r=n.messages;if(Array.isArray(r))for(let t of r)I(t)&&typeof t.id==`string`&&e.add(t.id);t.set(n.id,e)}return t}function Po(e,t){let n=No(t);for(let t=0;t<e.length;t++){let r=e[t];if(!I(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 Fo(e){let t=/* @__PURE__ */ new Map;for(let n of e){if(!I(n)||typeof n.id!=`string`)continue;let e=Array.isArray(n.messages)?n.messages:[];t.set(n.id,new Set(Eo(e)))}return t}function Io(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];if(!I(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 Lo(e,t){let n=/* @__PURE__ */ new Set;for(let e of t)I(e)&&typeof e.id==`string`&&n.add(e.id);return Io(e,n,Fo(t))}function Ro(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 zo(e,t){let n=/* @__PURE__ */ new Set;for(let e of t)I(e)&&typeof e.id==`string`&&n.add(e.id);for(let t=0;t<e.length;t++){let r=e[t];if(!I(r))continue;let i=r.target;if(!I(i))continue;let a=Ro(i,n,`privacy.redactions[${t}].target`);if(!a.ok)return a}return{ok:!0}}function Bo(e){let t=e.conversations,n=e.attachments,r=e.delegations,i=e.privacy,a=Array.isArray(i?.redactions)?i.redactions:[],o=wo(t);if(!o.ok)return o;let s=To(t);if(!s.ok)return s;let c=ko(t);if(!c.ok)return c;let l=Mo(t,n);if(!l.ok)return l;let u=Po(n,t);if(!u.ok)return u;let d=Lo(r,t);return d.ok?zo(a,n):d}function Vo(e){let t=Co(e);return t.ok?Bo(e):t}function Ho(e){if(!I(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=yo(e.export);if(!t.ok)return t;let n=xo(e.session);if(!n.ok)return n;let r=So(e.privacy);return r.ok?Vo(e):r}async function Uo(e,t,n){let r=await n({method:`GET`,path:`/${e}/sites/${t}/config.json`,origin:nt});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:Wo(a),sourceUrl:a}}function Wo(e){if(!e)return`da`;let t;try{t=new URL(e).host}catch{return`da`}return t===`api.aem.live`?`aem`:`da`}const Go=`slicc-sprinkle-routes`;function Ko(){try{let e=localStorage.getItem(Go);return e?JSON.parse(e):{}}catch{return{}}}function qo(e){try{localStorage.setItem(Go,JSON.stringify(e))}catch{}}function Jo(e){return Ko()[e]}function Yo(e,t){let n=Ko();n[e]=t,qo(n)}function Xo(e){let t=Ko();delete t[e],qo(t)}function Zo(){return Ko()}function Qo(e,t,n){return Et(t,n,`${e} adapter does not implement ${t}.${n}`)}function $o(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(Qo(e,t,n))]});return{...Object.fromEntries(a),allowlist:i,supports:e=>i.includes(e)}}function es(e){let{adapter:t,pageGestures:n}=e,r=n??{};return{adapter:t,browser:$o(t,`browser`,kt,e.browser),network:$o(t,`network`,Tt,e.network),secrets:$o(t,`secrets`,At,e.secrets),devices:$o(t,`devices`,jt,{usbRequest:r.usbRequest,serialRequest:r.serialRequest,hidRequest:r.hidRequest,...e.devices}),mounts:$o(t,`mounts`,Dt,{pickDirectory:r.pickDirectory,...e.mounts}),approvals:$o(t,`approvals`,Mt,e.approvals)}}function ts(e={}){return es({adapter:`connect`,pageGestures:e.pageGestures})}function ns(e){let t=Nt(()=>import(`./extension-ops-BWWe8FOb.js`).then(t=>t.createExtensionOps(e)));return es({adapter:e.adapter,pageGestures:e.pageGestures,network:{crossOriginFetch:e=>E(`network`,`crossOriginFetch`,async()=>(await t()).crossOriginFetch(e))},secrets:{listMaskedEnv:()=>E(`secrets`,`listMaskedEnv`,async()=>(await t()).secrets.listMaskedEnv()),getMasked:e=>E(`secrets`,`getMasked`,async()=>(await t()).secrets.getMasked(e)),set:e=>E(`secrets`,`set`,async()=>(await t()).secrets.set(e)),delete:e=>E(`secrets`,`delete`,async()=>(await t()).secrets.delete(e))},mounts:{signRequest:e=>E(`mounts`,`signRequest`,async()=>(await t()).signRequest(e))},approvals:{request:e=>E(`approvals`,`request`,async()=>(await t()).requestApproval(e))}})}function rs(e={}){let t=Nt(()=>import(`./rest-ops-DdaQHTK4.js`).then(t=>t.createRestOps(e)),e.controlTimeoutMs??1e4);return es({adapter:`node-rest`,pageGestures:e.pageGestures,network:{localNodeServer:()=>Promise.resolve({ok:!0,value:{available:!0}}),crossOriginFetch:e=>E(`network`,`crossOriginFetch`,async()=>(await t()).crossOriginFetch(e))},secrets:{listMaskedEnv:()=>E(`secrets`,`listMaskedEnv`,async()=>(await t()).secrets.listMaskedEnv()),getMasked:e=>E(`secrets`,`getMasked`,async()=>(await t()).secrets.getMasked(e)),set:e=>E(`secrets`,`set`,async()=>(await t()).secrets.set(e)),delete:e=>E(`secrets`,`delete`,async()=>(await t()).secrets.delete(e))},mounts:{signRequest:e=>E(`mounts`,`signRequest`,async()=>(await t()).signRequest(e))},approvals:{request:e=>E(`approvals`,`request`,async()=>(await t()).requestApproval(e))}})}function is(e,t={}){let{pageGestures:n}=t;switch(e){case`node-rest`:return rs({pageGestures:n});case`extension-direct`:case`extension-delegate`:return ns({adapter:e,pageGestures:n});case`connect`:return ts({pageGestures:n})}}const as=e(`quick-llm`);async function os(e){let t=d();if(!t)return as.debug(`No API key for active provider — skipping`),null;let n=u(),r=l(),i;if(i=e.modelId?us(n,e.modelId)??us(n,r):ss(n,r),!i)return as.debug(`No model available for provider`,{providerId:n}),null;let a=Fe(e.prompt),o=e.system===void 0?void 0:Fe(e.system),s={role:`user`,content:a,timestamp:Date.now()},c={};i.provider===`adobe`&&(c[`X-Session-Id`]=ds());try{let n=(await Pe(i,{systemPrompt:o,messages:[s]},{apiKey:t,maxTokens:e.maxTokens??60,temperature:e.temperature??.3,signal:e.signal,headers:Object.keys(c).length>0?c:void 0})).content.filter(e=>e.type===`text`).map(e=>e.text).join(``).trim();return n.length>0?n:null}catch(e){return as.debug(`Quick label call failed`,{error:e instanceof Error?e.message:String(e)}),null}}function ss(e,t){let n=f(e);if(n.length===0)return;let r=n.find(e=>e.id===t)??n[0],i=ls(r.id),a=n.filter(e=>cs(e,r,i));return a.length===0?r:(a.sort((e,t)=>(e.cost?.input??0)-(t.cost?.input??0)),a[0])}function cs(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 ls(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 us(e,t){return f(e).find(e=>e.id===t)}function ds(){return Ft(`ui-quick-llm`)}const fs=e(`sudo-suggest`),ps=[`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-Cx6Y120U.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,w as p}from"./account-store-QxWo48Y1.js";import{c as m,d as h,n as g,r as _,s as v}from"./proxied-fetch-1DfC_94U.js";import{t as ee}from"./sha256-DynDhwRL.js";import{t as te}from"./runtime-env-DadgceZk.js";import{t as ne}from"./slugify-BYJ6QVAt.js";import{i as re,n as ie,r as ae,t as oe}from"./host-command-CkJyrXy3.js";import{a as se,c as ce,d as y,f as le,i as ue,l as de,m as fe,n as pe,o as me,p as he,r as ge,s as _e,t as ve,u as ye}from"./snapshot-BqARfI1v.js";import{n as be,t as b}from"./panel-rpc-accessor-B4BfPLSo.js";import{a as xe,c as Se,n as Ce,o as we,s as Te,t as Ee}from"./feature-flags-CoR3q8DD.js";import{t as De}from"./providers-Bw0birsa.js";import{r as Oe}from"./binary-cache-HVfvmwmL.js";import{i as ke,n as Ae,r as je}from"./fetch-body-CuwTaJC_.js";import{s as Me,t as Ne}from"./api-endpoint-D8lUKmPu.js";import{t as Pe}from"./compat-CuWVDYYO.js";import{t as Fe}from"./utf16-clip-Dcxt-q1C.js";import{n as Ie,t as Le}from"./mime-types-D7IV6i7k.js";import"./core-TaEErdII.js";import{n as Re,t as ze}from"./float-topology-87nCRxRw.js";import{t as Be}from"./secrets-bridge-client-DlJPW3h4.js";import{a as Ve,i as He,n as Ue,r as We}from"./tool-ui-blvQ8qgI.js";import{a as Ge,i as Ke,n as x,t as S}from"./path-utils-DNJG-zQf.js";import{n as qe,r as Je,t as Ye}from"./merge-file-core-YFxa1Gy8.js";import{n as Xe,t as Ze}from"./types-D8gIX-W-.js";import{i as Qe}from"./mount-index-LvDi_MEB.js";import{a as $e,i as et,n as tt,o as nt,s as rt,t as it}from"./signed-fetch-B4_syuGv.js";import{o as at}from"./mount-table-store-xM3U8UHg.js";import{t as ot}from"./remote-cache-MMXYpOmA.js";import{n as st}from"./fs-DNsJRW_E.js";import{a as ct}from"./tray-leader-status-BPM2zVsj.js";import{n as lt,t as ut}from"./slicc-version-ComMn6Xo.js";import{a as dt,i as C,n as ft,r as pt,t as mt}from"./browser-4sjVvKih.js";import{t as w}from"./subcommand-flags-RpCj0auy.js";import{n as ht,r as gt,t as T}from"./subcommand-help-CgO7wRS5.js";import{n as _t}from"./cost-command-CG3mKA1r.js";import{d as vt,g as yt,i as bt,n as xt,o as St}from"./sudoers-2C-BpgXh.js";import{t as Ct}from"./sudo-refusal-DVwTXFRE.js";import{n as wt}from"./types-Dj5TU-Qg.js";import{a as Tt,c as Et,i as Dt,l as Ot,n as kt,o as At,r as jt,t as Mt}from"./types-JfhqX7lD.js";import{n as E,t as Nt}from"./boundary-DjgipyWT.js";import"./rest-paths-Dia19u9P.js";import{t as Pt}from"./html-B_Hg2WOy.js";import{n as Ft}from"./llm-session-id-BkEQhxBR.js";import{t as It}from"./src-SFACrjnb.js";import{i as Lt,o as Rt}from"./browser-DKcnER7J.js";import{a as zt,c as Bt,i as Vt,n as Ht,o as Ut,s as Wt,t as Gt}from"./pipe-status-BBrT3VeG.js";import{i as Kt,r as qt,t as Jt}from"./mount-picker-popup-DdbRdPNA.js";import{t as Yt}from"./buffer-C6ncbtB_.js";import"./buffer-polyfill-CaN2liDv.js";import{A as Xt,B as D,C as Zt,D as O,E as Qt,F as $t,G as en,H as k,I as A,J as tn,K as nn,L as rn,M as an,N as on,O as sn,P as cn,R as ln,S as un,T as dn,U as fn,V as pn,W as mn,Y as hn,_ as gn,a as _n,b as vn,c as yn,d as bn,f as xn,g as Sn,h as Cn,i as wn,j as Tn,k as En,l as Dn,m as On,n as kn,o as An,p as j,q as jn,r as Mn,s as Nn,t as Pn,u as Fn,v as In,w as Ln,x as Rn,y as zn,z as Bn}from"./isomorphic-git-Cmlj4OJW.js";import"./global-db-Bfy_NRtT.js";import{C as Vn,S as M,a as Hn,b as Un,c as Wn,d as Gn,f as Kn,g as qn,i as Jn,l as Yn,m as Xn,n as Zn,o as Qn,p as $n,r as er,s as tr,t as nr,u as rr,x as ir,y as N}from"./state-BEkTZ8Wn.js";import{a as ar,i as or,r as sr,t as cr}from"./git-config-CnzJWs4a.js";import{a as lr,i as ur,o as P,t as dr}from"./just-bash-compat-DWUHpp9U.js";import{h as fr,i as pr,r as mr}from"./stdio-tty-DhcdDEsf.js";import{i as hr,r as gr,t as _r}from"./home-dir-DAXEFyny.js";import{i as vr,r as yr}from"./global-prefix-DqCuANmV.js";import{t as br}from"./wasm-programs-BUEs4fiZ.js";import{a as xr,c as Sr,n as Cr,r as wr,s as Tr}from"./jsh-discovery-D7D5iKYT.js";import{C as Er,a as Dr,b as Or,c as kr,d as Ar,f as jr,h as Mr,i as Nr,l as Pr,m as Fr,n as Ir,o as Lr,p as Rr,r as zr,s as Br,t as F,u as Vr,v as Hr,y as Ur}from"./shared-DPVU7o5t.js";import{_ as Wr,a as Gr,b as Kr,d as qr,f as Jr,g as Yr,h as Xr,i as Zr,l as Qr,m as $r,p as ei,r as ti,s as ni,u as ri,v as ii,y as ai}from"./require-guards-CnSYqjDO.js";import{S as oi,_ as si,b as ci,c as li,d as ui,f as di,g as fi,h as pi,l as mi,m as hi,n as gi,o as _i,p as vi,t as yi,u as bi,v as xi,x as Si,y as Ci}from"./jsh-executor-BFwK2t97.js";import{n as wi,t as Ti}from"./esbuild-wasm-D-czepwO.js";import{n as Ei}from"./wasm-compiler-Ct7QZURL.js";import{a as Di,o as Oi,s as ki,t as Ai}from"./usb-device-registry-DEKs171n.js";import{i as ji,r as Mi,t as Ni}from"./script-catalog-DDeMaTU_.js";import{a as Pi,c as Fi,o as Ii,s as Li,t as Ri}from"./types-BR5TkXSs.js";import{a as zi,c as Bi,d as Vi,f as Hi,n as Ui,r as Wi,u as Gi}from"./github-zip-BSEJCt49.js";import{i as Ki,t as qi}from"./github-auth-CkLbjC-d.js";import{a as Ji,i as Yi,o as Xi,r as Zi,t as Qi}from"./provenance-C7BfNno_.js";import{a as $i,c as ea,i as ta,n as na,o as ra,r as ia,s as aa}from"./github-install-VgcR2-6K.js";import{n as oa,t as sa}from"./magick-wasm-BItevhnv.js";import{i as ca,n as la,r as ua,t as da}from"./pdf-raster-D30vfUF_.js";import{n as fa}from"./lick-target-env-8JxfVcIV.js";import{t as pa}from"./tmpdir-env-ate4iNcK.js";import{n as ma,t as ha}from"./keyboard-TcuVIW9F.js";import{n as ga,t as _a}from"./hf-defaults-BwJdGLgk.js";import{t as va}from"./ffmpeg-wasm-xaOnfsRx.js";import{t as ya}from"./local-llm-NE-qI2cb.js";import{i as ba,n as xa,r as Sa,t as Ca}from"./tar-BjnO16Uf.js";import{a as wa,c as Ta,i as Ea,o as Da,r as Oa,s as ka}from"./v86-vm-BlgIo0B_.js";import{n as Aa,r as ja}from"./lick-urls-CgPiVwD-.js";let Ma=null;function Na(e){Ma=e!==null&&Number.isFinite(e)&&e>0?e:null}function Pa(){if(Ma!==null)return Ma;let e=globalThis.performance?.timeOrigin;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:Date.now()}new URL(r).hostname;const Fa=/^([0-9a-f]{32})--(?:[0-9a-f]{8}-)?([0-9a-f]+)$/i;function Ia(e){let t;try{t=new URL(e.includes(`://`)?e:`https://${e}`).hostname}catch{return null}let n=Fa.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 La(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 Ra(e,t){return e.some(e=>La(e,t))}const za=`slicc-transcript`,Ba=[`canonical-agent-history-unavailable`,`tool-data-may-be-truncated`,`model-metadata-unavailable`,`scoop-history-unavailable`,`attachment-file-missing`,`attachment-association-unavailable`,`complete-snapshot-unavailable`],Va=/* @__PURE__ */ new Set(/* @__PURE__ */ `/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 Ha(e){return Va.has(e.replace(/\/\d+(?=\/|$)/g,`/*`))}var Ua=class extends Error{code;detail;constructor(e,t){super(t?`${e}: ${t}`:e),this.code=e,this.detail=t,this.name=`TranscriptExportError`}};const Wa=new Set(Ba),Ga=/^[0-9a-fA-F]{64}$/,Ka=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/;function I(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qa(e){return typeof e==`string`&&Ga.test(e)}function Ja(e){return Ka.test(e)&&Number.isFinite(Date.parse(e))}function Ya(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 Xa(e,t,n){return typeof e!=`string`||!t.includes(e)?{ok:!1,error:Ya(n,t)}:{ok:!0}}function Za(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 Qa(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 $a(e,t){if(!I(e))return{ok:!1,error:`${t} must be a non-null object`};let n=Xa(e.type,[`text`,`tool-call`,`attachment-ref`],`${t}.type`);return n.ok?Qa(e,t):n}function eo(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 to(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 no(e,t){let n=eo(e,t);if(!n.ok)return n;let r=e.cost;return I(r)?to(r,`${t}.cost`):{ok:!1,error:`${t}.cost must be a non-null object`}}function ro(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`?Ja(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 io(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 ao(e,t){let n=e.usage;return n===void 0?{ok:!0}:I(n)?no(n,`${t}.usage`):{ok:!1,error:`${t}.usage must be a non-null object`}}function oo(e,t){if(!I(e))return{ok:!1,error:`${t} must be a non-null object`};let n=Xa(e.role,[`user`,`assistant`,`tool-result`],`${t}.role`);if(!n.ok)return n;if(e.role===`tool-result`){let n=io(e,t);if(!n.ok)return n}let r=ro(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=Za(i,$a,`${t}.content`);return a.ok?ao(e,t):a}function so(e,t){if(!I(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=Xa(e.kind,[`cone`,`scoop`],`${t}.kind`);if(!n.ok)return n;let r=e.messages;return Array.isArray(r)?Za(r,oo,`${t}.messages`):{ok:!1,error:`${t}.messages must be an array`}}function co(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 lo(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`}:qa(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 uo=[`attachment-file-missing`,`attachment-association-unavailable`];function fo(e,t){let n=e.path,r=e.sha256,i=e.byteLength;return n===``?r===``?i===0?Xa(e.missingReason,uo,`${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 po(e,t){return e.present?lo(e,t):fo(e,t)}function mo(e,t){if(!I(e))return{ok:!1,error:`${t} must be a non-null object`};let n=co(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=Xa(e.handling,[`text-redacted`,`binary-unchanged`],`${t}.handling`);return r.ok?po(e,t):r}function ho(e,t){let n=Xa(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 go(e,t){if(!I(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=Xa(e.detector,[`known-secret`,`credential-pattern`,`pre-obfuscated`],`${t}.detector`);if(!n.ok)return n;let r=e.target;return I(r)?ho(r,`${t}.target`):{ok:!1,error:`${t}.target must be a non-null object`}}function _o(e,t){return I(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 vo(e,t){return typeof e!=`string`||!Wa.has(e)?{ok:!1,error:`${t} is not a valid completeness reason`}:{ok:!0}}function yo(e){if(!I(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 I(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 bo(e){if(!I(e))return{ok:!1,error:`session.completeness must be a non-null object`};let t=Xa(e.status,[`complete`,`partial`],`session.completeness.status`);return t.ok?Array.isArray(e.missing)?Za(e.missing,vo,`session.completeness.missing`):{ok:!1,error:`session.completeness.missing must be an array`}:t}function xo(e){if(!I(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=Xa(e.state,[`active`,`frozen`],`session.state`);return t.ok?bo(e.completeness):t}function So(e){if(!I(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(!I(e.redactionCounts))return{ok:!1,error:`privacy.redactionCounts must be a non-null object`};let n=e.redactions;return Array.isArray(n)?Za(n,go,`privacy.redactions`):{ok:!1,error:`privacy.redactions must be an array`}}function Co(e){let t=e.conversations;if(!Array.isArray(t))return{ok:!1,error:`conversations must be an array`};let n=Za(t,so,`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=Za(r,_o,`delegations`);if(!i.ok)return i;let a=e.attachments;return Array.isArray(a)?Za(a,mo,`attachments`):{ok:!1,error:`attachments must be an array`}}function wo(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let r of e){if(!I(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(I(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 To(e){for(let t of e){if(!I(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(!I(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 Eo(e){let t=[];for(let n of e){if(!I(n))continue;let e=n.content;if(Array.isArray(e))for(let n of e)I(n)&&n.type===`tool-call`&&typeof n.id==`string`&&t.push(n.id)}return t}function Do(e){let t=/* @__PURE__ */ new Set;for(let n of e){if(!I(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of Eo(e))t.add(n)}return t}function Oo(e,t){for(let n of e){if(!I(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of e){if(!I(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 ko(e){return Oo(e,Do(e))}function Ao(e,t){for(let n of e){if(!I(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 jo(e,t){for(let n of e){if(!I(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of e){if(!I(n))continue;let e=n.content;if(!Array.isArray(e))continue;let r=Ao(e,t);if(!r.ok)return r}}return{ok:!0}}function Mo(e,t){let n=/* @__PURE__ */ new Set;for(let e of t)I(e)&&typeof e.id==`string`&&n.add(e.id);return jo(e,n)}function No(e){let t=/* @__PURE__ */ new Map;for(let n of e){if(!I(n)||typeof n.id!=`string`)continue;let e=/* @__PURE__ */ new Set,r=n.messages;if(Array.isArray(r))for(let t of r)I(t)&&typeof t.id==`string`&&e.add(t.id);t.set(n.id,e)}return t}function Po(e,t){let n=No(t);for(let t=0;t<e.length;t++){let r=e[t];if(!I(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 Fo(e){let t=/* @__PURE__ */ new Map;for(let n of e){if(!I(n)||typeof n.id!=`string`)continue;let e=Array.isArray(n.messages)?n.messages:[];t.set(n.id,new Set(Eo(e)))}return t}function Io(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];if(!I(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 Lo(e,t){let n=/* @__PURE__ */ new Set;for(let e of t)I(e)&&typeof e.id==`string`&&n.add(e.id);return Io(e,n,Fo(t))}function Ro(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 zo(e,t){let n=/* @__PURE__ */ new Set;for(let e of t)I(e)&&typeof e.id==`string`&&n.add(e.id);for(let t=0;t<e.length;t++){let r=e[t];if(!I(r))continue;let i=r.target;if(!I(i))continue;let a=Ro(i,n,`privacy.redactions[${t}].target`);if(!a.ok)return a}return{ok:!0}}function Bo(e){let t=e.conversations,n=e.attachments,r=e.delegations,i=e.privacy,a=Array.isArray(i?.redactions)?i.redactions:[],o=wo(t);if(!o.ok)return o;let s=To(t);if(!s.ok)return s;let c=ko(t);if(!c.ok)return c;let l=Mo(t,n);if(!l.ok)return l;let u=Po(n,t);if(!u.ok)return u;let d=Lo(r,t);return d.ok?zo(a,n):d}function Vo(e){let t=Co(e);return t.ok?Bo(e):t}function Ho(e){if(!I(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=yo(e.export);if(!t.ok)return t;let n=xo(e.session);if(!n.ok)return n;let r=So(e.privacy);return r.ok?Vo(e):r}async function Uo(e,t,n){let r=await n({method:`GET`,path:`/${e}/sites/${t}/config.json`,origin:nt});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:Wo(a),sourceUrl:a}}function Wo(e){if(!e)return`da`;let t;try{t=new URL(e).host}catch{return`da`}return t===`api.aem.live`?`aem`:`da`}const Go=`slicc-sprinkle-routes`;function Ko(){try{let e=localStorage.getItem(Go);return e?JSON.parse(e):{}}catch{return{}}}function qo(e){try{localStorage.setItem(Go,JSON.stringify(e))}catch{}}function Jo(e){return Ko()[e]}function Yo(e,t){let n=Ko();n[e]=t,qo(n)}function Xo(e){let t=Ko();delete t[e],qo(t)}function Zo(){return Ko()}function Qo(e,t,n){return Et(t,n,`${e} adapter does not implement ${t}.${n}`)}function $o(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(Qo(e,t,n))]});return{...Object.fromEntries(a),allowlist:i,supports:e=>i.includes(e)}}function es(e){let{adapter:t,pageGestures:n}=e,r=n??{};return{adapter:t,browser:$o(t,`browser`,kt,e.browser),network:$o(t,`network`,Tt,e.network),secrets:$o(t,`secrets`,At,e.secrets),devices:$o(t,`devices`,jt,{usbRequest:r.usbRequest,serialRequest:r.serialRequest,hidRequest:r.hidRequest,...e.devices}),mounts:$o(t,`mounts`,Dt,{pickDirectory:r.pickDirectory,...e.mounts}),approvals:$o(t,`approvals`,Mt,e.approvals)}}function ts(e={}){return es({adapter:`connect`,pageGestures:e.pageGestures})}function ns(e){let t=Nt(()=>import(`./extension-ops-BWWe8FOb.js`).then(t=>t.createExtensionOps(e)));return es({adapter:e.adapter,pageGestures:e.pageGestures,network:{crossOriginFetch:e=>E(`network`,`crossOriginFetch`,async()=>(await t()).crossOriginFetch(e))},secrets:{listMaskedEnv:()=>E(`secrets`,`listMaskedEnv`,async()=>(await t()).secrets.listMaskedEnv()),getMasked:e=>E(`secrets`,`getMasked`,async()=>(await t()).secrets.getMasked(e)),set:e=>E(`secrets`,`set`,async()=>(await t()).secrets.set(e)),delete:e=>E(`secrets`,`delete`,async()=>(await t()).secrets.delete(e))},mounts:{signRequest:e=>E(`mounts`,`signRequest`,async()=>(await t()).signRequest(e))},approvals:{request:e=>E(`approvals`,`request`,async()=>(await t()).requestApproval(e))}})}function rs(e={}){let t=Nt(()=>import(`./rest-ops-DdaQHTK4.js`).then(t=>t.createRestOps(e)),e.controlTimeoutMs??1e4);return es({adapter:`node-rest`,pageGestures:e.pageGestures,network:{localNodeServer:()=>Promise.resolve({ok:!0,value:{available:!0}}),crossOriginFetch:e=>E(`network`,`crossOriginFetch`,async()=>(await t()).crossOriginFetch(e))},secrets:{listMaskedEnv:()=>E(`secrets`,`listMaskedEnv`,async()=>(await t()).secrets.listMaskedEnv()),getMasked:e=>E(`secrets`,`getMasked`,async()=>(await t()).secrets.getMasked(e)),set:e=>E(`secrets`,`set`,async()=>(await t()).secrets.set(e)),delete:e=>E(`secrets`,`delete`,async()=>(await t()).secrets.delete(e))},mounts:{signRequest:e=>E(`mounts`,`signRequest`,async()=>(await t()).signRequest(e))},approvals:{request:e=>E(`approvals`,`request`,async()=>(await t()).requestApproval(e))}})}function is(e,t={}){let{pageGestures:n}=t;switch(e){case`node-rest`:return rs({pageGestures:n});case`extension-direct`:case`extension-delegate`:return ns({adapter:e,pageGestures:n});case`connect`:return ts({pageGestures:n})}}const as=e(`quick-llm`);async function os(e){let t=d();if(!t)return as.debug(`No API key for active provider — skipping`),null;let n=u(),r=l(),i;if(i=e.modelId?us(n,e.modelId)??us(n,r):ss(n,r),!i)return as.debug(`No model available for provider`,{providerId:n}),null;let a=Fe(e.prompt),o=e.system===void 0?void 0:Fe(e.system),s={role:`user`,content:a,timestamp:Date.now()},c={};i.provider===`adobe`&&(c[`X-Session-Id`]=ds());try{let n=(await Pe(i,{systemPrompt:o,messages:[s]},{apiKey:t,maxTokens:e.maxTokens??60,temperature:e.temperature??.3,signal:e.signal,headers:Object.keys(c).length>0?c:void 0})).content.filter(e=>e.type===`text`).map(e=>e.text).join(``).trim();return n.length>0?n:null}catch(e){return as.debug(`Quick label call failed`,{error:e instanceof Error?e.message:String(e)}),null}}function ss(e,t){let n=f(e);if(n.length===0)return;let r=n.find(e=>e.id===t)??n[0],i=ls(r.id),a=n.filter(e=>cs(e,r,i));return a.length===0?r:(a.sort((e,t)=>(e.cost?.input??0)-(t.cost?.input??0)),a[0])}function cs(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 ls(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 us(e,t){return f(e).find(e=>e.id===t)}function ds(){return Ft(`ui-quick-llm`)}const fs=e(`sudo-suggest`),ps=[`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
  `),ms=[`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 hs(e,t){if(e.suggestedPattern&&e.suggestedPattern.trim().length>0)return e.suggestedPattern.trim();let n=e.detail.trim();if(e.kind===`guest-message`||e.kind===`guest-tool`)return n;let r=e.kind===`command`?ps:ms,i=null;try{i=await os({prompt:n,system:r,maxTokens:40,temperature:0,signal:t})}catch(e){fs.debug(`suggestPattern: quickLabel threw`,{error:e instanceof Error?e.message:String(e)}),i=null}return gs(i)||n}function gs(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 _s=e(`sudo:capability-gesture`);function vs(e,t={}){let n=t.suggest??hs;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 _s.warn(`sudo approval aborted before prompting — denying`,{detail:t.detail}),wt();if(!e)return _s.warn(`no CapabilityBroker injected for the sudo gesture hop — denying (composition bug, never a guessed transport)`,{detail:t.detail}),wt();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?Ot(o.value,a):(_s.warn(`capability broker approvals.request failed — denying`,{message:o.message}),wt())}}}const ys=e(`sudo:tray-first`);function bs(e,t={}){let n=t.suggest??hs,r=t.timeoutMs??6e5,i=t.getClient??(async()=>{let{getPanelRpcClient:e}=await import(`./panel-rpc-BJU93e51.js`).then(e=>e.r);return e()});return{async requestApproval(t,a){if(a?.signal?.aborted)return wt();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){ys.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 Ss(e?.decision,o)}catch(e){ys.warn(`tray-first sudo probe failed — using native broker`,{error:e instanceof Error?e.message:String(e)})}return e.requestApproval(s,a)}}}const xs=[`user-timeout`,`cone-timeout`,`unavailable`];function Ss(e,t){if(!e||typeof e!=`object`)return wt();let n=e,r=n.attestation===`biometric`||n.attestation===`passcode`||n.attestation===`none`?n.attestation:void 0;if(n.decision===`allow`)return{decision:`allow`,...r?{attestation:r}:{}};if(n.decision===`always`)return{decision:`always`,pattern:typeof n.pattern==`string`&&n.pattern.trim().length>0?n.pattern.trim():t,...r?{attestation:r}:{}};if(n.decision!==`deny`)return wt();let i=xs.find(e=>e===n.reason);return i?{decision:`deny`,reason:i}:{decision:`deny`}}function Cs(e,t){return{requestApproval(n){return t.enqueueSudoRequest(e,n)}}}function ws(){return`lick-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}var Ts=class{pending=/* @__PURE__ */ new Map;timeoutMs;newId;setTimer;clearTimer;onAutoSettle;constructor(e={}){this.timeoutMs=e.timeoutMs??3e5,this.newId=e.newId??ws,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(ae(`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`,reason:`unavailable`}),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`,reason:`unavailable`}),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 Es(e){return re(Ds(e))}function Ds(e){let t=vs(e);return e?.adapter===`extension-direct`||e?.adapter===`extension-delegate`?t:bs(t)}let Os=null;function ks(e){return Os=e,()=>{Os===e&&(Os=null)}}function As(){if(!Os)throw new Ua(`session-not-found`);return Os}const js=`focus`,Ms={type:`leaf`,surfaceId:`chat`};function Ns(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 Ps={focus:{name:`focus`,tree:Ns({left:Ms},{left:3,middle:1})}};function Fs(e){return Ps[e]??null}const Is=`progress`;async function Ls(){try{let e=await qt();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 Jt(e.idbKey);if(!t)throw Error(`mount: no directory handle found in storage`);return await Kt(t),t}throw Error(`mount: unexpected popup result`)}catch(e){throw Error(`mount: ${e instanceof Error?e.message:String(e)}`)}}async function Rs(){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)}`)}}async function zs(e,t){let n;try{({grants:n}=await e.call(`permission-request`,{kinds:[`filesystem`],description:`A command in the terminal asks to mount a local directory at ${t}.`},{timeoutMs:3e5}))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(t.replace(/^permission-request: /,``))}let r=n.find(e=>e.kind===`filesystem`);if(!r||!(`idbKey`in r))throw Error(`no directory selected`);let i=await Jt(r.idbKey);if(!i)throw Error(`no directory handle found in storage`);return await Kt(i),i}function Bs(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 Vs(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 Hs=/* @__PURE__ */ new Set([`--source`,`--profile`,`--backend`,`--max-body-mb`]);function Us(e){for(let t=0;t<e.length;t++){let n=e[t];if(n===`--`)return!1;if(n===`--help`||n===`-h`)return!0;Hs.has(n)&&t++}return!1}function Ws(e){return`aem://${e.org}/${e.name}${e.path?`/${e.path}`:``}`}var Gs=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=Bs(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=Ve();if(!n){let n=await Ks(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=be()?null:b(),i;if(n){let t=this.options.acquireLocalMountViaToolUI;if(!t)throw Error(`mount: tool UI not available in this runtime`);i=await t(n,e)}else i=te()?await Ls():r?await zs(r,e):await Rs();let a=Qe.fromHandle(i,{mountId:at()});return await this.options.fs.mount(e,a,{env:t}),{stdout:`Mounted '${a.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=at(),i=new ot({mountId:r,ttlMs:3e4}),a=new et({source:t.source,profile:n,cache:i,maxBodyBytes:t.maxBodyMb?t.maxBodyMb*1024*1024:void 0,mountId:r,signedFetch:this.signedFetchS3??tt(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??it(),i=Vs(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 Uo(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=at(),c=new ot({mountId:s,ttlMs:3e4}),l={source:a===`aem`?Ws(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 rt(l):new $e(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(Us(e))return n===`umount`?this.umountHelp():this.help();let r=Bs(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-xM3U8UHg.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-MMXYpOmA.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
@@ -288,7 +288,7 @@ Examples:
288
288
  skill list
289
289
  skill info bluebubbles
290
290
  skill read bluebubbles
291
- `,stderr:``,exitCode:0};let r=t[0],i=await import(`./kernel-worker-D39FXX2x.js`).then(e=>e.r);try{switch(r){case`list`:return Gh(t,e,i,n.env.get(`PATH`));case`info`:{let n=t[1];if(!n)return{stdout:``,stderr:`skill: info requires a skill name
291
+ `,stderr:``,exitCode:0};let r=t[0],i=await import(`./kernel-worker-DadD3ayk.js`).then(e=>e.r);try{switch(r){case`list`:return Gh(t,e,i,n.env.get(`PATH`));case`info`:{let n=t[1];if(!n)return{stdout:``,stderr:`skill: info requires a skill name
292
292
  `,exitCode:1};let r=await i.getSkillInfo(e,n);return r?{stdout:Uh(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
293
293
  `,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+`
294
294
  `,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 qh=[{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=>ta(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 Jh(e){let t={skills:[],dryRun:!1,json:!1};for(let n=0;n<e.length;n++){let r=e[n],i=qh.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 Yh(e,t){return!e||!t||e.byteLength!==t.byteLength?!1:e.every((e,n)=>e===t[n])}async function Xh(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 Zh(e,t,n,r){let i=await Xh(e,t);return Vi(n)?i?{status:`kept-local`,write:!1}:{status:`added`,write:!0}:i?Yh(i,r)?{status:`unchanged`,write:!1}:{status:`updated`,write:!0}:{status:`added`,write:!0}}async function Qh(e,t,n,r){let i={changes:[],writes:[],removals:[]};for(let[r,a]of n){let n=`${t}/${r}`,{status:o,write:s}=await Zh(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 $h(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 qi(t),d=await Yi(s,c,o.ref,u,!0,l||void 0);if(d&&r.sha===d&&await eg(e,n,r))return{...o,to:d,outcome:`current`,changes:[]};let f=await tg(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 Qh(e,`${Pi}/${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 og(e,{changes:h,writes:g,removals:_}),await Xi(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 eg(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 tg(e,t,n,r,i,a,o){let s=await Wi(e,t,a,i??`main`);if(s.status===`ok`){let i=zi(s.files),a=n||ng(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:ag(i,a),path:a}}try{return{files:ig(rg(await Ui(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 ng(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 rg(e){return new Map([...e].filter(([e])=>Bi(e)))}function ig(e){return new Map([...e].sort(([e],[t])=>e.localeCompare(t)))}function ag(e,t){let n=t?`${t}/`:``,r=/* @__PURE__ */ new Map;for(let[t,i]of Object.entries(e)){if(!t.startsWith(n)||t.endsWith(`/`))continue;let e=t.slice(n.length);Bi(e)&&r.set(e,i)}return ig(r)}async function og(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 sg(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 Rh(o,s,t);if(!c.ok)return{...a,outcome:`error`,error:c.error};let l=`${Pi}/${n}/SKILL.md`,u=await Xh(e,l),d=new TextEncoder().encode(c.content),f=u!==void 0&&Ih(new TextDecoder().decode(u))===Ih(c.content);if(Yh(u,d)||f)return{...a,changes:[{path:`SKILL.md`,status:`unchanged`}]};let p=u?`updated`:`added`;return i||(await e.mkdir(`${Pi}/${n}`,{recursive:!0}),await e.writeFile(l,d),await Xi(e,n,{...r,files:[`SKILL.md`]})),{...a,outcome:`updated`,changes:[{path:`SKILL.md`,status:p}]}}function cg(e,t){if(e.outcome===`error`)return` ${e.skill}: failed — ${e.error}\n`;let n=/* @__PURE__ */ 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 lg(e,t,n,r){let i=ta(t);return i?{version:1,kind:`github`,source:`${i.owner}/${i.repo}`,skill:e,ref:r??i.branch,path:n??i.path,installed:(/* @__PURE__ */ new Date()).toISOString()}:null}async function ug(e,t,n){if(t.length===0){let t=await Ji(e);return{targets:t.provenanced,missing:[],skipped:t.unattributed}}let r=[],i=[];for(let a of t){let t=await Zi(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?lg(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 dg(e){return e.reason===`not-installed`?`upskill: no skill named "${e.name}" is installed — check \`upskill list\`
@@ -299,7 +299,7 @@ Examples:
299
299
  `}function mg(e,t,n,r,i){let a=t?`Skill update (dry run — nothing written):
300
300
  `:`Skill update:
301
301
  `;for(let n of e)a+=cg(n,t);if(i.length>0&&(a+=pg(i)),!n&&r&&e.length>0){let n=i.length>0?`all ${fg(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 hg(e,t,n){let{targets:r,missing:i,skipped:a}=await ug(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 sg(e,t,i.name,i.provenance,n.dryRun):await $h(e,t,i.name,i.provenance,n.branch,n.dryRun));return{results:o,skipped:a,missing:i}}async function gg(e,t,n){let r=Jh(e);if(r.error)return{stdout:``,stderr:`${r.error}\n`,exitCode:1};let{results:i,missing:a,skipped:o}=await hg(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`:mg([],r.dryRun,!1,!0,o),stderr:``,exitCode:0}:{stdout:``,stderr:a.length?a.map(dg).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 ea();let l=a.map(dg).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:mg(i,r.dryRun,c,u,o),stderr:l,exitCode:+!u}}function _g(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 vg(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 yg(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}${vg(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(`
302
- `)}\n`}async function bg(e,t,n){let r=await(await import(`./kernel-worker-D39FXX2x.js`).then(e=>e.r)).discoverSkills(e),{collisions:i}=await wr(e,xr(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${Bh()}`,stderr:``,exitCode:0}:{...Sr(`upskill`,Hh(r,`Discoverable local skills`),i,{builtinNames:new Set(mt())}),exitCode:0}}async function xg(e,t,n){let{results:r,skipped:i}=await hg(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:yg(r,i),stderr:c,exitCode:+!s}}async function Sg(e,t,n,r){let i=_g(e);return i.error?{stdout:``,stderr:`${i.error}\n`,exitCode:1}:i.outdated?xg(t,n,i.json):bg(t,i.json,r)}async function Cg(e,t){let n=`${Fi}/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(Ki(e,n))}if(r.status!==200)throw Error(`Tessl returned HTTP ${r.status}`);let i=ke(r.body);if(!i.data)return[];let a=/* @__PURE__ */ new Map;for(let e of i.data){if(e.type!==`skill`)continue;let t=e.attributes,n=$i(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 wg(e,t){let n=`${Fi}/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: ${Ki(e,n)}`}}if(r.status!==200)return{error:`Tessl search failed (HTTP ${r.status})`};let i=ke(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=$i(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 Tg=[{label:`Tessl`,host:new URL(Fi).host,fetch:Cg},{label:`browse.sh`,host:new URL(Ri).host,fetch:Ah}];function Eg(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 Dg(e,t,n=1){let r=await Promise.allSettled(Tg.map(n=>n.fetch(e,t))),i=r.map(e=>e.status===`fulfilled`?e.value:[]),a=r.every(e=>e.status===`rejected`),o=Eg(i),s=``;for(let e=0;e<r.length;e++){let t=r[e];if(t.status===`rejected`){let n=Tg[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+=`
302
+ `)}\n`}async function bg(e,t,n){let r=await(await import(`./kernel-worker-DadD3ayk.js`).then(e=>e.r)).discoverSkills(e),{collisions:i}=await wr(e,xr(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${Bh()}`,stderr:``,exitCode:0}:{...Sr(`upskill`,Hh(r,`Discoverable local skills`),i,{builtinNames:new Set(mt())}),exitCode:0}}async function xg(e,t,n){let{results:r,skipped:i}=await hg(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:yg(r,i),stderr:c,exitCode:+!s}}async function Sg(e,t,n,r){let i=_g(e);return i.error?{stdout:``,stderr:`${i.error}\n`,exitCode:1}:i.outdated?xg(t,n,i.json):bg(t,i.json,r)}async function Cg(e,t){let n=`${Fi}/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(Ki(e,n))}if(r.status!==200)throw Error(`Tessl returned HTTP ${r.status}`);let i=ke(r.body);if(!i.data)return[];let a=/* @__PURE__ */ new Map;for(let e of i.data){if(e.type!==`skill`)continue;let t=e.attributes,n=$i(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 wg(e,t){let n=`${Fi}/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: ${Ki(e,n)}`}}if(r.status!==200)return{error:`Tessl search failed (HTTP ${r.status})`};let i=ke(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=$i(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 Tg=[{label:`Tessl`,host:new URL(Fi).host,fetch:Cg},{label:`browse.sh`,host:new URL(Ri).host,fetch:Ah}];function Eg(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 Dg(e,t,n=1){let r=await Promise.allSettled(Tg.map(n=>n.fetch(e,t))),i=r.map(e=>e.status===`fulfilled`?e.value:[]),a=r.every(e=>e.status===`rejected`),o=Eg(i),s=``;for(let e=0;e<r.length;e++){let t=r[e];if(t.status===`rejected`){let n=Tg[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+=`
303
303
  `}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:
304
304
  `,p+=` From Tessl: upskill <owner/repo> --skill <name>
305
305
  `,p+=` From browse.sh: upskill browse:<hostname>/<task>
@@ -322,7 +322,7 @@ Examples:
322
322
  `,{stdout:s,stderr:``,exitCode:0}}function Pg(e){return!e||e.startsWith(`-`)?{stdout:``,stderr:`upskill: --branch requires a value
323
323
  `,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
324
324
  `,exitCode:1}}function Fg(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
325
- `,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=Pg(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 Ig(e,t,n){if(!t)return{stdout:``,stderr:`upskill: ${e} requires a skill name\n`,exitCode:1};let r=await import(`./kernel-worker-D39FXX2x.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 Zi(n,t),a=i?Qi(i):"Installed from: (no provenance recorded — reinstall to enable `upskill update`)\n";return{stdout:Uh(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+`
325
+ `,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=Pg(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 Ig(e,t,n){if(!t)return{stdout:``,stderr:`upskill: ${e} requires a skill name\n`,exitCode:1};let r=await import(`./kernel-worker-DadD3ayk.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 Zi(n,t),a=i?Qi(i):"Installed from: (no provenance recorded — reinstall to enable `upskill update`)\n";return{stdout:Uh(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+`
326
326
  `,stderr:``,exitCode:0}}async function Lg(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 ra(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 Rg(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 na(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 zg(e,t,n,r,i,a,o,s){let c=``,l=``,u=0;for(let d of e){let e=await na(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 Bg(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 Vg(e,t,n,r){let{owner:i,repo:a}=e,o=t.branch??e.branch,s=t.subPath??e.path,c=await qi(r),l=await ia(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:Bg(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:Bg(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 Wi(i,a,r,o);if(e.status===`ok`){let r=await Yi(i,a,o,c,!0,s),l=await Lg(u,i,a,zi(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 Rg(u,i,a,c,n,t.force,o,f);({output:p,errors:m,successCount:h}=e)}}else({output:p,errors:m,successCount:h}=await zg(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 ea()),{stdout:p,stderr:m,exitCode:+!!m}}async function Hg(e,t,n,r,i){switch(e[0]){case`tabs`:return Mg(t,n,r,e.includes(`--json`));case`recommendations`:return Ng(t,n,e.includes(`--install`));case`update`:case`upgrade`:return gg(e.slice(1),t,n);case`list`:return Sg(e.slice(1),t,n,i);case`info`:case`read`:return Ig(e[0],e[1],t);case`search`:return Wg(e,n);default:return null}}function Ug(e,t,n){return C(`upskill`,async(r,i)=>{if(r.length===0||r.includes(`--help`)||r.includes(`-h`))return Wh();let a=await Hg(r,e,t,n,i.env.get(`PATH`));if(a)return a;let o=Fg(r);if(o.earlyReturn)return o.earlyReturn;if(!o.sourceRef)return Wh();if(o.sourceRef.startsWith(`tessl:`))return Gg(o.sourceRef,o.force,e,t);let s=Nh(o.sourceRef);if(s)return zh(s.hostname,s.task,e,t,o.force);let c=ta(o.sourceRef);return c?Vg(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 Wg(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?Dg(a,t,i):Wh()}async function Gg(e,t,n,r){let i=e.slice(6);if(!i)return{stdout:``,stderr:`upskill: tessl: requires a skill name
327
327
  `,exitCode:1};let a=await wg(i,r);if(`error`in a)return{stdout:``,stderr:`upskill: ${a.error}\n`,exitCode:1};let o=await qi(r);return na(a.owner,a.repo,a.skillPath,a.skillName,n,o,t,r)}function Kg(){return{stdout:`usage: afplay [-v volume] [-r rate] <file>
328
328
 
@@ -1273,7 +1273,7 @@ Options:
1273
1273
  `,exitCode:1};let i=[];for(let e of r.positionals){let t=n.fs.resolvePath(n.cwd,e);if(!(await n.fs.stat(t)).isFile)return{stdout:``,stderr:`imgcat: not a file: ${e}\n`,exitCode:1};let r=Le(t);if(!Ie(r))return{stdout:``,stderr:`imgcat: unsupported media type: ${e}\n`,exitCode:1};let a=await n.fs.readFileBuffer(t),o=new Uint8Array(a.byteLength);o.set(a),i.push({path:t,mimeType:r,bytes:o})}try{return await e.onMediaPreview(i),{stdout:``,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`imgcat: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}})}const UD=/* @__PURE__ */ new Set([`run`,`run-script`]),WD=/* @__PURE__ */ new Set([`test`,`start`,`stop`,`restart`]),GD=/* @__PURE__ */ new Set([` `,` `,`
1274
1274
  `,`;`,`|`,`&`,`(`,`)`,`{`,`}`,`<`,`>`]),KD=/* @__PURE__ */ new Set([`;`,`|`,`&`,`(`,`)`,`{`,`
1275
1275
  `]),qD=/^[A-Za-z_][A-Za-z0-9_]*=/,JD=/^[@A-Za-z0-9._-]+$/,YD=/* @__PURE__ */ new Set([`if`,`then`,`else`,`elif`,`fi`,`for`,`while`,`until`,`do`,`done`,`case`,`in`,`esac`,`function`,`time`,`!`]),XD=/* @__PURE__ */ new Set([`if`,`then`,`else`,`elif`,`while`,`until`,`do`,`time`,`!`]),ZD=/* @__PURE__ */ new Set([`ipx`,`npx`]);function QD(e){return`'${e.replace(/'/g,`'\\''`)}'`}async function $D(e,t){let n=await e.readFile(t);return typeof n==`string`?n:new TextDecoder().decode(n)}function*eO(e){let t=x(e);for(;yield t,t!==`/`;)t=Ge(t).dir}function tO(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 nO(e){return typeof e==`string`?e:void 0}async function rO(e,t){for(let n of eO(t)){let t=S(n,`package.json`);if(!await e.exists(t))continue;let r;try{r=JSON.parse(await $D(e,t))}catch(e){throw Error(`${t} is not valid JSON: ${e instanceof Error?e.message:String(e)}`)}return{dir:n,name:nO(r.name),version:nO(r.version),scripts:tO(r.scripts)}}return null}function iO(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(GD.has(t))break;n++}return{start:t,end:n,text:e.slice(t,n)}}function aO(e){let t=[],n=0,r=!0;for(;n<e.length;){let i=e[n];if(i===` `||i===` `){n++;continue}if(KD.has(i)){r=!0,n++;continue}let a=iO(e,n);if(a.end===a.start){n++;continue}if(r&&!qD.test(a.text)){if(XD.has(a.text)){n=a.end;continue}t.push(a),r=!1}n=a.end}return t}function oO(e,t){return!JD.test(e)||YD.has(e)||ZD.has(e)?!1:!t.isRegistered(e)}async function sO(e,t){let n=aO(e).filter(e=>oO(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 cO(e){let t=[];for(let n of eO(e))t.push(S(n,`node_modules`,`.bin`));return t}function lO(e,t,n,r){let i=r.env.get(`PATH`)??``,a={PATH:[...cO(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 uO(e){return e.name===void 0?e.dir:e.version===void 0?e.name:`${e.name}@${e.version}`}function dO(e,t){let n=Object.entries(t.scripts);if(n.length===0)return`${e}: no scripts defined in ${S(t.dir,`package.json`)}\n`;let r=[`Scripts available in ${uO(t)} via \`${e} run\`:`];for(let[e,t]of n)r.push(` ${e}`),r.push(` ${t}`);return`${r.join(`
1276
- `)}\n`}function fO(e,t){return t===`--silent`||t===`-s`?(e.silent=!0,!0):t===`--if-present`&&(e.ifPresent=!0,!0)}function pO(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}fO(t,a)||(r===void 0?r=a:n.push(a))}return{flags:t,script:r,extraArgs:n}}function mO(e,t){return{stdout:``,stderr:`${e}: ${t}\n`,exitCode:1}}function hO(e,t,n,r){let i=r.length>0?` ${r.map(QD).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 gO(e,t,n,r){if(n===`start`&&await r.exists(S(t.dir,`server.js`)))return`node server.js`;if(n===`restart`)return`${e} stop --if-present && ${e} start`}function _O(e,t,n){let r=new Set(n.getRegisteredCommands?.()??[]);return{isRegistered:e=>r.has(e),hasLocalBin:async n=>{for(let r of cO(t.dir))if(await e.exists(S(r,n)))return!0;return!1}}}async function vO(e,t,n,r,i,a){let o=i.exec;if(!o)return mO(e,`run requires shell exec support, which this context does not provide`);let s=_O(a.fs,t,i),c=uO(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 sO(a.body,s),{cwd:t.dir,env:lO(t,a.event,a.body,i),stdin:lr(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 yO(e,t,n,r){let i;try{i=await rO(r.fs,n.cwd)}catch(t){return mO(e,t instanceof Error?t.message:String(t))}if(!i)return mO(e,`no package.json found in ${n.cwd} or any parent directory — nothing to run`);let{flags:a,script:o,extraArgs:s}=pO(t);if(o===void 0)return{stdout:dO(e,i),stderr:``,exitCode:0};let c=i.scripts[o]??await gO(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 mO(e,`missing script: ${o}${t.length>0?` (available: ${t.join(`, `)})`:` (${S(i.dir,`package.json`)} defines no scripts)`}`)}return vO(e,i,hO(i,o,c,s),a,n,r)}const bO=()=>import(`./installer-c3P1y6c8.js`),xO=/* @__PURE__ */ new Set([`install`,`i`,`add`]),SO=/* @__PURE__ */ new Set([`uninstall`,`remove`,`rm`,`un`]),CO=/* @__PURE__ */ new Set([`list`,`ls`]),wO=/* @__PURE__ */ new Set([`-g`,`--global`,`--location=global`]),TO=[`-g`,`--global`,`-D`,`--save-dev`];function EO(e){return`${e} - install packages from the npm registry into node_modules
1276
+ `)}\n`}function fO(e,t){return t===`--silent`||t===`-s`?(e.silent=!0,!0):t===`--if-present`&&(e.ifPresent=!0,!0)}function pO(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}fO(t,a)||(r===void 0?r=a:n.push(a))}return{flags:t,script:r,extraArgs:n}}function mO(e,t){return{stdout:``,stderr:`${e}: ${t}\n`,exitCode:1}}function hO(e,t,n,r){let i=r.length>0?` ${r.map(QD).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 gO(e,t,n,r){if(n===`start`&&await r.exists(S(t.dir,`server.js`)))return`node server.js`;if(n===`restart`)return`${e} stop --if-present && ${e} start`}function _O(e,t,n){let r=new Set(n.getRegisteredCommands?.()??[]);return{isRegistered:e=>r.has(e),hasLocalBin:async n=>{for(let r of cO(t.dir))if(await e.exists(S(r,n)))return!0;return!1}}}async function vO(e,t,n,r,i,a){let o=i.exec;if(!o)return mO(e,`run requires shell exec support, which this context does not provide`);let s=_O(a.fs,t,i),c=uO(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 sO(a.body,s),{cwd:t.dir,env:lO(t,a.event,a.body,i),stdin:lr(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 yO(e,t,n,r){let i;try{i=await rO(r.fs,n.cwd)}catch(t){return mO(e,t instanceof Error?t.message:String(t))}if(!i)return mO(e,`no package.json found in ${n.cwd} or any parent directory — nothing to run`);let{flags:a,script:o,extraArgs:s}=pO(t);if(o===void 0)return{stdout:dO(e,i),stderr:``,exitCode:0};let c=i.scripts[o]??await gO(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 mO(e,`missing script: ${o}${t.length>0?` (available: ${t.join(`, `)})`:` (${S(i.dir,`package.json`)} defines no scripts)`}`)}return vO(e,i,hO(i,o,c,s),a,n,r)}const bO=()=>import(`./installer-CZYG64aH.js`),xO=/* @__PURE__ */ new Set([`install`,`i`,`add`]),SO=/* @__PURE__ */ new Set([`uninstall`,`remove`,`rm`,`un`]),CO=/* @__PURE__ */ new Set([`list`,`ls`]),wO=/* @__PURE__ */ new Set([`-g`,`--global`,`--location=global`]),TO=[`-g`,`--global`,`-D`,`--save-dev`];function EO(e){return`${e} - install packages from the npm registry into node_modules
1277
1277
  and run package.json scripts; also install conda/emscripten-forge
1278
1278
  packages via '${e} mamba'
1279
1279
 
@@ -1346,15 +1346,20 @@ under dependencies, or under devDependencies with -D / --save-dev. A bare
1346
1346
  name that is already declared is resolved against that existing range, not
1347
1347
  latest. Unknown install flags are rejected. The no-arg form reads the
1348
1348
  manifest without rewriting it. With -g, packages go to /shared/lib/node_modules
1349
- and deps are recorded in /shared/lib/package.json. Existing fields are
1350
- preserved. Idempotent: re-installing an already-satisfied package is a clean
1349
+ and deps are recorded in /shared/lib/package.json. Required peerDependencies
1350
+ are installed as npm 7+ does: an installed copy in range is kept, a missing
1351
+ one is hoisted, and a conflicting one is kept with an ERESOLVE warning. With
1352
+ -g (and on uninstall), a conflicting top-level copy nothing else keeps would
1353
+ be pruned, so it is replaced by the best match, with an ERESOLVE "replacing
1354
+ peer dependency" warning.
1355
+ Existing fields are preserved. Idempotent: re-installing an already-satisfied package is a clean
1351
1356
  no-op.
1352
- `}function DO(e){let t=w(e,{bool:TO,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 OO(e){let t=!1,n=[];for(let r of e){if(wO.has(r)){t=!0;continue}r.startsWith(`-`)||n.push(r)}return{global:t,specs:n}}function kO(e){return T(e)}function AO(e){return e instanceof Error?e.message:String(e)}async function jO(e){e.scriptCatalog?.invalidateJsh(),await e.syncScriptCommands?.()}function MO(e,t){let n=e===`i`;return C(e,async(r,i)=>{if(n)return kO(r)?{stdout:EO(e),stderr:``,exitCode:0}:PO(e,r,i,t);if(r[0]===`mamba`){let{runIpkMamba:n}=await import(`./ipk-mamba-VDJ25teM.js`);return n(e,r.slice(1),i,t)}if(kO(r))return{stdout:EO(e),stderr:``,exitCode:0};if(r.length===0)return{stdout:EO(e),stderr:`${e}: missing subcommand\n`,exitCode:1};let a=r[0],o=r.slice(1);return xO.has(a)?PO(e,o,i,t):SO.has(a)?IO(e,o,i,t):CO.has(a)?LO(e,o,i,t):a===`root`?RO(e,o,i,t):UD.has(a)?yO(e,o,i,{fs:t.fs}):WD.has(a)?yO(e,r,i,{fs:t.fs}):{stdout:``,stderr:`${e}: unknown subcommand '${a}' (supported: install, uninstall, list, root, run, mamba)\n`,exitCode:1}})}async function NO(e,t,n){let{installFromManifest:r,ManifestNotFoundError:i}=await bO(),a;try{a=await r({fs:n.fs,fetch:n.fetch,cwd:t.cwd})}catch(t){return t instanceof i?{stdout:``,stderr:`${e}: ${t.message}\n`,exitCode:1}:{stdout:``,stderr:`${e}: install failed: ${AO(t)}\n`,exitCode:1}}if(a.empty&&a.errors.length===0)return{stdout:`${e}: nothing to install (package.json declares no dependencies)\n`,stderr:``,exitCode:0};let o=a.results.map(t=>`${e}: installed ${t.name}@${t.version} -> ${t.installPath}`),s=[...(a.notes??[]).map(t=>`${e}: ${t}`),...a.errors.map(t=>`${e}: failed to install ${t.spec}: ${AO(t.error)}`)];return{stdout:o.length>0?`${o.join(`
1357
+ `}function DO(e){let t=w(e,{bool:TO,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 OO(e){let t=!1,n=[];for(let r of e){if(wO.has(r)){t=!0;continue}r.startsWith(`-`)||n.push(r)}return{global:t,specs:n}}function kO(e){return T(e)}function AO(e){return e instanceof Error?e.message:String(e)}async function jO(e){e.scriptCatalog?.invalidateJsh(),await e.syncScriptCommands?.()}function MO(e,t){let n=e===`i`;return C(e,async(r,i)=>{if(n)return kO(r)?{stdout:EO(e),stderr:``,exitCode:0}:PO(e,r,i,t);if(r[0]===`mamba`){let{runIpkMamba:n}=await import(`./ipk-mamba-_UczwftL.js`);return n(e,r.slice(1),i,t)}if(kO(r))return{stdout:EO(e),stderr:``,exitCode:0};if(r.length===0)return{stdout:EO(e),stderr:`${e}: missing subcommand\n`,exitCode:1};let a=r[0],o=r.slice(1);return xO.has(a)?PO(e,o,i,t):SO.has(a)?IO(e,o,i,t):CO.has(a)?LO(e,o,i,t):a===`root`?RO(e,o,i,t):UD.has(a)?yO(e,o,i,{fs:t.fs}):WD.has(a)?yO(e,r,i,{fs:t.fs}):{stdout:``,stderr:`${e}: unknown subcommand '${a}' (supported: install, uninstall, list, root, run, mamba)\n`,exitCode:1}})}async function NO(e,t,n){let{installFromManifest:r,ManifestNotFoundError:i}=await bO(),a;try{a=await r({fs:n.fs,fetch:n.fetch,cwd:t.cwd})}catch(t){return t instanceof i?{stdout:``,stderr:`${e}: ${t.message}\n`,exitCode:1}:{stdout:``,stderr:`${e}: install failed: ${AO(t)}\n`,exitCode:1}}if(a.empty&&a.errors.length===0)return{stdout:`${e}: nothing to install (package.json declares no dependencies)\n`,stderr:``,exitCode:0};let o=a.results.map(t=>`${e}: installed ${t.name}@${t.version} -> ${t.installPath}`),s=[...(a.notes??[]).map(t=>`${e}: ${t}`),...a.errors.map(t=>`${e}: failed to install ${t.spec}: ${AO(t.error)}`)];return{stdout:o.length>0?`${o.join(`
1353
1358
  `)}\n`:``,stderr:s.length>0?`${s.join(`
1354
1359
  `)}\n`:``,exitCode:a.errors.length===0?0:1}}async function PO(e,t,n,r){let i=DO(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 NO(e,n,r);let{installPackages:c}=await bO(),l;try{l=await c(s,{fs:r.fs,fetch:r.fetch,cwd:n.cwd,global:a,saveDev:o})}catch(t){return{stdout:``,stderr:`${e}: install failed: ${AO(t)}\n`,exitCode:1}}let u=l.results.map(t=>`${e}: installed ${t.name}@${t.version} -> ${t.installPath}`),d=[...(l.notes??[]).map(t=>`${e}: ${t}`),...l.errors.map(t=>`${e}: failed to install ${t.spec}: ${AO(t.error)}`)];return a&&l.results.length>0&&await jO(r),{stdout:u.length>0?`${u.join(`
1355
1360
  `)}\n`:``,stderr:d.length>0?`${d.join(`
1356
1361
  `)}\n`:``,exitCode:l.errors.length===0?0:1}}function FO(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(`
1357
- `)}\n`}async function IO(e,t,n,r){let{global:i,specs:a}=OO(t);if(a.length===0)return{stdout:``,stderr:`${e}: uninstall requires at least one package name\n`,exitCode:1};let{uninstallPackages:o}=await bO(),s;try{s=await o(a,{fs:r.fs,fetch:r.fetch,cwd:n.cwd,global:i})}catch(t){return{stdout:``,stderr:`${e}: uninstall failed: ${AO(t)}\n`,exitCode:1}}let c=s.results.filter(e=>e.removed).map(t=>`${e}: removed ${t.name}`),l=s.results.filter(e=>!e.removed).map(e=>e.name),u=s.errors.map(t=>`${e}: failed to uninstall ${t.spec}: ${AO(t.error)}`);l.length>0&&u.push(`${e}: ${l.join(`, `)} not installed${i?` globally`:``}`);let d=s.errors.length>0;return i&&await jO(r),{stdout:c.length>0?`${c.join(`
1362
+ `)}\n`}async function IO(e,t,n,r){let{global:i,specs:a}=OO(t);if(a.length===0)return{stdout:``,stderr:`${e}: uninstall requires at least one package name\n`,exitCode:1};let{uninstallPackages:o}=await bO(),s;try{s=await o(a,{fs:r.fs,fetch:r.fetch,cwd:n.cwd,global:i})}catch(t){return{stdout:``,stderr:`${e}: uninstall failed: ${AO(t)}\n`,exitCode:1}}let c=s.results.filter(e=>e.removed).map(t=>`${e}: removed ${t.name}`),l=s.results.filter(e=>!e.removed).map(e=>e.name),u=[...(s.notes??[]).map(t=>`${e}: ${t}`),...s.errors.map(t=>`${e}: failed to uninstall ${t.spec}: ${AO(t.error)}`)];l.length>0&&u.push(`${e}: ${l.join(`, `)} not installed${i?` globally`:``}`);let d=s.errors.length>0;return i&&await jO(r),{stdout:c.length>0?`${c.join(`
1358
1363
  `)}\n`:``,stderr:u.length>0?`${u.join(`
1359
1364
  `)}\n`:``,exitCode:+!!d}}async function LO(e,t,n,r){let{global:i}=OO(t);try{let{listGlobalPackages:e,listLocalPackages:t}=await bO(),a=i?await e(r.fs):await t(r.fs,n.cwd);return{stdout:FO(i?vr:n.cwd,a),stderr:``,exitCode:0}}catch(t){return{stdout:``,stderr:`${e}: list failed: ${AO(t)}\n`,exitCode:1}}}async function RO(e,t,n,r){let{global:i}=OO(t);return{stdout:`${i?yr:`${n.cwd.replace(/\/$/,``)}/node_modules`}\n`,stderr:``,exitCode:0}}const zO=`0.5.471`,BO=`v86 is not installed in node_modules: run \`${F} v86@${zO}\` (no network fallback)`;let VO=null;async function HO(e={}){return VO||=KO(e.ipk).catch(e=>{throw VO=null,e}),VO}const UO=[{js:`build/libv86.mjs`,wasm:`build/v86.wasm`}];async function WO(e,t){for(let{js:n,wasm:r}of UO){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 GO(e){let t;try{t=await Er(`v86/package.json`,e.fromDir,e.reader)}catch{return null}if(t.type!==`file`)return null;let n=await WO(Ge(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.471`);return{jsSource:await e.reader.readFile(n.jsPath),wasmBytes:await e.readBytes(n.wasmPath),version:i}}catch{return null}}async function KO(e){if(Rr())throw Error(`v86 is not available in Node runtime`);if(!e)throw Error(BO);let t=await GO(e);if(!t)throw Error(BO);let n=URL.createObjectURL(new Blob([t.jsSource],{type:`text/javascript`})),r;try{r=await import(
1360
1365
  /* @vite-ignore */
@@ -1372,8 +1377,8 @@ Options:
1372
1377
  --force Install a package even when a SLICC built-in shadows it
1373
1378
  --global Resolve only from the shared global prefix (/shared/lib/node_modules)
1374
1379
  -h, --help Show this help message
1375
- `}async function ok(e,t){let n=await e.readFile(t);return typeof n==`string`?n:new TextDecoder().decode(n)}async function sk(e,t){try{return(await e.stat(t)).type===`file`}catch{return!1}}async function ck(e,t){try{return(await e.stat(t)).type===`directory`}catch{return!1}}function*lk(e,t=!1){if(t){yield yr;return}let n=x(e);for(;yield S(n,`node_modules`),n!==`/`;)n=Ge(n).dir;yield yr}async function uk(e,t,n,r=!1){for(let i of lk(t,r)){let t=S(i,`.bin`,n);if(!await sk(e,t))continue;let r=await ok(e,t),a=ik.exec(r),o=Ge(t).dir;return{binFilePath:a?S(o,a[1]):t,argvName:t}}return null}function dk(e){if(e.startsWith(`@`)){let t=e.indexOf(`/`);if(t!==-1)return e.slice(t+1)}return e}function fk(e,t){if(typeof e==`string`)return{binName:dk(t),binPath:e};if(typeof e!=`object`||!e)return null;let n=[t,dk(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 pk(e,t,n,r=!1){for(let i of lk(t,r)){let t=S(i,n),r=S(t,`package.json`);if(!await sk(e,r))continue;let a;try{a=JSON.parse(await ok(e,r))}catch{return null}let o=fk(a.bin,n);if(!o)return null;let s=o.binPath.replace(/^\.\//,``);return{binFilePath:S(t,s),argvName:S(i,`.bin`,o.binName)}}return null}async function mk(e,t,n,r=!1){return await uk(e,t,n,r)??await pk(e,t,n,r)}async function hk(e,t,n){for(let r of lk(t))if(await sk(e,S(r,n,`package.json`)))return!0;return!1}function gk(e){return e instanceof Error?e.message:String(e)}function _k(e,t){return{stdout:``,stderr:`${e}: ${t}\n`,exitCode:1}}async function vk(e,t,n,r){try{let{installPackages:i}=await import(`./installer-c3P1y6c8.js`),a=await i([t],{fs:r.fs,fetch:r.fetch,cwd:n.cwd});if(a.errors.length>0)return{error:_k(e,`failed to install '${t}': ${gk(a.errors[0].error)}`)};let o=a.results.map(t=>`${e}: installed ${t.name}@${t.version}`);return{progress:o.length>0?`${o.join(`
1376
- `)}\n`:``}}catch(n){return{error:_k(e,`failed to install '${t}': ${gk(n)}`)}}}async function yk(e,t,n,r){return await sk(r,n)?null:await ck(r,n)?_k(e,`bin target '${n}' is a directory, not a file`):_k(e,`bin file '${n}' for '${t}' does not exist`)}async function bk(e,t,n,r,i,a){if(await hk(a.fs,i.cwd,t))return{error:_k(e,`package '${t}' does not expose an executable bin`)};let o=r?void 0:tk(t);if(o)return{error:{stdout:``,stderr:rk(e,t,n,o),exitCode:1}};let s=await vk(e,t,i,a);if(`error`in s)return s;let c=await mk(a.fs,i.cwd,t);return c?{resolved:c,installProgress:s.progress}:{error:_k(e,`package '${t}' was installed but does not expose an executable bin`)}}function xk(e,t){return{name:e,trusted:!0,async execute(n,r){if(n.length===0||n[0]===`--help`||n[0]===`-h`)return{stdout:ak(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:ak(e),stderr:``,exitCode:1};let c=s[0],l=s.slice(1),u;try{u=await mk(t.fs,r.cwd,c,o)}catch(t){return _k(e,gk(t))}let d=``;if(!u){if(o)return _k(e,`no global bin '${c}' found in ${yr}`);let n=await bk(e,c,l,i,r,t);if(`error`in n)return n.error;u=n.resolved,d=n.installProgress}let f=await yk(e,c,u.binFilePath,t.fs);if(f)return f;let p=Ci(await ok(t.fs,u.binFilePath)),m=[`node`,u.argvName,...l],h=await yi(p,m,r,void 0,{filename:u.binFilePath});return{stdout:h.stdout,stderr:d+h.stderr,exitCode:h.exitCode}}}}function Sk(e={}){return C(`jshd`,async(t,n)=>{let{runJshd:r}=await import(`./run-SjFQcoLt.js`);return r(t,n,e)})}const Ck=/* @__PURE__ */ new Set([`SIGINT`,`SIGTERM`,`SIGKILL`,`SIGSTOP`,`SIGCONT`]);function wk(e={}){return C(`kill`,async t=>{if(t.length===0||t.includes(`--help`)||t.includes(`-h`))return Ak();let n=e.processManager??Tk();if(!n)return{stdout:``,stderr:`kill: no process manager available in this runtime
1380
+ `}async function ok(e,t){let n=await e.readFile(t);return typeof n==`string`?n:new TextDecoder().decode(n)}async function sk(e,t){try{return(await e.stat(t)).type===`file`}catch{return!1}}async function ck(e,t){try{return(await e.stat(t)).type===`directory`}catch{return!1}}function*lk(e,t=!1){if(t){yield yr;return}let n=x(e);for(;yield S(n,`node_modules`),n!==`/`;)n=Ge(n).dir;yield yr}async function uk(e,t,n,r=!1){for(let i of lk(t,r)){let t=S(i,`.bin`,n);if(!await sk(e,t))continue;let r=await ok(e,t),a=ik.exec(r),o=Ge(t).dir;return{binFilePath:a?S(o,a[1]):t,argvName:t}}return null}function dk(e){if(e.startsWith(`@`)){let t=e.indexOf(`/`);if(t!==-1)return e.slice(t+1)}return e}function fk(e,t){if(typeof e==`string`)return{binName:dk(t),binPath:e};if(typeof e!=`object`||!e)return null;let n=[t,dk(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 pk(e,t,n,r=!1){for(let i of lk(t,r)){let t=S(i,n),r=S(t,`package.json`);if(!await sk(e,r))continue;let a;try{a=JSON.parse(await ok(e,r))}catch{return null}let o=fk(a.bin,n);if(!o)return null;let s=o.binPath.replace(/^\.\//,``);return{binFilePath:S(t,s),argvName:S(i,`.bin`,o.binName)}}return null}async function mk(e,t,n,r=!1){return await uk(e,t,n,r)??await pk(e,t,n,r)}async function hk(e,t,n){for(let r of lk(t))if(await sk(e,S(r,n,`package.json`)))return!0;return!1}function gk(e){return e instanceof Error?e.message:String(e)}function _k(e,t){return{stdout:``,stderr:`${e}: ${t}\n`,exitCode:1}}async function vk(e,t,n,r){try{let{installPackages:i}=await import(`./installer-CZYG64aH.js`),a=await i([t],{fs:r.fs,fetch:r.fetch,cwd:n.cwd});if(a.errors.length>0)return{error:_k(e,`failed to install '${t}': ${gk(a.errors[0].error)}`)};let o=a.results.map(t=>`${e}: installed ${t.name}@${t.version}`);return{progress:o.length>0?`${o.join(`
1381
+ `)}\n`:``}}catch(n){return{error:_k(e,`failed to install '${t}': ${gk(n)}`)}}}async function yk(e,t,n,r){return await sk(r,n)?null:await ck(r,n)?_k(e,`bin target '${n}' is a directory, not a file`):_k(e,`bin file '${n}' for '${t}' does not exist`)}async function bk(e,t,n,r,i,a){if(await hk(a.fs,i.cwd,t))return{error:_k(e,`package '${t}' does not expose an executable bin`)};let o=r?void 0:tk(t);if(o)return{error:{stdout:``,stderr:rk(e,t,n,o),exitCode:1}};let s=await vk(e,t,i,a);if(`error`in s)return s;let c=await mk(a.fs,i.cwd,t);return c?{resolved:c,installProgress:s.progress}:{error:_k(e,`package '${t}' was installed but does not expose an executable bin`)}}function xk(e,t){return{name:e,trusted:!0,async execute(n,r){if(n.length===0||n[0]===`--help`||n[0]===`-h`)return{stdout:ak(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:ak(e),stderr:``,exitCode:1};let c=s[0],l=s.slice(1),u;try{u=await mk(t.fs,r.cwd,c,o)}catch(t){return _k(e,gk(t))}let d=``;if(!u){if(o)return _k(e,`no global bin '${c}' found in ${yr}`);let n=await bk(e,c,l,i,r,t);if(`error`in n)return n.error;u=n.resolved,d=n.installProgress}let f=await yk(e,c,u.binFilePath,t.fs);if(f)return f;let p=Ci(await ok(t.fs,u.binFilePath)),m=[`node`,u.argvName,...l],h=await yi(p,m,r,void 0,{filename:u.binFilePath});return{stdout:h.stdout,stderr:d+h.stderr,exitCode:h.exitCode}}}}function Sk(e={}){return C(`jshd`,async(t,n)=>{let{runJshd:r}=await import(`./run-C4x_nui1.js`);return r(t,n,e)})}const Ck=/* @__PURE__ */ new Set([`SIGINT`,`SIGTERM`,`SIGKILL`,`SIGSTOP`,`SIGCONT`]);function wk(e={}){return C(`kill`,async t=>{if(t.length===0||t.includes(`--help`)||t.includes(`-h`))return Ak();let n=e.processManager??Tk();if(!n)return{stdout:``,stderr:`kill: no process manager available in this runtime
1377
1382
  `,exitCode:1};let r=Ek(t);if(!r.ok)return{stdout:``,stderr:r.stderr,exitCode:r.exitCode};let{allDelivered:i,errors:a}=Dk(n,r.pids,r.signal);return{stdout:``,stderr:a.length?`${a.join(`
1378
1383
  `)}\n`:``,exitCode:+!i}})}function Tk(){let e=globalThis.__slicc_pm;return e instanceof Object&&typeof e.signal==`function`?e:null}function Ek(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
1379
1384
  `,exitCode:2};let i=Ok(n);if(i instanceof Error)return{ok:!1,stderr:`kill: ${i.message}\n`,exitCode:2};t=i;continue}if(i.startsWith(`-`)){let e=kk(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
@@ -1446,7 +1451,7 @@ Common base URLs:
1446
1451
  `)+`
1447
1452
  `,stderr:``,exitCode:0}}function rA(e,t){let n=t.models.length;return{stdout:[`✓ ${e} (${$k(t.runtime,!1)})`,` Saved ${n} model${n===1?``:`s`} to Settings:`,...eA(t.models)].join(`
1448
1453
  `)+`
1449
- `,stderr:``,exitCode:0}}function iA(){return C(Zk,async e=>{if(e.includes(`--help`)||e.includes(`-h`))return{stdout:Qk(),stderr:``,exitCode:0};let{getApiKeyForProvider:t,getRawApiKeyForProvider:n,getBaseUrlForProvider:r,addAccount:i}=await import(`./account-store-BsPvuHqg.js`).then(e=>e.t),{verifyConnection:a}=await import(`./local-llm-DtDE4ic6.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(Zk);if(!s)return{stdout:``,stderr:`Local LLM is not configured. Open Settings → Providers → Local LLM and set a base URL.
1454
+ `,stderr:``,exitCode:0}}function iA(){return C(Zk,async e=>{if(e.includes(`--help`)||e.includes(`-h`))return{stdout:Qk(),stderr:``,exitCode:0};let{getApiKeyForProvider:t,getRawApiKeyForProvider:n,getBaseUrlForProvider:r,addAccount:i}=await import(`./account-store-QxWo48Y1.js`).then(e=>e.t),{verifyConnection:a}=await import(`./local-llm-NE-qI2cb.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(Zk);if(!s)return{stdout:``,stderr:`Local LLM is not configured. Open Settings → Providers → Local LLM and set a base URL.
1450
1455
  `,exitCode:1};let c=await a(s,t(Zk)??void 0);if(!c.ok)return tA(s,c);if(o===`discover`){let e=n(Zk)??``;return i(Zk,e,s,c.models.join(`, `)),rA(s,c)}return nA(s,c)})}function aA(){return{stdout:`usage: man <topic>
1451
1456
 
1452
1457
  Fetches documentation for a given topic from sliccy.com.
@@ -1465,7 +1470,7 @@ Notes:
1465
1470
  Document-Isolation-Policy). Embedded floats cannot be isolated and
1466
1471
  report why instead.
1467
1472
  - The browser randomizes measurement timing — expect a short delay.
1468
- `,stderr:``,exitCode:0};let r=e.isIsolated?e.isIsolated():globalThis.crossOriginIsolated===!0,i=e.measure??uA();if(!r&&!e.measure)return cA(`memory measurement requires a cross-origin-isolated runtime (Document-Isolation-Policy) — this runtime is not isolated`);if(!i)return cA(`performance.measureUserAgentSpecificMemory is not available in this browser`);let a;try{a=await i()}catch(e){return cA(e instanceof Error?e.message:String(e))}return n.json?{stdout:`${JSON.stringify(a,null,2)}\n`,stderr:``,exitCode:0}:{stdout:fA(a),stderr:``,exitCode:0}})}function mA(e){return C(`memory`,async t=>{let{runMemory:n}=await import(`./run-DvZAY3-G.js`);return n(t,e)})}function hA(){return C(`mktemp`,async(e,t)=>{let{runMktemp:n}=await import(`./run-BVa_5XaQ.js`);return n(e,t)})}const gA=`/.cache/artificial-analysis.json`,_A=[`--all`,`--all-versions`,`--json`,`--refresh`,`--no-benchmarks`,`--help`,`-h`],vA=[`--provider`];function yA(e){return{stdout:``,stderr:e.endsWith(`
1473
+ `,stderr:``,exitCode:0};let r=e.isIsolated?e.isIsolated():globalThis.crossOriginIsolated===!0,i=e.measure??uA();if(!r&&!e.measure)return cA(`memory measurement requires a cross-origin-isolated runtime (Document-Isolation-Policy) — this runtime is not isolated`);if(!i)return cA(`performance.measureUserAgentSpecificMemory is not available in this browser`);let a;try{a=await i()}catch(e){return cA(e instanceof Error?e.message:String(e))}return n.json?{stdout:`${JSON.stringify(a,null,2)}\n`,stderr:``,exitCode:0}:{stdout:fA(a),stderr:``,exitCode:0}})}function mA(e){return C(`memory`,async t=>{let{runMemory:n}=await import(`./run-CRGyQPIr.js`);return n(t,e)})}function hA(){return C(`mktemp`,async(e,t)=>{let{runMktemp:n}=await import(`./run-BVa_5XaQ.js`);return n(e,t)})}const gA=`/.cache/artificial-analysis.json`,_A=[`--all`,`--all-versions`,`--json`,`--refresh`,`--no-benchmarks`,`--help`,`-h`],vA=[`--provider`];function yA(e){return{stdout:``,stderr:e.endsWith(`
1469
1474
  `)?e:`${e}\n`,exitCode:1}}async function bA(e){try{let t=await e.readFile(gA),n=JSON.parse(t);if(Date.now()-n.fetchedAt<864e5)return n.models}catch{}return null}function xA(){try{return localStorage.getItem(`aa_api_key`)}catch{return null}}function SA(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 CA(e,t){let n={fetchedAt:Date.now(),models:t};try{await e.mkdir(`/.cache`,{recursive:!0}),await e.writeFile(gA,JSON.stringify(n))}catch{}}async function wA(e,t=!1){if(e&&!t){let t=await bA(e);if(t)return t}let n={Accept:`application/json`},r=xA();r&&(n[`x-api-key`]=r);let i=g(),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=SA(Array.isArray(s)?s:s.data??s.models??[]);return e&&c.length>0&&await CA(e,c),c}function TA(e){return e.toLowerCase().replace(/\./g,`-`).replace(/-\d{8}$/,``).replace(/-\d{4}$/,``)}function EA(e,t){let n=e.toLowerCase(),r=t.find(e=>e.slug===n);if(r)return r;let i=TA(e),a=t.find(e=>TA(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 DA(){return`models - list available LLM models
1470
1475
 
1471
1476
  Usage: models [options]
@@ -1480,7 +1485,7 @@ Options:
1480
1485
  -h, --help Show this help message
1481
1486
  `}function OA(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`.replace(`.0M`,`M`):e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function kA(e){return`$${e.toFixed(2)}`}const AA=/\b(embedding|embed|tts|whisper|dall-e|image-gen|audio|vision-preview)\b/i;function jA(e){let t=`${e.id} ${e.name??``}`;return!AA.test(t)}function MA(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 NA(e){let t=e.toLowerCase();return t=t.replace(/-\d{8}$/,``),t=t.replace(/-\d{4}$/,``),t=t.replace(/-(preview|latest)$/,``),MA(t)??t.replace(/-[\d.]+$/,``)}function PA(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=NA(n.id);(!t.has(e)||n.selected)&&t.set(e,n)}return[...t.values()]}function FA(e,t,n,r,i){let a=i?EA(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 IA(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=`${kA(e.cost.input)} / ${kA(e.cost.output)}`,a=`${OA(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(`
1482
1487
  `)+`
1483
- `}function LA(e){let t=w(e,{bool:_A,value:vA});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 RA(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 zA(e,t,n,r,i,a){let o=e.getProviderModels(t).filter(jA);if(o.length===0)return[];let s=o.map(e=>FA(e,t,n,r,i)).sort((e,t)=>t.cost.input-e.cost.input);return a||(s=PA(s)),s}function BA(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 VA(e,t){if(T(e,{valueFlags:vA}))return{stdout:DA(),stderr:``,exitCode:0};let n=LA(e);if(`error`in n)return yA(`models: ${n.error}`);let r=await import(`./account-store-BsPvuHqg.js`).then(e=>e.t);if(r.getAccounts().length===0)return yA(`No provider accounts configured. Run the provider settings to add one.
1488
+ `}function LA(e){let t=w(e,{bool:_A,value:vA});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 RA(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 zA(e,t,n,r,i,a){let o=e.getProviderModels(t).filter(jA);if(o.length===0)return[];let s=o.map(e=>FA(e,t,n,r,i)).sort((e,t)=>t.cost.input-e.cost.input);return a||(s=PA(s)),s}function BA(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 VA(e,t){if(T(e,{valueFlags:vA}))return{stdout:DA(),stderr:``,exitCode:0};let n=LA(e);if(`error`in n)return yA(`models: ${n.error}`);let r=await import(`./account-store-QxWo48Y1.js`).then(e=>e.t);if(r.getAccounts().length===0)return yA(`No provider accounts configured. Run the provider settings to add one.
1484
1489
  `);let i=r.resolveCurrentModel(),a=i.id,o=i.provider,s=r.getSelectedProvider(),c=r.getSelectedModelId(),l;if(!n.noBenchmarks){let e=await wA(t,n.forceRefresh);e.length>0&&(l=e)}let u=RA(r,n,s);if(`error`in u)return yA(u.error);let d=[],f=[];for(let e of u){let t=zA(r,e,a,o,l,n.allVersions);if(t.length===0){if(!n.allMode)return yA(`No models available for provider ${e}.\n`);continue}if(d.push(...t),!n.jsonMode){let n=r.getProviderConfig(e);f.push(IA(n.name,e,t,!!l))}}return n.jsonMode?{stdout:JSON.stringify(d,null,2)+`
1485
1490
  `,stderr:``,exitCode:0}:(n.allVersions||f.push(`Showing latest versions only. Use --all-versions to see all.
1486
1491
  `),f.push(BA(o,a,s,c)),{stdout:f.join(`
@@ -1538,7 +1543,7 @@ Examples:
1538
1543
  `)}\n`,stderr:``,exitCode:0}}async function fj(e,t,n){if(!t||!n)return{stdout:``,stderr:`oauth-domain add: requires <providerId> and <domain>
1539
1544
  `,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 pj(e,t,n){if(!t||!n)return{stdout:``,stderr:`oauth-domain remove: requires <providerId> and <domain>
1540
1545
  `,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 mj(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>
1541
- `,exitCode:1}}async function hj(e,t,n,r){switch(t){case`list`:return dj(e,n);case`add`:return fj(e,n,r);case`remove`:return pj(e,n,r);case`clear`:return mj(e,n);default:return{stdout:``,stderr:`oauth-domain: unknown subcommand "${t}"\n${lj()}`,exitCode:1}}}function gj(){return C(`oauth-domain`,async e=>{if(e.length===0||T(e))return{stdout:lj(),stderr:``,exitCode:0};let t=w(e);if(`error`in t)return uj(t.error);let[n,r,i]=t.positionals,a=await import(`./account-store-BsPvuHqg.js`).then(e=>e.t);try{return await hj(a,n,r,i)}catch(e){return uj(e instanceof Error?e.message:String(e))}})}function _j(){return C(`oauth-token`,async(e,t)=>{let{runOAuthToken:n}=await import(`./run-B-qC-Qkv.js`);return n(e,t)})}const vj=[`--download`,`-d`,`--view`,`-v`],yj=[`--size`],bj={low:256,medium:768,high:1536};function xj(){return{stdout:`usage: open [--download|-d] [--view|-v [--size <spec>]] <url|path> [url|path...]
1546
+ `,exitCode:1}}async function hj(e,t,n,r){switch(t){case`list`:return dj(e,n);case`add`:return fj(e,n,r);case`remove`:return pj(e,n,r);case`clear`:return mj(e,n);default:return{stdout:``,stderr:`oauth-domain: unknown subcommand "${t}"\n${lj()}`,exitCode:1}}}function gj(){return C(`oauth-domain`,async e=>{if(e.length===0||T(e))return{stdout:lj(),stderr:``,exitCode:0};let t=w(e);if(`error`in t)return uj(t.error);let[n,r,i]=t.positionals,a=await import(`./account-store-QxWo48Y1.js`).then(e=>e.t);try{return await hj(a,n,r,i)}catch(e){return uj(e instanceof Error?e.message:String(e))}})}function _j(){return C(`oauth-token`,async(e,t)=>{let{runOAuthToken:n}=await import(`./run-DS9gNHJH.js`);return n(e,t)})}const vj=[`--download`,`-d`,`--view`,`-v`],yj=[`--size`],bj={low:256,medium:768,high:1536};function xj(){return{stdout:`usage: open [--download|-d] [--view|-v [--size <spec>]] <url|path> [url|path...]
1542
1547
 
1543
1548
  VFS paths are served in a new browser tab via the preview service worker.
1544
1549
  URLs (http/https/etc.) are opened directly in a new tab.
@@ -1564,7 +1569,7 @@ Examples:
1564
1569
  `);let i=!1;try{i=(await t.fs.stat(e)).isDirectory}catch{}let a=await kr(t.fs,i?e:Lr(e)),o=Kr(e,a),s;try{s=await r(o)}catch(e){return G(`${e instanceof Error?e.message:String(e)}\n`)}return Aj(`opened ${e} → ${o}${jj(s)}`)}async function Rj(e,t,n,r){if(!jr(e)&&e.endsWith(`.shtml`)&&t.fs)return Nj(e,t,r.sprinkleManager,r.canOpenWindow,r.openExternal);if(!n.view&&!r.canOpenWindow)return G(`open: browser APIs are unavailable in this environment
1565
1570
  `);if(jr(e))return Pj(e,r.canOpenWindow,r.openExternal);let i=t.fs.resolvePath(t.cwd,e);return n.view?Fj(e,i,t,n.sizeSpec):n.download?Ij(e,i,t,r.hasDom):Lj(i,t,r.canOpenWindow,r.openExternal)}function zj(e){return C(`open`,async(t,n)=>{if(t.length===0||T(t,{valueFlags:yj}))return xj();let r=kj(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 xj();let c=globalThis.__slicc_sprinkleManager,l=typeof window<`u`&&typeof document<`u`,u=l?null:b(),d={canOpenWindow:!!e||l||!!u,hasDom:l,sprinkleManager:c,openExternal:Mj(e,l,u)},f=[];for(let e of s){let t=await Rj(e,n,{view:a,download:i,sizeSpec:o},d);if(!t.ok)return t.result;f.push(t.message)}return{stdout:f.join(`
1566
1571
  `)+`
1567
- `,stderr:``,exitCode:0}})}function Bj(){return C(`patch`,async(e,t)=>{let{runPatch:n}=await import(`./run-BnHQKxit.js`);return n(e,t)})}function Vj(e=`pdftk`){return C(e,async(t,n)=>{let{runPdftk:r}=await import(`./run-BckBWdRW.js`);return r(e,t,n)})}function Hj(){return{stdout:`usage: pdftoppm [options] <input.pdf> [output-prefix]
1572
+ `,stderr:``,exitCode:0}})}function Bj(){return C(`patch`,async(e,t)=>{let{runPatch:n}=await import(`./run-BV4IO7_J.js`);return n(e,t)})}function Vj(e=`pdftk`){return C(e,async(t,n)=>{let{runPdftk:r}=await import(`./run-BckBWdRW.js`);return r(e,t,n)})}function Hj(){return{stdout:`usage: pdftoppm [options] <input.pdf> [output-prefix]
1568
1573
 
1569
1574
  Rasterize PDF pages to images. Writes <prefix>-<n>.<ext> per page, where <n>
1570
1575
  is zero-padded to the digit width of the last page (out-1.png for a 9-page
@@ -1859,7 +1864,7 @@ Limits and lifetime:
1859
1864
  `,exitCode:1};if(e.ttlMs!==void 0&&e.maxTabs!==void 0)return{stdout:``,stderr:`serve: --ttl cannot be combined with --max-tabs
1860
1865
  `,exitCode:1}}async function UP(e,t,n){if(e.ttlMs!==void 0){if(!t)throw Error(`persistent snapshot filesystem unavailable`);return FP(t,n)}}async function WP(e,t,n,r){if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return yP();let i=TP(e);if(i.error)return{stdout:``,stderr:i.error,exitCode:1};let a=await VP(i);if(a)return a;if(!i.directory)return yP();let o=HP(i);if(o)return o;let s=await EP(i.directory,i.entry,t.fs,t.cwd);if(DP(s))return s;let{fullDirectory:c,entryPath:l}=s,u;try{u=await UP(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)
1861
1866
  `:``,f=await zP(!i.noBridge&&i.bridge,d);return f.ok?BP(i,c,l,f.webhookId,d,u,n):f.result}function GP(e,t){return C(`serve`,(n,r)=>WP(n,r,e,t))}const KP=`usage: session export [--id <id>] [--output <path>]
1862
- `;function qP(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 JP(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${KP}`};let n=r[e+1];if(!n||n.startsWith(`-`))return{ok:!1,stderr:`session export: --id requires a value\n${KP}`};t=n,e++}else if(i===`--output`){if(n!==null)return{ok:!1,stderr:`session export: duplicate flag --output\n${KP}`};let t=r[e+1];if(!t||t.startsWith(`-`))return{ok:!1,stderr:`session export: --output requires a path\n${KP}`};n=t,e++}else if(i.startsWith(`-`))return{ok:!1,stderr:`session export: unknown flag ${i}\n${KP}`};else return{ok:!1,stderr:`session export: unexpected argument ${JSON.stringify(i)}\n${KP}`}}return{ok:!0,args:{sessionId:t,outputPath:n}}}async function YP(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||It(r)!==a.sha256)throw new Ua(`transfer-corrupt`);return r}async function XP(e,t){let n=JP(e);if(!n.ok)return{stdout:``,stderr:n.stderr,exitCode:1};let{sessionId:r,outputPath:i}=n.args;if(i!==null){let e=qP(i);if(!e.ok)return{stdout:``,stderr:`session export: --output ${e.reason}\n${KP}`,exitCode:1}}let a=r==null?{kind:`active`}:{kind:`frozen`,sessionId:r};try{let e=await As().export(a,{}),n=await YP(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 Ua?e.code:e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}function ZP(){return C(`session`,async(e,t)=>{if(e[0]===`export`&&!T(e))return XP(e,t);let{dispatchSessionMemoryAware:n}=await import(`./session-command-memory-ckzD8HGJ.js`);return n(e,t,KP)})}function QP(){return C(`slicc`,async(e,t)=>{let{runSlicc:n}=await import(`./run-Df4gWXzQ.js`);return await n(e,t)})}const $P=`leader`;function eF(){try{let e=globalThis.localStorage?.getItem(`slicc.leaderSprinkleInstances`);if(e)return JSON.parse(e)}catch{}return[]}function tF(e){return+!!e.leader+e.followers.length}function nF(){return{stdout:`usage: sprinkle <subcommand> [args]
1867
+ `;function qP(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 JP(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${KP}`};let n=r[e+1];if(!n||n.startsWith(`-`))return{ok:!1,stderr:`session export: --id requires a value\n${KP}`};t=n,e++}else if(i===`--output`){if(n!==null)return{ok:!1,stderr:`session export: duplicate flag --output\n${KP}`};let t=r[e+1];if(!t||t.startsWith(`-`))return{ok:!1,stderr:`session export: --output requires a path\n${KP}`};n=t,e++}else if(i.startsWith(`-`))return{ok:!1,stderr:`session export: unknown flag ${i}\n${KP}`};else return{ok:!1,stderr:`session export: unexpected argument ${JSON.stringify(i)}\n${KP}`}}return{ok:!0,args:{sessionId:t,outputPath:n}}}async function YP(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||It(r)!==a.sha256)throw new Ua(`transfer-corrupt`);return r}async function XP(e,t){let n=JP(e);if(!n.ok)return{stdout:``,stderr:n.stderr,exitCode:1};let{sessionId:r,outputPath:i}=n.args;if(i!==null){let e=qP(i);if(!e.ok)return{stdout:``,stderr:`session export: --output ${e.reason}\n${KP}`,exitCode:1}}let a=r==null?{kind:`active`}:{kind:`frozen`,sessionId:r};try{let e=await As().export(a,{}),n=await YP(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 Ua?e.code:e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}function ZP(){return C(`session`,async(e,t)=>{if(e[0]===`export`&&!T(e))return XP(e,t);let{dispatchSessionMemoryAware:n}=await import(`./session-command-memory-CZZ78BU8.js`);return n(e,t,KP)})}function QP(){return C(`slicc`,async(e,t)=>{let{runSlicc:n}=await import(`./run-Df4gWXzQ.js`);return await n(e,t)})}const $P=`leader`;function eF(){try{let e=globalThis.localStorage?.getItem(`slicc.leaderSprinkleInstances`);if(e)return JSON.parse(e)}catch{}return[]}function tF(e){return+!!e.leader+e.followers.length}function nF(){return{stdout:`usage: sprinkle <subcommand> [args]
1863
1868
 
1864
1869
  list [--runtime <id>] List sprinkles + an instance line per runtime
1865
1870
  open <name> Open a sprinkle by name
@@ -1940,10 +1945,10 @@ Options:
1940
1945
  `,exitCode:1};let i=await Promise.all(r.map(e=>zF(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 VF(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 HF(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 UF(e,t,n){try{let r=e.fs.resolvePath(e.cwd,t),i=n.follow?await e.fs.stat(r):await LF(e,r);return{stdout:n.format?`${VF(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 WF(){return C(`stat`,async(e,t)=>{let n=HF(e);if(n.paths.length===0)return{stdout:``,stderr:`stat: missing operand
1941
1946
  `,exitCode:1};let r=await Promise.all(n.paths.map(e=>UF(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 GF(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n<=0?`/`:t.slice(0,n)}async function KF(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 LF(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}': ${IF(e)}\n`}}if(!n||s===i.length-1)return{stdout:o,stderr:``};a=GF(a)}return{stdout:o,stderr:``}}function qF(){return C(`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
1942
1947
  `,exitCode:1};let a=await Promise.all(i.map(e=>KF(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 JF(){return{stdout:`usage: tar (-c|-x|-t) [-zv] -f <archive> [-C <dir>] [paths...]
1943
- `,stderr:``,exitCode:0}}function YF(e){return{stdout:``,stderr:`tar: ${e}\n`,exitCode:1}}function XF(e,t){if(e.mode)return YF(`exactly one of -c, -x, or -t is required`);e.mode=t}function ZF(e,t,n){if(n)return[n,t];let r=e[t+1];return r===void 0?void 0:[r,t+1]}const QF={c:`create`,x:`extract`,t:`list`};function $F(e,t,n,r,i){let a=QF[e];if(a)return{nextIndex:r,error:XF(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:YF(`unsupported option -${e}`)};let o=ZF(n,r,t);return o?(e===`f`?i.archive=o[0]:i.directory=o[0],{nextIndex:o[1],consumedValue:!0}):{nextIndex:r,error:YF(`option -${e} requires an argument`)}}function eI(e,t,n){let r=e[t];for(let i=1;i<r.length;i++){let a=$F(r[i],r.slice(i+1),e,t,n);if(a.error||a.consumedValue)return a}return{nextIndex:t}}const tI=/^[cxtzvfC]+$/;function nI(e){let t=e.length>0&&tI.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 YF(`unsupported option ${r}`);let i=eI(t,e,n);if(i.error)return i.error;e=i.nextIndex}return n}function rI(e,t){let n=e.replace(/\\/g,`/`).replace(/^\/+/,``).replace(/^(?:\.\/)+/,``);return n?n===`.`?`.`:n.replace(/\/+$/,``):Nr(t)}function iI(e){let t=e.mtime?.getTime();return t===void 0||Number.isNaN(t)?{}:{mtime:Math.floor(t/1e3)}}async function aI(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},...iI(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:/* @__PURE__ */ new Uint8Array,directory:!0,...o===void 0?{}:{mode:o},...iI(i)});for(let n of await e.fs.readdir(t))await aI(e,Mr(t,n),`${a}${n}`,r)}function oI(e,t){let n=e.length>=2&&e[0]===31&&e[1]===139,r=t||n?Ca(e):e;return Sa(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 Br(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 lI(e,t,n,r){let i=new Map(t),a=new Map(n),o=[.../* @__PURE__ */ 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:/* @__PURE__ */ 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=/* @__PURE__ */ new Date(t*1e3);await cI(()=>c.utimes(e,n,n))}}async function uI(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=Lr(t);c!==`/`&&await e.fs.mkdir(c,{recursive:!0}),await e.fs.writeFile(t,n.bytes),s&&i.push([t,n.mode])}async function dI(e,t){if(e.paths.length===0)return YF(`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 aI(t,e,rI(i,e),n)}let i=t.fs.resolvePath(t.cwd,e.archive),a=ba(n);return await t.fs.writeFile(i,e.gzip?xa(a):a),{stdout:e.verbose?`${n.map(e=>e.path).join(`
1944
- `)}\n`:``,stderr:``,exitCode:0}}function fI(e){let t=/* @__PURE__ */ 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 pI(e,t,n){if(e.paths.length>0)return YF(`${e.mode} mode does not accept input paths`);let r=t.fs.resolvePath(t.cwd,e.archive),i=oI(await t.fs.readFileBuffer(r),e.gzip);if(e.mode===`list`){let e=i.map(e=>e.path).join(`
1945
- `);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 YF(`blocked suspicious path ${e.path}`);await uI(t,n,e,c,s),e.mtime!==void 0&&l.push([n,e.mtime]),o.push(e.path)}return await lI(t,[...fI(s),...fI(c)],fI(l),n),{stdout:e.verbose?`${o.join(`
1946
- `)}\n`:``,stderr:``,exitCode:0}}function mI(e={}){return C(`tar`,async(t,n)=>{if(t.length===0||t.includes(`--help`)||t.includes(`-h`))return JF();let r=nI(t);return`exitCode`in r?r:r.mode?r.archive?r.mode===`list`&&r.directory!==`.`?YF(`-C is only supported in create or extract mode`):r.mode===`create`?dI(r,n):pI(r,n,e.fs):YF(`option -f requires an archive path`):YF(`exactly one of -c, -x, or -t is required`)})}var hI=`/**
1948
+ `,stderr:``,exitCode:0}}function YF(e){return{stdout:``,stderr:`tar: ${e}\n`,exitCode:1}}function XF(e,t){if(e.mode)return YF(`exactly one of -c, -x, or -t is required`);e.mode=t}function ZF(e,t,n){if(n)return[n,t];let r=e[t+1];return r===void 0?void 0:[r,t+1]}const QF={c:`create`,x:`extract`,t:`list`};function $F(e,t,n,r,i){let a=QF[e];if(a)return{nextIndex:r,error:XF(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:YF(`unsupported option -${e}`)};let o=ZF(n,r,t);return o?(e===`f`?i.archive=o[0]:i.directory=o[0],{nextIndex:o[1],consumedValue:!0}):{nextIndex:r,error:YF(`option -${e} requires an argument`)}}function eI(e,t,n){let r=e[t];for(let i=1;i<r.length;i++){let a=$F(r[i],r.slice(i+1),e,t,n);if(a.error||a.consumedValue)return a}return{nextIndex:t}}const tI=/^[cxtzvfC]+$/;function nI(e){let t=e.length>0&&tI.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 YF(`unsupported option ${r}`);let i=eI(t,e,n);if(i.error)return i.error;e=i.nextIndex}return n}function rI(e,t){let n=e.replace(/\\/g,`/`).replace(/^\/+/,``).replace(/^(?:\.\/)+/,``);return n?n===`.`?`.`:n.replace(/\/+$/,``):Nr(t)}function iI(e){let t=e.mtime?.getTime();return t===void 0||Number.isNaN(t)?{}:{mtime:Math.floor(t/1e3)}}async function aI(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},...iI(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:/* @__PURE__ */ new Uint8Array,directory:!0,...o===void 0?{}:{mode:o},...iI(i)});for(let n of await e.fs.readdir(t))await aI(e,Mr(t,n),`${a}${n}`,r)}function oI(e,t){let n=e.length>=2&&e[0]===31&&e[1]===139,r=t||n?Ca(e):e;return Sa(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 Br(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 lI(e,t,n,r){let i=new Map(t),a=new Map(n),o=[.../* @__PURE__ */ 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:/* @__PURE__ */ 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=/* @__PURE__ */ new Date(t*1e3);await cI(()=>c.utimes(e,n,n))}}async function uI(e,t){try{return await e.fs.lstat(t)}catch{return null}}async function dI(e,t,n){let r=await uI(e,t);r&&(r.isSymbolicLink?await e.fs.rm(t):!n&&r.isDirectory&&await e.fs.rm(t,{recursive:!0}))}async function fI(e,t,n,r){if(r===t)return!1;let i=r.slice(t===`/`?1:t.length+1),a=t;for(let t of i.split(`/`).slice(0,-1)){a=Mr(a,t);let r=await uI(e,a);if(!r)return!1;if(!r.isSymbolicLink)continue;let i;try{i=await e.fs.realpath(a)}catch{return!0}if(!Br(n,i))return!0}return!1}async function pI(e,t,n,r,i){let a=n.directory?493:420;await dI(e,t,n.directory===!0);let 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=Lr(t);c!==`/`&&await e.fs.mkdir(c,{recursive:!0}),await e.fs.writeFile(t,n.bytes),s&&i.push([t,n.mode])}async function mI(e,t){if(e.paths.length===0)return YF(`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 aI(t,e,rI(i,e),n)}let i=t.fs.resolvePath(t.cwd,e.archive),a=ba(n);return await t.fs.writeFile(i,e.gzip?xa(a):a),{stdout:e.verbose?`${n.map(e=>e.path).join(`
1949
+ `)}\n`:``,stderr:``,exitCode:0}}function hI(e){let t=/* @__PURE__ */ 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 gI(e,t,n){if(e.paths.length>0)return YF(`${e.mode} mode does not accept input paths`);let r=t.fs.resolvePath(t.cwd,e.archive),i=oI(await t.fs.readFileBuffer(r),e.gzip);if(e.mode===`list`){let e=i.map(e=>e.path).join(`
1950
+ `);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=await t.fs.realpath(a),s=[],c=[],l=[],u=[];for(let e of i){let n=sI(t,a,e.path);if(!n)return YF(`blocked suspicious path ${e.path}`);if(await fI(t,a,o,n))return YF(`blocked path through symlink ${e.path}`);await pI(t,n,e,l,c),e.mtime!==void 0&&u.push([n,e.mtime]),s.push(e.path)}return await lI(t,[...hI(c),...hI(l)],hI(u),n),{stdout:e.verbose?`${s.join(`
1951
+ `)}\n`:``,stderr:``,exitCode:0}}function _I(e={}){return C(`tar`,async(t,n)=>{if(t.length===0||t.includes(`--help`)||t.includes(`-h`))return JF();let r=nI(t);return`exitCode`in r?r:r.mode?r.archive?r.mode===`list`&&r.directory!==`.`?YF(`-C is only supported in create or extract mode`):r.mode===`create`?mI(r,n):gI(r,n,e.fs):YF(`option -f requires an archive path`):YF(`exactly one of -c, -x, or -t is required`)})}var vI=`/**
1947
1952
  * Standalone assertions - no dependency on test runner
1948
1953
  *
1949
1954
  * Each assertion:
@@ -2131,7 +2136,7 @@ function sameMembers(a, b) {
2131
2136
  }
2132
2137
 
2133
2138
  const slice = a => (isPrimitive(a) ? a : a.slice ? a.slice() : Object.assign({}, a))
2134
- `,gI=`/**
2139
+ `,yI=`/**
2135
2140
  * tst - minimal test runner
2136
2141
  *
2137
2142
  * - Standalone assertions (assert.js works anywhere)
@@ -2761,7 +2766,7 @@ function scheduleAutoRun() {
2761
2766
  scheduleAutoRun()
2762
2767
 
2763
2768
  export * from './assert.js'
2764
- `;function _I(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 vI=`tsc - thin wrapper over the ipk-loaded TypeScript 6 package
2769
+ `;function bI(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 xI=`tsc - thin wrapper over the ipk-loaded TypeScript 6 package
2765
2770
 
2766
2771
  Usage:
2767
2772
  tsc [options] [files...]
@@ -2785,28 +2790,28 @@ Install:
2785
2790
  Then \`tsc --version\` and the transpile commands above. There is no
2786
2791
  bundled binary, no CDN fallback; a missing package exits non-zero
2787
2792
  with a clear \`ipk add\` hint.
2788
- `;function yI(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 bI(e,t){let n=`${Nr(e).replace(/\.(ts|tsx|mts|cts)$/i,``)}.js`;return t?`${t.endsWith(`/`)?t.slice(0,-1):t}/${n}`:`${Lr(e)}/${n}`}async function xI(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=Lr(n)}return null}function SI(e){return{target:e.ScriptTarget.ES2022,module:e.ModuleKind.ESNext,moduleResolution:e.ModuleResolutionKind.Bundler,esModuleInterop:!0,allowSyntheticDefaultImports:!0,isolatedModules:!0}}function CI(e){if(typeof e!=`object`||!e)return{};let{compilerOptions:t}=e;return t??{}}async function wI(e,t,n){let r=SI(t),i=await xI(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,...CI(o)}}}function TI(e,t){let n=e.flattenDiagnosticMessageText(t.messageText,`
2789
- `);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 EI(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 DI(e,t,n,r,i){let a=e.transpileModule(t,{compilerOptions:r,fileName:n,reportDiagnostics:i});return{outputText:a.outputText,diagnostics:a.diagnostics??[]}}function OI(e,t,n,r){let{outputText:i,diagnostics:a}=DI(e,r,`<stdin>.ts`,n.compilerOptions,!0),o=a.map(t=>TI(e,t)),s=o.length>0?`${o.join(`
2790
- `)}\n`:``;return{stdout:t.noEmit?``:i,stderr:s,exitCode:+(a.length>0)}}async function kI(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}}EI(e,a);let{outputText:s,diagnostics:c}=DI(e,o,a,i.compilerOptions,!0),l=[];for(let t of c)l.push(`${TI(e,t)}\n`);let u=c.length>0;if(r.noEmit)return{stderr:l.join(``),hadError:u};let d=t.fs.resolvePath(t.cwd,bI(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 AI(e,t){let n;try{n=yI(e)}catch(e){return{done:{stdout:``,stderr:`${e instanceof Error?e.message:String(e)}\n`,exitCode:2}}}if(n.showHelp)return{done:{stdout:vI,stderr:``,exitCode:0}};let r;try{r=await Ar(_I(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 jI(){return C(`tsc`,async(e,t)=>{let n=await AI(e,t);if(`done`in n)return n.done;let{parsed:r,ts:i}=n,a=await wI(t.fs,i,t.cwd);if(r.files.length===0){let e=P(t.stdin);return e?OI(i,r,a,e):{stdout:vI,stderr:``,exitCode:0}}let o=[],s=!1;for(let e of r.files){let n=await kI(i,t,e,r,a);n.stderr&&o.push(n.stderr),n.hadError&&(s=!0)}return{stdout:``,stderr:o.join(``),exitCode:+!!s}})}const MI=[`**/*.test.{js,ts}`];function NI(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 PI(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 FI(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=NI(s,e[o+1]);if(c){n=c.reporter,c.consumed===2&&(o+=1);continue}let l=PI(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:[...MI],reporter:n,showHelp:r,coverage:i,coverageDir:a}}function II(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 II(`${r}${e}${i}`))o.push(t);return o}function LI(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 RI(e,t,n){let r=n.flatMap(II).map(LI),i=/* @__PURE__ */ 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 zI=null;async function BI(e){if(zI)return zI;let t={module:e.ModuleKind.CommonJS,target:e.ScriptTarget.ES2022,esModuleInterop:!0,isolatedModules:!1};return zI=`
2793
+ `;function SI(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 CI(e,t){let n=`${Nr(e).replace(/\.(ts|tsx|mts|cts)$/i,``)}.js`;return t?`${t.endsWith(`/`)?t.slice(0,-1):t}/${n}`:`${Lr(e)}/${n}`}async function wI(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=Lr(n)}return null}function TI(e){return{target:e.ScriptTarget.ES2022,module:e.ModuleKind.ESNext,moduleResolution:e.ModuleResolutionKind.Bundler,esModuleInterop:!0,allowSyntheticDefaultImports:!0,isolatedModules:!0}}function EI(e){if(typeof e!=`object`||!e)return{};let{compilerOptions:t}=e;return t??{}}async function DI(e,t,n){let r=TI(t),i=await wI(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,...EI(o)}}}function OI(e,t){let n=e.flattenDiagnosticMessageText(t.messageText,`
2794
+ `);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 kI(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 AI(e,t,n,r,i){let a=e.transpileModule(t,{compilerOptions:r,fileName:n,reportDiagnostics:i});return{outputText:a.outputText,diagnostics:a.diagnostics??[]}}function jI(e,t,n,r){let{outputText:i,diagnostics:a}=AI(e,r,`<stdin>.ts`,n.compilerOptions,!0),o=a.map(t=>OI(e,t)),s=o.length>0?`${o.join(`
2795
+ `)}\n`:``;return{stdout:t.noEmit?``:i,stderr:s,exitCode:+(a.length>0)}}async function MI(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}}kI(e,a);let{outputText:s,diagnostics:c}=AI(e,o,a,i.compilerOptions,!0),l=[];for(let t of c)l.push(`${OI(e,t)}\n`);let u=c.length>0;if(r.noEmit)return{stderr:l.join(``),hadError:u};let d=t.fs.resolvePath(t.cwd,CI(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 NI(e,t){let n;try{n=SI(e)}catch(e){return{done:{stdout:``,stderr:`${e instanceof Error?e.message:String(e)}\n`,exitCode:2}}}if(n.showHelp)return{done:{stdout:xI,stderr:``,exitCode:0}};let r;try{r=await Ar(bI(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 PI(){return C(`tsc`,async(e,t)=>{let n=await NI(e,t);if(`done`in n)return n.done;let{parsed:r,ts:i}=n,a=await DI(t.fs,i,t.cwd);if(r.files.length===0){let e=P(t.stdin);return e?jI(i,r,a,e):{stdout:xI,stderr:``,exitCode:0}}let o=[],s=!1;for(let e of r.files){let n=await MI(i,t,e,r,a);n.stderr&&o.push(n.stderr),n.hadError&&(s=!0)}return{stdout:``,stderr:o.join(``),exitCode:+!!s}})}const FI=[`**/*.test.{js,ts}`];function II(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 LI(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 RI(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=II(s,e[o+1]);if(c){n=c.reporter,c.consumed===2&&(o+=1);continue}let l=LI(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:[...FI],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 BI(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 VI(e,t,n){let r=n.flatMap(zI).map(BI),i=/* @__PURE__ */ 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 HI=null;async function UI(e){if(HI)return HI;let t={module:e.ModuleKind.CommonJS,target:e.ScriptTarget.ES2022,esModuleInterop:!0,isolatedModules:!1};return HI=`
2791
2796
  if (typeof process !== 'undefined' && !process.versions) {
2792
2797
  try { process.versions = { node: '20.0.0' }; } catch (_) { /* readonly process.versions is fine */ }
2793
2798
  }
2794
2799
  const __tst_assert_exports = (function () {
2795
2800
  const module = { exports: {} };
2796
2801
  const exports = module.exports;
2797
- ${e.transpileModule(hI,{compilerOptions:t,fileName:`assert.js`}).outputText}
2802
+ ${e.transpileModule(vI,{compilerOptions:t,fileName:`assert.js`}).outputText}
2798
2803
  return module.exports;
2799
2804
  })();
2800
2805
  const __tst_module_exports = (function () {
2801
2806
  const module = { exports: {} };
2802
2807
  const exports = module.exports;
2803
- ${e.transpileModule(gI,{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"))`)}
2808
+ ${e.transpileModule(yI,{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"))`)}
2804
2809
  return module.exports;
2805
2810
  })();
2806
2811
  const __tst = __tst_module_exports.default || __tst_module_exports;
2807
2812
  __tst.manual = true;
2808
- `.trim(),zI}function VI(e,t=/* @__PURE__ */ 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 HI(e){let t=/* @__PURE__ */ new Set,n=/(?:^|[^\w$.])require\(\s*(["'`])([^"'`]+)\1\s*\)/g,r;for(;(r=n.exec(e))!==null;)t.add(r[2]);return[...t]}async function UI(e,t,n){let r=x(`${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 WI(e,t,n,r,i,a){let o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map,c=[{path:n,cjs:r}];for(;c.length>0;){let{path:n,cjs:r}=c.shift(),l=Lr(n),u=/* @__PURE__ */ new Map;for(let n of HI(r)){if(!n.startsWith(`./`)&&!n.startsWith(`../`))continue;let r=await UI(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 GI(e,t,n,r,i,a,o=``,s=``){let c=r===`spec`?`pretty`:`tap`,l=[];for(let[e,t]of i.entries()){let n=VI(t,a.get(e)??/* @__PURE__ */ new Map);l.push(`${JSON.stringify(e)}: function (module, exports, require) {\n${n}\n}`)}let u=`{${l.join(`,
2809
- `)}}`,d=VI(n,a.get(t)??/* @__PURE__ */ new Map),f=o,p=s;return`"use strict";
2813
+ `.trim(),HI}function WI(e,t=/* @__PURE__ */ 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 GI(e){let t=/* @__PURE__ */ new Set,n=/(?:^|[^\w$.])require\(\s*(["'`])([^"'`]+)\1\s*\)/g,r;for(;(r=n.exec(e))!==null;)t.add(r[2]);return[...t]}async function KI(e,t,n){let r=x(`${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 qI(e,t,n,r,i,a){let o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map,c=[{path:n,cjs:r}];for(;c.length>0;){let{path:n,cjs:r}=c.shift(),l=Lr(n),u=/* @__PURE__ */ new Map;for(let n of GI(r)){if(!n.startsWith(`./`)&&!n.startsWith(`../`))continue;let r=await KI(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 JI(e,t,n,r,i,a,o=``,s=``){let c=r===`spec`?`pretty`:`tap`,l=[];for(let[e,t]of i.entries()){let n=WI(t,a.get(e)??/* @__PURE__ */ new Map);l.push(`${JSON.stringify(e)}: function (module, exports, require) {\n${n}\n}`)}let u=`{${l.join(`,
2814
+ `)}}`,d=WI(n,a.get(t)??/* @__PURE__ */ new Map),f=o,p=s;return`"use strict";
2810
2815
  ${f}${e}
2811
2816
  const __realmRequire = require;
2812
2817
  const { createRequire: __createRequire } = __realmRequire("module");
@@ -2849,7 +2854,7 @@ await Promise.resolve();
2849
2854
  await new Promise((resolve) => setTimeout(resolve));
2850
2855
  ${p}
2851
2856
  if (__state && __state.failed && __state.failed.length > 0) process.exit(1);
2852
- `}const KI={esModuleInterop:!0,allowJs:!0,isolatedModules:!1};function qI(e){return{module:e.ModuleKind.CommonJS,target:e.ScriptTarget.ES2022,...KI}}async function JI(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:`tst - run *.test.{js,ts} files with the bundled tst runner
2857
+ `}const YI={esModuleInterop:!0,allowJs:!0,isolatedModules:!1};function XI(e){return{module:e.ModuleKind.CommonJS,target:e.ScriptTarget.ES2022,...YI}}async function ZI(e,t){let n;try{n=RI(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
2853
2858
 
2854
2859
  Usage:
2855
2860
  tst [options] [glob...]
@@ -2871,7 +2876,7 @@ Notes:
2871
2876
  with statement counters. nyc/c8 cannot wrap this runner: it is not a
2872
2877
  Node child. Istanbul/Babel are not bundled (webapp size-limit); the
2873
2878
  TypeScript AST already in process does the rewrite.
2874
- `,stderr:``,exitCode:0}};let r=await RI(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 Ar(_I(t))}catch(e){return{done:{stdout:``,stderr:`tst: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}let a=await BI(i),o=n.coverage?await import(`./coverage-instrument-C0KP58r0.js`):null;return{parsed:n,files:r,ts:i,harness:a,userOpts:qI(i),coverageMaps:{},coverageCounts:{},coverageMod:o}}function YI(e){return e.includes(`# fail `)||/(^|\n)not ok /.test(e)}async function XI(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 WI(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=GI(a,n,d,s.reporter,f,p,c?`${c.coverageRuntimeSource()}\n`:``,c?`\n${c.coverageDumpSource()}`:``),h=await yi(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||YI(g)}}function ZI(){return C(`tst`,async(e,t)=>{let n=await JI(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 XI(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 QI=[],$I=`usage: theme <subcommand> [args]
2879
+ `,stderr:``,exitCode:0}};let r=await VI(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 Ar(bI(t))}catch(e){return{done:{stdout:``,stderr:`tst: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}let a=await UI(i),o=n.coverage?await import(`./coverage-instrument-C0KP58r0.js`):null;return{parsed:n,files:r,ts:i,harness:a,userOpts:XI(i),coverageMaps:{},coverageCounts:{},coverageMod:o}}function QI(e){return e.includes(`# fail `)||/(^|\n)not ok /.test(e)}async function $I(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 qI(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=JI(a,n,d,s.reporter,f,p,c?`${c.coverageRuntimeSource()}\n`:``,c?`\n${c.coverageDumpSource()}`:``),h=await yi(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||QI(g)}}function eL(){return C(`tst`,async(e,t)=>{let n=await ZI(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 $I(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 tL=[],nL=`usage: theme <subcommand> [args]
2875
2880
 
2876
2881
  Subcommands:
2877
2882
  list List available preset and custom themes
@@ -2880,23 +2885,23 @@ Subcommands:
2880
2885
  reset Reset to the default theme
2881
2886
  current Show the currently active theme
2882
2887
  export <id> <path> Export a theme to a VFS path
2883
- `;function eL(e,t){return{stdout:``,stderr:`theme ${e}: ${t}\n`,exitCode:1}}function tL(){return C(`theme`,async(e,t)=>{if(e.length===0||e[0]===`--help`||e[0]===`-h`)return{stdout:$I,stderr:``,exitCode:0};let n=e[0];return T(e.slice(1),{valueFlags:QI})?{stdout:gt(`theme`,n,$I),stderr:``,exitCode:0}:n===`list`?nL(e):n===`current`?rL(e):n===`reset`?iL(e):n===`apply`?aL(e.slice(1),t):n===`export`?oL(e.slice(1),t):{stdout:``,stderr:`theme: unknown subcommand "${n}"\n${$I}`,exitCode:1}})}async function nL(e){let t=w(e.slice(1),{value:QI});if(`error`in t)return eL(`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(`
2884
- `),stderr:``,exitCode:0}}async function rL(e){let t=w(e.slice(1),{value:QI});return`error`in t?eL(`current`,t.error):{stdout:`Check the Theme settings dialog for the active theme.
2885
- `,stderr:``,exitCode:0}}async function iL(e){let t=w(e.slice(1),{value:QI});if(`error`in t)return eL(`reset`,t.error);let n=b();return n?(await n.call(`theme-apply`,{action:`reset`}),{stdout:`Theme reset to default.
2888
+ `;function rL(e,t){return{stdout:``,stderr:`theme ${e}: ${t}\n`,exitCode:1}}function iL(){return C(`theme`,async(e,t)=>{if(e.length===0||e[0]===`--help`||e[0]===`-h`)return{stdout:nL,stderr:``,exitCode:0};let n=e[0];return T(e.slice(1),{valueFlags:tL})?{stdout:gt(`theme`,n,nL),stderr:``,exitCode:0}:n===`list`?aL(e):n===`current`?oL(e):n===`reset`?sL(e):n===`apply`?cL(e.slice(1),t):n===`export`?lL(e.slice(1),t):{stdout:``,stderr:`theme: unknown subcommand "${n}"\n${nL}`,exitCode:1}})}async function aL(e){let t=w(e.slice(1),{value:tL});if(`error`in t)return rL(`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(`
2889
+ `),stderr:``,exitCode:0}}async function oL(e){let t=w(e.slice(1),{value:tL});return`error`in t?rL(`current`,t.error):{stdout:`Check the Theme settings dialog for the active theme.
2890
+ `,stderr:``,exitCode:0}}async function sL(e){let t=w(e.slice(1),{value:tL});if(`error`in t)return rL(`reset`,t.error);let n=b();return n?(await n.call(`theme-apply`,{action:`reset`}),{stdout:`Theme reset to default.
2886
2891
  `,stderr:``,exitCode:0}):{stdout:``,stderr:`theme: no panel-RPC connection available
2887
- `,exitCode:1}}async function aL(e,t){let n=w(e,{value:QI});if(`error`in n)return eL(`apply`,n.error);if(n.positionals.length===0)return{stdout:``,stderr:`theme apply: missing theme id or path
2892
+ `,exitCode:1}}async function cL(e,t){let n=w(e,{value:tL});if(`error`in n)return rL(`apply`,n.error);if(n.positionals.length===0)return{stdout:``,stderr:`theme apply: missing theme id or path
2888
2893
  `,exitCode:1};let r=b();if(!r)return{stdout:``,stderr:`theme: no panel-RPC connection available
2889
2894
  `,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)
2890
2895
  `,exitCode:1}}catch{return{stdout:``,stderr:`theme apply: file is not valid JSON
2891
- `,exitCode:1}}return{stdout:`Applied theme: ${(await r.call(`theme-apply`,{themeJson:c,action:`apply`})).applied}\n`,stderr:``,exitCode:0}}async function oL(e,t){let n=w(e,{value:QI});if(`error`in n)return eL(`export`,n.error);if(n.positionals.length<2)return{stdout:``,stderr:`theme export: usage: theme export <id> <path>
2892
- `,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]`,lL=[`s`,`n`,`r`,`v`,`m`,`o`];function uL(){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(`
2893
- `),stderr:``,exitCode:0}}function dL(){let{releasedAt:e,buildId:t}=lt();return e?`${t} (${e})`:t}function fL(){let e=globalThis.navigator,t=e?.userAgentData?.platform||e?.platform;return typeof t==`string`&&t.length>0?t:sL}function pL(){let e=globalThis.navigator?.userAgent;return typeof e==`string`&&e.length>0?e:sL}function mL(e){switch(e){case`s`:return`SLICC`;case`n`:return ct();case`r`:return lt().version;case`v`:return dL();case`m`:return fL();case`o`:return pL()}}function hL(e){return{stdout:``,stderr:`uname: ${e}\n${cL}\n`,exitCode:1}}function gL(e){let t=/* @__PURE__ */ 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 lL)t.add(e);continue}if(!lL.includes(e))return{error:`unrecognized option '-${e}'`};t.add(e)}}return t}function _L(){return C(`uname`,async e=>{if(e.includes(`--help`)||e.includes(`-h`))return uL();let t=gL(e);return`error`in t?hL(t.error):{stdout:`${(t.size>0?lL.filter(e=>t.has(e)):[`s`]).map(mL).join(` `)}\n`,stderr:``,exitCode:0}})}function vL(){return C(`unlink`,async(e,t)=>{if(e.includes(`--help`))return{stdout:`Usage: unlink FILE
2896
+ `,exitCode:1}}return{stdout:`Applied theme: ${(await r.call(`theme-apply`,{themeJson:c,action:`apply`})).applied}\n`,stderr:``,exitCode:0}}async function lL(e,t){let n=w(e,{value:tL});if(`error`in n)return rL(`export`,n.error);if(n.positionals.length<2)return{stdout:``,stderr:`theme export: usage: theme export <id> <path>
2897
+ `,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 uL=`unknown`,dL=`usage: uname [-amnorsv]`,fL=[`s`,`n`,`r`,`v`,`m`,`o`];function pL(){return{stdout:[dL,` -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(`
2898
+ `),stderr:``,exitCode:0}}function mL(){let{releasedAt:e,buildId:t}=lt();return e?`${t} (${e})`:t}function hL(){let e=globalThis.navigator,t=e?.userAgentData?.platform||e?.platform;return typeof t==`string`&&t.length>0?t:uL}function gL(){let e=globalThis.navigator?.userAgent;return typeof e==`string`&&e.length>0?e:uL}function _L(e){switch(e){case`s`:return`SLICC`;case`n`:return ct();case`r`:return lt().version;case`v`:return mL();case`m`:return hL();case`o`:return gL()}}function vL(e){return{stdout:``,stderr:`uname: ${e}\n${dL}\n`,exitCode:1}}function yL(e){let t=/* @__PURE__ */ 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 fL)t.add(e);continue}if(!fL.includes(e))return{error:`unrecognized option '-${e}'`};t.add(e)}}return t}function bL(){return C(`uname`,async e=>{if(e.includes(`--help`)||e.includes(`-h`))return pL();let t=yL(e);return`error`in t?vL(t.error):{stdout:`${(t.size>0?fL.filter(e=>t.has(e)):[`s`]).map(_L).join(` `)}\n`,stderr:``,exitCode:0}})}function xL(){return C(`unlink`,async(e,t)=>{if(e.includes(`--help`))return{stdout:`Usage: unlink FILE
2894
2899
  Remove FILE. Symbolic links are removed without following their target.
2895
2900
  `,stderr:``,exitCode:0};if(e.length!==1||e[0].startsWith(`-`))return{stdout:``,stderr:e.length===0?`unlink: missing operand
2896
2901
  `:`unlink: extra operand
2897
- `,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 yL(){return{stdout:`usage: unzip <archive.zip> [-d <destination>]
2898
- `,stderr:``,exitCode:0}}function bL(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
2899
- `,exitCode:1}}:{kind:`ok`,archive:n[0],destination:t||`.`}}async function xL(e,t,n,r){let i=n.replace(/\\/g,`/`);if(!i||i.endsWith(`/`))return!1;let a=e.fs.resolvePath(t,i);if(!Br(t,a))return{stdout:``,stderr:`unzip: blocked suspicious path ${n}\n`,exitCode:1};let o=Lr(a);return o!==`/`&&await e.fs.mkdir(o,{recursive:!0}),await e.fs.writeFile(a,r),!0}function SL(){return C(`unzip`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return yL();let n=bL(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=Lt(a),s=0;for(let[e,n]of Object.entries(o)){let r=await xL(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 CL=`ai-ecoverse/slicc`,wL=`usage: upgrade status | upgrade apply --from=<version> --to=<version>`,TL=`packages/vfs-root`,EL=3e4,DL=[`${TL}/workspace/skills/`,`${TL}/shared/sprinkles/`,`${TL}/shared/sounds/`,`${TL}/shared/GELATIERE.md`,`${TL}/shared/wiki/WIKI.md`,`${TL}/etc/`],OL=[`auto-applied`,`merged-clean`,`kept-local`,`needs-review`,`unchanged`,`added-new`];function kL(){return Object.fromEntries(OL.map(e=>[e,0]))}function AL(e,t,n,r){let i=kL();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 jL(e){if(e[0]!==`apply`)throw Error(wL);let t=/* @__PURE__ */ 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 ML(e){return e.startsWith(`v`)?e:`v${e}`}function NL(e){if(!DL.some(t=>e.startsWith(t)))return null;let t=e.slice(17);return!t||t.split(`/`).some(e=>e===`.`||e===`..`)||t.startsWith(`/workspace/skills/`)&&we()?null:t}async function PL(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(/* @__PURE__ */ Error(`request timed out after ${EL}ms`)),EL)})])}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 FL(e,t){let n=await PL(t,`https://api.github.com/repos/${CL}/git/trees/${encodeURIComponent(e)}?recursive=1`),r=ke(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=/* @__PURE__ */ new Map;for(let e of r.tree){if(e.type!==`blob`||typeof e.path!=`string`)continue;let t=NL(e.path);t&&i.set(t,e.path)}return i}function IL(e,t){let n=t.split(`/`).map(encodeURIComponent).join(`/`);return`https://raw.githubusercontent.com/${CL}/${encodeURIComponent(e)}/${n}`}function LL(e,t){return!e||!t||e.byteLength!==t.byteLength?!1:e.every((e,n)=>e===t[n])}function RL(e){try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{return null}}async function zL(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 BL(e,t,n,r,i){let a=`${t}.upgrade-${ML(n)}-to-${ML(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 VL(e,t,n,r,i,a,o){let s=await zL(e.fs,t);if(!a)return{path:t,classification:s?`kept-local`:`unchanged`};if(!i)return s?{path:t,classification:LL(s,a)?`unchanged`:`kept-local`}:{path:t,classification:`added-new`,content:a};if(LL(i,a)||LL(s,a))return{path:t,classification:`unchanged`};if(!s)return{path:t,classification:`kept-local`};if(LL(s,i))return{path:t,classification:`auto-applied`,content:a};let[c,l,u]=[s,i,a].map(RL);if(c!==null&&l!==null&&u!==null){let i=Ye(c,l,u,{diff3:!0,labels:{current:`local:${t}`,base:`${ML(n)}:${t}`,other:`${ML(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 BL(e.fs,t,n,r,o)}}return{path:t,classification:`needs-review`,content:a,sidecar:await BL(e.fs,t,n,r,o)}}async function HL(e,t){t.content?await e.writeFile(t.path,t.content):await e.exists(t.path)&&await e.rm(t.path)}async function UL(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 zL(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 HL(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 WL(e,t,n){let r=ML(t),i=ML(n),[a,o]=await Promise.all([FL(r,e.fetch),FL(i,e.fetch)]),s=[.../* @__PURE__ */ new Set([...a.keys(),...o.keys()])].sort(),c=await Promise.all(s.map(async t=>{let[n,s]=await Promise.all([a.has(t)?PL(e.fetch,IL(r,a.get(t))).then(e=>je(e.body)):void 0,o.has(t)?PL(e.fetch,IL(i,o.get(t))).then(e=>je(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 VL(e,r,t,n,i,a,l));return await UL(e.fs,u),u}async function GL(e){let{version:t,releasedAt:n,buildId:r}=lt(),i=[],a=null,o=e.getLastSeen??ut();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 KL(e){return C(`upgrade`,async t=>{if(t.includes(`--help`)||t.includes(`-h`))return{stdout:`${wL}\n`,stderr:``,exitCode:0};if(t[0]===`status`)return t.length>1?{stdout:AL(``,``,[],[`unsupported argument: ${t[1]}`]),stderr:``,exitCode:1}:{stdout:await GL(e),stderr:``,exitCode:0};let n=``,r=``;try{({from:n,to:r}=jL(t));let i=await WL(e,n,r),a=i.some(e=>e.classification===`needs-review`);return{stdout:AL(n,r,i,[]),stderr:``,exitCode:+!!a}}catch(e){let t=e instanceof Error?e.message:String(e);return{stdout:AL(n,r,[],[t]),stderr:``,exitCode:1}}})}const qL=`usage: uptime [-p|--pretty] [-s|--since]`,JL=`${qL}
2902
+ `,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 SL(){return{stdout:`usage: unzip <archive.zip> [-d <destination>]
2903
+ `,stderr:``,exitCode:0}}function CL(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
2904
+ `,exitCode:1}}:{kind:`ok`,archive:n[0],destination:t||`.`}}async function wL(e,t,n,r){let i=n.replace(/\\/g,`/`);if(!i||i.endsWith(`/`))return!1;let a=e.fs.resolvePath(t,i);if(!Br(t,a))return{stdout:``,stderr:`unzip: blocked suspicious path ${n}\n`,exitCode:1};let o=Lr(a);return o!==`/`&&await e.fs.mkdir(o,{recursive:!0}),await e.fs.writeFile(a,r),!0}function TL(){return C(`unzip`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return SL();let n=CL(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=Lt(a),s=0;for(let[e,n]of Object.entries(o)){let r=await wL(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 EL=`ai-ecoverse/slicc`,DL=`usage: upgrade status | upgrade apply --from=<version> --to=<version>`,OL=`packages/vfs-root`,kL=3e4,AL=[`${OL}/workspace/skills/`,`${OL}/shared/sprinkles/`,`${OL}/shared/sounds/`,`${OL}/shared/GELATIERE.md`,`${OL}/shared/wiki/WIKI.md`,`${OL}/etc/`],jL=[`auto-applied`,`merged-clean`,`kept-local`,`needs-review`,`unchanged`,`added-new`];function ML(){return Object.fromEntries(jL.map(e=>[e,0]))}function NL(e,t,n,r){let i=ML();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 PL(e){if(e[0]!==`apply`)throw Error(DL);let t=/* @__PURE__ */ 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 FL(e){return e.startsWith(`v`)?e:`v${e}`}function IL(e){if(!AL.some(t=>e.startsWith(t)))return null;let t=e.slice(17);return!t||t.split(`/`).some(e=>e===`.`||e===`..`)||t.startsWith(`/workspace/skills/`)&&we()?null:t}async function LL(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(/* @__PURE__ */ Error(`request timed out after ${kL}ms`)),kL)})])}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 RL(e,t){let n=await LL(t,`https://api.github.com/repos/${EL}/git/trees/${encodeURIComponent(e)}?recursive=1`),r=ke(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=/* @__PURE__ */ new Map;for(let e of r.tree){if(e.type!==`blob`||typeof e.path!=`string`)continue;let t=IL(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/${EL}/${encodeURIComponent(e)}/${n}`}function BL(e,t){return!e||!t||e.byteLength!==t.byteLength?!1:e.every((e,n)=>e===t[n])}function VL(e){try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{return null}}async function HL(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 UL(e,t,n,r,i){let a=`${t}.upgrade-${FL(n)}-to-${FL(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 WL(e,t,n,r,i,a,o){let s=await HL(e.fs,t);if(!a)return{path:t,classification:s?`kept-local`:`unchanged`};if(!i)return s?{path:t,classification:BL(s,a)?`unchanged`:`kept-local`}:{path:t,classification:`added-new`,content:a};if(BL(i,a)||BL(s,a))return{path:t,classification:`unchanged`};if(!s)return{path:t,classification:`kept-local`};if(BL(s,i))return{path:t,classification:`auto-applied`,content:a};let[c,l,u]=[s,i,a].map(VL);if(c!==null&&l!==null&&u!==null){let i=Ye(c,l,u,{diff3:!0,labels:{current:`local:${t}`,base:`${FL(n)}:${t}`,other:`${FL(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 UL(e.fs,t,n,r,o)}}return{path:t,classification:`needs-review`,content:a,sidecar:await UL(e.fs,t,n,r,o)}}async function GL(e,t){t.content?await e.writeFile(t.path,t.content):await e.exists(t.path)&&await e.rm(t.path)}async function KL(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 HL(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 GL(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 qL(e,t,n){let r=FL(t),i=FL(n),[a,o]=await Promise.all([RL(r,e.fetch),RL(i,e.fetch)]),s=[.../* @__PURE__ */ new Set([...a.keys(),...o.keys()])].sort(),c=await Promise.all(s.map(async t=>{let[n,s]=await Promise.all([a.has(t)?LL(e.fetch,zL(r,a.get(t))).then(e=>je(e.body)):void 0,o.has(t)?LL(e.fetch,zL(i,o.get(t))).then(e=>je(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 WL(e,r,t,n,i,a,l));return await KL(e.fs,u),u}async function JL(e){let{version:t,releasedAt:n,buildId:r}=lt(),i=[],a=null,o=e.getLastSeen??ut();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 YL(e){return C(`upgrade`,async t=>{if(t.includes(`--help`)||t.includes(`-h`))return{stdout:`${DL}\n`,stderr:``,exitCode:0};if(t[0]===`status`)return t.length>1?{stdout:NL(``,``,[],[`unsupported argument: ${t[1]}`]),stderr:``,exitCode:1}:{stdout:await JL(e),stderr:``,exitCode:0};let n=``,r=``;try{({from:n,to:r}=PL(t));let i=await qL(e,n,r),a=i.some(e=>e.classification===`needs-review`);return{stdout:NL(n,r,i,[]),stderr:``,exitCode:+!!a}}catch(e){let t=e instanceof Error?e.message:String(e);return{stdout:NL(n,r,[],[t]),stderr:``,exitCode:1}}})}const XL=`usage: uptime [-p|--pretty] [-s|--since]`,ZL=`${XL}
2900
2905
 
2901
2906
  Print how long this SLICC has been running. The clock starts when the browser
2902
2907
  window was last loaded — a reload is a reboot.
@@ -2912,7 +2917,7 @@ The load average is the average number of live kernel processes over the last
2912
2917
  processes are retained in bounded numbers, so a long burst of short commands
2913
2918
  can under-report the older windows. The user count is always 1: a SLICC
2914
2919
  runtime has one user identity (see \`id\`).
2915
- `,YL=[1,5,15],XL=6e4,ZL=60*XL,QL=24*ZL;function $L(){let e=globalThis.__slicc_pm;return e instanceof Object&&typeof e.list==`function`?e:null}function eR(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 tR(e){let t=Math.max(0,e),n=Math.floor(t/QL),r=Math.floor(t%QL/ZL),i=Math.floor(t%ZL/XL),a=r>0?`${r}:${String(i).padStart(2,`0`)}`:`${i} min`;return n===0?a:`${n} ${n===1?`day`:`days`}, ${a}`}function nR(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/QL),`day`),r(Math.floor(t%QL/ZL),`hour`),r(Math.floor(t%ZL/XL),`minute`),n.length===0?`up ${Math.floor(t/1e3)} seconds`:`up ${n.join(`, `)}`}function rR(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 iR(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function aR(e,t,n){let r=YL.map(r=>eR(e,t,r*XL,n).toFixed(2));return` ${iR(t)} up ${tR(t-n)}, 1 user, load average: ${r.join(`, `)}\n`}function oR(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 C(`uptime`,async t=>{let n=oR(t);if(typeof n!=`string`)return{stdout:``,stderr:`uptime: ${n.error}\n${qL}\n`,exitCode:1};if(n===`help`)return{stdout:JL,stderr:``,exitCode:0};if(n===`version`)return{stdout:`uptime (SLICC) ${lt().version}\n`,stderr:``,exitCode:0};let r=e.now?e.now():Date.now(),i=e.bootedAt?e.bootedAt():Pa();if(n===`since`)return cR(`${rR(i)}\n`);if(n===`pretty`)return cR(`${nR(r-i)}\n`);let a=e.processManager??$L();return cR(aR(a?a.list():[],r,i))})}function cR(e){return{stdout:e,stderr:``,exitCode:0}}const lR=/* @__PURE__ */ new Set([`--vid`,`--pid`,`--class`,`--subclass`,`--protocol`,`--serial`,`--request-type`,`--recipient`,`--request`,`--value`,`--index`,`--__resolved`]);function uR(e){return Vn(e,lR)}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 fR=/* @__PURE__ */ new Set([`standard`,`class`,`vendor`]),pR=/* @__PURE__ */ new Set([`device`,`interface`,`endpoint`,`other`]);function mR(e){let t=e.get(`--request-type`)??`vendor`,n=e.get(`--recipient`)??`device`;if(!fR.has(t))throw Error(`invalid --request-type: '${t}'`);if(!pR.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 hR(e){let t=lr(e.stdin),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e)&255;return n}function gR(e){return Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(` `)}function _R(e){return`0x${e.toString(16).padStart(4,`0`)}`}function vR(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${_R(e.vendorId)}:${_R(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 yR=`usb - access USB devices via WebUSB
2920
+ `,QL=[1,5,15],$L=6e4,eR=60*$L,tR=24*eR;function nR(){let e=globalThis.__slicc_pm;return e instanceof Object&&typeof e.list==`function`?e:null}function rR(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 iR(e){let t=Math.max(0,e),n=Math.floor(t/tR),r=Math.floor(t%tR/eR),i=Math.floor(t%eR/$L),a=r>0?`${r}:${String(i).padStart(2,`0`)}`:`${i} min`;return n===0?a:`${n} ${n===1?`day`:`days`}, ${a}`}function aR(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/tR),`day`),r(Math.floor(t%tR/eR),`hour`),r(Math.floor(t%eR/$L),`minute`),n.length===0?`up ${Math.floor(t/1e3)} seconds`:`up ${n.join(`, `)}`}function oR(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 sR(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function cR(e,t,n){let r=QL.map(r=>rR(e,t,r*$L,n).toFixed(2));return` ${sR(t)} up ${iR(t-n)}, 1 user, load average: ${r.join(`, `)}\n`}function lR(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 uR(e={}){return C(`uptime`,async t=>{let n=lR(t);if(typeof n!=`string`)return{stdout:``,stderr:`uptime: ${n.error}\n${XL}\n`,exitCode:1};if(n===`help`)return{stdout:ZL,stderr:``,exitCode:0};if(n===`version`)return{stdout:`uptime (SLICC) ${lt().version}\n`,stderr:``,exitCode:0};let r=e.now?e.now():Date.now(),i=e.bootedAt?e.bootedAt():Pa();if(n===`since`)return dR(`${oR(i)}\n`);if(n===`pretty`)return dR(`${aR(r-i)}\n`);let a=e.processManager??nR();return dR(cR(a?a.list():[],r,i))})}function dR(e){return{stdout:e,stderr:``,exitCode:0}}const fR=/* @__PURE__ */ new Set([`--vid`,`--pid`,`--class`,`--subclass`,`--protocol`,`--serial`,`--request-type`,`--recipient`,`--request`,`--value`,`--index`,`--__resolved`]);function pR(e){return Vn(e,fR)}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 mR(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 hR=/* @__PURE__ */ new Set([`standard`,`class`,`vendor`]),gR=/* @__PURE__ */ new Set([`device`,`interface`,`endpoint`,`other`]);function _R(e){let t=e.get(`--request-type`)??`vendor`,n=e.get(`--recipient`)??`device`;if(!hR.has(t))throw Error(`invalid --request-type: '${t}'`);if(!gR.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 vR(e){let t=lr(e.stdin),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e)&255;return n}function yR(e){return Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(` `)}function bR(e){return`0x${e.toString(16).padStart(4,`0`)}`}function xR(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${bR(e.vendorId)}:${bR(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 SR=`usb - access USB devices via WebUSB
2916
2921
 
2917
2922
  Usage: usb <subcommand> [options]
2918
2923
 
@@ -2951,9 +2956,9 @@ Options:
2951
2956
  -h, --help
2952
2957
 
2953
2958
  Transfers are capped at ${Ai} bytes (4 MiB).
2954
- `;function bR(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?`${gR(e)}\n`:``)}async function xR(e){let t=await e.list();return t.length===0?X(`no granted USB devices
2955
- `):X(`${t.map(vR).join(`
2956
- `)}\n`)}async function SR(e,t){let n=e.get(`--__resolved`);if(n)return X(`${vR(await t.info(n))}\n`);let r=dR(e),i=Ve();if(i){let e=await Yx(`usb-device`,r,i);if(e.handle)return X(`${vR(await t.info(e.handle))}\n`);let n=e.info,a=Oi();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=ki().register(o);return X(`${vR(Di(s,o))}\n`)}return X(`${vR(await t.request(r))}\n`)}async function CR(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 wR(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 TR(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 ER(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 DR(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`):bR((await n.controlIn(i,mR(t),o)).bytes,r)}async function OR(e,t,n,r){let i=e[1];if(!i)return Z(`control-out: handle required`);let a=hR(t);return a.length>4194304?Z(`control-out payload exceeds 4 MiB limit`):X(`${(await r.controlOut(i,mR(n),a)).bytesWritten} bytes written\n`)}async function kR(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`):bR((await n.transferIn(i,Y(a,`endpoint`),s)).bytes,r)}async function AR(e,t,n,r){let[,i,a]=e;if(!i||a===void 0)return Z(`transfer-out: handle and endpoint required`);let o=hR(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 jR(e,t,n){let{positionals:r,flags:i,bools:a}=uR(e),o=r[0],s=a.has(`--raw`);switch(o){case`list`:return xR(n);case`request`:return SR(i,n);case`open`:case`close`:case`reset`:return CR(o,r,n,a);case`clear-halt`:return wR(r,n);case`select-config`:return TR(r,n);case`claim`:case`release`:return ER(o,r,n,a);case`control-in`:return DR(r,i,n,s);case`control-out`:return OR(r,t,i,n);case`transfer-in`:return kR(r,i,n,s);case`transfer-out`:return AR(r,t,i,n);default:return Z(`unknown subcommand '${o??``}'. Try 'usb --help'.`)}}function MR(){return C(`usb`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return X(yR);let n=mi(be(),b());if(!n)return Z(`WebUSB is unavailable in this environment`);try{return await jR(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 NR=`/workspace/.v86`,PR=`v86 - run an x86 virtual machine (v86 wasm engine)
2959
+ `;function CR(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?`${yR(e)}\n`:``)}async function wR(e){let t=await e.list();return t.length===0?X(`no granted USB devices
2960
+ `):X(`${t.map(xR).join(`
2961
+ `)}\n`)}async function TR(e,t){let n=e.get(`--__resolved`);if(n)return X(`${xR(await t.info(n))}\n`);let r=mR(e),i=Ve();if(i){let e=await Yx(`usb-device`,r,i);if(e.handle)return X(`${xR(await t.info(e.handle))}\n`);let n=e.info,a=Oi();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=ki().register(o);return X(`${xR(Di(s,o))}\n`)}return X(`${xR(await t.request(r))}\n`)}async function ER(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 DR(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 OR(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 kR(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 AR(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`):CR((await n.controlIn(i,_R(t),o)).bytes,r)}async function jR(e,t,n,r){let i=e[1];if(!i)return Z(`control-out: handle required`);let a=vR(t);return a.length>4194304?Z(`control-out payload exceeds 4 MiB limit`):X(`${(await r.controlOut(i,_R(n),a)).bytesWritten} bytes written\n`)}async function MR(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`):CR((await n.transferIn(i,Y(a,`endpoint`),s)).bytes,r)}async function NR(e,t,n,r){let[,i,a]=e;if(!i||a===void 0)return Z(`transfer-out: handle and endpoint required`);let o=vR(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 PR(e,t,n){let{positionals:r,flags:i,bools:a}=pR(e),o=r[0],s=a.has(`--raw`);switch(o){case`list`:return wR(n);case`request`:return TR(i,n);case`open`:case`close`:case`reset`:return ER(o,r,n,a);case`clear-halt`:return DR(r,n);case`select-config`:return OR(r,n);case`claim`:case`release`:return kR(o,r,n,a);case`control-in`:return AR(r,i,n,s);case`control-out`:return jR(r,t,i,n);case`transfer-in`:return MR(r,i,n,s);case`transfer-out`:return NR(r,t,i,n);default:return Z(`unknown subcommand '${o??``}'. Try 'usb --help'.`)}}function FR(){return C(`usb`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return X(SR);let n=mi(be(),b());if(!n)return Z(`WebUSB is unavailable in this environment`);try{return await PR(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 IR=`/workspace/.v86`,LR=`v86 - run an x86 virtual machine (v86 wasm engine)
2957
2962
 
2958
2963
  Requires: ${F} v86@${zO}
2959
2964
 
@@ -2989,7 +2994,7 @@ Boot options (QEMU-flavored):
2989
2994
  proxy — no gateway needed, https upstream via the proxy
2990
2995
  -vga <MiB> SVGA/VBE video memory (default 8, max 64) —
2991
2996
  raise for high-res VESA modes (1080p32 needs ~9)
2992
- -bios <path> -vgabios <path> BIOS blobs (default ${NR}/{seabios,vgabios}.bin)
2997
+ -bios <path> -vgabios <path> BIOS blobs (default ${IR}/{seabios,vgabios}.bin)
2993
2998
  -nographic Serial-only guest (skip VGA)
2994
2999
 
2995
3000
  Notes:
@@ -2997,19 +3002,19 @@ Notes:
2997
3002
  (Alpine, FreeDOS, Buildroot Linux) work best.
2998
3003
  - The copy.sh Arch Linux image boots via -state + -fs9p; see the v86 skill.
2999
3004
  - BIOS blobs are not bundled; download once:
3000
- mkdir -p ${NR}
3001
- curl -o ${NR}/seabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/seabios.bin
3002
- curl -o ${NR}/vgabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/vgabios.bin
3003
- `,FR=`v86: BIOS images not found. Download them once:
3004
- mkdir -p ${NR}
3005
- curl -o ${NR}/seabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/seabios.bin
3006
- curl -o ${NR}/vgabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/vgabios.bin
3007
- or pass -bios / -vgabios with explicit VFS paths.`,IR={"-n":LR,"-name":LR,"--name":LR,"-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)=>RR(e,`cdrom`,t),"-hda":(e,t)=>RR(e,`hda`,t),"-fda":(e,t)=>RR(e,`fda`,t),"-kernel":(e,t)=>RR(e,`kernel`,t),"-initrd":(e,t)=>RR(e,`initrd`,t),"-append":(e,t)=>RR(e,`append`,t),"-bios":(e,t)=>RR(e,`bios`,t),"-vgabios":(e,t)=>RR(e,`vgabios`,t),"-state":(e,t)=>RR(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 LR(e,t){return/^[A-Za-z0-9_-]+$/.test(t)?(e.name=t,null):`invalid VM name '${t}'`}function RR(e,t,n){return e[t]=n,null}const zR=[...Object.keys(IR),`--fps`,`--tail`,`--send`,`--to`];function BR(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(IR,r)?IR[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 VR(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 HR(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 UR(e){return Oa(e)||Q(`no VM named '${e}' — boot one with \`v86 start -n ${e} ...\``)}function WR(e){return`exitCode`in e}async function GR(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 KR={a:801,c:306,d:531};function qR(){let e=globalThis.__slicc_pm;return e instanceof Object&&typeof e.signal==`function`?e:null}function JR(e={}){return C(`v86`,async(t,n)=>{if(t.length===0||t[0]===`--help`||t[0]===`-h`||t[0]===`help`)return $(PR);if(t[0]===`--version`)return YR(n,e);let r=t[0];if(T(t.slice(1),{valueFlags:zR}))return $(gt(`v86`,r,PR,{prefix:`v86`}));let i=ht(t.slice(1));try{switch(r){case`start`:return await tz(i,n,e);case`ls`:return rz();case`type`:return await sz(i,n);case`key`:return await cz(i,n);case`mouse`:return await uz(i,n);case`screenshot`:return await dz(i,n);case`text`:return await fz(i,n);case`serve`:return pz(i);case`serial`:return mz(i);case`state`:return await hz(i,n);case`stop`:return await gz(i,e);default:return Q(`unknown subcommand '${r}' — see \`v86 --help\``)}}catch(e){return Q(e instanceof Error?e.message:String(e))}})}async function YR(e,t){if(t.loadEngine)return $(`v86 ${(await t.loadEngine(VR(e))).version} (qemu-flavored CLI)\n`);let n=await GO(VR(e));return n?$(`v86 ${n.version} (qemu-flavored CLI)\n`):Q(BO)}async function XR(e,t,n){if(e.state&&!e.bios&&!e.vgabios)return null;let r=await GR(t,e.bios??`${NR}/seabios.bin`,`-bios`);if(`exitCode`in r)return e.bios?r:Q(FR.replace(/^v86: /u,``));if(n.bios=r,e.nographic)return null;let i=await GR(t,e.vgabios??`${NR}/vgabios.bin`,`-vgabios`);return`exitCode`in i?e.vgabios?i:Q(FR.replace(/^v86: /u,``)):(n.vga_bios=i,null)}async function ZR(e,t,n){let r=await XR(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 GR(t,a,`-${r}`);if(`exitCode`in o)return o;n[i]=o}if(e.append&&(n.cmdline=e.append),e.boot&&(n.boot_order=KR[e.boot]),e.state){let r=await GR(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 QR=6e4;function $R(e){return e.v86?Promise.resolve():new Promise((t,n)=>{let r=setTimeout(()=>n(/* @__PURE__ */ Error(`engine init timed out after ${QR/1e3}s`)),QR);e.add_listener(`emulator-loaded`,()=>{clearTimeout(r),t()})})}function ez(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??g();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 tz(e,t,n){let r=BR(e);if(!r.ok)return Q(r.error);let i=r.parsed;if(Oa(i.name))return Q(`VM '${i.name}' already running — stop it first or pick another -n name`);let a=VR(t),o=n.loadEngine?await n.loadEngine(a):await HO({ipk:a}),s={wasm_fn:qO(o.wasmModule),memory_size:i.memoryMib*1024*1024,vga_memory_size:i.vgaMemoryMib*1024*1024,autostart:!1,disable_speaker:!0,fastboot:!0},c=await ZR(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??qR();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`,()=>{nz(u,d)})}Da(u);try{if(await $R(l),i.netRelay===`fetch`){let e=ez(l,n);if(e)return await nz(u,d),e}Ea(u),await l.run()}catch(e){return await nz(u,d),Q(`boot failed: ${e instanceof Error?e.message:String(e)}`)}u.onScreenChange=()=>{import(`./registry-Bxb0uXZH.js`).then(({getComputerRegistry:e})=>{e()?.refresh(`v86:${u.name}`)})},import(`./v86-BhyJfU3t.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 nz(e,t){ka(e),Ta(e.name),import(`./v86-BhyJfU3t.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 rz(){let e=wa();if(e.length===0)return $(`no VMs running
3005
+ mkdir -p ${IR}
3006
+ curl -o ${IR}/seabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/seabios.bin
3007
+ curl -o ${IR}/vgabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/vgabios.bin
3008
+ `,RR=`v86: BIOS images not found. Download them once:
3009
+ mkdir -p ${IR}
3010
+ curl -o ${IR}/seabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/seabios.bin
3011
+ curl -o ${IR}/vgabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/vgabios.bin
3012
+ or pass -bios / -vgabios with explicit VFS paths.`,zR={"-n":BR,"-name":BR,"--name":BR,"-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)=>VR(e,`cdrom`,t),"-hda":(e,t)=>VR(e,`hda`,t),"-fda":(e,t)=>VR(e,`fda`,t),"-kernel":(e,t)=>VR(e,`kernel`,t),"-initrd":(e,t)=>VR(e,`initrd`,t),"-append":(e,t)=>VR(e,`append`,t),"-bios":(e,t)=>VR(e,`bios`,t),"-vgabios":(e,t)=>VR(e,`vgabios`,t),"-state":(e,t)=>VR(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 BR(e,t){return/^[A-Za-z0-9_-]+$/.test(t)?(e.name=t,null):`invalid VM name '${t}'`}function VR(e,t,n){return e[t]=n,null}const HR=[...Object.keys(zR),`--fps`,`--tail`,`--send`,`--to`];function UR(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 WR(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 GR(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 KR(e){return Oa(e)||Q(`no VM named '${e}' — boot one with \`v86 start -n ${e} ...\``)}function qR(e){return`exitCode`in e}async function JR(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 YR={a:801,c:306,d:531};function XR(){let e=globalThis.__slicc_pm;return e instanceof Object&&typeof e.signal==`function`?e:null}function ZR(e={}){return C(`v86`,async(t,n)=>{if(t.length===0||t[0]===`--help`||t[0]===`-h`||t[0]===`help`)return $(LR);if(t[0]===`--version`)return QR(n,e);let r=t[0];if(T(t.slice(1),{valueFlags:HR}))return $(gt(`v86`,r,LR,{prefix:`v86`}));let i=ht(t.slice(1));try{switch(r){case`start`:return await iz(i,n,e);case`ls`:return oz();case`type`:return await uz(i,n);case`key`:return await dz(i,n);case`mouse`:return await pz(i,n);case`screenshot`:return await mz(i,n);case`text`:return await hz(i,n);case`serve`:return gz(i);case`serial`:return _z(i);case`state`:return await vz(i,n);case`stop`:return await yz(i,e);default:return Q(`unknown subcommand '${r}' — see \`v86 --help\``)}}catch(e){return Q(e instanceof Error?e.message:String(e))}})}async function QR(e,t){if(t.loadEngine)return $(`v86 ${(await t.loadEngine(WR(e))).version} (qemu-flavored CLI)\n`);let n=await GO(WR(e));return n?$(`v86 ${n.version} (qemu-flavored CLI)\n`):Q(BO)}async function $R(e,t,n){if(e.state&&!e.bios&&!e.vgabios)return null;let r=await JR(t,e.bios??`${IR}/seabios.bin`,`-bios`);if(`exitCode`in r)return e.bios?r:Q(RR.replace(/^v86: /u,``));if(n.bios=r,e.nographic)return null;let i=await JR(t,e.vgabios??`${IR}/vgabios.bin`,`-vgabios`);return`exitCode`in i?e.vgabios?i:Q(RR.replace(/^v86: /u,``)):(n.vga_bios=i,null)}async function ez(e,t,n){let r=await $R(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 JR(t,a,`-${r}`);if(`exitCode`in o)return o;n[i]=o}if(e.append&&(n.cmdline=e.append),e.boot&&(n.boot_order=YR[e.boot]),e.state){let r=await JR(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 tz=6e4;function nz(e){return e.v86?Promise.resolve():new Promise((t,n)=>{let r=setTimeout(()=>n(/* @__PURE__ */ Error(`engine init timed out after ${tz/1e3}s`)),tz);e.add_listener(`emulator-loaded`,()=>{clearTimeout(r),t()})})}function rz(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??g();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 iz(e,t,n){let r=UR(e);if(!r.ok)return Q(r.error);let i=r.parsed;if(Oa(i.name))return Q(`VM '${i.name}' already running — stop it first or pick another -n name`);let a=WR(t),o=n.loadEngine?await n.loadEngine(a):await HO({ipk:a}),s={wasm_fn:qO(o.wasmModule),memory_size:i.memoryMib*1024*1024,vga_memory_size:i.vgaMemoryMib*1024*1024,autostart:!1,disable_speaker:!0,fastboot:!0},c=await ez(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??XR();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`,()=>{az(u,d)})}Da(u);try{if(await nz(l),i.netRelay===`fetch`){let e=rz(l,n);if(e)return await az(u,d),e}Ea(u),await l.run()}catch(e){return await az(u,d),Q(`boot failed: ${e instanceof Error?e.message:String(e)}`)}u.onScreenChange=()=>{import(`./registry-Bxb0uXZH.js`).then(({getComputerRegistry:e})=>{e()?.refresh(`v86:${u.name}`)})},import(`./v86-BhyJfU3t.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 az(e,t){ka(e),Ta(e.name),import(`./v86-BhyJfU3t.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 oz(){let e=wa();if(e.length===0)return $(`no VMs running
3008
3013
  `);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(`
3009
- `)}\n`)}function iz(e,t){return`prefer: computer ${e} -c ${t}\n`}async function az(e,t,n,r){let i=UR(t);if(WR(i))return i;let[{runComputer:a},{getComputerRegistry:o,installComputerRegistry:s},c]=await Promise.all([import(`./run-Ds-D_Vog.js`).then(e=>e.t),import(`./registry-Bxb0uXZH.js`),import(`./v86-BhyJfU3t.js`)]),l=c.v86ComputerId(t),u=o()??s(null);return u.get(l)||c.registerV86Computer(i,u),oz(await a([`-c`,l,...n],e,{registry:u}),r,l)}function oz(e,t,n){let r=iz(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}=HR(e);if(r.length===0){let e=UR(n);return WR(e)?e:Q(`type: no text supplied`)}return az(t,n,[`type`,`--`,...r],`type`)}async function cz(e,t){let{name:n,rest:r}=HR(e);if(r.length===0){let e=UR(n);return WR(e)?e:Q(`key: no chord supplied`)}return az(t,n,[`key`,...r],`key`)}const lz=[`left`,`middle`,`right`];async function uz(e,t){let{name:n,rest:r}=HR(e),i=UR(n);if(WR(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?az(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>`):az(t,n,[`--native`,`mousemove`,e,i,`--relative`],`mousemove`)}if(o===`click`){let e=r[1]??`left`;if(!lz.includes(e))return Q(`mouse: unknown button '${r[1]}'`);let i=[`click`,e];return r.includes(`--double`)&&i.push(`--repeat`,`2`),az(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}=HR(e);return az(t,n,[`screenshot`,...r],`screenshot`)}async function fz(e,t){let{name:n}=HR(e);return az(t,n,[`text`],`text`)}function pz(e){let{name:t}=HR(e);return $(`v86 serve is retired.\nUse: computer watch -c v86:${t}\nLive frames go to the overlay, lightbox, and bash rows.\n`)}function mz(e){let{name:t,rest:n}=HR(e),r=UR(t);if(WR(r))return r;let i=n.indexOf(`--send`);if(i!==-1){let e=n.slice(i+1).join(` `).replace(/\\n/gu,`
3014
+ `)}\n`)}function sz(e,t){return`prefer: computer ${e} -c ${t}\n`}async function cz(e,t,n,r){let i=KR(t);if(qR(i))return i;let[{runComputer:a},{getComputerRegistry:o,installComputerRegistry:s},c]=await Promise.all([import(`./run-Ds-D_Vog.js`).then(e=>e.t),import(`./registry-Bxb0uXZH.js`),import(`./v86-BhyJfU3t.js`)]),l=c.v86ComputerId(t),u=o()??s(null);return u.get(l)||c.registerV86Computer(i,u),lz(await a([`-c`,l,...n],e,{registry:u}),r,l)}function lz(e,t,n){let r=sz(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 uz(e,t){let{name:n,rest:r}=GR(e);if(r.length===0){let e=KR(n);return qR(e)?e:Q(`type: no text supplied`)}return cz(t,n,[`type`,`--`,...r],`type`)}async function dz(e,t){let{name:n,rest:r}=GR(e);if(r.length===0){let e=KR(n);return qR(e)?e:Q(`key: no chord supplied`)}return cz(t,n,[`key`,...r],`key`)}const fz=[`left`,`middle`,`right`];async function pz(e,t){let{name:n,rest:r}=GR(e),i=KR(n);if(qR(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?cz(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>`):cz(t,n,[`--native`,`mousemove`,e,i,`--relative`],`mousemove`)}if(o===`click`){let e=r[1]??`left`;if(!fz.includes(e))return Q(`mouse: unknown button '${r[1]}'`);let i=[`click`,e];return r.includes(`--double`)&&i.push(`--repeat`,`2`),cz(t,n,i,`click`)}return Q(`mouse: expected move <dx> <dy>, click [button], or --to <x>,<y>`)}async function mz(e,t){let{name:n,rest:r}=GR(e);return cz(t,n,[`screenshot`,...r],`screenshot`)}async function hz(e,t){let{name:n}=GR(e);return cz(t,n,[`text`],`text`)}function gz(e){let{name:t}=GR(e);return $(`v86 serve is retired.\nUse: computer watch -c v86:${t}\nLive frames go to the overlay, lightbox, and bash rows.\n`)}function _z(e){let{name:t,rest:n}=GR(e),r=KR(t);if(qR(r))return r;let i=n.indexOf(`--send`);if(i!==-1){let e=n.slice(i+1).join(` `).replace(/\\n/gu,`
3010
3015
  `);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(`
3011
3016
  `).slice(-Math.max(1,e)).join(`
3012
- `)}\n`)}return $(r.serial.buffer?`${r.serial.buffer}\n`:``)}async function hz(e,t){let{name:n,rest:r}=HR(e),i=UR(n);if(WR(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 gz(e,t){let{name:n,rest:r}=HR(e),i=UR(n);if(WR(i))return i;let a=t.processManager??qR();return r.includes(`--force`)&&a&&i.pid!==null?(a.signal(i.pid,`SIGKILL`),$(`VM '${n}' killed\n`)):(await nz(i,a),$(`VM '${n}' stopped\n`))}function _z(e={}){return C(`wasm`,async(t,n)=>{let{runWasmCommand:r}=await import(`./run-BBaO_6mp.js`);return r(t,n,{processConfig:e.buildProcessConfig?.(n.env),terminal:e.terminal,gate:e.gate,commands:e.commands,gitIdentity:e.gitIdentity})})}const vz=[`--name`,`--filter`,`--scoop`],yz={state:`inactive`,session:null};function bz(){return{stdout:`usage: webhook <command> [options]
3017
+ `)}\n`)}return $(r.serial.buffer?`${r.serial.buffer}\n`:``)}async function vz(e,t){let{name:n,rest:r}=GR(e),i=KR(n);if(qR(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 yz(e,t){let{name:n,rest:r}=GR(e),i=KR(n);if(qR(i))return i;let a=t.processManager??XR();return r.includes(`--force`)&&a&&i.pid!==null?(a.signal(i.pid,`SIGKILL`),$(`VM '${n}' killed\n`)):(await az(i,a),$(`VM '${n}' stopped\n`))}function bz(e={}){return C(`wasm`,async(t,n)=>{let{runWasmCommand:r}=await import(`./run-BBaO_6mp.js`);return r(t,n,{processConfig:e.buildProcessConfig?.(n.env),terminal:e.terminal,gate:e.gate,commands:e.commands,gitIdentity:e.gitIdentity})})}const xz=[`--name`,`--filter`,`--scoop`],Sz={state:`inactive`,session:null};function Cz(){return{stdout:`usage: webhook <command> [options]
3013
3018
 
3014
3019
  Commands:
3015
3020
  create [--scoop <name>] [--name <name>] [--filter <code>] Create a new webhook endpoint
@@ -3029,21 +3034,21 @@ Examples:
3029
3034
  webhook create --scoop slack-relay --name slack --filter "(e) => ({ text: e.body.text, user: e.body.user })"
3030
3035
  webhook list
3031
3036
  webhook delete abc123
3032
- `,stderr:``,exitCode:0}}function xz(e){return e().session?.webhookUrl??null}function Sz(e,t,n){return t?Aa(t,e):n()?ja(self.location.href,e):`(URL unavailable — connect a leader tray)`}function Cz(e){return{stdout:``,stderr:`webhook ${e}: kernel host has not booted yet — try again in a moment\n`,exitCode:1}}async function wz(e){if(e.length!==1)return{stdout:``,stderr:`webhook rotate: takes no arguments
3037
+ `,stderr:``,exitCode:0}}function wz(e){return e().session?.webhookUrl??null}function Tz(e,t,n){return t?Aa(t,e):n()?ja(self.location.href,e):`(URL unavailable — connect a leader tray)`}function Ez(e){return{stdout:``,stderr:`webhook ${e}: kernel host has not booted yet — try again in a moment\n`,exitCode:1}}async function Dz(e){if(e.length!==1)return{stdout:``,stderr:`webhook rotate: takes no arguments
3033
3038
  `,exitCode:1};let t=b();if(!t)return{stdout:``,stderr:`webhook rotate: no leader panel connected
3034
3039
  `,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.
3035
3040
  `,stderr:``,exitCode:0}}catch{return{stdout:``,stderr:`webhook rotate: rotation failed; reconnect the leader and retry
3036
- `,exitCode:1}}}async function Tz(e,t,n){let r=w(e.slice(1),{value:vz});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=fa(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
3037
- `,exitCode:1};let s=Oz(t);if(s)return s;let c=await Ey();if(!c)return Cz(`create`);let l=await Oy(c,`webhook create`,r.values.get(`--scoop`));if(l)return{stdout:``,stderr:l,exitCode:1};let u=await c.createWebhook(i,o,a),d=kz(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 Ez(e,t){let n=w(e.slice(1),{});if(`error`in n)return{stdout:``,stderr:`webhook list: ${n.error}\n`,exitCode:1};let r=await Ey();if(!r)return Cz(`list`);let i=await r.listWebhooks();if(i.length===0)return{stdout:`No active webhooks
3038
- `,stderr:``,exitCode:0};let{trayUrlBase:a,urlResolutionError:o}=Az(t);return{stdout:jz(i.map(e=>({id:e.id,name:e.name,url:Sz(e.id,a,t.hasLocalNodeServer),createdAt:e.createdAt,filter:e.filter,scoop:e.scoop})),a,o,t.hasLocalNodeServer),stderr:``,exitCode:0}}async function Dz(e,t){let n=w(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
3041
+ `,exitCode:1}}}async function Oz(e,t,n){let r=w(e.slice(1),{value:xz});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=fa(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
3042
+ `,exitCode:1};let s=jz(t);if(s)return s;let c=await Ey();if(!c)return Ez(`create`);let l=await Oy(c,`webhook create`,r.values.get(`--scoop`));if(l)return{stdout:``,stderr:l,exitCode:1};let u=await c.createWebhook(i,o,a),d=Mz(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 kz(e,t){let n=w(e.slice(1),{});if(`error`in n)return{stdout:``,stderr:`webhook list: ${n.error}\n`,exitCode:1};let r=await Ey();if(!r)return Ez(`list`);let i=await r.listWebhooks();if(i.length===0)return{stdout:`No active webhooks
3043
+ `,stderr:``,exitCode:0};let{trayUrlBase:a,urlResolutionError:o}=Nz(t);return{stdout:Pz(i.map(e=>({id:e.id,name:e.name,url:Tz(e.id,a,t.hasLocalNodeServer),createdAt:e.createdAt,filter:e.filter,scoop:e.scoop})),a,o,t.hasLocalNodeServer),stderr:``,exitCode:0}}async function Az(e,t){let n=w(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
3039
3044
  `,exitCode:1};if(!r)return{stdout:``,stderr:`webhook delete: requires an ID
3040
- `,exitCode:1};let i=await Ey();if(!i)return Cz(`delete`);let a=b();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
3041
- `,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 Oz(e){if(e.hasLocalNodeServer())return null;if(!xz(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}")`)+`
3042
- `,exitCode:1}}return null}function kz(e,t){try{return Sz(e,xz(t.getLeaderStatus),t.hasLocalNodeServer)}catch(e){return`(URL resolution failed: ${e instanceof Error?e.message:String(e)})`}}function Az(e){try{return{trayUrlBase:xz(e.getLeaderStatus),urlResolutionError:null}}catch(e){return{trayUrlBase:null,urlResolutionError:e instanceof Error?e.message:String(e)}}}function jz(e,t,n,r){let i=`Active webhooks:
3045
+ `,exitCode:1};let i=await Ey();if(!i)return Ez(`delete`);let a=b();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
3046
+ `,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 jz(e){if(e.hasLocalNodeServer())return null;if(!wz(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}")`)+`
3047
+ `,exitCode:1}}return null}function Mz(e,t){try{return Tz(e,wz(t.getLeaderStatus),t.hasLocalNodeServer)}catch(e){return`(URL resolution failed: ${e instanceof Error?e.message:String(e)})`}}function Nz(e){try{return{trayUrlBase:wz(e.getLeaderStatus),urlResolutionError:null}}catch(e){return{trayUrlBase:null,urlResolutionError:e instanceof Error?e.message:String(e)}}}function Pz(e,t,n,r){let i=`Active webhooks:
3043
3048
  `;for(let t of e)i+=` ${t.id} ${t.name.padEnd(20)} ${t.url}`,t.scoop&&(i+=` -> ${t.scoop}`),t.filter&&(i+=` [filtered]`),i+=`
3044
3049
  `;return n?i+=`\nNote: webhook URL resolution failed (${n}). Try again once the tray is connected.\n`:!r()&&!t&&(i+=`
3045
3050
  Note: webhook URLs require a leader tray. Configure one in Settings to expose POST endpoints.
3046
- `),i}function Mz(e={}){let t={hasLocalNodeServer:e.hasLocalNodeServer??(()=>!0),getLeaderStatus:e.getLeaderStatus??(()=>yz)};return C(`webhook`,async(e,n)=>{if(e.length===0)return bz();let r=e[0];if(T(e,{valueFlags:r===`create`?vz:void 0}))return bz();try{switch(r){case`create`:return await Tz(e,t,n.env);case`list`:return await Ez(e,t);case`delete`:return await Dz(e,t);case`rotate`:return await wz(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 Nz(){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 Pz(){return{stdout:`usage: websocat [FLAGS] [OPTIONS] <ws://URL | wss://URL>
3051
+ `),i}function Fz(e={}){let t={hasLocalNodeServer:e.hasLocalNodeServer??(()=>!0),getLeaderStatus:e.getLeaderStatus??(()=>Sz)};return C(`webhook`,async(e,n)=>{if(e.length===0)return Cz();let r=e[0];if(T(e,{valueFlags:r===`create`?xz:void 0}))return Cz();try{switch(r){case`create`:return await Oz(e,t,n.env);case`list`:return await kz(e,t);case`delete`:return await Az(e,t);case`rotate`:return await Dz(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 Iz(){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 Lz(){return{stdout:`usage: websocat [FLAGS] [OPTIONS] <ws://URL | wss://URL>
3047
3052
 
3048
3053
  Minimal websocat client. Sends stdin lines as WebSocket messages and prints
3049
3054
  received messages to stdout. Server mode and advanced specifiers (exec:, tcp:,
@@ -3085,14 +3090,14 @@ EXAMPLES:
3085
3090
  echo 'Page.navigate {"url":"https://example.com"}' \\
3086
3091
  | websocat -1 --jsonrpc --jsonrpc-omit-jsonrpc \\
3087
3092
  ws://127.0.0.1:9222/devtools/page/<id>
3088
- `,stderr:``,exitCode:0}}const Fz=/* @__PURE__ */ 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 Iz(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 Lz(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 Rz(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 zz(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 Bz(e,t){return t===`-v`?(e.verbose+=1,!0):t===`-vv`&&(e.verbose+=2,!0)}function Vz(e,t,n,r,i){let a=Iz(t,n,r,e);return a?(i(a.value),{nextIndex:a.next}):{stop:!0}}function Hz(e,t,n,r,i,a,o){let s=Iz(t,n,r,e);if(!s)return{stop:!0};let c=Lz(e,s.value,i,o);return c===null?{stop:!0}:(a(c),{nextIndex:s.next})}function Uz(e,t){return t.some(t=>e===t||e.startsWith(`${t}=`))}const Wz=[(e,t,n,r)=>{if(!Uz(r,[`--close-status-code`]))return null;let i=Iz(t,n,`--close-status-code`,e);if(!i)return{stop:!0};let a=Rz(e,i.value);return a===null?{stop:!0}:(e.closeStatus=a,{nextIndex:i.next})},(e,t,n,r)=>Uz(r,[`--close-reason`])?Vz(e,t,n,`--close-reason`,t=>{e.closeReason=t}):null,(e,t,n,r)=>Uz(r,[`-B`,`--buffer-size`])?Hz(e,t,n,r===`-B`?`-B`:`--buffer-size`,`--buffer-size`,t=>{e.bufferSize=t}):null,(e,t,n,r)=>Uz(r,[`--max-messages`])?Hz(e,t,n,`--max-messages`,`--max-messages`,t=>{e.maxMessages=t}):null,(e,t,n,r)=>Uz(r,[`--protocol`])?Vz(e,t,n,`--protocol`,t=>{e.protocol=t}):null,(e,t,n,r)=>{if(!Uz(r,[`--ping-interval`]))return null;let i=Iz(t,n,`--ping-interval`,e);return i?(e.pingInterval=Number(i.value),{nextIndex:i.next}):{stop:!0}},(e,t,n,r)=>Uz(r,[`--conn-timeout`])?Hz(e,t,n,`--conn-timeout`,`--conn-timeout`,t=>{e.connTimeoutMs=Math.round(t*1e3)},`positive seconds`):null,(e,t,n,r)=>Uz(r,[`-H`,`--header`])?Vz(e,t,n,r===`-H`?`-H`:`--header`,t=>{e.customHeaders.push(t)}):null];function Gz(e,t,n,r){for(let i of Wz){let a=i(e,t,n,r);if(a)return a}return null}function Kz(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)
3089
- `)}function qz(e){let t=Nz();for(let n=0;n<e.length;n+=1){let r=e[n];if(r===`-h`||r===`--help`)return t.showHelp=!0,t;if(Fz.has(r)||Fz.has(r.split(`=`)[0]))return t.error=`websocat: flag '${r}' is not supported in slicc's minimal client\n`,t;if(zz(t,r)||Bz(t,r))continue;let i=Gz(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 Kz(t),t}function Jz(e,t){if(!e)return[];let n=t?`\0`:`
3090
- `,r=e.split(n);return r.length>0&&r[r.length-1]===``&&r.pop(),r}function Yz(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 Xz(e){try{return new TextDecoder(`utf-8`,{fatal:!1}).decode(e)}catch{return t(e)}}function Zz(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 Qz=1e4;function $z(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function eB(){let e=!1,t=$z();return{...t,settle:n=>{e||(e=!0,t.resolve(n))}}}function tB(e,t){return e.length?e.join(t)+t:``}function nB(e){return e.length?e.join(`
3093
+ `,stderr:``,exitCode:0}}const Rz=/* @__PURE__ */ 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 Bz(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 Vz(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 Hz(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 Uz(e,t){return t===`-v`?(e.verbose+=1,!0):t===`-vv`&&(e.verbose+=2,!0)}function Wz(e,t,n,r,i){let a=zz(t,n,r,e);return a?(i(a.value),{nextIndex:a.next}):{stop:!0}}function Gz(e,t,n,r,i,a,o){let s=zz(t,n,r,e);if(!s)return{stop:!0};let c=Bz(e,s.value,i,o);return c===null?{stop:!0}:(a(c),{nextIndex:s.next})}function Kz(e,t){return t.some(t=>e===t||e.startsWith(`${t}=`))}const qz=[(e,t,n,r)=>{if(!Kz(r,[`--close-status-code`]))return null;let i=zz(t,n,`--close-status-code`,e);if(!i)return{stop:!0};let a=Vz(e,i.value);return a===null?{stop:!0}:(e.closeStatus=a,{nextIndex:i.next})},(e,t,n,r)=>Kz(r,[`--close-reason`])?Wz(e,t,n,`--close-reason`,t=>{e.closeReason=t}):null,(e,t,n,r)=>Kz(r,[`-B`,`--buffer-size`])?Gz(e,t,n,r===`-B`?`-B`:`--buffer-size`,`--buffer-size`,t=>{e.bufferSize=t}):null,(e,t,n,r)=>Kz(r,[`--max-messages`])?Gz(e,t,n,`--max-messages`,`--max-messages`,t=>{e.maxMessages=t}):null,(e,t,n,r)=>Kz(r,[`--protocol`])?Wz(e,t,n,`--protocol`,t=>{e.protocol=t}):null,(e,t,n,r)=>{if(!Kz(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)=>Kz(r,[`--conn-timeout`])?Gz(e,t,n,`--conn-timeout`,`--conn-timeout`,t=>{e.connTimeoutMs=Math.round(t*1e3)},`positive seconds`):null,(e,t,n,r)=>Kz(r,[`-H`,`--header`])?Wz(e,t,n,r===`-H`?`-H`:`--header`,t=>{e.customHeaders.push(t)}):null];function Jz(e,t,n,r){for(let i of qz){let a=i(e,t,n,r);if(a)return a}return null}function Yz(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)
3094
+ `)}function Xz(e){let t=Iz();for(let n=0;n<e.length;n+=1){let r=e[n];if(r===`-h`||r===`--help`)return t.showHelp=!0,t;if(Rz.has(r)||Rz.has(r.split(`=`)[0]))return t.error=`websocat: flag '${r}' is not supported in slicc's minimal client\n`,t;if(Hz(t,r)||Uz(t,r))continue;let i=Jz(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 Yz(t),t}function Zz(e,t){if(!e)return[];let n=t?`\0`:`
3095
+ `,r=e.split(n);return r.length>0&&r[r.length-1]===``&&r.pop(),r}function Qz(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 $z(e){try{return new TextDecoder(`utf-8`,{fatal:!1}).decode(e)}catch{return t(e)}}function eB(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 tB=1e4;function nB(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function rB(){let e=!1,t=nB();return{...t,settle:n=>{e||(e=!0,t.resolve(n))}}}function iB(e,t){return e.length?e.join(t)+t:``}function aB(e){return e.length?e.join(`
3091
3096
  `)+`
3092
- `:``}function rB(e,t,n){e.quiet||t.push(`websocat: ${n}`)}function iB(e,t){e.verbose<1||(e.customHeaders.length>0&&rB(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&&rB(e,t,`--ping-interval has no effect in browsers (no ping API exposed)`),e.insecure&&rB(e,t,`-k/--insecure has no effect in browsers`))}function aB(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 oB(e,t,n,r){if(n.outLines.length<Qz){n.outLines.push(r);return}n.droppedForOverflow===0&&rB(e,t,`output buffer reached ${Qz} 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}=Zz(r);return i.length>e.bufferSize&&(rB(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):Xz(i)}function cB(e,t){return e.maxMessages!==void 0&&t>=e.maxMessages||e.oneMessage}function lB(e,t,n){try{n===void 0?e.close(t):e.close(t,n)}catch{}}function uB(e,t){setTimeout(()=>{lB(t,e.closeStatus??1e3,e.closeReason)},0)}function dB(e,t,n){let r=Jz(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=Yz(n,i,t.jsonrpcOmit),i+=1),t.binary?e.send(new TextEncoder().encode(r).buffer):e.send(r),a+=1}return a}function fB(e,t,n){!t.oneMessage&&!t.noClose&&(t.exitOnEof||n===0)&&uB(t,e)}async function pB(e,t,n){let r=[];iB(e,r);let i=e.nullTerminated?`\0`:`
3093
- `,a=aB(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=$z(),u=eB(),d=0,f=!1,p=setTimeout(()=>{f=!0,lB(o,1e3),c||l.reject(/* @__PURE__ */ Error(`connect timeout`))},e.connTimeoutMs),m=()=>{if(e.noClose){u.settle(d);return}lB(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);oB(e,r,s,n)}s.received+=1,cB(e,s.received)&&(s.finishing=!0,m())}},o.onerror=()=>{f||(rB(e,r,`websocket error`),d=1,c||l.reject(/* @__PURE__ */ Error(`connect failed`)))},o.onclose=t=>{if(clearTimeout(p),f){u.settle(124);return}e.verbose>=1&&rB(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(/* @__PURE__ */ 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:tB(s.outLines,i),stderr:nB(r.concat([`websocat: ${t}`])),exitCode:t===`connect timeout`?124:1}}e.unidirectionalReverse?!e.noClose&&e.exitOnEof&&!e.oneMessage&&uB(e,o):fB(o,e,dB(o,e,t));let h=await u.promise;return s.droppedForOverflow>0&&rB(e,r,`dropped ${s.droppedForOverflow} inbound message(s) due to output buffer cap`),{stdout:tB(s.outLines,i),stderr:nB(r),exitCode:h}}function mB(e){return{stdout:``,stderr:e,exitCode:2}}function hB(e){return e.WebSocketCtor??(typeof WebSocket<`u`?WebSocket:void 0)}async function gB(e,t,n={}){let r=qz(e);if(r.showHelp)return Pz();if(r.error)return mB(r.error);if(!r.url)return mB(`websocat: missing ws:// or wss:// URL (use --help for usage)
3094
- `);if(!/^wss?:\/\//i.test(r.url))return mB(`websocat: URL must start with ws:// or wss://, got '${r.url}'\n`);let i=hB(n);return i?pB(r,t.stdin,i):{stdout:``,stderr:`websocat: no WebSocket implementation available in this runtime
3095
- `,exitCode:1}}function _B(){return C(`websocat`,async(e,t)=>gB(e,{stdin:P(t.stdin)}))}function vB(){return C(`__wf_progress`,async()=>({stdout:``,stderr:``,exitCode:0}))}const yB={commands:/* @__PURE__ */ new Map,collisions:[]};async function bB(e,t){let n=xr(t);return e.scriptCatalog?e.scriptCatalog.getJshIndex(n):e.fs?wr(e.fs,n):yB}async function xB(e){return e.scriptCatalog?e.scriptCatalog.getWorkflowCommands():e.fs?ji(e.fs):/* @__PURE__ */ new Map}async function SB(e){return e.scriptCatalog?e.scriptCatalog.getWasmCommands():/* @__PURE__ */ new Map}function CB(e,t){let n=e.script?`script`:`wasm`;return`${e.glue} (${n}, ${e.pkg}${t?`, ${t}`:``})`}function wB(e,{jshPath:t,collision:n,wasm:r,wf:i}){let a=[`/usr/bin/${e}`];if((t||r||i)&&a.push(` (shadowed by built-in ${e})`),r&&a.push(` (shadowed ${CB(r)})`),t){let e=n?[t,...n.shadowedPaths]:[t];for(let t of e)a.push(` (shadowed ${t})`)}return a}function TB(e,{collision:t,wasm:n,wf:r}){let i=[e];for(let e of t?.shadowedPaths??[])i.push(` (shadowed ${e})`);return n&&i.push(` ${CB(n,`shadowed by .jsh`)}`),r&&i.push(` ${r.path} (workflow, shadowed by .jsh)`),i}function EB(e,t,n,r,i){let{jshPath:a,wasm:o,wf:s}=t;if(n.has(e))return{lines:wB(e,t),found:!0};if(a)return{lines:TB(a,t),found:!0};if(o){let e=[CB(o)];return s&&e.push(` ${s.path} (workflow, shadowed by wasm)`),{lines:e,found:!0}}return s?{lines:[`${s.path} (workflow)`],found:!0}:r.has(e)&&!i.has(e)?{lines:[`/usr/bin/${e}`],found:!0}:{lines:[],found:!1}}function DB(e={}){let t=e.scriptCatalog!==void 0||e.fs!==void 0?e:typeof e.walk==`function`&&typeof e.exists==`function`?{fs:e}:{};return C(`which`,async(e,n)=>{if(T(e))return{stdout:`which - locate a command
3097
+ `:``}function oB(e,t,n){e.quiet||t.push(`websocat: ${n}`)}function sB(e,t){e.verbose<1||(e.customHeaders.length>0&&oB(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&&oB(e,t,`--ping-interval has no effect in browsers (no ping API exposed)`),e.insecure&&oB(e,t,`-k/--insecure has no effect in browsers`))}function cB(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 lB(e,t,n,r){if(n.outLines.length<tB){n.outLines.push(r);return}n.droppedForOverflow===0&&oB(e,t,`output buffer reached ${tB} 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 uB(e,n,r){let{bytes:i,isBinary:a}=eB(r);return i.length>e.bufferSize&&(oB(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):$z(i)}function dB(e,t){return e.maxMessages!==void 0&&t>=e.maxMessages||e.oneMessage}function fB(e,t,n){try{n===void 0?e.close(t):e.close(t,n)}catch{}}function pB(e,t){setTimeout(()=>{fB(t,e.closeStatus??1e3,e.closeReason)},0)}function mB(e,t,n){let r=Zz(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=Qz(n,i,t.jsonrpcOmit),i+=1),t.binary?e.send(new TextEncoder().encode(r).buffer):e.send(r),a+=1}return a}function hB(e,t,n){!t.oneMessage&&!t.noClose&&(t.exitOnEof||n===0)&&pB(t,e)}async function gB(e,t,n){let r=[];sB(e,r);let i=e.nullTerminated?`\0`:`
3098
+ `,a=cB(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=nB(),u=rB(),d=0,f=!1,p=setTimeout(()=>{f=!0,fB(o,1e3),c||l.reject(/* @__PURE__ */ Error(`connect timeout`))},e.connTimeoutMs),m=()=>{if(e.noClose){u.settle(d);return}fB(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=uB(e,r,t.data);lB(e,r,s,n)}s.received+=1,dB(e,s.received)&&(s.finishing=!0,m())}},o.onerror=()=>{f||(oB(e,r,`websocket error`),d=1,c||l.reject(/* @__PURE__ */ Error(`connect failed`)))},o.onclose=t=>{if(clearTimeout(p),f){u.settle(124);return}e.verbose>=1&&oB(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(/* @__PURE__ */ 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:iB(s.outLines,i),stderr:aB(r.concat([`websocat: ${t}`])),exitCode:t===`connect timeout`?124:1}}e.unidirectionalReverse?!e.noClose&&e.exitOnEof&&!e.oneMessage&&pB(e,o):hB(o,e,mB(o,e,t));let h=await u.promise;return s.droppedForOverflow>0&&oB(e,r,`dropped ${s.droppedForOverflow} inbound message(s) due to output buffer cap`),{stdout:iB(s.outLines,i),stderr:aB(r),exitCode:h}}function _B(e){return{stdout:``,stderr:e,exitCode:2}}function vB(e){return e.WebSocketCtor??(typeof WebSocket<`u`?WebSocket:void 0)}async function yB(e,t,n={}){let r=Xz(e);if(r.showHelp)return Lz();if(r.error)return _B(r.error);if(!r.url)return _B(`websocat: missing ws:// or wss:// URL (use --help for usage)
3099
+ `);if(!/^wss?:\/\//i.test(r.url))return _B(`websocat: URL must start with ws:// or wss://, got '${r.url}'\n`);let i=vB(n);return i?gB(r,t.stdin,i):{stdout:``,stderr:`websocat: no WebSocket implementation available in this runtime
3100
+ `,exitCode:1}}function bB(){return C(`websocat`,async(e,t)=>yB(e,{stdin:P(t.stdin)}))}function xB(){return C(`__wf_progress`,async()=>({stdout:``,stderr:``,exitCode:0}))}const SB={commands:/* @__PURE__ */ new Map,collisions:[]};async function CB(e,t){let n=xr(t);return e.scriptCatalog?e.scriptCatalog.getJshIndex(n):e.fs?wr(e.fs,n):SB}async function wB(e){return e.scriptCatalog?e.scriptCatalog.getWorkflowCommands():e.fs?ji(e.fs):/* @__PURE__ */ new Map}async function TB(e){return e.scriptCatalog?e.scriptCatalog.getWasmCommands():/* @__PURE__ */ new Map}function EB(e,t){let n=e.script?`script`:`wasm`;return`${e.glue} (${n}, ${e.pkg}${t?`, ${t}`:``})`}function DB(e,{jshPath:t,collision:n,wasm:r,wf:i}){let a=[`/usr/bin/${e}`];if((t||r||i)&&a.push(` (shadowed by built-in ${e})`),r&&a.push(` (shadowed ${EB(r)})`),t){let e=n?[t,...n.shadowedPaths]:[t];for(let t of e)a.push(` (shadowed ${t})`)}return a}function OB(e,{collision:t,wasm:n,wf:r}){let i=[e];for(let e of t?.shadowedPaths??[])i.push(` (shadowed ${e})`);return n&&i.push(` ${EB(n,`shadowed by .jsh`)}`),r&&i.push(` ${r.path} (workflow, shadowed by .jsh)`),i}function kB(e,t,n,r,i){let{jshPath:a,wasm:o,wf:s}=t;if(n.has(e))return{lines:DB(e,t),found:!0};if(a)return{lines:OB(a,t),found:!0};if(o){let e=[EB(o)];return s&&e.push(` ${s.path} (workflow, shadowed by wasm)`),{lines:e,found:!0}}return s?{lines:[`${s.path} (workflow)`],found:!0}:r.has(e)&&!i.has(e)?{lines:[`/usr/bin/${e}`],found:!0}:{lines:[],found:!1}}function AB(e={}){let t=e.scriptCatalog!==void 0||e.fs!==void 0?e:typeof e.walk==`function`&&typeof e.exists==`function`?{fs:e}:{};return C(`which`,async(e,n)=>{if(T(e))return{stdout:`which - locate a command
3096
3101
 
3097
3102
  Usage: which <command> [command...]
3098
3103
 
@@ -3104,9 +3109,9 @@ Prints the path of the given command(s).
3104
3109
 
3105
3110
  Exit code 0 if all commands found, 1 if any not found.
3106
3111
  `,stderr:``,exitCode:0};let r=w(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
3107
- `,exitCode:1};let i=n.getRegisteredCommands?.()??[],a=new Set(i),o=await bB(t,n.env.get(`PATH`)),s=o.commands,c=new Map(o.collisions.map(e=>[e.name,e])),l=await xB(t),u=await SB(t),d=typeof t.getStaticBuiltins==`function`?new Set(t.getStaticBuiltins()):a,f=new Set(t.getScriptRegisteredNames?.()??[]),p=[],m=!0;for(let e of r.positionals){let t=EB(e,{jshPath:s.get(e),collision:c.get(e),wasm:u.get(e),wf:l.get(e)},d,a,f);p.push(...t.lines),t.found||(m=!1)}return{stdout:p.length>0?p.join(`
3112
+ `,exitCode:1};let i=n.getRegisteredCommands?.()??[],a=new Set(i),o=await CB(t,n.env.get(`PATH`)),s=o.commands,c=new Map(o.collisions.map(e=>[e.name,e])),l=await wB(t),u=await TB(t),d=typeof t.getStaticBuiltins==`function`?new Set(t.getStaticBuiltins()):a,f=new Set(t.getScriptRegisteredNames?.()??[]),p=[],m=!0;for(let e of r.positionals){let t=kB(e,{jshPath:s.get(e),collision:c.get(e),wasm:u.get(e),wf:l.get(e)},d,a,f);p.push(...t.lines),t.found||(m=!1)}return{stdout:p.length>0?p.join(`
3108
3113
  `)+`
3109
- `:``,stderr:``,exitCode:+!m}})}const OB=`__slicc_workflows`,kB=String.raw`
3114
+ `:``,stderr:``,exitCode:+!m}})}const jB=`__slicc_workflows`,MB=String.raw`
3110
3115
  class WorkflowError extends Error {}
3111
3116
  class WorkflowDeterminismError extends WorkflowError {}
3112
3117
  class WorkflowAgentCapError extends WorkflowError {}
@@ -3225,40 +3230,40 @@ function log(message) {
3225
3230
  }
3226
3231
  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()); } };
3227
3232
  function workflow() { throw new WorkflowNestingUnsupportedError('nested workflow() unsupported in SP1'); }
3228
- `;function AB(){return`WF_RESULT_${globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`}`}function jB(e){let t=FB(e);return t===null?{name:null,description:null}:{name:IB(t,`name`),description:IB(t,`description`)}}function MB(e){return e.replace(/\bexport\s+(const|let|var|function|async\s+function|class)\b/g,`$1`)}function NB(e){return`const __emit = console.log.bind(console);
3233
+ `;function NB(){return`WF_RESULT_${globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`}`}function PB(e){let t=RB(e);return t===null?{name:null,description:null}:{name:zB(t,`name`),description:zB(t,`description`)}}function FB(e){return e.replace(/\bexport\s+(const|let|var|function|async\s+function|class)\b/g,`$1`)}function IB(e){return`const __emit = console.log.bind(console);
3229
3234
  const __stringify = JSON.stringify.bind(JSON);
3230
- const __WF = ${JSON.stringify(e.config)};\n${e.prelude}\nconst __r = await (async () => {\n${MB(e.body)}\n})();\n__emit(${JSON.stringify(e.sentinel)} + __stringify(__r ?? null));\n`}function PB(e,t){let n=e.split(`
3235
+ const __WF = ${JSON.stringify(e.config)};\n${e.prelude}\nconst __r = await (async () => {\n${FB(e.body)}\n})();\n__emit(${JSON.stringify(e.sentinel)} + __stringify(__r ?? null));\n`}function LB(e,t){let n=e.split(`
3231
3236
  `);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(`
3232
- `).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 FB(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 IB(e,t){let n=RegExp(`\\b${t}\\s*:\\s*(['"\\\`])((?:\\\\.|(?!\\1).)*)\\1`).exec(e);return n?n[2]:null}const LB=e(`workflow-command`),RB=`usage: workflow run <file.js> [--args <json>] [--budget <n>] [--concurrency <n>] [--wait]
3237
+ `).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 RB(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 zB(e,t){let n=RegExp(`\\b${t}\\s*:\\s*(['"\\\`])((?:\\\\.|(?!\\1).)*)\\1`).exec(e);return n?n[2]:null}const BB=e(`workflow-command`),VB=`usage: workflow run <file.js> [--args <json>] [--budget <n>] [--concurrency <n>] [--wait]
3233
3238
  workflow run --script '<inline js>' [...]
3234
3239
  workflow list
3235
3240
  workflow status <runId>
3236
3241
  workflow stop <runId>
3237
3242
  workflow save <runId> <name> [--force]
3238
3243
  Runs a Claude-Code-format dynamic workflow. Default is non-blocking (returns a run id);
3239
- pass --wait to block and print the full result.`,zB=/* @__PURE__ */ new Set([`list`,`status`,`stop`,`save`]);function BB(){return globalThis[OB]}function VB(){let e=globalThis.navigator?.hardwareConcurrency??8;return Math.min(16,Math.max(8,e*4))}function HB(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 UB(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=VB(),n={budget:null,cap:Math.min(8,t)};for(let r=1;r<e.length;r++){let i=HB(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 WB(e={}){return C(`workflow`,async(t,n)=>{if(zB.has(t[0])&&T(t.slice(1)))return{stdout:RB+`
3240
- `,stderr:``,exitCode:0};if(t[0]===`list`||t[0]===`status`||t[0]===`stop`)return XB(t,n);if(t[0]===`save`)return YB(t,n,e);let r=UB(t);if(r.help)return{stdout:RB+`
3244
+ pass --wait to block and print the full result.`,HB=/* @__PURE__ */ new Set([`list`,`status`,`stop`,`save`]);function UB(){return globalThis[jB]}function WB(){let e=globalThis.navigator?.hardwareConcurrency??8;return Math.min(16,Math.max(8,e*4))}function GB(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 KB(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=WB(),n={budget:null,cap:Math.min(8,t)};for(let r=1;r<e.length;r++){let i=GB(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 qB(e={}){return C(`workflow`,async(t,n)=>{if(HB.has(t[0])&&T(t.slice(1)))return{stdout:VB+`
3245
+ `,stderr:``,exitCode:0};if(t[0]===`list`||t[0]===`status`||t[0]===`stop`)return $B(t,n);if(t[0]===`save`)return QB(t,n,e);let r=KB(t);if(r.help)return{stdout:VB+`
3241
3246
  `,stderr:``,exitCode:0};if(r.error)return{stdout:``,stderr:r.error+`
3242
- `,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=jB(i);if(!o.name)return{stdout:``,stderr:`workflow: script must define a meta block with a name (description optional)
3243
- `,exitCode:1};let s=AB().slice(10,22),c=`/shared/workflow-runs/${s}/scratch/`;await n.fs.mkdir(c,{recursive:!0});let l=AB(),u=NB({prelude:kB,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?GB(u,a,l,o,n):KB({code:u,source:i,name:o.name,filename:a,sentinel:l,runId:s,ctx:n,options:e})})}async function GB(e,t,n,r,i){let a;try{a=await yi(e,[`workflow`,t],i,void 0,{filename:t})}catch(e){return LB.error(`workflow run failed`,e),{stdout:``,stderr:`workflow: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}return ZB(r,a,n)}async function KB(e){let t=BB();if(!t)return{stdout:``,stderr:`workflow: run manager not available
3244
- `,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 qB=/^[a-z0-9][a-z0-9-]*$/,JB=`/workspace/.workflows`;async function YB(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]
3245
- `,exitCode:1};if(!qB.test(o))return{stdout:``,stderr:`workflow: invalid name '${o}' (use [a-z0-9][a-z0-9-]*)\n`,exitCode:1};let c=BB()?.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=`${JB}/${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(JB,{recursive:!0}),await t.fs.writeFile(l,c.source);try{await n.syncScriptCommands?.()}catch(e){LB.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 XB(e,t){let n=BB();if(e[0]===`list`){if(!n)return{stdout:``,stderr:`workflow: run manager not available
3247
+ `,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=PB(i);if(!o.name)return{stdout:``,stderr:`workflow: script must define a meta block with a name (description optional)
3248
+ `,exitCode:1};let s=NB().slice(10,22),c=`/shared/workflow-runs/${s}/scratch/`;await n.fs.mkdir(c,{recursive:!0});let l=NB(),u=IB({prelude:MB,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?JB(u,a,l,o,n):YB({code:u,source:i,name:o.name,filename:a,sentinel:l,runId:s,ctx:n,options:e})})}async function JB(e,t,n,r,i){let a;try{a=await yi(e,[`workflow`,t],i,void 0,{filename:t})}catch(e){return BB.error(`workflow run failed`,e),{stdout:``,stderr:`workflow: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}return eV(r,a,n)}async function YB(e){let t=UB();if(!t)return{stdout:``,stderr:`workflow: run manager not available
3249
+ `,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 XB=/^[a-z0-9][a-z0-9-]*$/,ZB=`/workspace/.workflows`;async function QB(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]
3250
+ `,exitCode:1};if(!XB.test(o))return{stdout:``,stderr:`workflow: invalid name '${o}' (use [a-z0-9][a-z0-9-]*)\n`,exitCode:1};let c=UB()?.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=`${ZB}/${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(ZB,{recursive:!0}),await t.fs.writeFile(l,c.source);try{await n.syncScriptCommands?.()}catch(e){BB.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 $B(e,t){let n=UB();if(e[0]===`list`){if(!n)return{stdout:``,stderr:`workflow: run manager not available
3246
3251
  `,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(`
3247
3252
  `):`(no runs)`)+`
3248
3253
  `,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(`
3249
3254
  `)+`
3250
- `,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 ZB(e,t,n){let{result:r,log:i,hadResult:a}=PB(t.stdout,n),o=e.name?`workflow: ${e.name}${e.description?` — `+e.description:``}\n`:``,s=i?QB(i)+`
3255
+ `,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 eV(e,t,n){let{result:r,log:i,hadResult:a}=LB(t.stdout,n),o=e.name?`workflow: ${e.name}${e.description?` — `+e.description:``}\n`:``,s=i?tV(i)+`
3251
3256
  `:``;return t.exitCode!==0||!a?{stdout:o+s,stderr:t.stderr||(a?``:`workflow: script produced no result
3252
3257
  `),exitCode:t.exitCode||1}:{stdout:o+s+(typeof r==`string`?r:JSON.stringify(r))+`
3253
- `,stderr:t.stderr,exitCode:0}}function QB(e){return e.split(`
3258
+ `,stderr:t.stderr,exitCode:0}}function tV(e){return e.split(`
3254
3259
  `).map(e=>e.replace(/^WFPHASE/,`▸ `).replace(/^WFLOG/,`· `)).join(`
3255
- `)}function $B(e){return{stdout:``,stderr:`xxd: ${e}\n`,exitCode:1}}function eV(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 tV(e,t){let n=e.toString(16).padStart(2,`0`);return t?n.toUpperCase():n}function nV(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t}function rV(e){return e.replace(/[^0-9a-zA-Z]/g,`_`)}function iV(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?tV(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(`
3260
+ `)}function nV(e){return{stdout:``,stderr:`xxd: ${e}\n`,exitCode:1}}function rV(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 iV(e,t){let n=e.toString(16).padStart(2,`0`);return t?n.toUpperCase():n}function aV(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t}function oV(e){return e.replace(/[^0-9a-zA-Z]/g,`_`)}function sV(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?iV(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(`
3256
3261
  `)+`
3257
- `:``}function aV(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+=tV(e[i+r],n);r+=a+`
3258
- `}return r}function oV(e,t,n,r){let i=Array.from(e,e=>`0x${tV(e,n)}`),a=[];for(let e=0;e<i.length;e+=t)a.push(` `+i.slice(e,e+t).join(`, `));let o=a.join(`,
3262
+ `:``}function cV(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+=iV(e[i+r],n);r+=a+`
3263
+ `}return r}function lV(e,t,n,r){let i=Array.from(e,e=>`0x${iV(e,n)}`),a=[];for(let e=0;e<i.length;e+=t)a.push(` `+i.slice(e,e+t).join(`, `));let o=a.join(`,
3259
3264
  `);return r===null?i.length?o+`
3260
- `:``:`unsigned char ${r}[] = {\n${o}\n};\nunsigned int ${r}_len = ${e.length};\n`}function sV(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 cV(e){let t=[],n=0;for(let r of e.split(`
3261
- `)){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/* @__PURE__ */ 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 lV={"-u":`upper`,"-p":`plain`,"-ps":`plain`,"-postscript":`plain`,"-i":`include`,"-include":`include`,"-r":`revert`,"-revert":`revert`},uV=[{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 dV(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=lV[r];if(i){t[i]=!0;continue}let a=uV.find(e=>e.exact.includes(r)||e.attached.test(r));if(a){t[a.key]=eV(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 fV(e){return e.includes(`-h`)||e.includes(`--help`)||e.includes(`-help`)}async function pV(e,t,n){if(!n&&t)return e.fs.readFileBuffer(e.fs.resolvePath(e.cwd,t));let r=lr(e.stdin),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e)&255;return i}function mV(e,t,n,r,i){let a=e.cols&&e.cols>0?e.cols:e.plain?30:e.include?12:16;return e.plain?aV(t,a,e.upper):e.include?oV(t,a,e.upper,i?null:rV(r??``)):iV(t,a,e.group!=null&&e.group>=0?e.group:2,e.upper,n)}function hV(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 gV(){return C(`xxd`,async(e,t)=>{if(fV(e))return{stdout:`usage: xxd [options] [infile [outfile]]
3265
+ `:``:`unsigned char ${r}[] = {\n${o}\n};\nunsigned int ${r}_len = ${e.length};\n`}function uV(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 dV(e){let t=[],n=0;for(let r of e.split(`
3266
+ `)){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/* @__PURE__ */ 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 fV={"-u":`upper`,"-p":`plain`,"-ps":`plain`,"-postscript":`plain`,"-i":`include`,"-include":`include`,"-r":`revert`,"-revert":`revert`},pV=[{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 mV(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=fV[r];if(i){t[i]=!0;continue}let a=pV.find(e=>e.exact.includes(r)||e.attached.test(r));if(a){t[a.key]=rV(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 hV(e){return e.includes(`-h`)||e.includes(`--help`)||e.includes(`-help`)}async function gV(e,t,n){if(!n&&t)return e.fs.readFileBuffer(e.fs.resolvePath(e.cwd,t));let r=lr(e.stdin),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e)&255;return i}function _V(e,t,n,r,i){let a=e.cols&&e.cols>0?e.cols:e.plain?30:e.include?12:16;return e.plain?cV(t,a,e.upper):e.include?lV(t,a,e.upper,i?null:oV(r??``)):sV(t,a,e.group!=null&&e.group>=0?e.group:2,e.upper,n)}function vV(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 yV(){return C(`xxd`,async(e,t)=>{if(hV(e))return{stdout:`usage: xxd [options] [infile [outfile]]
3262
3267
  -c cols number of octets per line (default 16; 30 for -p; 12 for -i)
3263
3268
  -g bytes number of octets per group (default 2; 0 disables grouping)
3264
3269
  -l len stop after len octets
@@ -3268,9 +3273,9 @@ pass --wait to block and print the full result.`,zB=/* @__PURE__ */ new Set([`li
3268
3273
  -i output in C include style
3269
3274
  -r reverse: convert a hex dump back to binary (-r -p for plain)
3270
3275
  -h show this help
3271
- `,stderr:``,exitCode:0};let n;try{n=dV(e)}catch(e){return $B(e.message)}let r=n.positional[0],i=n.positional[1],a=!r||r===`-`,o;try{o=await pV(t,r,a)}catch{return $B(`${r}: No such file or directory`)}if(n.revert){let e=nV(o),r=n.plain?sV(e):cV(e);return i?(await t.fs.writeFile(t.fs.resolvePath(t.cwd,i),r),{stdout:``,stderr:``,exitCode:0}):{stdout:nV(r),stderr:``,exitCode:0}}let{data:s,base:c}=hV(n,o),l=mV(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 _V(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=Mr(t,o),s=n?`${n}/${o}`:o;a+=await _V(e,i,s,r)}return a}function vV(){return{stdout:`usage: zip [-r] <archive.zip> <path> [path...]
3272
- `,stderr:``,exitCode:0}}function yV(){return C(`zip`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return vV();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
3273
- `,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(/^\.\//,``))||Nr(r);if(i.isDirectory&&!n)return{stdout:``,stderr:`zip: ${e} is a directory (use -r)\n`,exitCode:1};s+=await _V(t,r,a,o)}if(s===0)return{stdout:``,stderr:`zip: nothing to do
3274
- `,exitCode:1};let c=Rt(o);return await t.fs.writeFile(i,c),{stdout:`created ${i} (${s} file(s))\n`,stderr:``,exitCode:0}})}function bV(e){let t;return C(`mcp`,async(n,r)=>{if(!t){let{createMcpCommand:n}=await import(`./mcp-command-Ck-K7dGv.js`);t=n({fs:e.fs,scriptCatalog:e.scriptCatalog,connectionManager:e.mcpConnectionManager})}return t.execute(n,r)})}function xV(e){return{setEnv:e.setEnv,unsetEnv:e.unsetEnv,broker:e.sudoCommand?.broker}}function SV(e){let{fs:t,fetch:n}=e;if(!t||!n)return[];let r={fs:t,fetch:n,scriptCatalog:e.scriptCatalog,syncScriptCommands:e.syncScriptCommands};return[MO(`ipk`,r),MO(`npm`,r),MO(`i`,r),xk(`ipx`,{fs:t,fetch:n}),xk(`npx`,{fs:t,fetch:n}),wb(`di`,{fs:t,fetch:n}),wb(`uv`,{fs:t,fetch:n}),KL({fs:t,fetch:n})]}function CV(e){let t={buildProcessConfig:e.buildProcessConfig};return[`python3`,`python`,`pyodide`].map(e=>tN(e,t))}function wV(e){let t=e.scriptCatalog;return{buildProcessConfig:e.buildProcessConfig,terminal:e.terminal,gate:e.gateNativeCommand,commands:t&&(()=>t.getWasmCommands()),gitIdentity:e.gitIdentity}}function TV(){return[ZP(),IS()]}function EV(e={}){let t=[LE({getJshCommands:e.getJshCommands,getWorkflowCommands:e.getWorkflowCommands}),oe(),NF(),QP(),GP(e.browserAPI,e.fs),zj(e.browserAPI),zy(e.browserAPI),HD(e),yV(),SL(),mI(e.fs?{fs:e.fs}:{}),BF(),qF(),WF(),Pv(),_z(wV(e)),lC(wV(e)),gV(),DF(`sqlite3`),DF(`sqllite`),jI(),ZI(),Bx(),gv(),nj({buildProcessConfig:e.buildProcessConfig}),nj({buildProcessConfig:e.buildProcessConfig},`jsh`),...CV(e),...SV(e),...e.fs?[cC({fs:e.fs})]:[],...e.fs?[mA({fs:e.fs})]:[],...e.fetch?[JE({fetch:e.fetch,streamFetch:e.streamFetch})]:[],LS(),RS(),XS(),Mz(e.webhook),_B(),Ry(e.crontask),bV(e),aM({fs:e.fs,fetch:e.fetch}),sC(),vF(),Bj(),Vj(`pdftk`),Vj(`pdf`),_v(`biscotto`,{getParentJid:e.getParentJid,isScoop:e.isScoop}),_v(`biscotti`,{getParentJid:e.getParentJid,isScoop:e.isScoop}),Zj(`pdftoppm`),Zj(`pdftocairo`),Qj(`pdftotext`),Sy(`convert`),Sy(`magick`),DB({fs:e.fs,scriptCatalog:e.scriptCatalog,getStaticBuiltins:e.getStaticBuiltins,getScriptRegisteredNames:e.getScriptRegisteredNames}),tL(),_L(),RD(),zD(),vL(),hA(),aN(),sA(),dx(),_j(),gj(),iA(),gP(xV(e)),Zp(e.gitCredential),vN({fs:e.fs}),WN(),jv(),Mv(),Nv(`xclip`),Nv(`xsel`),UN(),TC(),c_(),l_(),HA(e.fs),_t(),sj(),u_({getParentJid:e.getParentJid}),yx(),DM({processManager:e.processManager}),sR({processManager:e.processManager}),wk({processManager:e.processManager}),Sk({processManager:e.processManager,scriptCatalog:e.scriptCatalog}),...f_(),pA(),Xk(),MR(),bD(),xS(),JR({processManager:e.processManager}),Lv({processManager:e.processManager,browser:e.browserAPI,sudoBroker:e.sudoCommand?.broker}),MS(),wv({registry:e.cherryRuntimeRegistry}),Jy(),eb({fs:e.fs}),tb({fs:e.fs}),FF(e.sudoCommand),WB({getParentJid:e.getParentJid,syncScriptCommands:e.syncScriptCommands}),vB(),...TV()];return e.fs&&(eM(),t.push(...er.map(t=>PE(t,e.browserAPI,e.fs,{isScoop:e.isScoop})))),t}let DV=null;function OV(e){DV=e}function kV(e){DV?.(e)}var AV=Yt();const jV={user:`user`,home:_r},MV=/* @__PURE__ */ new Set([`root`,`nobody`,`nogroup`]),NV=/^[A-Za-z_][A-Za-z0-9_.-]*$/;function PV(e){return{user:NV.test(e.user)&&!MV.has(e.user)?e.user:jV.user,home:e.home.startsWith(`/`)&&!/[:\n]/.test(e.home)?e.home:jV.home}}function FV(e,t){let{user:n,home:r}=PV(t);if(e===`/etc/passwd`)return[`root:x:0:0:root:/root:/bin/bash`,`${n}:x:1000:1000:SLICC user:${r}:/bin/bash`,`nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin`,``].join(`
3276
+ `,stderr:``,exitCode:0};let n;try{n=mV(e)}catch(e){return nV(e.message)}let r=n.positional[0],i=n.positional[1],a=!r||r===`-`,o;try{o=await gV(t,r,a)}catch{return nV(`${r}: No such file or directory`)}if(n.revert){let e=aV(o),r=n.plain?uV(e):dV(e);return i?(await t.fs.writeFile(t.fs.resolvePath(t.cwd,i),r),{stdout:``,stderr:``,exitCode:0}):{stdout:aV(r),stderr:``,exitCode:0}}let{data:s,base:c}=vV(n,o),l=_V(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 bV(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=Mr(t,o),s=n?`${n}/${o}`:o;a+=await bV(e,i,s,r)}return a}function xV(){return{stdout:`usage: zip [-r] <archive.zip> <path> [path...]
3277
+ `,stderr:``,exitCode:0}}function SV(){return C(`zip`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return xV();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
3278
+ `,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(/^\.\//,``))||Nr(r);if(i.isDirectory&&!n)return{stdout:``,stderr:`zip: ${e} is a directory (use -r)\n`,exitCode:1};s+=await bV(t,r,a,o)}if(s===0)return{stdout:``,stderr:`zip: nothing to do
3279
+ `,exitCode:1};let c=Rt(o);return await t.fs.writeFile(i,c),{stdout:`created ${i} (${s} file(s))\n`,stderr:``,exitCode:0}})}function CV(e){let t;return C(`mcp`,async(n,r)=>{if(!t){let{createMcpCommand:n}=await import(`./mcp-command-n1wIw393.js`);t=n({fs:e.fs,scriptCatalog:e.scriptCatalog,connectionManager:e.mcpConnectionManager})}return t.execute(n,r)})}function wV(e){return{setEnv:e.setEnv,unsetEnv:e.unsetEnv,broker:e.sudoCommand?.broker}}function TV(e){let{fs:t,fetch:n}=e;if(!t||!n)return[];let r={fs:t,fetch:n,scriptCatalog:e.scriptCatalog,syncScriptCommands:e.syncScriptCommands};return[MO(`ipk`,r),MO(`npm`,r),MO(`i`,r),xk(`ipx`,{fs:t,fetch:n}),xk(`npx`,{fs:t,fetch:n}),wb(`di`,{fs:t,fetch:n}),wb(`uv`,{fs:t,fetch:n}),YL({fs:t,fetch:n})]}function EV(e){let t={buildProcessConfig:e.buildProcessConfig};return[`python3`,`python`,`pyodide`].map(e=>tN(e,t))}function DV(e){let t=e.scriptCatalog;return{buildProcessConfig:e.buildProcessConfig,terminal:e.terminal,gate:e.gateNativeCommand,commands:t&&(()=>t.getWasmCommands()),gitIdentity:e.gitIdentity}}function OV(){return[ZP(),IS()]}function kV(e={}){let t=[LE({getJshCommands:e.getJshCommands,getWorkflowCommands:e.getWorkflowCommands}),oe(),NF(),QP(),GP(e.browserAPI,e.fs),zj(e.browserAPI),zy(e.browserAPI),HD(e),SV(),TL(),_I(e.fs?{fs:e.fs}:{}),BF(),qF(),WF(),Pv(),bz(DV(e)),lC(DV(e)),yV(),DF(`sqlite3`),DF(`sqllite`),PI(),eL(),Bx(),gv(),nj({buildProcessConfig:e.buildProcessConfig}),nj({buildProcessConfig:e.buildProcessConfig},`jsh`),...EV(e),...TV(e),...e.fs?[cC({fs:e.fs})]:[],...e.fs?[mA({fs:e.fs})]:[],...e.fetch?[JE({fetch:e.fetch,streamFetch:e.streamFetch})]:[],LS(),RS(),XS(),Fz(e.webhook),bB(),Ry(e.crontask),CV(e),aM({fs:e.fs,fetch:e.fetch}),sC(),vF(),Bj(),Vj(`pdftk`),Vj(`pdf`),_v(`biscotto`,{getParentJid:e.getParentJid,isScoop:e.isScoop}),_v(`biscotti`,{getParentJid:e.getParentJid,isScoop:e.isScoop}),Zj(`pdftoppm`),Zj(`pdftocairo`),Qj(`pdftotext`),Sy(`convert`),Sy(`magick`),AB({fs:e.fs,scriptCatalog:e.scriptCatalog,getStaticBuiltins:e.getStaticBuiltins,getScriptRegisteredNames:e.getScriptRegisteredNames}),iL(),bL(),RD(),zD(),xL(),hA(),aN(),sA(),dx(),_j(),gj(),iA(),gP(wV(e)),Zp(e.gitCredential),vN({fs:e.fs}),WN(),jv(),Mv(),Nv(`xclip`),Nv(`xsel`),UN(),TC(),c_(),l_(),HA(e.fs),_t(),sj(),u_({getParentJid:e.getParentJid}),yx(),DM({processManager:e.processManager}),uR({processManager:e.processManager}),wk({processManager:e.processManager}),Sk({processManager:e.processManager,scriptCatalog:e.scriptCatalog}),...f_(),pA(),Xk(),FR(),bD(),xS(),ZR({processManager:e.processManager}),Lv({processManager:e.processManager,browser:e.browserAPI,sudoBroker:e.sudoCommand?.broker}),MS(),wv({registry:e.cherryRuntimeRegistry}),Jy(),eb({fs:e.fs}),tb({fs:e.fs}),FF(e.sudoCommand),qB({getParentJid:e.getParentJid,syncScriptCommands:e.syncScriptCommands}),xB(),...OV()];return e.fs&&(eM(),t.push(...er.map(t=>PE(t,e.browserAPI,e.fs,{isScoop:e.isScoop})))),t}let AV=null;function jV(e){AV=e}function MV(e){AV?.(e)}var NV=Yt();const PV={user:`user`,home:_r},FV=/* @__PURE__ */ new Set([`root`,`nobody`,`nogroup`]),IV=/^[A-Za-z_][A-Za-z0-9_.-]*$/;function LV(e){return{user:IV.test(e.user)&&!FV.has(e.user)?e.user:PV.user,home:e.home.startsWith(`/`)&&!/[:\n]/.test(e.home)?e.home:PV.home}}function RV(e,t){let{user:n,home:r}=LV(t);if(e===`/etc/passwd`)return[`root:x:0:0:root:/root:/bin/bash`,`${n}:x:1000:1000:SLICC user:${r}:/bin/bash`,`nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin`,``].join(`
3275
3280
  `);if(e===`/etc/group`)return[`root:x:0:`,`${n}:x:1000:`,`nogroup:x:65534:`,``].join(`
3276
- `)}function IV(e,t=jV){let n=FV(e,t);return n===void 0?void 0:new TextEncoder().encode(n)}function LV(e){return e===`/etc`?[`group`,`passwd`]:[]}function RV(e){return e?.code===`ENOENT`}const zV=Reflect.get(ft,`DefenseInDepthBox`);function BV(e){return(typeof e==`string`?e:e?.encoding)??`utf8`}function VV(e,t){if(typeof e!=`string`)return e;let n=BV(t);if(n===`binary`||n===`latin1`){let t=Oe(e);if(t)return t}return AV.Buffer.from(e,n)}function HV(e){return e===`/bin`?`/usr/bin`:e.startsWith(`/bin/`)?`/usr${e}`:e}function UV(e){let t=/^[A-Za-z0-9._+-]+$/.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`;return new TextEncoder().encode(`#!/bin/sh\n# SLICC command\nexec ${t} "$@"\n`)}function WV(e,t){let n=LV(e).filter(e=>!t.includes(e));return n.length?[...t,...n].sort():t}function GV(e,t){let n=LV(e).filter(e=>!t.some(t=>t.name===e));if(!n.length)return t;let r=n.map(e=>({name:e,isFile:!0,isDirectory:!1,isSymbolicLink:!1}));return[...t,...r].sort((e,t)=>e.name.localeCompare(t.name))}var KV=class{vfs;registeredCommandsFn=null;identityFn=null;listingStats=/* @__PURE__ */ 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),this.symlinkBatch=this.symlinkBatch.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=Xe(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}setIdentityFn(e){this.identityFn=e}identityFile(e){return IV(e,this.identityFn?.()??jV)}isVirtualBinCommand(e){return e.length>0&&!e.includes(`/`)&&this.getVirtualBinCommands().includes(e)}getVirtualBinCommands(){return this.registeredCommandsFn?.()??[]}virtualUsrStat(e){let t=HV(e);if(t===`/usr`||t===`/usr/bin`)return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:/* @__PURE__ */ new Date(0)};if(t.startsWith(`/usr/bin/`)){let e=t.slice(9);if(this.isVirtualBinCommand(e))return{isFile:!0,isDirectory:!1,isSymbolicLink:!1,mode:493,size:UV(e).length,mtime:/* @__PURE__ */ 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=zV?.runTrustedAsync;return t?t(e):Promise.resolve().then(e)}async readFile(e,t){return this.trusted(async()=>{let n=x(e),r=await this.readRaw(n),i=BV(t),a=AV.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString(i);return i!==`hex`&&i!==`base64`&&m(a,r),a})}async readFileBuffer(e){return this.trusted(()=>this.readRaw(x(e)))}async readRaw(e){let t=HV(e);if(t.startsWith(`/usr/bin/`)&&this.isVirtualBinCommand(t.slice(9)))return UV(t.slice(9));let n;try{n=await this.vfs.readFile(e,{encoding:`binary`})}catch(t){let n=this.identityFile(e);if(n&&RV(t))return n;throw t}return n instanceof Uint8Array?n:new TextEncoder().encode(n)}identityStat(e,t){let n=this.identityFile(e);if(n&&RV(t))return{isFile:!0,isDirectory:!1,isSymbolicLink:!1,mode:420,size:n.length,mtime:/* @__PURE__ */ new Date(0)}}async readFileBytes(e){let t=await this.readFileBuffer(e);return AV.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString(`latin1`)}async getNativeFile(e){return this.trusted(()=>this.vfs.getNativeFile(x(e)))}async readFileRange(e,t,n){return this.trusted(()=>this.vfs.readFileRange(x(e),t,n))}async writeFile(e,t,n){return this.dropListingStats(),this.trusted(async()=>{let r=x(e);await this.vfs.writeFile(r,VV(t,n))})}async appendFile(e,t,n){return this.dropListingStats(),this.trusted(()=>this.vfs.appendFile(x(e),VV(t,n)))}async exists(e){return this.trusted(async()=>{let t=x(e);return this.virtualUsrStat(t)?!0:await this.vfs.exists(t)||this.identityFile(t)!==void 0})}async stat(e){return this.trusted(async()=>{let t=x(e);try{return await this.statVfs(t)}catch(e){let n=this.identityStat(t,e);if(n)return n;throw e}})}async statVfs(e){let t=this.virtualUsrStat(e);if(t)return t;let n=this.vfs.statSync(e);if(n)return{isFile:n.type===`file`,isDirectory:n.type===`directory`,isSymbolicLink:!!n.isSymlink,mode:n.mode??(n.type===`directory`?493:420),size:n.size,mtime:new Date(n.mtime),identity:n.identity,dev:n.dev,ino:n.identity===void 0?void 0:n.ino};let r=this.primedStats(e)??await this.vfs.stat(e);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}}async lstat(e){return this.trusted(async()=>{let t=x(e);try{return await this.lstatVfs(t)}catch(e){let n=this.identityStat(t,e);if(n)return n;throw e}})}async lstatVfs(e){let t=this.virtualUsrStat(e);if(t)return t;let n=this.vfs.lstatSync(e);if(n)return{isFile:n.type===`file`,isDirectory:n.type===`directory`,isSymbolicLink:n.type===`symlink`,mode:n.mode??(n.type===`directory`?493:n.type===`symlink`?511:420),size:n.size,mtime:new Date(n.mtime),identity:n.identity,dev:n.dev,ino:n.identity===void 0?void 0:n.ino};let r=this.primedStats(e)??await this.vfs.lstat(e);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}}async mkdir(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.mkdir(x(e),t)})}async readdir(e){return this.trusted(async()=>{let t=x(e);if(t===`/usr`)return[`bin`];if(HV(t)===`/usr/bin`)return this.getVirtualBinCommands().slice().sort();let n=this.vfs.readDirSync(t);if(n!==null)return WV(t,n.map(e=>e.name));let r=await this.vfs.readDir(t,{includeStats:!0});return this.primeListingStats(t,r),WV(t,r.map(e=>e.name))})}async readdirWithFileTypes(e){return this.trusted(async()=>{let t=x(e);if(t===`/usr`)return[{name:`bin`,isFile:!1,isDirectory:!0,isSymbolicLink:!1}];if(HV(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 GV(t,this.mapFastEntriesToDirents(n));let r=await this.vfs.readDir(t,{includeStats:!0});return this.primeListingStats(t,r),GV(t,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(x(e),t)})}async cp(e,t,n){return this.dropListingStats(),this.trusted(async()=>{let r=x(e),i=x(t),a;try{a=await this.vfs.stat(r)}catch(e){let t=this.identityFile(r);if(!t||!RV(e))throw e;await this.vfs.writeFile(i,t);return}if(a.type===`directory`){if(!n?.recursive)throw new Ze(`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=S(e,r.name),i=S(t,r.name);r.type===`directory`?await this.cpDir(n,i):await this.vfs.copyFile(n,i)}let r=new Set(n.map(e=>e.name));for(let n of LV(e)){let i=r.has(n)?void 0:this.identityFile(S(e,n));i&&await this.vfs.writeFile(S(t,n),i)}}async mv(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.rename(x(e),x(t))})}async rename(e,t){return this.mv(e,t)}resolvePath(e,t){return t.startsWith(`/`)?x(t):x(S(e,t))}getAllPaths(){return[]}async chmod(e,t){return this.dropListingStats(),this.trusted(()=>this.vfs.chmod(x(e),t))}async updateMetadataBatch(e){return this.dropListingStats(),this.trusted(()=>this.vfs.updateMetadataBatch(e.map(e=>({...e,path:x(e.path)}))))}async symlinkBatch(e){return this.dropListingStats(),this.trusted(()=>this.vfs.symlinkBatch(e.map(e=>({target:e.target,path:x(e.path)}))))}async symlink(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.symlink(e,x(t))})}async link(e,t){throw Error(`Hard links not supported in VirtualFS`)}async readlink(e){return this.trusted(async()=>this.vfs.readlink(x(e)))}async realpath(e){return this.trusted(async()=>this.vfs.realpath(x(e)))}async utimes(e,t,n){return this.dropListingStats(),this.trusted(()=>this.vfs.utimes(x(e),t,n))}invalidatePaths(e){this.dropListingStats();let t=this.vfs;t.invalidatePaths&&t.invalidatePaths(e)}async forgetSidecarConsistency(){await this.vfs.forgetSidecarConsistency?.()}};function qV(e){return e&&typeof e.getWatcher==`function`?e.getWatcher?.()??null:e&&typeof e.getUnderlyingFS==`function`?qV(e.getUnderlyingFS?.()):null}const JV=e(`almost-bash-shell`);function YV(e){if(!(`__SLICC_RUN_PID`in e)&&!(`__SLICC_OUTPUT_TEE__`in e)&&!(`__SLICC_SUDO_REASON`in e)&&!(`__SLICC_PIPESTATUS`in e)&&!(`__SLICC_PIPESTATUS_EX`in e))return{...e};let{[om]:t,[sm]:n,[Ep]:r,[Gt]:i,[Ht]:a,...o}=e;return o}function XV(e){let t=new AbortController,n=e.filter(e=>e!==void 0),r=()=>t.abort();for(let e of n)e.aborted?t.abort():e.addEventListener(`abort`,r,{once:!0});return{signal:t.signal,release(){for(let e of n)e.removeEventListener(`abort`,r)}}}var ZV=class e{options;bash;vfsAdapter;gitCommands;mountCommands;lastEnv;cwd;umask=18;builtinCommandNames;staticBuiltinNames;allowedCommands;scriptCatalog;initialJshSync=null;ownsScriptCatalog;commandGate;jshRegistry;gnuBashFallback;pendingEnvWrites=/* @__PURE__ */ new Map;activeShellPid;progress;activeRunSignal;commandAbort=new AbortController;scriptRun=null;scriptRunsActive=0;registryNames=/* @__PURE__ */ new Set;outputTees=/* @__PURE__ */ new Map;nextOutputTeeId=0;resolveJshProcessConfig=e=>this.buildJshProcessConfig(cm(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:_r,PATH:Cr,USER:`user`,SHELL:`/bin/bash`,TMPDIR:`/tmp`,PWD:t,...e.env}}buildSupplementalCommands(e,t,n){return EV({onMediaPreview:async e=>this.renderMediaPreview(e),getJshCommands:()=>this.getJshCommandNames(),getWorkflowCommands:()=>this.getWorkflowCommandNames(),syncScriptCommands:()=>this.syncJshCommands(),getStaticBuiltins:()=>[...this.staticBuiltinNames],getScriptRegisteredNames:()=>this.jshRegistry.scriptRegisteredNames(),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,terminal:e.terminal,gateNativeCommand:this.gateNativeCommand,processManager:e.processManager,sudoCommand:e.sudo?{broker:e.sudo.broker,persistGrant:async e=>{this.commandGate.queueGrant(e)},suppressNextGate:e=>this.commandGate.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]},gitCredential:{githubToken:(e,t)=>this.gitCommands.githubCredential(e,t),githubDomains:xp},gitIdentity:()=>this.gitCommands.identity(),mcpConnectionManager:e.mcpConnectionManager})}constructor(t){this.options=t,this.vfsAdapter=new KV(t.fs),this.progress=new pm({scrubLabel:t.scrubProgressLabel}),this.allowedCommands=e.buildAllowedCommandSet(t),this.commandGate=new Qp({getSudo:()=>this.options.sudo,fs:t.fs});let n=t.cwd??`/`,r=e.buildInitialEnv(t,n);this.gitCommands=new vp({fs:t.fs,authorName:r.GIT_AUTHOR_NAME??`User`,authorEmail:r.GIT_AUTHOR_EMAIL??`user@example.com`,ensureFreshGithubToken:bp}),this.mountCommands=new Gs({fs:t.fs,isScoop:t.isScoop,acquireLocalMountViaToolUI:Qm});let i=t.jshDiscoveryFs??t.fs,a=t.bshDiscoveryFs??t.fs,o=qV(i)??qV(a);this.scriptCatalog=t.scriptCatalog??new Ni({jshFs:i,bshFs:a,watcher:o}),this.ownsScriptCatalog=!t.scriptCatalog,o&&o.watch(`/`,e=>e.endsWith(`.jsh`)||e.endsWith(`.workflow.js`)||br(e),()=>{this.syncJshCommands().catch(()=>void 0)});let s=this.createGitCustomCommand(),c=g({progress:vm(this.progress)}),l=_({progress:vm(this.progress)}),u=this.buildSupplementalCommands(t,c,l),d=[s,this.createMountCustomCommand(),this.createUmountCustomCommand(),Kh(t.fs),Ug(t.fs,c,t.browserAPI),...u].filter(e=>this.isCommandAllowed(e.name)),f=[...mt(),...dt()],p=this.allowedCommands?f.filter(e=>this.isCommandAllowed(e)):void 0;if(this.bash=new pt({fs:this.vfsAdapter,cwd:n,env:{},fetch:c,commands:p,customCommands:d,sleep:zm(this.progress,{isAborted:()=>this.activeRunSignal?.aborted??!1}),executionLimitProfile:t.executionLimitProfile,executionLimits:em(t.isScoop?.()??!1,t.executionLimits)}),this.bash.registerTransformPlugin(oh),this.allowedCommands!==null){let e=this.bash;for(let t of dt())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 m=d.map(e=>e.name),h=p??[...mt(),...dt()];this.builtinCommandNames=/* @__PURE__ */ new Set([...h,...m]),this.staticBuiltinNames=new Set(this.builtinCommandNames),this.vfsAdapter.setRegisteredCommandsFn(()=>[...this.builtinCommandNames]),this.vfsAdapter.setIdentityFn(()=>({user:this.lastEnv.USER??`user`,home:this.lastEnv.HOME??`/home/user`})),this.lastEnv={...r},this.cwd=n,this.bindCollaborators(t),this.startInitialJshSync()}bindCollaborators(e){let t=this;this.jshRegistry=new fm({get bash(){return t.bash},scriptCatalog:this.scriptCatalog,discoveryFs:e.jshDiscoveryFs??e.fs,vfsAdapter:this.vfsAdapter,get cwd(){return t.cwd},get lastEnv(){return t.lastEnv},get umask(){return t.umask},builtinCommandNames:this.builtinCommandNames,isCommandAllowed:e=>this.isCommandAllowed(e),wrapCommandForDispatch:e=>this.wrapCommandForDispatch(e),path:()=>this.lastEnv.PATH,buildJshProcessConfig:e=>this.buildJshProcessConfig(e),gateNativeCommand:this.gateNativeCommand,gitIdentity:()=>this.gitCommands.identity()}),this.gnuBashFallback=new lm({gnuBash:e.gnuBash===!0,get lastEnv(){return t.lastEnv},get cwd(){return t.cwd},get umask(){return t.umask},vfsAdapter:this.vfsAdapter,get bash(){return t.bash},scriptCatalog:this.scriptCatalog,outputTees:this.outputTees,gateNativeCommand:this.gateNativeCommand,buildJshProcessConfig:e=>this.buildJshProcessConfig(e),gitIdentity:()=>this.gitCommands.identity(),flushPendingCommandGrants:()=>this.commandGate.flushPendingCommandGrants(),applyPendingEnvWrites:()=>this.applyPendingEnvWrites(),syncJshCommands:()=>this.syncJshCommands(),adoptCwd:e=>{this.cwd=e},adoptEnv:e=>{this.lastEnv=e}})}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 this.jshRegistry.getJshCommandNames()}async syncJshCommands(){return this.jshRegistry.syncJshCommands()}cancelActiveCommand(){this.commandAbort.abort(),this.commandAbort=new AbortController}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 gi(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`)}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 gr(e);this.lastEnv.HOME=t,this.options.env?.USER||(this.lastEnv.USER=hr(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){JV.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){if(kV(e.trim().split(/\s+/)[0]||`unknown`),v(),await this.waitForInitialJshSync(t),await this.gnuBashFallback.usesGnuBash())return this.gnuBashFallback.runOnGnuBash(e,t,n,r,i,a);let o=Op(e),s={env:{...this.lastEnv,...n===void 0?{}:{[om]:String(n)},...i===void 0?{}:{[sm]:i},...o?{[Ep]:o}:{}},cwd:this.cwd,umask:this.umask,signal:t,...r===``?{}:{stdin:r,stdinKind:`bytes`}},c=this.lastEnv.PATH,l=XV([t,this.commandAbort.signal]);s.signal=l.signal,this.activeRunSignal=l.signal;let u=this.beginScriptRun(e),d;try{d=await this.bash.exec(Ut(e,a),s)}finally{l.release(),this.activeRunSignal===l.signal&&(this.activeRunSignal=void 0),this.endScriptRun(u)}if(await this.commandGate.flushPendingCommandGrants(),d=Vt(d,a),typeof d.umask==`number`&&(this.umask=d.umask),d.env&&(this.lastEnv=YV(d.env)),d.env&&this.lastEnv.PATH!==c&&await this.syncJshCommands().catch(()=>void 0),this.applyPendingEnvWrites(),d.env?.PWD&&(this.cwd=d.env.PWD),d.exitCode===127){let t=await this.jshRegistry.tryJshFallback(e,n);if(t)return this.syncJshCommands().catch(()=>void 0),t}if(d.exitCode!==0&&d.stderr.includes(`Permission denied`)){let{withShebangExecHint:e}=await import(`./shebang-exec-hint-DGW7999v.js`).then(e=>e.n);return zt(await e(d,this.cwd,this.vfsAdapter),d.pipeStatus)}return d}applyPendingEnvWrites(){for(let[e,t]of this.pendingEnvWrites)t===null?delete this.lastEnv[e]:this.lastEnv[e]=t;this.pendingEnvWrites.clear()}gateNativeCommand=async(e,t,n)=>{if(this.allowedCommands!==null&&!this.isCommandAllowed(e))return{stderr:`bash: ${e}: command not found\n`,exitCode:127};if(!this.commandGate.isTransparentGatingEnabled()||Hp.has(e))return null;let r=await this.commandGate.gateCommandDispatch(e,t,n[Ep]);return r?{stderr:r.stderr,exitCode:r.exitCode}:null};wrapCommandForDispatch(e){let t=this.commandGate.wrapCommandForSudo(e),n=e.name===`timeout`?Um(t,this.progress):Gm(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(sm),s=o?a.get(o):void 0;s&&(t.writeStdout=s);try{let r=await qm(()=>n.execute(e,t),t.signal);return i(t.env,r),r}finally{r()}}}}teeCommandOutput(e,t){let n=e?.get(sm);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=Pm(this.bash.transform(e).ast,this.registryNames)}catch{t={totalSteps:null}}return this.scriptRun=new Im(t,this.progress,Fm(e)),this.scriptRun}endScriptRun(e){this.scriptRunsActive=Math.max(0,this.scriptRunsActive-1),e&&(e.end(),this.scriptRun===e&&(this.scriptRun=null))}isCommandAllowed(e){return this.allowedCommands===null||this.allowedCommands.has(Hp.get(e)??e)}createGitCustomCommand(){let e=this.gitCommands;return C(`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 C(`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 C(`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 getWorkflowCommandNames(){return this.jshRegistry.getWorkflowCommandNames()}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{Ha as _,PB as a,ks as c,Cs as d,is as f,Ua as g,za as h,AB as i,Es as l,Jo as m,KV as n,OB as o,rs as p,OV as r,Is as s,ZV as t,Ts as u,Ho as v,Na as y};
3281
+ `)}function zV(e,t=PV){let n=RV(e,t);return n===void 0?void 0:new TextEncoder().encode(n)}function BV(e){return e===`/etc`?[`group`,`passwd`]:[]}function VV(e){return e?.code===`ENOENT`}const HV=Reflect.get(ft,`DefenseInDepthBox`);function UV(e){return(typeof e==`string`?e:e?.encoding)??`utf8`}function WV(e,t){if(typeof e!=`string`)return e;let n=UV(t);if(n===`binary`||n===`latin1`){let t=Oe(e);if(t)return t}return NV.Buffer.from(e,n)}function GV(e){return e===`/bin`?`/usr/bin`:e.startsWith(`/bin/`)?`/usr${e}`:e}function KV(e){let t=/^[A-Za-z0-9._+-]+$/.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`;return new TextEncoder().encode(`#!/bin/sh\n# SLICC command\nexec ${t} "$@"\n`)}function qV(e,t){let n=BV(e).filter(e=>!t.includes(e));return n.length?[...t,...n].sort():t}function JV(e,t){let n=BV(e).filter(e=>!t.some(t=>t.name===e));if(!n.length)return t;let r=n.map(e=>({name:e,isFile:!0,isDirectory:!1,isSymbolicLink:!1}));return[...t,...r].sort((e,t)=>e.name.localeCompare(t.name))}var YV=class{vfs;registeredCommandsFn=null;identityFn=null;listingStats=/* @__PURE__ */ 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),this.symlinkBatch=this.symlinkBatch.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=Xe(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}setIdentityFn(e){this.identityFn=e}identityFile(e){return zV(e,this.identityFn?.()??PV)}isVirtualBinCommand(e){return e.length>0&&!e.includes(`/`)&&this.getVirtualBinCommands().includes(e)}getVirtualBinCommands(){return this.registeredCommandsFn?.()??[]}virtualUsrStat(e){let t=GV(e);if(t===`/usr`||t===`/usr/bin`)return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:/* @__PURE__ */ new Date(0)};if(t.startsWith(`/usr/bin/`)){let e=t.slice(9);if(this.isVirtualBinCommand(e))return{isFile:!0,isDirectory:!1,isSymbolicLink:!1,mode:493,size:KV(e).length,mtime:/* @__PURE__ */ 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=HV?.runTrustedAsync;return t?t(e):Promise.resolve().then(e)}async readFile(e,t){return this.trusted(async()=>{let n=x(e),r=await this.readRaw(n),i=UV(t),a=NV.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString(i);return i!==`hex`&&i!==`base64`&&m(a,r),a})}async readFileBuffer(e){return this.trusted(()=>this.readRaw(x(e)))}async readRaw(e){let t=GV(e);if(t.startsWith(`/usr/bin/`)&&this.isVirtualBinCommand(t.slice(9)))return KV(t.slice(9));let n;try{n=await this.vfs.readFile(e,{encoding:`binary`})}catch(t){let n=this.identityFile(e);if(n&&VV(t))return n;throw t}return n instanceof Uint8Array?n:new TextEncoder().encode(n)}identityStat(e,t){let n=this.identityFile(e);if(n&&VV(t))return{isFile:!0,isDirectory:!1,isSymbolicLink:!1,mode:420,size:n.length,mtime:/* @__PURE__ */ new Date(0)}}async readFileBytes(e){let t=await this.readFileBuffer(e);return NV.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString(`latin1`)}async getNativeFile(e){return this.trusted(()=>this.vfs.getNativeFile(x(e)))}async readFileRange(e,t,n){return this.trusted(()=>this.vfs.readFileRange(x(e),t,n))}async writeFile(e,t,n){return this.dropListingStats(),this.trusted(async()=>{let r=x(e);await this.vfs.writeFile(r,WV(t,n))})}async appendFile(e,t,n){return this.dropListingStats(),this.trusted(()=>this.vfs.appendFile(x(e),WV(t,n)))}async exists(e){return this.trusted(async()=>{let t=x(e);return this.virtualUsrStat(t)?!0:await this.vfs.exists(t)||this.identityFile(t)!==void 0})}async stat(e){return this.trusted(async()=>{let t=x(e);try{return await this.statVfs(t)}catch(e){let n=this.identityStat(t,e);if(n)return n;throw e}})}async statVfs(e){let t=this.virtualUsrStat(e);if(t)return t;let n=this.vfs.statSync(e);if(n)return{isFile:n.type===`file`,isDirectory:n.type===`directory`,isSymbolicLink:!!n.isSymlink,mode:n.mode??(n.type===`directory`?493:420),size:n.size,mtime:new Date(n.mtime),identity:n.identity,dev:n.dev,ino:n.identity===void 0?void 0:n.ino};let r=this.primedStats(e)??await this.vfs.stat(e);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}}async lstat(e){return this.trusted(async()=>{let t=x(e);try{return await this.lstatVfs(t)}catch(e){let n=this.identityStat(t,e);if(n)return n;throw e}})}async lstatVfs(e){let t=this.virtualUsrStat(e);if(t)return t;let n=this.vfs.lstatSync(e);if(n)return{isFile:n.type===`file`,isDirectory:n.type===`directory`,isSymbolicLink:n.type===`symlink`,mode:n.mode??(n.type===`directory`?493:n.type===`symlink`?511:420),size:n.size,mtime:new Date(n.mtime),identity:n.identity,dev:n.dev,ino:n.identity===void 0?void 0:n.ino};let r=this.primedStats(e)??await this.vfs.lstat(e);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}}async mkdir(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.mkdir(x(e),t)})}async readdir(e){return this.trusted(async()=>{let t=x(e);if(t===`/usr`)return[`bin`];if(GV(t)===`/usr/bin`)return this.getVirtualBinCommands().slice().sort();let n=this.vfs.readDirSync(t);if(n!==null)return qV(t,n.map(e=>e.name));let r=await this.vfs.readDir(t,{includeStats:!0});return this.primeListingStats(t,r),qV(t,r.map(e=>e.name))})}async readdirWithFileTypes(e){return this.trusted(async()=>{let t=x(e);if(t===`/usr`)return[{name:`bin`,isFile:!1,isDirectory:!0,isSymbolicLink:!1}];if(GV(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 JV(t,this.mapFastEntriesToDirents(n));let r=await this.vfs.readDir(t,{includeStats:!0});return this.primeListingStats(t,r),JV(t,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(x(e),t)})}async cp(e,t,n){return this.dropListingStats(),this.trusted(async()=>{let r=x(e),i=x(t),a;try{a=await this.vfs.stat(r)}catch(e){let t=this.identityFile(r);if(!t||!VV(e))throw e;await this.vfs.writeFile(i,t);return}if(a.type===`directory`){if(!n?.recursive)throw new Ze(`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=S(e,r.name),i=S(t,r.name);r.type===`directory`?await this.cpDir(n,i):await this.vfs.copyFile(n,i)}let r=new Set(n.map(e=>e.name));for(let n of BV(e)){let i=r.has(n)?void 0:this.identityFile(S(e,n));i&&await this.vfs.writeFile(S(t,n),i)}}async mv(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.rename(x(e),x(t))})}async rename(e,t){return this.mv(e,t)}resolvePath(e,t){return t.startsWith(`/`)?x(t):x(S(e,t))}getAllPaths(){return[]}async chmod(e,t){return this.dropListingStats(),this.trusted(()=>this.vfs.chmod(x(e),t))}async updateMetadataBatch(e){return this.dropListingStats(),this.trusted(()=>this.vfs.updateMetadataBatch(e.map(e=>({...e,path:x(e.path)}))))}async symlinkBatch(e){return this.dropListingStats(),this.trusted(()=>this.vfs.symlinkBatch(e.map(e=>({target:e.target,path:x(e.path)}))))}async symlink(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.symlink(e,x(t))})}async link(e,t){throw Error(`Hard links not supported in VirtualFS`)}async readlink(e){return this.trusted(async()=>this.vfs.readlink(x(e)))}async realpath(e){return this.trusted(async()=>this.vfs.realpath(x(e)))}async utimes(e,t,n){return this.dropListingStats(),this.trusted(()=>this.vfs.utimes(x(e),t,n))}invalidatePaths(e){this.dropListingStats();let t=this.vfs;t.invalidatePaths&&t.invalidatePaths(e)}async forgetSidecarConsistency(){await this.vfs.forgetSidecarConsistency?.()}};function XV(e){return e&&typeof e.getWatcher==`function`?e.getWatcher?.()??null:e&&typeof e.getUnderlyingFS==`function`?XV(e.getUnderlyingFS?.()):null}const ZV=e(`almost-bash-shell`);function QV(e){if(!(`__SLICC_RUN_PID`in e)&&!(`__SLICC_OUTPUT_TEE__`in e)&&!(`__SLICC_SUDO_REASON`in e)&&!(`__SLICC_PIPESTATUS`in e)&&!(`__SLICC_PIPESTATUS_EX`in e))return{...e};let{[om]:t,[sm]:n,[Ep]:r,[Gt]:i,[Ht]:a,...o}=e;return o}function $V(e){let t=new AbortController,n=e.filter(e=>e!==void 0),r=()=>t.abort();for(let e of n)e.aborted?t.abort():e.addEventListener(`abort`,r,{once:!0});return{signal:t.signal,release(){for(let e of n)e.removeEventListener(`abort`,r)}}}var eH=class e{options;bash;vfsAdapter;gitCommands;mountCommands;lastEnv;cwd;umask=18;builtinCommandNames;staticBuiltinNames;allowedCommands;scriptCatalog;initialJshSync=null;ownsScriptCatalog;commandGate;jshRegistry;gnuBashFallback;pendingEnvWrites=/* @__PURE__ */ new Map;activeShellPid;progress;activeRunSignal;commandAbort=new AbortController;scriptRun=null;scriptRunsActive=0;registryNames=/* @__PURE__ */ new Set;outputTees=/* @__PURE__ */ new Map;nextOutputTeeId=0;resolveJshProcessConfig=e=>this.buildJshProcessConfig(cm(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:_r,PATH:Cr,USER:`user`,SHELL:`/bin/bash`,TMPDIR:`/tmp`,PWD:t,...e.env}}buildSupplementalCommands(e,t,n){return kV({onMediaPreview:async e=>this.renderMediaPreview(e),getJshCommands:()=>this.getJshCommandNames(),getWorkflowCommands:()=>this.getWorkflowCommandNames(),syncScriptCommands:()=>this.syncJshCommands(),getStaticBuiltins:()=>[...this.staticBuiltinNames],getScriptRegisteredNames:()=>this.jshRegistry.scriptRegisteredNames(),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,terminal:e.terminal,gateNativeCommand:this.gateNativeCommand,processManager:e.processManager,sudoCommand:e.sudo?{broker:e.sudo.broker,persistGrant:async e=>{this.commandGate.queueGrant(e)},suppressNextGate:e=>this.commandGate.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]},gitCredential:{githubToken:(e,t)=>this.gitCommands.githubCredential(e,t),githubDomains:xp},gitIdentity:()=>this.gitCommands.identity(),mcpConnectionManager:e.mcpConnectionManager})}constructor(t){this.options=t,this.vfsAdapter=new YV(t.fs),this.progress=new pm({scrubLabel:t.scrubProgressLabel}),this.allowedCommands=e.buildAllowedCommandSet(t),this.commandGate=new Qp({getSudo:()=>this.options.sudo,fs:t.fs});let n=t.cwd??`/`,r=e.buildInitialEnv(t,n);this.gitCommands=new vp({fs:t.fs,authorName:r.GIT_AUTHOR_NAME??`User`,authorEmail:r.GIT_AUTHOR_EMAIL??`user@example.com`,ensureFreshGithubToken:bp}),this.mountCommands=new Gs({fs:t.fs,isScoop:t.isScoop,acquireLocalMountViaToolUI:Qm});let i=t.jshDiscoveryFs??t.fs,a=t.bshDiscoveryFs??t.fs,o=XV(i)??XV(a);this.scriptCatalog=t.scriptCatalog??new Ni({jshFs:i,bshFs:a,watcher:o}),this.ownsScriptCatalog=!t.scriptCatalog,o&&o.watch(`/`,e=>e.endsWith(`.jsh`)||e.endsWith(`.workflow.js`)||br(e),()=>{this.syncJshCommands().catch(()=>void 0)});let s=this.createGitCustomCommand(),c=g({progress:vm(this.progress)}),l=_({progress:vm(this.progress)}),u=this.buildSupplementalCommands(t,c,l),d=[s,this.createMountCustomCommand(),this.createUmountCustomCommand(),Kh(t.fs),Ug(t.fs,c,t.browserAPI),...u].filter(e=>this.isCommandAllowed(e.name)),f=[...mt(),...dt()],p=this.allowedCommands?f.filter(e=>this.isCommandAllowed(e)):void 0;if(this.bash=new pt({fs:this.vfsAdapter,cwd:n,env:{},fetch:c,commands:p,customCommands:d,sleep:zm(this.progress,{isAborted:()=>this.activeRunSignal?.aborted??!1}),executionLimitProfile:t.executionLimitProfile,executionLimits:em(t.isScoop?.()??!1,t.executionLimits)}),this.bash.registerTransformPlugin(oh),this.allowedCommands!==null){let e=this.bash;for(let t of dt())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 m=d.map(e=>e.name),h=p??[...mt(),...dt()];this.builtinCommandNames=/* @__PURE__ */ new Set([...h,...m]),this.staticBuiltinNames=new Set(this.builtinCommandNames),this.vfsAdapter.setRegisteredCommandsFn(()=>[...this.builtinCommandNames]),this.vfsAdapter.setIdentityFn(()=>({user:this.lastEnv.USER??`user`,home:this.lastEnv.HOME??`/home/user`})),this.lastEnv={...r},this.cwd=n,this.bindCollaborators(t),this.startInitialJshSync()}bindCollaborators(e){let t=this;this.jshRegistry=new fm({get bash(){return t.bash},scriptCatalog:this.scriptCatalog,discoveryFs:e.jshDiscoveryFs??e.fs,vfsAdapter:this.vfsAdapter,get cwd(){return t.cwd},get lastEnv(){return t.lastEnv},get umask(){return t.umask},builtinCommandNames:this.builtinCommandNames,isCommandAllowed:e=>this.isCommandAllowed(e),wrapCommandForDispatch:e=>this.wrapCommandForDispatch(e),path:()=>this.lastEnv.PATH,buildJshProcessConfig:e=>this.buildJshProcessConfig(e),gateNativeCommand:this.gateNativeCommand,gitIdentity:()=>this.gitCommands.identity()}),this.gnuBashFallback=new lm({gnuBash:e.gnuBash===!0,get lastEnv(){return t.lastEnv},get cwd(){return t.cwd},get umask(){return t.umask},vfsAdapter:this.vfsAdapter,get bash(){return t.bash},scriptCatalog:this.scriptCatalog,outputTees:this.outputTees,gateNativeCommand:this.gateNativeCommand,buildJshProcessConfig:e=>this.buildJshProcessConfig(e),gitIdentity:()=>this.gitCommands.identity(),flushPendingCommandGrants:()=>this.commandGate.flushPendingCommandGrants(),applyPendingEnvWrites:()=>this.applyPendingEnvWrites(),syncJshCommands:()=>this.syncJshCommands(),adoptCwd:e=>{this.cwd=e},adoptEnv:e=>{this.lastEnv=e}})}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 this.jshRegistry.getJshCommandNames()}async syncJshCommands(){return this.jshRegistry.syncJshCommands()}cancelActiveCommand(){this.commandAbort.abort(),this.commandAbort=new AbortController}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 gi(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`)}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 gr(e);this.lastEnv.HOME=t,this.options.env?.USER||(this.lastEnv.USER=hr(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){ZV.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){if(MV(e.trim().split(/\s+/)[0]||`unknown`),v(),await this.waitForInitialJshSync(t),await this.gnuBashFallback.usesGnuBash())return this.gnuBashFallback.runOnGnuBash(e,t,n,r,i,a);let o=Op(e),s={env:{...this.lastEnv,...n===void 0?{}:{[om]:String(n)},...i===void 0?{}:{[sm]:i},...o?{[Ep]:o}:{}},cwd:this.cwd,umask:this.umask,signal:t,...r===``?{}:{stdin:r,stdinKind:`bytes`}},c=this.lastEnv.PATH,l=$V([t,this.commandAbort.signal]);s.signal=l.signal,this.activeRunSignal=l.signal;let u=this.beginScriptRun(e),d;try{d=await this.bash.exec(Ut(e,a),s)}finally{l.release(),this.activeRunSignal===l.signal&&(this.activeRunSignal=void 0),this.endScriptRun(u)}if(await this.commandGate.flushPendingCommandGrants(),d=Vt(d,a),typeof d.umask==`number`&&(this.umask=d.umask),d.env&&(this.lastEnv=QV(d.env)),d.env&&this.lastEnv.PATH!==c&&await this.syncJshCommands().catch(()=>void 0),this.applyPendingEnvWrites(),d.env?.PWD&&(this.cwd=d.env.PWD),d.exitCode===127){let t=await this.jshRegistry.tryJshFallback(e,n);if(t)return this.syncJshCommands().catch(()=>void 0),t}if(d.exitCode!==0&&d.stderr.includes(`Permission denied`)){let{withShebangExecHint:e}=await import(`./shebang-exec-hint-DGW7999v.js`).then(e=>e.n);return zt(await e(d,this.cwd,this.vfsAdapter),d.pipeStatus)}return d}applyPendingEnvWrites(){for(let[e,t]of this.pendingEnvWrites)t===null?delete this.lastEnv[e]:this.lastEnv[e]=t;this.pendingEnvWrites.clear()}gateNativeCommand=async(e,t,n)=>{if(this.allowedCommands!==null&&!this.isCommandAllowed(e))return{stderr:`bash: ${e}: command not found\n`,exitCode:127};if(!this.commandGate.isTransparentGatingEnabled()||Hp.has(e))return null;let r=await this.commandGate.gateCommandDispatch(e,t,n[Ep]);return r?{stderr:r.stderr,exitCode:r.exitCode}:null};wrapCommandForDispatch(e){let t=this.commandGate.wrapCommandForSudo(e),n=e.name===`timeout`?Um(t,this.progress):Gm(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(sm),s=o?a.get(o):void 0;s&&(t.writeStdout=s);try{let r=await qm(()=>n.execute(e,t),t.signal);return i(t.env,r),r}finally{r()}}}}teeCommandOutput(e,t){let n=e?.get(sm);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=Pm(this.bash.transform(e).ast,this.registryNames)}catch{t={totalSteps:null}}return this.scriptRun=new Im(t,this.progress,Fm(e)),this.scriptRun}endScriptRun(e){this.scriptRunsActive=Math.max(0,this.scriptRunsActive-1),e&&(e.end(),this.scriptRun===e&&(this.scriptRun=null))}isCommandAllowed(e){return this.allowedCommands===null||this.allowedCommands.has(Hp.get(e)??e)}createGitCustomCommand(){let e=this.gitCommands;return C(`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 C(`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 C(`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 getWorkflowCommandNames(){return this.jshRegistry.getWorkflowCommandNames()}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{Ha as _,LB as a,ks as c,Cs as d,is as f,Ua as g,za as h,NB as i,Es as l,Jo as m,YV as n,jB as o,rs as p,jV as r,Is as s,eH as t,Ts as u,Ho as v,Na as y};