@jerryan/just-bash 3.7.0 → 3.8.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 +64 -0
- package/README.md +15 -5
- package/dist/AGENTS.md +2 -2
- package/dist/Bash.d.ts +4 -2
- package/dist/bin/chunks/{awk2-KO7ZE3P7.js → awk2-NTRVFXRA.js} +1 -1
- package/dist/bin/chunks/{chmod-G2BCCQGF.js → chmod-GX5SYTRL.js} +1 -1
- package/dist/bin/chunks/chunk-2NJJXU4K.js +27 -0
- package/dist/bin/{shell/chunks/chunk-THFQI5LV.js → chunks/chunk-3ROYEBJI.js} +1 -1
- package/dist/bin/chunks/chunk-6FGMEZZP.js +20 -0
- package/dist/bin/chunks/{chunk-FO7XJH3J.js → chunk-6JUPBMCR.js} +1 -1
- package/dist/bin/chunks/{chunk-3DWQCLNP.js → chunk-7WBCA2BB.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-HYLF56CC.js → chunks/chunk-ABP4OLJV.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-7PUOS2OO.js → chunks/chunk-ANX7U57Q.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-2UKTHDUM.js → chunks/chunk-BB5VTPMQ.js} +1 -1
- package/dist/bin/chunks/{chunk-WFHYGSLJ.js → chunk-CNVNOT67.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-ADI36B7X.js → chunks/chunk-DRPHNXG7.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-OXLC2WWX.js → chunks/chunk-H7PD6FLC.js} +10 -10
- package/dist/bin/{shell/chunks/chunk-QYZN33JA.js → chunks/chunk-IOKQFPM6.js} +1 -1
- package/dist/bin/chunks/{chunk-7KMOGI3N.js → chunk-KMYJMEON.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-RPUFEP5O.js → chunks/chunk-M3Z5NZXT.js} +1 -1
- package/dist/bin/chunks/{chunk-NBTZL3VS.js → chunk-MBREBDZQ.js} +1 -1
- package/dist/bin/chunks/{chunk-L345YZ6R.js → chunk-MF3GVFLC.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-RRECHBUS.js → chunks/chunk-MPFNZYEA.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-F3UDTTI7.js → chunks/chunk-ONF4KUYV.js} +1 -1
- package/dist/bin/chunks/chunk-PPVF2N6C.js +3 -0
- package/dist/bin/chunks/{chunk-V2XF3TTW.js → chunk-PRVPFKTC.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-7VWOECJ3.js → chunks/chunk-PTUQEN6I.js} +1 -1
- package/dist/bin/chunks/{chunk-R2J5MJOM.js → chunk-QFOXSCOD.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-6TUILMPB.js → chunks/chunk-QFTZKD5O.js} +1 -1
- package/dist/bin/chunks/{chunk-PEUGMGJJ.js → chunk-QJWFCA7P.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-66UHJFN6.js → chunks/chunk-RTN6X652.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-6O4Z6BQT.js → chunks/chunk-T6OIISUC.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-R76AK3KD.js → chunks/chunk-U5JLGI56.js} +1 -1
- package/dist/bin/chunks/{chunk-7PPAWLUI.js → chunk-V4S4A7M6.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-E26NQEH2.js → chunks/chunk-VPSBWWXM.js} +1 -1
- package/dist/bin/chunks/{chunk-GA5TPRMF.js → chunk-YXPSX3SI.js} +11 -11
- package/dist/bin/chunks/{chunk-472JZJ2D.js → chunk-ZVG47PYA.js} +1 -1
- package/dist/bin/{shell/chunks/cp-TMDR6USI.js → chunks/cp-YLP7ULVT.js} +1 -1
- package/dist/bin/{shell/chunks/diff-YXZZCUSQ.js → chunks/diff-JSJ56EOK.js} +1 -1
- package/dist/bin/{shell/chunks/du-UKFUX7KM.js → chunks/du-DH76GZJ3.js} +1 -1
- package/dist/bin/chunks/{expr-NNMDHOCN.js → expr-PQEPO5TE.js} +1 -1
- package/dist/bin/chunks/{file-4T64QNLS.js → file-JA7QI2YT.js} +1 -1
- package/dist/bin/chunks/{find-W2RZWTOF.js → find-MHC4QV6H.js} +1 -1
- package/dist/bin/chunks/{flag-coverage-QJ5ZQKCF.js → flag-coverage-2H5CPEM6.js} +1 -1
- package/dist/bin/chunks/{grep-IHDO3L72.js → grep-VXWNMIDD.js} +1 -1
- package/dist/bin/chunks/{gzip-WUK63QLL.js → gzip-UQZL4R74.js} +1 -1
- package/dist/bin/{shell/chunks/jq-V7OTAVU5.js → chunks/jq-YS4PR46D.js} +1 -1
- package/dist/bin/chunks/js-exec-T3SAB2B6.js +1651 -0
- package/dist/bin/{shell/chunks/ls-EROTXGTC.js → chunks/ls-5Z45FV4U.js} +1 -1
- package/dist/bin/chunks/{mv-HDNKXPO6.js → mv-EOOP2TO3.js} +1 -1
- package/dist/bin/chunks/python3-3ERN3L6S.js +23 -0
- package/dist/bin/{shell/chunks/readlink-ZUIECKQC.js → chunks/readlink-EJ3IKLWW.js} +1 -1
- package/dist/bin/{shell/chunks/rg-ODJAYIKX.js → chunks/rg-WHVR3YDT.js} +1 -1
- package/dist/bin/{shell/chunks/rmdir-W5NBOJ7E.js → chunks/rmdir-PRNISPBA.js} +1 -1
- package/dist/bin/{shell/chunks/sed-4LVDFHIJ.js → chunks/sed-SY63U2YX.js} +1 -1
- package/dist/bin/chunks/{sleep-MOJQBZMY.js → sleep-DVFE2GSF.js} +1 -1
- package/dist/bin/chunks/{split-TVJYLTIJ.js → split-HIFKSV2A.js} +1 -1
- package/dist/bin/chunks/{sqlite3-5BGAK7VX.js → sqlite3-KNN6V2W6.js} +1 -1
- package/dist/bin/chunks/{tar-7HGZIMZD.js → tar-7XOP7VOX.js} +1 -1
- package/dist/bin/chunks/{timeout-RQOWSWYG.js → timeout-YGFHQJKX.js} +1 -1
- package/dist/bin/chunks/{xan-WW53ETXT.js → xan-RMH6JEXM.js} +1 -1
- package/dist/bin/chunks/{yq-MYZOS2WN.js → yq-CWBZMGUV.js} +1 -1
- package/dist/bin/just-bash.js +262 -262
- package/dist/bin/shell/chunks/{awk2-KO7ZE3P7.js → awk2-NTRVFXRA.js} +1 -1
- package/dist/bin/shell/chunks/{chmod-G2BCCQGF.js → chmod-GX5SYTRL.js} +1 -1
- package/dist/bin/shell/chunks/chunk-2NJJXU4K.js +27 -0
- package/dist/bin/{chunks/chunk-THFQI5LV.js → shell/chunks/chunk-3ROYEBJI.js} +1 -1
- package/dist/bin/shell/chunks/chunk-6FGMEZZP.js +20 -0
- package/dist/bin/shell/chunks/{chunk-FO7XJH3J.js → chunk-6JUPBMCR.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-3DWQCLNP.js → chunk-7WBCA2BB.js} +1 -1
- package/dist/bin/{chunks/chunk-HYLF56CC.js → shell/chunks/chunk-ABP4OLJV.js} +1 -1
- package/dist/bin/{chunks/chunk-7PUOS2OO.js → shell/chunks/chunk-ANX7U57Q.js} +1 -1
- package/dist/bin/{chunks/chunk-2UKTHDUM.js → shell/chunks/chunk-BB5VTPMQ.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-WFHYGSLJ.js → chunk-CNVNOT67.js} +1 -1
- package/dist/bin/{chunks/chunk-ADI36B7X.js → shell/chunks/chunk-DRPHNXG7.js} +1 -1
- package/dist/bin/{chunks/chunk-OXLC2WWX.js → shell/chunks/chunk-H7PD6FLC.js} +10 -10
- package/dist/bin/{chunks/chunk-QYZN33JA.js → shell/chunks/chunk-IOKQFPM6.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-7KMOGI3N.js → chunk-KMYJMEON.js} +1 -1
- package/dist/bin/{chunks/chunk-RPUFEP5O.js → shell/chunks/chunk-M3Z5NZXT.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-NBTZL3VS.js → chunk-MBREBDZQ.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-L345YZ6R.js → chunk-MF3GVFLC.js} +1 -1
- package/dist/bin/{chunks/chunk-RRECHBUS.js → shell/chunks/chunk-MPFNZYEA.js} +1 -1
- package/dist/bin/{chunks/chunk-F3UDTTI7.js → shell/chunks/chunk-ONF4KUYV.js} +1 -1
- package/dist/bin/shell/chunks/chunk-PPVF2N6C.js +3 -0
- package/dist/bin/shell/chunks/{chunk-V2XF3TTW.js → chunk-PRVPFKTC.js} +1 -1
- package/dist/bin/{chunks/chunk-7VWOECJ3.js → shell/chunks/chunk-PTUQEN6I.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-R2J5MJOM.js → chunk-QFOXSCOD.js} +1 -1
- package/dist/bin/{chunks/chunk-6TUILMPB.js → shell/chunks/chunk-QFTZKD5O.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-PEUGMGJJ.js → chunk-QJWFCA7P.js} +1 -1
- package/dist/bin/{chunks/chunk-66UHJFN6.js → shell/chunks/chunk-RTN6X652.js} +1 -1
- package/dist/bin/{chunks/chunk-6O4Z6BQT.js → shell/chunks/chunk-T6OIISUC.js} +1 -1
- package/dist/bin/{chunks/chunk-R76AK3KD.js → shell/chunks/chunk-U5JLGI56.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-7PPAWLUI.js → chunk-V4S4A7M6.js} +1 -1
- package/dist/bin/{chunks/chunk-E26NQEH2.js → shell/chunks/chunk-VPSBWWXM.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-GA5TPRMF.js → chunk-YXPSX3SI.js} +11 -11
- package/dist/bin/shell/chunks/{chunk-472JZJ2D.js → chunk-ZVG47PYA.js} +1 -1
- package/dist/bin/{chunks/cp-TMDR6USI.js → shell/chunks/cp-YLP7ULVT.js} +1 -1
- package/dist/bin/{chunks/diff-YXZZCUSQ.js → shell/chunks/diff-JSJ56EOK.js} +1 -1
- package/dist/bin/{chunks/du-UKFUX7KM.js → shell/chunks/du-DH76GZJ3.js} +1 -1
- package/dist/bin/shell/chunks/{expr-NNMDHOCN.js → expr-PQEPO5TE.js} +1 -1
- package/dist/bin/shell/chunks/{file-4T64QNLS.js → file-JA7QI2YT.js} +1 -1
- package/dist/bin/shell/chunks/{find-W2RZWTOF.js → find-MHC4QV6H.js} +1 -1
- package/dist/bin/shell/chunks/{flag-coverage-QJ5ZQKCF.js → flag-coverage-2H5CPEM6.js} +1 -1
- package/dist/bin/shell/chunks/{grep-IHDO3L72.js → grep-VXWNMIDD.js} +1 -1
- package/dist/bin/shell/chunks/{gzip-WUK63QLL.js → gzip-UQZL4R74.js} +1 -1
- package/dist/bin/{chunks/jq-V7OTAVU5.js → shell/chunks/jq-YS4PR46D.js} +1 -1
- package/dist/bin/shell/chunks/js-exec-T3SAB2B6.js +1651 -0
- package/dist/bin/{chunks/ls-EROTXGTC.js → shell/chunks/ls-5Z45FV4U.js} +1 -1
- package/dist/bin/shell/chunks/{mv-HDNKXPO6.js → mv-EOOP2TO3.js} +1 -1
- package/dist/bin/shell/chunks/python3-3ERN3L6S.js +23 -0
- package/dist/bin/{chunks/readlink-ZUIECKQC.js → shell/chunks/readlink-EJ3IKLWW.js} +1 -1
- package/dist/bin/{chunks/rg-ODJAYIKX.js → shell/chunks/rg-WHVR3YDT.js} +1 -1
- package/dist/bin/{chunks/rmdir-W5NBOJ7E.js → shell/chunks/rmdir-PRNISPBA.js} +1 -1
- package/dist/bin/{chunks/sed-4LVDFHIJ.js → shell/chunks/sed-SY63U2YX.js} +1 -1
- package/dist/bin/shell/chunks/{sleep-MOJQBZMY.js → sleep-DVFE2GSF.js} +1 -1
- package/dist/bin/shell/chunks/{split-TVJYLTIJ.js → split-HIFKSV2A.js} +1 -1
- package/dist/bin/shell/chunks/{sqlite3-5BGAK7VX.js → sqlite3-KNN6V2W6.js} +1 -1
- package/dist/bin/shell/chunks/{tar-7HGZIMZD.js → tar-7XOP7VOX.js} +1 -1
- package/dist/bin/shell/chunks/{timeout-RQOWSWYG.js → timeout-YGFHQJKX.js} +1 -1
- package/dist/bin/shell/chunks/{xan-WW53ETXT.js → xan-RMH6JEXM.js} +1 -1
- package/dist/bin/shell/chunks/{yq-MYZOS2WN.js → yq-CWBZMGUV.js} +1 -1
- package/dist/bin/shell/shell.js +263 -263
- package/dist/bundle/browser.js +598 -579
- package/dist/bundle/chunks/{awk2-W6BNZEJN.js → awk2-VS5QVYHU.js} +1 -1
- package/dist/bundle/chunks/{chmod-XZNKTJHL.js → chmod-TEY5MD2W.js} +1 -1
- package/dist/bundle/chunks/{chunk-26GP3ACY.js → chunk-35MBA3VY.js} +1 -1
- package/dist/bundle/chunks/{chunk-IYJLVOVE.js → chunk-3OBCZP7T.js} +1 -1
- package/dist/bundle/chunks/{chunk-OR544SGH.js → chunk-45QZRGYF.js} +1 -1
- package/dist/bundle/chunks/{chunk-73JQKNZT.js → chunk-4KZT23KR.js} +11 -11
- package/dist/bundle/chunks/{chunk-PJM5C3HZ.js → chunk-5EI7WSRV.js} +10 -10
- package/dist/bundle/chunks/{chunk-T6DNSPYO.js → chunk-6BSOPPZH.js} +1 -1
- package/dist/bundle/chunks/{chunk-YNYC232D.js → chunk-6HO6HX7V.js} +1 -1
- package/dist/bundle/chunks/{chunk-2T7PBFL4.js → chunk-6QAM55HM.js} +1 -1
- package/dist/bundle/chunks/{chunk-SBOTR4JQ.js → chunk-ATGOUOX2.js} +1 -1
- package/dist/bundle/chunks/chunk-B6OSJB22.js +26 -0
- package/dist/bundle/chunks/{chunk-2TSZPVPI.js → chunk-BLPYR4TN.js} +1 -1
- package/dist/bundle/chunks/{chunk-VJ6UXG2R.js → chunk-CH7SUFFO.js} +1 -1
- package/dist/bundle/chunks/{chunk-FQUVK4Q5.js → chunk-DDPD7SIB.js} +1 -1
- package/dist/bundle/chunks/{chunk-TLPMB3FO.js → chunk-DMWNBCXJ.js} +1 -1
- package/dist/bundle/chunks/{chunk-YUOBBH7P.js → chunk-FSKXIFYT.js} +1 -1
- package/dist/bundle/chunks/{chunk-E3ABCXE4.js → chunk-GNPLDVBD.js} +1 -1
- package/dist/bundle/chunks/{chunk-FZZL53S2.js → chunk-GRUZ4SBY.js} +1 -1
- package/dist/bundle/chunks/{chunk-PMBXJ3OQ.js → chunk-HCKTU6IR.js} +1 -1
- package/dist/bundle/chunks/{chunk-4EDQZIAN.js → chunk-LGIJSCWH.js} +1 -1
- package/dist/bundle/chunks/chunk-MWL2I5BV.js +19 -0
- package/dist/bundle/chunks/{chunk-6IA4DXG2.js → chunk-N3A4JVFJ.js} +1 -1
- package/dist/bundle/chunks/{chunk-PPEXVPHR.js → chunk-O452S4KX.js} +1 -1
- package/dist/bundle/chunks/{chunk-3BMWRGU2.js → chunk-RWQWFXMH.js} +1 -1
- package/dist/bundle/chunks/{chunk-D5FHVW27.js → chunk-S6DNKKUL.js} +1 -1
- package/dist/bundle/chunks/{chunk-OPYVVD5P.js → chunk-SE23TEGG.js} +1 -1
- package/dist/bundle/chunks/{chunk-ULXTDFQC.js → chunk-U57DSHID.js} +1 -1
- package/dist/bundle/chunks/{chunk-ACVD6PQF.js → chunk-WE7BJ7YU.js} +1 -1
- package/dist/bundle/chunks/chunk-WXPNKIIH.js +2 -0
- package/dist/bundle/chunks/{chunk-5I5U6IYI.js → chunk-XQ2ZZFO6.js} +1 -1
- package/dist/bundle/chunks/{chunk-YFFU74KY.js → chunk-XV2V56NQ.js} +1 -1
- package/dist/bundle/chunks/{chunk-5DMO6LFU.js → chunk-Y6JBSHCM.js} +1 -1
- package/dist/bundle/chunks/{cp-NWITRTH3.js → cp-UR762VVT.js} +1 -1
- package/dist/bundle/chunks/{diff-CSARC7WF.js → diff-VDB6RXHO.js} +1 -1
- package/dist/bundle/chunks/{du-IFLWEM6M.js → du-EQKH3UNA.js} +1 -1
- package/dist/bundle/chunks/{expr-XSBELPAC.js → expr-A5XITHQD.js} +1 -1
- package/dist/bundle/chunks/{file-URNAD6FQ.js → file-6AYYTULJ.js} +1 -1
- package/dist/bundle/chunks/{find-EW6OHRPJ.js → find-RLKBCGJR.js} +1 -1
- package/dist/bundle/chunks/{flag-coverage-PIF5QRO7.js → flag-coverage-UMQ3BWDP.js} +1 -1
- package/dist/bundle/chunks/{grep-QDFNKAUW.js → grep-Q2O5EIXQ.js} +1 -1
- package/dist/bundle/chunks/{gzip-HBDKZBIP.js → gzip-KC5ENBD2.js} +1 -1
- package/dist/bundle/chunks/{jq-NY7PCVMH.js → jq-UKAA3QWU.js} +1 -1
- package/dist/bundle/chunks/js-exec-ZQMIYQTH.js +1650 -0
- package/dist/bundle/chunks/{ls-WJ7EIFVM.js → ls-WH5S4PPL.js} +1 -1
- package/dist/bundle/chunks/{mv-E2NFLGRQ.js → mv-WE7DBLEK.js} +1 -1
- package/dist/bundle/chunks/python3-QB7OE256.js +22 -0
- package/dist/bundle/chunks/{readlink-XCFO7YD2.js → readlink-JSRKXLLQ.js} +1 -1
- package/dist/bundle/chunks/{rg-J7XDRV3B.js → rg-JKB7DR66.js} +1 -1
- package/dist/bundle/chunks/{rmdir-UMUDM2L2.js → rmdir-3WTXMVKI.js} +1 -1
- package/dist/bundle/chunks/{sed-LIRH26EA.js → sed-6G32B25J.js} +1 -1
- package/dist/bundle/chunks/{sleep-25QUPVDK.js → sleep-PPRBTSVR.js} +1 -1
- package/dist/bundle/chunks/{split-D4HPO4G5.js → split-HUKVGJTW.js} +1 -1
- package/dist/bundle/chunks/{sqlite3-3HL2ECCQ.js → sqlite3-KB3MXTTM.js} +1 -1
- package/dist/bundle/chunks/{tar-B72KU357.js → tar-LE7LAAIX.js} +1 -1
- package/dist/bundle/chunks/{timeout-37GM7IIL.js → timeout-C6WDYPLV.js} +1 -1
- package/dist/bundle/chunks/{xan-UIGVJCMA.js → xan-UIL24CGT.js} +1 -1
- package/dist/bundle/chunks/{yq-FGNXZCGX.js → yq-ZRNZKDLE.js} +1 -1
- package/dist/bundle/index.cjs +2654 -1083
- package/dist/bundle/index.js +218 -218
- package/dist/commands/diff/format.d.ts +46 -0
- package/dist/commands/js-exec/js-exec.d.ts +1 -14
- package/dist/commands/js-exec/run-runtime.d.ts +10 -0
- package/dist/fs/traversal.d.ts +9 -0
- package/dist/interpreter/helpers/substitution-status.d.ts +34 -0
- package/dist/interpreter/interpreter.d.ts +1 -1
- package/dist/interpreter/types.d.ts +8 -1
- package/dist/limits.d.ts +2 -0
- package/dist/timers.d.ts +0 -9
- package/dist/types.d.ts +4 -3
- package/package.json +8 -8
- package/dist/bin/chunks/chunk-23OI2XDJ.js +0 -20
- package/dist/bin/chunks/chunk-E54Z6VIE.js +0 -12
- package/dist/bin/chunks/chunk-QKJAAJ7J.js +0 -3
- package/dist/bin/chunks/chunk-U7YR5CDD.js +0 -20
- package/dist/bin/chunks/js-exec-BE37X4L2.js +0 -99
- package/dist/bin/chunks/js-exec-worker.js +0 -4989
- package/dist/bin/chunks/python3-TJ6DCPIA.js +0 -14
- package/dist/bin/shell/chunks/chunk-23OI2XDJ.js +0 -20
- package/dist/bin/shell/chunks/chunk-E54Z6VIE.js +0 -12
- package/dist/bin/shell/chunks/chunk-QKJAAJ7J.js +0 -3
- package/dist/bin/shell/chunks/chunk-U7YR5CDD.js +0 -20
- package/dist/bin/shell/chunks/js-exec-BE37X4L2.js +0 -99
- package/dist/bin/shell/chunks/python3-TJ6DCPIA.js +0 -14
- package/dist/bundle/chunks/chunk-BS6EJR2R.js +0 -11
- package/dist/bundle/chunks/chunk-HMM3NGUJ.js +0 -19
- package/dist/bundle/chunks/chunk-PS2RJNZZ.js +0 -2
- package/dist/bundle/chunks/chunk-UTKGYVUZ.js +0 -7
- package/dist/bundle/chunks/js-exec-IREGAOMH.js +0 -98
- package/dist/bundle/chunks/js-exec-worker.js +0 -4989
- package/dist/bundle/chunks/python3-W4UMQJAQ.js +0 -13
- package/dist/commands/js-exec/js-exec-worker.d.ts +0 -33
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output formatters for diff.
|
|
3
|
+
*
|
|
4
|
+
* The three formats GNU diff can produce: POSIX normal format (the default),
|
|
5
|
+
* unified format (-u) and context format (-c). Layout was derived by running
|
|
6
|
+
* GNU diffutils 3.12 and matching the bytes it emits.
|
|
7
|
+
*
|
|
8
|
+
* Two intentional deviations from GNU:
|
|
9
|
+
*
|
|
10
|
+
* - The -u/-c file header carries no timestamp. GNU appends a tab and the
|
|
11
|
+
* file's mtime; inside a virtual filesystem that is often synthetic or
|
|
12
|
+
* absent, and it would make output non-reproducible. Patch consumers ignore
|
|
13
|
+
* the field.
|
|
14
|
+
* - When several minimal edit scripts exist for the same pair of files, which
|
|
15
|
+
* one comes out is arbitrary, and this picks a different one than GNU on
|
|
16
|
+
* some inputs. Hunks are still minimal and the formats are exact; only the
|
|
17
|
+
* grouping of ambiguous changes can differ.
|
|
18
|
+
*/
|
|
19
|
+
/** Number of context lines GNU shows around a change for -u and -c. */
|
|
20
|
+
export declare const DEFAULT_CONTEXT = 3;
|
|
21
|
+
export interface FileLines {
|
|
22
|
+
/** Lines with their trailing newline stripped. */
|
|
23
|
+
lines: string[];
|
|
24
|
+
/** True when the last line is not newline-terminated. */
|
|
25
|
+
noEol: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A run of adjacent deleted and/or inserted lines. Starts are 0-based indices
|
|
29
|
+
* into the corresponding `FileLines.lines`.
|
|
30
|
+
*/
|
|
31
|
+
export interface Change {
|
|
32
|
+
oldStart: number;
|
|
33
|
+
oldCount: number;
|
|
34
|
+
newStart: number;
|
|
35
|
+
newCount: number;
|
|
36
|
+
}
|
|
37
|
+
/** Splits file content into lines, remembering a missing final newline. */
|
|
38
|
+
export declare function splitLines(content: string): FileLines;
|
|
39
|
+
/** Computes the runs of deleted and/or inserted lines between two files. */
|
|
40
|
+
export declare function computeChanges(oldFile: FileLines, newFile: FileLines, ignoreCase: boolean): Change[];
|
|
41
|
+
/** POSIX normal format: `2c2` / `< old` / `---` / `> new`. */
|
|
42
|
+
export declare function formatNormal(oldFile: FileLines, newFile: FileLines, changes: Change[]): string;
|
|
43
|
+
/** Unified format (-u): `--- old`, `+++ new`, `@@` hunks. */
|
|
44
|
+
export declare function formatUnified(oldName: string, newName: string, oldFile: FileLines, newFile: FileLines, changes: Change[], context: number): string;
|
|
45
|
+
/** Context format (-c): `*** old`, `--- new`, `***************` hunks. */
|
|
46
|
+
export declare function formatContext(oldName: string, newName: string, oldFile: FileLines, newFile: FileLines, changes: Change[], context: number): string;
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* js-exec - Execute JavaScript code via QuickJS (WASM)
|
|
3
|
-
*
|
|
4
|
-
* Runs JavaScript code in an isolated worker thread with access to the
|
|
5
|
-
* virtual filesystem, HTTP, and sub-shell execution via SharedArrayBuffer bridge.
|
|
6
|
-
*
|
|
7
|
-
* This command is Node.js only (uses worker_threads).
|
|
8
|
-
*/
|
|
1
|
+
/** js-exec - Execute JavaScript code via the run package. */
|
|
9
2
|
import type { RuntimeCommand } from "../../types.js";
|
|
10
|
-
/** @internal Set the idle-teardown delay — for focused lifecycle tests only. */
|
|
11
|
-
export declare function _setJsExecWorkerIdleTimeoutMsForTests(ms: number): void;
|
|
12
|
-
/** @internal Whether the shared worker is currently alive — for tests only. */
|
|
13
|
-
export declare function _hasSharedJsExecWorkerForTests(): boolean;
|
|
14
|
-
/** @internal Reset singleton worker state — for focused protocol tests only. */
|
|
15
|
-
export declare function _resetJsExecWorkerForTests(): void;
|
|
16
3
|
export declare const jsExecCommand: RuntimeCommand;
|
|
17
4
|
export declare const nodeStubCommand: RuntimeCommand;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ExecResult, RuntimeCommandContext } from "../../types.js";
|
|
2
|
+
interface RunJsOptions {
|
|
3
|
+
source: string;
|
|
4
|
+
scriptPath: string;
|
|
5
|
+
scriptArgs: string[];
|
|
6
|
+
bootstrapCode?: string;
|
|
7
|
+
isModule: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function executeWithRun(options: RunJsOptions, ctx: RuntimeCommandContext): Promise<ExecResult>;
|
|
10
|
+
export {};
|
package/dist/fs/traversal.d.ts
CHANGED
|
@@ -67,6 +67,15 @@ export declare class FileTraversalBudget {
|
|
|
67
67
|
constructor(options: TraversalBudgetOptions);
|
|
68
68
|
checkpoint(work?: number): void;
|
|
69
69
|
visit(depth: number): void;
|
|
70
|
+
/**
|
|
71
|
+
* Reserve directory children against the entry ceiling without charging for
|
|
72
|
+
* work not yet done. A single readdir can return far more entries than the
|
|
73
|
+
* traversal is allowed to retain, so the collection has to be admitted
|
|
74
|
+
* before it is held, but reading a directory is one filesystem operation
|
|
75
|
+
* however many names come back. Callers that go on to touch each child
|
|
76
|
+
* should use `discover` instead, which also charges the work.
|
|
77
|
+
*/
|
|
78
|
+
reserve(count: number): void;
|
|
70
79
|
/**
|
|
71
80
|
* Reserve directory children before retaining work items for them. A single
|
|
72
81
|
* readdir can return far more entries than the traversal is allowed to
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exit-status bookkeeping for command substitutions.
|
|
3
|
+
*/
|
|
4
|
+
import type { RedirectionNode } from "../../ast/types.js";
|
|
5
|
+
import type { InterpreterState } from "../types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Record the exit status of a command substitution.
|
|
8
|
+
*
|
|
9
|
+
* `$?` and the "a substitution ran here" marker have to move together: a
|
|
10
|
+
* command with no command word (`x=1`, `> file`, an expansion that came out
|
|
11
|
+
* empty) reports the status of the last substitution that ran inside it, and
|
|
12
|
+
* 0 when none did. Setting `lastExitCode` without the marker leaves such a
|
|
13
|
+
* command reporting the *previous* command's status instead.
|
|
14
|
+
*/
|
|
15
|
+
export declare function recordSubstitutionExit(state: InterpreterState, exitCode: number): void;
|
|
16
|
+
/**
|
|
17
|
+
* The status bash gives a command that has no command word.
|
|
18
|
+
*
|
|
19
|
+
* It is the status of the last command substitution performed while expanding
|
|
20
|
+
* the command — assigned values and redirection words alike, in that order —
|
|
21
|
+
* and 0 when no substitution ran. A bare `x=1` is therefore 0 rather than
|
|
22
|
+
* whatever the previous command left in `$?`.
|
|
23
|
+
*
|
|
24
|
+
* A redirection onto fd 0 overrides all of that with 0. bash performs the
|
|
25
|
+
* redirections of a null command in a forked child when one of them reads
|
|
26
|
+
* stdin (`execute_null_command`'s `forcefork`), so the shell reports the
|
|
27
|
+
* child's status and any substitution in the words is discarded:
|
|
28
|
+
* `x=$(exit 7) < /dev/null` is 0, while `x=$(exit 7) 3< /dev/null` is 7.
|
|
29
|
+
*
|
|
30
|
+
* Verified against GNU bash 5.3. bash 3.2 predates the fork and reports 7 for
|
|
31
|
+
* both; this follows 5.x, which is what the comparison fixtures are recorded
|
|
32
|
+
* against.
|
|
33
|
+
*/
|
|
34
|
+
export declare function nullCommandExitStatus(state: InterpreterState, redirections: readonly RedirectionNode[]): number;
|
|
@@ -38,7 +38,7 @@ export interface InterpreterOptions {
|
|
|
38
38
|
/** Bootstrap JavaScript code for js-exec */
|
|
39
39
|
jsBootstrapCode?: string;
|
|
40
40
|
/** Tool invoker hook for js-exec's `tools` proxy */
|
|
41
|
-
invokeTool?: (path: string, argsJson: string) => Promise<string>;
|
|
41
|
+
invokeTool?: (path: string, argsJson: string, abortSignal: AbortSignal) => Promise<string>;
|
|
42
42
|
}
|
|
43
43
|
export declare class Interpreter {
|
|
44
44
|
private ctx;
|
|
@@ -320,6 +320,13 @@ export interface InterpreterState extends VariableAttributeState, LocalScopingSt
|
|
|
320
320
|
previousDir: string;
|
|
321
321
|
/** Exit code of last executed command */
|
|
322
322
|
lastExitCode: number;
|
|
323
|
+
/**
|
|
324
|
+
* Exit status of the most recent command substitution, or `null` when none
|
|
325
|
+
* has run since the current simple command began expanding. A command with
|
|
326
|
+
* no command word takes its status from this, not from `lastExitCode`:
|
|
327
|
+
* `x=$(exit 7)` is 7, while a plain `x=1` is 0 no matter what ran before it.
|
|
328
|
+
*/
|
|
329
|
+
lastSubstitutionExitCode: number | null;
|
|
323
330
|
/** Last argument of previous command, for $_ expansion */
|
|
324
331
|
lastArg: string;
|
|
325
332
|
/** Current line number being executed (for $LINENO) */
|
|
@@ -398,5 +405,5 @@ export interface InterpreterContext {
|
|
|
398
405
|
* Tool invoker hook. When present, js-exec sets up a `tools` proxy that
|
|
399
406
|
* routes calls through this callback.
|
|
400
407
|
*/
|
|
401
|
-
invokeTool?: (path: string, argsJson: string) => Promise<string>;
|
|
408
|
+
invokeTool?: (path: string, argsJson: string, abortSignal: AbortSignal) => Promise<string>;
|
|
402
409
|
}
|
package/dist/limits.d.ts
CHANGED
|
@@ -82,6 +82,8 @@ export interface ExecutionLimits {
|
|
|
82
82
|
maxPythonTimeoutMs?: number;
|
|
83
83
|
/** Maximum JavaScript execution time in milliseconds (normal default: 30000) */
|
|
84
84
|
maxJsTimeoutMs?: number;
|
|
85
|
+
/** Maximum JavaScript host-bridge operations (normal default: 1000000) */
|
|
86
|
+
maxJsBridgeRequests?: number;
|
|
85
87
|
/** Maximum glob filesystem operations (normal default: 1000000) */
|
|
86
88
|
maxGlobOperations?: number;
|
|
87
89
|
/** Maximum string length in bytes (normal default: 64 MiB) */
|
package/dist/timers.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
export declare const _setTimeout: typeof globalThis.setTimeout;
|
|
2
2
|
export declare const _clearTimeout: typeof globalThis.clearTimeout;
|
|
3
|
-
/**
|
|
4
|
-
* Native setTimeout WITHOUT execution-context binding. `_setTimeout`
|
|
5
|
-
* binds callbacks to the scheduling execution's defense context, which
|
|
6
|
-
* DefenseInDepthBox suppresses once that execution deactivates — correct
|
|
7
|
-
* for intra-execution timers (sleep, fetch deadlines), fatal for host
|
|
8
|
-
* infrastructure callbacks that must fire AFTER the execution ends
|
|
9
|
-
* (e.g. idle teardown of a shared worker). Use this for the latter.
|
|
10
|
-
*/
|
|
11
|
-
export declare const _setTimeoutUnbound: typeof globalThis.setTimeout;
|
|
12
3
|
export interface FiniteTimeoutHandle {
|
|
13
4
|
cleared: boolean;
|
|
14
5
|
remainingMs: number;
|
package/dist/types.d.ts
CHANGED
|
@@ -283,10 +283,11 @@ export interface RuntimeCommandContext {
|
|
|
283
283
|
jsBootstrapCode?: string;
|
|
284
284
|
/**
|
|
285
285
|
* Tool invoker hook. When present, js-exec sets up a `tools` proxy that
|
|
286
|
-
* routes calls through this callback. Receives `(path, argsJson
|
|
287
|
-
* returns a JSON result string.
|
|
286
|
+
* routes calls through this callback. Receives `(path, argsJson,
|
|
287
|
+
* abortSignal)` and returns a JSON result string. Implementations should
|
|
288
|
+
* forward the signal to cancelable work.
|
|
288
289
|
*/
|
|
289
|
-
invokeTool?: (path: string, argsJson: string) => Promise<string>;
|
|
290
|
+
invokeTool?: (path: string, argsJson: string, abortSignal: AbortSignal) => Promise<string>;
|
|
290
291
|
}
|
|
291
292
|
/** Legacy standalone context shape used by direct command invocations. */
|
|
292
293
|
export type CommandContext = Omit<RuntimeCommandContext, "limits" | "executionScope"> & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jerryan/just-bash",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "A simulated bash environment with virtual filesystem",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -77,7 +77,6 @@
|
|
|
77
77
|
"fast-check": "^3.23.2",
|
|
78
78
|
"knip": "^5.88.1",
|
|
79
79
|
"tsx": "^4.23.12",
|
|
80
|
-
"typescript": "^5.9.3",
|
|
81
80
|
"vitest": "^4.1.10"
|
|
82
81
|
},
|
|
83
82
|
"dependencies": {
|
|
@@ -88,13 +87,14 @@
|
|
|
88
87
|
"ini": "^6.0.0",
|
|
89
88
|
"modern-tar": "^0.7.7",
|
|
90
89
|
"papaparse": "^5.6.0",
|
|
91
|
-
"quickjs-emscripten": "^0.32.0",
|
|
92
90
|
"re2js": "^1.3.3",
|
|
91
|
+
"run": "2.1.3",
|
|
93
92
|
"seek-bzip": "^2.0.0",
|
|
94
93
|
"smol-toml": "^1.8.0",
|
|
95
94
|
"sprintf-js": "^1.1.3",
|
|
96
95
|
"sql.js": "^1.14.1",
|
|
97
96
|
"turndown": "^7.2.4",
|
|
97
|
+
"typescript": "^5.9.3",
|
|
98
98
|
"undici": "^7.29.0",
|
|
99
99
|
"yaml": "^2.9.0"
|
|
100
100
|
},
|
|
@@ -105,12 +105,12 @@
|
|
|
105
105
|
"scripts": {
|
|
106
106
|
"build": "rm -rf dist && tsc && pnpm build:lib && pnpm build:lib:cjs && pnpm build:browser && pnpm build:cli && pnpm build:shell && pnpm build:worker && pnpm build:clean && cp dist/index.d.ts dist/index.d.cts && sed '1,/^-->/d' AGENTS.npm.md > dist/AGENTS.md",
|
|
107
107
|
"build:clean": "find dist -name '*.test.js' -delete && find dist -name '*.test.d.ts' -delete",
|
|
108
|
-
"build:worker": "esbuild src/commands/python3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/python3/worker.js --external:../../../vendor/cpython-emscripten/* && cp src/commands/python3/worker.js dist/commands/python3/worker.js && mkdir -p dist/bin/chunks && cp src/commands/python3/worker.js dist/bin/chunks/worker.js && mkdir -p dist/bundle/chunks && cp src/commands/python3/worker.js dist/bundle/chunks/worker.js && esbuild src/commands/
|
|
109
|
-
"build:lib": "esbuild dist/index.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bundle --chunk-names=chunks/[name]-[hash] --banner:js='import{createRequire} from\"node:module\";const require=createRequire(import.meta.url);' --external:diff --external:sprintf-js --external:turndown --external:sql.js --external:
|
|
110
|
-
"build:lib:cjs": "esbuild dist/index.js --bundle --platform=node --format=cjs --minify --outfile=dist/bundle/index.cjs --external:diff --external:sprintf-js --external:turndown --external:sql.js --external:
|
|
108
|
+
"build:worker": "esbuild src/commands/python3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/python3/worker.js --external:../../../vendor/cpython-emscripten/* && cp src/commands/python3/worker.js dist/commands/python3/worker.js && mkdir -p dist/bin/chunks && cp src/commands/python3/worker.js dist/bin/chunks/worker.js && mkdir -p dist/bundle/chunks && cp src/commands/python3/worker.js dist/bundle/chunks/worker.js && esbuild src/commands/sqlite3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/sqlite3/worker.js --external:sql.js && mkdir -p dist/commands/sqlite3 && cp src/commands/sqlite3/worker.js dist/commands/sqlite3/worker.js && cp src/commands/sqlite3/worker.js dist/bin/chunks/sqlite3-worker.js && cp src/commands/sqlite3/worker.js dist/bundle/chunks/sqlite3-worker.js",
|
|
109
|
+
"build:lib": "esbuild dist/index.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bundle --chunk-names=chunks/[name]-[hash] --banner:js='import{createRequire} from\"node:module\";const require=createRequire(import.meta.url);' --external:diff --external:sprintf-js --external:turndown --external:sql.js --external:run --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip --external:guarded-fetch",
|
|
110
|
+
"build:lib:cjs": "esbuild dist/index.js --bundle --platform=node --format=cjs --minify --outfile=dist/bundle/index.cjs --external:diff --external:sprintf-js --external:turndown --external:sql.js --external:run --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip --external:guarded-fetch",
|
|
111
111
|
"build:browser": "esbuild dist/browser.js --bundle --platform=browser --format=esm --minify --outfile=dist/bundle/browser.js --external:diff --external:sprintf-js --external:turndown --external:undici --external:guarded-fetch --external:node:zlib --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip --define:__BROWSER__=true --alias:node:async_hooks=./src/shims/browser-unsupported.js --alias:node:dns=./src/shims/browser-unsupported.js --alias:node:module=./src/shims/browser-unsupported.js",
|
|
112
|
-
"build:cli": "esbuild dist/cli/just-bash.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node\nimport{createRequire} from\"node:module\";const require=createRequire(import.meta.url);' --external:sql.js --external:
|
|
113
|
-
"build:shell": "esbuild dist/cli/shell.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin/shell --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node\nimport{createRequire} from\"node:module\";const require=createRequire(import.meta.url);' --external:sql.js --external:
|
|
112
|
+
"build:cli": "esbuild dist/cli/just-bash.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node\nimport{createRequire} from\"node:module\";const require=createRequire(import.meta.url);' --external:sql.js --external:run --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
113
|
+
"build:shell": "esbuild dist/cli/shell.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin/shell --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node\nimport{createRequire} from\"node:module\";const require=createRequire(import.meta.url);' --external:sql.js --external:run --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
114
114
|
"validate": "pnpm lint && pnpm knip && pnpm typecheck && pnpm build && pnpm check:worker-sync && pnpm test:run && pnpm test:wasm && pnpm test:dist",
|
|
115
115
|
"typecheck": "tsc --noEmit",
|
|
116
116
|
"lint": "pnpm lint:banned",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{b as D}from"./chunk-CPKBPQ2C.js";import{a as N}from"./chunk-NE4R2FVV.js";import{a as H,b as A}from"./chunk-MUFNRCMY.js";var b=class{diff(e,n,t={}){let i;typeof t=="function"?(i=t,t={}):"callback"in t&&(i=t.callback);let d=this.castInput(e,t),o=this.castInput(n,t),s=this.removeEmpty(this.tokenize(d,t)),a=this.removeEmpty(this.tokenize(o,t));return this.diffWithOptionsObj(s,a,t,i)}diffWithOptionsObj(e,n,t,i){var d;let o=l=>{if(l=this.postProcess(l,t),i){setTimeout(function(){i(l)},0);return}else return l},s=n.length,a=e.length,u=1,r=s+a;t.maxEditLength!=null&&(r=Math.min(r,t.maxEditLength));let g=(d=t.timeout)!==null&&d!==void 0?d:1/0,w=Date.now()+g,m=[{oldPos:-1,lastComponent:void 0}],C=this.extractCommon(m[0],n,e,0,t);if(m[0].oldPos+1>=a&&C+1>=s)return o(this.buildValues(m[0].lastComponent,n,e));let P=-1/0,x=1/0,L=()=>{for(let l=Math.max(P,-u);l<=Math.min(x,u);l+=2){let c,h=m[l-1],p=m[l+1];h&&(m[l-1]=void 0);let y=!1;if(p){let S=p.oldPos-l;y=p&&0<=S&&S<s}let v=h&&h.oldPos+1<a;if(!y&&!v){m[l]=void 0;continue}if(!v||y&&h.oldPos<p.oldPos?c=this.addToPath(p,!0,!1,0,t):c=this.addToPath(h,!1,!0,1,t),C=this.extractCommon(c,n,e,l,t),c.oldPos+1>=a&&C+1>=s)return o(this.buildValues(c.lastComponent,n,e))||!0;m[l]=c,c.oldPos+1>=a&&(x=Math.min(x,l-1)),C+1>=s&&(P=Math.max(P,l+1))}u++};if(i)(function l(){setTimeout(function(){if(u>r||Date.now()>w)return i(void 0);L()||l()},0)})();else for(;u<=r&&Date.now()<=w;){let l=L();if(l)return l}}addToPath(e,n,t,i,d){let o=e.lastComponent;return o&&!d.oneChangePerToken&&o.added===n&&o.removed===t?{oldPos:e.oldPos+i,lastComponent:{count:o.count+1,added:n,removed:t,previousComponent:o.previousComponent}}:{oldPos:e.oldPos+i,lastComponent:{count:1,added:n,removed:t,previousComponent:o}}}extractCommon(e,n,t,i,d){let o=n.length,s=t.length,a=e.oldPos,u=a-i,r=0;for(;u+1<o&&a+1<s&&this.equals(t[a+1],n[u+1],d);)u++,a++,r++,d.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return r&&!d.oneChangePerToken&&(e.lastComponent={count:r,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=a,u}equals(e,n,t){return t.comparator?t.comparator(e,n):e===n||!!t.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){let n=[];for(let t=0;t<e.length;t++)e[t]&&n.push(e[t]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,t){let i=[],d;for(;e;)i.push(e),d=e.previousComponent,delete e.previousComponent,e=d;i.reverse();let o=i.length,s=0,a=0,u=0;for(;s<o;s++){let r=i[s];if(r.removed)r.value=this.join(t.slice(u,u+r.count)),u+=r.count;else{if(!r.added&&this.useLongestToken){let g=n.slice(a,a+r.count);g=g.map(function(w,m){let C=t[u+m];return C.length>w.length?C:w}),r.value=this.join(g)}else r.value=this.join(n.slice(a,a+r.count));a+=r.count,r.added||(u+=r.count)}}return i}};var I=class extends b{constructor(){super(...arguments),this.tokenize=W}equals(e,n,t){return t.ignoreWhitespace?((!t.newlineIsToken||!e.includes(`
|
|
4
|
-
`))&&(e=e.trim()),(!t.newlineIsToken||!n.includes(`
|
|
5
|
-
`))&&(n=n.trim())):t.ignoreNewlineAtEof&&!t.newlineIsToken&&(e.endsWith(`
|
|
6
|
-
`)&&(e=e.slice(0,-1)),n.endsWith(`
|
|
7
|
-
`)&&(n=n.slice(0,-1))),super.equals(e,n,t)}},O=new I;function T(f,e,n){return O.diff(f,e,n)}function W(f,e){e.stripTrailingCr&&(f=f.replace(/\r\n/g,`
|
|
8
|
-
`));let n=[],t=f.split(/(\n|\r\n)/);t[t.length-1]||t.pop();for(let i=0;i<t.length;i++){let d=t[i];i%2&&!e.newlineIsToken?n[n.length-1]+=d:n.push(d)}return n}var j={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function F(f,e,n,t,i,d,o){let s;o?typeof o=="function"?s={callback:o}:s=o:s={},typeof s.context>"u"&&(s.context=4);let a=s.context;if(s.newlineIsToken)throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(s.callback){let{callback:r}=s;T(n,t,Object.assign(Object.assign({},s),{callback:g=>{let w=u(g);r(w)}}))}else return u(T(n,t,s));function u(r){if(!r)return;r.push({value:"",lines:[]});function g(l){return l.map(function(c){return" "+c})}let w=[],m=0,C=0,P=[],x=1,L=1;for(let l=0;l<r.length;l++){let c=r[l],h=c.lines||R(c.value);if(c.lines=h,c.added||c.removed){if(!m){let p=r[l-1];m=x,C=L,p&&(P=a>0?g(p.lines.slice(-a)):[],m-=P.length,C-=P.length)}for(let p of h)P.push((c.added?"+":"-")+p);c.added?L+=h.length:x+=h.length}else{if(m)if(h.length<=a*2&&l<r.length-2)for(let p of g(h))P.push(p);else{let p=Math.min(h.length,a);for(let v of g(h.slice(0,p)))P.push(v);let y={oldStart:m,oldLines:x-m+p,newStart:C,newLines:L-C+p,lines:P};w.push(y),m=0,C=0,P=[]}x+=h.length,L+=h.length}}for(let l of w)for(let c=0;c<l.lines.length;c++)l.lines[c].endsWith(`
|
|
9
|
-
`)?l.lines[c]=l.lines[c].slice(0,-1):(l.lines.splice(c+1,0,"\"),c++);return{oldFileName:f,newFileName:e,oldHeader:i,newHeader:d,hunks:w}}}function E(f,e){if(e||(e=j),Array.isArray(f)){if(f.length>1&&!e.includeFileHeaders)throw new Error("Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)");return f.map(t=>E(t,e)).join(`
|
|
10
|
-
`)}let n=[];e.includeIndex&&f.oldFileName==f.newFileName&&n.push("Index: "+f.oldFileName),e.includeUnderline&&n.push("==================================================================="),e.includeFileHeaders&&(n.push("--- "+f.oldFileName+(typeof f.oldHeader>"u"?"":" "+f.oldHeader)),n.push("+++ "+f.newFileName+(typeof f.newHeader>"u"?"":" "+f.newHeader)));for(let t=0;t<f.hunks.length;t++){let i=f.hunks[t];i.oldLines===0&&(i.oldStart-=1),i.newLines===0&&(i.newStart-=1),n.push("@@ -"+i.oldStart+","+i.oldLines+" +"+i.newStart+","+i.newLines+" @@");for(let d of i.lines)n.push(d)}return n.join(`
|
|
11
|
-
`)+`
|
|
12
|
-
`}function k(f,e,n,t,i,d,o){if(typeof o=="function"&&(o={callback:o}),o?.callback){let{callback:s}=o;F(f,e,n,t,i,d,Object.assign(Object.assign({},o),{callback:a=>{s(a?E(a,o.headerOptions):void 0)}}))}else{let s=F(f,e,n,t,i,d,o);return s?E(s,o?.headerOptions):void 0}}function R(f){let e=f.endsWith(`
|
|
13
|
-
`),n=f.split(`
|
|
14
|
-
`).map(t=>t+`
|
|
15
|
-
`);return e?n.pop():n.push(n.pop().slice(0,-1)),n}var z={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:["-u, --unified output unified diff format (default)","-q, --brief report only whether files differ","-s, --report-identical-files report when files are the same","-i, --ignore-case ignore case differences"," --help display this help and exit"]},_={unified:{short:"u",long:"unified",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"}},ee={name:"diff",async execute(f,e){if(A(f))return H(z);let n=N("diff",f,_);if(!n.ok)return n.error;let t=n.result.flags.brief,i=n.result.flags.reportSame,d=n.result.flags.ignoreCase,o=n.result.positional;if(n.result.flags.unified,o.length<2)return{stdout:"",stderr:`diff: missing operand
|
|
16
|
-
`,exitCode:2};let s,a,[u,r]=o;try{s=u==="-"?D(e.stdin):await e.fs.readFile(e.fs.resolvePath(e.cwd,u))}catch{return{stdout:"",stderr:`diff: ${u}: No such file or directory
|
|
17
|
-
`,exitCode:2}}try{a=r==="-"?D(e.stdin):await e.fs.readFile(e.fs.resolvePath(e.cwd,r))}catch{return{stdout:"",stderr:`diff: ${r}: No such file or directory
|
|
18
|
-
`,exitCode:2}}let g=s,w=a;return d&&(g=g.toLowerCase(),w=w.toLowerCase()),g===w?i?{stdout:`Files ${u} and ${r} are identical
|
|
19
|
-
`,stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0}:t?{stdout:`Files ${u} and ${r} differ
|
|
20
|
-
`,stderr:"",exitCode:1}:{stdout:k(u,r,s,a,"","",{context:3}),stderr:"",exitCode:1}}},ne={name:"diff",flags:[{flag:"-u",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-i",type:"boolean"}],needsArgs:!0,minArgs:2};export{ee as a,ne as b};
|
|
@@ -1,12 +0,0 @@
|
|
|
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,3 +0,0 @@
|
|
|
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};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{d as V}from"./chunk-I57EACSL.js";import{d as B}from"./chunk-NBTZL3VS.js";import{l as _,m as Y}from"./chunk-FUT3X2GJ.js";import{a as J}from"./chunk-CPKBPQ2C.js";import{a as Q}from"./chunk-NE4R2FVV.js";import{a as Z,b as q}from"./chunk-MUFNRCMY.js";function h(s,t,e){if(J(e)>s.limits.maxOutputSize-J(t))throw new _(`ls: output size limit exceeded (${s.limits.maxOutputSize} bytes)`,"output_size");return t+e}function X(s,t){let e=new V(s.limits.maxOutputSize,"ls");for(let l=0;l<t.length;l++)l>0&&e.append(`
|
|
4
|
-
`),e.append(t[l]);return t.length>0&&e.append(`
|
|
5
|
-
`),e.build()}function I(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 K(s){let e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][s.getMonth()],l=String(s.getDate()).padStart(2," "),p=new Date,g=new Date(p.getTime()-4320*60*60*1e3);if(s>g){let z=String(s.getHours()).padStart(2,"0"),d=String(s.getMinutes()).padStart(2,"0");return`${e} ${l} ${z}:${d}`}let b=s.getFullYear();return`${e} ${l} ${b}`}function W(s){return s.isDirectory?"/":s.isSymbolicLink?"@":(s.mode&73)!==0?"*":""}var nt={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"]},ot={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"}},pt={name:"ls",async execute(s,t){if(q(s))return Z(nt);let e=Q("ls",s,ot);if(!e.ok)return e.error;let l=e.result.flags.showAll,p=e.result.flags.showAlmostAll,g=e.result.flags.longFormat,b=e.result.flags.humanReadable,z=e.result.flags.recursive,d=e.result.flags.reverse,$=e.result.flags.classifyFiles,O=e.result.flags.directoryOnly,R=it(s,e.result.flags.sortBySize,e.result.flags.sortByTime);e.result.flags.onePerLine;let F=e.result.positional;F.length===0&&F.push(".");let S="",P="",C=0,M=new B({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"ls"});if(O){for(let n of await G(F,t,R,d,M)){M.visit(0);let i=t.fs.resolvePath(t.cwd,n);try{let D=await t.fs.stat(i);if(g){let L=D.isDirectory?"drwxr-xr-x":"-rw-r--r--",c=$?W(await t.fs.lstat(i)):"",u=D.size??0,A=b?I(u).padStart(5):String(u).padStart(5),a=D.mtime??new Date(0),o=K(a);S=h(t,S,`${L} 1 user user ${A} ${o} ${n}${c}
|
|
6
|
-
`)}else{let L=$?W(await t.fs.lstat(i)):"";S=h(t,S,`${n}${L}
|
|
7
|
-
`)}}catch{P=h(t,P,`ls: cannot access '${n}': No such file or directory
|
|
8
|
-
`),C=2}}return{stdout:S,stderr:P,exitCode:C}}let m=[],y=[];for(let n of F){M.visit(0);try{((await t.fs.stat(t.fs.resolvePath(t.cwd,n))).isDirectory?y:m).push(n)}catch{P=h(t,P,`ls: ${n}: No such file or directory
|
|
9
|
-
`),C=2}}let T=async(n,i)=>{let D=await x(n,t,l,p,g,z,i,d,b,R,$,!1,M,0,new Set,!0);S=h(t,S,D.stdout),P=h(t,P,D.stderr),D.exitCode!==0&&(C=D.exitCode)};for(let n of await G(m,t,R,d,M))await T(n,!1);let N=F.length>1;for(let n of await G(y,t,R,d,M))S&&(S=h(t,S,`
|
|
10
|
-
`)),await T(n,N);return{stdout:S,stderr:P,exitCode:C}}};function it(s,t,e){if(!t&&!e)return"name";if(t!==e)return t?"size":"time";let l="name";for(let p of s){if(p==="--")break;if(!(!p.startsWith("-")||p.startsWith("--")))for(let g of p.slice(1))g==="S"?l="size":g==="t"&&(l="time")}return l}async function G(s,t,e,l,p){return await j(s,g=>t.fs.resolvePath(t.cwd,g),t,e,l,p)}async function j(s,t,e,l,p,g){let b=[...s];if(l==="name")b.sort();else{g?.checkpoint(b.length);let z=new Map;for(let d of b)try{let $=await e.fs.lstat(t(d));z.set(d,l==="size"?$.size??0:($.mtime??new Date(0)).getTime())}catch{z.set(d,0)}b.sort((d,$)=>{let O=(z.get($)??0)-(z.get(d)??0);return O!==0?O:d<$?-1:d>$?1:0})}return p&&b.reverse(),b}async function x(s,t,e,l,p,g,b,z=!1,d=!1,$="name",O=!1,R=!1,F=new B({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"ls"}),S=0,P=new Set,C=!1){let M=e||l,m=t.fs.resolvePath(t.cwd,s);try{C||F.visit(S);let y=await t.fs.stat(m);if(!y.isDirectory){let c=O?W(await t.fs.lstat(m)):"";if(p){let u=y.size??0,A=d?I(u).padStart(5):String(u).padStart(5),a=y.mtime??new Date(0),o=K(a);return{stdout:`-rw-r--r-- 1 user user ${A} ${o} ${s}${c}
|
|
11
|
-
`,stderr:"",exitCode:0}}return{stdout:`${s}${c}
|
|
12
|
-
`,stderr:"",exitCode:0}}let T=y.identity??(y.dev!==void 0&&y.ino!==void 0?`${String(y.dev)}:${String(y.ino)}`:await t.fs.realpath(m).catch(()=>{}));if(T!==void 0&&P.has(T))return{stdout:"",stderr:`ls: ${s}: symbolic link cycle detected
|
|
13
|
-
`,exitCode:2};let N=new Set(P);T!==void 0&&N.add(T);let n=await t.fs.readdir(m);F.checkpoint(),M||(n=n.filter(c=>!c.startsWith("."))),n=await j(n,c=>m==="/"?`/${c}`:`${m}/${c}`,t,$,!1,F),e&&(n=[".","..",...n]),z&&n.reverse();let i="",D="",L=0;if((g||b)&&(i=h(t,i,`${s}:
|
|
14
|
-
`)),p){i=h(t,i,`total ${n.length}
|
|
15
|
-
`);let c=n.filter(o=>o==="."||o===".."),u=n.filter(o=>o!=="."&&o!=="..");for(let o of c)i=h(t,i,`drwxr-xr-x 1 user user 0 Jan 1 00:00 ${o}
|
|
16
|
-
`);let A=[];for(let o=0;o<u.length;o+=100){let r=u.slice(o,o+100),f=await Promise.all(r.map(async v=>{let w=m==="/"?`/${v}`:`${m}/${v}`;try{let k=await t.fs.stat(w),H=k.isDirectory?"drwxr-xr-x":"-rw-r--r--",tt=O?W(await t.fs.lstat(w)):"",U=k.size??0,et=d?I(U).padStart(5):String(U).padStart(5),st=k.mtime??new Date(0),rt=K(st);return{name:v,line:`${H} 1 user user ${et} ${rt} ${v}${tt}
|
|
17
|
-
`}}catch{return{name:v,line:`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${v}
|
|
18
|
-
`}}}));A.push(...f)}let a=new Map(u.map((o,r)=>[o,r]));A.sort((o,r)=>(a.get(o.name)??0)-(a.get(r.name)??0));for(let{line:o}of A)i=h(t,i,o)}else if(O){let c=[],u=n.filter(a=>a!=="."&&a!==".."),A=n.filter(a=>a==="."||a==="..");for(let a of A)c.push(`${a}/`);for(let a=0;a<u.length;a+=100){let o=u.slice(a,a+100),r=await Promise.all(o.map(async f=>{let v=m==="/"?`/${f}`:`${m}/${f}`;try{let w=await t.fs.lstat(v);return`${f}${W(w)}`}catch{return f}}));c.push(...r)}i=h(t,i,X(t,c))}else i=h(t,i,X(t,n));if(g){let c=n.filter(r=>r!=="."&&r!==".."),u=[];if(t.fs.readdirWithFileTypes)u=(await t.fs.readdirWithFileTypes(m)).filter(f=>f.isDirectory&&c.includes(f.name)).map(f=>({name:f.name,isDirectory:!0}));else for(let r=0;r<c.length;r+=100){let f=c.slice(r,r+100),v=await Promise.all(f.map(async w=>{let k=m==="/"?`/${w}`:`${m}/${w}`;try{let H=await t.fs.stat(k);return{name:w,isDirectory:H.isDirectory}}catch{return{name:w,isDirectory:!1}}}));u.push(...v.filter(w=>w.isDirectory))}let A=await j(u.map(r=>r.name),r=>m==="/"?`/${r}`:`${m}/${r}`,t,$,z,F),a=new Map(A.map((r,f)=>[r,f]));u.sort((r,f)=>(a.get(r.name)??0)-(a.get(f.name)??0));let o=[];for(let r=0;r<u.length;r+=100){let f=u.slice(r,r+100),v=await Promise.all(f.map(async w=>{let k=s==="."?`./${w.name}`:`${s}/${w.name}`,H=await x(k,t,e,l,p,g,!1,z,d,$,O,!0,F,S+1,N);return{name:w.name,result:H}}));o.push(...v)}o.sort((r,f)=>(a.get(r.name)??0)-(a.get(f.name)??0));for(let{result:r}of o)i=h(t,i,`
|
|
19
|
-
`),i=h(t,i,r.stdout),D=h(t,D,r.stderr),r.exitCode!==0&&(L=r.exitCode)}return{stdout:i,stderr:D,exitCode:L}}catch(y){if(y instanceof _||y instanceof Y)throw y;return{stdout:"",stderr:`ls: ${s}: No such file or directory
|
|
20
|
-
`,exitCode:2}}}var ht={name:"ls",flags:[{flag:"-a",type:"boolean"},{flag:"-A",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-R",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-S",type:"boolean"},{flag:"-F",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-t",type:"boolean"},{flag:"-1",type:"boolean"}],needsFiles:!0};export{pt as a,ht as b};
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{a as A,b as B}from"./chunk-E54Z6VIE.js";import{a as q}from"./chunk-3DWQCLNP.js";import"./chunk-3MRB66F4.js";import"./chunk-O2BCKSMK.js";import"./chunk-TW2IJRUF.js";import{b as v,c as j}from"./chunk-QKJAAJ7J.js";import{a as F}from"./chunk-MROECM42.js";import{b as C}from"./chunk-HWI42GQO.js";import{b as E}from"./chunk-CPKBPQ2C.js";import"./chunk-OHFB3M3X.js";import{a as W,b as h}from"./chunk-PBOVSFTJ.js";import{a as S}from"./chunk-I4IRHQDW.js";import{b as M}from"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";import{AsyncLocalStorage as H}from"node:async_hooks";import{fileURLToPath as J}from"node:url";import{Worker as L}from"node:worker_threads";var O=new H,P=`js-exec - Sandboxed JavaScript/TypeScript runtime with Node.js-compatible APIs
|
|
4
|
-
|
|
5
|
-
Usage: js-exec [OPTIONS] [-c CODE | FILE] [ARGS...]
|
|
6
|
-
|
|
7
|
-
Options:
|
|
8
|
-
-c CODE Execute inline code
|
|
9
|
-
-m, --module Enable ES module mode (import/export)
|
|
10
|
-
--strip-types Strip TypeScript type annotations
|
|
11
|
-
--version, -V Show version
|
|
12
|
-
--help Show this help
|
|
13
|
-
|
|
14
|
-
Examples:
|
|
15
|
-
js-exec -c "console.log(1 + 2)"
|
|
16
|
-
js-exec script.js
|
|
17
|
-
js-exec app.ts
|
|
18
|
-
echo 'console.log("hello")' | js-exec
|
|
19
|
-
|
|
20
|
-
File Extension Auto-Detection:
|
|
21
|
-
.js script mode (module mode if top-level await detected)
|
|
22
|
-
.mjs ES module mode
|
|
23
|
-
.ts, .mts ES module mode + TypeScript stripping
|
|
24
|
-
|
|
25
|
-
Node.js Compatibility:
|
|
26
|
-
Code written for Node.js largely works here. Both require and import
|
|
27
|
-
are supported, the node: prefix works, and standard globals like process,
|
|
28
|
-
console, and fetch are available. All I/O is synchronous.
|
|
29
|
-
|
|
30
|
-
Available modules:
|
|
31
|
-
fs, path, child_process, process, console,
|
|
32
|
-
os, url, assert, util, events, buffer, stream,
|
|
33
|
-
string_decoder, querystring
|
|
34
|
-
|
|
35
|
-
fs (global, require('fs'), or import from 'node:fs'):
|
|
36
|
-
readFileSync, writeFileSync, appendFileSync, copyFileSync, renameSync
|
|
37
|
-
readdirSync, mkdirSync, rmSync, unlinkSync, rmdirSync
|
|
38
|
-
statSync, lstatSync, existsSync, realpathSync, chmodSync
|
|
39
|
-
symlinkSync, readlinkSync, readFileBuffer
|
|
40
|
-
fs.promises.readFile, fs.promises.writeFile, fs.promises.access, ...
|
|
41
|
-
|
|
42
|
-
path: join, resolve, dirname, basename, extname, normalize,
|
|
43
|
-
relative, isAbsolute, parse, format, sep, delimiter
|
|
44
|
-
|
|
45
|
-
child_process:
|
|
46
|
-
execSync(cmd) throws on non-zero exit, returns stdout
|
|
47
|
-
spawnSync(cmd, args) returns { stdout, stderr, status }
|
|
48
|
-
|
|
49
|
-
process (also global): argv, cwd(), exit(), env, platform, arch,
|
|
50
|
-
version, versions
|
|
51
|
-
|
|
52
|
-
os: platform(), arch(), homedir(), tmpdir(), type(), hostname(),
|
|
53
|
-
EOL, cpus(), endianness()
|
|
54
|
-
|
|
55
|
-
url: URL, URLSearchParams, parse(), format()
|
|
56
|
-
|
|
57
|
-
assert: ok(), equal(), strictEqual(), deepEqual(), throws(),
|
|
58
|
-
doesNotThrow(), fail()
|
|
59
|
-
|
|
60
|
-
util: format(), inspect(), promisify(), types, inherits()
|
|
61
|
-
|
|
62
|
-
events: EventEmitter (on, once, emit, off, removeListener, ...)
|
|
63
|
-
|
|
64
|
-
buffer: Buffer.from(), Buffer.alloc(), Buffer.concat(),
|
|
65
|
-
Buffer.isBuffer(), toString(), slice(), equals()
|
|
66
|
-
|
|
67
|
-
stream: Readable, Writable, Duplex, Transform, PassThrough, pipeline
|
|
68
|
-
|
|
69
|
-
string_decoder: StringDecoder (write, end)
|
|
70
|
-
|
|
71
|
-
querystring: parse(), stringify(), escape(), unescape()
|
|
72
|
-
|
|
73
|
-
Other Globals:
|
|
74
|
-
console log (stdout), error/warn (stderr)
|
|
75
|
-
fetch(url, opts) HTTP; returns Promise<Response> (Web Fetch API)
|
|
76
|
-
URL, URLSearchParams, Headers, Request, Response
|
|
77
|
-
Buffer Buffer.from(), Buffer.alloc(), etc.
|
|
78
|
-
|
|
79
|
-
Not Available:
|
|
80
|
-
http, https, net, tls, crypto, zlib, dns, cluster, worker_threads,
|
|
81
|
-
vm, v8, readline, and other Node.js built-in modules that require
|
|
82
|
-
native bindings. Use fetch() for HTTP requests.
|
|
83
|
-
|
|
84
|
-
Limits:
|
|
85
|
-
Memory: 64 MB per execution
|
|
86
|
-
Timeout: 10 s by default; configurable via maxJsTimeoutMs
|
|
87
|
-
Engine: QuickJS (compiled to WebAssembly)
|
|
88
|
-
`;function N(r){let e={code:null,scriptFile:null,showVersion:!1,scriptArgs:[],isModule:!1,stripTypes:!1};if(r.length===0)return e;for(let t=0;t<r.length;t++){let s=r[t];if(s==="-m"||s==="--module"){e.isModule=!0;continue}if(s==="--strip-types"){e.stripTypes=!0;continue}if(s==="-c")return t+1>=r.length?{stdout:"",stderr:`js-exec: option requires an argument -- 'c'
|
|
89
|
-
`,exitCode:2}:(e.code=r[t+1],e.scriptArgs=r.slice(t+2),e);if(s==="--version"||s==="-V")return e.showVersion=!0,e;if(s.startsWith("-")&&s!=="-"&&s!=="--")return{stdout:"",stderr:`js-exec: unrecognized option '${s}'
|
|
90
|
-
`,exitCode:2};if(s==="--")return t+1<r.length&&(e.scriptFile=r[t+1],e.scriptArgs=r.slice(t+2)),e;if(!s.startsWith("-"))return e.scriptFile=s,e.scriptArgs=r.slice(t+1),e}return e}var l=null,y=null,c=[],n=null,x=null,U=1e3,R=5e3;function fe(r){R=r}function pe(){return l!==null}function _(r,e,t){r.controller.close();let s=!1,o=()=>{if(!s&&(s=!0,v(i),n===r)){x="worker termination was not acknowledged";for(let a of c)a.bridgeHandler.stop(),a.resolve({success:!1,error:x});c.length=0,r.resolve(t)}},u=()=>{s||(s=!0,v(i),n===r&&(r.resolve(t),n=null,g()))},i=j(()=>{o()},U);r.controller.terminate(e).then(a=>a?u():o(),o)}function me(){y&&(v(y),y=null),n?.bridgeHandler.stop(),n=null;for(let e of c)e.bridgeHandler.stop();c.length=0;let r=l;l=null,r&&r.terminate(),x=null}var D=J(new URL("./js-exec-worker.js",import.meta.url));function g(){if(n||c.length===0)return;let r=c.shift();if(!r)return;n=r;let e=null;try{e=V(),e.postMessage(r.input)}catch(t){r.bridgeHandler.stop();let s={success:!1,error:h(S(t))},o=e??l;l===o&&(l=null),o?_(r,o,s):(r.resolve(s),n===r&&(n=null),g())}}function $(r,e){if(!r||typeof r!="object")return{success:!1,error:"Malformed worker response"};let t=r;return typeof t.protocolToken!="string"||t.protocolToken!==e?{success:!1,error:"Malformed worker response: invalid protocol token"}:typeof t.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:t.success?{success:!0}:{success:!1,type:t.type==="initialization-failure"?"initialization-failure":void 0,error:typeof t.error=="string"&&t.error.length>0?t.error:"Worker execution failed"}}function V(){if(y&&(v(y),y=null),l)return l;let r=C.runTrusted(()=>new L(D));return l=r,r.on("message",e=>{if(l===r){if(n){let t;try{n.controller.assertMessageSize(e,"response"),t=$(e,n.input.protocolToken)}catch(s){t={success:!1,error:h(S(s))}}if(t.type==="initialization-failure"){x=t.error??"Worker initialization failed",n.bridgeHandler.stop(),n.resolve(t),n=null;for(let s of c)s.bridgeHandler.stop(),s.resolve({success:!1,type:"initialization-failure",error:x});c.length=0,l=null,r.terminate();return}n.resolve(t),n=null}c.length>0?g():Q()}}),r.on("error",e=>{if(l===r){if(n){let t=h(S(e));n.resolve({success:!1,error:t}),n=null}for(let t of c)t.resolve({success:!1,error:"Worker crashed"});c.length=0,l=null}}),r.on("exit",()=>{l===r&&(l=null,n&&(n.resolve({success:!1,error:"Worker exited unexpectedly"}),n=null),c.length>0&&g())}),r}function Q(){y=j(()=>{l&&!n&&c.length===0&&(l.terminate(),l=null)},R)}async function G(r,e,t,s=[],o,u,i){return O.getStore()?{stdout:"",stderr:`js-exec: recursive invocation is not supported
|
|
91
|
-
`,exitCode:1}:Y(r,e,t,s,o,u,i)}async function K(r,e,t,s){let o,u=new Promise(d=>{o=d}),i={input:r,bridgeHandler:e,resolve:()=>{},controller:s};s.assertMessageSize({...r,sharedBuffer:void 0},"request");let a=d=>{e.stop();let f={success:!1,error:d==="abort"?i.controller.abortMessage():i.controller.timeoutMessage()};if(n===i){let p=l;l=null,p?_(i,p,f):(i.resolve(f),n=null,g())}else{let p=c.indexOf(i);p!==-1&&c.splice(p,1),i.resolve(f),n||g()}};if(i.resolve=d=>{i.controller.close(),o(d)},i.controller.arm(a),!i.controller.isCanceled){c.push(i);try{g()}catch(d){let f=c.indexOf(i);throw f!==-1&&c.splice(f,1),i.controller.close(),d}}let[m,k]=await Promise.all([e.run(t),u.catch(d=>({success:!1,error:h(S(d))}))]);return{bridgeOutput:m,workerResult:k}}function X(r){return r.limits.maxJsTimeoutMs}async function Y(r,e,t,s=[],o,u,i){if(x!==null)return{stdout:"",stderr:`js-exec: ${h(x)}
|
|
92
|
-
`,exitCode:1};let a=A(),m=e.exec,k=m?(b,I)=>O.run(!0,()=>m(b,I)):void 0,d=new B(a,e.fs,e.cwd,"js-exec",e.fetch,e.limits.maxOutputSize,k,e.invokeTool),f=X(e),p=new q({commandName:"js-exec",timeoutMs:f,signal:e.signal,maxMessageBytes:e.limits.maxWorkerMessageBytes}),z={protocolToken:p.protocolToken,sharedBuffer:a,jsCode:r,cwd:e.cwd,env:F(e.env),args:s,scriptPath:t,bootstrapCode:o,isModule:u,stripTypes:i,timeoutMs:f,hasInvokeTool:e.invokeTool!==void 0},{bridgeOutput:T,workerResult:w}=await K(z,d,f,p);if(!w.success&&w.error){let b=w.error===p.timeoutMessage()||w.error===p.abortMessage();return{stdout:T.stdout,stderr:`${T.stderr}js-exec: ${h(w.error)}
|
|
93
|
-
`,exitCode:T.exitCode||(b?124:1)}}return{...T}}var he={name:"js-exec",async execute(r,e){if(M(r))return{stdout:P,stderr:"",exitCode:0};let t=N(r);if("exitCode"in t)return t;if(t.showVersion)return{stdout:`QuickJS (quickjs-emscripten)
|
|
94
|
-
`,stderr:"",exitCode:0};let s,o;if(t.code!==null)s=t.code,o="-c";else if(t.scriptFile!==null){let m=e.fs.resolvePath(e.cwd,t.scriptFile);if(!await e.fs.exists(m))return{stdout:"",stderr:`js-exec: can't open file '${t.scriptFile}': No such file or directory
|
|
95
|
-
`,exitCode:2};try{s=await e.fs.readFile(m),o=m}catch(k){return{stdout:"",stderr:`js-exec: can't open file '${t.scriptFile}': ${W(k.message)}
|
|
96
|
-
`,exitCode:2}}}else if(E(e.stdin).trim())s=E(e.stdin),o="<stdin>";else return{stdout:"",stderr:`js-exec: no input provided (use -c CODE or provide a script file)
|
|
97
|
-
`,exitCode:2};let u=t.isModule,i=t.stripTypes;o&&o!=="-c"&&o!=="<stdin>"&&((o.endsWith(".mjs")||o.endsWith(".mts")||o.endsWith(".ts"))&&(u=!0),(o.endsWith(".ts")||o.endsWith(".mts"))&&(i=!0)),!u&&/\bawait\s+[\w([`]/.test(s)&&(u=!0);let a=e.jsBootstrapCode;return G(s,e,o,t.scriptArgs,a,u,i)}},ye={name:"node",async execute(){return{stdout:"",stderr:`node: this sandbox uses js-exec instead of node
|
|
98
|
-
|
|
99
|
-
${P}`,exitCode:1}}};export{pe as _hasSharedJsExecWorkerForTests,me as _resetJsExecWorkerForTests,fe as _setJsExecWorkerIdleTimeoutMsForTests,he as jsExecCommand,ye as nodeStubCommand};
|