sliccy 6.209.0 → 6.210.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui/.vite/manifest.json +186 -186
- package/dist/ui/assets/{account-store-CXMrgQNZ.js → account-store-ByX1Dt0d.js} +1 -1
- package/dist/ui/assets/{account-store-D_95JvI-.js → account-store-DgfR_tf2.js} +1 -1
- package/dist/ui/assets/{adobe-DpfC7c2y.js → adobe-DxaC2zCR.js} +1 -1
- package/dist/ui/assets/{adobe-CGuSOIZ2.js → adobe-R_y7Dfut.js} +1 -1
- package/dist/ui/assets/{agent-panels-B0IKGzXg.js → agent-panels-C_PSIfT1.js} +1 -1
- package/dist/ui/assets/{almost-bash-shell-headless-DAxrU3sK.js → almost-bash-shell-headless-Ccu3_Uhw.js} +36 -36
- package/dist/ui/assets/{apply-layout-Cju0yZJn.js → apply-layout-OKdF-hhc.js} +1 -1
- package/dist/ui/assets/{apps-v9wPhTaT.js → apps-JHYPOU64.js} +1 -1
- package/dist/ui/assets/{azure-openai-BsKClIv1.js → azure-openai-BVUK3KXE.js} +1 -1
- package/dist/ui/assets/{azure-openai-aBi3cM3K.js → azure-openai-DXBUUMQQ.js} +1 -1
- package/dist/ui/assets/{backend-hostfs-5NmEIgGV.js → backend-hostfs-88hAlDb5.js} +1 -1
- package/dist/ui/assets/{cdp-8zqtNpCK.js → cdp-DjJWaZz6.js} +1 -1
- package/dist/ui/assets/{cerebras-DhmaKu3Y.js → cerebras-BJZYfn89.js} +1 -1
- package/dist/ui/assets/{cerebras-CSTfT4vG.js → cerebras-Cd6zKgza.js} +1 -1
- package/dist/ui/assets/{composer-speech-KDOhETAk.js → composer-speech-CJc-2k5O.js} +1 -1
- package/dist/ui/assets/{connect-surface-B7zzCdY_.js → connect-surface-DPvoPj55.js} +1 -1
- package/dist/ui/assets/{directed-approval-C5TsWG7I.js → directed-approval-DLUTxlNM.js} +1 -1
- package/dist/ui/assets/{emscripten-vfs-hook-pi_gCIBZ.js → emscripten-vfs-hook-DaUD5bwd.js} +1 -1
- package/dist/ui/assets/{ensure-speech-assets-BPAgYM0p.js → ensure-speech-assets-DcFMkg1m.js} +1 -1
- package/dist/ui/assets/{frozen-archive-writer-Bn9kqJre.js → frozen-archive-writer-Ct9GJG54.js} +1 -1
- package/dist/ui/assets/{fs-D5yEr6Lj.js → fs-B3WU3yr9.js} +1 -1
- package/dist/ui/assets/{fs-D13P93lG.js → fs-rBjZTyof.js} +2 -2
- package/dist/ui/assets/{gelatiere-store-002d76Pu.js → gelatiere-store-cZnVaRlS.js} +1 -1
- package/dist/ui/assets/{gelatiere-unit-PblSQDN5.js → gelatiere-unit-CLZPrZzv.js} +1 -1
- package/dist/ui/assets/{github-C1hhmywY.js → github-BW1eM6J3.js} +2 -2
- package/dist/ui/assets/{github-BZFHM2Et.js → github-Cq1sNS_K.js} +1 -1
- package/dist/ui/assets/{github-auth-B39F_Smu.js → github-auth-O6zGPogb.js} +1 -1
- package/dist/ui/assets/{github-copilot-CwhIXDTK.js → github-copilot-1kPf7awr.js} +1 -1
- package/dist/ui/assets/{github-copilot-cUPIRyvE.js → github-copilot-CUJZELWh.js} +1 -1
- package/dist/ui/assets/{github-install-DoUx643r.js → github-install-CXBoYKYM.js} +1 -1
- package/dist/ui/assets/{github-zip-CSPX1g-L.js → github-zip-DHBvTUIf.js} +1 -1
- package/dist/ui/assets/{hear-C5ECjuHu.js → hear-BVHHBpIb.js} +1 -1
- package/dist/ui/assets/{help-DghSr_hq.js → help-BYCrQyQm.js} +1 -1
- package/dist/ui/assets/{installer-BZvW1okl.js → installer-pOTEH6_f.js} +1 -1
- package/dist/ui/assets/{ipk-mamba-YIcGvmbs.js → ipk-mamba-13yN29Fi.js} +1 -1
- package/dist/ui/assets/{js-realm-worker-DMdELQLe.js → js-realm-worker-OZbA_gYe.js} +2 -2
- package/dist/ui/assets/{jsh-executor-B-jk9nVj.js → jsh-executor-DZO1HSOR.js} +2 -2
- package/dist/ui/assets/{kernel-worker-vwPHAOWR.js → kernel-worker-B9c7Iv6C.js} +9 -9
- package/dist/ui/assets/{lick-ws-bridge-BFC-sVhl.js → lick-ws-bridge-DjeZVXRW.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-CPX63GSt.js → lick-ws-bridge-TTmDE5-3.js} +1 -1
- package/dist/ui/assets/{live-session-curation-Dj9Mi2me.js → live-session-curation-hidMwgql.js} +1 -1
- package/dist/ui/assets/{live-session-snapshot-BMgXz5yR.js → live-session-snapshot-STfu1AIh.js} +1 -1
- package/dist/ui/assets/{local-llm-Dti8Zg2k.js → local-llm-B8dhTls8.js} +1 -1
- package/dist/ui/assets/{local-llm-2mEnfN8G.js → local-llm-D0k2uDUi.js} +1 -1
- package/dist/ui/assets/{main-DAU-AyCy.js → main-Ylszjlde.js} +3 -3
- package/dist/ui/assets/{main-cherry-4aXVU9rJ.js → main-cherry-C-bsI9l6.js} +1 -1
- package/dist/ui/assets/{memory-curation-seam-CDn-RTnL.js → memory-curation-seam-B7hMTwGX.js} +1 -1
- package/dist/ui/assets/{memory-health-B4tNJGRc.js → memory-health-as7mEPc6.js} +1 -1
- package/dist/ui/assets/{memory-write-execute-Cnhe2Xxb.js → memory-write-execute-DaCQKUN-.js} +1 -1
- package/dist/ui/assets/{merge-folded-cost-into-frozen-QOjJC7mR.js → merge-folded-cost-into-frozen-D-2Ph0GN.js} +1 -1
- package/dist/ui/assets/{mount-BLD3M6EK.js → mount-BByFpMAL.js} +3 -3
- package/dist/ui/assets/{mount-C1FVZ7Sn.js → mount-BYEvANlb.js} +1 -1
- package/dist/ui/assets/{new-session-BtSXodkO.js → new-session-BXB2Cf7y.js} +2 -2
- package/dist/ui/assets/{oauth-bootstrap-BYpeIatf.js → oauth-bootstrap-DeA2SKlj.js} +2 -2
- package/dist/ui/assets/{onboarding-orchestrator-WLJQQ-Vf.js → onboarding-orchestrator-ByFpaN7_.js} +1 -1
- package/dist/ui/assets/{openai-codex-lYWzqB0q.js → openai-codex-CCo3ZmW2.js} +1 -1
- package/dist/ui/assets/{openai-codex-BR_yced5.js → openai-codex-CgYrmMUk.js} +1 -1
- package/dist/ui/assets/{openrouter-CNf9NNc7.js → openrouter-97wg-v_R.js} +1 -1
- package/dist/ui/assets/{openrouter-DPBXpqgl.js → openrouter-CKicFuSH.js} +1 -1
- package/dist/ui/assets/{openrouter-free-71RJenB8.js → openrouter-free-B5IsIaNO.js} +1 -1
- package/dist/ui/assets/{openrouter-free-D7rahepE.js → openrouter-free-B9XNv61G.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-PUXZq93J.js → openrouter-oauth-B7xNpdYW.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-Bwi2hsU6.js → openrouter-oauth-BwMN3x2M.js} +1 -1
- package/dist/ui/assets/{opfs-mount-B6OI1oqH.js → opfs-mount-DpaBHmd-.js} +1 -1
- package/dist/ui/assets/{panel-rpc-handlers-DDhiuy4K.js → panel-rpc-handlers-BbazEhj0.js} +2 -2
- package/dist/ui/assets/{panelize-shell-Dfzx0Eja.js → panelize-shell-jWC6JaCw.js} +1 -1
- package/dist/ui/assets/{pi-edit-execution-BPgerAyF.js → pi-edit-execution-D79zjNpH.js} +1 -1
- package/dist/ui/assets/process-worker-BlGG6CFl.js +3 -0
- package/dist/ui/assets/{provider-LZtcBmKS.js → provider-CCQRZg4A.js} +1 -1
- package/dist/ui/assets/{provider-D9yEgxif.js → provider-SsZ1z43S.js} +2 -2
- package/dist/ui/assets/{provider-settings-DtdWymDf.js → provider-settings-CZLKq2oa.js} +1 -1
- package/dist/ui/assets/provider-store-access-DBSmvoO2.js +1 -0
- package/dist/ui/assets/provider-store-access-_IyYl-Xo.js +1 -0
- package/dist/ui/assets/{providers-CNBnEbCX.js → providers-TV6NIsPL.js} +1 -1
- package/dist/ui/assets/{providers-BtQv6Iun.js → providers-xwZovvsP.js} +2 -2
- package/dist/ui/assets/{quick-llm-14VNlAXQ.js → quick-llm-CruFRi7n.js} +1 -1
- package/dist/ui/assets/{realm-inprocess-DurO7I6Z.js → realm-inprocess-CKEpOeay.js} +2 -2
- package/dist/ui/assets/{realm-unhandled-rejections-BgGL8Mod.js → realm-unhandled-rejections-Ab7EMcr4.js} +1 -1
- package/dist/ui/assets/{realm-unhandled-rejections-DQRN5wlM.js → realm-unhandled-rejections-DrdoJZTU.js} +1 -1
- package/dist/ui/assets/{recovery-screen-BMUQTWIb.js → recovery-screen-BHZNLcMl.js} +1 -1
- package/dist/ui/assets/{remote-terminal-view-OA02y1n8.js → remote-terminal-view-B83V8Qzf.js} +2 -2
- package/dist/ui/assets/{restore-DNRcWWgP.js → restore-D5Y9NVvF.js} +1 -1
- package/dist/ui/assets/{run-BtrJghdw.js → run-B1CbbbHn.js} +1 -1
- package/dist/ui/assets/run-Bx861p9q.js +7 -0
- package/dist/ui/assets/{run-Cf-MrlWL.js → run-D3Yam1R4.js} +2 -2
- package/dist/ui/assets/{run-DWjXaL1W.js → run-DkflycnX.js} +2 -2
- package/dist/ui/assets/{run-BtNqaJOt.js → run-Dp-YY09r.js} +1 -1
- package/dist/ui/assets/{run-BMTzNhm7.js → run-gr518xGk.js} +1 -1
- package/dist/ui/assets/{run-reISaz1J.js → run-yvQfuwPq.js} +1 -1
- package/dist/ui/assets/{session-command-memory-B8eBiSlR.js → session-command-memory-Di_ppNKR.js} +2 -2
- package/dist/ui/assets/{session-jsonl-Dw_Aa6GO.js → session-jsonl-BDKaDkEF.js} +1 -1
- package/dist/ui/assets/{session-jsonl-CgBBbMPR.js → session-jsonl-sT2AW-s9.js} +1 -1
- package/dist/ui/assets/{session-search-index-DZ4EEMff.js → session-search-index-BD311OX5.js} +1 -1
- package/dist/ui/assets/{setup-feature-flags-remote-V0bXU-Xo.js → setup-feature-flags-remote-C0Sedip7.js} +1 -1
- package/dist/ui/assets/{setup-model-catalog-bOEh3I2Z.js → setup-model-catalog-BFF0xdNS.js} +1 -1
- package/dist/ui/assets/{signed-fetch-CMYMchhb.js → signed-fetch-BnBm1LRC.js} +1 -1
- package/dist/ui/assets/{silent-renew-backoff-DdU1grFR.js → silent-renew-backoff-Zup94X9e.js} +1 -1
- package/dist/ui/assets/slicc-version-klgPNoH5.js +1 -0
- package/dist/ui/assets/{snapshot-sMzJDppS.js → snapshot-C-rMXS0v.js} +1 -1
- package/dist/ui/assets/{snapshot-features-kDpOw0A8.js → snapshot-features-BGJFBLV3.js} +1 -1
- package/dist/ui/assets/{soundscape-CCmLSGeY.js → soundscape-DPMkpYDE.js} +1 -1
- package/dist/ui/assets/{speak-DQGvijsT.js → speak-DUcCnV6D.js} +1 -1
- package/dist/ui/assets/{sprinkle-manager-DTuZkM86.js → sprinkle-manager-BnLfND_U.js} +1 -1
- package/dist/ui/assets/{sprinkle-renderer-DLAqwc_L.js → sprinkle-renderer-Daaqfzq4.js} +1 -1
- package/dist/ui/assets/{state-B5mkDtuH.js → state-DuLjW_a4.js} +1 -1
- package/dist/ui/assets/{stdio-tty-CE0OUA_G.js → stdio-tty-uIuGda2o.js} +1 -1
- package/dist/ui/assets/{store-Dkmzxaja.js → store-BXNUAqDB.js} +1 -1
- package/dist/ui/assets/{store-Dxb78W8Q.js → store-HjKkYqua.js} +1 -1
- package/dist/ui/assets/{sudo-g88w-Yt7.js → sudo-B65OoUDr.js} +1 -1
- package/dist/ui/assets/{supervisor-CIp3y5wX.js → supervisor-CEzUkfGl.js} +1 -1
- package/dist/ui/assets/{sync-dialog-CNYsNEic.js → sync-dialog-DWj_c3Ea.js} +1 -1
- package/dist/ui/assets/{transformers-env-gUfVzZxD.js → transformers-env-BjXj92XS.js} +1 -1
- package/dist/ui/assets/{tray-leader-t2KaN0By.js → tray-leader-Cf1nSAit.js} +1 -1
- package/dist/ui/assets/{tray-leave-runtime-CDQM5sWi.js → tray-leave-runtime-BoHLFXbM.js} +1 -1
- package/dist/ui/assets/{tray-sidecar-0IJHOSmG.js → tray-sidecar-C7Cc8eNz.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-CkuR6fXR.js → upgrade-detection-YgD-QcYW.js} +1 -1
- package/dist/ui/assets/{upskill-lick-skip-Df5fMRF5.js → upskill-lick-skip-BeQH8zNC.js} +1 -1
- package/dist/ui/assets/{voice-reply-BzGMfJso.js → voice-reply-QkeBs58G.js} +1 -1
- package/dist/ui/assets/{wc-attach-Co3k_hVU.js → wc-attach-BVDYvHNr.js} +2 -2
- package/dist/ui/assets/{wc-browser-DU7Ll0Su.js → wc-browser-Dyx8RrLZ.js} +1 -1
- package/dist/ui/assets/{wc-computers-DKZ8uxal.js → wc-computers-CY0ywrNG.js} +1 -1
- package/dist/ui/assets/{wc-detached-CTVp8UAi.js → wc-detached-DWzA5mFf.js} +1 -1
- package/dist/ui/assets/{wc-extension-BSEBIUhE.js → wc-extension-v381y0tj.js} +2 -2
- package/dist/ui/assets/{wc-follower-lb8Q6FGB.js → wc-follower-BKeKPCgx.js} +3 -3
- package/dist/ui/assets/{wc-follower-oauth-DWvjmrz_.js → wc-follower-oauth-jDvLJ5_W.js} +1 -1
- package/dist/ui/assets/{wc-gelatiere-CgINXN3w.js → wc-gelatiere-BuN5Z24F.js} +1 -1
- package/dist/ui/assets/{wc-live-BVazwLWr.js → wc-live-BY93WkXA.js} +5 -5
- package/dist/ui/assets/{wc-nav-BeAxrAW3.js → wc-nav-DhCoJ7Ga.js} +2 -2
- package/dist/ui/assets/{wc-onboarding-DGarUiE6.js → wc-onboarding-B1XwN74x.js} +2 -2
- package/dist/ui/assets/{wc-permissions-BiDEAjXd.js → wc-permissions-DAesjSSK.js} +2 -2
- package/dist/ui/assets/{wc-placeholder-ZyBwZAnt.js → wc-placeholder-oCOmyAX6.js} +3 -3
- package/dist/ui/assets/{wc-secret-request-CrQLiiCF.js → wc-secret-request-hrqZov3u.js} +1 -1
- package/dist/ui/assets/{wc-settings-BE6p1PPQ.js → wc-settings-6XtcwxYz.js} +3 -3
- package/dist/ui/assets/{wc-shell-vt7qflet.js → wc-shell-B4HSSzcL.js} +3 -3
- package/dist/ui/assets/{wc-shortcut-config-DqgIZh8a.js → wc-shortcut-config-BJZuY_qb.js} +1 -1
- package/dist/ui/assets/{wc-sprinkles-B1RV7qvO.js → wc-sprinkles-CDlry7Bq.js} +2 -2
- package/dist/ui/assets/{wc-transcript-export-B_0SXPBh.js → wc-transcript-export-su4AiYik.js} +2 -2
- package/dist/ui/assets/{wc-tray-DGPwMFeq.js → wc-tray-DjO5tw9f.js} +4 -4
- package/dist/ui/assets/welcome-detection-CMSBlwRb.js +1 -0
- package/dist/ui/assets/{whisper-session-B-UNGtdO.js → whisper-session-3nC_uMHL.js} +2 -2
- package/dist/ui/assets/{xai-grok-BeE-NRdg.js → xai-grok-CYP2lVaC.js} +1 -1
- package/dist/ui/assets/{xai-grok-BrcpA9mE.js → xai-grok-Cfyo0OTy.js} +1 -1
- package/dist/ui/index.html +3 -3
- package/dist/ui/packages/webapp/index.html +3 -3
- package/package.json +1 -1
- package/dist/ui/assets/process-worker-BSgfWg_O.js +0 -3
- package/dist/ui/assets/provider-store-access-CFT8okou.js +0 -1
- package/dist/ui/assets/provider-store-access-CewS-Dmx.js +0 -1
- package/dist/ui/assets/run-ChsOHVUd.js +0 -7
- package/dist/ui/assets/slicc-version-DVRQVnZq.js +0 -1
- package/dist/ui/assets/welcome-detection-Ca48tQVP.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./logger-LESFN7Hj.js";import{r as t,t as n}from"./base64-BPBW1Gzr.js";import{n as r}from"./bridge-protocol-31SWTdS5.js";import{a as i,n as a,o,s,t as c}from"./handoff-link-B3It6xQY.js";import{d as l,f as u,i as d,u as f}from"./account-store-D_95JvI-.js";import{n as p,o as m,r as h,s as g,u as _}from"./proxied-fetch-DXaTHROw.js";import{t as v}from"./runtime-env-DadgceZk.js";import{t as ee}from"./slugify-BYJ6QVAt.js";import{n as te,t as ne}from"./host-command-guuPK7VN.js";import{a as re,i as ie,n as ae,r as oe,t as se}from"./snapshot-sMzJDppS.js";import{i as ce,r as y}from"./panel-rpc-DW7W4w6_.js";import{a as le,c as ue,n as de,o as fe,s as pe,t as me}from"./feature-flags-QlgHaQc1.js";import{t as he}from"./providers-CNBnEbCX.js";import{r as ge}from"./binary-cache-bSOhqXB1.js";import{i as _e,n as ve,r as ye}from"./fetch-body-CuwTaJC_.js";import{s as be,t as xe}from"./api-endpoint-D8lUKmPu.js";import{t as Se}from"./compat-uEPf6-XW.js";import{a as Ce,i as we}from"./core-VO3EvqHP.js";import{n as Te,t as Ee}from"./mime-types-D7IV6i7k.js";import{t as De}from"./secrets-bridge-client-BiJrSKN9.js";import{a as Oe,i as ke,n as Ae,r as je}from"./tool-ui-DRnUkp2g.js";import{a as Me,i as Ne,n as b,t as x}from"./path-utils-DNJG-zQf.js";import{n as Pe,r as Fe,t as Ie}from"./merge-file-core-VJlzucJY.js";import{r as Le}from"./workspace-mode-D0kUKBVS.js";import{n as Re,t as ze}from"./thinking-level-5x0UAu9N.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-CMYMchhb.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-D5yEr6Lj.js";import{a as Qe}from"./tray-leader-status-CpkFr6n7.js";import{n as $e,t as et}from"./slicc-version-DVRQVnZq.js";import{a as tt,i as nt,o as rt,r as S,t as it}from"./browser-CezNe0PF.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-D0tJNxsl.js";import{d as ct,g as lt,i as ut,n as dt,o as ft}from"./sudoers-BdBYQPUn.js";import{n as pt,r as mt,t as ht}from"./approval-timeout-BQ29Z0gf.js";import{a as gt,c as _t,i as vt,l as yt,n as bt,o as xt,r as St,t as Ct}from"./types-BfwydWt7.js";import{n as T,t as wt}from"./boundary-Cp9c_bPu.js";import"./rest-paths-Dia19u9P.js";import{t as Tt}from"./html-B_Hg2WOy.js";import{n as Et}from"./llm-session-id-BZyXP_j2.js";import{t as Dt}from"./src-CUSndb9K.js";import{i as Ot,o as kt}from"./browser-DuyhpHbR.js";import{i as At,r as jt,t as Mt}from"./mount-picker-popup-BMils9JY.js";import{t as Nt}from"./buffer-B5d1xHaH.js";import"./buffer-polyfill-BwLbCySD.js";import{A as Pt,B as E,C as Ft,D,E as It,F as Lt,G as Rt,H as O,I as k,J as zt,K as Bt,L as Vt,M as Ht,N as Ut,O as Wt,P as Gt,R as Kt,S as qt,T as Jt,U as Yt,V as Xt,W as Zt,Y as Qt,_ as $t,a as en,b as tn,c as nn,d as rn,f as an,g as on,h as sn,i as cn,j as ln,k as un,l as dn,m as fn,n as pn,o as mn,p as A,q as hn,r as gn,s as _n,t as vn,u as yn,v as bn,w as xn,x as Sn,y as Cn,z as wn}from"./isomorphic-git-r9mnHMnp.js";import"./global-db-DJXlpNui.js";import{S as Tn,_ as En,a as Dn,b as On,c as kn,d as An,f as jn,g as Mn,h as Nn,i as Pn,l as Fn,n as In,o as Ln,p as Rn,r as zn,s as Bn,t as Vn,u as Hn,v as j,x as M,y as Un}from"./state-B5mkDtuH.js";import{a as Wn,i as Gn,r as Kn,t as qn}from"./git-config-Bdgu8kD2.js";import{f as Jn,i as Yn,r as Xn}from"./stdio-tty-CE0OUA_G.js";import{i as Zn,r as Qn}from"./global-prefix-DqCuANmV.js";import{t as $n}from"./wasm-programs-CsoF9Lrt.js";import{a as er,n as tr,o as nr,r as rr,s as ir}from"./jsh-discovery-CnvNKojr.js";import{C as ar,a as or,b as sr,c as cr,d as lr,f as ur,h as dr,i as fr,l as pr,m as mr,n as hr,o as gr,p as _r,r as vr,s as yr,t as N,u as br,v as xr,y as Sr}from"./shared-Bi8EHIOr.js";import{_ as Cr,a as wr,b as Tr,d as Er,f as Dr,g as Or,h as kr,i as Ar,l as jr,m as Mr,p as Nr,r as Pr,s as Fr,u as Ir,v as Lr,x as Rr,y as zr}from"./require-guards-Dor7ByR7.js";import{_ as Br,a as Vr,b as Hr,c as Ur,d as Wr,f as Gr,g as Kr,h as qr,l as Jr,m as Yr,n as Xr,p as Zr,s as Qr,t as $r,u as ei,v as ti,x as ni,y as ri}from"./jsh-executor-B-jk9nVj.js";import{n as ii,t as ai}from"./esbuild-wasm-BqY5rzxc.js";import{n as oi}from"./wasm-compiler-Ct7QZURL.js";import{a as si,o as ci,s as li,t as ui}from"./usb-device-registry-DFzxaOky.js";import{a as P,i as di,r as fi,t as pi}from"./just-bash-compat-B-SPHuh_.js";import{i as mi,r as hi,t as gi}from"./script-catalog-1QnOA1GQ.js";import{a as _i,c as vi,o as yi,s as bi,t as xi}from"./types-Dzr0qYl3.js";import{a as Si,c as Ci,d as wi,f as Ti,n as Ei,r as Di,u as Oi}from"./github-zip-CSPX1g-L.js";import{i as ki,t as Ai}from"./github-auth-B39F_Smu.js";import{a as ji,i as Mi,o as Ni,r as Pi,t as Fi}from"./provenance-DdmsQ3Nr.js";import{a as Ii,c as Li,i as Ri,n as zi,o as Bi,r as Vi,s as Hi}from"./github-install-DoUx643r.js";import{n as Ui,t as Wi}from"./magick-wasm-DjyHtD1t.js";import{i as Gi,n as Ki,r as qi,t as Ji}from"./pdf-raster-BWk6ezTX.js";import{n as Yi}from"./lick-target-env-8JxfVcIV.js";import{t as Xi}from"./tmpdir-env-ate4iNcK.js";import{n as Zi,t as Qi}from"./hf-defaults-BwJdGLgk.js";import{a as $i,i as ea,n as ta,o as na,r as ra,t as ia}from"./installer-BZvW1okl.js";import{i as aa,n as oa,r as sa,t as ca}from"./tar-BWIPCxI2.js";import{t as la}from"./ffmpeg-wasm-NIvl0oHG.js";import{t as ua}from"./local-llm-2mEnfN8G.js";import{t as da}from"./client-CwxmlQM-.js";import{t as fa}from"./redirect-uri-CBCnYKsl.js";import{a as pa,c as ma,i as ha,o as ga,r as _a,s as va}from"./v86-vm-DCm7zA2r.js";import{n as ya,r as ba}from"./lick-urls-CgPiVwD-.js";let xa=null;function Sa(e){xa=e!==null&&Number.isFinite(e)&&e>0?e:null}function Ca(){if(xa!==null)return xa;let e=globalThis.performance?.timeOrigin;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:Date.now()}new URL(r).hostname;const wa=/^([0-9a-f]{32})--(?:[0-9a-f]{8}-)?([0-9a-f]+)$/i;function Ta(e){let t;try{t=new URL(e.includes(`://`)?e:`https://${e}`).hostname}catch{return null}let n=wa.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 Ea(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 Da(e,t){return e.some(e=>Ea(e,t))}const Oa=`slicc-transcript`,ka=[`canonical-agent-history-unavailable`,`tool-data-may-be-truncated`,`model-metadata-unavailable`,`scoop-history-unavailable`,`attachment-file-missing`,`attachment-association-unavailable`,`complete-snapshot-unavailable`],Aa=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 ja(e){return Aa.has(e.replace(/\/\d+(?=\/|$)/g,`/*`))}var Ma=class extends Error{code;detail;constructor(e,t){super(t?`${e}: ${t}`:e),this.code=e,this.detail=t,this.name=`TranscriptExportError`}};const Na=new Set(ka),Pa=/^[0-9a-fA-F]{64}$/,Fa=/^\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 Ia(e){return typeof e==`string`&&Pa.test(e)}function La(e){return Fa.test(e)&&Number.isFinite(Date.parse(e))}function Ra(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 za(e,t,n){return typeof e!=`string`||!t.includes(e)?{ok:!1,error:Ra(n,t)}:{ok:!0}}function Ba(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 Va(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 Ha(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};let n=za(e.type,[`text`,`tool-call`,`attachment-ref`],`${t}.type`);return n.ok?Va(e,t):n}function Ua(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 Wa(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 Ga(e,t){let n=Ua(e,t);if(!n.ok)return n;let r=e.cost;return F(r)?Wa(r,`${t}.cost`):{ok:!1,error:`${t}.cost must be a non-null object`}}function Ka(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`?La(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 qa(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 Ja(e,t){let n=e.usage;return n===void 0?{ok:!0}:F(n)?Ga(n,`${t}.usage`):{ok:!1,error:`${t}.usage must be a non-null object`}}function Ya(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};let n=za(e.role,[`user`,`assistant`,`tool-result`],`${t}.role`);if(!n.ok)return n;if(e.role===`tool-result`){let n=qa(e,t);if(!n.ok)return n}let r=Ka(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=Ba(i,Ha,`${t}.content`);return a.ok?Ja(e,t):a}function Xa(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=za(e.kind,[`cone`,`scoop`],`${t}.kind`);if(!n.ok)return n;let r=e.messages;return Array.isArray(r)?Ba(r,Ya,`${t}.messages`):{ok:!1,error:`${t}.messages must be an array`}}function Za(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 Qa(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`}:Ia(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 $a=[`attachment-file-missing`,`attachment-association-unavailable`];function eo(e,t){let n=e.path,r=e.sha256,i=e.byteLength;return n===``?r===``?i===0?za(e.missingReason,$a,`${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 to(e,t){return e.present?Qa(e,t):eo(e,t)}function no(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};let n=Za(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=za(e.handling,[`text-redacted`,`binary-unchanged`],`${t}.handling`);return r.ok?to(e,t):r}function ro(e,t){let n=za(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 io(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=za(e.detector,[`known-secret`,`credential-pattern`,`pre-obfuscated`],`${t}.detector`);if(!n.ok)return n;let r=e.target;return F(r)?ro(r,`${t}.target`):{ok:!1,error:`${t}.target must be a non-null object`}}function ao(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 oo(e,t){return typeof e!=`string`||!Na.has(e)?{ok:!1,error:`${t} is not a valid completeness reason`}:{ok:!0}}function so(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 co(e){if(!F(e))return{ok:!1,error:`session.completeness must be a non-null object`};let t=za(e.status,[`complete`,`partial`],`session.completeness.status`);return t.ok?Array.isArray(e.missing)?Ba(e.missing,oo,`session.completeness.missing`):{ok:!1,error:`session.completeness.missing must be an array`}:t}function lo(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=za(e.state,[`active`,`frozen`],`session.state`);return t.ok?co(e.completeness):t}function uo(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)?Ba(n,io,`privacy.redactions`):{ok:!1,error:`privacy.redactions must be an array`}}function fo(e){let t=e.conversations;if(!Array.isArray(t))return{ok:!1,error:`conversations must be an array`};let n=Ba(t,Xa,`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=Ba(r,ao,`delegations`);if(!i.ok)return i;let a=e.attachments;return Array.isArray(a)?Ba(a,no,`attachments`):{ok:!1,error:`attachments must be an array`}}function po(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 mo(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 ho(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 go(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 ho(e))t.add(n)}return t}function _o(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 vo(e){return _o(e,go(e))}function yo(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 bo(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=yo(e,t);if(!r.ok)return r}}return{ok:!0}}function xo(e,t){let n=new Set;for(let e of t)F(e)&&typeof e.id==`string`&&n.add(e.id);return bo(e,n)}function So(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 Co(e,t){let n=So(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 wo(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(ho(e)))}return t}function To(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 Eo(e,t){let n=new Set;for(let e of t)F(e)&&typeof e.id==`string`&&n.add(e.id);return To(e,n,wo(t))}function Do(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 Oo(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=Do(i,n,`privacy.redactions[${t}].target`);if(!a.ok)return a}return{ok:!0}}function ko(e){let t=e.conversations,n=e.attachments,r=e.delegations,i=e.privacy,a=Array.isArray(i?.redactions)?i.redactions:[],o=po(t);if(!o.ok)return o;let s=mo(t);if(!s.ok)return s;let c=vo(t);if(!c.ok)return c;let l=xo(t,n);if(!l.ok)return l;let u=Co(n,t);if(!u.ok)return u;let d=Eo(r,t);return d.ok?Oo(a,n):d}function Ao(e){let t=fo(e);return t.ok?ko(e):t}function jo(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=so(e.export);if(!t.ok)return t;let n=lo(e.session);if(!n.ok)return n;let r=uo(e.privacy);return r.ok?Ao(e):r}async function Mo(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:No(a),sourceUrl:a}}function No(e){if(!e)return`da`;let t;try{t=new URL(e).host}catch{return`da`}return t===`api.aem.live`?`aem`:`da`}const Po=`slicc-sprinkle-routes`;function Fo(){try{let e=localStorage.getItem(Po);return e?JSON.parse(e):{}}catch{return{}}}function Io(e){try{localStorage.setItem(Po,JSON.stringify(e))}catch{}}function Lo(e){return Fo()[e]}function Ro(e,t){let n=Fo();n[e]=t,Io(n)}function zo(e){let t=Fo();delete t[e],Io(t)}function Bo(){return Fo()}function Vo(e,t,n){return _t(t,n,`${e} adapter does not implement ${t}.${n}`)}function Ho(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(Vo(e,t,n))]});return{...Object.fromEntries(a),allowlist:i,supports:e=>i.includes(e)}}function Uo(e){let{adapter:t,pageGestures:n}=e,r=n??{};return{adapter:t,browser:Ho(t,`browser`,bt,e.browser),network:Ho(t,`network`,gt,e.network),secrets:Ho(t,`secrets`,xt,e.secrets),devices:Ho(t,`devices`,St,{usbRequest:r.usbRequest,serialRequest:r.serialRequest,hidRequest:r.hidRequest,...e.devices}),mounts:Ho(t,`mounts`,vt,{pickDirectory:r.pickDirectory,...e.mounts}),approvals:Ho(t,`approvals`,Ct,e.approvals)}}function Wo(e={}){return Uo({adapter:`connect`,pageGestures:e.pageGestures})}function Go(e){let t=wt(()=>import(`./extension-ops-CF2mLDRW.js`).then(t=>t.createExtensionOps(e)));return Uo({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 Ko(e={}){let t=wt(()=>import(`./rest-ops-CLliBy-9.js`).then(t=>t.createRestOps(e)),e.controlTimeoutMs??1e4);return Uo({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 qo(e,t={}){let{pageGestures:n}=t;switch(e){case`node-rest`:return Ko({pageGestures:n});case`extension-direct`:case`extension-delegate`:return Go({adapter:e,pageGestures:n});case`connect`:return Wo({pageGestures:n})}}const Jo=e(`quick-llm`);async function Yo(e){let t=d();if(!t)return Jo.debug(`No API key for active provider — skipping`),null;let n=u(),r=l(),i;if(i=e.modelId?$o(n,e.modelId)??$o(n,r):Xo(n,r),!i)return Jo.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`]=es());try{let n=(await Se(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 Jo.debug(`Quick label call failed`,{error:e instanceof Error?e.message:String(e)}),null}}function Xo(e,t){let n=f(e);if(n.length===0)return;let r=n.find(e=>e.id===t)??n[0],i=Qo(r.id),a=n.filter(e=>Zo(e,r,i));return a.length===0?r:(a.sort((e,t)=>(e.cost?.input??0)-(t.cost?.input??0)),a[0])}function Zo(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 Qo(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 $o(e,t){return f(e).find(e=>e.id===t)}function es(){return Et(`ui-quick-llm`)}const ts=e(`sudo-suggest`),ns=[`You generalize a single shell command into a minimal glob pattern for an`,`allow-list rule. Output ONLY the pattern on one line — no prose, no quotes,`,`no backticks. Keep the leading command/sub-command verbatim and replace only`,`the volatile tail (args, paths, refs) with a single trailing "*".`,`Examples:`,` git push origin main -> git push*`,` rm -rf build/cache -> rm -rf*`,` npm install left-pad -> npm install*`].join(`
|
|
1
|
+
import{t as e}from"./logger-LESFN7Hj.js";import{r as t,t as n}from"./base64-BPBW1Gzr.js";import{n as r}from"./bridge-protocol-31SWTdS5.js";import{a as i,n as a,o,s,t as c}from"./handoff-link-B3It6xQY.js";import{d as l,f as u,i as d,u as f}from"./account-store-DgfR_tf2.js";import{n as p,o as m,r as h,s as g,u as _}from"./proxied-fetch-DXaTHROw.js";import{t as v}from"./runtime-env-DadgceZk.js";import{t as ee}from"./slugify-BYJ6QVAt.js";import{n as te,t as ne}from"./host-command-guuPK7VN.js";import{a as re,i as ie,n as ae,r as oe,t as se}from"./snapshot-C-rMXS0v.js";import{i as ce,r as y}from"./panel-rpc-DW7W4w6_.js";import{a as le,c as ue,n as de,o as fe,s as pe,t as me}from"./feature-flags-QlgHaQc1.js";import{t as he}from"./providers-TV6NIsPL.js";import{r as ge}from"./binary-cache-bSOhqXB1.js";import{i as _e,n as ve,r as ye}from"./fetch-body-CuwTaJC_.js";import{s as be,t as xe}from"./api-endpoint-D8lUKmPu.js";import{t as Se}from"./compat-uEPf6-XW.js";import{a as Ce,i as we}from"./core-VO3EvqHP.js";import{n as Te,t as Ee}from"./mime-types-D7IV6i7k.js";import{t as De}from"./secrets-bridge-client-BiJrSKN9.js";import{a as Oe,i as ke,n as Ae,r as je}from"./tool-ui-DRnUkp2g.js";import{a as Me,i as Ne,n as b,t as x}from"./path-utils-DNJG-zQf.js";import{n as Pe,r as Fe,t as Ie}from"./merge-file-core-VJlzucJY.js";import{r as Le}from"./workspace-mode-D0kUKBVS.js";import{n as Re,t as ze}from"./thinking-level-5x0UAu9N.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-BnBm1LRC.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-B3WU3yr9.js";import{a as Qe}from"./tray-leader-status-CpkFr6n7.js";import{n as $e,t as et}from"./slicc-version-klgPNoH5.js";import{a as tt,i as nt,o as rt,r as S,t as it}from"./browser-CezNe0PF.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-D0tJNxsl.js";import{d as ct,g as lt,i as ut,n as dt,o as ft}from"./sudoers-BdBYQPUn.js";import{n as pt,r as mt,t as ht}from"./approval-timeout-BQ29Z0gf.js";import{a as gt,c as _t,i as vt,l as yt,n as bt,o as xt,r as St,t as Ct}from"./types-BfwydWt7.js";import{n as T,t as wt}from"./boundary-Cp9c_bPu.js";import"./rest-paths-Dia19u9P.js";import{t as Tt}from"./html-B_Hg2WOy.js";import{n as Et}from"./llm-session-id-BZyXP_j2.js";import{t as Dt}from"./src-CUSndb9K.js";import{i as Ot,o as kt}from"./browser-DuyhpHbR.js";import{i as At,r as jt,t as Mt}from"./mount-picker-popup-BMils9JY.js";import{t as Nt}from"./buffer-B5d1xHaH.js";import"./buffer-polyfill-BwLbCySD.js";import{A as Pt,B as E,C as Ft,D,E as It,F as Lt,G as Rt,H as O,I as k,J as zt,K as Bt,L as Vt,M as Ht,N as Ut,O as Wt,P as Gt,R as Kt,S as qt,T as Jt,U as Yt,V as Xt,W as Zt,Y as Qt,_ as $t,a as en,b as tn,c as nn,d as rn,f as an,g as on,h as sn,i as cn,j as ln,k as un,l as dn,m as fn,n as pn,o as mn,p as A,q as hn,r as gn,s as _n,t as vn,u as yn,v as bn,w as xn,x as Sn,y as Cn,z as wn}from"./isomorphic-git-r9mnHMnp.js";import"./global-db-DJXlpNui.js";import{S as Tn,_ as En,a as Dn,b as On,c as kn,d as An,f as jn,g as Mn,h as Nn,i as Pn,l as Fn,n as In,o as Ln,p as Rn,r as zn,s as Bn,t as Vn,u as Hn,v as j,x as M,y as Un}from"./state-DuLjW_a4.js";import{a as Wn,i as Gn,r as Kn,t as qn}from"./git-config-Bdgu8kD2.js";import{i as Jn,p as Yn,r as Xn}from"./stdio-tty-uIuGda2o.js";import{i as Zn,r as Qn}from"./global-prefix-DqCuANmV.js";import{t as $n}from"./wasm-programs-CsoF9Lrt.js";import{a as er,n as tr,o as nr,r as rr,s as ir}from"./jsh-discovery-CnvNKojr.js";import{C as ar,a as or,b as sr,c as cr,d as lr,f as ur,h as dr,i as fr,l as pr,m as mr,n as hr,o as gr,p as _r,r as vr,s as yr,t as N,u as br,v as xr,y as Sr}from"./shared-Bi8EHIOr.js";import{_ as Cr,a as wr,b as Tr,d as Er,f as Dr,g as Or,h as kr,i as Ar,l as jr,m as Mr,p as Nr,r as Pr,s as Fr,u as Ir,v as Lr,x as Rr,y as zr}from"./require-guards-Dor7ByR7.js";import{_ as Br,a as Vr,b as Hr,c as Ur,d as Wr,f as Gr,g as Kr,h as qr,l as Jr,m as Yr,n as Xr,p as Zr,s as Qr,t as $r,u as ei,v as ti,x as ni,y as ri}from"./jsh-executor-DZO1HSOR.js";import{n as ii,t as ai}from"./esbuild-wasm-BqY5rzxc.js";import{n as oi}from"./wasm-compiler-Ct7QZURL.js";import{a as si,o as ci,s as li,t as ui}from"./usb-device-registry-DFzxaOky.js";import{a as P,i as di,r as fi,t as pi}from"./just-bash-compat-B-SPHuh_.js";import{i as mi,r as hi,t as gi}from"./script-catalog-1QnOA1GQ.js";import{a as _i,c as vi,o as yi,s as bi,t as xi}from"./types-Dzr0qYl3.js";import{a as Si,c as Ci,d as wi,f as Ti,n as Ei,r as Di,u as Oi}from"./github-zip-DHBvTUIf.js";import{i as ki,t as Ai}from"./github-auth-O6zGPogb.js";import{a as ji,i as Mi,o as Ni,r as Pi,t as Fi}from"./provenance-DdmsQ3Nr.js";import{a as Ii,c as Li,i as Ri,n as zi,o as Bi,r as Vi,s as Hi}from"./github-install-CXBoYKYM.js";import{n as Ui,t as Wi}from"./magick-wasm-DjyHtD1t.js";import{i as Gi,n as Ki,r as qi,t as Ji}from"./pdf-raster-BWk6ezTX.js";import{n as Yi}from"./lick-target-env-8JxfVcIV.js";import{t as Xi}from"./tmpdir-env-ate4iNcK.js";import{n as Zi,t as Qi}from"./hf-defaults-BwJdGLgk.js";import{a as $i,i as ea,n as ta,o as na,r as ra,t as ia}from"./installer-pOTEH6_f.js";import{i as aa,n as oa,r as sa,t as ca}from"./tar-BWIPCxI2.js";import{t as la}from"./ffmpeg-wasm-NIvl0oHG.js";import{t as ua}from"./local-llm-D0k2uDUi.js";import{t as da}from"./client-CwxmlQM-.js";import{t as fa}from"./redirect-uri-CBCnYKsl.js";import{a as pa,c as ma,i as ha,o as ga,r as _a,s as va}from"./v86-vm-DCm7zA2r.js";import{n as ya,r as ba}from"./lick-urls-CgPiVwD-.js";let xa=null;function Sa(e){xa=e!==null&&Number.isFinite(e)&&e>0?e:null}function Ca(){if(xa!==null)return xa;let e=globalThis.performance?.timeOrigin;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:Date.now()}new URL(r).hostname;const wa=/^([0-9a-f]{32})--(?:[0-9a-f]{8}-)?([0-9a-f]+)$/i;function Ta(e){let t;try{t=new URL(e.includes(`://`)?e:`https://${e}`).hostname}catch{return null}let n=wa.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 Ea(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 Da(e,t){return e.some(e=>Ea(e,t))}const Oa=`slicc-transcript`,ka=[`canonical-agent-history-unavailable`,`tool-data-may-be-truncated`,`model-metadata-unavailable`,`scoop-history-unavailable`,`attachment-file-missing`,`attachment-association-unavailable`,`complete-snapshot-unavailable`],Aa=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 ja(e){return Aa.has(e.replace(/\/\d+(?=\/|$)/g,`/*`))}var Ma=class extends Error{code;detail;constructor(e,t){super(t?`${e}: ${t}`:e),this.code=e,this.detail=t,this.name=`TranscriptExportError`}};const Na=new Set(ka),Pa=/^[0-9a-fA-F]{64}$/,Fa=/^\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 Ia(e){return typeof e==`string`&&Pa.test(e)}function La(e){return Fa.test(e)&&Number.isFinite(Date.parse(e))}function Ra(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 za(e,t,n){return typeof e!=`string`||!t.includes(e)?{ok:!1,error:Ra(n,t)}:{ok:!0}}function Ba(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 Va(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 Ha(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};let n=za(e.type,[`text`,`tool-call`,`attachment-ref`],`${t}.type`);return n.ok?Va(e,t):n}function Ua(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 Wa(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 Ga(e,t){let n=Ua(e,t);if(!n.ok)return n;let r=e.cost;return F(r)?Wa(r,`${t}.cost`):{ok:!1,error:`${t}.cost must be a non-null object`}}function Ka(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`?La(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 qa(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 Ja(e,t){let n=e.usage;return n===void 0?{ok:!0}:F(n)?Ga(n,`${t}.usage`):{ok:!1,error:`${t}.usage must be a non-null object`}}function Ya(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};let n=za(e.role,[`user`,`assistant`,`tool-result`],`${t}.role`);if(!n.ok)return n;if(e.role===`tool-result`){let n=qa(e,t);if(!n.ok)return n}let r=Ka(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=Ba(i,Ha,`${t}.content`);return a.ok?Ja(e,t):a}function Xa(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=za(e.kind,[`cone`,`scoop`],`${t}.kind`);if(!n.ok)return n;let r=e.messages;return Array.isArray(r)?Ba(r,Ya,`${t}.messages`):{ok:!1,error:`${t}.messages must be an array`}}function Za(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 Qa(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`}:Ia(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 $a=[`attachment-file-missing`,`attachment-association-unavailable`];function eo(e,t){let n=e.path,r=e.sha256,i=e.byteLength;return n===``?r===``?i===0?za(e.missingReason,$a,`${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 to(e,t){return e.present?Qa(e,t):eo(e,t)}function no(e,t){if(!F(e))return{ok:!1,error:`${t} must be a non-null object`};let n=Za(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=za(e.handling,[`text-redacted`,`binary-unchanged`],`${t}.handling`);return r.ok?to(e,t):r}function ro(e,t){let n=za(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 io(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=za(e.detector,[`known-secret`,`credential-pattern`,`pre-obfuscated`],`${t}.detector`);if(!n.ok)return n;let r=e.target;return F(r)?ro(r,`${t}.target`):{ok:!1,error:`${t}.target must be a non-null object`}}function ao(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 oo(e,t){return typeof e!=`string`||!Na.has(e)?{ok:!1,error:`${t} is not a valid completeness reason`}:{ok:!0}}function so(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 co(e){if(!F(e))return{ok:!1,error:`session.completeness must be a non-null object`};let t=za(e.status,[`complete`,`partial`],`session.completeness.status`);return t.ok?Array.isArray(e.missing)?Ba(e.missing,oo,`session.completeness.missing`):{ok:!1,error:`session.completeness.missing must be an array`}:t}function lo(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=za(e.state,[`active`,`frozen`],`session.state`);return t.ok?co(e.completeness):t}function uo(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)?Ba(n,io,`privacy.redactions`):{ok:!1,error:`privacy.redactions must be an array`}}function fo(e){let t=e.conversations;if(!Array.isArray(t))return{ok:!1,error:`conversations must be an array`};let n=Ba(t,Xa,`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=Ba(r,ao,`delegations`);if(!i.ok)return i;let a=e.attachments;return Array.isArray(a)?Ba(a,no,`attachments`):{ok:!1,error:`attachments must be an array`}}function po(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 mo(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 ho(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 go(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 ho(e))t.add(n)}return t}function _o(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 vo(e){return _o(e,go(e))}function yo(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 bo(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=yo(e,t);if(!r.ok)return r}}return{ok:!0}}function xo(e,t){let n=new Set;for(let e of t)F(e)&&typeof e.id==`string`&&n.add(e.id);return bo(e,n)}function So(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 Co(e,t){let n=So(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 wo(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(ho(e)))}return t}function To(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 Eo(e,t){let n=new Set;for(let e of t)F(e)&&typeof e.id==`string`&&n.add(e.id);return To(e,n,wo(t))}function Do(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 Oo(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=Do(i,n,`privacy.redactions[${t}].target`);if(!a.ok)return a}return{ok:!0}}function ko(e){let t=e.conversations,n=e.attachments,r=e.delegations,i=e.privacy,a=Array.isArray(i?.redactions)?i.redactions:[],o=po(t);if(!o.ok)return o;let s=mo(t);if(!s.ok)return s;let c=vo(t);if(!c.ok)return c;let l=xo(t,n);if(!l.ok)return l;let u=Co(n,t);if(!u.ok)return u;let d=Eo(r,t);return d.ok?Oo(a,n):d}function Ao(e){let t=fo(e);return t.ok?ko(e):t}function jo(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=so(e.export);if(!t.ok)return t;let n=lo(e.session);if(!n.ok)return n;let r=uo(e.privacy);return r.ok?Ao(e):r}async function Mo(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:No(a),sourceUrl:a}}function No(e){if(!e)return`da`;let t;try{t=new URL(e).host}catch{return`da`}return t===`api.aem.live`?`aem`:`da`}const Po=`slicc-sprinkle-routes`;function Fo(){try{let e=localStorage.getItem(Po);return e?JSON.parse(e):{}}catch{return{}}}function Io(e){try{localStorage.setItem(Po,JSON.stringify(e))}catch{}}function Lo(e){return Fo()[e]}function Ro(e,t){let n=Fo();n[e]=t,Io(n)}function zo(e){let t=Fo();delete t[e],Io(t)}function Bo(){return Fo()}function Vo(e,t,n){return _t(t,n,`${e} adapter does not implement ${t}.${n}`)}function Ho(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(Vo(e,t,n))]});return{...Object.fromEntries(a),allowlist:i,supports:e=>i.includes(e)}}function Uo(e){let{adapter:t,pageGestures:n}=e,r=n??{};return{adapter:t,browser:Ho(t,`browser`,bt,e.browser),network:Ho(t,`network`,gt,e.network),secrets:Ho(t,`secrets`,xt,e.secrets),devices:Ho(t,`devices`,St,{usbRequest:r.usbRequest,serialRequest:r.serialRequest,hidRequest:r.hidRequest,...e.devices}),mounts:Ho(t,`mounts`,vt,{pickDirectory:r.pickDirectory,...e.mounts}),approvals:Ho(t,`approvals`,Ct,e.approvals)}}function Wo(e={}){return Uo({adapter:`connect`,pageGestures:e.pageGestures})}function Go(e){let t=wt(()=>import(`./extension-ops-CF2mLDRW.js`).then(t=>t.createExtensionOps(e)));return Uo({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 Ko(e={}){let t=wt(()=>import(`./rest-ops-CLliBy-9.js`).then(t=>t.createRestOps(e)),e.controlTimeoutMs??1e4);return Uo({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 qo(e,t={}){let{pageGestures:n}=t;switch(e){case`node-rest`:return Ko({pageGestures:n});case`extension-direct`:case`extension-delegate`:return Go({adapter:e,pageGestures:n});case`connect`:return Wo({pageGestures:n})}}const Jo=e(`quick-llm`);async function Yo(e){let t=d();if(!t)return Jo.debug(`No API key for active provider — skipping`),null;let n=u(),r=l(),i;if(i=e.modelId?$o(n,e.modelId)??$o(n,r):Xo(n,r),!i)return Jo.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`]=es());try{let n=(await Se(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 Jo.debug(`Quick label call failed`,{error:e instanceof Error?e.message:String(e)}),null}}function Xo(e,t){let n=f(e);if(n.length===0)return;let r=n.find(e=>e.id===t)??n[0],i=Qo(r.id),a=n.filter(e=>Zo(e,r,i));return a.length===0?r:(a.sort((e,t)=>(e.cost?.input??0)-(t.cost?.input??0)),a[0])}function Zo(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 Qo(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 $o(e,t){return f(e).find(e=>e.id===t)}function es(){return Et(`ui-quick-llm`)}const ts=e(`sudo-suggest`),ns=[`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
|
`),rs=[`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 is(e,t){if(e.suggestedPattern&&e.suggestedPattern.trim().length>0)return e.suggestedPattern.trim();let n=e.detail.trim(),r=e.kind===`command`?ns:rs,i=null;try{i=await Yo({prompt:n,system:r,maxTokens:40,temperature:0,signal:t})}catch(e){ts.debug(`suggestPattern: quickLabel threw`,{error:e instanceof Error?e.message:String(e)}),i=null}return as(i)||n}function as(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 os=e(`sudo:capability-gesture`);function ss(e,t={}){let n=t.suggest??is;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 os.warn(`sudo approval aborted before prompting — denying`,{detail:t.detail}),{decision:`deny`};if(!e)return os.warn(`no CapabilityBroker injected for the sudo gesture hop — denying (composition bug, never a guessed transport)`,{detail:t.detail}),{decision:`deny`};let o=await e.approvals.request({kind:t.kind,detail:t.detail,suggestedPattern:a,...t.requester?{requester:t.requester}:{},...t.reason?{reason:t.reason}:{},...t.approver?{approver:t.approver}:{},...i?{signal:i}:{}});return o.ok?yt(o.value,a):(os.warn(`capability broker approvals.request failed — denying`,{message:o.message}),{decision:`deny`})}}}const cs=e(`sudo:tray-first`);function ls(e,t={}){let n=t.suggest??is,r=t.timeoutMs??6e5,i=t.getClient??(async()=>{let{getPanelRpcClient:e}=await import(`./panel-rpc-DW7W4w6_.js`).then(e=>e.a);return e()});return{async requestApproval(t,a){if(a?.signal?.aborted)return{decision:`deny`};let o=t.suggestedPattern;if(!o)try{o=await n(t,a?.signal)}catch{o=t.detail}let s={...t,suggestedPattern:o},c=null;try{c=await i()}catch(e){cs.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 us(e?.decision,o)}catch(e){cs.warn(`tray-first sudo probe failed — using native broker`,{error:e instanceof Error?e.message:String(e)})}return e.requestApproval(s,a)}}}function us(e,t){if(!e||typeof e!=`object`)return{decision:`deny`};let n=e,r=n.attestation===`biometric`||n.attestation===`passcode`||n.attestation===`none`?n.attestation:void 0;return n.decision===`allow`?{decision:`allow`,...r?{attestation:r}:{}}:n.decision===`always`?{decision:`always`,pattern:typeof n.pattern==`string`&&n.pattern.trim().length>0?n.pattern.trim():t,...r?{attestation:r}:{}}:{decision:`deny`}}function ds(e,t){return{requestApproval(n){return t.enqueueSudoRequest(e,n)}}}function fs(){return`lick-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}var ps=class{pending=new Map;timeoutMs;newId;setTimer;clearTimer;onAutoSettle;constructor(e={}){this.timeoutMs=e.timeoutMs??3e5,this.newId=e.newId??fs,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(pt(`cone-timeout`)),this.notifyAutoSettle(r,`expired`,e.scoopJid))},this.timeoutMs)),this.pending.set(r,{scoopJid:e,request:t,resolve:i,timerHandle:a,approverJid:n})})}}resolve(e,t){let n=this.pending.get(e);return n?(this.pending.delete(e),n.timerHandle!=null&&this.clearTimer(n.timerHandle),n.resolve(t),!0):!1}failScoop(e){let t=0;for(let[n,r]of this.pending)r.scoopJid===e&&(this.pending.delete(n),r.timerHandle!=null&&this.clearTimer(r.timerHandle),r.resolve({decision:`deny`}),this.notifyAutoSettle(n,`scoop-dropped`,r.scoopJid),t++);return t}failAll(){let e=0;for(let[t,n]of this.pending)n.timerHandle!=null&&this.clearTimer(n.timerHandle),n.resolve({decision:`deny`}),this.notifyAutoSettle(t,`shutdown`,n.scoopJid),e++;return this.pending.clear(),e}get(e){let t=this.pending.get(e);return t?{id:e,scoopJid:t.scoopJid,request:t.request,...t.approverJid?{approverJid:t.approverJid}:{}}:null}list(){let e=[];for(let[t,n]of this.pending)e.push({id:t,scoopJid:n.scoopJid,request:n.request,...n.approverJid?{approverJid:n.approverJid}:{}});return e}size(){return this.pending.size}};e(`sudo-panel`),typeof globalThis.confirm==`function`&&globalThis.confirm.bind(globalThis),typeof globalThis.prompt==`function`&&globalThis.prompt.bind(globalThis),e(`sudo:page`),e(`sudo`);function ms(e){return mt(hs(e))}function hs(e){let t=ss(e);return e?.adapter===`extension-direct`||e?.adapter===`extension-delegate`?t:ls(t)}let gs=null;function _s(e){return gs=e,()=>{gs===e&&(gs=null)}}function vs(){if(!gs)throw new Ma(`session-not-found`);return gs}const ys=`focus`,bs={type:`leaf`,surfaceId:`chat`};function xs(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 Ss={focus:{name:`focus`,tree:xs({left:bs},{left:3,middle:1})}};function Cs(e){return Ss[e]??null}const ws=`progress`;function Ts(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)}async function Es(){try{let e=await jt();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 Mt(e.idbKey);if(!t)throw Error(`mount: no directory handle found in storage`);return await At(t),t}throw Error(`mount: unexpected popup result`)}catch(e){throw Error(`mount: ${e instanceof Error?e.message:String(e)}`)}}async function Ds(){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 Os(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 Mt(r.idbKey);if(!i)throw Error(`no directory handle found in storage`);return await At(i),i}function ks(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 As(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 js=new Set([`--source`,`--profile`,`--backend`,`--max-body-mb`]);function Ms(e){for(let t=0;t<e.length;t++){let n=e[t];if(n===`--`)return!1;if(n===`--help`||n===`-h`)return!0;js.has(n)&&t++}return!1}function Ns(e){return`aem://${e.org}/${e.name}${e.path?`/${e.path}`:``}`}var Ps=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=ks(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=Oe();if(!n){let n=await Fs(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=ce()?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=v()?await Es():r?await Os(r,e):await Ds();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=As(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 Mo(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`?Ns(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(Ms(e))return n===`umount`?this.umountHelp():this.help();let r=ks(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
|
|
@@ -151,7 +151,7 @@ Available commands:
|
|
|
151
151
|
config Get and set repository options
|
|
152
152
|
rev-parse Pick out and massage parameters
|
|
153
153
|
|
|
154
|
-
`,stderr:``,exitCode:0}}};const cp={maxTraversalEntries:1e5,maxTraversalDepth:256,maxTraversalWork:1e5,maxGlobOperations:1e5,maxLiveBytes:67108864,maxInputBytes:33554432,maxArchiveBytes:134217728,maxArchiveCompressedBytes:67108864,maxArchiveEntryBytes:67108864,maxArchiveEntries:1e5};function lp(e,t){return e?{...cp,...t}:t}const up=new Set([`SHLVL`,`_`]);function dp(e){let t=e.split(`\0`);if(t.length<4)return null;let[n=``,r=``,i=``,...a]=t;if(!/^\d+$/.test(n)||!i.startsWith(`/`))return null;let o={};for(let e of a){let t=e.indexOf(`=`);t>0&&(o[e.slice(0,t)]=e.slice(t+1))}let s=r.trim()===``?[]:r.trim().split(/\s+/).map(Number);return{status:Number(n),pipeStatus:s,cwd:i,env:o}}function fp(e,t=[]){let n=new Set([...up,...t]);return Object.fromEntries(Object.entries(e).filter(([e])=>!n.has(e)))}function pp(e,t){if(t!==`bytes`)return e;let n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t)&255;return new TextDecoder().decode(n)}async function mp(e,t){let n=[],r=
|
|
154
|
+
`,stderr:``,exitCode:0}}};const cp={maxTraversalEntries:1e5,maxTraversalDepth:256,maxTraversalWork:1e5,maxGlobOperations:1e5,maxLiveBytes:67108864,maxInputBytes:33554432,maxArchiveBytes:134217728,maxArchiveCompressedBytes:67108864,maxArchiveEntryBytes:67108864,maxArchiveEntries:1e5};function lp(e,t){return e?{...cp,...t}:t}const up=new Set([`SHLVL`,`_`]);function dp(e){let t=e.split(`\0`);if(t.length<4)return null;let[n=``,r=``,i=``,...a]=t;if(!/^\d+$/.test(n)||!i.startsWith(`/`))return null;let o={};for(let e of a){let t=e.indexOf(`=`);t>0&&(o[e.slice(0,t)]=e.slice(t+1))}let s=r.trim()===``?[]:r.trim().split(/\s+/).map(Number);return{status:Number(n),pipeStatus:s,cwd:i,env:o}}function fp(e,t=[]){let n=new Set([...up,...t]);return Object.fromEntries(Object.entries(e).filter(([e])=>!n.has(e)))}function pp(e,t){if(t!==`bytes`)return e;let n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t)&255;return new TextDecoder().decode(n)}async function mp(e,t){let n=[],r=Yn(e=>n.push(e)),i=await t.run([`bash`,`-c`,`__slicc_save() { local __s=\$1 __p=\$2 __c __n; { printf "%s\\0%s\\0%s\\0" "\$__s" "\$__p" "\$PWD"; for __c in {A..Z} {a..z} _; do eval "__slicc_names=(\\"\\\${!\${__c}@}\\")"; for __n in "\${__slicc_names[@]}"; do [[ \${!__n@a} == *x* ]] && printf "%s=%s\\0" "\$__n" "\${!__n}"; done; done; } >&97 2>/dev/null; }; trap '__slicc_save "\$?" "\${PIPESTATUS[*]}"' EXIT; ${e}`],t.env,[[97,r]]),a=n.reduce((e,t)=>e+t.length,0),o=new Uint8Array(a),s=0;for(let e of n)o.set(e,s),s+=e.length;return{stdout:pp(i.stdout,i.stdoutKind),stderr:i.stderr,exitCode:i.exitCode,state:a>0?dp(new TextDecoder().decode(o)):null}}const hp=`/home/user`;async function gp(e){try{let t=await e.readDir(`/home`),n=null,r=null;for(let i of t)if(i.type===`directory`){r??=i.name;try{let t=(await e.stat(`/home/${i.name}/.welcome.json`)).mtime??0;(!n||t>n.mtime)&&(n={name:i.name,mtime:t})}catch{}}let i=n?.name??r;return i?`/home/${i}`:hp}catch{return hp}}function _p(e){return e.replace(/\/+$/,``).split(`/`).pop()||`user`}function vp(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e[r];if(i===`"`){for(r++;r<e.length&&e[r]!==`"`;)n+=e[r],r++;r++}else if(i===`'`){for(r++;r<e.length&&e[r]!==`'`;)n+=e[r],r++;r++}else i===`\\`&&r+1<e.length&&e[r+1]===` `?(n+=` `,r+=2):/\s/.test(i)?(n.length>0&&(t.push(n),n=``),r++):(n+=i,r++)}return n.length>0&&t.push(n),t}const yp=`__SLICC_PIPESTATUS`,bp=`__SLICC_PIPESTATUS_EX`,xp=/^(0|[1-9]\d*)$/;function Sp(e){let t=Cp(e.trimEnd());return t?`{
|
|
155
155
|
${t}
|
|
156
156
|
}
|
|
157
157
|
${bp}=$? ${yp}="\${PIPESTATUS[*]}"`:e}function Cp(e){let t=0;for(let n=e.length-1;n>=0&&e[n]===`\\`;n--)t+=1;return t%2==0?e:`${e}\\`}function wp(e){if(!e)return[];let t=e.trim().split(/\s+/).filter(Boolean);if(t.length===0)return[];let n=[];for(let e of t){if(!xp.test(e))return[];let t=Number(e);if(t>255)return[];n.push(t)}return n}function Tp(e,t){return t?Sp(e):e}function Ep(e,t){if(!t||!e.env)return e;let n=Op(e.env),r=n.exitCode===void 0?e:{...e,exitCode:n.exitCode};return n.pipeStatus.length===0?r:{...r,pipeStatus:n.pipeStatus}}function Dp(e,t){return t===void 0?e:{...e,pipeStatus:t}}function Op(e){let t=e[yp],n=e[bp];delete e[yp],delete e[bp];let r;if(n!==void 0&&xp.test(n)){let e=Number(n);e<=255&&(r=e)}return{pipeStatus:wp(t),exitCode:r}}function kp(e){return e.length<2||e.every(e=>e===0)||!e.every(e=>Number.isInteger(e)&&e>=0&&e<=255)?null:`pipeline: ${e.join(` `)}`}function Ap(e,t){let n=t?kp(t):null;return n?e?e.endsWith(`
|
|
@@ -279,7 +279,7 @@ Examples:
|
|
|
279
279
|
skill list
|
|
280
280
|
skill info bluebubbles
|
|
281
281
|
skill read bluebubbles
|
|
282
|
-
`,stderr:``,exitCode:0};let r=t[0],i=await import(`./kernel-worker-
|
|
282
|
+
`,stderr:``,exitCode:0};let r=t[0],i=await import(`./kernel-worker-B9c7Iv6C.js`).then(e=>e.r);try{switch(r){case`list`:return _h(t,e,i,n.env.get(`PATH`));case`info`:{let n=t[1];if(!n)return{stdout:``,stderr:`skill: info requires a skill name
|
|
283
283
|
`,exitCode:1};let r=await i.getSkillInfo(e,n);return r?{stdout:hh(r),stderr:``,exitCode:0}:{stdout:``,stderr:`skill: "${n}" not found\n`,exitCode:1}}case`read`:{let n=t[1];if(!n)return{stdout:``,stderr:`skill: read requires a skill name
|
|
284
284
|
`,exitCode:1};let r=await i.readSkillInstructions(e,n);return r===null?{stdout:``,stderr:`skill: no SKILL.md found for "${n}"\n`,exitCode:1}:{stdout:r+`
|
|
285
285
|
`,stderr:``,exitCode:0}}default:return{stdout:``,stderr:`skill: unknown command "${r}"\n`,exitCode:1}}}catch(e){return{stdout:``,stderr:`skill: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}})}const yh=[{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=>Ri(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 bh(e){let t={skills:[],dryRun:!1,json:!1};for(let n=0;n<e.length;n++){let r=e[n],i=yh.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 xh(e,t){return!e||!t||e.byteLength!==t.byteLength?!1:e.every((e,n)=>e===t[n])}async function Sh(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 Ch(e,t,n,r){let i=await Sh(e,t);return wi(n)?i?{status:`kept-local`,write:!1}:{status:`added`,write:!0}:i?xh(i,r)?{status:`unchanged`,write:!1}:{status:`updated`,write:!0}:{status:`added`,write:!0}}async function wh(e,t,n,r){let i={changes:[],writes:[],removals:[]};for(let[r,a]of n){let n=`${t}/${r}`,{status:o,write:s}=await Ch(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 Ti(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 Th(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 Ai(t),d=await Mi(s,c,o.ref,u,!0,l||void 0);if(d&&r.sha===d&&await Eh(e,n,r))return{...o,to:d,outcome:`current`,changes:[]};let f=await Dh(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 wh(e,`${_i}/${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 Mh(e,{changes:h,writes:g,removals:_}),await Ni(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 Eh(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 Dh(e,t,n,r,i,a,o){let s=await Di(e,t,a,i??`main`);if(s.status===`ok`){let i=Si(s.files),a=n||Oh(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:jh(i,a),path:a}}try{return{files:Ah(kh(await Ei(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 Oh(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 kh(e){return new Map([...e].filter(([e])=>Ci(e)))}function Ah(e){return new Map([...e].sort(([e],[t])=>e.localeCompare(t)))}function jh(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);Ci(e)&&r.set(e,i)}return Ah(r)}async function Mh(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 Nh(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 uh(o,s,t);if(!c.ok)return{...a,outcome:`error`,error:c.error};let l=`${_i}/${n}/SKILL.md`,u=await Sh(e,l),d=new TextEncoder().encode(c.content),f=u!==void 0&&ch(new TextDecoder().decode(u))===ch(c.content);if(xh(u,d)||f)return{...a,changes:[{path:`SKILL.md`,status:`unchanged`}]};let p=u?`updated`:`added`;return i||(await e.mkdir(`${_i}/${n}`,{recursive:!0}),await e.writeFile(l,d),await Ni(e,n,{...r,files:[`SKILL.md`]})),{...a,outcome:`updated`,changes:[{path:`SKILL.md`,status:p}]}}function Ph(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 Fh(e,t,n,r){let i=Ri(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 Ih(e,t,n){if(t.length===0){let t=await ji(e);return{targets:t.provenanced,missing:[],skipped:t.unattributed}}let r=[],i=[];for(let a of t){let t=await Pi(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?Fh(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 Lh(e){return e.reason===`not-installed`?`upskill: no skill named "${e.name}" is installed — check \`upskill list\`
|
|
@@ -290,7 +290,7 @@ Examples:
|
|
|
290
290
|
`}function Bh(e,t,n,r,i){let a=t?`Skill update (dry run — nothing written):
|
|
291
291
|
`:`Skill update:
|
|
292
292
|
`;for(let n of e)a+=Ph(n,t);if(i.length>0&&(a+=zh(i)),!n&&r&&e.length>0){let n=i.length>0?`all ${Rh(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 Vh(e,t,n){let{targets:r,missing:i,skipped:a}=await Ih(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 Nh(e,t,i.name,i.provenance,n.dryRun):await Th(e,t,i.name,i.provenance,n.branch,n.dryRun));return{results:o,skipped:a,missing:i}}async function Hh(e,t,n){let r=bh(e);if(r.error)return{stdout:``,stderr:`${r.error}\n`,exitCode:1};let{results:i,missing:a,skipped:o}=await Vh(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`:Bh([],r.dryRun,!1,!0,o),stderr:``,exitCode:0}:{stdout:``,stderr:a.length?a.map(Lh).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 Li();let l=a.map(Lh).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:Bh(i,r.dryRun,c,u,o),stderr:l,exitCode:+!u}}function Uh(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 Wh(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 Gh(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}${Wh(e)}`)}if(t.length>0){let e=t.length===1?`skill`:`skills`;r.push(``,`Skipped ${t.length} ${e} with no install provenance — not checked.`)}let i=e.filter(e=>e.outcome===`error`);if(i.length>0){let e=i.length===1?`skill`:`skills`;r.push(``,`Could not check ${i.length} ${e}:`);for(let e of i)r.push(` ${e.skill}: failed — ${e.error}`)}return`${r.join(`
|
|
293
|
-
`)}\n`}async function Kh(e,t,n){let r=await(await import(`./kernel-worker-
|
|
293
|
+
`)}\n`}async function Kh(e,t,n){let r=await(await import(`./kernel-worker-B9c7Iv6C.js`).then(e=>e.r)).discoverSkills(e),{collisions:i}=await rr(e,er(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${fh()}`,stderr:``,exitCode:0}:{...ir(`upskill`,mh(r,`Discoverable local skills`),i,{builtinNames:new Set(rt())}),exitCode:0}}async function qh(e,t,n){let{results:r,skipped:i}=await Vh(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:Gh(r,i),stderr:c,exitCode:+!s}}async function Jh(e,t,n,r){let i=Uh(e);return i.error?{stdout:``,stderr:`${i.error}\n`,exitCode:1}:i.outdated?qh(t,n,i.json):Kh(t,i.json,r)}async function Yh(e,t){let n=`${vi}/experimental/search?q=${encodeURIComponent(e)}&contentType=skills&page%5Bsize%5D=20`,r;try{r=await t(n,{headers:{Accept:`application/json`}})}catch(e){throw Error(ki(e,n))}if(r.status!==200)throw Error(`Tessl returned HTTP ${r.status}`);let i=_e(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=Ii(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 Xh(e,t){let n=`${vi}/experimental/search?q=${encodeURIComponent(e)}&contentType=skills&page%5Bsize%5D=5`,r;try{r=await t(n,{headers:{Accept:`application/json`}})}catch(e){return{error:`Tessl search failed: ${ki(e,n)}`}}if(r.status!==200)return{error:`Tessl search failed (HTTP ${r.status})`};let i=_e(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=Ii(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 Zh=[{label:`Tessl`,host:new URL(vi).host,fetch:Yh},{label:`browse.sh`,host:new URL(xi).host,fetch:nh}];function Qh(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 $h(e,t,n=1){let r=await Promise.allSettled(Zh.map(n=>n.fetch(e,t))),i=r.map(e=>e.status===`fulfilled`?e.value:[]),a=r.every(e=>e.status===`rejected`),o=Qh(i),s=``;for(let e=0;e<r.length;e++){let t=r[e];if(t.status===`rejected`){let n=Zh[e],r=t.reason instanceof Error?t.reason.message:String(t.reason);s+=`warning: ${n.label} registry unavailable (${n.host}): ${r}\n`}}if(o.length===0){let t=a?`${s}upskill: registries failed to respond\n`:s;return{stdout:`No skills found for "${e}"\n\nTry a different search term or browse the registries at https://tessl.io/registry or https://browse.sh\n`,stderr:t,exitCode:+!!a}}let c=o.length,l=Math.ceil(c/10),u=Math.max(1,Math.min(n,l)),d=(u-1)*10,f=o.slice(d,d+10),p=`Search results for "${e}" (page ${u}/${l}, ${c} total):\n\n`;for(let e of f){let t=e.qualityScore==null?` `:String(e.qualityScore).padStart(3),n=`[${e.source}]`,r=e.sourceRepo?` ${e.sourceRepo}`:``;p+=` ${e.name.padEnd(30)} ${t} ${n.padEnd(10)}${r}\n`,e.summary&&(p+=` ${e.summary}\n`),p+=`
|
|
294
294
|
`}return u<l&&(p+=`Showing ${d+1}-${d+f.length} of ${c}. `,p+=`Next page: upskill search ${e} --page ${u+1}\n\n`),p+=`To install:
|
|
295
295
|
`,p+=` From Tessl: upskill <owner/repo> --skill <name>
|
|
296
296
|
`,p+=` From browse.sh: upskill browse:<hostname>/<task>
|
|
@@ -313,7 +313,7 @@ Examples:
|
|
|
313
313
|
`,{stdout:s,stderr:``,exitCode:0}}function og(e){return!e||e.startsWith(`-`)?{stdout:``,stderr:`upskill: --branch requires a value
|
|
314
314
|
`,exitCode:1}:i(e)?null:{stdout:``,stderr:`upskill: --branch must be a git ref of [A-Za-z0-9._/-]+ with no "..", leading "-"/"/", trailing "/" or ".lock", or shell metacharacters
|
|
315
315
|
`,exitCode:1}}function sg(e){let t={selectedSkills:[],listOnly:!1,installAll:!1,force:!1,sourceRef:``},n=0;for(;n<e.length;){let r=e[n];if(r===`--skill`)t.selectedSkills.push(e[++n]);else if(r===`--path`||r===`-p`){let r=e[++n];if(typeof r!=`string`||!o(r))return t.earlyReturn={stdout:``,stderr:`upskill: --path must be a repo-relative sub-path of [A-Za-z0-9._/-]+ with no "..", leading "-"/"/", or shell metacharacters
|
|
316
|
-
`,exitCode:1},t;t.subPath=r}else if(r===`--list`)t.listOnly=!0;else if(r===`--all`)t.installAll=!0;else if(r===`--force`)t.force=!0;else if(r===`--branch`||r===`-b`){let r=og(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 cg(e,t,n){if(!t)return{stdout:``,stderr:`upskill: ${e} requires a skill name\n`,exitCode:1};let r=await import(`./kernel-worker-
|
|
316
|
+
`,exitCode:1},t;t.subPath=r}else if(r===`--list`)t.listOnly=!0;else if(r===`--all`)t.installAll=!0;else if(r===`--force`)t.force=!0;else if(r===`--branch`||r===`-b`){let r=og(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 cg(e,t,n){if(!t)return{stdout:``,stderr:`upskill: ${e} requires a skill name\n`,exitCode:1};let r=await import(`./kernel-worker-B9c7Iv6C.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 Pi(n,t),a=i?Fi(i):"Installed from: (no provenance recorded — reinstall to enable `upskill update`)\n";return{stdout:hh(e)+a,stderr:``,exitCode:0}}let i=await r.readSkillInstructions(n,t);return i===null?{stdout:``,stderr:`upskill: no SKILL.md found for "${t}"\n`,exitCode:1}:{stdout:i+`
|
|
317
317
|
`,stderr:``,exitCode:0}}async function lg(e,t,n,r,i,a,o,s){let c=``,l=``,u=0,d=e.length;for(let f=0;f<e.length;f++){let p=e[f],m=await Bi(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 ug(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 zi(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 dg(e,t,n,r,i,a,o,s){let c=``,l=``,u=0;for(let d of e){let e=await zi(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 fg(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 pg(e,t,n,r){let{owner:i,repo:a}=e,o=t.branch??e.branch,s=t.subPath??e.path,c=await Ai(r),l=await Vi(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:fg(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:fg(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 Di(i,a,r,o);if(e.status===`ok`){let r=await Mi(i,a,o,c,!0,s),l=await lg(u,i,a,Si(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 ug(u,i,a,c,n,t.force,o,f);({output:p,errors:m,successCount:h}=e)}}else({output:p,errors:m,successCount:h}=await dg(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 Li()),{stdout:p,stderr:m,exitCode:+!!m}}async function mg(e,t,n,r,i){switch(e[0]){case`tabs`:return ig(t,n,r,e.includes(`--json`));case`recommendations`:return ag(t,n,e.includes(`--install`));case`update`:case`upgrade`:return Hh(e.slice(1),t,n);case`list`:return Jh(e.slice(1),t,n,i);case`info`:case`read`:return cg(e[0],e[1],t);case`search`:return gg(e,n);default:return null}}function hg(e,t,n){return S(`upskill`,async(r,i)=>{if(r.length===0||r.includes(`--help`)||r.includes(`-h`))return gh();let a=await mg(r,e,t,n,i.env.get(`PATH`));if(a)return a;let o=sg(r);if(o.earlyReturn)return o.earlyReturn;if(!o.sourceRef)return gh();if(o.sourceRef.startsWith(`tessl:`))return _g(o.sourceRef,o.force,e,t);let s=ah(o.sourceRef);if(s)return dh(s.hostname,s.task,e,t,o.force);let c=Ri(o.sourceRef);return c?pg(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 gg(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?$h(a,t,i):gh()}async function _g(e,t,n,r){let i=e.slice(6);if(!i)return{stdout:``,stderr:`upskill: tessl: requires a skill name
|
|
318
318
|
`,exitCode:1};let a=await Xh(i,r);if(`error`in a)return{stdout:``,stderr:`upskill: ${a.error}\n`,exitCode:1};let o=await Ai(r);return zi(a.owner,a.repo,a.skillPath,a.skillName,n,o,t,r)}function vg(){return{stdout:`usage: afplay [-v volume] [-r rate] <file>
|
|
319
319
|
|
|
@@ -707,7 +707,7 @@ Examples:
|
|
|
707
707
|
`;for(let n of e)t+=` ${n.id} ${n.name.padEnd(20)} ${n.cron.padEnd(15)}`,n.scoop&&(t+=` -> ${n.scoop}`),n.filter&&(t+=` [filtered]`),t+=` (${n.status})`,n.nextRun&&(t+=` next: ${new Date(n.nextRun).toLocaleString()}`),t+=`
|
|
708
708
|
`;return t}async function Oy(e,t){let n=C(e.slice(1),{});if(`error`in n)return Ty(n.error);if(!t()){let e=await vy();if(!e)return xy(`list`);let t=await e.listCronTasks();return t.length===0?{stdout:`No active cron tasks
|
|
709
709
|
`,stderr:``,exitCode:0}:{stdout:Dy(t),stderr:``,exitCode:0}}let{ok:r,data:i}=await Cy(`GET`,``);if(!r)return{stdout:``,stderr:`crontask: failed to list: ${i.error??`unknown error`}\n`,exitCode:1};let a=i;return a.length===0?{stdout:`No active cron tasks
|
|
710
|
-
`,stderr:``,exitCode:0}:{stdout:Dy(a),stderr:``,exitCode:0}}async function ky(e,t){let n=e[0],r=C(e.slice(1),{});if(`error`in r)return Ty(r.error);let i=r.positionals[0];if(!i)return{stdout:``,stderr:`crontask: ${n} requires an ID\n`,exitCode:1};if(!t()){let e=await vy();return e?await e.deleteCronTask(i)?{stdout:`Deleted cron task "${i}"\n`,stderr:``,exitCode:0}:{stdout:``,stderr:`crontask: task "${i}" not found\n`,exitCode:1}:xy(`delete`)}let{ok:a,status:o,data:s}=await Cy(`DELETE`,`/${i}`);return a?{stdout:`Deleted cron task "${i}"\n`,stderr:``,exitCode:0}:o===404?{stdout:``,stderr:`crontask: task "${i}" not found\n`,exitCode:1}:{stdout:``,stderr:`crontask: failed to delete: ${s.error??`unknown error`}\n`,exitCode:1}}function Ay(e={}){let t=e.hasLocalNodeServer??(()=>!1);return S(`crontask`,async(e,n)=>{let r=e[0];if(!r||w(e,{valueFlags:wy}))return Sy();try{switch(r){case`create`:return await Ey(e,n.env,t);case`list`:return await Oy(e,t);case`delete`:case`kill`:return await ky(e,t);default:return{stdout:``,stderr:`crontask: unknown command "${r}"\n`,exitCode:1}}}catch(e){return{stdout:``,stderr:`crontask: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}})}function jy(e){return S(`curlwright`,async(t,n)=>{let{runCurlwright:r}=await import(`./run-
|
|
710
|
+
`,stderr:``,exitCode:0}:{stdout:Dy(a),stderr:``,exitCode:0}}async function ky(e,t){let n=e[0],r=C(e.slice(1),{});if(`error`in r)return Ty(r.error);let i=r.positionals[0];if(!i)return{stdout:``,stderr:`crontask: ${n} requires an ID\n`,exitCode:1};if(!t()){let e=await vy();return e?await e.deleteCronTask(i)?{stdout:`Deleted cron task "${i}"\n`,stderr:``,exitCode:0}:{stdout:``,stderr:`crontask: task "${i}" not found\n`,exitCode:1}:xy(`delete`)}let{ok:a,status:o,data:s}=await Cy(`DELETE`,`/${i}`);return a?{stdout:`Deleted cron task "${i}"\n`,stderr:``,exitCode:0}:o===404?{stdout:``,stderr:`crontask: task "${i}" not found\n`,exitCode:1}:{stdout:``,stderr:`crontask: failed to delete: ${s.error??`unknown error`}\n`,exitCode:1}}function Ay(e={}){let t=e.hasLocalNodeServer??(()=>!1);return S(`crontask`,async(e,n)=>{let r=e[0];if(!r||w(e,{valueFlags:wy}))return Sy();try{switch(r){case`create`:return await Ey(e,n.env,t);case`list`:return await Oy(e,t);case`delete`:case`kill`:return await ky(e,t);default:return{stdout:``,stderr:`crontask: unknown command "${r}"\n`,exitCode:1}}}catch(e){return{stdout:``,stderr:`crontask: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}})}function jy(e){return S(`curlwright`,async(t,n)=>{let{runCurlwright:r}=await import(`./run-B1CbbbHn.js`);return r(e,t,n)})}function My(e,t={}){if(!Number.isFinite(e)||e<0)return``;if(t.si){if(e<1e3)return`${Math.round(e)} B`;let t=[`kB`,`MB`,`GB`,`TB`],n=e/1e3,r=0;for(;n>=1e3&&r<t.length-1;)n/=1e3,r+=1;return`${n<10?n.toFixed(1):Math.round(n)} ${t[r]}`}if(e<1024)return Number.isInteger(e)?`${e} B`:e>=.1?`${e.toFixed(1)} B`:e>0?`${Math.max(.01,Number(e.toFixed(2)))} B`:`0 B`;let n=[`KB`,`MB`,`GB`,`TB`,`PB`],r=e,i=-1;for(;r>=1024&&i<n.length-1;)r/=1024,i+=1;return`${r.toFixed(1)} ${n[i]}`}function Ny(e){return My(e,{si:!1})}const Py=`slicc-fs`;async function Fy(){try{let e=globalThis.indexedDB;if(!e)return!1;let t=e.databases;return typeof t!=`function`||(await t.call(e)).some(e=>e.name===Py)}catch{return!0}}async function Iy(){let e=globalThis.indexedDB;return e?new Promise(t=>{let n;try{n=e.deleteDatabase(Py)}catch{t(`error`);return}n.onsuccess=()=>t(`deleted`),n.onerror=()=>t(`error`),n.onblocked=()=>t(`blocked`)}):`error`}async function Ly(){if(!await Fy())return{kind:`absent`,message:`legacy slicc-fs IDB not present — nothing to clean`};let e=await Iy();return e===`deleted`?{kind:`deleted`,message:`legacy slicc-fs IDB deleted`}:e===`blocked`?{kind:`blocked`,message:`legacy slicc-fs IDB delete blocked by another connection — close other tabs and retry`}:{kind:`error`,message:`legacy slicc-fs IDB delete failed`}}function Ry(){return`slicc-fs-cleanup — delete the legacy slicc-fs IndexedDB
|
|
711
711
|
|
|
712
712
|
Usage:
|
|
713
713
|
slicc-fs-cleanup Delete the legacy slicc-fs IDB.
|
|
@@ -924,7 +924,7 @@ Options:
|
|
|
924
924
|
--pattern <glob> File pattern to match, e.g. "*.md", "*.bsh" (required)
|
|
925
925
|
--scoop <target> Scoop name, cone name, or folder. Omit for your own cone.
|
|
926
926
|
--name <name> Human-readable name for the watcher
|
|
927
|
-
`);switch(n){case`list`:return WS(e);case`delete`:return GS(e);case`create`:return await JS(e,t.env);default:return HS(`unknown command: ${n}`)}})}function XS(e){return S(`gelatiere`,async(t,n)=>{let{runGelatiere:r}=await import(`./run-
|
|
927
|
+
`);switch(n){case`list`:return WS(e);case`delete`:return GS(e);case`create`:return await JS(e,t.env);default:return HS(`unknown command: ${n}`)}})}function XS(e){return S(`gelatiere`,async(t,n)=>{let{runGelatiere:r}=await import(`./run-yvQfuwPq.js`);return r(t,n,e)})}function ZS(){return{stdout:`usage: hear [-i file] [-l lang] [-T seconds] [-d deviceId] [--engine name]
|
|
928
928
|
hear --devices | --status | --warmup
|
|
929
929
|
|
|
930
930
|
Speech recognition: listens on the microphone until you pause, then
|
|
@@ -1209,7 +1209,7 @@ Options:
|
|
|
1209
1209
|
`,stderr:``,exitCode:0}}let a=e.routes.get(r.targetId)??[],o=a.length,s=a.filter(e=>e.pattern!==i);if(e.routes.set(r.targetId,s),s.length===0){let t=e.routeCleanup.get(r.targetId);t&&(t(),e.routeCleanup.delete(r.targetId))}return{stdout:`Removed ${o-s.length} route(s) matching "${i}"\n`,stderr:``,exitCode:0}},CT=`/.playwright`;function wT(e,t){return e?`${t.replace(/\/+$/,``)}${CT}`:CT}async function TT(e,t,n){if(!t.sessionDirsCreated.has(n)){for(let t of[n,`${n}/snapshots`,`${n}/screenshots`])try{await e.mkdir(t,{recursive:!0})}catch(e){if(!jn(e))throw e}t.sessionDirsCreated.add(n)}}async function ET(e,t,n,r,i){try{return await e.withTab(n,async e=>{let{url:a,title:o,text:s,refToSelector:c,refToBackendNodeId:l,refToFrameId:u}=await se(e),d={url:a,title:o,refToSelector:c,refToBackendNodeId:l,refToFrameId:u,content:s,timestamp:Date.now()};r.snapshots.set(n,d);let f=[`Page URL: ${a}`,`Page Title: ${o}`,``,s].join(`
|
|
1210
1210
|
`),p=`${i}/snapshots/page-${kn(new Date)}.yml`;return await t.writeFile(p,f),p})}catch{return null}}async function DT(e,t,n,r){await TT(e,t,n);let i=new Date().toISOString(),a=`playwright-cli ${r.command}${r.args.length?` `+r.args.join(` `):``}`,o=r.result.exitCode===0?r.result.stdout.trim()||`OK`:`Error: ${r.result.stderr.trim()}`,s=[`### ${a}`,`- **Time**: ${i}`];if(r.tabUrl||r.targetId){let e=r.tabUrl?`${r.tabUrl}${r.targetId?` (targetId: ${r.targetId})`:``}`:`targetId: ${r.targetId}`;s.push(`- **Tab**: ${e}`)}s.push(`- **Result**: ${o}`),r.snapshotPath&&s.push(``,`[Snapshot](${r.snapshotPath})`),s.push(`---`,``);let c=s.join(`
|
|
1211
1211
|
`)+`
|
|
1212
|
-
`,l=`${n}/session.md`,u=``;try{let t=await e.readFile(l);u=typeof t==`string`?t:new TextDecoder().decode(t)}catch{}await e.writeFile(l,u+c)}function OT(){return import(`./snapshot-features-
|
|
1212
|
+
`,l=`${n}/session.md`,u=``;try{let t=await e.readFile(l);u=typeof t==`string`?t:new TextDecoder().decode(t)}catch{}await e.writeFile(l,u+c)}function OT(){return import(`./snapshot-features-BGJFBLV3.js`)}async function kT(e,t,n,r){let i=await e.getAccessibilityTreeForFrame(r.frameId),a=new Map,o=new Map,s=new Map,c=oe(i,a,o,{value:0},``,`f1`);for(let e of a.keys())s.set(e,r.frameId);let l=c.join(`
|
|
1213
1213
|
`);return t.snapshots.set(n,{url:r.url,title:r.name,refToSelector:a,refToBackendNodeId:o,refToFrameId:s,content:l,timestamp:Date.now()}),l}async function AT(e,t){await e.send(`DOM.enable`),await e.send(`Runtime.enable`);let n=(await e.send(`DOM.resolveNode`,{backendNodeId:t})).object;if(n?.objectId)return(await e.send(`Runtime.callFunctionOn`,{objectId:n.objectId,functionDeclaration:`function() {
|
|
1214
1214
|
this.scrollIntoView({ block: 'center' });
|
|
1215
1215
|
const r = this.getBoundingClientRect();
|
|
@@ -1287,7 +1287,7 @@ Options:
|
|
|
1287
1287
|
el.dispatchEvent(new Event('input', { bubbles: true }));
|
|
1288
1288
|
return el.files.length;
|
|
1289
1289
|
})()`,r=await t.send(`Runtime.evaluate`,{expression:n,returnByValue:!0,awaitPromise:!1},e);if(r.exceptionDetails){let e=r.exceptionDetails.exception?.description??r.exceptionDetails.text??`File upload failed`;throw Error(e)}});let p=d.map(e=>e.split(`/`).pop()??e).join(`, `);return{stdout:`Uploaded ${d.length} file(s): ${p}\n`,stderr:``,exitCode:0}}],[`state-save`,VT],[`state-load`,HT],[`console`,yC],[`requests`,sT],[`request`,cT],[`request-headers`,lT],[`request-body`,uT],[`response-headers`,dT],[`response-body`,fT],[`mousemove`,dw],[`mousedown`,fw],[`mouseup`,pw],[`mousewheel`,mw],[`drop`,hw],[`route`,bT],[`route-list`,xT],[`unroute`,ST],[`generate-locator`,kC],[`highlight`,AC]]);function dE(){let e=(Pn.string??[]).map(e=>`--${e}`),t=new Set(Pn.boolean??[]);for(let[e,n]of Object.entries(Pn.alias??{})){let r=[e,...Array.isArray(n)?n:[n]];if(r.some(e=>t.has(e)))for(let e of r)t.add(e)}return{value:e,bool:[...[...t].map(e=>`--${e}`),`--help`,`-h`,`--no-iframes`]}}function fE(e){return e.map(e=>e===`--no-iframes`||e.startsWith(`--no-iframes=`)?e.replace(`--no-iframes`,`--_noiframes`):e)}function pE(e){return{...e,bool:[...e.bool??[],`--_noiframes`],value:[...e.value??[],`--_noiframes`]}}const mE=2e3;function hE(e,t){if(typeof e.getTabLockStats!=`function`)return;let n=e.getTabLockStats();return t?{totalWaitMs:n.totalWaitMs,tabWaitMs:e.getTabLockStats(t).tabWaitMs}:{totalWaitMs:n.totalWaitMs}}function gE(e,t,n,r){if(!t||typeof e.getTabLockStats!=`function`)return r;let i=e.getTabLockStats(),a=i.totalWaitMs-t.totalWaitMs;if(a<mE)return r;let o=(a/1e3).toFixed(1),s=n&&t.tabWaitMs!==void 0?e.getTabLockStats(n).tabWaitMs-t.tabWaitMs:0,c=`note: browser bridge contended — lock waits totaled ${o}s while this command ran, ${s>=mE?`${(s/1e3).toFixed(1)}s of it waiting on this tab (--tab=${n})`:`all of it waiting on the bridge, not on this tab`} (queue depth ${i.queueDepth}). Commands on the same tab serialize; commands on different tabs run in parallel — stagger callers on THIS tab, or give each caller its own tab.
|
|
1290
|
-
`;return{...r,stderr:r.stderr+c}}async function _E(e,t,n){let r=n instanceof Error?n.message:String(n);return{stdout:``,stderr:`Error: ${(t.tab?await Fn(e,t.tab,n):null)??r}\n`,exitCode:1}}function vE(e,t,n){return{stdout:``,stderr:`${e} ${t}: ${n===void 0?`aborted: the caller stopped waiting for it`:n instanceof Error?n.message:String(n)}\n`,exitCode:130}}async function yE(e,t,n){let r=uE.get(t);if(!r)return{stdout:``,stderr:`Unknown command: ${t}\nRun "playwright-cli help" for usage.\n`,exitCode:1};let{signal:i}=n;try{let a=await r(n);return i?.aborted?vE(e,t,void 0):a}catch(r){return i?.aborted?vE(e,t,r):await _E(n.browser,n.flags,r)}}async function bE(e,t,n,r){let i=C(fE(n),pE(r));if(`error`in i)return{answer:{stdout:``,stderr:`${e} ${t}: ${i.error}\n`,exitCode:1}};let a;try{({flags:a}=Nn(n))}catch(n){return{answer:{stdout:``,stderr:`${e} ${t}: ${n instanceof Error?n.message:String(n)}\n`,exitCode:1}}}if(a.help===`true`||a.h===`true`){let{formatSubcommandHelp:n}=await import(`./help-
|
|
1290
|
+
`;return{...r,stderr:r.stderr+c}}async function _E(e,t,n){let r=n instanceof Error?n.message:String(n);return{stdout:``,stderr:`Error: ${(t.tab?await Fn(e,t.tab,n):null)??r}\n`,exitCode:1}}function vE(e,t,n){return{stdout:``,stderr:`${e} ${t}: ${n===void 0?`aborted: the caller stopped waiting for it`:n instanceof Error?n.message:String(n)}\n`,exitCode:130}}async function yE(e,t,n){let r=uE.get(t);if(!r)return{stdout:``,stderr:`Unknown command: ${t}\nRun "playwright-cli help" for usage.\n`,exitCode:1};let{signal:i}=n;try{let a=await r(n);return i?.aborted?vE(e,t,void 0):a}catch(r){return i?.aborted?vE(e,t,r):await _E(n.browser,n.flags,r)}}async function bE(e,t,n,r){let i=C(fE(n),pE(r));if(`error`in i)return{answer:{stdout:``,stderr:`${e} ${t}: ${i.error}\n`,exitCode:1}};let a;try{({flags:a}=Nn(n))}catch(n){return{answer:{stdout:``,stderr:`${e} ${t}: ${n instanceof Error?n.message:String(n)}\n`,exitCode:1}}}if(a.help===`true`||a.h===`true`){let{formatSubcommandHelp:n}=await import(`./help-BYCrQyQm.js`);return{answer:{stdout:n(e,t),stderr:``,exitCode:0}}}let o=null;try{let{validateSubcommandArgs:r}=await import(`./validate-args-BcxRh84E.js`);o=r(e,t,n,i.positionals)}catch{o=null}return o?{answer:{stdout:``,stderr:o,exitCode:1}}:{positional:i.positionals,flags:a}}function xE(e,t,n,r={}){let i=t?An(t,n):null,a=dE();return S(e,async(o,s)=>{if(o.length===0||o[0]===`help`||o[0]===`--help`||o[0]===`-h`){let{formatHelp:t}=await import(`./help-BYCrQyQm.js`);return{stdout:t(e)+`
|
|
1291
1291
|
`,stderr:``,exitCode:0}}let c=o[0],l=o.slice(1),u=await bE(e,c,l,a);if(`answer`in u)return u.answer;let{positional:d,flags:f}=u;if(!t||!i)return{stdout:``,stderr:`${e}: browser APIs are unavailable in this environment\n`,exitCode:1};let p=f.tab??null,m=hE(t,p),h=Xi(s.env),g=wT(r.isScoop?.()??!1,h),_=await yE(e,c,{browser:t,fs:n,state:i,positional:d,flags:f,scratchDir:h,sessionRoot:g,onTab:(e,n)=>t.withTab(e,n,{signal:s.signal}),signal:s.signal}),v=f.tab??null,ee=null;Vn.has(c)&&_.exitCode===0&&v&&(ee=await ET(t,n,v,i,g));try{await DT(n,i,g,{command:c,args:l,result:_,snapshotPath:ee,targetId:v})}catch{}return gE(t,m,p,_)})}const SE=new Map([[`File operations`,[`ls`,`cat`,`head`,`tail`,`wc`,`touch`,`mkdir`,`rm`,`cp`,`mv`,`ln`,`chmod`,`stat`,`readlink`,`file`,`rmdir`,`rsync`]],[`Text processing`,[`grep`,`sed`,`awk`,`sort`,`uniq`,`cut`,`tr`,`tee`,`diff`,`patch`,`column`,`comm`,`egrep`,`fgrep`,`expand`,`unexpand`,`fold`,`join`,`nl`,`od`,`paste`,`rev`,`split`,`strings`,`tac`]],[`Search`,[`find`,`rg`]],[`Navigation & paths`,[`pwd`,`basename`,`dirname`,`tree`,`du`,`cd`]],[`Archives`,[`zip`,`unzip`,`pdftk`,`pdf`,`gunzip`,`gzip`,`zcat`]],[`Media`,[`convert`,`magick`,`pdftoppm`,`pdftocairo`,`pdftotext`,`ffmpeg`,`ffprobe`,`screencapture`]],[`Audio`,[`say`,`hear`,`afplay`,`chime`]],[`Environment & shell`,`echo.printf.env.printenv.export.alias.unalias.history.clear.true.false.bash.sh.commands.which.uname.man.host.oauth-token.secret.nuke.models.local-llm.cost.hostname.whoami.id.help.sleep.time.timeout.oauth-domain`.split(`.`)],[`Data processing`,[`xargs`,`jq`,`base64`,`date`,`expr`,`seq`]],[`Hashes`,[`md5sum`,`sha1sum`,`sha256sum`]],[`Network`,[`curl`,`curlwright`,`wget`,`dig`,`websocat`,`html-to-markdown`]],[`Version control`,[`git`]],[`Languages`,[`node`,`jsh`,`python`,`python3`,`sqlite3`]],[`Virtualization`,[`v86`,`computer`]],[`Build tools`,[`tsc`,`tst`,`esbuild`,`biome`]],[`Packages`,[`ipk`,`hf`,`npm`,`i`,`ipx`,`npx`]],[`Skills`,[`skill`,`upskill`]],[`Browser & UI`,[`serve`,`open`,`imgcat`,...zn,`sprinkle`]],[`Clipboard`,[`pbcopy`,`pbpaste`,`xclip`,`xsel`]],[`Filesystem`,[`mount`,`umount`,`fswatch`]],[`Scoops & agents`,[`agent`,`gelatiere`,`mcp`,`webhook`,`crontask`]],[`Process`,[`ps`,`kill`,`jshd`,`meminfo`,`uptime`]],[`Shell builtins (limited)`,[...r_]]]);function CE(e,t=[],n=[]){let r=[],i=new Set(e);for(let e of t)i.delete(e);for(let e of n)i.delete(e);r.push(`Available commands:
|
|
1292
1292
|
`);let a=[];for(let[e,t]of SE){let n=t.filter(e=>i.has(e));if(n.length>0){r.push(` ${e}:`),r.push(` ${n.join(`, `)}\n`);for(let e of n)i.delete(e)}}for(let e of i)a.push(e);return a.length>0&&(r.push(` Other:`),r.push(` ${a.sort().join(`, `)}\n`)),t.length>0&&(r.push(` User scripts (.jsh):`),r.push(` ${t.sort().join(`, `)}\n`)),n.length>0&&(r.push(` Workflows:`),r.push(` ${n.sort().join(`, `)}\n`)),r.push(`Use '<command> --help' for details on a specific command.`),r.join(`
|
|
1293
1293
|
`)+`
|
|
@@ -1467,7 +1467,7 @@ manifest without rewriting it. With -g, packages go to /shared/lib/node_modules
|
|
|
1467
1467
|
and deps are recorded in /shared/lib/package.json. Existing fields are
|
|
1468
1468
|
preserved. Idempotent: re-installing an already-satisfied package is a clean
|
|
1469
1469
|
no-op.
|
|
1470
|
-
`}function pO(e){let t=C(e,{bool:dO,value:[`--location`]});if(`error`in t)return t;let n=t.values.get(`--location`);return n!==void 0&&n!==`global`?{error:`unknown flag: --location=${n}`}:{global:t.bools.has(`-g`)||t.bools.has(`--global`)||n===`global`,saveDev:t.bools.has(`-D`)||t.bools.has(`--save-dev`),specs:t.positionals}}function mO(e){let t=!1,n=[];for(let r of e){if(uO.has(r)){t=!0;continue}r.startsWith(`-`)||n.push(r)}return{global:t,specs:n}}function hO(e){return w(e)}function gO(e){return e instanceof Error?e.message:String(e)}async function _O(e){e.scriptCatalog?.invalidateJsh(),await e.syncScriptCommands?.()}function vO(e,t){let n=e===`i`;return S(e,async(r,i)=>{if(n)return hO(r)?{stdout:fO(e),stderr:``,exitCode:0}:bO(e,r,i,t);if(r[0]===`mamba`){let{runIpkMamba:n}=await import(`./ipk-mamba-
|
|
1470
|
+
`}function pO(e){let t=C(e,{bool:dO,value:[`--location`]});if(`error`in t)return t;let n=t.values.get(`--location`);return n!==void 0&&n!==`global`?{error:`unknown flag: --location=${n}`}:{global:t.bools.has(`-g`)||t.bools.has(`--global`)||n===`global`,saveDev:t.bools.has(`-D`)||t.bools.has(`--save-dev`),specs:t.positionals}}function mO(e){let t=!1,n=[];for(let r of e){if(uO.has(r)){t=!0;continue}r.startsWith(`-`)||n.push(r)}return{global:t,specs:n}}function hO(e){return w(e)}function gO(e){return e instanceof Error?e.message:String(e)}async function _O(e){e.scriptCatalog?.invalidateJsh(),await e.syncScriptCommands?.()}function vO(e,t){let n=e===`i`;return S(e,async(r,i)=>{if(n)return hO(r)?{stdout:fO(e),stderr:``,exitCode:0}:bO(e,r,i,t);if(r[0]===`mamba`){let{runIpkMamba:n}=await import(`./ipk-mamba-13yN29Fi.js`);return n(e,r.slice(1),i,t)}if(hO(r))return{stdout:fO(e),stderr:``,exitCode:0};if(r.length===0)return{stdout:fO(e),stderr:`${e}: missing subcommand\n`,exitCode:1};let a=r[0],o=r.slice(1);return sO.has(a)?bO(e,o,i,t):cO.has(a)?SO(e,o,i,t):lO.has(a)?CO(e,o,i,t):a===`root`?wO(e,o,i,t):AD.has(a)?oO(e,o,i,{fs:t.fs}):jD.has(a)?oO(e,r,i,{fs:t.fs}):{stdout:``,stderr:`${e}: unknown subcommand '${a}' (supported: install, uninstall, list, root, run, mamba)\n`,exitCode:1}})}async function yO(e,t,n){let r;try{r=await ta({fs:n.fs,fetch:n.fetch,cwd:t.cwd})}catch(t){return t instanceof ia?{stdout:``,stderr:`${e}: ${t.message}\n`,exitCode:1}:{stdout:``,stderr:`${e}: install failed: ${gO(t)}\n`,exitCode:1}}if(r.empty&&r.errors.length===0)return{stdout:`${e}: nothing to install (package.json declares no dependencies)\n`,stderr:``,exitCode:0};let i=r.results.map(t=>`${e}: installed ${t.name}@${t.version} -> ${t.installPath}`),a=r.errors.map(t=>`${e}: failed to install ${t.spec}: ${gO(t.error)}`);return{stdout:i.length>0?`${i.join(`
|
|
1471
1471
|
`)}\n`:``,stderr:a.length>0?`${a.join(`
|
|
1472
1472
|
`)}\n`:``,exitCode:r.errors.length===0?0:1}}async function bO(e,t,n,r){let i=pO(t);if(`error`in i)return{stdout:``,stderr:`${e}: ${i.error}\n`,exitCode:1};let{global:a,saveDev:o,specs:s}=i;if(a&&s.length===0)return{stdout:``,stderr:`${e}: global install requires at least one package name\n`,exitCode:1};if(s.length===0)return yO(e,n,r);let c;try{c=await ra(s,{fs:r.fs,fetch:r.fetch,cwd:n.cwd,global:a,saveDev:o})}catch(t){return{stdout:``,stderr:`${e}: install failed: ${gO(t)}\n`,exitCode:1}}let l=c.results.map(t=>`${e}: installed ${t.name}@${t.version} -> ${t.installPath}`),u=c.errors.map(t=>`${e}: failed to install ${t.spec}: ${gO(t.error)}`);return a&&c.results.length>0&&await _O(r),{stdout:l.length>0?`${l.join(`
|
|
1473
1473
|
`)}\n`:``,stderr:u.length>0?`${u.join(`
|
|
@@ -1489,7 +1489,7 @@ Options:
|
|
|
1489
1489
|
--global Resolve only from the shared global prefix (/shared/lib/node_modules)
|
|
1490
1490
|
-h, --help Show this help message
|
|
1491
1491
|
`}async function KO(e,t){let n=await e.readFile(t);return typeof n==`string`?n:new TextDecoder().decode(n)}async function qO(e,t){try{return(await e.stat(t)).type===`file`}catch{return!1}}async function JO(e,t){try{return(await e.stat(t)).type===`directory`}catch{return!1}}function*YO(e,t=!1){if(t){yield Qn;return}let n=b(e);for(;yield x(n,`node_modules`),n!==`/`;)n=Me(n).dir;yield Qn}async function XO(e,t,n,r=!1){for(let i of YO(t,r)){let t=x(i,`.bin`,n);if(!await qO(e,t))continue;let r=await KO(e,t),a=WO.exec(r),o=Me(t).dir;return{binFilePath:a?x(o,a[1]):t,argvName:t}}return null}function ZO(e){if(e.startsWith(`@`)){let t=e.indexOf(`/`);if(t!==-1)return e.slice(t+1)}return e}function QO(e,t){if(typeof e==`string`)return{binName:ZO(t),binPath:e};if(typeof e!=`object`||!e)return null;let n=[t,ZO(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 $O(e,t,n,r=!1){for(let i of YO(t,r)){let t=x(i,n),r=x(t,`package.json`);if(!await qO(e,r))continue;let a;try{a=JSON.parse(await KO(e,r))}catch{return null}let o=QO(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 ek(e,t,n,r=!1){return await XO(e,t,n,r)??await $O(e,t,n,r)}async function tk(e,t,n){for(let r of YO(t))if(await qO(e,x(r,n,`package.json`)))return!0;return!1}function nk(e){return e instanceof Error?e.message:String(e)}function rk(e,t){return{stdout:``,stderr:`${e}: ${t}\n`,exitCode:1}}async function ik(e,t,n,r){try{let i=await ra([t],{fs:r.fs,fetch:r.fetch,cwd:n.cwd});if(i.errors.length>0)return{error:rk(e,`failed to install '${t}': ${nk(i.errors[0].error)}`)};let a=i.results.map(t=>`${e}: installed ${t.name}@${t.version}`);return{progress:a.length>0?`${a.join(`
|
|
1492
|
-
`)}\n`:``}}catch(n){return{error:rk(e,`failed to install '${t}': ${nk(n)}`)}}}async function ak(e,t,n,r){return await qO(r,n)?null:await JO(r,n)?rk(e,`bin target '${n}' is a directory, not a file`):rk(e,`bin file '${n}' for '${t}' does not exist`)}async function ok(e,t,n,r,i,a){if(await tk(a.fs,i.cwd,t))return{error:rk(e,`package '${t}' does not expose an executable bin`)};let o=r?void 0:VO(t);if(o)return{error:{stdout:``,stderr:UO(e,t,n,o),exitCode:1}};let s=await ik(e,t,i,a);if(`error`in s)return s;let c=await ek(a.fs,i.cwd,t);return c?{resolved:c,installProgress:s.progress}:{error:rk(e,`package '${t}' was installed but does not expose an executable bin`)}}function sk(e,t){return{name:e,trusted:!0,async execute(n,r){if(n.length===0||n[0]===`--help`||n[0]===`-h`)return{stdout:GO(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:GO(e),stderr:``,exitCode:1};let c=s[0],l=s.slice(1),u;try{u=await ek(t.fs,r.cwd,c,o)}catch(t){return rk(e,nk(t))}let d=``;if(!u){if(o)return rk(e,`no global bin '${c}' found in ${Qn}`);let n=await ok(e,c,l,i,r,t);if(`error`in n)return n.error;u=n.resolved,d=n.installProgress}let f=await ak(e,c,u.binFilePath,t.fs);if(f)return f;let p=ti(await KO(t.fs,u.binFilePath)),m=[`node`,u.argvName,...l],h=await $r(p,m,r,void 0,{filename:u.binFilePath});return{stdout:h.stdout,stderr:d+h.stderr,exitCode:h.exitCode}}}}function ck(e={}){return S(`jshd`,async(t,n)=>{let{runJshd:r}=await import(`./run-
|
|
1492
|
+
`)}\n`:``}}catch(n){return{error:rk(e,`failed to install '${t}': ${nk(n)}`)}}}async function ak(e,t,n,r){return await qO(r,n)?null:await JO(r,n)?rk(e,`bin target '${n}' is a directory, not a file`):rk(e,`bin file '${n}' for '${t}' does not exist`)}async function ok(e,t,n,r,i,a){if(await tk(a.fs,i.cwd,t))return{error:rk(e,`package '${t}' does not expose an executable bin`)};let o=r?void 0:VO(t);if(o)return{error:{stdout:``,stderr:UO(e,t,n,o),exitCode:1}};let s=await ik(e,t,i,a);if(`error`in s)return s;let c=await ek(a.fs,i.cwd,t);return c?{resolved:c,installProgress:s.progress}:{error:rk(e,`package '${t}' was installed but does not expose an executable bin`)}}function sk(e,t){return{name:e,trusted:!0,async execute(n,r){if(n.length===0||n[0]===`--help`||n[0]===`-h`)return{stdout:GO(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:GO(e),stderr:``,exitCode:1};let c=s[0],l=s.slice(1),u;try{u=await ek(t.fs,r.cwd,c,o)}catch(t){return rk(e,nk(t))}let d=``;if(!u){if(o)return rk(e,`no global bin '${c}' found in ${Qn}`);let n=await ok(e,c,l,i,r,t);if(`error`in n)return n.error;u=n.resolved,d=n.installProgress}let f=await ak(e,c,u.binFilePath,t.fs);if(f)return f;let p=ti(await KO(t.fs,u.binFilePath)),m=[`node`,u.argvName,...l],h=await $r(p,m,r,void 0,{filename:u.binFilePath});return{stdout:h.stdout,stderr:d+h.stderr,exitCode:h.exitCode}}}}function ck(e={}){return S(`jshd`,async(t,n)=>{let{runJshd:r}=await import(`./run-D3Yam1R4.js`);return r(t,n,e)})}const lk=new Set([`SIGINT`,`SIGTERM`,`SIGKILL`,`SIGSTOP`,`SIGCONT`]);function uk(e={}){return S(`kill`,async t=>{if(t.length===0||t.includes(`--help`)||t.includes(`-h`))return gk();let n=e.processManager??dk();if(!n)return{stdout:``,stderr:`kill: no process manager available in this runtime
|
|
1493
1493
|
`,exitCode:1};let r=fk(t);if(!r.ok)return{stdout:``,stderr:r.stderr,exitCode:r.exitCode};let{allDelivered:i,errors:a}=pk(n,r.pids,r.signal);return{stdout:``,stderr:a.length?`${a.join(`
|
|
1494
1494
|
`)}\n`:``,exitCode:+!i}})}function dk(){let e=globalThis.__slicc_pm;return e instanceof Object&&typeof e.signal==`function`?e:null}function fk(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
|
|
1495
1495
|
`,exitCode:2};let i=mk(n);if(i instanceof Error)return{ok:!1,stderr:`kill: ${i.message}\n`,exitCode:2};t=i;continue}if(i.startsWith(`-`)){let e=hk(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
|
|
@@ -1562,7 +1562,7 @@ Common base URLs:
|
|
|
1562
1562
|
`)+`
|
|
1563
1563
|
`,stderr:``,exitCode:0}}function Uk(e,t){let n=t.models.length;return{stdout:[`✓ ${e} (${zk(t.runtime,!1)})`,` Saved ${n} model${n===1?``:`s`} to Settings:`,...Bk(t.models)].join(`
|
|
1564
1564
|
`)+`
|
|
1565
|
-
`,stderr:``,exitCode:0}}function Wk(){return S(Lk,async e=>{if(e.includes(`--help`)||e.includes(`-h`))return{stdout:Rk(),stderr:``,exitCode:0};let{getApiKeyForProvider:t,getRawApiKeyForProvider:n,getBaseUrlForProvider:r,addAccount:i}=await import(`./account-store-
|
|
1565
|
+
`,stderr:``,exitCode:0}}function Wk(){return S(Lk,async e=>{if(e.includes(`--help`)||e.includes(`-h`))return{stdout:Rk(),stderr:``,exitCode:0};let{getApiKeyForProvider:t,getRawApiKeyForProvider:n,getBaseUrlForProvider:r,addAccount:i}=await import(`./account-store-DgfR_tf2.js`).then(e=>e.t),{verifyConnection:a}=await import(`./local-llm-D0k2uDUi.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(Lk);if(!s)return{stdout:``,stderr:`Local LLM is not configured. Open Settings → Providers → Local LLM and set a base URL.
|
|
1566
1566
|
`,exitCode:1};let c=await a(s,t(Lk)??void 0);if(!c.ok)return Vk(s,c);if(o===`discover`){let e=n(Lk)??``;return i(Lk,e,s,c.models.join(`, `)),Uk(s,c)}return Hk(s,c)})}function Gk(){return{stdout:`usage: man <topic>
|
|
1567
1567
|
|
|
1568
1568
|
Fetches documentation for a given topic from sliccy.com.
|
|
@@ -1600,20 +1600,20 @@ authorization-code flow, stores the access token, and retries.
|
|
|
1600
1600
|
On success, the server is persisted to /workspace/.mcp/servers.json and
|
|
1601
1601
|
an alias shim is written to /workspace/.mcp/aliases/<name>.jsh so the
|
|
1602
1602
|
short name resolves on the PATH.
|
|
1603
|
-
`);let n=C(e,{});if(`error`in n)return Zk(n.error);if(n.positionals.length<2)return G(`mcp add: expected <url> <name>`);let[r,i]=n.positionals;if(!/^https?:\/\//i.test(r))return G(`mcp add: invalid URL "${r}" (must start with http:// or https://)`);if(!/^[A-Za-z][A-Za-z0-9_-]*$/.test(i))return G(`mcp add: invalid name "${i}" (letters, digits, _ and - only; must start with a letter)`);let{getServer:a,setServer:o}=await import(`./store-
|
|
1603
|
+
`);let n=C(e,{});if(`error`in n)return Zk(n.error);if(n.positionals.length<2)return G(`mcp add: expected <url> <name>`);let[r,i]=n.positionals;if(!/^https?:\/\//i.test(r))return G(`mcp add: invalid URL "${r}" (must start with http:// or https://)`);if(!/^[A-Za-z][A-Za-z0-9_-]*$/.test(i))return G(`mcp add: invalid name "${i}" (letters, digits, _ and - only; must start with a letter)`);let{getServer:a,setServer:o}=await import(`./store-BXNUAqDB.js`).then(e=>e.r);if(await a(i,t.fs))return G(`mcp add: a server named "${i}" already exists`);let{McpClient:s,McpAuthRequiredError:c}=await import(`./client-CwxmlQM-.js`).then(e=>e.n),l=new s({url:r,fetchImpl:t.fetchImpl}),u;try{await l.initialize()}catch(e){if(!(e instanceof c))throw e;u=await tA(r,i,e.resourceMetadataUrl,t),l=new s({url:r,fetchImpl:t.fetchImpl,getAuthHeader:()=>AA(i)}),await l.initialize()}let d=await l.toolsList(),f=await l.appsList(),p=new Date().toISOString();await o(i,{url:r,protocolVersion:l.getNegotiatedProtocolVersion(),tools:d,apps:f,addedAt:p,lastRefreshedAt:p,...u?{auth:u}:{}},t.fs),await FA(i,t);let m=await RA(i,f,t);if(u){let{registerMcpProvider:e}=await import(`./provider-CCQRZg4A.js`);e({name:i,serverUrl:r,auth:u})}return W([`Added MCP server "${i}" → ${r}`,` tools: ${d.length}, apps: ${f.length} (${m} sprinkle${m===1?``:`s`})`,` alias: ${Xk}/${i}.jsh`,u?` auth: oauth (provider mcp:${i})`:` auth: none`].join(`
|
|
1604
1604
|
`)+`
|
|
1605
|
-
`)}async function tA(e,t,n,r){let{discoverAuth:i,dynamicRegister:a,runAuthFlow:o}=await import(`./oauth-D20BEoY6.js`),{saveOAuthAccount:s}=await import(`./account-store-
|
|
1606
|
-
`);let n=C(e,{});if(`error`in n)return Zk(n.error);let{ensureAllMcpProvidersRegistered:r}=await import(`./provider-
|
|
1605
|
+
`)}async function tA(e,t,n,r){let{discoverAuth:i,dynamicRegister:a,runAuthFlow:o}=await import(`./oauth-D20BEoY6.js`),{saveOAuthAccount:s}=await import(`./account-store-DgfR_tf2.js`).then(e=>e.t),c=await MA(r.oauthFetchImpl),l=r.oauthLauncher??await jA(),u=await i(e,n,c);Yk.debug(`MCP OAuth discovery succeeded`,{name:t,serverUrl:e,discoveryPath:u.discoveryPath,issuer:u.issuer});let d=await fa(Ce()),f=await a(u,d,c),p=u.supportedScopes&&u.supportedScopes.length>0?u.supportedScopes.join(` `):void 0,m=await o({asMetadata:u,clientId:f.clientId,scope:p,redirectUri:d,launcher:l,fetchImpl:c}),h=`mcp:${t}`;return await s({providerId:h,accessToken:m.accessToken,refreshToken:m.refreshToken,tokenExpiresAt:m.expiresAt,scopes:m.scope}),{providerId:h,authorizationServer:u.issuer,clientId:f.clientId,redirectUri:d,scope:m.scope??p,registrationClientUri:f.registrationClientUri}}async function nA(e,t){if(w(e))return W(`usage: mcp list
|
|
1606
|
+
`);let n=C(e,{});if(`error`in n)return Zk(n.error);let{ensureAllMcpProvidersRegistered:r}=await import(`./provider-CCQRZg4A.js`);await r();let{listServers:i}=await import(`./store-BXNUAqDB.js`).then(e=>e.r),a=await i(t.fs),o=Object.keys(a).sort();if(o.length===0)return W("No MCP servers configured. Use `mcp add <url> <name>`.\n");let s=[[`NAME`,`URL`,`AUTH`,`TOOLS`,`APPS`,`ADDED`]];for(let e of o){let t=a[e];s.push([e,t.url,t.auth?`yes`:`no`,String(t.tools?.length??0),String(t.apps?.length??0),t.addedAt?t.addedAt.slice(0,10):`-`])}return W(rA(s))}function rA(e){let t=e[0].map((t,n)=>e.reduce((e,t)=>Math.max(e,(t[n]??``).length),0));return e.map(e=>e.map((e,n)=>e.padEnd(t[n])).join(` `).trimEnd()).join(`
|
|
1607
1607
|
`)+`
|
|
1608
1608
|
`}async function iA(e,t){if(w(e))return W(`usage: mcp search <query>
|
|
1609
1609
|
|
|
1610
1610
|
Case-insensitive substring search across the cached tools of every
|
|
1611
1611
|
registered MCP server. Matches tool name OR description and prints a
|
|
1612
1612
|
table of (server, tool, description, match-field) rows.
|
|
1613
|
-
`);let n=C(e,{});if(`error`in n)return Zk(n.error);if(n.positionals.length===0)return G(`mcp search: expected <query>`);let r=n.positionals[0],i=r.toLowerCase(),{ensureAllMcpProvidersRegistered:a}=await import(`./provider-
|
|
1614
|
-
`);let n=C(e,{});if(`error`in n)return Zk(n.error);let r=n.positionals[0];if(!r)return G(`mcp delete: expected <name>`);let{ensureMcpProviderRegistered:i,removeMcpProvider:a}=await import(`./provider-
|
|
1613
|
+
`);let n=C(e,{});if(`error`in n)return Zk(n.error);if(n.positionals.length===0)return G(`mcp search: expected <query>`);let r=n.positionals[0],i=r.toLowerCase(),{ensureAllMcpProvidersRegistered:a}=await import(`./provider-CCQRZg4A.js`);await a();let{listServers:o}=await import(`./store-BXNUAqDB.js`).then(e=>e.r),s=await o(t.fs),c=Object.keys(s).sort();if(c.length===0)return W("No MCP servers configured. Use `mcp add <url> <name>`.\n");let l=[];for(let e of c){let t=s[e].tools??[];for(let n of t){let t=n.description??``,r=n.name.toLowerCase().includes(i),a=t.toLowerCase().includes(i);if(!r&&!a)continue;let o=r&&a?`name+description`:r?`name`:`description`;l.push({server:e,tool:n.name,description:t,match:o})}}if(l.length===0)return W(`No tools matched "${r}".\n`);l.sort((e,t)=>e.server===t.server?e.tool.localeCompare(t.tool):e.server.localeCompare(t.server));let u=[[`SERVER`,`TOOL`,`DESCRIPTION`,`MATCH`]];for(let e of l)u.push([e.server,e.tool,aA(e.description),e.match]);return W(rA(u))}function aA(e){if(!e)return``;let t=e.replace(/\s+/g,` `).trim();return t.length<=60?t:t.slice(0,59)+`…`}async function oA(e,t){if(e.length===0||w(e))return e.length===0?G(`mcp delete: expected <name>`):W(`usage: mcp delete <name>
|
|
1614
|
+
`);let n=C(e,{});if(`error`in n)return Zk(n.error);let r=n.positionals[0];if(!r)return G(`mcp delete: expected <name>`);let{ensureMcpProviderRegistered:i,removeMcpProvider:a}=await import(`./provider-CCQRZg4A.js`);await i(r);let{deleteServer:o}=await import(`./store-BXNUAqDB.js`).then(e=>e.r),s=await o(r,t.fs);await IA(r,t),await LA(r,t);let c=`mcp:${r}`,l=!1;try{let{removeAccount:e,getAccounts:t}=await import(`./account-store-DgfR_tf2.js`).then(e=>e.t);t().some(e=>e.providerId===c)&&(await e(c),l=!0)}catch(e){Yk.warn(`mcp delete: OAuth removal failed`,{providerId:c,error:e instanceof Error?e.message:String(e)})}let u=a(r);return!s&&!l&&!u?G(`mcp delete: no server, alias, or account found for "${r}"`):W([`Removed MCP server "${r}"`,` servers.json: ${s?`removed`:`not present`}`,` alias: cleaned`,` sprinkles: cleaned`,` oauth: ${l?`removed`:`not present`}`,` provider: ${u?`unregistered`:`not registered`}`].join(`
|
|
1615
1615
|
`)+`
|
|
1616
|
-
`)}async function sA(e,t){if(e.length===0)return G(`mcp invoke: expected <name>`);if(w(e.slice(0,1)))return W(uA());let n=C([e[0]],{});if(`error`in n)return Zk(n.error);let r=n.positionals[0];if(!r)return G(`mcp invoke: expected <name>`);let i=e.slice(1),{ensureMcpProviderRegistered:a}=await import(`./provider-
|
|
1616
|
+
`)}async function sA(e,t){if(e.length===0)return G(`mcp invoke: expected <name>`);if(w(e.slice(0,1)))return W(uA());let n=C([e[0]],{});if(`error`in n)return Zk(n.error);let r=n.positionals[0];if(!r)return G(`mcp invoke: expected <name>`);let i=e.slice(1),{ensureMcpProviderRegistered:a}=await import(`./provider-CCQRZg4A.js`);await a(r);let{getServer:o}=await import(`./store-BXNUAqDB.js`).then(e=>e.r),s=await o(r,t.fs);if(!s)return G(`mcp invoke: unknown server "${r}" (run \`mcp add <url> ${r}\` first)`);let c=s.tools??[];if(i.length===0||w(i.slice(0,1)))return W(dA(r,s,c));let l=C([i[0]],{});if(`error`in l)return Zk(l.error);let u=l.positionals[0];if(!u)return G(`mcp invoke: expected <tool>`);let d=c.find(e=>e.name===u);if(!d)return G(`mcp invoke: unknown tool "${u}" on "${r}" (run \`${r}\` to list tools)`);let{timeoutMs:f,remaining:p,warnings:m}=cA(i.slice(1));if(w(p))return W(pA(r,d));let h=mA(p,d.inputSchema);if(!h.ok)return G(`mcp invoke: ${h.error}`);let{McpClient:g}=await import(`./client-CwxmlQM-.js`).then(e=>e.n),_=new g({url:s.url,fetchImpl:t.fetchImpl,headers:s.headers,getAuthHeader:s.auth?()=>AA(r):void 0,...f===void 0?{}:{timeoutMs:f}});await _.initialize();let v=EA(await _.toolsCall(u,h.value));return m.length>0&&(v.stderr=m.map(e=>`${e}\n`).join(``)+v.stderr),v}function cA(e){let t=[],n=[],r,i=0;for(;i<e.length;){let a=e[i];if(a.startsWith(`--timeout=`)){let e=lA(a.slice(10));e.ok?r=e.value:n.push(e.error),i+=1;continue}if(a===`--timeout`){let t=e[i+1];if(t===void 0||t.startsWith(`--`)){n.push(`mcp invoke: --timeout requires a value (got ${t===void 0?`nothing`:`"${t}"`}); using default.`),i+=1;continue}let a=lA(t);a.ok?r=a.value:n.push(a.error),i+=2;continue}t.push(a),i+=1}return{timeoutMs:r,remaining:t,warnings:n}}function lA(e){if(!/^-?\d+$/.test(e))return{ok:!1,error:`mcp invoke: invalid --timeout value "${e}" (expected positive integer seconds); using default.`};let t=Number(e);return!Number.isFinite(t)||t<1?{ok:!1,error:`mcp invoke: invalid --timeout value "${e}" (must be >= 1 second); using default.`}:{ok:!0,value:t*1e3}}function uA(){return`usage: mcp invoke <name> [tool] [--timeout <seconds>] [--flag value …]
|
|
1617
1617
|
|
|
1618
1618
|
mcp invoke <name> List tools on <name>.
|
|
1619
1619
|
mcp invoke <name> <tool> --help Show flags for <tool>.
|
|
@@ -1646,7 +1646,7 @@ Arguments are coerced according to the tool's JSON Schema:
|
|
|
1646
1646
|
|
|
1647
1647
|
Re-fetches the tool catalog and \`apps/list\` for <name>. Does NOT refresh
|
|
1648
1648
|
OAuth tokens — for OAuth token refresh use \`mcp auth <name>\`.
|
|
1649
|
-
`);let n=C(e,{});if(`error`in n)return Zk(n.error);let r=n.positionals[0];if(!r)return G(`mcp refresh: expected <name>`);let{ensureMcpProviderRegistered:i}=await import(`./provider-
|
|
1649
|
+
`);let n=C(e,{});if(`error`in n)return Zk(n.error);let r=n.positionals[0];if(!r)return G(`mcp refresh: expected <name>`);let{ensureMcpProviderRegistered:i}=await import(`./provider-CCQRZg4A.js`);await i(r);let{getServer:a,setServer:o}=await import(`./store-BXNUAqDB.js`).then(e=>e.r),s=await a(r,t.fs);if(!s)return G(`mcp refresh: unknown server "${r}"`);let{McpClient:c,McpAuthRequiredError:l}=await import(`./client-CwxmlQM-.js`).then(e=>e.n),u=new c({url:s.url,fetchImpl:t.fetchImpl,headers:s.headers,getAuthHeader:s.auth?()=>AA(r):void 0});try{await u.initialize()}catch(e){if(e instanceof l)return G(`mcp refresh: server "${r}" returned 401 — token may have expired. Run \`mcp auth ${r}\` to re-authenticate.`);throw e}let d=await u.toolsList(),f=await u.appsList();await o(r,{...s,protocolVersion:u.getNegotiatedProtocolVersion(),tools:d,apps:f,lastRefreshedAt:new Date().toISOString()},t.fs);let p=await RA(r,f,t);return W(`Refreshed "${r}" — tools: ${d.length}, apps: ${f.length} (${p} sprinkle${p===1?``:`s`})\n`)}async function OA(e,t){if(w(e))return W(`usage: mcp auth <name> [--silent | --interactive]
|
|
1650
1650
|
|
|
1651
1651
|
Re-authenticate an existing MCP server. By default, attempts a silent
|
|
1652
1652
|
token renewal using the persisted refresh_token; if that returns no
|
|
@@ -1658,7 +1658,7 @@ Options:
|
|
|
1658
1658
|
-i, --interactive Skip silent renewal and open the OAuth popup
|
|
1659
1659
|
directly. Use after revoking a refresh token or
|
|
1660
1660
|
when the AS no longer accepts the cached one.
|
|
1661
|
-
`);let n=C(e,{bool:Jk});if(`error`in n)return Zk(n.error);let r=n.positionals[0];if(!r)return G(`mcp auth: expected <name>`);let i=n.bools.has(`--silent`)||n.bools.has(`-s`),a=n.bools.has(`--interactive`)||n.bools.has(`-i`);if(i&&a)return G(`mcp auth: --silent and --interactive are mutually exclusive`);let{ensureMcpProviderRegistered:o}=await import(`./provider-
|
|
1661
|
+
`);let n=C(e,{bool:Jk});if(`error`in n)return Zk(n.error);let r=n.positionals[0];if(!r)return G(`mcp auth: expected <name>`);let i=n.bools.has(`--silent`)||n.bools.has(`-s`),a=n.bools.has(`--interactive`)||n.bools.has(`-i`);if(i&&a)return G(`mcp auth: --silent and --interactive are mutually exclusive`);let{ensureMcpProviderRegistered:o}=await import(`./provider-CCQRZg4A.js`),s=await o(r,{fetchImpl:t.oauthFetchImpl,launcher:t.oauthLauncher}),{getServer:c}=await import(`./store-BXNUAqDB.js`).then(e=>e.r),l=await c(r,t.fs);if(!l)return G(`mcp auth: unknown server "${r}" (run \`mcp list\` to see configured servers)`);if(!l.auth)return G(`mcp auth: server "${r}" does not use OAuth`);if(!s)return G(`mcp auth: failed to register provider for "${r}"`);let u=`mcp:${r}`,{getRegisteredProviderConfig:d}=await import(`./providers-TV6NIsPL.js`).then(e=>e.r),f=d(u);if(!f)return G(`mcp auth: provider "${u}" is not registered`);if(a)return await kA(r,f,t);if(!f.onSilentRenew)return i?G(`mcp auth: provider "${u}" does not support silent renewal; retry without --silent`):await kA(r,f,t);let p=null;try{p=await f.onSilentRenew()}catch(e){let t=e instanceof Error?e.message:String(e);if(i)return G(`mcp auth: silent renewal for "${r}" failed (${t}); retry without --silent to run the interactive flow`);Yk.debug(`mcp auth: silent renewal threw, falling back to interactive`,{name:r,error:t})}return p?W(`Re-authenticated "${r}" via silent renewal (provider ${u})\n`):i?G(`mcp auth: silent renewal for "${r}" returned no token; retry without --silent to run the interactive flow`):await kA(r,f,t)}async function kA(e,t,n){if(!t.onOAuthLogin)return G(`mcp auth: provider "${t.id}" does not support interactive OAuth login`);let r=n.oauthLauncher??await jA(),i=!1;return await t.onOAuthLogin(r,()=>{i=!0}),i?W(`Re-authenticated "${e}" via interactive login (provider ${t.id})\n`):G(`mcp auth: interactive login for "${e}" did not complete`)}async function AA(e){let t=`mcp:${e}`,{getOAuthAccountInfo:n}=await import(`./account-store-DgfR_tf2.js`).then(e=>e.t),r=n(t);if(!r)return null;if(r.expired){try{let{getRegisteredProviderConfig:e}=await import(`./providers-TV6NIsPL.js`).then(e=>e.r),n=await e(t)?.onSilentRenew?.();if(n)return`Bearer ${n}`}catch(e){Yk.debug(`silent renewal threw`,{providerId:t,error:e instanceof Error?e.message:String(e)})}return null}return`Bearer ${r.token}`}async function jA(){let{createOAuthLauncher:e}=await import(`./oauth-service-DP3Rx6V_.js`);return e()}async function MA(e){if(e)return e;let{createProxiedFetch:t}=await import(`./proxied-fetch-DXaTHROw.js`).then(e=>e.a),n=t();return async(e,t)=>{let r=await n(e,{method:t?.method,headers:t?.headers,body:t?.body}),i=new TextDecoder().decode(r.body);return{ok:r.status>=200&&r.status<300,status:r.status,statusText:r.statusText,text:async()=>i,json:async()=>JSON.parse(i),headers:{get:e=>r.headers[e.toLowerCase()]??null}}}}async function NA(e){if(e)return e;let{VirtualFS:t}=await import(`./fs-B3WU3yr9.js`).then(e=>e.t),{GLOBAL_FS_DB_NAME:n}=await import(`./global-db-DJXlpNui.js`).then(e=>e.n);return await t.create({dbName:n})}function PA(e){return`// MCP alias for "${e}" — forwards args to \`mcp invoke ${e}\`.
|
|
1662
1662
|
// Auto-generated by \`mcp add ${e}\`; do not edit by hand.
|
|
1663
1663
|
const { promisify } = require('util');
|
|
1664
1664
|
const { exec } = require('child_process');
|
|
@@ -1687,7 +1687,7 @@ try {
|
|
|
1687
1687
|
if (stdout) process.stdout.write(stdout);
|
|
1688
1688
|
if (stderr) process.stderr.write(stderr);
|
|
1689
1689
|
process.exit(exitCode);
|
|
1690
|
-
`}async function FA(e,t){let n=await NA(t.fs);await n.mkdir(Xk,{recursive:!0}),await n.writeFile(`${Xk}/${e}.jsh`,PA(e)),t.scriptCatalog?.invalidateJsh()}async function IA(e,t){let n=await NA(t.fs),r=`${Xk}/${e}.jsh`;try{await n.exists(r)&&await n.rm(r)}catch(e){Yk.debug(`alias removal failed`,{path:r,error:e instanceof Error?e.message:String(e)})}t.scriptCatalog?.invalidateJsh()}async function LA(e,t){let{removeAppSprinkles:n}=await import(`./apps-
|
|
1690
|
+
`}async function FA(e,t){let n=await NA(t.fs);await n.mkdir(Xk,{recursive:!0}),await n.writeFile(`${Xk}/${e}.jsh`,PA(e)),t.scriptCatalog?.invalidateJsh()}async function IA(e,t){let n=await NA(t.fs),r=`${Xk}/${e}.jsh`;try{await n.exists(r)&&await n.rm(r)}catch(e){Yk.debug(`alias removal failed`,{path:r,error:e instanceof Error?e.message:String(e)})}t.scriptCatalog?.invalidateJsh()}async function LA(e,t){let{removeAppSprinkles:n}=await import(`./apps-JHYPOU64.js`);await n(e,t.fs)}async function RA(e,t,n){try{let{materializeAppSprinkles:r}=await import(`./apps-JHYPOU64.js`);return(await r(e,t,n.fs)).length}catch(t){return Yk.warn(`mcp: failed to materialize app sprinkles`,{name:e,error:t instanceof Error?t.message:String(t)}),0}}function zA(e){return{stdout:``,stderr:`meminfo: ${e}\n`,exitCode:1}}function BA(e){return e.attribution.length===0?`(shared)`:e.attribution.map(e=>{let t=e.container?.src??e.container?.id??e.url??`?`;return e.scope?`${e.scope} ${t}`:t}).join(`, `)}function VA(){let e=globalThis.performance,t=e?.measureUserAgentSpecificMemory;return t?t.bind(e):null}function HA(e){if(e[0]===`--help`||e[0]===`-h`||e[0]===`help`)return{help:!0};let t=!1;for(let n of e){if(n!==`--json`)return{error:`unknown option '${n}' — see \`meminfo --help\``};t=!0}return{help:!1,json:t}}function UA(e){let t=[`total: ${Ny(e.bytes)}`],n=[...e.breakdown].filter(e=>e.bytes>0).sort((e,t)=>t.bytes-e.bytes);if(n.length>0){t.push(``,`BYTES TYPES ATTRIBUTION`);for(let e of n)t.push(`${Ny(e.bytes).padEnd(10)} ${e.types.join(`,`).padEnd(20)} ${BA(e)}`)}return`${t.join(`
|
|
1691
1691
|
`)}\n`}function WA(e={}){return S(`meminfo`,async t=>{let n=HA(t);if(`error`in n)return zA(n.error);if(n.help)return{stdout:`meminfo - agent-cluster memory diagnostics
|
|
1692
1692
|
|
|
1693
1693
|
Usage:
|
|
@@ -1699,7 +1699,7 @@ Notes:
|
|
|
1699
1699
|
Document-Isolation-Policy). Embedded floats cannot be isolated and
|
|
1700
1700
|
report why instead.
|
|
1701
1701
|
- The browser randomizes measurement timing — expect a short delay.
|
|
1702
|
-
`,stderr:``,exitCode:0};let r=e.isIsolated?e.isIsolated():globalThis.crossOriginIsolated===!0,i=e.measure??VA();if(!r&&!e.measure)return zA(`memory measurement requires a cross-origin-isolated runtime (Document-Isolation-Policy) — this runtime is not isolated`);if(!i)return zA(`performance.measureUserAgentSpecificMemory is not available in this browser`);let a;try{a=await i()}catch(e){return zA(e instanceof Error?e.message:String(e))}return n.json?{stdout:`${JSON.stringify(a,null,2)}\n`,stderr:``,exitCode:0}:{stdout:UA(a),stderr:``,exitCode:0}})}function GA(e){return S(`memory`,async t=>{let{runMemory:n}=await import(`./run-
|
|
1702
|
+
`,stderr:``,exitCode:0};let r=e.isIsolated?e.isIsolated():globalThis.crossOriginIsolated===!0,i=e.measure??VA();if(!r&&!e.measure)return zA(`memory measurement requires a cross-origin-isolated runtime (Document-Isolation-Policy) — this runtime is not isolated`);if(!i)return zA(`performance.measureUserAgentSpecificMemory is not available in this browser`);let a;try{a=await i()}catch(e){return zA(e instanceof Error?e.message:String(e))}return n.json?{stdout:`${JSON.stringify(a,null,2)}\n`,stderr:``,exitCode:0}:{stdout:UA(a),stderr:``,exitCode:0}})}function GA(e){return S(`memory`,async t=>{let{runMemory:n}=await import(`./run-Dp-YY09r.js`);return n(t,e)})}function KA(){return S(`mktemp`,async(e,t)=>{let{runMktemp:n}=await import(`./run-dAJe7sKp.js`);return n(e,t)})}const qA=`/.cache/artificial-analysis.json`,JA=[`--all`,`--all-versions`,`--json`,`--refresh`,`--no-benchmarks`,`--help`,`-h`],YA=[`--provider`];function XA(e){return{stdout:``,stderr:e.endsWith(`
|
|
1703
1703
|
`)?e:`${e}\n`,exitCode:1}}async function ZA(e){try{let t=await e.readFile(qA),n=JSON.parse(t);if(Date.now()-n.fetchedAt<864e5)return n.models}catch{}return null}function QA(){try{return localStorage.getItem(`aa_api_key`)}catch{return null}}function $A(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 ej(e,t){let n={fetchedAt:Date.now(),models:t};try{await e.mkdir(`/.cache`,{recursive:!0}),await e.writeFile(qA,JSON.stringify(n))}catch{}}async function tj(e,t=!1){if(e&&!t){let t=await ZA(e);if(t)return t}let n={Accept:`application/json`},r=QA();r&&(n[`x-api-key`]=r);let i=p(),a;try{a=await i(`https://artificialanalysis.ai/api/v2/data/llms/models`,{method:`GET`,headers:n})}catch{return[]}if(a.status===401||a.status<200||a.status>=300)return[];let o;try{o=JSON.parse(new TextDecoder().decode(a.body))}catch{return[]}if(typeof o!=`object`||!o)return[];let s=o,c=$A(Array.isArray(s)?s:s.data??s.models??[]);return e&&c.length>0&&await ej(e,c),c}function nj(e){return e.toLowerCase().replace(/\./g,`-`).replace(/-\d{8}$/,``).replace(/-\d{4}$/,``)}function rj(e,t){let n=e.toLowerCase(),r=t.find(e=>e.slug===n);if(r)return r;let i=nj(e),a=t.find(e=>nj(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 ij(){return`models - list available LLM models
|
|
1704
1704
|
|
|
1705
1705
|
Usage: models [options]
|
|
@@ -1714,7 +1714,7 @@ Options:
|
|
|
1714
1714
|
-h, --help Show this help message
|
|
1715
1715
|
`}function aj(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`.replace(`.0M`,`M`):e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function oj(e){return`$${e.toFixed(2)}`}const sj=/\b(embedding|embed|tts|whisper|dall-e|image-gen|audio|vision-preview)\b/i;function cj(e){let t=`${e.id} ${e.name??``}`;return!sj.test(t)}function lj(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 uj(e){let t=e.toLowerCase();return t=t.replace(/-\d{8}$/,``),t=t.replace(/-\d{4}$/,``),t=t.replace(/-(preview|latest)$/,``),lj(t)??t.replace(/-[\d.]+$/,``)}function dj(e){let t=new Map;for(let n of e){let e=uj(n.id);(!t.has(e)||n.selected)&&t.set(e,n)}return[...t.values()]}function fj(e,t,n,r,i){let a=i?rj(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 pj(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=`${oj(e.cost.input)} / ${oj(e.cost.output)}`,a=`${aj(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(`
|
|
1716
1716
|
`)+`
|
|
1717
|
-
`}function mj(e){let t=C(e,{bool:JA,value:YA});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 hj(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 gj(e,t,n,r,i,a){let o=e.getProviderModels(t).filter(cj);if(o.length===0)return[];let s=o.map(e=>fj(e,t,n,r,i)).sort((e,t)=>t.cost.input-e.cost.input);return a||(s=dj(s)),s}function _j(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 vj(e,t){if(w(e,{valueFlags:YA}))return{stdout:ij(),stderr:``,exitCode:0};let n=mj(e);if(`error`in n)return XA(`models: ${n.error}`);let r=await import(`./account-store-
|
|
1717
|
+
`}function mj(e){let t=C(e,{bool:JA,value:YA});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 hj(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 gj(e,t,n,r,i,a){let o=e.getProviderModels(t).filter(cj);if(o.length===0)return[];let s=o.map(e=>fj(e,t,n,r,i)).sort((e,t)=>t.cost.input-e.cost.input);return a||(s=dj(s)),s}function _j(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 vj(e,t){if(w(e,{valueFlags:YA}))return{stdout:ij(),stderr:``,exitCode:0};let n=mj(e);if(`error`in n)return XA(`models: ${n.error}`);let r=await import(`./account-store-DgfR_tf2.js`).then(e=>e.t);if(r.getAccounts().length===0)return XA(`No provider accounts configured. Run the provider settings to add one.
|
|
1718
1718
|
`);let i=r.resolveCurrentModel(),a=i.id,o=i.provider,s=r.getSelectedProvider(),c=r.getSelectedModelId(),l;if(!n.noBenchmarks){let e=await tj(t,n.forceRefresh);e.length>0&&(l=e)}let u=hj(r,n,s);if(`error`in u)return XA(u.error);let d=[],f=[];for(let e of u){let t=gj(r,e,a,o,l,n.allVersions);if(t.length===0){if(!n.allMode)return XA(`No models available for provider ${e}.\n`);continue}if(d.push(...t),!n.jsonMode){let n=r.getProviderConfig(e);f.push(pj(n.name,e,t,!!l))}}return n.jsonMode?{stdout:JSON.stringify(d,null,2)+`
|
|
1719
1719
|
`,stderr:``,exitCode:0}:(n.allVersions||f.push(`Showing latest versions only. Use --all-versions to see all.
|
|
1720
1720
|
`),f.push(_j(o,a,s,c)),{stdout:f.join(`
|
|
@@ -1772,7 +1772,7 @@ Examples:
|
|
|
1772
1772
|
`)}\n`,stderr:``,exitCode:0}}async function Uj(e,t,n){if(!t||!n)return{stdout:``,stderr:`oauth-domain add: requires <providerId> and <domain>
|
|
1773
1773
|
`,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 Wj(e,t,n){if(!t||!n)return{stdout:``,stderr:`oauth-domain remove: requires <providerId> and <domain>
|
|
1774
1774
|
`,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 Gj(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>
|
|
1775
|
-
`,exitCode:1}}async function Kj(e,t,n,r){switch(t){case`list`:return Hj(e,n);case`add`:return Uj(e,n,r);case`remove`:return Wj(e,n,r);case`clear`:return Gj(e,n);default:return{stdout:``,stderr:`oauth-domain: unknown subcommand "${t}"\n${Bj()}`,exitCode:1}}}function qj(){return S(`oauth-domain`,async e=>{if(e.length===0||w(e))return{stdout:Bj(),stderr:``,exitCode:0};let t=C(e);if(`error`in t)return Vj(t.error);let[n,r,i]=t.positionals,a=await import(`./account-store-
|
|
1775
|
+
`,exitCode:1}}async function Kj(e,t,n,r){switch(t){case`list`:return Hj(e,n);case`add`:return Uj(e,n,r);case`remove`:return Wj(e,n,r);case`clear`:return Gj(e,n);default:return{stdout:``,stderr:`oauth-domain: unknown subcommand "${t}"\n${Bj()}`,exitCode:1}}}function qj(){return S(`oauth-domain`,async e=>{if(e.length===0||w(e))return{stdout:Bj(),stderr:``,exitCode:0};let t=C(e);if(`error`in t)return Vj(t.error);let[n,r,i]=t.positionals,a=await import(`./account-store-DgfR_tf2.js`).then(e=>e.t);try{return await Kj(a,n,r,i)}catch(e){return Vj(e instanceof Error?e.message:String(e))}})}function Jj(){return S(`oauth-token`,async(e,t)=>{let{runOAuthToken:n}=await import(`./run-DkflycnX.js`);return n(e,t)})}const Yj=[`--download`,`-d`,`--view`,`-v`],Xj=[`--size`],Zj={low:256,medium:768,high:1536};function Qj(){return{stdout:`usage: open [--download|-d] [--view|-v [--size <spec>]] <url|path> [url|path...]
|
|
1776
1776
|
|
|
1777
1777
|
VFS paths are served in a new browser tab via the preview service worker.
|
|
1778
1778
|
URLs (http/https/etc.) are opened directly in a new tab.
|
|
@@ -1798,7 +1798,7 @@ Examples:
|
|
|
1798
1798
|
`);let i=!1;try{i=(await t.fs.stat(e)).isDirectory}catch{}let a=await cr(t.fs,i?e:gr(e)),o=Rr(e,a),s;try{s=await r(o)}catch(e){return K(`${e instanceof Error?e.message:String(e)}\n`)}return sM(`opened ${e} → ${o}${cM(s)}`)}async function hM(e,t,n,r){if(!ur(e)&&e.endsWith(`.shtml`)&&t.fs)return uM(e,t,r.sprinkleManager,r.canOpenWindow,r.openExternal);if(!n.view&&!r.canOpenWindow)return K(`open: browser APIs are unavailable in this environment
|
|
1799
1799
|
`);if(ur(e))return dM(e,r.canOpenWindow,r.openExternal);let i=t.fs.resolvePath(t.cwd,e);return n.view?fM(e,i,t,n.sizeSpec):n.download?pM(e,i,t,r.hasDom):mM(i,t,r.canOpenWindow,r.openExternal)}function gM(e){return S(`open`,async(t,n)=>{if(t.length===0||w(t,{valueFlags:Xj}))return Qj();let r=oM(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 Qj();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:lM(e,l,u)},f=[];for(let e of s){let t=await hM(e,n,{view:a,download:i,sizeSpec:o},d);if(!t.ok)return t.result;f.push(t.message)}return{stdout:f.join(`
|
|
1800
1800
|
`)+`
|
|
1801
|
-
`,stderr:``,exitCode:0}})}function _M(){return S(`patch`,async(e,t)=>{let{runPatch:n}=await import(`./run-
|
|
1801
|
+
`,stderr:``,exitCode:0}})}function _M(){return S(`patch`,async(e,t)=>{let{runPatch:n}=await import(`./run-gr518xGk.js`);return n(e,t)})}function vM(e=`pdftk`){return S(e,async(t,n)=>{let{runPdftk:r}=await import(`./run-BEs473Sp.js`);return r(e,t,n)})}function yM(){return{stdout:`usage: pdftoppm [options] <input.pdf> [output-prefix]
|
|
1802
1802
|
|
|
1803
1803
|
Rasterize PDF pages to images. Writes <prefix>-<n>.<ext> per page, where <n>
|
|
1804
1804
|
is zero-padded to the digit width of the last page (out-1.png for a 9-page
|
|
@@ -1858,7 +1858,7 @@ Examples:
|
|
|
1858
1858
|
plugin list
|
|
1859
1859
|
plugin info my-plugin
|
|
1860
1860
|
plugin remove my-plugin
|
|
1861
|
-
`}function IM(e={}){return S(`plugin`,async(t,n)=>{if(t.length===0||t[0]===`--help`||t[0]===`-h`)return NM(FM());let r=t[0],i=t.slice(1),a=n?.cwd??`/`;try{switch(r){case`install`:case`add`:return await UM(i,a,e);case`list`:case`ls`:return await qM(i,e);case`info`:return await JM(i,e);case`validate`:return await YM(i,a,e,Xi(n?.env));case`remove`:case`rm`:case`delete`:return await XM(i,e);default:return q(`plugin: unknown subcommand "${r}" (try \`plugin --help\`)`)}}catch(e){return q(`plugin ${r}: ${e instanceof Error?e.message:String(e)}`)}})}async function LM(e){if(e.fs)return e.fs;let{VirtualFS:t}=await import(`./fs-
|
|
1861
|
+
`}function IM(e={}){return S(`plugin`,async(t,n)=>{if(t.length===0||t[0]===`--help`||t[0]===`-h`)return NM(FM());let r=t[0],i=t.slice(1),a=n?.cwd??`/`;try{switch(r){case`install`:case`add`:return await UM(i,a,e);case`list`:case`ls`:return await qM(i,e);case`info`:return await JM(i,e);case`validate`:return await YM(i,a,e,Xi(n?.env));case`remove`:case`rm`:case`delete`:return await XM(i,e);default:return q(`plugin: unknown subcommand "${r}" (try \`plugin --help\`)`)}}catch(e){return q(`plugin ${r}: ${e instanceof Error?e.message:String(e)}`)}})}async function LM(e){if(e.fs)return e.fs;let{VirtualFS:t}=await import(`./fs-B3WU3yr9.js`).then(e=>e.t),{GLOBAL_FS_DB_NAME:n}=await import(`./global-db-DJXlpNui.js`).then(e=>e.n);return t.create({dbName:n})}async function RM(e,t,n){let r=ZM(t,e);if(await n.exists(r))return{kind:`local`,root:r};let{parseGitHubRef:i}=await import(`./github-install-CXBoYKYM.js`).then(e=>e.t),a=i(e);if(a){let e=`${a.owner}/${a.repo}${a.branch?`@${a.branch}`:``}${a.path?`/${a.path}`:``}`;return{kind:`github`,ref:{...a,display:e}}}return{kind:`error`,message:`${r} does not exist and "${e}" is not a GitHub reference (owner/repo[@branch] or https://github.com/owner/repo[/tree/branch[/dir]])`}}function zM(e){let t=e.replace(/[^A-Za-z0-9._-]+/g,`-`);return/^\.+$/.test(t)?t.replace(/\./g,`_`):t}function BM(e){let t=[e.owner,e.repo,...e.path?[e.path]:[]];return`${MM}/${t.map(zM).join(`--`)}`}async function VM(e,t,n,r){let{fetchRepoZip:i,stripZipPrefix:a,writeZipFilesToDir:o}=await import(`./github-zip-DHBvTUIf.js`).then(e=>e.i),s=await i(e.owner,e.repo,r,e.branch);if(s.status===`error`)return`failed to download ${e.display}: ${s.message}`;let c=a(s.files),l=e.path?e.path.replace(/^\/|\/$/g,``)+`/`:``;if(!c[`${l}plugin.json`])return`no plugin.json found at ${e.display} — not an Agent Plugins package`;try{await n.rm(t,{recursive:!0})}catch{}return await n.mkdir(t,{recursive:!0}),(await o(c,l,t,n,!1)).length===0?`no files found at ${e.display}`:null}async function HM(e,t){try{await e.rm(t,{recursive:!0})}catch{}}async function UM(e,t,n){if(w(e))return NM(`usage: plugin install <path|repo>
|
|
1862
1862
|
|
|
1863
1863
|
Loads the Agent Plugins package at <path>, or downloads it from a GitHub
|
|
1864
1864
|
reference (owner/repo, owner/repo@branch, or
|
|
@@ -1869,19 +1869,19 @@ mcp.json. On success the plugin is recorded in
|
|
|
1869
1869
|
/workspace/.plugins/plugins.json — its skills then surface through the
|
|
1870
1870
|
standard skills discovery, and each supported streamable-http MCP server
|
|
1871
1871
|
is registered in the MCP store as "<plugin>:<server>".
|
|
1872
|
-
`);let r=PM(`install`,e);if(!(`ok`in r))return r;if(r.positionals.length<1)return q(`plugin install: expected <path|repo>`);let i=await LM(n),a=await RM(r.positionals[0],t,i);if(a.kind===`error`)return q(`plugin install: ${a.message}`);let o,s;if(a.kind===`github`){if(!n.fetch)return q(`plugin install: GitHub installs are unavailable (no network fetch configured)`);o=BM(a.ref),s=a.ref.display;let e=await VM(a.ref,o,i,n.fetch);if(e)return q(`plugin install: ${e}`)}else o=a.root;let{loadPluginFromDirectory:c}=await import(`./loader-Dw-TPPKt.js`),l=await c(i,o);if(!l.ok)return a.kind===`github`&&await HM(i,o),q(`plugin install: plugin at ${s??o} was rejected:\n${QM(l.diagnostics)}`);let{plugin:u}=l,d=u.manifest.name,{getInstalledPlugin:f,setInstalledPlugin:p}=await import(`./store-
|
|
1872
|
+
`);let r=PM(`install`,e);if(!(`ok`in r))return r;if(r.positionals.length<1)return q(`plugin install: expected <path|repo>`);let i=await LM(n),a=await RM(r.positionals[0],t,i);if(a.kind===`error`)return q(`plugin install: ${a.message}`);let o,s;if(a.kind===`github`){if(!n.fetch)return q(`plugin install: GitHub installs are unavailable (no network fetch configured)`);o=BM(a.ref),s=a.ref.display;let e=await VM(a.ref,o,i,n.fetch);if(e)return q(`plugin install: ${e}`)}else o=a.root;let{loadPluginFromDirectory:c}=await import(`./loader-Dw-TPPKt.js`),l=await c(i,o);if(!l.ok)return a.kind===`github`&&await HM(i,o),q(`plugin install: plugin at ${s??o} was rejected:\n${QM(l.diagnostics)}`);let{plugin:u}=l,d=u.manifest.name,{getInstalledPlugin:f,setInstalledPlugin:p}=await import(`./store-HjKkYqua.js`),m=await f(d,n.fs);if(m&&m.root!==o)return a.kind===`github`&&await HM(i,o),q(`plugin install: a plugin named "${d}" is already installed from ${m.root} (remove it first)`);let h=await KM(u,n),g=await GM(d,m?.mcpServerNames,h.registered,n);return await p(d,{root:o,version:u.manifest.version,description:u.manifest.description,installedAt:new Date().toISOString(),mcpServerNames:h.registered,...s?{source:s}:{}},n.fs),NM(WM(u,h,g,s??o,l.diagnostics))}function WM(e,t,n,r,i){let a=e.manifest.name,o=t.registered,s=e.mcp.servers.filter(e=>e.status!==`supported`),c=[`Installed agent plugin "${a}"${e.manifest.version?` v${e.manifest.version}`:``} from ${r}`,` skills: ${e.skills.length}${e.skills.length>0?` (${e.skills.map(e=>e.name).join(`, `)})`:``}`,` mcp: ${o.length} registered${o.length>0?` (${o.join(`, `)})`:``}${s.length>0?`, ${s.length} skipped`:``}${n>0?`, ${n} removed from previous install`:``}`];return t.conflicts.length>0&&c.push(` warning: not bridged — MCP server name(s) already in use and not owned by this plugin: ${t.conflicts.join(`, `)} (remove them with \`mcp remove\` first)`),i.length>0&&c.push(`Diagnostics:`,QM(i)),c.join(`
|
|
1873
1873
|
`)+`
|
|
1874
|
-
`}async function GM(e,t,n,r){let i=(t??[]).filter(e=>!n.includes(e));if(i.length===0)return 0;let{deleteServer:a,getServer:o}=await import(`./store-
|
|
1875
|
-
`);let n=PM(`list`,e);if(!(`ok`in n))return n;let{listInstalledPlugins:r}=await import(`./store-
|
|
1874
|
+
`}async function GM(e,t,n,r){let i=(t??[]).filter(e=>!n.includes(e));if(i.length===0)return 0;let{deleteServer:a,getServer:o}=await import(`./store-BXNUAqDB.js`).then(e=>e.r),s=0;for(let t of i)(await o(t,r.fs))?.pluginOrigin===e&&await a(t,r.fs)&&(s+=1);return s}async function KM(e,t){let n=e.mcp.servers.filter(e=>e.status===`supported`);if(n.length===0)return{registered:[],conflicts:[]};let{getServer:r,setServer:i}=await import(`./store-BXNUAqDB.js`).then(e=>e.r),{McpClient:a}=await import(`./client-CwxmlQM-.js`).then(e=>e.n),o=[],s=[];for(let c of n){let n=c.config,l=`${e.manifest.name}:${c.name}`,u=await r(l,t.fs);if(u&&u.pluginOrigin!==e.manifest.name){s.push(l);continue}let d=[];try{let e=new a({url:n.url,headers:n.headers});await e.initialize(),d=await e.toolsList()}catch{}await i(l,{url:n.url,...n.headers?{headers:n.headers}:{},tools:d,addedAt:new Date().toISOString(),pluginOrigin:e.manifest.name},t.fs),o.push(l)}return{registered:o,conflicts:s}}async function qM(e,t){if(w(e))return NM(`usage: plugin list
|
|
1875
|
+
`);let n=PM(`list`,e);if(!(`ok`in n))return n;let{listInstalledPlugins:r}=await import(`./store-HjKkYqua.js`),i=await r(t.fs),a=Object.keys(i).sort();if(a.length===0)return NM("No agent plugins installed. Use `plugin install <path>`.\n");let o=[[`NAME`,`VERSION`,`ROOT`,`MCP`]];for(let e of a){let t=i[e];o.push([e,t.version??`-`,t.root,String(t.mcpServerNames?.length??0)])}let s=o[0].map((e,t)=>Math.max(...o.map(e=>e[t].length)));return NM(o.map(e=>e.map((e,t)=>e.padEnd(s[t])).join(` `)).join(`
|
|
1876
1876
|
`)+`
|
|
1877
1877
|
`)}async function JM(e,t){if(w(e))return NM(`usage: plugin info <name>
|
|
1878
|
-
`);let n=PM(`info`,e);if(!(`ok`in n))return n;if(n.positionals.length<1)return q(`plugin info: expected <name>`);let r=n.positionals[0],{getInstalledPlugin:i}=await import(`./store-
|
|
1878
|
+
`);let n=PM(`info`,e);if(!(`ok`in n))return n;if(n.positionals.length<1)return q(`plugin info: expected <name>`);let r=n.positionals[0],{getInstalledPlugin:i}=await import(`./store-HjKkYqua.js`),a=await i(r,t.fs);if(!a)return q(`plugin info: no installed plugin named "${r}"`);let o=await LM(t),{loadPluginFromDirectory:s}=await import(`./loader-Dw-TPPKt.js`),c=await s(o,a.root);if(!c.ok)return q(`plugin info: plugin at ${a.root} no longer loads:\n${QM(c.diagnostics)}`);let{plugin:l}=c,u=l.manifest,d=[`${u.name}${u.version?` v${u.version}`:``}`,...u.description?[` ${u.description}`]:[],` root: ${l.root}`,...u.license?[` license: ${u.license}`]:[],...u.homepage?[` home: ${u.homepage}`]:[],``,`Skills (${l.skills.length}):`,...l.skills.map(e=>` ${e.name} ${e.description}`),``,`MCP servers (${l.mcp.servers.length}):`,...l.mcp.servers.map(e=>e.status===`supported`?` ${e.name} ${e.config.type} ${e.config.url}`:` ${e.name} [skipped: ${e.reason}]`)];return c.diagnostics.length>0&&d.push(``,`Diagnostics:`,QM(c.diagnostics)),NM(d.join(`
|
|
1879
1879
|
`)+`
|
|
1880
1880
|
`)}async function YM(e,t,n,r){if(w(e))return NM(`usage: plugin validate <path|repo>
|
|
1881
1881
|
`);let i=PM(`validate`,e);if(!(`ok`in i))return i;if(i.positionals.length<1)return q(`plugin validate: expected <path|repo>`);let a=await LM(n),o=await RM(i.positionals[0],t,a);if(o.kind===`error`)return q(`plugin validate: ${o.message}`);let s,c=null;if(o.kind===`github`){if(!n.fetch)return q(`plugin validate: GitHub sources are unavailable (no network fetch configured)`);c=`${r}/.plugin-validate/${BM(o.ref).split(`/`).pop()}`;let e=await VM(o.ref,c,a,n.fetch);if(e)return q(`plugin validate: ${e}`);s=c}else s=o.root;let{loadPluginFromDirectory:l}=await import(`./loader-Dw-TPPKt.js`),u;try{u=await l(a,s)}finally{c&&await HM(a,c)}if(!u.ok)return{stdout:``,stderr:`plugin validate: REJECTED\n${QM(u.diagnostics)}\n`,exitCode:1};let{plugin:d}=u,f=d.mcp.servers.filter(e=>e.status===`supported`).length,p=[`plugin validate: OK — "${d.manifest.name}"${d.manifest.version?` v${d.manifest.version}`:``}`,` skills: ${d.skills.length}`,` mcp servers: ${f} supported, ${d.mcp.servers.length-f} skipped (mcp.json ${d.mcp.status})`];return u.diagnostics.length>0&&p.push(`Diagnostics:`,QM(u.diagnostics)),NM(p.join(`
|
|
1882
1882
|
`)+`
|
|
1883
1883
|
`)}async function XM(e,t){if(w(e))return NM(`usage: plugin remove <name>
|
|
1884
|
-
`);let n=PM(`remove`,e);if(!(`ok`in n))return n;if(n.positionals.length<1)return q(`plugin remove: expected <name>`);let r=n.positionals[0],{getInstalledPlugin:i,deleteInstalledPlugin:a}=await import(`./store-
|
|
1884
|
+
`);let n=PM(`remove`,e);if(!(`ok`in n))return n;if(n.positionals.length<1)return q(`plugin remove: expected <name>`);let r=n.positionals[0],{getInstalledPlugin:i,deleteInstalledPlugin:a}=await import(`./store-HjKkYqua.js`),o=await i(r,t.fs);if(!o)return q(`plugin remove: no installed plugin named "${r}"`);let s=0;if(o.mcpServerNames&&o.mcpServerNames.length>0){let{deleteServer:e,getServer:n}=await import(`./store-BXNUAqDB.js`).then(e=>e.r);for(let i of o.mcpServerNames)(await n(i,t.fs))?.pluginOrigin===r&&await e(i,t.fs)&&(s+=1)}await a(r,t.fs);let c=o.root.startsWith(`${MM}/`);return c&&await HM(await LM(t),o.root),NM([`Removed agent plugin "${r}"`,` registry: removed`,` mcp servers: ${s} removed`,c?` files: removed (${o.root})`:` files: left in place (${o.root})`].join(`
|
|
1885
1885
|
`)+`
|
|
1886
1886
|
`)}function ZM(e,t){let n=t.startsWith(`/`)?t:`${e.replace(/\/$/,``)}/${t}`,r=[];for(let e of n.split(`/`))e!==``&&e!==`.`&&(e===`..`?r.pop():r.push(e));return`/${r.join(`/`)}`}function QM(e){return e.map(e=>` ${e.level===`error`?`error`:`warn `} [${e.component}] ${e.message}`).join(`
|
|
1887
1887
|
`)}const $M=[`pid`,`ppid`,`kind`,`stat`,`start`,`scoop`,`command`],eN=[`pid`,`ppid`,`stat`,`start`,`scoop`,`command`],tN={running:`R`,pending:`S`,exited:`Z`,killed:`K`},nN=[`-a`,`-A`,`-e`,`--all`,`-T`,`--tree`],rN=[`-o`,`--columns`];function iN(e={}){return S(`ps`,async t=>{if(w(t,{valueFlags:rN}))return vN();let n=e.processManager??aN();if(!n)return{stdout:``,stderr:`ps: no process manager available in this runtime
|
|
@@ -1978,7 +1978,7 @@ Examples:
|
|
|
1978
1978
|
`)+`
|
|
1979
1979
|
`,stderr:``,exitCode:0}}try{return{stdout:(await e.panelRpc.call(`list-voices`,void 0)).voices.map(e=>sP(e)).join(`
|
|
1980
1980
|
`)+`
|
|
1981
|
-
`,stderr:``,exitCode:0}}catch(e){return QN($N(e))}}async function lP(e){if(!e.local)return(await e.panelRpc.call(`list-voices`,void 0)).voices;let{kokoroVoicesIfReady:t}=await import(`./speech-page-realm-stub-C7EPKrHd.js`),n=t().map(e=>({name:e.id})),r=(await nP()).map(e=>({name:e.name}));return[...n,...r]}async function uP(e,t){let n=(await lP(e)).find(e=>e.name.toLowerCase().includes(t.toLowerCase()));return n?{resolved:n.name}:{error:QN(`voice "${t}" not found. Use --list to see available voices.`)}}async function dP(e,t){try{if(e.local){let{kokoroStatus:e,kokoroWarmup:n}=await import(`./speech-page-realm-stub-C7EPKrHd.js`);return{stdout:ZN(t?n():e()),stderr:``,exitCode:0}}return{stdout:ZN(t?await e.panelRpc.call(`speak-warmup`,void 0):await e.panelRpc.call(`speak-status`,void 0)),stderr:``,exitCode:0}}catch(e){return QN($N(e))}}async function fP(e,t){return t.includes(`--list`)?cP(e):t.includes(`--status`)?dP(e,!1):t.includes(`--warmup`)?dP(e,!0):null}async function pP(e){try{let{speak:t}=await import(`./speech-page-realm-stub-C7EPKrHd.js`);return await t(e),{stdout:``,stderr:``,exitCode:0}}catch(e){return QN(`speech synthesis error: ${$N(e)}`)}}async function mP(e,t){try{return await e.panelRpc.call(`speak-text`,t,{timeoutMs:3e5}),{stdout:``,stderr:``,exitCode:0}}catch(e){return QN($N(e))}}async function hP(e){let{synthesizeToWav:t}=await import(`./speech-page-realm-stub-C7EPKrHd.js`);try{return{bytes:await t(e)}}catch(e){return QN($N(e))}}async function gP(e,t){try{let n=await e.panelRpc.call(`synthesize-to-wav`,{text:t.text,lang:t.lang,...t.voice?{voice:t.voice}:{},rate:t.rate},{timeoutMs:3e5});return{bytes:new Uint8Array(n.bytes)}}catch(e){return QN($N(e))}}async function _P(e,t){return e.local?hP(t):gP(e,t)}async function vP(e,t){let n=await _P(e,t);return`exitCode`in n?n:{...pi(n.bytes),stderr:``,exitCode:0}}async function yP(e,t,n,r){let i=await _P(e,r);if(`exitCode`in i)return i;let a=t.fs.resolvePath(t.cwd,n);try{await t.fs.writeFile(a,i.bytes)}catch(e){return QN(`failed to write ${n}: ${$N(e)}`)}return{stdout:`wrote ${Math.max(1,Math.round(i.bytes.byteLength/1024))} KB to ${a}\n`,stderr:``,exitCode:0}}async function bP(e,t,n){let r;if(n.voiceName){let{resolved:t,error:i}=await uP(e,n.voiceName);if(i)return i;r=t}let i={text:n.text,lang:n.lang,voice:r,rate:n.rate};return n.outFile===`-`||!n.outFile&&!
|
|
1981
|
+
`,stderr:``,exitCode:0}}catch(e){return QN($N(e))}}async function lP(e){if(!e.local)return(await e.panelRpc.call(`list-voices`,void 0)).voices;let{kokoroVoicesIfReady:t}=await import(`./speech-page-realm-stub-C7EPKrHd.js`),n=t().map(e=>({name:e.id})),r=(await nP()).map(e=>({name:e.name}));return[...n,...r]}async function uP(e,t){let n=(await lP(e)).find(e=>e.name.toLowerCase().includes(t.toLowerCase()));return n?{resolved:n.name}:{error:QN(`voice "${t}" not found. Use --list to see available voices.`)}}async function dP(e,t){try{if(e.local){let{kokoroStatus:e,kokoroWarmup:n}=await import(`./speech-page-realm-stub-C7EPKrHd.js`);return{stdout:ZN(t?n():e()),stderr:``,exitCode:0}}return{stdout:ZN(t?await e.panelRpc.call(`speak-warmup`,void 0):await e.panelRpc.call(`speak-status`,void 0)),stderr:``,exitCode:0}}catch(e){return QN($N(e))}}async function fP(e,t){return t.includes(`--list`)?cP(e):t.includes(`--status`)?dP(e,!1):t.includes(`--warmup`)?dP(e,!0):null}async function pP(e){try{let{speak:t}=await import(`./speech-page-realm-stub-C7EPKrHd.js`);return await t(e),{stdout:``,stderr:``,exitCode:0}}catch(e){return QN(`speech synthesis error: ${$N(e)}`)}}async function mP(e,t){try{return await e.panelRpc.call(`speak-text`,t,{timeoutMs:3e5}),{stdout:``,stderr:``,exitCode:0}}catch(e){return QN($N(e))}}async function hP(e){let{synthesizeToWav:t}=await import(`./speech-page-realm-stub-C7EPKrHd.js`);try{return{bytes:await t(e)}}catch(e){return QN($N(e))}}async function gP(e,t){try{let n=await e.panelRpc.call(`synthesize-to-wav`,{text:t.text,lang:t.lang,...t.voice?{voice:t.voice}:{},rate:t.rate},{timeoutMs:3e5});return{bytes:new Uint8Array(n.bytes)}}catch(e){return QN($N(e))}}async function _P(e,t){return e.local?hP(t):gP(e,t)}async function vP(e,t){let n=await _P(e,t);return`exitCode`in n?n:{...pi(n.bytes),stderr:``,exitCode:0}}async function yP(e,t,n,r){let i=await _P(e,r);if(`exitCode`in i)return i;let a=t.fs.resolvePath(t.cwd,n);try{await t.fs.writeFile(a,i.bytes)}catch(e){return QN(`failed to write ${n}: ${$N(e)}`)}return{stdout:`wrote ${Math.max(1,Math.round(i.bytes.byteLength/1024))} KB to ${a}\n`,stderr:``,exitCode:0}}async function bP(e,t,n){let r;if(n.voiceName){let{resolved:t,error:i}=await uP(e,n.voiceName);if(i)return i;r=t}let i={text:n.text,lang:n.lang,voice:r,rate:n.rate};return n.outFile===`-`||!n.outFile&&!Jn(t)?vP(e,i):n.outFile?yP(e,t,n.outFile,i):e.local?pP(i):mP(e,i)}function xP(){return S(`say`,async(e,t)=>{if(e.includes(`--help`)||e.includes(`-h`))return XN();let n={local:typeof window<`u`&&typeof speechSynthesis<`u`,panelRpc:y()};if(!n.local&&!n.panelRpc)return QN(`Web Speech API unavailable in this environment`);let r=await fP(n,e);if(r)return r;let i=oP(e);return`exitCode`in i?i:i.text?i.lang?bP(n,t,{...i,lang:i.lang}):QN(`-l language tag is required`):XN()})}function SP(){return S(`screencapture`,async(e,t)=>{let{runScreencapture:n}=await import(`./screencapture-run-CJF_k55t.js`);return n(e,t)})}function CP(e){return new Promise((t,n)=>{chrome.runtime.sendMessage(e,e=>{let r=chrome.runtime.lastError;if(r){n(Error(r.message??`chrome.runtime.lastError`));return}t(e)})})}const wP=1e4;async function TP(e,t,n){let r={method:e,headers:xe({"Content-Type":`application/json`}),signal:AbortSignal.timeout(wP)};n&&(r.body=JSON.stringify(n));try{let e=await fetch(be(`/api/secrets${t}`),r),n=await e.json().catch(()=>({}));return{ok:e.ok,status:e.status,data:n}}catch(e){return{ok:!1,status:0,data:{error:EP(e)}}}}function EP(e){let t=e instanceof Error?e.name:``;return t===`TimeoutError`||t===`AbortError`?`no response from the secret store within ${wP/1e3}s`:`secret store unreachable: ${e instanceof Error?e.message:String(e)}`}function DP(e,t){return`could not read ${e} secrets — ${t??`the bridge gave no reason`}`}function OP(e,t){let n=e.entries.find(e=>e.name===t)??null;if(n)return n;if(e.warnings.length>0)throw Error(e.warnings.join(`; `));return null}function kP(){return{async list(){let[e,t]=await Promise.all([TP(`GET`,``),TP(`GET`,`/session`)]),n=[],r=[];if(e.ok)for(let t of e.data)n.push({name:t.name,domains:t.domains,persisted:!0});else r.push(DP(`saved`,NP(e.data)));if(t.ok)for(let e of t.data)n.push({name:e.name,domains:e.domains,persisted:!1});else r.push(DP(`session`,NP(t.data)));return{entries:n,warnings:r}},async getInfo(e){return OP(await this.list(),e)},async getMasked(e){let{ok:t,data:n}=await TP(`GET`,`/masked`);return t?n.find(t=>t.name===e)??null:null},async peek(e){let{ok:t,data:n}=await TP(`GET`,`/peek?name=${encodeURIComponent(e)}`);return t?n:null},async setSession(e,t,n){let{ok:r,data:i}=await TP(`POST`,`/session`,{name:e,value:t,domains:n});if(!r)throw Error(NP(i)??`failed to set session secret`)},async setPersisted(e,t,n){let{ok:r,data:i}=await TP(`POST`,``,{name:e,value:t,domains:n});if(!r)throw Error(NP(i)??`failed to persist secret`)},async setScope(e,t){let{ok:n,data:r}=await TP(`POST`,`/scope`,{name:e,domains:t});if(!n)throw Error(NP(r)??`failed to update scope`)},async delete(e){let{ok:t,status:n,data:r}=await TP(`DELETE`,`/${encodeURIComponent(e)}`);if(n===404)return{removed:!1};if(!t)throw Error(NP(r)??`failed to delete secret`);return{removed:!0,fromSession:r&&typeof r==`object`&&`fromSession`in r?!!r.fromSession:void 0}}}}function AP(e){let t=t=>e(t);return{async list(){let[e,n]=await Promise.all([t({type:`secrets.list`}),t({type:`secrets.session.list`})]),r=[],i=[];for(let t of e?.entries??[])r.push({name:t.name,domains:t.domains,persisted:!0});for(let e of n?.entries??[])r.push({name:e.name,domains:e.domains,persisted:!1});return e?.entries||i.push(DP(`saved`,e?.error)),n?.entries||i.push(DP(`session`,n?.error)),{entries:r,warnings:i}},async getInfo(e){return OP(await this.list(),e)},async getMasked(e){return((await t({type:`secrets.list-masked-entries`}))?.entries??[]).find(t=>t.name===e)??null},async peek(e){let n=await t({type:`secrets.peek`,name:e});if(n?.error)throw Error(n.error);return n?.record??null},async setSession(e,n,r){let i=await t({type:`secrets.session.set`,name:e,value:n,domains:r});if(!i?.ok)throw Error(i?.error??`secrets.session.set failed`)},async setPersisted(e,n,r){let i=await t({type:`secrets.set`,name:e,value:n,domains:r});if(!i?.ok)throw Error(i?.error??`secrets.set failed`)},async setScope(e,n){let r=await t({type:`secrets.set-domains`,name:e,domains:n});if(!r?.ok)throw Error(r?.error??`secrets.set-domains failed`)},async delete(e){let n=await t({type:`secrets.delete`,name:e});if(!n?.ok)throw Error(n?.error??`secrets.delete failed`);return{removed:n.removed??!0,fromSession:n.fromSession}}}}function jP(){return AP(e=>CP(e))}function MP(){return AP(e=>{let{type:t,...n}=e;return De(t,n)})}function NP(e){if(e&&typeof e==`object`&&`error`in e){let t=e.error;if(typeof t==`string`)return t}}function PP(e){switch(e){case`extension-direct`:return jP();case`extension-delegate`:return MP();default:return kP()}}const FP=[`--domain`],IP=[`--persist`];function LP(){return`secret — manage secrets for the fetch proxy and mount backends
|
|
1982
1982
|
|
|
1983
1983
|
No approval (session-only, in-memory, never persisted):
|
|
1984
1984
|
secret set <name> <value> --domain <pat> Set a session secret. Free for a
|
|
@@ -2088,7 +2088,7 @@ Limits and lifetime:
|
|
|
2088
2088
|
`,exitCode:1};if(e.ttlMs!==void 0&&e.maxTabs!==void 0)return{stdout:``,stderr:`serve: --ttl cannot be combined with --max-tabs
|
|
2089
2089
|
`,exitCode:1}}async function jF(e,t,n){if(e.ttlMs!==void 0){if(!t)throw Error(`persistent snapshot filesystem unavailable`);return CF(t,n)}}async function MF(e,t,n,r){if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return sF();let i=pF(e);if(i.error)return{stdout:``,stderr:i.error,exitCode:1};let a=await kF(i);if(a)return a;if(!i.directory)return sF();let o=AF(i);if(o)return o;let s=await mF(i.directory,i.entry,t.fs,t.cwd);if(hF(s))return s;let{fullDirectory:c,entryPath:l}=s,u;try{u=await jF(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)
|
|
2090
2090
|
`:``,f=await DF(!i.noBridge&&i.bridge,d);return f.ok?OF(i,c,l,f.webhookId,d,u,n):f.result}function NF(e,t){return S(`serve`,(n,r)=>MF(n,r,e,t))}const PF=`usage: session export [--id <id>] [--output <path>]
|
|
2091
|
-
`;function FF(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 IF(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${PF}`};let n=r[e+1];if(!n||n.startsWith(`-`))return{ok:!1,stderr:`session export: --id requires a value\n${PF}`};t=n,e++}else if(i===`--output`){if(n!==null)return{ok:!1,stderr:`session export: duplicate flag --output\n${PF}`};let t=r[e+1];if(!t||t.startsWith(`-`))return{ok:!1,stderr:`session export: --output requires a path\n${PF}`};n=t,e++}else if(i.startsWith(`-`))return{ok:!1,stderr:`session export: unknown flag ${i}\n${PF}`};else return{ok:!1,stderr:`session export: unexpected argument ${JSON.stringify(i)}\n${PF}`}}return{ok:!0,args:{sessionId:t,outputPath:n}}}async function LF(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||Dt(r)!==a.sha256)throw new Ma(`transfer-corrupt`);return r}async function RF(e,t){let n=IF(e);if(!n.ok)return{stdout:``,stderr:n.stderr,exitCode:1};let{sessionId:r,outputPath:i}=n.args;if(i!==null){let e=FF(i);if(!e.ok)return{stdout:``,stderr:`session export: --output ${e.reason}\n${PF}`,exitCode:1}}let a=r==null?{kind:`active`}:{kind:`frozen`,sessionId:r};try{let e=await vs().export(a,{}),n=await LF(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 Ma?e.code:e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}function zF(){return S(`session`,async(e,t)=>{if(e[0]===`export`&&!w(e))return RF(e,t);let{dispatchSessionMemoryAware:n}=await import(`./session-command-memory-
|
|
2091
|
+
`;function FF(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 IF(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${PF}`};let n=r[e+1];if(!n||n.startsWith(`-`))return{ok:!1,stderr:`session export: --id requires a value\n${PF}`};t=n,e++}else if(i===`--output`){if(n!==null)return{ok:!1,stderr:`session export: duplicate flag --output\n${PF}`};let t=r[e+1];if(!t||t.startsWith(`-`))return{ok:!1,stderr:`session export: --output requires a path\n${PF}`};n=t,e++}else if(i.startsWith(`-`))return{ok:!1,stderr:`session export: unknown flag ${i}\n${PF}`};else return{ok:!1,stderr:`session export: unexpected argument ${JSON.stringify(i)}\n${PF}`}}return{ok:!0,args:{sessionId:t,outputPath:n}}}async function LF(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||Dt(r)!==a.sha256)throw new Ma(`transfer-corrupt`);return r}async function RF(e,t){let n=IF(e);if(!n.ok)return{stdout:``,stderr:n.stderr,exitCode:1};let{sessionId:r,outputPath:i}=n.args;if(i!==null){let e=FF(i);if(!e.ok)return{stdout:``,stderr:`session export: --output ${e.reason}\n${PF}`,exitCode:1}}let a=r==null?{kind:`active`}:{kind:`frozen`,sessionId:r};try{let e=await vs().export(a,{}),n=await LF(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 Ma?e.code:e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}function zF(){return S(`session`,async(e,t)=>{if(e[0]===`export`&&!w(e))return RF(e,t);let{dispatchSessionMemoryAware:n}=await import(`./session-command-memory-Di_ppNKR.js`);return n(e,t,PF)})}function BF(){return S(`slicc`,async(e,t)=>{let{runSlicc:n}=await import(`./run-cvQKad0O.js`);return await n(e,t)})}const VF=`leader`;function HF(){try{let e=globalThis.localStorage?.getItem(`slicc.leaderSprinkleInstances`);if(e)return JSON.parse(e)}catch{}return[]}function UF(e){return+!!e.leader+e.followers.length}function WF(){return{stdout:`usage: sprinkle <subcommand> [args]
|
|
2092
2092
|
|
|
2093
2093
|
list [--runtime <id>] List sprinkles + an instance line per runtime
|
|
2094
2094
|
open <name> Open a sprinkle by name
|
|
@@ -3238,7 +3238,7 @@ or pass -bios / -vgabios with explicit VFS paths.`,wz={"-n":Tz,"-name":Tz,"--nam
|
|
|
3238
3238
|
`)}\n`)}function Kz(e,t){return`prefer: computer ${e} -c ${t}\n`}async function qz(e,t,n,r){let i=jz(t);if(Mz(i))return i;let[{runComputer:a},{getComputerRegistry:o,installComputerRegistry:s},c]=await Promise.all([import(`./run-DWA1_d1u.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),Jz(await a([`-c`,l,...n],e,{registry:u}),r,l)}function Jz(e,t,n){let r=Kz(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 Yz(e,t){let{name:n,rest:r}=Az(e);if(r.length===0){let e=jz(n);return Mz(e)?e:Q(`type: no text supplied`)}return qz(t,n,[`type`,`--`,...r],`type`)}async function Xz(e,t){let{name:n,rest:r}=Az(e);if(r.length===0){let e=jz(n);return Mz(e)?e:Q(`key: no chord supplied`)}return qz(t,n,[`key`,...r],`key`)}const Zz=[`left`,`middle`,`right`];async function Qz(e,t){let{name:n,rest:r}=Az(e),i=jz(n);if(Mz(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?qz(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>`):qz(t,n,[`--native`,`mousemove`,e,i,`--relative`],`mousemove`)}if(o===`click`){let e=r[1]??`left`;if(!Zz.includes(e))return Q(`mouse: unknown button '${r[1]}'`);let i=[`click`,e];return r.includes(`--double`)&&i.push(`--repeat`,`2`),qz(t,n,i,`click`)}return Q(`mouse: expected move <dx> <dy>, click [button], or --to <x>,<y>`)}async function $z(e,t){let{name:n,rest:r}=Az(e);return qz(t,n,[`screenshot`,...r],`screenshot`)}async function eB(e,t){let{name:n}=Az(e);return qz(t,n,[`text`],`text`)}function tB(e){let{name:t}=Az(e);return $(`v86 serve is retired.\nUse: computer watch -c v86:${t}\nLive frames go to the overlay, lightbox, and bash rows.\n`)}function nB(e){let{name:t,rest:n}=Az(e),r=jz(t);if(Mz(r))return r;let i=n.indexOf(`--send`);if(i!==-1){let e=n.slice(i+1).join(` `).replace(/\\n/gu,`
|
|
3239
3239
|
`);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(`
|
|
3240
3240
|
`).slice(-Math.max(1,e)).join(`
|
|
3241
|
-
`)}\n`)}return $(r.serial.buffer?`${r.serial.buffer}\n`:``)}async function rB(e,t){let{name:n,rest:r}=Az(e),i=jz(n);if(Mz(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 iB(e,t){let{name:n,rest:r}=Az(e),i=jz(n);if(Mz(i))return i;let a=t.processManager??Fz();return r.includes(`--force`)&&a&&i.pid!==null?(a.signal(i.pid,`SIGKILL`),$(`VM '${n}' killed\n`)):(await Wz(i,a),$(`VM '${n}' stopped\n`))}function aB(e={}){return S(`wasm`,async(t,n)=>{let{runWasmCommand:r}=await import(`./run-
|
|
3241
|
+
`)}\n`)}return $(r.serial.buffer?`${r.serial.buffer}\n`:``)}async function rB(e,t){let{name:n,rest:r}=Az(e),i=jz(n);if(Mz(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 iB(e,t){let{name:n,rest:r}=Az(e),i=jz(n);if(Mz(i))return i;let a=t.processManager??Fz();return r.includes(`--force`)&&a&&i.pid!==null?(a.signal(i.pid,`SIGKILL`),$(`VM '${n}' killed\n`)):(await Wz(i,a),$(`VM '${n}' stopped\n`))}function aB(e={}){return S(`wasm`,async(t,n)=>{let{runWasmCommand:r}=await import(`./run-Bx861p9q.js`);return r(t,n,{processConfig:e.buildProcessConfig?.(n.env),terminal:e.terminal,gate:e.gate})})}const oB=[`--name`,`--filter`,`--scoop`],sB={state:`inactive`,session:null};function cB(){return{stdout:`usage: webhook <command> [options]
|
|
3242
3242
|
|
|
3243
3243
|
Commands:
|
|
3244
3244
|
create [--scoop <name>] [--name <name>] [--filter <code>] Create a new webhook endpoint
|
|
@@ -3494,5 +3494,5 @@ pass --wait to block and print the full result.`,DV=new Set([`list`,`status`,`st
|
|
|
3494
3494
|
`,stderr:``,exitCode:0};let n;try{n=$V(e)}catch(e){return VV(e.message)}let r=n.positional[0],i=n.positional[1],a=!r||r===`-`,o;try{o=await tH(t,r,a)}catch{return VV(`${r}: No such file or directory`)}if(n.revert){let e=WV(o),r=n.plain?YV(e):XV(e);return i?(await t.fs.writeFile(t.fs.resolvePath(t.cwd,i),r),{stdout:``,stderr:``,exitCode:0}):{stdout:WV(r),stderr:``,exitCode:0}}let{data:s,base:c}=rH(n,o),l=nH(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 aH(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=dr(t,o),s=n?`${n}/${o}`:o;a+=await aH(e,i,s,r)}return a}function oH(){return{stdout:`usage: zip [-r] <archive.zip> <path> [path...]
|
|
3495
3495
|
`,stderr:``,exitCode:0}}function sH(){return S(`zip`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return oH();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
|
|
3496
3496
|
`,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(/^\.\//,``))||fr(r);if(i.isDirectory&&!n)return{stdout:``,stderr:`zip: ${e} is a directory (use -r)\n`,exitCode:1};s+=await aH(t,r,a,o)}if(s===0)return{stdout:``,stderr:`zip: nothing to do
|
|
3497
|
-
`,exitCode:1};let c=kt(o);return await t.fs.writeFile(i,c),{stdout:`created ${i} (${s} file(s))\n`,stderr:``,exitCode:0}})}function cH(e){return{setEnv:e.setEnv,unsetEnv:e.unsetEnv,broker:e.sudoCommand?.broker}}function lH(e){let{fs:t,fetch:n}=e;if(!t||!n)return[];let r={fs:t,fetch:n,scriptCatalog:e.scriptCatalog,syncScriptCommands:e.syncScriptCommands};return[vO(`ipk`,r),vO(`npm`,r),vO(`i`,r),sk(`ipx`,{fs:t,fetch:n}),sk(`npx`,{fs:t,fetch:n}),gb(`di`,{fs:t,fetch:n}),gb(`uv`,{fs:t,fetch:n}),PR({fs:t,fetch:n})]}function uH(e={}){let t=[wE({getJshCommands:e.getJshCommands,getWorkflowCommands:e.getWorkflowCommands}),ne(),xI(),BF(),NF(e.browserAPI,e.fs),gM(e.browserAPI),jy(e.browserAPI),kD(e),sH(),uR(),nL(e.fs?{fs:e.fs}:{}),OI(),FI(),MI(),Ev(),aB({buildProcessConfig:e.buildProcessConfig,terminal:e.terminal,gate:e.gateNativeCommand}),iH(),hI(`sqlite3`),hI(`sqllite`),yL(),zL(),Mx(),cv(),Nj({buildProcessConfig:e.buildProcessConfig}),Nj({buildProcessConfig:e.buildProcessConfig},`jsh`),MN(`python3`,{buildProcessConfig:e.buildProcessConfig}),MN(`python`,{buildProcessConfig:e.buildProcessConfig}),...lH(e),...e.fs?[XS({fs:e.fs})]:[],...e.fs?[GA({fs:e.fs})]:[],...e.fetch?[FE({fetch:e.fetch,streamFetch:e.streamFetch})]:[],TS(),ES(),RS(),bB(e.webhook),aV(),Ay(e.crontask),$k({fs:e.fs,scriptCatalog:e.scriptCatalog}),IM({fs:e.fs,fetch:e.fetch}),YS(),oI(),_M(),vM(`pdftk`),vM(`pdf`),lv(`biscotto`),lv(`biscotti`),OM(`pdftoppm`),OM(`pdftocairo`),kM(`pdftotext`),my(`convert`),my(`magick`),hV({fs:e.fs,scriptCatalog:e.scriptCatalog,getStaticBuiltins:e.getStaticBuiltins,getScriptRegisteredNames:e.getScriptRegisteredNames}),UL(),aR(),TD(),ED(),oR(),KA(),IN(),qk(),rx(),Jj(),qj(),Wk(),iF(cH(e)),YN({fs:e.fs}),SP(),Cv(),wv(),Tv(`xclip`),Tv(`xsel`),xP(),fC(),Pg(),Fg(),yj(e.fs),st(),Rj(),t_({getParentJid:e.getParentJid}),dx(),iN({processManager:e.processManager}),YR({processManager:e.processManager}),uk({processManager:e.processManager}),ck({processManager:e.processManager,scriptCatalog:e.scriptCatalog}),...i_(),WA(),Ik(),bz(),sD(),pS(),Iz({processManager:e.processManager}),kv({processManager:e.processManager,browser:e.browserAPI,sudoBroker:e.sudoCommand?.broker}),wS(),gv({registry:e.cherryRuntimeRegistry}),By(),Ky({fs:e.fs}),qy({fs:e.fs}),CI(e.sudoCommand),MV({getParentJid:e.getParentJid,syncScriptCommands:e.syncScriptCommands}),oV(),zF()];return e.fs&&(jM(),t.push(...zn.map(t=>xE(t,e.browserAPI,e.fs,{isScoop:e.isScoop})))),t}let dH=null;function fH(e){dH=e}function pH(e){dH?.(e)}var mH=Nt();const hH=Reflect.get(tt,`DefenseInDepthBox`);function gH(e){return(typeof e==`string`?e:e?.encoding)??`utf8`}function _H(e,t){if(typeof e!=`string`)return e;let n=gH(t);if(n===`binary`||n===`latin1`){let t=ge(e);if(t)return t}return mH.Buffer.from(e,n)}function vH(e){return e===`/bin`?`/usr/bin`:e.startsWith(`/bin/`)?`/usr${e}`:e}var yH=class{vfs;registeredCommandsFn=null;listingStats=new Map;listingStatsMax;listingStatsTtlMs;constructor(e,t){this.vfs=e,this.listingStatsMax=Math.max(1,t?.listingStatsMax??2e4),this.listingStatsTtlMs=t?.listingStatsTtlMs??1e3,this.updateMetadataBatch=this.updateMetadataBatch.bind(this),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}getVirtualBinCommands(){return this.registeredCommandsFn?.()??[]}virtualUsrStat(e){let t=vH(e);if(t===`/usr`||t===`/usr/bin`)return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date(0)};if(t.startsWith(`/usr/bin/`)){let e=t.slice(9);if(e.length>0&&!e.includes(`/`)&&this.getVirtualBinCommands().includes(e))return{isFile:!0,isDirectory:!1,isSymbolicLink:!1,mode:493,size:0,mtime:new Date(0)}}return null}canWrite(e){let t=this.vfs;return typeof t.canWrite!=`function`||t.canWrite(e)}listMountPoints(){let e=this.vfs;return typeof e.listMountPoints==`function`?e.listMountPoints():[]}trusted(e){let t=hH?.runTrustedAsync;return t?t(e):Promise.resolve().then(e)}async readFile(e,t){return this.trusted(async()=>{let n=b(e),r=await this.vfs.readFile(n,{encoding:`binary`}),i=r instanceof Uint8Array?r:new TextEncoder().encode(r),a=gH(t),o=mH.Buffer.from(i.buffer,i.byteOffset,i.byteLength).toString(a);return a!==`hex`&&a!==`base64`&&g(o,i),o})}async readFileBuffer(e){return this.trusted(async()=>{let t=b(e),n=await this.vfs.readFile(t,{encoding:`binary`});return n instanceof Uint8Array?n:new TextEncoder().encode(n)})}async readFileBytes(e){let t=await this.readFileBuffer(e);return mH.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,_H(t,n))})}async appendFile(e,t,n){return this.dropListingStats(),this.trusted(()=>this.vfs.appendFile(b(e),_H(t,n)))}async exists(e){return this.trusted(async()=>{let t=b(e);return this.virtualUsrStat(t)?!0:this.vfs.exists(t)})}async stat(e){return this.trusted(async()=>{let t=b(e),n=this.virtualUsrStat(t);if(n)return n;let r=this.vfs.statSync(t);if(r)return{isFile:r.type===`file`,isDirectory:r.type===`directory`,isSymbolicLink:!!r.isSymlink,mode:r.mode??(r.type===`directory`?493:420),size:r.size,mtime:new Date(r.mtime),identity:r.identity,dev:r.dev,ino:r.identity===void 0?void 0:r.ino};let i=this.primedStats(t)??await this.vfs.stat(t);return{isFile:i.type===`file`,isDirectory:i.type===`directory`,isSymbolicLink:!!i.isSymlink,mode:i.mode??(i.type===`directory`?493:420),size:i.size,mtime:new Date(i.mtime),identity:i.identity,dev:i.dev,ino:i.identity===void 0?void 0:i.ino}})}async lstat(e){return this.trusted(async()=>{let t=b(e),n=this.virtualUsrStat(t);if(n)return n;let r=this.vfs.lstatSync(t);if(r)return{isFile:r.type===`file`,isDirectory:r.type===`directory`,isSymbolicLink:r.type===`symlink`,mode:r.mode??(r.type===`directory`?493:r.type===`symlink`?511:420),size:r.size,mtime:new Date(r.mtime),identity:r.identity,dev:r.dev,ino:r.identity===void 0?void 0:r.ino};let i=this.primedStats(t)??await this.vfs.lstat(t);return{isFile:i.type===`file`,isDirectory:i.type===`directory`,isSymbolicLink:i.type===`symlink`,mode:i.mode??(i.type===`directory`?493:i.type===`symlink`?511:420),size:i.size,mtime:new Date(i.mtime),identity:i.identity,dev:i.dev,ino:i.identity===void 0?void 0:i.ino}})}async mkdir(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.mkdir(b(e),t)})}async readdir(e){return this.trusted(async()=>{let t=b(e);if(t===`/usr`)return[`bin`];if(vH(t)===`/usr/bin`)return this.getVirtualBinCommands().slice().sort();let n=this.vfs.readDirSync(t);if(n!==null)return n.map(e=>e.name);let r=await this.vfs.readDir(t,{includeStats:!0});return this.primeListingStats(t,r),r.map(e=>e.name)})}async readdirWithFileTypes(e){return this.trusted(async()=>{let t=b(e);if(t===`/usr`)return[{name:`bin`,isFile:!1,isDirectory:!0,isSymbolicLink:!1}];if(vH(t)===`/usr/bin`)return this.getVirtualBinCommands().slice().sort().map(e=>({name:e,isFile:!0,isDirectory:!1,isSymbolicLink:!1}));let n=this.vfs.readDirSync(t);if(n!==null)return this.mapFastEntriesToDirents(n);let r=await this.vfs.readDir(t,{includeStats:!0});return this.primeListingStats(t,r),this.mapAsyncEntriesToDirents(r)})}mapFastEntriesToDirents(e){return e.map(e=>this.entryToDirent(e))}mapAsyncEntriesToDirents(e){return e.map(e=>this.entryToDirent(e))}entryToDirent(e){return e.type===`symlink`?{name:e.name,isFile:!1,isDirectory:!1,isSymbolicLink:!0}:{name:e.name,isFile:e.type===`file`,isDirectory:e.type===`directory`,isSymbolicLink:!1}}async rm(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.rm(b(e),t)})}async cp(e,t,n){return this.dropListingStats(),this.trusted(async()=>{let r=b(e),i=b(t);if((await this.vfs.stat(r)).type===`directory`){if(!n?.recursive)throw new 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)}}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 bH(e){return e&&typeof e.getWatcher==`function`?e.getWatcher?.()??null:e&&typeof e.getUnderlyingFS==`function`?bH(e.getUnderlyingFS?.()):null}async function xH(e){let t=he(`github`);if(t){if(e?.force){await t.onSilentRenew?.();return}await t.getValidAccessToken?.()}}const SH=e(`almost-bash-shell`),CH=`__SLICC_RUN_PID`,wH=`__SLICC_OUTPUT_TEE__`;function TH(e){let t=e?.get(CH);if(t===void 0)return;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>0?n:void 0}function EH(e){if(!(CH in e)&&!(wH in e)&&!(`__SLICC_SUDO_REASON`in e)&&!(`__SLICC_PIPESTATUS`in e)&&!(`__SLICC_PIPESTATUS_EX`in e))return{...e};let{[CH]:t,[wH]:n,[_m]:r,[yp]:i,[bp]:a,...o}=e;return o}function DH(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 OH=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(TH(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:hp,PATH:tr,USER:`user`,SHELL:`/bin/bash`,TMPDIR:`/tmp`,PWD:t,...e.env}}buildSupplementalCommands(e,t,n){return uH({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]}})}constructor(t){this.options=t,this.vfsAdapter=new yH(t.fs),this.progress=new jp({scrubLabel:t.scrubProgressLabel}),this.allowedCommands=e.buildAllowedCommandSet(t);let n=t.cwd??`/`,r=e.buildInitialEnv(t,n);this.gitCommands=new sp({fs:t.fs,authorName:r.GIT_AUTHOR_NAME??`User`,authorEmail:r.GIT_AUTHOR_EMAIL??`user@example.com`,ensureFreshGithubToken:xH}),this.mountCommands=new Ps({fs:t.fs,isScoop:t.isScoop,acquireLocalMountViaToolUI:wm});let i=t.jshDiscoveryFs??t.fs,a=t.bshDiscoveryFs??t.fs,o=bH(i)??bH(a);this.scriptCatalog=t.scriptCatalog??new gi({jshFs:i,bshFs:a,watcher:o}),this.ownsScriptCatalog=!t.scriptCatalog,o&&o.watch(`/`,e=>e.endsWith(`.jsh`)||e.endsWith(`.workflow.js`)||$n(e),()=>{this.syncJshCommands().catch(()=>void 0)});let s=this.createGitCustomCommand(),c=p({progress:Ip(this.progress)}),l=h({progress:Ip(this.progress)}),u=this.buildSupplementalCommands(t,c,l),d=[s,this.createMountCustomCommand(),this.createUmountCustomCommand(),vh(t.fs),hg(t.fs,c,t.browserAPI),...u].filter(e=>this.isCommandAllowed(e.name)),f=[...rt(),...nt()],m=this.allowedCommands?f.filter(e=>this.isCommandAllowed(e)):void 0;if(this.bash=new it({fs:this.vfsAdapter,cwd:n,env:{},fetch:c,commands:m,customCommands:d,sleep:rm(this.progress,{isAborted:()=>this.activeRunSignal?.aborted??!1}),executionLimitProfile:t.executionLimitProfile,executionLimits:lp(t.isScoop?.()??!1,t.executionLimits)}),this.bash.registerTransformPlugin(Mm),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 g=d.map(e=>e.name),_=m??[...rt(),...nt()];this.builtinCommandNames=new Set([..._,...g]),this.staticBuiltinNames=new Set(this.builtinCommandNames),this.vfsAdapter.setRegisteredCommandsFn(()=>[...this.builtinCommandNames]),this.lastEnv={...r},this.cwd=n,this.startInitialJshSync()}getBash(){return this.bash}getCwd(){return this.cwd}getScriptCatalog(){return this.scriptCatalog}getEnv(){return{...this.lastEnv}}setMaskedEnvVar(e,t){this.pendingEnvWrites.set(e,t),this.lastEnv[e]=t}applySessionOverrides(e){e.cwd!==void 0&&(this.cwd=e.cwd,this.lastEnv.PWD=e.cwd),e.env&&Object.assign(this.lastEnv,e.env)}async getJshCommandNames(){return[...(await this.getFilteredJshCommands()).keys()]}async syncJshCommands(){return this.jshSyncInflight===null?(this.jshSyncInflight=this.doSyncJshCommands(),this.jshSyncInflight):(this.jshSyncDirty=!0,this.jshSyncInflight)}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 Xr(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 nr(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 gp(e);this.lastEnv.HOME=t,this.options.env?.USER||(this.lastEnv.USER=_p(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){SH.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(pH(e.trim().split(/\s+/)[0]||`unknown`),m(),await this.waitForInitialJshSync(t),await this.usesGnuBash())return this.runOnGnuBash(e,t,n,r,i,a);let o=ym(e),s={env:{...this.lastEnv,...n===void 0?{}:{[CH]:String(n)},...i===void 0?{}:{[wH]:i},...o?{[_m]:o}:{}},cwd:this.cwd,umask:this.umask,signal:t,...r===``?{}:{stdin:r,stdinKind:`bytes`}},c=this.lastEnv.PATH,l=DH([t,this.commandAbort.signal]);s.signal=l.signal,this.activeRunSignal=l.signal;let u=this.beginScriptRun(e),d;try{d=await this.bash.exec(Tp(e,a),s)}finally{l.release(),this.activeRunSignal===l.signal&&(this.activeRunSignal=void 0),this.endScriptRun(u)}if(await this.flushPendingCommandGrants(),d=Ep(d,a),typeof d.umask==`number`&&(this.umask=d.umask),d.env&&(this.lastEnv=EH(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 Dp(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}=await import(`./run-ChsOHVUd.js`),s=ym(e),c={...this.lastEnv,...n===void 0?{}:{[CH]:String(n)},...s?{[_m]:s}:{}},l=i===void 0?void 0:this.outputTees.get(i),u=await mp(e,{env:c,run:(e,i,a)=>o(e,this.wasmContext(i,t,r),{processConfig:this.buildJshProcessConfig(n),gate:this.gateNativeCommand,onOutput:l,fds:a})}),d=this.lastEnv.PATH;return u.state&&(this.cwd=u.state.cwd,this.lastEnv=fp(u.state.env,[CH,_m,wH])),this.lastEnv.PATH!==d&&await this.syncJshCommands().catch(()=>void 0),await this.flushPendingCommandGrants(),this.applyPendingEnvWrites(),{stdout:u.stdout,stderr:u.stderr,exitCode:u.exitCode,env:{...this.lastEnv},...a&&u.state?{pipeStatus:u.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())return null;let r=await this.gateCommandDispatch(e,t,n[_m]);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`?sm(t,this.progress):lm(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(wH),s=o?a.get(o):void 0;s&&(t.writeStdout=s);try{let r=await dm(()=>n.execute(e,t),t.signal);return i(t.env,r),r}finally{r()}}}}teeCommandOutput(e,t){let n=e?.get(wH);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=Qp(this.bash.transform(e).ast,this.registryNames)}catch{t={totalSteps:null}}return this.scriptRun=new em(t,this.progress,$p(e)),this.scriptRun}endScriptRun(e){this.scriptRunsActive=Math.max(0,this.scriptRunsActive-1),e&&(e.end(),this.scriptRun===e&&(this.scriptRun=null))}wrapCommandForSudo(e){if(!this.isTransparentGatingEnabled())return e;let t=(t,n)=>this.gateCommandDispatch(e.name,t,n);return{...e,async execute(n,r){return await t(n,r.env?.get(_m))||e.execute(n,r)}}}async gateCommandDispatch(e,t,n){let r=this.options.sudo;if(!r)return null;let i=pm(e,t);if(this.consumeSudoBypass(i))return null;let a=r.getPolicy();if(!a)return null;let o=await hm(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(`
|
|
3498
|
-
`)?`${a}\n`:a;await i.writeFile(r,`${o}NOPASSWD Cmnd ${n}\n`)}isCommandAllowed(e){return this.allowedCommands===null||this.allowedCommands.has(e)}async doSyncJshCommands(){try{let e=await this.scriptCatalog.getJshIndex(this.currentScanRoots()),t=e.commands;for(let t of e.collisions)SH.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 $r(t,[`node`,o,...e],{fs:i.fs,cwd:i.cwd,env:i.env,stdin:i.stdin,exec:a},this.buildJshProcessConfig(TH(i.env)))}let s=(await t.getWasmCommands()).get(r);if(s){let{runWasmCommand:t}=await import(`./run-
|
|
3497
|
+
`,exitCode:1};let c=kt(o);return await t.fs.writeFile(i,c),{stdout:`created ${i} (${s} file(s))\n`,stderr:``,exitCode:0}})}function cH(e){return{setEnv:e.setEnv,unsetEnv:e.unsetEnv,broker:e.sudoCommand?.broker}}function lH(e){let{fs:t,fetch:n}=e;if(!t||!n)return[];let r={fs:t,fetch:n,scriptCatalog:e.scriptCatalog,syncScriptCommands:e.syncScriptCommands};return[vO(`ipk`,r),vO(`npm`,r),vO(`i`,r),sk(`ipx`,{fs:t,fetch:n}),sk(`npx`,{fs:t,fetch:n}),gb(`di`,{fs:t,fetch:n}),gb(`uv`,{fs:t,fetch:n}),PR({fs:t,fetch:n})]}function uH(e={}){let t=[wE({getJshCommands:e.getJshCommands,getWorkflowCommands:e.getWorkflowCommands}),ne(),xI(),BF(),NF(e.browserAPI,e.fs),gM(e.browserAPI),jy(e.browserAPI),kD(e),sH(),uR(),nL(e.fs?{fs:e.fs}:{}),OI(),FI(),MI(),Ev(),aB({buildProcessConfig:e.buildProcessConfig,terminal:e.terminal,gate:e.gateNativeCommand}),iH(),hI(`sqlite3`),hI(`sqllite`),yL(),zL(),Mx(),cv(),Nj({buildProcessConfig:e.buildProcessConfig}),Nj({buildProcessConfig:e.buildProcessConfig},`jsh`),MN(`python3`,{buildProcessConfig:e.buildProcessConfig}),MN(`python`,{buildProcessConfig:e.buildProcessConfig}),...lH(e),...e.fs?[XS({fs:e.fs})]:[],...e.fs?[GA({fs:e.fs})]:[],...e.fetch?[FE({fetch:e.fetch,streamFetch:e.streamFetch})]:[],TS(),ES(),RS(),bB(e.webhook),aV(),Ay(e.crontask),$k({fs:e.fs,scriptCatalog:e.scriptCatalog}),IM({fs:e.fs,fetch:e.fetch}),YS(),oI(),_M(),vM(`pdftk`),vM(`pdf`),lv(`biscotto`),lv(`biscotti`),OM(`pdftoppm`),OM(`pdftocairo`),kM(`pdftotext`),my(`convert`),my(`magick`),hV({fs:e.fs,scriptCatalog:e.scriptCatalog,getStaticBuiltins:e.getStaticBuiltins,getScriptRegisteredNames:e.getScriptRegisteredNames}),UL(),aR(),TD(),ED(),oR(),KA(),IN(),qk(),rx(),Jj(),qj(),Wk(),iF(cH(e)),YN({fs:e.fs}),SP(),Cv(),wv(),Tv(`xclip`),Tv(`xsel`),xP(),fC(),Pg(),Fg(),yj(e.fs),st(),Rj(),t_({getParentJid:e.getParentJid}),dx(),iN({processManager:e.processManager}),YR({processManager:e.processManager}),uk({processManager:e.processManager}),ck({processManager:e.processManager,scriptCatalog:e.scriptCatalog}),...i_(),WA(),Ik(),bz(),sD(),pS(),Iz({processManager:e.processManager}),kv({processManager:e.processManager,browser:e.browserAPI,sudoBroker:e.sudoCommand?.broker}),wS(),gv({registry:e.cherryRuntimeRegistry}),By(),Ky({fs:e.fs}),qy({fs:e.fs}),CI(e.sudoCommand),MV({getParentJid:e.getParentJid,syncScriptCommands:e.syncScriptCommands}),oV(),zF()];return e.fs&&(jM(),t.push(...zn.map(t=>xE(t,e.browserAPI,e.fs,{isScoop:e.isScoop})))),t}let dH=null;function fH(e){dH=e}function pH(e){dH?.(e)}var mH=Nt();const hH=Reflect.get(tt,`DefenseInDepthBox`);function gH(e){return(typeof e==`string`?e:e?.encoding)??`utf8`}function _H(e,t){if(typeof e!=`string`)return e;let n=gH(t);if(n===`binary`||n===`latin1`){let t=ge(e);if(t)return t}return mH.Buffer.from(e,n)}function vH(e){return e===`/bin`?`/usr/bin`:e.startsWith(`/bin/`)?`/usr${e}`:e}var yH=class{vfs;registeredCommandsFn=null;listingStats=new Map;listingStatsMax;listingStatsTtlMs;constructor(e,t){this.vfs=e,this.listingStatsMax=Math.max(1,t?.listingStatsMax??2e4),this.listingStatsTtlMs=t?.listingStatsTtlMs??1e3,this.updateMetadataBatch=this.updateMetadataBatch.bind(this),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}getVirtualBinCommands(){return this.registeredCommandsFn?.()??[]}virtualUsrStat(e){let t=vH(e);if(t===`/usr`||t===`/usr/bin`)return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date(0)};if(t.startsWith(`/usr/bin/`)){let e=t.slice(9);if(e.length>0&&!e.includes(`/`)&&this.getVirtualBinCommands().includes(e))return{isFile:!0,isDirectory:!1,isSymbolicLink:!1,mode:493,size:0,mtime:new Date(0)}}return null}canWrite(e){let t=this.vfs;return typeof t.canWrite!=`function`||t.canWrite(e)}listMountPoints(){let e=this.vfs;return typeof e.listMountPoints==`function`?e.listMountPoints():[]}trusted(e){let t=hH?.runTrustedAsync;return t?t(e):Promise.resolve().then(e)}async readFile(e,t){return this.trusted(async()=>{let n=b(e),r=await this.vfs.readFile(n,{encoding:`binary`}),i=r instanceof Uint8Array?r:new TextEncoder().encode(r),a=gH(t),o=mH.Buffer.from(i.buffer,i.byteOffset,i.byteLength).toString(a);return a!==`hex`&&a!==`base64`&&g(o,i),o})}async readFileBuffer(e){return this.trusted(async()=>{let t=b(e),n=await this.vfs.readFile(t,{encoding:`binary`});return n instanceof Uint8Array?n:new TextEncoder().encode(n)})}async readFileBytes(e){let t=await this.readFileBuffer(e);return mH.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,_H(t,n))})}async appendFile(e,t,n){return this.dropListingStats(),this.trusted(()=>this.vfs.appendFile(b(e),_H(t,n)))}async exists(e){return this.trusted(async()=>{let t=b(e);return this.virtualUsrStat(t)?!0:this.vfs.exists(t)})}async stat(e){return this.trusted(async()=>{let t=b(e),n=this.virtualUsrStat(t);if(n)return n;let r=this.vfs.statSync(t);if(r)return{isFile:r.type===`file`,isDirectory:r.type===`directory`,isSymbolicLink:!!r.isSymlink,mode:r.mode??(r.type===`directory`?493:420),size:r.size,mtime:new Date(r.mtime),identity:r.identity,dev:r.dev,ino:r.identity===void 0?void 0:r.ino};let i=this.primedStats(t)??await this.vfs.stat(t);return{isFile:i.type===`file`,isDirectory:i.type===`directory`,isSymbolicLink:!!i.isSymlink,mode:i.mode??(i.type===`directory`?493:420),size:i.size,mtime:new Date(i.mtime),identity:i.identity,dev:i.dev,ino:i.identity===void 0?void 0:i.ino}})}async lstat(e){return this.trusted(async()=>{let t=b(e),n=this.virtualUsrStat(t);if(n)return n;let r=this.vfs.lstatSync(t);if(r)return{isFile:r.type===`file`,isDirectory:r.type===`directory`,isSymbolicLink:r.type===`symlink`,mode:r.mode??(r.type===`directory`?493:r.type===`symlink`?511:420),size:r.size,mtime:new Date(r.mtime),identity:r.identity,dev:r.dev,ino:r.identity===void 0?void 0:r.ino};let i=this.primedStats(t)??await this.vfs.lstat(t);return{isFile:i.type===`file`,isDirectory:i.type===`directory`,isSymbolicLink:i.type===`symlink`,mode:i.mode??(i.type===`directory`?493:i.type===`symlink`?511:420),size:i.size,mtime:new Date(i.mtime),identity:i.identity,dev:i.dev,ino:i.identity===void 0?void 0:i.ino}})}async mkdir(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.mkdir(b(e),t)})}async readdir(e){return this.trusted(async()=>{let t=b(e);if(t===`/usr`)return[`bin`];if(vH(t)===`/usr/bin`)return this.getVirtualBinCommands().slice().sort();let n=this.vfs.readDirSync(t);if(n!==null)return n.map(e=>e.name);let r=await this.vfs.readDir(t,{includeStats:!0});return this.primeListingStats(t,r),r.map(e=>e.name)})}async readdirWithFileTypes(e){return this.trusted(async()=>{let t=b(e);if(t===`/usr`)return[{name:`bin`,isFile:!1,isDirectory:!0,isSymbolicLink:!1}];if(vH(t)===`/usr/bin`)return this.getVirtualBinCommands().slice().sort().map(e=>({name:e,isFile:!0,isDirectory:!1,isSymbolicLink:!1}));let n=this.vfs.readDirSync(t);if(n!==null)return this.mapFastEntriesToDirents(n);let r=await this.vfs.readDir(t,{includeStats:!0});return this.primeListingStats(t,r),this.mapAsyncEntriesToDirents(r)})}mapFastEntriesToDirents(e){return e.map(e=>this.entryToDirent(e))}mapAsyncEntriesToDirents(e){return e.map(e=>this.entryToDirent(e))}entryToDirent(e){return e.type===`symlink`?{name:e.name,isFile:!1,isDirectory:!1,isSymbolicLink:!0}:{name:e.name,isFile:e.type===`file`,isDirectory:e.type===`directory`,isSymbolicLink:!1}}async rm(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.rm(b(e),t)})}async cp(e,t,n){return this.dropListingStats(),this.trusted(async()=>{let r=b(e),i=b(t);if((await this.vfs.stat(r)).type===`directory`){if(!n?.recursive)throw new 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)}}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 bH(e){return e&&typeof e.getWatcher==`function`?e.getWatcher?.()??null:e&&typeof e.getUnderlyingFS==`function`?bH(e.getUnderlyingFS?.()):null}async function xH(e){let t=he(`github`);if(t){if(e?.force){await t.onSilentRenew?.();return}await t.getValidAccessToken?.()}}const SH=e(`almost-bash-shell`),CH=`__SLICC_RUN_PID`,wH=`__SLICC_OUTPUT_TEE__`;function TH(e){let t=e?.get(CH);if(t===void 0)return;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>0?n:void 0}function EH(e){if(!(CH in e)&&!(wH in e)&&!(`__SLICC_SUDO_REASON`in e)&&!(`__SLICC_PIPESTATUS`in e)&&!(`__SLICC_PIPESTATUS_EX`in e))return{...e};let{[CH]:t,[wH]:n,[_m]:r,[yp]:i,[bp]:a,...o}=e;return o}function DH(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 OH=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(TH(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:hp,PATH:tr,USER:`user`,SHELL:`/bin/bash`,TMPDIR:`/tmp`,PWD:t,...e.env}}buildSupplementalCommands(e,t,n){return uH({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]}})}constructor(t){this.options=t,this.vfsAdapter=new yH(t.fs),this.progress=new jp({scrubLabel:t.scrubProgressLabel}),this.allowedCommands=e.buildAllowedCommandSet(t);let n=t.cwd??`/`,r=e.buildInitialEnv(t,n);this.gitCommands=new sp({fs:t.fs,authorName:r.GIT_AUTHOR_NAME??`User`,authorEmail:r.GIT_AUTHOR_EMAIL??`user@example.com`,ensureFreshGithubToken:xH}),this.mountCommands=new Ps({fs:t.fs,isScoop:t.isScoop,acquireLocalMountViaToolUI:wm});let i=t.jshDiscoveryFs??t.fs,a=t.bshDiscoveryFs??t.fs,o=bH(i)??bH(a);this.scriptCatalog=t.scriptCatalog??new gi({jshFs:i,bshFs:a,watcher:o}),this.ownsScriptCatalog=!t.scriptCatalog,o&&o.watch(`/`,e=>e.endsWith(`.jsh`)||e.endsWith(`.workflow.js`)||$n(e),()=>{this.syncJshCommands().catch(()=>void 0)});let s=this.createGitCustomCommand(),c=p({progress:Ip(this.progress)}),l=h({progress:Ip(this.progress)}),u=this.buildSupplementalCommands(t,c,l),d=[s,this.createMountCustomCommand(),this.createUmountCustomCommand(),vh(t.fs),hg(t.fs,c,t.browserAPI),...u].filter(e=>this.isCommandAllowed(e.name)),f=[...rt(),...nt()],m=this.allowedCommands?f.filter(e=>this.isCommandAllowed(e)):void 0;if(this.bash=new it({fs:this.vfsAdapter,cwd:n,env:{},fetch:c,commands:m,customCommands:d,sleep:rm(this.progress,{isAborted:()=>this.activeRunSignal?.aborted??!1}),executionLimitProfile:t.executionLimitProfile,executionLimits:lp(t.isScoop?.()??!1,t.executionLimits)}),this.bash.registerTransformPlugin(Mm),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 g=d.map(e=>e.name),_=m??[...rt(),...nt()];this.builtinCommandNames=new Set([..._,...g]),this.staticBuiltinNames=new Set(this.builtinCommandNames),this.vfsAdapter.setRegisteredCommandsFn(()=>[...this.builtinCommandNames]),this.lastEnv={...r},this.cwd=n,this.startInitialJshSync()}getBash(){return this.bash}getCwd(){return this.cwd}getScriptCatalog(){return this.scriptCatalog}getEnv(){return{...this.lastEnv}}setMaskedEnvVar(e,t){this.pendingEnvWrites.set(e,t),this.lastEnv[e]=t}applySessionOverrides(e){e.cwd!==void 0&&(this.cwd=e.cwd,this.lastEnv.PWD=e.cwd),e.env&&Object.assign(this.lastEnv,e.env)}async getJshCommandNames(){return[...(await this.getFilteredJshCommands()).keys()]}async syncJshCommands(){return this.jshSyncInflight===null?(this.jshSyncInflight=this.doSyncJshCommands(),this.jshSyncInflight):(this.jshSyncDirty=!0,this.jshSyncInflight)}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 Xr(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 nr(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 gp(e);this.lastEnv.HOME=t,this.options.env?.USER||(this.lastEnv.USER=_p(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){SH.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(pH(e.trim().split(/\s+/)[0]||`unknown`),m(),await this.waitForInitialJshSync(t),await this.usesGnuBash())return this.runOnGnuBash(e,t,n,r,i,a);let o=ym(e),s={env:{...this.lastEnv,...n===void 0?{}:{[CH]:String(n)},...i===void 0?{}:{[wH]:i},...o?{[_m]:o}:{}},cwd:this.cwd,umask:this.umask,signal:t,...r===``?{}:{stdin:r,stdinKind:`bytes`}},c=this.lastEnv.PATH,l=DH([t,this.commandAbort.signal]);s.signal=l.signal,this.activeRunSignal=l.signal;let u=this.beginScriptRun(e),d;try{d=await this.bash.exec(Tp(e,a),s)}finally{l.release(),this.activeRunSignal===l.signal&&(this.activeRunSignal=void 0),this.endScriptRun(u)}if(await this.flushPendingCommandGrants(),d=Ep(d,a),typeof d.umask==`number`&&(this.umask=d.umask),d.env&&(this.lastEnv=EH(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 Dp(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}=await import(`./run-Bx861p9q.js`),s=ym(e),c={...this.lastEnv,...n===void 0?{}:{[CH]:String(n)},...s?{[_m]:s}:{}},l=i===void 0?void 0:this.outputTees.get(i),u=await mp(e,{env:c,run:(e,i,a)=>o(e,this.wasmContext(i,t,r),{processConfig:this.buildJshProcessConfig(n),gate:this.gateNativeCommand,onOutput:l,fds:a})}),d=this.lastEnv.PATH;return u.state&&(this.cwd=u.state.cwd,this.lastEnv=fp(u.state.env,[CH,_m,wH])),this.lastEnv.PATH!==d&&await this.syncJshCommands().catch(()=>void 0),await this.flushPendingCommandGrants(),this.applyPendingEnvWrites(),{stdout:u.stdout,stderr:u.stderr,exitCode:u.exitCode,env:{...this.lastEnv},...a&&u.state?{pipeStatus:u.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())return null;let r=await this.gateCommandDispatch(e,t,n[_m]);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`?sm(t,this.progress):lm(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(wH),s=o?a.get(o):void 0;s&&(t.writeStdout=s);try{let r=await dm(()=>n.execute(e,t),t.signal);return i(t.env,r),r}finally{r()}}}}teeCommandOutput(e,t){let n=e?.get(wH);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=Qp(this.bash.transform(e).ast,this.registryNames)}catch{t={totalSteps:null}}return this.scriptRun=new em(t,this.progress,$p(e)),this.scriptRun}endScriptRun(e){this.scriptRunsActive=Math.max(0,this.scriptRunsActive-1),e&&(e.end(),this.scriptRun===e&&(this.scriptRun=null))}wrapCommandForSudo(e){if(!this.isTransparentGatingEnabled())return e;let t=(t,n)=>this.gateCommandDispatch(e.name,t,n);return{...e,async execute(n,r){return await t(n,r.env?.get(_m))||e.execute(n,r)}}}async gateCommandDispatch(e,t,n){let r=this.options.sudo;if(!r)return null;let i=pm(e,t);if(this.consumeSudoBypass(i))return null;let a=r.getPolicy();if(!a)return null;let o=await hm(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(`
|
|
3498
|
+
`)?`${a}\n`:a;await i.writeFile(r,`${o}NOPASSWD Cmnd ${n}\n`)}isCommandAllowed(e){return this.allowedCommands===null||this.allowedCommands.has(e)}async doSyncJshCommands(){try{let e=await this.scriptCatalog.getJshIndex(this.currentScanRoots()),t=e.commands;for(let t of e.collisions)SH.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 $r(t,[`node`,o,...e],{fs:i.fs,cwd:i.cwd,env:i.env,stdin:i.stdin,exec:a},this.buildJshProcessConfig(TH(i.env)))}let s=(await t.getWasmCommands()).get(r);if(s){let{runWasmCommand:t}=await import(`./run-Bx861p9q.js`);return t([`--argv0`,s.argv0,`--module`,s.wasm,s.glue,...e],i,{processConfig:this.buildJshProcessConfig(TH(i.env)),gate:this.gateNativeCommand,defaults:s.env})}let c=(await t.getWorkflowCommands()).get(r);if(c){let t=hi(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?vp(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 $r(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{Sa as C,jo as S,Ko as _,SV as a,Ma as b,Ap as c,ws as d,_s as f,qo as g,ds as h,vV as i,hp as l,ps as m,yH as n,gV as o,ms as p,fH as r,gm as s,OH as t,Ts as u,Lo as v,ja as x,Oa as y};
|