@jerryan/just-bash 3.8.0 → 3.10.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/CHANGELOG.md +38 -0
- package/README.md +5 -15
- package/dist/AGENTS.md +2 -2
- package/dist/Bash.d.ts +2 -4
- package/dist/bin/chunks/builtin-manifest-ORBIZM7I.js +3 -0
- package/dist/bin/chunks/{chmod-GX5SYTRL.js → chmod-S4ARARR4.js} +1 -1
- package/dist/bin/chunks/chunk-3ASHUC7C.js +44 -0
- package/dist/bin/{shell/chunks/chunk-7WBCA2BB.js → chunks/chunk-3DWQCLNP.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-3ROYEBJI.js → chunks/chunk-4JPWP5WS.js} +1 -1
- package/dist/bin/chunks/{chunk-QFTZKD5O.js → chunk-6TUILMPB.js} +1 -1
- package/dist/bin/chunks/{chunk-DRPHNXG7.js → chunk-7LGT4LHQ.js} +1 -1
- package/dist/bin/chunks/{chunk-MBREBDZQ.js → chunk-AIWBN36Z.js} +1 -1
- package/dist/bin/chunks/chunk-AQKIHX3Q.js +3 -0
- package/dist/bin/chunks/chunk-E2O6S35K.js +10 -0
- package/dist/bin/chunks/chunk-E54Z6VIE.js +12 -0
- package/dist/bin/{shell/chunks/chunk-F2PYTUMR.js → chunks/chunk-F4ACJZIY.js} +7 -6
- package/dist/bin/{shell/chunks/chunk-MPFNZYEA.js → chunks/chunk-GKJD4ULC.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-QJWFCA7P.js → chunks/chunk-HARVZWUX.js} +1 -1
- package/dist/bin/chunks/chunk-IRCAXXH6.js +14 -0
- package/dist/bin/chunks/{chunk-T6OIISUC.js → chunk-K65FCSAT.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-MF3GVFLC.js → chunks/chunk-L345YZ6R.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-6FGMEZZP.js → chunks/chunk-MWQMHODV.js} +1 -1
- package/dist/bin/chunks/{chunk-BB5VTPMQ.js → chunk-NSI6LMDS.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-ABP4OLJV.js → chunks/chunk-OXEDIWNZ.js} +1 -1
- package/dist/bin/chunks/chunk-QKJAAJ7J.js +3 -0
- package/dist/bin/chunks/{chunk-KMYJMEON.js → chunk-R7THHH4J.js} +1 -1
- package/dist/bin/chunks/chunk-UBA7DOWE.js +3 -0
- package/dist/bin/chunks/{chunk-VPSBWWXM.js → chunk-UNCYBFWT.js} +7 -6
- package/dist/bin/chunks/chunk-VMVXACZ5.js +6 -0
- package/dist/bin/chunks/chunk-Z3TCELKN.js +12 -0
- package/dist/bin/chunks/{cp-YLP7ULVT.js → cp-WRBRHVVD.js} +1 -1
- package/dist/bin/chunks/{diff-JSJ56EOK.js → diff-YLVT27CZ.js} +1 -1
- package/dist/bin/{shell/chunks/du-DH76GZJ3.js → chunks/du-YNAJTGCR.js} +1 -1
- package/dist/bin/{shell/chunks/find-MHC4QV6H.js → chunks/find-T3JZPTUX.js} +1 -1
- package/dist/bin/chunks/{flag-coverage-2H5CPEM6.js → flag-coverage-LVKHEUTL.js} +1 -1
- package/dist/bin/chunks/{gzip-UQZL4R74.js → gzip-EXJSFNCU.js} +1 -1
- package/dist/bin/chunks/js-exec-PLUMFEX6.js +99 -0
- package/dist/bin/chunks/js-exec-worker.js +4995 -0
- package/dist/bin/chunks/{ls-5Z45FV4U.js → ls-LOCOWLZ3.js} +1 -1
- package/dist/bin/chunks/{mkdir-YJ3SOVRP.js → mkdir-VHLJ3E65.js} +1 -1
- package/dist/bin/chunks/{mv-EOOP2TO3.js → mv-NAMOL2HF.js} +1 -1
- package/dist/bin/chunks/python3-J5GXF27H.js +14 -0
- package/dist/bin/{shell/chunks/readlink-EJ3IKLWW.js → chunks/readlink-BF435HNQ.js} +1 -1
- package/dist/bin/chunks/{rg-WHVR3YDT.js → rg-XF5U7GS2.js} +1 -1
- package/dist/bin/{shell/chunks/rm-B4LVIG7A.js → chunks/rm-L4RHENMV.js} +1 -1
- package/dist/bin/{shell/chunks/rmdir-PRNISPBA.js → chunks/rmdir-W73C4GEA.js} +1 -1
- package/dist/bin/{shell/chunks/sleep-DVFE2GSF.js → chunks/sleep-MOJQBZMY.js} +1 -1
- package/dist/bin/{shell/chunks/split-HIFKSV2A.js → chunks/split-2VXPZJJ4.js} +1 -1
- package/dist/bin/chunks/{sqlite3-KNN6V2W6.js → sqlite3-3S5HIA5W.js} +1 -1
- package/dist/bin/chunks/{timeout-YGFHQJKX.js → timeout-RQOWSWYG.js} +1 -1
- package/dist/bin/chunks/{which-4TPGVSBZ.js → which-G7X54RZL.js} +1 -1
- package/dist/bin/just-bash.js +243 -242
- package/dist/bin/shell/chunks/builtin-manifest-ORBIZM7I.js +3 -0
- package/dist/bin/shell/chunks/{chmod-GX5SYTRL.js → chmod-S4ARARR4.js} +1 -1
- package/dist/bin/shell/chunks/chunk-3ASHUC7C.js +44 -0
- package/dist/bin/{chunks/chunk-7WBCA2BB.js → shell/chunks/chunk-3DWQCLNP.js} +1 -1
- package/dist/bin/{chunks/chunk-3ROYEBJI.js → shell/chunks/chunk-4JPWP5WS.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-QFTZKD5O.js → chunk-6TUILMPB.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-DRPHNXG7.js → chunk-7LGT4LHQ.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-MBREBDZQ.js → chunk-AIWBN36Z.js} +1 -1
- package/dist/bin/shell/chunks/chunk-AQKIHX3Q.js +3 -0
- package/dist/bin/shell/chunks/chunk-E2O6S35K.js +10 -0
- package/dist/bin/shell/chunks/chunk-E54Z6VIE.js +12 -0
- package/dist/bin/{chunks/chunk-F2PYTUMR.js → shell/chunks/chunk-F4ACJZIY.js} +7 -6
- package/dist/bin/{chunks/chunk-MPFNZYEA.js → shell/chunks/chunk-GKJD4ULC.js} +1 -1
- package/dist/bin/{chunks/chunk-QJWFCA7P.js → shell/chunks/chunk-HARVZWUX.js} +1 -1
- package/dist/bin/shell/chunks/chunk-IRCAXXH6.js +14 -0
- package/dist/bin/shell/chunks/{chunk-T6OIISUC.js → chunk-K65FCSAT.js} +1 -1
- package/dist/bin/{chunks/chunk-MF3GVFLC.js → shell/chunks/chunk-L345YZ6R.js} +1 -1
- package/dist/bin/{chunks/chunk-6FGMEZZP.js → shell/chunks/chunk-MWQMHODV.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-BB5VTPMQ.js → chunk-NSI6LMDS.js} +1 -1
- package/dist/bin/{chunks/chunk-ABP4OLJV.js → shell/chunks/chunk-OXEDIWNZ.js} +1 -1
- package/dist/bin/shell/chunks/chunk-QKJAAJ7J.js +3 -0
- package/dist/bin/shell/chunks/{chunk-KMYJMEON.js → chunk-R7THHH4J.js} +1 -1
- package/dist/bin/shell/chunks/chunk-UBA7DOWE.js +3 -0
- package/dist/bin/shell/chunks/{chunk-VPSBWWXM.js → chunk-UNCYBFWT.js} +7 -6
- package/dist/bin/shell/chunks/chunk-VMVXACZ5.js +6 -0
- package/dist/bin/shell/chunks/chunk-Z3TCELKN.js +12 -0
- package/dist/bin/shell/chunks/{cp-YLP7ULVT.js → cp-WRBRHVVD.js} +1 -1
- package/dist/bin/shell/chunks/{diff-JSJ56EOK.js → diff-YLVT27CZ.js} +1 -1
- package/dist/bin/{chunks/du-DH76GZJ3.js → shell/chunks/du-YNAJTGCR.js} +1 -1
- package/dist/bin/{chunks/find-MHC4QV6H.js → shell/chunks/find-T3JZPTUX.js} +1 -1
- package/dist/bin/shell/chunks/{flag-coverage-2H5CPEM6.js → flag-coverage-LVKHEUTL.js} +1 -1
- package/dist/bin/shell/chunks/{gzip-UQZL4R74.js → gzip-EXJSFNCU.js} +1 -1
- package/dist/bin/shell/chunks/js-exec-PLUMFEX6.js +99 -0
- package/dist/bin/shell/chunks/{ls-5Z45FV4U.js → ls-LOCOWLZ3.js} +1 -1
- package/dist/bin/shell/chunks/{mkdir-YJ3SOVRP.js → mkdir-VHLJ3E65.js} +1 -1
- package/dist/bin/shell/chunks/{mv-EOOP2TO3.js → mv-NAMOL2HF.js} +1 -1
- package/dist/bin/shell/chunks/python3-J5GXF27H.js +14 -0
- package/dist/bin/{chunks/readlink-EJ3IKLWW.js → shell/chunks/readlink-BF435HNQ.js} +1 -1
- package/dist/bin/shell/chunks/{rg-WHVR3YDT.js → rg-XF5U7GS2.js} +1 -1
- package/dist/bin/{chunks/rm-B4LVIG7A.js → shell/chunks/rm-L4RHENMV.js} +1 -1
- package/dist/bin/{chunks/rmdir-PRNISPBA.js → shell/chunks/rmdir-W73C4GEA.js} +1 -1
- package/dist/bin/{chunks/sleep-DVFE2GSF.js → shell/chunks/sleep-MOJQBZMY.js} +1 -1
- package/dist/bin/{chunks/split-HIFKSV2A.js → shell/chunks/split-2VXPZJJ4.js} +1 -1
- package/dist/bin/shell/chunks/{sqlite3-KNN6V2W6.js → sqlite3-3S5HIA5W.js} +1 -1
- package/dist/bin/shell/chunks/{timeout-YGFHQJKX.js → timeout-RQOWSWYG.js} +1 -1
- package/dist/bin/shell/chunks/{which-4TPGVSBZ.js → which-G7X54RZL.js} +1 -1
- package/dist/bin/shell/shell.js +305 -304
- package/dist/bundle/browser.js +637 -611
- package/dist/bundle/chunks/builtin-manifest-7MJJDZ2T.js +2 -0
- package/dist/bundle/chunks/{chmod-TEY5MD2W.js → chmod-KMFNCMRX.js} +1 -1
- package/dist/bundle/chunks/chunk-2A4OZBCS.js +43 -0
- package/dist/bundle/chunks/{chunk-SE23TEGG.js → chunk-4CDTAUYP.js} +1 -1
- package/dist/bundle/chunks/chunk-4OKRFRMS.js +13 -0
- package/dist/bundle/chunks/{chunk-ATGOUOX2.js → chunk-4WRO2G22.js} +1 -1
- package/dist/bundle/chunks/{chunk-45QZRGYF.js → chunk-5KOWUQOZ.js} +7 -6
- package/dist/bundle/chunks/{chunk-6HO6HX7V.js → chunk-5NUTFEEG.js} +1 -1
- package/dist/bundle/chunks/{chunk-N3A4JVFJ.js → chunk-6IA4DXG2.js} +1 -1
- package/dist/bundle/chunks/{chunk-WE7BJ7YU.js → chunk-6IFH67ZB.js} +1 -1
- package/dist/bundle/chunks/chunk-6L6OYVLY.js +2 -0
- package/dist/bundle/chunks/chunk-BMBITA6Y.js +2 -0
- package/dist/bundle/chunks/chunk-BS6EJR2R.js +11 -0
- package/dist/bundle/chunks/{chunk-S6DNKKUL.js → chunk-CM4T4GB4.js} +1 -1
- package/dist/bundle/chunks/{chunk-MWL2I5BV.js → chunk-FXAKF2QS.js} +1 -1
- package/dist/bundle/chunks/chunk-H4AFUSSQ.js +9 -0
- package/dist/bundle/chunks/{chunk-GNPLDVBD.js → chunk-MMXJJCAE.js} +1 -1
- package/dist/bundle/chunks/{chunk-6QAM55HM.js → chunk-NFODJFHN.js} +1 -1
- package/dist/bundle/chunks/{chunk-LRFR25IP.js → chunk-O5OYOY3C.js} +7 -6
- package/dist/bundle/chunks/{chunk-HCKTU6IR.js → chunk-PASYAXFP.js} +1 -1
- package/dist/bundle/chunks/chunk-PS2RJNZZ.js +2 -0
- package/dist/bundle/chunks/chunk-THDUQVY3.js +11 -0
- package/dist/bundle/chunks/{chunk-DMWNBCXJ.js → chunk-TLPMB3FO.js} +1 -1
- package/dist/bundle/chunks/{chunk-FSKXIFYT.js → chunk-Y6UHNLT5.js} +1 -1
- package/dist/bundle/chunks/{chunk-XV2V56NQ.js → chunk-YFFU74KY.js} +1 -1
- package/dist/bundle/chunks/chunk-ZIQS5QAW.js +5 -0
- package/dist/bundle/chunks/{cp-UR762VVT.js → cp-P2D2L6PC.js} +1 -1
- package/dist/bundle/chunks/{diff-VDB6RXHO.js → diff-Z3XOLW44.js} +1 -1
- package/dist/bundle/chunks/{du-EQKH3UNA.js → du-YBSJVBXP.js} +1 -1
- package/dist/bundle/chunks/{find-RLKBCGJR.js → find-IUWEB4XQ.js} +1 -1
- package/dist/bundle/chunks/{flag-coverage-UMQ3BWDP.js → flag-coverage-SZ4AUPRQ.js} +1 -1
- package/dist/bundle/chunks/{gzip-KC5ENBD2.js → gzip-VUJBDHZ5.js} +1 -1
- package/dist/bundle/chunks/js-exec-6RW7WZCG.js +98 -0
- package/dist/bundle/chunks/js-exec-worker.js +4995 -0
- package/dist/bundle/chunks/{ls-WH5S4PPL.js → ls-ECKG2XHZ.js} +1 -1
- package/dist/bundle/chunks/{mkdir-Z6MMWH3D.js → mkdir-YL7XGMD7.js} +1 -1
- package/dist/bundle/chunks/{mv-WE7DBLEK.js → mv-IF55A2UD.js} +1 -1
- package/dist/bundle/chunks/python3-XHTOW7VA.js +13 -0
- package/dist/bundle/chunks/{readlink-JSRKXLLQ.js → readlink-7XGQ3PL7.js} +1 -1
- package/dist/bundle/chunks/{rg-JKB7DR66.js → rg-E6H2HACA.js} +1 -1
- package/dist/bundle/chunks/{rm-IGPLE632.js → rm-CWLMERIO.js} +1 -1
- package/dist/bundle/chunks/{rmdir-3WTXMVKI.js → rmdir-WKKBLZ54.js} +1 -1
- package/dist/bundle/chunks/{sleep-PPRBTSVR.js → sleep-25QUPVDK.js} +1 -1
- package/dist/bundle/chunks/{split-HUKVGJTW.js → split-NEU2K2YN.js} +1 -1
- package/dist/bundle/chunks/{sqlite3-KB3MXTTM.js → sqlite3-KJ5NMKBM.js} +1 -1
- package/dist/bundle/chunks/{timeout-C6WDYPLV.js → timeout-37GM7IIL.js} +1 -1
- package/dist/bundle/chunks/{which-UWVKETYW.js → which-BP5YY5BR.js} +1 -1
- package/dist/bundle/index.cjs +1134 -2660
- package/dist/bundle/index.js +210 -209
- package/dist/commands/js-exec/js-exec-worker.d.ts +35 -0
- package/dist/commands/js-exec/js-exec.d.ts +14 -1
- package/dist/commands/which/which.d.ts +10 -0
- package/dist/custom-commands.d.ts +5 -0
- package/dist/fs/path-utils.d.ts +0 -4
- package/dist/fs/vfs-template.d.ts +6 -0
- package/dist/interpreter/interpreter.d.ts +1 -1
- package/dist/interpreter/types.d.ts +1 -1
- package/dist/limits.d.ts +2 -5
- package/dist/timers.d.ts +9 -0
- package/dist/types.d.ts +9 -4
- package/package.json +8 -8
- package/dist/bin/chunks/chunk-2NJJXU4K.js +0 -27
- package/dist/bin/chunks/chunk-6JUPBMCR.js +0 -13
- package/dist/bin/chunks/chunk-CN4JKMTR.js +0 -8
- package/dist/bin/chunks/chunk-HWK7KFGB.js +0 -3
- package/dist/bin/chunks/chunk-PPVF2N6C.js +0 -3
- package/dist/bin/chunks/chunk-RTN6X652.js +0 -11
- package/dist/bin/chunks/chunk-RVPTAYDS.js +0 -4
- package/dist/bin/chunks/js-exec-T3SAB2B6.js +0 -1651
- package/dist/bin/chunks/python3-3ERN3L6S.js +0 -23
- package/dist/bin/shell/chunks/chunk-2NJJXU4K.js +0 -27
- package/dist/bin/shell/chunks/chunk-6JUPBMCR.js +0 -13
- package/dist/bin/shell/chunks/chunk-CN4JKMTR.js +0 -8
- package/dist/bin/shell/chunks/chunk-HWK7KFGB.js +0 -3
- package/dist/bin/shell/chunks/chunk-PPVF2N6C.js +0 -3
- package/dist/bin/shell/chunks/chunk-RTN6X652.js +0 -11
- package/dist/bin/shell/chunks/chunk-RVPTAYDS.js +0 -4
- package/dist/bin/shell/chunks/js-exec-T3SAB2B6.js +0 -1651
- package/dist/bin/shell/chunks/python3-3ERN3L6S.js +0 -23
- package/dist/bundle/chunks/chunk-2SMD2AUA.js +0 -3
- package/dist/bundle/chunks/chunk-3OBCZP7T.js +0 -12
- package/dist/bundle/chunks/chunk-4CC3OZPU.js +0 -2
- package/dist/bundle/chunks/chunk-A257L6QO.js +0 -7
- package/dist/bundle/chunks/chunk-B6OSJB22.js +0 -26
- package/dist/bundle/chunks/chunk-RWQWFXMH.js +0 -10
- package/dist/bundle/chunks/chunk-WXPNKIIH.js +0 -2
- package/dist/bundle/chunks/js-exec-ZQMIYQTH.js +0 -1650
- package/dist/bundle/chunks/python3-QB7OE256.js +0 -22
- package/dist/commands/js-exec/run-runtime.d.ts +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# just-bash
|
|
2
2
|
|
|
3
|
+
## 3.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`c8b5eb6`](https://github.com/JerryAZR/just-bash/commit/c8b5eb67659a3269e7410353573be829026a8214) Thanks [@JerryAZR](https://github.com/JerryAZR)! - feat: generic --version, EROFS GNU messages, which improvements
|
|
8
|
+
|
|
9
|
+
- All commands respond to `--version` with `<cmd> (just-bash)` via
|
|
10
|
+
dispatch-level interception. Commands that handle their own version
|
|
11
|
+
(python3, js-exec, diff, rg) set `handlesOwnVersion: true`. Custom
|
|
12
|
+
commands that handle `--version` must set `handlesOwnVersion: true`
|
|
13
|
+
to opt out of the generic response.
|
|
14
|
+
- rm/cp/mv/mkdir map EROFS to "Read-only file system" (GNU style).
|
|
15
|
+
Redirect failures use errno descriptions ("Read-only file system",
|
|
16
|
+
"Permission denied", etc.) matching real bash.
|
|
17
|
+
- `which` checks shell builtins when no file found in PATH, and prints
|
|
18
|
+
"which: no X in this sandboxed bash environment" on miss.
|
|
19
|
+
- rg implements `--version`.
|
|
20
|
+
|
|
21
|
+
- [`c8b5eb6`](https://github.com/JerryAZR/just-bash/commit/c8b5eb67659a3269e7410353573be829026a8214) Thanks [@JerryAZR](https://github.com/JerryAZR)! - feat: Windows drive-letter path translation (win32 only)
|
|
22
|
+
|
|
23
|
+
On Windows, `C:\foo\bar` and `C:/foo/bar` are translated to `/c/foo/bar`
|
|
24
|
+
(Git Bash convention) in `resolvePath`. On POSIX, `C:\foo` is a valid
|
|
25
|
+
relative filename and is NOT rewritten.
|
|
26
|
+
|
|
27
|
+
## 3.9.0
|
|
28
|
+
|
|
29
|
+
### Minor Changes
|
|
30
|
+
|
|
31
|
+
- [`00e40f9`](https://github.com/JerryAZR/just-bash/commit/00e40f927dfa0c6b77cadf063be094282ced2a5a) Thanks [@JerryAZR](https://github.com/JerryAZR)! - Add `diff -r` (recursive directory comparison), `diff -rq` (brief recursive), and `diff -N` (treat absent files as empty). No new dependencies.
|
|
32
|
+
|
|
33
|
+
- [`00e40f9`](https://github.com/JerryAZR/just-bash/commit/00e40f927dfa0c6b77cadf063be094282ced2a5a) Thanks [@JerryAZR](https://github.com/JerryAZR)! - Expose `maxJsMemoryBytes` in `ExecutionLimits` — the QuickJS heap limit (default 64MB) is now configurable per Bash instance. This is the only real cap on js-exec read/write sizes.
|
|
34
|
+
|
|
35
|
+
- [`00e40f9`](https://github.com/JerryAZR/just-bash/commit/00e40f927dfa0c6b77cadf063be094282ced2a5a) Thanks [@JerryAZR](https://github.com/JerryAZR)! - Add `readOnly` option to `VfsTemplateOptions` — when true, all fork overlay mounts are read-only (EROFS on writes).
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- [`00e40f9`](https://github.com/JerryAZR/just-bash/commit/00e40f927dfa0c6b77cadf063be094282ced2a5a) Thanks [@JerryAZR](https://github.com/JerryAZR)! - Fix a class of CI failures where js-exec guest output was lost: loop `executePendingJobs()` until all QuickJS jobs drain, not just the first batch.
|
|
40
|
+
|
|
3
41
|
## 3.8.0
|
|
4
42
|
|
|
5
43
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -493,7 +493,7 @@ await env.exec('js-exec -c "console.log(API_BASE)"');
|
|
|
493
493
|
|
|
494
494
|
`fs.readFileSync()` returns a `Buffer` by default (matching Node.js). Pass an encoding like `'utf8'` to get a string.
|
|
495
495
|
|
|
496
|
-
**Note:** The `js-exec` command only exists when `javascript` is configured. It is not available in browser environments. Execution
|
|
496
|
+
**Note:** The `js-exec` command only exists when `javascript` is configured. It is not available in browser environments. Execution runs in a QuickJS WASM sandbox with a 64 MB memory limit and configurable timeout (30 seconds in the default `normal` profile and 10 seconds in the opt-in `hardened` profile). Enabling network access does not extend the configured deadline.
|
|
497
497
|
|
|
498
498
|
#### Tool Invocation Hook
|
|
499
499
|
|
|
@@ -507,10 +507,9 @@ const bash = new Bash({
|
|
|
507
507
|
// argsJson: '{"a":1,"b":2}' (or "" for no args)
|
|
508
508
|
// return: JSON-stringified result, or "" for undefined
|
|
509
509
|
// throw: propagates as a sandbox exception
|
|
510
|
-
invokeTool: async (path, argsJson
|
|
510
|
+
invokeTool: async (path, argsJson) => {
|
|
511
511
|
const args = argsJson ? JSON.parse(argsJson) : undefined;
|
|
512
512
|
if (path === "math.add") {
|
|
513
|
-
abortSignal.throwIfAborted();
|
|
514
513
|
return JSON.stringify({ sum: args.a + args.b });
|
|
515
514
|
}
|
|
516
515
|
throw new Error(`Unknown tool: ${path}`);
|
|
@@ -521,10 +520,6 @@ const bash = new Bash({
|
|
|
521
520
|
await bash.exec(`js-exec -c 'console.log((await tools.math.add({a:3,b:4})).sum)'`);
|
|
522
521
|
```
|
|
523
522
|
|
|
524
|
-
The `abortSignal` fires when the JavaScript execution is canceled or times
|
|
525
|
-
out. Tool implementations should forward it to network requests and other
|
|
526
|
-
cancelable work so effects do not outlive the sandbox execution.
|
|
527
|
-
|
|
528
523
|
The hook is generic — wire any tool framework through it (raw maps, MCP,
|
|
529
524
|
Anthropic tool-use, etc.). For full GraphQL / OpenAPI / MCP discovery via
|
|
530
525
|
`@executor-js/sdk`, plus auto-generated bash namespace commands, use the
|
|
@@ -772,22 +767,17 @@ const env = new Bash({
|
|
|
772
767
|
All resources remain bounded by default in both profiles. Explicit values
|
|
773
768
|
override the selected profile; non-negative safe integers and the legacy
|
|
774
769
|
`Infinity` spelling are accepted. Infinite deadlines omit the corresponding
|
|
775
|
-
platform timer rather than overflowing it
|
|
776
|
-
|
|
777
|
-
values are rejected when `Bash` is constructed. Error messages identify the
|
|
778
|
-
resource that was hit.
|
|
770
|
+
platform timer rather than overflowing it. Invalid values are rejected when
|
|
771
|
+
`Bash` is constructed. Error messages identify the resource that was hit.
|
|
779
772
|
|
|
780
773
|
## Security Model
|
|
781
774
|
|
|
782
|
-
The Node.js package requires Node `>=20.
|
|
775
|
+
The Node.js package requires Node `>=20.18.1`.
|
|
783
776
|
|
|
784
777
|
- The shell only has access to the provided filesystem.
|
|
785
778
|
- All execution happens without VM isolation. This does introduce additional risk. The code base was designed to be robust against prototype-pollution attacks and other break outs to the host JS engine and filesystem.
|
|
786
779
|
- There is no network access by default. When enabled, requests are checked against URL prefix allow-lists and HTTP-method allow-lists.
|
|
787
780
|
- Python and JavaScript execution are off by default as they represent additional security surface.
|
|
788
|
-
- `js-exec` guest code runs inside the `run` package's QuickJS/WASM realm. Its
|
|
789
|
-
primary isolation boundary is QuickJS plus the validated, bounded host
|
|
790
|
-
bridge; guest JavaScript does not execute in the Node worker realm.
|
|
791
781
|
- Execution is protected against infinite loops and deep recursion with configurable limits.
|
|
792
782
|
- Host-realm defense-in-depth uses the strongest scoped controls available on
|
|
793
783
|
each supported Node runtime. Where `node:module.registerHooks()` is present,
|
package/dist/AGENTS.md
CHANGED
|
@@ -343,7 +343,7 @@ to inline these, and some of them cannot be inlined. Mark all six as external:
|
|
|
343
343
|
| `@mongodb-js/zstd` | native binding (`optionalDependencies`) |
|
|
344
344
|
| `node-liblzma` | native binding (`optionalDependencies`) |
|
|
345
345
|
| `sql.js` | ships a `.wasm` asset |
|
|
346
|
-
| `
|
|
346
|
+
| `quickjs-emscripten` | ships a `.wasm` asset |
|
|
347
347
|
| `seek-bzip` | CommonJS-only bzip2 decoder |
|
|
348
348
|
| `guarded-fetch` | imports `node:dns/promises`, `node:net`, `node:dns` |
|
|
349
349
|
|
|
@@ -363,7 +363,7 @@ const nextConfig = {
|
|
|
363
363
|
"node-liblzma",
|
|
364
364
|
"seek-bzip",
|
|
365
365
|
"sql.js",
|
|
366
|
-
"
|
|
366
|
+
"quickjs-emscripten",
|
|
367
367
|
"guarded-fetch",
|
|
368
368
|
],
|
|
369
369
|
};
|
package/dist/Bash.d.ts
CHANGED
|
@@ -33,13 +33,11 @@ export interface JavaScriptConfig {
|
|
|
33
33
|
/**
|
|
34
34
|
* Tool invocation hook. When provided, code running in `js-exec` gets a
|
|
35
35
|
* global `tools` proxy that routes calls through this callback synchronously
|
|
36
|
-
*
|
|
36
|
+
* (the worker blocks via `Atomics.wait` while the host resolves the call).
|
|
37
37
|
*
|
|
38
38
|
* - `path`: dot-separated tool path (e.g. `"math.add"`). The proxy builds
|
|
39
39
|
* it from JS property access — `tools.math.add(...)` becomes `"math.add"`.
|
|
40
40
|
* - `argsJson`: JSON-stringified args object, or empty string for no args.
|
|
41
|
-
* - `abortSignal`: aborts when js-exec is canceled or times out. Tool
|
|
42
|
-
* implementations should forward it to cancelable work.
|
|
43
41
|
* - return: JSON-stringified result, or empty string for `undefined`.
|
|
44
42
|
* - throw: propagates as a catchable exception inside the sandbox.
|
|
45
43
|
*
|
|
@@ -49,7 +47,7 @@ export interface JavaScriptConfig {
|
|
|
49
47
|
* `@just-bash/executor` produces a matching `invokeTool` + `commands` pair
|
|
50
48
|
* from inline tools and/or `@executor-js/sdk` discovery.
|
|
51
49
|
*/
|
|
52
|
-
invokeTool?: (path: string, argsJson: string
|
|
50
|
+
invokeTool?: (path: string, argsJson: string) => Promise<string>;
|
|
53
51
|
}
|
|
54
52
|
export interface BashOptions {
|
|
55
53
|
files?: InitialFiles;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
+
import{a,b,c,d,e}from"./chunk-AQKIHX3Q.js";import"./chunk-DN2YCFOR.js";export{a as BUILTIN_MANIFEST,b as SHELL_BUILTINS,c as UNIMPLEMENTED_BUILTIN_NAMES,d as builtinPhase,e as builtinPosixEarly};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{a,b}from"./chunk-
|
|
3
|
+
import{a,b}from"./chunk-K65FCSAT.js";import"./chunk-GR4ZHKXI.js";import"./chunk-HWI42GQO.js";import"./chunk-I57EACSL.js";import"./chunk-AIWBN36Z.js";import"./chunk-UBA7DOWE.js";import"./chunk-FUT3X2GJ.js";import"./chunk-CPKBPQ2C.js";import"./chunk-OHFB3M3X.js";import"./chunk-PBOVSFTJ.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{a as chmodCommand,b as flagsForFuzzing};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
+
import{b as T}from"./chunk-CPKBPQ2C.js";import{a as R}from"./chunk-NE4R2FVV.js";import{a as _,b as k}from"./chunk-MUFNRCMY.js";var L=class{diff(t,o,e={}){let i;typeof e=="function"?(i=e,e={}):"callback"in e&&(i=e.callback);let s=this.castInput(t,e),f=this.castInput(o,e),l=this.removeEmpty(this.tokenize(s,e)),r=this.removeEmpty(this.tokenize(f,e));return this.diffWithOptionsObj(l,r,e,i)}diffWithOptionsObj(t,o,e,i){var s;let f=c=>{if(c=this.postProcess(c,e),i){setTimeout(function(){i(c)},0);return}else return c},l=o.length,r=t.length,a=1,u=l+r;e.maxEditLength!=null&&(u=Math.min(u,e.maxEditLength));let h=(s=e.timeout)!==null&&s!==void 0?s:1/0,w=Date.now()+h,C=[{oldPos:-1,lastComponent:void 0}],m=this.extractCommon(C[0],o,t,0,e);if(C[0].oldPos+1>=r&&m+1>=l)return f(this.buildValues(C[0].lastComponent,o,t));let d=-1/0,p=1/0,g=()=>{for(let c=Math.max(d,-a);c<=Math.min(p,a);c+=2){let $,P=C[c-1],y=C[c+1];P&&(C[c-1]=void 0);let v=!1;if(y){let W=y.oldPos-c;v=y&&0<=W&&W<l}let F=P&&P.oldPos+1<r;if(!v&&!F){C[c]=void 0;continue}if(!F||v&&P.oldPos<y.oldPos?$=this.addToPath(y,!0,!1,0,e):$=this.addToPath(P,!1,!0,1,e),m=this.extractCommon($,o,t,c,e),$.oldPos+1>=r&&m+1>=l)return f(this.buildValues($.lastComponent,o,t))||!0;C[c]=$,$.oldPos+1>=r&&(p=Math.min(p,c-1)),m+1>=l&&(d=Math.max(d,c+1))}a++};if(i)(function c(){setTimeout(function(){if(a>u||Date.now()>w)return i(void 0);g()||c()},0)})();else for(;a<=u&&Date.now()<=w;){let c=g();if(c)return c}}addToPath(t,o,e,i,s){let f=t.lastComponent;return f&&!s.oneChangePerToken&&f.added===o&&f.removed===e?{oldPos:t.oldPos+i,lastComponent:{count:f.count+1,added:o,removed:e,previousComponent:f.previousComponent}}:{oldPos:t.oldPos+i,lastComponent:{count:1,added:o,removed:e,previousComponent:f}}}extractCommon(t,o,e,i,s){let f=o.length,l=e.length,r=t.oldPos,a=r-i,u=0;for(;a+1<f&&r+1<l&&this.equals(e[r+1],o[a+1],s);)a++,r++,u++,s.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return u&&!s.oneChangePerToken&&(t.lastComponent={count:u,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=r,a}equals(t,o,e){return e.comparator?e.comparator(t,o):t===o||!!e.ignoreCase&&t.toLowerCase()===o.toLowerCase()}removeEmpty(t){let o=[];for(let e=0;e<t.length;e++)t[e]&&o.push(t[e]);return o}castInput(t,o){return t}tokenize(t,o){return Array.from(t)}join(t){return t.join("")}postProcess(t,o){return t}get useLongestToken(){return!1}buildValues(t,o,e){let i=[],s;for(;t;)i.push(t),s=t.previousComponent,delete t.previousComponent,t=s;i.reverse();let f=i.length,l=0,r=0,a=0;for(;l<f;l++){let u=i[l];if(u.removed)u.value=this.join(e.slice(a,a+u.count)),a+=u.count;else{if(!u.added&&this.useLongestToken){let h=o.slice(r,r+u.count);h=h.map(function(w,C){let m=e[a+C];return m.length>w.length?m:w}),u.value=this.join(h)}else u.value=this.join(o.slice(r,r+u.count));r+=u.count,u.added||(a+=u.count)}}return i}};var N=class extends L{tokenize(t){return t.slice()}join(t){return t}removeEmpty(t){return t}},z=new N;function M(n,t,o){return z.diff(n,t,o)}var ne=`\
|
|
4
|
+
`,A=3;function O(n){if(n==="")return{lines:[],noEol:!1};let t=!n.endsWith(`
|
|
5
|
+
`),o=n.split(`
|
|
6
|
+
`);return t||o.pop(),{lines:o,noEol:t}}function H(n,t){let o=n.lines.length-1;return n.lines.map((e,i)=>{let s=i===o&&n.noEol?e:`${e}
|
|
7
|
+
`;return t?s.toLowerCase():s})}function B(n,t,o){let e=M(H(n,o),H(t,o)),i=[],s=0,f=0,l=0;for(;l<e.length;){let r=e[l];if(!r.added&&!r.removed){s+=r.count??r.value.length,f+=r.count??r.value.length,l++;continue}let a={oldStart:s,oldCount:0,newStart:f,newCount:0};for(;l<e.length&&(e[l].added||e[l].removed);){let u=e[l].count??e[l].value.length;e[l].removed?(a.oldCount+=u,s+=u):(a.newCount+=u,f+=u),l++}i.push(a)}return i}function x(n){if(!/[\s"\u0000-\u001f\u007f]/.test(n))return n;let t='"';for(let o of n)o==='"'||o==="\\"?t+=`\\${o}`:o===" "?t+="\\t":o===`
|
|
8
|
+
`?t+="\\n":o==="\r"?t+="\\r":o<" "||o==="\x7F"?t+=`\\${o.charCodeAt(0).toString(8).padStart(3,"0")}`:t+=o;return`${t}"`}function D(n,t,o,e){n.push(`${e}${t.lines[o]}
|
|
9
|
+
`),t.noEol&&o===t.lines.length-1&&n.push(ne)}function q(n,t){return t===0?String(n):t===1?String(n+1):`${n+1},${n+t}`}function J(n,t,o){let e=[];for(let i of o){let s=i.oldCount===0?"a":i.newCount===0?"d":"c";e.push(`${q(i.oldStart,i.oldCount)}${s}${q(i.newStart,i.newCount)}
|
|
10
|
+
`);for(let f=0;f<i.oldCount;f++)D(e,n,i.oldStart+f,"< ");s==="c"&&e.push(`---
|
|
11
|
+
`);for(let f=0;f<i.newCount;f++)D(e,t,i.newStart+f,"> ")}return e.join("")}function Y(n,t){let o=[],e=[];for(let i of n){let s=e[e.length-1];s&&i.oldStart-(s.oldStart+s.oldCount)>2*t&&(o.push(e),e=[]),e.push(i)}return e.length>0&&o.push(e),o}function G(n,t,o,e){let i=n[0],s=n[n.length-1];return{oldFrom:Math.max(0,i.oldStart-e),oldTo:Math.min(t.lines.length,s.oldStart+s.oldCount+e),newFrom:Math.max(0,i.newStart-e),newTo:Math.min(o.lines.length,s.newStart+s.newCount+e)}}function V(n,t){let o=t-n;return o===0?`${n},0`:o===1?String(n+1):`${n+1},${o}`}function K(n,t,o,e,i,s){let f=[`--- ${x(n)}
|
|
12
|
+
`,`+++ ${x(t)}
|
|
13
|
+
`];for(let l of Y(i,s)){let r=G(l,o,e,s);f.push(`@@ -${V(r.oldFrom,r.oldTo)} +${V(r.newFrom,r.newTo)} @@
|
|
14
|
+
`);let a=r.oldFrom;for(let u of l){for(;a<u.oldStart;a++)D(f,o,a," ");for(let h=0;h<u.oldCount;h++)D(f,o,u.oldStart+h,"-");for(let h=0;h<u.newCount;h++)D(f,e,u.newStart+h,"+");a=u.oldStart+u.oldCount}for(;a<r.oldTo;a++)D(f,o,a," ")}return f.join("")}function U(n,t){let o=t-n;return o===0?String(n):o===1?String(n+1):`${n+1},${t}`}function X(n,t,o,e,i,s){if(!o.some(r=>(s?r.oldCount:r.newCount)>0))return;let l=e;for(let r of o){let a=s?r.oldStart:r.newStart,u=s?r.oldCount:r.newCount;for(;l<a;l++)D(n,t,l," ");let h=r.oldCount>0&&r.newCount>0?"! ":s?"- ":"+ ";for(let w=0;w<u;w++)D(n,t,a+w,h);l=a+u}for(;l<i;l++)D(n,t,l," ")}function Q(n,t,o,e,i,s){let f=[`*** ${x(n)}
|
|
15
|
+
`,`--- ${x(t)}
|
|
16
|
+
`];for(let l of Y(i,s)){let r=G(l,o,e,s);f.push(`***************
|
|
17
|
+
`),f.push(`*** ${U(r.oldFrom,r.oldTo)} ****
|
|
18
|
+
`),X(f,o,l,r.oldFrom,r.oldTo,!0),f.push(`--- ${U(r.newFrom,r.newTo)} ----
|
|
19
|
+
`),X(f,e,l,r.newFrom,r.newTo,!1)}return f.join("")}var re={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:[" --normal output a normal diff (default)","-u, --unified output a unified diff","-c, --context output a context diff","-q, --brief report only whether files differ","-s, --report-identical-files report when files are the same","-i, --ignore-case ignore case differences","-r, --recursive recursively compare directories","-N, --new-file treat absent files as empty"," --version output version information and exit"," --help display this help and exit"]},ie={normal:{long:"normal",type:"boolean"},unified:{short:"u",long:"unified",type:"boolean"},context:{short:"c",long:"context",type:"boolean"},brief:{short:"q",long:"brief",type:"boolean"},reportSame:{short:"s",long:"report-identical-files",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"},recursive:{short:"r",long:"recursive",type:"boolean"},newFile:{short:"N",long:"new-file",type:"boolean"},version:{long:"version",type:"boolean"}},E=100;function S(n,t,o,e,i){let s=o,f=e;if(i.ignoreCase&&(s=s.toLowerCase(),f=f.toLowerCase()),s===f)return i.reportSame?{output:`Files ${n} and ${t} are identical
|
|
20
|
+
`,differs:!1}:{output:"",differs:!1};if(i.brief)return{output:`Files ${n} and ${t} differ
|
|
21
|
+
`,differs:!0};let l=O(o),r=O(e),a=B(l,r,i.ignoreCase),u;return i.unified?u=K(n,t,l,r,a,A):i.context?u=Q(n,t,l,r,a,A):u=J(l,r,a),{output:u,differs:!0}}async function b(n,t){return n.fs.readFile(n.fs.resolvePath(n.cwd,t))}async function Z(n,t){try{let o=n.fs.resolvePath(n.cwd,t),e=await n.fs.stat(o);return{isFile:e.isFile,isDirectory:e.isDirectory}}catch{return null}}async function j(n,t){if(n.fs.readdirWithFileTypes)return n.fs.readdirWithFileTypes(t);let o=await n.fs.readdir(t),e=[];for(let i of o)try{let s=await n.fs.stat(`${t}/${i}`);e.push({name:i,isFile:s.isFile,isDirectory:s.isDirectory,isSymbolicLink:s.isSymbolicLink??!1})}catch{}return e}function ee(n){return n.isDirectory?"directory":n.isSymbolicLink?"symbolic link":"regular file"}async function te(n,t,o,e,i=0){if(i>E)return{output:`diff: maximum recursion depth exceeded (${E})
|
|
22
|
+
`,differs:!0};let s=o.fs.resolvePath(o.cwd,n),f=o.fs.resolvePath(o.cwd,t),l=await j(o,s),r=await j(o,f),a=new Set(l.map(p=>p.name)),u=new Set(r.map(p=>p.name)),h=[...new Set([...a,...u])].sort(),w=new Map(l.map(p=>[p.name,p])),C=new Map(r.map(p=>[p.name,p])),m="",d=!1;for(let p of h){let g=`${n}/${p}`,c=`${t}/${p}`,$=w.get(p),P=C.get(p);if($&&P)if($.isDirectory&&P.isDirectory){let y=await te(g,c,o,e,i+1);m+=y.output,d=d||y.differs}else if($.isFile&&P.isFile)try{let y=await b(o,g),v=await b(o,c),F=S(g,c,y,v,e);F.differs&&!e.brief&&F.output&&(m+=`${e.headerPrefix} ${g} ${c}
|
|
23
|
+
`),m+=F.output,d=d||F.differs}catch{m+=`diff: ${g}: No such file or directory
|
|
24
|
+
`,d=!0}else m+=`File ${g} is a ${ee($)} while file ${c} is a ${ee(P)}
|
|
25
|
+
`,d=!0;else if($)if(e.newFile)if($.isDirectory){let y=await I(g,c,o,e,!0,i+1);m+=y.output,d=d||y.differs}else if($.isFile){let y=await b(o,g),v=S(g,c,y,"",e);v.differs&&!e.brief&&v.output&&(m+=`${e.headerPrefix} ${g} ${c}
|
|
26
|
+
`),m+=v.output,d=d||v.differs}else m+=`Only in ${n}: ${p}
|
|
27
|
+
`,d=!0;else m+=`Only in ${n}: ${p}
|
|
28
|
+
`,d=!0;else if(P)if(e.newFile)if(P.isDirectory){let y=await I(c,g,o,e,!1,i+1);m+=y.output,d=d||y.differs}else if(P.isFile){let y=await b(o,c),v=S(g,c,"",y,e);v.differs&&!e.brief&&v.output&&(m+=`${e.headerPrefix} ${g} ${c}
|
|
29
|
+
`),m+=v.output,d=d||v.differs}else m+=`Only in ${t}: ${p}
|
|
30
|
+
`,d=!0;else m+=`Only in ${t}: ${p}
|
|
31
|
+
`,d=!0}return{output:m,differs:d}}async function I(n,t,o,e,i,s=0){if(s>E)return{output:`diff: maximum recursion depth exceeded (${E})
|
|
32
|
+
`,differs:!0};let f=o.fs.resolvePath(o.cwd,n),r=[...await j(o,f)].sort((h,w)=>h.name<w.name?-1:h.name>w.name?1:0),a="",u=!1;for(let h of r){let w=`${n}/${h.name}`,C=`${t}/${h.name}`;if(h.isDirectory){let m=await I(w,C,o,e,i,s+1);a+=m.output,u=u||m.differs}else if(h.isFile){let m=await b(o,w),d=i?m:"",p=i?"":m,g=i?w:C,c=i?C:w,$=S(g,c,d,p,e);$.differs&&!e.brief&&$.output&&(a+=`${e.headerPrefix} ${g} ${c}
|
|
33
|
+
`),a+=$.output,u=u||$.differs}}return{output:a,differs:u}}var he={handlesOwnVersion:!0,name:"diff",async execute(n,t){if(k(n))return _(re);let o=R("diff",n,ie);if(!o.ok)return o.error;let e=o.result.flags;if(e.version)return{stdout:`diff (just-bash)
|
|
34
|
+
`,stderr:"",exitCode:0};if(Number(e.normal)+Number(e.unified)+Number(e.context)>1)return{stdout:"",stderr:`diff: conflicting output style options
|
|
35
|
+
diff: Try 'diff --help' for more information.
|
|
36
|
+
`,exitCode:2};let s="diff -r";e.unified&&(s+="u"),e.context&&(s+="c"),e.newFile&&(s+="N"),e.ignoreCase&&(s+="i"),e.brief&&(s+="q");let f={unified:e.unified,context:e.context,brief:e.brief,reportSame:e.reportSame,ignoreCase:e.ignoreCase,newFile:e.newFile,headerPrefix:s},l=o.result.positional;if(l.length<2)return{stdout:"",stderr:`diff: missing operand
|
|
37
|
+
`,exitCode:2};let[r,a]=l;if(e.recursive){let C=await Z(t,r),m=await Z(t,a);if(C?.isFile&&m?.isDirectory){let d=`${a}/${r.split("/").pop()}`,p;try{p=await b(t,r)}catch{return{stdout:"",stderr:`diff: ${r}: No such file or directory
|
|
38
|
+
`,exitCode:2}}let g;try{g=await b(t,d)}catch{if(f.newFile)g="";else return{stdout:"",stderr:`diff: ${d}: No such file or directory
|
|
39
|
+
`,exitCode:2}}let c=S(r,d,p,g,f);return{stdout:c.output,stderr:"",exitCode:c.differs?1:0}}if(C?.isDirectory&&m?.isFile){let d=`${r}/${a.split("/").pop()}`,p;try{p=await b(t,d)}catch{if(f.newFile)p="";else return{stdout:"",stderr:`diff: ${d}: No such file or directory
|
|
40
|
+
`,exitCode:2}}let g;try{g=await b(t,a)}catch{return{stdout:"",stderr:`diff: ${a}: No such file or directory
|
|
41
|
+
`,exitCode:2}}let c=S(d,a,p,g,f);return{stdout:c.output,stderr:"",exitCode:c.differs?1:0}}if(!C||!m)return{stdout:"",stderr:`diff: ${C?a:r}: No such file or directory
|
|
42
|
+
`,exitCode:2};if(C.isDirectory&&m.isDirectory){let d=await te(r,a,t,f);return{stdout:d.output,stderr:"",exitCode:d.differs?1:0}}}let u,h;try{u=r==="-"?T(t.stdin):await b(t,r)}catch{if(f.newFile)u="";else return{stdout:"",stderr:`diff: ${r}: No such file or directory
|
|
43
|
+
`,exitCode:2}}try{h=a==="-"?T(t.stdin):await b(t,a)}catch{if(f.newFile)h="";else return{stdout:"",stderr:`diff: ${a}: No such file or directory
|
|
44
|
+
`,exitCode:2}}let w=S(r,a,u,h,f);return{stdout:w.output,stderr:"",exitCode:w.differs?1:0}}},ge={name:"diff",flags:[{flag:"--normal",type:"boolean"},{flag:"-u",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-i",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-N",type:"boolean"}],needsArgs:!0,minArgs:2};export{he as a,ge as b};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{
|
|
3
|
+
import{d as l,e as u}from"./chunk-QKJAAJ7J.js";import{randomBytes as h}from"node:crypto";var d=class{options;protocolToken=h(16).toString("hex");deadline;cleanups=[];cancelHandler;canceledReason;closed=!1;constructor(t){this.options=t,this.deadline=Date.now()+t.timeoutMs}arm(t){if(this.cancelHandler)throw new Error("worker request is already armed");this.cancelHandler=t;let a=this.options.signal;if(a){let i=()=>this.cancel("abort");a.addEventListener("abort",i,{once:!0}),this.cleanups.push(()=>a.removeEventListener("abort",i)),a.aborted&&this.cancel("abort")}if(!this.canceledReason){let i=l(()=>this.cancel("timeout"),Math.max(0,this.options.timeoutMs));i!==void 0&&this.cleanups.push(()=>u(i))}}get isCanceled(){return this.canceledReason!==void 0}remainingTimeMs(){return Math.max(0,this.deadline-Date.now())}timeoutMessage(t="Execution"){return`${t} timeout: exceeded ${this.options.timeoutMs}ms limit`}abortMessage(){return"Execution aborted"}assertMessageSize(t,a){if(f(t,this.options.maxMessageBytes)>this.options.maxMessageBytes)throw new Error(`${this.options.commandName}: worker ${a} exceeds ${this.options.maxMessageBytes} byte limit`)}async terminate(t){if(!t)return!0;try{return await t.terminate(),!0}catch{return!1}}close(){if(!this.closed){this.closed=!0;for(let t=this.cleanups.length-1;t>=0;t--)this.cleanups[t]();this.cleanups.length=0,this.cancelHandler=void 0}}cancel(t){this.closed||this.canceledReason||(this.canceledReason=t,this.cancelHandler?.(t))}};function f(o,t){let a=function*(n){for(let e in n)Object.hasOwn(n,e)&&(yield[e,n[e]])},i=[{kind:"value",value:o}],c=new WeakSet,s=0;for(;i.length>0&&s<=t;){let n=i.pop();if(!n)break;if(n.kind==="array"){n.index<n.value.length&&(i.push({...n,index:n.index+1}),i.push({kind:"value",value:n.value[n.index]}));continue}if(n.kind==="object"){let r=n.iterator.next();r.done||(s+=8+Buffer.byteLength(r.value[0],"utf8"),i.push(n),i.push({kind:"value",value:r.value[1]}));continue}let e=n.value;if(e==null)s+=4;else if(typeof e=="string")s+=Buffer.byteLength(e,"utf8");else if(typeof e=="number"||typeof e=="bigint")s+=8;else if(typeof e=="boolean")s+=1;else if(typeof e=="object"){if(c.has(e))continue;if(c.add(e),ArrayBuffer.isView(e))s+=e.byteLength;else if(e instanceof ArrayBuffer||e instanceof SharedArrayBuffer)s+=e.byteLength;else if(Array.isArray(e)){if(e.length>Math.floor((t-s)/8))return t+1;s+=e.length*8,i.push({kind:"array",value:e,index:0})}else i.push({kind:"object",iterator:a(e)})}}return s}export{d as a};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{d as C}from"./chunk-
|
|
3
|
+
import{d as C}from"./chunk-AIWBN36Z.js";import{a as g}from"./chunk-NE4R2FVV.js";import{a as v}from"./chunk-I4IRHQDW.js";var y=`Usage: rmdir [-pv] DIRECTORY...
|
|
4
4
|
Remove empty directories.
|
|
5
5
|
|
|
6
6
|
Options:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{a as w}from"./chunk-B2DRBHGQ.js";import{a as y}from"./chunk-3MRB66F4.js";import{a as b}from"./chunk-3PCPQIUD.js";import{a as h,b as A}from"./chunk-
|
|
3
|
+
import{a as w}from"./chunk-B2DRBHGQ.js";import{a as y}from"./chunk-3MRB66F4.js";import{a as b}from"./chunk-3PCPQIUD.js";import{a as h,b as A}from"./chunk-QKJAAJ7J.js";import{a as v,b as O,c as d}from"./chunk-MUFNRCMY.js";var x={name:"timeout",summary:"run a command with a time limit",usage:"timeout [OPTION] DURATION COMMAND [ARG]...",description:`Start COMMAND, and kill it if still running after DURATION.
|
|
4
4
|
|
|
5
5
|
DURATION is a number with optional suffix:
|
|
6
6
|
s - seconds (default)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{e as F}from"./chunk-
|
|
3
|
+
import{e as F}from"./chunk-AIWBN36Z.js";import{l as d,m as h}from"./chunk-FUT3X2GJ.js";import{a as x}from"./chunk-NE4R2FVV.js";import{a as g,b as z}from"./chunk-MUFNRCMY.js";var $={name:"du",summary:"estimate file space usage",usage:"du [OPTION]... [FILE]...",options:["-a write counts for all files, not just directories","-h print sizes in human readable format","-s display only a total for each argument","-c produce a grand total","--max-depth=N print total for directory only if N or fewer levels deep"," --help display this help and exit"]},b={allFiles:{short:"a",type:"boolean"},humanReadable:{short:"h",type:"boolean"},summarize:{short:"s",type:"boolean"},grandTotal:{short:"c",type:"boolean"},maxDepth:{long:"max-depth",type:"number"}},R={name:"du",async execute(t,s){if(z(t))return g($);let a=x("du",t,b);if(!a.ok)return a.error;let l={allFiles:a.result.flags.allFiles,humanReadable:a.result.flags.humanReadable,summarize:a.result.flags.summarize,grandTotal:a.result.flags.grandTotal,maxDepth:a.result.flags.maxDepth??null},i=a.result.positional;i.length===0&&i.push(".");let n="",o="",e=0;for(let u of i){let f=s.fs.resolvePath(s.cwd,u);try{await s.fs.stat(f);let r=await w(s,f,u,l,0);n+=r.output,e+=r.totalSize,o+=r.stderr}catch(r){if(r instanceof d||r instanceof h)throw r;o+=`du: cannot access '${u}': No such file or directory
|
|
4
4
|
`}}return l.grandTotal&&i.length>0&&(n+=`${p(e,l.humanReadable)} total
|
|
5
5
|
`),{stdout:n,stderr:o,exitCode:o?1:0}}};async function w(t,s,a,l,i){let n={output:"",totalSize:0,stderr:""},o=new Map;return await F({fs:t.fs,root:s,limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"du",symlinks:"never",includeLeave:!0},e=>{let u=e.path.slice(s.length).replace(/^\//,""),f=u?a==="."?u:`${a}/${u}`:a,r=e.path==="/"?"/":e.path.slice(0,e.path.lastIndexOf("/"))||"/";if(e.phase==="enter"){if(e.stat.isDirectory){o.set(e.path,0);return}o.set(r,(o.get(r)??0)+e.stat.size),(l.allFiles||e.depth===i)&&!l.summarize&&(n.output+=`${p(e.stat.size,l.humanReadable)} ${f}
|
|
6
6
|
`),e.depth===i&&(n.totalSize=e.stat.size);return}let m=o.get(e.path)??0;e.depth>i?o.set(r,(o.get(r)??0)+m):n.totalSize=m;let c=e.depth-i;(l.summarize&&c===0||!l.summarize&&(l.maxDepth===null||c<=l.maxDepth))&&(n.output+=`${p(m,l.humanReadable)} ${f}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{e as l,f as v,h as P,k as f}from"./chunk-
|
|
3
|
+
import{e as l,f as v,h as P,k as f}from"./chunk-UBA7DOWE.js";import{l as u,m as y}from"./chunk-FUT3X2GJ.js";import{c as k}from"./chunk-OHFB3M3X.js";import{a as g}from"./chunk-PBOVSFTJ.js";var w=class extends Error{operation;virtualPath;name="FileSystemPolicyError";constructor(t,r,n){super(`${t}: ${g(n)}`),this.operation=t,this.virtualPath=r}};function $(e){if(e.identity!==void 0)return`identity:${e.identity}`;if(e.dev!==void 0&&e.ino!==void 0)return`inode:${String(e.dev)}:${String(e.ino)}`}function b(e){return k(e,"ENOENT")}async function m(e,t,r){let n=l(t),s;try{s=await e.stat(n)}catch(a){if(!b(a))return{existence:"unknown"}}if(s!==void 0){let a=$(s);try{return{existence:"existing",canonicalPath:l(await e.realpath(n)),stableIdentity:a}}catch{return a===void 0?{existence:"unknown"}:{existence:"existing",stableIdentity:a}}}let i=[],o=n;for(;;){r?.checkpoint();let a=P(o);if(a===o)return{existence:"unknown"};i.unshift(o.slice(a==="/"?1:a.length+1)),o=a;try{let c=l(await e.realpath(o));return{existence:"missing",canonicalPath:i.reduce((h,d)=>f(h,d),c)}}catch(c){if(!b(c))return{existence:"missing"}}}}async function C(e,t,r){let[n,s]=await Promise.all([m(e,t),m(e,r)]);return n.existence==="unknown"||s.existence==="unknown"?"unknown":n.existence==="missing"||s.existence==="missing"?n.existence!==s.existence?"different":n.canonicalPath!==void 0&&n.canonicalPath===s.canonicalPath?"same":"unknown":n.stableIdentity!==void 0&&s.stableIdentity!==void 0?n.stableIdentity===s.stableIdentity?"same":"different":n.canonicalPath!==void 0&&n.canonicalPath===s.canonicalPath?"same":"unknown"}async function D(e,t,r,n){let[s,i]=await Promise.all([m(e,t,n),m(e,r,n)]);return s.existence!=="existing"||s.canonicalPath===void 0||i.existence==="unknown"||i.canonicalPath===void 0?"unknown":v(s.canonicalPath,i.canonicalPath)?"inside":"outside"}var x=class{options;entries=0;discoveredEntries=1;work=0;constructor(t){this.options=t}checkpoint(t=1){if(this.options.signal?.aborted)throw new y;if(this.options.executionScope?.throwIfAborted(this.options.site),!Number.isSafeInteger(t)||t<0||t>this.options.limits.maxTraversalWork-this.work)throw new u(`${this.options.site}: ${this.options.label??"filesystem traversal work"} limit exceeded (${this.options.limits.maxTraversalWork})`,"iterations");this.work+=t,this.options.executionScope?.consumeWork(t,`${this.options.site} filesystem traversal`)}visit(t){if(this.checkpoint(),t>this.options.limits.maxTraversalDepth)throw new u(`${this.options.site}: ${this.options.label??"filesystem traversal"} depth limit exceeded (${this.options.limits.maxTraversalDepth})`,"recursion");if(++this.entries>this.options.limits.maxTraversalEntries)throw new u(`${this.options.site}: ${this.options.label??"filesystem traversal"} entry limit exceeded (${this.options.limits.maxTraversalEntries})`,"iterations")}reserve(t){if(!Number.isSafeInteger(t)||t<0||t>this.options.limits.maxTraversalEntries-this.discoveredEntries)throw new u(`${this.options.site}: ${this.options.label??"filesystem traversal"} entry limit exceeded (${this.options.limits.maxTraversalEntries})`,"iterations");this.discoveredEntries+=t}discover(t){this.reserve(t),this.checkpoint(t)}};async function N(e,t){let r=e.budget??new x(e),n=[{kind:"enter",path:l(e.root),depth:0}],s=new Set;for(;n.length>0;){r.checkpoint(0);let i=n.pop();if(!i)break;if(i.kind==="leave"){e.includeLeave&&await t({path:i.path,depth:i.depth,stat:i.stat,isSymlink:i.isSymlink,phase:"leave"}),i.identity&&s.delete(i.identity);continue}r.visit(i.depth);let o=await e.fs.lstat(i.path),a=o.isSymbolicLink,c=a&&e.symlinks==="follow"?await e.fs.stat(i.path):o;if(await t({path:i.path,depth:i.depth,stat:c,isSymlink:a,phase:"enter"}),!c.isDirectory||a&&e.symlinks!=="follow")continue;let h=$(c)??await e.fs.realpath(i.path).then(l).catch(()=>{});if(h!==void 0){if(s.has(h))throw new w(e.site,i.path,"symbolic-link directory cycle detected");s.add(h)}n.push({kind:"leave",path:i.path,depth:i.depth,stat:c,isSymlink:a,identity:h});let d=await e.fs.readdir(i.path);r.checkpoint(),d.sort((p,E)=>p.localeCompare(E));for(let p=d.length-1;p>=0;p--)n.push({kind:"enter",path:f(i.path,d[p]),depth:i.depth+1})}}export{m as a,C as b,D as c,x as d,N as e};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
+
var d={export:{kind:"handler",phase:"early"},unset:{kind:"handler",phase:"early"},exit:{kind:"handler",phase:"early"},local:{kind:"handler",phase:"early"},set:{kind:"handler",phase:"early"},break:{kind:"handler",phase:"early"},continue:{kind:"handler",phase:"early"},return:{kind:"handler",phase:"early"},shift:{kind:"handler",phase:"early"},getopts:{kind:"handler",phase:"early"},compgen:{kind:"handler",phase:"early"},complete:{kind:"handler",phase:"early"},compopt:{kind:"handler",phase:"early"},pushd:{kind:"handler",phase:"early"},popd:{kind:"handler",phase:"early"},dirs:{kind:"handler",phase:"early"},source:{kind:"handler",phase:"early"},".":{kind:"handler",phase:"early"},read:{kind:"handler",phase:"early"},mapfile:{kind:"handler",phase:"early"},readarray:{kind:"handler",phase:"early"},declare:{kind:"handler",phase:"early"},typeset:{kind:"handler",phase:"early"},readonly:{kind:"handler",phase:"early"},eval:{kind:"handler",phase:"late",posixEarly:!0},cd:{kind:"handler",phase:"late"},":":{kind:"handler",phase:"late"},true:{kind:"handler",phase:"late"},false:{kind:"handler",phase:"late"},let:{kind:"handler",phase:"late"},command:{kind:"handler",phase:"late"},builtin:{kind:"handler",phase:"late"},shopt:{kind:"handler",phase:"late"},exec:{kind:"handler",phase:"late"},wait:{kind:"handler",phase:"late"},type:{kind:"handler",phase:"late"},hash:{kind:"handler",phase:"late"},help:{kind:"handler",phase:"late"},"[":{kind:"handler",phase:"late"},test:{kind:"handler",phase:"late"},echo:{kind:"registry"},printf:{kind:"registry"},pwd:{kind:"registry"},alias:{kind:"registry"},unalias:{kind:"registry"},history:{kind:"registry"},bg:{kind:"unimplemented"},caller:{kind:"unimplemented"},disown:{kind:"unimplemented"},enable:{kind:"unimplemented"},fc:{kind:"unimplemented"},fg:{kind:"unimplemented"},jobs:{kind:"unimplemented"},kill:{kind:"unimplemented"},suspend:{kind:"unimplemented"},times:{kind:"unimplemented"},trap:{kind:"unimplemented"},ulimit:{kind:"unimplemented"},umask:{kind:"unimplemented"}};for(let e of Object.values(d))Object.freeze(e);Object.freeze(d);var l=d,i=new Set(Object.keys(l)),r=new Set(Object.entries(l).filter(([,e])=>e.kind==="unimplemented").map(([e])=>e)),a=l;function t(e){let n=Object.hasOwn(a,e)?a[e]:void 0;return n?.kind==="handler"?n.phase:void 0}function h(e){let n=Object.hasOwn(a,e)?a[e]:void 0;return n?.kind==="handler"&&n.posixEarly===!0}export{l as a,i as b,r as c,t as d,h as e};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
+
import{c as s}from"./chunk-OHFB3M3X.js";import{a as m}from"./chunk-PBOVSFTJ.js";import{a as c}from"./chunk-NE4R2FVV.js";import{a as l}from"./chunk-I4IRHQDW.js";var y={recursive:{short:"p",long:"parents",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},b={name:"mkdir",async execute(f,i){let t=c("mkdir",f,y);if(!t.ok)return t.error;let g=t.result.flags.recursive,p=t.result.flags.verbose,n=t.result.positional;if(n.length===0)return{stdout:"",stderr:`mkdir: missing operand
|
|
4
|
+
`,exitCode:1};let a="",o="",d=0;for(let e of n)try{let r=i.fs.resolvePath(i.cwd,e);await i.fs.mkdir(r,{recursive:g}),p&&(a+=`mkdir: created directory '${e}'
|
|
5
|
+
`)}catch(r){let u=l(r);s(r,"ENOENT")?o+=`mkdir: cannot create directory '${e}': No such file or directory
|
|
6
|
+
`:s(r,"EEXIST")?o+=`mkdir: cannot create directory '${e}': File exists
|
|
7
|
+
`:s(r,"EROFS")?o+=`mkdir: cannot create directory '${e}': Read-only file system
|
|
8
|
+
`:s(r,"EACCES")?o+=`mkdir: cannot create directory '${e}': Permission denied
|
|
9
|
+
`:o+=`mkdir: cannot create directory '${e}': ${m(u)}
|
|
10
|
+
`,d=1}return{stdout:a,stderr:o,exitCode:d}}},$={name:"mkdir",flags:[{flag:"-p",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0};export{b as a,$ as b};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
+
import{a as C}from"./chunk-3MRB66F4.js";import{b as L}from"./chunk-O2BCKSMK.js";import{a as I,b as l}from"./chunk-TW2IJRUF.js";import{d as A,e as m}from"./chunk-QKJAAJ7J.js";import{b as w}from"./chunk-HWI42GQO.js";import{a as _,b as f}from"./chunk-OHFB3M3X.js";import{a as F,b as D}from"./chunk-PBOVSFTJ.js";var h={NOOP:0,READ_FILE:1,WRITE_FILE:2,STAT:3,READDIR:4,MKDIR:5,RM:6,EXISTS:7,APPEND_FILE:8,SYMLINK:9,READLINK:10,LSTAT:11,CHMOD:12,REALPATH:13,RENAME:14,COPY_FILE:15,WRITE_FILE_RANGE:17,READ_RESULT_RANGE:18,WRITE_STDOUT:100,WRITE_STDERR:101,EXIT:102,HTTP_REQUEST:200,EXEC_COMMAND:300,INVOKE_TOOL:400},S={IDLE:0,REQUEST:1,CANCELLED:2},r={NONE:0,SUCCESS:1,ERROR:2},a={NONE:0,NOT_FOUND:1,IS_DIRECTORY:2,NOT_DIRECTORY:3,EXISTS:4,PERMISSION_DENIED:5,INVALID_PATH:6,IO_ERROR:7,NETWORK_ERROR:9,NETWORK_NOT_CONFIGURED:10,NOT_EMPTY:11,LOOP:12,FILE_TOO_LARGE:13,NO_SPACE:14,BUSY:15,READ_ONLY:16,CROSS_DEVICE:17},O=Object.assign(Object.create(null),{ENOENT:a.NOT_FOUND,EISDIR:a.IS_DIRECTORY,ENOTDIR:a.NOT_DIRECTORY,ENOTEMPTY:a.NOT_EMPTY,EEXIST:a.EXISTS,EPERM:a.PERMISSION_DENIED,EACCES:a.PERMISSION_DENIED,EINVAL:a.INVALID_PATH,ELOOP:a.LOOP,EFBIG:a.FILE_TOO_LARGE,ENOSPC:a.NO_SPACE,EBUSY:a.BUSY,EROFS:a.READ_ONLY,EXDEV:a.CROSS_DEVICE}),P=Object.create(null);for(let[d,t]of Object.entries(O))P[t]=d;var o={OP_CODE:0,REQUEST:4,PATH_LENGTH:8,DATA_LENGTH:12,RESULT_LENGTH:16,ERROR_CODE:20,FLAGS:24,MODE:28,RESULT_STATE:32,PATH_BUFFER:36,DATA_BUFFER:4132},R={PATH_BUFFER:4096,DATA_BUFFER:8388608,TOTAL:8392740},g={NONE:0,RECURSIVE:1,FORCE:2,MKDIR_RECURSIVE:1},u={IS_FILE:0,IS_DIRECTORY:1,IS_SYMLINK:2,MODE:4,SIZE:8,MTIME:16,TOTAL:24};function M(){return new I(R.TOTAL)}var T=class{int32View;uint8View;dataView;constructor(t){this.int32View=new Int32Array(t),this.uint8View=new Uint8Array(t),this.dataView=new DataView(t)}getOpCode(){return l.load(this.int32View,o.OP_CODE/4)}setOpCode(t){l.store(this.int32View,o.OP_CODE/4,t)}getRequest(){return l.load(this.int32View,o.REQUEST/4)}setRequest(t){l.store(this.int32View,o.REQUEST/4,t)}getResultState(){return l.load(this.int32View,o.RESULT_STATE/4)}setResultState(t){l.store(this.int32View,o.RESULT_STATE/4,t)}getPathLength(){return l.load(this.int32View,o.PATH_LENGTH/4)}setPathLength(t){l.store(this.int32View,o.PATH_LENGTH/4,t)}getDataLength(){return l.load(this.int32View,o.DATA_LENGTH/4)}setDataLength(t){l.store(this.int32View,o.DATA_LENGTH/4,t)}getResultLength(){return l.load(this.int32View,o.RESULT_LENGTH/4)}setResultLength(t){l.store(this.int32View,o.RESULT_LENGTH/4,t)}getErrorCode(){return l.load(this.int32View,o.ERROR_CODE/4)}setErrorCode(t){l.store(this.int32View,o.ERROR_CODE/4,t)}getFlags(){return l.load(this.int32View,o.FLAGS/4)}setFlags(t){l.store(this.int32View,o.FLAGS/4,t)}getMode(){return l.load(this.int32View,o.MODE/4)}setMode(t){l.store(this.int32View,o.MODE/4,t)}getPath(){let t=this.getPathLength(),e=this.uint8View.slice(o.PATH_BUFFER,o.PATH_BUFFER+t);return new TextDecoder().decode(e)}setPath(t){let e=new TextEncoder().encode(t);if(e.length>R.PATH_BUFFER)throw new Error(`Path too long: ${e.length} > ${R.PATH_BUFFER}`);this.uint8View.set(e,o.PATH_BUFFER),this.setPathLength(e.length)}getData(){let t=this.getDataLength();return this.uint8View.slice(o.DATA_BUFFER,o.DATA_BUFFER+t)}setData(t){if(t.length>R.DATA_BUFFER)throw new Error(`Data too large: ${t.length} > ${R.DATA_BUFFER}`);this.uint8View.set(t,o.DATA_BUFFER),this.setDataLength(t.length)}getDataAsString(){let t=this.getData();return new TextDecoder().decode(t)}setDataFromString(t){let e=new TextEncoder().encode(t);this.setData(e)}getResult(){let t=this.getResultLength();return this.uint8View.slice(o.DATA_BUFFER,o.DATA_BUFFER+t)}setResult(t){if(t.length>R.DATA_BUFFER)throw new Error(`Result too large: ${t.length} > ${R.DATA_BUFFER}`);this.uint8View.set(t,o.DATA_BUFFER),this.setResultLength(t.length)}setResultPrefix(t){if(t.length>2147483647)throw new Error(`Result too large: ${t.length} exceeds int32`);let e=Math.min(t.length,R.DATA_BUFFER);this.uint8View.set(t.subarray(0,e),o.DATA_BUFFER),this.setResultLength(t.length)}getResultAsString(){let t=this.getResult();return new TextDecoder().decode(t)}setResultFromString(t){let e=new TextEncoder().encode(t);this.setResult(e)}encodeStat(t){this.uint8View[o.DATA_BUFFER+u.IS_FILE]=t.isFile?1:0,this.uint8View[o.DATA_BUFFER+u.IS_DIRECTORY]=t.isDirectory?1:0,this.uint8View[o.DATA_BUFFER+u.IS_SYMLINK]=t.isSymbolicLink?1:0,this.dataView.setInt32(o.DATA_BUFFER+u.MODE,t.mode,!0);let e=Math.min(t.size,Number.MAX_SAFE_INTEGER);this.dataView.setFloat64(o.DATA_BUFFER+u.SIZE,e,!0),this.dataView.setFloat64(o.DATA_BUFFER+u.MTIME,t.mtime.getTime(),!0),this.setResultLength(u.TOTAL)}decodeStat(){return{isFile:this.uint8View[o.DATA_BUFFER+u.IS_FILE]===1,isDirectory:this.uint8View[o.DATA_BUFFER+u.IS_DIRECTORY]===1,isSymbolicLink:this.uint8View[o.DATA_BUFFER+u.IS_SYMLINK]===1,mode:this.dataView.getInt32(o.DATA_BUFFER+u.MODE,!0),size:this.dataView.getFloat64(o.DATA_BUFFER+u.SIZE,!0),mtime:new Date(this.dataView.getFloat64(o.DATA_BUFFER+u.MTIME,!0))}}async waitUntilReady(t){let e=Date.now();for(;;){let s=this.getRequest();if(s===S.REQUEST)return!0;if(s!==S.IDLE)return!1;let i=Date.now()-e;if(i>=t)return!1;let n=t-i,c=l.waitAsync(this.int32View,o.REQUEST/4,S.IDLE,n);if(c.async&&await c.value==="timed-out")return!1}}waitForResult(t){return l.wait(this.int32View,o.RESULT_STATE/4,r.NONE,t)}notifyRequest(){return l.notify(this.int32View,o.REQUEST/4)}notifyResult(){return l.notify(this.int32View,o.RESULT_STATE/4)}reset(){this.setOpCode(h.NOOP),this.setRequest(S.IDLE),this.setResultState(r.NONE),this.setPathLength(0),this.setDataLength(0),this.setResultLength(0),this.setErrorCode(a.NONE),this.setFlags(g.NONE),this.setMode(0)}};function U(d){return d!==void 0&&Object.hasOwn(O,d)?O[d]:a.IO_ERROR}var N=class{fs;cwd;commandName;secureFetch;maxOutputSize;exec;invokeTool;protocol;running=!1;output={stdout:"",stderr:"",exitCode:0};outputLimitExceeded=!1;startTime=0;timeoutMs=0;lastResult=null;constructor(t,e,s,i,n=void 0,c=0,E=void 0,p=void 0){this.fs=e,this.cwd=s,this.commandName=i,this.secureFetch=n,this.maxOutputSize=c,this.exec=E,this.invokeTool=p,this.protocol=new T(t)}remainingMs(){return Math.max(0,this.timeoutMs-(Date.now()-this.startTime))}raceDeadline(t){let e=this.remainingMs();if(e<=0)return this.running=!1,this.output.exitCode=124,this.output.stderr+=`
|
|
4
|
+
${this.commandName}: execution timeout exceeded
|
|
5
|
+
`,Promise.reject(new Error("Operation timed out"));let s=t();return e===Number.POSITIVE_INFINITY?s:new Promise((i,n)=>{let c=A(()=>{this.running=!1,this.output.exitCode=124,this.output.stderr+=`
|
|
6
|
+
${this.commandName}: execution timeout exceeded
|
|
7
|
+
`,n(new Error("Operation timed out"))},e);s.then(E=>{m(c),i(E)},E=>{m(c),n(E)})})}async run(t){for(this.running=!0,this.startTime=Date.now(),this.timeoutMs=t;this.running;){if(Date.now()-this.startTime>=t){this.output.stderr+=`
|
|
8
|
+
${this.commandName}: execution timeout exceeded
|
|
9
|
+
`,this.output.exitCode=124;break}let s=this.remainingMs();if(!await this.protocol.waitUntilReady(s)){if(!this.running)break;this.output.stderr+=`
|
|
10
|
+
${this.commandName}: execution timeout exceeded
|
|
11
|
+
`,this.output.exitCode=124;break}if(!this.running)break;this.protocol.setRequest(S.IDLE);let n=this.protocol.getOpCode();await this.handleOperation(n),this.protocol.notifyResult()}return this.output}stop(){this.running=!1,this.lastResult=null,this.protocol.setRequest(S.CANCELLED),this.protocol.notifyRequest()}async handleOperation(t){try{switch(t){case h.READ_FILE:await this.handleReadFile();break;case h.WRITE_FILE:await this.handleWriteFile();break;case h.STAT:await this.handleStat();break;case h.LSTAT:await this.handleLstat();break;case h.READDIR:await this.handleReaddir();break;case h.MKDIR:await this.handleMkdir();break;case h.READ_RESULT_RANGE:this.handleReadResultRange();break;case h.WRITE_FILE_RANGE:await this.handleWriteFileRange();break;case h.RM:await this.handleRm();break;case h.EXISTS:await this.handleExists();break;case h.APPEND_FILE:await this.handleAppendFile();break;case h.SYMLINK:await this.handleSymlink();break;case h.READLINK:await this.handleReadlink();break;case h.CHMOD:await this.handleChmod();break;case h.REALPATH:await this.handleRealpath();break;case h.RENAME:await this.handleRename();break;case h.COPY_FILE:await this.handleCopyFile();break;case h.WRITE_STDOUT:this.handleWriteStdout();break;case h.WRITE_STDERR:this.handleWriteStderr();break;case h.EXIT:this.handleExit();break;case h.HTTP_REQUEST:await this.handleHttpRequest();break;case h.EXEC_COMMAND:await this.handleExecCommand();break;case h.INVOKE_TOOL:await this.handleInvokeTool();break;default:this.protocol.setErrorCode(a.IO_ERROR),this.protocol.setResultState(r.ERROR)}}catch(e){this.setErrorFromException(e)}}publishResult(t){let e=typeof t=="string"?new TextEncoder().encode(t):t;this.lastResult=e,this.protocol.setResultPrefix(e),this.protocol.setResultState(r.SUCCESS)}handleReadResultRange(){let t=this.protocol.getFlags(),e=this.protocol.getMode(),s=this.lastResult;if(!s||t>=s.length){this.protocol.setErrorCode(a.IO_ERROR),this.protocol.setResultFromString(`No retained result for range read (offset=${t}, length=${e}, retained=${s?.length??"none"})`),this.protocol.setResultState(r.ERROR);return}this.protocol.setResult(s.subarray(t,t+e)),this.protocol.setResultState(r.SUCCESS)}resolvePath(t){return this.fs.resolvePath(this.cwd,t)}async handleReadFile(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.readFileBuffer(t);this.publishResult(e)}catch(e){this.setErrorFromException(e)}}async handleWriteFileRange(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getFlags(),s=this.protocol.getData();try{if(e===0)await this.fs.writeFile(t,s);else{let i=await this.fs.stat(t);if(i.size!==e)throw new _("EIO",`non-sequential range write to '${t}': offset ${e} != size ${i.size}`);await this.fs.appendFile(t,s)}this.protocol.setResultState(r.SUCCESS)}catch(i){this.setErrorFromException(i)}}async handleWriteFile(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getData();try{await this.fs.writeFile(t,e),this.protocol.setResultState(r.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleStat(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.stat(t);this.protocol.encodeStat(e),this.protocol.setResultState(r.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleLstat(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.lstat(t);this.protocol.encodeStat(e),this.protocol.setResultState(r.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleReaddir(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.readdir(t);this.publishResult(JSON.stringify(e))}catch(e){this.setErrorFromException(e)}}async handleMkdir(){let t=this.resolvePath(this.protocol.getPath()),s=(this.protocol.getFlags()&g.MKDIR_RECURSIVE)!==0;try{await this.fs.mkdir(t,{recursive:s}),this.protocol.setResultState(r.SUCCESS)}catch(i){this.setErrorFromException(i)}}async handleRm(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getFlags(),s=(e&g.RECURSIVE)!==0,i=(e&g.FORCE)!==0;try{await this.fs.rm(t,{recursive:s,force:i}),this.protocol.setResultState(r.SUCCESS)}catch(n){this.setErrorFromException(n)}}async handleExists(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.exists(t);this.protocol.setResult(new Uint8Array([e?1:0])),this.protocol.setResultState(r.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleAppendFile(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getData();try{await this.fs.appendFile(t,e),this.protocol.setResultState(r.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleSymlink(){let t=this.protocol.getPath(),e=this.protocol.getDataAsString(),s=this.resolvePath(t);try{await this.fs.symlink(e,s),this.protocol.setResultState(r.SUCCESS)}catch(i){this.setErrorFromException(i)}}async handleReadlink(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.readlink(t);this.protocol.setResultFromString(e),this.protocol.setResultState(r.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleChmod(){let t=this.resolvePath(this.protocol.getPath()),e=this.protocol.getMode();try{await this.fs.chmod(t,e),this.protocol.setResultState(r.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleRealpath(){let t=this.resolvePath(this.protocol.getPath());try{let e=await this.fs.realpath(t);this.protocol.setResultFromString(e),this.protocol.setResultState(r.SUCCESS)}catch(e){this.setErrorFromException(e)}}async handleRename(){let t=this.resolvePath(this.protocol.getPath()),e=this.resolvePath(this.protocol.getDataAsString());try{await this.fs.mv(t,e),this.protocol.setResultState(r.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleCopyFile(){let t=this.resolvePath(this.protocol.getPath()),e=this.resolvePath(this.protocol.getDataAsString());try{await this.fs.cp(t,e),this.protocol.setResultState(r.SUCCESS)}catch(s){this.setErrorFromException(s)}}handleWriteStdout(){let t=this.protocol.getDataAsString();if(!this.tryAppendOutput("stdout",t)){this.outputLimitExceeded=!0,this.output.exitCode=1,this.appendOutputLimitError(),this.protocol.setErrorCode(a.IO_ERROR),this.protocol.setResultFromString("Output size limit exceeded"),this.protocol.setResultState(r.ERROR);return}this.protocol.setResultState(r.SUCCESS)}handleWriteStderr(){let t=this.protocol.getDataAsString();if(!this.tryAppendOutput("stderr",t)){this.outputLimitExceeded=!0,this.output.exitCode=1,this.appendOutputLimitError(),this.protocol.setErrorCode(a.IO_ERROR),this.protocol.setResultFromString("Output size limit exceeded"),this.protocol.setResultState(r.ERROR);return}this.protocol.setResultState(r.SUCCESS)}handleExit(){let t=this.protocol.getFlags();this.outputLimitExceeded?this.output.exitCode===0&&(this.output.exitCode=1):this.output.exitCode=t,this.protocol.setResultState(r.SUCCESS),this.running=!1}tryAppendOutput(t,e){return this.outputLimitExceeded?!1:this.maxOutputSize<=0?(t==="stdout"?this.output.stdout+=e:this.output.stderr+=e,!0):this.output.stdout.length+this.output.stderr.length+e.length>this.maxOutputSize?!1:(t==="stdout"?this.output.stdout+=e:this.output.stderr+=e,!0)}appendOutputLimitError(){if(this.maxOutputSize<=0)return;let t=`${this.commandName}: total output size exceeded (>${this.maxOutputSize} bytes), increase executionLimits.maxOutputSize
|
|
12
|
+
`,e=t.length>this.maxOutputSize?t.slice(0,this.maxOutputSize):t;if(this.output.stderr.includes("total output size exceeded"))return;let i=this.output.stdout.length+this.output.stderr.length+e.length-this.maxOutputSize;if(i>0)if(this.output.stdout.length>=i)this.output.stdout=this.output.stdout.slice(0,this.output.stdout.length-i);else{let n=i-this.output.stdout.length;this.output.stdout="",n>=this.output.stderr.length?this.output.stderr="":this.output.stderr=this.output.stderr.slice(0,this.output.stderr.length-n)}this.output.stderr+=e}async handleHttpRequest(){let t=this.secureFetch;if(!t){this.protocol.setErrorCode(a.NETWORK_NOT_CONFIGURED),this.protocol.setResultFromString("Network access not configured. Enable network in Bash options."),this.protocol.setResultState(r.ERROR);return}let e=this.protocol.getPath(),s=this.protocol.getDataAsString();try{let i=s?JSON.parse(s):{},n=this.remainingMs(),c=await this.raceDeadline(()=>t(e,{method:i.method,headers:i.headers,body:i.body,timeoutMs:n})),E=JSON.stringify({status:c.status,statusText:c.statusText,headers:c.headers,bodyBase64:L(c.body,"base64"),url:c.url});this.publishResult(E)}catch(i){let n=F(i instanceof Error?i.message:String(i));this.protocol.setErrorCode(a.NETWORK_ERROR),this.protocol.setResultFromString(n),this.protocol.setResultState(r.ERROR)}}async handleExecCommand(){let t=this.exec;if(!t){this.protocol.setErrorCode(a.IO_ERROR),this.protocol.setResultFromString("Command execution not available in this context."),this.protocol.setResultState(r.ERROR);return}let e=this.protocol.getPath(),s=this.protocol.getDataAsString(),i=new AbortController;try{let n={cwd:this.cwd,signal:i.signal};if(s){let p=JSON.parse(s);p.stdin&&(n.stdin=p.stdin),p.args&&Array.isArray(p.args)&&(n.args=p.args.map(x=>String(x)),e=C([e]))}let c=await this.raceDeadline(()=>t(e,n)),E=JSON.stringify({stdout:c.stdout,stderr:c.stderr,exitCode:c.exitCode});this.publishResult(E)}catch(n){i.abort();let c=n instanceof Error?n.message:String(n);this.protocol.setErrorCode(a.IO_ERROR),this.protocol.setResultFromString(c),this.protocol.setResultState(r.ERROR)}}async handleInvokeTool(){let t=this.invokeTool;if(!t){this.protocol.setErrorCode(a.IO_ERROR),this.protocol.setResultFromString("Tool invocation not available in this context."),this.protocol.setResultState(r.ERROR);return}let e=this.protocol.getPath(),s=this.protocol.getDataAsString();try{let i=await this.raceDeadline(()=>w.runTrustedAsync(()=>t(e,s)));this.publishResult(i)}catch(i){let n=D(i instanceof Error?i.message:String(i));this.protocol.setErrorCode(a.IO_ERROR),this.protocol.setResultFromString(n),this.protocol.setResultState(r.ERROR)}}setErrorFromException(t){let e=t instanceof Error?t.message:String(t),s=F(e);this.protocol.setErrorCode(U(f(t))),this.protocol.setResultFromString(s),this.protocol.setResultState(r.ERROR)}};export{M as a,N as b};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{c as
|
|
4
|
-
`,exitCode:1};let
|
|
5
|
-
`,
|
|
6
|
-
`)}catch(o){let m=g(o),p=
|
|
7
|
-
`:
|
|
3
|
+
import{c as n}from"./chunk-OHFB3M3X.js";import{a as d}from"./chunk-PBOVSFTJ.js";import{a as u}from"./chunk-NE4R2FVV.js";import{a as g}from"./chunk-I4IRHQDW.js";var b={recursive:{short:"r",long:"recursive",type:"boolean"},recursiveUpper:{short:"R",type:"boolean"},force:{short:"f",long:"force",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},C={name:"rm",async execute(v,s){let e=u("rm",v,b);if(!e.ok)return e.error;let l=e.result.flags.recursive||e.result.flags.recursiveUpper,a=e.result.flags.force,y=e.result.flags.verbose,f=e.result.positional;if(f.length===0)return a?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:`rm: missing operand
|
|
4
|
+
`,exitCode:1};let c="",t="",i=0;for(let r of f)try{let o=s.fs.resolvePath(s.cwd,r);if((await s.fs.stat(o)).isDirectory&&!l){t+=`rm: cannot remove '${r}': Is a directory
|
|
5
|
+
`,i=1;continue}await s.fs.rm(o,{recursive:l,force:a}),y&&(c+=`removed '${r}'
|
|
6
|
+
`)}catch(o){let m=g(o),p=n(o,"ENOENT");if(a&&p)continue;p?t+=`rm: cannot remove '${r}': No such file or directory
|
|
7
|
+
`:n(o,"ENOTEMPTY")?t+=`rm: cannot remove '${r}': Directory not empty
|
|
8
|
+
`:n(o,"EROFS")?t+=`rm: cannot remove '${r}': Read-only file system
|
|
8
9
|
`:t+=`rm: cannot remove '${r}': ${d(m)}
|
|
9
|
-
`,
|
|
10
|
+
`,i=1}return{stdout:c,stderr:t,exitCode:i}}},N={name:"rm",flags:[{flag:"-r",type:"boolean"},{flag:"-R",type:"boolean"},{flag:"-f",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0};export{C as a,N as b};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{a as W}from"./chunk-
|
|
3
|
+
import{a as W}from"./chunk-3DWQCLNP.js";import{c as $}from"./chunk-42AMF6EE.js";import{b as C}from"./chunk-HWI42GQO.js";import{a as V}from"./chunk-AIWBN36Z.js";import{b as I}from"./chunk-CPKBPQ2C.js";import{a as B,b}from"./chunk-PBOVSFTJ.js";import{a as x}from"./chunk-I4IRHQDW.js";import{a as N,b as R}from"./chunk-MUFNRCMY.js";import{existsSync as ce}from"node:fs";import{dirname as de,join as T,sep as Q}from"node:path";import{fileURLToPath as me}from"node:url";import{Worker as he}from"node:worker_threads";import pe from"sql.js";function K(e,t){return e==null?Buffer.byteLength(t,"utf8"):e instanceof Uint8Array||Buffer.isBuffer(e)?e.byteLength:Buffer.byteLength(String(e),"utf8")}function X(e,t,r){let n=r.maxOutputSize??Number.MAX_SAFE_INTEGER,s=Buffer.byteLength(r.separator,"utf8");s+=Buffer.byteLength(r.newline,"utf8");for(let a of e)s+=Buffer.byteLength(a,"utf8");for(let a of t){s+=a.length*16;for(let i of a)s+=K(i,r.nullValue);if(s>n)break}let o=s*8+(t.length+3)*(e.length+3)*16;if(!Number.isSafeInteger(o)||o>n)throw new Error(`formatted output exceeds ${n} byte limit`);return n}function _(e,t,r){let n=X(e,t,r),s;switch(r.mode){case"list":s=Y(e,t,r);break;case"csv":s=Z(e,t,r);break;case"json":s=te(e,t);break;case"line":s=re(e,t,r);break;case"column":s=ne(e,t,r);break;case"table":s=se(e,t,r);break;case"markdown":s=oe(e,t,r);break;case"tabs":s=ie(e,t,r);break;case"box":s=ae(e,t,r);break;case"quote":s=le(e,t,r);break;case"html":s=fe(e,t,r);break;case"ascii":s=ue(e,t,r);break}if(Buffer.byteLength(s,"utf8")>n)throw new Error(`formatted output exceeds ${n} byte limit`);return s}function m(e,t){return e==null?t:e instanceof Uint8Array||Buffer.isBuffer(e)?Buffer.from(e).toString("utf8"):typeof e=="number"&&!Number.isInteger(e)?e.toPrecision(17).replace(/\.?0+$/,""):String(e)}function Y(e,t,r){let n=[];r.header&&e.length>0&&n.push(e.join(r.separator));for(let s of t)n.push(s.map(o=>m(o,r.nullValue)).join(r.separator));return n.length>0?`${n.join(r.newline)}${r.newline}`:""}function Z(e,t,r){let n=[];r.header&&e.length>0&&n.push(e.map(v).join(","));for(let s of t)n.push(s.map(o=>v(m(o,r.nullValue))).join(","));return n.length>0?`${n.join(`
|
|
4
4
|
`)}
|
|
5
5
|
`:""}function v(e){return e.includes(",")||e.includes('"')||e.includes("'")||e.includes(`
|
|
6
6
|
`)?`"${e.replace(/"/g,'""')}"`:e}function F(e){return e.toPrecision(17).replace(/\.?0+$/,"")}function ee(e){return e===null?"null":typeof e=="number"?Number.isInteger(e)?String(e):F(e):JSON.stringify(e)}function te(e,t){return t.length===0?"":`[${t.map(n=>`{${e.map((o,a)=>`${JSON.stringify(o)}:${ee(n[a])}`).join(",")}}`).join(`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{a as w}from"./chunk-QES5OSUC.js";import{b as m}from"./chunk-GR4ZHKXI.js";import{d as v}from"./chunk-I57EACSL.js";import{e as B}from"./chunk-
|
|
3
|
+
import{a as w}from"./chunk-QES5OSUC.js";import{b as m}from"./chunk-GR4ZHKXI.js";import{d as v}from"./chunk-I57EACSL.js";import{e as B}from"./chunk-AIWBN36Z.js";import{l as z}from"./chunk-FUT3X2GJ.js";import{a as L}from"./chunk-NE4R2FVV.js";import{a as F,b as E}from"./chunk-MUFNRCMY.js";import{constants as C,gunzipSync as _,gzipSync as A}from"node:zlib";var D={name:"gzip",summary:"compress or expand files",usage:"gzip [OPTION]... [FILE]...",description:`Compress FILEs (by default, in-place).
|
|
4
4
|
|
|
5
5
|
When no FILE is given, or when FILE is -, read from standard input.
|
|
6
6
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
+
import{b as P,c as O,d as R,e as T}from"./chunk-AIWBN36Z.js";import{f as F}from"./chunk-UBA7DOWE.js";import{l as $,m as w}from"./chunk-FUT3X2GJ.js";import{c as d}from"./chunk-OHFB3M3X.js";import{a as S}from"./chunk-NE4R2FVV.js";import{a as D}from"./chunk-I4IRHQDW.js";import{a as C,b as E}from"./chunk-MUFNRCMY.js";var H={name:"cp",summary:"copy files and directories",usage:"cp [OPTION]... SOURCE... DEST",options:["-r, -R, --recursive copy directories recursively","-n, --no-clobber do not overwrite an existing file","-p, --preserve preserve file attributes","-v, --verbose explain what is being done"," --help display this help and exit"]},I={recursive:{short:"r",long:"recursive",type:"boolean"},recursiveUpper:{short:"R",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},preserve:{short:"p",long:"preserve",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},q={name:"cp",async execute(m,e){if(E(m))return C(H);let n=S("cp",m,I);if(!n.ok)return n.error;let g=n.result.flags.recursive||n.result.flags.recursiveUpper,k=n.result.flags.noClobber,A=n.result.flags.preserve,N=n.result.flags.verbose,p=n.result.positional;if(p.length<2)return{stdout:"",stderr:`cp: missing destination file operand
|
|
4
|
+
`,exitCode:1};let f=p.pop()??"",y=p,l=e.fs.resolvePath(e.cwd,f),h="",s="",i=0,b=new R({limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:"cp"}),u=!1;try{u=(await e.fs.stat(l)).isDirectory}catch{}if(y.length>1&&!u)return{stdout:"",stderr:`cp: target '${f}' is not a directory
|
|
5
|
+
`,exitCode:1};for(let r of y)try{let t=e.fs.resolvePath(e.cwd,r),a=await e.fs.stat(t),o=l;if(u){let c=r.split("/").pop()||r;o=l==="/"?`/${c}`:`${l}/${c}`}if(a.isDirectory&&!g){s+=`cp: -r not specified; omitting directory '${r}'
|
|
6
|
+
`,i=1;continue}if(a.isDirectory){let c=await O(e.fs,t,o,b);if(F(t,o)||c==="inside"){s+=`cp: cannot copy '${r}' into itself, '${o}'
|
|
7
|
+
`,i=1;continue}if(c==="unknown"){s+=`cp: cannot safely determine whether '${o}' is inside '${r}'
|
|
8
|
+
`,i=1;continue}}if(k)try{await e.fs.stat(o);continue}catch{}let v=await P(e.fs,t,o);if(v==="same"){s+=`cp: '${r}' and '${o}' are the same file
|
|
9
|
+
`,i=1;continue}if(v==="unknown"){s+=`cp: cannot safely determine whether '${r}' and '${o}' are the same file
|
|
10
|
+
`,i=1;continue}a.isDirectory&&await T({fs:e.fs,root:t,limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:"cp",symlinks:"never",budget:b},()=>{}),await e.fs.cp(t,o,{recursive:g}),N&&(h+=`'${r}' -> '${o}'
|
|
11
|
+
`)}catch(t){if(t instanceof $||t instanceof w)throw t;let a=D(t);d(t,"ENOENT")?s+=`cp: cannot stat '${r}': No such file or directory
|
|
12
|
+
`:d(t,"EROFS")?s+=`cp: cannot create regular file '${f}': Read-only file system
|
|
13
|
+
`:s+=`cp: cannot copy '${r}': ${a}
|
|
14
|
+
`,i=1}return{stdout:h,stderr:s,exitCode:i}}},J={name:"cp",flags:[{flag:"-r",type:"boolean"},{flag:"-R",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-p",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0,minArgs:2};export{q as a,J as b};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{b as w}from"./chunk-GR4ZHKXI.js";import{d as b}from"./chunk-I57EACSL.js";import{d as S,e as F}from"./chunk-
|
|
3
|
+
import{b as w}from"./chunk-GR4ZHKXI.js";import{d as b}from"./chunk-I57EACSL.js";import{d as S,e as F}from"./chunk-AIWBN36Z.js";import{a as v,b as $,c as y}from"./chunk-MUFNRCMY.js";var E={name:"chmod",summary:"change file mode bits",usage:"chmod [OPTIONS] MODE FILE...",options:["-R change files recursively","-v output a diagnostic for every file processed"," --help display this help and exit"]},O={name:"chmod",async execute(e,a){if($(e))return v(E);if(e.length<2)return{stdout:"",stderr:`chmod: missing operand
|
|
4
4
|
`,exitCode:1};let i=!1,f=!1,n=0;for(;n<e.length&&e[n].startsWith("-");){let t=e[n];if(t==="-R"||t==="--recursive")i=!0,n++;else if(t==="-v"||t==="--verbose")f=!0,n++;else if(t==="--"){n++;break}else{if(/^[+-]?[rwxugo]+/.test(t)||/^\d+$/.test(t))break;if(/^-[Rv]+$/.test(t)){t.includes("R")&&(i=!0),t.includes("v")&&(f=!0),n++;continue}return y("chmod",t)}}if(e.length-n<2)return{stdout:"",stderr:`chmod: missing operand
|
|
5
5
|
`,exitCode:1};let r=e[n],d=e.slice(n+1),o=/^[0-7]+$/.test(r),s;if(o)s=parseInt(r,8);else try{p(r,420)}catch{return{stdout:"",stderr:`chmod: invalid mode: '${r}'
|
|
6
6
|
`,exitCode:1}}let u=new b(Math.min(a.limits.maxOutputSize,a.limits.maxStringLength),"chmod"),l="",c=!1;for(let t of d){let m=a.fs.resolvePath(a.cwd,t);try{let h;if(o&&s!==void 0)h=s;else{let g=await a.fs.stat(m);h=p(r,g.mode)}await a.fs.chmod(m,h),f&&u.append(`mode of '${t}' changed to ${h.toString(8).padStart(4,"0")}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{a as p}from"./chunk-B2DRBHGQ.js";import{a as n,b as l}from"./chunk-
|
|
3
|
+
import{a as p}from"./chunk-B2DRBHGQ.js";import{a as n,b as l}from"./chunk-QKJAAJ7J.js";import{a as m,b as d}from"./chunk-MUFNRCMY.js";var f={name:"sleep",summary:"delay for a specified amount of time",usage:"sleep NUMBER[SUFFIX]",description:`Pause for NUMBER seconds. SUFFIX may be:
|
|
4
4
|
s - seconds (default)
|
|
5
5
|
m - minutes
|
|
6
6
|
h - hours
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{d as X}from"./chunk-I57EACSL.js";import{d as I}from"./chunk-
|
|
3
|
+
import{d as X}from"./chunk-I57EACSL.js";import{d as I}from"./chunk-AIWBN36Z.js";import{l as W,m as Z}from"./chunk-FUT3X2GJ.js";import{a as G}from"./chunk-CPKBPQ2C.js";import{a as V}from"./chunk-NE4R2FVV.js";import{a as q,b as Q}from"./chunk-MUFNRCMY.js";function h(s,t,e){if(G(e)>s.limits.maxOutputSize-G(t))throw new W(`ls: output size limit exceeded (${s.limits.maxOutputSize} bytes)`,"output_size");return t+e}function tt(s,t){if(t>s.limits.maxArrayElements)throw new W(`ls: array element limit exceeded (${s.limits.maxArrayElements})`,"array_elements")}function ot(s,t,e){tt(s,e),t.reserve(e)}function x(s,t){let e=new X(s.limits.maxOutputSize,"ls");for(let l=0;l<t.length;l++)l>0&&e.append(`
|
|
4
4
|
`),e.append(t[l]);return t.length>0&&e.append(`
|
|
5
5
|
`),e.build()}function j(s){if(s<1024)return String(s);if(s<1024*1024){let e=s/1024;return e<10?`${e.toFixed(1)}K`:`${Math.round(e)}K`}if(s<1024*1024*1024){let e=s/1048576;return e<10?`${e.toFixed(1)}M`:`${Math.round(e)}M`}let t=s/(1024*1024*1024);return t<10?`${t.toFixed(1)}G`:`${Math.round(t)}G`}function B(s){let e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][s.getMonth()],l=String(s.getDate()).padStart(2," "),m=new Date,g=new Date(m.getTime()-4320*60*60*1e3);if(s>g){let D=String(s.getHours()).padStart(2,"0"),u=String(s.getMinutes()).padStart(2,"0");return`${e} ${l} ${D}:${u}`}let b=s.getFullYear();return`${e} ${l} ${b}`}function H(s){return s.isDirectory?"/":s.isSymbolicLink?"@":(s.mode&73)!==0?"*":""}var it={name:"ls",summary:"list directory contents",usage:"ls [OPTION]... [FILE]...",options:["-a, --all do not ignore entries starting with .","-A, --almost-all do not list . and ..","-d, --directory list directories themselves, not their contents","-F, --classify append indicator (one of */=>@) to entries","-h, --human-readable with -l, print sizes like 1K 234M 2G etc.","-l use a long listing format","-r, --reverse reverse order while sorting","-R, --recursive list subdirectories recursively","-S sort by file size, largest first","-t sort by time, newest first","-1 list one file per line"," --help display this help and exit"]},at={showAll:{short:"a",long:"all",type:"boolean"},showAlmostAll:{short:"A",long:"almost-all",type:"boolean"},longFormat:{short:"l",type:"boolean"},humanReadable:{short:"h",long:"human-readable",type:"boolean"},recursive:{short:"R",long:"recursive",type:"boolean"},reverse:{short:"r",long:"reverse",type:"boolean"},sortBySize:{short:"S",type:"boolean"},classifyFiles:{short:"F",long:"classify",type:"boolean"},directoryOnly:{short:"d",long:"directory",type:"boolean"},sortByTime:{short:"t",type:"boolean"},onePerLine:{short:"1",type:"boolean"}},gt={name:"ls",async execute(s,t){if(Q(s))return q(it);let e=V("ls",s,at);if(!e.ok)return e.error;let l=e.result.flags.showAll,m=e.result.flags.showAlmostAll,g=e.result.flags.longFormat,b=e.result.flags.humanReadable,D=e.result.flags.recursive,u=e.result.flags.reverse,w=e.result.flags.classifyFiles,P=e.result.flags.directoryOnly,R=lt(s,e.result.flags.sortBySize,e.result.flags.sortByTime);e.result.flags.onePerLine;let z=e.result.positional;z.length===0&&z.push(".");let $="",E="",C=0,O=new I({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"ls"});if(P){for(let n of await K(z,t,R,u,O)){O.visit(0);let i=t.fs.resolvePath(t.cwd,n);try{let v=await t.fs.stat(i);if(g){let L=v.isDirectory?"drwxr-xr-x":"-rw-r--r--",c=w?H(await t.fs.lstat(i)):"",S=v.size??0,y=b?j(S).padStart(5):String(S).padStart(5),f=v.mtime??new Date(0),o=B(f);$=h(t,$,`${L} 1 user user ${y} ${o} ${n}${c}
|
|
6
6
|
`)}else{let L=w?H(await t.fs.lstat(i)):"";$=h(t,$,`${n}${L}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{a as we}from"./chunk-BIJXTWZ4.js";import{a as Y}from"./chunk-IOKQFPM6.js";import{a as le}from"./chunk-3MRB66F4.js";import{a as be}from"./chunk-K27FY3ES.js";import{a as ae}from"./chunk-YXPSX3SI.js";import{b as ue,c as de,d as he}from"./chunk-YERKK5B3.js";import{d as ge}from"./chunk-
|
|
3
|
+
import{a as we}from"./chunk-BIJXTWZ4.js";import{a as Y}from"./chunk-IOKQFPM6.js";import{a as le}from"./chunk-3MRB66F4.js";import{a as be}from"./chunk-K27FY3ES.js";import{a as ae}from"./chunk-YXPSX3SI.js";import{b as ue,c as de,d as he}from"./chunk-YERKK5B3.js";import{d as ge}from"./chunk-AIWBN36Z.js";import{l as ie}from"./chunk-FUT3X2GJ.js";import{a as re}from"./chunk-CPKBPQ2C.js";import{a as me,b as ye}from"./chunk-MUFNRCMY.js";function z(e,t){switch(e.type){case"name":{let n=e.pattern,s=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(s){let a=s[1],o=t.name;if(e.ignoreCase){if(!o.toLowerCase().endsWith(a.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!o.endsWith(a))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Y(t.name,n,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let n=e.pattern,s=t.relativePath,a=n.split("/");for(let u=0;u<a.length-1;u++){let r=a[u];if(r&&r!=="."&&r!==".."&&!r.includes("*")&&!r.includes("?")&&!r.includes("[")){let i=`/${r}/`;if(e.ignoreCase){if(!s.toLowerCase().includes(i.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!s.includes(i))return{matches:!1,pruned:!1,printed:!1}}}let o=n.match(/\*(\.[a-zA-Z0-9]+)$/);if(o){let u=o[1];if(e.ignoreCase){if(!s.toLowerCase().endsWith(u.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!s.endsWith(u))return{matches:!1,pruned:!1,printed:!1}}return{matches:Y(s,n,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let n=e.ignoreCase?"i":"";return{matches:ae(e.pattern,n).test(t.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:t.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:t.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:t.isEmpty,pruned:!1,printed:!1};case"mtime":{let s=(Date.now()-t.mtime)/(1e3*60*60*24),a;return e.comparison==="more"?a=s>e.days:e.comparison==="less"?a=s<e.days:a=Math.floor(s)===e.days,{matches:a,pruned:!1,printed:!1}}case"newer":{let n=t.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:t.mtime>n,pruned:!1,printed:!1}}case"size":{let n=e.value;switch(e.unit){case"c":n=e.value;break;case"k":n=e.value*1024;break;case"M":n=e.value*1024*1024;break;case"G":n=e.value*1024*1024*1024;break;case"b":n=e.value*512;break}let s;return e.comparison==="more"?s=t.size>n:e.comparison==="less"?s=t.size<n:e.unit==="b"?s=Math.ceil(t.size/512)===e.value:s=t.size===n,{matches:s,pruned:!1,printed:!1}}case"perm":{let n=t.mode&511,s=e.mode&511,a;return e.matchType==="exact"?a=n===s:e.matchType==="all"?a=(n&s)===s:a=(n&s)!==0,{matches:a,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"action":return{matches:!0,pruned:!1,printed:!1,actions:[e.action]};case"not":{let n=z(e.expr,t);return{matches:!n.matches,pruned:n.pruned,printed:!1,actions:n.actions}}case"and":{let n=z(e.left,t);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1,actions:n.actions};let s=z(e.right,t);return{matches:s.matches,pruned:n.pruned||s.pruned,printed:n.printed||s.printed,actions:[...n.actions??[],...s.actions??[]]}}case"or":{let n=z(e.left,t);if(n.matches)return n;let s=z(e.right,t);return{matches:s.matches,pruned:n.pruned||s.pruned,printed:s.printed,actions:[...n.actions??[],...s.actions??[]]}}}}function Z(e){if(!e)return!1;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":return!1;case"action":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!0;case"not":return Z(e.expr);case"and":case"or":return Z(e.left)||Z(e.right)}}function J(e){if(!e)return!1;switch(e.type){case"empty":return!0;case"not":return J(e.expr);case"and":case"or":return J(e.left)||J(e.right);default:return!1}}function Se(e){let t=[],n=s=>{s&&(s.type==="newer"?t.push(s.refPath):s.type==="not"?n(s.expr):(s.type==="and"||s.type==="or")&&(n(s.left),n(s.right)))};return n(e),t}function V(e){if(!e)return!0;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":return!0;case"action":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return V(e.expr);case"and":case"or":return V(e.left)&&V(e.right)}}function B(e,t,n,s,a){switch(e.type){case"name":{let o=e.pattern,u=o.match(/^\*(\.[a-zA-Z0-9]+)$/);if(u){let r=u[1];if(e.ignoreCase){if(!t.toLowerCase().endsWith(r.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!t.endsWith(r))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Y(t,o,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let o=e.pattern,u=o.split("/");for(let i=0;i<u.length-1;i++){let l=u[i];if(l&&l!=="."&&l!==".."&&!l.includes("*")&&!l.includes("?")&&!l.includes("[")){let p=`/${l}/`;if(e.ignoreCase){if(!n.toLowerCase().includes(p.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.includes(p))return{matches:!1,pruned:!1,printed:!1}}}let r=o.match(/\*(\.[a-zA-Z0-9]+)$/);if(r){let i=r[1];if(e.ignoreCase){if(!n.toLowerCase().endsWith(i.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.endsWith(i))return{matches:!1,pruned:!1,printed:!1}}return{matches:Y(n,o,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let o=e.ignoreCase?"i":"";return{matches:ae(e.pattern,o).test(n),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s,pruned:!1,printed:!1}:e.fileType==="d"?{matches:a,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"prune":return{matches:!0,pruned:!0,printed:!1};case"action":return{matches:!0,pruned:!1,printed:!1,actions:[e.action]};case"not":{let o=B(e.expr,t,n,s,a);return{matches:!o.matches,pruned:o.pruned,printed:!1,actions:o.actions}}case"and":{let o=B(e.left,t,n,s,a);if(!o.matches)return{matches:!1,pruned:o.pruned,printed:!1,actions:o.actions};let u=B(e.right,t,n,s,a);return{matches:u.matches,pruned:o.pruned||u.pruned,printed:o.printed||u.printed,actions:[...o.actions??[],...u.actions??[]]}}case"or":{let o=B(e.left,t,n,s,a);if(o.matches)return o;let u=B(e.right,t,n,s,a);return{matches:u.matches,pruned:o.pruned||u.pruned,printed:u.printed,actions:[...o.actions??[],...u.actions??[]]}}default:return{matches:!1,pruned:!1,printed:!1}}}function _(e){if(!e)return!1;switch(e.type){case"prune":return!0;case"not":return _(e.expr);case"and":case"or":return _(e.left)||_(e.right);default:return!1}}function L(e){switch(e.type){case"name":case"path":case"regex":case"type":case"prune":return!0;case"action":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return L(e.expr);case"and":case"or":return L(e.left)&&L(e.right)}}function Te(e,t){if(!e||!t.isDirectory)return{shouldPrune:!1};if(!L(e))return oe(e,t);let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:z(e,n).pruned}}function oe(e,t){switch(e.type){case"or":{if(L(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};if(z(e.left,n).pruned)return{shouldPrune:!0}}return oe(e.right,t)}case"and":{if(L(e.left)&&L(e.right)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:z(e,n).pruned}}if(L(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return z(e.left,n).matches?oe(e.right,t):{shouldPrune:!1}}return{shouldPrune:!1}}case"not":return{shouldPrune:!1};default:return{shouldPrune:!1}}}function Ce(e,t){let n=[],s=t,a=r=>({expr:null,pathIndex:s,error:`find: missing argument to \`${r}'
|
|
4
4
|
`}),o=(r,i)=>({expr:null,pathIndex:s,error:`find: invalid argument \`${i}' to \`${r}'
|
|
5
5
|
`});for(;s<e.length;){let r=e[s];if(r==="("||r==="\\("){n.push({type:"lparen"}),s++;continue}if(r===")"||r==="\\)"){n.push({type:"rparen"}),s++;continue}if(r==="-name"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"name",pattern:e[++s]}})}else if(r==="-iname"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"name",pattern:e[++s],ignoreCase:!0}})}else if(r==="-path"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"path",pattern:e[++s]}})}else if(r==="-ipath"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"path",pattern:e[++s],ignoreCase:!0}})}else if(r==="-regex"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"regex",pattern:e[++s]}})}else if(r==="-iregex"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"regex",pattern:e[++s],ignoreCase:!0}})}else if(r==="-type"){if(s+1>=e.length)return a(r);let i=e[++s];if(i==="f"||i==="d")n.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${i}
|
|
6
6
|
`}}else if(r==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(r==="-mtime"){if(s+1>=e.length)return a(r);let i=e[++s],l="exact",p=i;if(i.startsWith("+")?(l="more",p=i.slice(1)):i.startsWith("-")&&(l="less",p=i.slice(1)),!/^\d+$/.test(p))return o(r,i);let I=Number(p);if(!Number.isSafeInteger(I))return o(r,i);n.push({type:"expr",expr:{type:"mtime",days:I,comparison:l}})}else if(r==="-newer"){if(s+1>=e.length)return a(r);let i=e[++s];n.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(r==="-size"){if(s+1>=e.length)return a(r);let i=e[++s],l="exact",p=i;i.startsWith("+")?(l="more",p=i.slice(1)):i.startsWith("-")&&(l="less",p=i.slice(1));let I=p.match(/^(\d+)([ckMGb])?$/);if(!I)return o(r,i);let N=Number(I[1]);if(!Number.isSafeInteger(N))return o(r,i);let P=I[2]||"b",j=P==="G"?1024**3:P==="M"?1024**2:P==="k"?1024:P==="b"?512:1;if(!Number.isSafeInteger(N*j))return o(r,i);n.push({type:"expr",expr:{type:"size",value:N,unit:P,comparison:l}})}else if(r==="-perm"){if(s+1>=e.length)return a(r);let i=e[++s],l="exact",p=i;if(i.startsWith("-")?(l="all",p=i.slice(1)):i.startsWith("/")&&(l="any",p=i.slice(1)),!/^[0-7]{1,4}$/.test(p))return o(r,i);let I=Number.parseInt(p,8);n.push({type:"expr",expr:{type:"perm",mode:I,matchType:l}})}else if(r==="-prune")n.push({type:"expr",expr:{type:"prune"}});else if(r==="-not"||r==="!")n.push({type:"not"});else if(r==="-o"||r==="-or")n.push({type:"op",op:"or"});else if(r==="-a"||r==="-and")n.push({type:"op",op:"and"});else if(r==="-maxdepth"||r==="-mindepth"){if(s+1>=e.length)return a(r);s++}else if(r!=="-depth")if(r==="-exec"){let i=[];for(s++;s<e.length&&e[s]!==";"&&e[s]!=="+";)i.push(e[s]),s++;if(s>=e.length)return{expr:null,pathIndex:s,error:"find: missing argument to `-exec'\n"};if(i.length===0)return a("-exec");let l=e[s]==="+";if(l&&(i.at(-1)!=="{}"||i.filter(p=>p==="{}").length!==1))return o("-exec","+");n.push({type:"expr",expr:{type:"action",action:{type:"exec",command:i,batchMode:l}}})}else if(r==="-print")n.push({type:"expr",expr:{type:"action",action:{type:"print"}}});else if(r==="-print0")n.push({type:"expr",expr:{type:"action",action:{type:"print0"}}});else if(r==="-printf"){if(s+1>=e.length)return a(r);let i=e[++s];n.push({type:"expr",expr:{type:"action",action:{type:"printf",format:i}}})}else if(r==="-delete")n.push({type:"expr",expr:{type:"action",action:{type:"delete"}}});else return r.startsWith("-")?{expr:null,pathIndex:s,error:`find: unknown predicate '${r}'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{d as k}from"./chunk-
|
|
3
|
+
import{d as k}from"./chunk-AIWBN36Z.js";import{l as u,m}from"./chunk-FUT3X2GJ.js";import{a as h,b as p,c as g}from"./chunk-MUFNRCMY.js";var w={name:"readlink",summary:"print resolved symbolic links or canonical file names",usage:"readlink [OPTIONS] FILE...",options:["-f canonicalize by following every symlink in every component of the given name recursively"," --help display this help and exit"]},x={name:"readlink",async execute(r,n){if(p(r))return h(w);let l=!1,t=0;for(;t<r.length&&r[t].startsWith("-");){let i=r[t];if(i==="-f"||i==="--canonicalize")l=!0,t++;else if(i==="--"){t++;break}else return g("readlink",i)}let c=r.slice(t);if(c.length===0)return{stdout:"",stderr:`readlink: missing operand
|
|
4
4
|
`,exitCode:1};let a="",d=!1,y=new k({limits:n.limits,signal:n.signal,executionScope:n.executionScope,site:"readlink",label:"symlink traversal"});for(let i of c){let s=n.fs.resolvePath(n.cwd,i);try{if(l){let e=s,o=new Set;for(;y.visit(o.size),!o.has(e);){o.add(e);try{let f=await n.fs.readlink(e);if(f.startsWith("/"))e=f;else{let b=e.substring(0,e.lastIndexOf("/"))||"/";e=n.fs.resolvePath(b,f)}}catch{break}}a+=`${e}
|
|
5
5
|
`}else{let e=await n.fs.readlink(s);a+=`${e}
|
|
6
6
|
`}}catch(e){if(e instanceof u||e instanceof m)throw e;l?a+=`${s}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
+
import{b as a}from"./chunk-HWI42GQO.js";var r=globalThis.setTimeout.bind(globalThis),l=globalThis.clearTimeout.bind(globalThis),T=globalThis.setInterval.bind(globalThis),f=globalThis.clearInterval.bind(globalThis);function u(e){return typeof e!="function"?e:a.bindCurrentContext(e)}var b=((e,n,...i)=>r(u(e),n,...i)),d=l,I=((e,n,...i)=>r(e,n,...i)),c=2147483647;function _(e,n){if(n===Number.POSITIVE_INFINITY)return;let i=u(e),t={cleared:!1,remainingMs:Math.max(0,n),timer:void 0},o=()=>{if(t.cleared)return;let s=Math.min(t.remainingMs,c);t.timer=r(()=>{t.cleared||(t.remainingMs-=s,t.remainingMs>0?o():i())},s)};return o(),t}function g(e){e&&(e.cleared=!0,e.timer!==void 0&&l(e.timer))}export{b as a,d as b,I as c,_ as d,g as e};
|