sliccy 6.173.6 → 6.174.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/node-server/_shared/proxy-headers.d.ts +9 -0
- package/dist/node-server/_shared/proxy-headers.d.ts.map +1 -1
- package/dist/node-server/_shared/proxy-headers.js +12 -0
- package/dist/node-server/_shared/proxy-headers.js.map +1 -1
- package/dist/node-server/_shared/tray-sync-protocol.d.ts +19 -0
- package/dist/node-server/_shared/tray-sync-protocol.d.ts.map +1 -1
- package/dist/node-server/_shared/tray-sync-protocol.js.map +1 -1
- package/dist/node-server/bridge-security.js +4 -3
- package/dist/node-server/fetch-proxy-headers.js +1 -0
- package/dist/node-server/routes/fetch-proxy.js +8 -2
- package/dist/ui/.vite/manifest.json +249 -249
- package/dist/ui/assets/SKILL-B_vSLfiC.js +1 -0
- package/dist/ui/assets/{account-store-D83RaetR.js → account-store-CDXeAYze.js} +1 -1
- package/dist/ui/assets/{account-store-CoyslJ3K.js → account-store-DSPpsyER.js} +2 -2
- package/dist/ui/assets/{adobe-BlxDeK6W.js → adobe-B3aAAtCn.js} +1 -1
- package/dist/ui/assets/{adobe-Drxr5UYr.js → adobe-BXnbK_bW.js} +2 -2
- package/dist/ui/assets/{agent-panels-BUQrQelp.js → agent-panels-DFPv3ZaM.js} +1 -1
- package/dist/ui/assets/{almost-bash-shell-headless-D8l53ykE.js → almost-bash-shell-headless-DZEyLKy6.js} +114 -107
- package/dist/ui/assets/{apply-layout-B0G4YPUy.js → apply-layout-BKBn5ifk.js} +1 -1
- package/dist/ui/assets/{apps-eoZzhQzf.js → apps-CrxAbeAz.js} +1 -1
- package/dist/ui/assets/{azure-openai-dqLRWGNr.js → azure-openai-BgGWZh7o.js} +1 -1
- package/dist/ui/assets/{azure-openai-D2uD7aXY.js → azure-openai-DvKSXXxQ.js} +1 -1
- package/dist/ui/assets/{backend-hostfs-DQtwG6Im.js → backend-hostfs-CBKo87g2.js} +1 -1
- package/dist/ui/assets/{capability-SIitRcq_.js → capability-Ozyg0pIj.js} +2 -2
- package/dist/ui/assets/{cdp-B3Z1iwwA.js → cdp-BZ5hqgkH.js} +1 -1
- package/dist/ui/assets/{cerebras-b-8UO3Z3.js → cerebras-3lMC5DMW.js} +1 -1
- package/dist/ui/assets/{cerebras-Bj3Ow_0A.js → cerebras-B52Lw-RW.js} +1 -1
- package/dist/ui/assets/client-GY8xUpw7.js +4 -0
- package/dist/ui/assets/{composer-speech-DcOZpM4q.js → composer-speech-CwdSXfak.js} +1 -1
- package/dist/ui/assets/{connect-surface-Crb-5gbp.js → connect-surface-xGyfavSn.js} +1 -1
- package/dist/ui/assets/{core-DWdpOAZd.js → core-DzCO93gg.js} +1 -1
- package/dist/ui/assets/{core-w0-0FXns.js → core-NCt3m1n7.js} +1 -1
- package/dist/ui/assets/coverage-instrument-CjoHgKzK.js +20 -0
- package/dist/ui/assets/{directed-approval-0yi5vf8n.js → directed-approval-BdVTU42Z.js} +1 -1
- package/dist/ui/assets/{discovery-preference-G3mw_EUO.js → discovery-preference-DETLSUyX.js} +1 -1
- package/dist/ui/assets/{ensure-speech-assets-BZUpcquF.js → ensure-speech-assets-BtFktw9h.js} +1 -1
- package/dist/ui/assets/{extension-ops-B2RMipFn.js → extension-ops-2LnlLuXD.js} +1 -1
- package/dist/ui/assets/{float-topology-CyZCUfkj.js → float-topology-BYFyBtfs.js} +1 -1
- package/dist/ui/assets/{follower-navigate-watcher-BAstHBQ5.js → follower-navigate-watcher-CikMiDmz.js} +1 -1
- package/dist/ui/assets/{frozen-archive-writer-DIOuhz2G.js → frozen-archive-writer-Dkh2oIdl.js} +1 -1
- package/dist/ui/assets/{fs-B0fs_qLm.js → fs-BjjYK9VY.js} +1 -1
- package/dist/ui/assets/{fs--4C74S0K.js → fs-Cw_2bYAM.js} +2 -2
- package/dist/ui/assets/{gelatiere-store-DgHzYrsk.js → gelatiere-store-BPbm7LbJ.js} +1 -1
- package/dist/ui/assets/{gelatiere-unit-BwzYXE9F.js → gelatiere-unit-B7kSBWVP.js} +1 -1
- package/dist/ui/assets/{github-BEHC4Fr9.js → github-Dp2gtGvR.js} +1 -1
- package/dist/ui/assets/{github-auth-BDKUEfX_.js → github-auth-B7p5l36m.js} +1 -1
- package/dist/ui/assets/{github-copilot-ETtaDtJ_.js → github-copilot-Cl8XllPb.js} +1 -1
- package/dist/ui/assets/{github-copilot-CO6175Ko.js → github-copilot-jhyDV7Lg.js} +1 -1
- package/dist/ui/assets/{github-U981jKU8.js → github-ggCJDb9L.js} +2 -2
- package/dist/ui/assets/{github-install-DBEDVo0L.js → github-install-DTmIqVHt.js} +1 -1
- package/dist/ui/assets/{github-zip-C8TQwjyj.js → github-zip-BhnRGzD6.js} +1 -1
- package/dist/ui/assets/{guest-tool-gate-C6sp1l3H.js → guest-tool-gate-DImAU5XR.js} +1 -1
- package/dist/ui/assets/{hear-fcQhxHjM.js → hear-BvYOLsdb.js} +1 -1
- package/dist/ui/assets/{help-B0cBctpG.js → help-Byyp6Pcv.js} +1 -1
- package/dist/ui/assets/{host-command-BJLYDTCR.js → host-command-5ESITqj8.js} +1 -1
- package/dist/ui/assets/{installer-BeY2oJma.js → installer-CAPOWOiB.js} +1 -1
- package/dist/ui/assets/{interrupted-work-recovery-p8rpTJ6o.js → interrupted-work-recovery-DfZ1NojB.js} +1 -1
- package/dist/ui/assets/{js-realm-worker-D7PL-6kk.js → js-realm-worker-X2VIj-Na.js} +1 -1
- package/dist/ui/assets/{jsh-executor-Co2HK2VT.js → jsh-executor-DbpfbKzV.js} +2 -2
- package/dist/ui/assets/{kernel-worker-YNYryr6x.js → kernel-worker-DVDNaQZZ.js} +10 -10
- package/dist/ui/assets/{lick-ws-bridge-D8f46MUd.js → lick-ws-bridge-CqmNMdGO.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-C4-cFLcU.js → lick-ws-bridge-Y0GH_wJq.js} +1 -1
- package/dist/ui/assets/{live-session-snapshot-Brw0rT2j.js → live-session-snapshot-5FWkefDU.js} +1 -1
- package/dist/ui/assets/{local-llm-DFilOR_e.js → local-llm-B6veJ_ef.js} +1 -1
- package/dist/ui/assets/{local-llm-Dn6ejNUW.js → local-llm-CED8ADMA.js} +1 -1
- package/dist/ui/assets/{main-De32EVTt.js → main-2iTv-J5c.js} +3 -3
- package/dist/ui/assets/{main-cherry-BdBbI6Kw.js → main-cherry-C7l1nuXL.js} +1 -1
- package/dist/ui/assets/{memory-curation-seam-C0Jbi83u.js → memory-curation-seam-DQ5obo1q.js} +1 -1
- package/dist/ui/assets/{memory-health-COoWahef.js → memory-health-DWog3bzV.js} +1 -1
- package/dist/ui/assets/memory-v2-flag-bEVVkrvI.js +1 -0
- package/dist/ui/assets/{memory-write-execute-CKRXW0Xv.js → memory-write-execute-emoQbf9q.js} +1 -1
- package/dist/ui/assets/{mount-DxbjX2Co.js → mount-C948i4KJ.js} +3 -3
- package/dist/ui/assets/{mount-BLglsYUl.js → mount-CaX4-s5m.js} +1 -1
- package/dist/ui/assets/{mount-bridge-client-BOZDQLbT.js → mount-bridge-client-Cvu7boPy.js} +1 -1
- package/dist/ui/assets/{mount-bridge-client-BRywSH1d.js → mount-bridge-client-DYjwnGiI.js} +1 -1
- package/dist/ui/assets/{new-session--3r6d-rq.js → new-session-BZEGrhPF.js} +2 -2
- package/dist/ui/assets/{oauth-bootstrap-BkwHC4HC.js → oauth-bootstrap-wCbMfvXb.js} +2 -2
- package/dist/ui/assets/{oauth-service-CRmx6zI1.js → oauth-service-DLGjPRxS.js} +1 -1
- package/dist/ui/assets/{oauth-service-WTeDvR5m.js → oauth-service-JZ31fJQ0.js} +1 -1
- package/dist/ui/assets/{onboarding-orchestrator-dXSFMVgf.js → onboarding-orchestrator-B30-qpNm.js} +1 -1
- package/dist/ui/assets/{openai-codex-B7dMfLAG.js → openai-codex-BkPZlmwD.js} +1 -1
- package/dist/ui/assets/{openai-codex-CV4AoPzt.js → openai-codex-DUSNBnHV.js} +1 -1
- package/dist/ui/assets/{openrouter-N64TWXjF.js → openrouter-BqJT2iaF.js} +1 -1
- package/dist/ui/assets/{openrouter-DmJq2bIz.js → openrouter-WvoH761e.js} +1 -1
- package/dist/ui/assets/{openrouter-free-C-DIROA7.js → openrouter-free-FwYHT08L.js} +1 -1
- package/dist/ui/assets/{openrouter-free-C-rMYEyX.js → openrouter-free-fFdXDN5u.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-DeYY4W1D.js → openrouter-oauth-BVogmvFn.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-Cnn1o-Am.js → openrouter-oauth-BXAfL40-.js} +1 -1
- package/dist/ui/assets/{opfs-mount-aghtPclC.js → opfs-mount-mwDa35fW.js} +1 -1
- package/dist/ui/assets/{page-approval-service-BkqDCbBQ.js → page-approval-service-Dz1E4_a-.js} +1 -1
- package/dist/ui/assets/{panel-rpc-BPwAqRch.js → panel-rpc-DVS1uJpt.js} +1 -1
- package/dist/ui/assets/{panel-rpc-handlers-DCBSIp7z.js → panel-rpc-handlers-1PDaTKzV.js} +2 -2
- package/dist/ui/assets/{panelize-shell-E8Ehnf-M.js → panelize-shell-B05YN5rd.js} +1 -1
- package/dist/ui/assets/{pi-edit-execution-CozHyqew.js → pi-edit-execution-DW6yaKJo.js} +1 -1
- package/dist/ui/assets/{port-bridge-client-CZFX4fUT.js → port-bridge-client-CIPpFep1.js} +1 -1
- package/dist/ui/assets/{port-bridge-client-CkkC3v5w.js → port-bridge-client-nVkmNLtE.js} +1 -1
- package/dist/ui/assets/{provider-BCX_VQzU.js → provider-CP2FrBD1.js} +1 -1
- package/dist/ui/assets/{provider-BoofFfY6.js → provider-CyUQmCNr.js} +2 -2
- package/dist/ui/assets/{provider-settings-CBXm-_ol.js → provider-settings-eD9-CdTW.js} +1 -1
- package/dist/ui/assets/provider-store-access-HGzRhSvy.js +1 -0
- package/dist/ui/assets/provider-store-access-VH16-Et2.js +1 -0
- package/dist/ui/assets/{providers--EwqZSik.js → providers-CRB366Q3.js} +2 -2
- package/dist/ui/assets/{providers-Dz0oI_I_.js → providers-XoHqlC-q.js} +1 -1
- package/dist/ui/assets/{proxied-fetch-CnCvBaGV.js → proxied-fetch-CUw_f_qQ.js} +1 -1
- package/dist/ui/assets/proxied-fetch-D6EBne5P.js +1 -0
- package/dist/ui/assets/{quick-llm-CCDAB7W0.js → quick-llm-D8yJ5aCy.js} +1 -1
- package/dist/ui/assets/{realm-inprocess-jb-eavxM.js → realm-inprocess-vrLSOBJx.js} +1 -1
- package/dist/ui/assets/{recovery-screen-GaSZsHfe.js → recovery-screen-BNmxwA3-.js} +1 -1
- package/dist/ui/assets/{redirect-uri-D2aDPCyB.js → redirect-uri-C-c6wFfz.js} +1 -1
- package/dist/ui/assets/{remote-terminal-view-DHybE9f5.js → remote-terminal-view-CyWEIsvq.js} +1 -1
- package/dist/ui/assets/{rest-ops-Yu_dXm4T.js → rest-ops-2kW9P3JM.js} +1 -1
- package/dist/ui/assets/{rest-ops-aP40ni1y.js → rest-ops-DBG2rYMP.js} +1 -1
- package/dist/ui/assets/{restore-Do1V9Vkz.js → restore-CL9_UXh6.js} +1 -1
- package/dist/ui/assets/{run-DZ1XSYMo.js → run-AEc54ckO.js} +2 -2
- package/dist/ui/assets/{run-BCqBkVk2.js → run-BDv7ZbKM.js} +1 -1
- package/dist/ui/assets/{run-DgYl0bVk.js → run-BFBGwUPV.js} +3 -3
- package/dist/ui/assets/{run-5qk0wmMN.js → run-BI7sTnua.js} +3 -3
- package/dist/ui/assets/{run-mVpvcDi1.js → run-BkjrFIPc.js} +1 -1
- package/dist/ui/assets/{run-MUpVN_eu.js → run-BzjnYE1_.js} +2 -2
- package/dist/ui/assets/{run-QfVNOBuX.js → run-C7DSv_4z.js} +2 -2
- package/dist/ui/assets/{run-3fPaLUnY.js → run-CMIBcXTS.js} +1 -1
- package/dist/ui/assets/{run-q3LJN-6v.js → run-DK8nktud.js} +1 -1
- package/dist/ui/assets/{run-CreCrLyX.js → run-DLiMjFBS.js} +1 -1
- package/dist/ui/assets/{run-C43Eohyd.js → run-dNFrBZDI.js} +1 -1
- package/dist/ui/assets/{screen-s6LdF1JP.js → screen-C5DDwz1F.js} +1 -1
- package/dist/ui/assets/{screencapture-run-zmx5QKf_.js → screencapture-run-CoYnKG1H.js} +1 -1
- package/dist/ui/assets/{secret-env-DgrZZVFU.js → secret-env-Plkbj3bZ.js} +1 -1
- package/dist/ui/assets/secret-topology-CYhWCLbt.js +1 -0
- package/dist/ui/assets/{secrets-bridge-client-BJqZCK6Q.js → secrets-bridge-client-DB1JAAHL.js} +1 -1
- package/dist/ui/assets/{secrets-bridge-client-CeK7HpDf.js → secrets-bridge-client-nOf1jubu.js} +1 -1
- package/dist/ui/assets/{session-command-memory-DpGJ9X-0.js → session-command-memory-CkGlqxMy.js} +2 -2
- package/dist/ui/assets/{session-jsonl-BJUiRviB.js → session-jsonl-BF-5_KrL.js} +1 -1
- package/dist/ui/assets/{session-jsonl-45aLhXBH.js → session-jsonl-BLFP_6Ii.js} +1 -1
- package/dist/ui/assets/{session-search-index-Bk9sCu3h.js → session-search-index-xg5DvCwK.js} +1 -1
- package/dist/ui/assets/{setup-feature-flags-remote-YSOTFePu.js → setup-feature-flags-remote-Buvq9-IJ.js} +1 -1
- package/dist/ui/assets/{signed-fetch-BUx8lpSN.js → signed-fetch-BVSCXSzZ.js} +1 -1
- package/dist/ui/assets/{silent-renew-backoff-CvQGo0bE.js → silent-renew-backoff-DW5hzrBT.js} +1 -1
- package/dist/ui/assets/slicc-version-Doo30hXa.js +1 -0
- package/dist/ui/assets/{snapshot-CfWTb-Vt.js → snapshot-Br4Fps5z.js} +1 -1
- package/dist/ui/assets/{snapshot-features-BrkZDXTW.js → snapshot-features-B_aMougo.js} +1 -1
- package/dist/ui/assets/{soundscape-Cn7B6Rtm.js → soundscape-jhHin1Xo.js} +1 -1
- package/dist/ui/assets/{speak-DnS87OYM.js → speak-tgqwR-dQ.js} +1 -1
- package/dist/ui/assets/{sprinkle-manager-CglKZNsS.js → sprinkle-manager-xLrk-JV0.js} +1 -1
- package/dist/ui/assets/{sprinkle-renderer-DDEUNGTB.js → sprinkle-renderer-CU17tlEP.js} +1 -1
- package/dist/ui/assets/{ssh-Cv7xXFQ2.js → ssh-hdAOAXd4.js} +1 -1
- package/dist/ui/assets/{state-KqYYAZMz.js → state-DK8S4qLC.js} +1 -1
- package/dist/ui/assets/{store-DzpRa7xy.js → store-BaPEf7w5.js} +1 -1
- package/dist/ui/assets/{store-DGZwBoWM.js → store-BuVY3ZgP.js} +1 -1
- package/dist/ui/assets/{sudo-03OWCqcB.js → sudo-D0k_0Iiy.js} +1 -1
- package/dist/ui/assets/{supervisor-jFFa_2cn.js → supervisor-DP0ZHn5z.js} +1 -1
- package/dist/ui/assets/{sync-dialog-Br5yAk0N.js → sync-dialog-D3862EzR.js} +1 -1
- package/dist/ui/assets/{transformers-env-CD8oT6gB.js → transformers-env-IZuYOmBX.js} +1 -1
- package/dist/ui/assets/{tray-leader-BWjdUCWF.js → tray-leader-azxIi7rJ.js} +1 -1
- package/dist/ui/assets/{tray-leave-runtime-Ba-3i4QZ.js → tray-leave-runtime-CoDtxQV7.js} +1 -1
- package/dist/ui/assets/{tray-runtime-config-dyxCfUex.js → tray-runtime-config-CdGCS5ij.js} +1 -1
- package/dist/ui/assets/{tray-sidecar-CuUb5xnY.js → tray-sidecar-C0-hqQur.js} +1 -1
- package/dist/ui/assets/{turn-journal-CyInnakf.js → turn-journal-Bs0f1xVJ.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-S4KvXBSQ.js → upgrade-detection-CNAzDDet.js} +1 -1
- package/dist/ui/assets/{upskill-lick-skip-CHc2Eeit.js → upskill-lick-skip-DAgLwgHG.js} +1 -1
- package/dist/ui/assets/{voice-reply-BV4BxXWq.js → voice-reply-OZtT_11b.js} +1 -1
- package/dist/ui/assets/{wc-attach-H7otf6xn.js → wc-attach-CQRK5HfC.js} +2 -2
- package/dist/ui/assets/{wc-browser-D4Awp-9F.js → wc-browser-U_xxltEH.js} +1 -1
- package/dist/ui/assets/{wc-computers-CzaU6VBs.js → wc-computers-UgD3jpnJ.js} +1 -1
- package/dist/ui/assets/{wc-detached-P7p2Rvsy.js → wc-detached-CRhnTzGv.js} +1 -1
- package/dist/ui/assets/{wc-extension-BBxAvGBg.js → wc-extension-BPNoDlrO.js} +2 -2
- package/dist/ui/assets/{wc-follower-DTt17LO2.js → wc-follower-BMjuwmaH.js} +3 -3
- package/dist/ui/assets/{wc-follower-oauth-CsZMW3Yo.js → wc-follower-oauth-CA_WM7zP.js} +1 -1
- package/dist/ui/assets/{wc-gelatiere-CmmXE6Rk.js → wc-gelatiere-DUTgXME6.js} +1 -1
- package/dist/ui/assets/{wc-live-yAsFosPL.js → wc-live-BAQ7D2zb.js} +5 -5
- package/dist/ui/assets/{wc-nav-BkfyT42w.js → wc-nav-CCMyp5Zb.js} +2 -2
- package/dist/ui/assets/{wc-onboarding-Dymctkkc.js → wc-onboarding-DO-CCOxL.js} +2 -2
- package/dist/ui/assets/{wc-permissions-B0_jjtWa.js → wc-permissions-CfY4qZeE.js} +2 -2
- package/dist/ui/assets/{wc-placeholder-Bx_3GJMJ.js → wc-placeholder-DBYMq9N6.js} +3 -3
- package/dist/ui/assets/{wc-secret-request-C3uEwBTf.js → wc-secret-request-BPaxBjDh.js} +1 -1
- package/dist/ui/assets/{wc-settings-BHZTNA2z.js → wc-settings-BEPacGf0.js} +3 -3
- package/dist/ui/assets/{wc-shell-DlV6puxN.js → wc-shell-C5v9tSwt.js} +3 -3
- package/dist/ui/assets/{wc-shortcut-config-DpKzT219.js → wc-shortcut-config-BfWjijii.js} +1 -1
- package/dist/ui/assets/{wc-sprinkles-CPk0k0YE.js → wc-sprinkles-CilQw7jr.js} +2 -2
- package/dist/ui/assets/{wc-transcript-export-DoiLRFXI.js → wc-transcript-export-BwNsBIr6.js} +2 -2
- package/dist/ui/assets/wc-tray-BW6eaWfx.js +5 -0
- package/dist/ui/assets/welcome-detection-CQPo-8Su.js +1 -0
- package/dist/ui/assets/{whisper-session-RGGaAVmE.js → whisper-session-BXq1fTR6.js} +2 -2
- package/dist/ui/assets/{xai-grok-38edIGhF.js → xai-grok-Cq3J9Wgd.js} +1 -1
- package/dist/ui/assets/{xai-grok-B1jd0jyL.js → xai-grok-CskrH1tU.js} +1 -1
- package/dist/ui/index.html +9 -9
- package/dist/ui/llm-proxy-sw.js +1 -1
- package/dist/ui/packages/webapp/index.html +9 -9
- package/package.json +1 -1
- package/dist/ui/assets/SKILL-CszQ22CT.js +0 -1
- package/dist/ui/assets/client-_vVqanZy.js +0 -4
- package/dist/ui/assets/memory-v2-flag-DqJQCWEj.js +0 -1
- package/dist/ui/assets/provider-store-access-BCFqMZXW.js +0 -1
- package/dist/ui/assets/provider-store-access-D5LR74jc.js +0 -1
- package/dist/ui/assets/proxied-fetch-CPL8wJM2.js +0 -1
- package/dist/ui/assets/secret-topology-BrobAGSV.js +0 -1
- package/dist/ui/assets/slicc-version-CDssWF-h.js +0 -1
- package/dist/ui/assets/wc-tray-CClEnHxD.js +0 -5
- package/dist/ui/assets/welcome-detection-B9tU9uhm.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{t as e}from"./logger-LESFN7Hj.js";import{a as t,i as n,n as r,r as i,t as a}from"./snapshot-CfWTb-Vt.js";import{n as o,r as s}from"./panel-rpc-BPwAqRch.js";import{t as c}from"./providers-Dz0oI_I_.js";import{r as l,t as u}from"./base64-BPBW1Gzr.js";import{n as d}from"./bridge-protocol-31SWTdS5.js";import{a as f,n as p,o as m,s as h,t as g}from"./handoff-link-B3It6xQY.js";import{d as _,f as v,i as ee,u as te}from"./account-store-D83RaetR.js";import{a as ne,l as re,n as ie,o as ae}from"./proxied-fetch-CPL8wJM2.js";import{t as oe}from"./runtime-env-DadgceZk.js";import{t as se}from"./slugify-BYJ6QVAt.js";import{n as ce,t as le}from"./host-command-BJLYDTCR.js";import{r as ue}from"./binary-cache-bSOhqXB1.js";import{i as de,n as fe,r as pe}from"./fetch-body-CuwTaJC_.js";import{o as me,t as he}from"./api-endpoint-3qEcn7BY.js";import{t as ge}from"./compat-uEPf6-XW.js";import{a as _e,i as ve}from"./core-w0-0FXns.js";import{n as ye,t as be}from"./mime-types-D7IV6i7k.js";import{t as xe}from"./secrets-bridge-client-CeK7HpDf.js";import{a as Se,i as Ce,n as we,r as Te}from"./tool-ui-DRnUkp2g.js";import{a as Ee,i as De,n as y,t as b}from"./path-utils-DNJG-zQf.js";import{n as Oe,r as ke,t as Ae}from"./merge-file-core-VJlzucJY.js";import{r as je}from"./workspace-mode-D0kUKBVS.js";import{n as Me,t as Ne}from"./thinking-level-5x0UAu9N.js";import{n as Pe,t as Fe}from"./types-D8gIX-W-.js";import{i as Ie}from"./mount-index-CQfmUPuZ.js";import{a as Le,i as Re,n as ze,o as Be,s as Ve,t as He}from"./signed-fetch-BUx8lpSN.js";import{o as Ue}from"./mount-table-store-DrF_Ifaz.js";import{t as We}from"./remote-cache-BE5T1-53.js";import{n as Ge}from"./fs-B0fs_qLm.js";import{a as Ke}from"./tray-leader-status-CpkFr6n7.js";import{n as qe,t as Je}from"./slicc-version-CDssWF-h.js";import{a as Ye,i as Xe,o as Ze,r as x,t as Qe}from"./browser-DG5MjvHF.js";import{t as S}from"./subcommand-flags-BZi7j78Q.js";import{n as $e,r as et,t as C}from"./subcommand-help-CgO7wRS5.js";import{n as tt}from"./cost-command-DZQVtgRS.js";import{d as nt,g as rt,i as it,n as at,o as ot}from"./sudoers-BdBYQPUn.js";import{n as st,r as ct,t as lt}from"./approval-timeout-BQ29Z0gf.js";import{a as ut,c as dt,i as ft,l as pt,n as mt,o as ht,r as gt,t as _t}from"./types-BfwydWt7.js";import{n as w,t as vt}from"./boundary-Cp9c_bPu.js";import"./rest-paths-Dia19u9P.js";import{t as yt}from"./html-B_Hg2WOy.js";import{n as bt}from"./llm-session-id-BZyXP_j2.js";import{t as xt}from"./buffer-polyfill-BccMjOKj.js";import{i as St,o as Ct}from"./browser-DuyhpHbR.js";import{_ as wt,b as Tt,c as Et,d as Dt,f as Ot,g as kt,h as At,l as jt,m as Mt,n as Nt,o as Pt,p as Ft,s as It,t as Lt,u as Rt,v as zt,x as Bt,y as Vt}from"./jsh-executor-Co2HK2VT.js";import{t as Ht}from"./buffer-B5d1xHaH.js";import{A as Ut,B as T,C as Wt,D as E,E as Gt,F as Kt,G as qt,H as D,I as O,J as Jt,K as Yt,L as Xt,M as Zt,N as Qt,O as $t,P as en,R as tn,S as nn,T as rn,U as an,V as on,W as sn,Y as cn,_ as ln,a as un,b as dn,c as fn,d as pn,f as mn,g as hn,h as gn,i as _n,j as vn,k as yn,l as bn,m as xn,n as Sn,o as Cn,p as k,q as wn,r as Tn,s as En,t as Dn,u as On,v as kn,w as An,x as jn,y as Mn,z as Nn}from"./isomorphic-git-r9mnHMnp.js";import"./global-db-DJXlpNui.js";import{S as Pn,_ as Fn,a as In,b as Ln,c as Rn,d as zn,f as Bn,g as Vn,h as Hn,i as Un,l as Wn,n as Gn,o as Kn,p as qn,r as Jn,s as Yn,t as Xn,u as Zn,v as A,x as j,y as Qn}from"./state-KqYYAZMz.js";import{a as $n,i as er,r as tr,t as nr}from"./git-config-Bdgu8kD2.js";import{a as rr,n as ir,o as ar,r as or,s as sr}from"./jsh-discovery-CnvNKojr.js";import{A as cr,C as lr,a as ur,b as dr,c as fr,d as pr,f as mr,h as hr,i as gr,j as _r,l as vr,m as yr,n as br,o as xr,p as Sr,r as Cr,s as wr,t as M,u as Tr,v as Er,y as Dr}from"./shared-C_68vn79.js";import{B as Or,F as kr,G as Ar,H as jr,J as Mr,K as Nr,L as Pr,N as Fr,P as Ir,U as Lr,V as Rr,W as zr,X as Br,Y as Vr,Z as Hr,q as Ur,z as Wr}from"./sync-sab-wire-CC30v4TL.js";import{n as Gr,t as Kr}from"./esbuild-wasm-DS_YG2EY.js";import{n as qr}from"./wasm-compiler-Ct7QZURL.js";import{a as Jr,o as Yr,s as Xr,t as Zr}from"./usb-device-registry-DFzxaOky.js";import{a as N,i as Qr,r as $r,t as ei}from"./just-bash-compat-B-SPHuh_.js";import{i as ti,r as ni,t as ri}from"./script-catalog-DZtOMxvi.js";import{a as ii,c as ai,o as oi,s as si,t as ci}from"./types-Dzr0qYl3.js";import{a as li,c as ui,d as di,f as fi,n as pi,r as mi,u as hi}from"./github-zip-C8TQwjyj.js";import{i as gi,t as _i}from"./github-auth-BDKUEfX_.js";import{a as vi,i as yi,o as bi,r as xi,t as Si}from"./provenance-DdmsQ3Nr.js";import{a as Ci,c as wi,i as Ti,n as Ei,o as Di,r as Oi,s as ki}from"./github-install-DBEDVo0L.js";import{n as Ai,t as ji}from"./magick-wasm-DCNZhAyd.js";import{i as Mi,n as Ni,r as Pi,t as Fi}from"./pdf-raster-BWk6ezTX.js";import{n as Ii}from"./lick-target-env-8JxfVcIV.js";import{t as Li}from"./tmpdir-env-ate4iNcK.js";import{a as Ri,c as zi,d as Bi,f as Vi,i as Hi,l as Ui,n as Wi,o as Gi,p as Ki,r as qi,s as Ji,t as Yi,u as Xi}from"./installer-BeY2oJma.js";import{t as Zi}from"./ffmpeg-wasm-B77gfnB_.js";import{t as Qi}from"./local-llm-DFilOR_e.js";import{t as $i}from"./client-_vVqanZy.js";import{t as ea}from"./redirect-uri-D2aDPCyB.js";import{a as ta,c as na,i as ra,o as ia,r as aa,s as oa}from"./v86-vm-DCm7zA2r.js";import{n as sa,r as ca}from"./lick-urls-CgPiVwD-.js";let la=null;function ua(e){la=e!==null&&Number.isFinite(e)&&e>0?e:null}function da(){if(la!==null)return la;let e=globalThis.performance?.timeOrigin;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:Date.now()}new URL(d).hostname;const fa=/^([0-9a-f]{32})--(?:[0-9a-f]{8}-)?([0-9a-f]+)$/i;function pa(e){let t;try{t=new URL(e.includes(`://`)?e:`https://${e}`).hostname}catch{return null}let n=fa.exec(t.split(`.`)[0]??``);if(!n||!t.includes(`.`))return null;let r=n[1].toLowerCase();return`${[r.slice(0,8),r.slice(8,12),r.slice(12,16),r.slice(16,20),r.slice(20)].join(`-`)}.${n[2].toLowerCase()}`}[`ghp_`,`gho_`,`ghu_`,`ghs_`,`ghr_`,`github_pat_`,`sk-`,`pk-`,`xoxb-`,`xoxp-`,`xoxa-`,`xoxs-`,`AKIA`,`ABIA`,`ACCA`,`ASIA`,`sk-ant-`,`Bearer `].sort((e,t)=>t.length-e.length);function ma(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 ha(e,t){return e.some(e=>ma(e,t))}const ga=`slicc-transcript`,_a=[`canonical-agent-history-unavailable`,`tool-data-may-be-truncated`,`model-metadata-unavailable`,`scoop-history-unavailable`,`attachment-file-missing`,`attachment-association-unavailable`,`complete-snapshot-unavailable`],va=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 ya(e){return va.has(e.replace(/\/\d+(?=\/|$)/g,`/*`))}var ba=class extends Error{code;detail;constructor(e,t){super(t?`${e}: ${t}`:e),this.code=e,this.detail=t,this.name=`TranscriptExportError`}};const xa=new Set(_a),Sa=/^[0-9a-fA-F]{64}$/,Ca=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/;function P(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function wa(e){return typeof e==`string`&&Sa.test(e)}function Ta(e){return Ca.test(e)&&Number.isFinite(Date.parse(e))}function Ea(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 Da(e,t,n){return typeof e!=`string`||!t.includes(e)?{ok:!1,error:Ea(n,t)}:{ok:!0}}function Oa(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 ka(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 Aa(e,t){if(!P(e))return{ok:!1,error:`${t} must be a non-null object`};let n=Da(e.type,[`text`,`tool-call`,`attachment-ref`],`${t}.type`);return n.ok?ka(e,t):n}function ja(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 Ma(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 Na(e,t){let n=ja(e,t);if(!n.ok)return n;let r=e.cost;return P(r)?Ma(r,`${t}.cost`):{ok:!1,error:`${t}.cost must be a non-null object`}}function Pa(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`?Ta(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 Fa(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 Ia(e,t){let n=e.usage;return n===void 0?{ok:!0}:P(n)?Na(n,`${t}.usage`):{ok:!1,error:`${t}.usage must be a non-null object`}}function La(e,t){if(!P(e))return{ok:!1,error:`${t} must be a non-null object`};let n=Da(e.role,[`user`,`assistant`,`tool-result`],`${t}.role`);if(!n.ok)return n;if(e.role===`tool-result`){let n=Fa(e,t);if(!n.ok)return n}let r=Pa(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=Oa(i,Aa,`${t}.content`);return a.ok?Ia(e,t):a}function Ra(e,t){if(!P(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=Da(e.kind,[`cone`,`scoop`],`${t}.kind`);if(!n.ok)return n;let r=e.messages;return Array.isArray(r)?Oa(r,La,`${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 Ba(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`}:wa(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 Va=[`attachment-file-missing`,`attachment-association-unavailable`];function Ha(e,t){let n=e.path,r=e.sha256,i=e.byteLength;return n===``?r===``?i===0?Da(e.missingReason,Va,`${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 Ua(e,t){return e.present?Ba(e,t):Ha(e,t)}function Wa(e,t){if(!P(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=Da(e.handling,[`text-redacted`,`binary-unchanged`],`${t}.handling`);return r.ok?Ua(e,t):r}function Ga(e,t){let n=Da(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 Ka(e,t){if(!P(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=Da(e.detector,[`known-secret`,`credential-pattern`,`pre-obfuscated`],`${t}.detector`);if(!n.ok)return n;let r=e.target;return P(r)?Ga(r,`${t}.target`):{ok:!1,error:`${t}.target must be a non-null object`}}function qa(e,t){return P(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 Ja(e,t){return typeof e!=`string`||!xa.has(e)?{ok:!1,error:`${t} is not a valid completeness reason`}:{ok:!0}}function Ya(e){if(!P(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 P(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 Xa(e){if(!P(e))return{ok:!1,error:`session.completeness must be a non-null object`};let t=Da(e.status,[`complete`,`partial`],`session.completeness.status`);return t.ok?Array.isArray(e.missing)?Oa(e.missing,Ja,`session.completeness.missing`):{ok:!1,error:`session.completeness.missing must be an array`}:t}function Za(e){if(!P(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=Da(e.state,[`active`,`frozen`],`session.state`);return t.ok?Xa(e.completeness):t}function Qa(e){if(!P(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(!P(e.redactionCounts))return{ok:!1,error:`privacy.redactionCounts must be a non-null object`};let n=e.redactions;return Array.isArray(n)?Oa(n,Ka,`privacy.redactions`):{ok:!1,error:`privacy.redactions must be an array`}}function $a(e){let t=e.conversations;if(!Array.isArray(t))return{ok:!1,error:`conversations must be an array`};let n=Oa(t,Ra,`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=Oa(r,qa,`delegations`);if(!i.ok)return i;let a=e.attachments;return Array.isArray(a)?Oa(a,Wa,`attachments`):{ok:!1,error:`attachments must be an array`}}function eo(e){let t=new Set,n=new Set;for(let r of e){if(!P(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(!(!P(t)||typeof t.id!=`string`)){if(n.has(t.id))return{ok:!1,error:`duplicate message id "${t.id}"`};n.add(t.id)}}}return{ok:!0}}function to(e){for(let t of e){if(!P(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(!P(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 no(e){let t=[];for(let n of e){if(!P(n))continue;let e=n.content;if(Array.isArray(e))for(let n of e)P(n)&&n.type===`tool-call`&&typeof n.id==`string`&&t.push(n.id)}return t}function ro(e){let t=new Set;for(let n of e){if(!P(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of no(e))t.add(n)}return t}function io(e,t){for(let n of e){if(!P(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of e){if(!P(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 ao(e){return io(e,ro(e))}function oo(e,t){for(let n of e){if(!P(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 so(e,t){for(let n of e){if(!P(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of e){if(!P(n))continue;let e=n.content;if(!Array.isArray(e))continue;let r=oo(e,t);if(!r.ok)return r}}return{ok:!0}}function co(e,t){let n=new Set;for(let e of t)P(e)&&typeof e.id==`string`&&n.add(e.id);return so(e,n)}function lo(e){let t=new Map;for(let n of e){if(!P(n)||typeof n.id!=`string`)continue;let e=new Set,r=n.messages;if(Array.isArray(r))for(let t of r)P(t)&&typeof t.id==`string`&&e.add(t.id);t.set(n.id,e)}return t}function uo(e,t){let n=lo(t);for(let t=0;t<e.length;t++){let r=e[t];if(!P(r))continue;let i=r.sourceConversationId,a=r.sourceMessageId;if(typeof i!=`string`||typeof a!=`string`)continue;let o=n.get(i);if(!o)return{ok:!1,error:`attachments[${t}].sourceConversationId "${i}" does not exist`};if(!o.has(a))return{ok:!1,error:`attachments[${t}].sourceMessageId "${a}" does not exist in conversation "${i}"`}}return{ok:!0}}function fo(e){let t=new Map;for(let n of e){if(!P(n)||typeof n.id!=`string`)continue;let e=Array.isArray(n.messages)?n.messages:[];t.set(n.id,new Set(no(e)))}return t}function po(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];if(!P(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 mo(e,t){let n=new Set;for(let e of t)P(e)&&typeof e.id==`string`&&n.add(e.id);return po(e,n,fo(t))}function ho(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 go(e,t){let n=new Set;for(let e of t)P(e)&&typeof e.id==`string`&&n.add(e.id);for(let t=0;t<e.length;t++){let r=e[t];if(!P(r))continue;let i=r.target;if(!P(i))continue;let a=ho(i,n,`privacy.redactions[${t}].target`);if(!a.ok)return a}return{ok:!0}}function _o(e){let t=e.conversations,n=e.attachments,r=e.delegations,i=e.privacy,a=Array.isArray(i?.redactions)?i.redactions:[],o=eo(t);if(!o.ok)return o;let s=to(t);if(!s.ok)return s;let c=ao(t);if(!c.ok)return c;let l=co(t,n);if(!l.ok)return l;let u=uo(n,t);if(!u.ok)return u;let d=mo(r,t);return d.ok?go(a,n):d}function vo(e){let t=$a(e);return t.ok?_o(e):t}function yo(e){if(!P(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=Ya(e.export);if(!t.ok)return t;let n=Za(e.session);if(!n.ok)return n;let r=Qa(e.privacy);return r.ok?vo(e):r}async function bo(e,t,n){let r=await n({method:`GET`,path:`/${e}/sites/${t}/config.json`,origin:Be});if(r.status===401||r.status===403)throw Error(`not authorized to read the site config for ${e}/${t} — log in via Settings → Providers → Adobe, or pass --backend to skip the probe`);if(r.status===404)throw Error(`no site config for ${e}/${t} — check the org and site names`);if(r.status>=400)throw Error(`site config probe failed for ${e}/${t}: ${r.status}`);let i;try{i=await r.json()}catch(n){throw Error(`site config for ${e}/${t} is not JSON: ${n instanceof Error?n.message:String(n)}`)}let a=i.content?.source?.url;return{backend:xo(a),sourceUrl:a}}function xo(e){if(!e)return`da`;let t;try{t=new URL(e).host}catch{return`da`}return t===`api.aem.live`?`aem`:`da`}const So=`slicc-sprinkle-routes`;function Co(){try{let e=localStorage.getItem(So);return e?JSON.parse(e):{}}catch{return{}}}function wo(e){try{localStorage.setItem(So,JSON.stringify(e))}catch{}}function To(e){return Co()[e]}function Eo(e,t){let n=Co();n[e]=t,wo(n)}function Do(e){let t=Co();delete t[e],wo(t)}function Oo(){return Co()}function ko(e,t,n){return dt(t,n,`${e} adapter does not implement ${t}.${n}`)}function Ao(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(ko(e,t,n))]});return{...Object.fromEntries(a),allowlist:i,supports:e=>i.includes(e)}}function jo(e){let{adapter:t,pageGestures:n}=e,r=n??{};return{adapter:t,browser:Ao(t,`browser`,mt,e.browser),network:Ao(t,`network`,ut,e.network),secrets:Ao(t,`secrets`,ht,e.secrets),devices:Ao(t,`devices`,gt,{usbRequest:r.usbRequest,serialRequest:r.serialRequest,hidRequest:r.hidRequest,...e.devices}),mounts:Ao(t,`mounts`,ft,{pickDirectory:r.pickDirectory,...e.mounts}),approvals:Ao(t,`approvals`,_t,e.approvals)}}function Mo(e={}){return jo({adapter:`connect`,pageGestures:e.pageGestures})}function No(e){let t=vt(()=>import(`./extension-ops-B2RMipFn.js`).then(t=>t.createExtensionOps(e)));return jo({adapter:e.adapter,pageGestures:e.pageGestures,network:{crossOriginFetch:e=>w(`network`,`crossOriginFetch`,async()=>(await t()).crossOriginFetch(e))},secrets:{listMaskedEnv:()=>w(`secrets`,`listMaskedEnv`,async()=>(await t()).secrets.listMaskedEnv()),getMasked:e=>w(`secrets`,`getMasked`,async()=>(await t()).secrets.getMasked(e)),set:e=>w(`secrets`,`set`,async()=>(await t()).secrets.set(e)),delete:e=>w(`secrets`,`delete`,async()=>(await t()).secrets.delete(e))},mounts:{signRequest:e=>w(`mounts`,`signRequest`,async()=>(await t()).signRequest(e))},approvals:{request:e=>w(`approvals`,`request`,async()=>(await t()).requestApproval(e))}})}function Po(e={}){let t=vt(()=>import(`./rest-ops-aP40ni1y.js`).then(t=>t.createRestOps(e)),e.controlTimeoutMs??1e4);return jo({adapter:`node-rest`,pageGestures:e.pageGestures,network:{localNodeServer:()=>Promise.resolve({ok:!0,value:{available:!0}}),crossOriginFetch:e=>w(`network`,`crossOriginFetch`,async()=>(await t()).crossOriginFetch(e))},secrets:{listMaskedEnv:()=>w(`secrets`,`listMaskedEnv`,async()=>(await t()).secrets.listMaskedEnv()),getMasked:e=>w(`secrets`,`getMasked`,async()=>(await t()).secrets.getMasked(e)),set:e=>w(`secrets`,`set`,async()=>(await t()).secrets.set(e)),delete:e=>w(`secrets`,`delete`,async()=>(await t()).secrets.delete(e))},mounts:{signRequest:e=>w(`mounts`,`signRequest`,async()=>(await t()).signRequest(e))},approvals:{request:e=>w(`approvals`,`request`,async()=>(await t()).requestApproval(e))}})}function Fo(e,t={}){let{pageGestures:n}=t;switch(e){case`node-rest`:return Po({pageGestures:n});case`extension-direct`:case`extension-delegate`:return No({adapter:e,pageGestures:n});case`connect`:return Mo({pageGestures:n})}}const Io=e(`quick-llm`);async function Lo(e){let t=ee();if(!t)return Io.debug(`No API key for active provider — skipping`),null;let n=v(),r=_(),i;if(i=e.modelId?Vo(n,e.modelId)??Vo(n,r):Ro(n,r),!i)return Io.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`]=Ho());try{let n=(await ge(i,{systemPrompt:e.system,messages:[a]},{apiKey:t,maxTokens:e.maxTokens??60,temperature:e.temperature??.3,signal:e.signal,headers:Object.keys(o).length>0?o:void 0})).content.filter(e=>e.type===`text`).map(e=>e.text).join(``).trim();return n.length>0?n:null}catch(e){return Io.debug(`Quick label call failed`,{error:e instanceof Error?e.message:String(e)}),null}}function Ro(e,t){let n=te(e);if(n.length===0)return;let r=n.find(e=>e.id===t)??n[0],i=Bo(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 Bo(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 Vo(e,t){return te(e).find(e=>e.id===t)}function Ho(){return bt(`ui-quick-llm`)}const Uo=e(`sudo-suggest`),Wo=[`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{a as t,i as n,n as r,r as i,t as a}from"./snapshot-Br4Fps5z.js";import{n as o,r as s}from"./panel-rpc-DVS1uJpt.js";import{t as c}from"./providers-XoHqlC-q.js";import{r as l,t as u}from"./base64-BPBW1Gzr.js";import{n as d}from"./bridge-protocol-31SWTdS5.js";import{a as f,n as p,o as m,s as h,t as g}from"./handoff-link-B3It6xQY.js";import{d as _,f as v,i as ee,u as te}from"./account-store-CDXeAYze.js";import{a as ne,l as re,n as ie,o as ae}from"./proxied-fetch-D6EBne5P.js";import{t as oe}from"./runtime-env-DadgceZk.js";import{t as se}from"./slugify-BYJ6QVAt.js";import{n as ce,t as le}from"./host-command-5ESITqj8.js";import{r as ue}from"./binary-cache-bSOhqXB1.js";import{i as de,n as fe,r as pe}from"./fetch-body-CuwTaJC_.js";import{o as me,t as he}from"./api-endpoint-3qEcn7BY.js";import{t as ge}from"./compat-uEPf6-XW.js";import{a as _e,i as ve}from"./core-NCt3m1n7.js";import{n as ye,t as be}from"./mime-types-D7IV6i7k.js";import{t as xe}from"./secrets-bridge-client-nOf1jubu.js";import{a as Se,i as Ce,n as we,r as Te}from"./tool-ui-DRnUkp2g.js";import{a as Ee,i as De,n as y,t as b}from"./path-utils-DNJG-zQf.js";import{n as Oe,r as ke,t as Ae}from"./merge-file-core-VJlzucJY.js";import{r as je}from"./workspace-mode-D0kUKBVS.js";import{n as Me,t as Ne}from"./thinking-level-5x0UAu9N.js";import{n as Pe,t as Fe}from"./types-D8gIX-W-.js";import{i as Ie}from"./mount-index-CQfmUPuZ.js";import{a as Le,i as Re,n as ze,o as Be,s as Ve,t as He}from"./signed-fetch-BVSCXSzZ.js";import{o as Ue}from"./mount-table-store-DrF_Ifaz.js";import{t as We}from"./remote-cache-BE5T1-53.js";import{n as Ge}from"./fs-BjjYK9VY.js";import{a as Ke}from"./tray-leader-status-CpkFr6n7.js";import{n as qe,t as Je}from"./slicc-version-Doo30hXa.js";import{a as Ye,i as Xe,o as Ze,r as x,t as Qe}from"./browser-DG5MjvHF.js";import{t as S}from"./subcommand-flags-BZi7j78Q.js";import{n as $e,r as et,t as C}from"./subcommand-help-CgO7wRS5.js";import{n as tt}from"./cost-command-DZQVtgRS.js";import{d as nt,g as rt,i as it,n as at,o as ot}from"./sudoers-BdBYQPUn.js";import{n as st,r as ct,t as lt}from"./approval-timeout-BQ29Z0gf.js";import{a as ut,c as dt,i as ft,l as pt,n as mt,o as ht,r as gt,t as _t}from"./types-BfwydWt7.js";import{n as w,t as vt}from"./boundary-Cp9c_bPu.js";import"./rest-paths-Dia19u9P.js";import{t as yt}from"./html-B_Hg2WOy.js";import{n as bt}from"./llm-session-id-BZyXP_j2.js";import{t as xt}from"./buffer-polyfill-BccMjOKj.js";import{i as St,o as Ct}from"./browser-DuyhpHbR.js";import{_ as wt,b as Tt,c as Et,d as Dt,f as Ot,g as kt,h as At,l as jt,m as Mt,n as Nt,o as Pt,p as Ft,s as It,t as Lt,u as Rt,v as zt,x as Bt,y as Vt}from"./jsh-executor-DbpfbKzV.js";import{t as Ht}from"./buffer-B5d1xHaH.js";import{A as Ut,B as T,C as Wt,D as E,E as Gt,F as Kt,G as qt,H as D,I as O,J as Jt,K as Yt,L as Xt,M as Zt,N as Qt,O as $t,P as en,R as tn,S as nn,T as rn,U as an,V as on,W as sn,Y as cn,_ as ln,a as un,b as dn,c as fn,d as pn,f as mn,g as hn,h as gn,i as _n,j as vn,k as yn,l as bn,m as xn,n as Sn,o as Cn,p as k,q as wn,r as Tn,s as En,t as Dn,u as On,v as kn,w as An,x as jn,y as Mn,z as Nn}from"./isomorphic-git-r9mnHMnp.js";import"./global-db-DJXlpNui.js";import{S as Pn,_ as Fn,a as In,b as Ln,c as Rn,d as zn,f as Bn,g as Vn,h as Hn,i as Un,l as Wn,n as Gn,o as Kn,p as qn,r as Jn,s as Yn,t as Xn,u as Zn,v as A,x as j,y as Qn}from"./state-DK8S4qLC.js";import{a as $n,i as er,r as tr,t as nr}from"./git-config-Bdgu8kD2.js";import{a as rr,n as ir,o as ar,r as or,s as sr}from"./jsh-discovery-CnvNKojr.js";import{A as cr,C as lr,a as ur,b as dr,c as fr,d as pr,f as mr,h as hr,i as gr,j as _r,l as vr,m as yr,n as br,o as xr,p as Sr,r as Cr,s as wr,t as M,u as Tr,v as Er,y as Dr}from"./shared-C_68vn79.js";import{B as Or,F as kr,G as Ar,H as jr,J as Mr,K as Nr,L as Pr,N as Fr,P as Ir,U as Lr,V as Rr,W as zr,X as Br,Y as Vr,Z as Hr,q as Ur,z as Wr}from"./sync-sab-wire-CC30v4TL.js";import{n as Gr,t as Kr}from"./esbuild-wasm-DS_YG2EY.js";import{n as qr}from"./wasm-compiler-Ct7QZURL.js";import{a as Jr,o as Yr,s as Xr,t as Zr}from"./usb-device-registry-DFzxaOky.js";import{a as N,i as Qr,r as $r,t as ei}from"./just-bash-compat-B-SPHuh_.js";import{i as ti,r as ni,t as ri}from"./script-catalog-DZtOMxvi.js";import{a as ii,c as ai,o as oi,s as si,t as ci}from"./types-Dzr0qYl3.js";import{a as li,c as ui,d as di,f as fi,n as pi,r as mi,u as hi}from"./github-zip-BhnRGzD6.js";import{i as gi,t as _i}from"./github-auth-B7p5l36m.js";import{a as vi,i as yi,o as bi,r as xi,t as Si}from"./provenance-DdmsQ3Nr.js";import{a as Ci,c as wi,i as Ti,n as Ei,o as Di,r as Oi,s as ki}from"./github-install-DTmIqVHt.js";import{n as Ai,t as ji}from"./magick-wasm-DCNZhAyd.js";import{i as Mi,n as Ni,r as Pi,t as Fi}from"./pdf-raster-BWk6ezTX.js";import{n as Ii}from"./lick-target-env-8JxfVcIV.js";import{t as Li}from"./tmpdir-env-ate4iNcK.js";import{a as Ri,c as zi,d as Bi,f as Vi,i as Hi,l as Ui,n as Wi,o as Gi,p as Ki,r as qi,s as Ji,t as Yi,u as Xi}from"./installer-CAPOWOiB.js";import{t as Zi}from"./ffmpeg-wasm-B77gfnB_.js";import{t as Qi}from"./local-llm-B6veJ_ef.js";import{t as $i}from"./client-GY8xUpw7.js";import{t as ea}from"./redirect-uri-C-c6wFfz.js";import{a as ta,c as na,i as ra,o as ia,r as aa,s as oa}from"./v86-vm-DCm7zA2r.js";import{n as sa,r as ca}from"./lick-urls-CgPiVwD-.js";let la=null;function ua(e){la=e!==null&&Number.isFinite(e)&&e>0?e:null}function da(){if(la!==null)return la;let e=globalThis.performance?.timeOrigin;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:Date.now()}new URL(d).hostname;const fa=/^([0-9a-f]{32})--(?:[0-9a-f]{8}-)?([0-9a-f]+)$/i;function pa(e){let t;try{t=new URL(e.includes(`://`)?e:`https://${e}`).hostname}catch{return null}let n=fa.exec(t.split(`.`)[0]??``);if(!n||!t.includes(`.`))return null;let r=n[1].toLowerCase();return`${[r.slice(0,8),r.slice(8,12),r.slice(12,16),r.slice(16,20),r.slice(20)].join(`-`)}.${n[2].toLowerCase()}`}[`ghp_`,`gho_`,`ghu_`,`ghs_`,`ghr_`,`github_pat_`,`sk-`,`pk-`,`xoxb-`,`xoxp-`,`xoxa-`,`xoxs-`,`AKIA`,`ABIA`,`ACCA`,`ASIA`,`sk-ant-`,`Bearer `].sort((e,t)=>t.length-e.length);function ma(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 ha(e,t){return e.some(e=>ma(e,t))}const ga=`slicc-transcript`,_a=[`canonical-agent-history-unavailable`,`tool-data-may-be-truncated`,`model-metadata-unavailable`,`scoop-history-unavailable`,`attachment-file-missing`,`attachment-association-unavailable`,`complete-snapshot-unavailable`],va=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 ya(e){return va.has(e.replace(/\/\d+(?=\/|$)/g,`/*`))}var ba=class extends Error{code;detail;constructor(e,t){super(t?`${e}: ${t}`:e),this.code=e,this.detail=t,this.name=`TranscriptExportError`}};const xa=new Set(_a),Sa=/^[0-9a-fA-F]{64}$/,Ca=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/;function P(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function wa(e){return typeof e==`string`&&Sa.test(e)}function Ta(e){return Ca.test(e)&&Number.isFinite(Date.parse(e))}function Ea(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 Da(e,t,n){return typeof e!=`string`||!t.includes(e)?{ok:!1,error:Ea(n,t)}:{ok:!0}}function Oa(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 ka(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 Aa(e,t){if(!P(e))return{ok:!1,error:`${t} must be a non-null object`};let n=Da(e.type,[`text`,`tool-call`,`attachment-ref`],`${t}.type`);return n.ok?ka(e,t):n}function ja(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 Ma(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 Na(e,t){let n=ja(e,t);if(!n.ok)return n;let r=e.cost;return P(r)?Ma(r,`${t}.cost`):{ok:!1,error:`${t}.cost must be a non-null object`}}function Pa(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`?Ta(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 Fa(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 Ia(e,t){let n=e.usage;return n===void 0?{ok:!0}:P(n)?Na(n,`${t}.usage`):{ok:!1,error:`${t}.usage must be a non-null object`}}function La(e,t){if(!P(e))return{ok:!1,error:`${t} must be a non-null object`};let n=Da(e.role,[`user`,`assistant`,`tool-result`],`${t}.role`);if(!n.ok)return n;if(e.role===`tool-result`){let n=Fa(e,t);if(!n.ok)return n}let r=Pa(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=Oa(i,Aa,`${t}.content`);return a.ok?Ia(e,t):a}function Ra(e,t){if(!P(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=Da(e.kind,[`cone`,`scoop`],`${t}.kind`);if(!n.ok)return n;let r=e.messages;return Array.isArray(r)?Oa(r,La,`${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 Ba(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`}:wa(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 Va=[`attachment-file-missing`,`attachment-association-unavailable`];function Ha(e,t){let n=e.path,r=e.sha256,i=e.byteLength;return n===``?r===``?i===0?Da(e.missingReason,Va,`${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 Ua(e,t){return e.present?Ba(e,t):Ha(e,t)}function Wa(e,t){if(!P(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=Da(e.handling,[`text-redacted`,`binary-unchanged`],`${t}.handling`);return r.ok?Ua(e,t):r}function Ga(e,t){let n=Da(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 Ka(e,t){if(!P(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=Da(e.detector,[`known-secret`,`credential-pattern`,`pre-obfuscated`],`${t}.detector`);if(!n.ok)return n;let r=e.target;return P(r)?Ga(r,`${t}.target`):{ok:!1,error:`${t}.target must be a non-null object`}}function qa(e,t){return P(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 Ja(e,t){return typeof e!=`string`||!xa.has(e)?{ok:!1,error:`${t} is not a valid completeness reason`}:{ok:!0}}function Ya(e){if(!P(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 P(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 Xa(e){if(!P(e))return{ok:!1,error:`session.completeness must be a non-null object`};let t=Da(e.status,[`complete`,`partial`],`session.completeness.status`);return t.ok?Array.isArray(e.missing)?Oa(e.missing,Ja,`session.completeness.missing`):{ok:!1,error:`session.completeness.missing must be an array`}:t}function Za(e){if(!P(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=Da(e.state,[`active`,`frozen`],`session.state`);return t.ok?Xa(e.completeness):t}function Qa(e){if(!P(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(!P(e.redactionCounts))return{ok:!1,error:`privacy.redactionCounts must be a non-null object`};let n=e.redactions;return Array.isArray(n)?Oa(n,Ka,`privacy.redactions`):{ok:!1,error:`privacy.redactions must be an array`}}function $a(e){let t=e.conversations;if(!Array.isArray(t))return{ok:!1,error:`conversations must be an array`};let n=Oa(t,Ra,`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=Oa(r,qa,`delegations`);if(!i.ok)return i;let a=e.attachments;return Array.isArray(a)?Oa(a,Wa,`attachments`):{ok:!1,error:`attachments must be an array`}}function eo(e){let t=new Set,n=new Set;for(let r of e){if(!P(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(!(!P(t)||typeof t.id!=`string`)){if(n.has(t.id))return{ok:!1,error:`duplicate message id "${t.id}"`};n.add(t.id)}}}return{ok:!0}}function to(e){for(let t of e){if(!P(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(!P(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 no(e){let t=[];for(let n of e){if(!P(n))continue;let e=n.content;if(Array.isArray(e))for(let n of e)P(n)&&n.type===`tool-call`&&typeof n.id==`string`&&t.push(n.id)}return t}function ro(e){let t=new Set;for(let n of e){if(!P(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of no(e))t.add(n)}return t}function io(e,t){for(let n of e){if(!P(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of e){if(!P(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 ao(e){return io(e,ro(e))}function oo(e,t){for(let n of e){if(!P(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 so(e,t){for(let n of e){if(!P(n))continue;let e=n.messages;if(Array.isArray(e))for(let n of e){if(!P(n))continue;let e=n.content;if(!Array.isArray(e))continue;let r=oo(e,t);if(!r.ok)return r}}return{ok:!0}}function co(e,t){let n=new Set;for(let e of t)P(e)&&typeof e.id==`string`&&n.add(e.id);return so(e,n)}function lo(e){let t=new Map;for(let n of e){if(!P(n)||typeof n.id!=`string`)continue;let e=new Set,r=n.messages;if(Array.isArray(r))for(let t of r)P(t)&&typeof t.id==`string`&&e.add(t.id);t.set(n.id,e)}return t}function uo(e,t){let n=lo(t);for(let t=0;t<e.length;t++){let r=e[t];if(!P(r))continue;let i=r.sourceConversationId,a=r.sourceMessageId;if(typeof i!=`string`||typeof a!=`string`)continue;let o=n.get(i);if(!o)return{ok:!1,error:`attachments[${t}].sourceConversationId "${i}" does not exist`};if(!o.has(a))return{ok:!1,error:`attachments[${t}].sourceMessageId "${a}" does not exist in conversation "${i}"`}}return{ok:!0}}function fo(e){let t=new Map;for(let n of e){if(!P(n)||typeof n.id!=`string`)continue;let e=Array.isArray(n.messages)?n.messages:[];t.set(n.id,new Set(no(e)))}return t}function po(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];if(!P(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 mo(e,t){let n=new Set;for(let e of t)P(e)&&typeof e.id==`string`&&n.add(e.id);return po(e,n,fo(t))}function ho(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 go(e,t){let n=new Set;for(let e of t)P(e)&&typeof e.id==`string`&&n.add(e.id);for(let t=0;t<e.length;t++){let r=e[t];if(!P(r))continue;let i=r.target;if(!P(i))continue;let a=ho(i,n,`privacy.redactions[${t}].target`);if(!a.ok)return a}return{ok:!0}}function _o(e){let t=e.conversations,n=e.attachments,r=e.delegations,i=e.privacy,a=Array.isArray(i?.redactions)?i.redactions:[],o=eo(t);if(!o.ok)return o;let s=to(t);if(!s.ok)return s;let c=ao(t);if(!c.ok)return c;let l=co(t,n);if(!l.ok)return l;let u=uo(n,t);if(!u.ok)return u;let d=mo(r,t);return d.ok?go(a,n):d}function vo(e){let t=$a(e);return t.ok?_o(e):t}function yo(e){if(!P(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=Ya(e.export);if(!t.ok)return t;let n=Za(e.session);if(!n.ok)return n;let r=Qa(e.privacy);return r.ok?vo(e):r}async function bo(e,t,n){let r=await n({method:`GET`,path:`/${e}/sites/${t}/config.json`,origin:Be});if(r.status===401||r.status===403)throw Error(`not authorized to read the site config for ${e}/${t} — log in via Settings → Providers → Adobe, or pass --backend to skip the probe`);if(r.status===404)throw Error(`no site config for ${e}/${t} — check the org and site names`);if(r.status>=400)throw Error(`site config probe failed for ${e}/${t}: ${r.status}`);let i;try{i=await r.json()}catch(n){throw Error(`site config for ${e}/${t} is not JSON: ${n instanceof Error?n.message:String(n)}`)}let a=i.content?.source?.url;return{backend:xo(a),sourceUrl:a}}function xo(e){if(!e)return`da`;let t;try{t=new URL(e).host}catch{return`da`}return t===`api.aem.live`?`aem`:`da`}const So=`slicc-sprinkle-routes`;function Co(){try{let e=localStorage.getItem(So);return e?JSON.parse(e):{}}catch{return{}}}function wo(e){try{localStorage.setItem(So,JSON.stringify(e))}catch{}}function To(e){return Co()[e]}function Eo(e,t){let n=Co();n[e]=t,wo(n)}function Do(e){let t=Co();delete t[e],wo(t)}function Oo(){return Co()}function ko(e,t,n){return dt(t,n,`${e} adapter does not implement ${t}.${n}`)}function Ao(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(ko(e,t,n))]});return{...Object.fromEntries(a),allowlist:i,supports:e=>i.includes(e)}}function jo(e){let{adapter:t,pageGestures:n}=e,r=n??{};return{adapter:t,browser:Ao(t,`browser`,mt,e.browser),network:Ao(t,`network`,ut,e.network),secrets:Ao(t,`secrets`,ht,e.secrets),devices:Ao(t,`devices`,gt,{usbRequest:r.usbRequest,serialRequest:r.serialRequest,hidRequest:r.hidRequest,...e.devices}),mounts:Ao(t,`mounts`,ft,{pickDirectory:r.pickDirectory,...e.mounts}),approvals:Ao(t,`approvals`,_t,e.approvals)}}function Mo(e={}){return jo({adapter:`connect`,pageGestures:e.pageGestures})}function No(e){let t=vt(()=>import(`./extension-ops-2LnlLuXD.js`).then(t=>t.createExtensionOps(e)));return jo({adapter:e.adapter,pageGestures:e.pageGestures,network:{crossOriginFetch:e=>w(`network`,`crossOriginFetch`,async()=>(await t()).crossOriginFetch(e))},secrets:{listMaskedEnv:()=>w(`secrets`,`listMaskedEnv`,async()=>(await t()).secrets.listMaskedEnv()),getMasked:e=>w(`secrets`,`getMasked`,async()=>(await t()).secrets.getMasked(e)),set:e=>w(`secrets`,`set`,async()=>(await t()).secrets.set(e)),delete:e=>w(`secrets`,`delete`,async()=>(await t()).secrets.delete(e))},mounts:{signRequest:e=>w(`mounts`,`signRequest`,async()=>(await t()).signRequest(e))},approvals:{request:e=>w(`approvals`,`request`,async()=>(await t()).requestApproval(e))}})}function Po(e={}){let t=vt(()=>import(`./rest-ops-DBG2rYMP.js`).then(t=>t.createRestOps(e)),e.controlTimeoutMs??1e4);return jo({adapter:`node-rest`,pageGestures:e.pageGestures,network:{localNodeServer:()=>Promise.resolve({ok:!0,value:{available:!0}}),crossOriginFetch:e=>w(`network`,`crossOriginFetch`,async()=>(await t()).crossOriginFetch(e))},secrets:{listMaskedEnv:()=>w(`secrets`,`listMaskedEnv`,async()=>(await t()).secrets.listMaskedEnv()),getMasked:e=>w(`secrets`,`getMasked`,async()=>(await t()).secrets.getMasked(e)),set:e=>w(`secrets`,`set`,async()=>(await t()).secrets.set(e)),delete:e=>w(`secrets`,`delete`,async()=>(await t()).secrets.delete(e))},mounts:{signRequest:e=>w(`mounts`,`signRequest`,async()=>(await t()).signRequest(e))},approvals:{request:e=>w(`approvals`,`request`,async()=>(await t()).requestApproval(e))}})}function Fo(e,t={}){let{pageGestures:n}=t;switch(e){case`node-rest`:return Po({pageGestures:n});case`extension-direct`:case`extension-delegate`:return No({adapter:e,pageGestures:n});case`connect`:return Mo({pageGestures:n})}}const Io=e(`quick-llm`);async function Lo(e){let t=ee();if(!t)return Io.debug(`No API key for active provider — skipping`),null;let n=v(),r=_(),i;if(i=e.modelId?Vo(n,e.modelId)??Vo(n,r):Ro(n,r),!i)return Io.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`]=Ho());try{let n=(await ge(i,{systemPrompt:e.system,messages:[a]},{apiKey:t,maxTokens:e.maxTokens??60,temperature:e.temperature??.3,signal:e.signal,headers:Object.keys(o).length>0?o:void 0})).content.filter(e=>e.type===`text`).map(e=>e.text).join(``).trim();return n.length>0?n:null}catch(e){return Io.debug(`Quick label call failed`,{error:e instanceof Error?e.message:String(e)}),null}}function Ro(e,t){let n=te(e);if(n.length===0)return;let r=n.find(e=>e.id===t)??n[0],i=Bo(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 Bo(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 Vo(e,t){return te(e).find(e=>e.id===t)}function Ho(){return bt(`ui-quick-llm`)}const Uo=e(`sudo-suggest`),Wo=[`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
|
`),Go=[`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 Ko(e,t){if(e.suggestedPattern&&e.suggestedPattern.trim().length>0)return e.suggestedPattern.trim();let n=e.detail.trim(),r=e.kind===`command`?Wo:Go,i=null;try{i=await Lo({prompt:n,system:r,maxTokens:40,temperature:0,signal:t})}catch(e){Uo.debug(`suggestPattern: quickLabel threw`,{error:e instanceof Error?e.message:String(e)}),i=null}return qo(i)||n}function qo(e){if(!e)return null;let t=(e.split(`
|
|
4
|
-
`,1)[0]?.trim()??``).replace(/^`+/,``).replace(/`+$/,``).replace(/^["']/,``).replace(/["']$/,``).trim();return t.length===0?null:t}const Jo=e(`sudo:capability-gesture`);function Yo(e,t={}){let n=t.suggest??Ko;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 Jo.warn(`sudo approval aborted before prompting — denying`,{detail:t.detail}),{decision:`deny`};if(!e)return Jo.warn(`no CapabilityBroker injected for the sudo gesture hop — denying (composition bug, never a guessed transport)`,{detail:t.detail}),{decision:`deny`};let o=await e.approvals.request({kind:t.kind,detail:t.detail,suggestedPattern:a,...t.requester?{requester:t.requester}:{},...t.reason?{reason:t.reason}:{},...t.approver?{approver:t.approver}:{},...i?{signal:i}:{}});return o.ok?pt(o.value,a):(Jo.warn(`capability broker approvals.request failed — denying`,{message:o.message}),{decision:`deny`})}}}const Xo=e(`sudo:tray-first`);function Zo(e,t={}){let n=t.suggest??Ko,r=t.timeoutMs??6e5,i=t.getClient??(async()=>{let{getPanelRpcClient:e}=await import(`./panel-rpc-BPwAqRch.js`).then(e=>e.i);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){Xo.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 Qo(e?.decision,o)}catch(e){Xo.warn(`tray-first sudo probe failed — using native broker`,{error:e instanceof Error?e.message:String(e)})}return e.requestApproval(s,a)}}}function Qo(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 $o(e,t){return{requestApproval(n){return t.enqueueSudoRequest(e,n)}}}function es(){return`lick-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}var ts=class{pending=new Map;timeoutMs;newId;setTimer;clearTimer;onAutoSettle;constructor(e={}){this.timeoutMs=e.timeoutMs??3e5,this.newId=e.newId??es,this.setTimer=e.setTimer??((e,t)=>setTimeout(e,t)),this.clearTimer=e.clearTimer??(e=>clearTimeout(e)),this.onAutoSettle=e.onAutoSettle??(()=>{})}notifyAutoSettle(e,t,n){try{this.onAutoSettle(e,t,n)}catch{}}register(e,t,n){let r=this.newId();return{id:r,pending:new Promise(i=>{let a=null;Number.isFinite(this.timeoutMs)&&this.timeoutMs>0&&(a=this.setTimer(()=>{let e=this.pending.get(r);e&&(this.pending.delete(r),e.resolve(st(`cone-timeout`)),this.notifyAutoSettle(r,`expired`,e.scoopJid))},this.timeoutMs)),this.pending.set(r,{scoopJid:e,request:t,resolve:i,timerHandle:a,approverJid:n})})}}resolve(e,t){let n=this.pending.get(e);return n?(this.pending.delete(e),n.timerHandle!=null&&this.clearTimer(n.timerHandle),n.resolve(t),!0):!1}failScoop(e){let t=0;for(let[n,r]of this.pending)r.scoopJid===e&&(this.pending.delete(n),r.timerHandle!=null&&this.clearTimer(r.timerHandle),r.resolve({decision:`deny`}),this.notifyAutoSettle(n,`scoop-dropped`,r.scoopJid),t++);return t}failAll(){let e=0;for(let[t,n]of this.pending)n.timerHandle!=null&&this.clearTimer(n.timerHandle),n.resolve({decision:`deny`}),this.notifyAutoSettle(t,`shutdown`,n.scoopJid),e++;return this.pending.clear(),e}get(e){let t=this.pending.get(e);return t?{id:e,scoopJid:t.scoopJid,request:t.request,...t.approverJid?{approverJid:t.approverJid}:{}}:null}list(){let e=[];for(let[t,n]of this.pending)e.push({id:t,scoopJid:n.scoopJid,request:n.request,...n.approverJid?{approverJid:n.approverJid}:{}});return e}size(){return this.pending.size}};e(`sudo-panel`),typeof globalThis.confirm==`function`&&globalThis.confirm.bind(globalThis),typeof globalThis.prompt==`function`&&globalThis.prompt.bind(globalThis),e(`sudo:page`),e(`sudo`);function ns(e){return ct(rs(e))}function rs(e){let t=Yo(e);return e?.adapter===`extension-direct`||e?.adapter===`extension-delegate`?t:Zo(t)}let is=null;function as(e){return is=e,()=>{is===e&&(is=null)}}function os(){if(!is)throw new ba(`session-not-found`);return is}const ss=`focus`,cs={type:`leaf`,surfaceId:`chat`};function ls(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 us={focus:{name:`focus`,tree:ls({left:cs},{left:3,middle:1})}};function ds(e){return us[e]??null}const fs=`progress`;function ps(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)}const ms=e(`mount-picker-popup`),hs=6e4;function gs(e){let t=e??`mount-${Date.now().toString(36)}`;return new Promise(e=>{let n=!1,r=t=>{n||(n=!0,clearTimeout(i),e(t))},i=setTimeout(()=>r({cancelled:!0}),hs);Bt(`directory`,[],t,{timeoutMs:hs}).then(e=>{let n=e;if(n.error){ms.error(`picker popup launch failed for directory kind`,{requestId:t,error:n.error}),r({error:`Failed to open directory picker window`});return}r(n)}).catch(e=>{ms.error(`picker popup launch threw for directory kind`,{requestId:t,error:e instanceof Error?e.message:String(e),name:e instanceof Error?e.name:void 0}),r({error:`Failed to open directory picker window`})})})}async function _s(e){let t=await new Promise((e,t)=>{let n=indexedDB.open(`slicc-pending-mount`,1);n.onupgradeneeded=()=>{n.result.objectStoreNames.contains(`handles`)||n.result.createObjectStore(`handles`)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),n=t.transaction(`handles`,`readwrite`),r=n.objectStore(`handles`),i=r.get(e),a=r.delete(e);a.onerror=()=>{ms.warn(`Failed to delete pending handle from IDB`,{idbKey:e,error:a.error})};let o=await new Promise((e,t)=>{n.oncomplete=()=>e(i.result??null),i.onerror=()=>t(i.error??Error(`IDB get failed`)),n.onerror=()=>t(n.error??Error(`IDB transaction failed`)),n.onabort=()=>t(n.error??Error(`IDB transaction aborted`))});return t.close(),o}async function vs(e){let t=e;if(t.requestPermission){let n=await t.requestPermission({mode:`readwrite`});if(n!==`granted`)throw Error(`Permission denied for "${e.name}" (${n})`)}}async function ys(){try{let e=await gs();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 _s(e.idbKey);if(!t)throw Error(`mount: no directory handle found in storage`);return await vs(t),t}throw Error(`mount: unexpected popup result`)}catch(e){throw Error(`mount: ${e instanceof Error?e.message:String(e)}`)}}async function bs(){if(typeof window>`u`||!(`showDirectoryPicker`in window))throw Error(`mount: local picker requires a user gesture in the panel (unavailable in this runtime). Ask the agent to mount it instead.`);try{return await window.showDirectoryPicker({mode:`readwrite`})}catch(e){throw e instanceof Error&&e.name===`AbortError`?Error(`mount: cancelled`):Error(`mount: ${e instanceof Error?e.message:String(e)}`)}}function xs(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 Ss(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 Cs=new Set([`--source`,`--profile`,`--backend`,`--max-body-mb`]);function ws(e){for(let t=0;t<e.length;t++){let n=e[t];if(n===`--`)return!1;if(n===`--help`||n===`-h`)return!0;Cs.has(n)&&t++}return!1}function Ts(e){return`aem://${e.org}/${e.name}${e.path?`/${e.path}`:``}`}var Es=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=xs(e);if(i.positional.length===0)return this.usageError(`mount: mount point required`);let a=this.resolvePath(i.positional[0],t);return i.backendError===void 0?i.source?i.source.startsWith(`s3://`)?this.mountS3(a,i):i.source.startsWith(`da://`)||i.source.startsWith(`aem://`)?this.mountAdobe(a,i):this.usageError(`mount: invalid source '${i.source}' — expected s3://..., da://... or aem://...`):this.mountLocal(a,n):this.usageError(`mount: invalid --backend '${i.backendError}' — expected 'da' or 'aem'`)}async executeUmount(e,t){return this.handleUnmount(e,t,`umount`)}async mountLocal(e,t){try{if((this.options.isScoop??(()=>!1))())throw Error(`mount: cannot mount local directories from a scoop (no UI). Ask the cone.`);let n=Se();if(!n){let n=await Ds(e);if(n)return await this.options.fs.mount(e,n,{env:t}),{stdout:`Mounted '${n.describe().displayName}' → ${e}\nIndexing in background for fast file discovery.\nNote: External changes are not auto-detected — use 'mount refresh ${e}' after modifying files outside the browser.\n`,stderr:``,exitCode:0}}let r;if(n){let t=this.options.acquireLocalMountViaToolUI;if(!t)throw Error(`mount: tool UI not available in this runtime`);r=await t(n,e)}else r=oe()?await ys():await bs();let i=Ie.fromHandle(r,{mountId:Ue()});return await this.options.fs.mount(e,i,{env:t}),{stdout:`Mounted '${i.describe().displayName}' → ${e}\nIndexing in background for fast file discovery.\nNote: External changes are not auto-detected — use 'mount refresh ${e}' after modifying files outside the browser.\n`,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`mount: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}async mountS3(e,t){if(!t.source)return this.usageError(`mount: --source required`);let n=t.profile??`default`,r=Ue(),i=new We({mountId:r,ttlMs:3e4}),a=new Re({source:t.source,profile:n,cache:i,maxBodyBytes:t.maxBodyMb?t.maxBodyMb*1024*1024:void 0,mountId:r,signedFetch:this.signedFetchS3??ze(n)});if(!t.noProbe)try{await a.readDir(`/`)}catch(e){return await a.close(),{stdout:``,stderr:`mount: probe failed for ${t.source} — ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}return await this.options.fs.mount(e,a),{stdout:`Mounted '${a.describe().displayName}' → ${e} (profile: ${n})\n`,stderr:``,exitCode:0}}async mountAdobe(e,t){if(!t.source)return this.usageError(`mount: --source required`);let n=t.profile??`default`,r=this.signedFetchDa??He(),i=Ss(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 bo(i.org,i.name,r)).backend,a===`aem`&&(o=`mount: ${i.org}/${i.name} is on Helix 6 — its content lives in the Source Bus at https://api.aem.live/${i.org}/sites/${i.name}/source, not admin.da.live. Mounting through aem://${i.org}/${i.name}. Pass --backend da to force the old endpoint.\n`)}catch(e){return{stdout:``,stderr:`mount: could not determine the content source for ${t.source} — ${e instanceof Error?e.message:String(e)}. Pass --backend da or --backend aem to skip this probe.\n`,exitCode:1}}let s=Ue(),c=new We({mountId:s,ttlMs:3e4}),l={source:a===`aem`?Ts(i):`da://${i.org}/${i.name}${i.path?`/${i.path}`:``}`,profile:n,cache:c,maxBodyBytes:t.maxBodyMb?t.maxBodyMb*1024*1024:void 0,mountId:s,signedFetch:r},u=a===`aem`?new Ve(l):new Le(l);if(!t.noProbe)try{await u.readDir(`/`)}catch(e){return await u.close(),{stdout:``,stderr:o+`mount: probe failed for ${l.source} — ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}return await this.options.fs.mount(e,u),{stdout:`Mounted '${u.describe().displayName}' → ${e} (profile: ${n})\n`,stderr:o,exitCode:0}}async handleUnmount(e,t,n){if(ws(e))return n===`umount`?this.umountHelp():this.help();let r=xs(e);if(r.positional.length===0)return{stdout:``,stderr:`${n}: path required\n`,exitCode:1};let i=this.resolvePath(r.positional[0],t);try{let e,t;if(r.clearCache){let{getAllMountEntries:n}=await import(`./mount-table-store-DrF_Ifaz.js`).then(e=>e.r),r=(await n()).find(e=>e.targetPath===i),a=r?.descriptor.kind;r&&(a===`s3`||a===`da`||a===`aem`)&&(e=r.descriptor.mountId,t=r.descriptor.kind)}await this.options.fs.unmount(i);let n=``;if(r.clearCache&&e&&t){let{RemoteMountCache:t}=await import(`./remote-cache-BE5T1-53.js`).then(e=>e.n);await new t({mountId:e,ttlMs:3e4}).clearMount(),n=` (cache cleared)`}else r.clearCache&&(n=` (no remote cache to clear)`);return{stdout:`Unmounted ${i}${n}\n`,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`${n}: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}async handleList(){try{let e=this.options.fs.listMounts();if(e.length===0)return{stdout:`No active mounts
|
|
4
|
+
`,1)[0]?.trim()??``).replace(/^`+/,``).replace(/`+$/,``).replace(/^["']/,``).replace(/["']$/,``).trim();return t.length===0?null:t}const Jo=e(`sudo:capability-gesture`);function Yo(e,t={}){let n=t.suggest??Ko;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 Jo.warn(`sudo approval aborted before prompting — denying`,{detail:t.detail}),{decision:`deny`};if(!e)return Jo.warn(`no CapabilityBroker injected for the sudo gesture hop — denying (composition bug, never a guessed transport)`,{detail:t.detail}),{decision:`deny`};let o=await e.approvals.request({kind:t.kind,detail:t.detail,suggestedPattern:a,...t.requester?{requester:t.requester}:{},...t.reason?{reason:t.reason}:{},...t.approver?{approver:t.approver}:{},...i?{signal:i}:{}});return o.ok?pt(o.value,a):(Jo.warn(`capability broker approvals.request failed — denying`,{message:o.message}),{decision:`deny`})}}}const Xo=e(`sudo:tray-first`);function Zo(e,t={}){let n=t.suggest??Ko,r=t.timeoutMs??6e5,i=t.getClient??(async()=>{let{getPanelRpcClient:e}=await import(`./panel-rpc-DVS1uJpt.js`).then(e=>e.i);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){Xo.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 Qo(e?.decision,o)}catch(e){Xo.warn(`tray-first sudo probe failed — using native broker`,{error:e instanceof Error?e.message:String(e)})}return e.requestApproval(s,a)}}}function Qo(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 $o(e,t){return{requestApproval(n){return t.enqueueSudoRequest(e,n)}}}function es(){return`lick-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}var ts=class{pending=new Map;timeoutMs;newId;setTimer;clearTimer;onAutoSettle;constructor(e={}){this.timeoutMs=e.timeoutMs??3e5,this.newId=e.newId??es,this.setTimer=e.setTimer??((e,t)=>setTimeout(e,t)),this.clearTimer=e.clearTimer??(e=>clearTimeout(e)),this.onAutoSettle=e.onAutoSettle??(()=>{})}notifyAutoSettle(e,t,n){try{this.onAutoSettle(e,t,n)}catch{}}register(e,t,n){let r=this.newId();return{id:r,pending:new Promise(i=>{let a=null;Number.isFinite(this.timeoutMs)&&this.timeoutMs>0&&(a=this.setTimer(()=>{let e=this.pending.get(r);e&&(this.pending.delete(r),e.resolve(st(`cone-timeout`)),this.notifyAutoSettle(r,`expired`,e.scoopJid))},this.timeoutMs)),this.pending.set(r,{scoopJid:e,request:t,resolve:i,timerHandle:a,approverJid:n})})}}resolve(e,t){let n=this.pending.get(e);return n?(this.pending.delete(e),n.timerHandle!=null&&this.clearTimer(n.timerHandle),n.resolve(t),!0):!1}failScoop(e){let t=0;for(let[n,r]of this.pending)r.scoopJid===e&&(this.pending.delete(n),r.timerHandle!=null&&this.clearTimer(r.timerHandle),r.resolve({decision:`deny`}),this.notifyAutoSettle(n,`scoop-dropped`,r.scoopJid),t++);return t}failAll(){let e=0;for(let[t,n]of this.pending)n.timerHandle!=null&&this.clearTimer(n.timerHandle),n.resolve({decision:`deny`}),this.notifyAutoSettle(t,`shutdown`,n.scoopJid),e++;return this.pending.clear(),e}get(e){let t=this.pending.get(e);return t?{id:e,scoopJid:t.scoopJid,request:t.request,...t.approverJid?{approverJid:t.approverJid}:{}}:null}list(){let e=[];for(let[t,n]of this.pending)e.push({id:t,scoopJid:n.scoopJid,request:n.request,...n.approverJid?{approverJid:n.approverJid}:{}});return e}size(){return this.pending.size}};e(`sudo-panel`),typeof globalThis.confirm==`function`&&globalThis.confirm.bind(globalThis),typeof globalThis.prompt==`function`&&globalThis.prompt.bind(globalThis),e(`sudo:page`),e(`sudo`);function ns(e){return ct(rs(e))}function rs(e){let t=Yo(e);return e?.adapter===`extension-direct`||e?.adapter===`extension-delegate`?t:Zo(t)}let is=null;function as(e){return is=e,()=>{is===e&&(is=null)}}function os(){if(!is)throw new ba(`session-not-found`);return is}const ss=`focus`,cs={type:`leaf`,surfaceId:`chat`};function ls(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 us={focus:{name:`focus`,tree:ls({left:cs},{left:3,middle:1})}};function ds(e){return us[e]??null}const fs=`progress`;function ps(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)}const ms=e(`mount-picker-popup`),hs=6e4;function gs(e){let t=e??`mount-${Date.now().toString(36)}`;return new Promise(e=>{let n=!1,r=t=>{n||(n=!0,clearTimeout(i),e(t))},i=setTimeout(()=>r({cancelled:!0}),hs);Bt(`directory`,[],t,{timeoutMs:hs}).then(e=>{let n=e;if(n.error){ms.error(`picker popup launch failed for directory kind`,{requestId:t,error:n.error}),r({error:`Failed to open directory picker window`});return}r(n)}).catch(e=>{ms.error(`picker popup launch threw for directory kind`,{requestId:t,error:e instanceof Error?e.message:String(e),name:e instanceof Error?e.name:void 0}),r({error:`Failed to open directory picker window`})})})}async function _s(e){let t=await new Promise((e,t)=>{let n=indexedDB.open(`slicc-pending-mount`,1);n.onupgradeneeded=()=>{n.result.objectStoreNames.contains(`handles`)||n.result.createObjectStore(`handles`)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),n=t.transaction(`handles`,`readwrite`),r=n.objectStore(`handles`),i=r.get(e),a=r.delete(e);a.onerror=()=>{ms.warn(`Failed to delete pending handle from IDB`,{idbKey:e,error:a.error})};let o=await new Promise((e,t)=>{n.oncomplete=()=>e(i.result??null),i.onerror=()=>t(i.error??Error(`IDB get failed`)),n.onerror=()=>t(n.error??Error(`IDB transaction failed`)),n.onabort=()=>t(n.error??Error(`IDB transaction aborted`))});return t.close(),o}async function vs(e){let t=e;if(t.requestPermission){let n=await t.requestPermission({mode:`readwrite`});if(n!==`granted`)throw Error(`Permission denied for "${e.name}" (${n})`)}}async function ys(){try{let e=await gs();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 _s(e.idbKey);if(!t)throw Error(`mount: no directory handle found in storage`);return await vs(t),t}throw Error(`mount: unexpected popup result`)}catch(e){throw Error(`mount: ${e instanceof Error?e.message:String(e)}`)}}async function bs(){if(typeof window>`u`||!(`showDirectoryPicker`in window))throw Error(`mount: local picker requires a user gesture in the panel (unavailable in this runtime). Ask the agent to mount it instead.`);try{return await window.showDirectoryPicker({mode:`readwrite`})}catch(e){throw e instanceof Error&&e.name===`AbortError`?Error(`mount: cancelled`):Error(`mount: ${e instanceof Error?e.message:String(e)}`)}}function xs(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 Ss(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 Cs=new Set([`--source`,`--profile`,`--backend`,`--max-body-mb`]);function ws(e){for(let t=0;t<e.length;t++){let n=e[t];if(n===`--`)return!1;if(n===`--help`||n===`-h`)return!0;Cs.has(n)&&t++}return!1}function Ts(e){return`aem://${e.org}/${e.name}${e.path?`/${e.path}`:``}`}var Es=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=xs(e);if(i.positional.length===0)return this.usageError(`mount: mount point required`);let a=this.resolvePath(i.positional[0],t);return i.backendError===void 0?i.source?i.source.startsWith(`s3://`)?this.mountS3(a,i):i.source.startsWith(`da://`)||i.source.startsWith(`aem://`)?this.mountAdobe(a,i):this.usageError(`mount: invalid source '${i.source}' — expected s3://..., da://... or aem://...`):this.mountLocal(a,n):this.usageError(`mount: invalid --backend '${i.backendError}' — expected 'da' or 'aem'`)}async executeUmount(e,t){return this.handleUnmount(e,t,`umount`)}async mountLocal(e,t){try{if((this.options.isScoop??(()=>!1))())throw Error(`mount: cannot mount local directories from a scoop (no UI). Ask the cone.`);let n=Se();if(!n){let n=await Ds(e);if(n)return await this.options.fs.mount(e,n,{env:t}),{stdout:`Mounted '${n.describe().displayName}' → ${e}\nIndexing in background for fast file discovery.\nNote: External changes are not auto-detected — use 'mount refresh ${e}' after modifying files outside the browser.\n`,stderr:``,exitCode:0}}let r;if(n){let t=this.options.acquireLocalMountViaToolUI;if(!t)throw Error(`mount: tool UI not available in this runtime`);r=await t(n,e)}else r=oe()?await ys():await bs();let i=Ie.fromHandle(r,{mountId:Ue()});return await this.options.fs.mount(e,i,{env:t}),{stdout:`Mounted '${i.describe().displayName}' → ${e}\nIndexing in background for fast file discovery.\nNote: External changes are not auto-detected — use 'mount refresh ${e}' after modifying files outside the browser.\n`,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`mount: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}async mountS3(e,t){if(!t.source)return this.usageError(`mount: --source required`);let n=t.profile??`default`,r=Ue(),i=new We({mountId:r,ttlMs:3e4}),a=new Re({source:t.source,profile:n,cache:i,maxBodyBytes:t.maxBodyMb?t.maxBodyMb*1024*1024:void 0,mountId:r,signedFetch:this.signedFetchS3??ze(n)});if(!t.noProbe)try{await a.readDir(`/`)}catch(e){return await a.close(),{stdout:``,stderr:`mount: probe failed for ${t.source} — ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}return await this.options.fs.mount(e,a),{stdout:`Mounted '${a.describe().displayName}' → ${e} (profile: ${n})\n`,stderr:``,exitCode:0}}async mountAdobe(e,t){if(!t.source)return this.usageError(`mount: --source required`);let n=t.profile??`default`,r=this.signedFetchDa??He(),i=Ss(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 bo(i.org,i.name,r)).backend,a===`aem`&&(o=`mount: ${i.org}/${i.name} is on Helix 6 — its content lives in the Source Bus at https://api.aem.live/${i.org}/sites/${i.name}/source, not admin.da.live. Mounting through aem://${i.org}/${i.name}. Pass --backend da to force the old endpoint.\n`)}catch(e){return{stdout:``,stderr:`mount: could not determine the content source for ${t.source} — ${e instanceof Error?e.message:String(e)}. Pass --backend da or --backend aem to skip this probe.\n`,exitCode:1}}let s=Ue(),c=new We({mountId:s,ttlMs:3e4}),l={source:a===`aem`?Ts(i):`da://${i.org}/${i.name}${i.path?`/${i.path}`:``}`,profile:n,cache:c,maxBodyBytes:t.maxBodyMb?t.maxBodyMb*1024*1024:void 0,mountId:s,signedFetch:r},u=a===`aem`?new Ve(l):new Le(l);if(!t.noProbe)try{await u.readDir(`/`)}catch(e){return await u.close(),{stdout:``,stderr:o+`mount: probe failed for ${l.source} — ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}return await this.options.fs.mount(e,u),{stdout:`Mounted '${u.describe().displayName}' → ${e} (profile: ${n})\n`,stderr:o,exitCode:0}}async handleUnmount(e,t,n){if(ws(e))return n===`umount`?this.umountHelp():this.help();let r=xs(e);if(r.positional.length===0)return{stdout:``,stderr:`${n}: path required\n`,exitCode:1};let i=this.resolvePath(r.positional[0],t);try{let e,t;if(r.clearCache){let{getAllMountEntries:n}=await import(`./mount-table-store-DrF_Ifaz.js`).then(e=>e.r),r=(await n()).find(e=>e.targetPath===i),a=r?.descriptor.kind;r&&(a===`s3`||a===`da`||a===`aem`)&&(e=r.descriptor.mountId,t=r.descriptor.kind)}await this.options.fs.unmount(i);let n=``;if(r.clearCache&&e&&t){let{RemoteMountCache:t}=await import(`./remote-cache-BE5T1-53.js`).then(e=>e.n);await new t({mountId:e,ttlMs:3e4}).clearMount(),n=` (cache cleared)`}else r.clearCache&&(n=` (no remote cache to clear)`);return{stdout:`Unmounted ${i}${n}\n`,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`${n}: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}async handleList(){try{let e=this.options.fs.listMounts();if(e.length===0)return{stdout:`No active mounts
|
|
5
5
|
`,stderr:``,exitCode:0};let t=this.options.fs.getMountIndex();return{stdout:e.map(e=>{let n=t.getState(e);if(!n)return e;if(n.status===`ready`)return`${e} (indexed: ${n.indexed} entries)`;if(n.status===`indexing`)return`${e} (indexing: ${n.indexed} entries...)`;if(n.status===`error`)switch(n.abortCause){case`depth-exceeded`:return`${e} (index skipped: directory nesting exceeded the depth limit — reads use the slow path; raise SLICC_MOUNT_INDEX_MAX_DEPTH or 'mount unmount ${e}')`;case`entries-exceeded`:return`${e} (index skipped: mounted tree is too large — reads use the slow path; raise SLICC_MOUNT_INDEX_MAX_ENTRIES or 'mount unmount ${e}')`;case`cycle-detected`:return`${e} (index skipped: self-referential mount cycle detected — run 'mount unmount ${e}' to remove it)`;default:return`${e} (index error: ${n.error})`}return`${e} (pending index)`}).join(`
|
|
6
6
|
`)+`
|
|
7
7
|
`,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`mount list: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}async handleInfo(e,t){if(ws(e))return this.help();let n=xs(e);if(n.positional.length===0)return{stdout:``,stderr:`mount info: path required
|
|
@@ -275,7 +275,7 @@ Examples:
|
|
|
275
275
|
skill list
|
|
276
276
|
skill info bluebubbles
|
|
277
277
|
skill read bluebubbles
|
|
278
|
-
`,stderr:``,exitCode:0};let r=t[0],i=await import(`./kernel-worker-
|
|
278
|
+
`,stderr:``,exitCode:0};let r=t[0],i=await import(`./kernel-worker-DVDNaQZZ.js`).then(e=>e.n);try{switch(r){case`list`:return Wm(t,e,i,n.env.get(`PATH`));case`info`:{let n=t[1];if(!n)return{stdout:``,stderr:`skill: info requires a skill name
|
|
279
279
|
`,exitCode:1};let r=await i.getSkillInfo(e,n);return r?{stdout:Hm(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
|
|
280
280
|
`,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+`
|
|
281
281
|
`,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 Km=[{names:[`--branch`,`-b`],validate:e=>!e.startsWith(`-`)&&f(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=>Ti(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=>m(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 qm(e){let t={skills:[],dryRun:!1,json:!1};for(let n=0;n<e.length;n++){let r=e[n],i=Km.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 Jm(e,t){return!e||!t||e.byteLength!==t.byteLength?!1:e.every((e,n)=>e===t[n])}async function Ym(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 Xm(e,t,n,r){let i=await Ym(e,t);return di(n)?i?{status:`kept-local`,write:!1}:{status:`added`,write:!0}:i?Jm(i,r)?{status:`unchanged`,write:!1}:{status:`updated`,write:!0}:{status:`added`,write:!0}}async function Zm(e,t,n,r){let i={changes:[],writes:[],removals:[]};for(let[r,a]of n){let n=`${t}/${r}`,{status:o,write:s}=await Xm(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 fi(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 Qm(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 _i(t),d=await yi(s,c,o.ref,u,!0,l||void 0);if(d&&r.sha===d&&await $m(e,n,r))return{...o,to:d,outcome:`current`,changes:[]};let f=await eh(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 Zm(e,`${ii}/${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 ah(e,{changes:h,writes:g,removals:_}),await bi(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 $m(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 eh(e,t,n,r,i,a,o){let s=await mi(e,t,a,i??`main`);if(s.status===`ok`){let i=li(s.files),a=n||th(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:ih(i,a),path:a}}try{return{files:rh(nh(await pi(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 th(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 nh(e){return new Map([...e].filter(([e])=>ui(e)))}function rh(e){return new Map([...e].sort(([e],[t])=>e.localeCompare(t)))}function ih(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);ui(e)&&r.set(e,i)}return rh(r)}async function ah(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 oh(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 Lm(o,s,t);if(!c.ok)return{...a,outcome:`error`,error:c.error};let l=`${ii}/${n}/SKILL.md`,u=await Ym(e,l),d=new TextEncoder().encode(c.content),f=u!==void 0&&Fm(new TextDecoder().decode(u))===Fm(c.content);if(Jm(u,d)||f)return{...a,changes:[{path:`SKILL.md`,status:`unchanged`}]};let p=u?`updated`:`added`;return i||(await e.mkdir(`${ii}/${n}`,{recursive:!0}),await e.writeFile(l,d),await bi(e,n,{...r,files:[`SKILL.md`]})),{...a,outcome:`updated`,changes:[{path:`SKILL.md`,status:p}]}}function sh(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 ch(e,t,n,r){let i=Ti(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 lh(e,t,n){if(t.length===0){let t=await vi(e);return{targets:t.provenanced,missing:[],skipped:t.unattributed}}let r=[],i=[];for(let a of t){let t=await xi(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?ch(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 uh(e){return e.reason===`not-installed`?`upskill: no skill named "${e.name}" is installed — check \`upskill list\`
|
|
@@ -286,7 +286,7 @@ Examples:
|
|
|
286
286
|
`}function ph(e,t,n,r,i){let a=t?`Skill update (dry run — nothing written):
|
|
287
287
|
`:`Skill update:
|
|
288
288
|
`;for(let n of e)a+=sh(n,t);if(i.length>0&&(a+=fh(i)),!n&&r&&e.length>0){let n=i.length>0?`all ${dh(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 mh(e,t,n){let{targets:r,missing:i,skipped:a}=await lh(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 oh(e,t,i.name,i.provenance,n.dryRun):await Qm(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=qm(e);if(r.error)return{stdout:``,stderr:`${r.error}\n`,exitCode:1};let{results:i,missing:a,skipped:o}=await mh(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`:ph([],r.dryRun,!1,!0,o),stderr:``,exitCode:0}:{stdout:``,stderr:a.length?a.map(uh).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 wi();let l=a.map(uh).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:ph(i,r.dryRun,c,u,o),stderr:l,exitCode:+!u}}function gh(e){let t={outdated:!1,json:!1};for(let n of e)if(n===`--outdated`)t.outdated=!0;else if(n===`--json`)t.json=!0;else if(n.startsWith(`-`))return t.error=`upskill: unknown option "${n}" for list`,t;else return t.error=`upskill: unexpected argument "${n}" for list`,t;return t}function _h(e){return e.to&&e.from&&e.to!==e.from?` ${e.from.slice(0,7)} → ${e.to.slice(0,7)}`:e.to?` ${e.to.slice(0,7)}`:``}function vh(e,t){let n=e.filter(e=>e.outcome===`updated`),r=[];if(n.length===0)r.push(`No outdated skills.`);else{r.push(`Outdated skills:`,``);for(let e of n)r.push(` ${e.skill} ${e.source}${_h(e)}`)}if(t.length>0){let e=t.length===1?`skill`:`skills`;r.push(``,`Skipped ${t.length} ${e} with no install provenance — not checked.`)}let i=e.filter(e=>e.outcome===`error`);if(i.length>0){let e=i.length===1?`skill`:`skills`;r.push(``,`Could not check ${i.length} ${e}:`);for(let e of i)r.push(` ${e.skill}: failed — ${e.error}`)}return`${r.join(`
|
|
289
|
-
`)}\n`}async function yh(e,t,n){let r=await(await import(`./kernel-worker-
|
|
289
|
+
`)}\n`}async function yh(e,t,n){let r=await(await import(`./kernel-worker-DVDNaQZZ.js`).then(e=>e.n)).discoverSkills(e),{collisions:i}=await or(e,rr(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${zm()}`,stderr:``,exitCode:0}:{...sr(`upskill`,Vm(r,`Discoverable local skills`),i,{builtinNames:new Set(Ze())}),exitCode:0}}async function bh(e,t,n){let{results:r,skipped:i}=await mh(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:vh(r,i),stderr:c,exitCode:+!s}}async function xh(e,t,n,r){let i=gh(e);return i.error?{stdout:``,stderr:`${i.error}\n`,exitCode:1}:i.outdated?bh(t,n,i.json):yh(t,i.json,r)}async function Sh(e,t){let n=`${ai}/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(gi(e,n))}if(r.status!==200)throw Error(`Tessl returned HTTP ${r.status}`);let i=de(r.body);if(!i.data)return[];let a=new Map;for(let e of i.data){if(e.type!==`skill`)continue;let t=e.attributes,n=Ci(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 Ch(e,t){let n=`${ai}/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: ${gi(e,n)}`}}if(r.status!==200)return{error:`Tessl search failed (HTTP ${r.status})`};let i=de(r.body).data?.find(t=>t.type===`skill`&&t.attributes.name===e);if(!i)return{error:`skill "${e}" not found on Tessl registry`};let a=Ci(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 wh=[{label:`Tessl`,host:new URL(ai).host,fetch:Sh},{label:`browse.sh`,host:new URL(ci).host,fetch:km}];function Th(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 Eh(e,t,n=1){let r=await Promise.allSettled(wh.map(n=>n.fetch(e,t))),i=r.map(e=>e.status===`fulfilled`?e.value:[]),a=r.every(e=>e.status===`rejected`),o=Th(i),s=``;for(let e=0;e<r.length;e++){let t=r[e];if(t.status===`rejected`){let n=wh[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+=`
|
|
290
290
|
`}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:
|
|
291
291
|
`,p+=` From Tessl: upskill <owner/repo> --skill <name>
|
|
292
292
|
`,p+=` From browse.sh: upskill browse:<hostname>/<task>
|
|
@@ -309,7 +309,7 @@ Examples:
|
|
|
309
309
|
`,{stdout:s,stderr:``,exitCode:0}}function Nh(e){return!e||e.startsWith(`-`)?{stdout:``,stderr:`upskill: --branch requires a value
|
|
310
310
|
`,exitCode:1}:f(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
|
|
311
311
|
`,exitCode:1}}function Ph(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`||!m(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
|
|
312
|
-
`,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=Nh(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 Fh(e,t,n){if(!t)return{stdout:``,stderr:`upskill: ${e} requires a skill name\n`,exitCode:1};let r=await import(`./kernel-worker-
|
|
312
|
+
`,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=Nh(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 Fh(e,t,n){if(!t)return{stdout:``,stderr:`upskill: ${e} requires a skill name\n`,exitCode:1};let r=await import(`./kernel-worker-DVDNaQZZ.js`).then(e=>e.n);if(e===`info`){let e=await r.getSkillInfo(n,t);if(!e)return{stdout:``,stderr:`upskill: skill "${t}" not found\n`,exitCode:1};let i=await xi(n,t),a=i?Si(i):"Installed from: (no provenance recorded — reinstall to enable `upskill update`)\n";return{stdout:Hm(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+`
|
|
313
313
|
`,stderr:``,exitCode:0}}async function Ih(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 Di(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 Lh(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 Ei(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 Rh(e,t,n,r,i,a,o,s){let c=``,l=``,u=0;for(let d of e){let e=await Ei(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 zh(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 Bh(e,t,n,r){let{owner:i,repo:a}=e,o=t.branch??e.branch,s=t.subPath??e.path,c=await _i(r),l=await Oi(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:zh(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:zh(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 mi(i,a,r,o);if(e.status===`ok`){let r=await yi(i,a,o,c,!0,s),l=await Ih(u,i,a,li(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 Lh(u,i,a,c,n,t.force,o,f);({output:p,errors:m,successCount:h}=e)}}else({output:p,errors:m,successCount:h}=await Rh(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 wi()),{stdout:p,stderr:m,exitCode:+!!m}}async function Vh(e,t,n,r,i){switch(e[0]){case`tabs`:return jh(t,n,r,e.includes(`--json`));case`recommendations`:return Mh(t,n,e.includes(`--install`));case`update`:case`upgrade`:return hh(e.slice(1),t,n);case`list`:return xh(e.slice(1),t,n,i);case`info`:case`read`:return Fh(e[0],e[1],t);case`search`:return Uh(e,n);default:return null}}function Hh(e,t,n){return x(`upskill`,async(r,i)=>{if(r.length===0||r.includes(`--help`)||r.includes(`-h`))return Um();let a=await Vh(r,e,t,n,i.env.get(`PATH`));if(a)return a;let o=Ph(r);if(o.earlyReturn)return o.earlyReturn;if(!o.sourceRef)return Um();if(o.sourceRef.startsWith(`tessl:`))return Wh(o.sourceRef,o.force,e,t);let s=Mm(o.sourceRef);if(s)return Rm(s.hostname,s.task,e,t,o.force);let c=Ti(o.sourceRef);return c?Bh(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 Uh(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?Eh(a,t,i):Um()}async function Wh(e,t,n,r){let i=e.slice(6);if(!i)return{stdout:``,stderr:`upskill: tessl: requires a skill name
|
|
314
314
|
`,exitCode:1};let a=await Ch(i,r);if(`error`in a)return{stdout:``,stderr:`upskill: ${a.error}\n`,exitCode:1};let o=await _i(r);return Ei(a.owner,a.repo,a.skillPath,a.skillName,n,o,t,r)}function Gh(){return{stdout:`usage: afplay [-v volume] [-r rate] <file>
|
|
315
315
|
|
|
@@ -605,7 +605,7 @@ main().catch((err) => { process.stderr.write(String(err && err.message || err) +
|
|
|
605
605
|
`;function w_(e){let t=e.match(/Cannot find module '(@biomejs\/[^']+)'/);if(!t)return null;let n=t[1].split(`/`).slice(0,2).join(`/`);return`biome: ${n} is not installed (run: ${M} ${l_[n]??n}); ${u_}\n`}async function T_(e,t,n,r,i,a,o,s,c){let l={op:t,write:n,check:r,configuration:i,configurationRoot:a,reporter:o,files:s.map(e=>({path:e.path,biomePath:S_(e.path,a),source:e.source,wrap:$g(e.path)}))},u=[`node`,`[biome-helper]`,JSON.stringify(l),c];return E_(await Lt(C_,u,e,void 0,{filename:`[biome-helper]`}))}function E_(e){if(e.exitCode!==0)return{results:[],stderr:w_(e.stderr)??e.stderr,exitCode:e.exitCode};if(e.stdout.trim()===``){let t=w_(e.stderr)??e.stderr.trim();return{results:[],stderr:t?`biome: helper exited 0 with no output: ${t.replace(/\n$/,``)}\n`:`biome: helper exited 0 with no output (nothing was linted)
|
|
606
606
|
`,exitCode:1}}try{return{results:JSON.parse(e.stdout),stderr:``,exitCode:0}}catch(t){let n=t instanceof Error?t.message:String(t),r=e.stderr.trim();return{results:[],stderr:r?`biome: failed to parse helper output: ${n} (helper stderr: ${r})\n`:`biome: failed to parse helper output: ${n}\n`,exitCode:1}}}function D_(e,t,n,r=``){if(e===`plain`)return t;let i=(t.stderr||t.stdout).trimEnd(),a=i?[{severity:t.exitCode===0?`information`:`error`,category:n,message:i,filePath:r,line:null,column:null}]:[],o={summary:{errors:t.exitCode===0?0:1,warnings:0,filesChecked:0,unformattedFiles:0},diagnostics:a,files:[]};return{stdout:`${JSON.stringify(o)}\n`,stderr:``,exitCode:t.exitCode}}async function O_(e,t){let n=await x_(t);if(!n.ok)return{stdout:``,stderr:`biome: ${n.missing} is not installed (run: ${M} ${l_[n.missing]??n.missing}); ${u_}\n`,exitCode:1};let r=`${n.wasmPkgDir}/biome_wasm_bg.wasm`;return await e.fs.exists(r)?{wasmPath:r}:{stdout:``,stderr:`biome: ${r} not found (reinstall: ${M} ${l_[`@biomejs/wasm-web`]})\n`,exitCode:1}}async function k_(e,t){if(t.paths.length===0&&e.stdin)return{inputs:[{path:t.stdinFilePath??`/stdin.ts`,source:N(e.stdin)}],missingErrText:``};if(t.paths.length===0)return{stdout:``,stderr:`biome: no files or directories specified
|
|
607
607
|
`,exitCode:2};let n=await v_(e.fs,e.cwd,t.paths),r=n.missing.map(e=>`biome: ${e}: no such file or directory\n`).join(``),i=[];for(let t of n.files)i.push({path:t,source:await e.fs.readFile(t)});return i.length===0?{stdout:``,stderr:`${r}biome: no lintable files found\n`,exitCode:+(n.missing.length>0)}:{inputs:i,missingErrText:r}}async function A_(e,t,n,r,i){let a=[],o=[i],s=0,c=0,l=0;for(let i of r.results)t.reporter===`plain`&&i.diagnosticsText&&o.push(qg(i.diagnosticsText)),s+=i.errorCount,c+=i.warningCount,t.write&&i.formatted!==null&&!i.unchanged?(await e.fs.writeFile(i.path,i.formatted),l++):!t.write&&t.subcommand===`format`&&!t.check&&n.length===1&&n[0].path===i.path&&a.push(i.formatted??n[0].source);t.write&&l>0&&o.push(`biome: wrote ${l} file(s)\n`);let u=+(s>0||c>0||i.length>0);if(t.reporter===`json`){let e=i?[{severity:`error`,category:`io`,message:i.trimEnd(),filePath:``,line:null,column:null}]:[],t={summary:{errors:s+e.length,warnings:c,filesChecked:r.results.length,unformattedFiles:r.results.filter(e=>!e.unchanged).length},diagnostics:[...r.results.flatMap(e=>e.diagnostics),...e],files:r.results.map(e=>({path:e.path,unchanged:e.unchanged}))};return{stdout:`${JSON.stringify(t)}\n`,stderr:``,exitCode:u}}return{stdout:a.join(``),stderr:o.join(``),exitCode:u}}async function j_(e){let t=await b_(e);return t?{stdout:`${t}\n`,stderr:``,exitCode:0}:{stdout:``,stderr:`biome: @biomejs/wasm-web is not installed (run: ${M} @biomejs/wasm-web@${a_}); ${u_}\n`,exitCode:1}}async function M_(e,t){return e.showHelp?D_(e.reporter,{stdout:d_,stderr:``,exitCode:0},`usage`):e.showVersion?D_(e.reporter,await j_(t),`runtime`):null}function N_(e,t){let n=e.paths[0];if(!n)return``;try{return t.fs.resolvePath(t.cwd,n)}catch{return``}}async function P_(e,t){let n=n_(t),r=await M_(e,n);if(r)return r;if(e.subcommand===null)return D_(e.reporter,{stdout:``,stderr:`biome: missing subcommand (expected check, lint, or format)
|
|
608
|
-
`,exitCode:2},`usage`);let i=await k_(t,e);if(`exitCode`in i)return D_(e.reporter,i,`io`);let a=e.paths.length===0&&t.stdin?t.cwd:Ee(i.inputs[0].path).dir,o=await Ug(t.fs,t.cwd,a,e.configPath);if(!o.ok)return D_(e.reporter,{stdout:``,stderr:`${o.error}\n`,exitCode:o.exitCode},`configuration`,i.inputs[0].path);let s=await O_(t,n);if(`exitCode`in s)return D_(e.reporter,s,`runtime`,i.inputs[0].path);let c=await T_(t,e.subcommand,e.write,e.check,o.resolved?.configuration??null,o.resolved===null?null:Ee(o.resolved.path).dir,e.reporter,i.inputs,s.wasmPath);return c.exitCode===0?A_(t,e,i.inputs,c,i.missingErrText):D_(e.reporter,{stdout:``,stderr:i.missingErrText+c.stderr,exitCode:c.exitCode},`runtime`,i.inputs[0].path)}function F_(){return x(`biome`,async(e,t)=>{let n;try{n=__(e)}catch(t){return D_(m_(e)?`json`:`plain`,{stdout:``,stderr:`${t instanceof Error?t.message:String(t)}\n`,exitCode:2},`usage`)}try{return await P_(n,t)}catch(e){if(n.reporter===`plain`)throw e;return D_(`json`,{stdout:``,stderr:`biome: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1},`runtime`,N_(n,t))}})}function I_(e=`biscotto`){return x(e,async(t,n)=>{let{runBiscotto:r}=await import(`./run-
|
|
608
|
+
`,exitCode:2},`usage`);let i=await k_(t,e);if(`exitCode`in i)return D_(e.reporter,i,`io`);let a=e.paths.length===0&&t.stdin?t.cwd:Ee(i.inputs[0].path).dir,o=await Ug(t.fs,t.cwd,a,e.configPath);if(!o.ok)return D_(e.reporter,{stdout:``,stderr:`${o.error}\n`,exitCode:o.exitCode},`configuration`,i.inputs[0].path);let s=await O_(t,n);if(`exitCode`in s)return D_(e.reporter,s,`runtime`,i.inputs[0].path);let c=await T_(t,e.subcommand,e.write,e.check,o.resolved?.configuration??null,o.resolved===null?null:Ee(o.resolved.path).dir,e.reporter,i.inputs,s.wasmPath);return c.exitCode===0?A_(t,e,i.inputs,c,i.missingErrText):D_(e.reporter,{stdout:``,stderr:i.missingErrText+c.stderr,exitCode:c.exitCode},`runtime`,i.inputs[0].path)}function F_(){return x(`biome`,async(e,t)=>{let n;try{n=__(e)}catch(t){return D_(m_(e)?`json`:`plain`,{stdout:``,stderr:`${t instanceof Error?t.message:String(t)}\n`,exitCode:2},`usage`)}try{return await P_(n,t)}catch(e){if(n.reporter===`plain`)throw e;return D_(`json`,{stdout:``,stderr:`biome: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1},`runtime`,N_(n,t))}})}function I_(e=`biscotto`){return x(e,async(t,n)=>{let{runBiscotto:r}=await import(`./run-BkjrFIPc.js`);return r(e,t,n)})}function L_(e={}){let t=e.getFollowers??ce,n=e.getPanelRpc??o,r=e.getEmitter??(()=>null);return{listRuntimeIds(){return t().filter(e=>e.runtime===`slicc-cherry`).map(e=>e.runtimeId)},async emitSliccEvent(e,t,i){let a=r();if(a)try{return await a(e,t,i)?{delivered:!0}:{delivered:!1,reason:`the follower runtime is not connected to the leader`}}catch(e){return{delivered:!1,reason:`direct emit failed: ${e instanceof Error?e.message:String(e)}`}}let o=n();if(!o)return{delivered:!1,reason:`no page bridge to the leader tray (panel-RPC client)`};try{return(await o.call(`cherry-emit`,{runtimeId:e,name:t,detail:i}))?.delivered?{delivered:!0}:{delivered:!1,reason:`the follower runtime is not connected to the leader`}}catch(e){return{delivered:!1,reason:`panel-RPC delivery failed: ${e instanceof Error?e.message:String(e)}`}}}}}const R_=[`--detail`,`--runtime`];function z_(e){return{stdout:``,stderr:`cherry-emit: ${e}\n`,exitCode:1}}function B_(e){let t=S(e,{value:R_});return`error`in t?z_(t.error):{positionals:t.positionals,detailJson:t.values.get(`--detail`),runtime:t.values.get(`--runtime`)}}function V_(e,t){return e.length===0?z_(`no cherry follower runtime is connected`):t?e.includes(t)?t:z_(`runtime '${t}' not connected. Available: ${e.join(`, `)}`):e.length>1?z_(`multiple runtimes connected, pass --runtime <id>. Available: ${e.join(`, `)}`):e[0]}function H_(e){if(e===void 0)return{detail:void 0};try{return{detail:JSON.parse(e)}}catch{return z_(`--detail must be valid JSON`)}}function U_(e={}){let t=e.registry??L_();return x(`cherry-emit`,async e=>{if(C(e,{valueFlags:R_}))return{stdout:`cherry-emit - push a slicc.event to a cherry host page through a follower runtime
|
|
609
609
|
|
|
610
610
|
Usage: cherry-emit <name> [--detail <json>] [--runtime <id>]
|
|
611
611
|
|
|
@@ -623,7 +623,7 @@ Usage: cherry-emit <name> [--detail <json>] [--runtime <id>]
|
|
|
623
623
|
-o Force paste mode (write to stdout)
|
|
624
624
|
(default) Auto-detect: stdin present = copy, no stdin = paste
|
|
625
625
|
Example: echo hello | ${e}\n Example: ${e} -o > file.txt\n`,stderr:``,exitCode:0}}async function J_(e,t){let n=!!globalThis.navigator?.clipboard,r=n?null:o();if(!n&&!r)return{stdout:``,stderr:`${t}: clipboard API is unavailable\n`,exitCode:1};try{return n?await navigator.clipboard.writeText(e):await r.call(`clipboard-write-text`,{text:e}),{stdout:``,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`${t}: failed to write to clipboard: ${W_(e)}\n`,exitCode:1}}}async function Y_(e){let t=!!globalThis.navigator?.clipboard,n=t?null:o();if(!t&&!n)return{stdout:``,stderr:`${e}: clipboard API is unavailable\n`,exitCode:1};try{return{stdout:t?await navigator.clipboard.readText():(await n.call(`clipboard-read-text`,void 0)).text,stderr:``,exitCode:0}}catch(t){return{stdout:``,stderr:`${e}: failed to read from clipboard: ${W_(t)}\n`,exitCode:1}}}function X_(){return x(`pbcopy`,async(e,t)=>e.includes(`--help`)||e.includes(`-h`)?G_():J_(N(t.stdin),`pbcopy`))}function Z_(){return x(`pbpaste`,async e=>e.includes(`--help`)||e.includes(`-h`)?K_():Y_(`pbpaste`))}function Q_(e){return x(e,async(t,n)=>{if(t.includes(`--help`)||t.includes(`-h`))return q_(e);let r=t.includes(`-i`),i=t.includes(`-o`);if(r&&i)return{stdout:``,stderr:`${e}: cannot use both -i and -o\n`,exitCode:1};if(i)return Y_(e);let a=N(n.stdin);return r||a.length>0?J_(a,e):Y_(e)})}function $_(){return x(`cmp`,async(e,t)=>{let n=e.some(e=>e===`-s`||e===`--quiet`||e===`--silent`),r=e.filter(e=>![`-s`,`--quiet`,`--silent`].includes(e));if(r.length!==2||r.some(e=>e.startsWith(`-`)&&e!==`-`))return{stdout:``,stderr:`cmp: usage: cmp [-s|--quiet|--silent] FILE1 FILE2
|
|
626
|
-
`,exitCode:2};let i=await ev(t,r[0]);if(`error`in i)return n?{...i.error,stderr:``}:i.error;let a=await ev(t,r[1]);if(`error`in a)return n?{...a.error,stderr:``}:a.error;let o=tv(i.bytes,a.bytes);return o?n?{stdout:``,stderr:``,exitCode:1}:o.eof?{stdout:``,stderr:`cmp: EOF on ${i.bytes.length<a.bytes.length?r[0]:r[1]} after byte ${o.byte-1}, line ${o.line}\n`,exitCode:1}:{stdout:`${r[0]} ${r[1]} differ: byte ${o.byte}, line ${o.line}\n`,stderr:``,exitCode:1}:{stdout:``,stderr:``,exitCode:0}})}async function ev(e,t){if(t===`-`){let t=Qr(e.stdin);return{bytes:Uint8Array.from(t,e=>e.charCodeAt(0)&255)}}try{return{bytes:await e.fs.readFileBuffer(e.fs.resolvePath(e.cwd,t))}}catch{return{error:{stdout:``,stderr:`cmp: ${t}: No such file or directory\n`,exitCode:2}}}}function tv(e,t){let n=Math.min(e.length,t.length),r=1;for(let i=0;i<n;i++){if(e[i]!==t[i])return{byte:i+1,line:r,eof:!1};e[i]===10&&r++}return e.length===t.length?null:{byte:n+1,line:r,eof:!0}}function nv(e={}){return x(`computer`,async(t,n)=>{let{runComputer:r}=await import(`./run-
|
|
626
|
+
`,exitCode:2};let i=await ev(t,r[0]);if(`error`in i)return n?{...i.error,stderr:``}:i.error;let a=await ev(t,r[1]);if(`error`in a)return n?{...a.error,stderr:``}:a.error;let o=tv(i.bytes,a.bytes);return o?n?{stdout:``,stderr:``,exitCode:1}:o.eof?{stdout:``,stderr:`cmp: EOF on ${i.bytes.length<a.bytes.length?r[0]:r[1]} after byte ${o.byte-1}, line ${o.line}\n`,exitCode:1}:{stdout:`${r[0]} ${r[1]} differ: byte ${o.byte}, line ${o.line}\n`,stderr:``,exitCode:1}:{stdout:``,stderr:``,exitCode:0}})}async function ev(e,t){if(t===`-`){let t=Qr(e.stdin);return{bytes:Uint8Array.from(t,e=>e.charCodeAt(0)&255)}}try{return{bytes:await e.fs.readFileBuffer(e.fs.resolvePath(e.cwd,t))}}catch{return{error:{stdout:``,stderr:`cmp: ${t}: No such file or directory\n`,exitCode:2}}}}function tv(e,t){let n=Math.min(e.length,t.length),r=1;for(let i=0;i<n;i++){if(e[i]!==t[i])return{byte:i+1,line:r,eof:!1};e[i]===10&&r++}return e.length===t.length?null:{byte:n+1,line:r,eof:!0}}function nv(e={}){return x(`computer`,async(t,n)=>{let{runComputer:r}=await import(`./run-BI7sTnua.js`).then(e=>e.t);return r(t,n,e)})}var rv=`/assets/AdobeClean-Regular-CVsq5gF7.otf`;function iv(e){return{reader:{exists:t=>e.fs.exists(t),isDirectory:async t=>{try{return(await e.fs.stat(t)).isDirectory}catch{return!1}},readFile:t=>e.fs.readFile(t)},readBytes:t=>e.fs.readFileBuffer(t),fromDir:e.cwd}}function av(e){let t=e.toLowerCase();return t.endsWith(`.jpg`)||t.endsWith(`.jpeg`)?`JPEG`:t.endsWith(`.png`)?`PNG`:t.endsWith(`.gif`)?`GIF`:t.endsWith(`.webp`)?`WEBP`:t.endsWith(`.bmp`)?`BMP`:t.endsWith(`.tiff`)||t.endsWith(`.tif`)?`TIFF`:t.endsWith(`.avif`)?`AVIF`:`PNG`}const ov=`AdobeClean-Regular.otf`,sv=new WeakSet;let cv=null;function lv(){return{stdout:`usage: convert [input ...] [operations...] [output]
|
|
627
627
|
|
|
628
628
|
Operations:
|
|
629
629
|
-resize GEOMETRY resize; supports %, !, ^, >, and < modifiers
|
|
@@ -703,7 +703,7 @@ Examples:
|
|
|
703
703
|
`;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+=`
|
|
704
704
|
`;return t}async function ty(e,t){let n=S(e.slice(1),{});if(`error`in n)return Qv(n.error);if(!t()){let e=await Gv();if(!e)return Jv(`list`);let t=await e.listCronTasks();return t.length===0?{stdout:`No active cron tasks
|
|
705
705
|
`,stderr:``,exitCode:0}:{stdout:ey(t),stderr:``,exitCode:0}}let{ok:r,data:i}=await Xv(`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
|
|
706
|
-
`,stderr:``,exitCode:0}:{stdout:ey(a),stderr:``,exitCode:0}}async function ny(e,t){let n=e[0],r=S(e.slice(1),{});if(`error`in r)return Qv(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 Gv();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}:Jv(`delete`)}let{ok:a,status:o,data:s}=await Xv(`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 ry(e={}){let t=e.hasLocalNodeServer??(()=>!1);return x(`crontask`,async(e,n)=>{let r=e[0];if(!r||C(e,{valueFlags:Zv}))return Yv();try{switch(r){case`create`:return await $v(e,n.env,t);case`list`:return await ty(e,t);case`delete`:case`kill`:return await ny(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 iy(e){return x(`curlwright`,async(t,n)=>{let{runCurlwright:r}=await import(`./run-
|
|
706
|
+
`,stderr:``,exitCode:0}:{stdout:ey(a),stderr:``,exitCode:0}}async function ny(e,t){let n=e[0],r=S(e.slice(1),{});if(`error`in r)return Qv(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 Gv();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}:Jv(`delete`)}let{ok:a,status:o,data:s}=await Xv(`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 ry(e={}){let t=e.hasLocalNodeServer??(()=>!1);return x(`crontask`,async(e,n)=>{let r=e[0];if(!r||C(e,{valueFlags:Zv}))return Yv();try{switch(r){case`create`:return await $v(e,n.env,t);case`list`:return await ty(e,t);case`delete`:case`kill`:return await ny(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 iy(e){return x(`curlwright`,async(t,n)=>{let{runCurlwright:r}=await import(`./run-BDv7ZbKM.js`);return r(e,t,n)})}const ay=`slicc-fs`;async function oy(){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===ay)}catch{return!0}}async function sy(){let e=globalThis.indexedDB;return e?new Promise(t=>{let n;try{n=e.deleteDatabase(ay)}catch{t(`error`);return}n.onsuccess=()=>t(`deleted`),n.onerror=()=>t(`error`),n.onblocked=()=>t(`blocked`)}):`error`}async function cy(){if(!await oy())return{kind:`absent`,message:`legacy slicc-fs IDB not present — nothing to clean`};let e=await sy();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 ly(){return`slicc-fs-cleanup — delete the legacy slicc-fs IndexedDB
|
|
707
707
|
|
|
708
708
|
Usage:
|
|
709
709
|
slicc-fs-cleanup Delete the legacy slicc-fs IDB.
|
|
@@ -898,7 +898,7 @@ Without --port, the Web Serial picker opens (needs a user gesture).
|
|
|
898
898
|
`)}\n`:`region erased
|
|
899
899
|
`)}case`run`:{let e=await qx(a,r);return await n.run(e,c,u),Wx(l.length?`${l.join(`
|
|
900
900
|
`)}\n`:`running app
|
|
901
|
-
`)}default:return Gx(`unknown subcommand '${i[0]??``}'. Try 'esptool --help'.`)}}function Xx(){return x(`esptool`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return Wx(Kx);let n=s(),r=o(),i=dx(n,r),a=Et(n,r);if(!i||!a)return Gx(`Web Serial is unavailable in this environment`);try{return await Yx(e,t,i,a)}catch(e){let t=e instanceof Error?e.message:String(e);return/cancelled|NotFoundError|No port selected/i.test(t)?Gx(`user cancelled or no port selected`):Gx(t)}})}function Zx(){return x(`ffmpeg`,async(e,t)=>{let{runFfmpeg:n}=await import(`./run-
|
|
901
|
+
`)}default:return Gx(`unknown subcommand '${i[0]??``}'. Try 'esptool --help'.`)}}function Xx(){return x(`esptool`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return Wx(Kx);let n=s(),r=o(),i=dx(n,r),a=Et(n,r);if(!i||!a)return Gx(`Web Serial is unavailable in this environment`);try{return await Yx(e,t,i,a)}catch(e){let t=e instanceof Error?e.message:String(e);return/cancelled|NotFoundError|No port selected/i.test(t)?Gx(`user cancelled or no port selected`):Gx(t)}})}function Zx(){return x(`ffmpeg`,async(e,t)=>{let{runFfmpeg:n}=await import(`./run-dNFrBZDI.js`);return n(e,t)})}function Qx(){return x(`ffprobe`,async(e,t)=>{let{runFfprobe:n}=await import(`./run-DK8nktud.js`);return n(e,t)})}const $x=new Map;let eS=0;const tS=e=>({stdout:e,stderr:``,exitCode:0}),nS=e=>({stdout:``,stderr:`fswatch: ${e}\n`,exitCode:1}),rS=[`--path`,`--pattern`,`--scoop`,`--name`];function iS(e){let t=S(e.slice(1),{});if(`error`in t)return nS(t.error);if($x.size===0)return tS(`No active file watchers.
|
|
902
902
|
`);let n=``;for(let[,e]of $x)n+=`ID: ${e.id}\n`,n+=` Name: ${e.name}\n`,n+=` Path: ${e.basePath}\n`,n+=` Pattern: ${e.pattern}\n`,e.scoop&&(n+=` Scoop: ${e.scoop}\n`),n+=` Created: ${e.createdAt}\n\n`;return tS(n)}function aS(e){let t=S(e.slice(1),{});if(`error`in t)return nS(t.error);let n=t.positionals[0];if(!n)return nS(`delete requires an ID`);let r=$x.get(n);return r?(r.unsubscribe(),$x.delete(n),tS(`Deleted watcher "${r.name}" (${n})\n`)):nS(`watcher not found: ${n}`)}function oS(e){let t=S(e.slice(1),{value:rS});return`error`in t?t:{basePath:t.values.get(`--path`)??``,pattern:t.values.get(`--pattern`)??``,scoop:t.values.get(`--scoop`)??``,name:t.values.get(`--name`)??``}}function sS(e){let t=RegExp(`^`+e.replace(/\./g,`\\.`).replace(/\*/g,`.*`)+`$`);return e=>t.test(e.split(`/`).pop()??``)}async function cS(e,t){let n=oS(e);if(`error`in n)return nS(n.error);let r=n,i=r.scoop||void 0;if(r.scoop=Ii(r.scoop,t)??``,!r.basePath||!r.pattern)return nS(`--path and --pattern are required`);let a=await qv(await Gv(),`fswatch create`,i);if(a)return{stdout:``,stderr:a,exitCode:1};let o=globalThis,s=o.__slicc_fs_watcher;if(!s)return nS(`file system watcher not available`);let c=`fsw-${++eS}`,l=r.name||`${r.pattern} in ${r.basePath}`,u=o.__slicc_lick_handler,d=s.watch(r.basePath,sS(r.pattern),e=>{if(!u)return;let t=e.map(e=>({type:e.type,path:e.path}));u({type:`fswatch`,fswatchId:c,fswatchName:l,targetScoop:r.scoop,timestamp:new Date().toISOString(),changes:t,body:{changes:t}})});$x.set(c,{id:c,name:l,basePath:r.basePath,pattern:r.pattern,scoop:r.scoop,unsubscribe:d,createdAt:new Date().toISOString()});let f=`Created file watcher "${l}"\n`;return f+=`ID: ${c}\n`,f+=`Path: ${r.basePath}\n`,f+=`Pattern: ${r.pattern}\n`,r.scoop&&(f+=`Scoop: ${r.scoop}\n`),tS(f)}function lS(){return x(`fswatch`,async(e,t)=>{let n=e[0];if(!n||C(e,{valueFlags:rS}))return tS(`usage: fswatch <command> [options]
|
|
903
903
|
|
|
904
904
|
Commands:
|
|
@@ -911,7 +911,7 @@ Options:
|
|
|
911
911
|
--pattern <glob> File pattern to match, e.g. "*.md", "*.bsh" (required)
|
|
912
912
|
--scoop <target> Scoop name, cone name, or folder. Omit for your own cone.
|
|
913
913
|
--name <name> Human-readable name for the watcher
|
|
914
|
-
`);switch(n){case`list`:return iS(e);case`delete`:return aS(e);case`create`:return await cS(e,t.env);default:return nS(`unknown command: ${n}`)}})}function uS(e){return x(`gelatiere`,async(t,n)=>{let{runGelatiere:r}=await import(`./run-
|
|
914
|
+
`);switch(n){case`list`:return iS(e);case`delete`:return aS(e);case`create`:return await cS(e,t.env);default:return nS(`unknown command: ${n}`)}})}function uS(e){return x(`gelatiere`,async(t,n)=>{let{runGelatiere:r}=await import(`./run-AEc54ckO.js`);return r(t,n,e)})}function dS(e){return typeof e.stdoutIsTTY!=`boolean`||e.stdoutIsTTY}function fS(e,t){return typeof e.stdinIsTTY==`boolean`?e.stdinIsTTY:t===void 0?Qr(e.stdin).length===0:t===0}function pS(){return{stdout:`usage: hear [-i file] [-l lang] [-T seconds] [-d deviceId] [--engine name]
|
|
915
915
|
hear --devices | --status | --warmup
|
|
916
916
|
|
|
917
917
|
Speech recognition: listens on the microphone until you pause, then
|
|
@@ -1196,7 +1196,7 @@ Options:
|
|
|
1196
1196
|
`,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}};async function zw(e,t){if(!t.sessionDirsCreated){for(let t of[`/.playwright`,`/.playwright/snapshots`,`/.playwright/screenshots`])try{await e.mkdir(t,{recursive:!0})}catch(e){if(!Bn(e))throw e}t.sessionDirsCreated=!0}}async function Bw(e,t,n,r){try{return await e.withTab(n,async e=>{let{url:i,title:o,text:s,refToSelector:c,refToBackendNodeId:l,refToFrameId:u}=await a(e),d={url:i,title:o,refToSelector:c,refToBackendNodeId:l,refToFrameId:u,content:s,timestamp:Date.now()};r.snapshots.set(n,d);let f=[`Page URL: ${i}`,`Page Title: ${o}`,``,s].join(`
|
|
1197
1197
|
`),p=`/.playwright/snapshots/page-${Rn(new Date)}.yml`;return await t.writeFile(p,f),p})}catch{return null}}async function Vw(e,t,n){await zw(e,t);let r=new Date().toISOString(),i=`playwright-cli ${n.command}${n.args.length?` `+n.args.join(` `):``}`,a=n.result.exitCode===0?n.result.stdout.trim()||`OK`:`Error: ${n.result.stderr.trim()}`,o=[`### ${i}`,`- **Time**: ${r}`];if(n.tabUrl||n.targetId){let e=n.tabUrl?`${n.tabUrl}${n.targetId?` (targetId: ${n.targetId})`:``}`:`targetId: ${n.targetId}`;o.push(`- **Tab**: ${e}`)}o.push(`- **Result**: ${a}`),n.snapshotPath&&o.push(``,`[Snapshot](${n.snapshotPath})`),o.push(`---`,``);let s=o.join(`
|
|
1198
1198
|
`)+`
|
|
1199
|
-
`,c=`/.playwright/session.md`,l=``;try{let t=await e.readFile(c);l=typeof t==`string`?t:new TextDecoder().decode(t)}catch{}await e.writeFile(c,l+s)}function Hw(){return import(`./snapshot-features-
|
|
1199
|
+
`,c=`/.playwright/session.md`,l=``;try{let t=await e.readFile(c);l=typeof t==`string`?t:new TextDecoder().decode(t)}catch{}await e.writeFile(c,l+s)}function Hw(){return import(`./snapshot-features-B_aMougo.js`)}async function Uw(e,t,n,r){let a=await e.getAccessibilityTreeForFrame(r.frameId),o=new Map,s=new Map,c=new Map,l=i(a,o,s,{value:0},``,`f1`);for(let e of o.keys())c.set(e,r.frameId);let u=l.join(`
|
|
1200
1200
|
`);return t.snapshots.set(n,{url:r.url,title:r.name,refToSelector:o,refToBackendNodeId:s,refToFrameId:c,content:u,timestamp:Date.now()}),u}async function Ww(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() {
|
|
1201
1201
|
this.scrollIntoView({ block: 'center' });
|
|
1202
1202
|
const r = this.getBoundingClientRect();
|
|
@@ -1274,7 +1274,7 @@ Options:
|
|
|
1274
1274
|
el.dispatchEvent(new Event('input', { bubbles: true }));
|
|
1275
1275
|
return el.files.length;
|
|
1276
1276
|
})()`,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`,tT],[`state-load`,nT],[`console`,FS],[`requests`,Cw],[`request`,ww],[`request-headers`,Tw],[`request-body`,Ew],[`response-headers`,Dw],[`response-body`,Ow],[`mousemove`,DC],[`mousedown`,OC],[`mouseup`,kC],[`mousewheel`,AC],[`drop`,jC],[`route`,Iw],[`route-list`,Lw],[`unroute`,Rw],[`generate-locator`,GS],[`highlight`,KS]]);function TT(){let e=(Un.string??[]).map(e=>`--${e}`),t=new Set(Un.boolean??[]);for(let[e,n]of Object.entries(Un.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 ET(e){return e.map(e=>e===`--no-iframes`||e.startsWith(`--no-iframes=`)?e.replace(`--no-iframes`,`--_noiframes`):e)}function DT(e){return{...e,bool:[...e.bool??[],`--_noiframes`],value:[...e.value??[],`--_noiframes`]}}const OT=2e3;function kT(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 AT(e,t,n,r){if(!t||typeof e.getTabLockStats!=`function`)return r;let i=e.getTabLockStats(),a=i.totalWaitMs-t.totalWaitMs;if(a<OT)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>=OT?`${(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.
|
|
1277
|
-
`;return{...r,stderr:r.stderr+c}}async function jT(e,t,n){let r=n instanceof Error?n.message:String(n);return{stdout:``,stderr:`Error: ${(t.tab?await Wn(e,t.tab,n):null)??r}\n`,exitCode:1}}function MT(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 NT(e,t,n){let r=wT.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?MT(e,t,void 0):a}catch(r){return i?.aborted?MT(e,t,r):await jT(n.browser,n.flags,r)}}async function PT(e,t,n,r){let i=S(ET(n),DT(r));if(`error`in i)return{answer:{stdout:``,stderr:`${e} ${t}: ${i.error}\n`,exitCode:1}};let a;try{({flags:a}=Hn(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-
|
|
1277
|
+
`;return{...r,stderr:r.stderr+c}}async function jT(e,t,n){let r=n instanceof Error?n.message:String(n);return{stdout:``,stderr:`Error: ${(t.tab?await Wn(e,t.tab,n):null)??r}\n`,exitCode:1}}function MT(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 NT(e,t,n){let r=wT.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?MT(e,t,void 0):a}catch(r){return i?.aborted?MT(e,t,r):await jT(n.browser,n.flags,r)}}async function PT(e,t,n,r){let i=S(ET(n),DT(r));if(`error`in i)return{answer:{stdout:``,stderr:`${e} ${t}: ${i.error}\n`,exitCode:1}};let a;try{({flags:a}=Hn(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-Byyp6Pcv.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 FT(e,t,n){let r=t?zn(t,n):null,i=TT();return x(e,async(a,o)=>{if(a.length===0||a[0]===`help`||a[0]===`--help`||a[0]===`-h`){let{formatHelp:t}=await import(`./help-Byyp6Pcv.js`);return{stdout:t(e)+`
|
|
1278
1278
|
`,stderr:``,exitCode:0}}let s=a[0],c=a.slice(1),l=await PT(e,s,c,i);if(`answer`in l)return l.answer;let{positional:u,flags:d}=l;if(!t||!r)return{stdout:``,stderr:`${e}: browser APIs are unavailable in this environment\n`,exitCode:1};let f=d.tab??null,p=kT(t,f),m=await NT(e,s,{browser:t,fs:n,state:r,positional:u,flags:d,scratchDir:Li(o.env),onTab:(e,n)=>t.withTab(e,n,{signal:o.signal}),signal:o.signal}),h=d.tab??null,g=null;Xn.has(s)&&m.exitCode===0&&h&&(g=await Bw(t,n,h,r));try{await Vw(n,r,{command:s,args:c,result:m,snapshotPath:g,targetId:h})}catch{}return AT(t,p,f,m)})}const IT=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`,...Jn,`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)`,[...Ag]]]);function LT(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:
|
|
1279
1279
|
`);let a=[];for(let[e,t]of IT){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(`
|
|
1280
1280
|
`)+`
|
|
@@ -1459,7 +1459,7 @@ Options:
|
|
|
1459
1459
|
--global Resolve only from the shared global prefix (/shared/lib/node_modules)
|
|
1460
1460
|
-h, --help Show this help message
|
|
1461
1461
|
`}async function nO(e,t){let n=await e.readFile(t);return typeof n==`string`?n:new TextDecoder().decode(n)}async function rO(e,t){try{return(await e.stat(t)).type===`file`}catch{return!1}}async function iO(e,t){try{return(await e.stat(t)).type===`directory`}catch{return!1}}function*aO(e,t=!1){if(t){yield cr;return}let n=y(e);for(;yield b(n,`node_modules`),n!==`/`;)n=Ee(n).dir;yield cr}async function oO(e,t,n,r=!1){for(let i of aO(t,r)){let t=b(i,`.bin`,n);if(!await rO(e,t))continue;let r=await nO(e,t),a=eO.exec(r),o=Ee(t).dir;return{binFilePath:a?b(o,a[1]):t,argvName:t}}return null}function sO(e){if(e.startsWith(`@`)){let t=e.indexOf(`/`);if(t!==-1)return e.slice(t+1)}return e}function cO(e,t){if(typeof e==`string`)return{binName:sO(t),binPath:e};if(typeof e!=`object`||!e)return null;let n=[t,sO(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 lO(e,t,n,r=!1){for(let i of aO(t,r)){let t=b(i,n),r=b(t,`package.json`);if(!await rO(e,r))continue;let a;try{a=JSON.parse(await nO(e,r))}catch{return null}let o=cO(a.bin,n);if(!o)return null;let s=o.binPath.replace(/^\.\//,``);return{binFilePath:b(t,s),argvName:b(i,`.bin`,o.binName)}}return null}async function uO(e,t,n,r=!1){return await oO(e,t,n,r)??await lO(e,t,n,r)}async function dO(e,t,n){for(let r of aO(t))if(await rO(e,b(r,n,`package.json`)))return!0;return!1}function fO(e){return e instanceof Error?e.message:String(e)}function pO(e,t){return{stdout:``,stderr:`${e}: ${t}\n`,exitCode:1}}async function mO(e,t,n,r){try{let i=await qi([t],{fs:r.fs,fetch:r.fetch,cwd:n.cwd});if(i.errors.length>0)return{error:pO(e,`failed to install '${t}': ${fO(i.errors[0].error)}`)};let a=i.results.map(t=>`${e}: installed ${t.name}@${t.version}`);return{progress:a.length>0?`${a.join(`
|
|
1462
|
-
`)}\n`:``}}catch(n){return{error:pO(e,`failed to install '${t}': ${fO(n)}`)}}}async function hO(e,t,n,r){return await rO(r,n)?null:await iO(r,n)?pO(e,`bin target '${n}' is a directory, not a file`):pO(e,`bin file '${n}' for '${t}' does not exist`)}async function gO(e,t,n,r,i,a){if(await dO(a.fs,i.cwd,t))return{error:pO(e,`package '${t}' does not expose an executable bin`)};let o=r?void 0:ZD(t);if(o)return{error:{stdout:``,stderr:$D(e,t,n,o),exitCode:1}};let s=await mO(e,t,i,a);if(`error`in s)return s;let c=await uO(a.fs,i.cwd,t);return c?{resolved:c,installProgress:s.progress}:{error:pO(e,`package '${t}' was installed but does not expose an executable bin`)}}function _O(e,t){return{name:e,trusted:!0,async execute(n,r){if(n.length===0||n[0]===`--help`||n[0]===`-h`)return{stdout:tO(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:tO(e),stderr:``,exitCode:1};let c=s[0],l=s.slice(1),u;try{u=await uO(t.fs,r.cwd,c,o)}catch(t){return pO(e,fO(t))}let d=``;if(!u){if(o)return pO(e,`no global bin '${c}' found in ${cr}`);let n=await gO(e,c,l,i,r,t);if(`error`in n)return n.error;u=n.resolved,d=n.installProgress}let f=await hO(e,c,u.binFilePath,t.fs);if(f)return f;let p=wt(await nO(t.fs,u.binFilePath)),m=[`node`,u.argvName,...l],h=await Lt(p,m,r,void 0,{filename:u.binFilePath});return{stdout:h.stdout,stderr:d+h.stderr,exitCode:h.exitCode}}}}function vO(e={}){return x(`jshd`,async(t,n)=>{let{runJshd:r}=await import(`./run-
|
|
1462
|
+
`)}\n`:``}}catch(n){return{error:pO(e,`failed to install '${t}': ${fO(n)}`)}}}async function hO(e,t,n,r){return await rO(r,n)?null:await iO(r,n)?pO(e,`bin target '${n}' is a directory, not a file`):pO(e,`bin file '${n}' for '${t}' does not exist`)}async function gO(e,t,n,r,i,a){if(await dO(a.fs,i.cwd,t))return{error:pO(e,`package '${t}' does not expose an executable bin`)};let o=r?void 0:ZD(t);if(o)return{error:{stdout:``,stderr:$D(e,t,n,o),exitCode:1}};let s=await mO(e,t,i,a);if(`error`in s)return s;let c=await uO(a.fs,i.cwd,t);return c?{resolved:c,installProgress:s.progress}:{error:pO(e,`package '${t}' was installed but does not expose an executable bin`)}}function _O(e,t){return{name:e,trusted:!0,async execute(n,r){if(n.length===0||n[0]===`--help`||n[0]===`-h`)return{stdout:tO(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:tO(e),stderr:``,exitCode:1};let c=s[0],l=s.slice(1),u;try{u=await uO(t.fs,r.cwd,c,o)}catch(t){return pO(e,fO(t))}let d=``;if(!u){if(o)return pO(e,`no global bin '${c}' found in ${cr}`);let n=await gO(e,c,l,i,r,t);if(`error`in n)return n.error;u=n.resolved,d=n.installProgress}let f=await hO(e,c,u.binFilePath,t.fs);if(f)return f;let p=wt(await nO(t.fs,u.binFilePath)),m=[`node`,u.argvName,...l],h=await Lt(p,m,r,void 0,{filename:u.binFilePath});return{stdout:h.stdout,stderr:d+h.stderr,exitCode:h.exitCode}}}}function vO(e={}){return x(`jshd`,async(t,n)=>{let{runJshd:r}=await import(`./run-BzjnYE1_.js`);return r(t,n,e)})}const yO=new Set([`SIGINT`,`SIGTERM`,`SIGKILL`,`SIGSTOP`,`SIGCONT`]);function bO(e={}){return x(`kill`,async t=>{if(t.length===0||t.includes(`--help`)||t.includes(`-h`))return EO();let n=e.processManager??xO();if(!n)return{stdout:``,stderr:`kill: no process manager available in this runtime
|
|
1463
1463
|
`,exitCode:1};let r=SO(t);if(!r.ok)return{stdout:``,stderr:r.stderr,exitCode:r.exitCode};let{allDelivered:i,errors:a}=CO(n,r.pids,r.signal);return{stdout:``,stderr:a.length?`${a.join(`
|
|
1464
1464
|
`)}\n`:``,exitCode:+!i}})}function xO(){let e=globalThis.__slicc_pm;return e instanceof Object&&typeof e.signal==`function`?e:null}function SO(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
|
|
1465
1465
|
`,exitCode:2};let i=wO(n);if(i instanceof Error)return{ok:!1,stderr:`kill: ${i.message}\n`,exitCode:2};t=i;continue}if(i.startsWith(`-`)){let e=TO(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
|
|
@@ -1532,7 +1532,7 @@ Common base URLs:
|
|
|
1532
1532
|
`)+`
|
|
1533
1533
|
`,stderr:``,exitCode:0}}function $O(e,t){let n=t.models.length;return{stdout:[`✓ ${e} (${YO(t.runtime,!1)})`,` Saved ${n} model${n===1?``:`s`} to Settings:`,...XO(t.models)].join(`
|
|
1534
1534
|
`)+`
|
|
1535
|
-
`,stderr:``,exitCode:0}}function ek(){return x(qO,async e=>{if(e.includes(`--help`)||e.includes(`-h`))return{stdout:JO(),stderr:``,exitCode:0};let{getApiKeyForProvider:t,getRawApiKeyForProvider:n,getBaseUrlForProvider:r,addAccount:i}=await import(`./account-store-
|
|
1535
|
+
`,stderr:``,exitCode:0}}function ek(){return x(qO,async e=>{if(e.includes(`--help`)||e.includes(`-h`))return{stdout:JO(),stderr:``,exitCode:0};let{getApiKeyForProvider:t,getRawApiKeyForProvider:n,getBaseUrlForProvider:r,addAccount:i}=await import(`./account-store-CDXeAYze.js`).then(e=>e.t),{verifyConnection:a}=await import(`./local-llm-B6veJ_ef.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(qO);if(!s)return{stdout:``,stderr:`Local LLM is not configured. Open Settings → Providers → Local LLM and set a base URL.
|
|
1536
1536
|
`,exitCode:1};let c=await a(s,t(qO)??void 0);if(!c.ok)return ZO(s,c);if(o===`discover`){let e=n(qO)??``;return i(qO,e,s,c.models.join(`, `)),$O(s,c)}return QO(s,c)})}function tk(){return{stdout:`usage: man <topic>
|
|
1537
1537
|
|
|
1538
1538
|
Fetches documentation for a given topic from sliccy.com.
|
|
@@ -1570,20 +1570,20 @@ authorization-code flow, stores the access token, and retries.
|
|
|
1570
1570
|
On success, the server is persisted to /workspace/.mcp/servers.json and
|
|
1571
1571
|
an alias shim is written to /workspace/.mcp/aliases/<name>.jsh so the
|
|
1572
1572
|
short name resolves on the PATH.
|
|
1573
|
-
`);let n=S(e,{});if(`error`in n)return sk(n.error);if(n.positionals.length<2)return W(`mcp add: expected <url> <name>`);let[r,i]=n.positionals;if(!/^https?:\/\//i.test(r))return W(`mcp add: invalid URL "${r}" (must start with http:// or https://)`);if(!/^[A-Za-z][A-Za-z0-9_-]*$/.test(i))return W(`mcp add: invalid name "${i}" (letters, digits, _ and - only; must start with a letter)`);let{getServer:a,setServer:o}=await import(`./store-
|
|
1573
|
+
`);let n=S(e,{});if(`error`in n)return sk(n.error);if(n.positionals.length<2)return W(`mcp add: expected <url> <name>`);let[r,i]=n.positionals;if(!/^https?:\/\//i.test(r))return W(`mcp add: invalid URL "${r}" (must start with http:// or https://)`);if(!/^[A-Za-z][A-Za-z0-9_-]*$/.test(i))return W(`mcp add: invalid name "${i}" (letters, digits, _ and - only; must start with a letter)`);let{getServer:a,setServer:o}=await import(`./store-BuVY3ZgP.js`).then(e=>e.r);if(await a(i,t.fs))return W(`mcp add: a server named "${i}" already exists`);let{McpClient:s,McpAuthRequiredError:c}=await import(`./client-GY8xUpw7.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 dk(r,i,e.resourceMetadataUrl,t),l=new s({url:r,fetchImpl:t.fetchImpl,getAuthHeader:()=>Bk(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 Gk(i,t);let m=await Jk(i,f,t);if(u){let{registerMcpProvider:e}=await import(`./provider-CP2FrBD1.js`);e({name:i,serverUrl:r,auth:u})}return U([`Added MCP server "${i}" → ${r}`,` tools: ${d.length}, apps: ${f.length} (${m} sprinkle${m===1?``:`s`})`,` alias: ${ok}/${i}.jsh`,u?` auth: oauth (provider mcp:${i})`:` auth: none`].join(`
|
|
1574
1574
|
`)+`
|
|
1575
|
-
`)}async function dk(e,t,n,r){let{discoverAuth:i,dynamicRegister:a,runAuthFlow:o}=await import(`./oauth-DR6XMm1M.js`),{saveOAuthAccount:s}=await import(`./account-store-
|
|
1576
|
-
`);let n=S(e,{});if(`error`in n)return sk(n.error);let{ensureAllMcpProvidersRegistered:r}=await import(`./provider-
|
|
1575
|
+
`)}async function dk(e,t,n,r){let{discoverAuth:i,dynamicRegister:a,runAuthFlow:o}=await import(`./oauth-DR6XMm1M.js`),{saveOAuthAccount:s}=await import(`./account-store-CDXeAYze.js`).then(e=>e.t),c=await Hk(r.oauthFetchImpl),l=r.oauthLauncher??await Vk(),u=await i(e,n,c);ak.debug(`MCP OAuth discovery succeeded`,{name:t,serverUrl:e,discoveryPath:u.discoveryPath,issuer:u.issuer});let d=await ea(_e()),f=await a(u,d,c),p=u.supportedScopes&&u.supportedScopes.length>0?u.supportedScopes.join(` `):void 0,m=await o({asMetadata:u,clientId:f.clientId,scope:p,redirectUri:d,launcher:l,fetchImpl:c}),h=`mcp:${t}`;return await s({providerId:h,accessToken:m.accessToken,refreshToken:m.refreshToken,tokenExpiresAt:m.expiresAt,scopes:m.scope}),{providerId:h,authorizationServer:u.issuer,clientId:f.clientId,redirectUri:d,scope:m.scope??p,registrationClientUri:f.registrationClientUri}}async function fk(e,t){if(C(e))return U(`usage: mcp list
|
|
1576
|
+
`);let n=S(e,{});if(`error`in n)return sk(n.error);let{ensureAllMcpProvidersRegistered:r}=await import(`./provider-CP2FrBD1.js`);await r();let{listServers:i}=await import(`./store-BuVY3ZgP.js`).then(e=>e.r),a=await i(t.fs),o=Object.keys(a).sort();if(o.length===0)return U("No MCP servers configured. Use `mcp add <url> <name>`.\n");let s=[[`NAME`,`URL`,`AUTH`,`TOOLS`,`APPS`,`ADDED`]];for(let e of o){let t=a[e];s.push([e,t.url,t.auth?`yes`:`no`,String(t.tools?.length??0),String(t.apps?.length??0),t.addedAt?t.addedAt.slice(0,10):`-`])}return U(pk(s))}function pk(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(`
|
|
1577
1577
|
`)+`
|
|
1578
1578
|
`}async function mk(e,t){if(C(e))return U(`usage: mcp search <query>
|
|
1579
1579
|
|
|
1580
1580
|
Case-insensitive substring search across the cached tools of every
|
|
1581
1581
|
registered MCP server. Matches tool name OR description and prints a
|
|
1582
1582
|
table of (server, tool, description, match-field) rows.
|
|
1583
|
-
`);let n=S(e,{});if(`error`in n)return sk(n.error);if(n.positionals.length===0)return W(`mcp search: expected <query>`);let r=n.positionals[0],i=r.toLowerCase(),{ensureAllMcpProvidersRegistered:a}=await import(`./provider-
|
|
1584
|
-
`);let n=S(e,{});if(`error`in n)return sk(n.error);let r=n.positionals[0];if(!r)return W(`mcp delete: expected <name>`);let{ensureMcpProviderRegistered:i,removeMcpProvider:a}=await import(`./provider-
|
|
1583
|
+
`);let n=S(e,{});if(`error`in n)return sk(n.error);if(n.positionals.length===0)return W(`mcp search: expected <query>`);let r=n.positionals[0],i=r.toLowerCase(),{ensureAllMcpProvidersRegistered:a}=await import(`./provider-CP2FrBD1.js`);await a();let{listServers:o}=await import(`./store-BuVY3ZgP.js`).then(e=>e.r),s=await o(t.fs),c=Object.keys(s).sort();if(c.length===0)return U("No MCP servers configured. Use `mcp add <url> <name>`.\n");let l=[];for(let e of c){let t=s[e].tools??[];for(let n of t){let t=n.description??``,r=n.name.toLowerCase().includes(i),a=t.toLowerCase().includes(i);if(!r&&!a)continue;let o=r&&a?`name+description`:r?`name`:`description`;l.push({server:e,tool:n.name,description:t,match:o})}}if(l.length===0)return U(`No tools matched "${r}".\n`);l.sort((e,t)=>e.server===t.server?e.tool.localeCompare(t.tool):e.server.localeCompare(t.server));let u=[[`SERVER`,`TOOL`,`DESCRIPTION`,`MATCH`]];for(let e of l)u.push([e.server,e.tool,hk(e.description),e.match]);return U(pk(u))}function hk(e){if(!e)return``;let t=e.replace(/\s+/g,` `).trim();return t.length<=60?t:t.slice(0,59)+`…`}async function gk(e,t){if(e.length===0||C(e))return e.length===0?W(`mcp delete: expected <name>`):U(`usage: mcp delete <name>
|
|
1584
|
+
`);let n=S(e,{});if(`error`in n)return sk(n.error);let r=n.positionals[0];if(!r)return W(`mcp delete: expected <name>`);let{ensureMcpProviderRegistered:i,removeMcpProvider:a}=await import(`./provider-CP2FrBD1.js`);await i(r);let{deleteServer:o}=await import(`./store-BuVY3ZgP.js`).then(e=>e.r),s=await o(r,t.fs);await Kk(r,t),await qk(r,t);let c=`mcp:${r}`,l=!1;try{let{removeAccount:e,getAccounts:t}=await import(`./account-store-CDXeAYze.js`).then(e=>e.t);t().some(e=>e.providerId===c)&&(await e(c),l=!0)}catch(e){ak.warn(`mcp delete: OAuth removal failed`,{providerId:c,error:e instanceof Error?e.message:String(e)})}let u=a(r);return!s&&!l&&!u?W(`mcp delete: no server, alias, or account found for "${r}"`):U([`Removed MCP server "${r}"`,` servers.json: ${s?`removed`:`not present`}`,` alias: cleaned`,` sprinkles: cleaned`,` oauth: ${l?`removed`:`not present`}`,` provider: ${u?`unregistered`:`not registered`}`].join(`
|
|
1585
1585
|
`)+`
|
|
1586
|
-
`)}async function _k(e,t){if(e.length===0)return W(`mcp invoke: expected <name>`);if(C(e.slice(0,1)))return U(bk());let n=S([e[0]],{});if(`error`in n)return sk(n.error);let r=n.positionals[0];if(!r)return W(`mcp invoke: expected <name>`);let i=e.slice(1),{ensureMcpProviderRegistered:a}=await import(`./provider-
|
|
1586
|
+
`)}async function _k(e,t){if(e.length===0)return W(`mcp invoke: expected <name>`);if(C(e.slice(0,1)))return U(bk());let n=S([e[0]],{});if(`error`in n)return sk(n.error);let r=n.positionals[0];if(!r)return W(`mcp invoke: expected <name>`);let i=e.slice(1),{ensureMcpProviderRegistered:a}=await import(`./provider-CP2FrBD1.js`);await a(r);let{getServer:o}=await import(`./store-BuVY3ZgP.js`).then(e=>e.r),s=await o(r,t.fs);if(!s)return W(`mcp invoke: unknown server "${r}" (run \`mcp add <url> ${r}\` first)`);let c=s.tools??[];if(i.length===0||C(i.slice(0,1)))return U(xk(r,s,c));let l=S([i[0]],{});if(`error`in l)return sk(l.error);let u=l.positionals[0];if(!u)return W(`mcp invoke: expected <tool>`);let d=c.find(e=>e.name===u);if(!d)return W(`mcp invoke: unknown tool "${u}" on "${r}" (run \`${r}\` to list tools)`);let{timeoutMs:f,remaining:p,warnings:m}=vk(i.slice(1));if(C(p))return U(Ck(r,d));let h=wk(p,d.inputSchema);if(!h.ok)return W(`mcp invoke: ${h.error}`);let{McpClient:g}=await import(`./client-GY8xUpw7.js`).then(e=>e.n),_=new g({url:s.url,fetchImpl:t.fetchImpl,headers:s.headers,getAuthHeader:s.auth?()=>Bk(r):void 0,...f===void 0?{}:{timeoutMs:f}});await _.initialize();let v=Ik(await _.toolsCall(u,h.value));return m.length>0&&(v.stderr=m.map(e=>`${e}\n`).join(``)+v.stderr),v}function vk(e){let t=[],n=[],r,i=0;for(;i<e.length;){let a=e[i];if(a.startsWith(`--timeout=`)){let e=yk(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=yk(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 yk(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 bk(){return`usage: mcp invoke <name> [tool] [--timeout <seconds>] [--flag value …]
|
|
1587
1587
|
|
|
1588
1588
|
mcp invoke <name> List tools on <name>.
|
|
1589
1589
|
mcp invoke <name> <tool> --help Show flags for <tool>.
|
|
@@ -1616,7 +1616,7 @@ Arguments are coerced according to the tool's JSON Schema:
|
|
|
1616
1616
|
|
|
1617
1617
|
Re-fetches the tool catalog and \`apps/list\` for <name>. Does NOT refresh
|
|
1618
1618
|
OAuth tokens — for OAuth token refresh use \`mcp auth <name>\`.
|
|
1619
|
-
`);let n=S(e,{});if(`error`in n)return sk(n.error);let r=n.positionals[0];if(!r)return W(`mcp refresh: expected <name>`);let{ensureMcpProviderRegistered:i}=await import(`./provider-
|
|
1619
|
+
`);let n=S(e,{});if(`error`in n)return sk(n.error);let r=n.positionals[0];if(!r)return W(`mcp refresh: expected <name>`);let{ensureMcpProviderRegistered:i}=await import(`./provider-CP2FrBD1.js`);await i(r);let{getServer:a,setServer:o}=await import(`./store-BuVY3ZgP.js`).then(e=>e.r),s=await a(r,t.fs);if(!s)return W(`mcp refresh: unknown server "${r}"`);let{McpClient:c,McpAuthRequiredError:l}=await import(`./client-GY8xUpw7.js`).then(e=>e.n),u=new c({url:s.url,fetchImpl:t.fetchImpl,headers:s.headers,getAuthHeader:s.auth?()=>Bk(r):void 0});try{await u.initialize()}catch(e){if(e instanceof l)return W(`mcp refresh: server "${r}" returned 401 — token may have expired. Run \`mcp auth ${r}\` to re-authenticate.`);throw e}let d=await u.toolsList(),f=await u.appsList();await o(r,{...s,protocolVersion:u.getNegotiatedProtocolVersion(),tools:d,apps:f,lastRefreshedAt:new Date().toISOString()},t.fs);let p=await Jk(r,f,t);return U(`Refreshed "${r}" — tools: ${d.length}, apps: ${f.length} (${p} sprinkle${p===1?``:`s`})\n`)}async function Rk(e,t){if(C(e))return U(`usage: mcp auth <name> [--silent | --interactive]
|
|
1620
1620
|
|
|
1621
1621
|
Re-authenticate an existing MCP server. By default, attempts a silent
|
|
1622
1622
|
token renewal using the persisted refresh_token; if that returns no
|
|
@@ -1628,7 +1628,7 @@ Options:
|
|
|
1628
1628
|
-i, --interactive Skip silent renewal and open the OAuth popup
|
|
1629
1629
|
directly. Use after revoking a refresh token or
|
|
1630
1630
|
when the AS no longer accepts the cached one.
|
|
1631
|
-
`);let n=S(e,{bool:ik});if(`error`in n)return sk(n.error);let r=n.positionals[0];if(!r)return W(`mcp auth: expected <name>`);let i=n.bools.has(`--silent`)||n.bools.has(`-s`),a=n.bools.has(`--interactive`)||n.bools.has(`-i`);if(i&&a)return W(`mcp auth: --silent and --interactive are mutually exclusive`);let{ensureMcpProviderRegistered:o}=await import(`./provider-
|
|
1631
|
+
`);let n=S(e,{bool:ik});if(`error`in n)return sk(n.error);let r=n.positionals[0];if(!r)return W(`mcp auth: expected <name>`);let i=n.bools.has(`--silent`)||n.bools.has(`-s`),a=n.bools.has(`--interactive`)||n.bools.has(`-i`);if(i&&a)return W(`mcp auth: --silent and --interactive are mutually exclusive`);let{ensureMcpProviderRegistered:o}=await import(`./provider-CP2FrBD1.js`),s=await o(r,{fetchImpl:t.oauthFetchImpl,launcher:t.oauthLauncher}),{getServer:c}=await import(`./store-BuVY3ZgP.js`).then(e=>e.r),l=await c(r,t.fs);if(!l)return W(`mcp auth: unknown server "${r}" (run \`mcp list\` to see configured servers)`);if(!l.auth)return W(`mcp auth: server "${r}" does not use OAuth`);if(!s)return W(`mcp auth: failed to register provider for "${r}"`);let u=`mcp:${r}`,{getRegisteredProviderConfig:d}=await import(`./providers-XoHqlC-q.js`).then(e=>e.r),f=d(u);if(!f)return W(`mcp auth: provider "${u}" is not registered`);if(a)return await zk(r,f,t);if(!f.onSilentRenew)return i?W(`mcp auth: provider "${u}" does not support silent renewal; retry without --silent`):await zk(r,f,t);let p=null;try{p=await f.onSilentRenew()}catch(e){let t=e instanceof Error?e.message:String(e);if(i)return W(`mcp auth: silent renewal for "${r}" failed (${t}); retry without --silent to run the interactive flow`);ak.debug(`mcp auth: silent renewal threw, falling back to interactive`,{name:r,error:t})}return p?U(`Re-authenticated "${r}" via silent renewal (provider ${u})\n`):i?W(`mcp auth: silent renewal for "${r}" returned no token; retry without --silent to run the interactive flow`):await zk(r,f,t)}async function zk(e,t,n){if(!t.onOAuthLogin)return W(`mcp auth: provider "${t.id}" does not support interactive OAuth login`);let r=n.oauthLauncher??await Vk(),i=!1;return await t.onOAuthLogin(r,()=>{i=!0}),i?U(`Re-authenticated "${e}" via interactive login (provider ${t.id})\n`):W(`mcp auth: interactive login for "${e}" did not complete`)}async function Bk(e){let t=`mcp:${e}`,{getOAuthAccountInfo:n}=await import(`./account-store-CDXeAYze.js`).then(e=>e.t),r=n(t);if(!r)return null;if(r.expired){try{let{getRegisteredProviderConfig:e}=await import(`./providers-XoHqlC-q.js`).then(e=>e.r),n=await e(t)?.onSilentRenew?.();if(n)return`Bearer ${n}`}catch(e){ak.debug(`silent renewal threw`,{providerId:t,error:e instanceof Error?e.message:String(e)})}return null}return`Bearer ${r.token}`}async function Vk(){let{createOAuthLauncher:e}=await import(`./oauth-service-DLGjPRxS.js`);return e()}async function Hk(e){if(e)return e;let{createProxiedFetch:t}=await import(`./proxied-fetch-D6EBne5P.js`).then(e=>e.i),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 Uk(e){if(e)return e;let{VirtualFS:t}=await import(`./fs-BjjYK9VY.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 Wk(e){return`// MCP alias for "${e}" — forwards args to \`mcp invoke ${e}\`.
|
|
1632
1632
|
// Auto-generated by \`mcp add ${e}\`; do not edit by hand.
|
|
1633
1633
|
const { promisify } = require('util');
|
|
1634
1634
|
const { exec } = require('child_process');
|
|
@@ -1657,7 +1657,7 @@ try {
|
|
|
1657
1657
|
if (stdout) process.stdout.write(stdout);
|
|
1658
1658
|
if (stderr) process.stderr.write(stderr);
|
|
1659
1659
|
process.exit(exitCode);
|
|
1660
|
-
`}async function Gk(e,t){let n=await Uk(t.fs);await n.mkdir(ok,{recursive:!0}),await n.writeFile(`${ok}/${e}.jsh`,Wk(e)),t.scriptCatalog?.invalidateJsh()}async function Kk(e,t){let n=await Uk(t.fs),r=`${ok}/${e}.jsh`;try{await n.exists(r)&&await n.rm(r)}catch(e){ak.debug(`alias removal failed`,{path:r,error:e instanceof Error?e.message:String(e)})}t.scriptCatalog?.invalidateJsh()}async function qk(e,t){let{removeAppSprinkles:n}=await import(`./apps-
|
|
1660
|
+
`}async function Gk(e,t){let n=await Uk(t.fs);await n.mkdir(ok,{recursive:!0}),await n.writeFile(`${ok}/${e}.jsh`,Wk(e)),t.scriptCatalog?.invalidateJsh()}async function Kk(e,t){let n=await Uk(t.fs),r=`${ok}/${e}.jsh`;try{await n.exists(r)&&await n.rm(r)}catch(e){ak.debug(`alias removal failed`,{path:r,error:e instanceof Error?e.message:String(e)})}t.scriptCatalog?.invalidateJsh()}async function qk(e,t){let{removeAppSprinkles:n}=await import(`./apps-CrxAbeAz.js`);await n(e,t.fs)}async function Jk(e,t,n){try{let{materializeAppSprinkles:r}=await import(`./apps-CrxAbeAz.js`);return(await r(e,t,n.fs)).length}catch(t){return ak.warn(`mcp: failed to materialize app sprinkles`,{name:e,error:t instanceof Error?t.message:String(t)}),0}}function Yk(e){return{stdout:``,stderr:`meminfo: ${e}\n`,exitCode:1}}function Xk(e){if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`],n=e,r=`B`;for(let e of t){if(n<1024)break;n/=1024,r=e}return`${n.toFixed(1)} ${r}`}function Zk(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 Qk(){let e=globalThis.performance,t=e?.measureUserAgentSpecificMemory;return t?t.bind(e):null}function $k(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 eA(e){let t=[`total: ${Xk(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(`${Xk(e.bytes).padEnd(10)} ${e.types.join(`,`).padEnd(20)} ${Zk(e)}`)}return`${t.join(`
|
|
1661
1661
|
`)}\n`}function tA(e={}){return x(`meminfo`,async t=>{let n=$k(t);if(`error`in n)return Yk(n.error);if(n.help)return{stdout:`meminfo - agent-cluster memory diagnostics
|
|
1662
1662
|
|
|
1663
1663
|
Usage:
|
|
@@ -1669,7 +1669,7 @@ Notes:
|
|
|
1669
1669
|
Document-Isolation-Policy). Embedded floats cannot be isolated and
|
|
1670
1670
|
report why instead.
|
|
1671
1671
|
- The browser randomizes measurement timing — expect a short delay.
|
|
1672
|
-
`,stderr:``,exitCode:0};let r=e.isIsolated?e.isIsolated():globalThis.crossOriginIsolated===!0,i=e.measure??Qk();if(!r&&!e.measure)return Yk(`memory measurement requires a cross-origin-isolated runtime (Document-Isolation-Policy) — this runtime is not isolated`);if(!i)return Yk(`performance.measureUserAgentSpecificMemory is not available in this browser`);let a;try{a=await i()}catch(e){return Yk(e instanceof Error?e.message:String(e))}return n.json?{stdout:`${JSON.stringify(a,null,2)}\n`,stderr:``,exitCode:0}:{stdout:eA(a),stderr:``,exitCode:0}})}function nA(e){return x(`memory`,async t=>{let{runMemory:n}=await import(`./run-
|
|
1672
|
+
`,stderr:``,exitCode:0};let r=e.isIsolated?e.isIsolated():globalThis.crossOriginIsolated===!0,i=e.measure??Qk();if(!r&&!e.measure)return Yk(`memory measurement requires a cross-origin-isolated runtime (Document-Isolation-Policy) — this runtime is not isolated`);if(!i)return Yk(`performance.measureUserAgentSpecificMemory is not available in this browser`);let a;try{a=await i()}catch(e){return Yk(e instanceof Error?e.message:String(e))}return n.json?{stdout:`${JSON.stringify(a,null,2)}\n`,stderr:``,exitCode:0}:{stdout:eA(a),stderr:``,exitCode:0}})}function nA(e){return x(`memory`,async t=>{let{runMemory:n}=await import(`./run-C7DSv_4z.js`);return n(t,e)})}function rA(){return x(`mktemp`,async(e,t)=>{let{runMktemp:n}=await import(`./run-dAJe7sKp.js`);return n(e,t)})}const iA=`/.cache/artificial-analysis.json`,aA=[`--all`,`--all-versions`,`--json`,`--refresh`,`--no-benchmarks`,`--help`,`-h`],oA=[`--provider`];function sA(e){return{stdout:``,stderr:e.endsWith(`
|
|
1673
1673
|
`)?e:`${e}\n`,exitCode:1}}async function cA(e){try{let t=await e.readFile(iA),n=JSON.parse(t);if(Date.now()-n.fetchedAt<864e5)return n.models}catch{}return null}function lA(){try{return localStorage.getItem(`aa_api_key`)}catch{return null}}function uA(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 dA(e,t){let n={fetchedAt:Date.now(),models:t};try{await e.mkdir(`/.cache`,{recursive:!0}),await e.writeFile(iA,JSON.stringify(n))}catch{}}async function fA(e,t=!1){if(e&&!t){let t=await cA(e);if(t)return t}let n={Accept:`application/json`},r=lA();r&&(n[`x-api-key`]=r);let i=ie(),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=uA(Array.isArray(s)?s:s.data??s.models??[]);return e&&c.length>0&&await dA(e,c),c}function pA(e){return e.toLowerCase().replace(/\./g,`-`).replace(/-\d{8}$/,``).replace(/-\d{4}$/,``)}function mA(e,t){let n=e.toLowerCase(),r=t.find(e=>e.slug===n);if(r)return r;let i=pA(e),a=t.find(e=>pA(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 hA(){return`models - list available LLM models
|
|
1674
1674
|
|
|
1675
1675
|
Usage: models [options]
|
|
@@ -1684,7 +1684,7 @@ Options:
|
|
|
1684
1684
|
-h, --help Show this help message
|
|
1685
1685
|
`}function gA(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`.replace(`.0M`,`M`):e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function _A(e){return`$${e.toFixed(2)}`}const vA=/\b(embedding|embed|tts|whisper|dall-e|image-gen|audio|vision-preview)\b/i;function yA(e){let t=`${e.id} ${e.name??``}`;return!vA.test(t)}function bA(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 xA(e){let t=e.toLowerCase();return t=t.replace(/-\d{8}$/,``),t=t.replace(/-\d{4}$/,``),t=t.replace(/-(preview|latest)$/,``),bA(t)??t.replace(/-[\d.]+$/,``)}function SA(e){let t=new Map;for(let n of e){let e=xA(n.id);(!t.has(e)||n.selected)&&t.set(e,n)}return[...t.values()]}function CA(e,t,n,r,i){let a=i?mA(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 wA(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=`${_A(e.cost.input)} / ${_A(e.cost.output)}`,a=`${gA(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(`
|
|
1686
1686
|
`)+`
|
|
1687
|
-
`}function TA(e){let t=S(e,{bool:aA,value:oA});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 EA(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 DA(e,t,n,r,i,a){let o=e.getProviderModels(t).filter(yA);if(o.length===0)return[];let s=o.map(e=>CA(e,t,n,r,i)).sort((e,t)=>t.cost.input-e.cost.input);return a||(s=SA(s)),s}function OA(e,t,n,r){let i=`${e}:${t}`,a=`${n}:${r}`;return i===a?`Currently using: ${i}\n`:`Currently using: ${i} (selected ${a} — resolved to a different model)\n`}async function kA(e,t){if(C(e,{valueFlags:oA}))return{stdout:hA(),stderr:``,exitCode:0};let n=TA(e);if(`error`in n)return sA(`models: ${n.error}`);let r=await import(`./account-store-
|
|
1687
|
+
`}function TA(e){let t=S(e,{bool:aA,value:oA});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 EA(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 DA(e,t,n,r,i,a){let o=e.getProviderModels(t).filter(yA);if(o.length===0)return[];let s=o.map(e=>CA(e,t,n,r,i)).sort((e,t)=>t.cost.input-e.cost.input);return a||(s=SA(s)),s}function OA(e,t,n,r){let i=`${e}:${t}`,a=`${n}:${r}`;return i===a?`Currently using: ${i}\n`:`Currently using: ${i} (selected ${a} — resolved to a different model)\n`}async function kA(e,t){if(C(e,{valueFlags:oA}))return{stdout:hA(),stderr:``,exitCode:0};let n=TA(e);if(`error`in n)return sA(`models: ${n.error}`);let r=await import(`./account-store-CDXeAYze.js`).then(e=>e.t);if(r.getAccounts().length===0)return sA(`No provider accounts configured. Run the provider settings to add one.
|
|
1688
1688
|
`);let i=r.resolveCurrentModel(),a=i.id,o=i.provider,s=r.getSelectedProvider(),c=r.getSelectedModelId(),l;if(!n.noBenchmarks){let e=await fA(t,n.forceRefresh);e.length>0&&(l=e)}let u=EA(r,n,s);if(`error`in u)return sA(u.error);let d=[],f=[];for(let e of u){let t=DA(r,e,a,o,l,n.allVersions);if(t.length===0){if(!n.allMode)return sA(`No models available for provider ${e}.\n`);continue}if(d.push(...t),!n.jsonMode){let n=r.getProviderConfig(e);f.push(wA(n.name,e,t,!!l))}}return n.jsonMode?{stdout:JSON.stringify(d,null,2)+`
|
|
1689
1689
|
`,stderr:``,exitCode:0}:(n.allVersions||f.push(`Showing latest versions only. Use --all-versions to see all.
|
|
1690
1690
|
`),f.push(OA(o,a,s,c)),{stdout:f.join(`
|
|
@@ -1742,7 +1742,7 @@ Examples:
|
|
|
1742
1742
|
`)}\n`,stderr:``,exitCode:0}}async function ej(e,t,n){if(!t||!n)return{stdout:``,stderr:`oauth-domain add: requires <providerId> and <domain>
|
|
1743
1743
|
`,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 tj(e,t,n){if(!t||!n)return{stdout:``,stderr:`oauth-domain remove: requires <providerId> and <domain>
|
|
1744
1744
|
`,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 nj(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>
|
|
1745
|
-
`,exitCode:1}}async function rj(e,t,n,r){switch(t){case`list`:return $A(e,n);case`add`:return ej(e,n,r);case`remove`:return tj(e,n,r);case`clear`:return nj(e,n);default:return{stdout:``,stderr:`oauth-domain: unknown subcommand "${t}"\n${ZA()}`,exitCode:1}}}function ij(){return x(`oauth-domain`,async e=>{if(e.length===0||C(e))return{stdout:ZA(),stderr:``,exitCode:0};let t=S(e);if(`error`in t)return QA(t.error);let[n,r,i]=t.positionals,a=await import(`./account-store-
|
|
1745
|
+
`,exitCode:1}}async function rj(e,t,n,r){switch(t){case`list`:return $A(e,n);case`add`:return ej(e,n,r);case`remove`:return tj(e,n,r);case`clear`:return nj(e,n);default:return{stdout:``,stderr:`oauth-domain: unknown subcommand "${t}"\n${ZA()}`,exitCode:1}}}function ij(){return x(`oauth-domain`,async e=>{if(e.length===0||C(e))return{stdout:ZA(),stderr:``,exitCode:0};let t=S(e);if(`error`in t)return QA(t.error);let[n,r,i]=t.positionals,a=await import(`./account-store-CDXeAYze.js`).then(e=>e.t);try{return await rj(a,n,r,i)}catch(e){return QA(e instanceof Error?e.message:String(e))}})}function aj(){return x(`oauth-token`,async(e,t)=>{let{runOAuthToken:n}=await import(`./run-BFBGwUPV.js`);return n(e,t)})}const oj=[`--download`,`-d`,`--view`,`-v`],sj=[`--size`],cj={low:256,medium:768,high:1536};function lj(){return{stdout:`usage: open [--download|-d] [--view|-v [--size <spec>]] <url|path> [url|path...]
|
|
1746
1746
|
|
|
1747
1747
|
VFS paths are served in a new browser tab via the preview service worker.
|
|
1748
1748
|
URLs (http/https/etc.) are opened directly in a new tab.
|
|
@@ -1768,7 +1768,7 @@ Examples:
|
|
|
1768
1768
|
`);let i=!1;try{i=(await t.fs.stat(e)).isDirectory}catch{}let a=await fr(t.fs,i?e:xr(e)),o=Hr(e,a),s;try{s=await r(o)}catch(e){return G(`${e instanceof Error?e.message:String(e)}\n`)}return vj(`opened ${e} → ${o}${yj(s)}`)}async function Ej(e,t,n,r){if(!mr(e)&&e.endsWith(`.shtml`)&&t.fs)return xj(e,t,r.sprinkleManager,r.canOpenWindow,r.openExternal);if(!n.view&&!r.canOpenWindow)return G(`open: browser APIs are unavailable in this environment
|
|
1769
1769
|
`);if(mr(e))return Sj(e,r.canOpenWindow,r.openExternal);let i=t.fs.resolvePath(t.cwd,e);return n.view?Cj(e,i,t,n.sizeSpec):n.download?wj(e,i,t,r.hasDom):Tj(i,t,r.canOpenWindow,r.openExternal)}function Dj(e){return x(`open`,async(t,n)=>{if(t.length===0||C(t,{valueFlags:sj}))return lj();let r=_j(t);if(`error`in r)return{stdout:``,stderr:`${r.error}\n`,exitCode:1};let{download:i,view:a,sizeSpec:s,targets:c}=r;if(c.length===0)return lj();let l=globalThis.__slicc_sprinkleManager,u=typeof window<`u`&&typeof document<`u`,d=u?null:o(),f={canOpenWindow:!!e||u||!!d,hasDom:u,sprinkleManager:l,openExternal:bj(e,u,d)},p=[];for(let e of c){let t=await Ej(e,n,{view:a,download:i,sizeSpec:s},f);if(!t.ok)return t.result;p.push(t.message)}return{stdout:p.join(`
|
|
1770
1770
|
`)+`
|
|
1771
|
-
`,stderr:``,exitCode:0}})}function Oj(){return x(`patch`,async(e,t)=>{let{runPatch:n}=await import(`./run-
|
|
1771
|
+
`,stderr:``,exitCode:0}})}function Oj(){return x(`patch`,async(e,t)=>{let{runPatch:n}=await import(`./run-CMIBcXTS.js`);return n(e,t)})}function kj(e=`pdftk`){return x(e,async(t,n)=>{let{runPdftk:r}=await import(`./run-BEs473Sp.js`);return r(e,t,n)})}function Aj(){return{stdout:`usage: pdftoppm [options] <input.pdf> [output-prefix]
|
|
1772
1772
|
|
|
1773
1773
|
Rasterize PDF pages to images. Writes <prefix>-<n>.<ext> per page, where <n>
|
|
1774
1774
|
is zero-padded to the digit width of the last page (out-1.png for a 9-page
|
|
@@ -1828,7 +1828,7 @@ Examples:
|
|
|
1828
1828
|
plugin list
|
|
1829
1829
|
plugin info my-plugin
|
|
1830
1830
|
plugin remove my-plugin
|
|
1831
|
-
`}function qj(e={}){return x(`plugin`,async(t,n)=>{if(t.length===0||t[0]===`--help`||t[0]===`-h`)return Wj(Kj());let r=t[0],i=t.slice(1),a=n?.cwd??`/`;try{switch(r){case`install`:case`add`:return await eM(i,a,e);case`list`:case`ls`:return await iM(i,e);case`info`:return await aM(i,e);case`validate`:return await oM(i,a,e,Li(n?.env));case`remove`:case`rm`:case`delete`:return await sM(i,e);default:return K(`plugin: unknown subcommand "${r}" (try \`plugin --help\`)`)}}catch(e){return K(`plugin ${r}: ${e instanceof Error?e.message:String(e)}`)}})}async function Jj(e){if(e.fs)return e.fs;let{VirtualFS:t}=await import(`./fs-
|
|
1831
|
+
`}function qj(e={}){return x(`plugin`,async(t,n)=>{if(t.length===0||t[0]===`--help`||t[0]===`-h`)return Wj(Kj());let r=t[0],i=t.slice(1),a=n?.cwd??`/`;try{switch(r){case`install`:case`add`:return await eM(i,a,e);case`list`:case`ls`:return await iM(i,e);case`info`:return await aM(i,e);case`validate`:return await oM(i,a,e,Li(n?.env));case`remove`:case`rm`:case`delete`:return await sM(i,e);default:return K(`plugin: unknown subcommand "${r}" (try \`plugin --help\`)`)}}catch(e){return K(`plugin ${r}: ${e instanceof Error?e.message:String(e)}`)}})}async function Jj(e){if(e.fs)return e.fs;let{VirtualFS:t}=await import(`./fs-BjjYK9VY.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 Yj(e,t,n){let r=cM(t,e);if(await n.exists(r))return{kind:`local`,root:r};let{parseGitHubRef:i}=await import(`./github-install-DTmIqVHt.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 Xj(e){let t=e.replace(/[^A-Za-z0-9._-]+/g,`-`);return/^\.+$/.test(t)?t.replace(/\./g,`_`):t}function Zj(e){let t=[e.owner,e.repo,...e.path?[e.path]:[]];return`${Uj}/${t.map(Xj).join(`--`)}`}async function Qj(e,t,n,r){let{fetchRepoZip:i,stripZipPrefix:a,writeZipFilesToDir:o}=await import(`./github-zip-BhnRGzD6.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 $j(e,t){try{await e.rm(t,{recursive:!0})}catch{}}async function eM(e,t,n){if(C(e))return Wj(`usage: plugin install <path|repo>
|
|
1832
1832
|
|
|
1833
1833
|
Loads the Agent Plugins package at <path>, or downloads it from a GitHub
|
|
1834
1834
|
reference (owner/repo, owner/repo@branch, or
|
|
@@ -1839,19 +1839,19 @@ mcp.json. On success the plugin is recorded in
|
|
|
1839
1839
|
/workspace/.plugins/plugins.json — its skills then surface through the
|
|
1840
1840
|
standard skills discovery, and each supported streamable-http MCP server
|
|
1841
1841
|
is registered in the MCP store as "<plugin>:<server>".
|
|
1842
|
-
`);let r=Gj(`install`,e);if(!(`ok`in r))return r;if(r.positionals.length<1)return K(`plugin install: expected <path|repo>`);let i=await Jj(n),a=await Yj(r.positionals[0],t,i);if(a.kind===`error`)return K(`plugin install: ${a.message}`);let o,s;if(a.kind===`github`){if(!n.fetch)return K(`plugin install: GitHub installs are unavailable (no network fetch configured)`);o=Zj(a.ref),s=a.ref.display;let e=await Qj(a.ref,o,i,n.fetch);if(e)return K(`plugin install: ${e}`)}else o=a.root;let{loadPluginFromDirectory:c}=await import(`./loader-Dw-TPPKt.js`),l=await c(i,o);if(!l.ok)return a.kind===`github`&&await $j(i,o),K(`plugin install: plugin at ${s??o} was rejected:\n${lM(l.diagnostics)}`);let{plugin:u}=l,d=u.manifest.name,{getInstalledPlugin:f,setInstalledPlugin:p}=await import(`./store-
|
|
1842
|
+
`);let r=Gj(`install`,e);if(!(`ok`in r))return r;if(r.positionals.length<1)return K(`plugin install: expected <path|repo>`);let i=await Jj(n),a=await Yj(r.positionals[0],t,i);if(a.kind===`error`)return K(`plugin install: ${a.message}`);let o,s;if(a.kind===`github`){if(!n.fetch)return K(`plugin install: GitHub installs are unavailable (no network fetch configured)`);o=Zj(a.ref),s=a.ref.display;let e=await Qj(a.ref,o,i,n.fetch);if(e)return K(`plugin install: ${e}`)}else o=a.root;let{loadPluginFromDirectory:c}=await import(`./loader-Dw-TPPKt.js`),l=await c(i,o);if(!l.ok)return a.kind===`github`&&await $j(i,o),K(`plugin install: plugin at ${s??o} was rejected:\n${lM(l.diagnostics)}`);let{plugin:u}=l,d=u.manifest.name,{getInstalledPlugin:f,setInstalledPlugin:p}=await import(`./store-BaPEf7w5.js`),m=await f(d,n.fs);if(m&&m.root!==o)return a.kind===`github`&&await $j(i,o),K(`plugin install: a plugin named "${d}" is already installed from ${m.root} (remove it first)`);let h=await rM(u,n),g=await nM(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),Wj(tM(u,h,g,s??o,l.diagnostics))}function tM(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:`,lM(i)),c.join(`
|
|
1843
1843
|
`)+`
|
|
1844
|
-
`}async function nM(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-
|
|
1845
|
-
`);let n=Gj(`list`,e);if(!(`ok`in n))return n;let{listInstalledPlugins:r}=await import(`./store-
|
|
1844
|
+
`}async function nM(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-BuVY3ZgP.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 rM(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-BuVY3ZgP.js`).then(e=>e.r),{McpClient:a}=await import(`./client-GY8xUpw7.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 iM(e,t){if(C(e))return Wj(`usage: plugin list
|
|
1845
|
+
`);let n=Gj(`list`,e);if(!(`ok`in n))return n;let{listInstalledPlugins:r}=await import(`./store-BaPEf7w5.js`),i=await r(t.fs),a=Object.keys(i).sort();if(a.length===0)return Wj("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 Wj(o.map(e=>e.map((e,t)=>e.padEnd(s[t])).join(` `)).join(`
|
|
1846
1846
|
`)+`
|
|
1847
1847
|
`)}async function aM(e,t){if(C(e))return Wj(`usage: plugin info <name>
|
|
1848
|
-
`);let n=Gj(`info`,e);if(!(`ok`in n))return n;if(n.positionals.length<1)return K(`plugin info: expected <name>`);let r=n.positionals[0],{getInstalledPlugin:i}=await import(`./store-
|
|
1848
|
+
`);let n=Gj(`info`,e);if(!(`ok`in n))return n;if(n.positionals.length<1)return K(`plugin info: expected <name>`);let r=n.positionals[0],{getInstalledPlugin:i}=await import(`./store-BaPEf7w5.js`),a=await i(r,t.fs);if(!a)return K(`plugin info: no installed plugin named "${r}"`);let o=await Jj(t),{loadPluginFromDirectory:s}=await import(`./loader-Dw-TPPKt.js`),c=await s(o,a.root);if(!c.ok)return K(`plugin info: plugin at ${a.root} no longer loads:\n${lM(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:`,lM(c.diagnostics)),Wj(d.join(`
|
|
1849
1849
|
`)+`
|
|
1850
1850
|
`)}async function oM(e,t,n,r){if(C(e))return Wj(`usage: plugin validate <path|repo>
|
|
1851
1851
|
`);let i=Gj(`validate`,e);if(!(`ok`in i))return i;if(i.positionals.length<1)return K(`plugin validate: expected <path|repo>`);let a=await Jj(n),o=await Yj(i.positionals[0],t,a);if(o.kind===`error`)return K(`plugin validate: ${o.message}`);let s,c=null;if(o.kind===`github`){if(!n.fetch)return K(`plugin validate: GitHub sources are unavailable (no network fetch configured)`);c=`${r}/.plugin-validate/${Zj(o.ref).split(`/`).pop()}`;let e=await Qj(o.ref,c,a,n.fetch);if(e)return K(`plugin validate: ${e}`);s=c}else s=o.root;let{loadPluginFromDirectory:l}=await import(`./loader-Dw-TPPKt.js`),u;try{u=await l(a,s)}finally{c&&await $j(a,c)}if(!u.ok)return{stdout:``,stderr:`plugin validate: REJECTED\n${lM(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:`,lM(u.diagnostics)),Wj(p.join(`
|
|
1852
1852
|
`)+`
|
|
1853
1853
|
`)}async function sM(e,t){if(C(e))return Wj(`usage: plugin remove <name>
|
|
1854
|
-
`);let n=Gj(`remove`,e);if(!(`ok`in n))return n;if(n.positionals.length<1)return K(`plugin remove: expected <name>`);let r=n.positionals[0],{getInstalledPlugin:i,deleteInstalledPlugin:a}=await import(`./store-
|
|
1854
|
+
`);let n=Gj(`remove`,e);if(!(`ok`in n))return n;if(n.positionals.length<1)return K(`plugin remove: expected <name>`);let r=n.positionals[0],{getInstalledPlugin:i,deleteInstalledPlugin:a}=await import(`./store-BaPEf7w5.js`),o=await i(r,t.fs);if(!o)return K(`plugin remove: no installed plugin named "${r}"`);let s=0;if(o.mcpServerNames&&o.mcpServerNames.length>0){let{deleteServer:e,getServer:n}=await import(`./store-BuVY3ZgP.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(`${Uj}/`);return c&&await $j(await Jj(t),o.root),Wj([`Removed agent plugin "${r}"`,` registry: removed`,` mcp servers: ${s} removed`,c?` files: removed (${o.root})`:` files: left in place (${o.root})`].join(`
|
|
1855
1855
|
`)+`
|
|
1856
1856
|
`)}function cM(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 lM(e){return e.map(e=>` ${e.level===`error`?`error`:`warn `} [${e.component}] ${e.message}`).join(`
|
|
1857
1857
|
`)}const uM=[`pid`,`ppid`,`kind`,`stat`,`start`,`scoop`,`command`],dM=[`pid`,`ppid`,`stat`,`start`,`scoop`,`command`],fM={running:`R`,pending:`S`,exited:`Z`,killed:`K`},pM=[`-a`,`-A`,`-e`,`--all`,`-T`,`--tree`],mM=[`-o`,`--columns`];function hM(e={}){return x(`ps`,async t=>{if(C(t,{valueFlags:mM}))return DM();let n=e.processManager??gM();if(!n)return{stdout:``,stderr:`ps: no process manager available in this runtime
|
|
@@ -1945,7 +1945,7 @@ Examples:
|
|
|
1945
1945
|
`)+`
|
|
1946
1946
|
`,stderr:``,exitCode:0}}try{return{stdout:(await e.panelRpc.call(`list-voices`,void 0)).voices.map(e=>pN(e)).join(`
|
|
1947
1947
|
`)+`
|
|
1948
|
-
`,stderr:``,exitCode:0}}catch(e){return q(aN(e))}}async function hN(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 cN()).map(e=>({name:e.name}));return[...n,...r]}async function gN(e,t){let n=(await hN(e)).find(e=>e.name.toLowerCase().includes(t.toLowerCase()));return n?{resolved:n.name}:{error:q(`voice "${t}" not found. Use --list to see available voices.`)}}async function _N(e,t){try{if(e.local){let{kokoroStatus:e,kokoroWarmup:n}=await import(`./speech-page-realm-stub-C7EPKrHd.js`);return{stdout:iN(t?n():e()),stderr:``,exitCode:0}}return{stdout:iN(t?await e.panelRpc.call(`speak-warmup`,void 0):await e.panelRpc.call(`speak-status`,void 0)),stderr:``,exitCode:0}}catch(e){return q(aN(e))}}async function vN(e,t){return t.includes(`--list`)?mN(e):t.includes(`--status`)?_N(e,!1):t.includes(`--warmup`)?_N(e,!0):null}async function yN(e){try{let{speak:t}=await import(`./speech-page-realm-stub-C7EPKrHd.js`);return await t(e),{stdout:``,stderr:``,exitCode:0}}catch(e){return q(`speech synthesis error: ${aN(e)}`)}}async function bN(e,t){try{return await e.panelRpc.call(`speak-text`,t,{timeoutMs:3e5}),{stdout:``,stderr:``,exitCode:0}}catch(e){return q(aN(e))}}async function xN(e){let{synthesizeToWav:t}=await import(`./speech-page-realm-stub-C7EPKrHd.js`);try{return{bytes:await t(e)}}catch(e){return q(aN(e))}}async function SN(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 q(aN(e))}}async function CN(e,t){return e.local?xN(t):SN(e,t)}async function wN(e,t){let n=await CN(e,t);return`exitCode`in n?n:{...ei(n.bytes),stderr:``,exitCode:0}}async function TN(e,t,n,r){let i=await CN(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 q(`failed to write ${n}: ${aN(e)}`)}return{stdout:`wrote ${Math.max(1,Math.round(i.bytes.byteLength/1024))} KB to ${a}\n`,stderr:``,exitCode:0}}async function EN(e,t,n){let r;if(n.voiceName){let{resolved:t,error:i}=await gN(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&&!dS(t)?wN(e,i):n.outFile?TN(e,t,n.outFile,i):e.local?yN(i):bN(e,i)}function DN(){return x(`say`,async(e,t)=>{if(e.includes(`--help`)||e.includes(`-h`))return rN();let n={local:typeof window<`u`&&typeof speechSynthesis<`u`,panelRpc:o()};if(!n.local&&!n.panelRpc)return q(`Web Speech API unavailable in this environment`);let r=await vN(n,e);if(r)return r;let i=fN(e);return`exitCode`in i?i:i.text?i.lang?EN(n,t,{...i,lang:i.lang}):q(`-l language tag is required`):rN()})}function ON(){return x(`screencapture`,async(e,t)=>{let{runScreencapture:n}=await import(`./screencapture-run-
|
|
1948
|
+
`,stderr:``,exitCode:0}}catch(e){return q(aN(e))}}async function hN(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 cN()).map(e=>({name:e.name}));return[...n,...r]}async function gN(e,t){let n=(await hN(e)).find(e=>e.name.toLowerCase().includes(t.toLowerCase()));return n?{resolved:n.name}:{error:q(`voice "${t}" not found. Use --list to see available voices.`)}}async function _N(e,t){try{if(e.local){let{kokoroStatus:e,kokoroWarmup:n}=await import(`./speech-page-realm-stub-C7EPKrHd.js`);return{stdout:iN(t?n():e()),stderr:``,exitCode:0}}return{stdout:iN(t?await e.panelRpc.call(`speak-warmup`,void 0):await e.panelRpc.call(`speak-status`,void 0)),stderr:``,exitCode:0}}catch(e){return q(aN(e))}}async function vN(e,t){return t.includes(`--list`)?mN(e):t.includes(`--status`)?_N(e,!1):t.includes(`--warmup`)?_N(e,!0):null}async function yN(e){try{let{speak:t}=await import(`./speech-page-realm-stub-C7EPKrHd.js`);return await t(e),{stdout:``,stderr:``,exitCode:0}}catch(e){return q(`speech synthesis error: ${aN(e)}`)}}async function bN(e,t){try{return await e.panelRpc.call(`speak-text`,t,{timeoutMs:3e5}),{stdout:``,stderr:``,exitCode:0}}catch(e){return q(aN(e))}}async function xN(e){let{synthesizeToWav:t}=await import(`./speech-page-realm-stub-C7EPKrHd.js`);try{return{bytes:await t(e)}}catch(e){return q(aN(e))}}async function SN(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 q(aN(e))}}async function CN(e,t){return e.local?xN(t):SN(e,t)}async function wN(e,t){let n=await CN(e,t);return`exitCode`in n?n:{...ei(n.bytes),stderr:``,exitCode:0}}async function TN(e,t,n,r){let i=await CN(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 q(`failed to write ${n}: ${aN(e)}`)}return{stdout:`wrote ${Math.max(1,Math.round(i.bytes.byteLength/1024))} KB to ${a}\n`,stderr:``,exitCode:0}}async function EN(e,t,n){let r;if(n.voiceName){let{resolved:t,error:i}=await gN(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&&!dS(t)?wN(e,i):n.outFile?TN(e,t,n.outFile,i):e.local?yN(i):bN(e,i)}function DN(){return x(`say`,async(e,t)=>{if(e.includes(`--help`)||e.includes(`-h`))return rN();let n={local:typeof window<`u`&&typeof speechSynthesis<`u`,panelRpc:o()};if(!n.local&&!n.panelRpc)return q(`Web Speech API unavailable in this environment`);let r=await vN(n,e);if(r)return r;let i=fN(e);return`exitCode`in i?i:i.text?i.lang?EN(n,t,{...i,lang:i.lang}):q(`-l language tag is required`):rN()})}function ON(){return x(`screencapture`,async(e,t)=>{let{runScreencapture:n}=await import(`./screencapture-run-CoYnKG1H.js`);return n(e,t)})}function kN(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 AN=1e4;async function jN(e,t,n){let r={method:e,headers:he({"Content-Type":`application/json`}),signal:AbortSignal.timeout(AN)};n&&(r.body=JSON.stringify(n));try{let e=await fetch(me(`/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:MN(e)}}}}function MN(e){let t=e instanceof Error?e.name:``;return t===`TimeoutError`||t===`AbortError`?`no response from the secret store within ${AN/1e3}s`:`secret store unreachable: ${e instanceof Error?e.message:String(e)}`}function NN(e,t){return`could not read ${e} secrets — ${t??`the bridge gave no reason`}`}function PN(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 FN(){return{async list(){let[e,t]=await Promise.all([jN(`GET`,``),jN(`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(NN(`saved`,zN(e.data)));if(t.ok)for(let e of t.data)n.push({name:e.name,domains:e.domains,persisted:!1});else r.push(NN(`session`,zN(t.data)));return{entries:n,warnings:r}},async getInfo(e){return PN(await this.list(),e)},async getMasked(e){let{ok:t,data:n}=await jN(`GET`,`/masked`);return t?n.find(t=>t.name===e)??null:null},async peek(e){let{ok:t,data:n}=await jN(`GET`,`/peek?name=${encodeURIComponent(e)}`);return t?n:null},async setSession(e,t,n){let{ok:r,data:i}=await jN(`POST`,`/session`,{name:e,value:t,domains:n});if(!r)throw Error(zN(i)??`failed to set session secret`)},async setPersisted(e,t,n){let{ok:r,data:i}=await jN(`POST`,``,{name:e,value:t,domains:n});if(!r)throw Error(zN(i)??`failed to persist secret`)},async setScope(e,t){let{ok:n,data:r}=await jN(`POST`,`/scope`,{name:e,domains:t});if(!n)throw Error(zN(r)??`failed to update scope`)},async delete(e){let{ok:t,status:n,data:r}=await jN(`DELETE`,`/${encodeURIComponent(e)}`);if(n===404)return{removed:!1};if(!t)throw Error(zN(r)??`failed to delete secret`);return{removed:!0,fromSession:r&&typeof r==`object`&&`fromSession`in r?!!r.fromSession:void 0}}}}function IN(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(NN(`saved`,e?.error)),n?.entries||i.push(NN(`session`,n?.error)),{entries:r,warnings:i}},async getInfo(e){return PN(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 LN(){return IN(e=>kN(e))}function RN(){return IN(e=>{let{type:t,...n}=e;return xe(t,n)})}function zN(e){if(e&&typeof e==`object`&&`error`in e){let t=e.error;if(typeof t==`string`)return t}}function BN(e){switch(e){case`extension-direct`:return LN();case`extension-delegate`:return RN();default:return FN()}}const VN=[`--domain`],HN=[`--persist`];function UN(){return`secret — manage secrets for the fetch proxy and mount backends
|
|
1949
1949
|
|
|
1950
1950
|
No approval (session-only, in-memory, never persisted):
|
|
1951
1951
|
secret set <name> <value> --domain <pat> Set a session secret. Free for a
|
|
@@ -2055,7 +2055,7 @@ Limits and lifetime:
|
|
|
2055
2055
|
`,exitCode:1};if(e.ttlMs!==void 0&&e.maxTabs!==void 0)return{stdout:``,stderr:`serve: --ttl cannot be combined with --max-tabs
|
|
2056
2056
|
`,exitCode:1}}async function LP(e,t,n){if(e.ttlMs!==void 0){if(!t)throw Error(`persistent snapshot filesystem unavailable`);return kP(t,n)}}async function RP(e,t,n,r){if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return pP();let i=yP(e);if(i.error)return{stdout:``,stderr:i.error,exitCode:1};let a=await FP(i);if(a)return a;if(!i.directory)return pP();let o=IP(i);if(o)return o;let s=await bP(i.directory,i.entry,t.fs,t.cwd);if(xP(s))return s;let{fullDirectory:c,entryPath:l}=s,u;try{u=await LP(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)
|
|
2057
2057
|
`:``,f=await NP(!i.noBridge&&i.bridge,d);return f.ok?PP(i,c,l,f.webhookId,d,u,n):f.result}function zP(e,t){return x(`serve`,(n,r)=>RP(n,r,e,t))}const BP=`usage: session export [--id <id>] [--output <path>]
|
|
2058
|
-
`;function VP(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 HP(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${BP}`};let n=r[e+1];if(!n||n.startsWith(`-`))return{ok:!1,stderr:`session export: --id requires a value\n${BP}`};t=n,e++}else if(i===`--output`){if(n!==null)return{ok:!1,stderr:`session export: duplicate flag --output\n${BP}`};let t=r[e+1];if(!t||t.startsWith(`-`))return{ok:!1,stderr:`session export: --output requires a path\n${BP}`};n=t,e++}else if(i.startsWith(`-`))return{ok:!1,stderr:`session export: unknown flag ${i}\n${BP}`};else return{ok:!1,stderr:`session export: unexpected argument ${JSON.stringify(i)}\n${BP}`}}return{ok:!0,args:{sessionId:t,outputPath:n}}}async function UP(e){let t=[],n=0;for await(let r of e.chunks)t.push(r),n+=r.byteLength;let r=new Uint8Array(n),i=0;for(let e of t)r.set(e,i),i+=e.byteLength;let a=await e.completion;if(a.byteLength!==n||xt(r)!==a.sha256)throw new ba(`transfer-corrupt`);return r}async function WP(e,t){let n=HP(e);if(!n.ok)return{stdout:``,stderr:n.stderr,exitCode:1};let{sessionId:r,outputPath:i}=n.args;if(i!==null){let e=VP(i);if(!e.ok)return{stdout:``,stderr:`session export: --output ${e.reason}\n${BP}`,exitCode:1}}let a=r==null?{kind:`active`}:{kind:`frozen`,sessionId:r};try{let e=await os().export(a,{}),n=await UP(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 ba?e.code:e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}function GP(){return x(`session`,async(e,t)=>{if(e[0]===`export`&&!C(e))return WP(e,t);let{dispatchSessionMemoryAware:n}=await import(`./session-command-memory-
|
|
2058
|
+
`;function VP(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 HP(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${BP}`};let n=r[e+1];if(!n||n.startsWith(`-`))return{ok:!1,stderr:`session export: --id requires a value\n${BP}`};t=n,e++}else if(i===`--output`){if(n!==null)return{ok:!1,stderr:`session export: duplicate flag --output\n${BP}`};let t=r[e+1];if(!t||t.startsWith(`-`))return{ok:!1,stderr:`session export: --output requires a path\n${BP}`};n=t,e++}else if(i.startsWith(`-`))return{ok:!1,stderr:`session export: unknown flag ${i}\n${BP}`};else return{ok:!1,stderr:`session export: unexpected argument ${JSON.stringify(i)}\n${BP}`}}return{ok:!0,args:{sessionId:t,outputPath:n}}}async function UP(e){let t=[],n=0;for await(let r of e.chunks)t.push(r),n+=r.byteLength;let r=new Uint8Array(n),i=0;for(let e of t)r.set(e,i),i+=e.byteLength;let a=await e.completion;if(a.byteLength!==n||xt(r)!==a.sha256)throw new ba(`transfer-corrupt`);return r}async function WP(e,t){let n=HP(e);if(!n.ok)return{stdout:``,stderr:n.stderr,exitCode:1};let{sessionId:r,outputPath:i}=n.args;if(i!==null){let e=VP(i);if(!e.ok)return{stdout:``,stderr:`session export: --output ${e.reason}\n${BP}`,exitCode:1}}let a=r==null?{kind:`active`}:{kind:`frozen`,sessionId:r};try{let e=await os().export(a,{}),n=await UP(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 ba?e.code:e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}function GP(){return x(`session`,async(e,t)=>{if(e[0]===`export`&&!C(e))return WP(e,t);let{dispatchSessionMemoryAware:n}=await import(`./session-command-memory-CkGlqxMy.js`);return n(e,t,BP)})}function KP(){return x(`slicc`,async(e,t)=>{let{runSlicc:n}=await import(`./run-DLiMjFBS.js`);return await n(e,t)})}const qP=`leader`;function JP(){try{let e=globalThis.localStorage?.getItem(`slicc.leaderSprinkleInstances`);if(e)return JSON.parse(e)}catch{}return[]}function YP(e){return+!!e.leader+e.followers.length}function XP(){return{stdout:`usage: sprinkle <subcommand> [args]
|
|
2059
2059
|
|
|
2060
2060
|
list [--runtime <id>] List sprinkles + an instance line per runtime
|
|
2061
2061
|
open <name> Open a sprinkle by name
|
|
@@ -2980,7 +2980,7 @@ Install:
|
|
|
2980
2980
|
with a clear \`ipk add\` hint.
|
|
2981
2981
|
`;function sI(e){let t=[],n=!1,r=null,i=!1,a=!1;for(let o=0;o<e.length;o++){let s=e[o];if(s===`-h`||s===`--help`){i=!0;continue}if(s===`-v`||s===`--version`){a=!0;continue}if(s===`--noEmit`){n=!0;continue}if(s===`--outDir`){let t=e[o+1];if(typeof t!=`string`||t.startsWith(`-`))throw Error(`tsc: --outDir requires a value`);r=t,o+=1;continue}if(s.startsWith(`--outDir=`)){r=s.slice(9);continue}if(s.startsWith(`-`))throw Error(`tsc: unknown option: ${s}`);t.push(s)}return{files:t,noEmit:n,outDir:r,showHelp:i,showVersion:a}}function cI(e,t){let n=`${gr(e).replace(/\.(ts|tsx|mts|cts)$/i,``)}.js`;return t?`${t.endsWith(`/`)?t.slice(0,-1):t}/${n}`:`${xr(e)}/${n}`}async function lI(e,t){let n=t||`/`,r=``;for(;n&&n!==r;){let t=n===`/`?`/tsconfig.json`:`${n}/tsconfig.json`;if(await e.exists(t))return t;r=n,n=xr(n)}return null}function uI(e){return{target:e.ScriptTarget.ES2022,module:e.ModuleKind.ESNext,moduleResolution:e.ModuleResolutionKind.Bundler,esModuleInterop:!0,allowSyntheticDefaultImports:!0,isolatedModules:!0}}function dI(e){if(typeof e!=`object`||!e)return{};let{compilerOptions:t}=e;return t??{}}async function fI(e,t,n){let r=uI(t),i=await lI(e,n);if(!i)return{compilerOptions:{...r}};let a;try{a=await e.readFile(i)}catch{return{compilerOptions:{...r}}}let{config:o,error:s}=t.parseConfigFileTextToJson(i,a);return s||!o?{compilerOptions:{...r}}:{compilerOptions:{...r,...dI(o)}}}function pI(e,t){let n=e.flattenDiagnosticMessageText(t.messageText,`
|
|
2982
2982
|
`);if(t.file&&typeof t.start==`number`){let{line:e,character:r}=t.file.getLineAndCharacterOfPosition(t.start);return`${t.file.fileName}(${e+1},${r+1}): error TS${t.code}: ${n}`}return`error TS${t.code}: ${n}`}function mI(e,t){let n=t.toLowerCase();return n.endsWith(`.tsx`)?e.ScriptKind.TSX:n.endsWith(`.jsx`)?e.ScriptKind.JSX:n.endsWith(`.js`)||n.endsWith(`.mjs`)||n.endsWith(`.cjs`)?e.ScriptKind.JS:e.ScriptKind.TS}function hI(e,t,n,r,i){let a=e.transpileModule(t,{compilerOptions:r,fileName:n,reportDiagnostics:i});return{outputText:a.outputText,diagnostics:a.diagnostics??[]}}function gI(e,t,n,r){let{outputText:i,diagnostics:a}=hI(e,r,`<stdin>.ts`,n.compilerOptions,!0),o=a.map(t=>pI(e,t)),s=o.length>0?`${o.join(`
|
|
2983
|
-
`)}\n`:``;return{stdout:t.noEmit?``:i,stderr:s,exitCode:+(a.length>0)}}async function _I(e,t,n,r,i){let a=t.fs.resolvePath(t.cwd,n);if(!await t.fs.exists(a))return{stderr:`tsc: ${n}: no such file\n`,hadError:!0};let o;try{o=await t.fs.readFile(a)}catch(e){return{stderr:`tsc: ${n}: ${e instanceof Error?e.message:String(e)}\n`,hadError:!0}}mI(e,a);let{outputText:s,diagnostics:c}=hI(e,o,a,i.compilerOptions,!0),l=[];for(let t of c)l.push(`${pI(e,t)}\n`);let u=c.length>0;if(r.noEmit)return{stderr:l.join(``),hadError:u};let d=t.fs.resolvePath(t.cwd,cI(a,r.outDir));try{await t.fs.writeFile(d,s)}catch(e){l.push(`tsc: ${d}: ${e instanceof Error?e.message:String(e)}\n`),u=!0}return{stderr:l.join(``),hadError:u}}async function vI(e,t){let n;try{n=sI(e)}catch(e){return{done:{stdout:``,stderr:`${e instanceof Error?e.message:String(e)}\n`,exitCode:2}}}if(n.showHelp)return{done:{stdout:oI,stderr:``,exitCode:0}};let r;try{r=await pr(aI(t))}catch(e){return{done:{stdout:``,stderr:`tsc: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}return n.showVersion?{done:{stdout:`Version ${r.version}\n`,stderr:``,exitCode:0}}:{parsed:n,ts:r}}function yI(){return x(`tsc`,async(e,t)=>{let n=await vI(e,t);if(`done`in n)return n.done;let{parsed:r,ts:i}=n,a=await fI(t.fs,i,t.cwd);if(r.files.length===0){let e=N(t.stdin);return e?gI(i,r,a,e):{stdout:oI,stderr:``,exitCode:0}}let o=[],s=!1;for(let e of r.files){let n=await _I(i,t,e,r,a);n.stderr&&o.push(n.stderr),n.hadError&&(s=!0)}return{stdout:``,stderr:o.join(``),exitCode:+!!s}})}const bI=[`**/*.test.{js,ts}`];function xI(e){let t=[],n=`tap`,r=!1
|
|
2983
|
+
`)}\n`:``;return{stdout:t.noEmit?``:i,stderr:s,exitCode:+(a.length>0)}}async function _I(e,t,n,r,i){let a=t.fs.resolvePath(t.cwd,n);if(!await t.fs.exists(a))return{stderr:`tsc: ${n}: no such file\n`,hadError:!0};let o;try{o=await t.fs.readFile(a)}catch(e){return{stderr:`tsc: ${n}: ${e instanceof Error?e.message:String(e)}\n`,hadError:!0}}mI(e,a);let{outputText:s,diagnostics:c}=hI(e,o,a,i.compilerOptions,!0),l=[];for(let t of c)l.push(`${pI(e,t)}\n`);let u=c.length>0;if(r.noEmit)return{stderr:l.join(``),hadError:u};let d=t.fs.resolvePath(t.cwd,cI(a,r.outDir));try{await t.fs.writeFile(d,s)}catch(e){l.push(`tsc: ${d}: ${e instanceof Error?e.message:String(e)}\n`),u=!0}return{stderr:l.join(``),hadError:u}}async function vI(e,t){let n;try{n=sI(e)}catch(e){return{done:{stdout:``,stderr:`${e instanceof Error?e.message:String(e)}\n`,exitCode:2}}}if(n.showHelp)return{done:{stdout:oI,stderr:``,exitCode:0}};let r;try{r=await pr(aI(t))}catch(e){return{done:{stdout:``,stderr:`tsc: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}return n.showVersion?{done:{stdout:`Version ${r.version}\n`,stderr:``,exitCode:0}}:{parsed:n,ts:r}}function yI(){return x(`tsc`,async(e,t)=>{let n=await vI(e,t);if(`done`in n)return n.done;let{parsed:r,ts:i}=n,a=await fI(t.fs,i,t.cwd);if(r.files.length===0){let e=N(t.stdin);return e?gI(i,r,a,e):{stdout:oI,stderr:``,exitCode:0}}let o=[],s=!1;for(let e of r.files){let n=await _I(i,t,e,r,a);n.stderr&&o.push(n.stderr),n.hadError&&(s=!0)}return{stdout:``,stderr:o.join(``),exitCode:+!!s}})}const bI=[`**/*.test.{js,ts}`];function xI(e,t){let n,r=1;if(e===`--reporter`)n=t,r=2;else if(e.startsWith(`--reporter=`))n=e.slice(11);else return null;if(n!==`tap`&&n!==`spec`)throw Error(`tst: --reporter must be tap or spec`);return{reporter:n,consumed:r}}function SI(e,t){return e===`--coverage`?{consumed:1}:e===`--coverage-dir`&&t!==void 0?{coverageDir:t,consumed:2}:e.startsWith(`--coverage-dir=`)?{coverageDir:e.slice(15),consumed:1}:null}function CI(e){let t=[],n=`tap`,r=!1,i=!1,a=``;for(let o=0;o<e.length;o++){let s=e[o];if(s===`-h`||s===`--help`){r=!0;continue}let c=xI(s,e[o+1]);if(c){n=c.reporter,c.consumed===2&&(o+=1);continue}let l=SI(s,e[o+1]);if(l){i=!0,l.coverageDir!==void 0&&(a=l.coverageDir),l.consumed===2&&(o+=1);continue}if(s.startsWith(`-`))throw Error(`tst: unknown option: ${s}`);t.push(s)}return{globs:t.length>0?t:[...bI],reporter:n,showHelp:r,coverage:i,coverageDir:a}}function wI(e){let t=e.indexOf(`{`);if(t===-1)return[e];let n=e.indexOf(`}`,t);if(n===-1)return[e];let r=e.slice(0,t),i=e.slice(n+1),a=e.slice(t+1,n).split(`,`),o=[];for(let e of a)for(let t of wI(`${r}${e}${i}`))o.push(t);return o}function TI(e){let t=``,n=0;for(;n<e.length;){let r=e[n];r===`*`&&e[n+1]===`*`?(t+=`(?:.*/)?`,n+=2,e[n]===`/`&&(n+=1)):r===`*`?(t+=`[^/]*`,n+=1):r===`?`?(t+=`[^/]`,n+=1):`.+^$()[]|\\`.includes(r)?(t+=`\\${r}`,n+=1):(t+=r,n+=1)}return RegExp(`^${t}$`)}async function EI(e,t,n){let r=n.flatMap(wI).map(TI),i=new Set,a=t===`/`?``:t;async function o(t){let n;try{n=await e.readdir(t)}catch{return}for(let s of n){if(s===`node_modules`||s.startsWith(`.`))continue;let n=t===`/`?`/${s}`:`${t}/${s}`,c=!1;try{c=(await e.stat(n)).isDirectory}catch{continue}if(c){await o(n);continue}let l=n.startsWith(`${a}/`)?n.slice(a.length+1):n;r.some(e=>e.test(l))&&i.add(n)}}return await o(t),[...i].sort()}let DI=null;async function OI(e){if(DI)return DI;let t={module:e.ModuleKind.CommonJS,target:e.ScriptTarget.ES2022,esModuleInterop:!0,isolatedModules:!1};return DI=`
|
|
2984
2984
|
if (typeof process !== 'undefined' && !process.versions) {
|
|
2985
2985
|
try { process.versions = { node: '20.0.0' }; } catch (_) { /* readonly process.versions is fine */ }
|
|
2986
2986
|
}
|
|
@@ -2998,8 +2998,9 @@ const __tst_module_exports = (function () {
|
|
|
2998
2998
|
})();
|
|
2999
2999
|
const __tst = __tst_module_exports.default || __tst_module_exports;
|
|
3000
3000
|
__tst.manual = true;
|
|
3001
|
-
`.trim(),
|
|
3002
|
-
|
|
3001
|
+
`.trim(),DI}function kI(e,t=new Map){return e.replace(/(^|[^\w$.])require\(\s*(["'`])([^"'`]+)\2\s*\)/g,(e,n,r,i)=>i===`tst`||i===`tst/tst.js`?`${n}__tstReq("tst")`:i===`tst/assert`||i===`tst/assert.js`?`${n}__tstReq("tst/assert")`:t.has(i)?`${n}__localReq(${JSON.stringify(t.get(i))})`:e)}function AI(e){let t=new Set,n=/(?:^|[^\w$.])require\(\s*(["'`])([^"'`]+)\1\s*\)/g,r;for(;(r=n.exec(e))!==null;)t.add(r[2]);return[...t]}async function jI(e,t,n){let r=y(`${t}/${n}`),i=[r];r.endsWith(`.js`)&&i.push(`${r.slice(0,-3)}.ts`),/\.[a-zA-Z0-9]+$/.test(r)||i.push(`${r}.ts`,`${r}.js`);for(let t of i)if(await e.exists(t))return t;return null}async function MI(e,t,n,r,i,a){let o=new Map,s=new Map,c=[{path:n,cjs:r}];for(;c.length>0;){let{path:n,cjs:r}=c.shift(),l=xr(n),u=new Map;for(let n of AI(r)){if(!n.startsWith(`./`)&&!n.startsWith(`../`))continue;let r=await jI(e,l,n);if(!r||(u.set(n,r),o.has(r)))continue;let s=await e.readFile(r);a&&(s=a(s,r));let d=t.transpileModule(s,{compilerOptions:i,fileName:r}).outputText;o.set(r,d),c.push({path:r,cjs:d})}s.set(n,u)}return{modules:o,edgeRewrites:s}}function NI(e,t,n,r,i,a,o=``,s=``){let c=r===`spec`?`pretty`:`tap`,l=[];for(let[e,t]of i.entries()){let n=kI(t,a.get(e)??new Map);l.push(`${JSON.stringify(e)}: function (module, exports, require) {\n${n}\n}`)}let u=`{${l.join(`,
|
|
3002
|
+
`)}}`,d=kI(n,a.get(t)??new Map),f=o,p=s;return`"use strict";
|
|
3003
|
+
${f}${e}
|
|
3003
3004
|
const __realmRequire = require;
|
|
3004
3005
|
const { createRequire: __createRequire } = __realmRequire("module");
|
|
3005
3006
|
const __tstReq = (id) => {
|
|
@@ -3007,8 +3008,7 @@ const __tstReq = (id) => {
|
|
|
3007
3008
|
if (id === "tst/assert") return __tst_assert_exports;
|
|
3008
3009
|
throw new Error("tst: cannot require " + id);
|
|
3009
3010
|
};
|
|
3010
|
-
const __localFactories = ${
|
|
3011
|
-
`)}}`};
|
|
3011
|
+
const __localFactories = ${u};
|
|
3012
3012
|
const __localCache = Object.create(null);
|
|
3013
3013
|
const __bridgeRequire = (realmReq, id) => {
|
|
3014
3014
|
if (id === "tst" || id === "tst/assert") return __tstReq(id);
|
|
@@ -3029,9 +3029,9 @@ const __localReq = (absPath) => {
|
|
|
3029
3029
|
return module.exports;
|
|
3030
3030
|
};
|
|
3031
3031
|
await (async function (require) {
|
|
3032
|
-
${
|
|
3032
|
+
${d}
|
|
3033
3033
|
})(__userRequire);
|
|
3034
|
-
const __state = await __tst.run({ format: ${JSON.stringify(
|
|
3034
|
+
const __state = await __tst.run({ format: ${JSON.stringify(c)} });
|
|
3035
3035
|
// EXT6 (F-C03): for an explicit single-file run under the default tap
|
|
3036
3036
|
// reporter, run()'s promise can resolve before a thrown test's rejection
|
|
3037
3037
|
// has settled into __state.failed, so the exit raced ahead and read 0.
|
|
@@ -3040,14 +3040,17 @@ const __state = await __tst.run({ format: ${JSON.stringify(o)} });
|
|
|
3040
3040
|
// enough async work to settle first, which is why only this path swallowed.
|
|
3041
3041
|
await Promise.resolve();
|
|
3042
3042
|
await new Promise((resolve) => setTimeout(resolve));
|
|
3043
|
+
${p}
|
|
3043
3044
|
if (__state && __state.failed && __state.failed.length > 0) process.exit(1);
|
|
3044
|
-
`}const
|
|
3045
|
+
`}const PI={esModuleInterop:!0,allowJs:!0,isolatedModules:!1};function FI(e){return{module:e.ModuleKind.CommonJS,target:e.ScriptTarget.ES2022,...PI}}async function II(e,t){let n;try{n=CI(e)}catch(e){return{done:{stdout:``,stderr:`${e instanceof Error?e.message:String(e)}\n`,exitCode:2}}}if(n.showHelp)return{done:{stdout:`tst - run *.test.{js,ts} files with the bundled tst runner
|
|
3045
3046
|
|
|
3046
3047
|
Usage:
|
|
3047
3048
|
tst [options] [glob...]
|
|
3048
3049
|
|
|
3049
3050
|
Options:
|
|
3050
3051
|
--reporter=<name> tap (default) | spec
|
|
3052
|
+
--coverage statement coverage of executed files (see Notes)
|
|
3053
|
+
--coverage-dir=<dir> write lcov + json here (default: <cwd>/coverage)
|
|
3051
3054
|
-h, --help Show this help
|
|
3052
3055
|
|
|
3053
3056
|
Notes:
|
|
@@ -3057,7 +3060,11 @@ Notes:
|
|
|
3057
3060
|
- require('fs') / require('path') / require('sliccy:*') and ipk
|
|
3058
3061
|
packages resolve through the realm require shim; relative
|
|
3059
3062
|
'./…' imports are inlined from the VFS.
|
|
3060
|
-
|
|
3063
|
+
- --coverage instruments the test file and its relative require() graph
|
|
3064
|
+
with statement counters. nyc/c8 cannot wrap this runner: it is not a
|
|
3065
|
+
Node child. Istanbul/Babel are not bundled (webapp size-limit); the
|
|
3066
|
+
TypeScript AST already in process does the rewrite.
|
|
3067
|
+
`,stderr:``,exitCode:0}};let r=await EI(t.fs,t.cwd,n.globs);if(r.length===0)return{done:{stdout:``,stderr:`tst: no test files matched ${n.globs.join(` `)}\n`,exitCode:1}};let i;try{i=await pr(aI(t))}catch(e){return{done:{stdout:``,stderr:`tst: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}let a=await OI(i),o=n.coverage?await import(`./coverage-instrument-CjoHgKzK.js`):null;return{parsed:n,files:r,ts:i,harness:a,userOpts:FI(i),coverageMaps:{},coverageCounts:{},coverageMod:o}}function LI(e){return e.includes(`# fail `)||/(^|\n)not ok /.test(e)}async function RI(e,t,n,r){let{ts:i,harness:a,userOpts:o,parsed:s}=t,c=t.coverageMod,l=c?(e,n)=>{let{source:r,map:a}=c.instrumentSource(i,e,n);return t.coverageMaps[n]=a,r}:void 0,u;try{u=await e.fs.readFile(n)}catch(e){return{stdout:``,stderr:`tst: ${n}: ${e instanceof Error?e.message:String(e)}\n`,failed:!0}}l&&(u=l(u,n));let d;try{d=i.transpileModule(u,{compilerOptions:o,fileName:n}).outputText}catch(e){return{stdout:``,stderr:`tst: ${n}: transpile error: ${e instanceof Error?e.message:String(e)}\n`,failed:!0}}let f,p;try{({modules:f,edgeRewrites:p}=await MI(e.fs,i,n,d,o,l))}catch(e){return{stdout:``,stderr:`tst: ${n}: local-require resolve error: ${e instanceof Error?e.message:String(e)}\n`,failed:!0}}let m=NI(a,n,d,s.reporter,f,p,c?`${c.coverageRuntimeSource()}\n`:``,c?`\n${c.coverageDumpSource()}`:``),h=await Lt(m,[`node`,n],e,void 0,{filename:n}),g=h.stdout;if(c){let e=c.extractCoverageCounts(g);g=e.stdout,c.mergeCounts(t.coverageCounts,e.counts)}return{stdout:r?`# ${n}\n${g}`:g,stderr:h.stderr,failed:h.exitCode!==0||LI(g)}}function zI(){return x(`tst`,async(e,t)=>{let n=await II(e,t);if(`done`in n)return n.done;let r=n.files.length>1,i=``,a=``,o=!1;for(let e of n.files){let s=await RI(t,n,e,r);i+=s.stdout,a+=s.stderr,s.failed&&(o=!0)}if(n.coverageMod){let e=n.coverageMod.resolveCoverageDir(t.cwd,n.parsed.coverageDir,(e,n)=>t.fs.resolvePath(e,n)),r=JSON.stringify({counts:n.coverageCounts,maps:n.coverageMaps},null,2),s=n.coverageMod.toLcov(n.coverageCounts,n.coverageMaps),c=n.coverageMod.coverageSummary(n.coverageCounts,n.coverageMaps);try{await t.fs.writeFile(`${e}/coverage.json`,r),await t.fs.writeFile(`${e}/coverage.lcov`,s)}catch(t){a+=`tst: writing coverage to ${e}: ${t instanceof Error?t.message:String(t)}\n`,o=!0}i+=`\n${c}`}return{stdout:i,stderr:a,exitCode:+!!o}})}const BI=[],VI=`usage: theme <subcommand> [args]
|
|
3061
3068
|
|
|
3062
3069
|
Subcommands:
|
|
3063
3070
|
list List available preset and custom themes
|
|
@@ -3066,23 +3073,23 @@ Subcommands:
|
|
|
3066
3073
|
reset Reset to the default theme
|
|
3067
3074
|
current Show the currently active theme
|
|
3068
3075
|
export <id> <path> Export a theme to a VFS path
|
|
3069
|
-
`;function
|
|
3070
|
-
`),stderr:``,exitCode:0}}async function
|
|
3071
|
-
`,stderr:``,exitCode:0}}async function
|
|
3076
|
+
`;function HI(e,t){return{stdout:``,stderr:`theme ${e}: ${t}\n`,exitCode:1}}function UI(){return x(`theme`,async(e,t)=>{if(e.length===0||e[0]===`--help`||e[0]===`-h`)return{stdout:VI,stderr:``,exitCode:0};let n=e[0];return C(e.slice(1),{valueFlags:BI})?{stdout:et(`theme`,n,VI),stderr:``,exitCode:0}:n===`list`?WI(e):n===`current`?GI(e):n===`reset`?KI(e):n===`apply`?qI(e.slice(1),t):n===`export`?JI(e.slice(1),t):{stdout:``,stderr:`theme: unknown subcommand "${n}"\n${VI}`,exitCode:1}})}async function WI(e){let t=S(e.slice(1),{value:BI});if(`error`in t)return HI(`list`,t.error);let{PRESETS:n}=await import(`./theme-presets-xiOb9AFN.js`),r=[`Presets:`];for(let e of n)r.push(` ${e.id.padEnd(16)} ${e.name}`);return r.push(``),{stdout:r.join(`
|
|
3077
|
+
`),stderr:``,exitCode:0}}async function GI(e){let t=S(e.slice(1),{value:BI});return`error`in t?HI(`current`,t.error):{stdout:`Check the Theme settings dialog for the active theme.
|
|
3078
|
+
`,stderr:``,exitCode:0}}async function KI(e){let t=S(e.slice(1),{value:BI});if(`error`in t)return HI(`reset`,t.error);let n=o();return n?(await n.call(`theme-apply`,{action:`reset`}),{stdout:`Theme reset to default.
|
|
3072
3079
|
`,stderr:``,exitCode:0}):{stdout:``,stderr:`theme: no panel-RPC connection available
|
|
3073
|
-
`,exitCode:1}}async function
|
|
3080
|
+
`,exitCode:1}}async function qI(e,t){let n=S(e,{value:BI});if(`error`in n)return HI(`apply`,n.error);if(n.positionals.length===0)return{stdout:``,stderr:`theme apply: missing theme id or path
|
|
3074
3081
|
`,exitCode:1};let r=o();if(!r)return{stdout:``,stderr:`theme: no panel-RPC connection available
|
|
3075
3082
|
`,exitCode:1};let i=n.positionals[0],{PRESETS:a}=await import(`./theme-presets-xiOb9AFN.js`),s=a.find(e=>e.id===i);if(s){let e=JSON.stringify(s);return await r.call(`theme-apply`,{themeJson:e,action:`apply`}),{stdout:`Applied theme: ${s.name}\n`,stderr:``,exitCode:0}}let c=t.fs.resolvePath(t.cwd,i),l;try{l=await t.fs.readFile(c)}catch{return{stdout:``,stderr:`theme apply: "${i}" is not a known preset id and file not found at ${c}\n`,exitCode:1}}try{let e=JSON.parse(l);if(!e.id||!e.name||!e.base||!e.tokens)return{stdout:``,stderr:`theme apply: invalid theme file (missing id, name, base, or tokens)
|
|
3076
3083
|
`,exitCode:1}}catch{return{stdout:``,stderr:`theme apply: file is not valid JSON
|
|
3077
|
-
`,exitCode:1}}return{stdout:`Applied theme: ${(await r.call(`theme-apply`,{themeJson:l,action:`apply`})).applied}\n`,stderr:``,exitCode:0}}async function
|
|
3078
|
-
`,exitCode:1};let[r,i]=n.positionals,{PRESETS:a}=await import(`./theme-presets-xiOb9AFN.js`),o=a.find(e=>e.id===r);if(!o)return{stdout:``,stderr:`theme export: unknown preset id "${r}"\n`,exitCode:1};let s=t.fs.resolvePath(t.cwd,i);try{await t.fs.writeFile(s,JSON.stringify(o,null,2))}catch(e){return{stdout:``,stderr:`theme export: write failed: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}return{stdout:`Exported "${o.name}" to ${s}\n`,stderr:``,exitCode:0}}const
|
|
3079
|
-
`),stderr:``,exitCode:0}}function
|
|
3084
|
+
`,exitCode:1}}return{stdout:`Applied theme: ${(await r.call(`theme-apply`,{themeJson:l,action:`apply`})).applied}\n`,stderr:``,exitCode:0}}async function JI(e,t){let n=S(e,{value:BI});if(`error`in n)return HI(`export`,n.error);if(n.positionals.length<2)return{stdout:``,stderr:`theme export: usage: theme export <id> <path>
|
|
3085
|
+
`,exitCode:1};let[r,i]=n.positionals,{PRESETS:a}=await import(`./theme-presets-xiOb9AFN.js`),o=a.find(e=>e.id===r);if(!o)return{stdout:``,stderr:`theme export: unknown preset id "${r}"\n`,exitCode:1};let s=t.fs.resolvePath(t.cwd,i);try{await t.fs.writeFile(s,JSON.stringify(o,null,2))}catch(e){return{stdout:``,stderr:`theme export: write failed: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}return{stdout:`Exported "${o.name}" to ${s}\n`,stderr:``,exitCode:0}}const YI=`unknown`,XI=`usage: uname [-amnorsv]`,ZI=[`s`,`n`,`r`,`v`,`m`,`o`];function QI(){return{stdout:[XI,` -s kernel name (SLICC) -n nodename (leader/follower/standalone)`,` -r release (SLICC version) -v build stamp`,` -m machine (realm platform) -o operating system (user agent)`,` -a all of the above, in uname order`,``].join(`
|
|
3086
|
+
`),stderr:``,exitCode:0}}function $I(){let{releasedAt:e,buildId:t}=qe();return e?`${t} (${e})`:t}function eL(){let e=globalThis.navigator,t=e?.userAgentData?.platform||e?.platform;return typeof t==`string`&&t.length>0?t:YI}function tL(){let e=globalThis.navigator?.userAgent;return typeof e==`string`&&e.length>0?e:YI}function nL(e){switch(e){case`s`:return`SLICC`;case`n`:return Ke();case`r`:return qe().version;case`v`:return $I();case`m`:return eL();case`o`:return tL()}}function rL(e){return{stdout:``,stderr:`uname: ${e}\n${XI}\n`,exitCode:1}}function iL(e){let t=new Set;for(let n of e){if(!n.startsWith(`-`)||n===`-`)return{error:`extra operand '${n}'`};if(n.startsWith(`--`))return{error:`unrecognized option '${n}'`};for(let e of n.slice(1)){if(e===`a`){for(let e of ZI)t.add(e);continue}if(!ZI.includes(e))return{error:`unrecognized option '-${e}'`};t.add(e)}}return t}function aL(){return x(`uname`,async e=>{if(e.includes(`--help`)||e.includes(`-h`))return QI();let t=iL(e);return`error`in t?rL(t.error):{stdout:`${(t.size>0?ZI.filter(e=>t.has(e)):[`s`]).map(nL).join(` `)}\n`,stderr:``,exitCode:0}})}function oL(){return x(`unlink`,async(e,t)=>{if(e.includes(`--help`))return{stdout:`Usage: unlink FILE
|
|
3080
3087
|
Remove FILE. Symbolic links are removed without following their target.
|
|
3081
3088
|
`,stderr:``,exitCode:0};if(e.length!==1||e[0].startsWith(`-`))return{stdout:``,stderr:e.length===0?`unlink: missing operand
|
|
3082
3089
|
`:`unlink: extra operand
|
|
3083
|
-
`,exitCode:1};let n=t.fs.resolvePath(t.cwd,e[0]);try{let r=t.fs.lstat?await t.fs.lstat(n):await t.fs.stat(n);return r.isDirectory&&!r.isSymbolicLink?{stdout:``,stderr:`unlink: cannot unlink '${e[0]}': Is a directory\n`,exitCode:1}:(await t.fs.rm(n,{recursive:!1,force:!1}),{stdout:``,stderr:``,exitCode:0})}catch(t){let n=t instanceof Error?t.message:String(t);return{stdout:``,stderr:`unlink: cannot unlink '${e[0]}': ${n}\n`,exitCode:1}}})}function
|
|
3084
|
-
`,stderr:``,exitCode:0}}function
|
|
3085
|
-
`,exitCode:1}}:{kind:`ok`,archive:n[0],destination:t||`.`}}async function
|
|
3090
|
+
`,exitCode:1};let n=t.fs.resolvePath(t.cwd,e[0]);try{let r=t.fs.lstat?await t.fs.lstat(n):await t.fs.stat(n);return r.isDirectory&&!r.isSymbolicLink?{stdout:``,stderr:`unlink: cannot unlink '${e[0]}': Is a directory\n`,exitCode:1}:(await t.fs.rm(n,{recursive:!1,force:!1}),{stdout:``,stderr:``,exitCode:0})}catch(t){let n=t instanceof Error?t.message:String(t);return{stdout:``,stderr:`unlink: cannot unlink '${e[0]}': ${n}\n`,exitCode:1}}})}function sL(){return{stdout:`usage: unzip <archive.zip> [-d <destination>]
|
|
3091
|
+
`,stderr:``,exitCode:0}}function cL(e){let t=`.`,n=[];for(let r=0;r<e.length;r++){let i=e[r];if(i===`-d`){t=e[r+1]??``,r++;continue}if(i.startsWith(`-`))return{kind:`error`,result:{stdout:``,stderr:`unzip: unsupported option ${i}\n`,exitCode:1}};n.push(i)}return n.length<1?{kind:`error`,result:{stdout:``,stderr:`unzip: expected archive path
|
|
3092
|
+
`,exitCode:1}}:{kind:`ok`,archive:n[0],destination:t||`.`}}async function lL(e,t,n,r){let i=n.replace(/\\/g,`/`);if(!i||i.endsWith(`/`))return!1;let a=e.fs.resolvePath(t,i);if(!wr(t,a))return{stdout:``,stderr:`unzip: blocked suspicious path ${n}\n`,exitCode:1};let o=xr(a);return o!==`/`&&await e.fs.mkdir(o,{recursive:!0}),await e.fs.writeFile(a,r),!0}function uL(){return x(`unzip`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return sL();let n=cL(e);if(n.kind===`error`)return n.result;let r=t.fs.resolvePath(t.cwd,n.archive),i=t.fs.resolvePath(t.cwd,n.destination);await t.fs.mkdir(i,{recursive:!0});let a=await t.fs.readFileBuffer(r),o=St(a),s=0;for(let[e,n]of Object.entries(o)){let r=await lL(t,i,e,n);if(r===!0)s++;else if(r!==!1)return r}return{stdout:`extracted ${s} file(s) to ${i}\n`,stderr:``,exitCode:0}})}const dL=`ai-ecoverse/slicc`,fL=`usage: upgrade status | upgrade apply --from=<version> --to=<version>`,pL=`packages/vfs-root`,mL=3e4,hL=[`${pL}/workspace/skills/`,`${pL}/shared/sprinkles/`,`${pL}/shared/sounds/`,`${pL}/shared/GELATIERE.md`,`${pL}/shared/wiki/WIKI.md`,`${pL}/etc/`],gL=[`auto-applied`,`merged-clean`,`kept-local`,`needs-review`,`unchanged`,`added-new`];function _L(){return Object.fromEntries(gL.map(e=>[e,0]))}function vL(e,t,n,r){let i=_L();for(let e of n)i[e.classification]+=1;return`${JSON.stringify({ok:r.length===0&&i[`needs-review`]===0,from:e,to:t,results:n.map(({path:e,classification:t,sidecar:n})=>({path:e,status:t,...n?{sidecar:n}:{}})),summary:i,errors:r})}\n`}function yL(e){if(e[0]!==`apply`)throw Error(fL);let t=new Map;for(let n of e.slice(1)){let e=n.match(/^--(from|to)=(.+)$/);if(!e)throw Error(`unsupported argument: ${n}`);t.set(e[1],e[2])}let n=t.get(`from`)??``,r=t.get(`to`)??``,i=/^v?[0-9][0-9A-Za-z.+_-]*$/;if(!i.test(n)||!i.test(r))throw Error(`both --from and --to must be release versions`);return{from:n,to:r}}function bL(e){return e.startsWith(`v`)?e:`v${e}`}function xL(e){if(!hL.some(t=>e.startsWith(t)))return null;let t=e.slice(17);return!t||t.split(`/`).some(e=>e===`.`||e===`..`)?null:t}async function SL(e,t){let n,r;try{n=await Promise.race([e(t,{method:`GET`,headers:{Accept:`application/json`}}),new Promise((e,t)=>{r=setTimeout(()=>t(Error(`request timed out after ${mL}ms`)),mL)})])}catch(e){let n=e instanceof Error?e.message:String(e);throw Error(`fetch failed for ${t}: ${n}`)}finally{r!==void 0&&clearTimeout(r)}if(n.status<200||n.status>=300)throw Error(`fetch failed for ${t}: HTTP ${n.status} ${n.statusText}`);return n}async function CL(e,t){let n=await SL(t,`https://api.github.com/repos/${dL}/git/trees/${encodeURIComponent(e)}?recursive=1`),r=de(n.body);if(r.truncated)throw Error(`bundled file discovery was truncated for ${e}`);if(!Array.isArray(r.tree))throw Error(`invalid bundled file discovery response for ${e}`);let i=new Map;for(let e of r.tree){if(e.type!==`blob`||typeof e.path!=`string`)continue;let t=xL(e.path);t&&i.set(t,e.path)}return i}function wL(e,t){let n=t.split(`/`).map(encodeURIComponent).join(`/`);return`https://raw.githubusercontent.com/${dL}/${encodeURIComponent(e)}/${n}`}function TL(e,t){return!e||!t||e.byteLength!==t.byteLength?!1:e.every((e,n)=>e===t[n])}function EL(e){try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{return null}}async function DL(e,t){if(!await e.exists(t))return;let n=await e.readFile(t,{encoding:`binary`});return n instanceof Uint8Array?n:new TextEncoder().encode(n)}async function OL(e,t,n,r,i){let a=`${t}.upgrade-${bL(n)}-to-${bL(r)}.conflict`;if(!i.has(a)&&!await e.exists(a))return i.add(a),a;for(let t=1;;t+=1){let n=`${a}.${t}`;if(!i.has(n)&&!await e.exists(n))return i.add(n),n}}async function kL(e,t,n,r,i,a,o){let s=await DL(e.fs,t);if(!a)return{path:t,classification:s?`kept-local`:`unchanged`};if(!i)return s?{path:t,classification:TL(s,a)?`unchanged`:`kept-local`}:{path:t,classification:`added-new`,content:a};if(TL(i,a)||TL(s,a))return{path:t,classification:`unchanged`};if(!s)return{path:t,classification:`kept-local`};if(TL(s,i))return{path:t,classification:`auto-applied`,content:a};let[c,l,u]=[s,i,a].map(EL);if(c!==null&&l!==null&&u!==null){let i=Ae(c,l,u,{diff3:!0,labels:{current:`local:${t}`,base:`${bL(n)}:${t}`,other:`${bL(r)}:${t}`}}),a=new TextEncoder().encode(i.content);return i.conflicts===0?{path:t,classification:`merged-clean`,content:a}:{path:t,classification:`needs-review`,content:a,sidecar:await OL(e.fs,t,n,r,o)}}return{path:t,classification:`needs-review`,content:a,sidecar:await OL(e.fs,t,n,r,o)}}async function AL(e,t){t.content?await e.writeFile(t.path,t.content):await e.exists(t.path)&&await e.rm(t.path)}async function jL(e,t){let n=t.filter(e=>e.content!==void 0),r=await Promise.all(n.map(async t=>{let n=t.sidecar??t.path;return{path:n,content:await DL(e,n)}})),i=[];for(let t=0;t<n.length;t+=1){let a=n[t],o=r[t];try{await e.writeFile(o.path,a.content),i.push(o)}catch(t){let n=[];for(let t of[o,...i.slice().reverse()])try{await AL(e,t)}catch(e){n.push(`${t.path}: ${e instanceof Error?e.message:String(e)}`)}let r=t instanceof Error?t.message:String(t),a=n.length===0?`all writes rolled back`:`rollback failed (${n.join(`; `)})`;throw Error(`apply failed for ${o.path}: ${r}; ${a}`)}}}async function ML(e,t,n){let r=bL(t),i=bL(n),[a,o]=await Promise.all([CL(r,e.fetch),CL(i,e.fetch)]),s=[...new Set([...a.keys(),...o.keys()])].sort(),c=await Promise.all(s.map(async t=>{let[n,s]=await Promise.all([a.has(t)?SL(e.fetch,wL(r,a.get(t))).then(e=>pe(e.body)):void 0,o.has(t)?SL(e.fetch,wL(i,o.get(t))).then(e=>pe(e.body)):void 0]);return{path:t,base:n,theirs:s}})),l=new Set(s),u=[];for(let{path:r,base:i,theirs:a}of c)u.push(await kL(e,r,t,n,i,a,l));return await jL(e.fs,u),u}async function NL(e){let{version:t,releasedAt:n,buildId:r}=qe(),i=[],a=null,o=e.getLastSeen??Je();if(!o)i.push(`last-seen version unavailable: no reader registered in this runtime`);else try{a=await o()}catch(e){i.push(`last-seen version unavailable: ${e instanceof Error?e.message:String(e)}`)}let s=a!==null&&a!==t;return`${JSON.stringify({ok:i.length===0,version:t,releasedAt:n,build:r,lastSeen:a,mergePending:s,...s?{apply:`upgrade apply --from=${a} --to=${t}`}:{},errors:i})}\n`}function PL(e){return x(`upgrade`,async t=>{if(t.includes(`--help`)||t.includes(`-h`))return{stdout:`${fL}\n`,stderr:``,exitCode:0};if(t[0]===`status`)return t.length>1?{stdout:vL(``,``,[],[`unsupported argument: ${t[1]}`]),stderr:``,exitCode:1}:{stdout:await NL(e),stderr:``,exitCode:0};let n=``,r=``;try{({from:n,to:r}=yL(t));let i=await ML(e,n,r),a=i.some(e=>e.classification===`needs-review`);return{stdout:vL(n,r,i,[]),stderr:``,exitCode:+!!a}}catch(e){let t=e instanceof Error?e.message:String(e);return{stdout:vL(n,r,[],[t]),stderr:``,exitCode:1}}})}const FL=`usage: uptime [-p|--pretty] [-s|--since]`,IL=`${FL}
|
|
3086
3093
|
|
|
3087
3094
|
Print how long this SLICC has been running. The clock starts when the browser
|
|
3088
3095
|
window was last loaded — a reload is a reboot.
|
|
@@ -3098,7 +3105,7 @@ The load average is the average number of live kernel processes over the last
|
|
|
3098
3105
|
processes are retained in bounded numbers, so a long burst of short commands
|
|
3099
3106
|
can under-report the older windows. The user count is always 1: a SLICC
|
|
3100
3107
|
runtime has one user identity (see \`id\`).
|
|
3101
|
-
`,
|
|
3108
|
+
`,LL=[1,5,15],RL=6e4,zL=60*RL,BL=24*zL;function VL(){let e=globalThis.__slicc_pm;return e instanceof Object&&typeof e.list==`function`?e:null}function HL(e,t,n,r){let i=Math.min(n,Math.max(1,t-r)),a=t-i,o=0;for(let n of e){let e=Math.min(n.finishedAt??t,t);o+=Math.max(0,e-Math.max(n.startedAt,a))}return o/i}function UL(e){let t=Math.max(0,e),n=Math.floor(t/BL),r=Math.floor(t%BL/zL),i=Math.floor(t%zL/RL),a=r>0?`${r}:${String(i).padStart(2,`0`)}`:`${i} min`;return n===0?a:`${n} ${n===1?`day`:`days`}, ${a}`}function WL(e){let t=Math.max(0,e),n=[],r=(e,t)=>{e>0&&n.push(`${e} ${t}${e===1?``:`s`}`)};return r(Math.floor(t/BL),`day`),r(Math.floor(t%BL/zL),`hour`),r(Math.floor(t%zL/RL),`minute`),n.length===0?`up ${Math.floor(t/1e3)} seconds`:`up ${n.join(`, `)}`}function GL(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function KL(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function qL(e,t,n){let r=LL.map(r=>HL(e,t,r*RL,n).toFixed(2));return` ${KL(t)} up ${UL(t-n)}, 1 user, load average: ${r.join(`, `)}\n`}function JL(e){let t=`default`;for(let n of e)switch(n){case`-p`:case`--pretty`:t=`pretty`;break;case`-s`:case`--since`:t=`since`;break;case`-h`:case`--help`:return`help`;case`--version`:return`version`;default:return{error:`unrecognized option '${n}'`}}return t}function YL(e={}){return x(`uptime`,async t=>{let n=JL(t);if(typeof n!=`string`)return{stdout:``,stderr:`uptime: ${n.error}\n${FL}\n`,exitCode:1};if(n===`help`)return{stdout:IL,stderr:``,exitCode:0};if(n===`version`)return{stdout:`uptime (SLICC) ${qe().version}\n`,stderr:``,exitCode:0};let r=e.now?e.now():Date.now(),i=e.bootedAt?e.bootedAt():da();if(n===`since`)return XL(`${GL(i)}\n`);if(n===`pretty`)return XL(`${WL(r-i)}\n`);let a=e.processManager??VL();return XL(qL(a?a.list():[],r,i))})}function XL(e){return{stdout:e,stderr:``,exitCode:0}}const ZL=new Set([`--vid`,`--pid`,`--class`,`--subclass`,`--protocol`,`--serial`,`--request-type`,`--recipient`,`--request`,`--value`,`--index`,`--__resolved`]);function QL(e){return Pn(e,ZL)}function Y(e,t){let n=/^0x/i.test(e)?parseInt(e,16):parseInt(e,10);if(!Number.isFinite(n)||Number.isNaN(n))throw Error(`invalid ${t}: '${e}'`);return n}function $L(e){let t={};return e.has(`--vid`)&&(t.vendorId=Y(e.get(`--vid`),`vid`)),e.has(`--pid`)&&(t.productId=Y(e.get(`--pid`),`pid`)),e.has(`--class`)&&(t.classCode=Y(e.get(`--class`),`class`)),e.has(`--subclass`)&&(t.subclassCode=Y(e.get(`--subclass`),`subclass`)),e.has(`--protocol`)&&(t.protocolCode=Y(e.get(`--protocol`),`protocol`)),e.has(`--serial`)&&(t.serialNumber=e.get(`--serial`)),Object.keys(t).length>0?[t]:[]}const eR=new Set([`standard`,`class`,`vendor`]),tR=new Set([`device`,`interface`,`endpoint`,`other`]);function nR(e){let t=e.get(`--request-type`)??`vendor`,n=e.get(`--recipient`)??`device`;if(!eR.has(t))throw Error(`invalid --request-type: '${t}'`);if(!tR.has(n))throw Error(`invalid --recipient: '${n}'`);return{requestType:t,recipient:n,request:Y(e.get(`--request`)??`0`,`request`),value:Y(e.get(`--value`)??`0`,`value`),index:Y(e.get(`--index`)??`0`,`index`)}}function rR(e){let t=Qr(e.stdin),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e)&255;return n}function iR(e){return Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(` `)}function aR(e){return`0x${e.toString(16).padStart(4,`0`)}`}function oR(e){let t=[e.manufacturerName,e.productName].filter(Boolean).join(` `)||`(unknown)`,n=e.serialNumber?` serial=${e.serialNumber}`:``,r=e.opened?` [open]`:``;return`${e.handle}\t${aR(e.vendorId)}:${aR(e.productId)}\t${t}${n}${r}`}function X(e){return{stdout:e,stderr:``,exitCode:0}}function Z(e){return{stdout:``,stderr:`usb: ${e}\n`,exitCode:1}}const sR=`usb - access USB devices via WebUSB
|
|
3102
3109
|
|
|
3103
3110
|
Usage: usb <subcommand> [options]
|
|
3104
3111
|
|
|
@@ -3137,9 +3144,9 @@ Options:
|
|
|
3137
3144
|
-h, --help
|
|
3138
3145
|
|
|
3139
3146
|
Transfers are capped at ${Zr} bytes (4 MiB).
|
|
3140
|
-
`;function
|
|
3141
|
-
`):X(`${t.map(
|
|
3142
|
-
`)}\n`)}async function
|
|
3147
|
+
`;function cR(e,t){if(t){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return X(t)}return X(e.length?`${iR(e)}\n`:``)}async function lR(e){let t=await e.list();return t.length===0?X(`no granted USB devices
|
|
3148
|
+
`):X(`${t.map(oR).join(`
|
|
3149
|
+
`)}\n`)}async function uR(e,t){let n=e.get(`--__resolved`);if(n)return X(`${oR(await t.info(n))}\n`);let r=$L(e),i=Se();if(i){let e=await px(`usb-device`,r,i);if(e.handle)return X(`${oR(await t.info(e.handle))}\n`);let n=e.info,a=Yr();if(!a)return Z(`request: WebUSB unavailable for device re-acquire`);let o=(await a.getDevices()).find(e=>e.vendorId===n.vendorId&&e.productId===n.productId&&(!n.serialNumber||e.serialNumber===n.serialNumber));if(!o)return Z(`request: granted device could not be re-acquired`);let s=Xr().register(o);return X(`${oR(Jr(s,o))}\n`)}return X(`${oR(await t.request(r))}\n`)}async function dR(e,t,n,r){let i=t[1];if(!i)return Z(`${e}: handle required`);let a=r.has(`--force`);return e===`open`?await n.open(i):e===`close`?await n.close(i,{force:a}):await n.reset(i,{force:a}),X(``)}async function fR(e,t){let[,n,r,i]=e;return!n||r===void 0||i===void 0?Z(`clear-halt: handle, direction and endpoint required`):r!==`in`&&r!==`out`?Z(`clear-halt: direction must be 'in' or 'out', got '${r}'`):(await t.clearHalt(n,r,Y(i,`endpoint`)),X(``))}async function pR(e,t){let[,n,r]=e;return!n||r===void 0?Z(`select-config: handle and value required`):(await t.selectConfig(n,Y(r,`configuration`)),X(``))}async function mR(e,t,n,r){let[,i,a]=t;if(!i||a===void 0)return Z(`${e}: handle and interface required`);let o=Y(a,`interface`);return e===`claim`?await n.claim(i,o,{wait:r.has(`--wait`)}):await n.release(i,o),X(``)}async function hR(e,t,n,r){let[,i,a]=e;if(!i||a===void 0)return Z(`control-in: handle and length required`);let o=Y(a,`length`);return o>4194304?Z(`control-in length exceeds 4 MiB limit`):cR((await n.controlIn(i,nR(t),o)).bytes,r)}async function gR(e,t,n,r){let i=e[1];if(!i)return Z(`control-out: handle required`);let a=rR(t);return a.length>4194304?Z(`control-out payload exceeds 4 MiB limit`):X(`${(await r.controlOut(i,nR(n),a)).bytesWritten} bytes written\n`)}async function _R(e,t,n,r){let[,i,a,o]=e;if(!i||a===void 0||o===void 0)return Z(`transfer-in: handle, endpoint and length required`);let s=Y(o,`length`);return s>4194304?Z(`transfer-in length exceeds 4 MiB limit`):cR((await n.transferIn(i,Y(a,`endpoint`),s)).bytes,r)}async function vR(e,t,n,r){let[,i,a]=e;if(!i||a===void 0)return Z(`transfer-out: handle and endpoint required`);let o=rR(t);return o.length>4194304?Z(`transfer-out payload exceeds 4 MiB limit`):X(`${(await r.transferOut(i,Y(a,`endpoint`),o)).bytesWritten} bytes written\n`)}async function yR(e,t,n){let{positionals:r,flags:i,bools:a}=QL(e),o=r[0],s=a.has(`--raw`);switch(o){case`list`:return lR(n);case`request`:return uR(i,n);case`open`:case`close`:case`reset`:return dR(o,r,n,a);case`clear-halt`:return fR(r,n);case`select-config`:return pR(r,n);case`claim`:case`release`:return mR(o,r,n,a);case`control-in`:return hR(r,i,n,s);case`control-out`:return gR(r,t,i,n);case`transfer-in`:return _R(r,i,n,s);case`transfer-out`:return vR(r,t,i,n);default:return Z(`unknown subcommand '${o??``}'. Try 'usb --help'.`)}}function bR(){return x(`usb`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return X(sR);let n=It(s(),o());if(!n)return Z(`WebUSB is unavailable in this environment`);try{return await yR(e,t,n)}catch(e){let t=e instanceof Error?e.message:String(e);return/cancelled|NotFoundError|No device selected/i.test(t)?Z(`user cancelled or no device selected`):Z(t)}})}const xR=`/workspace/.v86`,SR=`v86 - run an x86 virtual machine (v86 wasm engine)
|
|
3143
3150
|
|
|
3144
3151
|
Requires: ${M} v86@${FD}
|
|
3145
3152
|
|
|
@@ -3175,7 +3182,7 @@ Boot options (QEMU-flavored):
|
|
|
3175
3182
|
proxy — no gateway needed, https upstream via the proxy
|
|
3176
3183
|
-vga <MiB> SVGA/VBE video memory (default 8, max 64) —
|
|
3177
3184
|
raise for high-res VESA modes (1080p32 needs ~9)
|
|
3178
|
-
-bios <path> -vgabios <path> BIOS blobs (default ${
|
|
3185
|
+
-bios <path> -vgabios <path> BIOS blobs (default ${xR}/{seabios,vgabios}.bin)
|
|
3179
3186
|
-nographic Serial-only guest (skip VGA)
|
|
3180
3187
|
|
|
3181
3188
|
Notes:
|
|
@@ -3183,19 +3190,19 @@ Notes:
|
|
|
3183
3190
|
(Alpine, FreeDOS, Buildroot Linux) work best.
|
|
3184
3191
|
- The copy.sh Arch Linux image boots via -state + -fs9p; see the v86 skill.
|
|
3185
3192
|
- BIOS blobs are not bundled; download once:
|
|
3186
|
-
mkdir -p ${
|
|
3187
|
-
curl -o ${
|
|
3188
|
-
curl -o ${
|
|
3189
|
-
`,
|
|
3190
|
-
mkdir -p ${
|
|
3191
|
-
curl -o ${
|
|
3192
|
-
curl -o ${
|
|
3193
|
-
or pass -bios / -vgabios with explicit VFS paths.`,
|
|
3193
|
+
mkdir -p ${xR}
|
|
3194
|
+
curl -o ${xR}/seabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/seabios.bin
|
|
3195
|
+
curl -o ${xR}/vgabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/vgabios.bin
|
|
3196
|
+
`,CR=`v86: BIOS images not found. Download them once:
|
|
3197
|
+
mkdir -p ${xR}
|
|
3198
|
+
curl -o ${xR}/seabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/seabios.bin
|
|
3199
|
+
curl -o ${xR}/vgabios.bin https://raw.githubusercontent.com/copy/v86/master/bios/vgabios.bin
|
|
3200
|
+
or pass -bios / -vgabios with explicit VFS paths.`,wR={"-n":TR,"-name":TR,"--name":TR,"-m":(e,t)=>{let n=Number.parseInt(t,10);return!Number.isFinite(n)||n<=0?`-m requires a positive MiB value`:n>512?`-m ${n} exceeds the 512 MiB cap`:(e.memoryMib=n,null)},"-vga":(e,t)=>{let n=Number.parseInt(t,10);return!Number.isFinite(n)||n<=0?`-vga requires a positive MiB value`:n>64?`-vga ${n} exceeds the 64 MiB cap`:(e.vgaMemoryMib=n,null)},"-cdrom":(e,t)=>ER(e,`cdrom`,t),"-hda":(e,t)=>ER(e,`hda`,t),"-fda":(e,t)=>ER(e,`fda`,t),"-kernel":(e,t)=>ER(e,`kernel`,t),"-initrd":(e,t)=>ER(e,`initrd`,t),"-append":(e,t)=>ER(e,`append`,t),"-bios":(e,t)=>ER(e,`bios`,t),"-vgabios":(e,t)=>ER(e,`vgabios`,t),"-state":(e,t)=>ER(e,`state`,t),"-fs9p":(e,t)=>/^https?:\/\//u.test(t)?(e.fs9p=t,null):`-fs9p requires an http(s) base URL`,"-net":(e,t)=>{let[n,...r]=t.split(`,`);if(n!==`ne2k`&&n!==`virtio`)return`-net requires ne2k or virtio`;for(let t of r){if(t!==`relay=fetch`)return`-net: unknown option '${t}' (only relay=fetch)`;e.netRelay=`fetch`}return e.net=n,null},"-boot":(e,t)=>t!==`a`&&t!==`c`&&t!==`d`?`-boot requires a, c, or d`:(e.boot=t,null)};function TR(e,t){return/^[A-Za-z0-9_-]+$/.test(t)?(e.name=t,null):`invalid VM name '${t}'`}function ER(e,t,n){return e[t]=n,null}const DR=[...Object.keys(wR),`--fps`,`--tail`,`--send`,`--to`];function OR(e){let t={name:`vm0`,memoryMib:128,vgaMemoryMib:8,nographic:!1};for(let n=0;n<e.length;n++){let r=e[n];if(r===`-nographic`){t.nographic=!0;continue}let i=Object.hasOwn(wR,r)?wR[r]:void 0;if(!i)return{ok:!1,error:`unknown option '${r}'`};let a=n+1<e.length?e[n+1]:null;if(a===null)return{ok:!1,error:`${r} requires a value`};let o=i(t,a);if(o)return{ok:!1,error:o};n++}return!t.cdrom&&!t.hda&&!t.fda&&!t.kernel&&!t.state?{ok:!1,error:`no bootable media (-cdrom, -hda, -fda, -kernel, or -state required)`}:{ok:!0,parsed:t}}function kR(e){return{reader:{exists:t=>e.fs.exists(t),isDirectory:async t=>{try{return(await e.fs.stat(t)).isDirectory}catch{return!1}},readFile:t=>e.fs.readFile(t)},readBytes:t=>e.fs.readFileBuffer(t),fromDir:e.cwd}}function Q(e){return{stdout:``,stderr:`v86: ${e}\n`,exitCode:1}}function $(e=``){return{stdout:e,stderr:``,exitCode:0}}function AR(e){let t=[],n=`vm0`;for(let r=0;r<e.length;r++){if(e[r]===`-n`||e[r]===`-name`||e[r]===`--name`){let t=e[r+1];if(t){n=t,r++;continue}}t.push(e[r])}return{name:n,rest:t}}function jR(e){return aa(e)||Q(`no VM named '${e}' — boot one with \`v86 start -n ${e} ...\``)}function MR(e){return`exitCode`in e}async function NR(e,t,n){let r=e.fs.resolvePath(e.cwd,t);if(!await e.fs.exists(r))return Q(`${n}: no such file: ${t}`);let i=await e.fs.readFileBuffer(r),a=new ArrayBuffer(i.byteLength);return new Uint8Array(a).set(i),{buffer:a}}const PR={a:801,c:306,d:531};function FR(){let e=globalThis.__slicc_pm;return e instanceof Object&&typeof e.signal==`function`?e:null}function IR(e={}){return x(`v86`,async(t,n)=>{if(t.length===0||t[0]===`--help`||t[0]===`-h`||t[0]===`help`)return $(SR);if(t[0]===`--version`)return LR(n,e);let r=t[0];if(C(t.slice(1),{valueFlags:DR}))return $(et(`v86`,r,SR,{prefix:`v86`}));let i=$e(t.slice(1));try{switch(r){case`start`:return await UR(i,n,e);case`ls`:return GR();case`type`:return await YR(i,n);case`key`:return await XR(i,n);case`mouse`:return await QR(i,n);case`screenshot`:return await $R(i,n);case`text`:return await ez(i,n);case`serve`:return tz(i);case`serial`:return nz(i);case`state`:return await rz(i,n);case`stop`:return await iz(i,e);default:return Q(`unknown subcommand '${r}' — see \`v86 --help\``)}}catch(e){return Q(e instanceof Error?e.message:String(e))}})}async function LR(e,t){if(t.loadEngine)return $(`v86 ${(await t.loadEngine(kR(e))).version} (qemu-flavored CLI)\n`);let n=await VD(kR(e));return n?$(`v86 ${n.version} (qemu-flavored CLI)\n`):Q(ID)}async function RR(e,t,n){if(e.state&&!e.bios&&!e.vgabios)return null;let r=await NR(t,e.bios??`${xR}/seabios.bin`,`-bios`);if(`exitCode`in r)return e.bios?r:Q(CR.replace(/^v86: /u,``));if(n.bios=r,e.nographic)return null;let i=await NR(t,e.vgabios??`${xR}/vgabios.bin`,`-vgabios`);return`exitCode`in i?e.vgabios?i:Q(CR.replace(/^v86: /u,``)):(n.vga_bios=i,null)}async function zR(e,t,n){let r=await RR(e,t,n);if(r)return r;for(let[r,i]of[[`cdrom`,`cdrom`],[`hda`,`hda`],[`fda`,`fda`],[`kernel`,`bzimage`],[`initrd`,`initrd`]]){let a=e[r];if(!a)continue;let o=await NR(t,a,`-${r}`);if(`exitCode`in o)return o;n[i]=o}if(e.append&&(n.cmdline=e.append),e.boot&&(n.boot_order=PR[e.boot]),e.state){let r=await NR(t,e.state,`-state`);if(`exitCode`in r)return r;n.initial_state=r}return e.fs9p&&(n.filesystem={baseurl:e.fs9p}),e.net&&(n.net_device=e.netRelay===`fetch`?{type:e.net,relay_url:`fetch`}:{type:e.net}),null}const BR=6e4;function VR(e){return e.v86?Promise.resolve():new Promise((t,n)=>{let r=setTimeout(()=>n(Error(`engine init timed out after ${BR/1e3}s`)),BR);e.add_listener(`emulator-loaded`,()=>{clearTimeout(r),t()})})}function HR(e,t){let n=e.network_adapter;if(!n||typeof n.fetch!=`function`)return Q(`relay=fetch: engine exposed no fetch-relay network adapter`);let r=t.proxiedFetch??ie();return n.fetch=async(e,t)=>{let n=e.replace(/^http:\/\/(?!localhost[:/]|127\.0\.0\.1[:/])/u,`https://`),i={};t?.headers?.forEach((e,t)=>{i[t]=e});let a;if(t?.body){let e=``;for(let n of t.body)e+=String.fromCharCode(n);a=e}let o=await r(n,{method:t?.method,headers:i,body:a}),s=o.body,c=s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength);return{status:o.status,statusText:o.statusText,headers:new Headers(o.headers),redirected:!1,url:o.url,arrayBuffer:async()=>c}},null}async function UR(e,t,n){let r=OR(e);if(!r.ok)return Q(r.error);let i=r.parsed;if(aa(i.name))return Q(`VM '${i.name}' already running — stop it first or pick another -n name`);let a=kR(t),o=n.loadEngine?await n.loadEngine(a):await RD({ipk:a}),s={wasm_fn:UD(o.wasmModule),memory_size:i.memoryMib*1024*1024,vga_memory_size:i.vgaMemoryMib*1024*1024,autostart:!1,disable_speaker:!0,fastboot:!0},c=await zR(i,t,s);if(c)return c;let l=new o.V86(s),u={name:i.name,emulator:l,engineVersion:o.version,pid:null,startedAt:Date.now(),bootArgv:[`v86`,`start`,...e],serial:{buffer:``},screen:{mode:`text`,width:0,height:0,frame:null},serve:null},d=n.processManager??FR();if(d){let e=d.spawn({kind:`net`,argv:u.bootArgv,cwd:t.cwd,owner:{kind:`system`}});u.pid=e.pid,e.abort.signal.addEventListener(`abort`,()=>{WR(u,d)})}ia(u);try{if(await VR(l),i.netRelay===`fetch`){let e=HR(l,n);if(e)return await WR(u,d),e}ra(u),await l.run()}catch(e){return await WR(u,d),Q(`boot failed: ${e instanceof Error?e.message:String(e)}`)}u.onScreenChange=()=>{import(`./registry-qHtWYFOX.js`).then(({getComputerRegistry:e})=>{e()?.refresh(`v86:${u.name}`)})},import(`./v86-BF0NlNun.js`).then(({registerV86Computer:e})=>e(u)).catch(()=>{});let f=u.pid===null?``:` (pid ${u.pid})`;return $(`VM '${i.name}' booting in the background${f}.\nDrive it with: v86 text -n ${i.name} | v86 screenshot -n ${i.name} | v86 type -n ${i.name} "..."\n`)}async function WR(e,t){oa(e),na(e.name),import(`./v86-BF0NlNun.js`).then(({unregisterV86Computer:t})=>t(e.name)).catch(()=>{});try{e.emulator.is_running()&&await e.emulator.stop()}catch{}try{await e.emulator.destroy()}catch{}t&&e.pid!==null&&t.exit(e.pid,null)}function GR(){let e=ta();if(e.length===0)return $(`no VMs running
|
|
3194
3201
|
`);let t=[`NAME PID STATE UP BOOT`];for(let n of e){let e=Math.round((Date.now()-n.startedAt)/1e3),r=e>=60?`${Math.floor(e/60)}m${e%60}s`:`${e}s`;t.push(`${n.name.padEnd(10)} ${String(n.pid??`-`).padEnd(6)} ${(n.emulator.is_running()?`running`:`stopped`).padEnd(9)} ${r.padEnd(9)} `+n.bootArgv.slice(2).join(` `))}return $(`${t.join(`
|
|
3195
|
-
`)}\n`)}function
|
|
3202
|
+
`)}\n`)}function KR(e,t){return`prefer: computer ${e} -c ${t}\n`}async function qR(e,t,n,r){let i=jR(t);if(MR(i))return i;let[{runComputer:a},{getComputerRegistry:o,installComputerRegistry:s},c]=await Promise.all([import(`./run-BI7sTnua.js`).then(e=>e.t),import(`./registry-qHtWYFOX.js`),import(`./v86-BF0NlNun.js`)]),l=c.v86ComputerId(t),u=o()??s(null);return u.get(l)||c.registerV86Computer(i,u),JR(await a([`-c`,l,...n],e,{registry:u}),r,l)}function JR(e,t,n){let r=KR(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 YR(e,t){let{name:n,rest:r}=AR(e);if(r.length===0){let e=jR(n);return MR(e)?e:Q(`type: no text supplied`)}return qR(t,n,[`type`,`--`,...r],`type`)}async function XR(e,t){let{name:n,rest:r}=AR(e);if(r.length===0){let e=jR(n);return MR(e)?e:Q(`key: no chord supplied`)}return qR(t,n,[`key`,...r],`key`)}const ZR=[`left`,`middle`,`right`];async function QR(e,t){let{name:n,rest:r}=AR(e),i=jR(n);if(MR(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?qR(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>`):qR(t,n,[`--native`,`mousemove`,e,i,`--relative`],`mousemove`)}if(o===`click`){let e=r[1]??`left`;if(!ZR.includes(e))return Q(`mouse: unknown button '${r[1]}'`);let i=[`click`,e];return r.includes(`--double`)&&i.push(`--repeat`,`2`),qR(t,n,i,`click`)}return Q(`mouse: expected move <dx> <dy>, click [button], or --to <x>,<y>`)}async function $R(e,t){let{name:n,rest:r}=AR(e);return qR(t,n,[`screenshot`,...r],`screenshot`)}async function ez(e,t){let{name:n}=AR(e);return qR(t,n,[`text`],`text`)}function tz(e){let{name:t}=AR(e);return $(`v86 serve is retired.\nUse: computer watch -c v86:${t}\nLive frames go to the overlay, lightbox, and bash rows.\n`)}function nz(e){let{name:t,rest:n}=AR(e),r=jR(t);if(MR(r))return r;let i=n.indexOf(`--send`);if(i!==-1){let e=n.slice(i+1).join(` `).replace(/\\n/gu,`
|
|
3196
3203
|
`);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(`
|
|
3197
3204
|
`).slice(-Math.max(1,e)).join(`
|
|
3198
|
-
`)}\n`)}return $(r.serial.buffer?`${r.serial.buffer}\n`:``)}async function
|
|
3205
|
+
`)}\n`)}return $(r.serial.buffer?`${r.serial.buffer}\n`:``)}async function rz(e,t){let{name:n,rest:r}=AR(e),i=jR(n);if(MR(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 iz(e,t){let{name:n,rest:r}=AR(e),i=jR(n);if(MR(i))return i;let a=t.processManager??FR();return r.includes(`--force`)&&a&&i.pid!==null?(a.signal(i.pid,`SIGKILL`),$(`VM '${n}' killed\n`)):(await WR(i,a),$(`VM '${n}' stopped\n`))}const az=[`--name`,`--filter`,`--scoop`],oz={state:`inactive`,session:null};function sz(){return{stdout:`usage: webhook <command> [options]
|
|
3199
3206
|
|
|
3200
3207
|
Commands:
|
|
3201
3208
|
create [--scoop <name>] [--name <name>] [--filter <code>] Create a new webhook endpoint
|
|
@@ -3215,21 +3222,21 @@ Examples:
|
|
|
3215
3222
|
webhook create --scoop slack-relay --name slack --filter "(e) => ({ text: e.body.text, user: e.body.user })"
|
|
3216
3223
|
webhook list
|
|
3217
3224
|
webhook delete abc123
|
|
3218
|
-
`,stderr:``,exitCode:0}}function
|
|
3225
|
+
`,stderr:``,exitCode:0}}function cz(e){return e().session?.webhookUrl??null}function lz(e,t,n){return t?sa(t,e):n()?ca(self.location.href,e):`(URL unavailable — connect a leader tray)`}function uz(e){return{stdout:``,stderr:`webhook ${e}: kernel host has not booted yet — try again in a moment\n`,exitCode:1}}async function dz(e){if(e.length!==1)return{stdout:``,stderr:`webhook rotate: takes no arguments
|
|
3219
3226
|
`,exitCode:1};let t=o();if(!t)return{stdout:``,stderr:`webhook rotate: no leader panel connected
|
|
3220
3227
|
`,exitCode:1};try{return await t.call(`tray-webhook-rotate`,void 0),{stdout:`Rotated webhook delivery secret. Old URLs no longer work; run webhook list for replacement URLs.
|
|
3221
3228
|
`,stderr:``,exitCode:0}}catch{return{stdout:``,stderr:`webhook rotate: rotation failed; reconnect the leader and retry
|
|
3222
|
-
`,exitCode:1}}}async function
|
|
3223
|
-
`,exitCode:1};let s=
|
|
3224
|
-
`,stderr:``,exitCode:0};let{trayUrlBase:a,urlResolutionError:o}=
|
|
3229
|
+
`,exitCode:1}}}async function fz(e,t,n){let r=S(e.slice(1),{value:az});if(`error`in r)return{stdout:``,stderr:`webhook create: ${r.error}\n`,exitCode:1};let i=r.values.get(`--name`)??`default`,a=r.values.get(`--filter`),o=Ii(r.values.get(`--scoop`),n);if(!t.hasLocalNodeServer()&&a)return{stdout:``,stderr:`webhook create: --filter is not supported in extension mode (CSP forbids dynamic eval) — drop --filter, or use standalone CLI mode
|
|
3230
|
+
`,exitCode:1};let s=hz(t);if(s)return s;let c=await Gv();if(!c)return uz(`create`);let l=await qv(c,`webhook create`,r.values.get(`--scoop`));if(l)return{stdout:``,stderr:l,exitCode:1};let u=await c.createWebhook(i,o,a),d=gz(u.id,t),f=`Created webhook "${u.name}"\nID: ${u.id}\nURL: ${d}\n`;return u.scoop&&(f+=`Scoop: ${u.scoop}\n`),u.filter&&(f+=`Filter: ${u.filter}\n`),{stdout:f,stderr:``,exitCode:0}}async function pz(e,t){let n=S(e.slice(1),{});if(`error`in n)return{stdout:``,stderr:`webhook list: ${n.error}\n`,exitCode:1};let r=await Gv();if(!r)return uz(`list`);let i=await r.listWebhooks();if(i.length===0)return{stdout:`No active webhooks
|
|
3231
|
+
`,stderr:``,exitCode:0};let{trayUrlBase:a,urlResolutionError:o}=_z(t);return{stdout:vz(i.map(e=>({id:e.id,name:e.name,url:lz(e.id,a,t.hasLocalNodeServer),createdAt:e.createdAt,filter:e.filter,scoop:e.scoop})),a,o,t.hasLocalNodeServer),stderr:``,exitCode:0}}async function mz(e,t){let n=S(e.slice(1),{});if(`error`in n)return{stdout:``,stderr:`webhook delete: ${n.error}\n`,exitCode:1};let r=n.positionals[0];if(n.positionals.length>1)return{stdout:``,stderr:`webhook delete: requires exactly one ID
|
|
3225
3232
|
`,exitCode:1};if(!r)return{stdout:``,stderr:`webhook delete: requires an ID
|
|
3226
|
-
`,exitCode:1};let i=await Gv();if(!i)return
|
|
3227
|
-
`,exitCode:1}}return await i.deleteWebhook(r)?{stdout:`Deleted webhook "${r}"\n`,stderr:``,exitCode:0}:{stdout:``,stderr:`webhook delete: webhook "${r}" not found\n`,exitCode:1}}function
|
|
3228
|
-
`,exitCode:1}}return null}function
|
|
3233
|
+
`,exitCode:1};let i=await Gv();if(!i)return uz(`delete`);let a=o();try{if(a){if((await a.call(`tray-webhook-revoke`,{webhookId:r}))?.ok!==!0)throw Error(`revocation not acknowledged`)}else if(t.getLeaderStatus().session?.webhookUrl?.includes(`/wh/`))throw Error(`no leader panel`)}catch{return{stdout:``,stderr:`webhook delete: revocation failed; registration retained, reconnect the leader and retry
|
|
3234
|
+
`,exitCode:1}}return await i.deleteWebhook(r)?{stdout:`Deleted webhook "${r}"\n`,stderr:``,exitCode:0}:{stdout:``,stderr:`webhook delete: webhook "${r}" not found\n`,exitCode:1}}function hz(e){if(e.hasLocalNodeServer())return null;if(!cz(e.getLeaderStatus)){let t=e.getLeaderStatus().state;return{stdout:``,stderr:(t===`leader`?`webhook create: tray session is not connected yet — wait for the leader to attach`:`webhook create: requires extension-leader mode with a tray worker URL configured (current state: "${t}")`)+`
|
|
3235
|
+
`,exitCode:1}}return null}function gz(e,t){try{return lz(e,cz(t.getLeaderStatus),t.hasLocalNodeServer)}catch(e){return`(URL resolution failed: ${e instanceof Error?e.message:String(e)})`}}function _z(e){try{return{trayUrlBase:cz(e.getLeaderStatus),urlResolutionError:null}}catch(e){return{trayUrlBase:null,urlResolutionError:e instanceof Error?e.message:String(e)}}}function vz(e,t,n,r){let i=`Active webhooks:
|
|
3229
3236
|
`;for(let t of e)i+=` ${t.id} ${t.name.padEnd(20)} ${t.url}`,t.scoop&&(i+=` -> ${t.scoop}`),t.filter&&(i+=` [filtered]`),i+=`
|
|
3230
3237
|
`;return n?i+=`\nNote: webhook URL resolution failed (${n}). Try again once the tray is connected.\n`:!r()&&!t&&(i+=`
|
|
3231
3238
|
Note: webhook URLs require a leader tray. Configure one in Settings to expose POST endpoints.
|
|
3232
|
-
`),i}function
|
|
3239
|
+
`),i}function yz(e={}){let t={hasLocalNodeServer:e.hasLocalNodeServer??(()=>!0),getLeaderStatus:e.getLeaderStatus??(()=>oz)};return x(`webhook`,async(e,n)=>{if(e.length===0)return sz();let r=e[0];if(C(e,{valueFlags:r===`create`?az:void 0}))return sz();try{switch(r){case`create`:return await fz(e,t,n.env);case`list`:return await pz(e,t);case`delete`:return await mz(e,t);case`rotate`:return await dz(e);default:return{stdout:``,stderr:`webhook: unknown command "${r}"\n`,exitCode:1}}}catch(e){let t=e instanceof Error?e.message:String(e);return{stdout:``,stderr:`webhook ${r??`?`}: ${t}\n`,exitCode:1}}})}function bz(){return{text:!0,binary:!1,oneMessage:!1,noClose:!1,exitOnEof:!1,unidirectional:!1,unidirectionalReverse:!1,insecure:!1,quiet:!1,verbose:0,nullTerminated:!1,base64:!1,jsonrpc:!1,jsonrpcOmit:!1,bufferSize:65536,connTimeoutMs:3e4,customHeaders:[],showHelp:!1}}function xz(){return{stdout:`usage: websocat [FLAGS] [OPTIONS] <ws://URL | wss://URL>
|
|
3233
3240
|
|
|
3234
3241
|
Minimal websocat client. Sends stdin lines as WebSocket messages and prints
|
|
3235
3242
|
received messages to stdout. Server mode and advanced specifiers (exec:, tcp:,
|
|
@@ -3271,14 +3278,14 @@ EXAMPLES:
|
|
|
3271
3278
|
echo 'Page.navigate {"url":"https://example.com"}' \\
|
|
3272
3279
|
| websocat -1 --jsonrpc --jsonrpc-omit-jsonrpc \\
|
|
3273
3280
|
ws://127.0.0.1:9222/devtools/page/<id>
|
|
3274
|
-
`,stderr:``,exitCode:0}}const
|
|
3275
|
-
`)}function
|
|
3276
|
-
`,r=e.split(n);return r.length>0&&r[r.length-1]===``&&r.pop(),r}function
|
|
3281
|
+
`,stderr:``,exitCode:0}}const Sz=new Set([`-s`,`--server-mode`,`--oneshot`,`--socks5`,`--basic-auth`,`--basic-auth-file`,`--header-to-env`,`--server-header`,`--exec`,`--ws-c-uri`,`--restrict-uri`,`--unlink`,`--strict`,`-S`]);function Cz(e,t,n,r){let i=e[t].indexOf(`=`);if(i!==-1&&e[t].startsWith(n))return{value:e[t].slice(i+1),next:t};let a=e[t+1];return a===void 0?(r.error=`websocat: missing value for ${n}\n`,null):{value:a,next:t+1}}function wz(e,t,n,r=`positive integer`){let i=Number(t);return!Number.isFinite(i)||i<=0?(e.error=`websocat: ${n} expects ${r}\n`,null):i}function Tz(e,t){let n=Number(t);return!Number.isFinite(n)||n<1e3||n>4999?(e.error=`websocat: --close-status-code expects 1000..4999, got '${t}'\n`,null):n}function Ez(e,t){let n={"-t":()=>{e.text=!0,e.binary=!1},"--text":()=>{e.text=!0,e.binary=!1},"-b":()=>{e.binary=!0,e.text=!1},"--binary":()=>{e.binary=!0,e.text=!1},"-1n":()=>{e.oneMessage=!0,e.noClose=!0},"-n1":()=>{e.oneMessage=!0,e.noClose=!0},"-1":()=>{e.oneMessage=!0},"--one-message":()=>{e.oneMessage=!0},"-n":()=>{e.noClose=!0},"--no-close":()=>{e.noClose=!0},"-E":()=>{e.exitOnEof=!0},"--exit-on-eof":()=>{e.exitOnEof=!0},"-u":()=>{e.unidirectional=!0},"--unidirectional":()=>{e.unidirectional=!0},"-U":()=>{e.unidirectionalReverse=!0},"--unidirectional-reverse":()=>{e.unidirectionalReverse=!0},"-k":()=>{e.insecure=!0},"--insecure":()=>{e.insecure=!0},"-q":()=>{e.quiet=!0},"-0":()=>{e.nullTerminated=!0},"--null-terminated":()=>{e.nullTerminated=!0},"--base64":()=>{e.base64=!0},"--jsonrpc":()=>{e.jsonrpc=!0},"--jsonrpc-omit-jsonrpc":()=>{e.jsonrpcOmit=!0,e.jsonrpc=!0}}[t];return n?(n(),!0):!1}function Dz(e,t){return t===`-v`?(e.verbose+=1,!0):t===`-vv`&&(e.verbose+=2,!0)}function Oz(e,t,n,r,i){let a=Cz(t,n,r,e);return a?(i(a.value),{nextIndex:a.next}):{stop:!0}}function kz(e,t,n,r,i,a,o){let s=Cz(t,n,r,e);if(!s)return{stop:!0};let c=wz(e,s.value,i,o);return c===null?{stop:!0}:(a(c),{nextIndex:s.next})}function Az(e,t){return t.some(t=>e===t||e.startsWith(`${t}=`))}const jz=[(e,t,n,r)=>{if(!Az(r,[`--close-status-code`]))return null;let i=Cz(t,n,`--close-status-code`,e);if(!i)return{stop:!0};let a=Tz(e,i.value);return a===null?{stop:!0}:(e.closeStatus=a,{nextIndex:i.next})},(e,t,n,r)=>Az(r,[`--close-reason`])?Oz(e,t,n,`--close-reason`,t=>{e.closeReason=t}):null,(e,t,n,r)=>Az(r,[`-B`,`--buffer-size`])?kz(e,t,n,r===`-B`?`-B`:`--buffer-size`,`--buffer-size`,t=>{e.bufferSize=t}):null,(e,t,n,r)=>Az(r,[`--max-messages`])?kz(e,t,n,`--max-messages`,`--max-messages`,t=>{e.maxMessages=t}):null,(e,t,n,r)=>Az(r,[`--protocol`])?Oz(e,t,n,`--protocol`,t=>{e.protocol=t}):null,(e,t,n,r)=>{if(!Az(r,[`--ping-interval`]))return null;let i=Cz(t,n,`--ping-interval`,e);return i?(e.pingInterval=Number(i.value),{nextIndex:i.next}):{stop:!0}},(e,t,n,r)=>Az(r,[`--conn-timeout`])?kz(e,t,n,`--conn-timeout`,`--conn-timeout`,t=>{e.connTimeoutMs=Math.round(t*1e3)},`positive seconds`):null,(e,t,n,r)=>Az(r,[`-H`,`--header`])?Oz(e,t,n,r===`-H`?`-H`:`--header`,t=>{e.customHeaders.push(t)}):null];function Mz(e,t,n,r){for(let i of jz){let a=i(e,t,n,r);if(a)return a}return null}function Nz(e){e.closeReason!==void 0&&e.closeStatus===void 0&&(e.error=`websocat: --close-reason requires --close-status-code (the WebSocket close frame cannot carry a reason without a status code)
|
|
3282
|
+
`)}function Pz(e){let t=bz();for(let n=0;n<e.length;n+=1){let r=e[n];if(r===`-h`||r===`--help`)return t.showHelp=!0,t;if(Sz.has(r)||Sz.has(r.split(`=`)[0]))return t.error=`websocat: flag '${r}' is not supported in slicc's minimal client\n`,t;if(Ez(t,r)||Dz(t,r))continue;let i=Mz(t,e,n,r);if(i){if(`stop`in i)return t;n=i.nextIndex;continue}if(r.startsWith(`-`))return t.error=`websocat: unknown flag '${r}'\n`,t;if(t.url)return t.error=`websocat: extra positional argument '${r}' — advanced mode is not supported\n`,t;t.url=r}return Nz(t),t}function Fz(e,t){if(!e)return[];let n=t?`\0`:`
|
|
3283
|
+
`,r=e.split(n);return r.length>0&&r[r.length-1]===``&&r.pop(),r}function Iz(e,t,n){let r=e.trim();if(!r)return e;let i=r.search(/\s/),a=i===-1?r:r.slice(0,i),o=i===-1?``:r.slice(i+1).trim(),s=[];if(o)try{s=JSON.parse(o)}catch{s=[o]}let c={id:t,method:a,params:s};return n||(c.jsonrpc=`2.0`),JSON.stringify(c)}function Lz(e){try{return new TextDecoder(`utf-8`,{fatal:!1}).decode(e)}catch{return l(e)}}function Rz(e){if(typeof e==`string`)return{bytes:new TextEncoder().encode(e),isBinary:!1};if(e instanceof ArrayBuffer)return{bytes:new Uint8Array(e),isBinary:!0};if(ArrayBuffer.isView(e)){let t=e;return{bytes:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),isBinary:!0}}return{bytes:new TextEncoder().encode(String(e)),isBinary:!1}}const zz=1e4;function Bz(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Vz(){let e=!1,t=Bz();return{...t,settle:n=>{e||(e=!0,t.resolve(n))}}}function Hz(e,t){return e.length?e.join(t)+t:``}function Uz(e){return e.length?e.join(`
|
|
3277
3284
|
`)+`
|
|
3278
|
-
`:``}function
|
|
3279
|
-
`,a=
|
|
3280
|
-
`);if(!/^wss?:\/\//i.test(r.url))return
|
|
3281
|
-
`,exitCode:1}}function
|
|
3285
|
+
`:``}function Wz(e,t,n){e.quiet||t.push(`websocat: ${n}`)}function Gz(e,t){e.verbose<1||(e.customHeaders.length>0&&Wz(e,t,`-H/--header is accepted for parity but browsers do not allow setting WebSocket request headers; only --protocol is honored`),e.pingInterval!==void 0&&Wz(e,t,`--ping-interval has no effect in browsers (no ping API exposed)`),e.insecure&&Wz(e,t,`-k/--insecure has no effect in browsers`))}function Kz(e,t){try{let n=t.protocol?new e(t.url,t.protocol):new e(t.url);return n.binaryType=`arraybuffer`,{ws:n}}catch(e){return{error:`websocat: connect failed: ${e instanceof Error?e.message:String(e)}\n`}}}function qz(e,t,n,r){if(n.outLines.length<zz){n.outLines.push(r);return}n.droppedForOverflow===0&&Wz(e,t,`output buffer reached ${zz} messages; dropping further inbound messages — use -1, --max-messages, or pipe to a file with a different tool for long-running streams`),n.droppedForOverflow+=1}function Jz(e,t,n){let{bytes:r,isBinary:i}=Rz(n);return r.length>e.bufferSize&&(Wz(e,t,`inbound message of ${r.length} bytes exceeds --buffer-size ${e.bufferSize}; truncating`),r=r.slice(0,e.bufferSize)),i&&e.base64?l(r):Lz(r)}function Yz(e,t){return e.maxMessages!==void 0&&t>=e.maxMessages||e.oneMessage}function Xz(e,t,n){try{n===void 0?e.close(t):e.close(t,n)}catch{}}function Zz(e,t){setTimeout(()=>{Xz(t,e.closeStatus??1e3,e.closeReason)},0)}function Qz(e,t,n){let r=Fz(n,t.nullTerminated),i=1,a=0,o=t.oneMessage?r.slice(0,1):r;for(let n of o){let r=n;t.jsonrpc&&(r=Iz(n,i,t.jsonrpcOmit),i+=1),t.binary?e.send(new TextEncoder().encode(r).buffer):e.send(r),a+=1}return a}function $z(e,t,n){!t.oneMessage&&!t.noClose&&(t.exitOnEof||n===0)&&Zz(t,e)}async function eB(e,t,n){let r=[];Gz(e,r);let i=e.nullTerminated?`\0`:`
|
|
3286
|
+
`,a=Kz(n,e);if(`error`in a)return{stdout:``,stderr:a.error,exitCode:1};let{ws:o}=a,s={outLines:[],droppedForOverflow:0,received:0,finishing:!1},c=!1,l=Bz(),u=Vz(),d=0,f=!1,p=setTimeout(()=>{f=!0,Xz(o,1e3),c||l.reject(Error(`connect timeout`))},e.connTimeoutMs),m=()=>{if(e.noClose){u.settle(d);return}Xz(o,e.closeStatus??1e3,e.closeReason)};o.onopen=()=>{clearTimeout(p),c=!0,l.resolve()},o.onmessage=t=>{if(!s.finishing){if(!e.unidirectional){let n=Jz(e,r,t.data);qz(e,r,s,n)}s.received+=1,Yz(e,s.received)&&(s.finishing=!0,m())}},o.onerror=()=>{f||(Wz(e,r,`websocket error`),d=1,c||l.reject(Error(`connect failed`)))},o.onclose=t=>{if(clearTimeout(p),f){u.settle(124);return}e.verbose>=1&&Wz(e,r,`closed code=${t.code} reason=${JSON.stringify(t.reason||``)}`),d===0&&t.code!==1e3&&t.code!==1005&&t.code!==1001&&(d=1),c||l.reject(Error(`connect closed (code ${t.code})`)),u.settle(d)};try{await l.promise}catch(e){clearTimeout(p);let t=e instanceof Error?e.message:String(e);return{stdout:Hz(s.outLines,i),stderr:Uz(r.concat([`websocat: ${t}`])),exitCode:t===`connect timeout`?124:1}}e.unidirectionalReverse?!e.noClose&&e.exitOnEof&&!e.oneMessage&&Zz(e,o):$z(o,e,Qz(o,e,t));let h=await u.promise;return s.droppedForOverflow>0&&Wz(e,r,`dropped ${s.droppedForOverflow} inbound message(s) due to output buffer cap`),{stdout:Hz(s.outLines,i),stderr:Uz(r),exitCode:h}}function tB(e){return{stdout:``,stderr:e,exitCode:2}}function nB(e){return e.WebSocketCtor??(typeof WebSocket<`u`?WebSocket:void 0)}async function rB(e,t,n={}){let r=Pz(e);if(r.showHelp)return xz();if(r.error)return tB(r.error);if(!r.url)return tB(`websocat: missing ws:// or wss:// URL (use --help for usage)
|
|
3287
|
+
`);if(!/^wss?:\/\//i.test(r.url))return tB(`websocat: URL must start with ws:// or wss://, got '${r.url}'\n`);let i=nB(n);return i?eB(r,t.stdin,i):{stdout:``,stderr:`websocat: no WebSocket implementation available in this runtime
|
|
3288
|
+
`,exitCode:1}}function iB(){return x(`websocat`,async(e,t)=>rB(e,{stdin:N(t.stdin)}))}function aB(){return x(`__wf_progress`,async()=>({stdout:``,stderr:``,exitCode:0}))}const oB={commands:new Map,collisions:[]};async function sB(e,t){let n=rr(t);return e.scriptCatalog?e.scriptCatalog.getJshIndex(n):e.fs?or(e.fs,n):oB}async function cB(e){return e.scriptCatalog?e.scriptCatalog.getWorkflowCommands():e.fs?ti(e.fs):new Map}function lB(e,t,n,r,i,a,o){if(i.has(e)){let i=[`/usr/bin/${e}`];if((t||r)&&i.push(` (shadowed by built-in ${e})`),t){let e=n?[t,...n.shadowedPaths]:[t];for(let t of e)i.push(` (shadowed ${t})`)}return{lines:i,found:!0}}if(t){let e=[t];if(n)for(let t of n.shadowedPaths)e.push(` (shadowed ${t})`);return r&&e.push(` ${r.path} (workflow, shadowed by .jsh)`),{lines:e,found:!0}}return r?{lines:[`${r.path} (workflow)`],found:!0}:a.has(e)&&!o.has(e)?{lines:[`/usr/bin/${e}`],found:!0}:{lines:[],found:!1}}function uB(e={}){let t=e.scriptCatalog!==void 0||e.fs!==void 0?e:typeof e.walk==`function`&&typeof e.exists==`function`?{fs:e}:{};return x(`which`,async(e,n)=>{if(C(e))return{stdout:`which - locate a command
|
|
3282
3289
|
|
|
3283
3290
|
Usage: which <command> [command...]
|
|
3284
3291
|
|
|
@@ -3289,9 +3296,9 @@ Prints the path of the given command(s).
|
|
|
3289
3296
|
|
|
3290
3297
|
Exit code 0 if all commands found, 1 if any not found.
|
|
3291
3298
|
`,stderr:``,exitCode:0};let r=S(e,{});if(`error`in r)return{stdout:``,stderr:`which: ${r.error}\n`,exitCode:1};if(r.positionals.length===0)return{stdout:``,stderr:`which: missing argument
|
|
3292
|
-
`,exitCode:1};let i=n.getRegisteredCommands?.()??[],a=new Set(i),o=await
|
|
3299
|
+
`,exitCode:1};let i=n.getRegisteredCommands?.()??[],a=new Set(i),o=await sB(t,n.env.get(`PATH`)),s=o.commands,c=new Map(o.collisions.map(e=>[e.name,e])),l=await cB(t),u=typeof t.getStaticBuiltins==`function`?new Set(t.getStaticBuiltins()):a,d=new Set(t.getScriptRegisteredNames?.()??[]),f=[],p=!0;for(let e of r.positionals){let t=s.get(e),n=l.get(e),r=lB(e,t,c.get(e),n,u,a,d);f.push(...r.lines),r.found||(p=!1)}return{stdout:f.length>0?f.join(`
|
|
3293
3300
|
`)+`
|
|
3294
|
-
`:``,stderr:``,exitCode:+!p}})}const
|
|
3301
|
+
`:``,stderr:``,exitCode:+!p}})}const dB=`__slicc_workflows`,fB=String.raw`
|
|
3295
3302
|
class WorkflowError extends Error {}
|
|
3296
3303
|
class WorkflowDeterminismError extends WorkflowError {}
|
|
3297
3304
|
class WorkflowAgentCapError extends WorkflowError {}
|
|
@@ -3404,40 +3411,40 @@ function log(message) {
|
|
|
3404
3411
|
}
|
|
3405
3412
|
const budget = { total: (__WF.budget == null ? null : __WF.budget), spent() { return 0; }, remaining() { return this.total == null ? Infinity : Math.max(0, this.total - this.spent()); } };
|
|
3406
3413
|
function workflow() { throw new WorkflowNestingUnsupportedError('nested workflow() unsupported in SP1'); }
|
|
3407
|
-
`;function
|
|
3414
|
+
`;function pB(){return`WF_RESULT_${globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`}`}function mB(e){let t=vB(e);return t===null?{name:null,description:null}:{name:yB(t,`name`),description:yB(t,`description`)}}function hB(e){return e.replace(/\bexport\s+(const|let|var|function|async\s+function|class)\b/g,`$1`)}function gB(e){return`const __emit = console.log.bind(console);
|
|
3408
3415
|
const __stringify = JSON.stringify.bind(JSON);
|
|
3409
|
-
const __WF = ${JSON.stringify(e.config)};\n${e.prelude}\nconst __r = await (async () => {\n${
|
|
3416
|
+
const __WF = ${JSON.stringify(e.config)};\n${e.prelude}\nconst __r = await (async () => {\n${hB(e.body)}\n})();\n__emit(${JSON.stringify(e.sentinel)} + __stringify(__r ?? null));\n`}function _B(e,t){let n=e.split(`
|
|
3410
3417
|
`);for(let e=n.length-1;e>=0;e--)if(n[e].startsWith(t)){let r=[...n.slice(0,e),...n.slice(e+1)].join(`
|
|
3411
|
-
`).replace(/\n+$/,``);try{return{result:JSON.parse(n[e].slice(t.length)),log:r,hadResult:!0}}catch{return{result:null,log:r,hadResult:!0}}}return{result:null,log:e.replace(/\n+$/,``),hadResult:!1}}function
|
|
3418
|
+
`).replace(/\n+$/,``);try{return{result:JSON.parse(n[e].slice(t.length)),log:r,hadResult:!0}}catch{return{result:null,log:r,hadResult:!0}}}return{result:null,log:e.replace(/\n+$/,``),hadResult:!1}}function vB(e){let t=/\bmeta\s*=\s*\{/.exec(e);if(!t)return null;let n=t.index+t[0].length-1,r=0;for(let t=n;t<e.length;t++)if(e[t]===`{`)r++;else if(e[t]===`}`&&--r===0)return e.slice(n+1,t);return null}function yB(e,t){let n=RegExp(`\\b${t}\\s*:\\s*(['"\\\`])((?:\\\\.|(?!\\1).)*)\\1`).exec(e);return n?n[2]:null}const bB=e(`workflow-command`),xB=`usage: workflow run <file.js> [--args <json>] [--budget <n>] [--concurrency <n>] [--wait]
|
|
3412
3419
|
workflow run --script '<inline js>' [...]
|
|
3413
3420
|
workflow list
|
|
3414
3421
|
workflow status <runId>
|
|
3415
3422
|
workflow stop <runId>
|
|
3416
3423
|
workflow save <runId> <name> [--force]
|
|
3417
3424
|
Runs a Claude-Code-format dynamic workflow. Default is non-blocking (returns a run id);
|
|
3418
|
-
pass --wait to block and print the full result.`,
|
|
3419
|
-
`,stderr:``,exitCode:0};if(t[0]===`list`||t[0]===`status`||t[0]===`stop`)return
|
|
3425
|
+
pass --wait to block and print the full result.`,SB=new Set([`list`,`status`,`stop`,`save`]);function CB(){return globalThis[dB]}function wB(){let e=globalThis.navigator?.hardwareConcurrency??8;return Math.min(16,Math.max(8,e*4))}function TB(e,t,n,r){let i=t[n];switch(i){case`-h`:case`--help`:return{i:n,help:!0};case`--script`:return e.script=t[++n],{i:n};case`--wait`:return e.wait=!0,{i:n};case`--args`:try{e.args=JSON.parse(t[++n]??``),e.hasArgs=!0}catch{return{i:n,error:`workflow: --args must be valid JSON`}}return{i:n};case`--budget`:{let r=Number(t[++n]);return Number.isFinite(r)?(e.budget=r,{i:n}):{i:n,error:`workflow: --budget must be a number`}}case`--concurrency`:{let i=Number(t[++n]);return Number.isFinite(i)?(e.cap=Math.min(r,Math.max(1,Math.trunc(i))),{i:n}):{i:n,error:`workflow: --concurrency must be a number`}}default:return i.startsWith(`-`)?{i:n,error:`workflow: unknown flag '${i}'`}:e.file===void 0?(e.file=i,{i:n}):{i:n,error:`workflow: too many arguments`}}}function EB(e){if(e[0]!==`run`)return e.length===0||e.includes(`-h`)||e.includes(`--help`)?{help:!0}:{error:`workflow: unknown subcommand '${e[0]}' (only 'run' in SP1)`};let t=wB(),n={budget:null,cap:Math.min(8,t)};for(let r=1;r<e.length;r++){let i=TB(n,e,r,t);if(i.help)return{help:!0};if(i.error)return{error:i.error};r=i.i}return n.script===void 0&&n.file===void 0?{error:`workflow: a <file.js> or --script is required`}:n}function DB(e={}){return x(`workflow`,async(t,n)=>{if(SB.has(t[0])&&C(t.slice(1)))return{stdout:xB+`
|
|
3426
|
+
`,stderr:``,exitCode:0};if(t[0]===`list`||t[0]===`status`||t[0]===`stop`)return NB(t,n);if(t[0]===`save`)return MB(t,n,e);let r=EB(t);if(r.help)return{stdout:xB+`
|
|
3420
3427
|
`,stderr:``,exitCode:0};if(r.error)return{stdout:``,stderr:r.error+`
|
|
3421
|
-
`,exitCode:1};let i,a;if(r.script!==void 0)i=r.script,a=`<workflow>`;else{let e=n.fs.resolvePath(n.cwd,r.file);if(!await n.fs.exists(e))return{stdout:``,stderr:`workflow: file not found: ${r.file}\n`,exitCode:1};i=await n.fs.readFile(e),a=r.file}let o=
|
|
3422
|
-
`,exitCode:1};let s=
|
|
3423
|
-
`,exitCode:1};let n=e.options.getParentJid?.(),{runId:r}=await t.start({code:e.code,source:e.source,name:e.name,filename:e.filename,parentJid:n,ctx:e.ctx,sentinel:e.sentinel,runId:e.runId});return{stdout:`▶ workflow '${e.name}' started (run ${r}). Watch: workflow status ${r}\n`,stderr:``,exitCode:0}}const
|
|
3424
|
-
`,exitCode:1};if(!
|
|
3428
|
+
`,exitCode:1};let i,a;if(r.script!==void 0)i=r.script,a=`<workflow>`;else{let e=n.fs.resolvePath(n.cwd,r.file);if(!await n.fs.exists(e))return{stdout:``,stderr:`workflow: file not found: ${r.file}\n`,exitCode:1};i=await n.fs.readFile(e),a=r.file}let o=mB(i);if(!o.name)return{stdout:``,stderr:`workflow: script must define a meta block with a name (description optional)
|
|
3429
|
+
`,exitCode:1};let s=pB().slice(10,22),c=`/shared/workflow-runs/${s}/scratch/`;await n.fs.mkdir(c,{recursive:!0});let l=pB(),u=gB({prelude:fB,config:{...r.hasArgs?{args:r.args}:{},cap:r.cap??8,budget:r.budget??null,cwd:n.cwd,agentCwd:c},body:i,sentinel:l});return r.wait?OB(u,a,l,o,n):kB({code:u,source:i,name:o.name,filename:a,sentinel:l,runId:s,ctx:n,options:e})})}async function OB(e,t,n,r,i){let a;try{a=await Lt(e,[`workflow`,t],i,void 0,{filename:t})}catch(e){return bB.error(`workflow run failed`,e),{stdout:``,stderr:`workflow: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}return PB(r,a,n)}async function kB(e){let t=CB();if(!t)return{stdout:``,stderr:`workflow: run manager not available
|
|
3430
|
+
`,exitCode:1};let n=e.options.getParentJid?.(),{runId:r}=await t.start({code:e.code,source:e.source,name:e.name,filename:e.filename,parentJid:n,ctx:e.ctx,sentinel:e.sentinel,runId:e.runId});return{stdout:`▶ workflow '${e.name}' started (run ${r}). Watch: workflow status ${r}\n`,stderr:``,exitCode:0}}const AB=/^[a-z0-9][a-z0-9-]*$/,jB=`/workspace/.workflows`;async function MB(e,t,n){let r=!1,i=[];for(let t of e.slice(1))t===`--force`?r=!0:i.push(t);let[a,o,...s]=i;if(!a||!o||s.length>0)return{stdout:``,stderr:`usage: workflow save <runId> <name> [--force]
|
|
3431
|
+
`,exitCode:1};if(!AB.test(o))return{stdout:``,stderr:`workflow: invalid name '${o}' (use [a-z0-9][a-z0-9-]*)\n`,exitCode:1};let c=CB()?.getRun(a);if(!c)return{stdout:``,stderr:`workflow: no run '${a}' (only backgrounded runs are saveable; --wait runs are not)\n`,exitCode:1};if(!c.source)return{stdout:``,stderr:`workflow: run '${a}' has no source to save\n`,exitCode:1};let l=`${jB}/${o}.workflow.js`;if(await t.fs.exists(l)){if(!r)return{stdout:``,stderr:`workflow: ${l} already exists (pass --force to overwrite)\n`,exitCode:1}}else if(new Set(t.getRegisteredCommands?.()??[]).has(o))return{stdout:``,stderr:`workflow: '${o}' is already a command — choose another name\n`,exitCode:1};await t.fs.mkdir(jB,{recursive:!0}),await t.fs.writeFile(l,c.source);try{await n.syncScriptCommands?.()}catch(e){bB.warn(`workflow save: command re-sync failed; workflow saved, will register on next sync`,{name:o,error:e instanceof Error?e.message:String(e)})}return{stdout:`saved workflow '${o}' → ${l}\nrun it as '${o}' (or 'workflow run ${l}' if a built-in/.jsh shadows the name)\n`,stderr:``,exitCode:0}}async function NB(e,t){let n=CB();if(e[0]===`list`){if(!n)return{stdout:``,stderr:`workflow: run manager not available
|
|
3425
3432
|
`,exitCode:1};let e=n.listRuns().map(e=>`${e.id} ${e.status.padEnd(7)} ${e.agentsDone}/${e.agentsStarted} ${e.name??``}`);return{stdout:(e.length?e.join(`
|
|
3426
3433
|
`):`(no runs)`)+`
|
|
3427
3434
|
`,stderr:``,exitCode:0}}let r=e[1],i=n?.getRun(r??``);if(!i)return{stdout:``,stderr:`workflow: no run '${r}'\n`,exitCode:1};if(e[0]===`status`)return{stdout:[`run ${i.id} (${i.name??`unnamed`}) status=${i.status}`,`agents ${i.agentsDone}/${i.agentsStarted} phase=${i.currentPhase??`-`}`,i.resultPath?`result: ${i.resultPath}`:``,i.preview?`preview: ${i.preview}`:``,i.error?`error: ${i.error}`:``].filter(Boolean).join(`
|
|
3428
3435
|
`)+`
|
|
3429
|
-
`,stderr:``,exitCode:0};if(i.pid==null)return{stdout:`workflow: run ${i.id} has not started a realm process yet (nothing to stop)\n`,stderr:``,exitCode:0};if(i.status!==`running`&&i.status!==`paused`)return{stdout:`workflow: run ${i.id} already ${i.status}\n`,stderr:``,exitCode:0};let a=await t.exec?.(`kill`,{cwd:t.cwd,args:[`-KILL`,String(i.pid)]});return a&&a.exitCode!==0?{stdout:``,stderr:a.stderr||`workflow: kill failed (exit ${a.exitCode})\n`,exitCode:a.exitCode}:{stdout:`stopped run ${i.id} (pid ${i.pid})\n`,stderr:``,exitCode:0}}function
|
|
3436
|
+
`,stderr:``,exitCode:0};if(i.pid==null)return{stdout:`workflow: run ${i.id} has not started a realm process yet (nothing to stop)\n`,stderr:``,exitCode:0};if(i.status!==`running`&&i.status!==`paused`)return{stdout:`workflow: run ${i.id} already ${i.status}\n`,stderr:``,exitCode:0};let a=await t.exec?.(`kill`,{cwd:t.cwd,args:[`-KILL`,String(i.pid)]});return a&&a.exitCode!==0?{stdout:``,stderr:a.stderr||`workflow: kill failed (exit ${a.exitCode})\n`,exitCode:a.exitCode}:{stdout:`stopped run ${i.id} (pid ${i.pid})\n`,stderr:``,exitCode:0}}function PB(e,t,n){let{result:r,log:i,hadResult:a}=_B(t.stdout,n),o=e.name?`workflow: ${e.name}${e.description?` — `+e.description:``}\n`:``,s=i?FB(i)+`
|
|
3430
3437
|
`:``;return t.exitCode!==0||!a?{stdout:o+s,stderr:t.stderr||(a?``:`workflow: script produced no result
|
|
3431
3438
|
`),exitCode:t.exitCode||1}:{stdout:o+s+(typeof r==`string`?r:JSON.stringify(r))+`
|
|
3432
|
-
`,stderr:t.stderr,exitCode:0}}function
|
|
3439
|
+
`,stderr:t.stderr,exitCode:0}}function FB(e){return e.split(`
|
|
3433
3440
|
`).map(e=>e.replace(/^WFPHASE/,`▸ `).replace(/^WFLOG/,`· `)).join(`
|
|
3434
|
-
`)}function
|
|
3441
|
+
`)}function IB(e){return{stdout:``,stderr:`xxd: ${e}\n`,exitCode:1}}function LB(e){if(e==null)throw Error(`missing option value`);let t=e.startsWith(`-`),n=t||e.startsWith(`+`)?e.slice(1):e,r;if(/^0x[0-9a-fA-F]+$/.test(n))r=parseInt(n.slice(2),16);else if(/^[0-9]+$/.test(n))r=parseInt(n,10);else throw Error(`invalid number: ${e}`);return t?-r:r}function RB(e,t){let n=e.toString(16).padStart(2,`0`);return t?n.toUpperCase():n}function zB(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t}function BB(e){return e.replace(/[^0-9a-zA-Z]/g,`_`)}function VB(e,t,n,r,i){let a=[];for(let o=0;o<e.length;o+=t){let s=Math.min(o+t,e.length),c=(i+o).toString(16).padStart(8,`0`),l=``;for(let i=0;i<t;i++)n>0&&i>0&&i%n===0&&(l+=` `),l+=o+i<s?RB(e[o+i],r):` `;let u=``;for(let t=o;t<s;t++)u+=e[t]>=32&&e[t]<=126?String.fromCharCode(e[t]):`.`;a.push(`${c}: ${l} ${u}`)}return a.length?a.join(`
|
|
3435
3442
|
`)+`
|
|
3436
|
-
`:``}function
|
|
3437
|
-
`}return r}function
|
|
3443
|
+
`:``}function HB(e,t,n){let r=``;for(let i=0;i<e.length;i+=t){let a=``;for(let r=0;r<t&&i+r<e.length;r++)a+=RB(e[i+r],n);r+=a+`
|
|
3444
|
+
`}return r}function UB(e,t,n,r){let i=Array.from(e,e=>`0x${RB(e,n)}`),a=[];for(let e=0;e<i.length;e+=t)a.push(` `+i.slice(e,e+t).join(`, `));let o=a.join(`,
|
|
3438
3445
|
`);return r===null?i.length?o+`
|
|
3439
|
-
`:``:`unsigned char ${r}[] = {\n${o}\n};\nunsigned int ${r}_len = ${e.length};\n`}function
|
|
3440
|
-
`)){let e=r.replace(/\r$/,``),i=e.indexOf(`:`);if(i<0)continue;let a=parseInt(e.slice(0,i).trim(),16);if(Number.isNaN(a))continue;let o=e.slice(i+1),s=o.indexOf(` `);s>=0&&(o=o.slice(0,s));let c=o.replace(/[^0-9a-fA-F]/g,``),l=[];for(let e=0;e+1<c.length;e+=2)l.push(parseInt(c.substr(e,2),16));l.length&&(t.push({offset:a,bytes:l}),n=Math.max(n,a+l.length))}if(!t.length)return new Uint8Array;let r=new Uint8Array(n);for(let e of t)for(let t=0;t<e.bytes.length;t++)r[e.offset+t]=e.bytes[t];return r}const
|
|
3446
|
+
`:``:`unsigned char ${r}[] = {\n${o}\n};\nunsigned int ${r}_len = ${e.length};\n`}function WB(e){let t=e.replace(/[^0-9a-fA-F]/g,``),n=Math.floor(t.length/2),r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=parseInt(t.substr(e*2,2),16);return r}function GB(e){let t=[],n=0;for(let r of e.split(`
|
|
3447
|
+
`)){let e=r.replace(/\r$/,``),i=e.indexOf(`:`);if(i<0)continue;let a=parseInt(e.slice(0,i).trim(),16);if(Number.isNaN(a))continue;let o=e.slice(i+1),s=o.indexOf(` `);s>=0&&(o=o.slice(0,s));let c=o.replace(/[^0-9a-fA-F]/g,``),l=[];for(let e=0;e+1<c.length;e+=2)l.push(parseInt(c.substr(e,2),16));l.length&&(t.push({offset:a,bytes:l}),n=Math.max(n,a+l.length))}if(!t.length)return new Uint8Array;let r=new Uint8Array(n);for(let e of t)for(let t=0;t<e.bytes.length;t++)r[e.offset+t]=e.bytes[t];return r}const KB={"-u":`upper`,"-p":`plain`,"-ps":`plain`,"-postscript":`plain`,"-i":`include`,"-include":`include`,"-r":`revert`,"-revert":`revert`},qB=[{key:`cols`,exact:[`-c`,`-cols`],attached:/^-c(0x)?[0-9]/},{key:`group`,exact:[`-g`,`-groupsize`],attached:/^-g(0x)?[0-9]/},{key:`length`,exact:[`-l`,`-len`],attached:/^-l(0x)?[0-9]/},{key:`seek`,exact:[`-s`,`-seek`],attached:/^-s[+-]?(0x)?[0-9]/}];function JB(e){let t={upper:!1,plain:!1,include:!1,revert:!1,positional:[]};for(let n=0;n<e.length;n++){let r=e[n],i=KB[r];if(i){t[i]=!0;continue}let a=qB.find(e=>e.exact.includes(r)||e.attached.test(r));if(a){t[a.key]=LB(a.exact.includes(r)?e[++n]:r.slice(2));continue}if(r!==`-`&&r.startsWith(`-`)&&r.length>1)throw Error(`invalid option ${r}`);t.positional.push(r)}return t}function YB(e){return e.includes(`-h`)||e.includes(`--help`)||e.includes(`-help`)}async function XB(e,t,n){if(!n&&t)return e.fs.readFileBuffer(e.fs.resolvePath(e.cwd,t));let r=Qr(e.stdin),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e)&255;return i}function ZB(e,t,n,r,i){let a=e.cols&&e.cols>0?e.cols:e.plain?30:e.include?12:16;return e.plain?HB(t,a,e.upper):e.include?UB(t,a,e.upper,i?null:BB(r??``)):VB(t,a,e.group!=null&&e.group>=0?e.group:2,e.upper,n)}function QB(e,t){let n=0,r=t;return e.seek!==void 0&&(n=e.seek<0?Math.max(0,r.length+e.seek):Math.min(e.seek,r.length),r=r.subarray(n)),e.length!==void 0&&(r=r.subarray(0,Math.max(0,e.length))),{data:r,base:n}}function $B(){return x(`xxd`,async(e,t)=>{if(YB(e))return{stdout:`usage: xxd [options] [infile [outfile]]
|
|
3441
3448
|
-c cols number of octets per line (default 16; 30 for -p; 12 for -i)
|
|
3442
3449
|
-g bytes number of octets per group (default 2; 0 disables grouping)
|
|
3443
3450
|
-l len stop after len octets
|
|
@@ -3447,8 +3454,8 @@ pass --wait to block and print the full result.`,bB=new Set([`list`,`status`,`st
|
|
|
3447
3454
|
-i output in C include style
|
|
3448
3455
|
-r reverse: convert a hex dump back to binary (-r -p for plain)
|
|
3449
3456
|
-h show this help
|
|
3450
|
-
`,stderr:``,exitCode:0};let n;try{n=
|
|
3451
|
-
`,stderr:``,exitCode:0}}function
|
|
3452
|
-
`,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(/^\.\//,``))||gr(r);if(i.isDirectory&&!n)return{stdout:``,stderr:`zip: ${e} is a directory (use -r)\n`,exitCode:1};s+=await
|
|
3453
|
-
`,exitCode:1};let c=Ct(o);return await t.fs.writeFile(i,c),{stdout:`created ${i} (${s} file(s))\n`,stderr:``,exitCode:0}})}function tV(e){return{setEnv:e.setEnv,unsetEnv:e.unsetEnv,broker:e.sudoCommand?.broker}}function nV(e){let{fs:t,fetch:n}=e;if(!t||!n)return[];let r={fs:t,fetch:n,scriptCatalog:e.scriptCatalog,syncScriptCommands:e.syncScriptCommands};return[PD(`ipk`,r),PD(`npm`,r),PD(`i`,r),_O(`ipx`,{fs:t,fetch:n}),_O(`npx`,{fs:t,fetch:n}),Hy(`di`,{fs:t,fetch:n}),Hy(`uv`,{fs:t,fetch:n}),ML({fs:t,fetch:n})]}function rV(e={}){let t=[RT({getJshCommands:e.getJshCommands,getWorkflowCommands:e.getWorkflowCommands}),le(),DF(),KP(),zP(e.browserAPI,e.fs),Dj(e.browserAPI),iy(e.browserAPI),zE(e),eV(),cL(),nI(),PF(),VF(),RF(),$_(),ZB(),xF(`sqlite3`),xF(`sqllite`),yI(),LI(),ix(),F_(),WA({buildProcessConfig:e.buildProcessConfig}),WA({buildProcessConfig:e.buildProcessConfig},`jsh`),zM(`python3`,{buildProcessConfig:e.buildProcessConfig}),zM(`python`,{buildProcessConfig:e.buildProcessConfig}),...nV(e),...e.fs?[uS({fs:e.fs})]:[],...e.fs?[nA({fs:e.fs})]:[],...e.fetch?[GT({fetch:e.fetch})]:[],Zx(),Qx(),_z(e.webhook),nB(),ry(e.crontask),lk({fs:e.fs,scriptCatalog:e.scriptCatalog}),qj({fs:e.fs,fetch:e.fetch}),lS(),fF(),Oj(),kj(`pdftk`),kj(`pdf`),I_(`biscotto`),I_(`biscotti`),zj(`pdftoppm`),zj(`pdftocairo`),Bj(`pdftotext`),Vv(`convert`),Vv(`magick`),cB({fs:e.fs,scriptCatalog:e.scriptCatalog,getStaticBuiltins:e.getStaticBuiltins,getScriptRegisteredNames:e.getScriptRegisteredNames}),VI(),rL(),FE(),IE(),iL(),rA(),UM(),rk(),kb(),aj(),ij(),ek(),uP(tV(e)),nN({fs:e.fs}),ON(),X_(),Z_(),Q_(`xclip`),Q_(`xsel`),DN(),OS(),sg(),cg(),AA(e.fs),tt(),YA(),Og({getParentJid:e.getParentJid}),Lb(),hM({processManager:e.processManager}),qL({processManager:e.processManager}),bO({processManager:e.processManager}),vO({processManager:e.processManager,scriptCatalog:e.scriptCatalog}),...jg(),tA(),KO(),vR(),_E(),zx(),PR({processManager:e.processManager}),nv({processManager:e.processManager,browser:e.browserAPI,sudoBroker:e.sudoCommand?.broker}),Xx(),U_({registry:e.cherryRuntimeRegistry}),dy(),vy({fs:e.fs}),yy({fs:e.fs}),kF(e.sudoCommand),TB({getParentJid:e.getParentJid,syncScriptCommands:e.syncScriptCommands}),rB(),GP()];return e.fs&&(Hj(),t.push(...Jn.map(t=>FT(t,e.browserAPI,e.fs)))),t}let iV=null;function aV(e){iV=e}function oV(e){iV?.(e)}var sV=Ht();const cV=Reflect.get(Ye,`DefenseInDepthBox`);function lV(e){return(typeof e==`string`?e:e?.encoding)??`utf8`}function uV(e,t){if(typeof e!=`string`)return e;let n=lV(t);if(n===`binary`||n===`latin1`){let t=ue(e);if(t)return t}return sV.Buffer.from(e,n)}var dV=class{vfs;registeredCommandsFn=null;listingStats=new Map;listingStatsMax;listingStatsTtlMs;constructor(e,t){this.vfs=e,this.listingStatsMax=Math.max(1,t?.listingStatsMax??2e4),this.listingStatsTtlMs=t?.listingStatsTtlMs??1e3}get listingStatsSize(){return this.listingStats.size}primeListingStats(e,t){let n=Date.now();if(t.length>this.listingStatsMax){this.listingStats.clear();return}this.sweepExpiredListingStats(n),this.listingStats.size+t.length>this.listingStatsMax&&this.listingStats.clear();let r=e===`/`?`/`:`${e}/`;for(let e of t){let t=Pe(e),i=`${r}${e.name}`;this.listingStats.delete(i),t&&this.listingStats.set(i,{stats:t,at:n})}}sweepExpiredListingStats(e){for(let[t,n]of this.listingStats){if(e-n.at<=this.listingStatsTtlMs)break;this.listingStats.delete(t)}}primedStats(e){let t=this.listingStats.get(e);if(t){if(Date.now()-t.at>this.listingStatsTtlMs){this.listingStats.delete(e);return}return t.stats}}dropListingStats(){this.listingStats.clear()}setRegisteredCommandsFn(e){this.registeredCommandsFn=e}getVirtualBinCommands(){return this.registeredCommandsFn?.()??[]}virtualUsrStat(e){if(e===`/usr`||e===`/usr/bin`)return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date(0)};if(e.startsWith(`/usr/bin/`)){let t=e.slice(9);if(t.length>0&&!t.includes(`/`)&&this.getVirtualBinCommands().includes(t))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=cV?.runTrustedAsync;return t?t(e):Promise.resolve().then(e)}async readFile(e,t){return this.trusted(async()=>{let n=y(e),r=await this.vfs.readFile(n,{encoding:`binary`}),i=r instanceof Uint8Array?r:new TextEncoder().encode(r),a=lV(t),o=sV.Buffer.from(i.buffer,i.byteOffset,i.byteLength).toString(a);return a!==`hex`&&a!==`base64`&&ae(o,i),o})}async readFileBuffer(e){return this.trusted(async()=>{let t=y(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 sV.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString(`latin1`)}async getNativeFile(e){return this.trusted(()=>this.vfs.getNativeFile(y(e)))}async readFileRange(e,t,n){return this.trusted(()=>this.vfs.readFileRange(y(e),t,n))}async writeFile(e,t,n){return this.dropListingStats(),this.trusted(async()=>{let r=y(e);await this.vfs.writeFile(r,uV(t,n))})}async appendFile(e,t,n){return this.dropListingStats(),this.trusted(()=>this.vfs.appendFile(y(e),uV(t,n)))}async exists(e){return this.trusted(async()=>{let t=y(e);return this.virtualUsrStat(t)?!0:this.vfs.exists(t)})}async stat(e){return this.trusted(async()=>{let t=y(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=y(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(y(e),t)})}async readdir(e){return this.trusted(async()=>{let t=y(e);if(t===`/usr`)return[`bin`];if(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=y(e);if(t===`/usr`)return[{name:`bin`,isFile:!1,isDirectory:!0,isSymbolicLink:!1}];if(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(y(e),t)})}async cp(e,t,n){return this.dropListingStats(),this.trusted(async()=>{let r=y(e),i=y(t);if((await this.vfs.stat(r)).type===`directory`){if(!n?.recursive)throw new Fe(`EISDIR`,`is a directory`,r);await this.cpDir(r,i)}else await this.vfs.copyFile(r,i)})}async cpDir(e,t){await this.vfs.mkdir(t,{recursive:!0});let n=await this.vfs.readDir(e);for(let r of n){let n=b(e,r.name),i=b(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(y(e),y(t))})}async rename(e,t){return this.mv(e,t)}resolvePath(e,t){return t.startsWith(`/`)?y(t):y(b(e,t))}getAllPaths(){return[]}async chmod(e,t){return this.dropListingStats(),this.trusted(()=>this.vfs.chmod(y(e),t))}async symlink(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.symlink(e,y(t))})}async link(e,t){throw Error(`Hard links not supported in VirtualFS`)}async readlink(e){return this.trusted(async()=>this.vfs.readlink(y(e)))}async realpath(e){return this.trusted(async()=>this.vfs.realpath(y(e)))}async utimes(e,t,n){return this.dropListingStats(),this.trusted(()=>this.vfs.utimes(y(e),t,n))}invalidatePaths(e){this.dropListingStats();let t=this.vfs;t.invalidatePaths&&t.invalidatePaths(e)}};function fV(e){return e&&typeof e.getWatcher==`function`?e.getWatcher?.()??null:e&&typeof e.getUnderlyingFS==`function`?fV(e.getUnderlyingFS?.()):null}async function pV(e){let t=c(`github`);if(t){if(e?.force){await t.onSilentRenew?.();return}await t.getValidAccessToken?.()}}const mV=e(`almost-bash-shell`),hV=`__SLICC_RUN_PID`,gV=`__SLICC_OUTPUT_TEE__`;function _V(e){let t=e?.get(hV);if(t===void 0)return;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>0?n:void 0}function vV(e){if(!(hV in e)&&!(gV in e)&&!(`__SLICC_SUDO_REASON`in e))return{...e};let{[hV]:t,[gV]:n,[Wp]:r,...i}=e;return i}var yV=class e{options;bash;vfsAdapter;gitCommands;mountCommands;lastEnv;cwd;builtinCommandNames;staticBuiltinNames;allowedCommands;scriptCatalog;initialJshSync=null;ownsScriptCatalog;registeredJshCommands=new Map;registeredWorkflowCommands=new Set;jshSyncInflight=null;jshSyncDirty=!1;pendingCommandGrants=[];pendingSudoBypasses=new Map;pendingEnvWrites=new Map;activeShellPid;progress;activeRunSignal;scriptRun=null;scriptRunsActive=0;registryNames=new Set;outputTees=new Map;nextOutputTeeId=0;resolveJshProcessConfig=e=>this.buildJshProcessConfig(_V(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:np,PATH:ir,USER:`user`,SHELL:`/bin/bash`,TMPDIR:`/tmp`,PWD:t,...e.env}}buildSupplementalCommands(e,t){return rV({onMediaPreview:async e=>this.renderMediaPreview(e),getJshCommands:()=>this.getJshCommandNames(),getWorkflowCommands:()=>this.getWorkflowCommandNames(),syncScriptCommands:()=>this.syncJshCommands(),getStaticBuiltins:()=>[...this.staticBuiltinNames],getScriptRegisteredNames:()=>[...this.registeredJshCommands.keys(),...this.registeredWorkflowCommands],fs:e.fs,fetch:t,scriptCatalog:this.scriptCatalog,browserAPI:e.browserAPI,webhook:e.webhook,crontask:e.crontask,getParentJid:e.getParentJid,buildProcessConfig:this.resolveJshProcessConfig,processManager:e.processManager,sudoCommand:e.sudo?{broker:e.sudo.broker,persistGrant:async e=>{this.pendingCommandGrants.push(e)},suppressNextGate:e=>this.registerSudoBypass(e)}:void 0,setEnv:(e,t)=>{this.pendingEnvWrites.set(e,t),this.lastEnv[e]=t},unsetEnv:e=>{this.pendingEnvWrites.set(e,null),delete this.lastEnv[e]}})}constructor(t){this.options=t,this.vfsAdapter=new dV(t.fs),this.progress=new op({scrubLabel:t.scrubProgressLabel}),this.allowedCommands=e.buildAllowedCommandSet(t);let n=t.cwd??`/`,r=e.buildInitialEnv(t,n);this.gitCommands=new $f({fs:t.fs,authorName:r.GIT_AUTHOR_NAME??`User`,authorEmail:r.GIT_AUTHOR_EMAIL??`user@example.com`,ensureFreshGithubToken:pV}),this.mountCommands=new Es({fs:t.fs,isScoop:t.isScoop,acquireLocalMountViaToolUI:Zp});let i=t.jshDiscoveryFs??t.fs,a=t.bshDiscoveryFs??t.fs,o=fV(i)??fV(a);this.scriptCatalog=t.scriptCatalog??new ri({jshFs:i,bshFs:a,watcher:o}),this.ownsScriptCatalog=!t.scriptCatalog,o&&o.watch(`/`,e=>e.endsWith(`.jsh`)||e.endsWith(`.workflow.js`),()=>{this.syncJshCommands().catch(()=>void 0)});let s=this.createGitCustomCommand(),c=ie({progress:dp(this.progress)}),l=this.buildSupplementalCommands(t,c),u=[s,this.createMountCustomCommand(),this.createUmountCustomCommand(),Gm(t.fs),Hh(t.fs,c,t.browserAPI),...l].filter(e=>this.isCommandAllowed(e.name)),d=[...Ze(),...Xe()],f=this.allowedCommands?d.filter(e=>this.isCommandAllowed(e)):void 0;if(this.bash=new Qe({fs:this.vfsAdapter,cwd:n,env:{},fetch:c,commands:f,customCommands:u,sleep:Mp(this.progress,{isAborted:()=>this.activeRunSignal?.aborted??!1}),executionLimitProfile:t.executionLimitProfile,executionLimits:tp(t.isScoop?.()??!1,t.executionLimits)}),this.bash.registerTransformPlugin(am),this.allowedCommands!==null){let e=this.bash;for(let t of Xe())this.isCommandAllowed(t)||e.commands.delete(t)}{let e=this.bash;for(let[t,n]of e.commands)e.commands.set(t,this.wrapCommandForDispatch(n));this.registryNames=new Set(e.commands.keys())}let p=u.map(e=>e.name),m=f??[...Ze(),...Xe()];this.builtinCommandNames=new Set([...m,...p]),this.staticBuiltinNames=new Set(this.builtinCommandNames),this.vfsAdapter.setRegisteredCommandsFn(()=>[...this.builtinCommandNames]),this.lastEnv={...r},this.cwd=n,this.startInitialJshSync()}getBash(){return this.bash}getCwd(){return this.cwd}getScriptCatalog(){return this.scriptCatalog}getEnv(){return{...this.lastEnv}}setMaskedEnvVar(e,t){this.pendingEnvWrites.set(e,t),this.lastEnv[e]=t}applySessionOverrides(e){e.cwd!==void 0&&(this.cwd=e.cwd,this.lastEnv.PWD=e.cwd),e.env&&Object.assign(this.lastEnv,e.env)}async getJshCommandNames(){return[...(await this.getFilteredJshCommands()).keys()]}async syncJshCommands(){return this.jshSyncInflight===null?(this.jshSyncInflight=this.doSyncJshCommands(),this.jshSyncInflight):(this.jshSyncDirty=!0,this.jshSyncInflight)}async executeCommand(e,t,n,r=``,i){let a=this.activeShellPid;n!==void 0&&(this.activeShellPid=n);let o=i?.onOutput?`tee-${this.nextOutputTeeId+=1}`:void 0;o&&i?.onOutput&&this.outputTees.set(o,i.onOutput);try{let i=await this.runCommand(e,t,n,r,o);return{stdout:i.stdout,stderr:i.stderr,exitCode:i.exitCode}}finally{this.activeShellPid=a,o&&this.outputTees.delete(o)}}async executeScriptFile(e,t=[]){return Nt(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,...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 ar(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 rp(e);this.lastEnv.HOME=t,this.options.env?.USER||(this.lastEnv.USER=ip(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});if(r.env){let{PWD:e,...t}=r.env;this.lastEnv={...t,PWD:this.lastEnv.PWD??this.cwd}}}catch(e){mV.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){oV(e.trim().split(/\s+/)[0]||`unknown`),ne(),await this.waitForInitialJshSync(t);let a=Kp(e),o={env:{...this.lastEnv,...n===void 0?{}:{[hV]:String(n)},...i===void 0?{}:{[gV]:i},...a?{[Wp]:a}:{}},cwd:this.cwd,signal:t,...r===``?{}:{stdin:r,stdinKind:`bytes`}},s=this.lastEnv.PATH;this.activeRunSignal=t;let c=this.beginScriptRun(e),l;try{l=await this.bash.exec(e,o)}finally{this.activeRunSignal===t&&(this.activeRunSignal=void 0),this.endScriptRun(c)}if(await this.flushPendingCommandGrants(),l.env&&(this.lastEnv=vV(l.env)),l.env&&this.lastEnv.PATH!==s&&await this.syncJshCommands().catch(()=>void 0),this.pendingEnvWrites.size>0){for(let[e,t]of this.pendingEnvWrites)t===null?delete this.lastEnv[e]:this.lastEnv[e]=t;this.pendingEnvWrites.clear()}if(l.env?.PWD&&(this.cwd=l.env.PWD),l.exitCode===127){let t=await this.tryJshFallback(e,n);if(t)return this.syncJshCommands().catch(()=>void 0),t}if(l.exitCode!==0&&l.stderr.includes(`Permission denied`)){let{withShebangExecHint:e}=await import(`./shebang-exec-hint-BISPom3l.js`);return e(l,this.cwd,this.vfsAdapter)}return l}isTransparentGatingEnabled(){let e=this.options.sudo;return!!e&&e.transparentGating!==!1}wrapCommandForDispatch(e){let t=this.wrapCommandForSudo(e),n=e.name===`timeout`?Ip(t,this.progress):Rp(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(gV),s=o?a.get(o):void 0;s&&(t.writeStdout=s);try{let r=await n.execute(e,t);return i(t.env,r),r}finally{r()}}}}teeCommandOutput(e,t){let n=e?.get(gV);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=Dp(this.bash.transform(e).ast,this.registryNames)}catch{t={totalSteps:null}}return this.scriptRun=new kp(t,this.progress,Op(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(Wp))||e.execute(n,r)}}}async gateCommandDispatch(e,t,n){let r=this.options.sudo;if(!r)return null;let i=Bp(e,t);if(this.consumeSudoBypass(i))return null;let a=r.getPolicy();if(!a)return null;let o=await Hp(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:1}}registerSudoBypass(e){let t=e.trim();t&&this.pendingSudoBypasses.set(t,(this.pendingSudoBypasses.get(t)??0)+1)}consumeSudoBypass(e){let t=this.pendingSudoBypasses.get(e);return t?(t===1?this.pendingSudoBypasses.delete(e):this.pendingSudoBypasses.set(e,t-1),!0):!1}async flushPendingCommandGrants(){if(this.pendingCommandGrants.length===0)return;let e=this.pendingCommandGrants;this.pendingCommandGrants=[];for(let t of e)try{await this.persistCommandGrant(t)}catch{}}async persistCommandGrant(e){let t=this.options.sudo?.persistCommandGrant;if(t){await t(e);return}let n=rt(e);if(!n)return;let r=`${at}/granted`,i=this.options.fs,a=``;try{await i.exists(r)&&(a=await i.readFile(r))}catch(e){if(!(e instanceof Fe&&e.code===`ENOENT`))throw e}let o=a&&!a.endsWith(`
|
|
3454
|
-
`)?`${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)
|
|
3457
|
+
`,stderr:``,exitCode:0};let n;try{n=JB(e)}catch(e){return IB(e.message)}let r=n.positional[0],i=n.positional[1],a=!r||r===`-`,o;try{o=await XB(t,r,a)}catch{return IB(`${r}: No such file or directory`)}if(n.revert){let e=zB(o),r=n.plain?WB(e):GB(e);return i?(await t.fs.writeFile(t.fs.resolvePath(t.cwd,i),r),{stdout:``,stderr:``,exitCode:0}):{stdout:zB(r),stderr:``,exitCode:0}}let{data:s,base:c}=QB(n,o),l=ZB(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 eV(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=hr(t,o),s=n?`${n}/${o}`:o;a+=await eV(e,i,s,r)}return a}function tV(){return{stdout:`usage: zip [-r] <archive.zip> <path> [path...]
|
|
3458
|
+
`,stderr:``,exitCode:0}}function nV(){return x(`zip`,async(e,t)=>{if(e.length===0||e.includes(`--help`)||e.includes(`-h`))return tV();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
|
|
3459
|
+
`,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(/^\.\//,``))||gr(r);if(i.isDirectory&&!n)return{stdout:``,stderr:`zip: ${e} is a directory (use -r)\n`,exitCode:1};s+=await eV(t,r,a,o)}if(s===0)return{stdout:``,stderr:`zip: nothing to do
|
|
3460
|
+
`,exitCode:1};let c=Ct(o);return await t.fs.writeFile(i,c),{stdout:`created ${i} (${s} file(s))\n`,stderr:``,exitCode:0}})}function rV(e){return{setEnv:e.setEnv,unsetEnv:e.unsetEnv,broker:e.sudoCommand?.broker}}function iV(e){let{fs:t,fetch:n}=e;if(!t||!n)return[];let r={fs:t,fetch:n,scriptCatalog:e.scriptCatalog,syncScriptCommands:e.syncScriptCommands};return[PD(`ipk`,r),PD(`npm`,r),PD(`i`,r),_O(`ipx`,{fs:t,fetch:n}),_O(`npx`,{fs:t,fetch:n}),Hy(`di`,{fs:t,fetch:n}),Hy(`uv`,{fs:t,fetch:n}),PL({fs:t,fetch:n})]}function aV(e={}){let t=[RT({getJshCommands:e.getJshCommands,getWorkflowCommands:e.getWorkflowCommands}),le(),DF(),KP(),zP(e.browserAPI,e.fs),Dj(e.browserAPI),iy(e.browserAPI),zE(e),nV(),uL(),nI(),PF(),VF(),RF(),$_(),$B(),xF(`sqlite3`),xF(`sqllite`),yI(),zI(),ix(),F_(),WA({buildProcessConfig:e.buildProcessConfig}),WA({buildProcessConfig:e.buildProcessConfig},`jsh`),zM(`python3`,{buildProcessConfig:e.buildProcessConfig}),zM(`python`,{buildProcessConfig:e.buildProcessConfig}),...iV(e),...e.fs?[uS({fs:e.fs})]:[],...e.fs?[nA({fs:e.fs})]:[],...e.fetch?[GT({fetch:e.fetch})]:[],Zx(),Qx(),yz(e.webhook),iB(),ry(e.crontask),lk({fs:e.fs,scriptCatalog:e.scriptCatalog}),qj({fs:e.fs,fetch:e.fetch}),lS(),fF(),Oj(),kj(`pdftk`),kj(`pdf`),I_(`biscotto`),I_(`biscotti`),zj(`pdftoppm`),zj(`pdftocairo`),Bj(`pdftotext`),Vv(`convert`),Vv(`magick`),uB({fs:e.fs,scriptCatalog:e.scriptCatalog,getStaticBuiltins:e.getStaticBuiltins,getScriptRegisteredNames:e.getScriptRegisteredNames}),UI(),aL(),FE(),IE(),oL(),rA(),UM(),rk(),kb(),aj(),ij(),ek(),uP(rV(e)),nN({fs:e.fs}),ON(),X_(),Z_(),Q_(`xclip`),Q_(`xsel`),DN(),OS(),sg(),cg(),AA(e.fs),tt(),YA(),Og({getParentJid:e.getParentJid}),Lb(),hM({processManager:e.processManager}),YL({processManager:e.processManager}),bO({processManager:e.processManager}),vO({processManager:e.processManager,scriptCatalog:e.scriptCatalog}),...jg(),tA(),KO(),bR(),_E(),zx(),IR({processManager:e.processManager}),nv({processManager:e.processManager,browser:e.browserAPI,sudoBroker:e.sudoCommand?.broker}),Xx(),U_({registry:e.cherryRuntimeRegistry}),dy(),vy({fs:e.fs}),yy({fs:e.fs}),kF(e.sudoCommand),DB({getParentJid:e.getParentJid,syncScriptCommands:e.syncScriptCommands}),aB(),GP()];return e.fs&&(Hj(),t.push(...Jn.map(t=>FT(t,e.browserAPI,e.fs)))),t}let oV=null;function sV(e){oV=e}function cV(e){oV?.(e)}var lV=Ht();const uV=Reflect.get(Ye,`DefenseInDepthBox`);function dV(e){return(typeof e==`string`?e:e?.encoding)??`utf8`}function fV(e,t){if(typeof e!=`string`)return e;let n=dV(t);if(n===`binary`||n===`latin1`){let t=ue(e);if(t)return t}return lV.Buffer.from(e,n)}var pV=class{vfs;registeredCommandsFn=null;listingStats=new Map;listingStatsMax;listingStatsTtlMs;constructor(e,t){this.vfs=e,this.listingStatsMax=Math.max(1,t?.listingStatsMax??2e4),this.listingStatsTtlMs=t?.listingStatsTtlMs??1e3}get listingStatsSize(){return this.listingStats.size}primeListingStats(e,t){let n=Date.now();if(t.length>this.listingStatsMax){this.listingStats.clear();return}this.sweepExpiredListingStats(n),this.listingStats.size+t.length>this.listingStatsMax&&this.listingStats.clear();let r=e===`/`?`/`:`${e}/`;for(let e of t){let t=Pe(e),i=`${r}${e.name}`;this.listingStats.delete(i),t&&this.listingStats.set(i,{stats:t,at:n})}}sweepExpiredListingStats(e){for(let[t,n]of this.listingStats){if(e-n.at<=this.listingStatsTtlMs)break;this.listingStats.delete(t)}}primedStats(e){let t=this.listingStats.get(e);if(t){if(Date.now()-t.at>this.listingStatsTtlMs){this.listingStats.delete(e);return}return t.stats}}dropListingStats(){this.listingStats.clear()}setRegisteredCommandsFn(e){this.registeredCommandsFn=e}getVirtualBinCommands(){return this.registeredCommandsFn?.()??[]}virtualUsrStat(e){if(e===`/usr`||e===`/usr/bin`)return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date(0)};if(e.startsWith(`/usr/bin/`)){let t=e.slice(9);if(t.length>0&&!t.includes(`/`)&&this.getVirtualBinCommands().includes(t))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=uV?.runTrustedAsync;return t?t(e):Promise.resolve().then(e)}async readFile(e,t){return this.trusted(async()=>{let n=y(e),r=await this.vfs.readFile(n,{encoding:`binary`}),i=r instanceof Uint8Array?r:new TextEncoder().encode(r),a=dV(t),o=lV.Buffer.from(i.buffer,i.byteOffset,i.byteLength).toString(a);return a!==`hex`&&a!==`base64`&&ae(o,i),o})}async readFileBuffer(e){return this.trusted(async()=>{let t=y(e),n=await this.vfs.readFile(t,{encoding:`binary`});return n instanceof Uint8Array?n:new TextEncoder().encode(n)})}async readFileBytes(e){let t=await this.readFileBuffer(e);return lV.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString(`latin1`)}async getNativeFile(e){return this.trusted(()=>this.vfs.getNativeFile(y(e)))}async readFileRange(e,t,n){return this.trusted(()=>this.vfs.readFileRange(y(e),t,n))}async writeFile(e,t,n){return this.dropListingStats(),this.trusted(async()=>{let r=y(e);await this.vfs.writeFile(r,fV(t,n))})}async appendFile(e,t,n){return this.dropListingStats(),this.trusted(()=>this.vfs.appendFile(y(e),fV(t,n)))}async exists(e){return this.trusted(async()=>{let t=y(e);return this.virtualUsrStat(t)?!0:this.vfs.exists(t)})}async stat(e){return this.trusted(async()=>{let t=y(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=y(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(y(e),t)})}async readdir(e){return this.trusted(async()=>{let t=y(e);if(t===`/usr`)return[`bin`];if(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=y(e);if(t===`/usr`)return[{name:`bin`,isFile:!1,isDirectory:!0,isSymbolicLink:!1}];if(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(y(e),t)})}async cp(e,t,n){return this.dropListingStats(),this.trusted(async()=>{let r=y(e),i=y(t);if((await this.vfs.stat(r)).type===`directory`){if(!n?.recursive)throw new Fe(`EISDIR`,`is a directory`,r);await this.cpDir(r,i)}else await this.vfs.copyFile(r,i)})}async cpDir(e,t){await this.vfs.mkdir(t,{recursive:!0});let n=await this.vfs.readDir(e);for(let r of n){let n=b(e,r.name),i=b(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(y(e),y(t))})}async rename(e,t){return this.mv(e,t)}resolvePath(e,t){return t.startsWith(`/`)?y(t):y(b(e,t))}getAllPaths(){return[]}async chmod(e,t){return this.dropListingStats(),this.trusted(()=>this.vfs.chmod(y(e),t))}async symlink(e,t){return this.dropListingStats(),this.trusted(async()=>{await this.vfs.symlink(e,y(t))})}async link(e,t){throw Error(`Hard links not supported in VirtualFS`)}async readlink(e){return this.trusted(async()=>this.vfs.readlink(y(e)))}async realpath(e){return this.trusted(async()=>this.vfs.realpath(y(e)))}async utimes(e,t,n){return this.dropListingStats(),this.trusted(()=>this.vfs.utimes(y(e),t,n))}invalidatePaths(e){this.dropListingStats();let t=this.vfs;t.invalidatePaths&&t.invalidatePaths(e)}};function mV(e){return e&&typeof e.getWatcher==`function`?e.getWatcher?.()??null:e&&typeof e.getUnderlyingFS==`function`?mV(e.getUnderlyingFS?.()):null}async function hV(e){let t=c(`github`);if(t){if(e?.force){await t.onSilentRenew?.();return}await t.getValidAccessToken?.()}}const gV=e(`almost-bash-shell`),_V=`__SLICC_RUN_PID`,vV=`__SLICC_OUTPUT_TEE__`;function yV(e){let t=e?.get(_V);if(t===void 0)return;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>0?n:void 0}function bV(e){if(!(_V in e)&&!(vV in e)&&!(`__SLICC_SUDO_REASON`in e))return{...e};let{[_V]:t,[vV]:n,[Wp]:r,...i}=e;return i}var xV=class e{options;bash;vfsAdapter;gitCommands;mountCommands;lastEnv;cwd;builtinCommandNames;staticBuiltinNames;allowedCommands;scriptCatalog;initialJshSync=null;ownsScriptCatalog;registeredJshCommands=new Map;registeredWorkflowCommands=new Set;jshSyncInflight=null;jshSyncDirty=!1;pendingCommandGrants=[];pendingSudoBypasses=new Map;pendingEnvWrites=new Map;activeShellPid;progress;activeRunSignal;scriptRun=null;scriptRunsActive=0;registryNames=new Set;outputTees=new Map;nextOutputTeeId=0;resolveJshProcessConfig=e=>this.buildJshProcessConfig(yV(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:np,PATH:ir,USER:`user`,SHELL:`/bin/bash`,TMPDIR:`/tmp`,PWD:t,...e.env}}buildSupplementalCommands(e,t){return aV({onMediaPreview:async e=>this.renderMediaPreview(e),getJshCommands:()=>this.getJshCommandNames(),getWorkflowCommands:()=>this.getWorkflowCommandNames(),syncScriptCommands:()=>this.syncJshCommands(),getStaticBuiltins:()=>[...this.staticBuiltinNames],getScriptRegisteredNames:()=>[...this.registeredJshCommands.keys(),...this.registeredWorkflowCommands],fs:e.fs,fetch:t,scriptCatalog:this.scriptCatalog,browserAPI:e.browserAPI,webhook:e.webhook,crontask:e.crontask,getParentJid:e.getParentJid,buildProcessConfig:this.resolveJshProcessConfig,processManager:e.processManager,sudoCommand:e.sudo?{broker:e.sudo.broker,persistGrant:async e=>{this.pendingCommandGrants.push(e)},suppressNextGate:e=>this.registerSudoBypass(e)}:void 0,setEnv:(e,t)=>{this.pendingEnvWrites.set(e,t),this.lastEnv[e]=t},unsetEnv:e=>{this.pendingEnvWrites.set(e,null),delete this.lastEnv[e]}})}constructor(t){this.options=t,this.vfsAdapter=new pV(t.fs),this.progress=new op({scrubLabel:t.scrubProgressLabel}),this.allowedCommands=e.buildAllowedCommandSet(t);let n=t.cwd??`/`,r=e.buildInitialEnv(t,n);this.gitCommands=new $f({fs:t.fs,authorName:r.GIT_AUTHOR_NAME??`User`,authorEmail:r.GIT_AUTHOR_EMAIL??`user@example.com`,ensureFreshGithubToken:hV}),this.mountCommands=new Es({fs:t.fs,isScoop:t.isScoop,acquireLocalMountViaToolUI:Zp});let i=t.jshDiscoveryFs??t.fs,a=t.bshDiscoveryFs??t.fs,o=mV(i)??mV(a);this.scriptCatalog=t.scriptCatalog??new ri({jshFs:i,bshFs:a,watcher:o}),this.ownsScriptCatalog=!t.scriptCatalog,o&&o.watch(`/`,e=>e.endsWith(`.jsh`)||e.endsWith(`.workflow.js`),()=>{this.syncJshCommands().catch(()=>void 0)});let s=this.createGitCustomCommand(),c=ie({progress:dp(this.progress)}),l=this.buildSupplementalCommands(t,c),u=[s,this.createMountCustomCommand(),this.createUmountCustomCommand(),Gm(t.fs),Hh(t.fs,c,t.browserAPI),...l].filter(e=>this.isCommandAllowed(e.name)),d=[...Ze(),...Xe()],f=this.allowedCommands?d.filter(e=>this.isCommandAllowed(e)):void 0;if(this.bash=new Qe({fs:this.vfsAdapter,cwd:n,env:{},fetch:c,commands:f,customCommands:u,sleep:Mp(this.progress,{isAborted:()=>this.activeRunSignal?.aborted??!1}),executionLimitProfile:t.executionLimitProfile,executionLimits:tp(t.isScoop?.()??!1,t.executionLimits)}),this.bash.registerTransformPlugin(am),this.allowedCommands!==null){let e=this.bash;for(let t of Xe())this.isCommandAllowed(t)||e.commands.delete(t)}{let e=this.bash;for(let[t,n]of e.commands)e.commands.set(t,this.wrapCommandForDispatch(n));this.registryNames=new Set(e.commands.keys())}let p=u.map(e=>e.name),m=f??[...Ze(),...Xe()];this.builtinCommandNames=new Set([...m,...p]),this.staticBuiltinNames=new Set(this.builtinCommandNames),this.vfsAdapter.setRegisteredCommandsFn(()=>[...this.builtinCommandNames]),this.lastEnv={...r},this.cwd=n,this.startInitialJshSync()}getBash(){return this.bash}getCwd(){return this.cwd}getScriptCatalog(){return this.scriptCatalog}getEnv(){return{...this.lastEnv}}setMaskedEnvVar(e,t){this.pendingEnvWrites.set(e,t),this.lastEnv[e]=t}applySessionOverrides(e){e.cwd!==void 0&&(this.cwd=e.cwd,this.lastEnv.PWD=e.cwd),e.env&&Object.assign(this.lastEnv,e.env)}async getJshCommandNames(){return[...(await this.getFilteredJshCommands()).keys()]}async syncJshCommands(){return this.jshSyncInflight===null?(this.jshSyncInflight=this.doSyncJshCommands(),this.jshSyncInflight):(this.jshSyncDirty=!0,this.jshSyncInflight)}async executeCommand(e,t,n,r=``,i){let a=this.activeShellPid;n!==void 0&&(this.activeShellPid=n);let o=i?.onOutput?`tee-${this.nextOutputTeeId+=1}`:void 0;o&&i?.onOutput&&this.outputTees.set(o,i.onOutput);try{let i=await this.runCommand(e,t,n,r,o);return{stdout:i.stdout,stderr:i.stderr,exitCode:i.exitCode}}finally{this.activeShellPid=a,o&&this.outputTees.delete(o)}}async executeScriptFile(e,t=[]){return Nt(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,...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 ar(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 rp(e);this.lastEnv.HOME=t,this.options.env?.USER||(this.lastEnv.USER=ip(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});if(r.env){let{PWD:e,...t}=r.env;this.lastEnv={...t,PWD:this.lastEnv.PWD??this.cwd}}}catch(e){gV.warn(`HOME/profile init failed; continuing with defaults`,e)}}async waitForInitialJshSync(e){let t=this.initialJshSync;if(t===null)return;if(!e){await t;return}if(e.aborted)return;let n;try{await new Promise(r=>{n=()=>r(),e.addEventListener(`abort`,n,{once:!0}),t.then(()=>r(),()=>r())})}finally{n&&e.removeEventListener(`abort`,n)}}async runCommand(e,t,n,r=``,i){cV(e.trim().split(/\s+/)[0]||`unknown`),ne(),await this.waitForInitialJshSync(t);let a=Kp(e),o={env:{...this.lastEnv,...n===void 0?{}:{[_V]:String(n)},...i===void 0?{}:{[vV]:i},...a?{[Wp]:a}:{}},cwd:this.cwd,signal:t,...r===``?{}:{stdin:r,stdinKind:`bytes`}},s=this.lastEnv.PATH;this.activeRunSignal=t;let c=this.beginScriptRun(e),l;try{l=await this.bash.exec(e,o)}finally{this.activeRunSignal===t&&(this.activeRunSignal=void 0),this.endScriptRun(c)}if(await this.flushPendingCommandGrants(),l.env&&(this.lastEnv=bV(l.env)),l.env&&this.lastEnv.PATH!==s&&await this.syncJshCommands().catch(()=>void 0),this.pendingEnvWrites.size>0){for(let[e,t]of this.pendingEnvWrites)t===null?delete this.lastEnv[e]:this.lastEnv[e]=t;this.pendingEnvWrites.clear()}if(l.env?.PWD&&(this.cwd=l.env.PWD),l.exitCode===127){let t=await this.tryJshFallback(e,n);if(t)return this.syncJshCommands().catch(()=>void 0),t}if(l.exitCode!==0&&l.stderr.includes(`Permission denied`)){let{withShebangExecHint:e}=await import(`./shebang-exec-hint-BISPom3l.js`);return e(l,this.cwd,this.vfsAdapter)}return l}isTransparentGatingEnabled(){let e=this.options.sudo;return!!e&&e.transparentGating!==!1}wrapCommandForDispatch(e){let t=this.wrapCommandForSudo(e),n=e.name===`timeout`?Ip(t,this.progress):Rp(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(vV),s=o?a.get(o):void 0;s&&(t.writeStdout=s);try{let r=await n.execute(e,t);return i(t.env,r),r}finally{r()}}}}teeCommandOutput(e,t){let n=e?.get(vV);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=Dp(this.bash.transform(e).ast,this.registryNames)}catch{t={totalSteps:null}}return this.scriptRun=new kp(t,this.progress,Op(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(Wp))||e.execute(n,r)}}}async gateCommandDispatch(e,t,n){let r=this.options.sudo;if(!r)return null;let i=Bp(e,t);if(this.consumeSudoBypass(i))return null;let a=r.getPolicy();if(!a)return null;let o=await Hp(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:1}}registerSudoBypass(e){let t=e.trim();t&&this.pendingSudoBypasses.set(t,(this.pendingSudoBypasses.get(t)??0)+1)}consumeSudoBypass(e){let t=this.pendingSudoBypasses.get(e);return t?(t===1?this.pendingSudoBypasses.delete(e):this.pendingSudoBypasses.set(e,t-1),!0):!1}async flushPendingCommandGrants(){if(this.pendingCommandGrants.length===0)return;let e=this.pendingCommandGrants;this.pendingCommandGrants=[];for(let t of e)try{await this.persistCommandGrant(t)}catch{}}async persistCommandGrant(e){let t=this.options.sudo?.persistCommandGrant;if(t){await t(e);return}let n=rt(e);if(!n)return;let r=`${at}/granted`,i=this.options.fs,a=``;try{await i.exists(r)&&(a=await i.readFile(r))}catch(e){if(!(e instanceof Fe&&e.code===`ENOENT`))throw e}let o=a&&!a.endsWith(`
|
|
3461
|
+
`)?`${a}\n`:a;await i.writeFile(r,`${o}NOPASSWD Cmnd ${n}\n`)}isCommandAllowed(e){return this.allowedCommands===null||this.allowedCommands.has(e)}async doSyncJshCommands(){try{let e=await this.scriptCatalog.getJshIndex(this.currentScanRoots()),t=e.commands;for(let t of e.collisions)gV.warn(`jsh command '${t.name}' is provided by more than one skill; using ${t.winnerPath} (${t.reason}), shadowed ${t.shadowedPaths.join(`, `)}`);let n=await this.getFilteredWorkflowCommands();for(let[e,n]of t)this.isCommandAllowed(e)&&(this.builtinCommandNames.has(e)&&!this.registeredJshCommands.has(e)||this.registeredJshCommands.get(e)!==n&&(this.bash.registerCommand(this.wrapCommandForDispatch(this.makeScriptCommand(e))),this.registeredJshCommands.set(e,n),this.builtinCommandNames.add(e)));for(let e of n.keys())if(!this.registeredWorkflowCommands.has(e)){if(this.registeredJshCommands.has(e)){this.registeredWorkflowCommands.add(e);continue}this.builtinCommandNames.has(e)||(this.bash.registerCommand(this.wrapCommandForDispatch(this.makeScriptCommand(e))),this.registeredWorkflowCommands.add(e),this.builtinCommandNames.add(e))}}finally{this.jshSyncInflight=null,this.jshSyncDirty&&(this.jshSyncDirty=!1,this.syncJshCommands().catch(()=>void 0))}}makeScriptCommand(e){let t=this.scriptCatalog,n=this.options.jshDiscoveryFs??this.options.fs,r=e,i=async(e,i)=>{let a=i.exec??((e,t)=>this.bash.exec(e,{env:t?.env??Object.fromEntries(i.env),cwd:t?.cwd??i.cwd,args:t?.args,...t?.env===void 0?{}:{replaceEnv:!0}})),o=(await t.getJshCommands(this.currentScanRoots())).get(r);if(o){let t;try{let e=await n.readFile(o,{encoding:`utf-8`});t=typeof e==`string`?e:new TextDecoder().decode(e)}catch{return{stdout:``,stderr:`jsh: cannot read script '${o}'\n`,exitCode:127}}return Lt(t,[`node`,o,...e],{fs:i.fs,cwd:i.cwd,env:i.env,stdin:i.stdin,exec:a},this.buildJshProcessConfig(yV(i.env)))}let s=(await t.getWorkflowCommands()).get(r);if(s){let t=ni(s.path,e);return a(t[0],{args:t.slice(1),cwd:i.cwd})}return{stdout:``,stderr:`${r}: command no longer exists\n`,exitCode:127}};return{name:e,trusted:!0,async execute(e,t){try{return await i(e,t)}catch(e){let t=e instanceof Error?e.message:String(e);return{stdout:``,stderr:`${r}: ${t}\n`,exitCode:1}}}}}createGitCustomCommand(){let e=this.gitCommands;return x(`git`,async(t,n)=>{let r=n.cwd,i=await e.execute(t,r,n.env,N(n.stdin));return{stdout:i.stdout,stderr:i.stderr,exitCode:i.exitCode}})}createMountCustomCommand(){let e=this.mountCommands;return x(`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 x(`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?ap(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 Lt(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,...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{ua as S,To as _,_B as a,ya as b,np as c,as as d,ns as f,Po as g,Fo as h,pB as i,ps as l,$o as m,pV as n,dB as o,ts as p,sV as r,Up as s,xV as t,fs as u,ga as v,yo as x,ba as y};
|