@jerryan/just-bash 3.6.0 → 3.7.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 +349 -316
- package/LICENSE +201 -201
- package/README.md +827 -827
- package/dist/agent-sandbox.d.ts +5 -0
- package/dist/bin/chunks/chmod-G2BCCQGF.js +3 -0
- package/dist/bin/chunks/{chunk-B2GCIQI2.js → chunk-2UKTHDUM.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-7WBCA2BB.js → chunks/chunk-3DWQCLNP.js} +1 -1
- package/dist/bin/chunks/chunk-66UHJFN6.js +11 -0
- package/dist/bin/{shell/chunks/chunk-67XYNGRV.js → chunks/chunk-6O4Z6BQT.js} +1 -1
- package/dist/bin/chunks/{chunk-QFTZKD5O.js → chunk-6TUILMPB.js} +1 -1
- package/dist/bin/chunks/{chunk-M7SIPZZZ.js → chunk-7KMOGI3N.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-6ESRNSO7.js → chunks/chunk-ADI36B7X.js} +1 -1
- package/dist/bin/chunks/chunk-CN4JKMTR.js +8 -0
- package/dist/bin/{shell/chunks/chunk-DZAFUADN.js → chunks/chunk-E26NQEH2.js} +1 -1
- package/dist/bin/chunks/chunk-E54Z6VIE.js +12 -0
- package/dist/bin/chunks/chunk-F2PYTUMR.js +9 -0
- package/dist/bin/chunks/chunk-FO7XJH3J.js +13 -0
- package/dist/bin/chunks/chunk-HWK7KFGB.js +3 -0
- package/dist/bin/{shell/chunks/chunk-LE2XKKGQ.js → chunks/chunk-HYLF56CC.js} +1 -1
- package/dist/bin/chunks/chunk-KNTDFP7X.js +12 -0
- package/dist/bin/{shell/chunks/chunk-MF3GVFLC.js → chunks/chunk-L345YZ6R.js} +1 -1
- package/dist/bin/chunks/chunk-NBTZL3VS.js +3 -0
- package/dist/bin/chunks/chunk-OHFB3M3X.js +3 -0
- package/dist/bin/{shell/chunks/chunk-HQ63MFHG.js → chunks/chunk-PEUGMGJJ.js} +1 -1
- package/dist/bin/chunks/chunk-QKJAAJ7J.js +3 -0
- package/dist/bin/{shell/chunks/chunk-JELR4642.js → chunks/chunk-R76AK3KD.js} +12 -12
- package/dist/bin/chunks/{chunk-NLU5LALY.js → chunk-RRECHBUS.js} +1 -1
- package/dist/bin/chunks/{chunk-ZMGLTHSU.js → chunk-THFQI5LV.js} +1 -1
- package/dist/bin/chunks/{chunk-CL7IYCGG.js → chunk-U7YR5CDD.js} +1 -1
- package/dist/bin/chunks/cp-TMDR6USI.js +3 -0
- package/dist/bin/chunks/du-UKFUX7KM.js +3 -0
- package/dist/bin/chunks/find-W2RZWTOF.js +3 -0
- package/dist/bin/chunks/{flag-coverage-C7PB2MO7.js → flag-coverage-QJ5ZQKCF.js} +1 -1
- package/dist/bin/{shell/chunks/grep-CVU5V66H.js → chunks/grep-IHDO3L72.js} +1 -1
- package/dist/bin/chunks/gzip-WUK63QLL.js +3 -0
- package/dist/bin/{shell/chunks/js-exec-DJQLXWCS.js → chunks/js-exec-BE37X4L2.js} +7 -7
- package/dist/bin/chunks/js-exec-worker.js +296 -116
- package/dist/bin/chunks/ln-XVC53673.js +3 -0
- package/dist/bin/chunks/ls-EROTXGTC.js +3 -0
- package/dist/bin/chunks/mkdir-YJ3SOVRP.js +3 -0
- package/dist/bin/chunks/mv-HDNKXPO6.js +3 -0
- package/dist/bin/{shell/chunks/python3-JCJHSX4Z.js → chunks/python3-TJ6DCPIA.js} +1 -1
- package/dist/bin/chunks/readlink-ZUIECKQC.js +3 -0
- package/dist/bin/chunks/rg-ODJAYIKX.js +3 -0
- package/dist/bin/chunks/rm-B4LVIG7A.js +3 -0
- package/dist/bin/chunks/rmdir-W5NBOJ7E.js +3 -0
- package/dist/bin/{shell/chunks/sleep-DVFE2GSF.js → chunks/sleep-MOJQBZMY.js} +1 -1
- package/dist/bin/chunks/split-TVJYLTIJ.js +3 -0
- package/dist/bin/chunks/sqlite3-5BGAK7VX.js +3 -0
- package/dist/bin/chunks/{timeout-YGFHQJKX.js → timeout-RQOWSWYG.js} +1 -1
- package/dist/bin/chunks/worker.js +233 -108
- package/dist/bin/just-bash.js +381 -376
- package/dist/bin/shell/chunks/chmod-G2BCCQGF.js +3 -0
- package/dist/bin/shell/chunks/{chunk-B2GCIQI2.js → chunk-2UKTHDUM.js} +1 -1
- package/dist/bin/{chunks/chunk-7WBCA2BB.js → shell/chunks/chunk-3DWQCLNP.js} +1 -1
- package/dist/bin/shell/chunks/chunk-66UHJFN6.js +11 -0
- package/dist/bin/{chunks/chunk-67XYNGRV.js → shell/chunks/chunk-6O4Z6BQT.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-QFTZKD5O.js → chunk-6TUILMPB.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-M7SIPZZZ.js → chunk-7KMOGI3N.js} +1 -1
- package/dist/bin/{chunks/chunk-6ESRNSO7.js → shell/chunks/chunk-ADI36B7X.js} +1 -1
- package/dist/bin/shell/chunks/chunk-CN4JKMTR.js +8 -0
- package/dist/bin/{chunks/chunk-DZAFUADN.js → shell/chunks/chunk-E26NQEH2.js} +1 -1
- package/dist/bin/shell/chunks/chunk-E54Z6VIE.js +12 -0
- package/dist/bin/shell/chunks/chunk-F2PYTUMR.js +9 -0
- package/dist/bin/shell/chunks/chunk-FO7XJH3J.js +13 -0
- package/dist/bin/shell/chunks/chunk-HWK7KFGB.js +3 -0
- package/dist/bin/{chunks/chunk-LE2XKKGQ.js → shell/chunks/chunk-HYLF56CC.js} +1 -1
- package/dist/bin/shell/chunks/chunk-KNTDFP7X.js +12 -0
- package/dist/bin/{chunks/chunk-MF3GVFLC.js → shell/chunks/chunk-L345YZ6R.js} +1 -1
- package/dist/bin/shell/chunks/chunk-NBTZL3VS.js +3 -0
- package/dist/bin/shell/chunks/chunk-OHFB3M3X.js +3 -0
- package/dist/bin/{chunks/chunk-HQ63MFHG.js → shell/chunks/chunk-PEUGMGJJ.js} +1 -1
- package/dist/bin/shell/chunks/chunk-QKJAAJ7J.js +3 -0
- package/dist/bin/{chunks/chunk-JELR4642.js → shell/chunks/chunk-R76AK3KD.js} +12 -12
- package/dist/bin/shell/chunks/{chunk-NLU5LALY.js → chunk-RRECHBUS.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-ZMGLTHSU.js → chunk-THFQI5LV.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-CL7IYCGG.js → chunk-U7YR5CDD.js} +1 -1
- package/dist/bin/shell/chunks/cp-TMDR6USI.js +3 -0
- package/dist/bin/shell/chunks/du-UKFUX7KM.js +3 -0
- package/dist/bin/shell/chunks/find-W2RZWTOF.js +3 -0
- package/dist/bin/shell/chunks/{flag-coverage-C7PB2MO7.js → flag-coverage-QJ5ZQKCF.js} +1 -1
- package/dist/bin/{chunks/grep-CVU5V66H.js → shell/chunks/grep-IHDO3L72.js} +1 -1
- package/dist/bin/shell/chunks/gzip-WUK63QLL.js +3 -0
- package/dist/bin/{chunks/js-exec-DJQLXWCS.js → shell/chunks/js-exec-BE37X4L2.js} +7 -7
- package/dist/bin/shell/chunks/ln-XVC53673.js +3 -0
- package/dist/bin/shell/chunks/ls-EROTXGTC.js +3 -0
- package/dist/bin/shell/chunks/mkdir-YJ3SOVRP.js +3 -0
- package/dist/bin/shell/chunks/mv-HDNKXPO6.js +3 -0
- package/dist/bin/{chunks/python3-JCJHSX4Z.js → shell/chunks/python3-TJ6DCPIA.js} +1 -1
- package/dist/bin/shell/chunks/readlink-ZUIECKQC.js +3 -0
- package/dist/bin/shell/chunks/rg-ODJAYIKX.js +3 -0
- package/dist/bin/shell/chunks/rm-B4LVIG7A.js +3 -0
- package/dist/bin/shell/chunks/rmdir-W5NBOJ7E.js +3 -0
- package/dist/bin/{chunks/sleep-DVFE2GSF.js → shell/chunks/sleep-MOJQBZMY.js} +1 -1
- package/dist/bin/shell/chunks/split-TVJYLTIJ.js +3 -0
- package/dist/bin/shell/chunks/sqlite3-5BGAK7VX.js +3 -0
- package/dist/bin/shell/chunks/{timeout-YGFHQJKX.js → timeout-RQOWSWYG.js} +1 -1
- package/dist/bin/shell/shell.js +385 -380
- package/dist/bundle/browser.js +643 -638
- package/dist/bundle/chunks/chmod-XZNKTJHL.js +2 -0
- package/dist/bundle/chunks/{chunk-XVSR5HHH.js → chunk-2T7PBFL4.js} +1 -1
- package/dist/bundle/chunks/chunk-3BMWRGU2.js +10 -0
- package/dist/bundle/chunks/chunk-3CIDHL5V.js +11 -0
- package/dist/bundle/chunks/chunk-4CC3OZPU.js +2 -0
- package/dist/bundle/chunks/{chunk-FIMF2TLE.js → chunk-5DMO6LFU.js} +12 -12
- package/dist/bundle/chunks/{chunk-N3A4JVFJ.js → chunk-6IA4DXG2.js} +1 -1
- package/dist/bundle/chunks/chunk-A257L6QO.js +7 -0
- package/dist/bundle/chunks/{chunk-6DDRR56B.js → chunk-ACVD6PQF.js} +1 -1
- package/dist/bundle/chunks/chunk-BS6EJR2R.js +11 -0
- package/dist/bundle/chunks/chunk-D5FHVW27.js +2 -0
- package/dist/bundle/chunks/{chunk-24NLAR7R.js → chunk-E3ABCXE4.js} +1 -1
- package/dist/bundle/chunks/{chunk-FSJ6TTCC.js → chunk-HMM3NGUJ.js} +1 -1
- package/dist/bundle/chunks/chunk-IYJLVOVE.js +12 -0
- package/dist/bundle/chunks/chunk-LRFR25IP.js +8 -0
- package/dist/bundle/chunks/{chunk-NBNI7G66.js → chunk-OPYVVD5P.js} +1 -1
- package/dist/bundle/chunks/{chunk-F6XU52K3.js → chunk-OR544SGH.js} +1 -1
- package/dist/bundle/chunks/{chunk-RPKJJFGZ.js → chunk-PMBXJ3OQ.js} +1 -1
- package/dist/bundle/chunks/chunk-PS2RJNZZ.js +2 -0
- package/dist/bundle/chunks/{chunk-UC76ZOWM.js → chunk-SBOTR4JQ.js} +1 -1
- package/dist/bundle/chunks/chunk-T5ZEIOJ3.js +2 -0
- package/dist/bundle/chunks/{chunk-DMWNBCXJ.js → chunk-TLPMB3FO.js} +1 -1
- package/dist/bundle/chunks/{chunk-XV2V56NQ.js → chunk-YFFU74KY.js} +1 -1
- package/dist/bundle/chunks/{chunk-DAKEIWT3.js → chunk-YNYC232D.js} +1 -1
- package/dist/bundle/chunks/{chunk-ZXFELXJH.js → chunk-YUOBBH7P.js} +1 -1
- package/dist/bundle/chunks/cp-NWITRTH3.js +2 -0
- package/dist/bundle/chunks/du-IFLWEM6M.js +2 -0
- package/dist/bundle/chunks/find-EW6OHRPJ.js +2 -0
- package/dist/bundle/chunks/{flag-coverage-XTIQGK65.js → flag-coverage-PIF5QRO7.js} +1 -1
- package/dist/bundle/chunks/{grep-4AYF3A5J.js → grep-QDFNKAUW.js} +1 -1
- package/dist/bundle/chunks/gzip-HBDKZBIP.js +2 -0
- package/dist/bundle/chunks/{js-exec-XKF2B7C3.js → js-exec-IREGAOMH.js} +7 -7
- package/dist/bundle/chunks/js-exec-worker.js +296 -116
- package/dist/bundle/chunks/ln-CEM7GDB5.js +2 -0
- package/dist/bundle/chunks/ls-WJ7EIFVM.js +2 -0
- package/dist/bundle/chunks/mkdir-Z6MMWH3D.js +2 -0
- package/dist/bundle/chunks/mv-E2NFLGRQ.js +2 -0
- package/dist/bundle/chunks/{python3-F5S5TYGS.js → python3-W4UMQJAQ.js} +1 -1
- package/dist/bundle/chunks/readlink-XCFO7YD2.js +2 -0
- package/dist/bundle/chunks/rg-J7XDRV3B.js +2 -0
- package/dist/bundle/chunks/rm-IGPLE632.js +2 -0
- package/dist/bundle/chunks/rmdir-UMUDM2L2.js +2 -0
- package/dist/bundle/chunks/{sleep-PPRBTSVR.js → sleep-25QUPVDK.js} +1 -1
- package/dist/bundle/chunks/split-D4HPO4G5.js +2 -0
- package/dist/bundle/chunks/sqlite3-3HL2ECCQ.js +2 -0
- package/dist/bundle/chunks/{timeout-C6WDYPLV.js → timeout-37GM7IIL.js} +1 -1
- package/dist/bundle/chunks/worker.js +233 -108
- package/dist/bundle/index.cjs +975 -970
- package/dist/bundle/index.js +357 -352
- package/dist/commands/js-exec/js-exec.d.ts +4 -0
- package/dist/commands/worker-bridge/bridge-handler.d.ts +9 -3
- package/dist/commands/worker-bridge/protocol.d.ts +72 -21
- package/dist/commands/worker-bridge/sync-backend.d.ts +3 -0
- package/dist/fs/fs-error.d.ts +43 -0
- package/dist/fs/interface.d.ts +13 -0
- package/dist/fs/mountable-fs/mountable-fs.d.ts +20 -0
- package/dist/fs/overlay-fs/apply.d.ts +15 -1
- package/dist/fs/overlay-fs/index.d.ts +1 -0
- package/dist/fs/overlay-fs/overlay-fs.d.ts +31 -0
- package/dist/fs/overlay-fs/overlay-tree.d.ts +39 -0
- package/dist/fs/path-utils.d.ts +5 -0
- package/dist/fs/vfs-template.d.ts +74 -0
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/interpreter/builtin-dispatch.d.ts +10 -0
- package/dist/interpreter/builtin-manifest.d.ts +273 -0
- package/dist/interpreter/builtins/help.d.ts +6 -0
- package/dist/interpreter/builtins/shopt.d.ts +3 -0
- package/dist/interpreter/helpers/shell-constants.d.ts +0 -20
- package/dist/timers.d.ts +9 -0
- package/package.json +135 -136
- package/vendor/cpython-emscripten/python.cjs +2 -2
- package/dist/bin/chunks/chmod-WYYTXGVB.js +0 -3
- package/dist/bin/chunks/chunk-43E7AR6A.js +0 -3
- package/dist/bin/chunks/chunk-6LDOIBU7.js +0 -9
- package/dist/bin/chunks/chunk-AI7JUA46.js +0 -13
- package/dist/bin/chunks/chunk-GQKQEK5N.js +0 -11
- package/dist/bin/chunks/chunk-JQM3DKCH.js +0 -12
- package/dist/bin/chunks/chunk-OLEQNRKX.js +0 -8
- package/dist/bin/chunks/chunk-PPVF2N6C.js +0 -3
- package/dist/bin/chunks/chunk-WEHA3JFD.js +0 -3
- package/dist/bin/chunks/chunk-YQEKKZTU.js +0 -12
- package/dist/bin/chunks/cp-OMVKM35F.js +0 -3
- package/dist/bin/chunks/du-LUFPVLNW.js +0 -3
- package/dist/bin/chunks/find-AWH2KOY7.js +0 -3
- package/dist/bin/chunks/gzip-FDPA6EKG.js +0 -3
- package/dist/bin/chunks/ln-B35EKC2Q.js +0 -3
- package/dist/bin/chunks/ls-Q6ZZ6SQ2.js +0 -3
- package/dist/bin/chunks/mkdir-74BP5NTG.js +0 -3
- package/dist/bin/chunks/mv-76LAHXFR.js +0 -3
- package/dist/bin/chunks/readlink-EHXJNW62.js +0 -3
- package/dist/bin/chunks/rg-PXNKNIMY.js +0 -3
- package/dist/bin/chunks/rm-TF2NJQIA.js +0 -3
- package/dist/bin/chunks/rmdir-7ZIVFZJX.js +0 -3
- package/dist/bin/chunks/split-ZNNNHKSP.js +0 -3
- package/dist/bin/chunks/sqlite3-KP42NNIY.js +0 -3
- package/dist/bin/shell/chunks/chmod-WYYTXGVB.js +0 -3
- package/dist/bin/shell/chunks/chunk-43E7AR6A.js +0 -3
- package/dist/bin/shell/chunks/chunk-6LDOIBU7.js +0 -9
- package/dist/bin/shell/chunks/chunk-AI7JUA46.js +0 -13
- package/dist/bin/shell/chunks/chunk-GQKQEK5N.js +0 -11
- package/dist/bin/shell/chunks/chunk-JQM3DKCH.js +0 -12
- package/dist/bin/shell/chunks/chunk-OLEQNRKX.js +0 -8
- package/dist/bin/shell/chunks/chunk-PPVF2N6C.js +0 -3
- package/dist/bin/shell/chunks/chunk-WEHA3JFD.js +0 -3
- package/dist/bin/shell/chunks/chunk-YQEKKZTU.js +0 -12
- package/dist/bin/shell/chunks/cp-OMVKM35F.js +0 -3
- package/dist/bin/shell/chunks/du-LUFPVLNW.js +0 -3
- package/dist/bin/shell/chunks/find-AWH2KOY7.js +0 -3
- package/dist/bin/shell/chunks/gzip-FDPA6EKG.js +0 -3
- package/dist/bin/shell/chunks/ln-B35EKC2Q.js +0 -3
- package/dist/bin/shell/chunks/ls-Q6ZZ6SQ2.js +0 -3
- package/dist/bin/shell/chunks/mkdir-74BP5NTG.js +0 -3
- package/dist/bin/shell/chunks/mv-76LAHXFR.js +0 -3
- package/dist/bin/shell/chunks/readlink-EHXJNW62.js +0 -3
- package/dist/bin/shell/chunks/rg-PXNKNIMY.js +0 -3
- package/dist/bin/shell/chunks/rm-TF2NJQIA.js +0 -3
- package/dist/bin/shell/chunks/rmdir-7ZIVFZJX.js +0 -3
- package/dist/bin/shell/chunks/split-ZNNNHKSP.js +0 -3
- package/dist/bin/shell/chunks/sqlite3-KP42NNIY.js +0 -3
- package/dist/bundle/chunks/chmod-WM2JFFQC.js +0 -2
- package/dist/bundle/chunks/chunk-7IJWBG4I.js +0 -2
- package/dist/bundle/chunks/chunk-MLIO3BK2.js +0 -7
- package/dist/bundle/chunks/chunk-PIRTX3D3.js +0 -8
- package/dist/bundle/chunks/chunk-TBVD66LC.js +0 -10
- package/dist/bundle/chunks/chunk-W2Z6LYL6.js +0 -11
- package/dist/bundle/chunks/chunk-WN54B5NQ.js +0 -12
- package/dist/bundle/chunks/chunk-WXPNKIIH.js +0 -2
- package/dist/bundle/chunks/chunk-YJKHREBZ.js +0 -11
- package/dist/bundle/chunks/chunk-YUSFCOM7.js +0 -2
- package/dist/bundle/chunks/cp-2KZIPZJS.js +0 -2
- package/dist/bundle/chunks/du-7AZCLKR6.js +0 -2
- package/dist/bundle/chunks/find-END3EAHV.js +0 -2
- package/dist/bundle/chunks/gzip-RQOBR22H.js +0 -2
- package/dist/bundle/chunks/ln-OPY2ZVGQ.js +0 -2
- package/dist/bundle/chunks/ls-ZPXGZX63.js +0 -2
- package/dist/bundle/chunks/mkdir-WDDKK2P3.js +0 -2
- package/dist/bundle/chunks/mv-ZF6UBVRB.js +0 -2
- package/dist/bundle/chunks/readlink-U5OM5A3M.js +0 -2
- package/dist/bundle/chunks/rg-NAMXBYKS.js +0 -2
- package/dist/bundle/chunks/rm-OAZOF7XI.js +0 -2
- package/dist/bundle/chunks/rmdir-YJKPQVCK.js +0 -2
- package/dist/bundle/chunks/split-JICLAMP6.js +0 -2
- package/dist/bundle/chunks/sqlite3-4EZ4GXVD.js +0 -2
|
@@ -1690,6 +1690,16 @@ var OpCode = {
|
|
|
1690
1690
|
REALPATH: 13,
|
|
1691
1691
|
RENAME: 14,
|
|
1692
1692
|
COPY_FILE: 15,
|
|
1693
|
+
// Ranged variant for write payloads larger than the data buffer.
|
|
1694
|
+
// FLAGS carries the file offset (uint32); the chunk length is its
|
|
1695
|
+
// DATA_LENGTH. (Reads use plain READ_FILE plus the generic
|
|
1696
|
+
// READ_RESULT_RANGE assembly; only the write direction needs this.)
|
|
1697
|
+
WRITE_FILE_RANGE: 17,
|
|
1698
|
+
// Fetch the next slice of an oversized result (any op). The host
|
|
1699
|
+
// publishes the first DATA_BUFFER bytes with the FULL length in
|
|
1700
|
+
// RESULT_LENGTH and retains the complete buffer; the worker loops
|
|
1701
|
+
// this op (FLAGS = offset, MODE = length) to assemble the rest.
|
|
1702
|
+
READ_RESULT_RANGE: 18,
|
|
1693
1703
|
// Special operations for I/O
|
|
1694
1704
|
WRITE_STDOUT: 100,
|
|
1695
1705
|
WRITE_STDERR: 101,
|
|
@@ -1701,11 +1711,18 @@ var OpCode = {
|
|
|
1701
1711
|
// Tool invocation (executor mode)
|
|
1702
1712
|
INVOKE_TOOL: 400
|
|
1703
1713
|
};
|
|
1704
|
-
var
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1714
|
+
var RequestState = {
|
|
1715
|
+
IDLE: 0,
|
|
1716
|
+
/** Worker has published an op. */
|
|
1717
|
+
REQUEST: 1,
|
|
1718
|
+
/** stop() cancellation wake. The host treats any non-REQUEST wake as
|
|
1719
|
+
* loop-abort (stop() also flips its `running` flag). */
|
|
1720
|
+
CANCELLED: 2
|
|
1721
|
+
};
|
|
1722
|
+
var ResultState = {
|
|
1723
|
+
NONE: 0,
|
|
1724
|
+
SUCCESS: 1,
|
|
1725
|
+
ERROR: 2
|
|
1709
1726
|
};
|
|
1710
1727
|
var ErrorCode = {
|
|
1711
1728
|
NONE: 0,
|
|
@@ -1716,32 +1733,65 @@ var ErrorCode = {
|
|
|
1716
1733
|
PERMISSION_DENIED: 5,
|
|
1717
1734
|
INVALID_PATH: 6,
|
|
1718
1735
|
IO_ERROR: 7,
|
|
1719
|
-
TIMEOUT: 8,
|
|
1720
1736
|
NETWORK_ERROR: 9,
|
|
1721
|
-
NETWORK_NOT_CONFIGURED: 10
|
|
1737
|
+
NETWORK_NOT_CONFIGURED: 10,
|
|
1738
|
+
NOT_EMPTY: 11,
|
|
1739
|
+
LOOP: 12,
|
|
1740
|
+
FILE_TOO_LARGE: 13,
|
|
1741
|
+
NO_SPACE: 14,
|
|
1742
|
+
BUSY: 15,
|
|
1743
|
+
READ_ONLY: 16,
|
|
1744
|
+
CROSS_DEVICE: 17
|
|
1722
1745
|
};
|
|
1746
|
+
var ERRNO_TO_WIRE = Object.assign(
|
|
1747
|
+
/* @__PURE__ */ Object.create(null),
|
|
1748
|
+
{
|
|
1749
|
+
ENOENT: ErrorCode.NOT_FOUND,
|
|
1750
|
+
EISDIR: ErrorCode.IS_DIRECTORY,
|
|
1751
|
+
ENOTDIR: ErrorCode.NOT_DIRECTORY,
|
|
1752
|
+
ENOTEMPTY: ErrorCode.NOT_EMPTY,
|
|
1753
|
+
EEXIST: ErrorCode.EXISTS,
|
|
1754
|
+
EPERM: ErrorCode.PERMISSION_DENIED,
|
|
1755
|
+
EACCES: ErrorCode.PERMISSION_DENIED,
|
|
1756
|
+
EINVAL: ErrorCode.INVALID_PATH,
|
|
1757
|
+
ELOOP: ErrorCode.LOOP,
|
|
1758
|
+
EFBIG: ErrorCode.FILE_TOO_LARGE,
|
|
1759
|
+
ENOSPC: ErrorCode.NO_SPACE,
|
|
1760
|
+
EBUSY: ErrorCode.BUSY,
|
|
1761
|
+
EROFS: ErrorCode.READ_ONLY,
|
|
1762
|
+
EXDEV: ErrorCode.CROSS_DEVICE
|
|
1763
|
+
}
|
|
1764
|
+
);
|
|
1765
|
+
var WIRE_TO_ERRNO = /* @__PURE__ */ Object.create(null);
|
|
1766
|
+
for (const [name, code] of Object.entries(ERRNO_TO_WIRE)) {
|
|
1767
|
+
WIRE_TO_ERRNO[code] = name;
|
|
1768
|
+
}
|
|
1769
|
+
function wireToErrnoName(code) {
|
|
1770
|
+
return Object.hasOwn(WIRE_TO_ERRNO, code) ? WIRE_TO_ERRNO[code] : void 0;
|
|
1771
|
+
}
|
|
1723
1772
|
var Offset = {
|
|
1724
1773
|
OP_CODE: 0,
|
|
1725
|
-
|
|
1774
|
+
REQUEST: 4,
|
|
1726
1775
|
PATH_LENGTH: 8,
|
|
1727
1776
|
DATA_LENGTH: 12,
|
|
1728
1777
|
RESULT_LENGTH: 16,
|
|
1729
1778
|
ERROR_CODE: 20,
|
|
1730
1779
|
FLAGS: 24,
|
|
1731
1780
|
MODE: 28,
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1781
|
+
RESULT_STATE: 32,
|
|
1782
|
+
PATH_BUFFER: 36,
|
|
1783
|
+
DATA_BUFFER: 4132
|
|
1784
|
+
// 36 + 4096
|
|
1735
1785
|
};
|
|
1736
1786
|
var Size = {
|
|
1737
|
-
CONTROL_REGION: 32,
|
|
1738
1787
|
PATH_BUFFER: 4096,
|
|
1739
|
-
// 8MB
|
|
1740
|
-
//
|
|
1741
|
-
//
|
|
1788
|
+
// 8MB transfer CHUNK size — not a semantic cap. Results larger than
|
|
1789
|
+
// this are assembled transparently (READ_RESULT_RANGE), and large
|
|
1790
|
+
// writes stream as WRITE_FILE_RANGE chunks. Sized to keep ordinary
|
|
1791
|
+
// ops single-transfer while bounding per-transfer copies.
|
|
1742
1792
|
DATA_BUFFER: 8388608,
|
|
1743
|
-
TOTAL:
|
|
1744
|
-
//
|
|
1793
|
+
TOTAL: 8392740
|
|
1794
|
+
// 36 + 4096 + 8MB
|
|
1745
1795
|
};
|
|
1746
1796
|
var Flags = {
|
|
1747
1797
|
NONE: 0,
|
|
@@ -1773,11 +1823,23 @@ var ProtocolBuffer = class {
|
|
|
1773
1823
|
setOpCode(code) {
|
|
1774
1824
|
_Atomics.store(this.int32View, Offset.OP_CODE / 4, code);
|
|
1775
1825
|
}
|
|
1776
|
-
|
|
1777
|
-
return _Atomics.load(
|
|
1826
|
+
getRequest() {
|
|
1827
|
+
return _Atomics.load(
|
|
1828
|
+
this.int32View,
|
|
1829
|
+
Offset.REQUEST / 4
|
|
1830
|
+
);
|
|
1831
|
+
}
|
|
1832
|
+
setRequest(request) {
|
|
1833
|
+
_Atomics.store(this.int32View, Offset.REQUEST / 4, request);
|
|
1834
|
+
}
|
|
1835
|
+
getResultState() {
|
|
1836
|
+
return _Atomics.load(
|
|
1837
|
+
this.int32View,
|
|
1838
|
+
Offset.RESULT_STATE / 4
|
|
1839
|
+
);
|
|
1778
1840
|
}
|
|
1779
|
-
|
|
1780
|
-
_Atomics.store(this.int32View, Offset.
|
|
1841
|
+
setResultState(state) {
|
|
1842
|
+
_Atomics.store(this.int32View, Offset.RESULT_STATE / 4, state);
|
|
1781
1843
|
}
|
|
1782
1844
|
getPathLength() {
|
|
1783
1845
|
return _Atomics.load(this.int32View, Offset.PATH_LENGTH / 4);
|
|
@@ -1870,6 +1932,20 @@ var ProtocolBuffer = class {
|
|
|
1870
1932
|
this.uint8View.set(data, Offset.DATA_BUFFER);
|
|
1871
1933
|
this.setResultLength(data.length);
|
|
1872
1934
|
}
|
|
1935
|
+
/**
|
|
1936
|
+
* Publish a result of ANY size: the first DATA_BUFFER bytes land in
|
|
1937
|
+
* the data region and RESULT_LENGTH carries the FULL length. The
|
|
1938
|
+
* worker detects the overflow and fetches the rest with
|
|
1939
|
+
* READ_RESULT_RANGE ops (served from the host's retained buffer).
|
|
1940
|
+
*/
|
|
1941
|
+
setResultPrefix(data) {
|
|
1942
|
+
if (data.length > 2147483647) {
|
|
1943
|
+
throw new Error(`Result too large: ${data.length} exceeds int32`);
|
|
1944
|
+
}
|
|
1945
|
+
const n = Math.min(data.length, Size.DATA_BUFFER);
|
|
1946
|
+
this.uint8View.set(data.subarray(0, n), Offset.DATA_BUFFER);
|
|
1947
|
+
this.setResultLength(data.length);
|
|
1948
|
+
}
|
|
1873
1949
|
getResultAsString() {
|
|
1874
1950
|
const result = this.getResult();
|
|
1875
1951
|
return new TextDecoder().decode(result);
|
|
@@ -1911,33 +1987,21 @@ var ProtocolBuffer = class {
|
|
|
1911
1987
|
)
|
|
1912
1988
|
};
|
|
1913
1989
|
}
|
|
1914
|
-
waitForReady(timeout) {
|
|
1915
|
-
return _Atomics.wait(
|
|
1916
|
-
this.int32View,
|
|
1917
|
-
Offset.STATUS / 4,
|
|
1918
|
-
Status.PENDING,
|
|
1919
|
-
timeout
|
|
1920
|
-
);
|
|
1921
|
-
}
|
|
1922
|
-
waitForReadyAsync(timeout) {
|
|
1923
|
-
return _Atomics.waitAsync(
|
|
1924
|
-
this.int32View,
|
|
1925
|
-
Offset.STATUS / 4,
|
|
1926
|
-
Status.PENDING,
|
|
1927
|
-
timeout
|
|
1928
|
-
);
|
|
1929
|
-
}
|
|
1930
1990
|
/**
|
|
1931
|
-
* Wait for
|
|
1932
|
-
* Returns immediately if
|
|
1991
|
+
* Wait for the request word to become REQUEST.
|
|
1992
|
+
* Returns immediately if already REQUEST; CANCELLED or any unexpected
|
|
1993
|
+
* state returns false (the caller's running-flag check aborts the loop).
|
|
1933
1994
|
*/
|
|
1934
1995
|
async waitUntilReady(timeout) {
|
|
1935
1996
|
const startTime = Date.now();
|
|
1936
1997
|
while (true) {
|
|
1937
|
-
const
|
|
1938
|
-
if (
|
|
1998
|
+
const request = this.getRequest();
|
|
1999
|
+
if (request === RequestState.REQUEST) {
|
|
1939
2000
|
return true;
|
|
1940
2001
|
}
|
|
2002
|
+
if (request !== RequestState.IDLE) {
|
|
2003
|
+
return false;
|
|
2004
|
+
}
|
|
1941
2005
|
const elapsed = Date.now() - startTime;
|
|
1942
2006
|
if (elapsed >= timeout) {
|
|
1943
2007
|
return false;
|
|
@@ -1945,8 +2009,8 @@ var ProtocolBuffer = class {
|
|
|
1945
2009
|
const remainingMs = timeout - elapsed;
|
|
1946
2010
|
const result = _Atomics.waitAsync(
|
|
1947
2011
|
this.int32View,
|
|
1948
|
-
Offset.
|
|
1949
|
-
|
|
2012
|
+
Offset.REQUEST / 4,
|
|
2013
|
+
RequestState.IDLE,
|
|
1950
2014
|
remainingMs
|
|
1951
2015
|
);
|
|
1952
2016
|
if (result.async) {
|
|
@@ -1957,20 +2021,25 @@ var ProtocolBuffer = class {
|
|
|
1957
2021
|
}
|
|
1958
2022
|
}
|
|
1959
2023
|
}
|
|
2024
|
+
/** Worker-side blocking wait on the RESULT word (host writes). */
|
|
1960
2025
|
waitForResult(timeout) {
|
|
1961
2026
|
return _Atomics.wait(
|
|
1962
2027
|
this.int32View,
|
|
1963
|
-
Offset.
|
|
1964
|
-
|
|
2028
|
+
Offset.RESULT_STATE / 4,
|
|
2029
|
+
ResultState.NONE,
|
|
1965
2030
|
timeout
|
|
1966
2031
|
);
|
|
1967
2032
|
}
|
|
1968
|
-
|
|
1969
|
-
return _Atomics.notify(this.int32View, Offset.
|
|
2033
|
+
notifyRequest() {
|
|
2034
|
+
return _Atomics.notify(this.int32View, Offset.REQUEST / 4);
|
|
2035
|
+
}
|
|
2036
|
+
notifyResult() {
|
|
2037
|
+
return _Atomics.notify(this.int32View, Offset.RESULT_STATE / 4);
|
|
1970
2038
|
}
|
|
1971
2039
|
reset() {
|
|
1972
2040
|
this.setOpCode(OpCode.NOOP);
|
|
1973
|
-
this.
|
|
2041
|
+
this.setRequest(RequestState.IDLE);
|
|
2042
|
+
this.setResultState(ResultState.NONE);
|
|
1974
2043
|
this.setPathLength(0);
|
|
1975
2044
|
this.setDataLength(0);
|
|
1976
2045
|
this.setResultLength(0);
|
|
@@ -1997,52 +2066,117 @@ var SyncBackend = class {
|
|
|
1997
2066
|
if (data) {
|
|
1998
2067
|
this.protocol.setData(data);
|
|
1999
2068
|
}
|
|
2000
|
-
this.protocol.
|
|
2001
|
-
this.protocol.
|
|
2069
|
+
this.protocol.setRequest(RequestState.REQUEST);
|
|
2070
|
+
this.protocol.notifyRequest();
|
|
2002
2071
|
const waitResult = this.protocol.waitForResult(this.operationTimeoutMs);
|
|
2003
2072
|
if (waitResult === "timed-out") {
|
|
2004
2073
|
return { success: false, error: "Operation timed out" };
|
|
2005
2074
|
}
|
|
2006
|
-
const
|
|
2007
|
-
if (
|
|
2008
|
-
|
|
2075
|
+
const resultState = this.protocol.getResultState();
|
|
2076
|
+
if (resultState === ResultState.SUCCESS) {
|
|
2077
|
+
const totalLength = this.protocol.getResultLength();
|
|
2078
|
+
if (totalLength <= Size.DATA_BUFFER) {
|
|
2079
|
+
return { success: true, result: this.protocol.getResult() };
|
|
2080
|
+
}
|
|
2081
|
+
const content = new Uint8Array(totalLength);
|
|
2082
|
+
content.set(this.protocol.getResult().subarray(0, Size.DATA_BUFFER), 0);
|
|
2083
|
+
let offset = Size.DATA_BUFFER;
|
|
2084
|
+
while (offset < totalLength) {
|
|
2085
|
+
const length = Math.min(Size.DATA_BUFFER, totalLength - offset);
|
|
2086
|
+
const slice = this.execSync(
|
|
2087
|
+
OpCode.READ_RESULT_RANGE,
|
|
2088
|
+
"",
|
|
2089
|
+
void 0,
|
|
2090
|
+
offset,
|
|
2091
|
+
length
|
|
2092
|
+
);
|
|
2093
|
+
if (!slice.success) {
|
|
2094
|
+
throw this.opError_("Failed to read result range", slice);
|
|
2095
|
+
}
|
|
2096
|
+
const chunk = slice.result ?? new Uint8Array(0);
|
|
2097
|
+
content.set(chunk, offset);
|
|
2098
|
+
offset += chunk.length;
|
|
2099
|
+
if (chunk.length === 0) {
|
|
2100
|
+
throw this.opError_("bridge returned an empty result slice", slice);
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
return { success: true, result: content };
|
|
2104
|
+
}
|
|
2105
|
+
if (resultState === ResultState.ERROR) {
|
|
2106
|
+
return {
|
|
2107
|
+
success: false,
|
|
2108
|
+
error: this.protocol.getResultAsString() || // Impossible by construction: every host error path publishes a
|
|
2109
|
+
// code and message. If this ever fires, the diagnostic payload
|
|
2110
|
+
// must identify the exact protocol state.
|
|
2111
|
+
`bridge protocol violation: op ${opCode} ERROR with empty message (wait=${waitResult}, errorCode=${this.protocol.getErrorCode()})`,
|
|
2112
|
+
errorCode: this.protocol.getErrorCode()
|
|
2113
|
+
};
|
|
2009
2114
|
}
|
|
2010
2115
|
return {
|
|
2011
2116
|
success: false,
|
|
2012
|
-
error:
|
|
2117
|
+
error: `bridge protocol violation: op ${opCode} woke with resultState ${resultState} (wait=${waitResult}, errorCode=${this.protocol.getErrorCode()})`,
|
|
2118
|
+
errorCode: this.protocol.getErrorCode()
|
|
2013
2119
|
};
|
|
2014
2120
|
}
|
|
2121
|
+
/** Build an op failure that preserves the bridge's numeric error code,
|
|
2122
|
+
* so downstream errno mapping prefers it over substring matching. */
|
|
2123
|
+
opError_(fallback, result) {
|
|
2124
|
+
const err = new Error(result.error || fallback);
|
|
2125
|
+
err.bridgeErrorCode = result.errorCode;
|
|
2126
|
+
if (result.errorCode !== void 0) {
|
|
2127
|
+
const name = wireToErrnoName(result.errorCode);
|
|
2128
|
+
if (name !== void 0) err.code = name;
|
|
2129
|
+
}
|
|
2130
|
+
return err;
|
|
2131
|
+
}
|
|
2015
2132
|
readFile(path) {
|
|
2016
2133
|
const result = this.execSync(OpCode.READ_FILE, path);
|
|
2017
2134
|
if (!result.success) {
|
|
2018
|
-
throw
|
|
2135
|
+
throw this.opError_("Failed to read file", result);
|
|
2019
2136
|
}
|
|
2020
2137
|
return result.result ?? new Uint8Array(0);
|
|
2021
2138
|
}
|
|
2022
2139
|
writeFile(path, data) {
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2140
|
+
if (data.length <= Size.DATA_BUFFER) {
|
|
2141
|
+
const result = this.execSync(OpCode.WRITE_FILE, path, data);
|
|
2142
|
+
if (!result.success) {
|
|
2143
|
+
throw this.opError_("Failed to write file", result);
|
|
2144
|
+
}
|
|
2145
|
+
return;
|
|
2146
|
+
}
|
|
2147
|
+
let offset = 0;
|
|
2148
|
+
while (offset < data.length) {
|
|
2149
|
+
const chunk = data.subarray(offset, offset + Size.DATA_BUFFER);
|
|
2150
|
+
const result = this.execSync(
|
|
2151
|
+
OpCode.WRITE_FILE_RANGE,
|
|
2152
|
+
path,
|
|
2153
|
+
chunk,
|
|
2154
|
+
offset
|
|
2155
|
+
);
|
|
2156
|
+
if (!result.success) {
|
|
2157
|
+
throw this.opError_("Failed to write file", result);
|
|
2158
|
+
}
|
|
2159
|
+
offset += chunk.length;
|
|
2026
2160
|
}
|
|
2027
2161
|
}
|
|
2028
2162
|
stat(path) {
|
|
2029
2163
|
const result = this.execSync(OpCode.STAT, path);
|
|
2030
2164
|
if (!result.success) {
|
|
2031
|
-
throw
|
|
2165
|
+
throw this.opError_("Failed to stat", result);
|
|
2032
2166
|
}
|
|
2033
2167
|
return this.protocol.decodeStat();
|
|
2034
2168
|
}
|
|
2035
2169
|
lstat(path) {
|
|
2036
2170
|
const result = this.execSync(OpCode.LSTAT, path);
|
|
2037
2171
|
if (!result.success) {
|
|
2038
|
-
throw
|
|
2172
|
+
throw this.opError_("Failed to lstat", result);
|
|
2039
2173
|
}
|
|
2040
2174
|
return this.protocol.decodeStat();
|
|
2041
2175
|
}
|
|
2042
2176
|
readdir(path) {
|
|
2043
2177
|
const result = this.execSync(OpCode.READDIR, path);
|
|
2044
2178
|
if (!result.success) {
|
|
2045
|
-
throw
|
|
2179
|
+
throw this.opError_("Failed to readdir", result);
|
|
2046
2180
|
}
|
|
2047
2181
|
return JSON.parse(this.protocol.getResultAsString());
|
|
2048
2182
|
}
|
|
@@ -2050,7 +2184,7 @@ var SyncBackend = class {
|
|
|
2050
2184
|
const flags = recursive ? Flags.MKDIR_RECURSIVE : 0;
|
|
2051
2185
|
const result = this.execSync(OpCode.MKDIR, path, void 0, flags);
|
|
2052
2186
|
if (!result.success) {
|
|
2053
|
-
throw
|
|
2187
|
+
throw this.opError_("Failed to mkdir", result);
|
|
2054
2188
|
}
|
|
2055
2189
|
}
|
|
2056
2190
|
rm(path, recursive = false, force = false) {
|
|
@@ -2059,7 +2193,7 @@ var SyncBackend = class {
|
|
|
2059
2193
|
if (force) flags |= Flags.FORCE;
|
|
2060
2194
|
const result = this.execSync(OpCode.RM, path, void 0, flags);
|
|
2061
2195
|
if (!result.success) {
|
|
2062
|
-
throw
|
|
2196
|
+
throw this.opError_("Failed to rm", result);
|
|
2063
2197
|
}
|
|
2064
2198
|
}
|
|
2065
2199
|
exists(path) {
|
|
@@ -2072,33 +2206,33 @@ var SyncBackend = class {
|
|
|
2072
2206
|
appendFile(path, data) {
|
|
2073
2207
|
const result = this.execSync(OpCode.APPEND_FILE, path, data);
|
|
2074
2208
|
if (!result.success) {
|
|
2075
|
-
throw
|
|
2209
|
+
throw this.opError_("Failed to append file", result);
|
|
2076
2210
|
}
|
|
2077
2211
|
}
|
|
2078
2212
|
symlink(target, linkPath) {
|
|
2079
2213
|
const targetData = new TextEncoder().encode(target);
|
|
2080
2214
|
const result = this.execSync(OpCode.SYMLINK, linkPath, targetData);
|
|
2081
2215
|
if (!result.success) {
|
|
2082
|
-
throw
|
|
2216
|
+
throw this.opError_("Failed to symlink", result);
|
|
2083
2217
|
}
|
|
2084
2218
|
}
|
|
2085
2219
|
readlink(path) {
|
|
2086
2220
|
const result = this.execSync(OpCode.READLINK, path);
|
|
2087
2221
|
if (!result.success) {
|
|
2088
|
-
throw
|
|
2222
|
+
throw this.opError_("Failed to readlink", result);
|
|
2089
2223
|
}
|
|
2090
2224
|
return this.protocol.getResultAsString();
|
|
2091
2225
|
}
|
|
2092
2226
|
chmod(path, mode) {
|
|
2093
2227
|
const result = this.execSync(OpCode.CHMOD, path, void 0, 0, mode);
|
|
2094
2228
|
if (!result.success) {
|
|
2095
|
-
throw
|
|
2229
|
+
throw this.opError_("Failed to chmod", result);
|
|
2096
2230
|
}
|
|
2097
2231
|
}
|
|
2098
2232
|
realpath(path) {
|
|
2099
2233
|
const result = this.execSync(OpCode.REALPATH, path);
|
|
2100
2234
|
if (!result.success) {
|
|
2101
|
-
throw
|
|
2235
|
+
throw this.opError_("Failed to realpath", result);
|
|
2102
2236
|
}
|
|
2103
2237
|
return this.protocol.getResultAsString();
|
|
2104
2238
|
}
|
|
@@ -2106,28 +2240,28 @@ var SyncBackend = class {
|
|
|
2106
2240
|
const newPathData = new TextEncoder().encode(newPath);
|
|
2107
2241
|
const result = this.execSync(OpCode.RENAME, oldPath, newPathData);
|
|
2108
2242
|
if (!result.success) {
|
|
2109
|
-
throw
|
|
2243
|
+
throw this.opError_("Failed to rename", result);
|
|
2110
2244
|
}
|
|
2111
2245
|
}
|
|
2112
2246
|
copyFile(src, dest) {
|
|
2113
2247
|
const destData = new TextEncoder().encode(dest);
|
|
2114
2248
|
const result = this.execSync(OpCode.COPY_FILE, src, destData);
|
|
2115
2249
|
if (!result.success) {
|
|
2116
|
-
throw
|
|
2250
|
+
throw this.opError_("Failed to copyFile", result);
|
|
2117
2251
|
}
|
|
2118
2252
|
}
|
|
2119
2253
|
writeStdout(data) {
|
|
2120
2254
|
const encoded = new TextEncoder().encode(data);
|
|
2121
2255
|
const result = this.execSync(OpCode.WRITE_STDOUT, "", encoded);
|
|
2122
2256
|
if (!result.success) {
|
|
2123
|
-
throw
|
|
2257
|
+
throw this.opError_("Failed to write stdout", result);
|
|
2124
2258
|
}
|
|
2125
2259
|
}
|
|
2126
2260
|
writeStderr(data) {
|
|
2127
2261
|
const encoded = new TextEncoder().encode(data);
|
|
2128
2262
|
const result = this.execSync(OpCode.WRITE_STDERR, "", encoded);
|
|
2129
2263
|
if (!result.success) {
|
|
2130
|
-
throw
|
|
2264
|
+
throw this.opError_("Failed to write stderr", result);
|
|
2131
2265
|
}
|
|
2132
2266
|
}
|
|
2133
2267
|
exit(code) {
|
|
@@ -2141,7 +2275,7 @@ var SyncBackend = class {
|
|
|
2141
2275
|
const requestData = options ? new TextEncoder().encode(JSON.stringify(options)) : void 0;
|
|
2142
2276
|
const result = this.execSync(OpCode.HTTP_REQUEST, url, requestData);
|
|
2143
2277
|
if (!result.success) {
|
|
2144
|
-
throw
|
|
2278
|
+
throw this.opError_("HTTP request failed", result);
|
|
2145
2279
|
}
|
|
2146
2280
|
const responseJson = new TextDecoder().decode(result.result);
|
|
2147
2281
|
const parsed = JSON.parse(responseJson);
|
|
@@ -2164,7 +2298,7 @@ var SyncBackend = class {
|
|
|
2164
2298
|
const requestData = stdin ? new TextEncoder().encode(JSON.stringify({ stdin })) : void 0;
|
|
2165
2299
|
const result = this.execSync(OpCode.EXEC_COMMAND, command, requestData);
|
|
2166
2300
|
if (!result.success) {
|
|
2167
|
-
throw
|
|
2301
|
+
throw this.opError_("Command execution failed", result);
|
|
2168
2302
|
}
|
|
2169
2303
|
const responseJson = new TextDecoder().decode(result.result);
|
|
2170
2304
|
return JSON.parse(responseJson);
|
|
@@ -2177,7 +2311,7 @@ var SyncBackend = class {
|
|
|
2177
2311
|
const requestData = new TextEncoder().encode(JSON.stringify({ args }));
|
|
2178
2312
|
const result = this.execSync(OpCode.EXEC_COMMAND, command, requestData);
|
|
2179
2313
|
if (!result.success) {
|
|
2180
|
-
throw
|
|
2314
|
+
throw this.opError_("Command execution failed", result);
|
|
2181
2315
|
}
|
|
2182
2316
|
const responseJson = new TextDecoder().decode(result.result);
|
|
2183
2317
|
return JSON.parse(responseJson);
|
|
@@ -2190,7 +2324,7 @@ var SyncBackend = class {
|
|
|
2190
2324
|
const requestData = argsJson ? new TextEncoder().encode(argsJson) : void 0;
|
|
2191
2325
|
const result = this.execSync(OpCode.INVOKE_TOOL, path, requestData);
|
|
2192
2326
|
if (!result.success) {
|
|
2193
|
-
throw
|
|
2327
|
+
throw this.opError_("Tool invocation failed", result);
|
|
2194
2328
|
}
|
|
2195
2329
|
return new TextDecoder().decode(result.result);
|
|
2196
2330
|
}
|
|
@@ -2202,14 +2336,14 @@ var require2 = createRequire(import.meta.url);
|
|
|
2202
2336
|
var CPYTHON_ENTRY_BASENAME = "/vendor/cpython-emscripten/python.cjs";
|
|
2203
2337
|
var CPYTHON_STDLIB_BASENAME = "/vendor/cpython-emscripten/python313.zip";
|
|
2204
2338
|
var moduleLoadGuardInstalled = false;
|
|
2205
|
-
function
|
|
2339
|
+
function normalizeSeparators(path) {
|
|
2206
2340
|
return path.replace(/\\/g, "/");
|
|
2207
2341
|
}
|
|
2208
2342
|
function isApprovedCpythonEntryPath(path) {
|
|
2209
|
-
return
|
|
2343
|
+
return normalizeSeparators(path).endsWith(CPYTHON_ENTRY_BASENAME);
|
|
2210
2344
|
}
|
|
2211
2345
|
function isApprovedStdlibZipPath(path) {
|
|
2212
|
-
return
|
|
2346
|
+
return normalizeSeparators(path).endsWith(CPYTHON_STDLIB_BASENAME);
|
|
2213
2347
|
}
|
|
2214
2348
|
function assertApprovedPath(path, kind) {
|
|
2215
2349
|
const ok = kind === "cpython-entry" ? isApprovedCpythonEntryPath(path) : isApprovedStdlibZipPath(path);
|
|
@@ -2289,26 +2423,20 @@ function createHOSTFS(backend, FS, PATH, configuredMaxFileSize) {
|
|
|
2289
2423
|
const ERRNO_CODES = Object.assign(
|
|
2290
2424
|
/* @__PURE__ */ Object.create(null),
|
|
2291
2425
|
{
|
|
2292
|
-
EPERM: 63,
|
|
2293
2426
|
ENOENT: 44,
|
|
2294
2427
|
EIO: 29,
|
|
2295
|
-
EBADF: 8,
|
|
2296
|
-
EAGAIN: 6,
|
|
2297
2428
|
EACCES: 2,
|
|
2298
2429
|
EBUSY: 10,
|
|
2299
2430
|
EEXIST: 20,
|
|
2300
2431
|
ENOTDIR: 54,
|
|
2301
2432
|
EISDIR: 31,
|
|
2433
|
+
ELOOP: 32,
|
|
2302
2434
|
EINVAL: 28,
|
|
2303
2435
|
EFBIG: 27,
|
|
2304
|
-
EMFILE: 33,
|
|
2305
2436
|
ENOSPC: 51,
|
|
2306
|
-
ESPIPE: 70,
|
|
2307
2437
|
EROFS: 69,
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
ENOTSUP: 138,
|
|
2311
|
-
ENODATA: 42
|
|
2438
|
+
EXDEV: 75,
|
|
2439
|
+
ENOTEMPTY: 55
|
|
2312
2440
|
}
|
|
2313
2441
|
);
|
|
2314
2442
|
function realPath(node) {
|
|
@@ -2321,26 +2449,22 @@ function createHOSTFS(backend, FS, PATH, configuredMaxFileSize) {
|
|
|
2321
2449
|
parts.reverse();
|
|
2322
2450
|
return PATH.join(...parts);
|
|
2323
2451
|
}
|
|
2452
|
+
function errnoFromError(e) {
|
|
2453
|
+
const bridgeCode = e?.bridgeErrorCode;
|
|
2454
|
+
if (typeof bridgeCode === "number" && bridgeCode !== ErrorCode.NONE) {
|
|
2455
|
+
const name = wireToErrnoName(bridgeCode);
|
|
2456
|
+
if (name !== void 0 && Object.hasOwn(ERRNO_CODES, name)) {
|
|
2457
|
+
return ERRNO_CODES[name];
|
|
2458
|
+
}
|
|
2459
|
+
return ERRNO_CODES.EIO;
|
|
2460
|
+
}
|
|
2461
|
+
return ERRNO_CODES.EIO;
|
|
2462
|
+
}
|
|
2324
2463
|
function tryFSOperation(f) {
|
|
2325
2464
|
try {
|
|
2326
2465
|
return f();
|
|
2327
2466
|
} catch (e) {
|
|
2328
|
-
|
|
2329
|
-
let code = ERRNO_CODES.EIO;
|
|
2330
|
-
if (msg.includes("no such file") || msg.includes("not found")) {
|
|
2331
|
-
code = ERRNO_CODES.ENOENT;
|
|
2332
|
-
} else if (msg.includes("is a directory")) {
|
|
2333
|
-
code = ERRNO_CODES.EISDIR;
|
|
2334
|
-
} else if (msg.includes("not a directory")) {
|
|
2335
|
-
code = ERRNO_CODES.ENOTDIR;
|
|
2336
|
-
} else if (msg.includes("already exists")) {
|
|
2337
|
-
code = ERRNO_CODES.EEXIST;
|
|
2338
|
-
} else if (msg.includes("permission")) {
|
|
2339
|
-
code = ERRNO_CODES.EACCES;
|
|
2340
|
-
} else if (msg.includes("not empty")) {
|
|
2341
|
-
code = ERRNO_CODES.ENOTEMPTY;
|
|
2342
|
-
}
|
|
2343
|
-
throw new FS.ErrnoError(code);
|
|
2467
|
+
throw new FS.ErrnoError(errnoFromError(e));
|
|
2344
2468
|
}
|
|
2345
2469
|
}
|
|
2346
2470
|
function getMode(path) {
|
|
@@ -2491,11 +2615,12 @@ function createHOSTFS(backend, FS, PATH, configuredMaxFileSize) {
|
|
|
2491
2615
|
} else {
|
|
2492
2616
|
content = backend.readFile(path);
|
|
2493
2617
|
}
|
|
2494
|
-
} catch (
|
|
2495
|
-
|
|
2618
|
+
} catch (e) {
|
|
2619
|
+
const code = errnoFromError(e);
|
|
2620
|
+
if (code === ERRNO_CODES.ENOENT && isCreate && isWrite) {
|
|
2496
2621
|
content = new Uint8Array(0);
|
|
2497
2622
|
} else {
|
|
2498
|
-
throw new FS.ErrnoError(
|
|
2623
|
+
throw new FS.ErrnoError(code);
|
|
2499
2624
|
}
|
|
2500
2625
|
}
|
|
2501
2626
|
if (content.length > maxFileSize) {
|
|
@@ -3282,7 +3407,7 @@ function activateDefense(protocolToken) {
|
|
|
3282
3407
|
);
|
|
3283
3408
|
defense = new WorkerDefenseInDepth({
|
|
3284
3409
|
excludeViolationTypes: [
|
|
3285
|
-
// SharedArrayBuffer/Atomics: Used by sync-
|
|
3410
|
+
// SharedArrayBuffer/Atomics: Used by worker-bridge/sync-backend.ts for synchronous
|
|
3286
3411
|
// filesystem communication between the WASM thread and the main thread.
|
|
3287
3412
|
"shared_array_buffer",
|
|
3288
3413
|
"atomics",
|