sliccy 6.235.2 → 6.235.3

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 (136) hide show
  1. package/dist/ui/.vite/manifest.json +181 -181
  2. package/dist/ui/assets/{account-store-BT0pbAvQ.js → account-store-B2cAHozW.js} +1 -1
  3. package/dist/ui/assets/{account-store-D7DGAxNM.js → account-store-D0xdiy20.js} +1 -1
  4. package/dist/ui/assets/{adobe-_I4i3x_7.js → adobe-BXAZ88v2.js} +1 -1
  5. package/dist/ui/assets/{adobe-CEArSxCX.js → adobe-zXST80lm.js} +1 -1
  6. package/dist/ui/assets/{agent-panels-C_58flxq.js → agent-panels-BsN6GFr4.js} +1 -1
  7. package/dist/ui/assets/{almost-bash-shell-headless-B6ZMvYl4.js → almost-bash-shell-headless-Bylkd2NC.js} +16 -16
  8. package/dist/ui/assets/{apply-layout-8fGhBCeJ.js → apply-layout-TzbiHcrs.js} +1 -1
  9. package/dist/ui/assets/{azure-openai-eCi3qaKl.js → azure-openai-DNsUNlBw.js} +1 -1
  10. package/dist/ui/assets/{azure-openai-B1ImIasn.js → azure-openai-Dj3KGYSj.js} +1 -1
  11. package/dist/ui/assets/{cdp-D7X02m26.js → cdp-BE0rEHUV.js} +1 -1
  12. package/dist/ui/assets/{cerebras-Dw16qbLP.js → cerebras-CiB1p3ck.js} +1 -1
  13. package/dist/ui/assets/{cerebras-DLriLpBm.js → cerebras-iuuYSkHk.js} +1 -1
  14. package/dist/ui/assets/{composer-speech-C5aq2EHX.js → composer-speech-ClVbp0TA.js} +1 -1
  15. package/dist/ui/assets/{connect-surface-B33YxHel.js → connect-surface-BIc-MC9V.js} +1 -1
  16. package/dist/ui/assets/{directed-approval-CsWbrazD.js → directed-approval-B_moMyEh.js} +1 -1
  17. package/dist/ui/assets/{emscripten-vfs-hook-D4rVkB6b.js → emscripten-vfs-hook-DN8XE7DM.js} +1 -1
  18. package/dist/ui/assets/{emscripten-vfs-hook-C_WW9D-C.js → emscripten-vfs-hook-HZsDmdXD.js} +1 -1
  19. package/dist/ui/assets/{frozen-archive-writer-Bjl1A6fy.js → frozen-archive-writer-BIfwr3dS.js} +1 -1
  20. package/dist/ui/assets/{gelatiere-unit-69YQevwx.js → gelatiere-unit-C53alO2X.js} +1 -1
  21. package/dist/ui/assets/{github-5665N6-Q.js → github-DFs9J5AY.js} +1 -1
  22. package/dist/ui/assets/{github-DeAThA8k.js → github-Dt4Pt5eh.js} +1 -1
  23. package/dist/ui/assets/{github-copilot-B-F9GN74.js → github-copilot-C66RPMFw.js} +1 -1
  24. package/dist/ui/assets/{github-copilot-2CNJ6evQ.js → github-copilot-DdlROed6.js} +1 -1
  25. package/dist/ui/assets/{go-driver-C0zJJSTi.js → go-driver-DOU6iF-0.js} +1 -1
  26. package/dist/ui/assets/{hear-DzjhPERk.js → hear-Cg1OJA6u.js} +1 -1
  27. package/dist/ui/assets/{js-realm-worker-ALz7TOVI.js → js-realm-worker-CJyYHP3T.js} +2 -2
  28. package/dist/ui/assets/{jsh-executor-UfR3L63B.js → jsh-executor-DvcG7M6y.js} +2 -2
  29. package/dist/ui/assets/{kernel-worker-coLE80Cx.js → kernel-worker-XCbAqv4r.js} +8 -8
  30. package/dist/ui/assets/{lick-ws-bridge-BwZ6Lsqx.js → lick-ws-bridge-Bq-GRhDY.js} +1 -1
  31. package/dist/ui/assets/{lick-ws-bridge-DpjVEf6h.js → lick-ws-bridge-q1AekYjP.js} +1 -1
  32. package/dist/ui/assets/{live-session-curation-CN8ifDXh.js → live-session-curation-YPPGXSpf.js} +1 -1
  33. package/dist/ui/assets/{live-session-snapshot-BoQYDzUq.js → live-session-snapshot-CU49P35v.js} +1 -1
  34. package/dist/ui/assets/{local-llm-DAdQyx68.js → local-llm-C5n6HmT5.js} +1 -1
  35. package/dist/ui/assets/{local-llm-CBWcw9ga.js → local-llm-DIaHbO0U.js} +1 -1
  36. package/dist/ui/assets/{main-D7Ilh1cw.js → main-CvOzoNa2.js} +3 -3
  37. package/dist/ui/assets/{main-cherry-9nngpfRy.js → main-cherry-DNfw_XPy.js} +1 -1
  38. package/dist/ui/assets/{mcp-command-BeBM1rHC.js → mcp-command-CSD8gKx4.js} +9 -9
  39. package/dist/ui/assets/{memory-curation-seam-CUFsPZ6T.js → memory-curation-seam-DTZEIHwq.js} +1 -1
  40. package/dist/ui/assets/{memory-health-hDyNPmp-.js → memory-health-Bn8iMJCS.js} +1 -1
  41. package/dist/ui/assets/{memory-write-execute-CgR8Y6VS.js → memory-write-execute-BBKygSIa.js} +1 -1
  42. package/dist/ui/assets/{merge-folded-cost-into-frozen-DTjO_AHz.js → merge-folded-cost-into-frozen-DqNEvymy.js} +1 -1
  43. package/dist/ui/assets/{new-session-CLqykoTf.js → new-session-CVLuvA2i.js} +2 -2
  44. package/dist/ui/assets/{oauth-bootstrap-UPOMQS2N.js → oauth-bootstrap-CAu-GVnp.js} +2 -2
  45. package/dist/ui/assets/{onboarding-orchestrator-DKu8ScwD.js → onboarding-orchestrator-oag1I7jn.js} +1 -1
  46. package/dist/ui/assets/{openai-codex-C3rT7EJ-.js → openai-codex-CvAG8oXv.js} +1 -1
  47. package/dist/ui/assets/{openai-codex-CXG3CPUO.js → openai-codex-ka8GCZAT.js} +1 -1
  48. package/dist/ui/assets/{openrouter-MNU1Hy35.js → openrouter-8hmQkp_h.js} +1 -1
  49. package/dist/ui/assets/{openrouter-C_mHcLUY.js → openrouter-CgzBS5eF.js} +1 -1
  50. package/dist/ui/assets/{openrouter-free-wsl2KNbX.js → openrouter-free-B3u9DjXb.js} +1 -1
  51. package/dist/ui/assets/{openrouter-free-2vZpBTFE.js → openrouter-free-BqFGpSf1.js} +1 -1
  52. package/dist/ui/assets/{openrouter-oauth-Bw05OEXj.js → openrouter-oauth-BoLX7zIe.js} +1 -1
  53. package/dist/ui/assets/{openrouter-oauth-sx8YMfw_.js → openrouter-oauth-Dukaywoy.js} +1 -1
  54. package/dist/ui/assets/{panel-rpc-handlers-C4ZEbr-L.js → panel-rpc-handlers-CHCXtmkW.js} +2 -2
  55. package/dist/ui/assets/{panelize-shell-CLTgjV9N.js → panelize-shell-BUcAuePy.js} +1 -1
  56. package/dist/ui/assets/{pi-edit-execution-DF0ZCxw2.js → pi-edit-execution-CQIW45Xq.js} +1 -1
  57. package/dist/ui/assets/{provider-CWkiPaFF.js → provider-DXgG2OZw.js} +1 -1
  58. package/dist/ui/assets/{provider-CBb3zRgf.js → provider-DmCJ9gDr.js} +1 -1
  59. package/dist/ui/assets/{provider-settings-BySNZFTG.js → provider-settings-Cwu3oMsc.js} +1 -1
  60. package/dist/ui/assets/provider-store-access-D3z_1dVo.js +1 -0
  61. package/dist/ui/assets/provider-store-access-D4NGG9AL.js +1 -0
  62. package/dist/ui/assets/{providers-Dz9lZ6WH.js → providers-DS41fGUE.js} +1 -1
  63. package/dist/ui/assets/{providers-3muwTGPn.js → providers-MaL3c9jG.js} +2 -2
  64. package/dist/ui/assets/{py-live-vfs-CPGqrKx-.js → py-live-vfs-C6sLzy_c.js} +1 -1
  65. package/dist/ui/assets/{quick-llm-BE1MoA8w.js → quick-llm-D8to-Hwt.js} +1 -1
  66. package/dist/ui/assets/{realm-inprocess-B-C5-frg.js → realm-inprocess-CrLMANsF.js} +2 -2
  67. package/dist/ui/assets/{realm-sync-transport-CTz7jTgb.js → realm-sync-transport-Ble3Euu9.js} +1 -1
  68. package/dist/ui/assets/{realm-unhandled-rejections-CE1G6Vqu.js → realm-unhandled-rejections-DBUiMZxS.js} +1 -1
  69. package/dist/ui/assets/{realm-unhandled-rejections-zi6bFzVe.js → realm-unhandled-rejections-DV1qqH3i.js} +1 -1
  70. package/dist/ui/assets/{recovery-screen-tADn1zrY.js → recovery-screen-C6d2MLJJ.js} +1 -1
  71. package/dist/ui/assets/{remote-terminal-view-4u9dBB0E.js → remote-terminal-view-BDbv2zvX.js} +2 -2
  72. package/dist/ui/assets/{require-guards-DnafTLJr.js → require-guards-6ovYBhVp.js} +1 -1
  73. package/dist/ui/assets/{restore-ue1IxJw4.js → restore-Df_2h2Vb.js} +1 -1
  74. package/dist/ui/assets/run-BStZvimF.js +18 -0
  75. package/dist/ui/assets/{run-DKbvbERf.js → run-BaJvd-iq.js} +1 -1
  76. package/dist/ui/assets/{run-BSPrcB21.js → run-C4iWmNHr.js} +2 -2
  77. package/dist/ui/assets/{run-BVj8rfi8.js → run-DCDVvZUu.js} +1 -1
  78. package/dist/ui/assets/{run-Blqu2GaE.js → run-RApyrvLo.js} +2 -2
  79. package/dist/ui/assets/{session-command-memory-Cep9cwKm.js → session-command-memory-C7L8WXSk.js} +2 -2
  80. package/dist/ui/assets/{session-jsonl-CFn8rdop.js → session-jsonl-B_EOHqt3.js} +1 -1
  81. package/dist/ui/assets/{session-jsonl-j0zMWVNK.js → session-jsonl-CjbA2mfG.js} +1 -1
  82. package/dist/ui/assets/{session-search-index-la9-q_G1.js → session-search-index-DKyMCIRb.js} +1 -1
  83. package/dist/ui/assets/{setup-feature-flags-remote-BTYJL90t.js → setup-feature-flags-remote-4aRL2v1V.js} +1 -1
  84. package/dist/ui/assets/{setup-model-catalog-D8Ea_olZ.js → setup-model-catalog-xzt4XzKs.js} +1 -1
  85. package/dist/ui/assets/{silent-renew-backoff-BtuCuxCi.js → silent-renew-backoff-BUhiQyS7.js} +1 -1
  86. package/dist/ui/assets/slicc-version-FUaX8_Vl.js +1 -0
  87. package/dist/ui/assets/{soundscape-CGUkUoeQ.js → soundscape-Cpy1E-nZ.js} +1 -1
  88. package/dist/ui/assets/{speak-CxwK7WUc.js → speak-Du4tcKVz.js} +1 -1
  89. package/dist/ui/assets/{sprinkle-manager-7If5XMR2.js → sprinkle-manager-DUVDawuh.js} +1 -1
  90. package/dist/ui/assets/{sprinkle-renderer-BZE6UauM.js → sprinkle-renderer-DxAXLFWp.js} +1 -1
  91. package/dist/ui/assets/{stdio-tty-BB4qV92F.js → stdio-tty-CipJs8Mm.js} +1 -1
  92. package/dist/ui/assets/{sudo-Bur3ckJR.js → sudo-N3ES_yIz.js} +1 -1
  93. package/dist/ui/assets/{supervisor-BoiwgqlW.js → supervisor-yb8fat4x.js} +1 -1
  94. package/dist/ui/assets/{sync-dialog-CoFg-wC1.js → sync-dialog-pTWQG4zf.js} +1 -1
  95. package/dist/ui/assets/sync-exec-dispatch-B-gdI8lu.js +1 -0
  96. package/dist/ui/assets/{sync-sab-responder-BmZDqqnK.js → sync-sab-responder-DlSgon7c.js} +1 -1
  97. package/dist/ui/assets/{transformers-env-CvumQVfQ.js → transformers-env-CDipGBbT.js} +1 -1
  98. package/dist/ui/assets/{tray-leader-B4zwhLBC.js → tray-leader-JZcY_AKg.js} +1 -1
  99. package/dist/ui/assets/{tray-leave-runtime-gvronesJ.js → tray-leave-runtime-BYMhFVQv.js} +1 -1
  100. package/dist/ui/assets/{tray-sidecar-DOIJd5vJ.js → tray-sidecar-1Q-OhirE.js} +1 -1
  101. package/dist/ui/assets/{upgrade-detection-DbUZ5LnM.js → upgrade-detection-COjImWh-.js} +1 -1
  102. package/dist/ui/assets/{voice-reply-CMQ06Wn-.js → voice-reply-DsPjL5l1.js} +1 -1
  103. package/dist/ui/assets/{wc-attach-CtS_GXt-.js → wc-attach-rtUbV5PZ.js} +2 -2
  104. package/dist/ui/assets/{wc-browser-DjJiSTyC.js → wc-browser-DPaBVvzQ.js} +1 -1
  105. package/dist/ui/assets/{wc-computers-hk2xbTfE.js → wc-computers-CYTchiSB.js} +1 -1
  106. package/dist/ui/assets/{wc-detached-Cwjv2dxL.js → wc-detached-DhYRiQ8m.js} +1 -1
  107. package/dist/ui/assets/{wc-extension-ClEdff6M.js → wc-extension-CWYr1L8A.js} +2 -2
  108. package/dist/ui/assets/{wc-follower-Bf76brRQ.js → wc-follower-Dbsl0I7s.js} +3 -3
  109. package/dist/ui/assets/{wc-follower-oauth-BZYWuEQu.js → wc-follower-oauth-qh9ruLxg.js} +1 -1
  110. package/dist/ui/assets/{wc-gelatiere-Cs0ORVhQ.js → wc-gelatiere-BLcHmhFb.js} +1 -1
  111. package/dist/ui/assets/{wc-live-C-qevd3g.js → wc-live-G7p_45yP.js} +5 -5
  112. package/dist/ui/assets/{wc-nav-Rophsgk9.js → wc-nav-BL2hYnNf.js} +2 -2
  113. package/dist/ui/assets/{wc-onboarding-Caj_waOY.js → wc-onboarding-CJFEu5mU.js} +2 -2
  114. package/dist/ui/assets/{wc-permissions-D9yyGqLl.js → wc-permissions-CqKn9BBO.js} +2 -2
  115. package/dist/ui/assets/{wc-placeholder-BfxhJIh1.js → wc-placeholder-LVt-As7o.js} +3 -3
  116. package/dist/ui/assets/{wc-secret-request-DqxZuJUL.js → wc-secret-request-ryN5uoXN.js} +1 -1
  117. package/dist/ui/assets/{wc-settings-Bh44ZTl-.js → wc-settings-DCNUE5q3.js} +3 -3
  118. package/dist/ui/assets/{wc-shell-CJLjywlF.js → wc-shell-YAIg1dQz.js} +3 -3
  119. package/dist/ui/assets/{wc-shortcut-config-Cz7Vv65u.js → wc-shortcut-config-DeOptzeG.js} +1 -1
  120. package/dist/ui/assets/{wc-sprinkles-DVTcJSN3.js → wc-sprinkles-C7nWwTw7.js} +2 -2
  121. package/dist/ui/assets/{wc-transcript-export-CE_ns2-x.js → wc-transcript-export-DSn9BmBf.js} +2 -2
  122. package/dist/ui/assets/{wc-tray-DSEM6WbT.js → wc-tray-DYXO7SA9.js} +4 -4
  123. package/dist/ui/assets/welcome-detection-By9W44RJ.js +1 -0
  124. package/dist/ui/assets/{whisper-session-BycheH59.js → whisper-session-CEY5-9vS.js} +2 -2
  125. package/dist/ui/assets/{xai-grok-Xy7OSykN.js → xai-grok-BPcVCGo0.js} +1 -1
  126. package/dist/ui/assets/{xai-grok-CW0J74cE.js → xai-grok-CxgP5e0A.js} +1 -1
  127. package/dist/ui/index.html +3 -3
  128. package/dist/ui/llm-proxy-sw.js +1 -1
  129. package/dist/ui/packages/webapp/index.html +3 -3
  130. package/package.json +2 -2
  131. package/dist/ui/assets/provider-store-access-BmLF3yiQ.js +0 -1
  132. package/dist/ui/assets/provider-store-access-qocbyVYP.js +0 -1
  133. package/dist/ui/assets/run-Cf2apntf.js +0 -18
  134. package/dist/ui/assets/slicc-version-_RfsCQCx.js +0 -1
  135. package/dist/ui/assets/sync-exec-dispatch-DSTbkRmG.js +0 -1
  136. package/dist/ui/assets/welcome-detection-BxKU2eoh.js +0 -1
@@ -1,4 +1,4 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import{r as t,t as n}from"./base64-BPBW1Gzr.js";import{n as r}from"./bridge-protocol-31SWTdS5.js";import{a as i,n as a,o,s,t as c}from"./handoff-link-B3It6xQY.js";import{C as l,d as u,f as d,i as f,u as p}from"./account-store-D7DGAxNM.js";import{c as m,d as h,n as g,r as _,s as v}from"./proxied-fetch-F-dCBEfh.js";import{t as ee}from"./runtime-env-DadgceZk.js";import{t as te}from"./slugify-BYJ6QVAt.js";import{i as ne,n as re,r as ie,t as ae}from"./host-command-CwRNpVLr.js";import{a as oe,i as se,n as ce,r as le,t as ue}from"./snapshot-Dtq5VBeA.js";import{n as de,t as y}from"./panel-rpc-accessor-B4BfPLSo.js";import{a as fe,c as pe,n as me,o as he,s as ge,t as _e}from"./feature-flags-QlgHaQc1.js";import{t as ve}from"./providers-Dz9lZ6WH.js";import{r as ye}from"./binary-cache-bSOhqXB1.js";import{i as be,n as xe,r as Se}from"./fetch-body-CuwTaJC_.js";import{s as Ce,t as we}from"./api-endpoint-D8lUKmPu.js";import{t as Te}from"./compat-nGhSz-U1.js";import"./core-C1m4D34S.js";import{n as Ee,t as De}from"./mime-types-D7IV6i7k.js";import{n as Oe,t as ke}from"./float-topology-COIC4j_U.js";import{t as Ae}from"./secrets-bridge-client-GOCzDscb.js";import{a as je,i as Me,n as Ne,r as Pe}from"./tool-ui-DRnUkp2g.js";import{a as Fe,i as Ie,n as b,t as x}from"./path-utils-DNJG-zQf.js";import{n as Le,r as Re,t as ze}from"./merge-file-core-VJlzucJY.js";import{n as Be,t as Ve}from"./types-D8gIX-W-.js";import{i as He}from"./mount-index-CQfmUPuZ.js";import{a as Ue,i as We,n as Ge,o as Ke,s as qe,t as Je}from"./signed-fetch-DeDG40wV.js";import{o as Ye}from"./mount-table-store-DrF_Ifaz.js";import{t as Xe}from"./remote-cache-UwMD8EkX.js";import{n as Ze}from"./fs-CKSBDyCr.js";import{a as Qe}from"./tray-leader-status-CpkFr6n7.js";import{n as $e,t as et}from"./slicc-version-_RfsCQCx.js";import{a as tt,i as nt,o as rt,r as S,t as it}from"./browser-Jlk38XAj.js";import{t as C}from"./subcommand-flags-BZi7j78Q.js";import{n as at,r as ot,t as w}from"./subcommand-help-CgO7wRS5.js";import{n as st}from"./cost-command-05RLVzlt.js";import{d as ct,g as lt,i as ut,n as dt,o as ft}from"./sudoers-BdBYQPUn.js";import{t as pt}from"./sudo-refusal-DVwTXFRE.js";import{n as mt}from"./types-Dj5TU-Qg.js";import{a as ht,c as gt,i as _t,l as vt,n as yt,o as bt,r as xt,t as St}from"./types-JfhqX7lD.js";import{n as T,t as Ct}from"./boundary-DjgipyWT.js";import"./rest-paths-Dia19u9P.js";import{t as wt}from"./html-B_Hg2WOy.js";import{n as Tt}from"./llm-session-id-BZyXP_j2.js";import{t as Et}from"./src-CUSndb9K.js";import{i as Dt,o as Ot}from"./browser-DuyhpHbR.js";import{a as kt,c as At,n as jt,o as Mt,r as Nt,s as Pt,t as Ft}from"./reason-l_1I9RdR.js";import{i as It,r as Lt,t as Rt}from"./mount-picker-popup-BMils9JY.js";import{t as zt}from"./buffer-B5d1xHaH.js";import"./buffer-polyfill-BwLbCySD.js";import{A as Bt,B as E,C as Vt,D,E as Ht,F as Ut,G as Wt,H as O,I as k,J as Gt,K as Kt,L as qt,M as Jt,N as Yt,O as Xt,P as Zt,R as Qt,S as $t,T as en,U as tn,V as nn,W as rn,Y as an,_ as on,a as sn,b as cn,c as ln,d as un,f as dn,g as fn,h as pn,i as mn,j as hn,k as gn,l as _n,m as vn,n as yn,o as bn,p as A,q as xn,r as Sn,s as Cn,t as wn,u as Tn,v as En,w as Dn,x as On,y as kn,z as An}from"./isomorphic-git-r9mnHMnp.js";import"./global-db-DJXlpNui.js";import{S as jn,_ as Mn,a as Nn,b as Pn,c as Fn,d as In,f as Ln,g as Rn,h as zn,i as Bn,l as Vn,n as Hn,o as Un,p as Wn,r as Gn,s as Kn,t as qn,u as Jn,v as j,x as M,y as Yn}from"./state-Tykh4Vum.js";import{a as Xn,i as Zn,r as Qn,t as $n}from"./git-config-Bdgu8kD2.js";import{h as er,i as tr,r as nr}from"./stdio-tty-BB4qV92F.js";import{i as rr,r as ir}from"./global-prefix-DqCuANmV.js";import{t as ar}from"./wasm-programs-Bd5YaoqY.js";import{a as or,n as sr,o as cr,r as lr,s as ur}from"./jsh-discovery-CnvNKojr.js";import{C as dr,a as fr,b as pr,c as mr,d as hr,f as gr,h as _r,i as vr,l as yr,m as br,n as xr,o as Sr,p as Cr,r as wr,s as Tr,t as N,u as Er,v as Dr,y as Or}from"./shared-D-ZRFYou.js";import{_ as kr,a as Ar,b as jr,d as Mr,f as Nr,g as Pr,h as Fr,i as Ir,l as Lr,m as Rr,p as zr,r as Br,s as Vr,u as Hr,v as Ur,x as Wr,y as Gr}from"./require-guards-DnafTLJr.js";import{_ as Kr,a as qr,b as Jr,c as Yr,d as Xr,f as Zr,g as Qr,h as $r,l as ei,m as ti,n as ni,p as ri,s as ii,t as ai,u as oi,v as si,x as ci,y as li}from"./jsh-executor-UfR3L63B.js";import{n as ui,t as di}from"./esbuild-wasm-DeTghvWH.js";import{n as fi}from"./wasm-compiler-Ct7QZURL.js";import{a as pi,o as mi,s as hi,t as gi}from"./usb-device-registry-DFzxaOky.js";import{a as P,i as _i,r as vi,t as yi}from"./just-bash-compat-B-SPHuh_.js";import{i as bi,r as xi,t as Si}from"./script-catalog-WaCMvXY3.js";import{a as Ci,c as wi,o as Ti,s as Ei,t as Di}from"./types-Dzr0qYl3.js";import{a as Oi,c as ki,d as Ai,f as ji,n as Mi,r as Ni,u as Pi}from"./github-zip-CUIsX5nN.js";import{i as Fi,t as Ii}from"./github-auth-CSG4xZUZ.js";import{a as Li,i as Ri,o as zi,r as Bi,t as Vi}from"./provenance-DdmsQ3Nr.js";import{a as Hi,c as Ui,i as Wi,n as Gi,o as Ki,r as qi,s as Ji}from"./github-install-HX3c8n0G.js";import{n as Yi,t as Xi}from"./magick-wasm-BbnwhVj1.js";import{i as Zi,n as Qi,r as $i,t as ea}from"./pdf-raster-BWk6ezTX.js";import{n as ta}from"./lick-target-env-8JxfVcIV.js";import{t as na}from"./tmpdir-env-ate4iNcK.js";import{n as ra,t as ia}from"./hf-defaults-BwJdGLgk.js";import{t as aa}from"./ffmpeg-wasm-sx-3yVAE.js";import{t as oa}from"./local-llm-DAdQyx68.js";import{i as sa,n as ca,r as la,t as ua}from"./tar-BWIPCxI2.js";import{a as da,c as fa,i as pa,o as ma,r as ha,s as ga}from"./v86-vm-DCm7zA2r.js";import{n as _a,r as va}from"./lick-urls-CgPiVwD-.js";let ya=null;function ba(e){ya=e!==null&&Number.isFinite(e)&&e>0?e:null}function xa(){if(ya!==null)return ya;let e=globalThis.performance?.timeOrigin;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:Date.now()}new URL(r).hostname;const Sa=/^([0-9a-f]{32})--(?:[0-9a-f]{8}-)?([0-9a-f]+)$/i;function Ca(e){let t;try{t=new URL(e.includes(`://`)?e:`https://${e}`).hostname}catch{return null}let n=Sa.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 wa(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 Ta(e,t){return e.some(e=>wa(e,t))}const Ea=`slicc-transcript`,Da=[`canonical-agent-history-unavailable`,`tool-data-may-be-truncated`,`model-metadata-unavailable`,`scoop-history-unavailable`,`attachment-file-missing`,`attachment-association-unavailable`,`complete-snapshot-unavailable`],Oa=new Set(`/export/format./export/producer/application./session/id./session/state./session/completeness/status./session/completeness/missing/*./conversations/*/id./conversations/*/kind./conversations/*/parentConversationId./conversations/*/messages/*/id./conversations/*/messages/*/role./conversations/*/messages/*/timestamp./conversations/*/messages/*/toolCallId./conversations/*/messages/*/content/*/type./conversations/*/messages/*/content/*/id./conversations/*/messages/*/content/*/name./conversations/*/messages/*/content/*/attachmentId./delegations/*/sourceConversationId./delegations/*/targetConversationId./delegations/*/toolCallId./attachments/*/id./attachments/*/path./attachments/*/sha256./attachments/*/sourceConversationId./attachments/*/sourceMessageId./attachments/*/handling./attachments/*/missingReason`.split(`.`));function ka(e){return Oa.has(e.replace(/\/\d+(?=\/|$)/g,`/*`))}var Aa=class extends Error{code;detail;constructor(e,t){super(t?`${e}: ${t}`:e),this.code=e,this.detail=t,this.name=`TranscriptExportError`}};const ja=new Set(Da),Ma=/^[0-9a-fA-F]{64}$/,Na=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/;function F(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pa(e){return typeof e==`string`&&Ma.test(e)}function Fa(e){return Na.test(e)&&Number.isFinite(Date.parse(e))}function Ia(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 La(e,t,n){return typeof e!=`string`||!t.includes(e)?{ok:!1,error:Ia(n,t)}:{ok:!0}}function Ra(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 za(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 Ba(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};let n=La(e.type,[`text`,`tool-call`,`attachment-ref`],`${t}.type`);return n.ok?za(e,t):n}function Va(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 Ha(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 Ua(e,t){let n=Va(e,t);if(!n.ok)return n;let r=e.cost;return F(r)?Ha(r,`${t}.cost`):{ok:!1,error:`${t}.cost must be a non-null object`}}function Wa(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`?Fa(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 Ga(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 Ka(e,t){let n=e.usage;return n===void 0?{ok:!0}:F(n)?Ua(n,`${t}.usage`):{ok:!1,error:`${t}.usage must be a non-null object`}}function qa(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};let n=La(e.role,[`user`,`assistant`,`tool-result`],`${t}.role`);if(!n.ok)return n;if(e.role===`tool-result`){let n=Ga(e,t);if(!n.ok)return n}let r=Wa(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=Ra(i,Ba,`${t}.content`);return a.ok?Ka(e,t):a}function Ja(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};if(typeof e.id!=`string`)return{ok:!1,error:`${t}.id must be a string`};if(typeof e.name!=`string`)return{ok:!1,error:`${t}.name must be a string`};let n=La(e.kind,[`cone`,`scoop`],`${t}.kind`);if(!n.ok)return n;let r=e.messages;return Array.isArray(r)?Ra(r,qa,`${t}.messages`):{ok:!1,error:`${t}.messages must be an array`}}function Ya(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 Xa(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`}:Pa(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 Za=[`attachment-file-missing`,`attachment-association-unavailable`];function Qa(e,t){let n=e.path,r=e.sha256,i=e.byteLength;return n===``?r===``?i===0?La(e.missingReason,Za,`${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 $a(e,t){return e.present?Xa(e,t):Qa(e,t)}function eo(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};let n=Ya(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=La(e.handling,[`text-redacted`,`binary-unchanged`],`${t}.handling`);return r.ok?$a(e,t):r}function to(e,t){let n=La(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 no(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};if(typeof e.id!=`string`)return{ok:!1,error:`${t}.id must be a string`};if(typeof e.category!=`string`)return{ok:!1,error:`${t}.category must be a string`};let n=La(e.detector,[`known-secret`,`credential-pattern`,`pre-obfuscated`],`${t}.detector`);if(!n.ok)return n;let r=e.target;return F(r)?to(r,`${t}.target`):{ok:!1,error:`${t}.target must be a non-null object`}}function ro(e,t){return F(e)?typeof e.sourceConversationId==`string`?typeof e.targetConversationId==`string`?{ok:!0}:{ok:!1,error:`${t}.targetConversationId must be a string`}:{ok:!1,error:`${t}.sourceConversationId must be a string`}:{ok:!1,error:`${t} must be a non-null object`}}function io(e,t){return typeof e!=`string`||!ja.has(e)?{ok:!1,error:`${t} is not a valid completeness reason`}:{ok:!0}}function ao(e){if(!F(e))return{ok:!1,error:`export must be a non-null object`};if(typeof e.id!=`string`)return{ok:!1,error:`export.id must be a string`};if(typeof e.generatedAt!=`string`)return{ok:!1,error:`export.generatedAt must be a string`};if(e.format!==`slicc-transcript`)return{ok:!1,error:`export.format must equal "slicc-transcript"`};let t=e.producer;return F(t)?t.application===`slicc`?typeof t.version==`string`?{ok:!0}:{ok:!1,error:`export.producer.version must be a string`}:{ok:!1,error:`export.producer.application must equal "slicc"`}:{ok:!1,error:`export.producer must be a non-null object`}}function oo(e){if(!F(e))return{ok:!1,error:`session.completeness must be a non-null object`};let t=La(e.status,[`complete`,`partial`],`session.completeness.status`);return t.ok?Array.isArray(e.missing)?Ra(e.missing,io,`session.completeness.missing`):{ok:!1,error:`session.completeness.missing must be an array`}:t}function so(e){if(!F(e))return{ok:!1,error:`session must be a non-null object`};if(typeof e.id!=`string`)return{ok:!1,error:`session.id must be a string`};if(typeof e.title!=`string`)return{ok:!1,error:`session.title must be a string`};let t=La(e.state,[`active`,`frozen`],`session.state`);return t.ok?oo(e.completeness):t}function co(e){if(!F(e))return{ok:!1,error:`privacy must be a non-null object`};if(e.reasoningExcluded!==!0)return{ok:!1,error:`privacy.reasoningExcluded must be true`};let t=e.excludedReasoningBlocks;if(typeof t!=`number`)return{ok:!1,error:`privacy.excludedReasoningBlocks must be a number`};if(!Number.isInteger(t)||t<0)return{ok:!1,error:`privacy.excludedReasoningBlocks must be a non-negative integer`};if(e.binaryAttachments!==`included-unchanged`)return{ok:!1,error:`privacy.binaryAttachments must equal "included-unchanged"`};if(!F(e.redactionCounts))return{ok:!1,error:`privacy.redactionCounts must be a non-null object`};let n=e.redactions;return Array.isArray(n)?Ra(n,no,`privacy.redactions`):{ok:!1,error:`privacy.redactions must be an array`}}function lo(e){let t=e.conversations;if(!Array.isArray(t))return{ok:!1,error:`conversations must be an array`};let n=Ra(t,Ja,`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=Ra(r,ro,`delegations`);if(!i.ok)return i;let a=e.attachments;return Array.isArray(a)?Ra(a,eo,`attachments`):{ok:!1,error:`attachments must be an array`}}function uo(e){let t=new Set,n=new Set;for(let r of e){if(!F(r)||typeof r.id!=`string`)continue;if(t.has(r.id))return{ok:!1,error:`duplicate conversation id "${r.id}"`};t.add(r.id);let e=r.messages;if(Array.isArray(e)){for(let t of e)if(!(!F(t)||typeof t.id!=`string`)){if(n.has(t.id))return{ok:!1,error:`duplicate message id "${t.id}"`};n.add(t.id)}}}return{ok:!0}}function fo(e){for(let t of e){if(!F(t))continue;let e=t.messages;if(!Array.isArray(e))continue;let n=typeof t.id==`string`?t.id:`?`,r=0;for(let t of e){if(!F(t)||typeof t.sequence!=`number`)continue;let e=t.sequence;if(e<=r)return{ok:!1,error:`sequences in conversation "${n}" must be strictly increasing`};r=e}}return{ok:!0}}function po(e){let t=[];for(let n of e){if(!F(n))continue;let e=n.content;if(Array.isArray(e))for(let n of e)F(n)&&n.type===`tool-call`&&typeof n.id==`string`&&t.push(n.id)}return t}function mo(e){let t=new Set;for(let n of e){if(!F(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of po(e))t.add(n)}return t}function ho(e,t){for(let n of e){if(!F(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of e){if(!F(n)||n.role!==`tool-result`)continue;let e=n.toolCallId;if(typeof e==`string`&&e!==``&&!t.has(e))return{ok:!1,error:`tool-result message references unknown toolCallId "${e}"`}}}return{ok:!0}}function go(e){return ho(e,mo(e))}function _o(e,t){for(let n of e){if(!F(n)||n.type!==`attachment-ref`)continue;let e=n.attachmentId;if(typeof e!=`string`||!t.has(e))return{ok:!1,error:`attachment-ref references unknown attachmentId "${e}"`}}return{ok:!0}}function vo(e,t){for(let n of e){if(!F(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of e){if(!F(n))continue;let e=n.content;if(!Array.isArray(e))continue;let r=_o(e,t);if(!r.ok)return r}}return{ok:!0}}function yo(e,t){let n=new Set;for(let e of t)F(e)&&typeof e.id==`string`&&n.add(e.id);return vo(e,n)}function bo(e){let t=new Map;for(let n of e){if(!F(n)||typeof n.id!=`string`)continue;let e=new Set,r=n.messages;if(Array.isArray(r))for(let t of r)F(t)&&typeof t.id==`string`&&e.add(t.id);t.set(n.id,e)}return t}function xo(e,t){let n=bo(t);for(let t=0;t<e.length;t++){let r=e[t];if(!F(r))continue;let i=r.sourceConversationId,a=r.sourceMessageId;if(typeof i!=`string`||typeof a!=`string`)continue;let o=n.get(i);if(!o)return{ok:!1,error:`attachments[${t}].sourceConversationId "${i}" does not exist`};if(!o.has(a))return{ok:!1,error:`attachments[${t}].sourceMessageId "${a}" does not exist in conversation "${i}"`}}return{ok:!0}}function So(e){let t=new Map;for(let n of e){if(!F(n)||typeof n.id!=`string`)continue;let e=Array.isArray(n.messages)?n.messages:[];t.set(n.id,new Set(po(e)))}return t}function Co(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];if(!F(i))continue;let a=i.sourceConversationId,o=i.targetConversationId;if(typeof a!=`string`||!t.has(a))return{ok:!1,error:`delegations[${r}].sourceConversationId "${a}" does not exist`};if(typeof o!=`string`||!t.has(o))return{ok:!1,error:`delegations[${r}].targetConversationId "${o}" does not exist`};let s=i.toolCallId;if(typeof s==`string`&&s!==``&&!n.get(a)?.has(s))return{ok:!1,error:`delegations[${r}].toolCallId "${s}" does not exist in source conversation "${a}"`}}return{ok:!0}}function wo(e,t){let n=new Set;for(let e of t)F(e)&&typeof e.id==`string`&&n.add(e.id);return Co(e,n,So(t))}function To(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 Eo(e,t){let n=new Set;for(let e of t)F(e)&&typeof e.id==`string`&&n.add(e.id);for(let t=0;t<e.length;t++){let r=e[t];if(!F(r))continue;let i=r.target;if(!F(i))continue;let a=To(i,n,`privacy.redactions[${t}].target`);if(!a.ok)return a}return{ok:!0}}function Do(e){let t=e.conversations,n=e.attachments,r=e.delegations,i=e.privacy,a=Array.isArray(i?.redactions)?i.redactions:[],o=uo(t);if(!o.ok)return o;let s=fo(t);if(!s.ok)return s;let c=go(t);if(!c.ok)return c;let l=yo(t,n);if(!l.ok)return l;let u=xo(n,t);if(!u.ok)return u;let d=wo(r,t);return d.ok?Eo(a,n):d}function Oo(e){let t=lo(e);return t.ok?Do(e):t}function ko(e){if(!F(e))return{ok:!1,error:`document must be a non-null object`};if(e.schemaVersion!==1)return{ok:!1,error:`schemaVersion must equal 1`};let t=ao(e.export);if(!t.ok)return t;let n=so(e.session);if(!n.ok)return n;let r=co(e.privacy);return r.ok?Oo(e):r}async function Ao(e,t,n){let r=await n({method:`GET`,path:`/${e}/sites/${t}/config.json`,origin:Ke});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:jo(a),sourceUrl:a}}function jo(e){if(!e)return`da`;let t;try{t=new URL(e).host}catch{return`da`}return t===`api.aem.live`?`aem`:`da`}const Mo=`slicc-sprinkle-routes`;function No(){try{let e=localStorage.getItem(Mo);return e?JSON.parse(e):{}}catch{return{}}}function Po(e){try{localStorage.setItem(Mo,JSON.stringify(e))}catch{}}function Fo(e){return No()[e]}function Io(e,t){let n=No();n[e]=t,Po(n)}function Lo(e){let t=No();delete t[e],Po(t)}function Ro(){return No()}function zo(e,t,n){return gt(t,n,`${e} adapter does not implement ${t}.${n}`)}function Bo(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(zo(e,t,n))]});return{...Object.fromEntries(a),allowlist:i,supports:e=>i.includes(e)}}function Vo(e){let{adapter:t,pageGestures:n}=e,r=n??{};return{adapter:t,browser:Bo(t,`browser`,yt,e.browser),network:Bo(t,`network`,ht,e.network),secrets:Bo(t,`secrets`,bt,e.secrets),devices:Bo(t,`devices`,xt,{usbRequest:r.usbRequest,serialRequest:r.serialRequest,hidRequest:r.hidRequest,...e.devices}),mounts:Bo(t,`mounts`,_t,{pickDirectory:r.pickDirectory,...e.mounts}),approvals:Bo(t,`approvals`,St,e.approvals)}}function Ho(e={}){return Vo({adapter:`connect`,pageGestures:e.pageGestures})}function Uo(e){let t=Ct(()=>import(`./extension-ops-OtrqWANJ.js`).then(t=>t.createExtensionOps(e)));return Vo({adapter:e.adapter,pageGestures:e.pageGestures,network:{crossOriginFetch:e=>T(`network`,`crossOriginFetch`,async()=>(await t()).crossOriginFetch(e))},secrets:{listMaskedEnv:()=>T(`secrets`,`listMaskedEnv`,async()=>(await t()).secrets.listMaskedEnv()),getMasked:e=>T(`secrets`,`getMasked`,async()=>(await t()).secrets.getMasked(e)),set:e=>T(`secrets`,`set`,async()=>(await t()).secrets.set(e)),delete:e=>T(`secrets`,`delete`,async()=>(await t()).secrets.delete(e))},mounts:{signRequest:e=>T(`mounts`,`signRequest`,async()=>(await t()).signRequest(e))},approvals:{request:e=>T(`approvals`,`request`,async()=>(await t()).requestApproval(e))}})}function Wo(e={}){let t=Ct(()=>import(`./rest-ops-j0P6ql7f.js`).then(t=>t.createRestOps(e)),e.controlTimeoutMs??1e4);return Vo({adapter:`node-rest`,pageGestures:e.pageGestures,network:{localNodeServer:()=>Promise.resolve({ok:!0,value:{available:!0}}),crossOriginFetch:e=>T(`network`,`crossOriginFetch`,async()=>(await t()).crossOriginFetch(e))},secrets:{listMaskedEnv:()=>T(`secrets`,`listMaskedEnv`,async()=>(await t()).secrets.listMaskedEnv()),getMasked:e=>T(`secrets`,`getMasked`,async()=>(await t()).secrets.getMasked(e)),set:e=>T(`secrets`,`set`,async()=>(await t()).secrets.set(e)),delete:e=>T(`secrets`,`delete`,async()=>(await t()).secrets.delete(e))},mounts:{signRequest:e=>T(`mounts`,`signRequest`,async()=>(await t()).signRequest(e))},approvals:{request:e=>T(`approvals`,`request`,async()=>(await t()).requestApproval(e))}})}function Go(e,t={}){let{pageGestures:n}=t;switch(e){case`node-rest`:return Wo({pageGestures:n});case`extension-direct`:case`extension-delegate`:return Uo({adapter:e,pageGestures:n});case`connect`:return Ho({pageGestures:n})}}const Ko=e(`quick-llm`);async function qo(e){let t=f();if(!t)return Ko.debug(`No API key for active provider — skipping`),null;let n=d(),r=u(),i;if(i=e.modelId?Zo(n,e.modelId)??Zo(n,r):Jo(n,r),!i)return Ko.debug(`No model available for provider`,{providerId:n}),null;let a={role:`user`,content:e.prompt,timestamp:Date.now()},o={};i.provider===`adobe`&&(o[`X-Session-Id`]=Qo());try{let n=(await Te(i,{systemPrompt:e.system,messages:[a]},{apiKey:t,maxTokens:e.maxTokens??60,temperature:e.temperature??.3,signal:e.signal,headers:Object.keys(o).length>0?o:void 0})).content.filter(e=>e.type===`text`).map(e=>e.text).join(``).trim();return n.length>0?n:null}catch(e){return Ko.debug(`Quick label call failed`,{error:e instanceof Error?e.message:String(e)}),null}}function Jo(e,t){let n=p(e);if(n.length===0)return;let r=n.find(e=>e.id===t)??n[0],i=Xo(r.id),a=n.filter(e=>Yo(e,r,i));return a.length===0?r:(a.sort((e,t)=>(e.cost?.input??0)-(t.cost?.input??0)),a[0])}function Yo(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 Xo(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 Zo(e,t){return p(e).find(e=>e.id===t)}function Qo(){return Tt(`ui-quick-llm`)}const $o=e(`sudo-suggest`),es=[`You generalize a single shell command into a minimal glob pattern for an`,`allow-list rule. Output ONLY the pattern on one line — no prose, no quotes,`,`no backticks. Keep the leading command/sub-command verbatim and replace only`,`the volatile tail (args, paths, refs) with a single trailing "*".`,`Examples:`,` git push origin main -> git push*`,` rm -rf build/cache -> rm -rf*`,` npm install left-pad -> npm install*`].join(`
1
+ import{t as e}from"./logger-LESFN7Hj.js";import{r as t,t as n}from"./base64-BPBW1Gzr.js";import{n as r}from"./bridge-protocol-31SWTdS5.js";import{a as i,n as a,o,s,t as c}from"./handoff-link-B3It6xQY.js";import{C as l,d as u,f as d,i as f,u as p}from"./account-store-D0xdiy20.js";import{c as m,d as h,n as g,r as _,s as v}from"./proxied-fetch-F-dCBEfh.js";import{t as ee}from"./runtime-env-DadgceZk.js";import{t as te}from"./slugify-BYJ6QVAt.js";import{i as ne,n as re,r as ie,t as ae}from"./host-command-CwRNpVLr.js";import{a as oe,i as se,n as ce,r as le,t as ue}from"./snapshot-Dtq5VBeA.js";import{n as de,t as y}from"./panel-rpc-accessor-B4BfPLSo.js";import{a as fe,c as pe,n as me,o as he,s as ge,t as _e}from"./feature-flags-QlgHaQc1.js";import{t as ve}from"./providers-DS41fGUE.js";import{r as ye}from"./binary-cache-bSOhqXB1.js";import{i as be,n as xe,r as Se}from"./fetch-body-CuwTaJC_.js";import{s as Ce,t as we}from"./api-endpoint-D8lUKmPu.js";import{t as Te}from"./compat-nGhSz-U1.js";import"./core-C1m4D34S.js";import{n as Ee,t as De}from"./mime-types-D7IV6i7k.js";import{n as Oe,t as ke}from"./float-topology-COIC4j_U.js";import{t as Ae}from"./secrets-bridge-client-GOCzDscb.js";import{a as je,i as Me,n as Ne,r as Pe}from"./tool-ui-DRnUkp2g.js";import{a as Fe,i as Ie,n as b,t as x}from"./path-utils-DNJG-zQf.js";import{n as Le,r as Re,t as ze}from"./merge-file-core-VJlzucJY.js";import{n as Be,t as Ve}from"./types-D8gIX-W-.js";import{i as He}from"./mount-index-CQfmUPuZ.js";import{a as Ue,i as We,n as Ge,o as Ke,s as qe,t as Je}from"./signed-fetch-DeDG40wV.js";import{o as Ye}from"./mount-table-store-DrF_Ifaz.js";import{t as Xe}from"./remote-cache-UwMD8EkX.js";import{n as Ze}from"./fs-CKSBDyCr.js";import{a as Qe}from"./tray-leader-status-CpkFr6n7.js";import{n as $e,t as et}from"./slicc-version-FUaX8_Vl.js";import{a as tt,i as nt,o as rt,r as S,t as it}from"./browser-Jlk38XAj.js";import{t as C}from"./subcommand-flags-BZi7j78Q.js";import{n as at,r as ot,t as w}from"./subcommand-help-CgO7wRS5.js";import{n as st}from"./cost-command-05RLVzlt.js";import{d as ct,g as lt,i as ut,n as dt,o as ft}from"./sudoers-BdBYQPUn.js";import{t as pt}from"./sudo-refusal-DVwTXFRE.js";import{n as mt}from"./types-Dj5TU-Qg.js";import{a as ht,c as gt,i as _t,l as vt,n as yt,o as bt,r as xt,t as St}from"./types-JfhqX7lD.js";import{n as T,t as Ct}from"./boundary-DjgipyWT.js";import"./rest-paths-Dia19u9P.js";import{t as wt}from"./html-B_Hg2WOy.js";import{n as Tt}from"./llm-session-id-BZyXP_j2.js";import{t as Et}from"./src-CUSndb9K.js";import{i as Dt,o as Ot}from"./browser-DuyhpHbR.js";import{a as kt,c as At,n as jt,o as Mt,r as Nt,s as Pt,t as Ft}from"./reason-l_1I9RdR.js";import{i as It,r as Lt,t as Rt}from"./mount-picker-popup-BMils9JY.js";import{t as zt}from"./buffer-B5d1xHaH.js";import"./buffer-polyfill-BwLbCySD.js";import{A as Bt,B as E,C as Vt,D,E as Ht,F as Ut,G as Wt,H as O,I as k,J as Gt,K as Kt,L as qt,M as Jt,N as Yt,O as Xt,P as Zt,R as Qt,S as $t,T as en,U as tn,V as nn,W as rn,Y as an,_ as on,a as sn,b as cn,c as ln,d as un,f as dn,g as fn,h as pn,i as mn,j as hn,k as gn,l as _n,m as vn,n as yn,o as bn,p as A,q as xn,r as Sn,s as Cn,t as wn,u as Tn,v as En,w as Dn,x as On,y as kn,z as An}from"./isomorphic-git-r9mnHMnp.js";import"./global-db-DJXlpNui.js";import{S as jn,_ as Mn,a as Nn,b as Pn,c as Fn,d as In,f as Ln,g as Rn,h as zn,i as Bn,l as Vn,n as Hn,o as Un,p as Wn,r as Gn,s as Kn,t as qn,u as Jn,v as j,x as M,y as Yn}from"./state-Tykh4Vum.js";import{a as Xn,i as Zn,r as Qn,t as $n}from"./git-config-Bdgu8kD2.js";import{h as er,i as tr,r as nr}from"./stdio-tty-CipJs8Mm.js";import{i as rr,r as ir}from"./global-prefix-DqCuANmV.js";import{t as ar}from"./wasm-programs-Bd5YaoqY.js";import{a as or,n as sr,o as cr,r as lr,s as ur}from"./jsh-discovery-CnvNKojr.js";import{C as dr,a as fr,b as pr,c as mr,d as hr,f as gr,h as _r,i as vr,l as yr,m as br,n as xr,o as Sr,p as Cr,r as wr,s as Tr,t as N,u as Er,v as Dr,y as Or}from"./shared-D-ZRFYou.js";import{_ as kr,a as Ar,b as jr,d as Mr,f as Nr,g as Pr,h as Fr,i as Ir,l as Lr,m as Rr,p as zr,r as Br,s as Vr,u as Hr,v as Ur,x as Wr,y as Gr}from"./require-guards-6ovYBhVp.js";import{_ as Kr,a as qr,b as Jr,c as Yr,d as Xr,f as Zr,g as Qr,h as $r,l as ei,m as ti,n as ni,p as ri,s as ii,t as ai,u as oi,v as si,x as ci,y as li}from"./jsh-executor-DvcG7M6y.js";import{n as ui,t as di}from"./esbuild-wasm-DeTghvWH.js";import{n as fi}from"./wasm-compiler-Ct7QZURL.js";import{a as pi,o as mi,s as hi,t as gi}from"./usb-device-registry-DFzxaOky.js";import{a as P,i as _i,r as vi,t as yi}from"./just-bash-compat-B-SPHuh_.js";import{i as bi,r as xi,t as Si}from"./script-catalog-WaCMvXY3.js";import{a as Ci,c as wi,o as Ti,s as Ei,t as Di}from"./types-Dzr0qYl3.js";import{a as Oi,c as ki,d as Ai,f as ji,n as Mi,r as Ni,u as Pi}from"./github-zip-CUIsX5nN.js";import{i as Fi,t as Ii}from"./github-auth-CSG4xZUZ.js";import{a as Li,i as Ri,o as zi,r as Bi,t as Vi}from"./provenance-DdmsQ3Nr.js";import{a as Hi,c as Ui,i as Wi,n as Gi,o as Ki,r as qi,s as Ji}from"./github-install-HX3c8n0G.js";import{n as Yi,t as Xi}from"./magick-wasm-BbnwhVj1.js";import{i as Zi,n as Qi,r as $i,t as ea}from"./pdf-raster-BWk6ezTX.js";import{n as ta}from"./lick-target-env-8JxfVcIV.js";import{t as na}from"./tmpdir-env-ate4iNcK.js";import{n as ra,t as ia}from"./hf-defaults-BwJdGLgk.js";import{t as aa}from"./ffmpeg-wasm-sx-3yVAE.js";import{t as oa}from"./local-llm-C5n6HmT5.js";import{i as sa,n as ca,r as la,t as ua}from"./tar-BWIPCxI2.js";import{a as da,c as fa,i as pa,o as ma,r as ha,s as ga}from"./v86-vm-DCm7zA2r.js";import{n as _a,r as va}from"./lick-urls-CgPiVwD-.js";let ya=null;function ba(e){ya=e!==null&&Number.isFinite(e)&&e>0?e:null}function xa(){if(ya!==null)return ya;let e=globalThis.performance?.timeOrigin;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:Date.now()}new URL(r).hostname;const Sa=/^([0-9a-f]{32})--(?:[0-9a-f]{8}-)?([0-9a-f]+)$/i;function Ca(e){let t;try{t=new URL(e.includes(`://`)?e:`https://${e}`).hostname}catch{return null}let n=Sa.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 wa(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 Ta(e,t){return e.some(e=>wa(e,t))}const Ea=`slicc-transcript`,Da=[`canonical-agent-history-unavailable`,`tool-data-may-be-truncated`,`model-metadata-unavailable`,`scoop-history-unavailable`,`attachment-file-missing`,`attachment-association-unavailable`,`complete-snapshot-unavailable`],Oa=new Set(`/export/format./export/producer/application./session/id./session/state./session/completeness/status./session/completeness/missing/*./conversations/*/id./conversations/*/kind./conversations/*/parentConversationId./conversations/*/messages/*/id./conversations/*/messages/*/role./conversations/*/messages/*/timestamp./conversations/*/messages/*/toolCallId./conversations/*/messages/*/content/*/type./conversations/*/messages/*/content/*/id./conversations/*/messages/*/content/*/name./conversations/*/messages/*/content/*/attachmentId./delegations/*/sourceConversationId./delegations/*/targetConversationId./delegations/*/toolCallId./attachments/*/id./attachments/*/path./attachments/*/sha256./attachments/*/sourceConversationId./attachments/*/sourceMessageId./attachments/*/handling./attachments/*/missingReason`.split(`.`));function ka(e){return Oa.has(e.replace(/\/\d+(?=\/|$)/g,`/*`))}var Aa=class extends Error{code;detail;constructor(e,t){super(t?`${e}: ${t}`:e),this.code=e,this.detail=t,this.name=`TranscriptExportError`}};const ja=new Set(Da),Ma=/^[0-9a-fA-F]{64}$/,Na=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/;function F(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pa(e){return typeof e==`string`&&Ma.test(e)}function Fa(e){return Na.test(e)&&Number.isFinite(Date.parse(e))}function Ia(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 La(e,t,n){return typeof e!=`string`||!t.includes(e)?{ok:!1,error:Ia(n,t)}:{ok:!0}}function Ra(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 za(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 Ba(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};let n=La(e.type,[`text`,`tool-call`,`attachment-ref`],`${t}.type`);return n.ok?za(e,t):n}function Va(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 Ha(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 Ua(e,t){let n=Va(e,t);if(!n.ok)return n;let r=e.cost;return F(r)?Ha(r,`${t}.cost`):{ok:!1,error:`${t}.cost must be a non-null object`}}function Wa(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`?Fa(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 Ga(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 Ka(e,t){let n=e.usage;return n===void 0?{ok:!0}:F(n)?Ua(n,`${t}.usage`):{ok:!1,error:`${t}.usage must be a non-null object`}}function qa(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};let n=La(e.role,[`user`,`assistant`,`tool-result`],`${t}.role`);if(!n.ok)return n;if(e.role===`tool-result`){let n=Ga(e,t);if(!n.ok)return n}let r=Wa(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=Ra(i,Ba,`${t}.content`);return a.ok?Ka(e,t):a}function Ja(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};if(typeof e.id!=`string`)return{ok:!1,error:`${t}.id must be a string`};if(typeof e.name!=`string`)return{ok:!1,error:`${t}.name must be a string`};let n=La(e.kind,[`cone`,`scoop`],`${t}.kind`);if(!n.ok)return n;let r=e.messages;return Array.isArray(r)?Ra(r,qa,`${t}.messages`):{ok:!1,error:`${t}.messages must be an array`}}function Ya(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 Xa(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`}:Pa(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 Za=[`attachment-file-missing`,`attachment-association-unavailable`];function Qa(e,t){let n=e.path,r=e.sha256,i=e.byteLength;return n===``?r===``?i===0?La(e.missingReason,Za,`${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 $a(e,t){return e.present?Xa(e,t):Qa(e,t)}function eo(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};let n=Ya(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=La(e.handling,[`text-redacted`,`binary-unchanged`],`${t}.handling`);return r.ok?$a(e,t):r}function to(e,t){let n=La(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 no(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};if(typeof e.id!=`string`)return{ok:!1,error:`${t}.id must be a string`};if(typeof e.category!=`string`)return{ok:!1,error:`${t}.category must be a string`};let n=La(e.detector,[`known-secret`,`credential-pattern`,`pre-obfuscated`],`${t}.detector`);if(!n.ok)return n;let r=e.target;return F(r)?to(r,`${t}.target`):{ok:!1,error:`${t}.target must be a non-null object`}}function ro(e,t){return F(e)?typeof e.sourceConversationId==`string`?typeof e.targetConversationId==`string`?{ok:!0}:{ok:!1,error:`${t}.targetConversationId must be a string`}:{ok:!1,error:`${t}.sourceConversationId must be a string`}:{ok:!1,error:`${t} must be a non-null object`}}function io(e,t){return typeof e!=`string`||!ja.has(e)?{ok:!1,error:`${t} is not a valid completeness reason`}:{ok:!0}}function ao(e){if(!F(e))return{ok:!1,error:`export must be a non-null object`};if(typeof e.id!=`string`)return{ok:!1,error:`export.id must be a string`};if(typeof e.generatedAt!=`string`)return{ok:!1,error:`export.generatedAt must be a string`};if(e.format!==`slicc-transcript`)return{ok:!1,error:`export.format must equal "slicc-transcript"`};let t=e.producer;return F(t)?t.application===`slicc`?typeof t.version==`string`?{ok:!0}:{ok:!1,error:`export.producer.version must be a string`}:{ok:!1,error:`export.producer.application must equal "slicc"`}:{ok:!1,error:`export.producer must be a non-null object`}}function oo(e){if(!F(e))return{ok:!1,error:`session.completeness must be a non-null object`};let t=La(e.status,[`complete`,`partial`],`session.completeness.status`);return t.ok?Array.isArray(e.missing)?Ra(e.missing,io,`session.completeness.missing`):{ok:!1,error:`session.completeness.missing must be an array`}:t}function so(e){if(!F(e))return{ok:!1,error:`session must be a non-null object`};if(typeof e.id!=`string`)return{ok:!1,error:`session.id must be a string`};if(typeof e.title!=`string`)return{ok:!1,error:`session.title must be a string`};let t=La(e.state,[`active`,`frozen`],`session.state`);return t.ok?oo(e.completeness):t}function co(e){if(!F(e))return{ok:!1,error:`privacy must be a non-null object`};if(e.reasoningExcluded!==!0)return{ok:!1,error:`privacy.reasoningExcluded must be true`};let t=e.excludedReasoningBlocks;if(typeof t!=`number`)return{ok:!1,error:`privacy.excludedReasoningBlocks must be a number`};if(!Number.isInteger(t)||t<0)return{ok:!1,error:`privacy.excludedReasoningBlocks must be a non-negative integer`};if(e.binaryAttachments!==`included-unchanged`)return{ok:!1,error:`privacy.binaryAttachments must equal "included-unchanged"`};if(!F(e.redactionCounts))return{ok:!1,error:`privacy.redactionCounts must be a non-null object`};let n=e.redactions;return Array.isArray(n)?Ra(n,no,`privacy.redactions`):{ok:!1,error:`privacy.redactions must be an array`}}function lo(e){let t=e.conversations;if(!Array.isArray(t))return{ok:!1,error:`conversations must be an array`};let n=Ra(t,Ja,`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=Ra(r,ro,`delegations`);if(!i.ok)return i;let a=e.attachments;return Array.isArray(a)?Ra(a,eo,`attachments`):{ok:!1,error:`attachments must be an array`}}function uo(e){let t=new Set,n=new Set;for(let r of e){if(!F(r)||typeof r.id!=`string`)continue;if(t.has(r.id))return{ok:!1,error:`duplicate conversation id "${r.id}"`};t.add(r.id);let e=r.messages;if(Array.isArray(e)){for(let t of e)if(!(!F(t)||typeof t.id!=`string`)){if(n.has(t.id))return{ok:!1,error:`duplicate message id "${t.id}"`};n.add(t.id)}}}return{ok:!0}}function fo(e){for(let t of e){if(!F(t))continue;let e=t.messages;if(!Array.isArray(e))continue;let n=typeof t.id==`string`?t.id:`?`,r=0;for(let t of e){if(!F(t)||typeof t.sequence!=`number`)continue;let e=t.sequence;if(e<=r)return{ok:!1,error:`sequences in conversation "${n}" must be strictly increasing`};r=e}}return{ok:!0}}function po(e){let t=[];for(let n of e){if(!F(n))continue;let e=n.content;if(Array.isArray(e))for(let n of e)F(n)&&n.type===`tool-call`&&typeof n.id==`string`&&t.push(n.id)}return t}function mo(e){let t=new Set;for(let n of e){if(!F(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of po(e))t.add(n)}return t}function ho(e,t){for(let n of e){if(!F(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of e){if(!F(n)||n.role!==`tool-result`)continue;let e=n.toolCallId;if(typeof e==`string`&&e!==``&&!t.has(e))return{ok:!1,error:`tool-result message references unknown toolCallId "${e}"`}}}return{ok:!0}}function go(e){return ho(e,mo(e))}function _o(e,t){for(let n of e){if(!F(n)||n.type!==`attachment-ref`)continue;let e=n.attachmentId;if(typeof e!=`string`||!t.has(e))return{ok:!1,error:`attachment-ref references unknown attachmentId "${e}"`}}return{ok:!0}}function vo(e,t){for(let n of e){if(!F(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of e){if(!F(n))continue;let e=n.content;if(!Array.isArray(e))continue;let r=_o(e,t);if(!r.ok)return r}}return{ok:!0}}function yo(e,t){let n=new Set;for(let e of t)F(e)&&typeof e.id==`string`&&n.add(e.id);return vo(e,n)}function bo(e){let t=new Map;for(let n of e){if(!F(n)||typeof n.id!=`string`)continue;let e=new Set,r=n.messages;if(Array.isArray(r))for(let t of r)F(t)&&typeof t.id==`string`&&e.add(t.id);t.set(n.id,e)}return t}function xo(e,t){let n=bo(t);for(let t=0;t<e.length;t++){let r=e[t];if(!F(r))continue;let i=r.sourceConversationId,a=r.sourceMessageId;if(typeof i!=`string`||typeof a!=`string`)continue;let o=n.get(i);if(!o)return{ok:!1,error:`attachments[${t}].sourceConversationId "${i}" does not exist`};if(!o.has(a))return{ok:!1,error:`attachments[${t}].sourceMessageId "${a}" does not exist in conversation "${i}"`}}return{ok:!0}}function So(e){let t=new Map;for(let n of e){if(!F(n)||typeof n.id!=`string`)continue;let e=Array.isArray(n.messages)?n.messages:[];t.set(n.id,new Set(po(e)))}return t}function Co(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];if(!F(i))continue;let a=i.sourceConversationId,o=i.targetConversationId;if(typeof a!=`string`||!t.has(a))return{ok:!1,error:`delegations[${r}].sourceConversationId "${a}" does not exist`};if(typeof o!=`string`||!t.has(o))return{ok:!1,error:`delegations[${r}].targetConversationId "${o}" does not exist`};let s=i.toolCallId;if(typeof s==`string`&&s!==``&&!n.get(a)?.has(s))return{ok:!1,error:`delegations[${r}].toolCallId "${s}" does not exist in source conversation "${a}"`}}return{ok:!0}}function wo(e,t){let n=new Set;for(let e of t)F(e)&&typeof e.id==`string`&&n.add(e.id);return Co(e,n,So(t))}function To(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 Eo(e,t){let n=new Set;for(let e of t)F(e)&&typeof e.id==`string`&&n.add(e.id);for(let t=0;t<e.length;t++){let r=e[t];if(!F(r))continue;let i=r.target;if(!F(i))continue;let a=To(i,n,`privacy.redactions[${t}].target`);if(!a.ok)return a}return{ok:!0}}function Do(e){let t=e.conversations,n=e.attachments,r=e.delegations,i=e.privacy,a=Array.isArray(i?.redactions)?i.redactions:[],o=uo(t);if(!o.ok)return o;let s=fo(t);if(!s.ok)return s;let c=go(t);if(!c.ok)return c;let l=yo(t,n);if(!l.ok)return l;let u=xo(n,t);if(!u.ok)return u;let d=wo(r,t);return d.ok?Eo(a,n):d}function Oo(e){let t=lo(e);return t.ok?Do(e):t}function ko(e){if(!F(e))return{ok:!1,error:`document must be a non-null object`};if(e.schemaVersion!==1)return{ok:!1,error:`schemaVersion must equal 1`};let t=ao(e.export);if(!t.ok)return t;let n=so(e.session);if(!n.ok)return n;let r=co(e.privacy);return r.ok?Oo(e):r}async function Ao(e,t,n){let r=await n({method:`GET`,path:`/${e}/sites/${t}/config.json`,origin:Ke});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:jo(a),sourceUrl:a}}function jo(e){if(!e)return`da`;let t;try{t=new URL(e).host}catch{return`da`}return t===`api.aem.live`?`aem`:`da`}const Mo=`slicc-sprinkle-routes`;function No(){try{let e=localStorage.getItem(Mo);return e?JSON.parse(e):{}}catch{return{}}}function Po(e){try{localStorage.setItem(Mo,JSON.stringify(e))}catch{}}function Fo(e){return No()[e]}function Io(e,t){let n=No();n[e]=t,Po(n)}function Lo(e){let t=No();delete t[e],Po(t)}function Ro(){return No()}function zo(e,t,n){return gt(t,n,`${e} adapter does not implement ${t}.${n}`)}function Bo(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(zo(e,t,n))]});return{...Object.fromEntries(a),allowlist:i,supports:e=>i.includes(e)}}function Vo(e){let{adapter:t,pageGestures:n}=e,r=n??{};return{adapter:t,browser:Bo(t,`browser`,yt,e.browser),network:Bo(t,`network`,ht,e.network),secrets:Bo(t,`secrets`,bt,e.secrets),devices:Bo(t,`devices`,xt,{usbRequest:r.usbRequest,serialRequest:r.serialRequest,hidRequest:r.hidRequest,...e.devices}),mounts:Bo(t,`mounts`,_t,{pickDirectory:r.pickDirectory,...e.mounts}),approvals:Bo(t,`approvals`,St,e.approvals)}}function Ho(e={}){return Vo({adapter:`connect`,pageGestures:e.pageGestures})}function Uo(e){let t=Ct(()=>import(`./extension-ops-OtrqWANJ.js`).then(t=>t.createExtensionOps(e)));return Vo({adapter:e.adapter,pageGestures:e.pageGestures,network:{crossOriginFetch:e=>T(`network`,`crossOriginFetch`,async()=>(await t()).crossOriginFetch(e))},secrets:{listMaskedEnv:()=>T(`secrets`,`listMaskedEnv`,async()=>(await t()).secrets.listMaskedEnv()),getMasked:e=>T(`secrets`,`getMasked`,async()=>(await t()).secrets.getMasked(e)),set:e=>T(`secrets`,`set`,async()=>(await t()).secrets.set(e)),delete:e=>T(`secrets`,`delete`,async()=>(await t()).secrets.delete(e))},mounts:{signRequest:e=>T(`mounts`,`signRequest`,async()=>(await t()).signRequest(e))},approvals:{request:e=>T(`approvals`,`request`,async()=>(await t()).requestApproval(e))}})}function Wo(e={}){let t=Ct(()=>import(`./rest-ops-j0P6ql7f.js`).then(t=>t.createRestOps(e)),e.controlTimeoutMs??1e4);return Vo({adapter:`node-rest`,pageGestures:e.pageGestures,network:{localNodeServer:()=>Promise.resolve({ok:!0,value:{available:!0}}),crossOriginFetch:e=>T(`network`,`crossOriginFetch`,async()=>(await t()).crossOriginFetch(e))},secrets:{listMaskedEnv:()=>T(`secrets`,`listMaskedEnv`,async()=>(await t()).secrets.listMaskedEnv()),getMasked:e=>T(`secrets`,`getMasked`,async()=>(await t()).secrets.getMasked(e)),set:e=>T(`secrets`,`set`,async()=>(await t()).secrets.set(e)),delete:e=>T(`secrets`,`delete`,async()=>(await t()).secrets.delete(e))},mounts:{signRequest:e=>T(`mounts`,`signRequest`,async()=>(await t()).signRequest(e))},approvals:{request:e=>T(`approvals`,`request`,async()=>(await t()).requestApproval(e))}})}function Go(e,t={}){let{pageGestures:n}=t;switch(e){case`node-rest`:return Wo({pageGestures:n});case`extension-direct`:case`extension-delegate`:return Uo({adapter:e,pageGestures:n});case`connect`:return Ho({pageGestures:n})}}const Ko=e(`quick-llm`);async function qo(e){let t=f();if(!t)return Ko.debug(`No API key for active provider — skipping`),null;let n=d(),r=u(),i;if(i=e.modelId?Zo(n,e.modelId)??Zo(n,r):Jo(n,r),!i)return Ko.debug(`No model available for provider`,{providerId:n}),null;let a={role:`user`,content:e.prompt,timestamp:Date.now()},o={};i.provider===`adobe`&&(o[`X-Session-Id`]=Qo());try{let n=(await Te(i,{systemPrompt:e.system,messages:[a]},{apiKey:t,maxTokens:e.maxTokens??60,temperature:e.temperature??.3,signal:e.signal,headers:Object.keys(o).length>0?o:void 0})).content.filter(e=>e.type===`text`).map(e=>e.text).join(``).trim();return n.length>0?n:null}catch(e){return Ko.debug(`Quick label call failed`,{error:e instanceof Error?e.message:String(e)}),null}}function Jo(e,t){let n=p(e);if(n.length===0)return;let r=n.find(e=>e.id===t)??n[0],i=Xo(r.id),a=n.filter(e=>Yo(e,r,i));return a.length===0?r:(a.sort((e,t)=>(e.cost?.input??0)-(t.cost?.input??0)),a[0])}function Yo(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 Xo(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 Zo(e,t){return p(e).find(e=>e.id===t)}function Qo(){return Tt(`ui-quick-llm`)}const $o=e(`sudo-suggest`),es=[`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
  `),ts=[`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 ns(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`?es:ts,i=null;try{i=await qo({prompt:n,system:r,maxTokens:40,temperature:0,signal:t})}catch(e){$o.debug(`suggestPattern: quickLabel threw`,{error:e instanceof Error?e.message:String(e)}),i=null}return rs(i)||n}function rs(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 is=e(`sudo:capability-gesture`);function as(e,t={}){let n=t.suggest??ns;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 is.warn(`sudo approval aborted before prompting — denying`,{detail:t.detail}),mt();if(!e)return is.warn(`no CapabilityBroker injected for the sudo gesture hop — denying (composition bug, never a guessed transport)`,{detail:t.detail}),mt();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?vt(o.value,a):(is.warn(`capability broker approvals.request failed — denying`,{message:o.message}),mt())}}}const os=e(`sudo:tray-first`);function ss(e,t={}){let n=t.suggest??ns,r=t.timeoutMs??6e5,i=t.getClient??(async()=>{let{getPanelRpcClient:e}=await import(`./panel-rpc-CR9k3qWE.js`).then(e=>e.r);return e()});return{async requestApproval(t,a){if(a?.signal?.aborted)return mt();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){os.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 ls(e?.decision,o)}catch(e){os.warn(`tray-first sudo probe failed — using native broker`,{error:e instanceof Error?e.message:String(e)})}return e.requestApproval(s,a)}}}const cs=[`user-timeout`,`cone-timeout`,`unavailable`];function ls(e,t){if(!e||typeof e!=`object`)return mt();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 mt();let i=cs.find(e=>e===n.reason);return i?{decision:`deny`,reason:i}:{decision:`deny`}}function us(e,t){return{requestApproval(n){return t.enqueueSudoRequest(e,n)}}}function ds(){return`lick-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}var fs=class{pending=new Map;timeoutMs;newId;setTimer;clearTimer;onAutoSettle;constructor(e={}){this.timeoutMs=e.timeoutMs??3e5,this.newId=e.newId??ds,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(ie(`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 ps(e){return ne(ms(e))}function ms(e){let t=as(e);return e?.adapter===`extension-direct`||e?.adapter===`extension-delegate`?t:ss(t)}let hs=null;function gs(e){return hs=e,()=>{hs===e&&(hs=null)}}function _s(){if(!hs)throw new Aa(`session-not-found`);return hs}const vs=`focus`,ys={type:`leaf`,surfaceId:`chat`};function bs(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 xs={focus:{name:`focus`,tree:bs({left:ys},{left:3,middle:1})}};function Ss(e){return xs[e]??null}const Cs=`progress`;async function ws(){try{let e=await Lt();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 Rt(e.idbKey);if(!t)throw Error(`mount: no directory handle found in storage`);return await It(t),t}throw Error(`mount: unexpected popup result`)}catch(e){throw Error(`mount: ${e instanceof Error?e.message:String(e)}`)}}async function Ts(){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 Es(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 Rt(r.idbKey);if(!i)throw Error(`no directory handle found in storage`);return await It(i),i}function Ds(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 Os(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 ks=new Set([`--source`,`--profile`,`--backend`,`--max-body-mb`]);function As(e){for(let t=0;t<e.length;t++){let n=e[t];if(n===`--`)return!1;if(n===`--help`||n===`-h`)return!0;ks.has(n)&&t++}return!1}function js(e){return`aem://${e.org}/${e.name}${e.path?`/${e.path}`:``}`}var Ms=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=Ds(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=je();if(!n){let n=await Ns(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=de()?null:y(),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=ee()?await ws():r?await Es(r,e):await Ts();let a=He.fromHandle(i,{mountId:Ye()});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=Ye(),i=new Xe({mountId:r,ttlMs:3e4}),a=new We({source:t.source,profile:n,cache:i,maxBodyBytes:t.maxBodyMb?t.maxBodyMb*1024*1024:void 0,mountId:r,signedFetch:this.signedFetchS3??Ge(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??Je(),i=Os(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 Ao(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=Ye(),c=new Xe({mountId:s,ttlMs:3e4}),l={source:a===`aem`?js(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 qe(l):new Ue(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(As(e))return n===`umount`?this.umountHelp():this.help();let r=Ds(e);if(r.positional.length===0)return{stdout:``,stderr:`${n}: path required\n`,exitCode:1};let i=this.resolvePath(r.positional[0],t);try{let e,t;if(r.clearCache){let{getAllMountEntries:n}=await import(`./mount-table-store-DrF_Ifaz.js`).then(e=>e.r),r=(await n()).find(e=>e.targetPath===i),a=r?.descriptor.kind;r&&(a===`s3`||a===`da`||a===`aem`)&&(e=r.descriptor.mountId,t=r.descriptor.kind)}await this.options.fs.unmount(i);let n=``;if(r.clearCache&&e&&t){let{RemoteMountCache:t}=await import(`./remote-cache-UwMD8EkX.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
@@ -287,7 +287,7 @@ Examples:
287
287
  skill list
288
288
  skill info bluebubbles
289
289
  skill read bluebubbles
290
- `,stderr:``,exitCode:0};let r=t[0],i=await import(`./kernel-worker-coLE80Cx.js`).then(e=>e.r);try{switch(r){case`list`:return Eh(t,e,i,n.env.get(`PATH`));case`info`:{let n=t[1];if(!n)return{stdout:``,stderr:`skill: info requires a skill name
290
+ `,stderr:``,exitCode:0};let r=t[0],i=await import(`./kernel-worker-XCbAqv4r.js`).then(e=>e.r);try{switch(r){case`list`:return Eh(t,e,i,n.env.get(`PATH`));case`info`:{let n=t[1];if(!n)return{stdout:``,stderr:`skill: info requires a skill name
291
291
  `,exitCode:1};let r=await i.getSkillInfo(e,n);return r?{stdout:wh(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
292
292
  `,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+`
293
293
  `,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 Oh=[{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=>Wi(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 kh(e){let t={skills:[],dryRun:!1,json:!1};for(let n=0;n<e.length;n++){let r=e[n],i=Oh.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 Ah(e,t){return!e||!t||e.byteLength!==t.byteLength?!1:e.every((e,n)=>e===t[n])}async function jh(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 Mh(e,t,n,r){let i=await jh(e,t);return Ai(n)?i?{status:`kept-local`,write:!1}:{status:`added`,write:!0}:i?Ah(i,r)?{status:`unchanged`,write:!1}:{status:`updated`,write:!0}:{status:`added`,write:!0}}async function Nh(e,t,n,r){let i={changes:[],writes:[],removals:[]};for(let[r,a]of n){let n=`${t}/${r}`,{status:o,write:s}=await Mh(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 ji(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 Ph(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 Ii(t),d=await Ri(s,c,o.ref,u,!0,l||void 0);if(d&&r.sha===d&&await Fh(e,n,r))return{...o,to:d,outcome:`current`,changes:[]};let f=await Ih(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 Nh(e,`${Ci}/${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 Vh(e,{changes:h,writes:g,removals:_}),await zi(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 Fh(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 Ih(e,t,n,r,i,a,o){let s=await Ni(e,t,a,i??`main`);if(s.status===`ok`){let i=Oi(s.files),a=n||Lh(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:Bh(i,a),path:a}}try{return{files:zh(Rh(await Mi(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 Lh(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 Rh(e){return new Map([...e].filter(([e])=>ki(e)))}function zh(e){return new Map([...e].sort(([e],[t])=>e.localeCompare(t)))}function Bh(e,t){let n=t?`${t}/`:``,r=new Map;for(let[t,i]of Object.entries(e)){if(!t.startsWith(n)||t.endsWith(`/`))continue;let e=t.slice(n.length);ki(e)&&r.set(e,i)}return zh(r)}async function Vh(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 Hh(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 yh(o,s,t);if(!c.ok)return{...a,outcome:`error`,error:c.error};let l=`${Ci}/${n}/SKILL.md`,u=await jh(e,l),d=new TextEncoder().encode(c.content),f=u!==void 0&&_h(new TextDecoder().decode(u))===_h(c.content);if(Ah(u,d)||f)return{...a,changes:[{path:`SKILL.md`,status:`unchanged`}]};let p=u?`updated`:`added`;return i||(await e.mkdir(`${Ci}/${n}`,{recursive:!0}),await e.writeFile(l,d),await zi(e,n,{...r,files:[`SKILL.md`]})),{...a,outcome:`updated`,changes:[{path:`SKILL.md`,status:p}]}}function Uh(e,t){if(e.outcome===`error`)return` ${e.skill}: failed — ${e.error}\n`;let n=new Map;for(let t of e.changes)n.set(t.status,(n.get(t.status)??0)+1);let r=e.to&&e.to!==e.from?` → ${e.to.slice(0,7)}`:``;if(e.outcome===`current`)return` ${e.skill}: already current (${e.source}${r})\n`;let i=t?`would update`:`updated`,a=` ${e.skill}: ${i} from ${e.source}${r}\n`;for(let t of e.changes)t.status!==`unchanged`&&(a+=` ${t.status.padEnd(10)} ${t.path}\n`);let o=n.get(`kept-local`)??0;return o>0&&(a+=` (${o} kept-local — dotfiles and local additions are never touched)\n`),a}function Wh(e,t,n,r){let i=Wi(t);return i?{version:1,kind:`github`,source:`${i.owner}/${i.repo}`,skill:e,ref:r??i.branch,path:n??i.path,installed:new Date().toISOString()}:null}async function Gh(e,t,n){if(t.length===0){let t=await Li(e);return{targets:t.provenanced,missing:[],skipped:t.unattributed}}let r=[],i=[];for(let a of t){let t=await Bi(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?Wh(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 Kh(e){return e.reason===`not-installed`?`upskill: no skill named "${e.name}" is installed — check \`upskill list\`
@@ -298,7 +298,7 @@ Examples:
298
298
  `}function Yh(e,t,n,r,i){let a=t?`Skill update (dry run — nothing written):
299
299
  `:`Skill update:
300
300
  `;for(let n of e)a+=Uh(n,t);if(i.length>0&&(a+=Jh(i)),!n&&r&&e.length>0){let n=i.length>0?`all ${qh(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 Xh(e,t,n){let{targets:r,missing:i,skipped:a}=await Gh(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 Hh(e,t,i.name,i.provenance,n.dryRun):await Ph(e,t,i.name,i.provenance,n.branch,n.dryRun));return{results:o,skipped:a,missing:i}}async function Zh(e,t,n){let r=kh(e);if(r.error)return{stdout:``,stderr:`${r.error}\n`,exitCode:1};let{results:i,missing:a,skipped:o}=await Xh(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`:Yh([],r.dryRun,!1,!0,o),stderr:``,exitCode:0}:{stdout:``,stderr:a.length?a.map(Kh).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 Ui();let l=a.map(Kh).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:Yh(i,r.dryRun,c,u,o),stderr:l,exitCode:+!u}}function Qh(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 $h(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 eg(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}${$h(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(`
301
- `)}\n`}async function tg(e,t,n){let r=await(await import(`./kernel-worker-coLE80Cx.js`).then(e=>e.r)).discoverSkills(e),{collisions:i}=await lr(e,or(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${xh()}`,stderr:``,exitCode:0}:{...ur(`upskill`,Ch(r,`Discoverable local skills`),i,{builtinNames:new Set(rt())}),exitCode:0}}async function ng(e,t,n){let{results:r,skipped:i}=await Xh(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:eg(r,i),stderr:c,exitCode:+!s}}async function rg(e,t,n,r){let i=Qh(e);return i.error?{stdout:``,stderr:`${i.error}\n`,exitCode:1}:i.outdated?ng(t,n,i.json):tg(t,i.json,r)}async function ig(e,t){let n=`${wi}/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(Fi(e,n))}if(r.status!==200)throw Error(`Tessl returned HTTP ${r.status}`);let i=be(r.body);if(!i.data)return[];let a=new Map;for(let e of i.data){if(e.type!==`skill`)continue;let t=e.attributes,n=Hi(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 ag(e,t){let n=`${wi}/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: ${Fi(e,n)}`}}if(r.status!==200)return{error:`Tessl search failed (HTTP ${r.status})`};let i=be(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=Hi(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 og=[{label:`Tessl`,host:new URL(wi).host,fetch:ig},{label:`browse.sh`,host:new URL(Di).host,fetch:dh}];function sg(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 cg(e,t,n=1){let r=await Promise.allSettled(og.map(n=>n.fetch(e,t))),i=r.map(e=>e.status===`fulfilled`?e.value:[]),a=r.every(e=>e.status===`rejected`),o=sg(i),s=``;for(let e=0;e<r.length;e++){let t=r[e];if(t.status===`rejected`){let n=og[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+=`
301
+ `)}\n`}async function tg(e,t,n){let r=await(await import(`./kernel-worker-XCbAqv4r.js`).then(e=>e.r)).discoverSkills(e),{collisions:i}=await lr(e,or(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${xh()}`,stderr:``,exitCode:0}:{...ur(`upskill`,Ch(r,`Discoverable local skills`),i,{builtinNames:new Set(rt())}),exitCode:0}}async function ng(e,t,n){let{results:r,skipped:i}=await Xh(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:eg(r,i),stderr:c,exitCode:+!s}}async function rg(e,t,n,r){let i=Qh(e);return i.error?{stdout:``,stderr:`${i.error}\n`,exitCode:1}:i.outdated?ng(t,n,i.json):tg(t,i.json,r)}async function ig(e,t){let n=`${wi}/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(Fi(e,n))}if(r.status!==200)throw Error(`Tessl returned HTTP ${r.status}`);let i=be(r.body);if(!i.data)return[];let a=new Map;for(let e of i.data){if(e.type!==`skill`)continue;let t=e.attributes,n=Hi(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 ag(e,t){let n=`${wi}/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: ${Fi(e,n)}`}}if(r.status!==200)return{error:`Tessl search failed (HTTP ${r.status})`};let i=be(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=Hi(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 og=[{label:`Tessl`,host:new URL(wi).host,fetch:ig},{label:`browse.sh`,host:new URL(Di).host,fetch:dh}];function sg(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 cg(e,t,n=1){let r=await Promise.allSettled(og.map(n=>n.fetch(e,t))),i=r.map(e=>e.status===`fulfilled`?e.value:[]),a=r.every(e=>e.status===`rejected`),o=sg(i),s=``;for(let e=0;e<r.length;e++){let t=r[e];if(t.status===`rejected`){let n=og[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
302
  `}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:
303
303
  `,p+=` From Tessl: upskill <owner/repo> --skill <name>
304
304
  `,p+=` From browse.sh: upskill browse:<hostname>/<task>
@@ -321,7 +321,7 @@ Examples:
321
321
  `,{stdout:s,stderr:``,exitCode:0}}function hg(e){return!e||e.startsWith(`-`)?{stdout:``,stderr:`upskill: --branch requires a value
322
322
  `,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
323
323
  `,exitCode:1}}function gg(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
324
- `,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=hg(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 _g(e,t,n){if(!t)return{stdout:``,stderr:`upskill: ${e} requires a skill name\n`,exitCode:1};let r=await import(`./kernel-worker-coLE80Cx.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 Bi(n,t),a=i?Vi(i):"Installed from: (no provenance recorded — reinstall to enable `upskill update`)\n";return{stdout:wh(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+`
324
+ `,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=hg(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 _g(e,t,n){if(!t)return{stdout:``,stderr:`upskill: ${e} requires a skill name\n`,exitCode:1};let r=await import(`./kernel-worker-XCbAqv4r.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 Bi(n,t),a=i?Vi(i):"Installed from: (no provenance recorded — reinstall to enable `upskill update`)\n";return{stdout:wh(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
325
  `,stderr:``,exitCode:0}}async function vg(e,t,n,r,i,a,o,s){let c=``,l=``,u=0,d=e.length;for(let f=0;f<e.length;f++){let p=e[f],m=await Ki(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 yg(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 Gi(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 bg(e,t,n,r,i,a,o,s){let c=``,l=``,u=0;for(let d of e){let e=await Gi(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 xg(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 Sg(e,t,n,r){let{owner:i,repo:a}=e,o=t.branch??e.branch,s=t.subPath??e.path,c=await Ii(r),l=await qi(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:xg(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:xg(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 Ni(i,a,r,o);if(e.status===`ok`){let r=await Ri(i,a,o,c,!0,s),l=await vg(u,i,a,Oi(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 yg(u,i,a,c,n,t.force,o,f);({output:p,errors:m,successCount:h}=e)}}else({output:p,errors:m,successCount:h}=await bg(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 Ui()),{stdout:p,stderr:m,exitCode:+!!m}}async function Cg(e,t,n,r,i){switch(e[0]){case`tabs`:return pg(t,n,r,e.includes(`--json`));case`recommendations`:return mg(t,n,e.includes(`--install`));case`update`:case`upgrade`:return Zh(e.slice(1),t,n);case`list`:return rg(e.slice(1),t,n,i);case`info`:case`read`:return _g(e[0],e[1],t);case`search`:return Tg(e,n);default:return null}}function wg(e,t,n){return S(`upskill`,async(r,i)=>{if(r.length===0||r.includes(`--help`)||r.includes(`-h`))return Th();let a=await Cg(r,e,t,n,i.env.get(`PATH`));if(a)return a;let o=gg(r);if(o.earlyReturn)return o.earlyReturn;if(!o.sourceRef)return Th();if(o.sourceRef.startsWith(`tessl:`))return Eg(o.sourceRef,o.force,e,t);let s=mh(o.sourceRef);if(s)return bh(s.hostname,s.task,e,t,o.force);let c=Wi(o.sourceRef);return c?Sg(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 Tg(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?cg(a,t,i):Th()}async function Eg(e,t,n,r){let i=e.slice(6);if(!i)return{stdout:``,stderr:`upskill: tessl: requires a skill name
326
326
  `,exitCode:1};let a=await ag(i,r);if(`error`in a)return{stdout:``,stderr:`upskill: ${a.error}\n`,exitCode:1};let o=await Ii(r);return Gi(a.owner,a.repo,a.skillPath,a.skillName,n,o,t,r)}function Dg(){return{stdout:`usage: afplay [-v volume] [-r rate] <file>
327
327
 
@@ -841,7 +841,7 @@ Options:
841
841
  --pattern <glob> File pattern to match, e.g. "*.md", "*.bsh" (required)
842
842
  --scoop <target> Scoop name, cone name, or folder. Omit for your own cone.
843
843
  --name <name> Human-readable name for the watcher
844
- `);switch(n){case`list`:return NS(e);case`delete`:return PS(e);case`create`:return await LS(e,t.env);default:return jS(`unknown command: ${n}`)}})}function zS(e){return S(`gelatiere`,async(t,n)=>{let{runGelatiere:r}=await import(`./run-ZVh0R1Qb.js`);return r(t,n,e)})}function BS(e={}){return S(`go`,async(t,n)=>{let{runGoCommand:r}=await import(`./go-driver-C0zJJSTi.js`);return r(t,n,{processConfig:e.buildProcessConfig?.(n.env),terminal:e.terminal,gate:e.gate,commands:e.commands,gitIdentity:e.gitIdentity})})}function VS(){return{stdout:`usage: hear [-i file] [-l lang] [-T seconds] [-d deviceId] [--engine name]
844
+ `);switch(n){case`list`:return NS(e);case`delete`:return PS(e);case`create`:return await LS(e,t.env);default:return jS(`unknown command: ${n}`)}})}function zS(e){return S(`gelatiere`,async(t,n)=>{let{runGelatiere:r}=await import(`./run-ZVh0R1Qb.js`);return r(t,n,e)})}function BS(e={}){return S(`go`,async(t,n)=>{let{runGoCommand:r}=await import(`./go-driver-DOU6iF-0.js`);return r(t,n,{processConfig:e.buildProcessConfig?.(n.env),terminal:e.terminal,gate:e.gate,commands:e.commands,gitIdentity:e.gitIdentity})})}function VS(){return{stdout:`usage: hear [-i file] [-l lang] [-T seconds] [-d deviceId] [--engine name]
845
845
  hear --devices | --status | --warmup
846
846
 
847
847
  Speech recognition: listens on the microphone until you pause, then
@@ -1426,7 +1426,7 @@ Options:
1426
1426
  --global Resolve only from the shared global prefix (/shared/lib/node_modules)
1427
1427
  -h, --help Show this help message
1428
1428
  `}async function HO(e,t){let n=await e.readFile(t);return typeof n==`string`?n:new TextDecoder().decode(n)}async function UO(e,t){try{return(await e.stat(t)).type===`file`}catch{return!1}}async function WO(e,t){try{return(await e.stat(t)).type===`directory`}catch{return!1}}function*GO(e,t=!1){if(t){yield ir;return}let n=b(e);for(;yield x(n,`node_modules`),n!==`/`;)n=Fe(n).dir;yield ir}async function KO(e,t,n,r=!1){for(let i of GO(t,r)){let t=x(i,`.bin`,n);if(!await UO(e,t))continue;let r=await HO(e,t),a=BO.exec(r),o=Fe(t).dir;return{binFilePath:a?x(o,a[1]):t,argvName:t}}return null}function qO(e){if(e.startsWith(`@`)){let t=e.indexOf(`/`);if(t!==-1)return e.slice(t+1)}return e}function JO(e,t){if(typeof e==`string`)return{binName:qO(t),binPath:e};if(typeof e!=`object`||!e)return null;let n=[t,qO(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 YO(e,t,n,r=!1){for(let i of GO(t,r)){let t=x(i,n),r=x(t,`package.json`);if(!await UO(e,r))continue;let a;try{a=JSON.parse(await HO(e,r))}catch{return null}let o=JO(a.bin,n);if(!o)return null;let s=o.binPath.replace(/^\.\//,``);return{binFilePath:x(t,s),argvName:x(i,`.bin`,o.binName)}}return null}async function XO(e,t,n,r=!1){return await KO(e,t,n,r)??await YO(e,t,n,r)}async function ZO(e,t,n){for(let r of GO(t))if(await UO(e,x(r,n,`package.json`)))return!0;return!1}function QO(e){return e instanceof Error?e.message:String(e)}function $O(e,t){return{stdout:``,stderr:`${e}: ${t}\n`,exitCode:1}}async function ek(e,t,n,r){try{let{installPackages:i}=await import(`./installer-CbjJjnwg.js`),a=await i([t],{fs:r.fs,fetch:r.fetch,cwd:n.cwd});if(a.errors.length>0)return{error:$O(e,`failed to install '${t}': ${QO(a.errors[0].error)}`)};let o=a.results.map(t=>`${e}: installed ${t.name}@${t.version}`);return{progress:o.length>0?`${o.join(`
1429
- `)}\n`:``}}catch(n){return{error:$O(e,`failed to install '${t}': ${QO(n)}`)}}}async function tk(e,t,n,r){return await UO(r,n)?null:await WO(r,n)?$O(e,`bin target '${n}' is a directory, not a file`):$O(e,`bin file '${n}' for '${t}' does not exist`)}async function nk(e,t,n,r,i,a){if(await ZO(a.fs,i.cwd,t))return{error:$O(e,`package '${t}' does not expose an executable bin`)};let o=r?void 0:LO(t);if(o)return{error:{stdout:``,stderr:zO(e,t,n,o),exitCode:1}};let s=await ek(e,t,i,a);if(`error`in s)return s;let c=await XO(a.fs,i.cwd,t);return c?{resolved:c,installProgress:s.progress}:{error:$O(e,`package '${t}' was installed but does not expose an executable bin`)}}function rk(e,t){return{name:e,trusted:!0,async execute(n,r){if(n.length===0||n[0]===`--help`||n[0]===`-h`)return{stdout:VO(e),stderr:``,exitCode:+(n.length===0)};let i=n[0]===`--force`,a=i?n.slice(1):n,o=a[0]===`--global`;o&&(a=a.slice(1));let s=a;if(s.length===0)return{stdout:VO(e),stderr:``,exitCode:1};let c=s[0],l=s.slice(1),u;try{u=await XO(t.fs,r.cwd,c,o)}catch(t){return $O(e,QO(t))}let d=``;if(!u){if(o)return $O(e,`no global bin '${c}' found in ${ir}`);let n=await nk(e,c,l,i,r,t);if(`error`in n)return n.error;u=n.resolved,d=n.installProgress}let f=await tk(e,c,u.binFilePath,t.fs);if(f)return f;let p=si(await HO(t.fs,u.binFilePath)),m=[`node`,u.argvName,...l],h=await ai(p,m,r,void 0,{filename:u.binFilePath});return{stdout:h.stdout,stderr:d+h.stderr,exitCode:h.exitCode}}}}function ik(e={}){return S(`jshd`,async(t,n)=>{let{runJshd:r}=await import(`./run-BSPrcB21.js`);return r(t,n,e)})}const ak=new Set([`SIGINT`,`SIGTERM`,`SIGKILL`,`SIGSTOP`,`SIGCONT`]);function ok(e={}){return S(`kill`,async t=>{if(t.length===0||t.includes(`--help`)||t.includes(`-h`))return fk();let n=e.processManager??sk();if(!n)return{stdout:``,stderr:`kill: no process manager available in this runtime
1429
+ `)}\n`:``}}catch(n){return{error:$O(e,`failed to install '${t}': ${QO(n)}`)}}}async function tk(e,t,n,r){return await UO(r,n)?null:await WO(r,n)?$O(e,`bin target '${n}' is a directory, not a file`):$O(e,`bin file '${n}' for '${t}' does not exist`)}async function nk(e,t,n,r,i,a){if(await ZO(a.fs,i.cwd,t))return{error:$O(e,`package '${t}' does not expose an executable bin`)};let o=r?void 0:LO(t);if(o)return{error:{stdout:``,stderr:zO(e,t,n,o),exitCode:1}};let s=await ek(e,t,i,a);if(`error`in s)return s;let c=await XO(a.fs,i.cwd,t);return c?{resolved:c,installProgress:s.progress}:{error:$O(e,`package '${t}' was installed but does not expose an executable bin`)}}function rk(e,t){return{name:e,trusted:!0,async execute(n,r){if(n.length===0||n[0]===`--help`||n[0]===`-h`)return{stdout:VO(e),stderr:``,exitCode:+(n.length===0)};let i=n[0]===`--force`,a=i?n.slice(1):n,o=a[0]===`--global`;o&&(a=a.slice(1));let s=a;if(s.length===0)return{stdout:VO(e),stderr:``,exitCode:1};let c=s[0],l=s.slice(1),u;try{u=await XO(t.fs,r.cwd,c,o)}catch(t){return $O(e,QO(t))}let d=``;if(!u){if(o)return $O(e,`no global bin '${c}' found in ${ir}`);let n=await nk(e,c,l,i,r,t);if(`error`in n)return n.error;u=n.resolved,d=n.installProgress}let f=await tk(e,c,u.binFilePath,t.fs);if(f)return f;let p=si(await HO(t.fs,u.binFilePath)),m=[`node`,u.argvName,...l],h=await ai(p,m,r,void 0,{filename:u.binFilePath});return{stdout:h.stdout,stderr:d+h.stderr,exitCode:h.exitCode}}}}function ik(e={}){return S(`jshd`,async(t,n)=>{let{runJshd:r}=await import(`./run-C4iWmNHr.js`);return r(t,n,e)})}const ak=new Set([`SIGINT`,`SIGTERM`,`SIGKILL`,`SIGSTOP`,`SIGCONT`]);function ok(e={}){return S(`kill`,async t=>{if(t.length===0||t.includes(`--help`)||t.includes(`-h`))return fk();let n=e.processManager??sk();if(!n)return{stdout:``,stderr:`kill: no process manager available in this runtime
1430
1430
  `,exitCode:1};let r=ck(t);if(!r.ok)return{stdout:``,stderr:r.stderr,exitCode:r.exitCode};let{allDelivered:i,errors:a}=lk(n,r.pids,r.signal);return{stdout:``,stderr:a.length?`${a.join(`
1431
1431
  `)}\n`:``,exitCode:+!i}})}function sk(){let e=globalThis.__slicc_pm;return e instanceof Object&&typeof e.signal==`function`?e:null}function ck(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
1432
1432
  `,exitCode:2};let i=uk(n);if(i instanceof Error)return{ok:!1,stderr:`kill: ${i.message}\n`,exitCode:2};t=i;continue}if(i.startsWith(`-`)){let e=dk(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
@@ -1499,7 +1499,7 @@ Common base URLs:
1499
1499
  `)+`
1500
1500
  `,stderr:``,exitCode:0}}function zk(e,t){let n=t.models.length;return{stdout:[`✓ ${e} (${Fk(t.runtime,!1)})`,` Saved ${n} model${n===1?``:`s`} to Settings:`,...Ik(t.models)].join(`
1501
1501
  `)+`
1502
- `,stderr:``,exitCode:0}}function Bk(){return S(Nk,async e=>{if(e.includes(`--help`)||e.includes(`-h`))return{stdout:Pk(),stderr:``,exitCode:0};let{getApiKeyForProvider:t,getRawApiKeyForProvider:n,getBaseUrlForProvider:r,addAccount:i}=await import(`./account-store-D7DGAxNM.js`).then(e=>e.t),{verifyConnection:a}=await import(`./local-llm-DAdQyx68.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(Nk);if(!s)return{stdout:``,stderr:`Local LLM is not configured. Open Settings → Providers → Local LLM and set a base URL.
1502
+ `,stderr:``,exitCode:0}}function Bk(){return S(Nk,async e=>{if(e.includes(`--help`)||e.includes(`-h`))return{stdout:Pk(),stderr:``,exitCode:0};let{getApiKeyForProvider:t,getRawApiKeyForProvider:n,getBaseUrlForProvider:r,addAccount:i}=await import(`./account-store-D0xdiy20.js`).then(e=>e.t),{verifyConnection:a}=await import(`./local-llm-C5n6HmT5.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(Nk);if(!s)return{stdout:``,stderr:`Local LLM is not configured. Open Settings → Providers → Local LLM and set a base URL.
1503
1503
  `,exitCode:1};let c=await a(s,t(Nk)??void 0);if(!c.ok)return Lk(s,c);if(o===`discover`){let e=n(Nk)??``;return i(Nk,e,s,c.models.join(`, `)),zk(s,c)}return Rk(s,c)})}function Vk(){return{stdout:`usage: man <topic>
1504
1504
 
1505
1505
  Fetches documentation for a given topic from sliccy.com.
@@ -1518,7 +1518,7 @@ Notes:
1518
1518
  Document-Isolation-Policy). Embedded floats cannot be isolated and
1519
1519
  report why instead.
1520
1520
  - The browser randomizes measurement timing — expect a short delay.
1521
- `,stderr:``,exitCode:0};let r=e.isIsolated?e.isIsolated():globalThis.crossOriginIsolated===!0,i=e.measure??Kk();if(!r&&!e.measure)return Wk(`memory measurement requires a cross-origin-isolated runtime (Document-Isolation-Policy) — this runtime is not isolated`);if(!i)return Wk(`performance.measureUserAgentSpecificMemory is not available in this browser`);let a;try{a=await i()}catch(e){return Wk(e instanceof Error?e.message:String(e))}return n.json?{stdout:`${JSON.stringify(a,null,2)}\n`,stderr:``,exitCode:0}:{stdout:Jk(a),stderr:``,exitCode:0}})}function Xk(e){return S(`memory`,async t=>{let{runMemory:n}=await import(`./run-DKbvbERf.js`);return n(t,e)})}function Zk(){return S(`mktemp`,async(e,t)=>{let{runMktemp:n}=await import(`./run-dAJe7sKp.js`);return n(e,t)})}const Qk=`/.cache/artificial-analysis.json`,$k=[`--all`,`--all-versions`,`--json`,`--refresh`,`--no-benchmarks`,`--help`,`-h`],eA=[`--provider`];function tA(e){return{stdout:``,stderr:e.endsWith(`
1521
+ `,stderr:``,exitCode:0};let r=e.isIsolated?e.isIsolated():globalThis.crossOriginIsolated===!0,i=e.measure??Kk();if(!r&&!e.measure)return Wk(`memory measurement requires a cross-origin-isolated runtime (Document-Isolation-Policy) — this runtime is not isolated`);if(!i)return Wk(`performance.measureUserAgentSpecificMemory is not available in this browser`);let a;try{a=await i()}catch(e){return Wk(e instanceof Error?e.message:String(e))}return n.json?{stdout:`${JSON.stringify(a,null,2)}\n`,stderr:``,exitCode:0}:{stdout:Jk(a),stderr:``,exitCode:0}})}function Xk(e){return S(`memory`,async t=>{let{runMemory:n}=await import(`./run-BaJvd-iq.js`);return n(t,e)})}function Zk(){return S(`mktemp`,async(e,t)=>{let{runMktemp:n}=await import(`./run-dAJe7sKp.js`);return n(e,t)})}const Qk=`/.cache/artificial-analysis.json`,$k=[`--all`,`--all-versions`,`--json`,`--refresh`,`--no-benchmarks`,`--help`,`-h`],eA=[`--provider`];function tA(e){return{stdout:``,stderr:e.endsWith(`
1522
1522
  `)?e:`${e}\n`,exitCode:1}}async function nA(e){try{let t=await e.readFile(Qk),n=JSON.parse(t);if(Date.now()-n.fetchedAt<864e5)return n.models}catch{}return null}function rA(){try{return localStorage.getItem(`aa_api_key`)}catch{return null}}function iA(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 aA(e,t){let n={fetchedAt:Date.now(),models:t};try{await e.mkdir(`/.cache`,{recursive:!0}),await e.writeFile(Qk,JSON.stringify(n))}catch{}}async function oA(e,t=!1){if(e&&!t){let t=await nA(e);if(t)return t}let n={Accept:`application/json`},r=rA();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=iA(Array.isArray(s)?s:s.data??s.models??[]);return e&&c.length>0&&await aA(e,c),c}function sA(e){return e.toLowerCase().replace(/\./g,`-`).replace(/-\d{8}$/,``).replace(/-\d{4}$/,``)}function cA(e,t){let n=e.toLowerCase(),r=t.find(e=>e.slug===n);if(r)return r;let i=sA(e),a=t.find(e=>sA(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 lA(){return`models - list available LLM models
1523
1523
 
1524
1524
  Usage: models [options]
@@ -1533,7 +1533,7 @@ Options:
1533
1533
  -h, --help Show this help message
1534
1534
  `}function uA(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`.replace(`.0M`,`M`):e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function dA(e){return`$${e.toFixed(2)}`}const fA=/\b(embedding|embed|tts|whisper|dall-e|image-gen|audio|vision-preview)\b/i;function pA(e){let t=`${e.id} ${e.name??``}`;return!fA.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 hA(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 gA(e){let t=new Map;for(let n of e){let e=hA(n.id);(!t.has(e)||n.selected)&&t.set(e,n)}return[...t.values()]}function _A(e,t,n,r,i){let a=i?cA(e.id,i):void 0,o={id:e.id,name:e.name,provider:t,cost:e.cost??{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:e.contextWindow??0,maxTokens:e.maxTokens??0,reasoning:!!e.reasoning,input:e.input??[`text`],selected:e.id===n&&t===r};return a?.intelligence_index!=null&&(o.intelligence=a.intelligence_index),a?.coding_index!=null&&(o.codingScore=a.coding_index),a?.speed_tps!=null&&(o.speed=a.speed_tps),o}function vA(e,t,n,r){let i=[];i.push(`Models for "${e}" (${t}):\n`);for(let e of n){let t=e.selected?` ► `:` `,n=e.id.padEnd(30),r=`${dA(e.cost.input)} / ${dA(e.cost.output)}`,a=`${uA(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(`
1535
1535
  `)+`
1536
- `}function yA(e){let t=C(e,{bool:$k,value:eA});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 bA(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 xA(e,t,n,r,i,a){let o=e.getProviderModels(t).filter(pA);if(o.length===0)return[];let s=o.map(e=>_A(e,t,n,r,i)).sort((e,t)=>t.cost.input-e.cost.input);return a||(s=gA(s)),s}function SA(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 CA(e,t){if(w(e,{valueFlags:eA}))return{stdout:lA(),stderr:``,exitCode:0};let n=yA(e);if(`error`in n)return tA(`models: ${n.error}`);let r=await import(`./account-store-D7DGAxNM.js`).then(e=>e.t);if(r.getAccounts().length===0)return tA(`No provider accounts configured. Run the provider settings to add one.
1536
+ `}function yA(e){let t=C(e,{bool:$k,value:eA});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 bA(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 xA(e,t,n,r,i,a){let o=e.getProviderModels(t).filter(pA);if(o.length===0)return[];let s=o.map(e=>_A(e,t,n,r,i)).sort((e,t)=>t.cost.input-e.cost.input);return a||(s=gA(s)),s}function SA(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 CA(e,t){if(w(e,{valueFlags:eA}))return{stdout:lA(),stderr:``,exitCode:0};let n=yA(e);if(`error`in n)return tA(`models: ${n.error}`);let r=await import(`./account-store-D0xdiy20.js`).then(e=>e.t);if(r.getAccounts().length===0)return tA(`No provider accounts configured. Run the provider settings to add one.
1537
1537
  `);let i=r.resolveCurrentModel(),a=i.id,o=i.provider,s=r.getSelectedProvider(),c=r.getSelectedModelId(),l;if(!n.noBenchmarks){let e=await oA(t,n.forceRefresh);e.length>0&&(l=e)}let u=bA(r,n,s);if(`error`in u)return tA(u.error);let d=[],f=[];for(let e of u){let t=xA(r,e,a,o,l,n.allVersions);if(t.length===0){if(!n.allMode)return tA(`No models available for provider ${e}.\n`);continue}if(d.push(...t),!n.jsonMode){let n=r.getProviderConfig(e);f.push(vA(n.name,e,t,!!l))}}return n.jsonMode?{stdout:JSON.stringify(d,null,2)+`
1538
1538
  `,stderr:``,exitCode:0}:(n.allVersions||f.push(`Showing latest versions only. Use --all-versions to see all.
1539
1539
  `),f.push(SA(o,a,s,c)),{stdout:f.join(`
@@ -1591,7 +1591,7 @@ Examples:
1591
1591
  `)}\n`,stderr:``,exitCode:0}}async function JA(e,t,n){if(!t||!n)return{stdout:``,stderr:`oauth-domain add: requires <providerId> and <domain>
1592
1592
  `,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 YA(e,t,n){if(!t||!n)return{stdout:``,stderr:`oauth-domain remove: requires <providerId> and <domain>
1593
1593
  `,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 XA(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>
1594
- `,exitCode:1}}async function ZA(e,t,n,r){switch(t){case`list`:return qA(e,n);case`add`:return JA(e,n,r);case`remove`:return YA(e,n,r);case`clear`:return XA(e,n);default:return{stdout:``,stderr:`oauth-domain: unknown subcommand "${t}"\n${GA()}`,exitCode:1}}}function QA(){return S(`oauth-domain`,async e=>{if(e.length===0||w(e))return{stdout:GA(),stderr:``,exitCode:0};let t=C(e);if(`error`in t)return KA(t.error);let[n,r,i]=t.positionals,a=await import(`./account-store-D7DGAxNM.js`).then(e=>e.t);try{return await ZA(a,n,r,i)}catch(e){return KA(e instanceof Error?e.message:String(e))}})}function $A(){return S(`oauth-token`,async(e,t)=>{let{runOAuthToken:n}=await import(`./run-Blqu2GaE.js`);return n(e,t)})}const ej=[`--download`,`-d`,`--view`,`-v`],tj=[`--size`],nj={low:256,medium:768,high:1536};function rj(){return{stdout:`usage: open [--download|-d] [--view|-v [--size <spec>]] <url|path> [url|path...]
1594
+ `,exitCode:1}}async function ZA(e,t,n,r){switch(t){case`list`:return qA(e,n);case`add`:return JA(e,n,r);case`remove`:return YA(e,n,r);case`clear`:return XA(e,n);default:return{stdout:``,stderr:`oauth-domain: unknown subcommand "${t}"\n${GA()}`,exitCode:1}}}function QA(){return S(`oauth-domain`,async e=>{if(e.length===0||w(e))return{stdout:GA(),stderr:``,exitCode:0};let t=C(e);if(`error`in t)return KA(t.error);let[n,r,i]=t.positionals,a=await import(`./account-store-D0xdiy20.js`).then(e=>e.t);try{return await ZA(a,n,r,i)}catch(e){return KA(e instanceof Error?e.message:String(e))}})}function $A(){return S(`oauth-token`,async(e,t)=>{let{runOAuthToken:n}=await import(`./run-RApyrvLo.js`);return n(e,t)})}const ej=[`--download`,`-d`,`--view`,`-v`],tj=[`--size`],nj={low:256,medium:768,high:1536};function rj(){return{stdout:`usage: open [--download|-d] [--view|-v [--size <spec>]] <url|path> [url|path...]
1595
1595
 
1596
1596
  VFS paths are served in a new browser tab via the preview service worker.
1597
1597
  URLs (http/https/etc.) are opened directly in a new tab.
@@ -1617,7 +1617,7 @@ Examples:
1617
1617
  `);let i=!1;try{i=(await t.fs.stat(e)).isDirectory}catch{}let a=await mr(t.fs,i?e:Sr(e)),o=Wr(e,a),s;try{s=await r(o)}catch(e){return G(`${e instanceof Error?e.message:String(e)}\n`)}return fj(`opened ${e} → ${o}${pj(s)}`)}async function bj(e,t,n,r){if(!gr(e)&&e.endsWith(`.shtml`)&&t.fs)return hj(e,t,r.sprinkleManager,r.canOpenWindow,r.openExternal);if(!n.view&&!r.canOpenWindow)return G(`open: browser APIs are unavailable in this environment
1618
1618
  `);if(gr(e))return gj(e,r.canOpenWindow,r.openExternal);let i=t.fs.resolvePath(t.cwd,e);return n.view?_j(e,i,t,n.sizeSpec):n.download?vj(e,i,t,r.hasDom):yj(i,t,r.canOpenWindow,r.openExternal)}function xj(e){return S(`open`,async(t,n)=>{if(t.length===0||w(t,{valueFlags:tj}))return rj();let r=dj(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 rj();let c=globalThis.__slicc_sprinkleManager,l=typeof window<`u`&&typeof document<`u`,u=l?null:y(),d={canOpenWindow:!!e||l||!!u,hasDom:l,sprinkleManager:c,openExternal:mj(e,l,u)},f=[];for(let e of s){let t=await bj(e,n,{view:a,download:i,sizeSpec:o},d);if(!t.ok)return t.result;f.push(t.message)}return{stdout:f.join(`
1619
1619
  `)+`
1620
- `,stderr:``,exitCode:0}})}function Sj(){return S(`patch`,async(e,t)=>{let{runPatch:n}=await import(`./run-BVj8rfi8.js`);return n(e,t)})}function Cj(e=`pdftk`){return S(e,async(t,n)=>{let{runPdftk:r}=await import(`./run-BEs473Sp.js`);return r(e,t,n)})}function wj(){return{stdout:`usage: pdftoppm [options] <input.pdf> [output-prefix]
1620
+ `,stderr:``,exitCode:0}})}function Sj(){return S(`patch`,async(e,t)=>{let{runPatch:n}=await import(`./run-DCDVvZUu.js`);return n(e,t)})}function Cj(e=`pdftk`){return S(e,async(t,n)=>{let{runPdftk:r}=await import(`./run-BEs473Sp.js`);return r(e,t,n)})}function wj(){return{stdout:`usage: pdftoppm [options] <input.pdf> [output-prefix]
1621
1621
 
1622
1622
  Rasterize PDF pages to images. Writes <prefix>-<n>.<ext> per page, where <n>
1623
1623
  is zero-padded to the digit width of the last page (out-1.png for a 9-page
@@ -1912,7 +1912,7 @@ Limits and lifetime:
1912
1912
  `,exitCode:1};if(e.ttlMs!==void 0&&e.maxTabs!==void 0)return{stdout:``,stderr:`serve: --ttl cannot be combined with --max-tabs
1913
1913
  `,exitCode:1}}async function TP(e,t,n){if(e.ttlMs!==void 0){if(!t)throw Error(`persistent snapshot filesystem unavailable`);return _P(t,n)}}async function EP(e,t,n,r){if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return tP();let i=sP(e);if(i.error)return{stdout:``,stderr:i.error,exitCode:1};let a=await CP(i);if(a)return a;if(!i.directory)return tP();let o=wP(i);if(o)return o;let s=await cP(i.directory,i.entry,t.fs,t.cwd);if(lP(s))return s;let{fullDirectory:c,entryPath:l}=s,u;try{u=await TP(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)
1914
1914
  `:``,f=await xP(!i.noBridge&&i.bridge,d);return f.ok?SP(i,c,l,f.webhookId,d,u,n):f.result}function DP(e,t){return S(`serve`,(n,r)=>EP(n,r,e,t))}const OP=`usage: session export [--id <id>] [--output <path>]
1915
- `;function kP(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 AP(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${OP}`};let n=r[e+1];if(!n||n.startsWith(`-`))return{ok:!1,stderr:`session export: --id requires a value\n${OP}`};t=n,e++}else if(i===`--output`){if(n!==null)return{ok:!1,stderr:`session export: duplicate flag --output\n${OP}`};let t=r[e+1];if(!t||t.startsWith(`-`))return{ok:!1,stderr:`session export: --output requires a path\n${OP}`};n=t,e++}else if(i.startsWith(`-`))return{ok:!1,stderr:`session export: unknown flag ${i}\n${OP}`};else return{ok:!1,stderr:`session export: unexpected argument ${JSON.stringify(i)}\n${OP}`}}return{ok:!0,args:{sessionId:t,outputPath:n}}}async function jP(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||Et(r)!==a.sha256)throw new Aa(`transfer-corrupt`);return r}async function MP(e,t){let n=AP(e);if(!n.ok)return{stdout:``,stderr:n.stderr,exitCode:1};let{sessionId:r,outputPath:i}=n.args;if(i!==null){let e=kP(i);if(!e.ok)return{stdout:``,stderr:`session export: --output ${e.reason}\n${OP}`,exitCode:1}}let a=r==null?{kind:`active`}:{kind:`frozen`,sessionId:r};try{let e=await _s().export(a,{}),n=await jP(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 Aa?e.code:e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}function NP(){return S(`session`,async(e,t)=>{if(e[0]===`export`&&!w(e))return MP(e,t);let{dispatchSessionMemoryAware:n}=await import(`./session-command-memory-Cep9cwKm.js`);return n(e,t,OP)})}function PP(){return S(`slicc`,async(e,t)=>{let{runSlicc:n}=await import(`./run-BRFnmkzR.js`);return await n(e,t)})}const FP=`leader`;function IP(){try{let e=globalThis.localStorage?.getItem(`slicc.leaderSprinkleInstances`);if(e)return JSON.parse(e)}catch{}return[]}function LP(e){return+!!e.leader+e.followers.length}function RP(){return{stdout:`usage: sprinkle <subcommand> [args]
1915
+ `;function kP(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 AP(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${OP}`};let n=r[e+1];if(!n||n.startsWith(`-`))return{ok:!1,stderr:`session export: --id requires a value\n${OP}`};t=n,e++}else if(i===`--output`){if(n!==null)return{ok:!1,stderr:`session export: duplicate flag --output\n${OP}`};let t=r[e+1];if(!t||t.startsWith(`-`))return{ok:!1,stderr:`session export: --output requires a path\n${OP}`};n=t,e++}else if(i.startsWith(`-`))return{ok:!1,stderr:`session export: unknown flag ${i}\n${OP}`};else return{ok:!1,stderr:`session export: unexpected argument ${JSON.stringify(i)}\n${OP}`}}return{ok:!0,args:{sessionId:t,outputPath:n}}}async function jP(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||Et(r)!==a.sha256)throw new Aa(`transfer-corrupt`);return r}async function MP(e,t){let n=AP(e);if(!n.ok)return{stdout:``,stderr:n.stderr,exitCode:1};let{sessionId:r,outputPath:i}=n.args;if(i!==null){let e=kP(i);if(!e.ok)return{stdout:``,stderr:`session export: --output ${e.reason}\n${OP}`,exitCode:1}}let a=r==null?{kind:`active`}:{kind:`frozen`,sessionId:r};try{let e=await _s().export(a,{}),n=await jP(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 Aa?e.code:e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}function NP(){return S(`session`,async(e,t)=>{if(e[0]===`export`&&!w(e))return MP(e,t);let{dispatchSessionMemoryAware:n}=await import(`./session-command-memory-C7L8WXSk.js`);return n(e,t,OP)})}function PP(){return S(`slicc`,async(e,t)=>{let{runSlicc:n}=await import(`./run-BRFnmkzR.js`);return await n(e,t)})}const FP=`leader`;function IP(){try{let e=globalThis.localStorage?.getItem(`slicc.leaderSprinkleInstances`);if(e)return JSON.parse(e)}catch{}return[]}function LP(e){return+!!e.leader+e.followers.length}function RP(){return{stdout:`usage: sprinkle <subcommand> [args]
1916
1916
 
1917
1917
  list [--runtime <id>] List sprinkles + an instance line per runtime
1918
1918
  open <name> Open a sprinkle by name
@@ -3062,7 +3062,7 @@ or pass -bios / -vgabios with explicit VFS paths.`,vR={"-n":yR,"-name":yR,"--nam
3062
3062
  `)}\n`)}function BR(e,t){return`prefer: computer ${e} -c ${t}\n`}async function VR(e,t,n,r){let i=TR(t);if(ER(i))return i;let[{runComputer:a},{getComputerRegistry:o,installComputerRegistry:s},c]=await Promise.all([import(`./run-CnfMQAT6.js`).then(e=>e.t),import(`./registry-DfuJBCKY.js`),import(`./v86-DKE8ZbX9.js`)]),l=c.v86ComputerId(t),u=o()??s(null);return u.get(l)||c.registerV86Computer(i,u),HR(await a([`-c`,l,...n],e,{registry:u}),r,l)}function HR(e,t,n){let r=BR(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 UR(e,t){let{name:n,rest:r}=wR(e);if(r.length===0){let e=TR(n);return ER(e)?e:Q(`type: no text supplied`)}return VR(t,n,[`type`,`--`,...r],`type`)}async function WR(e,t){let{name:n,rest:r}=wR(e);if(r.length===0){let e=TR(n);return ER(e)?e:Q(`key: no chord supplied`)}return VR(t,n,[`key`,...r],`key`)}const GR=[`left`,`middle`,`right`];async function KR(e,t){let{name:n,rest:r}=wR(e),i=TR(n);if(ER(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?VR(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>`):VR(t,n,[`--native`,`mousemove`,e,i,`--relative`],`mousemove`)}if(o===`click`){let e=r[1]??`left`;if(!GR.includes(e))return Q(`mouse: unknown button '${r[1]}'`);let i=[`click`,e];return r.includes(`--double`)&&i.push(`--repeat`,`2`),VR(t,n,i,`click`)}return Q(`mouse: expected move <dx> <dy>, click [button], or --to <x>,<y>`)}async function qR(e,t){let{name:n,rest:r}=wR(e);return VR(t,n,[`screenshot`,...r],`screenshot`)}async function JR(e,t){let{name:n}=wR(e);return VR(t,n,[`text`],`text`)}function YR(e){let{name:t}=wR(e);return $(`v86 serve is retired.\nUse: computer watch -c v86:${t}\nLive frames go to the overlay, lightbox, and bash rows.\n`)}function XR(e){let{name:t,rest:n}=wR(e),r=TR(t);if(ER(r))return r;let i=n.indexOf(`--send`);if(i!==-1){let e=n.slice(i+1).join(` `).replace(/\\n/gu,`
3063
3063
  `);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(`
3064
3064
  `).slice(-Math.max(1,e)).join(`
3065
- `)}\n`)}return $(r.serial.buffer?`${r.serial.buffer}\n`:``)}async function ZR(e,t){let{name:n,rest:r}=wR(e),i=TR(n);if(ER(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 QR(e,t){let{name:n,rest:r}=wR(e),i=TR(n);if(ER(i))return i;let a=t.processManager??kR();return r.includes(`--force`)&&a&&i.pid!==null?(a.signal(i.pid,`SIGKILL`),$(`VM '${n}' killed\n`)):(await RR(i,a),$(`VM '${n}' stopped\n`))}function $R(e={}){return S(`wasm`,async(t,n)=>{let{runWasmCommand:r}=await import(`./run-Cf2apntf.js`);return r(t,n,{processConfig:e.buildProcessConfig?.(n.env),terminal:e.terminal,gate:e.gate,commands:e.commands,gitIdentity:e.gitIdentity})})}const ez=[`--name`,`--filter`,`--scoop`],tz={state:`inactive`,session:null};function nz(){return{stdout:`usage: webhook <command> [options]
3065
+ `)}\n`)}return $(r.serial.buffer?`${r.serial.buffer}\n`:``)}async function ZR(e,t){let{name:n,rest:r}=wR(e),i=TR(n);if(ER(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 QR(e,t){let{name:n,rest:r}=wR(e),i=TR(n);if(ER(i))return i;let a=t.processManager??kR();return r.includes(`--force`)&&a&&i.pid!==null?(a.signal(i.pid,`SIGKILL`),$(`VM '${n}' killed\n`)):(await RR(i,a),$(`VM '${n}' stopped\n`))}function $R(e={}){return S(`wasm`,async(t,n)=>{let{runWasmCommand:r}=await import(`./run-BStZvimF.js`);return r(t,n,{processConfig:e.buildProcessConfig?.(n.env),terminal:e.terminal,gate:e.gate,commands:e.commands,gitIdentity:e.gitIdentity})})}const ez=[`--name`,`--filter`,`--scoop`],tz={state:`inactive`,session:null};function nz(){return{stdout:`usage: webhook <command> [options]
3066
3066
 
3067
3067
  Commands:
3068
3068
  create [--scoop <name>] [--name <name>] [--filter <code>] Create a new webhook endpoint
@@ -3324,7 +3324,7 @@ pass --wait to block and print the full result.`,xB=new Set([`list`,`status`,`st
3324
3324
  `,stderr:``,exitCode:0};let n;try{n=qB(e)}catch(e){return FB(e.message)}let r=n.positional[0],i=n.positional[1],a=!r||r===`-`,o;try{o=await YB(t,r,a)}catch{return FB(`${r}: No such file or directory`)}if(n.revert){let e=RB(o),r=n.plain?UB(e):WB(e);return i?(await t.fs.writeFile(t.fs.resolvePath(t.cwd,i),r),{stdout:``,stderr:``,exitCode:0}):{stdout:RB(r),stderr:``,exitCode:0}}let{data:s,base:c}=ZB(n,o),l=XB(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 $B(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=_r(t,o),s=n?`${n}/${o}`:o;a+=await $B(e,i,s,r)}return a}function eV(){return{stdout:`usage: zip [-r] <archive.zip> <path> [path...]
3325
3325
  `,stderr:``,exitCode:0}}function tV(){return S(`zip`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return eV();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
3326
3326
  `,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(/^\.\//,``))||vr(r);if(i.isDirectory&&!n)return{stdout:``,stderr:`zip: ${e} is a directory (use -r)\n`,exitCode:1};s+=await $B(t,r,a,o)}if(s===0)return{stdout:``,stderr:`zip: nothing to do
3327
- `,exitCode:1};let c=Ot(o);return await t.fs.writeFile(i,c),{stdout:`created ${i} (${s} file(s))\n`,stderr:``,exitCode:0}})}function nV(e){let t;return S(`mcp`,async(n,r)=>{if(!t){let{createMcpCommand:n}=await import(`./mcp-command-BeBM1rHC.js`);t=n({fs:e.fs,scriptCatalog:e.scriptCatalog,connectionManager:e.mcpConnectionManager})}return t.execute(n,r)})}function rV(e){return{setEnv:e.setEnv,unsetEnv:e.unsetEnv,broker:e.sudoCommand?.broker}}function iV(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),rk(`ipx`,{fs:t,fetch:n}),rk(`npx`,{fs:t,fetch:n}),ab(`di`,{fs:t,fetch:n}),ab(`uv`,{fs:t,fetch:n}),OL({fs:t,fetch:n})]}function aV(e){let t={buildProcessConfig:e.buildProcessConfig};return[`python3`,`python`,`pyodide`].map(e=>LM(e,t))}function oV(e){let t=e.scriptCatalog;return{buildProcessConfig:e.buildProcessConfig,terminal:e.terminal,gate:e.gateNativeCommand,commands:t&&(()=>t.getWasmCommands()),gitIdentity:e.gitIdentity}}function sV(e={}){let t=[yE({getJshCommands:e.getJshCommands,getWorkflowCommands:e.getWorkflowCommands}),ae(),hF(),PP(),DP(e.browserAPI,e.fs),xj(e.browserAPI),by(e.browserAPI),wD(e),tV(),iL(),XF(e.fs?{fs:e.fs}:{}),SF(),kF(),EF(),hv(),$R(oV(e)),BS(oV(e)),QB(),lF(`sqlite3`),lF(`sqllite`),pI(),NI(),xx(),Z_(),RA({buildProcessConfig:e.buildProcessConfig}),RA({buildProcessConfig:e.buildProcessConfig},`jsh`),...aV(e),...iV(e),...e.fs?[zS({fs:e.fs})]:[],...e.fs?[Xk({fs:e.fs})]:[],...e.fetch?[AE({fetch:e.fetch,streamFetch:e.streamFetch})]:[],mS(),hS(),DS(),mz(e.webhook),$z(),yy(e.crontask),nV(e),Vj({fs:e.fs,fetch:e.fetch}),RS(),eF(),Sj(),Cj(`pdftk`),Cj(`pdf`),Q_(`biscotto`,{getParentJid:e.getParentJid,isScoop:e.isScoop}),Q_(`biscotti`,{getParentJid:e.getParentJid,isScoop:e.isScoop}),Nj(`pdftoppm`),Nj(`pdftocairo`),Pj(`pdftotext`),ry(`convert`),ry(`magick`),lB({fs:e.fs,scriptCatalog:e.scriptCatalog,getStaticBuiltins:e.getStaticBuiltins,getScriptRegisteredNames:e.getScriptRegisteredNames}),LI(),$I(),bD(),xD(),eL(),Zk(),VM(),Uk(),Kb(),$A(),QA(),Bk(),QN(rV(e)),Om(e.gitCredential),eN({fs:e.fs}),EN(),fv(),pv(),mv(`xclip`),mv(`xsel`),TN(),tC(),Ug(),Wg(),wA(e.fs),st(),UA(),Gg({getParentJid:e.getParentJid}),ex(),lM({processManager:e.processManager}),UL({processManager:e.processManager}),ok({processManager:e.processManager}),ik({processManager:e.processManager,scriptCatalog:e.scriptCatalog}),...qg(),Yk(),Mk(),mR(),nD(),nS(),AR({processManager:e.processManager}),vv({processManager:e.processManager,browser:e.browserAPI,sudoBroker:e.sudoCommand?.broker}),pS(),av({registry:e.cherryRuntimeRegistry}),ky(),Fy({fs:e.fs}),Iy({fs:e.fs}),_F(e.sudoCommand),EB({getParentJid:e.getParentJid,syncScriptCommands:e.syncScriptCommands}),eB(),NP()];return e.fs&&(Ij(),t.push(...Gn.map(t=>gE(t,e.browserAPI,e.fs,{isScoop:e.isScoop})))),t}let cV=null;function lV(e){cV=e}function uV(e){cV?.(e)}var dV=zt();const fV={user:`user`,home:pp},pV=new Set([`root`,`nobody`,`nogroup`]),mV=/^[A-Za-z_][A-Za-z0-9_.-]*$/;function hV(e){return{user:mV.test(e.user)&&!pV.has(e.user)?e.user:fV.user,home:e.home.startsWith(`/`)&&!/[:\n]/.test(e.home)?e.home:fV.home}}function gV(e,t){let{user:n,home:r}=hV(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(`
3327
+ `,exitCode:1};let c=Ot(o);return await t.fs.writeFile(i,c),{stdout:`created ${i} (${s} file(s))\n`,stderr:``,exitCode:0}})}function nV(e){let t;return S(`mcp`,async(n,r)=>{if(!t){let{createMcpCommand:n}=await import(`./mcp-command-CSD8gKx4.js`);t=n({fs:e.fs,scriptCatalog:e.scriptCatalog,connectionManager:e.mcpConnectionManager})}return t.execute(n,r)})}function rV(e){return{setEnv:e.setEnv,unsetEnv:e.unsetEnv,broker:e.sudoCommand?.broker}}function iV(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),rk(`ipx`,{fs:t,fetch:n}),rk(`npx`,{fs:t,fetch:n}),ab(`di`,{fs:t,fetch:n}),ab(`uv`,{fs:t,fetch:n}),OL({fs:t,fetch:n})]}function aV(e){let t={buildProcessConfig:e.buildProcessConfig};return[`python3`,`python`,`pyodide`].map(e=>LM(e,t))}function oV(e){let t=e.scriptCatalog;return{buildProcessConfig:e.buildProcessConfig,terminal:e.terminal,gate:e.gateNativeCommand,commands:t&&(()=>t.getWasmCommands()),gitIdentity:e.gitIdentity}}function sV(e={}){let t=[yE({getJshCommands:e.getJshCommands,getWorkflowCommands:e.getWorkflowCommands}),ae(),hF(),PP(),DP(e.browserAPI,e.fs),xj(e.browserAPI),by(e.browserAPI),wD(e),tV(),iL(),XF(e.fs?{fs:e.fs}:{}),SF(),kF(),EF(),hv(),$R(oV(e)),BS(oV(e)),QB(),lF(`sqlite3`),lF(`sqllite`),pI(),NI(),xx(),Z_(),RA({buildProcessConfig:e.buildProcessConfig}),RA({buildProcessConfig:e.buildProcessConfig},`jsh`),...aV(e),...iV(e),...e.fs?[zS({fs:e.fs})]:[],...e.fs?[Xk({fs:e.fs})]:[],...e.fetch?[AE({fetch:e.fetch,streamFetch:e.streamFetch})]:[],mS(),hS(),DS(),mz(e.webhook),$z(),yy(e.crontask),nV(e),Vj({fs:e.fs,fetch:e.fetch}),RS(),eF(),Sj(),Cj(`pdftk`),Cj(`pdf`),Q_(`biscotto`,{getParentJid:e.getParentJid,isScoop:e.isScoop}),Q_(`biscotti`,{getParentJid:e.getParentJid,isScoop:e.isScoop}),Nj(`pdftoppm`),Nj(`pdftocairo`),Pj(`pdftotext`),ry(`convert`),ry(`magick`),lB({fs:e.fs,scriptCatalog:e.scriptCatalog,getStaticBuiltins:e.getStaticBuiltins,getScriptRegisteredNames:e.getScriptRegisteredNames}),LI(),$I(),bD(),xD(),eL(),Zk(),VM(),Uk(),Kb(),$A(),QA(),Bk(),QN(rV(e)),Om(e.gitCredential),eN({fs:e.fs}),EN(),fv(),pv(),mv(`xclip`),mv(`xsel`),TN(),tC(),Ug(),Wg(),wA(e.fs),st(),UA(),Gg({getParentJid:e.getParentJid}),ex(),lM({processManager:e.processManager}),UL({processManager:e.processManager}),ok({processManager:e.processManager}),ik({processManager:e.processManager,scriptCatalog:e.scriptCatalog}),...qg(),Yk(),Mk(),mR(),nD(),nS(),AR({processManager:e.processManager}),vv({processManager:e.processManager,browser:e.browserAPI,sudoBroker:e.sudoCommand?.broker}),pS(),av({registry:e.cherryRuntimeRegistry}),ky(),Fy({fs:e.fs}),Iy({fs:e.fs}),_F(e.sudoCommand),EB({getParentJid:e.getParentJid,syncScriptCommands:e.syncScriptCommands}),eB(),NP()];return e.fs&&(Ij(),t.push(...Gn.map(t=>gE(t,e.browserAPI,e.fs,{isScoop:e.isScoop})))),t}let cV=null;function lV(e){cV=e}function uV(e){cV?.(e)}var dV=zt();const fV={user:`user`,home:pp},pV=new Set([`root`,`nobody`,`nogroup`]),mV=/^[A-Za-z_][A-Za-z0-9_.-]*$/;function hV(e){return{user:mV.test(e.user)&&!pV.has(e.user)?e.user:fV.user,home:e.home.startsWith(`/`)&&!/[:\n]/.test(e.home)?e.home:fV.home}}function gV(e,t){let{user:n,home:r}=hV(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(`
3328
3328
  `);if(e===`/etc/group`)return[`root:x:0:`,`${n}:x:1000:`,`nogroup:x:65534:`,``].join(`
3329
- `)}function _V(e,t=fV){let n=gV(e,t);return n===void 0?void 0:new TextEncoder().encode(n)}function vV(e){return e===`/etc`?[`group`,`passwd`]:[]}function yV(e){return e?.code===`ENOENT`}const bV=Reflect.get(tt,`DefenseInDepthBox`);function xV(e){return(typeof e==`string`?e:e?.encoding)??`utf8`}function SV(e,t){if(typeof e!=`string`)return e;let n=xV(t);if(n===`binary`||n===`latin1`){let t=ye(e);if(t)return t}return dV.Buffer.from(e,n)}function CV(e){return e===`/bin`?`/usr/bin`:e.startsWith(`/bin/`)?`/usr${e}`:e}function wV(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 TV(e,t){let n=vV(e).filter(e=>!t.includes(e));return n.length?[...t,...n].sort():t}function EV(e,t){let n=vV(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 DV=class{vfs;registeredCommandsFn=null;identityFn=null;listingStats=new Map;listingStatsMax;listingStatsTtlMs;constructor(e,t){this.vfs=e,this.listingStatsMax=Math.max(1,t?.listingStatsMax??2e4),this.listingStatsTtlMs=t?.listingStatsTtlMs??1e3,this.updateMetadataBatch=this.updateMetadataBatch.bind(this),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=Be(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 _V(e,this.identityFn?.()??fV)}isVirtualBinCommand(e){return e.length>0&&!e.includes(`/`)&&this.getVirtualBinCommands().includes(e)}getVirtualBinCommands(){return this.registeredCommandsFn?.()??[]}virtualUsrStat(e){let t=CV(e);if(t===`/usr`||t===`/usr/bin`)return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date(0)};if(t.startsWith(`/usr/bin/`)){let e=t.slice(9);if(this.isVirtualBinCommand(e))return{isFile:!0,isDirectory:!1,isSymbolicLink:!1,mode:493,size:wV(e).length,mtime:new Date(0)}}return null}canWrite(e){let t=this.vfs;return typeof t.canWrite!=`function`||t.canWrite(e)}listMountPoints(){let e=this.vfs;return typeof e.listMountPoints==`function`?e.listMountPoints():[]}trusted(e){let t=bV?.runTrustedAsync;return t?t(e):Promise.resolve().then(e)}async readFile(e,t){return this.trusted(async()=>{let n=b(e),r=await this.readRaw(n),i=xV(t),a=dV.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(b(e)))}async readRaw(e){let t=CV(e);if(t.startsWith(`/usr/bin/`)&&this.isVirtualBinCommand(t.slice(9)))return wV(t.slice(9));let n;try{n=await this.vfs.readFile(e,{encoding:`binary`})}catch(t){let n=this.identityFile(e);if(n&&yV(t))return n;throw t}return n instanceof Uint8Array?n:new TextEncoder().encode(n)}identityStat(e,t){let n=this.identityFile(e);if(!(!n||!yV(t)))return{isFile:!0,isDirectory:!1,isSymbolicLink:!1,mode:420,size:n.length,mtime:new Date(0)}}async readFileBytes(e){let t=await this.readFileBuffer(e);return dV.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString(`latin1`)}async getNativeFile(e){return this.trusted(()=>this.vfs.getNativeFile(b(e)))}async readFileRange(e,t,n){return this.trusted(()=>this.vfs.readFileRange(b(e),t,n))}async writeFile(e,t,n){return this.dropListingStats(),this.trusted(async()=>{let r=b(e);await this.vfs.writeFile(r,SV(t,n))})}async appendFile(e,t,n){return this.dropListingStats(),this.trusted(()=>this.vfs.appendFile(b(e),SV(t,n)))}async exists(e){return this.trusted(async()=>{let t=b(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=b(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=b(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(b(e),t)})}async readdir(e){return this.trusted(async()=>{let t=b(e);if(t===`/usr`)return[`bin`];if(CV(t)===`/usr/bin`)return this.getVirtualBinCommands().slice().sort();let n=this.vfs.readDirSync(t);if(n!==null)return TV(t,n.map(e=>e.name));let r=await this.vfs.readDir(t,{includeStats:!0});return this.primeListingStats(t,r),TV(t,r.map(e=>e.name))})}async readdirWithFileTypes(e){return this.trusted(async()=>{let t=b(e);if(t===`/usr`)return[{name:`bin`,isFile:!1,isDirectory:!0,isSymbolicLink:!1}];if(CV(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 EV(t,this.mapFastEntriesToDirents(n));let r=await this.vfs.readDir(t,{includeStats:!0});return this.primeListingStats(t,r),EV(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(b(e),t)})}async cp(e,t,n){return this.dropListingStats(),this.trusted(async()=>{let r=b(e),i=b(t),a;try{a=await this.vfs.stat(r)}catch(e){let t=this.identityFile(r);if(!t||!yV(e))throw e;await this.vfs.writeFile(i,t);return}if(a.type===`directory`){if(!n?.recursive)throw new Ve(`EISDIR`,`is a directory`,r);await this.cpDir(r,i)}else await this.vfs.copyFile(r,i)})}async cpDir(e,t){await this.vfs.mkdir(t,{recursive:!0});let n=await this.vfs.readDir(e);for(let r of n){let n=x(e,r.name),i=x(t,r.name);r.type===`directory`?await this.cpDir(n,i):await this.vfs.copyFile(n,i)}let r=new Set(n.map(e=>e.name));for(let n of vV(e)){let i=r.has(n)?void 0:this.identityFile(x(e,n));i&&await this.vfs.writeFile(x(t,n),i)}}async mv(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.rename(b(e),b(t))})}async rename(e,t){return this.mv(e,t)}resolvePath(e,t){return t.startsWith(`/`)?b(t):b(x(e,t))}getAllPaths(){return[]}async chmod(e,t){return this.dropListingStats(),this.trusted(()=>this.vfs.chmod(b(e),t))}async updateMetadataBatch(e){return this.dropListingStats(),this.trusted(()=>this.vfs.updateMetadataBatch(e.map(e=>({...e,path:b(e.path)}))))}async symlinkBatch(e){return this.dropListingStats(),this.trusted(()=>this.vfs.symlinkBatch(e.map(e=>({target:e.target,path:b(e.path)}))))}async symlink(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.symlink(e,b(t))})}async link(e,t){throw Error(`Hard links not supported in VirtualFS`)}async readlink(e){return this.trusted(async()=>this.vfs.readlink(b(e)))}async realpath(e){return this.trusted(async()=>this.vfs.realpath(b(e)))}async utimes(e,t,n){return this.dropListingStats(),this.trusted(()=>this.vfs.utimes(b(e),t,n))}invalidatePaths(e){this.dropListingStats();let t=this.vfs;t.invalidatePaths&&t.invalidatePaths(e)}async forgetSidecarConsistency(){await this.vfs.forgetSidecarConsistency?.()}};function OV(e){return e&&typeof e.getWatcher==`function`?e.getWatcher?.()??null:e&&typeof e.getUnderlyingFS==`function`?OV(e.getUnderlyingFS?.()):null}async function kV(e){let t=ve(`github`);if(t){if(e?.force){await t.onSilentRenew?.();return}await t.getValidAccessToken?.()}}function AV(){let e=ve(`github`);if(!e)return ym;let t=typeof localStorage>`u`?[]:l(localStorage).github;return[...e.oauthTokenDomains??ym,...t??[]]}const jV=e(`almost-bash-shell`),MV=`__SLICC_RUN_PID`,NV=`__SLICC_OUTPUT_TEE__`;function PV(e){let t=e?.get(MV);if(t===void 0)return;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>0?n:void 0}function FV(e){if(!(MV in e)&&!(NV in e)&&!(`__SLICC_SUDO_REASON`in e)&&!(`__SLICC_PIPESTATUS`in e)&&!(`__SLICC_PIPESTATUS_EX`in e))return{...e};let{[MV]:t,[NV]:n,[nm]:r,[jt]:i,[Nt]:a,...o}=e;return o}function IV(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 LV=class e{options;bash;vfsAdapter;gitCommands;mountCommands;lastEnv;cwd;umask=18;builtinCommandNames;staticBuiltinNames;allowedCommands;scriptCatalog;initialJshSync=null;ownsScriptCatalog;registeredJshCommands=new Map;registeredWorkflowCommands=new Set;registeredWasmCommands=new Set;jshSyncInflight=null;jshSyncDirty=!1;pendingCommandGrants=[];pendingSudoBypasses=new Map;pendingEnvWrites=new Map;activeShellPid;progress;activeRunSignal;commandAbort=new AbortController;scriptRun=null;scriptRunsActive=0;registryNames=new Set;outputTees=new Map;nextOutputTeeId=0;resolveJshProcessConfig=e=>this.buildJshProcessConfig(PV(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:pp,PATH:sr,USER:`user`,SHELL:`/bin/bash`,TMPDIR:`/tmp`,PWD:t,...e.env}}buildSupplementalCommands(e,t,n){return sV({onMediaPreview:async e=>this.renderMediaPreview(e),getJshCommands:()=>this.getJshCommandNames(),getWorkflowCommands:()=>this.getWorkflowCommandNames(),syncScriptCommands:()=>this.syncJshCommands(),getStaticBuiltins:()=>[...this.staticBuiltinNames],getScriptRegisteredNames:()=>[...this.registeredJshCommands.keys(),...this.registeredWorkflowCommands,...this.registeredWasmCommands],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.pendingCommandGrants.push(e)},suppressNextGate:e=>this.registerSudoBypass(e)}:void 0,setEnv:(e,t)=>{this.pendingEnvWrites.set(e,t),this.lastEnv[e]=t},unsetEnv:e=>{this.pendingEnvWrites.set(e,null),delete this.lastEnv[e]},gitCredential:{githubToken:(e,t)=>this.gitCommands.githubCredential(e,t),githubDomains:AV},gitIdentity:()=>this.gitCommands.identity(),mcpConnectionManager:e.mcpConnectionManager})}constructor(t){this.options=t,this.vfsAdapter=new DV(t.fs),this.progress=new _p({scrubLabel:t.scrubProgressLabel}),this.allowedCommands=e.buildAllowedCommandSet(t);let n=t.cwd??`/`,r=e.buildInitialEnv(t,n);this.gitCommands=new ap({fs:t.fs,authorName:r.GIT_AUTHOR_NAME??`User`,authorEmail:r.GIT_AUTHOR_EMAIL??`user@example.com`,ensureFreshGithubToken:kV}),this.mountCommands=new Ms({fs:t.fs,isScoop:t.isScoop,acquireLocalMountViaToolUI:Nm});let i=t.jshDiscoveryFs??t.fs,a=t.bshDiscoveryFs??t.fs,o=OV(i)??OV(a);this.scriptCatalog=t.scriptCatalog??new Si({jshFs:i,bshFs:a,watcher:o}),this.ownsScriptCatalog=!t.scriptCatalog,o&&o.watch(`/`,e=>e.endsWith(`.jsh`)||e.endsWith(`.workflow.js`)||ar(e),()=>{this.syncJshCommands().catch(()=>void 0)});let s=this.createGitCustomCommand(),c=g({progress:Sp(this.progress)}),l=_({progress:Sp(this.progress)}),u=this.buildSupplementalCommands(t,c,l),d=[s,this.createMountCustomCommand(),this.createUmountCustomCommand(),Dh(t.fs),wg(t.fs,c,t.browserAPI),...u].filter(e=>this.isCommandAllowed(e.name)),f=[...rt(),...nt()],p=this.allowedCommands?f.filter(e=>this.isCommandAllowed(e)):void 0;if(this.bash=new it({fs:this.vfsAdapter,cwd:n,env:{},fetch:c,commands:p,customCommands:d,sleep:Up(this.progress,{isAborted:()=>this.activeRunSignal?.aborted??!1}),executionLimitProfile:t.executionLimitProfile,executionLimits:sp(t.isScoop?.()??!1,t.executionLimits)}),this.bash.registerTransformPlugin(Vm),this.allowedCommands!==null){let e=this.bash;for(let t of nt())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??[...rt(),...nt()];this.builtinCommandNames=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.startInitialJshSync()}getBash(){return this.bash}getCwd(){return this.cwd}getScriptCatalog(){return this.scriptCatalog}getEnv(){return{...this.lastEnv}}setMaskedEnvVar(e,t){this.pendingEnvWrites.set(e,t),this.lastEnv[e]=t}applySessionOverrides(e){e.cwd!==void 0&&(this.cwd=e.cwd,this.lastEnv.PWD=e.cwd),e.env&&Object.assign(this.lastEnv,e.env)}async getJshCommandNames(){return[...(await this.getFilteredJshCommands()).keys()]}async syncJshCommands(){return this.jshSyncInflight===null?(this.jshSyncInflight=this.doSyncJshCommands(),this.jshSyncInflight):(this.jshSyncDirty=!0,this.jshSyncInflight)}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 ni(e,t,{fs:this.vfsAdapter,cwd:this.cwd,env:new Map(Object.entries(this.lastEnv)),stdin:``,exec:(e,t)=>this.bash.exec(e,{env:t?.env??this.lastEnv,cwd:t?.cwd??this.cwd,umask:this.umask,...t?.env===void 0?{}:{replaceEnv:!0}})},this.buildJshProcessConfig())}dispose(){this.ownsScriptCatalog&&this.scriptCatalog.dispose()}async renderMediaPreview(e){throw Error(`terminal preview is unavailable in headless mode`)}currentScanRoots(){return cr(this.lastEnv.PATH)}startInitialJshSync(){this.initialJshSync=this.initHomeAndProfile().then(()=>this.syncJshCommands()).catch(()=>void 0).finally(()=>{this.initialJshSync=null})}async initHomeAndProfile(){let e=this.options.fs;try{let t=this.options.env?.HOME??await mp(e);this.lastEnv.HOME=t,this.options.env?.USER||(this.lastEnv.USER=hp(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(uV(e.trim().split(/\s+/)[0]||`unknown`),v(),await this.waitForInitialJshSync(t),await this.usesGnuBash())return this.runOnGnuBash(e,t,n,r,i,a);let o=im(e),s={env:{...this.lastEnv,...n===void 0?{}:{[MV]:String(n)},...i===void 0?{}:{[NV]:i},...o?{[nm]:o}:{}},cwd:this.cwd,umask:this.umask,signal:t,...r===``?{}:{stdin:r,stdinKind:`bytes`}},c=this.lastEnv.PATH,l=IV([t,this.commandAbort.signal]);s.signal=l.signal,this.activeRunSignal=l.signal;let u=this.beginScriptRun(e),d;try{d=await this.bash.exec(Pt(e,a),s)}finally{l.release(),this.activeRunSignal===l.signal&&(this.activeRunSignal=void 0),this.endScriptRun(u)}if(await this.flushPendingCommandGrants(),d=kt(d,a),typeof d.umask==`number`&&(this.umask=d.umask),d.env&&(this.lastEnv=FV(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.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-BISPom3l.js`);return Mt(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()}async usesGnuBash(){return!this.options.gnuBash||this.lastEnv.SLICC_SHELL===`just-bash`||typeof SharedArrayBuffer!=`function`?!1:(await this.scriptCatalog.getWasmCommands()).has(`bash`)}async runOnGnuBash(e,t,n,r,i,a){let{runWasmCommand:o,withoutRealmDefaults:s}=await import(`./run-Cf2apntf.js`),c=im(e),l={...this.lastEnv,...n===void 0?{}:{[MV]:String(n)},...c?{[nm]:c}:{}},u=i===void 0?void 0:this.outputTees.get(i),d=await fp(e,{env:l,run:(e,i,a)=>o(e,this.wasmContext(i,t,r),{processConfig:this.buildJshProcessConfig(n),gate:this.gateNativeCommand,onOutput:u,fds:a,commands:()=>this.scriptCatalog.getWasmCommands(),gitIdentity:()=>this.gitCommands.identity()})}),f=this.lastEnv.PATH;return d.state&&(this.cwd=d.state.cwd,this.lastEnv=up(s(d.state.env,l),[MV,nm,NV])),this.lastEnv.PATH!==f&&await this.syncJshCommands().catch(()=>void 0),await this.flushPendingCommandGrants(),this.applyPendingEnvWrites(),{stdout:d.stdout,stderr:d.stderr,exitCode:d.exitCode,env:{...this.lastEnv},...a&&d.state?{pipeStatus:d.state.pipeStatus}:{}}}wasmContext(e,t,n){return{fs:this.vfsAdapter,cwd:this.cwd,env:new Map(Object.entries(e)),exportedEnv:e,stdin:n,signal:t,exec:(e,t)=>this.bash.exec(e,{...t,umask:this.umask})}}gateNativeCommand=async(e,t,n)=>{if(this.allowedCommands!==null&&!this.isCommandAllowed(e))return{stderr:`bash: ${e}: command not found\n`,exitCode:127};if(!this.isTransparentGatingEnabled()||vm.has(e))return null;let r=await this.gateCommandDispatch(e,t,n[nm]);return r?{stderr:r.stderr,exitCode:r.exitCode}:null};isTransparentGatingEnabled(){let e=this.options.sudo;return!!e&&e.transparentGating!==!1}wrapCommandForDispatch(e){let t=this.wrapCommandForSudo(e),n=e.name===`timeout`?qp(t,this.progress):Yp(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(NV),s=o?a.get(o):void 0;s&&(t.writeStdout=s);try{let r=await Zp(()=>n.execute(e,t),t.signal);return i(t.env,r),r}finally{r()}}}}teeCommandOutput(e,t){let n=e?.get(NV);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=Rp(this.bash.transform(e).ast,this.registryNames)}catch{t={totalSteps:null}}return this.scriptRun=new Bp(t,this.progress,zp(e)),this.scriptRun}endScriptRun(e){this.scriptRunsActive=Math.max(0,this.scriptRunsActive-1),e&&(e.end(),this.scriptRun===e&&(this.scriptRun=null))}wrapCommandForSudo(e){if(!this.isTransparentGatingEnabled()||vm.has(e.name))return e;let t=(t,n)=>this.gateCommandDispatch(e.name,t,n);return{...e,async execute(n,r){return await t(n,r.env?.get(nm))||e.execute(n,r)}}}async gateCommandDispatch(e,t,n){let r=this.options.sudo;if(!r)return null;let i=$p(e,t);if(this.consumeSudoBypass(i))return null;let a=r.getPolicy();if(!a)return null;let o=await tm(i,{policy:a,broker:r.broker,persistGrant:async e=>{this.pendingCommandGrants.push(e)},defaultDisposition:r.defaultDisposition,...n?{reason:n}:{}});return o.allowed?null:{stdout:``,stderr:`${o.message}\n`,exitCode:o.exitCode??77}}registerSudoBypass(e){let t=e.trim();t&&this.pendingSudoBypasses.set(t,(this.pendingSudoBypasses.get(t)??0)+1)}consumeSudoBypass(e){let t=this.pendingSudoBypasses.get(e);return t?(t===1?this.pendingSudoBypasses.delete(e):this.pendingSudoBypasses.set(e,t-1),!0):!1}async flushPendingCommandGrants(){if(this.pendingCommandGrants.length===0)return;let e=this.pendingCommandGrants;this.pendingCommandGrants=[];for(let t of e)try{await this.persistCommandGrant(t)}catch{}}async persistCommandGrant(e){let t=this.options.sudo?.persistCommandGrant;if(t){await t(e);return}let n=lt(e);if(!n)return;let r=`${dt}/granted`,i=this.options.fs,a=``;try{await i.exists(r)&&(a=await i.readFile(r))}catch(e){if(!(e instanceof Ve&&e.code===`ENOENT`))throw e}let o=a&&!a.endsWith(`
3330
- `)?`${a}\n`:a;await i.writeFile(r,`${o}NOPASSWD Cmnd ${n}\n`)}isCommandAllowed(e){return this.allowedCommands===null||this.allowedCommands.has(vm.get(e)??e)}async doSyncJshCommands(){try{let e=await this.scriptCatalog.getJshIndex(this.currentScanRoots()),t=e.commands;for(let t of e.collisions)jV.warn(`jsh command '${t.name}' is provided by more than one skill; using ${t.winnerPath} (${t.reason}), shadowed ${t.shadowedPaths.join(`, `)}`);let n=await this.getFilteredWorkflowCommands(),r=await this.scriptCatalog.getWasmCommands();for(let[e,n]of t)this.isCommandAllowed(e)&&(this.builtinCommandNames.has(e)&&!this.registeredJshCommands.has(e)||this.registeredJshCommands.get(e)!==n&&(this.bash.registerCommand(this.wrapCommandForDispatch(this.makeScriptCommand(e))),this.registeredJshCommands.set(e,n),this.builtinCommandNames.add(e)));let i=[...r.keys()].filter(e=>this.isCommandAllowed(e));this.registerLateScriptNames(i,this.registeredWasmCommands),this.registerLateScriptNames(n.keys(),this.registeredWorkflowCommands)}finally{this.jshSyncInflight=null,this.jshSyncDirty&&(this.jshSyncDirty=!1,this.syncJshCommands().catch(()=>void 0))}}registerLateScriptNames(e,t){let n=[this.registeredJshCommands,this.registeredWasmCommands,this.registeredWorkflowCommands];for(let r of e)if(!t.has(r)){if(n.some(e=>e!==t&&e.has(r))){t.add(r);continue}this.builtinCommandNames.has(r)||(this.bash.registerCommand(this.wrapCommandForDispatch(this.makeScriptCommand(r))),t.add(r),this.builtinCommandNames.add(r))}}makeScriptCommand(e){let t=this.scriptCatalog,n=this.options.jshDiscoveryFs??this.options.fs,r=e,i=async(e,i)=>{let a=i.exec??((e,t)=>this.bash.exec(e,{env:t?.env??Object.fromEntries(i.env),cwd:t?.cwd??i.cwd,args:t?.args,...t?.env===void 0?{}:{replaceEnv:!0}})),o=(await t.getJshCommands(this.currentScanRoots())).get(r);if(o){let t;try{let e=await n.readFile(o,{encoding:`utf-8`});t=typeof e==`string`?e:new TextDecoder().decode(e)}catch{return{stdout:``,stderr:`jsh: cannot read script '${o}'\n`,exitCode:127}}return ai(t,[`node`,o,...e],{fs:i.fs,cwd:i.cwd,env:i.env,stdin:i.stdin,exec:a},this.buildJshProcessConfig(PV(i.env)))}let s=(await t.getWasmCommands()).get(r);if(s){let{runWasmCommand:n}=await import(`./run-Cf2apntf.js`);return n(s.script?[r,...e]:[`--argv0`,s.argv0,`--module`,s.wasm,s.glue,...s.args??[],...e],i,{processConfig:this.buildJshProcessConfig(PV(i.env)),gate:this.gateNativeCommand,defaults:s.env,commands:()=>t.getWasmCommands(),gitIdentity:()=>this.gitCommands.identity()})}let c=(await t.getWorkflowCommands()).get(r);if(c){let t=xi(c.path,e);return a(t[0],{args:t.slice(1),cwd:i.cwd})}return{stdout:``,stderr:`${r}: command no longer exists\n`,exitCode:127}};return{name:e,trusted:!0,async execute(e,t){try{return await i(e,t)}catch(e){let t=e instanceof Error?e.message:String(e);return{stdout:``,stderr:`${r}: ${t}\n`,exitCode:1}}}}}createGitCustomCommand(){let e=this.gitCommands;return S(`git`,async(t,n)=>{let r=n.cwd,i=await e.execute(t,r,n.env,P(n.stdin));return{stdout:i.stdout,stderr:i.stderr,exitCode:i.exitCode}})}createMountCustomCommand(){let e=this.mountCommands;return S(`mount`,async(t,n)=>{let r=n.cwd,i=await e.execute(t,r,n.env);return{stdout:i.stdout,stderr:i.stderr,exitCode:i.exitCode}})}createUmountCustomCommand(){let e=this.mountCommands;return S(`umount`,async(t,n)=>{let r=n.cwd,i=await e.executeUmount(t,r);return{stdout:i.stdout,stderr:i.stderr,exitCode:i.exitCode}})}async getFilteredJshCommands(){let e=await this.scriptCatalog.getJshCommands(this.currentScanRoots()),t=new Map;for(let[n,r]of e)this.builtinCommandNames.has(n)||this.isCommandAllowed(n)&&t.set(n,r);return t}async getFilteredWorkflowCommands(){let e=await this.scriptCatalog.getWorkflowCommands(),t=new Map;for(let[n,r]of e)this.isCommandAllowed(n)&&t.set(n,r);return t}async getWorkflowCommandNames(){return[...(await this.getFilteredWorkflowCommands()).keys()]}async tryJshFallback(e,t){let n=e.trim(),r=n.indexOf(` `),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1).trim():``,o=(await this.getFilteredJshCommands()).get(i);if(!o)return null;let s=a?gp(a):[],c=this.options.jshDiscoveryFs??this.options.fs,l;try{let e=await c.readFile(o,{encoding:`utf-8`});l=typeof e==`string`?e:new TextDecoder().decode(e)}catch{return{stdout:``,stderr:`jsh: cannot read script '${o}'\n`,exitCode:127,env:this.lastEnv}}let u=[`node`,o,...s],d=await ai(l,u,{fs:this.vfsAdapter,cwd:this.cwd,env:new Map(Object.entries(this.lastEnv)),stdin:``,exec:(e,t)=>this.bash.exec(e,{env:t?.env??this.lastEnv,cwd:t?.cwd??this.cwd,umask:this.umask,...t?.env===void 0?{}:{replaceEnv:!0}})},this.buildJshProcessConfig(t));return{stdout:d.stdout,stderr:d.stderr,exitCode:d.exitCode,env:this.lastEnv}}buildJshProcessConfig(e){if(!(!this.options.processManager||!this.options.processOwner))return{processManager:this.options.processManager,owner:this.options.processOwner,getParentPid:()=>e??this.activeShellPid??this.options.getCurrentShellPid?.()}}};export{Aa as _,gB as a,ba as b,Cs as c,fs as d,us as f,Ea as g,Fo as h,fB as i,gs as l,Wo as m,DV as n,uB as o,Go as p,lV as r,pp as s,LV as t,ps as u,ka as v,ko as y};
3329
+ `)}function _V(e,t=fV){let n=gV(e,t);return n===void 0?void 0:new TextEncoder().encode(n)}function vV(e){return e===`/etc`?[`group`,`passwd`]:[]}function yV(e){return e?.code===`ENOENT`}const bV=Reflect.get(tt,`DefenseInDepthBox`);function xV(e){return(typeof e==`string`?e:e?.encoding)??`utf8`}function SV(e,t){if(typeof e!=`string`)return e;let n=xV(t);if(n===`binary`||n===`latin1`){let t=ye(e);if(t)return t}return dV.Buffer.from(e,n)}function CV(e){return e===`/bin`?`/usr/bin`:e.startsWith(`/bin/`)?`/usr${e}`:e}function wV(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 TV(e,t){let n=vV(e).filter(e=>!t.includes(e));return n.length?[...t,...n].sort():t}function EV(e,t){let n=vV(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 DV=class{vfs;registeredCommandsFn=null;identityFn=null;listingStats=new Map;listingStatsMax;listingStatsTtlMs;constructor(e,t){this.vfs=e,this.listingStatsMax=Math.max(1,t?.listingStatsMax??2e4),this.listingStatsTtlMs=t?.listingStatsTtlMs??1e3,this.updateMetadataBatch=this.updateMetadataBatch.bind(this),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=Be(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 _V(e,this.identityFn?.()??fV)}isVirtualBinCommand(e){return e.length>0&&!e.includes(`/`)&&this.getVirtualBinCommands().includes(e)}getVirtualBinCommands(){return this.registeredCommandsFn?.()??[]}virtualUsrStat(e){let t=CV(e);if(t===`/usr`||t===`/usr/bin`)return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date(0)};if(t.startsWith(`/usr/bin/`)){let e=t.slice(9);if(this.isVirtualBinCommand(e))return{isFile:!0,isDirectory:!1,isSymbolicLink:!1,mode:493,size:wV(e).length,mtime:new Date(0)}}return null}canWrite(e){let t=this.vfs;return typeof t.canWrite!=`function`||t.canWrite(e)}listMountPoints(){let e=this.vfs;return typeof e.listMountPoints==`function`?e.listMountPoints():[]}trusted(e){let t=bV?.runTrustedAsync;return t?t(e):Promise.resolve().then(e)}async readFile(e,t){return this.trusted(async()=>{let n=b(e),r=await this.readRaw(n),i=xV(t),a=dV.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(b(e)))}async readRaw(e){let t=CV(e);if(t.startsWith(`/usr/bin/`)&&this.isVirtualBinCommand(t.slice(9)))return wV(t.slice(9));let n;try{n=await this.vfs.readFile(e,{encoding:`binary`})}catch(t){let n=this.identityFile(e);if(n&&yV(t))return n;throw t}return n instanceof Uint8Array?n:new TextEncoder().encode(n)}identityStat(e,t){let n=this.identityFile(e);if(!(!n||!yV(t)))return{isFile:!0,isDirectory:!1,isSymbolicLink:!1,mode:420,size:n.length,mtime:new Date(0)}}async readFileBytes(e){let t=await this.readFileBuffer(e);return dV.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString(`latin1`)}async getNativeFile(e){return this.trusted(()=>this.vfs.getNativeFile(b(e)))}async readFileRange(e,t,n){return this.trusted(()=>this.vfs.readFileRange(b(e),t,n))}async writeFile(e,t,n){return this.dropListingStats(),this.trusted(async()=>{let r=b(e);await this.vfs.writeFile(r,SV(t,n))})}async appendFile(e,t,n){return this.dropListingStats(),this.trusted(()=>this.vfs.appendFile(b(e),SV(t,n)))}async exists(e){return this.trusted(async()=>{let t=b(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=b(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=b(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(b(e),t)})}async readdir(e){return this.trusted(async()=>{let t=b(e);if(t===`/usr`)return[`bin`];if(CV(t)===`/usr/bin`)return this.getVirtualBinCommands().slice().sort();let n=this.vfs.readDirSync(t);if(n!==null)return TV(t,n.map(e=>e.name));let r=await this.vfs.readDir(t,{includeStats:!0});return this.primeListingStats(t,r),TV(t,r.map(e=>e.name))})}async readdirWithFileTypes(e){return this.trusted(async()=>{let t=b(e);if(t===`/usr`)return[{name:`bin`,isFile:!1,isDirectory:!0,isSymbolicLink:!1}];if(CV(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 EV(t,this.mapFastEntriesToDirents(n));let r=await this.vfs.readDir(t,{includeStats:!0});return this.primeListingStats(t,r),EV(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(b(e),t)})}async cp(e,t,n){return this.dropListingStats(),this.trusted(async()=>{let r=b(e),i=b(t),a;try{a=await this.vfs.stat(r)}catch(e){let t=this.identityFile(r);if(!t||!yV(e))throw e;await this.vfs.writeFile(i,t);return}if(a.type===`directory`){if(!n?.recursive)throw new Ve(`EISDIR`,`is a directory`,r);await this.cpDir(r,i)}else await this.vfs.copyFile(r,i)})}async cpDir(e,t){await this.vfs.mkdir(t,{recursive:!0});let n=await this.vfs.readDir(e);for(let r of n){let n=x(e,r.name),i=x(t,r.name);r.type===`directory`?await this.cpDir(n,i):await this.vfs.copyFile(n,i)}let r=new Set(n.map(e=>e.name));for(let n of vV(e)){let i=r.has(n)?void 0:this.identityFile(x(e,n));i&&await this.vfs.writeFile(x(t,n),i)}}async mv(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.rename(b(e),b(t))})}async rename(e,t){return this.mv(e,t)}resolvePath(e,t){return t.startsWith(`/`)?b(t):b(x(e,t))}getAllPaths(){return[]}async chmod(e,t){return this.dropListingStats(),this.trusted(()=>this.vfs.chmod(b(e),t))}async updateMetadataBatch(e){return this.dropListingStats(),this.trusted(()=>this.vfs.updateMetadataBatch(e.map(e=>({...e,path:b(e.path)}))))}async symlinkBatch(e){return this.dropListingStats(),this.trusted(()=>this.vfs.symlinkBatch(e.map(e=>({target:e.target,path:b(e.path)}))))}async symlink(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.symlink(e,b(t))})}async link(e,t){throw Error(`Hard links not supported in VirtualFS`)}async readlink(e){return this.trusted(async()=>this.vfs.readlink(b(e)))}async realpath(e){return this.trusted(async()=>this.vfs.realpath(b(e)))}async utimes(e,t,n){return this.dropListingStats(),this.trusted(()=>this.vfs.utimes(b(e),t,n))}invalidatePaths(e){this.dropListingStats();let t=this.vfs;t.invalidatePaths&&t.invalidatePaths(e)}async forgetSidecarConsistency(){await this.vfs.forgetSidecarConsistency?.()}};function OV(e){return e&&typeof e.getWatcher==`function`?e.getWatcher?.()??null:e&&typeof e.getUnderlyingFS==`function`?OV(e.getUnderlyingFS?.()):null}async function kV(e){let t=ve(`github`);if(t){if(e?.force){await t.onSilentRenew?.();return}await t.getValidAccessToken?.()}}function AV(){let e=ve(`github`);if(!e)return ym;let t=typeof localStorage>`u`?[]:l(localStorage).github;return[...e.oauthTokenDomains??ym,...t??[]]}const jV=e(`almost-bash-shell`),MV=`__SLICC_RUN_PID`,NV=`__SLICC_OUTPUT_TEE__`;function PV(e){let t=e?.get(MV);if(t===void 0)return;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>0?n:void 0}function FV(e){if(!(MV in e)&&!(NV in e)&&!(`__SLICC_SUDO_REASON`in e)&&!(`__SLICC_PIPESTATUS`in e)&&!(`__SLICC_PIPESTATUS_EX`in e))return{...e};let{[MV]:t,[NV]:n,[nm]:r,[jt]:i,[Nt]:a,...o}=e;return o}function IV(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 LV=class e{options;bash;vfsAdapter;gitCommands;mountCommands;lastEnv;cwd;umask=18;builtinCommandNames;staticBuiltinNames;allowedCommands;scriptCatalog;initialJshSync=null;ownsScriptCatalog;registeredJshCommands=new Map;registeredWorkflowCommands=new Set;registeredWasmCommands=new Set;jshSyncInflight=null;jshSyncDirty=!1;pendingCommandGrants=[];pendingSudoBypasses=new Map;pendingEnvWrites=new Map;activeShellPid;progress;activeRunSignal;commandAbort=new AbortController;scriptRun=null;scriptRunsActive=0;registryNames=new Set;outputTees=new Map;nextOutputTeeId=0;resolveJshProcessConfig=e=>this.buildJshProcessConfig(PV(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:pp,PATH:sr,USER:`user`,SHELL:`/bin/bash`,TMPDIR:`/tmp`,PWD:t,...e.env}}buildSupplementalCommands(e,t,n){return sV({onMediaPreview:async e=>this.renderMediaPreview(e),getJshCommands:()=>this.getJshCommandNames(),getWorkflowCommands:()=>this.getWorkflowCommandNames(),syncScriptCommands:()=>this.syncJshCommands(),getStaticBuiltins:()=>[...this.staticBuiltinNames],getScriptRegisteredNames:()=>[...this.registeredJshCommands.keys(),...this.registeredWorkflowCommands,...this.registeredWasmCommands],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.pendingCommandGrants.push(e)},suppressNextGate:e=>this.registerSudoBypass(e)}:void 0,setEnv:(e,t)=>{this.pendingEnvWrites.set(e,t),this.lastEnv[e]=t},unsetEnv:e=>{this.pendingEnvWrites.set(e,null),delete this.lastEnv[e]},gitCredential:{githubToken:(e,t)=>this.gitCommands.githubCredential(e,t),githubDomains:AV},gitIdentity:()=>this.gitCommands.identity(),mcpConnectionManager:e.mcpConnectionManager})}constructor(t){this.options=t,this.vfsAdapter=new DV(t.fs),this.progress=new _p({scrubLabel:t.scrubProgressLabel}),this.allowedCommands=e.buildAllowedCommandSet(t);let n=t.cwd??`/`,r=e.buildInitialEnv(t,n);this.gitCommands=new ap({fs:t.fs,authorName:r.GIT_AUTHOR_NAME??`User`,authorEmail:r.GIT_AUTHOR_EMAIL??`user@example.com`,ensureFreshGithubToken:kV}),this.mountCommands=new Ms({fs:t.fs,isScoop:t.isScoop,acquireLocalMountViaToolUI:Nm});let i=t.jshDiscoveryFs??t.fs,a=t.bshDiscoveryFs??t.fs,o=OV(i)??OV(a);this.scriptCatalog=t.scriptCatalog??new Si({jshFs:i,bshFs:a,watcher:o}),this.ownsScriptCatalog=!t.scriptCatalog,o&&o.watch(`/`,e=>e.endsWith(`.jsh`)||e.endsWith(`.workflow.js`)||ar(e),()=>{this.syncJshCommands().catch(()=>void 0)});let s=this.createGitCustomCommand(),c=g({progress:Sp(this.progress)}),l=_({progress:Sp(this.progress)}),u=this.buildSupplementalCommands(t,c,l),d=[s,this.createMountCustomCommand(),this.createUmountCustomCommand(),Dh(t.fs),wg(t.fs,c,t.browserAPI),...u].filter(e=>this.isCommandAllowed(e.name)),f=[...rt(),...nt()],p=this.allowedCommands?f.filter(e=>this.isCommandAllowed(e)):void 0;if(this.bash=new it({fs:this.vfsAdapter,cwd:n,env:{},fetch:c,commands:p,customCommands:d,sleep:Up(this.progress,{isAborted:()=>this.activeRunSignal?.aborted??!1}),executionLimitProfile:t.executionLimitProfile,executionLimits:sp(t.isScoop?.()??!1,t.executionLimits)}),this.bash.registerTransformPlugin(Vm),this.allowedCommands!==null){let e=this.bash;for(let t of nt())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??[...rt(),...nt()];this.builtinCommandNames=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.startInitialJshSync()}getBash(){return this.bash}getCwd(){return this.cwd}getScriptCatalog(){return this.scriptCatalog}getEnv(){return{...this.lastEnv}}setMaskedEnvVar(e,t){this.pendingEnvWrites.set(e,t),this.lastEnv[e]=t}applySessionOverrides(e){e.cwd!==void 0&&(this.cwd=e.cwd,this.lastEnv.PWD=e.cwd),e.env&&Object.assign(this.lastEnv,e.env)}async getJshCommandNames(){return[...(await this.getFilteredJshCommands()).keys()]}async syncJshCommands(){return this.jshSyncInflight===null?(this.jshSyncInflight=this.doSyncJshCommands(),this.jshSyncInflight):(this.jshSyncDirty=!0,this.jshSyncInflight)}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 ni(e,t,{fs:this.vfsAdapter,cwd:this.cwd,env:new Map(Object.entries(this.lastEnv)),stdin:``,exec:(e,t)=>this.bash.exec(e,{env:t?.env??this.lastEnv,cwd:t?.cwd??this.cwd,umask:this.umask,...t?.env===void 0?{}:{replaceEnv:!0}})},this.buildJshProcessConfig())}dispose(){this.ownsScriptCatalog&&this.scriptCatalog.dispose()}async renderMediaPreview(e){throw Error(`terminal preview is unavailable in headless mode`)}currentScanRoots(){return cr(this.lastEnv.PATH)}startInitialJshSync(){this.initialJshSync=this.initHomeAndProfile().then(()=>this.syncJshCommands()).catch(()=>void 0).finally(()=>{this.initialJshSync=null})}async initHomeAndProfile(){let e=this.options.fs;try{let t=this.options.env?.HOME??await mp(e);this.lastEnv.HOME=t,this.options.env?.USER||(this.lastEnv.USER=hp(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(uV(e.trim().split(/\s+/)[0]||`unknown`),v(),await this.waitForInitialJshSync(t),await this.usesGnuBash())return this.runOnGnuBash(e,t,n,r,i,a);let o=im(e),s={env:{...this.lastEnv,...n===void 0?{}:{[MV]:String(n)},...i===void 0?{}:{[NV]:i},...o?{[nm]:o}:{}},cwd:this.cwd,umask:this.umask,signal:t,...r===``?{}:{stdin:r,stdinKind:`bytes`}},c=this.lastEnv.PATH,l=IV([t,this.commandAbort.signal]);s.signal=l.signal,this.activeRunSignal=l.signal;let u=this.beginScriptRun(e),d;try{d=await this.bash.exec(Pt(e,a),s)}finally{l.release(),this.activeRunSignal===l.signal&&(this.activeRunSignal=void 0),this.endScriptRun(u)}if(await this.flushPendingCommandGrants(),d=kt(d,a),typeof d.umask==`number`&&(this.umask=d.umask),d.env&&(this.lastEnv=FV(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.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-BISPom3l.js`);return Mt(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()}async usesGnuBash(){return!this.options.gnuBash||this.lastEnv.SLICC_SHELL===`just-bash`||typeof SharedArrayBuffer!=`function`?!1:(await this.scriptCatalog.getWasmCommands()).has(`bash`)}async runOnGnuBash(e,t,n,r,i,a){let{runWasmCommand:o,withoutRealmDefaults:s}=await import(`./run-BStZvimF.js`),c=im(e),l={...this.lastEnv,...n===void 0?{}:{[MV]:String(n)},...c?{[nm]:c}:{}},u=i===void 0?void 0:this.outputTees.get(i),d=await fp(e,{env:l,run:(e,i,a)=>o(e,this.wasmContext(i,t,r),{processConfig:this.buildJshProcessConfig(n),gate:this.gateNativeCommand,onOutput:u,fds:a,commands:()=>this.scriptCatalog.getWasmCommands(),gitIdentity:()=>this.gitCommands.identity()})}),f=this.lastEnv.PATH;return d.state&&(this.cwd=d.state.cwd,this.lastEnv=up(s(d.state.env,l),[MV,nm,NV])),this.lastEnv.PATH!==f&&await this.syncJshCommands().catch(()=>void 0),await this.flushPendingCommandGrants(),this.applyPendingEnvWrites(),{stdout:d.stdout,stderr:d.stderr,exitCode:d.exitCode,env:{...this.lastEnv},...a&&d.state?{pipeStatus:d.state.pipeStatus}:{}}}wasmContext(e,t,n){return{fs:this.vfsAdapter,cwd:this.cwd,env:new Map(Object.entries(e)),exportedEnv:e,stdin:n,signal:t,exec:(e,t)=>this.bash.exec(e,{...t,umask:this.umask})}}gateNativeCommand=async(e,t,n)=>{if(this.allowedCommands!==null&&!this.isCommandAllowed(e))return{stderr:`bash: ${e}: command not found\n`,exitCode:127};if(!this.isTransparentGatingEnabled()||vm.has(e))return null;let r=await this.gateCommandDispatch(e,t,n[nm]);return r?{stderr:r.stderr,exitCode:r.exitCode}:null};isTransparentGatingEnabled(){let e=this.options.sudo;return!!e&&e.transparentGating!==!1}wrapCommandForDispatch(e){let t=this.wrapCommandForSudo(e),n=e.name===`timeout`?qp(t,this.progress):Yp(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(NV),s=o?a.get(o):void 0;s&&(t.writeStdout=s);try{let r=await Zp(()=>n.execute(e,t),t.signal);return i(t.env,r),r}finally{r()}}}}teeCommandOutput(e,t){let n=e?.get(NV);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=Rp(this.bash.transform(e).ast,this.registryNames)}catch{t={totalSteps:null}}return this.scriptRun=new Bp(t,this.progress,zp(e)),this.scriptRun}endScriptRun(e){this.scriptRunsActive=Math.max(0,this.scriptRunsActive-1),e&&(e.end(),this.scriptRun===e&&(this.scriptRun=null))}wrapCommandForSudo(e){if(!this.isTransparentGatingEnabled()||vm.has(e.name))return e;let t=(t,n)=>this.gateCommandDispatch(e.name,t,n);return{...e,async execute(n,r){return await t(n,r.env?.get(nm))||e.execute(n,r)}}}async gateCommandDispatch(e,t,n){let r=this.options.sudo;if(!r)return null;let i=$p(e,t);if(this.consumeSudoBypass(i))return null;let a=r.getPolicy();if(!a)return null;let o=await tm(i,{policy:a,broker:r.broker,persistGrant:async e=>{this.pendingCommandGrants.push(e)},defaultDisposition:r.defaultDisposition,...n?{reason:n}:{}});return o.allowed?null:{stdout:``,stderr:`${o.message}\n`,exitCode:o.exitCode??77}}registerSudoBypass(e){let t=e.trim();t&&this.pendingSudoBypasses.set(t,(this.pendingSudoBypasses.get(t)??0)+1)}consumeSudoBypass(e){let t=this.pendingSudoBypasses.get(e);return t?(t===1?this.pendingSudoBypasses.delete(e):this.pendingSudoBypasses.set(e,t-1),!0):!1}async flushPendingCommandGrants(){if(this.pendingCommandGrants.length===0)return;let e=this.pendingCommandGrants;this.pendingCommandGrants=[];for(let t of e)try{await this.persistCommandGrant(t)}catch{}}async persistCommandGrant(e){let t=this.options.sudo?.persistCommandGrant;if(t){await t(e);return}let n=lt(e);if(!n)return;let r=`${dt}/granted`,i=this.options.fs,a=``;try{await i.exists(r)&&(a=await i.readFile(r))}catch(e){if(!(e instanceof Ve&&e.code===`ENOENT`))throw e}let o=a&&!a.endsWith(`
3330
+ `)?`${a}\n`:a;await i.writeFile(r,`${o}NOPASSWD Cmnd ${n}\n`)}isCommandAllowed(e){return this.allowedCommands===null||this.allowedCommands.has(vm.get(e)??e)}async doSyncJshCommands(){try{let e=await this.scriptCatalog.getJshIndex(this.currentScanRoots()),t=e.commands;for(let t of e.collisions)jV.warn(`jsh command '${t.name}' is provided by more than one skill; using ${t.winnerPath} (${t.reason}), shadowed ${t.shadowedPaths.join(`, `)}`);let n=await this.getFilteredWorkflowCommands(),r=await this.scriptCatalog.getWasmCommands();for(let[e,n]of t)this.isCommandAllowed(e)&&(this.builtinCommandNames.has(e)&&!this.registeredJshCommands.has(e)||this.registeredJshCommands.get(e)!==n&&(this.bash.registerCommand(this.wrapCommandForDispatch(this.makeScriptCommand(e))),this.registeredJshCommands.set(e,n),this.builtinCommandNames.add(e)));let i=[...r.keys()].filter(e=>this.isCommandAllowed(e));this.registerLateScriptNames(i,this.registeredWasmCommands),this.registerLateScriptNames(n.keys(),this.registeredWorkflowCommands)}finally{this.jshSyncInflight=null,this.jshSyncDirty&&(this.jshSyncDirty=!1,this.syncJshCommands().catch(()=>void 0))}}registerLateScriptNames(e,t){let n=[this.registeredJshCommands,this.registeredWasmCommands,this.registeredWorkflowCommands];for(let r of e)if(!t.has(r)){if(n.some(e=>e!==t&&e.has(r))){t.add(r);continue}this.builtinCommandNames.has(r)||(this.bash.registerCommand(this.wrapCommandForDispatch(this.makeScriptCommand(r))),t.add(r),this.builtinCommandNames.add(r))}}makeScriptCommand(e){let t=this.scriptCatalog,n=this.options.jshDiscoveryFs??this.options.fs,r=e,i=async(e,i)=>{let a=i.exec??((e,t)=>this.bash.exec(e,{env:t?.env??Object.fromEntries(i.env),cwd:t?.cwd??i.cwd,args:t?.args,...t?.env===void 0?{}:{replaceEnv:!0}})),o=(await t.getJshCommands(this.currentScanRoots())).get(r);if(o){let t;try{let e=await n.readFile(o,{encoding:`utf-8`});t=typeof e==`string`?e:new TextDecoder().decode(e)}catch{return{stdout:``,stderr:`jsh: cannot read script '${o}'\n`,exitCode:127}}return ai(t,[`node`,o,...e],{fs:i.fs,cwd:i.cwd,env:i.env,stdin:i.stdin,exec:a},this.buildJshProcessConfig(PV(i.env)))}let s=(await t.getWasmCommands()).get(r);if(s){let{runWasmCommand:n}=await import(`./run-BStZvimF.js`);return n(s.script?[r,...e]:[`--argv0`,s.argv0,`--module`,s.wasm,s.glue,...s.args??[],...e],i,{processConfig:this.buildJshProcessConfig(PV(i.env)),gate:this.gateNativeCommand,defaults:s.env,commands:()=>t.getWasmCommands(),gitIdentity:()=>this.gitCommands.identity()})}let c=(await t.getWorkflowCommands()).get(r);if(c){let t=xi(c.path,e);return a(t[0],{args:t.slice(1),cwd:i.cwd})}return{stdout:``,stderr:`${r}: command no longer exists\n`,exitCode:127}};return{name:e,trusted:!0,async execute(e,t){try{return await i(e,t)}catch(e){let t=e instanceof Error?e.message:String(e);return{stdout:``,stderr:`${r}: ${t}\n`,exitCode:1}}}}}createGitCustomCommand(){let e=this.gitCommands;return S(`git`,async(t,n)=>{let r=n.cwd,i=await e.execute(t,r,n.env,P(n.stdin));return{stdout:i.stdout,stderr:i.stderr,exitCode:i.exitCode}})}createMountCustomCommand(){let e=this.mountCommands;return S(`mount`,async(t,n)=>{let r=n.cwd,i=await e.execute(t,r,n.env);return{stdout:i.stdout,stderr:i.stderr,exitCode:i.exitCode}})}createUmountCustomCommand(){let e=this.mountCommands;return S(`umount`,async(t,n)=>{let r=n.cwd,i=await e.executeUmount(t,r);return{stdout:i.stdout,stderr:i.stderr,exitCode:i.exitCode}})}async getFilteredJshCommands(){let e=await this.scriptCatalog.getJshCommands(this.currentScanRoots()),t=new Map;for(let[n,r]of e)this.builtinCommandNames.has(n)||this.isCommandAllowed(n)&&t.set(n,r);return t}async getFilteredWorkflowCommands(){let e=await this.scriptCatalog.getWorkflowCommands(),t=new Map;for(let[n,r]of e)this.isCommandAllowed(n)&&t.set(n,r);return t}async getWorkflowCommandNames(){return[...(await this.getFilteredWorkflowCommands()).keys()]}async tryJshFallback(e,t){let n=e.trim(),r=n.indexOf(` `),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1).trim():``,o=(await this.getFilteredJshCommands()).get(i);if(!o)return null;let s=a?gp(a):[],c=this.options.jshDiscoveryFs??this.options.fs,l;try{let e=await c.readFile(o,{encoding:`utf-8`});l=typeof e==`string`?e:new TextDecoder().decode(e)}catch{return{stdout:``,stderr:`jsh: cannot read script '${o}'\n`,exitCode:127,env:this.lastEnv}}let u=[`node`,o,...s],d=await ai(l,u,{fs:this.vfsAdapter,cwd:this.cwd,env:new Map(Object.entries(this.lastEnv)),stdin:``,exec:(e,t)=>this.bash.exec(e,{env:t?.env??this.lastEnv,cwd:t?.cwd??this.cwd,umask:this.umask,...t?.env===void 0?{}:{replaceEnv:!0}})},this.buildJshProcessConfig(t));return{stdout:d.stdout,stderr:d.stderr,exitCode:d.exitCode,env:this.lastEnv}}buildJshProcessConfig(e){if(!(!this.options.processManager||!this.options.processOwner))return{processManager:this.options.processManager,owner:this.options.processOwner,getParentPid:()=>e??this.activeShellPid??this.options.getCurrentShellPid?.()}}};export{Aa as _,gB as a,ba as b,Cs as c,fs as d,us as f,Ea as g,Fo as h,fB as i,gs as l,Wo as m,DV as n,uB as o,Go as p,lV as r,pp as s,LV as t,ps as u,ka as v,ko as y};
@@ -1 +1 @@
1
- import{CHAT_SURFACE_ID as e}from"./wc-sprinkles-DVTcJSN3.js";var t=`focus`,n={type:`leaf`,surfaceId:`chat`};function r(e,t={},n={}){return{zones:{top:null,left:null,middle:null,right:null,bottom:null,...e},rowFr:{top:1,center:1,bottom:1,...n},colFr:{left:1,middle:1,right:1,...t}}}var i={focus:{name:`focus`,tree:r({left:n},{left:3,middle:1})}};function a(e){return i[e]??null}function o(n,r){switch(r.kind){case`set`:n.applyLayout(r.tree);break;case`reset`:{let e=a(t);e&&n.applyLayout(e.tree);break}case`chat`:n.moveSurfaceToZone(e,r.zone);break;case`open`:n.placeSurface(r.zone,r.surfaceId);break;case`close`:n.removeSurface(r.surfaceId);break;case`move`:n.moveSurfaceToZone(r.surfaceId,r.zone);break;case`size`:n.setSurfaceSize(r.surfaceId,r.size)}}export{o as applyLayout};
1
+ import{CHAT_SURFACE_ID as e}from"./wc-sprinkles-C7nWwTw7.js";var t=`focus`,n={type:`leaf`,surfaceId:`chat`};function r(e,t={},n={}){return{zones:{top:null,left:null,middle:null,right:null,bottom:null,...e},rowFr:{top:1,center:1,bottom:1,...n},colFr:{left:1,middle:1,right:1,...t}}}var i={focus:{name:`focus`,tree:r({left:n},{left:3,middle:1})}};function a(e){return i[e]??null}function o(n,r){switch(r.kind){case`set`:n.applyLayout(r.tree);break;case`reset`:{let e=a(t);e&&n.applyLayout(e.tree);break}case`chat`:n.moveSurfaceToZone(e,r.zone);break;case`open`:n.placeSurface(r.zone,r.surfaceId);break;case`close`:n.removeSurface(r.surfaceId);break;case`move`:n.moveSurfaceToZone(r.surfaceId,r.zone);break;case`size`:n.setSurfaceSize(r.surfaceId,r.size)}}export{o as applyLayout};