sliccy 6.190.0 → 6.192.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/tray-sync-protocol.d.ts +22 -1
- package/dist/node-server/_shared/tray-sync-protocol.d.ts.map +1 -1
- package/dist/node-server/_shared/tray-sync-protocol.js +5 -1
- package/dist/node-server/_shared/tray-sync-protocol.js.map +1 -1
- package/dist/ui/.vite/manifest.json +202 -200
- package/dist/ui/assets/{CLAUDE-BMBoR1hd.js → CLAUDE-Cp-Dty1s.js} +1 -1
- package/dist/ui/assets/{MEMORY-Dl8Y_nOo.js → MEMORY-CbB3xjAS.js} +1 -1
- package/dist/ui/assets/__vite-browser-external-CnFJWAkm.js +1 -0
- package/dist/ui/assets/account-store-Bevys7WL.js +2 -0
- package/dist/ui/assets/account-store-irTFXEHq.js +1 -0
- package/dist/ui/assets/{adobe-DAk5mRTR.js → adobe-C2Yk0FjU.js} +1 -1
- package/dist/ui/assets/{adobe-CMB6BAX8.js → adobe-CxPY_Nvf.js} +1 -1
- package/dist/ui/assets/{agent-panels-BLEQfwy2.js → agent-panels-CDAHwcGe.js} +1 -1
- package/dist/ui/assets/{almost-bash-shell-headless-B40I6EzY.js → almost-bash-shell-headless-B6lKPYip.js} +41 -38
- package/dist/ui/assets/{apply-layout-D4hoY6q2.js → apply-layout-BaPTlEmq.js} +1 -1
- package/dist/ui/assets/{apps-oTATee4K.js → apps-CWLDElDt.js} +1 -1
- package/dist/ui/assets/{azure-openai-BUzdslaw.js → azure-openai-BrEMU1w0.js} +1 -1
- package/dist/ui/assets/{azure-openai-vgxsDn6T.js → azure-openai-CAmcCxYK.js} +1 -1
- package/dist/ui/assets/{backend-hostfs-DyW6kRxx.js → backend-hostfs-DVOOQmWO.js} +1 -1
- package/dist/ui/assets/bedrock-camp-CMfZujT_.js +1 -0
- package/dist/ui/assets/bedrock-camp-Ck_nFSMy.js +1 -0
- package/dist/ui/assets/bedrock-camp-compat-Bdpnq7TU.js +1 -0
- package/dist/ui/assets/bedrock-camp-compat-Bz7u6y4g.js +1 -0
- package/dist/ui/assets/bedrock-camp-extra-models-D5MhCrhJ.js +1 -0
- package/dist/ui/assets/bedrock-camp-extra-models-IBZyfEdZ.js +1 -0
- package/dist/ui/assets/{browser-BPbYUZ91.js → browser-DL3zbJrM.js} +10 -11
- package/dist/ui/assets/{bsh-watchdog-CmaS7wa9.js → bsh-watchdog-CCz8gp5d.js} +1 -1
- package/dist/ui/assets/buffer-polyfill-BwLbCySD.js +1 -0
- package/dist/ui/assets/{cdp-BBXpHC3W.js → cdp-l5Vq6Mtp.js} +1 -1
- package/dist/ui/assets/{cerebras-DUTPWZ3a.js → cerebras-COJ_qkGu.js} +1 -1
- package/dist/ui/assets/{cerebras-Bm9kz-h8.js → cerebras-DyJkWRm7.js} +1 -1
- package/dist/ui/assets/{composer-speech-D0uHFdYf.js → composer-speech-CYdWOXqF.js} +1 -1
- package/dist/ui/assets/{connect-surface-Gme43nbM.js → connect-surface-DnaS1qCD.js} +1 -1
- package/dist/ui/assets/{core-BfCKeVcE.js → core-PJsXG3mm.js} +1 -1
- package/dist/ui/assets/{cost-command-BQTDpqWV.js → cost-command-DC0JwdLM.js} +1 -1
- package/dist/ui/assets/{directed-approval-C-N4Lyz-.js → directed-approval-Bo1zb-ki.js} +1 -1
- package/dist/ui/assets/emscripten-vfs-hook-DORb16y9.js +1 -0
- package/dist/ui/assets/{emscripten-vfs-hook-DNWfHxzZ.js → emscripten-vfs-hook-jxmK_i72.js} +1 -1
- package/dist/ui/assets/{ensure-speech-assets-CslAjHHs.js → ensure-speech-assets-DXQUrOok.js} +1 -1
- package/dist/ui/assets/{esbuild-wasm-CeZYVyQ9.js → esbuild-wasm-CbTVjIj0.js} +1 -1
- package/dist/ui/assets/{ffmpeg-wasm-CV1BmGNS.js → ffmpeg-wasm-CmLVzRDe.js} +1 -1
- package/dist/ui/assets/{frozen-archive-writer-Bzn2q24C.js → frozen-archive-writer-C_qn0GDJ.js} +1 -1
- package/dist/ui/assets/{fs-DnLOvvvT.js → fs-D5UZBrBX.js} +1 -1
- package/dist/ui/assets/{fs-D1Dp_Ep1.js → fs-DouF0VP9.js} +2 -2
- package/dist/ui/assets/{gelatiere-store-BzLpmCkk.js → gelatiere-store-D0SzDyoX.js} +1 -1
- package/dist/ui/assets/{gelatiere-unit-CWRGe17z.js → gelatiere-unit-D0eC3q8k.js} +1 -1
- package/dist/ui/assets/{github-DWvM7A3I.js → github-CMMdXD7-.js} +1 -1
- package/dist/ui/assets/{github-CiP7BlgM.js → github-DrXxnqrr.js} +2 -2
- package/dist/ui/assets/{github-auth-Bw46MVyY.js → github-auth-CVs8hOEW.js} +1 -1
- package/dist/ui/assets/{github-copilot-Cw6ggpYJ.js → github-copilot-BDW-hvGU.js} +1 -1
- package/dist/ui/assets/{github-copilot-DPCFqh6W.js → github-copilot-F_OWE6ig.js} +1 -1
- package/dist/ui/assets/{github-install-BMRS10U5.js → github-install-B-rr32FO.js} +1 -1
- package/dist/ui/assets/{github-zip-BuNrfmPG.js → github-zip-DA_-VtNu.js} +1 -1
- package/dist/ui/assets/{guest-tool-gate-XJ21QL4L.js → guest-tool-gate-CaXA5eEm.js} +1 -1
- package/dist/ui/assets/{hear-C9TMsdyp.js → hear-B1QjKHJS.js} +1 -1
- package/dist/ui/assets/{help-CT-6K18M.js → help-C3q6Ha5a.js} +1 -1
- package/dist/ui/assets/{host-command-AyzKgQLr.js → host-command-DTM6_CU_.js} +1 -1
- package/dist/ui/assets/{installer-BqstqF0q.js → installer-BamTBGiN.js} +1 -1
- package/dist/ui/assets/{interrupted-work-recovery-DvvxB451.js → interrupted-work-recovery-4r2qWReh.js} +1 -1
- package/dist/ui/assets/{js-realm-worker-By6mzrxF.js → js-realm-worker-CIzPgKVU.js} +14 -14
- package/dist/ui/assets/{jsh-executor-DkQ_pn3q.js → jsh-executor-8n8-NVRR.js} +4 -4
- package/dist/ui/assets/{kernel-worker-Cp4UmRK8.js → kernel-worker-YhNfUQ_y.js} +57 -57
- package/dist/ui/assets/{lick-ws-bridge-4OMsthUP.js → lick-ws-bridge-BWmnM4i8.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-Di__mYYU.js → lick-ws-bridge-CDPuY-EA.js} +1 -1
- package/dist/ui/assets/{live-session-curation-Df4vTXXp.js → live-session-curation-eGH4uyM1.js} +1 -1
- package/dist/ui/assets/{live-session-snapshot-DMDS-wW3.js → live-session-snapshot-CAY9GlTD.js} +1 -1
- package/dist/ui/assets/live-vfs-fs-CX95TogC.js +1 -0
- package/dist/ui/assets/{local-llm-DvXzOnVy.js → local-llm-CsIWLXJ2.js} +1 -1
- package/dist/ui/assets/{local-llm-w0RCshcM.js → local-llm-dPetWUMs.js} +1 -1
- package/dist/ui/assets/{magick-wasm-KFp97Nzb.js → magick-wasm-BATj-KUu.js} +1 -1
- package/dist/ui/assets/{main-BZ7qq-Vs.js → main-DUD5pTDH.js} +3 -3
- package/dist/ui/assets/{main-cherry-npF7LwF_.js → main-cherry-BoO4BB-J.js} +1 -1
- package/dist/ui/assets/{memory-curation-seam-C0BliwwJ.js → memory-curation-seam-DFftwyHh.js} +1 -1
- package/dist/ui/assets/{memory-health-C3D8lYLJ.js → memory-health-DF6IEFmt.js} +1 -1
- package/dist/ui/assets/{memory-write-execute-DbjHzPlQ.js → memory-write-execute-C7SUGCPF.js} +1 -1
- package/dist/ui/assets/{mount-CbM_5jlW.js → mount-BfPgf0TT.js} +1 -1
- package/dist/ui/assets/{mount-Cc1ACftx.js → mount-BsWbgqHU.js} +3 -3
- package/dist/ui/assets/{new-session-Dhc5HhIU.js → new-session-n4ieWj9Q.js} +2 -2
- package/dist/ui/assets/node-builtins-CDetdLPH.js +1 -0
- package/dist/ui/assets/{oauth-bootstrap-qAiKs1B_.js → oauth-bootstrap-DEjPbx0S.js} +2 -2
- package/dist/ui/assets/{onboarding-orchestrator-hoO7C1AA.js → onboarding-orchestrator-DTq_WzOT.js} +1 -1
- package/dist/ui/assets/{openai-codex-COpScXj-.js → openai-codex-CRBPHYXu.js} +1 -1
- package/dist/ui/assets/{openai-codex-DG55IJPc.js → openai-codex-CZFJxrdp.js} +1 -1
- package/dist/ui/assets/{openrouter-oXd9rfD3.js → openrouter-Bp2hCSj0.js} +1 -1
- package/dist/ui/assets/{openrouter-free-CCSSamEo.js → openrouter-free-B1aHr6YX.js} +1 -1
- package/dist/ui/assets/{openrouter-free-CcVhLq57.js → openrouter-free-Ciud-jQF.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-2uZjw1ni.js → openrouter-oauth-BShl7mda.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-D79F7soa.js → openrouter-oauth-CBNfp9B7.js} +1 -1
- package/dist/ui/assets/{openrouter-CvejhujC.js → openrouter-xrK_Q7tb.js} +1 -1
- package/dist/ui/assets/{opfs-mount-DLFtoGv0.js → opfs-mount-DF1_TQm7.js} +1 -1
- package/dist/ui/assets/{panel-rpc-handlers-7ANN9krW.js → panel-rpc-handlers-DYotibPR.js} +2 -2
- package/dist/ui/assets/{panelize-shell-DvvHjgSE.js → panelize-shell-5hKkbwSl.js} +1 -1
- package/dist/ui/assets/{pi-edit-execution-B9ByKtUU.js → pi-edit-execution-CcLt8vSI.js} +1 -1
- package/dist/ui/assets/{provider-Dx5FZDvY.js → provider-BLshPMsZ.js} +2 -2
- package/dist/ui/assets/{provider-sZNLAM5_.js → provider-DqEfigmv.js} +1 -1
- package/dist/ui/assets/{provider-settings-geYZ3XeM.js → provider-settings-BuaTQYid.js} +1 -1
- package/dist/ui/assets/provider-store-access-BABW1Cfu.js +1 -0
- package/dist/ui/assets/provider-store-access-C2xFS3NU.js +1 -0
- package/dist/ui/assets/{providers-Cv9xIHXL.js → providers-B3cOXz1H.js} +1 -1
- package/dist/ui/assets/providers-CE4VqQs6.js +2 -0
- package/dist/ui/assets/{py-live-vfs-Uud7Qmjl.js → py-live-vfs-9-2YNjh0.js} +1 -1
- package/dist/ui/assets/{py-live-vfs-DeChUQwG.js → py-live-vfs-CUJmBBlI.js} +1 -1
- package/dist/ui/assets/{py-realm-worker-CpOMOUd5.js → py-realm-worker-DtGB9J_v.js} +1 -1
- package/dist/ui/assets/{pyodide-DFCa52VK.js → pyodide-D9Uqa092.js} +2 -2
- package/dist/ui/assets/{quick-llm-CpA-UQN0.js → quick-llm-D1wGZooG.js} +1 -1
- package/dist/ui/assets/realm-inprocess-Dcn5yLm3.js +33 -0
- package/dist/ui/assets/realm-unhandled-rejections-BU76F0PI.js +1 -0
- package/dist/ui/assets/realm-unhandled-rejections-BXxVemlU.js +1 -0
- package/dist/ui/assets/{recovery-screen-i_JWvRnt.js → recovery-screen-D6HBp0xj.js} +1 -1
- package/dist/ui/assets/{remote-terminal-view-g-DPTw6U.js → remote-terminal-view-BDO5t9M_.js} +2 -2
- package/dist/ui/assets/{require-guards-DyoCy2Tn.js → require-guards-e8NvgvH_.js} +2 -2
- package/dist/ui/assets/{restore-Yho5__FC.js → restore-CdH_ze1C.js} +1 -1
- package/dist/ui/assets/{run-BvmSPgsD.js → run-B4snw1GL.js} +2 -2
- package/dist/ui/assets/{run-Czj6x4Rv.js → run-C-NU4dPD.js} +1 -1
- package/dist/ui/assets/{run-OgGDVYh4.js → run-CK7bQLZ0.js} +3 -3
- package/dist/ui/assets/{run-Dc0GjGeK.js → run-C_6GKpBV.js} +1 -1
- package/dist/ui/assets/{run-Clez1C47.js → run-CkKb9UWF.js} +2 -2
- package/dist/ui/assets/{run-DRsWmRGT.js → run-D2pF2y1_.js} +1 -1
- package/dist/ui/assets/{run-CyJBimTl.js → run-DNvbqTbo.js} +1 -1
- package/dist/ui/assets/{run-BKoiZyLe.js → run-DsYsM6Yl.js} +1 -1
- package/dist/ui/assets/{run-DK9rNW7X.js → run-fHfrubKD.js} +1 -1
- package/dist/ui/assets/{run-bWHW0TzP.js → run-xrVX3llR.js} +1 -1
- package/dist/ui/assets/{screencapture-run-Dt7lEfIp.js → screencapture-run-jNQom_As.js} +1 -1
- package/dist/ui/assets/{session-command-memory-DwQY_-Jn.js → session-command-memory-CGqbKVAE.js} +2 -2
- package/dist/ui/assets/{session-jsonl-BPjOpnuv.js → session-jsonl-CbNA3lGB.js} +1 -1
- package/dist/ui/assets/{session-jsonl-D5OWzUb8.js → session-jsonl-CgKvYDUr.js} +1 -1
- package/dist/ui/assets/{session-search-index-CQCVYWik.js → session-search-index-CKHuYyZd.js} +1 -1
- package/dist/ui/assets/{setup-feature-flags-remote-Da98m8-c.js → setup-feature-flags-remote-DU_3gSCe.js} +1 -1
- package/dist/ui/assets/{setup-model-catalog-CpN89kS0.js → setup-model-catalog-CQmIQSJ6.js} +1 -1
- package/dist/ui/assets/shared-2XhBobrM.js +4 -0
- package/dist/ui/assets/{signed-fetch-B9AefGxo.js → signed-fetch-DEi8arT4.js} +1 -1
- package/dist/ui/assets/{silent-renew-backoff-D4BkLCku.js → silent-renew-backoff-UU1St8tN.js} +1 -1
- package/dist/ui/assets/slicc-version-D8Zbv4vp.js +1 -0
- package/dist/ui/assets/{snapshot-BpngInyf.js → snapshot-BPuldVwP.js} +1 -1
- package/dist/ui/assets/{snapshot-features-C1KRnKvW.js → snapshot-features-Ddz9jsBd.js} +1 -1
- package/dist/ui/assets/{soundscape-55hCbegl.js → soundscape-Uopjnq2I.js} +1 -1
- package/dist/ui/assets/{speak-DRjoNxOT.js → speak-D_PLnidz.js} +1 -1
- package/dist/ui/assets/{sprinkle-manager-Cj9OtFk7.js → sprinkle-manager-BpNh9Lri.js} +1 -1
- package/dist/ui/assets/{sprinkle-renderer-DvisyAbr.js → sprinkle-renderer-BljwWT0g.js} +1 -1
- package/dist/ui/assets/src-CUSndb9K.js +1 -0
- package/dist/ui/assets/{ssh-hwEw2JDy.js → ssh-DBPFvqmL.js} +1 -1
- package/dist/ui/assets/{state-xnCFNcHc.js → state-CHrSe9Ro.js} +1 -1
- package/dist/ui/assets/{store-CsgLyaBu.js → store-BikzV66S.js} +1 -1
- package/dist/ui/assets/{store-BZUZEii9.js → store-BvFCmAq8.js} +1 -1
- package/dist/ui/assets/{sudo-CpM0_7-f.js → sudo-rquT1VWH.js} +1 -1
- package/dist/ui/assets/{supervisor-CCtgWHNU.js → supervisor-MXcG8SU6.js} +1 -1
- package/dist/ui/assets/{sync-dialog-kfyeJrvC.js → sync-dialog-zmsfROKR.js} +1 -1
- package/dist/ui/assets/temperature-support-CIu8ekGh.js +1 -0
- package/dist/ui/assets/temperature-support-D3pN575q.js +1 -0
- package/dist/ui/assets/{transformers-env-D0Ft5AnW.js → transformers-env-DVU2J7Xd.js} +1 -1
- package/dist/ui/assets/tray-leader-5xt9j15D.js +1 -0
- package/dist/ui/assets/{tray-leave-runtime-D1kxfPYV.js → tray-leave-runtime-B5LmQl4b.js} +1 -1
- package/dist/ui/assets/tray-sidecar-pljn-63X.js +2 -0
- package/dist/ui/assets/{turn-journal-C3RmT-4t.js → turn-journal-I2u4GdDj.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-CZsbpDf8.js → upgrade-detection-Ta4nIJJR.js} +1 -1
- package/dist/ui/assets/{upskill-lick-skip-B1aTWac3.js → upskill-lick-skip-IyN1i0IF.js} +1 -1
- package/dist/ui/assets/{voice-reply-Dc0ozuqt.js → voice-reply-aiuvZ8F3.js} +1 -1
- package/dist/ui/assets/{wc-attach-6OZlMIwW.js → wc-attach-C1CTfWQ-.js} +2 -2
- package/dist/ui/assets/{wc-browser-B2QFEwqe.js → wc-browser-RbezSPht.js} +1 -1
- package/dist/ui/assets/{wc-computers-CCdbZdxQ.js → wc-computers-D4IEEM5M.js} +1 -1
- package/dist/ui/assets/{wc-detached-CvESCw-O.js → wc-detached-CrVlYV_z.js} +1 -1
- package/dist/ui/assets/{wc-extension-D0foV_ib.js → wc-extension-BW5y8hdg.js} +2 -2
- package/dist/ui/assets/wc-follower-oauth-BArMqE7c.js +5 -0
- package/dist/ui/assets/wc-follower-xchSJ13T.js +17 -0
- package/dist/ui/assets/{wc-gelatiere-CJxyMbHo.js → wc-gelatiere-CxGkXDNo.js} +1 -1
- package/dist/ui/assets/{wc-live-BoLWLz9Z.js → wc-live-DdOUCb1z.js} +6 -6
- package/dist/ui/assets/{wc-nav-C3wn-3dH.js → wc-nav-C-cqoNl9.js} +2 -2
- package/dist/ui/assets/{wc-onboarding-DSGTg720.js → wc-onboarding-CId-wqvG.js} +2 -2
- package/dist/ui/assets/{wc-permissions-Dt6tAGYb.js → wc-permissions-lj9xrdU-.js} +2 -2
- package/dist/ui/assets/{wc-placeholder-tXAR_WLy.js → wc-placeholder-bs83QBxc.js} +3 -3
- package/dist/ui/assets/{wc-secret-request-D3oqwar-.js → wc-secret-request-BmVSG3Qe.js} +1 -1
- package/dist/ui/assets/{wc-settings-CA4t9KOD.js → wc-settings-CE5aZbkW.js} +3 -3
- package/dist/ui/assets/{wc-shell-kYp04Uca.js → wc-shell-DdSbkIp-.js} +3 -3
- package/dist/ui/assets/{wc-shortcut-config-t41Zisk5.js → wc-shortcut-config-C2d66GP8.js} +1 -1
- package/dist/ui/assets/{wc-sprinkles-Ce0z4QiY.js → wc-sprinkles-ak7XBDCk.js} +2 -2
- package/dist/ui/assets/{wc-transcript-export-zUoMikMo.js → wc-transcript-export-DYVbwupj.js} +2 -2
- package/dist/ui/assets/wc-tray-CjkC7SwM.js +5 -0
- package/dist/ui/assets/welcome-detection-BAQGL8Ld.js +1 -0
- package/dist/ui/assets/{whisper-session-Dv9ZtYsN.js → whisper-session-DBea3Pzc.js} +2 -2
- package/dist/ui/assets/{xai-grok-Bd2BL4cS.js → xai-grok-B-WV19uN.js} +1 -1
- package/dist/ui/assets/{xai-grok-BIYj0ZEJ.js → xai-grok-CAPZiieq.js} +1 -1
- package/dist/ui/index.html +5 -5
- package/dist/ui/packages/webapp/index.html +5 -5
- package/package.json +1 -1
- package/dist/ui/assets/__vite-browser-external-DH1K0mQP.js +0 -1
- package/dist/ui/assets/account-store-BMyZ1LC1.js +0 -1
- package/dist/ui/assets/account-store-ClzKIIMy.js +0 -2
- package/dist/ui/assets/bedrock-camp-BQ02i7Bk.js +0 -1
- package/dist/ui/assets/bedrock-camp-CMYc0nQP.js +0 -1
- package/dist/ui/assets/bedrock-camp-compat-99DjWBHV.js +0 -1
- package/dist/ui/assets/bedrock-camp-compat-BeCSBUrZ.js +0 -1
- package/dist/ui/assets/bedrock-camp-extra-models-B0WH9IRx.js +0 -1
- package/dist/ui/assets/bedrock-camp-extra-models-WTCIjj5a.js +0 -1
- package/dist/ui/assets/buffer-polyfill-BccMjOKj.js +0 -1
- package/dist/ui/assets/emscripten-vfs-hook-D0g146Sa.js +0 -1
- package/dist/ui/assets/live-vfs-fs-DXo5N-ez.js +0 -1
- package/dist/ui/assets/provider-store-access-PD8D6Ly5.js +0 -1
- package/dist/ui/assets/provider-store-access-tUmVoIgf.js +0 -1
- package/dist/ui/assets/providers-CsJ6PgRK.js +0 -2
- package/dist/ui/assets/realm-inprocess-BPfc1UTZ.js +0 -33
- package/dist/ui/assets/shared-DfMXB1pm.js +0 -4
- package/dist/ui/assets/slicc-version-D3PQZH1j.js +0 -1
- package/dist/ui/assets/temperature-support-Dd00cuZX.js +0 -1
- package/dist/ui/assets/temperature-support-PjwXIa-F.js +0 -1
- package/dist/ui/assets/tray-leader-gwAMllRq.js +0 -1
- package/dist/ui/assets/tray-sidecar-CF5Qu4Xu.js +0 -2
- package/dist/ui/assets/wc-follower-DRG_fFhc.js +0 -17
- package/dist/ui/assets/wc-follower-oauth-BNclaglp.js +0 -5
- package/dist/ui/assets/wc-tray-D6Q1hPos.js +0 -5
- package/dist/ui/assets/welcome-detection-CvTYmIMA.js +0 -1
|
@@ -394,8 +394,7 @@ Addresses:
|
|
|
394
394
|
$ last line
|
|
395
395
|
/regexp/ lines matching regexp
|
|
396
396
|
N,M range from line N to M
|
|
397
|
-
first~step every step-th line starting at first`},nd={name:`sed`,async execute(e,t){Su(t.requireDefenseContext,`sed`,`execution entry`);let n=(e,n)=>Cu(t.requireDefenseContext,`sed`,e,n);if(N(e))return M(td);let r=[],i=[],a=!1,o=!1,s=!1,c=[];for(let t=0;t<e.length;t++){let n=e[t];if(n===`-n`||n===`--quiet`||n===`--silent`)a=!0;else if(n===`-i`||n===`--in-place`)o=!0;else if(n.startsWith(`-i`))o=!0;else if(n===`-E`||n===`-r`||n===`--regexp-extended`)s=!0;else if(n===`-e`)t+1<e.length&&r.push(e[++t]);else if(n===`-f`)t+1<e.length&&i.push(e[++t]);else{if(n.startsWith(`--`))return P(`sed`,n);if(n===`-`)c.push(n);else if(n.startsWith(`-`)&&n.length>1){for(let e of n.slice(1))if(e!==`n`&&e!==`e`&&e!==`f`&&e!==`i`&&e!==`E`&&e!==`r`)return P(`sed`,`-${e}`);n.includes(`n`)&&(a=!0),n.includes(`i`)&&(o=!0),(n.includes(`E`)||n.includes(`r`))&&(s=!0),n.includes(`e`)&&!n.includes(`n`)&&!n.includes(`i`)&&t+1<e.length&&r.push(e[++t]),n.includes(`f`)&&!n.includes(`e`)&&t+1<e.length&&i.push(e[++t])}else!n.startsWith(`-`)&&r.length===0&&i.length===0?r.push(n):n.startsWith(`-`)||c.push(n)}}for(let e of i){let i=t.fs.resolvePath(t.cwd,e);try{let e=await n(`script file read`,()=>t.fs.readFile(i));
|
|
398
|
-
`)){let e=t.trim();e&&!e.startsWith(`#`)&&r.push(e)}}catch(t){if(t instanceof D)throw t;return{stdout:``,stderr:`sed: couldn't open file ${e}: No such file or directory
|
|
397
|
+
first~step every step-th line starting at first`},nd={name:`sed`,async execute(e,t){Su(t.requireDefenseContext,`sed`,`execution entry`);let n=(e,n)=>Cu(t.requireDefenseContext,`sed`,e,n);if(N(e))return M(td);let r=[],i=[],a=!1,o=!1,s=!1,c=[];for(let t=0;t<e.length;t++){let n=e[t];if(n===`-n`||n===`--quiet`||n===`--silent`)a=!0;else if(n===`-i`||n===`--in-place`)o=!0;else if(n.startsWith(`-i`))o=!0;else if(n===`-E`||n===`-r`||n===`--regexp-extended`)s=!0;else if(n===`-e`)t+1<e.length&&r.push(e[++t]);else if(n===`-f`)t+1<e.length&&i.push(e[++t]);else{if(n.startsWith(`--`))return P(`sed`,n);if(n===`-`)c.push(n);else if(n.startsWith(`-`)&&n.length>1){for(let e of n.slice(1))if(e!==`n`&&e!==`e`&&e!==`f`&&e!==`i`&&e!==`E`&&e!==`r`)return P(`sed`,`-${e}`);n.includes(`n`)&&(a=!0),n.includes(`i`)&&(o=!0),(n.includes(`E`)||n.includes(`r`))&&(s=!0),n.includes(`e`)&&!n.includes(`n`)&&!n.includes(`i`)&&t+1<e.length&&r.push(e[++t]),n.includes(`f`)&&!n.includes(`e`)&&t+1<e.length&&i.push(e[++t])}else!n.startsWith(`-`)&&r.length===0&&i.length===0?r.push(n):n.startsWith(`-`)||c.push(n)}}for(let e of i){let i=t.fs.resolvePath(t.cwd,e);try{let e=await n(`script file read`,()=>t.fs.readFile(i));r.push(e.replace(/\n$/,``))}catch(t){if(t instanceof D)throw t;return{stdout:``,stderr:`sed: couldn't open file ${e}: No such file or directory
|
|
399
398
|
`,exitCode:1}}}if(r.length===0)return{stdout:``,stderr:`sed: no script specified
|
|
400
399
|
`,exitCode:1};let{commands:l,error:u,silentMode:d}=qu(r,s,t.limits);if(u)return{stdout:``,stderr:`sed: ${u}
|
|
401
400
|
`,exitCode:1};let f=!!(a||d);if(o){if(c.length===0)return{stdout:``,stderr:`sed: -i requires at least one file argument
|
|
@@ -830,7 +829,7 @@ When no FILE is given, or when FILE is -, read from standard input.`,options:[`-
|
|
|
830
829
|
`,exitCode:2};if(!t.fetch)return{stdout:``,stderr:`curl: internal error: fetch not available
|
|
831
830
|
`,exitCode:1};let i=r.url;i.match(/^https?:\/\//)||(i=`https://${i}`);try{let e=await cE(r,t);r.getMode&&(i=uE(i,e));let{body:n,contentType:a}=await lE(r,t,e),o=dE(r,a),s=await t.fetch(i,{method:r.method,headers:o,body:n,followRedirects:r.followRedirects,timeoutMs:r.timeoutMs,maxRedirects:r.maxRedirects,signal:t.signal});if(await fE(r,s.headers,t),r.failSilently&&s.status>=400)return{stdout:``,stderr:r.showError||!r.silent?`curl: (22) The requested URL returned error: ${s.status}
|
|
832
831
|
`:``,exitCode:22};let c=(r.outputFile||r.useRemoteName)&&!r.verbose?``:mE(r,s,i);if(r.outputFile||r.useRemoteName){let e=r.outputFile||iE(i),n=t.fs.resolvePath(t.cwd,e);await t.fs.writeFile(n,r.headOnly?``:s.body),r.verbose||(c=``),r.writeOut&&(c=aE(r.writeOut,{status:s.status,headers:s.headers,url:s.url,bodyLength:s.body.byteLength}))}return{stdout:c,stderr:``,exitCode:0,stdoutKind:`bytes`}}catch(e){let t=li(e),n=1;return t.includes(`Network access denied`)?n=7:t.includes(`HTTP method`)&&t.includes(`not allowed`)?n=3:t.includes(`Redirect target not in allow-list`)||t.includes(`Too many redirects`)?n=47:t.includes(`aborted`)&&(n=28),{stdout:``,stderr:!r.silent||r.showError?`curl: (${n}) ${t}
|
|
833
|
-
`:``,exitCode:n}}}}});ir(),or(),zr(),Yn();var _E=[{name:`echo`,load:async()=>(await Promise.resolve().then(()=>(Wr(),Br))).echoCommand},{name:`cat`,load:async()=>(await Promise.resolve().then(()=>(ci(),ei))).catCommand},{name:`printf`,load:async()=>(await Promise.resolve().then(()=>(zi(),xi))).printfCommand},{name:`ls`,load:async()=>(await Promise.resolve().then(()=>(wa(),fa))).lsCommand},{name:`mkdir`,load:async()=>(await Promise.resolve().then(()=>(ka(),Ta))).mkdirCommand},{name:`rmdir`,load:async()=>(await Promise.resolve().then(()=>(Ra(),Aa))).rmdirCommand},{name:`touch`,load:async()=>(await Promise.resolve().then(()=>(Ua(),za))).touchCommand},{name:`rm`,load:async()=>(await Promise.resolve().then(()=>(Ja(),Wa))).rmCommand},{name:`cp`,load:async()=>(await Promise.resolve().then(()=>(eo(),Ya))).cpCommand},{name:`mv`,load:async()=>(await Promise.resolve().then(()=>(oo(),to))).mvCommand},{name:`ln`,load:async()=>(await Promise.resolve().then(()=>(fo(),so))).lnCommand},{name:`chmod`,load:async()=>(await Promise.resolve().then(()=>(yo(),po))).chmodCommand},{name:`pwd`,load:async()=>(await Promise.resolve().then(()=>(Co(),bo))).pwdCommand},{name:`readlink`,load:async()=>(await Promise.resolve().then(()=>(Oo(),wo))).readlinkCommand},{name:`head`,load:async()=>(await Promise.resolve().then(()=>(Ro(),Po))).headCommand},{name:`tail`,load:async()=>(await Promise.resolve().then(()=>(Uo(),zo))).tailCommand},{name:`wc`,load:async()=>(await Promise.resolve().then(()=>(Zo(),Wo))).wcCommand},{name:`stat`,load:async()=>(await Promise.resolve().then(()=>(as(),es))).statCommand},{name:`grep`,load:async()=>(await Promise.resolve().then(()=>(fl(),Kc))).grepCommand},{name:`fgrep`,load:async()=>(await Promise.resolve().then(()=>(fl(),Kc))).fgrepCommand},{name:`egrep`,load:async()=>(await Promise.resolve().then(()=>(fl(),Kc))).egrepCommand},{name:`rg`,load:async()=>(await Promise.resolve().then(()=>(xu(),_u))).rgCommand},{name:`sed`,load:async()=>(await Promise.resolve().then(()=>(id(),$u))).sedCommand},{name:`awk`,load:async()=>(await Promise.resolve().then(()=>(zp(),Mp))).awkCommand2},{name:`sort`,load:async()=>(await Promise.resolve().then(()=>(rm(),$p))).sortCommand},{name:`uniq`,load:async()=>(await Promise.resolve().then(()=>(lm(),im))).uniqCommand},{name:`comm`,load:async()=>(await Promise.resolve().then(()=>(mm(),um))).commCommand},{name:`cut`,load:async()=>(await Promise.resolve().then(()=>(xm(),hm))).cutCommand},{name:`paste`,load:async()=>(await Promise.resolve().then(()=>(Om(),Sm))).pasteCommand},{name:`tr`,load:async()=>(await Promise.resolve().then(()=>(Im(),km))).trCommand},{name:`rev`,load:async()=>(await Promise.resolve().then(()=>(Hm(),Lm))).rev},{name:`nl`,load:async()=>(await Promise.resolve().then(()=>(Xm(),Um))).nl},{name:`fold`,load:async()=>(await Promise.resolve().then(()=>(ih(),Zm))).fold},{name:`expand`,load:async()=>(await Promise.resolve().then(()=>(ph(),ah))).expand},{name:`unexpand`,load:async()=>(await Promise.resolve().then(()=>(Sh(),mh))).unexpand},{name:`strings`,load:async()=>(await Promise.resolve().then(()=>(Ah(),Ch))).strings},{name:`split`,load:async()=>(await Promise.resolve().then(()=>(Jh(),jh))).split},{name:`column`,load:async()=>(await Promise.resolve().then(()=>(ig(),Yh))).column},{name:`join`,load:async()=>(await Promise.resolve().then(()=>(pg(),ag))).join},{name:`tee`,load:async()=>(await Promise.resolve().then(()=>(yg(),mg))).teeCommand},{name:`find`,load:async()=>(await Promise.resolve().then(()=>(Jg(),Lg))).findCommand},{name:`basename`,load:async()=>(await Promise.resolve().then(()=>($g(),Yg))).basenameCommand},{name:`dirname`,load:async()=>(await Promise.resolve().then(()=>(i_(),e_))).dirnameCommand},{name:`tree`,load:async()=>(await Promise.resolve().then(()=>(f_(),a_))).treeCommand},{name:`du`,load:async()=>(await Promise.resolve().then(()=>(b_(),p_))).duCommand},{name:`env`,load:async()=>(await Promise.resolve().then(()=>(O_(),x_))).envCommand},{name:`printenv`,load:async()=>(await Promise.resolve().then(()=>(O_(),x_))).printenvCommand},{name:`alias`,load:async()=>(await Promise.resolve().then(()=>(I_(),k_))).aliasCommand},{name:`unalias`,load:async()=>(await Promise.resolve().then(()=>(I_(),k_))).unaliasCommand},{name:`history`,load:async()=>(await Promise.resolve().then(()=>(H_(),L_))).historyCommand},{name:`xargs`,load:async()=>(await Promise.resolve().then(()=>(Y_(),U_))).xargsCommand},{name:`true`,load:async()=>(await Promise.resolve().then(()=>(tv(),X_))).trueCommand},{name:`false`,load:async()=>(await Promise.resolve().then(()=>(tv(),X_))).falseCommand},{name:`clear`,load:async()=>(await Promise.resolve().then(()=>(ov(),nv))).clearCommand},{name:`bash`,load:async()=>(await Promise.resolve().then(()=>(mv(),sv))).bashCommand},{name:`sh`,load:async()=>(await Promise.resolve().then(()=>(mv(),sv))).shCommand},{name:`jq`,load:async()=>(await Promise.resolve().then(()=>(lb(),eb))).jqCommand},{name:`base64`,load:async()=>(await Promise.resolve().then(()=>(yb(),ub))).base64Command},{name:`diff`,load:async()=>(await Promise.resolve().then(()=>(Tb(),bb))).diffCommand},{name:`date`,load:async()=>(await Promise.resolve().then(()=>(Pb(),Eb))).dateCommand},{name:`sleep`,load:async()=>(await Promise.resolve().then(()=>(Hb(),Lb))).sleepCommand},{name:`timeout`,load:async()=>(await Promise.resolve().then(()=>(qb(),Ub))).timeoutCommand},{name:`time`,load:async()=>(await Promise.resolve().then(()=>(nx(),Qb))).timeCommand},{name:`seq`,load:async()=>(await Promise.resolve().then(()=>(ox(),rx))).seqCommand},{name:`expr`,load:async()=>(await Promise.resolve().then(()=>(dx(),sx))).exprCommand},{name:`md5sum`,load:async()=>(await Promise.resolve().then(()=>(bx(),_x))).md5sumCommand},{name:`sha1sum`,load:async()=>(await Promise.resolve().then(()=>(wx(),xx))).sha1sumCommand},{name:`sha256sum`,load:async()=>(await Promise.resolve().then(()=>(Ox(),Tx))).sha256sumCommand},{name:`file`,load:async()=>(await Promise.resolve().then(()=>(Ew(),gw))).fileCommand},{name:`html-to-markdown`,load:async()=>(await Promise.resolve().then(()=>(jw(),Dw))).htmlToMarkdownCommand},{name:`help`,load:async()=>(await Promise.resolve().then(()=>(Lw(),Mw))).helpCommand},{name:`which`,load:async()=>(await Promise.resolve().then(()=>(Uw(),Rw))).whichCommand},{name:`tac`,load:async()=>(await Promise.resolve().then(()=>(Jw(),Ww))).tac},{name:`hostname`,load:async()=>(await Promise.resolve().then(()=>($w(),Yw))).hostname},{name:`whoami`,load:async()=>(await Promise.resolve().then(()=>(iT(),eT))).whoami},{name:`od`,load:async()=>(await Promise.resolve().then(()=>(lT(),aT))).od},{name:`gzip`,load:async()=>(await Promise.resolve().then(()=>(zT(),fT))).gzipCommand},{name:`gunzip`,load:async()=>(await Promise.resolve().then(()=>(zT(),fT))).gunzipCommand},{name:`zcat`,load:async()=>(await Promise.resolve().then(()=>(zT(),fT))).zcatCommand}],vE=[],yE=[],bE=[{name:`curl`,load:async()=>(await Promise.resolve().then(()=>(gE(),sE))).curlCommand}],xE=new Map;function SE(e){return{name:e.name,async execute(t,n){let r=xE.get(e.name);return r||(r=await Jn.runTrustedAsync(()=>e.load()),xE.set(e.name,r)),n.coverage,r.execute(t,n)}}}function CE(){return _E.map(e=>e.name)}function wE(){return bE.map(e=>e.name)}function TE(e){return(e?_E.filter(t=>e.includes(t.name)):_E).map(SE)}function EE(){return bE.map(SE)}function DE(){return vE.map(SE)}function OE(){return yE.map(SE)}k();var kE=new WeakMap,AE=new WeakSet;function jE(e){let t=kE.get(e);return t===void 0&&(t=Object.freeze(Object.create(null)),kE.set(e,t),AE.add(t)),t}function ME(e){return AE.has(e)}var NE={maxSourceBytes:67108864,maxExecDepth:64,maxCallDepth:100,maxCommandCount:1e5,maxLoopIterations:1e5,maxAwkIterations:1e5,maxSedIterations:1e5,maxJqIterations:1e7,maxQueryTokens:1e5,maxQueryDepth:1e3,maxQueryElements:1e6,maxAwkParserTokens:1e5,maxAwkParserDepth:256,maxAwkParserOperations:1e6,maxCsvRows:1e6,maxCsvCells:1e7,maxWorkUnits:1e8,maxTraversalEntries:1e6,maxTraversalDepth:1e3,maxTraversalWork:1e6,maxLiveBytes:536870912,maxInputBytes:536870912,maxFileSystemBytes:1073741824,maxDatabaseBytes:1073741824,maxDatabaseResultBytes:268435456,maxArchiveBytes:1073741824,maxArchiveCompressedBytes:536870912,maxArchiveEntryBytes:536870912,maxArchiveEntries:1e6,maxWorkerMessageBytes:67108864,maxExecutionTimeMs:36e5,maxExtensionCleanupTimeMs:100,maxSqliteTimeoutMs:3e4,maxPythonTimeoutMs:3e4,maxJsTimeoutMs:3e4,maxGlobOperations:1e6,maxStringLength:67108864,maxArrayElements:1e6,maxHeredocSize:67108864,maxSubstitutionDepth:50,maxBraceExpansionResults:1e5,maxOutputSize:268435456,maxFileDescriptors:4096,maxSourceDepth:100},PE={...NE,maxSourceBytes:8388608,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3,maxPythonTimeoutMs:1e4,maxJsTimeoutMs:1e4,maxExtensionCleanupTimeMs:25,maxGlobOperations:1e5,maxStringLength:10485760,maxArrayElements:1e5,maxHeredocSize:10485760,maxBraceExpansionResults:1e4,maxOutputSize:10485760,maxFileDescriptors:1024,maxQueryTokens:25e3,maxQueryDepth:256,maxQueryElements:1e5,maxAwkParserTokens:25e3,maxAwkParserDepth:128,maxAwkParserOperations:1e5,maxCsvRows:1e5,maxCsvCells:1e6,maxWorkUnits:1e5,maxTraversalEntries:1e5,maxTraversalDepth:256,maxTraversalWork:1e5,maxLiveBytes:67108864,maxInputBytes:33554432,maxFileSystemBytes:134217728,maxDatabaseBytes:67108864,maxDatabaseResultBytes:16777216,maxArchiveBytes:134217728,maxArchiveCompressedBytes:67108864,maxArchiveEntryBytes:67108864,maxArchiveEntries:1e5,maxWorkerMessageBytes:16777216,maxExecutionTimeMs:3e4};function FE(e,t=`normal`){if(t!==`normal`&&t!==`hardened`)throw RangeError(`executionLimitProfile must be "normal" or "hardened"`);let n=t===`hardened`?PE:NE;if(!e)return{...n};let r={maxSourceBytes:e.maxSourceBytes??n.maxSourceBytes,maxExecDepth:e.maxExecDepth??n.maxExecDepth,maxCallDepth:e.maxCallDepth??n.maxCallDepth,maxCommandCount:e.maxCommandCount??n.maxCommandCount,maxLoopIterations:e.maxLoopIterations??n.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??n.maxAwkIterations,maxSedIterations:e.maxSedIterations??n.maxSedIterations,maxJqIterations:e.maxJqIterations??n.maxJqIterations,maxQueryTokens:e.maxQueryTokens??n.maxQueryTokens,maxQueryDepth:e.maxQueryDepth??n.maxQueryDepth,maxQueryElements:e.maxQueryElements??n.maxQueryElements,maxAwkParserTokens:e.maxAwkParserTokens??n.maxAwkParserTokens,maxAwkParserDepth:e.maxAwkParserDepth??n.maxAwkParserDepth,maxAwkParserOperations:e.maxAwkParserOperations??n.maxAwkParserOperations,maxCsvRows:e.maxCsvRows??n.maxCsvRows,maxCsvCells:e.maxCsvCells??n.maxCsvCells,maxWorkUnits:e.maxWorkUnits??n.maxWorkUnits,maxTraversalEntries:e.maxTraversalEntries??n.maxTraversalEntries,maxTraversalDepth:e.maxTraversalDepth??n.maxTraversalDepth,maxTraversalWork:e.maxTraversalWork??n.maxTraversalWork,maxLiveBytes:e.maxLiveBytes??n.maxLiveBytes,maxInputBytes:e.maxInputBytes??n.maxInputBytes,maxFileSystemBytes:e.maxFileSystemBytes??n.maxFileSystemBytes,maxDatabaseBytes:e.maxDatabaseBytes??n.maxDatabaseBytes,maxDatabaseResultBytes:e.maxDatabaseResultBytes??n.maxDatabaseResultBytes,maxArchiveBytes:e.maxArchiveBytes??n.maxArchiveBytes,maxArchiveCompressedBytes:e.maxArchiveCompressedBytes??n.maxArchiveCompressedBytes,maxArchiveEntryBytes:e.maxArchiveEntryBytes??n.maxArchiveEntryBytes,maxArchiveEntries:e.maxArchiveEntries??n.maxArchiveEntries,maxWorkerMessageBytes:e.maxWorkerMessageBytes??n.maxWorkerMessageBytes,maxExecutionTimeMs:e.maxExecutionTimeMs??n.maxExecutionTimeMs,maxExtensionCleanupTimeMs:e.maxExtensionCleanupTimeMs??n.maxExtensionCleanupTimeMs,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??n.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??n.maxPythonTimeoutMs,maxJsTimeoutMs:e.maxJsTimeoutMs??n.maxJsTimeoutMs,maxGlobOperations:e.maxGlobOperations??n.maxGlobOperations,maxStringLength:e.maxStringLength??n.maxStringLength,maxArrayElements:e.maxArrayElements??n.maxArrayElements,maxHeredocSize:e.maxHeredocSize??n.maxHeredocSize,maxSubstitutionDepth:e.maxSubstitutionDepth??n.maxSubstitutionDepth,maxBraceExpansionResults:e.maxBraceExpansionResults??n.maxBraceExpansionResults,maxOutputSize:e.maxOutputSize??n.maxOutputSize,maxFileDescriptors:e.maxFileDescriptors??n.maxFileDescriptors,maxSourceDepth:e.maxSourceDepth??n.maxSourceDepth};for(let e of Object.keys(r)){let t=r[e];if(t!==1/0&&(!Number.isSafeInteger(t)||t<0))throw RangeError(`${e} must be a non-negative safe integer or positive Infinity`)}return r}function IE(e){let{executionLimits:t,executionLimitProfile:n,fs:r,stdin:i=vr,...a}=e;return{fs:r,fsIdentity:a.fsIdentity??jE(r),cwd:`/`,env:new Map,stdin:i,limits:FE(t,n),...a}}function LE(e){return`load`in e&&typeof e.load==`function`}function RE(e,t,n={}){return{name:e,trusted:n.trusted!==!1,execute:t}}function zE(e){let t=null,n=null;return{name:e.name,trusted:e.trusted!==!1,async execute(r,i){if(!t){let r=n;r||(r=e.load().then(e=>(t=e,e)),n=r);try{t=await r}catch(e){throw n===r&&(n=null),e}}let a=t;if(!a)throw Error(`Failed to load command: ${e.name}`);return a.execute(r,i)}}}k(),k(),j(),ir();var BE=Object.freeze(Object.create(null)),VE=class{limits;signal;commandCount=0;workUnits=0;liveBytes=0;inputBytes=0;outputBytes=0;countersByKind=new Map;bytesByKind=new Map;depthByKind=new Map;cleanupCallbacks=[];poisoned;closed=!1;startedAt=Date.now();get remainingLiveBytes(){return Math.max(0,this.limits.maxLiveBytes-this.liveBytes)}get outputBytesUsed(){return this.outputBytes}constructor(e,t=void 0){this.limits=e,this.signal=t}fail(e){throw this.poisoned??=e,this.poisoned}poisonAfterAbort(e){this.poisoned??=e}assertUsable(){if(this.poisoned)throw this.poisoned;if(this.closed)throw Error(`execution budget is already closed`);this.throwIfAborted()}chargeCommand(){return this.consume(`commands`,1,`execution`)}consumeWork(e=1,t=`execution`){return this.consume(`work`,e,t)}consumeLimited(e,t,n,r=e){this.assertUsable();let i=this.countersByKind.get(e)??0;return(!Number.isSafeInteger(t)||t<0||!Number.isSafeInteger(n)||n<0||t>n-i)&&this.fail(new A(`${r}: ${e} work limit exceeded (${n})`,`iterations`)),t>this.limits.maxWorkUnits-this.workUnits&&this.fail(new A(`${r}: aggregate work limit exceeded (${this.limits.maxWorkUnits})`,`iterations`)),this.countersByKind.set(e,i+t),this.workUnits+=t,i+t}consumeInput(e,t=`execution`){return this.assertUsable(),(!Number.isSafeInteger(e)||e<0||e>this.limits.maxInputBytes-this.inputBytes)&&this.fail(new A(`${t}: aggregate input size limit exceeded (${this.limits.maxInputBytes} bytes)`,`string_length`)),this.inputBytes+=e,this.inputBytes}consume(e,t=1,n=e){this.assertUsable();let r=this.countersByKind.get(e)??0,i=e===`commands`?this.commandCount:this.workUnits,a=e===`commands`?this.limits.maxCommandCount:this.limits.maxWorkUnits;(!Number.isSafeInteger(t)||t<0||t>a-i)&&this.fail(new A(e===`commands`?`too many commands executed (>${a}), increase executionLimits.maxCommandCount`:`${n}: ${e} work limit exceeded (${a})`,e===`commands`?`commands`:`iterations`));let o=i+t;return e===`commands`?this.commandCount=o:this.workUnits=o,this.countersByKind.set(e,r+t),o}reserveBytes(e,t,n){this.assertUsable();let r=typeof e==`string`?e:`live`,i=typeof e==`string`?t:e,a=typeof e==`string`?n??r:t??`execution`;(!Number.isSafeInteger(i)||i<0||i>this.limits.maxLiveBytes-this.liveBytes)&&this.fail(new A(`${a}: live byte limit exceeded (${this.limits.maxLiveBytes} bytes)`,`string_length`)),this.liveBytes+=i,this.bytesByKind.set(r,(this.bytesByKind.get(r)??0)+i);let o=!1;return{release:()=>{if(o)return;o=!0,this.liveBytes-=i;let e=(this.bytesByKind.get(r)??i)-i;e<=0?this.bytesByKind.delete(r):this.bytesByKind.set(r,e)}}}appendOutput(e,t,n=`execution`,r=0,i=`text`){this.assertUsable();let a=i===`bytes`?t.length:O(t);(!Number.isSafeInteger(r)||r<0||r>a)&&this.fail(new A(`${n}: invalid ${e} accounting`,`output_size`));let o=a-r;return o>this.limits.maxOutputSize-this.outputBytes&&this.fail(new A(`${n}: total output size exceeded (>${this.limits.maxOutputSize} bytes), increase executionLimits.maxOutputSize`,`output_size`)),this.outputBytes+=o,a}accountResult(e,t=`execution`,n=1/0){let r=e.internalOutputAccounting,i=Math.min(r?.stdout??0,n),a=Math.min(r?.stderr??0,Math.max(0,n-i)),o=this.appendOutput(`stdout`,e.stdout,t,i,e.stdoutKind===`bytes`||e.stdoutEncoding===`binary`?`bytes`:`text`),s=this.appendOutput(`stderr`,e.stderr,t,a);return Object.isExtensible(e)?(e.internalOutputAccounting={stdout:o,stderr:s},e):o===0&&s===0?e:{...e,internalOutputAccounting:{stdout:o,stderr:s}}}relinquishOutput(e,t,n){this.assertUsable(),n!==BE&&this.fail(new A(`${t}: unauthorized output accounting release`,`output_size`)),(!Number.isSafeInteger(e)||e<0||e>this.outputBytes)&&this.fail(new A(`${t}: invalid output accounting release`,`output_size`)),this.outputBytes-=e}enterDepth(e,t=this.limits.maxCallDepth,n){this.assertUsable();let r=typeof t==`number`?t:this.limits.maxCallDepth,i=typeof t==`string`?t:n??e,a=this.depthByKind.get(e)??0;a>=r&&this.fail(new A(`${i}: maximum depth (${r}) exceeded`,`recursion`)),this.depthByKind.set(e,a+1);let o=!1;return{release:()=>{if(o)return;o=!0;let t=(this.depthByKind.get(e)??1)-1;t<=0?this.depthByKind.delete(e):this.depthByKind.set(e,t)}}}throwIfAborted(e=`execution`){this.signal?.aborted&&this.fail(new jr(``,`bash: ${e} aborted
|
|
832
|
+
`:``,exitCode:n}}}}});ir(),or(),zr(),Yn();var _E=[{name:`echo`,load:async()=>(await Promise.resolve().then(()=>(Wr(),Br))).echoCommand},{name:`cat`,load:async()=>(await Promise.resolve().then(()=>(ci(),ei))).catCommand},{name:`printf`,load:async()=>(await Promise.resolve().then(()=>(zi(),xi))).printfCommand},{name:`ls`,load:async()=>(await Promise.resolve().then(()=>(wa(),fa))).lsCommand},{name:`mkdir`,load:async()=>(await Promise.resolve().then(()=>(ka(),Ta))).mkdirCommand},{name:`rmdir`,load:async()=>(await Promise.resolve().then(()=>(Ra(),Aa))).rmdirCommand},{name:`touch`,load:async()=>(await Promise.resolve().then(()=>(Ua(),za))).touchCommand},{name:`rm`,load:async()=>(await Promise.resolve().then(()=>(Ja(),Wa))).rmCommand},{name:`cp`,load:async()=>(await Promise.resolve().then(()=>(eo(),Ya))).cpCommand},{name:`mv`,load:async()=>(await Promise.resolve().then(()=>(oo(),to))).mvCommand},{name:`ln`,load:async()=>(await Promise.resolve().then(()=>(fo(),so))).lnCommand},{name:`chmod`,load:async()=>(await Promise.resolve().then(()=>(yo(),po))).chmodCommand},{name:`pwd`,load:async()=>(await Promise.resolve().then(()=>(Co(),bo))).pwdCommand},{name:`readlink`,load:async()=>(await Promise.resolve().then(()=>(Oo(),wo))).readlinkCommand},{name:`head`,load:async()=>(await Promise.resolve().then(()=>(Ro(),Po))).headCommand},{name:`tail`,load:async()=>(await Promise.resolve().then(()=>(Uo(),zo))).tailCommand},{name:`wc`,load:async()=>(await Promise.resolve().then(()=>(Zo(),Wo))).wcCommand},{name:`stat`,load:async()=>(await Promise.resolve().then(()=>(as(),es))).statCommand},{name:`grep`,load:async()=>(await Promise.resolve().then(()=>(fl(),Kc))).grepCommand},{name:`fgrep`,load:async()=>(await Promise.resolve().then(()=>(fl(),Kc))).fgrepCommand},{name:`egrep`,load:async()=>(await Promise.resolve().then(()=>(fl(),Kc))).egrepCommand},{name:`rg`,load:async()=>(await Promise.resolve().then(()=>(xu(),_u))).rgCommand},{name:`sed`,load:async()=>(await Promise.resolve().then(()=>(id(),$u))).sedCommand},{name:`awk`,load:async()=>(await Promise.resolve().then(()=>(zp(),Mp))).awkCommand2},{name:`sort`,load:async()=>(await Promise.resolve().then(()=>(rm(),$p))).sortCommand},{name:`uniq`,load:async()=>(await Promise.resolve().then(()=>(lm(),im))).uniqCommand},{name:`comm`,load:async()=>(await Promise.resolve().then(()=>(mm(),um))).commCommand},{name:`cut`,load:async()=>(await Promise.resolve().then(()=>(xm(),hm))).cutCommand},{name:`paste`,load:async()=>(await Promise.resolve().then(()=>(Om(),Sm))).pasteCommand},{name:`tr`,load:async()=>(await Promise.resolve().then(()=>(Im(),km))).trCommand},{name:`rev`,load:async()=>(await Promise.resolve().then(()=>(Hm(),Lm))).rev},{name:`nl`,load:async()=>(await Promise.resolve().then(()=>(Xm(),Um))).nl},{name:`fold`,load:async()=>(await Promise.resolve().then(()=>(ih(),Zm))).fold},{name:`expand`,load:async()=>(await Promise.resolve().then(()=>(ph(),ah))).expand},{name:`unexpand`,load:async()=>(await Promise.resolve().then(()=>(Sh(),mh))).unexpand},{name:`strings`,load:async()=>(await Promise.resolve().then(()=>(Ah(),Ch))).strings},{name:`split`,load:async()=>(await Promise.resolve().then(()=>(Jh(),jh))).split},{name:`column`,load:async()=>(await Promise.resolve().then(()=>(ig(),Yh))).column},{name:`join`,load:async()=>(await Promise.resolve().then(()=>(pg(),ag))).join},{name:`tee`,load:async()=>(await Promise.resolve().then(()=>(yg(),mg))).teeCommand},{name:`find`,load:async()=>(await Promise.resolve().then(()=>(Jg(),Lg))).findCommand},{name:`basename`,load:async()=>(await Promise.resolve().then(()=>($g(),Yg))).basenameCommand},{name:`dirname`,load:async()=>(await Promise.resolve().then(()=>(i_(),e_))).dirnameCommand},{name:`tree`,load:async()=>(await Promise.resolve().then(()=>(f_(),a_))).treeCommand},{name:`du`,load:async()=>(await Promise.resolve().then(()=>(b_(),p_))).duCommand},{name:`env`,load:async()=>(await Promise.resolve().then(()=>(O_(),x_))).envCommand},{name:`printenv`,load:async()=>(await Promise.resolve().then(()=>(O_(),x_))).printenvCommand},{name:`alias`,load:async()=>(await Promise.resolve().then(()=>(I_(),k_))).aliasCommand},{name:`unalias`,load:async()=>(await Promise.resolve().then(()=>(I_(),k_))).unaliasCommand},{name:`history`,load:async()=>(await Promise.resolve().then(()=>(H_(),L_))).historyCommand},{name:`xargs`,load:async()=>(await Promise.resolve().then(()=>(Y_(),U_))).xargsCommand},{name:`true`,load:async()=>(await Promise.resolve().then(()=>(tv(),X_))).trueCommand},{name:`false`,load:async()=>(await Promise.resolve().then(()=>(tv(),X_))).falseCommand},{name:`clear`,load:async()=>(await Promise.resolve().then(()=>(ov(),nv))).clearCommand},{name:`bash`,load:async()=>(await Promise.resolve().then(()=>(mv(),sv))).bashCommand},{name:`sh`,load:async()=>(await Promise.resolve().then(()=>(mv(),sv))).shCommand},{name:`jq`,load:async()=>(await Promise.resolve().then(()=>(lb(),eb))).jqCommand},{name:`base64`,load:async()=>(await Promise.resolve().then(()=>(yb(),ub))).base64Command},{name:`diff`,load:async()=>(await Promise.resolve().then(()=>(Tb(),bb))).diffCommand},{name:`date`,load:async()=>(await Promise.resolve().then(()=>(Pb(),Eb))).dateCommand},{name:`sleep`,load:async()=>(await Promise.resolve().then(()=>(Hb(),Lb))).sleepCommand},{name:`timeout`,load:async()=>(await Promise.resolve().then(()=>(qb(),Ub))).timeoutCommand},{name:`time`,load:async()=>(await Promise.resolve().then(()=>(nx(),Qb))).timeCommand},{name:`seq`,load:async()=>(await Promise.resolve().then(()=>(ox(),rx))).seqCommand},{name:`expr`,load:async()=>(await Promise.resolve().then(()=>(dx(),sx))).exprCommand},{name:`md5sum`,load:async()=>(await Promise.resolve().then(()=>(bx(),_x))).md5sumCommand},{name:`sha1sum`,load:async()=>(await Promise.resolve().then(()=>(wx(),xx))).sha1sumCommand},{name:`sha256sum`,load:async()=>(await Promise.resolve().then(()=>(Ox(),Tx))).sha256sumCommand},{name:`file`,load:async()=>(await Promise.resolve().then(()=>(Ew(),gw))).fileCommand},{name:`html-to-markdown`,load:async()=>(await Promise.resolve().then(()=>(jw(),Dw))).htmlToMarkdownCommand},{name:`help`,load:async()=>(await Promise.resolve().then(()=>(Lw(),Mw))).helpCommand},{name:`which`,load:async()=>(await Promise.resolve().then(()=>(Uw(),Rw))).whichCommand},{name:`tac`,load:async()=>(await Promise.resolve().then(()=>(Jw(),Ww))).tac},{name:`hostname`,load:async()=>(await Promise.resolve().then(()=>($w(),Yw))).hostname},{name:`whoami`,load:async()=>(await Promise.resolve().then(()=>(iT(),eT))).whoami},{name:`od`,load:async()=>(await Promise.resolve().then(()=>(lT(),aT))).od},{name:`gzip`,load:async()=>(await Promise.resolve().then(()=>(zT(),fT))).gzipCommand},{name:`gunzip`,load:async()=>(await Promise.resolve().then(()=>(zT(),fT))).gunzipCommand},{name:`zcat`,load:async()=>(await Promise.resolve().then(()=>(zT(),fT))).zcatCommand}],vE=[],yE=[],bE=[{name:`curl`,load:async()=>(await Promise.resolve().then(()=>(gE(),sE))).curlCommand}],xE=new Map;function SE(e){return{name:e.name,async execute(t,n){let r=xE.get(e.name);return r||(r=await Jn.runTrustedAsync(()=>e.load()),xE.set(e.name,r)),n.coverage,r.execute(t,n)}}}function CE(){return _E.map(e=>e.name)}function wE(){return bE.map(e=>e.name)}function TE(e){return(e?_E.filter(t=>e.includes(t.name)):_E).map(SE)}function EE(){return bE.map(SE)}function DE(){return vE.map(SE)}function OE(){return yE.map(SE)}k();var kE=new WeakMap,AE=new WeakSet;function jE(e){let t=kE.get(e);return t===void 0&&(t=Object.freeze(Object.create(null)),kE.set(e,t),AE.add(t)),t}function ME(e){return AE.has(e)}var NE={maxParserTokens:1e5,maxParseIterations:1e6,maxSourceBytes:67108864,maxExecDepth:64,maxCallDepth:100,maxCommandCount:1e5,maxLoopIterations:1e5,maxAwkIterations:1e5,maxSedIterations:1e5,maxJqIterations:1e7,maxQueryTokens:1e5,maxQueryDepth:1e3,maxQueryElements:1e6,maxAwkParserTokens:1e5,maxAwkParserDepth:256,maxAwkParserOperations:1e6,maxCsvRows:1e6,maxCsvCells:1e7,maxWorkUnits:1e8,maxTraversalEntries:1e6,maxTraversalDepth:1e3,maxTraversalWork:1e6,maxLiveBytes:536870912,maxInputBytes:536870912,maxFileSystemBytes:1073741824,maxDatabaseBytes:1073741824,maxDatabaseResultBytes:268435456,maxArchiveBytes:1073741824,maxArchiveCompressedBytes:536870912,maxArchiveEntryBytes:536870912,maxArchiveEntries:1e6,maxWorkerMessageBytes:67108864,maxExecutionTimeMs:36e5,maxExtensionCleanupTimeMs:100,maxSqliteTimeoutMs:3e4,maxPythonTimeoutMs:3e4,maxJsTimeoutMs:3e4,maxGlobOperations:1e6,maxStringLength:67108864,maxArrayElements:1e6,maxHeredocSize:67108864,maxSubstitutionDepth:50,maxBraceExpansionResults:1e5,maxOutputSize:268435456,maxFileDescriptors:4096,maxSourceDepth:100},PE={...NE,maxParserTokens:1e5,maxParseIterations:1e6,maxSourceBytes:8388608,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3,maxPythonTimeoutMs:1e4,maxJsTimeoutMs:1e4,maxExtensionCleanupTimeMs:25,maxGlobOperations:1e5,maxStringLength:10485760,maxArrayElements:1e5,maxHeredocSize:10485760,maxBraceExpansionResults:1e4,maxOutputSize:10485760,maxFileDescriptors:1024,maxQueryTokens:25e3,maxQueryDepth:256,maxQueryElements:1e5,maxAwkParserTokens:25e3,maxAwkParserDepth:128,maxAwkParserOperations:1e5,maxCsvRows:1e5,maxCsvCells:1e6,maxWorkUnits:1e5,maxTraversalEntries:1e5,maxTraversalDepth:256,maxTraversalWork:1e5,maxLiveBytes:67108864,maxInputBytes:33554432,maxFileSystemBytes:134217728,maxDatabaseBytes:67108864,maxDatabaseResultBytes:16777216,maxArchiveBytes:134217728,maxArchiveCompressedBytes:67108864,maxArchiveEntryBytes:67108864,maxArchiveEntries:1e5,maxWorkerMessageBytes:16777216,maxExecutionTimeMs:3e4};function FE(e,t=`normal`){if(t!==`normal`&&t!==`hardened`)throw RangeError(`executionLimitProfile must be "normal" or "hardened"`);let n=t===`hardened`?PE:NE;if(!e)return{...n};let r={maxParserTokens:e.maxParserTokens??n.maxParserTokens,maxParseIterations:e.maxParseIterations??n.maxParseIterations,maxSourceBytes:e.maxSourceBytes??n.maxSourceBytes,maxExecDepth:e.maxExecDepth??n.maxExecDepth,maxCallDepth:e.maxCallDepth??n.maxCallDepth,maxCommandCount:e.maxCommandCount??n.maxCommandCount,maxLoopIterations:e.maxLoopIterations??n.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??n.maxAwkIterations,maxSedIterations:e.maxSedIterations??n.maxSedIterations,maxJqIterations:e.maxJqIterations??n.maxJqIterations,maxQueryTokens:e.maxQueryTokens??n.maxQueryTokens,maxQueryDepth:e.maxQueryDepth??n.maxQueryDepth,maxQueryElements:e.maxQueryElements??n.maxQueryElements,maxAwkParserTokens:e.maxAwkParserTokens??n.maxAwkParserTokens,maxAwkParserDepth:e.maxAwkParserDepth??n.maxAwkParserDepth,maxAwkParserOperations:e.maxAwkParserOperations??n.maxAwkParserOperations,maxCsvRows:e.maxCsvRows??n.maxCsvRows,maxCsvCells:e.maxCsvCells??n.maxCsvCells,maxWorkUnits:e.maxWorkUnits??n.maxWorkUnits,maxTraversalEntries:e.maxTraversalEntries??n.maxTraversalEntries,maxTraversalDepth:e.maxTraversalDepth??n.maxTraversalDepth,maxTraversalWork:e.maxTraversalWork??n.maxTraversalWork,maxLiveBytes:e.maxLiveBytes??n.maxLiveBytes,maxInputBytes:e.maxInputBytes??n.maxInputBytes,maxFileSystemBytes:e.maxFileSystemBytes??n.maxFileSystemBytes,maxDatabaseBytes:e.maxDatabaseBytes??n.maxDatabaseBytes,maxDatabaseResultBytes:e.maxDatabaseResultBytes??n.maxDatabaseResultBytes,maxArchiveBytes:e.maxArchiveBytes??n.maxArchiveBytes,maxArchiveCompressedBytes:e.maxArchiveCompressedBytes??n.maxArchiveCompressedBytes,maxArchiveEntryBytes:e.maxArchiveEntryBytes??n.maxArchiveEntryBytes,maxArchiveEntries:e.maxArchiveEntries??n.maxArchiveEntries,maxWorkerMessageBytes:e.maxWorkerMessageBytes??n.maxWorkerMessageBytes,maxExecutionTimeMs:e.maxExecutionTimeMs??n.maxExecutionTimeMs,maxExtensionCleanupTimeMs:e.maxExtensionCleanupTimeMs??n.maxExtensionCleanupTimeMs,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??n.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??n.maxPythonTimeoutMs,maxJsTimeoutMs:e.maxJsTimeoutMs??n.maxJsTimeoutMs,maxGlobOperations:e.maxGlobOperations??n.maxGlobOperations,maxStringLength:e.maxStringLength??n.maxStringLength,maxArrayElements:e.maxArrayElements??n.maxArrayElements,maxHeredocSize:e.maxHeredocSize??n.maxHeredocSize,maxSubstitutionDepth:e.maxSubstitutionDepth??n.maxSubstitutionDepth,maxBraceExpansionResults:e.maxBraceExpansionResults??n.maxBraceExpansionResults,maxOutputSize:e.maxOutputSize??n.maxOutputSize,maxFileDescriptors:e.maxFileDescriptors??n.maxFileDescriptors,maxSourceDepth:e.maxSourceDepth??n.maxSourceDepth};for(let e of Object.keys(r)){let t=r[e];if(t!==1/0&&(!Number.isSafeInteger(t)||t<0))throw RangeError(`${e} must be a non-negative safe integer or positive Infinity`)}return r}function IE(e){let{executionLimits:t,executionLimitProfile:n,fs:r,stdin:i=vr,...a}=e;return{fs:r,fsIdentity:a.fsIdentity??jE(r),cwd:`/`,env:new Map,stdin:i,limits:FE(t,n),...a}}function LE(e){return`load`in e&&typeof e.load==`function`}function RE(e,t,n={}){return{name:e,trusted:n.trusted!==!1,execute:t}}function zE(e){let t=null,n=null;return{name:e.name,trusted:e.trusted!==!1,async execute(r,i){if(!t){let r=n;r||(r=e.load().then(e=>(t=e,e)),n=r);try{t=await r}catch(e){throw n===r&&(n=null),e}}let a=t;if(!a)throw Error(`Failed to load command: ${e.name}`);return a.execute(r,i)}}}k(),k(),j(),ir();var BE=Object.freeze(Object.create(null)),VE=class{limits;signal;commandCount=0;workUnits=0;liveBytes=0;inputBytes=0;outputBytes=0;countersByKind=new Map;bytesByKind=new Map;depthByKind=new Map;cleanupCallbacks=[];poisoned;closed=!1;startedAt=Date.now();get remainingLiveBytes(){return Math.max(0,this.limits.maxLiveBytes-this.liveBytes)}get outputBytesUsed(){return this.outputBytes}constructor(e,t=void 0){this.limits=e,this.signal=t}fail(e){throw this.poisoned??=e,this.poisoned}poisonAfterAbort(e){this.poisoned??=e}assertUsable(){if(this.poisoned)throw this.poisoned;if(this.closed)throw Error(`execution budget is already closed`);this.throwIfAborted()}chargeCommand(){return this.consume(`commands`,1,`execution`)}consumeWork(e=1,t=`execution`){return this.consume(`work`,e,t)}consumeLimited(e,t,n,r=e){this.assertUsable();let i=this.countersByKind.get(e)??0;return(!Number.isSafeInteger(t)||t<0||!Number.isSafeInteger(n)||n<0||t>n-i)&&this.fail(new A(`${r}: ${e} work limit exceeded (${n})`,`iterations`)),t>this.limits.maxWorkUnits-this.workUnits&&this.fail(new A(`${r}: aggregate work limit exceeded (${this.limits.maxWorkUnits})`,`iterations`)),this.countersByKind.set(e,i+t),this.workUnits+=t,i+t}consumeInput(e,t=`execution`){return this.assertUsable(),(!Number.isSafeInteger(e)||e<0||e>this.limits.maxInputBytes-this.inputBytes)&&this.fail(new A(`${t}: aggregate input size limit exceeded (${this.limits.maxInputBytes} bytes)`,`string_length`)),this.inputBytes+=e,this.inputBytes}consume(e,t=1,n=e){this.assertUsable();let r=this.countersByKind.get(e)??0,i=e===`commands`?this.commandCount:this.workUnits,a=e===`commands`?this.limits.maxCommandCount:this.limits.maxWorkUnits;(!Number.isSafeInteger(t)||t<0||t>a-i)&&this.fail(new A(e===`commands`?`too many commands executed (>${a}), increase executionLimits.maxCommandCount`:`${n}: ${e} work limit exceeded (${a})`,e===`commands`?`commands`:`iterations`));let o=i+t;return e===`commands`?this.commandCount=o:this.workUnits=o,this.countersByKind.set(e,r+t),o}reserveBytes(e,t,n){this.assertUsable();let r=typeof e==`string`?e:`live`,i=typeof e==`string`?t:e,a=typeof e==`string`?n??r:t??`execution`;(!Number.isSafeInteger(i)||i<0||i>this.limits.maxLiveBytes-this.liveBytes)&&this.fail(new A(`${a}: live byte limit exceeded (${this.limits.maxLiveBytes} bytes)`,`string_length`)),this.liveBytes+=i,this.bytesByKind.set(r,(this.bytesByKind.get(r)??0)+i);let o=!1;return{release:()=>{if(o)return;o=!0,this.liveBytes-=i;let e=(this.bytesByKind.get(r)??i)-i;e<=0?this.bytesByKind.delete(r):this.bytesByKind.set(r,e)}}}appendOutput(e,t,n=`execution`,r=0,i=`text`){this.assertUsable();let a=i===`bytes`?t.length:O(t);(!Number.isSafeInteger(r)||r<0||r>a)&&this.fail(new A(`${n}: invalid ${e} accounting`,`output_size`));let o=a-r;return o>this.limits.maxOutputSize-this.outputBytes&&this.fail(new A(`${n}: total output size exceeded (>${this.limits.maxOutputSize} bytes), increase executionLimits.maxOutputSize`,`output_size`)),this.outputBytes+=o,a}accountResult(e,t=`execution`,n=1/0){let r=e.internalOutputAccounting,i=Math.min(r?.stdout??0,n),a=Math.min(r?.stderr??0,Math.max(0,n-i)),o=this.appendOutput(`stdout`,e.stdout,t,i,e.stdoutKind===`bytes`||e.stdoutEncoding===`binary`?`bytes`:`text`),s=this.appendOutput(`stderr`,e.stderr,t,a);return Object.isExtensible(e)?(e.internalOutputAccounting={stdout:o,stderr:s},e):o===0&&s===0?e:{...e,internalOutputAccounting:{stdout:o,stderr:s}}}relinquishOutput(e,t,n){this.assertUsable(),n!==BE&&this.fail(new A(`${t}: unauthorized output accounting release`,`output_size`)),(!Number.isSafeInteger(e)||e<0||e>this.outputBytes)&&this.fail(new A(`${t}: invalid output accounting release`,`output_size`)),this.outputBytes-=e}enterDepth(e,t=this.limits.maxCallDepth,n){this.assertUsable();let r=typeof t==`number`?t:this.limits.maxCallDepth,i=typeof t==`string`?t:n??e,a=this.depthByKind.get(e)??0;a>=r&&this.fail(new A(`${i}: maximum depth (${r}) exceeded`,`recursion`)),this.depthByKind.set(e,a+1);let o=!1;return{release:()=>{if(o)return;o=!0;let t=(this.depthByKind.get(e)??1)-1;t<=0?this.depthByKind.delete(e):this.depthByKind.set(e,t)}}}throwIfAborted(e=`execution`){this.signal?.aborted&&this.fail(new jr(``,`bash: ${e} aborted
|
|
834
833
|
`)),Date.now()-this.startedAt>this.limits.maxExecutionTimeMs&&this.fail(new jr(``,`bash: ${e} exceeded execution deadline (${this.limits.maxExecutionTimeMs}ms)
|
|
835
834
|
`))}remainingTimeMs(){return Math.max(0,this.limits.maxExecutionTimeMs-(Date.now()-this.startedAt))}registerCleanup(e){this.assertUsable(),this.cleanupCallbacks.push(e);let t=!0;return()=>{if(!t)return;t=!1;let n=this.cleanupCallbacks.indexOf(e);n>=0&&this.cleanupCallbacks.splice(n,1)}}async close(){if(this.closed)return;this.closed=!0;let e=[],t=Date.now()+this.limits.maxExtensionCleanupTimeMs;for(let n=this.cleanupCallbacks.length-1;n>=0;n--)try{let r=t-Date.now();if(r<=0){e.push(Error(`execution cleanup grace period exceeded`));break}let i,a=await Promise.race([Promise.resolve().then(this.cleanupCallbacks[n]).then(()=>({ok:!0}),e=>({ok:!1,error:e})),new Promise(e=>{i=Zn(()=>e({ok:!1,error:Error(`execution cleanup grace period exceeded`)}),r)})]);if(Qn(i),!a.ok&&(e.push(a.error),Date.now()>=t))break}catch(t){e.push(t)}if(this.cleanupCallbacks.length=0,this.depthByKind.clear(),this.bytesByKind.clear(),this.liveBytes=0,e.length>0)throw AggregateError(e,`execution cleanup failed`)}assertExecDepth(e){this.assertUsable(),e>this.limits.maxExecDepth&&this.fail(new A(`maximum nested execution depth (${this.limits.maxExecDepth}) exceeded`,`recursion`))}};function HE(e){let t=Object.create(null);return Object.defineProperties(t,{remainingLiveBytes:{enumerable:!0,get:()=>e.remainingLiveBytes},consumeWork:{enumerable:!0,value:e.consumeWork.bind(e)},consumeLimited:{enumerable:!0,value:e.consumeLimited.bind(e)},consumeInput:{enumerable:!0,value:e.consumeInput.bind(e)},reserveBytes:{enumerable:!0,value:e.reserveBytes.bind(e)},enterDepth:{enumerable:!0,value:e.enterDepth.bind(e)},throwIfAborted:{enumerable:!0,value:e.throwIfAborted.bind(e)},remainingTimeMs:{enumerable:!0,value:e.remainingTimeMs.bind(e)},registerCleanup:{enumerable:!0,value:e.registerCleanup.bind(e)}}),Object.freeze(t)}function UE(e,t,n=`pipeline`){e.relinquishOutput(t,n,BE)}k(),GT(),$i();var WE=new TextEncoder;function GE(e){return typeof e==`object`&&!!e&&!(e instanceof Uint8Array)&&`content`in e}var KE=class{data=new Map;entryIdentities=new WeakMap;nextEntryIdentity=1;maxTotalBytes;retainedBytes=0;contentReferences=new WeakMap;materializedContent(e){return e?.type===`file`&&`content`in e?e.content:null}storedByteLength(e){return e===null?0:e instanceof Uint8Array?e.byteLength:O(e)}wouldReleaseBytes(e){let t=this.materializedContent(e);return t===null?0:t instanceof Uint8Array?this.contentReferences.get(t)===1?t.byteLength:0:this.storedByteLength(t)}assertCanAllocate(e,t){let n=this.wouldReleaseBytes(this.data.get(e));if(!Number.isSafeInteger(t)||t<0||t>this.maxTotalBytes-this.retainedBytes+n)throw Error(`ENOSPC: in-memory filesystem byte limit exceeded (${this.maxTotalBytes} bytes)`)}setEntry(e,t){let n=this.data.get(e),r=this.materializedContent(n),i=this.materializedContent(t);if(r===i){this.data.set(e,t);return}let a=this.wouldReleaseBytes(n),o=i instanceof Uint8Array?this.contentReferences.has(i)?0:i.byteLength:this.storedByteLength(i);if(o>this.maxTotalBytes-this.retainedBytes+a)throw Error(`ENOSPC: in-memory filesystem byte limit exceeded (${this.maxTotalBytes} bytes)`);if(r instanceof Uint8Array){let e=this.contentReferences.get(r)??0;e<=1?this.contentReferences.delete(r):this.contentReferences.set(r,e-1)}i instanceof Uint8Array&&this.contentReferences.set(i,(this.contentReferences.get(i)??0)+1),this.retainedBytes+=o-a,this.data.set(e,t)}deleteEntry(e){let t=this.data.get(e);if(!t)return!1;let n=this.materializedContent(t),r=this.wouldReleaseBytes(t);if(n instanceof Uint8Array){let e=this.contentReferences.get(n)??0;e<=1?this.contentReferences.delete(n):this.contentReferences.set(n,e-1)}return this.retainedBytes-=r,this.data.delete(e)}contentByteLength(e,t){if(e instanceof Uint8Array)return e.byteLength;if(t===`hex`)return Math.floor(e.length/2);if(t===`base64`){let t=e.endsWith(`==`)?2:+!!e.endsWith(`=`);return Math.max(0,Math.floor(e.length*3/4)-t)}return t===`binary`||t===`latin1`?e.length:O(e)}identityFor(e){let t=this.entryIdentities.get(e);return t||(t=`memfs:${this.nextEntryIdentity++}`,this.entryIdentities.set(e,t)),t}constructor(e,t={}){if(this.maxTotalBytes=t.maxTotalBytes??1073741824,!Number.isSafeInteger(this.maxTotalBytes)||this.maxTotalBytes<0)throw Error(`InMemoryFs: invalid maxTotalBytes`);if(this.data.set(`/`,{type:`directory`,mode:493,mtime:new Date}),e)for(let[t,n]of Object.entries(e))typeof n==`function`?this.writeFileLazy(t,n):GE(n)?this.writeFileSync(t,n.content,void 0,{mode:n.mode,mtime:n.mtime}):this.writeFileSync(t,n)}ensureParentDirs(e){let t=Yi(e);t!==`/`&&(this.data.has(t)||(this.ensureParentDirs(t),this.data.set(t,{type:`directory`,mode:493,mtime:new Date})))}writeFileSync(e,t,n,r){Ji(e,`write`);let i=I(e);this.ensureParentDirs(i);let a=HT(n);this.assertCanAllocate(i,this.contentByteLength(t,a));let o=BT(t,a);this.setEntry(i,{type:`file`,content:o,mode:r?.mode??420,mtime:r?.mtime??new Date})}writeFileLazy(e,t,n){Ji(e,`write`);let r=I(e);this.ensureParentDirs(r),this.setEntry(r,{type:`file`,lazy:t,mode:n?.mode??420,mtime:n?.mtime??new Date})}async materializeLazy(e,t){let n=await t.lazy(),r=typeof n==`string`?WE.encode(n):n,i={type:`file`,content:r,mode:t.mode,mtime:t.mtime};return this.assertCanAllocate(e,r.byteLength),this.setEntry(e,i),i}async readFile(e,t){return VT(await this.readFileBuffer(e),HT(t))}async readFileBytes(e){return VT(await this.readFileBuffer(e),`binary`)}async readFileBuffer(e){Ji(e,`open`);let t=this.resolvePathWithSymlinks(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, open '${e}'`);if(n.type!==`file`)throw Error(`EISDIR: illegal operation on a directory, read '${e}'`);if(`lazy`in n){let e=await this.materializeLazy(t,n);return e.content instanceof Uint8Array?e.content:WE.encode(e.content)}return n.content instanceof Uint8Array?n.content:WE.encode(n.content)}async writeFile(e,t,n){this.writeFileSync(e,t,n)}async appendFile(e,t,n){Ji(e,`append`);let r=I(e),i=this.data.get(r);if(i&&i.type===`directory`)throw Error(`EISDIR: illegal operation on a directory, write '${e}'`);let a=HT(n),o=this.contentByteLength(t,a);if(i?.type===`file`){let e=i;`lazy`in e&&(e=await this.materializeLazy(r,e));let n=`content`in e&&e.content instanceof Uint8Array?e.content:WE.encode(`content`in e?e.content:``);this.assertCanAllocate(r,n.byteLength+o);let s=BT(t,a),c=new Uint8Array(n.length+s.length);c.set(n),c.set(s,n.length),this.setEntry(r,{type:`file`,content:c,mode:e.mode,mtime:new Date})}else this.writeFileSync(e,t,n)}async exists(e){if(e.includes(`\0`))return!1;try{let t=this.resolvePathWithSymlinks(e);return this.data.has(t)}catch{return!1}}async stat(e){Ji(e,`stat`);let t=this.resolvePathWithSymlinks(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, stat '${e}'`);n.type===`file`&&`lazy`in n&&(n=await this.materializeLazy(t,n));let r=0;return n.type===`file`&&`content`in n&&n.content&&(r=n.content instanceof Uint8Array?n.content.length:WE.encode(n.content).length),{isFile:n.type===`file`,isDirectory:n.type===`directory`,isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date,identity:this.identityFor(n)}}async lstat(e){Ji(e,`lstat`);let t=this.resolveIntermediateSymlinks(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, lstat '${e}'`);if(n.type===`symlink`)return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:n.mode,size:n.target.length,mtime:n.mtime||new Date};n.type===`file`&&`lazy`in n&&(n=await this.materializeLazy(t,n));let r=0;return n.type===`file`&&`content`in n&&n.content&&(r=n.content instanceof Uint8Array?n.content.length:WE.encode(n.content).length),{isFile:n.type===`file`,isDirectory:n.type===`directory`,isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date,identity:this.identityFor(n)}}resolveIntermediateSymlinks(e){let t=I(e);if(t===`/`)return`/`;let n=t.slice(1).split(`/`);if(n.length<=1)return t;let r=``,i=new Set;for(let t=0;t<n.length-1;t++){let a=n[t];r=`${r}/${a}`;let o=this.data.get(r),s=0;for(;o&&o.type===`symlink`&&s<40;){if(i.has(r))throw Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`);i.add(r),r=Qi(r,o.target),o=this.data.get(r),s++}if(s>=40)throw Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`)}return`${r}/${n[n.length-1]}`}resolvePathWithSymlinks(e){let t=I(e);if(t===`/`)return`/`;let n=t.slice(1).split(`/`),r=``,i=new Set;for(let t of n){r=`${r}/${t}`;let n=this.data.get(r),a=0;for(;n&&n.type===`symlink`&&a<40;){if(i.has(r))throw Error(`ELOOP: too many levels of symbolic links, open '${e}'`);i.add(r),r=Qi(r,n.target),n=this.data.get(r),a++}if(a>=40)throw Error(`ELOOP: too many levels of symbolic links, open '${e}'`)}return r}async mkdir(e,t){this.mkdirSync(e,t)}mkdirSync(e,t){Ji(e,`mkdir`);let n=I(e);if(this.data.has(n)){if(this.data.get(n)?.type===`file`)throw Error(`EEXIST: file already exists, mkdir '${e}'`);if(!t?.recursive)throw Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let r=Yi(n);if(r!==`/`&&!this.data.has(r)){if(t?.recursive)this.mkdirSync(r,{recursive:!0});else throw Error(`ENOENT: no such file or directory, mkdir '${e}'`)}this.data.set(n,{type:`directory`,mode:493,mtime:new Date})}async readdir(e){return(await this.readdirWithFileTypes(e)).map(e=>e.name)}async readdirWithFileTypes(e){Ji(e,`scandir`);let t=I(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, scandir '${e}'`);let r=new Set;for(;n&&n.type===`symlink`;){if(r.has(t))throw Error(`ELOOP: too many levels of symbolic links, scandir '${e}'`);r.add(t),t=Qi(t,n.target),n=this.data.get(t)}if(!n)throw Error(`ENOENT: no such file or directory, scandir '${e}'`);if(n.type!==`directory`)throw Error(`ENOTDIR: not a directory, scandir '${e}'`);let i=t===`/`?`/`:`${t}/`,a=new Map;for(let[e,n]of this.data.entries())if(e!==t&&e.startsWith(i)){let t=e.slice(i.length),r=t.split(`/`)[0];r&&!t.includes(`/`,r.length)&&!a.has(r)&&a.set(r,{name:r,isFile:n.type===`file`,isDirectory:n.type===`directory`,isSymbolicLink:n.type===`symlink`})}return Array.from(a.values()).sort((e,t)=>e.name<t.name?-1:+(e.name>t.name))}async rm(e,t){Ji(e,`rm`);let n=I(e),r=this.data.get(n);if(!r){if(t?.force)return;throw Error(`ENOENT: no such file or directory, rm '${e}'`)}if(r.type===`directory`){let r=await this.readdir(n);if(r.length>0){if(!t?.recursive)throw Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let e of r){let r=Zi(n,e);await this.rm(r,t)}}}this.deleteEntry(n)}async cp(e,t,n){Ji(e,`cp`),Ji(t,`cp`);let r=I(e),i=I(t),a=this.data.get(r);if(!a)throw Error(`ENOENT: no such file or directory, cp '${e}'`);if(a.type===`file`){if(this.ensureParentDirs(i),`content`in a){let e=a.content instanceof Uint8Array?a.content.byteLength:WE.encode(a.content).byteLength;this.assertCanAllocate(i,e);let t=a.content instanceof Uint8Array?new Uint8Array(a.content):a.content;this.setEntry(i,{...a,content:t})}else this.setEntry(i,{...a})}else if(a.type===`symlink`)this.ensureParentDirs(i),this.data.set(i,{...a});else if(a.type===`directory`){if(!n?.recursive)throw Error(`EISDIR: is a directory, cp '${e}'`);if(qi(r,i))throw Error(`EINVAL: cannot copy '${e}' into itself, '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(r);for(let e of a){let t=Zi(r,e),a=Zi(i,e);await this.cp(t,a,n)}}}async mv(e,t){Ji(e,`mv`),Ji(t,`mv`);let n=I(e),r=I(t);if(n===r)return;let i=this.data.get(n);if(!i)throw Error(`ENOENT: no such file or directory, mv '${e}'`);if(i.type===`directory`&&qi(n,r))throw Error(`EINVAL: cannot move '${e}' into itself, '${t}'`);if(i.type===`directory`){await this.mkdir(r,{recursive:!0});let e=await this.readdir(n);for(let t of e)await this.mv(Zi(n,t),Zi(r,t));this.deleteEntry(n);return}this.ensureParentDirs(r),this.setEntry(r,i),this.deleteEntry(n)}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,t){return Xi(e,t)}async chmod(e,t){Ji(e,`chmod`);let n=I(e),r=this.data.get(n);if(!r)throw Error(`ENOENT: no such file or directory, chmod '${e}'`);r.mode=t}async symlink(e,t){Ji(t,`symlink`);let n=I(t);if(this.data.has(n))throw Error(`EEXIST: file already exists, symlink '${t}'`);this.ensureParentDirs(n),this.data.set(n,{type:`symlink`,target:e,mode:511,mtime:new Date})}async link(e,t){Ji(e,`link`),Ji(t,`link`);let n=I(e),r=I(t),i=this.data.get(n);if(!i)throw Error(`ENOENT: no such file or directory, link '${e}'`);if(i.type!==`file`)throw Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(r))throw Error(`EEXIST: file already exists, link '${t}'`);let a=i;`lazy`in a&&(a=await this.materializeLazy(n,a)),this.ensureParentDirs(r);let o={type:`file`,content:a.content,mode:a.mode,mtime:a.mtime};this.entryIdentities.set(o,this.identityFor(a)),this.setEntry(r,o)}async readlink(e){Ji(e,`readlink`);let t=I(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, readlink '${e}'`);if(n.type!==`symlink`)throw Error(`EINVAL: invalid argument, readlink '${e}'`);return n.target}async realpath(e){Ji(e,`realpath`);let t=this.resolvePathWithSymlinks(e);if(!this.data.has(t))throw Error(`ENOENT: no such file or directory, realpath '${e}'`);return t}async utimes(e,t,n){Ji(e,`utimes`);let r=I(e),i=this.resolvePathWithSymlinks(r),a=this.data.get(i);if(!a)throw Error(`ENOENT: no such file or directory, utimes '${e}'`);a.mtime=n}},qE=`5.1.0(1)-release`,JE=`Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT`;function YE(e){let{pid:t,ppid:n,uid:r,gid:i}=e;return`Name: bash
|
|
836
835
|
State: R (running)
|
|
@@ -862,7 +861,7 @@ Gid: ${i} ${i} ${i} ${i}
|
|
|
862
861
|
`||e===`;`||e===`&`||e===`|`||e===`(`||e===`)`||e===`<`||e===`>`||e===`'`||e===`"`||e===`\\`||e===`$`||e==="`"||e===`{`||e===`}`||e===`~`||e===`*`||e===`?`||e===`[`)break;a++}if(a>o){let s=r[a];if(!(s===`(`&&a>o&&`@*+?!`.includes(r[a-1]))&&(a>=i||s===` `||s===` `||s===`
|
|
863
862
|
`||s===`;`||s===`&`||s===`|`||s===`(`||s===`)`||s===`<`||s===`>`)){let i=r.slice(o,a);this.pos=a,this.column=n+(a-o);let s=FD.get(i);if(s!==void 0)return{type:s,value:i,start:e,end:a,line:t,column:n};let c=zD(i);return c>0&&RD(i.slice(0,c))?{type:Z.ASSIGNMENT_WORD,value:i,start:e,end:a,line:t,column:n}:/^[0-9]+$/.test(i)?{type:Z.NUMBER,value:i,start:e,end:a,line:t,column:n}:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)?{type:Z.NAME,value:i,start:e,end:a,line:t,column:n,quoted:!1,singleQuoted:!1}:{type:Z.WORD,value:i,start:e,end:a,line:t,column:n,quoted:!1,singleQuoted:!1}}}a=this.pos;let s=this.column,c=this.line,l=``,u=!1,d=!1,f=!1,p=!1,m=r[a]===`"`||r[a]===`'`,h=!1,g=0;for(;a<i;){let e=r[a];if(!f&&!p){if(e===`(`&&l.length>0&&`@*+?!`.includes(l[l.length-1])){let e=this.scanExtglobPattern(a);if(e!==null){l+=e.content,a=e.end,s+=e.content.length;continue}}if(e===`[`&&g===0){if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l)){let t=a+1<i?r[a+1]:``;if(t===`^`||t===`!`){l+=e,a++,s++;continue}g=1,l+=e,a++,s++;continue}}else if(e===`[`&&g>0){l.length>0&&l[l.length-1]!==`\\`&&g++,l+=e,a++,s++;continue}else if(e===`]`&&g>0){l.length>0&&l[l.length-1]!==`\\`&&g--,l+=e,a++,s++;continue}if(g>0){if(e===`
|
|
864
863
|
`)break;l+=e,a++,s++;continue}if(e===` `||e===` `||e===`
|
|
865
|
-
`||e===`;`||e===`&`||e===`|`||e===`(`||e===`)`||e===`<`||e===`>`)break}if(e===`$`&&a+1<i&&r[a+1]===`'`&&!f&&!p){for(l+=`$'`,a+=2,s+=2;a<i&&r[a]!==`'`;)r[a]===`\\`&&a+1<i?(l+=r[a]+r[a+1],a+=2,s+=2):(l+=r[a],a++,s++);a<i&&(l+=`'`,a++,s++);continue}if(e===`$`&&a+1<i&&r[a+1]===`"`&&!f&&!p){a++,s++,p=!0,u=!0,l===``&&(m=!0),a++,s++;continue}if(e===`'`&&!p){if(f){if(f=!1,!m||h)l+=e;else{let t=a+1<i?r[a+1]:``;t&&!WD(t)&&t!==`'`&&(t===`"`?(h=!0,l+=e,d=!1,u=!1):(h=!0,l+=e))}}else f=!0,m&&!h?(d=!0,u=!0):l+=e;a++,s++;continue}if(e===`"`&&!f){if(p){if(p=!1,!m||h)l+=e;else{let t=a+1<i?r[a+1]:``;t&&!WD(t)&&
|
|
864
|
+
`||e===`;`||e===`&`||e===`|`||e===`(`||e===`)`||e===`<`||e===`>`)break}if(e===`$`&&a+1<i&&r[a+1]===`'`&&!f&&!p){for(l+=`$'`,a+=2,s+=2;a<i&&r[a]!==`'`;)r[a]===`\\`&&a+1<i?(l+=r[a]+r[a+1],a+=2,s+=2):(l+=r[a],a++,s++);a<i&&(l+=`'`,a++,s++);continue}if(e===`$`&&a+1<i&&r[a+1]===`"`&&!f&&!p){a++,s++,p=!0,u=!0,l===``&&(m=!0),a++,s++;continue}if(e===`'`&&!p){if(f){if(f=!1,!m||h)l+=e;else{let t=a+1<i?r[a+1]:``;t&&!WD(t)&&t!==`'`&&(t===`"`?(h=!0,l+=e,d=!1,u=!1):(h=!0,l+=e))}}else f=!0,m&&!h?(d=!0,u=!0):l+=e;a++,s++;continue}if(e===`"`&&!f){if(p){if(p=!1,!m||h)l+=e;else{let t=a+1<i?r[a+1]:``;t&&!WD(t)&&(t===`'`||t===`"`?(h=!0,l+=e,d=!1,u=!1):(h=!0,l+=e))}}else p=!0,m&&!h?u=!0:l+=e;a++,s++;continue}if(e===`\\`&&!f&&a+1<i){let t=r[a+1];if(t===`
|
|
866
865
|
`){a+=2,c++,s=1;continue}if(p){if(t===`"`||t===`\\`||t===`$`||t==="`"||t===`
|
|
867
866
|
`){if(t===`
|
|
868
867
|
`){a+=2,s=1,c++;continue}l+=e+t,a+=2,s+=2;continue}}else{l+=e+t,a+=2,s+=2;continue}}if(e===`$`&&a+1<i&&r[a+1]===`(`&&!f){l+=e,a++,s++,l+=r[a],a++,s++;let t=1,n=!1,o=!1,u=0,d=!1,f=``,p=[],m=r[a]===`(`&&!this.dollarDparenIsSubshell(a),h=+!!m;for(;t>0&&a<i;){let e=r[a];if(l+=e,n)e===`'`&&(n=!1);else if(o)e===`\\`&&a+1<i?(l+=r[a+1],a++,s++):e===`"`&&(o=!1);else{if(e===`(`&&r[a+1]===`(`?h++:e===`)`&&r[a+1]===`)`&&h>0&&h--,h===0&&e===`<`&&r[a+1]===`<`&&r[a+2]!==`<`){let e=a+2,t=!1;for(r[e]===`-`&&(t=!0,e++);r[e]===` `||r[e]===` `;)e++;let{delim:n,endPos:i,unclosedQuote:o,unclosedSubstitution:u}=DD(r,e);if(o)throw new PD(`unexpected EOF while looking for matching \`${o}'`,c,s);if(u)throw new PD("unexpected EOF while looking for matching `)'",c,s);if(n.length>0){l+=r.slice(a+1,i),s+=i-a,p.push({delim:n,stripTabs:t}),a=i;continue}}if(e===`
|
|
@@ -892,7 +891,7 @@ Gid: ${i} ${i} ${i} ${i}
|
|
|
892
891
|
`&&(s=!0),r++;continue}if(e===`'`){a=!0,r++;continue}if(e===`"`){o=!0,r++;continue}if(e===`\\`){r+=2;continue}if(e===`
|
|
893
892
|
`&&(s=!0),e===`(`){i++,r++;continue}if(e===`)`){if(i--,i===1){let e=r+1;if(e<n&&t[e]===`)`)return!1;let i=e,a=!1;for(;i<n&&(t[i]===` `||t[i]===` `||t[i]===`
|
|
894
893
|
`);)a=!0,i++;if(a&&i<n&&t[i]===`)`||s)return!0}if(i===0)return!1;r++;continue}r++}return!1}dparenClosesWithSpacedParens(e){let t=this.input,n=t.length,r=e,i=2,a=!1,o=!1;for(;r<n&&i>0;){let e=t[r];if(a){e===`'`&&(a=!1),r++;continue}if(o){if(e===`\\`){r+=2;continue}e===`"`&&(o=!1),r++;continue}if(e===`'`){a=!0,r++;continue}if(e===`"`){o=!0,r++;continue}if(e===`\\`){r+=2;continue}if(e===`(`){i++,r++;continue}if(e===`)`){if(i--,i===1){let e=r+1;if(e<n&&t[e]===`)`)return!1;let i=e,a=!1;for(;i<n&&(t[i]===` `||t[i]===` `||t[i]===`
|
|
895
|
-
`);)a=!0,i++;if(a&&i<n&&t[i]===`)`)return!0}if(i===0)return!1;r++;continue}if(i===1&&(e===`|`&&r+1<n&&t[r+1]===`|`||e===`&`&&r+1<n&&t[r+1]===`&`||e===`|`&&r+1<n&&t[r+1]!==`|`))return!0;r++}return!1}},KD=1e6,qD=1e5,JD=1e6,YD=200,XD;(function(e){e[e.Default=0]=`Default`,e[e.Assignment=1]=`Assignment`,e[e.NoBraceExpansion=2]=`NoBraceExpansion`,e[e.Regex=4]=`Regex`})(XD||={});var ZD=new Set([Z.LESS,Z.GREAT,Z.DLESS,Z.DGREAT,Z.LESSAND,Z.GREATAND,Z.LESSGREAT,Z.DLESSDASH,Z.CLOBBER,Z.TLESS,Z.AND_GREAT,Z.AND_DGREAT]),QD=new Set([Z.LESS,Z.GREAT,Z.DLESS,Z.DGREAT,Z.LESSAND,Z.GREATAND,Z.LESSGREAT,Z.DLESSDASH,Z.CLOBBER,Z.TLESS]),$D=new Set([Z.LESS,Z.GREAT,Z.DLESS,Z.DGREAT,Z.LESSAND,Z.GREATAND,Z.LESSGREAT,Z.DLESSDASH,Z.CLOBBER,Z.TLESS,Z.AND_GREAT,Z.AND_DGREAT]),eO=class extends Error{line;column;token;constructor(e,t,n,r=void 0){super(`Parse error at ${t}:${n}: ${e}`),this.line=t,this.column=n,this.token=r,this.name=`ParseException`}},tO=class{iterations=0;tokens=0;depth=0;reset(){this.iterations=0,this.tokens=0,this.depth=0}chargeIteration(e,t){if(this.iterations++,this.iterations>JD)throw new eO(`Maximum parse iterations exceeded (possible infinite loop)`,e,t)}chargeTokens(e,t=1,n=1){if(this.tokens+=e,this.tokens>qD)throw new eO(`Too many tokens: cumulative count exceeds limit of ${qD}`,t,n)}enter(e,t){if(this.depth++,this.depth>YD)throw this.depth--,new eO(`Maximum parser nesting depth exceeded (${YD})`,e,t);let n=!0;return()=>{n&&(n=!1,this.depth--)}}};Yn(),zr(),j();function nO(e,t){for(;t<e.length;){if(e[t]===`\\`&&e[t+1]===`
|
|
894
|
+
`);)a=!0,i++;if(a&&i<n&&t[i]===`)`)return!0}if(i===0)return!1;r++;continue}if(i===1&&(e===`|`&&r+1<n&&t[r+1]===`|`||e===`&`&&r+1<n&&t[r+1]===`&`||e===`|`&&r+1<n&&t[r+1]!==`|`))return!0;r++}return!1}},KD=1e6,qD=1e5,JD=1e6,YD=200,XD;(function(e){e[e.Default=0]=`Default`,e[e.Assignment=1]=`Assignment`,e[e.NoBraceExpansion=2]=`NoBraceExpansion`,e[e.Regex=4]=`Regex`})(XD||={});var ZD=new Set([Z.LESS,Z.GREAT,Z.DLESS,Z.DGREAT,Z.LESSAND,Z.GREATAND,Z.LESSGREAT,Z.DLESSDASH,Z.CLOBBER,Z.TLESS,Z.AND_GREAT,Z.AND_DGREAT]),QD=new Set([Z.LESS,Z.GREAT,Z.DLESS,Z.DGREAT,Z.LESSAND,Z.GREATAND,Z.LESSGREAT,Z.DLESSDASH,Z.CLOBBER,Z.TLESS]),$D=new Set([Z.LESS,Z.GREAT,Z.DLESS,Z.DGREAT,Z.LESSAND,Z.GREATAND,Z.LESSGREAT,Z.DLESSDASH,Z.CLOBBER,Z.TLESS,Z.AND_GREAT,Z.AND_DGREAT]),eO=class extends Error{line;column;token;constructor(e,t,n,r=void 0){super(`Parse error at ${t}:${n}: ${e}`),this.line=t,this.column=n,this.token=r,this.name=`ParseException`}},tO=class{iterations=0;tokens=0;depth=0;reset(){this.iterations=0,this.tokens=0,this.depth=0}chargeIteration(e,t){if(this.iterations++,this.iterations>(this.maxIterations??JD))throw new eO(`Maximum parse iterations exceeded (possible infinite loop)`,e,t)}chargeTokens(e,t=1,n=1){if(this.tokens+=e,this.tokens>(this.maxTokens??qD))throw new eO(`Too many tokens: cumulative count exceeds limit of ${this.maxTokens??qD}`,t,n)}enter(e,t){if(this.depth++,this.depth>YD)throw this.depth--,new eO(`Maximum parser nesting depth exceeded (${YD})`,e,t);let n=!0;return()=>{n&&(n=!1,this.depth--)}}};Yn(),zr(),j();function nO(e,t){for(;t<e.length;){if(e[t]===`\\`&&e[t+1]===`
|
|
896
895
|
`){t+=2;continue}if(/\s/.test(e[t])){t++;continue}break}return t}var rO=[`=`,`+=`,`-=`,`*=`,`/=`,`%=`,`<<=`,`>>=`,`&=`,`|=`,`^=`];function iO(e){if(e.includes(`#`)){let t=e.split(`#`);if(t.length!==2)return NaN;let[n,r]=t;if(!/^\d+$/.test(n)||r.length===0)return NaN;let i=Number.parseInt(n,10);if(i<2||i>64)return NaN;let a=0;for(let e of r){let t;if(/[0-9]/.test(e))t=e.charCodeAt(0)-48;else if(/[a-z]/.test(e))t=e.charCodeAt(0)-97+10;else if(/[A-Z]/.test(e))t=e.charCodeAt(0)-65+(i<=36?10:36);else if(e===`@`)t=62;else if(e===`_`)t=63;else return NaN;if(t>=i)return NaN;if(a=a*i+t,a>2**53-1)return 2**53-1}return a}if(e.startsWith(`0x`)||e.startsWith(`0X`)){let t=Number.parseInt(e.slice(2),16);return t>2**53-1?2**53-1:t}if(e.startsWith(`0`)&&e.length>1&&/^[0-9]+$/.test(e)){if(/[89]/.test(e))return NaN;let t=Number.parseInt(e,8);return t>2**53-1?2**53-1:t}let t=Number.parseInt(e,10);return t>2**53-1?2**53-1:t}function aO(e,t,n,r){if(n.slice(r,r+3)!==`$((`)return null;let i=r+3,a=1,o=i;for(;i<n.length-1&&a>0;)n[i]===`(`&&n[i+1]===`(`?(a++,i+=2):n[i]===`)`&&n[i+1]===`)`?(a--,a>0&&(i+=2)):i++;let{expr:s}=e(t,n.slice(o,i),0);return i+=2,{expr:{type:`ArithNested`,expression:s},pos:i}}function oO(e,t){if(e.slice(t,t+2)!==`$'`)return null;let n=t+2,r=``;for(;n<e.length&&e[n]!==`'`;)if(e[n]===`\\`&&n+1<e.length){let t=e[n+1];switch(t){case`n`:r+=`
|
|
897
896
|
`;break;case`t`:r+=` `;break;case`r`:r+=`\r`;break;case`\\`:r+=`\\`;break;case`'`:r+=`'`;break;default:r+=t}n+=2}else r+=e[n],n++;e[n]===`'`&&n++;let i=Number.parseInt(r,10);return{expr:{type:`ArithNumber`,value:Number.isNaN(i)?0:i},pos:n}}function sO(e,t){if(e.slice(t,t+2)!==`$"`)return null;let n=t+2,r=``;for(;n<e.length&&e[n]!==`"`;)e[n]===`\\`&&n+1<e.length?(r+=e[n+1],n+=2):(r+=e[n],n++);e[n]===`"`&&n++;let i=Number.parseInt(r,10);return{expr:{type:`ArithNumber`,value:Number.isNaN(i)?0:i},pos:n}}function cO(e){let t=``,n=0;for(;n<e.length;)if(e[n]===`"`){for(n++;n<e.length&&e[n]!==`"`;)e[n]===`\\`&&n+1<e.length?(t+=e[n+1],n+=2):(t+=e[n],n++);n<e.length&&n++}else t+=e[n],n++;return t}function lO(e,t){let n=cO(t),{expr:r,pos:i}=fO(e,n,0),a=nO(n,i);if(a<n.length){let e=t.slice(a).trim();if(e)return{type:`ArithmeticExpression`,originalText:t,expression:{type:`ArithSyntaxError`,errorToken:e,message:`${e}: syntax error: invalid arithmetic operator (error token is "${e}")`}}}return{type:`ArithmeticExpression`,expression:r,originalText:t}}function uO(e,t){return{expr:{type:`ArithSyntaxError`,errorToken:e,message:`syntax error: operand expected (error token is "${e}")`},pos:t}}function dO(e,t){return nO(e,t)>=e.length}function fO(e,t,n){return mO(e,t,n)}function pO(e,t,n){return e.withDepth(()=>fO(e,t,n))}function mO(e,t,n){let{expr:r,pos:i}=hO(e,t,n);for(i=nO(t,i);t[i]===`,`;){if(i++,dO(t,i))return uO(`,`,i);let{expr:n,pos:a}=hO(e,t,i);r={type:`ArithBinary`,operator:`,`,left:r,right:n},i=nO(t,a)}return{expr:r,pos:i}}function hO(e,t,n){let{expr:r,pos:i}=gO(e,t,n);if(i=nO(t,i),t[i]===`?`){i++;let{expr:n,pos:a}=pO(e,t,i);if(i=nO(t,a),t[i]===`:`){i++;let{expr:a,pos:o}=pO(e,t,i);return{expr:{type:`ArithTernary`,condition:r,consequent:n,alternate:a},pos:o}}}return{expr:r,pos:i}}function gO(e,t,n){let{expr:r,pos:i}=_O(e,t,n);for(;i=nO(t,i),t.slice(i,i+2)===`||`;){if(i+=2,dO(t,i))return uO(`||`,i);let{expr:n,pos:a}=_O(e,t,i);r={type:`ArithBinary`,operator:`||`,left:r,right:n},i=a}return{expr:r,pos:i}}function _O(e,t,n){let{expr:r,pos:i}=vO(e,t,n);for(;i=nO(t,i),t.slice(i,i+2)===`&&`;){if(i+=2,dO(t,i))return uO(`&&`,i);let{expr:n,pos:a}=vO(e,t,i);r={type:`ArithBinary`,operator:`&&`,left:r,right:n},i=a}return{expr:r,pos:i}}function vO(e,t,n){let{expr:r,pos:i}=yO(e,t,n);for(;i=nO(t,i),t[i]===`|`&&t[i+1]!==`|`;){if(i++,dO(t,i))return uO(`|`,i);let{expr:n,pos:a}=yO(e,t,i);r={type:`ArithBinary`,operator:`|`,left:r,right:n},i=a}return{expr:r,pos:i}}function yO(e,t,n){let{expr:r,pos:i}=bO(e,t,n);for(;i=nO(t,i),t[i]===`^`;){if(i++,dO(t,i))return uO(`^`,i);let{expr:n,pos:a}=bO(e,t,i);r={type:`ArithBinary`,operator:`^`,left:r,right:n},i=a}return{expr:r,pos:i}}function bO(e,t,n){let{expr:r,pos:i}=xO(e,t,n);for(;i=nO(t,i),t[i]===`&`&&t[i+1]!==`&`;){if(i++,dO(t,i))return uO(`&`,i);let{expr:n,pos:a}=xO(e,t,i);r={type:`ArithBinary`,operator:`&`,left:r,right:n},i=a}return{expr:r,pos:i}}function xO(e,t,n){let{expr:r,pos:i}=SO(e,t,n);for(;i=nO(t,i),t.slice(i,i+2)===`==`||t.slice(i,i+2)===`!=`;){let n=t.slice(i,i+2);if(i+=2,dO(t,i))return uO(n,i);let{expr:a,pos:o}=SO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function SO(e,t,n){let{expr:r,pos:i}=CO(e,t,n);for(;;)if(i=nO(t,i),t.slice(i,i+2)===`<=`||t.slice(i,i+2)===`>=`){let n=t.slice(i,i+2);if(i+=2,dO(t,i))return uO(n,i);let{expr:a,pos:o}=CO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else if(t[i]===`<`||t[i]===`>`){let n=t[i];if(i++,dO(t,i))return uO(n,i);let{expr:a,pos:o}=CO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else break;return{expr:r,pos:i}}function CO(e,t,n){let{expr:r,pos:i}=wO(e,t,n);for(;i=nO(t,i),t.slice(i,i+2)===`<<`||t.slice(i,i+2)===`>>`;){let n=t.slice(i,i+2);if(i+=2,dO(t,i))return uO(n,i);let{expr:a,pos:o}=wO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function wO(e,t,n){let{expr:r,pos:i}=TO(e,t,n);for(;i=nO(t,i),(t[i]===`+`||t[i]===`-`)&&t[i+1]!==t[i];){let n=t[i];if(i++,dO(t,i))return uO(n,i);let{expr:a,pos:o}=TO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function TO(e,t,n){let{expr:r,pos:i}=EO(e,t,n);for(;;)if(i=nO(t,i),t[i]===`*`&&t[i+1]!==`*`){if(i++,dO(t,i))return uO(`*`,i);let{expr:n,pos:a}=EO(e,t,i);r={type:`ArithBinary`,operator:`*`,left:r,right:n},i=a}else if(t[i]===`/`||t[i]===`%`){let n=t[i];if(i++,dO(t,i))return uO(n,i);let{expr:a,pos:o}=EO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else break;return{expr:r,pos:i}}function EO(e,t,n){let{expr:r,pos:i}=DO(e,t,n),a=nO(t,i);if(t.slice(a,a+2)===`**`){if(a+=2,dO(t,a))return uO(`**`,a);let{expr:n,pos:i}=e.withDepth(()=>EO(e,t,a));return{expr:{type:`ArithBinary`,operator:`**`,left:r,right:n},pos:i}}return{expr:r,pos:i}}function DO(e,t,n){let r=nO(t,n);if(t.slice(r,r+2)===`++`||t.slice(r,r+2)===`--`){let n=t.slice(r,r+2);r+=2;let{expr:i,pos:a}=e.withDepth(()=>DO(e,t,r));return{expr:{type:`ArithUnary`,operator:n,operand:i,prefix:!0},pos:a}}if(t[r]===`+`||t[r]===`-`||t[r]===`!`||t[r]===`~`){let n=t[r];r++;let{expr:i,pos:a}=e.withDepth(()=>DO(e,t,r));return{expr:{type:`ArithUnary`,operator:n,operand:i,prefix:!0},pos:a}}return kO(e,t,r)}function OO(e,t){let n=e[t];return n===`$`||n==="`"}function kO(e,t,n){let{expr:r,pos:i}=AO(e,t,n,!1),a=[r];for(;OO(t,i);){let{expr:n,pos:r}=AO(e,t,i,!0);a.push(n),i=r}a.length>1&&(r={type:`ArithConcat`,parts:a});let o;if(t[i]===`[`&&r.type===`ArithConcat`){i++;let{expr:n,pos:r}=pO(e,t,i);o=n,i=r,t[i]===`]`&&i++}if(o&&r.type===`ArithConcat`&&(r={type:`ArithDynamicElement`,nameExpr:r,subscript:o},o=void 0),i=nO(t,i),r.type===`ArithConcat`||r.type===`ArithVariable`||r.type===`ArithDynamicElement`){for(let n of rO)if(t.slice(i,i+n.length)===n&&t.slice(i,i+n.length+1)!==`==`){i+=n.length;let{expr:a,pos:o}=e.withDepth(()=>hO(e,t,i));return r.type===`ArithDynamicElement`?{expr:{type:`ArithDynamicAssignment`,operator:n,target:r.nameExpr,subscript:r.subscript,value:a},pos:o}:r.type===`ArithConcat`?{expr:{type:`ArithDynamicAssignment`,operator:n,target:r,value:a},pos:o}:{expr:{type:`ArithAssignment`,operator:n,variable:r.name,value:a},pos:o}}}if(t.slice(i,i+2)===`++`||t.slice(i,i+2)===`--`){let e=t.slice(i,i+2);return i+=2,{expr:{type:`ArithUnary`,operator:e,operand:r,prefix:!1},pos:i}}return{expr:r,pos:i}}function AO(e,t,n,r=!1){let i=nO(t,n),a=aO(pO,e,t,i);if(a)return a;let o=oO(t,i);if(o)return o;let s=sO(t,i);if(s)return s;if(t.slice(i,i+2)===`$(`&&t[i+2]!==`(`){i+=2;let e=1,n=i;for(;i<t.length&&e>0;)t[i]===`(`?e++:t[i]===`)`&&e--,e>0&&i++;let r=t.slice(n,i);return i++,{expr:{type:`ArithCommandSubst`,command:r},pos:i}}if(t[i]==="`"){i++;let e=i;for(;i<t.length&&t[i]!=="`";)i++;let n=t.slice(e,i);return t[i]==="`"&&i++,{expr:{type:`ArithCommandSubst`,command:n},pos:i}}if(t[i]===`(`){i++;let{expr:n,pos:r}=pO(e,t,i);return i=nO(t,r),t[i]===`)`&&i++,{expr:{type:`ArithGroup`,expression:n},pos:i}}if(t[i]===`'`){i++;let e=``;for(;i<t.length&&t[i]!==`'`;)e+=t[i],i++;t[i]===`'`&&i++;let n=Number.parseInt(e,10);return{expr:{type:`ArithSingleQuote`,content:e,value:Number.isNaN(n)?0:n},pos:i}}if(t[i]===`"`){i++;let n=``;for(;i<t.length&&t[i]!==`"`;)t[i]===`\\`&&i+1<t.length?(n+=t[i+1],i+=2):(n+=t[i],i++);t[i]===`"`&&i++;let r=n.trim();if(!r)return{expr:{type:`ArithNumber`,value:0},pos:i};let{expr:a}=pO(e,r,0);return{expr:a,pos:i}}if(/[0-9]/.test(t[i])){let e=``,n=!1,r=!1;for(;i<t.length;){let a=t[i];if(n){if(/[0-9a-zA-Z@_]/.test(a))e+=a,i++;else break}else if(a===`#`)n=!0,e+=a,i++;else if(e===`0`&&(a===`x`||a===`X`)&&i+1<t.length&&/[0-9a-fA-F]/.test(t[i+1]))r=!0,e+=a,i++;else if(r&&/[0-9a-fA-F]/.test(a))e+=a,i++;else if(!r&&/[0-9]/.test(a))e+=a,i++;else break}if(i<t.length&&/[a-zA-Z_]/.test(t[i])){let n=e;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)n+=t[i],i++;return{expr:{type:`ArithSyntaxError`,errorToken:n,message:`${n}: value too great for base (error token is "${n}")`},pos:i}}if(t[i]===`.`&&/[0-9]/.test(t[i+1]))throw new Dr(`${e}.${t[i+1]}...: syntax error: invalid arithmetic operator`);if(t[i]===`[`){let n=t.slice(i).trim();return{expr:{type:`ArithNumberSubscript`,number:e,errorToken:n},pos:t.length}}return{expr:{type:`ArithNumber`,value:iO(e)},pos:i}}if(t[i]===`$`&&t[i+1]===`{`){let e=i+2,n=1,r=e;for(;r<t.length&&n>0;)t[r]===`{`?n++:t[r]===`}`&&n--,n>0&&r++;let a=t.slice(e,r),o=r+1;if(t[o]===`#`){let e=o+1;for(;e<t.length&&/[0-9a-zA-Z@_]/.test(t[e]);)e++;return{expr:{type:`ArithDynamicBase`,baseExpr:a,value:t.slice(o+1,e)},pos:e}}if(/[0-9]/.test(t[o])||t[o]===`x`||t[o]===`X`){let e=o;if(t[o]===`x`||t[o]===`X`)for(e++;e<t.length&&/[0-9a-fA-F]/.test(t[e]);)e++;else for(;e<t.length&&/[0-9]/.test(t[e]);)e++;return{expr:{type:`ArithDynamicNumber`,prefix:a,suffix:t.slice(o,e)},pos:e}}return i=o,{expr:{type:`ArithBracedExpansion`,content:a},pos:i}}if(t[i]===`$`&&i+1<t.length&&/[0-9]/.test(t[i+1])){i++;let e=``;for(;i<t.length&&/[0-9]/.test(t[i]);)e+=t[i],i++;return{expr:{type:`ArithVariable`,name:e,hasDollarPrefix:!0},pos:i}}if(t[i]===`$`&&i+1<t.length&&/[*@#?\-!$]/.test(t[i+1])){let e=t[i+1];return i+=2,{expr:{type:`ArithSpecialVar`,name:e},pos:i}}let c=!1;if(t[i]===`$`&&i+1<t.length&&/[a-zA-Z_]/.test(t[i+1])&&(c=!0,i++),i<t.length&&/[a-zA-Z_]/.test(t[i])){let n=``;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)n+=t[i],i++;if(t[i]===`[`&&!r){i++;let a;if(t[i]===`'`||t[i]===`"`){let e=t[i];for(i++,a=``;i<t.length&&t[i]!==e;)a+=t[i],i++;t[i]===e&&i++,i=nO(t,i),t[i]===`]`&&i++}let o;if(a===void 0){let{expr:n,pos:r}=pO(e,t,i);o=n,i=r,t[i]===`]`&&i++}if(i=nO(t,i),t[i]===`[`&&o)return{expr:{type:`ArithDoubleSubscript`,array:n,index:o},pos:i};if(!r){for(let r of rO)if(t.slice(i,i+r.length)===r&&t.slice(i,i+r.length+1)!==`==`){i+=r.length;let{expr:s,pos:c}=e.withDepth(()=>hO(e,t,i));return{expr:{type:`ArithAssignment`,operator:r,variable:n,subscript:o,stringKey:a,value:s},pos:c}}}return{expr:{type:`ArithArrayElement`,array:n,index:o,stringKey:a},pos:i}}if(i=nO(t,i),!r){for(let r of rO)if(t.slice(i,i+r.length)===r&&t.slice(i,i+r.length+1)!==`==`){i+=r.length;let{expr:a,pos:o}=e.withDepth(()=>hO(e,t,i));return{expr:{type:`ArithAssignment`,operator:r,variable:n,value:a},pos:o}}}return{expr:{type:`ArithVariable`,name:n,hasDollarPrefix:c},pos:i}}if(t[i]===`#`){let e=i+1;for(;e<t.length&&t[e]!==`
|
|
898
897
|
`;)e++;let n=t.slice(i,e).trim()||`#`;return{expr:{type:`ArithSyntaxError`,errorToken:n,message:`${n}: syntax error: invalid arithmetic operator (error token is "${n}")`},pos:t.length}}return{expr:{type:`ArithNumber`,value:0},pos:i}}var jO=e=>{let t,n=``;for(let r=0;r<e.length;r++){let i=e[r];if(i===`\\`&&t===`"`&&r+1<e.length){n+=i+e[r+1],r+=1;continue}if(i===`'`||i===`"`){t===i?t=void 0:t||=i,n+=i;continue}if(i===`\\`&&!t&&r+1<e.length){let t=e[r+1];n+=t===`$`||t==="`"?`\\${t}`:t,r+=1;continue}n+=i}return n};function MO(e){let t=``,n=0;for(;n<e.length;){let r=e[n];if(r<128){t+=String.fromCharCode(r),n++;continue}if((r&224)==192){if(n+1<e.length&&(e[n+1]&192)==128&&r>=194){let i=(r&31)<<6|e[n+1]&63;t+=String.fromCharCode(i),n+=2;continue}t+=String.fromCharCode(r),n++;continue}if((r&240)==224){if(n+2<e.length&&(e[n+1]&192)==128&&(e[n+2]&192)==128){if(r===224&&e[n+1]<160){t+=String.fromCharCode(r),n++;continue}let i=(r&15)<<12|(e[n+1]&63)<<6|e[n+2]&63;if(i>=55296&&i<=57343){t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(i),n+=3;continue}t+=String.fromCharCode(r),n++;continue}if((r&248)==240&&r<=244){if(n+3<e.length&&(e[n+1]&192)==128&&(e[n+2]&192)==128&&(e[n+3]&192)==128){if(r===240&&e[n+1]<144){t+=String.fromCharCode(r),n++;continue}let i=(r&7)<<18|(e[n+1]&63)<<12|(e[n+2]&63)<<6|e[n+3]&63;if(i>1114111){t+=String.fromCharCode(r),n++;continue}t+=String.fromCodePoint(i),n+=4;continue}t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(r),n++}return t}function NO(e,t,n){let r=n+1;for(;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)r++;return r}function PO(e,t,n,r,i){let a=1,o=n+1;for(;o<t.length&&a>0;)t[o]===r?a++:t[o]===i&&a--,a>0&&o++;return a===0?o:-1}function FO(e,t,n){let r=n,i=1;for(;r<t.length&&i>0;){let e=t[r];if(e===`\\`&&r+1<t.length){r+=2;continue}if(e===`'`){let e=t.indexOf(`'`,r+1);if(e!==-1){r=e+1;continue}}if(e===`"`){for(r++;r<t.length&&t[r]!==`"`;)t[r]===`\\`&&r+1<t.length?r+=2:r++;r<t.length&&r++;continue}e===`{`?i++:e===`}`&&i--,i>0&&r++}return r}function IO(e,t,n){let r=n,i=!1;for(;r<t.length;){let e=t[r];if(e===`/`&&i||e===`}`)break;if(e===`'`){let e=t.indexOf(`'`,r+1);if(e!==-1){r=e+1,i=!0;continue}}if(e===`"`){for(r++;r<t.length&&t[r]!==`"`;)t[r]===`\\`&&r+1<t.length?r+=2:r++;r<t.length&&r++,i=!0;continue}e===`\\`?(r+=2,i=!0):(r++,i=!0)}return r}function LO(e,t,n){let r=n,i=``;for(;r<t.length;){let e=t[r];if(e===`*`||e===`?`)i+=e,r++;else if(e===`[`){let n=RO(t,r);n===-1?(i+=e,r++):(i+=t.slice(r,n+1),r=n+1)}else break}return{pattern:i,endIndex:r}}function RO(e,t){let n=t+1;for(n<e.length&&e[n]===`^`&&n++,n<e.length&&e[n]===`]`&&n++;n<e.length;){let t=e[n];if(t===`\\`&&n+1<e.length){let t=e[n+1];if(t===`"`||t===`'`)return-1;n+=2;continue}if(t===`]`)return n;if(t===`"`||t===`$`||t==="`")return-1;if(t===`'`){let t=e.indexOf(`'`,n+1);if(t!==-1){n=t+1;continue}}if(t===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){n=t+2;continue}}if(t===`[`&&n+1<e.length&&(e[n+1]===`.`||e[n+1]===`=`)){let t=`${e[n+1]}]`,r=e.indexOf(t,n+2);if(r!==-1){n=r+2;continue}}n++}return-1}function zO(e,t,n){let r=``,i=n;for(;i<t.length&&t[i]!==`'`;){let e=t[i];if(e===`\\`&&i+1<t.length)switch(t[i+1]){case`n`:r+=`
|
|
@@ -901,7 +900,7 @@ Gid: ${i} ${i} ${i} ${i}
|
|
|
901
900
|
`&&(m(),d.push(X.escaped(e))),f+=2;continue}let n=a?e===`$`||e==="`"||e===`
|
|
902
901
|
`:e===`$`||e==="`"||e===`"`||e===`'`||e===`
|
|
903
902
|
`||l&&e===`}`,r=o?`*?[]\\`.includes(e):`*?[]\\(){}.^+`.includes(e);n?e!==`
|
|
904
|
-
`&&(p+=e):r?(m(),d.push(X.escaped(e))):p+=`\\${e}`,f+=2;continue}if(n===`'`&&!o&&!a){m();let e=t.indexOf(`'`,f+1);if(e===-1){p+=t.slice(f);break}d.push(X.singleQuoted(t.slice(f+1,e))),f=e+1;continue}if(n===`"`&&!a){m();let{part:n,endIndex:r}=Tk(e,t,f+1);d.push(n),f=r+1;continue}if(n===`$`&&t[f+1]===`'`){m();let{part:n,endIndex:r}=zO(e,t,f+2);d.push(n),f=r;continue}if(n===`$`){m();let{part:n,endIndex:r}=Ck(e,t,f);n&&d.push(n),f=r;continue}if(n==="`"){m();let{part:n,endIndex:r}=e.parseBacktickSubstitution(t,f);d.push(n),f=r;continue}if((n===`<`||n===`>`)&&t[f+1]===`(`&&!a&&!o){m();let{part:n,endIndex:r}=e.parseProcessSubstitutionFromString(t,f);d.push(n),f=r;continue}if(n===`~`){let n=f>0?t[f-1]:``;if(f===0&&u||n===`=`||i&&n===`:`){let n=NO(e,t,f),r=t[n];if(r===void 0||r===`/`||r===`:`){m();let e=t.slice(f+1,n)||null;d.push({type:`TildeExpansion`,user:e}),f=n;continue}}}if(`@*+?!`.includes(n)&&f+1<t.length&&t[f+1]===`(`){let e=yk(t,f+1);if(e!==-1){m();let n=t.slice(f,e+1);d.push({type:`Glob`,pattern:n}),f=e+1;continue}}if(n===`*`||n===`?`||n===`[`){m();let{pattern:n,endIndex:r}=LO(e,t,f);d.push({type:`Glob`,pattern:c?_k(n):n}),f=r;continue}if(n===`{`&&!i&&!s&&!a){let n=HO(e,t,f,Ek);if(n){m(),d.push(n.part),f=n.endIndex;continue}}p+=n,f++}return m(),d}var Dk=class e{tokens=[];pos=0;pendingHeredocs=[];parseBudget;ownsParseBudget;_input=``;processLineState;constructor(e){this.parseBudget=e??new tO,this.ownsParseBudget=e===void 0}getInput(){return this._input}checkIterationLimit(){let e=this.current();this.parseBudget.chargeIteration(e?.line??1,e?.column??1)}enterDepth(){let e=this.current();return this.parseBudget.enter(e?.line??1,e?.column??1)}withDepth(e){let t=this.enterDepth();try{return e()}finally{t()}}parse(e,t){this.ownsParseBudget&&this.parseBudget.reset();let n=this.ownsParseBudget?void 0:this.enterDepth();try{if(e.length>KD)throw new eO(`Input too large: ${e.length} bytes exceeds limit of ${KD}`,1,1);this._input=e,this.processLineState=void 0;let n=new GD(e,t);if(this.tokens=n.tokenize(),this.tokens.length>qD)throw new eO(`Too many tokens: ${this.tokens.length} exceeds limit of ${qD}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseBudget.chargeTokens(this.tokens.length),this.parseScript()}finally{n?.()}}parseTokens(e){this.ownsParseBudget&&this.parseBudget.reset();let t=this.ownsParseBudget?void 0:this.enterDepth();try{return this.tokens=e,this.pos=0,this.pendingHeredocs=[],this.processLineState=void 0,this.parseBudget.chargeTokens(e.length),this.parseScript()}finally{t?.()}}current(){return this.tokens[this.pos]||this.tokens[this.tokens.length-1]}peek(e=0){return this.tokens[this.pos+e]||this.tokens[this.tokens.length-1]}advance(){let e=this.current();return this.pos<this.tokens.length-1&&this.pos++,e}getPos(){return this.pos}getSourceLine(e=this.current()){let t=this.processLineState;return t?(t.currentPhysicalLine===void 0?t.currentPhysicalLine=e.line:e.line>t.currentPhysicalLine&&(t.currentPhysicalLine=e.line,t.currentLogicalLine+=1),t.currentLogicalLine):e.line}check(e,t,n,r,...i){let a=this.tokens[this.pos]?.type;return a===e||t!==void 0&&a===t||n!==void 0&&a===n||r!==void 0&&a===r||i.length>0&&i.includes(a)}expect(e,t){if(this.check(e))return this.advance();let n=this.current();throw new eO(t||`Expected ${e}, got ${n.type}`,n.line,n.column,n)}error(e){let t=this.current();throw new eO(e,t.line,t.column,t)}skipNewlines(){for(;this.check(Z.NEWLINE,Z.COMMENT);)this.check(Z.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(e=!0){for(;;){if(this.check(Z.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(Z.SEMICOLON,Z.COMMENT)){this.advance();continue}if(e&&this.check(Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(e,t,n,r){this.pendingHeredocs.push({redirect:e,delimiter:t,stripTabs:n,quoted:r})}processHeredocs(){for(let e of this.pendingHeredocs)if(this.check(Z.HEREDOC_CONTENT)){let t=this.advance(),n;n=e.quoted?X.word([X.literal(t.value)]):this.parseWordFromString(t.value,!1,!1,!1,!0),e.redirect.target=X.hereDoc(e.delimiter,n,e.stripTabs,e.quoted,t.heredocTerminated??!1)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(Z.EOF,Z.NEWLINE,Z.SEMICOLON,Z.AMP,Z.AND_AND,Z.OR_OR,Z.RPAREN,Z.RBRACE,Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND)}isCommandStart(){let e=this.current().type;return this.isWord()||e===Z.ASSIGNMENT_WORD||e===Z.FD_VARIABLE||e===Z.LPAREN||e===Z.LBRACE||e===Z.DPAREN_START||e===Z.DBRACK_START||GO(this)}parseScript(){let e=[],t=0;for(this.skipNewlines();!this.check(Z.EOF);){t++,t>1e4&&this.error(`Parser stuck: too many iterations (>10000)`);let n=this.checkUnexpectedToken();if(n){e.push(n),this.skipSeparators(!1);continue}let r=this.pos,i=this.parseStatement();i&&e.push(i),this.check(Z.HEREDOC_CONTENT)&&this.processHeredocs(),this.skipSeparators(!1),this.check(Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===r&&!this.check(Z.EOF)&&this.error(`syntax error near unexpected token \`${this.current().value}'`)}return X.script(e)}checkUnexpectedToken(){let e=this.current().type,t=this.current().value;if(this.currentTokenJoinsProcessSubstitution())return null;if((e===Z.DO||e===Z.DONE||e===Z.THEN||e===Z.ELSE||e===Z.ELIF||e===Z.FI||e===Z.ESAC)&&this.error(`syntax error near unexpected token \`${t}'`),e===Z.RBRACE||e===Z.RPAREN){let e=`syntax error near unexpected token \`${t}'`;return this.advance(),X.statement([X.pipeline([X.simpleCommand(null,[],[],[])])],[],!1,{message:e,token:t})}return(e===Z.DSEMI||e===Z.SEMI_AND||e===Z.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${t}'`),e===Z.SEMICOLON&&this.error(`syntax error near unexpected token \`${t}'`),(e===Z.AMP||e===Z.AND_AND||e===Z.OR_OR||e===Z.PIPE||e===Z.PIPE_AMP)&&this.error(`syntax error near unexpected token \`${t}'`),null}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let e=this.current().start,t=[],n=[],r=!1,i=this.parsePipeline();for(t.push(i);this.check(Z.AND_AND,Z.OR_OR);){let e=this.advance();n.push(e.type===Z.AND_AND?`&&`:`||`),this.skipNewlines();let r=this.parsePipeline();t.push(r)}this.check(Z.AMP)&&(this.advance(),r=!0);let a=this.pos>0?this.tokens[this.pos-1].end:e,o=this._input.slice(e,a);return X.statement(t,n,r,void 0,o)}parseTimePrefix(){if(!this.check(Z.TIME)||this.currentTokenJoinsProcessSubstitution())return;this.advance();let e=!1;return this.check(Z.WORD,Z.NAME)&&this.current().value===`-p`&&(this.advance(),e=!0),e}parsePipeline(){let e=!1,t=!1,n=0;for(;this.check(Z.BANG)&&!this.currentTokenJoinsProcessSubstitution();)this.advance(),n++;if(n===0){let r=this.parseTimePrefix();if(r!==void 0)for(e=!0,t=r;this.check(Z.BANG)&&!this.currentTokenJoinsProcessSubstitution();)this.advance(),n++}let r=n%2==1,i=[],a=[],o=this.parseCommand();for(i.push(o);this.check(Z.PIPE,Z.PIPE_AMP);){let e=this.advance();this.skipNewlines(),a.push(e.type===Z.PIPE_AMP);let t=this.parseCommand();i.push(t)}return X.pipeline(i,r,e,t,a.length>0?a:void 0)}parseCommand(){if(this.currentTokenJoinsProcessSubstitution())return JO(this);let e=this.current();switch(e.type){case Z.IF:return QO(this);case Z.FOR:return $O(this);case Z.WHILE:return tk(this);case Z.UNTIL:return nk(this);case Z.CASE:return rk(this);case Z.LPAREN:return ak(this);case Z.LBRACE:return ok(this);case Z.DPAREN_START:return this.dparenClosesWithSpacedParens()?this.parseNestedSubshellsFromDparen():this.parseArithmeticCommand();case Z.DBRACK_START:return this.parseConditionalCommand();case Z.FUNCTION:return this.parseFunctionDef();case Z.TIME:break;case Z.BANG:this.error(`syntax error near unexpected token \`${e.value}'`);break;default:LD(e.type)&&this.error(`syntax error near unexpected token \`${e.value}'`)}return this.check(Z.NAME,Z.WORD)&&this.peek(1).type===Z.LPAREN&&this.peek(2).type===Z.RPAREN?this.parseFunctionDef():JO(this)}dparenClosesWithSpacedParens(){let e=1,t=1;for(;t<this.tokens.length-this.pos;){let n=this.peek(t);if(n.type===Z.EOF)return!1;if(n.type===Z.DPAREN_START||n.type===Z.LPAREN)e++;else if(n.type===Z.DPAREN_END){if(e-=2,e<=0)return!1}else if(n.type===Z.RPAREN&&(e--,e===0&&this.peek(t+1).type===Z.RPAREN))return!0;t++}return!1}parseNestedSubshellsFromDparen(){this.advance();let e=this.parseCompoundList();this.expect(Z.RPAREN),this.expect(Z.RPAREN);let t=this.parseOptionalRedirections(),n=X.subshell(e,[]);return X.subshell([X.statement([X.pipeline([n],!1,!1,!1)])],t)}isWord(){return this.isWordToken(XD.Default)||this.isProcessSubstitutionStart()||this.currentTokenJoinsProcessSubstitution()}isWordToken(e){let t=this.current().type;return t===Z.WORD||t===Z.NAME||t===Z.NUMBER||LD(t)||t===Z.BANG||t===Z.ASSIGNMENT_WORD&&(e&XD.Regex)!==0}isProcessSubstitutionStart(e=0){let t=this.peek(e),n=this.peek(e+1);return(t.type===Z.LESS||t.type===Z.GREAT)&&n.type===Z.LPAREN&&t.end===n.start}currentTokenJoinsProcessSubstitution(){return this.current().type===Z.COMMENT||!this.isAdjacentWordToken(XD.Default)?!1:this.current().end===this.peek(1).start&&this.isProcessSubstitutionStart(1)}isAdjacentWordToken(e){let t=this.current().type;return this.isWordToken(e)||t===Z.ASSIGNMENT_WORD||t===Z.COMMENT||t===Z.LBRACE||t===Z.RBRACE||t===Z.DBRACK_START||t===Z.DBRACK_END||t===Z.FD_VARIABLE}parseWord(e=XD.Default){if(this.isProcessSubstitutionStart())return this.parseAdjacentWordParts([],this.current().start,e);let t=this.advance(),n=this.parseWordToken(t,e);return this.parseAdjacentWordParts(n.parts,t.end,e)}parseAdjacentWordParts(e,t,n=XD.Default){for(;t===this.current().start;){if(this.isProcessSubstitutionStart()){e.push(this.parseProcessSubstitution()),t=this.tokens[this.pos-1].end;continue}if(!this.isAdjacentWordToken(n))break;let r=this.advance();e.push(...this.parseWordToken(r,n,e.length===0).parts),t=r.end}return X.word(e)}parseWordNoBraceExpansion(){return this.parseWord(XD.NoBraceExpansion)}parseWordForRegex(){return this.parseWord(XD.NoBraceExpansion|XD.Regex)}parseWordToken(e,t,n=!0){return e.type===Z.LBRACE||e.type===Z.RBRACE||e.type===Z.DBRACK_START||e.type===Z.DBRACK_END||e.type===Z.FD_VARIABLE?X.word([X.literal(e.type===Z.FD_VARIABLE?`{${e.value}}`:e.value)]):this.parseWordFromString(e.value,e.quoted,e.singleQuoted,(t&XD.Assignment)!==0,!1,(t&XD.NoBraceExpansion)!==0,(t&XD.Regex)!==0,n)}parseWordFromString(e,t=!1,n=!1,r=!1,i=!1,a=!1,o=!1,s=!0){let c=Ek(this,e,t,n,r,i,!1,a,o,!1,s);return X.word(c)}parseCommandSubstitution(t,n){return AD(t,n,()=>new e(this.parseBudget),e=>this.error(e))}parseProcessSubstitutionFromString(t,n){return jD(t,n,()=>new e(this.parseBudget),e=>this.error(e))}parseProcessSubstitution(){let e=this.advance();this.expect(Z.LPAREN);let t=this.processLineState,n=this.getSourceLine(e);this.processLineState={currentLogicalLine:n};let r;try{r=X.script(this.parseCompoundList())}finally{this.processLineState=t}return this.check(Z.EOF)&&this.error("unexpected EOF while looking for matching `)'"),this.expect(Z.RPAREN),X.processSubstitution(r,e.type===Z.LESS?`input`:`output`)}parseBacktickSubstitution(t,n,r=!1){return MD(t,n,r,()=>new e(this.parseBudget),e=>this.error(e))}isDollarDparenSubshell(e,t){return ED(e,t)}parseArithmeticExpansion(e,t){let n=t+3,r=1,i=0,a=n;for(;a<e.length-1&&r>0;)e[a]===`$`&&e[a+1]===`(`?e[a+2]===`(`?(r++,a+=3):(i++,a+=2):e[a]===`(`&&e[a+1]===`(`?(r++,a+=2):e[a]===`)`&&e[a+1]===`)`?i>0?(i--,a++):(r--,r>0&&(a+=2)):e[a]===`(`?(i++,a++):(e[a]===`)`&&i>0&&i--,a++);let o=e.slice(n,a),s=this.parseArithmeticExpression(o);return{part:X.arithmeticExpansion(s),endIndex:a+2}}parseArithmeticCommand(){let e=this.expect(Z.DPAREN_START),t=``,n=1,r=0,i=!1,a=!1;for(;n>0&&!this.check(Z.EOF);){if(i){if(i=!1,r>0){r--,t+=`)`;continue}if(this.check(Z.RPAREN)){n--,a=!0,this.advance();continue}if(this.check(Z.DPAREN_END)){n--,a=!0;continue}t+=`)`;continue}if(this.check(Z.DPAREN_START))n++,t+=`((`,this.advance();else if(this.check(Z.DPAREN_END))r>=2?(r-=2,t+=`))`,this.advance()):r===1?(r--,t+=`)`,i=!0,this.advance()):(n--,a=!0,n>0&&(t+=`))`),this.advance());else if(this.check(Z.LPAREN))r++,t+=`(`,this.advance();else if(this.check(Z.RPAREN))r>0&&r--,t+=`)`,this.advance();else{let e=this.current().value,n=t.length>0?t[t.length-1]:``;t.length>0&&!t.endsWith(` `)&&!(e===`=`&&/[|&^+\-*/%<>]$/.test(t))&&(e!==`<`||n!==`<`)&&(e!==`>`||n!==`>`)&&(t+=` `),t+=e,this.advance()}}a||this.expect(Z.DPAREN_END);let o=this.parseArithmeticExpression(t.trim()),s=this.parseOptionalRedirections();return X.arithmeticCommand(o,s,this.getSourceLine(e))}parseConditionalCommand(){let e=this.expect(Z.DBRACK_START),t=dk(this);this.expect(Z.DBRACK_END);let n=this.parseOptionalRedirections();return X.conditionalCommand(t,n,this.getSourceLine(e))}parseFunctionDef(){let e;if(this.check(Z.FUNCTION)){if(this.advance(),this.check(Z.NAME)||this.check(Z.WORD))e=this.advance().value;else{let e=this.current();throw new eO(`Expected function name`,e.line,e.column,e)}this.check(Z.LPAREN)&&(this.advance(),this.expect(Z.RPAREN))}else e=this.advance().value,e.includes(`$`)&&this.error(`\`${e}': not a valid identifier`),this.expect(Z.LPAREN),this.expect(Z.RPAREN);this.skipNewlines();let t=this.parseCompoundCommandBody({forFunctionBody:!0}),n=this.parseOptionalRedirections();return X.functionDef(e,t,n)}parseCompoundCommandBody(e){let t=e?.forFunctionBody;if(this.check(Z.LBRACE))return ok(this,{skipRedirections:t});if(this.check(Z.LPAREN))return ak(this,{skipRedirections:t});if(this.check(Z.IF))return QO(this,{skipRedirections:t});if(this.check(Z.FOR))return $O(this,{skipRedirections:t});if(this.check(Z.WHILE))return tk(this,{skipRedirections:t});if(this.check(Z.UNTIL))return nk(this,{skipRedirections:t});if(this.check(Z.CASE))return rk(this,{skipRedirections:t});this.error(`Expected compound command for function body`)}parseCompoundList(){let e=this.enterDepth();try{let e=[];for(this.skipNewlines();(this.currentTokenJoinsProcessSubstitution()||!this.check(Z.EOF,Z.FI,Z.ELSE,Z.ELIF,Z.THEN,Z.DO,Z.DONE,Z.ESAC,Z.RPAREN,Z.RBRACE,Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND))&&this.isCommandStart();){this.checkIterationLimit();let t=this.pos,n=this.parseStatement();if(n&&e.push(n),this.skipSeparators(),this.pos===t&&!n)break}return e}finally{e()}}parseOptionalRedirections(){let e=[];for(;GO(this);){this.checkIterationLimit();let t=this.pos;if(e.push(KO(this)),this.pos===t)break}return e}parseArithmeticExpression(e){return lO(this,e)}};function Ok(e,t){return new Dk().parse(e,t)}function kk(e){return Ak(e)}function Ak(e){return e.statements.map(jk).join(`
|
|
903
|
+
`&&(p+=e):r?(m(),d.push(X.escaped(e))):p+=`\\${e}`,f+=2;continue}if(n===`'`&&!o&&!a){m();let e=t.indexOf(`'`,f+1);if(e===-1){p+=t.slice(f);break}d.push(X.singleQuoted(t.slice(f+1,e))),f=e+1;continue}if(n===`"`&&!a){m();let{part:n,endIndex:r}=Tk(e,t,f+1);d.push(n),f=r+1;continue}if(n===`$`&&t[f+1]===`'`){m();let{part:n,endIndex:r}=zO(e,t,f+2);d.push(n),f=r;continue}if(n===`$`){m();let{part:n,endIndex:r}=Ck(e,t,f);n&&d.push(n),f=r;continue}if(n==="`"){m();let{part:n,endIndex:r}=e.parseBacktickSubstitution(t,f);d.push(n),f=r;continue}if((n===`<`||n===`>`)&&t[f+1]===`(`&&!a&&!o){m();let{part:n,endIndex:r}=e.parseProcessSubstitutionFromString(t,f);d.push(n),f=r;continue}if(n===`~`){let n=f>0?t[f-1]:``;if(f===0&&u||n===`=`||i&&n===`:`){let n=NO(e,t,f),r=t[n];if(r===void 0||r===`/`||r===`:`){m();let e=t.slice(f+1,n)||null;d.push({type:`TildeExpansion`,user:e}),f=n;continue}}}if(`@*+?!`.includes(n)&&f+1<t.length&&t[f+1]===`(`){let e=yk(t,f+1);if(e!==-1){m();let n=t.slice(f,e+1);d.push({type:`Glob`,pattern:n}),f=e+1;continue}}if(n===`*`||n===`?`||n===`[`){m();let{pattern:n,endIndex:r}=LO(e,t,f);d.push({type:`Glob`,pattern:c?_k(n):n}),f=r;continue}if(n===`{`&&!i&&!s&&!a){let n=HO(e,t,f,Ek);if(n){m(),d.push(n.part),f=n.endIndex;continue}}p+=n,f++}return m(),d}var Dk=class e{tokens=[];pos=0;pendingHeredocs=[];parseBudget;ownsParseBudget;_input=``;processLineState;constructor(e){this.parseBudget=e??new tO,this.ownsParseBudget=e===void 0}getInput(){return this._input}checkIterationLimit(){let e=this.current();this.parseBudget.chargeIteration(e?.line??1,e?.column??1)}enterDepth(){let e=this.current();return this.parseBudget.enter(e?.line??1,e?.column??1)}withDepth(e){let t=this.enterDepth();try{return e()}finally{t()}}parse(e,t){this.ownsParseBudget&&(this.parseBudget.reset(),this.parseBudget.maxTokens=t?.maxParserTokens,this.parseBudget.maxIterations=t?.maxParseIterations);let n=this.ownsParseBudget?void 0:this.enterDepth();try{if(e.length>(t?.maxInputSize??KD))throw new eO(`Input too large: ${e.length} bytes exceeds limit of ${t?.maxInputSize??KD}`,1,1);this._input=e,this.processLineState=void 0;let n=new GD(e,t);if(this.tokens=n.tokenize(),this.tokens.length>(t?.maxParserTokens??qD))throw new eO(`Too many tokens: ${this.tokens.length} exceeds limit of ${t?.maxParserTokens??qD}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseBudget.chargeTokens(this.tokens.length),this.parseScript()}finally{n?.()}}parseTokens(e){this.ownsParseBudget&&this.parseBudget.reset();let t=this.ownsParseBudget?void 0:this.enterDepth();try{return this.tokens=e,this.pos=0,this.pendingHeredocs=[],this.processLineState=void 0,this.parseBudget.chargeTokens(e.length),this.parseScript()}finally{t?.()}}current(){return this.tokens[this.pos]||this.tokens[this.tokens.length-1]}peek(e=0){return this.tokens[this.pos+e]||this.tokens[this.tokens.length-1]}advance(){let e=this.current();return this.pos<this.tokens.length-1&&this.pos++,e}getPos(){return this.pos}getSourceLine(e=this.current()){let t=this.processLineState;return t?(t.currentPhysicalLine===void 0?t.currentPhysicalLine=e.line:e.line>t.currentPhysicalLine&&(t.currentPhysicalLine=e.line,t.currentLogicalLine+=1),t.currentLogicalLine):e.line}check(e,t,n,r,...i){let a=this.tokens[this.pos]?.type;return a===e||t!==void 0&&a===t||n!==void 0&&a===n||r!==void 0&&a===r||i.length>0&&i.includes(a)}expect(e,t){if(this.check(e))return this.advance();let n=this.current();throw new eO(t||`Expected ${e}, got ${n.type}`,n.line,n.column,n)}error(e){let t=this.current();throw new eO(e,t.line,t.column,t)}skipNewlines(){for(;this.check(Z.NEWLINE,Z.COMMENT);)this.check(Z.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(e=!0){for(;;){if(this.check(Z.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(Z.SEMICOLON,Z.COMMENT)){this.advance();continue}if(e&&this.check(Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(e,t,n,r){this.pendingHeredocs.push({redirect:e,delimiter:t,stripTabs:n,quoted:r})}processHeredocs(){for(let e of this.pendingHeredocs)if(this.check(Z.HEREDOC_CONTENT)){let t=this.advance(),n;n=e.quoted?X.word([X.literal(t.value)]):this.parseWordFromString(t.value,!1,!1,!1,!0),e.redirect.target=X.hereDoc(e.delimiter,n,e.stripTabs,e.quoted,t.heredocTerminated??!1)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(Z.EOF,Z.NEWLINE,Z.SEMICOLON,Z.AMP,Z.AND_AND,Z.OR_OR,Z.RPAREN,Z.RBRACE,Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND)}isCommandStart(){let e=this.current().type;return this.isWord()||e===Z.ASSIGNMENT_WORD||e===Z.FD_VARIABLE||e===Z.LPAREN||e===Z.LBRACE||e===Z.DPAREN_START||e===Z.DBRACK_START||GO(this)}parseScript(){let e=[],t=0;for(this.skipNewlines();!this.check(Z.EOF);){t++,t>(this.parseBudget.maxIterations??1e4)&&this.error(`Parser stuck: too many iterations (>${this.parseBudget.maxIterations??1e4})`);let n=this.checkUnexpectedToken();if(n){e.push(n),this.skipSeparators(!1);continue}let r=this.pos,i=this.parseStatement();i&&e.push(i),this.check(Z.HEREDOC_CONTENT)&&this.processHeredocs(),this.skipSeparators(!1),this.check(Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===r&&!this.check(Z.EOF)&&this.error(`syntax error near unexpected token \`${this.current().value}'`)}return X.script(e)}checkUnexpectedToken(){let e=this.current().type,t=this.current().value;if(this.currentTokenJoinsProcessSubstitution())return null;if((e===Z.DO||e===Z.DONE||e===Z.THEN||e===Z.ELSE||e===Z.ELIF||e===Z.FI||e===Z.ESAC)&&this.error(`syntax error near unexpected token \`${t}'`),e===Z.RBRACE||e===Z.RPAREN){let e=`syntax error near unexpected token \`${t}'`;return this.advance(),X.statement([X.pipeline([X.simpleCommand(null,[],[],[])])],[],!1,{message:e,token:t})}return(e===Z.DSEMI||e===Z.SEMI_AND||e===Z.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${t}'`),e===Z.SEMICOLON&&this.error(`syntax error near unexpected token \`${t}'`),(e===Z.AMP||e===Z.AND_AND||e===Z.OR_OR||e===Z.PIPE||e===Z.PIPE_AMP)&&this.error(`syntax error near unexpected token \`${t}'`),null}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let e=this.current().start,t=[],n=[],r=!1,i=this.parsePipeline();for(t.push(i);this.check(Z.AND_AND,Z.OR_OR);){let e=this.advance();n.push(e.type===Z.AND_AND?`&&`:`||`),this.skipNewlines();let r=this.parsePipeline();t.push(r)}this.check(Z.AMP)&&(this.advance(),r=!0);let a=this.pos>0?this.tokens[this.pos-1].end:e,o=this._input.slice(e,a);return X.statement(t,n,r,void 0,o)}parseTimePrefix(){if(!this.check(Z.TIME)||this.currentTokenJoinsProcessSubstitution())return;this.advance();let e=!1;return this.check(Z.WORD,Z.NAME)&&this.current().value===`-p`&&(this.advance(),e=!0),e}parsePipeline(){let e=!1,t=!1,n=0;for(;this.check(Z.BANG)&&!this.currentTokenJoinsProcessSubstitution();)this.advance(),n++;if(n===0){let r=this.parseTimePrefix();if(r!==void 0)for(e=!0,t=r;this.check(Z.BANG)&&!this.currentTokenJoinsProcessSubstitution();)this.advance(),n++}let r=n%2==1,i=[],a=[],o=this.parseCommand();for(i.push(o);this.check(Z.PIPE,Z.PIPE_AMP);){let e=this.advance();this.skipNewlines(),a.push(e.type===Z.PIPE_AMP);let t=this.parseCommand();i.push(t)}return X.pipeline(i,r,e,t,a.length>0?a:void 0)}parseCommand(){if(this.currentTokenJoinsProcessSubstitution())return JO(this);let e=this.current();switch(e.type){case Z.IF:return QO(this);case Z.FOR:return $O(this);case Z.WHILE:return tk(this);case Z.UNTIL:return nk(this);case Z.CASE:return rk(this);case Z.LPAREN:return ak(this);case Z.LBRACE:return ok(this);case Z.DPAREN_START:return this.dparenClosesWithSpacedParens()?this.parseNestedSubshellsFromDparen():this.parseArithmeticCommand();case Z.DBRACK_START:return this.parseConditionalCommand();case Z.FUNCTION:return this.parseFunctionDef();case Z.TIME:break;case Z.BANG:this.error(`syntax error near unexpected token \`${e.value}'`);break;default:LD(e.type)&&this.error(`syntax error near unexpected token \`${e.value}'`)}return this.check(Z.NAME,Z.WORD)&&this.peek(1).type===Z.LPAREN&&this.peek(2).type===Z.RPAREN?this.parseFunctionDef():JO(this)}dparenClosesWithSpacedParens(){let e=1,t=1;for(;t<this.tokens.length-this.pos;){let n=this.peek(t);if(n.type===Z.EOF)return!1;if(n.type===Z.DPAREN_START||n.type===Z.LPAREN)e++;else if(n.type===Z.DPAREN_END){if(e-=2,e<=0)return!1}else if(n.type===Z.RPAREN&&(e--,e===0&&this.peek(t+1).type===Z.RPAREN))return!0;t++}return!1}parseNestedSubshellsFromDparen(){this.advance();let e=this.parseCompoundList();this.expect(Z.RPAREN),this.expect(Z.RPAREN);let t=this.parseOptionalRedirections(),n=X.subshell(e,[]);return X.subshell([X.statement([X.pipeline([n],!1,!1,!1)])],t)}isWord(){return this.isWordToken(XD.Default)||this.isProcessSubstitutionStart()||this.currentTokenJoinsProcessSubstitution()}isWordToken(e){let t=this.current().type;return t===Z.WORD||t===Z.NAME||t===Z.NUMBER||LD(t)||t===Z.BANG||t===Z.ASSIGNMENT_WORD&&(e&XD.Regex)!==0}isProcessSubstitutionStart(e=0){let t=this.peek(e),n=this.peek(e+1);return(t.type===Z.LESS||t.type===Z.GREAT)&&n.type===Z.LPAREN&&t.end===n.start}currentTokenJoinsProcessSubstitution(){return this.current().type===Z.COMMENT||!this.isAdjacentWordToken(XD.Default)?!1:this.current().end===this.peek(1).start&&this.isProcessSubstitutionStart(1)}isAdjacentWordToken(e){let t=this.current().type;return this.isWordToken(e)||t===Z.ASSIGNMENT_WORD||t===Z.COMMENT||t===Z.LBRACE||t===Z.RBRACE||t===Z.DBRACK_START||t===Z.DBRACK_END||t===Z.FD_VARIABLE}parseWord(e=XD.Default){if(this.isProcessSubstitutionStart())return this.parseAdjacentWordParts([],this.current().start,e);let t=this.advance(),n=this.parseWordToken(t,e);return this.parseAdjacentWordParts(n.parts,t.end,e)}parseAdjacentWordParts(e,t,n=XD.Default){for(;t===this.current().start;){if(this.isProcessSubstitutionStart()){e.push(this.parseProcessSubstitution()),t=this.tokens[this.pos-1].end;continue}if(!this.isAdjacentWordToken(n))break;let r=this.advance();e.push(...this.parseWordToken(r,n,e.length===0).parts),t=r.end}return X.word(e)}parseWordNoBraceExpansion(){return this.parseWord(XD.NoBraceExpansion)}parseWordForRegex(){return this.parseWord(XD.NoBraceExpansion|XD.Regex)}parseWordToken(e,t,n=!0){return e.type===Z.LBRACE||e.type===Z.RBRACE||e.type===Z.DBRACK_START||e.type===Z.DBRACK_END||e.type===Z.FD_VARIABLE?X.word([X.literal(e.type===Z.FD_VARIABLE?`{${e.value}}`:e.value)]):this.parseWordFromString(e.value,e.quoted,e.singleQuoted,(t&XD.Assignment)!==0,!1,(t&XD.NoBraceExpansion)!==0,(t&XD.Regex)!==0,n)}parseWordFromString(e,t=!1,n=!1,r=!1,i=!1,a=!1,o=!1,s=!0){let c=Ek(this,e,t,n,r,i,!1,a,o,!1,s);return X.word(c)}parseCommandSubstitution(t,n){return AD(t,n,()=>new e(this.parseBudget),e=>this.error(e))}parseProcessSubstitutionFromString(t,n){return jD(t,n,()=>new e(this.parseBudget),e=>this.error(e))}parseProcessSubstitution(){let e=this.advance();this.expect(Z.LPAREN);let t=this.processLineState,n=this.getSourceLine(e);this.processLineState={currentLogicalLine:n};let r;try{r=X.script(this.parseCompoundList())}finally{this.processLineState=t}return this.check(Z.EOF)&&this.error("unexpected EOF while looking for matching `)'"),this.expect(Z.RPAREN),X.processSubstitution(r,e.type===Z.LESS?`input`:`output`)}parseBacktickSubstitution(t,n,r=!1){return MD(t,n,r,()=>new e(this.parseBudget),e=>this.error(e))}isDollarDparenSubshell(e,t){return ED(e,t)}parseArithmeticExpansion(e,t){let n=t+3,r=1,i=0,a=n;for(;a<e.length-1&&r>0;)e[a]===`$`&&e[a+1]===`(`?e[a+2]===`(`?(r++,a+=3):(i++,a+=2):e[a]===`(`&&e[a+1]===`(`?(r++,a+=2):e[a]===`)`&&e[a+1]===`)`?i>0?(i--,a++):(r--,r>0&&(a+=2)):e[a]===`(`?(i++,a++):(e[a]===`)`&&i>0&&i--,a++);let o=e.slice(n,a),s=this.parseArithmeticExpression(o);return{part:X.arithmeticExpansion(s),endIndex:a+2}}parseArithmeticCommand(){let e=this.expect(Z.DPAREN_START),t=``,n=1,r=0,i=!1,a=!1;for(;n>0&&!this.check(Z.EOF);){if(i){if(i=!1,r>0){r--,t+=`)`;continue}if(this.check(Z.RPAREN)){n--,a=!0,this.advance();continue}if(this.check(Z.DPAREN_END)){n--,a=!0;continue}t+=`)`;continue}if(this.check(Z.DPAREN_START))n++,t+=`((`,this.advance();else if(this.check(Z.DPAREN_END))r>=2?(r-=2,t+=`))`,this.advance()):r===1?(r--,t+=`)`,i=!0,this.advance()):(n--,a=!0,n>0&&(t+=`))`),this.advance());else if(this.check(Z.LPAREN))r++,t+=`(`,this.advance();else if(this.check(Z.RPAREN))r>0&&r--,t+=`)`,this.advance();else{let e=this.current().value,n=t.length>0?t[t.length-1]:``;t.length>0&&!t.endsWith(` `)&&!(e===`=`&&/[|&^+\-*/%<>]$/.test(t))&&(e!==`<`||n!==`<`)&&(e!==`>`||n!==`>`)&&(t+=` `),t+=e,this.advance()}}a||this.expect(Z.DPAREN_END);let o=this.parseArithmeticExpression(t.trim()),s=this.parseOptionalRedirections();return X.arithmeticCommand(o,s,this.getSourceLine(e))}parseConditionalCommand(){let e=this.expect(Z.DBRACK_START),t=dk(this);this.expect(Z.DBRACK_END);let n=this.parseOptionalRedirections();return X.conditionalCommand(t,n,this.getSourceLine(e))}parseFunctionDef(){let e;if(this.check(Z.FUNCTION)){if(this.advance(),this.check(Z.NAME)||this.check(Z.WORD))e=this.advance().value;else{let e=this.current();throw new eO(`Expected function name`,e.line,e.column,e)}this.check(Z.LPAREN)&&(this.advance(),this.expect(Z.RPAREN))}else e=this.advance().value,e.includes(`$`)&&this.error(`\`${e}': not a valid identifier`),this.expect(Z.LPAREN),this.expect(Z.RPAREN);this.skipNewlines();let t=this.parseCompoundCommandBody({forFunctionBody:!0}),n=this.parseOptionalRedirections();return X.functionDef(e,t,n)}parseCompoundCommandBody(e){let t=e?.forFunctionBody;if(this.check(Z.LBRACE))return ok(this,{skipRedirections:t});if(this.check(Z.LPAREN))return ak(this,{skipRedirections:t});if(this.check(Z.IF))return QO(this,{skipRedirections:t});if(this.check(Z.FOR))return $O(this,{skipRedirections:t});if(this.check(Z.WHILE))return tk(this,{skipRedirections:t});if(this.check(Z.UNTIL))return nk(this,{skipRedirections:t});if(this.check(Z.CASE))return rk(this,{skipRedirections:t});this.error(`Expected compound command for function body`)}parseCompoundList(){let e=this.enterDepth();try{let e=[];for(this.skipNewlines();(this.currentTokenJoinsProcessSubstitution()||!this.check(Z.EOF,Z.FI,Z.ELSE,Z.ELIF,Z.THEN,Z.DO,Z.DONE,Z.ESAC,Z.RPAREN,Z.RBRACE,Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND))&&this.isCommandStart();){this.checkIterationLimit();let t=this.pos,n=this.parseStatement();if(n&&e.push(n),this.skipSeparators(),this.pos===t&&!n)break}return e}finally{e()}}parseOptionalRedirections(){let e=[];for(;GO(this);){this.checkIterationLimit();let t=this.pos;if(e.push(KO(this)),this.pos===t)break}return e}parseArithmeticExpression(e){return lO(this,e)}};function Ok(e,t){return new Dk().parse(e,t)}function kk(e){return Ak(e)}function Ak(e){return e.statements.map(jk).join(`
|
|
905
904
|
`)}function jk(e){let t=[];for(let n=0;n<e.pipelines.length;n++)t.push(Mk(e.pipelines[n])),n<e.operators.length&&t.push(e.operators[n]);let n=t.join(` `);return e.background&&(n+=` &`),n}function Mk(e){let t=[];e.timed&&t.push(e.timePosix?`time -p`:`time`),e.negated&&t.push(`!`);let n=[];for(let t=0;t<e.commands.length;t++)if(n.push(Nk(e.commands[t])),t<e.commands.length-1){let r=e.pipeStderr?.[t];n.push(r?`|&`:`|`)}return(t.length>0?`${t.join(` `)} `:``)+n.join(` `)}function Nk(e){switch(e.type){case`SimpleCommand`:return Pk(e);case`If`:return Zk(e);case`For`:return Qk(e);case`CStyleFor`:return $k(e);case`While`:return eA(e);case`Until`:return tA(e);case`Case`:return nA(e);case`Subshell`:return iA(e);case`Group`:return aA(e);case`ArithmeticCommand`:return oA(e);case`ConditionalCommand`:return sA(e);case`FunctionDef`:return cA(e);default:throw Error(`Unsupported command type: ${e.type}`)}}function Pk(e){let t=[];for(let n of e.assignments)t.push(Fk(n));e.name&&t.push(Ik(e.name));for(let n of e.args)t.push(Ik(n));for(let n of e.redirections)t.push(Jk(n));return t.join(` `)}function Fk(e){let t=e.append?`+=`:`=`;if(e.array){let n=e.array.map(Ik).join(` `);return`${e.name}${t}(${n})`}return e.value?`${e.name}${t}${Ik(e.value)}`:`${e.name}${t}`}function Ik(e){return e.parts.map(e=>Rk(e,!1)).join(``)}function Lk(e){return e.parts.map(e=>Rk(e,!0)).join(``)}function Rk(e,t){switch(e.type){case`Literal`:return t?Bk(e.value):zk(e.value);case`SingleQuoted`:return`'${e.value}'`;case`DoubleQuoted`:return`"${e.parts.map(e=>Rk(e,!0)).join(``)}"`;case`Escaped`:return`\\${e.value}`;case`ParameterExpansion`:return Uk(e);case`CommandSubstitution`:return e.legacy?`\`${Ak(e.body)}\``:`$(${Ak(e.body)})`;case`ArithmeticExpansion`:return`$((${lA(e.expression.expression)}))`;case`ProcessSubstitution`:return e.direction===`input`?`<(${Ak(e.body)})`:`>(${Ak(e.body)})`;case`BraceExpansion`:return Kk(e);case`TildeExpansion`:return e.user===null?`~`:`~${e.user}`;case`Glob`:return e.pattern;default:throw Error(`Unsupported word part type: ${e.type}`)}}function zk(e){return e.replace(/[\s\\'"`!|&;()<>{}[\]*?~#]/g,`\\$&`)}function Bk(e){return e.replace(/[$`"\\]/g,`\\$&`)}function Vk(e,t){return e.parts.map(e=>Hk(e,t)).join(``)}function Hk(e,t){switch(e.type){case`Literal`:return t?e.value:e.value.replace(/[$`]/g,`\\$&`);case`Escaped`:return`\\${e.value}`;case`ParameterExpansion`:return Uk(e);case`CommandSubstitution`:return e.legacy?`\`${Ak(e.body)}\``:`$(${Ak(e.body)})`;case`ArithmeticExpansion`:return`$((${lA(e.expression.expression)}))`;default:return Rk(e,!1)}}function Uk(e){return e.operation?`\${${Gk(e.parameter,e.operation)}}`:Wk(e.parameter)?`\${${e.parameter}}`:`$${e.parameter}`}function Wk(e){return!(/^[?#@*$!\-0-9]$/.test(e)||/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e))}function Gk(e,t){switch(t.type){case`Length`:return`#${e}`;case`LengthSliceError`:return`#${e}:`;case`BadSubstitution`:return t.text;case`DefaultValue`:return`${e}${t.checkEmpty?`:`:``}-${Lk(t.word)}`;case`AssignDefault`:return`${e}${t.checkEmpty?`:`:``}=${Lk(t.word)}`;case`ErrorIfUnset`:return`${e}${t.checkEmpty?`:`:``}?${t.word?Lk(t.word):``}`;case`UseAlternative`:return`${e}${t.checkEmpty?`:`:``}+${Lk(t.word)}`;case`Substring`:{let n=lA(t.offset.expression);return t.length?`${e}:${n}:${lA(t.length.expression)}`:`${e}:${n}`}case`PatternRemoval`:{let n=t.side===`prefix`?`#`:`%`;return`${e}${t.greedy?`${n}${n}`:n}${Lk(t.pattern)}`}case`PatternReplacement`:{let n=`/`;t.all?n=`//`:t.anchor===`start`?n=`/#`:t.anchor===`end`&&(n=`/%`);let r=t.replacement?`/${Lk(t.replacement)}`:``;return`${e}${n}${Lk(t.pattern)}${r}`}case`CaseModification`:{let n=t.direction===`upper`?`^`:`,`;return`${e}${t.all?`${n}${n}`:n}${t.pattern?Lk(t.pattern):``}`}case`Transform`:return`${e}@${t.operator}`;case`Indirection`:return t.innerOp?`!${Gk(e,t.innerOp)}`:`!${e}`;case`ArrayKeys`:return`!${t.array}[${t.star?`*`:`@`}]`;case`VarNamePrefix`:return`!${t.prefix}${t.star?`*`:`@`}`;default:throw Error(`Unsupported parameter operation type: ${t.type}`)}}function Kk(e){return`{${e.items.map(qk).join(`,`)}}`}function qk(e){if(e.type===`Word`)return Ik(e.word);let t=e.startStr??String(e.start),n=e.endStr??String(e.end);return e.step===void 0?`${t}..${n}`:`${t}..${n}..${e.step}`}function Jk(e){let t=e.fdVariable?`{${e.fdVariable}}`:e.fd===null?``:String(e.fd);if(e.operator===`<<`||e.operator===`<<-`){let n=e.target;if(n.terminated===!1)throw Error(`Cannot serialize an unterminated here-document`);let r=n.quoted?`'${n.delimiter}'`:n.delimiter,i=Vk(n.content,n.quoted);return`${t}${e.operator}${r}
|
|
906
905
|
${i}${n.delimiter}`}return e.operator===`<<<`?`${t}<<< ${Ik(e.target)}`:e.operator===`&>`||e.operator===`&>>`?`${e.operator} ${Ik(e.target)}`:`${t}${e.operator} ${Ik(e.target)}`}function Yk(e){return e.length===0?``:` ${e.map(Jk).join(` `)}`}function Xk(e){return e.map(jk).join(`
|
|
907
906
|
`)}function Zk(e){let t=[];for(let n=0;n<e.clauses.length;n++){let r=e.clauses[n],i=n===0?`if`:`elif`;t.push(`${i} ${Xk(r.condition)}; then
|
|
@@ -1074,7 +1073,7 @@ ${e.terminator}`}function iA(e){return`(${Xk(e.body)})${Yk(e.redirections)}`}fun
|
|
|
1074
1073
|
`:s.map(e=>i?e:SL(e,c)).join(` `)+`
|
|
1075
1074
|
`,pP(l)}j();async function DL(e,t,n,r=!1){let i=t;if(i.length>0){let e=i[0];if(e===`--`)i=i.slice(1);else if(e.startsWith(`-`)&&e!==`-`&&e.length>1)return Q(`bash: eval: ${e}: invalid option
|
|
1076
1075
|
eval: usage: eval [arg ...]
|
|
1077
|
-
`,2)}if(i.length===0)return fP;let a=i.join(` `);if(a.trim()===``)return fP;let o=e.state.groupStdin,s=r||n!==void 0&&n!==``;s&&(e.state.groupStdin=n??``);try{let t=Ok(a);return await e.executeScript(t)}catch(e){if(e instanceof xr||e instanceof Sr||e instanceof Cr||e instanceof Er)throw e;if(e.name===`ParseException`)return Q(`bash: eval: ${e.message}
|
|
1076
|
+
`,2)}if(i.length===0)return fP;let a=i.join(` `);if(a.trim()===``)return fP;let o=e.state.groupStdin,s=r||n!==void 0&&n!==``;s&&(e.state.groupStdin=n??``);try{let t=Ok(a,{maxInputSize:e.limits.maxSourceBytes,maxParserTokens:e.limits.maxParserTokens,maxParseIterations:e.limits.maxParseIterations});return await e.executeScript(t)}catch(e){if(e instanceof xr||e instanceof Sr||e instanceof Cr||e instanceof Er)throw e;if(e.name===`ParseException`)return Q(`bash: eval: ${e.message}
|
|
1078
1077
|
`);throw e}finally{(s||o!==void 0&&e.state.groupStdin===void 0)&&(e.state.groupStdin=o)}}j();function OL(e,t){let n,r=``;if(t.length===0)n=e.state.lastExitCode;else{let e=t[0];if(e===``||!/^-?\d+$/.test(e))r=`bash: exit: ${e}: numeric argument required
|
|
1079
1078
|
`,n=2;else{let t=BigInt(e);n=Number((t%256n+256n)%256n)}}throw new Er(n,``,r)}function kL(e,t){let n=!1,r=[];for(let e of t)e===`-n`?n=!0:e===`-p`||e===`--`||r.push(e);if(r.length===0&&!n){let t=``,n=e.state.exportedVars??new Set,r=Array.from(n).sort();for(let n of r){let r=e.state.env.get(n);r!==void 0&&(t+=`declare -x ${n}=${YI(r)}
|
|
1080
1079
|
`)}return pP(t)}if(n){for(let t of r){let n,r;if(t.includes(`=`)){let e=t.indexOf(`=`);n=t.slice(0,e),r=t.slice(e+1)}else n=t;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n))return $(``,`bash: export: \`${t}': not a valid identifier
|
|
@@ -1505,7 +1504,7 @@ ${UL}`;if(e.state.options.posix)throw new Nr(1,``,t);return Q(t)}return iR(e,t.s
|
|
|
1505
1504
|
`;if(e.state.options.posix)throw new Nr(1,``,n);return Q(n)}n=r}let r=Number.parseInt(e.state.env.get(`#`)||`0`,10);if(n>r){let t=`bash: shift: shift count out of range
|
|
1506
1505
|
`;if(e.state.options.posix)throw new Nr(1,``,t);return Q(t)}if(n===0)return fP;let i=[];for(let t=1;t<=r;t++)i.push(e.state.env.get(String(t))||``);let a=i.slice(n);for(let t=1;t<=r;t++)e.state.env.delete(String(t));for(let t=0;t<a.length;t++)e.state.env.set(String(t+1),a[t]);return e.state.env.set(`#`,String(a.length)),e.state.env.set(`@`,a.join(` `)),fP}j();async function oR(e,t){let n=t;if(n.length>0&&n[0]===`--`&&(n=n.slice(1)),n.length===0)return $(``,`bash: source: filename argument required
|
|
1507
1506
|
`,2);let r=n[0],i=null;if(r.includes(`/`)){let t=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFile(t)}catch{}}else{let t=(e.state.env.get(`PATH`)||``).split(`:`).filter(e=>e);for(let n of t){let t=e.fs.resolvePath(e.state.cwd,`${n}/${r}`);try{if((await e.fs.stat(t)).isDirectory)continue;i=await e.fs.readFile(t);break}catch{}}if(i===null){let t=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFile(t)}catch{}}}if(i===null)return Q(`bash: ${r}: No such file or directory
|
|
1508
|
-
`);let a=new Map;if(n.length>1){for(let t=1,r=Math.max(9,n.length,+(e.state.env.get(`#`)||0));t<=r;t++)a.set(String(t),e.state.env.get(String(t)));a.set(`#`,e.state.env.get(`#`)),a.set(`@`,e.state.env.get(`@`));let t=n.slice(1);e.state.env.set(`#`,String(t.length)),e.state.env.set(`@`,t.join(` `));for(let n=0;n<t.length;n++)e.state.env.set(String(n+1),t[n]);for(let n of[...e.state.env.keys()])/^[1-9][0-9]*$/.test(n)&&+n>t.length&&e.state.env.delete(n)}let o=e.state.currentSource,s=()=>{if(e.state.sourceDepth--,e.state.currentSource=o,n.length>1)for(let[t,n]of a)n===void 0?e.state.env.delete(t):e.state.env.set(t,n)};if(e.state.sourceDepth++,e.state.sourceDepth>e.limits.maxSourceDepth)throw e.state.sourceDepth--,new A(`source: maximum nesting depth (${e.limits.maxSourceDepth}) exceeded, increase executionLimits.maxSourceDepth`,`recursion`);e.state.currentSource=r;try{let t=Ok(i),n=await e.executeScript(t);return s(),n}catch(e){if(s(),e instanceof Er)throw e;if(e instanceof Cr)return $(e.stdout,e.stderr,e.exitCode);if(e.name===`ParseException`)return Q(`bash: ${r}: ${e.message}
|
|
1507
|
+
`);let a=new Map;if(n.length>1){for(let t=1,r=Math.max(9,n.length,+(e.state.env.get(`#`)||0));t<=r;t++)a.set(String(t),e.state.env.get(String(t)));a.set(`#`,e.state.env.get(`#`)),a.set(`@`,e.state.env.get(`@`));let t=n.slice(1);e.state.env.set(`#`,String(t.length)),e.state.env.set(`@`,t.join(` `));for(let n=0;n<t.length;n++)e.state.env.set(String(n+1),t[n]);for(let n of[...e.state.env.keys()])/^[1-9][0-9]*$/.test(n)&&+n>t.length&&e.state.env.delete(n)}let o=e.state.currentSource,s=()=>{if(e.state.sourceDepth--,e.state.currentSource=o,n.length>1)for(let[t,n]of a)n===void 0?e.state.env.delete(t):e.state.env.set(t,n)};if(e.state.sourceDepth++,e.state.sourceDepth>e.limits.maxSourceDepth)throw e.state.sourceDepth--,new A(`source: maximum nesting depth (${e.limits.maxSourceDepth}) exceeded, increase executionLimits.maxSourceDepth`,`recursion`);e.state.currentSource=r;try{let t=Ok(i,{maxInputSize:e.limits.maxSourceBytes,maxParserTokens:e.limits.maxParserTokens,maxParseIterations:e.limits.maxParseIterations}),n=await e.executeScript(t);return s(),n}catch(e){if(s(),e instanceof Er)throw e;if(e instanceof Cr)return $(e.stdout,e.stderr,e.exitCode);if(e.name===`ParseException`)return Q(`bash: ${r}: ${e.message}
|
|
1509
1508
|
`);throw e}}function sR(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function cR(e){return e.startsWith(`'`)&&e.endsWith(`'`)||e.startsWith(`"`)&&e.endsWith(`"`)}async function lR(e,t){if(cR(t))return null;try{return await aP(e,lO(new Dk,t).expression)}catch{let e=parseInt(t,10);return Number.isNaN(e)?0:e}}function uR(e,t){if(e.state.localVarStack?.has(t)){let n=fF(e,t);if(n){n.value===void 0?e.state.env.delete(t):e.state.env.set(t,n.value);let r=e.state.localVarStack?.get(t);if(!r||r.length===0)uF(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,n.scopeIndex),dR(e,t);else{let n=r[r.length-1];e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,n.scopeIndex+1)}return!0}return e.state.env.delete(t),uF(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,0),!0}for(let n=e.state.localScopes.length-1;n>=0;n--){let r=e.state.localScopes[n];if(r.has(t)){let i=r.get(t);i===void 0?e.state.env.delete(t):e.state.env.set(t,i),r.delete(t);let a=!1;for(let r=n-1;r>=0;r--)if(e.state.localScopes[r].has(t)){e.state.localVarDepth&&e.state.localVarDepth.set(t,r+1),a=!0;break}return a||uF(e,t),!0}}return!1}function dR(e,t){if(!e.state.tempEnvBindings||e.state.tempEnvBindings.length===0)return!1;for(let n=e.state.tempEnvBindings.length-1;n>=0;n--){let r=e.state.tempEnvBindings[n];if(r.has(t)){let n=r.get(t);return n===void 0?e.state.env.delete(t):e.state.env.set(t,n),r.delete(t),!0}}return!1}async function fR(e,t){if(t.startsWith(`'`)&&t.endsWith(`'`))return t.slice(1,-1);if(t.startsWith(`"`)&&t.endsWith(`"`)){let n=t.slice(1,-1);return PN(e,new Dk().parseWordFromString(n,!0,!1))}return t.includes(`$`)?PN(e,new Dk().parseWordFromString(t,!1,!1)):t}async function pR(e,t){let n=`both`,r=``,i=0;for(let a of t){if(a===`-v`){n=`variable`;continue}if(a===`-f`){n=`function`;continue}if(n===`function`){e.state.functions.delete(a);continue}if(n===`variable`){let t=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(t){let n=t[1],a=t[2];if(Lj(e,n)){r+=`bash: unset: ${n}: cannot unset: readonly variable
|
|
1510
1509
|
`,i=1;continue}if(a===`@`||a===`*`){dD(e,n),e.state.env.delete(n);continue}let o=e.state.associativeArrays?.has(n);if(o){uD(e,n,await fR(e,a));continue}let s=aj(e,n),c=e.state.declaredVars?.has(n);if((e.state.env.has(n)||c)&&!s&&!o){r+=`bash: unset: ${n}: not an array variable
|
|
1511
1510
|
`,i=1;continue}let l=await lR(e,a);if(l===null&&s){r+=`bash: unset: ${a}: not a valid identifier
|
|
@@ -1620,7 +1619,7 @@ sys 0m0.000s
|
|
|
1620
1619
|
`),o.build(1)}return d(),o.build(s)}async function Fz(e,t,n,r,i){let a;try{a=await e.fs.readFile(t)}catch{return Q(`bash: ${t}: No such file or directory
|
|
1621
1620
|
`,127)}if(a.startsWith(`#!`)){let e=a.indexOf(`
|
|
1622
1621
|
`),t=(e===-1?a.slice(2):a.slice(2,e)).trim(),n=t.split(/\s+/),r=e=>e.slice(e.lastIndexOf(`/`)+1),i=r(n[0]||``);i===`env`&&(i=r(n.slice(1).find(e=>!e.startsWith(`-`))||``)),t&&!/^(sh|bash|dash|ash|ksh|zsh)$/.test(i)?a=t+` "$0" "$@"
|
|
1623
|
-
`:e!==-1&&(a=a.slice(e+1))}let o=e.state.loopDepth,s=Az(e.state);e.state.parentHasLoopContext=o>0,e.state.loopDepth=0,e.state.bashPid=e.state.nextVirtualPid++,r&&(e.state.groupStdin=r),e.state.currentSource=t,e.state.env.set(`0`,t),e.state.env.set(`#`,String(n.length)),e.state.env.set(`@`,n.join(` `)),e.state.env.set(`*`,n.join(` `));for(let t=0;t<n.length;t++)e.state.env.set(String(t+1),n[t]);for(let t of[...e.state.env.keys()])/^[1-9][0-9]*$/.test(t)&&+t>n.length&&e.state.env.delete(t);try{let
|
|
1622
|
+
`:e!==-1&&(a=a.slice(e+1))}let o=e.state.loopDepth,s=Az(e.state);e.state.parentHasLoopContext=o>0,e.state.loopDepth=0,e.state.bashPid=e.state.nextVirtualPid++,r&&(e.state.groupStdin=r),e.state.currentSource=t,e.state.env.set(`0`,t),e.state.env.set(`#`,String(n.length)),e.state.env.set(`@`,n.join(` `)),e.state.env.set(`*`,n.join(` `));for(let t=0;t<n.length;t++)e.state.env.set(String(t+1),n[t]);for(let t of[...e.state.env.keys()])/^[1-9][0-9]*$/.test(t)&&+t>n.length&&e.state.env.delete(t);try{let t=await i(new Dk().parse(a,{maxInputSize:e.limits.maxSourceBytes,maxParserTokens:e.limits.maxParserTokens,maxParseIterations:e.limits.maxParseIterations}));return s(),t}catch(e){if(s(),e instanceof Er)return $(e.stdout,e.stderr,e.exitCode);if(e instanceof A)throw e;if(e.name===`ParseException`)return Q(`bash: ${t}: ${e.message}
|
|
1624
1623
|
`);throw e}}function Iz(e){throw TypeError(`Unsupported command node: ${JSON.stringify(e)}`)}var Lz=class{ctx;constructor(e,t){this.ctx={state:t,fs:e.fs,commands:e.commands,limits:e.limits,executionScope:e.executionScope,execFn:e.exec,executeScript:this.executeScript.bind(this),executeStatement:this.executeStatement.bind(this),executeCommand:this.executeCommand.bind(this),fetch:e.fetch,sleep:e.sleep,trace:e.trace,coverage:e.coverage,requireDefenseContext:e.requireDefenseContext??!1,jsBootstrapCode:e.jsBootstrapCode,invokeTool:e.invokeTool}}assertDefenseContext(e){if(!this.ctx.requireDefenseContext||Jn.isInSandboxedContext())return;let t=`interpreter ${e} attempted outside defense context`;throw new D(t,{timestamp:Date.now(),type:`missing_defense_context`,message:t,path:`DefenseInDepthBox.context`,stack:Error().stack,executionId:Jn.getCurrentExecutionId()})}buildExportedEnv(){let e=this.ctx.state.exportedVars,t=this.ctx.state.tempExportedVars,n=new Set;if(e)for(let t of e)n.add(t);if(t)for(let e of t)n.add(e);if(n.size===0)return Object.create(null);let r=Object.create(null);for(let e of n){let t=this.ctx.state.env.get(e);t!==void 0&&(r[e]=t)}return r}async executeScript(e){this.assertDefenseContext(`execution`);let t=0,n=new bg(this.ctx.executionScope,`script`);for(let r of e.statements)try{let e=await this.executeStatement(r);n.appendResult(e,mr(e)),t=e.exitCode,this.ctx.state.lastExitCode=t,this.ctx.state.env.set(`?`,String(t))}catch(e){if(e instanceof Er)throw e.prependOutput(n.stdout,n.stderr),e;if(e instanceof Nr)return n.append(`stdout`,e.stdout,e.internalOutputAccounting.stdout),n.append(`stderr`,e.stderr,e.internalOutputAccounting.stderr),t=e.exitCode,this.ctx.state.lastExitCode=t,this.ctx.state.env.set(`?`,String(t)),{...n.build(t),exitCode:t,env:ad(this.ctx.state.env)};if(e instanceof A)throw n.prependTo(e),e;if(e instanceof wr)return n.append(`stdout`,e.stdout,e.internalOutputAccounting.stdout),n.append(`stderr`,e.stderr,e.internalOutputAccounting.stderr),t=e.exitCode,this.ctx.state.lastExitCode=t,this.ctx.state.env.set(`?`,String(t)),{...n.build(t),exitCode:t,env:ad(this.ctx.state.env)};if(e instanceof Tr||e instanceof Or)return n.append(`stdout`,e.stdout,e.internalOutputAccounting.stdout),n.append(`stderr`,e.stderr,e.internalOutputAccounting.stderr),t=1,this.ctx.state.lastExitCode=t,this.ctx.state.env.set(`?`,String(t)),{...n.build(t),exitCode:t,env:ad(this.ctx.state.env)};if(e instanceof Dr){n.append(`stdout`,e.stdout,e.internalOutputAccounting.stdout),n.append(`stderr`,e.stderr,e.internalOutputAccounting.stderr),t=1,this.ctx.state.lastExitCode=t,this.ctx.state.env.set(`?`,String(t));continue}if(e instanceof Ar){n.append(`stdout`,e.stdout,e.internalOutputAccounting.stdout),n.append(`stderr`,e.stderr,e.internalOutputAccounting.stderr),t=1,this.ctx.state.lastExitCode=t,this.ctx.state.env.set(`?`,String(t));continue}if(e instanceof xr||e instanceof Sr){if(this.ctx.state.loopDepth>0)throw e.prependOutput(n.stdout,n.stderr),e;n.append(`stdout`,e.stdout),n.append(`stderr`,e.stderr);continue}throw e instanceof Cr&&e.prependOutput(n.stdout,n.stderr),e}return{...n.build(t),env:ad(this.ctx.state.env)}}async executeUserScript(e,t,n=``){return Fz(this.ctx,e,t,n,e=>this.executeScript(e))}async executeStatement(e){if(this.assertDefenseContext(`statement`),this.ctx.state.signal?.aborted)throw new jr;if(e.deferredError)throw new eO(e.deferredError.message,e.line??1,1);if(this.ctx.state.options.noexec)return fP;this.ctx.state.errexitSafe=!1;let t=new bg(this.ctx.executionScope,`statement`);this.ctx.state.options.verbose&&!this.ctx.state.suppressVerbose&&e.sourceText&&t.append(`stderr`,`${e.sourceText}
|
|
1625
1624
|
`);let n=0,r=-1,i=!1;try{for(let a=0;a<e.pipelines.length;a++){let o=e.pipelines[a],s=a>0?e.operators[a-1]:null;if(s===`&&`&&n!==0||s===`||`&&n===0)continue;let c=await this.executePipeline(o);t.appendResult(c,mr(c)),n=c.exitCode,r=a,i=o.negated,this.ctx.state.lastExitCode=n,this.ctx.state.env.set(`?`,String(n))}}catch(e){throw t.prependTo(e),e}let a=r<e.pipelines.length-1,o=this.ctx.state.errexitSafe;if(this.ctx.state.errexitSafe=a||i||o,this.ctx.state.options.errexit&&n!==0&&r===e.pipelines.length-1&&!i&&!this.ctx.state.inCondition&&!o){let e=new wr(n);throw e.prependOutput(t.stdout,t.stderr),e}return t.build(n)}async executePipeline(e){return wz(this.ctx,e,(e,t)=>this.executeCommand(e,t))}async executeCommand(e,t,n=!1){let r=EN(this.ctx),i;try{i=await this.executeCommandInner(e,t,n)}catch(e){throw await ON(this.ctx,r).catch(()=>{}),e}let a=await ON(this.ctx,r);return!a.stdout&&!a.stderr?i:{...i,stdout:a.stdout?pr(i)+a.stdout:i.stdout,stdoutKind:a.stdout?`bytes`:i.stdoutKind,stderr:i.stderr+a.stderr}}async executeCommandInner(e,t,n){switch(this.assertDefenseContext(`command`),this.ctx.coverage?.hit(`bash:cmd:${e.type}`),e.type){case`SimpleCommand`:return this.executeSimpleCommand(e,t);case`If`:return dz(this.ctx,e);case`For`:return pz(this.ctx,e);case`CStyleFor`:return hz(this.ctx,e);case`While`:return _z(this.ctx,e,t);case`Until`:return yz(this.ctx,e,t);case`Case`:return xz(this.ctx,e);case`Subshell`:return this.executeSubshell(e,t,n);case`Group`:return this.executeGroup(e,t,n);case`FunctionDef`:return hI(this.ctx,e);case`ArithmeticCommand`:return this.executeArithmeticCommand(e);case`ConditionalCommand`:return this.executeConditionalCommand(e);default:return Iz(e)}}async executeSimpleCommand(e,t){let n;try{return await this.executeSimpleCommandInner(e,t,e=>{n=e})}catch(e){if(n?.finish(),e instanceof kr)return Q(e.stderr);throw e}}async executeSimpleCommandInner(e,t,n){if(e.line!==void 0&&(this.ctx.state.currentLine=e.line),this.ctx.state.shoptOptions.expand_aliases&&e.name){let t=e,n=0;for(;;){let e=this.expandAlias(t);if(e===t)break;if(n>=this.ctx.limits.maxCallDepth)throw new A(`alias expansion depth limit exceeded (${this.ctx.limits.maxCallDepth})`,`recursion`);n++,t=e}this.aliasExpansionStack.clear(),t!==e&&(e=t)}this.ctx.state.expansionStderr=``;let r=await FR(this.ctx,e);if(r.error)return r.error;let i=r.tempAssignments,a=r.xtraceOutput,o=()=>{for(let[e,t]of i)t===void 0?this.ctx.state.env.delete(e):this.ctx.state.env.set(e,t)};if(!e.name){if(e.redirections.length>0){let r=uI(this.ctx,e.redirections,$F);n(r);let i=await r.prepare(t);if(i.error){if(o(),!i.errorCause)return r.finish(),i.error;try{return dI(i)}finally{r.finish()}}let s=$(``,a,0),c=await mI(this.ctx,s,e.redirections,i.targets,i.dupSources,i.standardRoutes);return r.finish(),c}this.ctx.state.lastArg=``;let r=(this.ctx.state.expansionStderr||``)+a;return this.ctx.state.expansionStderr=``,$(``,r,JSON.stringify(e.assignments).includes(`"CommandSubstitution"`)?this.ctx.state.lastExitCode:0)}let s=e.name&&Cz(e.name,[`local`,`declare`,`typeset`,`export`,`readonly`]),c=Array.from(i.keys());if(c.length>0&&!s){this.ctx.state.tempExportedVars=this.ctx.state.tempExportedVars||new Set;for(let e of c)this.ctx.state.tempExportedVars.add(e)}let l=await UN(this.ctx,e.name),u=l.values[0]??``,d=[],f=[],p=(e,t)=>{if(d.length>=this.ctx.limits.maxArrayElements)throw new A(`expanded argument element limit exceeded (${this.ctx.limits.maxArrayElements})`,`array_elements`);d.push(e),f.push(t)};if(Cz(e.name,[`local`,`declare`,`typeset`,`export`,`readonly`])&&(u===`local`||u===`declare`||u===`typeset`||u===`export`||u===`readonly`))for(let t of e.args){let e=await cP(this.ctx,t);if(e)p(e,!0);else{let e=await lP(this.ctx,t);if(e!==null)p(e,!0);else{let e=await UN(this.ctx,t);for(let t of e.values)p(t,e.quoted)}}}else for(let t of e.args){let e=await UN(this.ctx,t);for(let t of e.values)p(t,e.quoted)}l.values.length>1&&(d.unshift(...l.values.slice(1)),f.unshift(...l.values.slice(1).map(()=>l.quoted)));let m=e.name.parts.every(e=>e.type===`CommandSubstitution`||e.type===`ParameterExpansion`||e.type===`ArithmeticExpansion`);!u&&m&&d.length>0&&(u=d.shift(),f.shift());let h=uI(this.ctx,e.redirections,u===`exec`?eI:QF);n(h);let g=await h.prepare(t);if(g.error)return o(),g.errorCause?dI(g):(h.finish(),g.error);let _=g.stdinSourceFd,v=g.stdin!==void 0;if(g.stdin!==void 0&&(t=g.stdin),!u)return m?(h.finish(),$(``,``,this.ctx.state.lastExitCode)):(h.finish(),Q(`bash: : command not found
|
|
1626
1625
|
`,127));if(u===`exec`&&(d.length===0||d[0]===`--`)){for(let[e,t]of i)t===void 0?this.ctx.state.env.delete(e):this.ctx.state.env.set(e,t);if(this.ctx.state.tempExportedVars)for(let e of i.keys())this.ctx.state.tempExportedVars.delete(e);return h.finish(),fP}if(this.ctx.state.extraArgs){let e=this.ctx.state.extraArgs;this.ctx.state.extraArgs=void 0;for(let t of e)p(t,!0)}let y=await MR(this.ctx,u,d);i.size>0&&(this.ctx.state.tempEnvBindings=this.ctx.state.tempEnvBindings||[],this.ctx.state.tempEnvBindings.push(new Map(i)));let b,x=null;try{b=await this.runCommand(u,d,f,t,!1,!1,_,v)}catch(e){if(e instanceof xr||e instanceof Sr)x=e,b=fP;else throw e}_>=0&&u!==`read`&&WF(this.ctx,_,b.internalStdinConsumed??0);let S=a+y;if(S&&(b={...b,stderr:S+b.stderr}),b=await mI(this.ctx,b,e.redirections,g.targets,g.dupSources,g.standardRoutes,b.internalProducerCommand??u,b.internalProducerOmitsShellPrefix),h.finish(),x)throw x;if(d.length>0){let e=d[d.length-1];if((u===`declare`||u===`local`||u===`typeset`)&&/^[a-zA-Z_][a-zA-Z0-9_]*=\(/.test(e)){let t=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);t&&(e=t[1])}this.ctx.state.lastArg=e}else this.ctx.state.lastArg=u;let ee=hF(u)&&u!==`unset`&&u!==`eval`;if(!this.ctx.state.options.posix||!ee)for(let[e,t]of i)this.ctx.state.fullyUnsetLocals?.has(e)||(t===void 0?this.ctx.state.env.delete(e):this.ctx.state.env.set(e,t));if(this.ctx.state.tempExportedVars)for(let e of i.keys())this.ctx.state.tempExportedVars.delete(e);return i.size>0&&this.ctx.state.tempEnvBindings&&this.ctx.state.tempEnvBindings.pop(),this.ctx.state.expansionStderr&&(b={...b,stderr:this.ctx.state.expansionStderr+b.stderr},this.ctx.state.expansionStderr=``),b}async runCommand(e,t,n,r,i=!1,a=!1,o=-1,s=!1){let c={ctx:this.ctx,runCommand:(e,t,n,r,i,a,o,s)=>this.runCommand(e,t,n,r,i,a,o,s),buildExportedEnv:()=>this.buildExportedEnv(),executeUserScript:(e,t,n)=>this.executeUserScript(e,t,n)},l=await nz(c,e,t,n,r,i,a,o,s);return l===null?{...await az(c,e,t,r,a),internalProducerCommand:e}:l.internalProducerCommand===void 0?{...l,internalProducerCommand:e}:l}aliasExpansionStack=new Set;expandAlias(e){return gA({env:this.ctx.state.env,limits:this.ctx.limits},e,this.aliasExpansionStack)}async findCommandInPath(e){return CR(this.ctx,e)}async executeSubshell(e,t=``,n=!1){return jz(this.ctx,e,t,e=>this.executeStatement(e),n)}async executeGroup(e,t=``,n=!1){return Nz(this.ctx,e,t,e=>this.executeStatement(e),n)}async executeArithmeticCommand(e){return e.line!==void 0&&(this.ctx.state.currentLine=e.line),pI(this.ctx,e.redirections,``,async()=>{try{let t=mP(await aP(this.ctx,e.expression.expression)!==0);return this.ctx.state.expansionStderr&&(t={...t,stderr:this.ctx.state.expansionStderr+t.stderr},this.ctx.state.expansionStderr=``),t}catch(e){return Q(`bash: arithmetic expression: ${e.message}
|
|
@@ -1631,11 +1630,11 @@ ${e.join(`
|
|
|
1631
1630
|
`],[`OSTYPE`,`linux-gnu`],[`MACHTYPE`,`x86_64-pc-linux-gnu`],[`HOSTTYPE`,`x86_64`],[`HOSTNAME`,`localhost`],[`PWD`,n],[`OLDPWD`,n],[`OPTIND`,`1`],...Object.entries(e.env??{})]);if(e.fetch?this.secureFetch=e.fetch:e.network&&(this.secureFetch=yB(e.network)),this.sleepFn=e.sleep,this.traceFn=e.trace,this.logger=e.logger,this.defenseInDepthConfig=e.defenseInDepth??!0,this.coverageWriter=e.coverage,this.state={env:r,arrays:new Map,cwd:n,previousDir:`/home/user`,functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:``,startTime:Date.now(),lastBackgroundPid:0,virtualPid:e.processInfo?.pid??1,virtualPpid:e.processInfo?.ppid??0,virtualUid:e.processInfo?.uid??1e3,virtualGid:e.processInfo?.gid??1e3,bashPid:e.processInfo?.pid??1,nextVirtualPid:(e.processInfo?.pid??1)+1,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1,posix:!1,allexport:!1,noclobber:!1,noglob:!1,noexec:!1,vi:!1,emacs:!1},shoptOptions:{extglob:!1,dotglob:!1,nullglob:!1,failglob:!1,globstar:!1,globskipdots:!0,nocaseglob:!1,nocasematch:!1,expand_aliases:!1,lastpipe:!1,xpg_echo:!1},inCondition:!1,loopDepth:0,exportedVars:new Set([`HOME`,`PATH`,`PWD`,`OLDPWD`,...Object.keys(e.env||{})]),readonlyVars:new Set([`SHELLOPTS`,`BASHOPTS`]),hashTable:new Map},this.state.env.set(`SHELLOPTS`,xD(this.state.options)),this.state.env.set(`BASHOPTS`,wD(this.state.shoptOptions)),eD(t,this.useDefaultLayout,{pid:this.state.virtualPid,ppid:this.state.virtualPpid,uid:this.state.virtualUid,gid:this.state.virtualGid}),n!==`/`&&t instanceof KE)try{t.mkdirSync(n,{recursive:!0})}catch{}for(let t of TE(e.commands))this.registerBundledCommand(t);if(e.fetch||e.network)for(let e of EE())this.registerBundledCommand(e);if(e.python)for(let e of DE())this.registerBundledCommand(e);let i=typeof e.javascript==`object`?e.javascript:Object.create(null);if(e.javascript||i.invokeTool){for(let e of OE())this.registerBundledCommand(e);i.bootstrap&&(this.jsBootstrapCode=i.bootstrap),i.invokeTool&&(this.invokeToolFn=i.invokeTool)}if(e.customCommands)for(let t of e.customCommands)if(LE(t)){let e=zE(t);this.registerCommandInternal(e,!0)}else this.registerCommandInternal(t,!0)}registerCommand(e){this.registerCommandInternal(e,!0)}registerBundledCommand(e){this.registerCommandInternal(e,!1)}registerCommandInternal(e,t,n=t?e.trusted??!0:e.trusted){let r=this.commands.get(e.name),i=t?r?.internalOriginalCommand??(r&&!r.internalIsExtension?r:void 0):void 0,a={name:e.name,trusted:n,internalIsExtension:t,internalOriginalCommand:i,execute:(t,n)=>e.execute(t,n)};this.commands.set(e.name,a);let o=this.fs;if(typeof o.writeFileSync==`function`){let t=`#!/bin/bash
|
|
1632
1631
|
# Built-in command: ${e.name}
|
|
1633
1632
|
`;try{o.writeFileSync(`/bin/${e.name}`,t)}catch{}try{o.writeFileSync(`/usr/bin/${e.name}`,t)}catch{}}}logResult(e){return this.logger&&(e.stdout&&this.logger.debug(`stdout`,{output:e.stdout}),e.stderr&&this.logger.info(`stderr`,{output:e.stderr}),this.logger.info(`exit`,{exitCode:e.exitCode})),e.stdout=DB(e.stdout),e.stderr=DB(e.stderr),e}async exec(e,t){let n=new VE(this.limits,t?.signal),r;try{r=await this.execInScope(e,t,n,0,t?.signal,!1,!1)}catch(e){try{await n.close()}catch{}throw e}let i=r;try{await n.close()}catch{i={...r,stderr:`${r.stderr}bash: execution cleanup failed
|
|
1634
|
-
`,exitCode:126}}return e.trim()?this.logResult(i):i}async execInScope(e,t,n,r,i,a=!1,o=!0){let s=e=>o?this.logResult(e):e,c=ar(i,t?.signal),l=t?{...t,signal:c.signal}:{signal:c.signal};try{if(n.assertExecDepth(r),SB(e,this.limits.maxSourceBytes),!e.trim())return{stdout:``,stderr:``,exitCode:0,env:od(this.state.env,l.env)};this.logger?.info(`exec`,{command:e});let t=l.cwd??this.state.cwd,i,o=t;if(l.cwd){if(l.env&&`PWD`in l.env)i=l.env.PWD;else if(l.env&&!(`PWD`in l.env))try{i=await this.fs.realpath(t),o=i}catch{i=t}else i=t}let c=l.replaceEnv?new Map:new Map(this.state.env);if(l.env)for(let[e,t]of Object.entries(l.env))c.set(e,t);i!==void 0&&c.set(`PWD`,i);let u=l.replaceEnv?new Set(c.keys()):new Set(this.state.exportedVars||[]);if(!l.replaceEnv&&l.env)for(let e of Object.keys(l.env))u.add(e);let d={...this.state,umask:l.umask??this.state.umask??18,env:c,exportedVars:u,arrays:l.replaceEnv?new Map:nD(this.state.arrays),cwd:o,previousDir:l.env?.OLDPWD??this.state.previousDir,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:OB(l.stdin,l.stdinKind,this.limits.maxInputBytes,this.limits.maxStringLength,n,a),signal:l.signal,extraArgs:l.args},f=e;l.rawScript||(f=TB(e));let p=this.defenseInDepthConfig?Jn.getInstance(this.defenseInDepthConfig):null,m=p?.activate();try{let e=async()=>{let e=Ok(f,{maxHeredocSize:this.limits.maxHeredocSize}),t;if(this.transformPlugins.length>0){let n=Object.create(null);for(let t of this.transformPlugins){let r=t.transform({ast:e,metadata:n});e=r.ast,r.metadata&&(n=sd(n,r.metadata))}t=n}let i=await new Lz({fs:(()=>{let e=cn(this.fs,d);return kE.set(e,jE(this.fs)),e})(),commands:this.commands,limits:this.limits,executionScope:n,exec:(e,t,i=!1)=>this.execInScope(e,t&&t.umask!==void 0?t:{...t,umask:d.umask},n,r+1,l.signal,i),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter,requireDefenseContext:p?.isEnabled()===!0,jsBootstrapCode:this.jsBootstrapCode,invokeTool:this.invokeToolFn},d).executeScript(e);return i.umask=d.umask,t&&(i.metadata=t),s(i)};return m?await m.run(e):await e()}catch(e){if(e instanceof Er)return s({stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,internalOutputAccounting:e.internalOutputAccounting,env:od(this.state.env,l.env)});if(e instanceof Nr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,env:od(this.state.env,l.env)});if(e instanceof Dr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:1,env:od(this.state.env,l.env)});if(e instanceof jr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:124,env:od(this.state.env,l.env)});if(e instanceof A)return s({stdout:e.stdout,stderr:ta(e.stderr),exitCode:A.EXIT_CODE,internalOutputAccounting:e.internalOutputAccounting,env:od(this.state.env,l.env)});if(e instanceof D)return s({stdout:``,stderr:`bash: security violation: ${ta(e.message)}
|
|
1633
|
+
`,exitCode:126}}return e.trim()?this.logResult(i):i}async execInScope(e,t,n,r,i,a=!1,o=!0){let s=e=>o?this.logResult(e):e,c=ar(i,t?.signal),l=t?{...t,signal:c.signal}:{signal:c.signal};try{if(n.assertExecDepth(r),SB(e,this.limits.maxSourceBytes),!e.trim())return{stdout:``,stderr:``,exitCode:0,env:od(this.state.env,l.env)};this.logger?.info(`exec`,{command:e});let t=l.cwd??this.state.cwd,i,o=t;if(l.cwd){if(l.env&&`PWD`in l.env)i=l.env.PWD;else if(l.env&&!(`PWD`in l.env))try{i=await this.fs.realpath(t),o=i}catch{i=t}else i=t}let c=l.replaceEnv?new Map:new Map(this.state.env);if(l.env)for(let[e,t]of Object.entries(l.env))c.set(e,t);i!==void 0&&c.set(`PWD`,i);let u=l.replaceEnv?new Set(c.keys()):new Set(this.state.exportedVars||[]);if(!l.replaceEnv&&l.env)for(let e of Object.keys(l.env))u.add(e);let d={...this.state,umask:l.umask??this.state.umask??18,env:c,exportedVars:u,arrays:l.replaceEnv?new Map:nD(this.state.arrays),cwd:o,previousDir:l.env?.OLDPWD??this.state.previousDir,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:OB(l.stdin,l.stdinKind,this.limits.maxInputBytes,this.limits.maxStringLength,n,a),signal:l.signal,extraArgs:l.args},f=e;l.rawScript||(f=TB(e));let p=this.defenseInDepthConfig?Jn.getInstance(this.defenseInDepthConfig):null,m=p?.activate();try{let e=async()=>{let e=Ok(f,{maxHeredocSize:this.limits.maxHeredocSize,maxInputSize:this.limits.maxSourceBytes,maxParserTokens:this.limits.maxParserTokens,maxParseIterations:this.limits.maxParseIterations}),t;if(this.transformPlugins.length>0){let n=Object.create(null);for(let t of this.transformPlugins){let r=t.transform({ast:e,metadata:n});e=r.ast,r.metadata&&(n=sd(n,r.metadata))}t=n}let i=await new Lz({fs:(()=>{let e=cn(this.fs,d);return kE.set(e,jE(this.fs)),e})(),commands:this.commands,limits:this.limits,executionScope:n,exec:(e,t,i=!1)=>this.execInScope(e,t&&t.umask!==void 0?t:{...t,umask:d.umask},n,r+1,l.signal,i),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter,requireDefenseContext:p?.isEnabled()===!0,jsBootstrapCode:this.jsBootstrapCode,invokeTool:this.invokeToolFn},d).executeScript(e);return i.umask=d.umask,t&&(i.metadata=t),s(i)};return m?await m.run(e):await e()}catch(e){if(e instanceof Er)return s({stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,internalOutputAccounting:e.internalOutputAccounting,env:od(this.state.env,l.env)});if(e instanceof Nr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,env:od(this.state.env,l.env)});if(e instanceof Dr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:1,env:od(this.state.env,l.env)});if(e instanceof jr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:124,env:od(this.state.env,l.env)});if(e instanceof A)return s({stdout:e.stdout,stderr:ta(e.stderr),exitCode:A.EXIT_CODE,internalOutputAccounting:e.internalOutputAccounting,env:od(this.state.env,l.env)});if(e instanceof D)return s({stdout:``,stderr:`bash: security violation: ${ta(e.message)}
|
|
1635
1634
|
`,exitCode:1,env:od(this.state.env,l.env)});if(e.name===`ParseException`)return s({stdout:``,stderr:`bash: syntax error: ${ta(e.message)}
|
|
1636
1635
|
`,exitCode:2,env:od(this.state.env,l.env)});if(e instanceof PD)return s({stdout:``,stderr:`bash: ${ta(e.message)}
|
|
1637
1636
|
`,exitCode:2,env:od(this.state.env,l.env)});if(e instanceof RangeError)return s({stdout:``,stderr:`bash: ${ta(e.message)}
|
|
1638
|
-
`,exitCode:1,env:od(this.state.env,l.env)});throw e}finally{m?.deactivate()}}catch(e){if(e instanceof jr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:124,env:od(this.state.env,l.env)});if(e instanceof A)return s({stdout:e.stdout,stderr:ta(e.stderr),exitCode:A.EXIT_CODE,internalOutputAccounting:e.internalOutputAccounting,env:od(this.state.env,l.env)});throw e}finally{c.cleanup()}}async readFile(e){return this.fs.readFile(this.fs.resolvePath(this.state.cwd,e))}async writeFile(e,t){return this.fs.writeFile(this.fs.resolvePath(this.state.cwd,e),t)}getCwd(){return this.state.cwd}getEnv(){return ad(this.state.env)}registerTransformPlugin(e){this.transformPlugins.push(e)}transform(e){SB(e,this.limits.maxSourceBytes);let t=Ok(TB(e),{maxHeredocSize:this.limits.maxHeredocSize}),n=Object.create(null);for(let e of this.transformPlugins){let r=e.transform({ast:t,metadata:n});t=r.ast,r.metadata&&(n=sd(n,r.metadata))}return{script:kk(t),ast:t,metadata:n}}};function wB(e,t){let n=t;for(let t=0;t<e.length;t++){let r=e[t];if(n===`single`)r===`'`&&(n=`none`);else if(n===`double`)r===`\\`?t++:r===`"`&&(n=`none`);else if(r===`'`)n=`single`;else if(r===`"`)n=`double`;else if(r===`\\`)t++;else if(r===`#`&&(t===0||/\s/.test(e[t-1])))break}return n}function TB(e){let t=e.split(`
|
|
1637
|
+
`,exitCode:1,env:od(this.state.env,l.env)});throw e}finally{m?.deactivate()}}catch(e){if(e instanceof jr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:124,env:od(this.state.env,l.env)});if(e instanceof A)return s({stdout:e.stdout,stderr:ta(e.stderr),exitCode:A.EXIT_CODE,internalOutputAccounting:e.internalOutputAccounting,env:od(this.state.env,l.env)});throw e}finally{c.cleanup()}}async readFile(e){return this.fs.readFile(this.fs.resolvePath(this.state.cwd,e))}async writeFile(e,t){return this.fs.writeFile(this.fs.resolvePath(this.state.cwd,e),t)}getCwd(){return this.state.cwd}getEnv(){return ad(this.state.env)}registerTransformPlugin(e){this.transformPlugins.push(e)}transform(e){SB(e,this.limits.maxSourceBytes);let t=Ok(TB(e),{maxHeredocSize:this.limits.maxHeredocSize,maxInputSize:this.limits.maxSourceBytes,maxParserTokens:this.limits.maxParserTokens,maxParseIterations:this.limits.maxParseIterations}),n=Object.create(null);for(let e of this.transformPlugins){let r=e.transform({ast:t,metadata:n});t=r.ast,r.metadata&&(n=sd(n,r.metadata))}return{script:kk(t),ast:t,metadata:n}}};function wB(e,t){let n=t;for(let t=0;t<e.length;t++){let r=e[t];if(n===`single`)r===`'`&&(n=`none`);else if(n===`double`)r===`\\`?t++:r===`"`&&(n=`none`);else if(r===`'`)n=`single`;else if(r===`"`)n=`double`;else if(r===`\\`)t++;else if(r===`#`&&(t===0||/\s/.test(e[t-1])))break}return n}function TB(e){let t=e.split(`
|
|
1639
1638
|
`),n=[],r=[],i=`none`;for(let e=0;e<t.length;e++){let a=t[e];if(r.length>0){let e=r[r.length-1];if((e.stripTabs?a.replace(/^\t+/,``):a)===e.delimiter){n.push(a.trimStart()),r.pop();continue}n.push(a);continue}let o=i,s=e>0&&/(^|[^\\])(\\\\)*\\$/.test(t[e-1]),c=o===`none`&&!s?a.trimStart():a;if(n.push(c),i=wB(a,o),o===`none`)for(let e of c.matchAll(/<<(-?)\s*(['"]?)([\w-]+)\2/g)){let t=e[1]===`-`,n=e[3];r.push({delimiter:n,stripTabs:t})}}return n.join(`
|
|
1640
1639
|
`)}var EB=new TextDecoder(`utf-8`,{fatal:!0});function DB(e){if(!e)return e;let t=!1;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r>255)return e;r>127&&(t=!0)}if(!t)return e;let n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);try{return EB.decode(n)}catch{return e}}function OB(e,t,n,r,i,a){if(e===void 0)return;let o=t===`bytes`?e.length:O(e);if(o>n||o>r)throw new A(`stdin size limit exceeded (${Math.min(n,r)} bytes)`,`string_length`);return a||i.consumeInput(o,`stdin`),t===`bytes`?e:lr(e)}
|
|
1641
1640
|
/*! Bundled license information:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./logger-LESFN7Hj.js";import{t}from"./esbuild-wasm-
|
|
1
|
+
import{t as e}from"./logger-LESFN7Hj.js";import{t}from"./esbuild-wasm-CbTVjIj0.js";const n=e(`bsh-watchdog`),r=`.bsh scripts must be pre-bundled. Install deps via \`ipk add <pkg>\`, then bootstrap esbuild via \`ipk add esbuild-wasm@${t}\` and bundle with \`esbuild --bundle <script>.bsh --outfile=<script>.bundled.bsh\`. Drop the bundled file in place. There is no runtime resolver in the target page.`;var i=class{transport;browserAPI;fs;scriptCatalog;running=!1;executing=new Set;constructor(e){if(!e.transport&&!e.browserAPI)throw Error(`BshWatchdog requires either transport or browserAPI`);if(!e.scriptCatalog)throw Error(`BshWatchdog requires a ScriptCatalog`);this.browserAPI=e.browserAPI,this.transport=e.transport??e.browserAPI.getTransport(),this.fs=e.fs,this.scriptCatalog=e.scriptCatalog}async start(){if(this.running)return;this.running=!0,this.transport.on(`Page.frameNavigated`,this.onFrameNavigated),this.browserAPI&&this.browserAPI.setSessionChangeCallback((e,t)=>{t!==this.transport&&this.setTransport(t)});let e;try{e=(await this.scriptCatalog.getBshEntries()).length}catch(e){n.warn(`BSH watchdog startup discovery failed`,{error:e instanceof Error?e.message:String(e)})}n.info(`BSH watchdog started`,e===void 0?void 0:{scriptCount:e})}stop(){this.running&&(this.running=!1,this.transport.off(`Page.frameNavigated`,this.onFrameNavigated),this.browserAPI&&this.browserAPI.setSessionChangeCallback(void 0),this.executing.clear(),n.info(`BSH watchdog stopped`))}setTransport(e){e!==this.transport&&(this.transport.off(`Page.frameNavigated`,this.onFrameNavigated),this.transport=e,this.running&&this.transport.on(`Page.frameNavigated`,this.onFrameNavigated),n.info(`BSH watchdog transport swapped`))}async discover(){this.scriptCatalog.invalidateBsh(),await this.scriptCatalog.getBshEntries()}async getEntries(){return this.scriptCatalog.getBshEntries()}onFrameNavigated=e=>{let t=e.frame;if(t?.parentId||!t?.url)return;let r=t.url,i=e.sessionId;if(!(!r.startsWith(`http://`)&&!r.startsWith(`https://`))){if(!i){n.warn(`BSH watchdog: no sessionId in Page.frameNavigated params, skipping`,{url:r});return}this.scriptCatalog.findMatchingBshScripts(r).then(e=>{if(e.length!==0)for(let t of e){let e=`${t.path}::${r}`;this.executing.has(e)||(this.executing.add(e),n.info(`BSH watchdog executing script`,{script:t.path,url:r}),this.executeInTargetPage(t.path,r,i).then(()=>{n.info(`BSH script completed`,{script:t.path,url:r})}).catch(e=>{n.error(`BSH script execution error`,{script:t.path,url:r,error:e instanceof Error?e.message:String(e)})}).finally(()=>{this.executing.delete(e)}))}}).catch(e=>{n.error(`BSH discovery failed`,{url:r,error:e instanceof Error?e.message:String(e)})})}};async executeInTargetPage(e,t,i){let a=await this.fs.readFile(e),o=typeof a==`string`?a:new TextDecoder().decode(a),s=`(async () => {
|
|
2
2
|
const __requireSpecifiers = (function() {
|
|
3
3
|
const re = /require\\s*\\(\\s*['"]([^'"]+)['"]\\s*\\)/g;
|
|
4
4
|
const code = ${JSON.stringify(o)};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./buffer-B5d1xHaH.js";var t=e();globalThis.Buffer===void 0&&(globalThis.Buffer=t.Buffer);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./logger-DDBAeTLF.js";import"./navigation-watcher-CPcnZL9l.js";import"./wc-follower-oauth-BNclaglp.js";import{d as t,l as n,u as r}from"./main-BZ7qq-Vs.js";import{n as i,t as a}from"./pending-request-table-k-D7ZZsL.js";var o=e(`cdp`);function s(e){return e===4001?`CDP connection superseded by another SLICC tab/window on this instance`:e===4002?`CDP connection reset by proxy (upstream Chrome connection was re-established)`:`CDP connection closed`}var c=class{ws=null;nextId=1;_superseded=!1;pending=new a;listeners=new Map;_state=`disconnected`;stateListeners=new Set;lastNotifiedState=`disconnected`;lastNotifiedReason;get state(){return this._state}onStateChange(e){return this.stateListeners.add(e),()=>{this.stateListeners.delete(e)}}get superseded(){return this._superseded}async connect(e){if(this._state!==`disconnected`)throw Error(`Cannot connect: state is ${this._state}`);if(!e?.url)throw Error(`CDPClient.connect() requires a WebSocket URL`);let{url:t,timeout:n=5e3,protocols:r}=e;return this._state=`connecting`,new Promise((e,i)=>{let a=setTimeout(()=>{this.cleanup(),i(Error(`CDP connection timed out after ${n}ms`))},n);try{this.ws=r===void 0?new WebSocket(t):new WebSocket(t,r)}catch(e){clearTimeout(a),this._state=`disconnected`,i(e);return}this.ws.onopen=()=>{clearTimeout(a),this._state=`connected`,this._superseded=!1,o.info(`Connected`,{url:t}),this.notifyState(`connected`),e()},this.ws.onerror=e=>{clearTimeout(a),this._state===`connecting`&&(o.error(`Connection failed`,{url:t}),this.cleanup(),i(Error(`CDP WebSocket connection failed`)))},this.ws.onmessage=e=>{this.handleMessage(e.data)},this.ws.onclose=e=>{this.handleClose(e?.code)}})}disconnect(){this.ws&&(this.ws.onclose=null,this.ws.close()),this._superseded=!1,this.cleanup(),o.info(`Disconnected`)}async send(e,t,n,r=3e4){if(this._state!==`connected`||!this.ws)throw Error(`CDP client is not connected`);let i=this.nextId++,a={id:i,method:e};t&&(a.params=t),n&&(a.sessionId=n),o.debug(`Send`,{method:e,id:i,sessionId:n});let s=this.pending.issue(i,r,`CDP command timed out after ${r}ms: ${e}`);return this.ws.send(JSON.stringify(a)),s}on(e,t){let n=this.listeners.get(e);n||(n=new Set,this.listeners.set(e,n)),n.add(t)}off(e,t){let n=this.listeners.get(e);n&&(n.delete(t),n.size===0&&this.listeners.delete(e))}once(e,t=3e4){return i(t=>(this.on(e,t),()=>this.off(e,t)),t,`Timed out waiting for event: ${e}`)}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}if(`id`in t&&typeof t.id==`number`){let e=t;o.debug(`Response`,{id:e.id,hasError:!!e.error}),e.error?(o.error(`Command error`,{id:e.id,code:e.error.code,message:e.error.message}),this.pending.reject(e.id,Error(`CDP error: ${e.error.message} (${e.error.code})`))):this.pending.resolve(e.id,e.result??{});return}if(`method`in t){let e=t;o.debug(`Event`,{method:e.method,sessionId:e.sessionId});let n=this.listeners.get(e.method);if(n){let t=e.sessionId?{...e.params,sessionId:e.sessionId}:e.params??{};for(let e of n)try{e(t)}catch{}}}}handleClose(e){e===4001?(this._superseded=!0,o.warn(`CDP slot superseded by another SLICC tab/window on this instance`,{code:e})):e===4002?o.warn(`CDP proxy reset its upstream Chrome connection — sessions dropped`,{code:e,pendingCommands:this.pending.size}):o.error(`Connection closed unexpectedly`,{pendingCommands:this.pending.size}),this.cleanup(s(e))}cleanup(e=`CDP client disconnected`){this.ws=null,this._state=`disconnected`,this.pending.rejectAll(e),this.notifyState(`disconnected`,e)}notifyState(e,t){if(e!==this.lastNotifiedState||t!==this.lastNotifiedReason){this.lastNotifiedState=e,this.lastNotifiedReason=t;for(let n of this.stateListeners)try{n(e,t)}catch{}}}},l=class extends Error{step;name=`CommandAbortedError`;constructor(e){super(`Browser command aborted while ${e}. A CDP round trip already in flight cannot be cancelled, so it may still have been applied to the page; nothing after it was started.`),this.step=e}};function u(e,t){if(e?.aborted)throw new l(t)}function d(e,t){return e?{signal:e,error:()=>new l(t)}:void 0}function f(e,t,n){return new Promise((r,i)=>{if(t?.aborted){i(new l(n));return}let a=()=>{clearTimeout(o),i(new l(n))},o=setTimeout(()=>{t?.removeEventListener(`abort`,a),r()},e);t?.addEventListener(`abort`,a,{once:!0})})}function p(e,t,n){return t?t.aborted?Promise.reject(new l(n)):new Promise((r,i)=>{let a=()=>i(new l(n));t.addEventListener(`abort`,a,{once:!0}),e.then(()=>{t.removeEventListener(`abort`,a),r()},e=>{t.removeEventListener(`abort`,a),i(e instanceof Error?e:Error(String(e)))})}):e}var m=e(`har-recorder`),h=class{recordings=new Map;client;fs;eventCleanup=new Map;constructor(e,t){this.client=e,this.fs=t}async startRecording(e,t,n,r){let i=`rec-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;u(r,`about to enable Network on tab ${e}`),await this.client.send(`Network.enable`,{},t),u(r,`about to enable Page on tab ${e}`),await this.client.send(`Page.enable`,{},t),u(r,`about to read the URL of tab ${e}`);let a=(await this.client.send(`Runtime.evaluate`,{expression:`location.href`,returnByValue:!0},t)).result?.value??`about:blank`,o={id:i,targetId:e,sessionId:t,filterCode:n,pendingRequests:new Map,entries:[],startTime:Date.now(),currentUrl:a,snapshotCount:0};return this.recordings.set(i,o),this.setupEventListeners(o),await this.ensureDir(`/recordings/${i}`),m.debug(`Started recording`,{recordingId:i,targetId:e,currentUrl:a}),i}setupEventListeners(e){let{sessionId:t,id:n}=e,r=n=>{let r=n;r.sessionId===t&&this.handleRequestWillBeSent(e,r)},i=n=>{let r=n;r.sessionId===t&&this.handleResponseReceived(e,r)},a=r=>{let i=r;i.sessionId===t&&this.handleLoadingFinished(e,i).catch(e=>{m.error(`Failed to process loadingFinished event`,{recordingId:n,requestId:i.requestId,error:e instanceof Error?e.message:String(e)})})},o=n=>{let r=n;r.sessionId===t&&this.handleLoadingFailed(e,r)},s=r=>{let i=r;if(i.sessionId!==t)return;let a=i.frame;if(!a?.parentId&&a?.url){let t=[...e.entries],r=e.currentUrl;e.currentUrl=a.url,e.entries=[],e.pendingRequests.clear(),this.saveSnapshotWithEntries(e,`navigation`,t,r).catch(e=>{m.error(`Failed to save navigation snapshot`,{recordingId:n,error:e instanceof Error?e.message:String(e)})})}};this.client.on(`Network.requestWillBeSent`,r),this.client.on(`Network.responseReceived`,i),this.client.on(`Network.loadingFinished`,a),this.client.on(`Network.loadingFailed`,o),this.client.on(`Page.frameNavigated`,s),this.eventCleanup.set(n,()=>{this.client.off(`Network.requestWillBeSent`,r),this.client.off(`Network.responseReceived`,i),this.client.off(`Network.loadingFinished`,a),this.client.off(`Network.loadingFailed`,o),this.client.off(`Page.frameNavigated`,s)})}handleRequestWillBeSent(e,t){let{requestId:n,request:r,timestamp:i}=t;!n||!r||i==null||e.pendingRequests.set(n,{requestId:n,startTime:i*1e3,request:{method:r.method,url:r.url,headers:r.headers,postData:r.postData}})}handleResponseReceived(e,t){let{requestId:n,response:r}=t;if(!n||!r)return;let i=e.pendingRequests.get(n);i&&(i.response={status:r.status,statusText:r.statusText,headers:r.headers,mimeType:r.mimeType},i.timing=r.timing)}async handleLoadingFinished(e,t){let{requestId:n,timestamp:r}=t;if(!n||r==null)return;let i=e.pendingRequests.get(n);if(!i)return;i.endTime=r*1e3;try{let t=await this.client.send(`Network.getResponseBody`,{requestId:n},e.sessionId);i.responseBody=t.body,i.responseBodyBase64=t.base64Encoded===!0}catch{}let a=this.buildHarEntry(i);a&&e.entries.push(a),e.pendingRequests.delete(n)}handleLoadingFailed(e,t){let{requestId:n}=t;n&&e.pendingRequests.delete(n)}buildHarEntry(e){if(!e.response)return null;let{request:t,response:n,timing:r,startTime:i,endTime:a,responseBody:o,responseBodyBase64:s}=e,c=a?a-i:0,l=[];try{let e=new URL(t.url);l=Array.from(e.searchParams.entries()).map(([e,t])=>({name:e,value:t}))}catch{}let u=r?(()=>{let e=(e,t)=>{if(e==null||t==null||e<0||t<0)return-1;let n=t-e;return n>=0?n:-1},t=r.dnsStart>=0?r.dnsStart:r.connectStart>=0?r.connectStart:0;return{blocked:t>0?t:-1,dns:e(r.dnsStart,r.dnsEnd),connect:e(r.connectStart,r.connectEnd),ssl:e(r.sslStart,r.sslEnd),send:e(r.sendStart,r.sendEnd),wait:e(r.sendEnd,r.receiveHeadersStart),receive:e(r.receiveHeadersStart,r.receiveHeadersEnd)}})():{blocked:-1,dns:-1,connect:-1,ssl:-1,send:0,wait:c,receive:0},d={size:o?.length??0,mimeType:n.mimeType??`application/octet-stream`};o&&(d.text=o,s&&(d.encoding=`base64`));let f;return t.postData&&(f={mimeType:t.headers[`content-type`]??t.headers[`Content-Type`]??`text/plain`,text:t.postData}),{startedDateTime:new Date(i).toISOString(),time:c,request:{method:t.method,url:t.url,httpVersion:`HTTP/1.1`,cookies:[],headers:Object.entries(t.headers).map(([e,t])=>({name:e,value:t})),queryString:l,postData:f,headersSize:-1,bodySize:t.postData?.length??0},response:{status:n.status,statusText:n.statusText,httpVersion:`HTTP/1.1`,cookies:[],headers:Object.entries(n.headers).map(([e,t])=>({name:e,value:t})),content:d,redirectURL:n.headers.location??n.headers.Location??``,headersSize:-1,bodySize:d.size},cache:{},timings:u}}async saveSnapshot(e,t){return this.saveSnapshotWithEntries(e,t,e.entries,e.currentUrl)}async applyFilter(e,t){return g(e,t)}async saveSnapshotWithEntries(e,t,n,r){if(n.length===0)return m.debug(`No entries to save`,{recordingId:e.id,trigger:t}),null;let i=e.filterCode?await this.applyFilter(n,e.filterCode):n;if(i.length===0)return m.debug(`All entries filtered out`,{recordingId:e.id,trigger:t}),null;e.snapshotCount++;let a=new Date().toISOString().replace(/[:.]/g,`-`),o=this.urlToSlug(r),s=`${e.snapshotCount.toString().padStart(3,`0`)}-${a}-${t}-${o}.har`,c=`/recordings/${e.id}/${s}`,l={log:{version:`1.2`,creator:{name:`SLICC HAR Recorder`,version:`1.0.0`},entries:i}};return await this.fs.writeFile(c,JSON.stringify(l,null,2)),m.debug(`Saved HAR snapshot`,{recordingId:e.id,path:c,entryCount:i.length}),c}urlToSlug(e){try{let t=new URL(e);return`${t.hostname}${t.pathname}`.replace(/[^a-zA-Z0-9]/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``).slice(0,50)||`page`}catch{return`page`}}async stopRecording(e){let t=this.recordings.get(e);if(!t)throw Error(`Recording not found: ${e}`);await this.saveSnapshot(t,`close`);let n=this.eventCleanup.get(e);n&&(n(),this.eventCleanup.delete(e));try{await this.client.send(`Network.disable`,{},t.sessionId)}catch{}this.recordings.delete(e);let r=`/recordings/${e}`;return m.debug(`Stopped recording`,{recordingId:e,snapshotCount:t.snapshotCount}),r}getRecording(e){return this.recordings.get(e)}getRecordingByTarget(e){for(let[t,n]of this.recordings)if(n.targetId===e)return t}async ensureDir(e){await this.fs.mkdir(e,{recursive:!0})}};function g(e,t){try{let n=Function(`entry`,`return (${t})(entry);`),r=[];for(let t of e)try{let e=n(t);if(e===!1)continue;typeof e==`object`&&e?r.push(e):r.push(t)}catch(e){m.error(`Filter function error on entry, keeping it`,{error:e instanceof Error?e.message:String(e)}),r.push(t)}return r}catch(t){return m.error(`Failed to compile filter, returning unfiltered`,{error:t instanceof Error?t.message:String(t)}),e}}var _=`(function() {
|
|
1
|
+
import{t as e}from"./logger-DDBAeTLF.js";import"./navigation-watcher-CPcnZL9l.js";import"./wc-follower-oauth-BArMqE7c.js";import{d as t,l as n,u as r}from"./main-DUD5pTDH.js";import{n as i,t as a}from"./pending-request-table-k-D7ZZsL.js";var o=e(`cdp`);function s(e){return e===4001?`CDP connection superseded by another SLICC tab/window on this instance`:e===4002?`CDP connection reset by proxy (upstream Chrome connection was re-established)`:`CDP connection closed`}var c=class{ws=null;nextId=1;_superseded=!1;pending=new a;listeners=new Map;_state=`disconnected`;stateListeners=new Set;lastNotifiedState=`disconnected`;lastNotifiedReason;get state(){return this._state}onStateChange(e){return this.stateListeners.add(e),()=>{this.stateListeners.delete(e)}}get superseded(){return this._superseded}async connect(e){if(this._state!==`disconnected`)throw Error(`Cannot connect: state is ${this._state}`);if(!e?.url)throw Error(`CDPClient.connect() requires a WebSocket URL`);let{url:t,timeout:n=5e3,protocols:r}=e;return this._state=`connecting`,new Promise((e,i)=>{let a=setTimeout(()=>{this.cleanup(),i(Error(`CDP connection timed out after ${n}ms`))},n);try{this.ws=r===void 0?new WebSocket(t):new WebSocket(t,r)}catch(e){clearTimeout(a),this._state=`disconnected`,i(e);return}this.ws.onopen=()=>{clearTimeout(a),this._state=`connected`,this._superseded=!1,o.info(`Connected`,{url:t}),this.notifyState(`connected`),e()},this.ws.onerror=e=>{clearTimeout(a),this._state===`connecting`&&(o.error(`Connection failed`,{url:t}),this.cleanup(),i(Error(`CDP WebSocket connection failed`)))},this.ws.onmessage=e=>{this.handleMessage(e.data)},this.ws.onclose=e=>{this.handleClose(e?.code)}})}disconnect(){this.ws&&(this.ws.onclose=null,this.ws.close()),this._superseded=!1,this.cleanup(),o.info(`Disconnected`)}async send(e,t,n,r=3e4){if(this._state!==`connected`||!this.ws)throw Error(`CDP client is not connected`);let i=this.nextId++,a={id:i,method:e};t&&(a.params=t),n&&(a.sessionId=n),o.debug(`Send`,{method:e,id:i,sessionId:n});let s=this.pending.issue(i,r,`CDP command timed out after ${r}ms: ${e}`);return this.ws.send(JSON.stringify(a)),s}on(e,t){let n=this.listeners.get(e);n||(n=new Set,this.listeners.set(e,n)),n.add(t)}off(e,t){let n=this.listeners.get(e);n&&(n.delete(t),n.size===0&&this.listeners.delete(e))}once(e,t=3e4){return i(t=>(this.on(e,t),()=>this.off(e,t)),t,`Timed out waiting for event: ${e}`)}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}if(`id`in t&&typeof t.id==`number`){let e=t;o.debug(`Response`,{id:e.id,hasError:!!e.error}),e.error?(o.error(`Command error`,{id:e.id,code:e.error.code,message:e.error.message}),this.pending.reject(e.id,Error(`CDP error: ${e.error.message} (${e.error.code})`))):this.pending.resolve(e.id,e.result??{});return}if(`method`in t){let e=t;o.debug(`Event`,{method:e.method,sessionId:e.sessionId});let n=this.listeners.get(e.method);if(n){let t=e.sessionId?{...e.params,sessionId:e.sessionId}:e.params??{};for(let e of n)try{e(t)}catch{}}}}handleClose(e){e===4001?(this._superseded=!0,o.warn(`CDP slot superseded by another SLICC tab/window on this instance`,{code:e})):e===4002?o.warn(`CDP proxy reset its upstream Chrome connection — sessions dropped`,{code:e,pendingCommands:this.pending.size}):o.error(`Connection closed unexpectedly`,{pendingCommands:this.pending.size}),this.cleanup(s(e))}cleanup(e=`CDP client disconnected`){this.ws=null,this._state=`disconnected`,this.pending.rejectAll(e),this.notifyState(`disconnected`,e)}notifyState(e,t){if(e!==this.lastNotifiedState||t!==this.lastNotifiedReason){this.lastNotifiedState=e,this.lastNotifiedReason=t;for(let n of this.stateListeners)try{n(e,t)}catch{}}}},l=class extends Error{step;name=`CommandAbortedError`;constructor(e){super(`Browser command aborted while ${e}. A CDP round trip already in flight cannot be cancelled, so it may still have been applied to the page; nothing after it was started.`),this.step=e}};function u(e,t){if(e?.aborted)throw new l(t)}function d(e,t){return e?{signal:e,error:()=>new l(t)}:void 0}function f(e,t,n){return new Promise((r,i)=>{if(t?.aborted){i(new l(n));return}let a=()=>{clearTimeout(o),i(new l(n))},o=setTimeout(()=>{t?.removeEventListener(`abort`,a),r()},e);t?.addEventListener(`abort`,a,{once:!0})})}function p(e,t,n){return t?t.aborted?Promise.reject(new l(n)):new Promise((r,i)=>{let a=()=>i(new l(n));t.addEventListener(`abort`,a,{once:!0}),e.then(()=>{t.removeEventListener(`abort`,a),r()},e=>{t.removeEventListener(`abort`,a),i(e instanceof Error?e:Error(String(e)))})}):e}var m=e(`har-recorder`),h=class{recordings=new Map;client;fs;eventCleanup=new Map;constructor(e,t){this.client=e,this.fs=t}async startRecording(e,t,n,r){let i=`rec-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;u(r,`about to enable Network on tab ${e}`),await this.client.send(`Network.enable`,{},t),u(r,`about to enable Page on tab ${e}`),await this.client.send(`Page.enable`,{},t),u(r,`about to read the URL of tab ${e}`);let a=(await this.client.send(`Runtime.evaluate`,{expression:`location.href`,returnByValue:!0},t)).result?.value??`about:blank`,o={id:i,targetId:e,sessionId:t,filterCode:n,pendingRequests:new Map,entries:[],startTime:Date.now(),currentUrl:a,snapshotCount:0};return this.recordings.set(i,o),this.setupEventListeners(o),await this.ensureDir(`/recordings/${i}`),m.debug(`Started recording`,{recordingId:i,targetId:e,currentUrl:a}),i}setupEventListeners(e){let{sessionId:t,id:n}=e,r=n=>{let r=n;r.sessionId===t&&this.handleRequestWillBeSent(e,r)},i=n=>{let r=n;r.sessionId===t&&this.handleResponseReceived(e,r)},a=r=>{let i=r;i.sessionId===t&&this.handleLoadingFinished(e,i).catch(e=>{m.error(`Failed to process loadingFinished event`,{recordingId:n,requestId:i.requestId,error:e instanceof Error?e.message:String(e)})})},o=n=>{let r=n;r.sessionId===t&&this.handleLoadingFailed(e,r)},s=r=>{let i=r;if(i.sessionId!==t)return;let a=i.frame;if(!a?.parentId&&a?.url){let t=[...e.entries],r=e.currentUrl;e.currentUrl=a.url,e.entries=[],e.pendingRequests.clear(),this.saveSnapshotWithEntries(e,`navigation`,t,r).catch(e=>{m.error(`Failed to save navigation snapshot`,{recordingId:n,error:e instanceof Error?e.message:String(e)})})}};this.client.on(`Network.requestWillBeSent`,r),this.client.on(`Network.responseReceived`,i),this.client.on(`Network.loadingFinished`,a),this.client.on(`Network.loadingFailed`,o),this.client.on(`Page.frameNavigated`,s),this.eventCleanup.set(n,()=>{this.client.off(`Network.requestWillBeSent`,r),this.client.off(`Network.responseReceived`,i),this.client.off(`Network.loadingFinished`,a),this.client.off(`Network.loadingFailed`,o),this.client.off(`Page.frameNavigated`,s)})}handleRequestWillBeSent(e,t){let{requestId:n,request:r,timestamp:i}=t;!n||!r||i==null||e.pendingRequests.set(n,{requestId:n,startTime:i*1e3,request:{method:r.method,url:r.url,headers:r.headers,postData:r.postData}})}handleResponseReceived(e,t){let{requestId:n,response:r}=t;if(!n||!r)return;let i=e.pendingRequests.get(n);i&&(i.response={status:r.status,statusText:r.statusText,headers:r.headers,mimeType:r.mimeType},i.timing=r.timing)}async handleLoadingFinished(e,t){let{requestId:n,timestamp:r}=t;if(!n||r==null)return;let i=e.pendingRequests.get(n);if(!i)return;i.endTime=r*1e3;try{let t=await this.client.send(`Network.getResponseBody`,{requestId:n},e.sessionId);i.responseBody=t.body,i.responseBodyBase64=t.base64Encoded===!0}catch{}let a=this.buildHarEntry(i);a&&e.entries.push(a),e.pendingRequests.delete(n)}handleLoadingFailed(e,t){let{requestId:n}=t;n&&e.pendingRequests.delete(n)}buildHarEntry(e){if(!e.response)return null;let{request:t,response:n,timing:r,startTime:i,endTime:a,responseBody:o,responseBodyBase64:s}=e,c=a?a-i:0,l=[];try{let e=new URL(t.url);l=Array.from(e.searchParams.entries()).map(([e,t])=>({name:e,value:t}))}catch{}let u=r?(()=>{let e=(e,t)=>{if(e==null||t==null||e<0||t<0)return-1;let n=t-e;return n>=0?n:-1},t=r.dnsStart>=0?r.dnsStart:r.connectStart>=0?r.connectStart:0;return{blocked:t>0?t:-1,dns:e(r.dnsStart,r.dnsEnd),connect:e(r.connectStart,r.connectEnd),ssl:e(r.sslStart,r.sslEnd),send:e(r.sendStart,r.sendEnd),wait:e(r.sendEnd,r.receiveHeadersStart),receive:e(r.receiveHeadersStart,r.receiveHeadersEnd)}})():{blocked:-1,dns:-1,connect:-1,ssl:-1,send:0,wait:c,receive:0},d={size:o?.length??0,mimeType:n.mimeType??`application/octet-stream`};o&&(d.text=o,s&&(d.encoding=`base64`));let f;return t.postData&&(f={mimeType:t.headers[`content-type`]??t.headers[`Content-Type`]??`text/plain`,text:t.postData}),{startedDateTime:new Date(i).toISOString(),time:c,request:{method:t.method,url:t.url,httpVersion:`HTTP/1.1`,cookies:[],headers:Object.entries(t.headers).map(([e,t])=>({name:e,value:t})),queryString:l,postData:f,headersSize:-1,bodySize:t.postData?.length??0},response:{status:n.status,statusText:n.statusText,httpVersion:`HTTP/1.1`,cookies:[],headers:Object.entries(n.headers).map(([e,t])=>({name:e,value:t})),content:d,redirectURL:n.headers.location??n.headers.Location??``,headersSize:-1,bodySize:d.size},cache:{},timings:u}}async saveSnapshot(e,t){return this.saveSnapshotWithEntries(e,t,e.entries,e.currentUrl)}async applyFilter(e,t){return g(e,t)}async saveSnapshotWithEntries(e,t,n,r){if(n.length===0)return m.debug(`No entries to save`,{recordingId:e.id,trigger:t}),null;let i=e.filterCode?await this.applyFilter(n,e.filterCode):n;if(i.length===0)return m.debug(`All entries filtered out`,{recordingId:e.id,trigger:t}),null;e.snapshotCount++;let a=new Date().toISOString().replace(/[:.]/g,`-`),o=this.urlToSlug(r),s=`${e.snapshotCount.toString().padStart(3,`0`)}-${a}-${t}-${o}.har`,c=`/recordings/${e.id}/${s}`,l={log:{version:`1.2`,creator:{name:`SLICC HAR Recorder`,version:`1.0.0`},entries:i}};return await this.fs.writeFile(c,JSON.stringify(l,null,2)),m.debug(`Saved HAR snapshot`,{recordingId:e.id,path:c,entryCount:i.length}),c}urlToSlug(e){try{let t=new URL(e);return`${t.hostname}${t.pathname}`.replace(/[^a-zA-Z0-9]/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``).slice(0,50)||`page`}catch{return`page`}}async stopRecording(e){let t=this.recordings.get(e);if(!t)throw Error(`Recording not found: ${e}`);await this.saveSnapshot(t,`close`);let n=this.eventCleanup.get(e);n&&(n(),this.eventCleanup.delete(e));try{await this.client.send(`Network.disable`,{},t.sessionId)}catch{}this.recordings.delete(e);let r=`/recordings/${e}`;return m.debug(`Stopped recording`,{recordingId:e,snapshotCount:t.snapshotCount}),r}getRecording(e){return this.recordings.get(e)}getRecordingByTarget(e){for(let[t,n]of this.recordings)if(n.targetId===e)return t}async ensureDir(e){await this.fs.mkdir(e,{recursive:!0})}};function g(e,t){try{let n=Function(`entry`,`return (${t})(entry);`),r=[];for(let t of e)try{let e=n(t);if(e===!1)continue;typeof e==`object`&&e?r.push(e):r.push(t)}catch(e){m.error(`Filter function error on entry, keeping it`,{error:e instanceof Error?e.message:String(e)}),r.push(t)}return r}catch(t){return m.error(`Failed to compile filter, returning unfiltered`,{error:t instanceof Error?t.message:String(t)}),e}}var _=`(function() {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
// ===== DOM Utilities =====
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./account-store-
|
|
1
|
+
import{a as e}from"./account-store-irTFXEHq.js";import{a as t}from"./diagnostics-DN_idNHx.js";import{a as n}from"./compat-uEPf6-XW.js";import{r,s as i}from"./legacy-api-aliases-jKEvBgOL.js";const a=`cerebras`,o=`https://api.cerebras.ai/v1`,s=`openai-completions`,c=`${a}-openai`,l=`slicc-cerebras-models`;let u=[];const d=[{id:`gpt-oss-120b`,name:`GPT OSS 120B`,api:`openai`,reasoning:!0,input:[`text`],context_window:131072,max_tokens:40960},{id:`gemma-4-31b`,name:`Gemma 4 31B`,api:`openai`,reasoning:!1,input:[`text`,`image`],context_window:131072,max_tokens:40960},{id:`zai-glm-4.7`,name:`Z.AI GLM-4.7`,api:`openai`,reasoning:!1,input:[`text`],context_window:131072,max_tokens:40960}];function f(e){try{localStorage.setItem(l,JSON.stringify(e))}catch{}}function p(){try{let e=localStorage.getItem(l);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function m(e){let t=e.id??``,n=d.find(e=>e.id===t);return{id:t,name:e.name??n?.name??t,api:`openai`,reasoning:e.capabilities?.reasoning??n?.reasoning??!1,input:e.capabilities?.vision?[`text`,`image`]:n?.input??[`text`],context_window:e.limits?.max_context_length??n?.context_window??8192,max_tokens:e.limits?.max_completion_tokens??n?.max_tokens??4096}}async function h(e){let t=await fetch(`${o}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(m).filter(e=>e.id.length>0);n.length>0&&(u=n,f(n))}function g(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:c,provider:a,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}function _(e){console.error(`[cerebras] Stream error:`,e instanceof Error?e.message:String(e))}const v=(e,n,r={})=>{let i=t();return y(i,e,n,r).catch(_),i};async function y(e,t,n,i){try{let a={...t,baseUrl:o,api:s},c=r(a,n,i);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}const b=(e,n,r)=>{let i=t();return x(i,e,n,r).catch(_),i};async function x(e,t,n,r){try{let a={...t,baseUrl:o,api:s},c=i(a,n,r);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}const S={id:a,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(u.length>0)return u;let e=p();return e.length>0?e:d},refreshModels:async t=>{let n=t??e(a)??``;if(n)try{await h(n)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function C(){n({api:c,stream:v,streamSimple:b})}export{S as config,C as register};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./diagnostics-DN_idNHx.js";import{a as t}from"./compat-qQM4gjF_.js";import{r as n,s as r}from"./legacy-api-aliases-DtQJ5I7w.js";import{_ as i}from"./account-store-
|
|
1
|
+
import{a as e}from"./diagnostics-DN_idNHx.js";import{a as t}from"./compat-qQM4gjF_.js";import{r as n,s as r}from"./legacy-api-aliases-DtQJ5I7w.js";import{_ as i}from"./account-store-Bevys7WL.js";var a=`cerebras`,o=`https://api.cerebras.ai/v1`,s=`openai-completions`,c=`${a}-openai`,l=`slicc-cerebras-models`,u=[],d=[{id:`gpt-oss-120b`,name:`GPT OSS 120B`,api:`openai`,reasoning:!0,input:[`text`],context_window:131072,max_tokens:40960},{id:`gemma-4-31b`,name:`Gemma 4 31B`,api:`openai`,reasoning:!1,input:[`text`,`image`],context_window:131072,max_tokens:40960},{id:`zai-glm-4.7`,name:`Z.AI GLM-4.7`,api:`openai`,reasoning:!1,input:[`text`],context_window:131072,max_tokens:40960}];function f(e){try{localStorage.setItem(l,JSON.stringify(e))}catch{}}function p(){try{let e=localStorage.getItem(l);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function m(e){let t=e.id??``,n=d.find(e=>e.id===t);return{id:t,name:e.name??n?.name??t,api:`openai`,reasoning:e.capabilities?.reasoning??n?.reasoning??!1,input:e.capabilities?.vision?[`text`,`image`]:n?.input??[`text`],context_window:e.limits?.max_context_length??n?.context_window??8192,max_tokens:e.limits?.max_completion_tokens??n?.max_tokens??4096}}async function h(e){let t=await fetch(`${o}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(m).filter(e=>e.id.length>0);n.length>0&&(u=n,f(n))}function g(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:c,provider:a,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}function _(e){console.error(`[cerebras] Stream error:`,e instanceof Error?e.message:String(e))}var v=(t,n,r={})=>{let i=e();return y(i,t,n,r).catch(_),i};async function y(e,t,r,i){try{let a={...t,baseUrl:o,api:s},c=n(a,r,i);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}var b=(t,n,r)=>{let i=e();return x(i,t,n,r).catch(_),i};async function x(e,t,n,i){try{let a={...t,baseUrl:o,api:s},c=r(a,n,i);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}var S={id:a,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(u.length>0)return u;let e=p();return e.length>0?e:d},refreshModels:async e=>{let t=e??i(a)??``;if(t)try{await h(t)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function C(){t({api:c,stream:v,streamSimple:b})}export{S as config,C as register};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./logger-DDBAeTLF.js";import{st as t}from"./wc-shell-
|
|
1
|
+
import{t as e}from"./logger-DDBAeTLF.js";import{st as t}from"./wc-shell-DdSbkIp-.js";import{n}from"./runtime-env-Dlaokqg1.js";import{t as r}from"./permissions-surface-registry-CilCRwhh.js";import{t as i}from"./speech-assets-bridge-CFYafE89.js";import{o as a}from"./transformers-env-DVU2J7Xd.js";import{i as o,t as s}from"./whisper-session-DBea3Pzc.js";var c=e(`speech:composer`),l=5e3,u=(e,t,n)=>new Promise((r,i)=>{let a=setTimeout(()=>i(Error(`${n} timed out after ${t}ms`)),t);e.then(e=>{clearTimeout(a),r(e)},e=>{clearTimeout(a),i(e)})}),d=class{#e;#t;#n;#r;#i;#a=null;#o=!1;#s={engine:`builtin`,state:`idle`};#c=a();#l=new Set;#u=null;constructor(e={}){this.#e=e.builtin??t(),this.#t=e.loadWhisper??o,this.#n=e.startSession??s,this.#r=e.getPermissionSurface??f,this.#i=e.ensureAssets??v}permission(){return this.#e.permission()}async requestPermission(){let e=this.#r();if(e)try{let t=await e.request(`microphone`);return t?(this.#p(t.stream),!0):!1}catch(e){return c.warn(`permission surface microphone request failed`,e),!1}return this.#e.requestPermission()}microphones(){return this.#e.microphones()}status(){return this.#s}onStatus(e){return this.#l.add(e),e(this.#s),()=>this.#l.delete(e)}warmup(){this.#o||(this.#o=!0,this.#c=a(),this.#_({engine:`builtin`,state:`downloading`}),this.#d().then(e=>{this.#a=e,this.#_({engine:`enhanced`,state:`ready`})},e=>{this.#o=!1,this.#_({engine:`builtin`,state:`unavailable`,message:m(e)}),c.warn(`enhanced speech engine unavailable`,e)}))}async#d(){let e=null;try{await this.#i(e=>this.#h(e))}catch(t){e=t,c.warn(`speech asset staging failed; trying already-present assets`,t)}try{return await this.#t(e=>this.#g(e))}catch(t){throw e??t}}async start(e){let t=this.#a;if(t){let n=null;try{return n=await this.#f(e.deviceId),await this.#n(t,{deviceId:e.deviceId,lang:e.lang,onPartial:e.onPartial,onError:e.onError,stream:n??void 0})}catch(e){if(n)for(let e of n.getTracks())e.stop();c.warn(`whisper session failed to start; falling back to builtin`,e)}}return this.#e.start(e)}async#f(e){let t=e&&e!=="default"?e:void 0,n=this.#m();if(n){if(!t&&p(n))return n;for(let e of n.getTracks())e.stop()}let r=this.#r();if(!r)return null;let i={audio:!t||{deviceId:{exact:t}}},a=await u(r.request(`microphone`,{constraints:i}),l,`microphone capture`);if(!a)throw Error(`microphone permission denied`);return a.stream}#p(e){if(this.#u&&this.#u!==e)for(let e of this.#u.getTracks())e.stop();this.#u=e}#m(){let e=this.#u;return this.#u=null,e}get enhancedReady(){return this.#a!==null}#h(e){if(this.#s.state!==`downloading`)return;(e.bytesTotal!=null||e.bytesLoaded!=null)&&this.#c.update(e.asset,e.bytesLoaded??0,e.bytesTotal??0);let t=this.#c.snapshot();t.total<=0||this.#_({engine:`builtin`,state:`downloading`,download:{loaded:t.loaded,total:t.total,etaSeconds:t.etaSeconds}})}#g(e){this.#s.state===`downloading`&&this.#_({engine:`builtin`,state:`downloading`,download:{loaded:e.loaded,total:e.total,etaSeconds:e.etaSeconds}})}#_(e){this.#s=e;for(let t of this.#l)t(e)}};function f(){let e=r();return e?{async request(t,n){let r=await e.request(t,n);return r?.kind===`microphone`?{kind:`microphone`,stream:r.stream}:null}}:null}function p(e){let t=e.getTracks();return t.length>0&&t.some(e=>e.readyState!==`ended`)}function m(e){return`Enhanced speech unavailable: ${e instanceof Error?e.message:String(e)}`}var h=n,g;function _(e){g=e}function v(e){return h()?Promise.resolve():i({instanceId:g,onProgress:e})}var y=null;function b(){return y??=new d,y}export{b as getComposerSpeech,_ as setComposerSpeechInstanceId};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{B as e,E as t,f as n,p as r}from"./account-store-
|
|
1
|
+
import{B as e,E as t,f as n,p as r}from"./account-store-Bevys7WL.js";import{a as i}from"./main-DUD5pTDH.js";var a=`slicc_cloud_model_catalog`,o=`adobe`;function s(e){if(e===o)return!1;let n=t(e);return!(n.hidden||n.onOAuthLoginIntercepted)}function c(){try{let e=r().map(e=>({providerId:e.providerId,providerName:e.providerName,models:e.models.map(e=>({id:e.id,name:e.name}))}));localStorage.setItem(a,JSON.stringify(e))}catch{}}async function l(r){for(;r.firstChild;)r.removeChild(r.firstChild);r.className=`connect-surface`;let a=document.createElement(`h1`);a.className=`connect-surface__title`,a.textContent=`Connect providers`,r.appendChild(a);let l=document.createElement(`p`);l.className=`connect-surface__desc`,l.textContent=`Log in or add API keys for the providers your cone should use, then click Done to return to the dashboard.`,r.appendChild(l);let u=document.createElement(`div`);u.className=`connect-surface__accounts`,r.appendChild(u);function d(){for(;u.firstChild;)u.removeChild(u.firstChild);let r=n().filter(e=>e.providerId!==o);if(r.length===0){let e=document.createElement(`div`);e.className=`connect-surface__empty`,e.textContent=`No providers connected yet.`,u.appendChild(e)}else{let n=document.createElement(`div`);n.className=`connect-surface__accounts-list`;for(let i of r){let r=t(i.providerId),a=document.createElement(`div`);a.className=`connect-surface__account-row`;let o=document.createElement(`div`);o.className=`connect-surface__account-info`;let s=document.createElement(`div`);s.className=`connect-surface__account-name`,s.textContent=r.name,o.appendChild(s);let l=document.createElement(`div`);l.className=`connect-surface__account-detail`,l.textContent=i.userName?i.userName:i.accessToken?`Logged in`:i.apiKey?`API key set`:`No credentials`,o.appendChild(l),a.appendChild(o);let u=document.createElement(`button`);u.className=`connect-surface__remove-btn`,u.textContent=`Remove`,u.onclick=async()=>{await e(i.providerId),c(),d()},a.appendChild(u),n.appendChild(a)}u.appendChild(n)}let a=document.createElement(`button`);a.className=`connect-surface__add-btn`,a.textContent=r.length===0?`Add provider`:`Manage providers`,a.onclick=async()=>{await i({startInAddAccount:!0,providerFilter:s})&&(c(),d())},u.appendChild(a)}d(),c();let f=document.createElement(`div`);f.className=`connect-surface__footer`;let p=document.createElement(`button`);if(p.className=`connect-surface__done-btn`,p.textContent=`Done — return to dashboard`,p.onclick=()=>{c(),window.close()},f.appendChild(p),r.appendChild(f),!document.getElementById(`connect-surface-style`)){let e=document.createElement(`style`);e.id=`connect-surface-style`,e.textContent=`
|
|
2
2
|
.connect-surface {
|
|
3
3
|
padding: 2rem;
|
|
4
4
|
max-width: 560px;
|