just-bash 1.0.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/LICENSE +201 -0
- package/README.md +326 -0
- package/dist/Bash.d.ts +90 -0
- package/dist/ai/index.d.ts +56 -0
- package/dist/ast/types.d.ts +518 -0
- package/dist/bin/chunks/alias-74DFXE2E.js +7 -0
- package/dist/bin/chunks/awk-S63F6IYK.js +15 -0
- package/dist/bin/chunks/base64-NC7HTKLZ.js +5 -0
- package/dist/bin/chunks/basename-Y7JDBYHN.js +6 -0
- package/dist/bin/chunks/bash-TQGTNXAE.js +7 -0
- package/dist/bin/chunks/cat-YZXBF5YF.js +6 -0
- package/dist/bin/chunks/chmod-3G4LK462.js +9 -0
- package/dist/bin/chunks/chunk-26Q3PZQ6.js +2 -0
- package/dist/bin/chunks/chunk-4VDEBYW7.js +2 -0
- package/dist/bin/chunks/chunk-5KNEBKYN.js +2 -0
- package/dist/bin/chunks/chunk-GTNBSMZR.js +23 -0
- package/dist/bin/chunks/chunk-J7BCMQDI.js +16 -0
- package/dist/bin/chunks/chunk-J7MJV6WO.js +3 -0
- package/dist/bin/chunks/chunk-LV662IGP.js +6 -0
- package/dist/bin/chunks/chunk-TA7RUHGQ.js +4 -0
- package/dist/bin/chunks/clear-GTCFHSB2.js +2 -0
- package/dist/bin/chunks/cp-77UY7PGN.js +8 -0
- package/dist/bin/chunks/curl-NE7XEWMN.js +26 -0
- package/dist/bin/chunks/cut-UYV3FM7R.js +6 -0
- package/dist/bin/chunks/date-7NBRXV2Z.js +5 -0
- package/dist/bin/chunks/diff-TG2NXCX2.js +19 -0
- package/dist/bin/chunks/dirname-VLHP44TU.js +5 -0
- package/dist/bin/chunks/du-4FZ7WF2P.js +8 -0
- package/dist/bin/chunks/echo-DEUIS5JO.js +4 -0
- package/dist/bin/chunks/env-FVITWNHG.js +9 -0
- package/dist/bin/chunks/expr-HA2ZNL6S.js +5 -0
- package/dist/bin/chunks/find-4B67H4RP.js +11 -0
- package/dist/bin/chunks/grep-OVWU4WCZ.js +15 -0
- package/dist/bin/chunks/head-VGXR3WWL.js +2 -0
- package/dist/bin/chunks/help-5V3MPCYQ.js +16 -0
- package/dist/bin/chunks/history-PRQ4B6N2.js +3 -0
- package/dist/bin/chunks/html-to-markdown-L4UWMK4S.js +84 -0
- package/dist/bin/chunks/jq-EYSXBSCP.js +14 -0
- package/dist/bin/chunks/ln-DB7J2W5X.js +10 -0
- package/dist/bin/chunks/ls-C4MPAF3H.js +26 -0
- package/dist/bin/chunks/mkdir-LWULWDHP.js +7 -0
- package/dist/bin/chunks/mv-TDYCNSIQ.js +7 -0
- package/dist/bin/chunks/paste-R36J3G4K.js +8 -0
- package/dist/bin/chunks/printf-BOFQVMMK.js +15 -0
- package/dist/bin/chunks/pwd-X4MWD4JP.js +3 -0
- package/dist/bin/chunks/readlink-DPNOQY67.js +7 -0
- package/dist/bin/chunks/rm-W6CCBEMG.js +8 -0
- package/dist/bin/chunks/sed-7IS44XON.js +48 -0
- package/dist/bin/chunks/seq-DGJILX2Q.js +7 -0
- package/dist/bin/chunks/sleep-E4DIYGTT.js +10 -0
- package/dist/bin/chunks/sort-UJP353TM.js +15 -0
- package/dist/bin/chunks/stat-3PHITCPO.js +9 -0
- package/dist/bin/chunks/tail-YSVKBQ77.js +2 -0
- package/dist/bin/chunks/tee-UU2VS3OM.js +3 -0
- package/dist/bin/chunks/timeout-OZVAGW2H.js +12 -0
- package/dist/bin/chunks/touch-XCIAYF5I.js +4 -0
- package/dist/bin/chunks/tr-2EEKHHO6.js +20 -0
- package/dist/bin/chunks/tree-4247W67O.js +12 -0
- package/dist/bin/chunks/true-JCX733LK.js +2 -0
- package/dist/bin/chunks/uniq-W4HF6YSB.js +5 -0
- package/dist/bin/chunks/wc-CNJ3QDRA.js +6 -0
- package/dist/bin/chunks/which-HX2NMOP3.js +3 -0
- package/dist/bin/chunks/xargs-YNLVLPOF.js +4 -0
- package/dist/bin/just-bash.js +188 -0
- package/dist/bin/shell/chunks/alias-74DFXE2E.js +7 -0
- package/dist/bin/shell/chunks/awk-S63F6IYK.js +15 -0
- package/dist/bin/shell/chunks/base64-NC7HTKLZ.js +5 -0
- package/dist/bin/shell/chunks/basename-Y7JDBYHN.js +6 -0
- package/dist/bin/shell/chunks/bash-TQGTNXAE.js +7 -0
- package/dist/bin/shell/chunks/cat-YZXBF5YF.js +6 -0
- package/dist/bin/shell/chunks/chmod-3G4LK462.js +9 -0
- package/dist/bin/shell/chunks/chunk-26Q3PZQ6.js +2 -0
- package/dist/bin/shell/chunks/chunk-4VDEBYW7.js +2 -0
- package/dist/bin/shell/chunks/chunk-5KNEBKYN.js +2 -0
- package/dist/bin/shell/chunks/chunk-GTNBSMZR.js +23 -0
- package/dist/bin/shell/chunks/chunk-J7BCMQDI.js +16 -0
- package/dist/bin/shell/chunks/chunk-J7MJV6WO.js +3 -0
- package/dist/bin/shell/chunks/chunk-LV662IGP.js +6 -0
- package/dist/bin/shell/chunks/chunk-TA7RUHGQ.js +4 -0
- package/dist/bin/shell/chunks/clear-GTCFHSB2.js +2 -0
- package/dist/bin/shell/chunks/cp-77UY7PGN.js +8 -0
- package/dist/bin/shell/chunks/curl-NE7XEWMN.js +26 -0
- package/dist/bin/shell/chunks/cut-UYV3FM7R.js +6 -0
- package/dist/bin/shell/chunks/date-7NBRXV2Z.js +5 -0
- package/dist/bin/shell/chunks/diff-TG2NXCX2.js +19 -0
- package/dist/bin/shell/chunks/dirname-VLHP44TU.js +5 -0
- package/dist/bin/shell/chunks/du-4FZ7WF2P.js +8 -0
- package/dist/bin/shell/chunks/echo-DEUIS5JO.js +4 -0
- package/dist/bin/shell/chunks/env-FVITWNHG.js +9 -0
- package/dist/bin/shell/chunks/expr-HA2ZNL6S.js +5 -0
- package/dist/bin/shell/chunks/find-4B67H4RP.js +11 -0
- package/dist/bin/shell/chunks/grep-OVWU4WCZ.js +15 -0
- package/dist/bin/shell/chunks/head-VGXR3WWL.js +2 -0
- package/dist/bin/shell/chunks/help-5V3MPCYQ.js +16 -0
- package/dist/bin/shell/chunks/history-PRQ4B6N2.js +3 -0
- package/dist/bin/shell/chunks/html-to-markdown-L4UWMK4S.js +84 -0
- package/dist/bin/shell/chunks/jq-EYSXBSCP.js +14 -0
- package/dist/bin/shell/chunks/ln-DB7J2W5X.js +10 -0
- package/dist/bin/shell/chunks/ls-C4MPAF3H.js +26 -0
- package/dist/bin/shell/chunks/mkdir-LWULWDHP.js +7 -0
- package/dist/bin/shell/chunks/mv-TDYCNSIQ.js +7 -0
- package/dist/bin/shell/chunks/paste-R36J3G4K.js +8 -0
- package/dist/bin/shell/chunks/printf-BOFQVMMK.js +15 -0
- package/dist/bin/shell/chunks/pwd-X4MWD4JP.js +3 -0
- package/dist/bin/shell/chunks/readlink-DPNOQY67.js +7 -0
- package/dist/bin/shell/chunks/rm-W6CCBEMG.js +8 -0
- package/dist/bin/shell/chunks/sed-7IS44XON.js +48 -0
- package/dist/bin/shell/chunks/seq-DGJILX2Q.js +7 -0
- package/dist/bin/shell/chunks/sleep-E4DIYGTT.js +10 -0
- package/dist/bin/shell/chunks/sort-UJP353TM.js +15 -0
- package/dist/bin/shell/chunks/stat-3PHITCPO.js +9 -0
- package/dist/bin/shell/chunks/tail-YSVKBQ77.js +2 -0
- package/dist/bin/shell/chunks/tee-UU2VS3OM.js +3 -0
- package/dist/bin/shell/chunks/timeout-OZVAGW2H.js +12 -0
- package/dist/bin/shell/chunks/touch-XCIAYF5I.js +4 -0
- package/dist/bin/shell/chunks/tr-2EEKHHO6.js +20 -0
- package/dist/bin/shell/chunks/tree-4247W67O.js +12 -0
- package/dist/bin/shell/chunks/true-JCX733LK.js +2 -0
- package/dist/bin/shell/chunks/uniq-W4HF6YSB.js +5 -0
- package/dist/bin/shell/chunks/wc-CNJ3QDRA.js +6 -0
- package/dist/bin/shell/chunks/which-HX2NMOP3.js +3 -0
- package/dist/bin/shell/chunks/xargs-YNLVLPOF.js +4 -0
- package/dist/bin/shell/shell.js +172 -0
- package/dist/bundle/ai/index.js +541 -0
- package/dist/bundle/chunks/alias-7ZSTROM7.js +6 -0
- package/dist/bundle/chunks/awk-V4C3GTJI.js +14 -0
- package/dist/bundle/chunks/base64-WATI5PWI.js +4 -0
- package/dist/bundle/chunks/basename-SB5JXIY3.js +5 -0
- package/dist/bundle/chunks/bash-T4PXVRYX.js +6 -0
- package/dist/bundle/chunks/cat-5KESXK2M.js +5 -0
- package/dist/bundle/chunks/chmod-VLKWIL3N.js +8 -0
- package/dist/bundle/chunks/chunk-3YNHMZ5M.js +2 -0
- package/dist/bundle/chunks/chunk-44UOCSGV.js +1 -0
- package/dist/bundle/chunks/chunk-74CEPOFO.js +22 -0
- package/dist/bundle/chunks/chunk-JYYFSUWP.js +5 -0
- package/dist/bundle/chunks/chunk-UJMN5NLH.js +1 -0
- package/dist/bundle/chunks/chunk-W2EKKAIL.js +15 -0
- package/dist/bundle/chunks/chunk-ZVV5VXYZ.js +3 -0
- package/dist/bundle/chunks/clear-ZBD2DMXN.js +1 -0
- package/dist/bundle/chunks/cp-BLHAPLQZ.js +7 -0
- package/dist/bundle/chunks/curl-PA2MWGKN.js +25 -0
- package/dist/bundle/chunks/cut-7RHEYJ7Y.js +5 -0
- package/dist/bundle/chunks/date-YOOSNZVA.js +4 -0
- package/dist/bundle/chunks/diff-IVJFQANX.js +6 -0
- package/dist/bundle/chunks/dirname-Q5HDZLH2.js +4 -0
- package/dist/bundle/chunks/du-I5HYAKTQ.js +7 -0
- package/dist/bundle/chunks/echo-W2TA2N7Y.js +3 -0
- package/dist/bundle/chunks/env-OORA5GFS.js +8 -0
- package/dist/bundle/chunks/expr-A4LJAGVP.js +4 -0
- package/dist/bundle/chunks/find-K3NO35MZ.js +10 -0
- package/dist/bundle/chunks/grep-3D2INI4S.js +14 -0
- package/dist/bundle/chunks/head-7H5R4WKO.js +1 -0
- package/dist/bundle/chunks/help-SDCRRU2F.js +15 -0
- package/dist/bundle/chunks/history-7Z2STZ6Y.js +2 -0
- package/dist/bundle/chunks/html-to-markdown-XMBYO6FD.js +4 -0
- package/dist/bundle/chunks/jq-7R2XGLLH.js +13 -0
- package/dist/bundle/chunks/ln-UTUVIAFP.js +9 -0
- package/dist/bundle/chunks/ls-B7C35UDO.js +23 -0
- package/dist/bundle/chunks/mkdir-WYI2LJ6H.js +6 -0
- package/dist/bundle/chunks/mv-GN23UIZU.js +6 -0
- package/dist/bundle/chunks/paste-L4TYPVSP.js +7 -0
- package/dist/bundle/chunks/printf-3ZT5XOIZ.js +14 -0
- package/dist/bundle/chunks/pwd-ZVX5RTL4.js +2 -0
- package/dist/bundle/chunks/readlink-HHC33N5C.js +6 -0
- package/dist/bundle/chunks/rm-5X2XSQQ6.js +7 -0
- package/dist/bundle/chunks/sed-UZJSXYQZ.js +47 -0
- package/dist/bundle/chunks/seq-TFPZQZPJ.js +6 -0
- package/dist/bundle/chunks/sleep-QJBQD6VS.js +9 -0
- package/dist/bundle/chunks/sort-LHMQWYH2.js +14 -0
- package/dist/bundle/chunks/stat-TM5F5YO4.js +8 -0
- package/dist/bundle/chunks/tail-BLGGG2VX.js +1 -0
- package/dist/bundle/chunks/tee-VCNOG5VI.js +2 -0
- package/dist/bundle/chunks/timeout-THAT7IOO.js +11 -0
- package/dist/bundle/chunks/touch-Z5XRYFYY.js +3 -0
- package/dist/bundle/chunks/tr-UV4V27RJ.js +19 -0
- package/dist/bundle/chunks/tree-75UXQ4XJ.js +11 -0
- package/dist/bundle/chunks/true-OD7ZXH3O.js +1 -0
- package/dist/bundle/chunks/uniq-IIOQKNTS.js +4 -0
- package/dist/bundle/chunks/wc-OXLYBRUE.js +5 -0
- package/dist/bundle/chunks/which-ONWH3TNF.js +2 -0
- package/dist/bundle/chunks/xargs-E5JPQL24.js +3 -0
- package/dist/bundle/index.js +141 -0
- package/dist/commands/alias/alias.d.ts +3 -0
- package/dist/commands/awk/awk.d.ts +2 -0
- package/dist/commands/awk/executor.d.ts +3 -0
- package/dist/commands/awk/expressions.d.ts +3 -0
- package/dist/commands/awk/functions.d.ts +12 -0
- package/dist/commands/awk/parser.d.ts +3 -0
- package/dist/commands/awk/types.d.ts +44 -0
- package/dist/commands/base64/base64.d.ts +5 -0
- package/dist/commands/basename/basename.d.ts +2 -0
- package/dist/commands/bash/bash.d.ts +3 -0
- package/dist/commands/cat/cat.d.ts +2 -0
- package/dist/commands/chmod/chmod.d.ts +2 -0
- package/dist/commands/clear/clear.d.ts +2 -0
- package/dist/commands/cp/cp.d.ts +2 -0
- package/dist/commands/curl/curl.d.ts +8 -0
- package/dist/commands/curl/form.d.ts +21 -0
- package/dist/commands/curl/help.d.ts +9 -0
- package/dist/commands/curl/parse.d.ts +9 -0
- package/dist/commands/curl/types.d.ts +31 -0
- package/dist/commands/curl/utils.d.ts +20 -0
- package/dist/commands/cut/cut.d.ts +2 -0
- package/dist/commands/date/date.d.ts +5 -0
- package/dist/commands/diff/diff.d.ts +5 -0
- package/dist/commands/dirname/dirname.d.ts +2 -0
- package/dist/commands/du/du.d.ts +2 -0
- package/dist/commands/echo/echo.d.ts +2 -0
- package/dist/commands/env/env.d.ts +3 -0
- package/dist/commands/expr/expr.d.ts +7 -0
- package/dist/commands/find/find.d.ts +2 -0
- package/dist/commands/find/matcher.d.ts +3 -0
- package/dist/commands/find/parser.d.ts +2 -0
- package/dist/commands/find/types.d.ts +70 -0
- package/dist/commands/grep/grep.d.ts +4 -0
- package/dist/commands/head/head-tail-shared.d.ts +38 -0
- package/dist/commands/head/head.d.ts +2 -0
- package/dist/commands/help/help.d.ts +2 -0
- package/dist/commands/help.d.ts +16 -0
- package/dist/commands/history/history.d.ts +2 -0
- package/dist/commands/html-to-markdown/html-to-markdown.d.ts +7 -0
- package/dist/commands/jq/jq.d.ts +14 -0
- package/dist/commands/ln/ln.d.ts +2 -0
- package/dist/commands/ls/ls.d.ts +2 -0
- package/dist/commands/mkdir/mkdir.d.ts +2 -0
- package/dist/commands/mv/mv.d.ts +2 -0
- package/dist/commands/paste/paste.d.ts +2 -0
- package/dist/commands/printf/printf.d.ts +2 -0
- package/dist/commands/pwd/pwd.d.ts +2 -0
- package/dist/commands/readlink/readlink.d.ts +2 -0
- package/dist/commands/registry.d.ts +33 -0
- package/dist/commands/rm/rm.d.ts +2 -0
- package/dist/commands/sed/executor.d.ts +7 -0
- package/dist/commands/sed/parser.d.ts +5 -0
- package/dist/commands/sed/sed.d.ts +2 -0
- package/dist/commands/sed/types.d.ts +141 -0
- package/dist/commands/seq/seq.d.ts +14 -0
- package/dist/commands/sleep/sleep.d.ts +2 -0
- package/dist/commands/sort/comparator.d.ts +9 -0
- package/dist/commands/sort/parser.d.ts +11 -0
- package/dist/commands/sort/sort.d.ts +2 -0
- package/dist/commands/sort/types.d.ts +18 -0
- package/dist/commands/stat/stat.d.ts +2 -0
- package/dist/commands/tail/tail.d.ts +2 -0
- package/dist/commands/tee/tee.d.ts +2 -0
- package/dist/commands/timeout/timeout.d.ts +2 -0
- package/dist/commands/touch/touch.d.ts +2 -0
- package/dist/commands/tr/tr.d.ts +2 -0
- package/dist/commands/tree/tree.d.ts +2 -0
- package/dist/commands/true/true.d.ts +3 -0
- package/dist/commands/uniq/uniq.d.ts +2 -0
- package/dist/commands/wc/wc.d.ts +2 -0
- package/dist/commands/which/which.d.ts +2 -0
- package/dist/commands/xargs/xargs.d.ts +2 -0
- package/dist/fs-interface.d.ts +186 -0
- package/dist/fs.d.ts +39 -0
- package/dist/index.d.ts +12 -0
- package/dist/interpreter/arithmetic.d.ts +29 -0
- package/dist/interpreter/builtins/break.d.ts +6 -0
- package/dist/interpreter/builtins/cd.d.ts +6 -0
- package/dist/interpreter/builtins/continue.d.ts +6 -0
- package/dist/interpreter/builtins/declare.d.ts +29 -0
- package/dist/interpreter/builtins/eval.d.ts +9 -0
- package/dist/interpreter/builtins/exit.d.ts +5 -0
- package/dist/interpreter/builtins/export.d.ts +13 -0
- package/dist/interpreter/builtins/index.d.ts +36 -0
- package/dist/interpreter/builtins/let.d.ts +18 -0
- package/dist/interpreter/builtins/local.d.ts +6 -0
- package/dist/interpreter/builtins/read.d.ts +6 -0
- package/dist/interpreter/builtins/return.d.ts +6 -0
- package/dist/interpreter/builtins/set.d.ts +6 -0
- package/dist/interpreter/builtins/shift.d.ts +12 -0
- package/dist/interpreter/builtins/source.d.ts +6 -0
- package/dist/interpreter/builtins/unset.d.ts +12 -0
- package/dist/interpreter/builtins/variable-helpers.d.ts +30 -0
- package/dist/interpreter/conditionals.d.ts +17 -0
- package/dist/interpreter/control-flow.d.ts +21 -0
- package/dist/interpreter/errors.d.ts +107 -0
- package/dist/interpreter/expansion/analysis.d.ts +39 -0
- package/dist/interpreter/expansion/brace-range.d.ts +20 -0
- package/dist/interpreter/expansion/pattern.d.ts +22 -0
- package/dist/interpreter/expansion/variable.d.ts +27 -0
- package/dist/interpreter/expansion/word-split.d.ts +24 -0
- package/dist/interpreter/expansion.d.ts +27 -0
- package/dist/interpreter/functions.d.ts +12 -0
- package/dist/interpreter/helpers/array.d.ts +23 -0
- package/dist/interpreter/helpers/condition.d.ts +22 -0
- package/dist/interpreter/helpers/errors.d.ts +8 -0
- package/dist/interpreter/helpers/file-tests.d.ts +33 -0
- package/dist/interpreter/helpers/ifs.d.ts +43 -0
- package/dist/interpreter/helpers/loop.d.ts +24 -0
- package/dist/interpreter/helpers/numeric-compare.d.ts +13 -0
- package/dist/interpreter/helpers/readonly.d.ts +21 -0
- package/dist/interpreter/helpers/regex.d.ts +8 -0
- package/dist/interpreter/helpers/result.d.ts +54 -0
- package/dist/interpreter/helpers/statements.d.ts +20 -0
- package/dist/interpreter/helpers/string-compare.d.ts +22 -0
- package/dist/interpreter/helpers/string-tests.d.ts +13 -0
- package/dist/interpreter/helpers/variable-tests.d.ts +9 -0
- package/dist/interpreter/helpers/word-parts.d.ts +22 -0
- package/dist/interpreter/index.d.ts +3 -0
- package/dist/interpreter/interpreter.d.ts +61 -0
- package/dist/interpreter/redirections.d.ts +14 -0
- package/dist/interpreter/types.d.ts +68 -0
- package/dist/limits.d.ts +26 -0
- package/dist/network/allow-list/shared.d.ts +45 -0
- package/dist/network/allow-list.d.ts +51 -0
- package/dist/network/fetch.d.ts +25 -0
- package/dist/network/index.d.ts +7 -0
- package/dist/network/types.d.ts +85 -0
- package/dist/overlay-fs/OverlayFs.d.ts +87 -0
- package/dist/overlay-fs/index.d.ts +1 -0
- package/dist/parser/arithmetic-parser.d.ts +25 -0
- package/dist/parser/command-parser.d.ts +10 -0
- package/dist/parser/compound-parser.d.ts +14 -0
- package/dist/parser/conditional-parser.d.ts +8 -0
- package/dist/parser/expansion-parser.d.ts +10 -0
- package/dist/parser/lexer.d.ts +135 -0
- package/dist/parser/parser.d.ts +92 -0
- package/dist/parser/types.d.ts +23 -0
- package/dist/parser/word-parser.d.ts +33 -0
- package/dist/sandbox/Command.d.ts +28 -0
- package/dist/sandbox/Sandbox.d.ts +60 -0
- package/dist/sandbox/index.d.ts +2 -0
- package/dist/types.d.ts +80 -0
- package/dist/utils/args.d.ts +55 -0
- package/dist/utils/file-reader.d.ts +64 -0
- package/dist/utils/glob.d.ts +25 -0
- package/package.json +103 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interpreter - AST Execution Engine
|
|
3
|
+
*
|
|
4
|
+
* Main interpreter class that executes bash AST nodes.
|
|
5
|
+
* Delegates to specialized modules for:
|
|
6
|
+
* - Word expansion (expansion.ts)
|
|
7
|
+
* - Arithmetic evaluation (arithmetic.ts)
|
|
8
|
+
* - Conditional evaluation (conditionals.ts)
|
|
9
|
+
* - Built-in commands (builtins.ts)
|
|
10
|
+
* - Redirections (redirections.ts)
|
|
11
|
+
*/
|
|
12
|
+
import type { ScriptNode } from "../ast/types.js";
|
|
13
|
+
import type { IFileSystem } from "../fs-interface.js";
|
|
14
|
+
import type { ExecutionLimits } from "../limits.js";
|
|
15
|
+
import type { SecureFetch } from "../network/index.js";
|
|
16
|
+
import type { CommandRegistry, ExecResult } from "../types.js";
|
|
17
|
+
import type { InterpreterState } from "./types.js";
|
|
18
|
+
export type { InterpreterContext, InterpreterState } from "./types.js";
|
|
19
|
+
export interface InterpreterOptions {
|
|
20
|
+
fs: IFileSystem;
|
|
21
|
+
commands: CommandRegistry;
|
|
22
|
+
limits: Required<ExecutionLimits>;
|
|
23
|
+
exec: (script: string, options?: {
|
|
24
|
+
env?: Record<string, string>;
|
|
25
|
+
cwd?: string;
|
|
26
|
+
}) => Promise<ExecResult>;
|
|
27
|
+
/** Optional secure fetch function for network-enabled commands */
|
|
28
|
+
fetch?: SecureFetch;
|
|
29
|
+
/** Optional sleep function for testing with mock clocks */
|
|
30
|
+
sleep?: (ms: number) => Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export declare class Interpreter {
|
|
33
|
+
private ctx;
|
|
34
|
+
constructor(options: InterpreterOptions, state: InterpreterState);
|
|
35
|
+
executeScript(node: ScriptNode): Promise<ExecResult>;
|
|
36
|
+
private executeStatement;
|
|
37
|
+
private executePipeline;
|
|
38
|
+
private executeCommand;
|
|
39
|
+
private executeSimpleCommand;
|
|
40
|
+
private executeSimpleCommandInner;
|
|
41
|
+
private runCommand;
|
|
42
|
+
/**
|
|
43
|
+
* Resolve a command name to its implementation via PATH lookup.
|
|
44
|
+
* Returns the command and its resolved path, or null if not found.
|
|
45
|
+
*
|
|
46
|
+
* Resolution order:
|
|
47
|
+
* 1. If command contains "/", resolve as a path
|
|
48
|
+
* 2. Search PATH directories for the command file
|
|
49
|
+
* 3. Fall back to registry lookup (for non-VirtualFs filesystems like OverlayFs)
|
|
50
|
+
*/
|
|
51
|
+
private resolveCommand;
|
|
52
|
+
/**
|
|
53
|
+
* Find all paths for a command in PATH (for `which -a`).
|
|
54
|
+
*/
|
|
55
|
+
findCommandInPath(commandName: string): Promise<string[]>;
|
|
56
|
+
private handleType;
|
|
57
|
+
private executeSubshell;
|
|
58
|
+
private executeGroup;
|
|
59
|
+
private executeArithmeticCommand;
|
|
60
|
+
private executeConditionalCommand;
|
|
61
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redirection Handling
|
|
3
|
+
*
|
|
4
|
+
* Handles output redirections:
|
|
5
|
+
* - > : Write stdout to file
|
|
6
|
+
* - >> : Append stdout to file
|
|
7
|
+
* - 2> : Write stderr to file
|
|
8
|
+
* - &> : Write both stdout and stderr to file
|
|
9
|
+
* - >& : Redirect fd to another fd
|
|
10
|
+
*/
|
|
11
|
+
import type { RedirectionNode } from "../ast/types.js";
|
|
12
|
+
import type { ExecResult } from "../types.js";
|
|
13
|
+
import type { InterpreterContext } from "./types.js";
|
|
14
|
+
export declare function applyRedirections(ctx: InterpreterContext, result: ExecResult, redirections: RedirectionNode[]): Promise<ExecResult>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interpreter Types
|
|
3
|
+
*/
|
|
4
|
+
import type { CommandNode, FunctionDefNode, ScriptNode, StatementNode } from "../ast/types.js";
|
|
5
|
+
import type { IFileSystem } from "../fs-interface.js";
|
|
6
|
+
import type { ExecutionLimits } from "../limits.js";
|
|
7
|
+
import type { SecureFetch } from "../network/index.js";
|
|
8
|
+
import type { CommandRegistry, ExecResult } from "../types.js";
|
|
9
|
+
export interface ShellOptions {
|
|
10
|
+
/** set -e: Exit immediately if a command exits with non-zero status */
|
|
11
|
+
errexit: boolean;
|
|
12
|
+
/** set -o pipefail: Return the exit status of the last (rightmost) command in a pipeline that fails */
|
|
13
|
+
pipefail: boolean;
|
|
14
|
+
/** set -u: Treat unset variables as an error when substituting */
|
|
15
|
+
nounset: boolean;
|
|
16
|
+
/** set -x: Print commands and their arguments as they are executed */
|
|
17
|
+
xtrace: boolean;
|
|
18
|
+
/** set -v: Print shell input lines as they are read (verbose) */
|
|
19
|
+
verbose: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface InterpreterState {
|
|
22
|
+
env: Record<string, string>;
|
|
23
|
+
cwd: string;
|
|
24
|
+
previousDir: string;
|
|
25
|
+
functions: Map<string, FunctionDefNode>;
|
|
26
|
+
localScopes: Map<string, string | undefined>[];
|
|
27
|
+
callDepth: number;
|
|
28
|
+
/** Current source script nesting depth (for return in sourced scripts) */
|
|
29
|
+
sourceDepth: number;
|
|
30
|
+
commandCount: number;
|
|
31
|
+
lastExitCode: number;
|
|
32
|
+
/** Last argument of previous command, for $_ expansion */
|
|
33
|
+
lastArg: string;
|
|
34
|
+
/** Shell options (set -e, etc.) */
|
|
35
|
+
options: ShellOptions;
|
|
36
|
+
/** True when executing condition for if/while/until (errexit doesn't apply) */
|
|
37
|
+
inCondition: boolean;
|
|
38
|
+
/** Current loop nesting depth (for break/continue) */
|
|
39
|
+
loopDepth: number;
|
|
40
|
+
/** Stdin available for commands in compound commands (groups, subshells, while loops with piped input) */
|
|
41
|
+
groupStdin?: string;
|
|
42
|
+
/** Set of variable names that are readonly */
|
|
43
|
+
readonlyVars?: Set<string>;
|
|
44
|
+
/** Exit code from expansion errors (arithmetic, etc.) - overrides command exit code */
|
|
45
|
+
expansionExitCode?: number;
|
|
46
|
+
/** Stderr from expansion errors */
|
|
47
|
+
expansionStderr?: string;
|
|
48
|
+
/** Set of variable names that are associative arrays */
|
|
49
|
+
associativeArrays?: Set<string>;
|
|
50
|
+
}
|
|
51
|
+
export interface InterpreterContext {
|
|
52
|
+
state: InterpreterState;
|
|
53
|
+
fs: IFileSystem;
|
|
54
|
+
commands: CommandRegistry;
|
|
55
|
+
/** Execution limits configuration */
|
|
56
|
+
limits: Required<ExecutionLimits>;
|
|
57
|
+
execFn: (script: string, options?: {
|
|
58
|
+
env?: Record<string, string>;
|
|
59
|
+
cwd?: string;
|
|
60
|
+
}) => Promise<ExecResult>;
|
|
61
|
+
executeScript: (node: ScriptNode) => Promise<ExecResult>;
|
|
62
|
+
executeStatement: (node: StatementNode) => Promise<ExecResult>;
|
|
63
|
+
executeCommand: (node: CommandNode, stdin: string) => Promise<ExecResult>;
|
|
64
|
+
/** Optional secure fetch function for network-enabled commands */
|
|
65
|
+
fetch?: SecureFetch;
|
|
66
|
+
/** Optional sleep function for testing with mock clocks */
|
|
67
|
+
sleep?: (ms: number) => Promise<void>;
|
|
68
|
+
}
|
package/dist/limits.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution Limits Configuration
|
|
3
|
+
*
|
|
4
|
+
* Centralized configuration for all execution limits to prevent runaway compute.
|
|
5
|
+
* These limits can be overridden when creating a BashEnv instance.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Configuration for execution limits.
|
|
9
|
+
* All limits are optional - undefined values use defaults.
|
|
10
|
+
*/
|
|
11
|
+
export interface ExecutionLimits {
|
|
12
|
+
/** Maximum function call/recursion depth (default: 100) */
|
|
13
|
+
maxCallDepth?: number;
|
|
14
|
+
/** Maximum number of commands to execute (default: 10000) */
|
|
15
|
+
maxCommandCount?: number;
|
|
16
|
+
/** Maximum loop iterations for bash while/for/until loops (default: 10000) */
|
|
17
|
+
maxLoopIterations?: number;
|
|
18
|
+
/** Maximum loop iterations for AWK while/for loops (default: 10000) */
|
|
19
|
+
maxAwkIterations?: number;
|
|
20
|
+
/** Maximum command iterations for SED (branch loops) (default: 10000) */
|
|
21
|
+
maxSedIterations?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Resolve execution limits by merging user-provided limits with defaults.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveLimits(userLimits?: ExecutionLimits): Required<ExecutionLimits>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for allow-list e2e tests
|
|
3
|
+
*
|
|
4
|
+
* This module provides:
|
|
5
|
+
* - Mock fetch implementation with predefined responses
|
|
6
|
+
* - Environment adapters for BashEnv and Sandbox
|
|
7
|
+
* - Test utilities like expectBlocked
|
|
8
|
+
*/
|
|
9
|
+
import { vi } from "vitest";
|
|
10
|
+
import type { BashOptions } from "../../Bash.js";
|
|
11
|
+
export declare const MOCK_SUCCESS_BODY: string;
|
|
12
|
+
export declare const MOCK_USERS_BODY: string;
|
|
13
|
+
export declare const MOCK_POSTS_BODY: string;
|
|
14
|
+
export declare const MOCK_FILE_BODY: string;
|
|
15
|
+
export declare const MOCK_EVIL_BODY: string;
|
|
16
|
+
export declare const originalFetch: typeof fetch;
|
|
17
|
+
export declare function createMockFetch(): ReturnType<typeof vi.fn<typeof fetch>>;
|
|
18
|
+
/**
|
|
19
|
+
* Environment adapter interface for running tests with both BashEnv and Sandbox
|
|
20
|
+
*/
|
|
21
|
+
export interface EnvAdapter {
|
|
22
|
+
exec(cmd: string): Promise<{
|
|
23
|
+
exitCode: number;
|
|
24
|
+
stdout: string;
|
|
25
|
+
stderr: string;
|
|
26
|
+
}>;
|
|
27
|
+
readFile(path: string): Promise<string>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Creates an adapter for BashEnv
|
|
31
|
+
*/
|
|
32
|
+
export declare function createBashEnvAdapter(options: BashOptions): EnvAdapter;
|
|
33
|
+
/**
|
|
34
|
+
* Creates an adapter for Sandbox
|
|
35
|
+
*/
|
|
36
|
+
export declare function createSandboxAdapter(options: BashOptions): Promise<EnvAdapter>;
|
|
37
|
+
export type AdapterFactory = (options: BashOptions) => EnvAdapter | Promise<EnvAdapter>;
|
|
38
|
+
/**
|
|
39
|
+
* Utility for testing that a URL is blocked
|
|
40
|
+
*/
|
|
41
|
+
export declare function expectBlocked(env: EnvAdapter, url: string, expectedUrl?: string): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Utility for testing that a URL succeeds with expected mock response
|
|
44
|
+
*/
|
|
45
|
+
export declare function expectAllowed(env: EnvAdapter, url: string, expectedBody: string): Promise<void>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL allow-list matching
|
|
3
|
+
*
|
|
4
|
+
* This module provides URL allow-list matching that is enforced at the fetch layer,
|
|
5
|
+
* independent of any parsing or user input manipulation.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Parses a URL string into its components.
|
|
9
|
+
* Returns null if the URL is invalid.
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseUrl(urlString: string): {
|
|
12
|
+
origin: string;
|
|
13
|
+
pathname: string;
|
|
14
|
+
href: string;
|
|
15
|
+
} | null;
|
|
16
|
+
/**
|
|
17
|
+
* Normalizes an allow-list entry for consistent matching.
|
|
18
|
+
* - Removes trailing slashes from origins without paths
|
|
19
|
+
* - Preserves path prefixes as-is
|
|
20
|
+
*/
|
|
21
|
+
export declare function normalizeAllowListEntry(entry: string): {
|
|
22
|
+
origin: string;
|
|
23
|
+
pathPrefix: string;
|
|
24
|
+
} | null;
|
|
25
|
+
/**
|
|
26
|
+
* Checks if a URL matches an allow-list entry.
|
|
27
|
+
*
|
|
28
|
+
* The matching rules are:
|
|
29
|
+
* 1. Origins must match exactly (case-sensitive for scheme and host)
|
|
30
|
+
* 2. The URL's path must start with the allow-list entry's path
|
|
31
|
+
* 3. If the allow-list entry has no path (or just "/"), all paths are allowed
|
|
32
|
+
*
|
|
33
|
+
* @param url The URL to check (as a string)
|
|
34
|
+
* @param allowedEntry The allow-list entry to match against
|
|
35
|
+
* @returns true if the URL matches the allow-list entry
|
|
36
|
+
*/
|
|
37
|
+
export declare function matchesAllowListEntry(url: string, allowedEntry: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Checks if a URL is allowed by any entry in the allow-list.
|
|
40
|
+
*
|
|
41
|
+
* @param url The URL to check
|
|
42
|
+
* @param allowedUrlPrefixes The list of allowed URL prefixes
|
|
43
|
+
* @returns true if the URL is allowed
|
|
44
|
+
*/
|
|
45
|
+
export declare function isUrlAllowed(url: string, allowedUrlPrefixes: string[]): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Validates an allow-list configuration.
|
|
48
|
+
* Each entry must be a full origin (scheme + host), optionally followed by a path prefix.
|
|
49
|
+
* Returns an array of error messages for invalid entries.
|
|
50
|
+
*/
|
|
51
|
+
export declare function validateAllowList(allowedUrlPrefixes: string[]): string[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secure fetch wrapper with allow-list enforcement
|
|
3
|
+
*
|
|
4
|
+
* This module provides a fetch wrapper that:
|
|
5
|
+
* 1. Enforces URL allow-list at the fetch layer (not subject to parsing)
|
|
6
|
+
* 2. Handles redirects manually to check each redirect target against the allow-list
|
|
7
|
+
* 3. Provides timeout support
|
|
8
|
+
*/
|
|
9
|
+
import { type FetchResult, type NetworkConfig } from "./types.js";
|
|
10
|
+
export interface SecureFetchOptions {
|
|
11
|
+
method?: string;
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
body?: string;
|
|
14
|
+
followRedirects?: boolean;
|
|
15
|
+
/** Override timeout for this request (capped at global timeout) */
|
|
16
|
+
timeoutMs?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Type for the secure fetch function
|
|
20
|
+
*/
|
|
21
|
+
export type SecureFetch = (url: string, options?: SecureFetchOptions) => Promise<FetchResult>;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a secure fetch function that enforces the allow-list.
|
|
24
|
+
*/
|
|
25
|
+
export declare function createSecureFetch(config: NetworkConfig): SecureFetch;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network module
|
|
3
|
+
*
|
|
4
|
+
* Provides secure network access with URL allow-list enforcement.
|
|
5
|
+
*/
|
|
6
|
+
export { createSecureFetch, type SecureFetch, type SecureFetchOptions, } from "./fetch.js";
|
|
7
|
+
export { type FetchResult, type HttpMethod, NetworkAccessDeniedError, type NetworkConfig, RedirectNotAllowedError, TooManyRedirectsError, } from "./types.js";
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network configuration types
|
|
3
|
+
*
|
|
4
|
+
* Network access is disabled by default. To enable network access (e.g., for curl),
|
|
5
|
+
* you must explicitly configure allowed URLs.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* HTTP methods that can be allowed
|
|
9
|
+
*/
|
|
10
|
+
export type HttpMethod = "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS";
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for network access
|
|
13
|
+
*/
|
|
14
|
+
export interface NetworkConfig {
|
|
15
|
+
/**
|
|
16
|
+
* List of allowed URL prefixes. Each entry must be a full origin (scheme + host),
|
|
17
|
+
* optionally followed by a path prefix:
|
|
18
|
+
* - An origin: "https://api.example.com" - allows all paths on this origin
|
|
19
|
+
* - An origin + path prefix: "https://api.example.com/v1/" - allows only paths starting with /v1/
|
|
20
|
+
*
|
|
21
|
+
* The check is performed on the full URL, so "https://api.example.com/v1" will allow:
|
|
22
|
+
* - https://api.example.com/v1
|
|
23
|
+
* - https://api.example.com/v1/users
|
|
24
|
+
* - https://api.example.com/v1/users/123
|
|
25
|
+
*
|
|
26
|
+
* But NOT:
|
|
27
|
+
* - https://api.example.com/v2/users
|
|
28
|
+
* - https://api.example.org/v1/users (different origin)
|
|
29
|
+
*
|
|
30
|
+
* Invalid entries (missing scheme, missing host, relative paths) will throw an error.
|
|
31
|
+
*/
|
|
32
|
+
allowedUrlPrefixes?: string[];
|
|
33
|
+
/**
|
|
34
|
+
* List of allowed HTTP methods. Defaults to ["GET", "HEAD"] for safety.
|
|
35
|
+
* dangerouslyAllowFullInternetAccess to enables all methods.
|
|
36
|
+
*/
|
|
37
|
+
allowedMethods?: HttpMethod[];
|
|
38
|
+
/**
|
|
39
|
+
* Bypass the allow-list and allow all URLs and methods.
|
|
40
|
+
* DANGEROUS: Only use this in trusted environments.
|
|
41
|
+
*/
|
|
42
|
+
dangerouslyAllowFullInternetAccess?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Maximum number of redirects to follow (default: 20)
|
|
45
|
+
*/
|
|
46
|
+
maxRedirects?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Request timeout in milliseconds (default: 30000)
|
|
49
|
+
*/
|
|
50
|
+
timeoutMs?: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Result of a network fetch operation
|
|
54
|
+
*/
|
|
55
|
+
export interface FetchResult {
|
|
56
|
+
status: number;
|
|
57
|
+
statusText: string;
|
|
58
|
+
headers: Record<string, string>;
|
|
59
|
+
body: string;
|
|
60
|
+
url: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Error thrown when a URL is not allowed
|
|
64
|
+
*/
|
|
65
|
+
export declare class NetworkAccessDeniedError extends Error {
|
|
66
|
+
constructor(url: string);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Error thrown when too many redirects occur
|
|
70
|
+
*/
|
|
71
|
+
export declare class TooManyRedirectsError extends Error {
|
|
72
|
+
constructor(maxRedirects: number);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Error thrown when a redirect target is not allowed
|
|
76
|
+
*/
|
|
77
|
+
export declare class RedirectNotAllowedError extends Error {
|
|
78
|
+
constructor(url: string);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Error thrown when an HTTP method is not allowed
|
|
82
|
+
*/
|
|
83
|
+
export declare class MethodNotAllowedError extends Error {
|
|
84
|
+
constructor(method: string, allowedMethods: string[]);
|
|
85
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OverlayFs - Copy-on-write filesystem backed by a real directory
|
|
3
|
+
*
|
|
4
|
+
* Reads come from the real filesystem, writes go to an in-memory layer.
|
|
5
|
+
* Changes don't persist to disk and can't escape the root directory.
|
|
6
|
+
*/
|
|
7
|
+
import type { BufferEncoding, CpOptions, FsStat, IFileSystem, MkdirOptions, ReadFileOptions, RmOptions, WriteFileOptions } from "../fs-interface.js";
|
|
8
|
+
type FileContent = string | Uint8Array;
|
|
9
|
+
export interface OverlayFsOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The root directory on the real filesystem.
|
|
12
|
+
* All paths are relative to this root and cannot escape it.
|
|
13
|
+
*/
|
|
14
|
+
root: string;
|
|
15
|
+
/**
|
|
16
|
+
* The virtual mount point where the root directory appears.
|
|
17
|
+
* Defaults to "/home/user/project".
|
|
18
|
+
*/
|
|
19
|
+
mountPoint?: string;
|
|
20
|
+
/**
|
|
21
|
+
* If true, all write operations will throw an error.
|
|
22
|
+
* Useful for truly read-only access to the filesystem.
|
|
23
|
+
* Defaults to false.
|
|
24
|
+
*/
|
|
25
|
+
readOnly?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare class OverlayFs implements IFileSystem {
|
|
28
|
+
private readonly root;
|
|
29
|
+
private readonly mountPoint;
|
|
30
|
+
private readonly readOnly;
|
|
31
|
+
private readonly memory;
|
|
32
|
+
private readonly deleted;
|
|
33
|
+
constructor(options: OverlayFsOptions);
|
|
34
|
+
/**
|
|
35
|
+
* Throws an error if the filesystem is in read-only mode.
|
|
36
|
+
*/
|
|
37
|
+
private assertWritable;
|
|
38
|
+
/**
|
|
39
|
+
* Create directory entries for the mount point path
|
|
40
|
+
*/
|
|
41
|
+
private createMountPointDirs;
|
|
42
|
+
/**
|
|
43
|
+
* Get the mount point for this overlay
|
|
44
|
+
*/
|
|
45
|
+
getMountPoint(): string;
|
|
46
|
+
/**
|
|
47
|
+
* Normalize a virtual path (resolve . and .., ensure starts with /)
|
|
48
|
+
*/
|
|
49
|
+
private normalizePath;
|
|
50
|
+
/**
|
|
51
|
+
* Check if a normalized virtual path is under the mount point.
|
|
52
|
+
* Returns the relative path within the mount point, or null if not under it.
|
|
53
|
+
*/
|
|
54
|
+
private getRelativeToMount;
|
|
55
|
+
/**
|
|
56
|
+
* Convert a virtual path to a real filesystem path.
|
|
57
|
+
* Returns null if the path is not under the mount point or would escape the root.
|
|
58
|
+
*/
|
|
59
|
+
private toRealPath;
|
|
60
|
+
private dirname;
|
|
61
|
+
private ensureParentDirs;
|
|
62
|
+
/**
|
|
63
|
+
* Check if a path exists in the overlay (memory + real fs - deleted)
|
|
64
|
+
*/
|
|
65
|
+
private existsInOverlay;
|
|
66
|
+
readFile(path: string, options?: ReadFileOptions | BufferEncoding): Promise<string>;
|
|
67
|
+
readFileBuffer(path: string, seen?: Set<string>): Promise<Uint8Array>;
|
|
68
|
+
writeFile(path: string, content: FileContent, options?: WriteFileOptions | BufferEncoding): Promise<void>;
|
|
69
|
+
appendFile(path: string, content: FileContent, options?: WriteFileOptions | BufferEncoding): Promise<void>;
|
|
70
|
+
exists(path: string): Promise<boolean>;
|
|
71
|
+
stat(path: string, seen?: Set<string>): Promise<FsStat>;
|
|
72
|
+
lstat(path: string): Promise<FsStat>;
|
|
73
|
+
private resolveSymlink;
|
|
74
|
+
mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
|
75
|
+
readdir(path: string): Promise<string[]>;
|
|
76
|
+
rm(path: string, options?: RmOptions): Promise<void>;
|
|
77
|
+
cp(src: string, dest: string, options?: CpOptions): Promise<void>;
|
|
78
|
+
mv(src: string, dest: string): Promise<void>;
|
|
79
|
+
resolvePath(base: string, path: string): string;
|
|
80
|
+
getAllPaths(): string[];
|
|
81
|
+
private scanRealFs;
|
|
82
|
+
chmod(path: string, mode: number): Promise<void>;
|
|
83
|
+
symlink(target: string, linkPath: string): Promise<void>;
|
|
84
|
+
link(existingPath: string, newPath: string): Promise<void>;
|
|
85
|
+
readlink(path: string): Promise<string>;
|
|
86
|
+
}
|
|
87
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { OverlayFs, type OverlayFsOptions } from "./OverlayFs.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arithmetic Expression Parser
|
|
3
|
+
*
|
|
4
|
+
* Parses bash arithmetic expressions like:
|
|
5
|
+
* - $((1 + 2))
|
|
6
|
+
* - $((x++))
|
|
7
|
+
* - $((a ? b : c))
|
|
8
|
+
* - $((2#1010))
|
|
9
|
+
*
|
|
10
|
+
* All functions take a Parser instance as the first argument for shared state access.
|
|
11
|
+
*/
|
|
12
|
+
import type { ArithExpr, ArithmeticExpressionNode } from "../ast/types.js";
|
|
13
|
+
import type { Parser } from "./parser.js";
|
|
14
|
+
/**
|
|
15
|
+
* Parse an arithmetic expression string into an AST node
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseArithmeticExpression(_p: Parser, input: string): ArithmeticExpressionNode;
|
|
18
|
+
export declare function parseArithExpr(p: Parser, input: string, pos: number): {
|
|
19
|
+
expr: ArithExpr;
|
|
20
|
+
pos: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Parse a number string with various bases (decimal, hex, octal, base#num)
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseArithNumber(str: string): number;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command Parser
|
|
3
|
+
*
|
|
4
|
+
* Handles parsing of simple commands, redirections, and assignments.
|
|
5
|
+
*/
|
|
6
|
+
import { type RedirectionNode, type SimpleCommandNode } from "../ast/types.js";
|
|
7
|
+
import type { Parser } from "./parser.js";
|
|
8
|
+
export declare function isRedirection(p: Parser): boolean;
|
|
9
|
+
export declare function parseRedirection(p: Parser): RedirectionNode;
|
|
10
|
+
export declare function parseSimpleCommand(p: Parser): SimpleCommandNode;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compound Command Parser
|
|
3
|
+
*
|
|
4
|
+
* Handles parsing of compound commands: if, for, while, until, case, subshell, group.
|
|
5
|
+
*/
|
|
6
|
+
import { type CaseNode, type CStyleForNode, type ForNode, type GroupNode, type IfNode, type SubshellNode, type UntilNode, type WhileNode } from "../ast/types.js";
|
|
7
|
+
import type { Parser } from "./parser.js";
|
|
8
|
+
export declare function parseIf(p: Parser): IfNode;
|
|
9
|
+
export declare function parseFor(p: Parser): ForNode | CStyleForNode;
|
|
10
|
+
export declare function parseWhile(p: Parser): WhileNode;
|
|
11
|
+
export declare function parseUntil(p: Parser): UntilNode;
|
|
12
|
+
export declare function parseCase(p: Parser): CaseNode;
|
|
13
|
+
export declare function parseSubshell(p: Parser): SubshellNode | CStyleForNode;
|
|
14
|
+
export declare function parseGroup(p: Parser): GroupNode;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conditional Expression Parser
|
|
3
|
+
*
|
|
4
|
+
* Handles parsing of [[ ... ]] conditional commands.
|
|
5
|
+
*/
|
|
6
|
+
import type { ConditionalExpressionNode } from "../ast/types.js";
|
|
7
|
+
import type { Parser } from "./parser.js";
|
|
8
|
+
export declare function parseConditionalExpression(p: Parser): ConditionalExpressionNode;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expansion Parser
|
|
3
|
+
*
|
|
4
|
+
* Handles parsing of parameter expansions, arithmetic expansions, etc.
|
|
5
|
+
*/
|
|
6
|
+
import { type WordPart } from "../ast/types.js";
|
|
7
|
+
import type { Parser } from "./parser.js";
|
|
8
|
+
export declare function parseWordParts(p: Parser, value: string, quoted?: boolean, singleQuoted?: boolean, isAssignment?: boolean, hereDoc?: boolean,
|
|
9
|
+
/** When true, single quotes are treated as literal characters, not quote delimiters */
|
|
10
|
+
singleQuotesAreLiteral?: boolean): WordPart[];
|