@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
|
@@ -1652,6 +1652,16 @@ var OpCode = {
|
|
|
1652
1652
|
REALPATH: 13,
|
|
1653
1653
|
RENAME: 14,
|
|
1654
1654
|
COPY_FILE: 15,
|
|
1655
|
+
// Ranged variant for write payloads larger than the data buffer.
|
|
1656
|
+
// FLAGS carries the file offset (uint32); the chunk length is its
|
|
1657
|
+
// DATA_LENGTH. (Reads use plain READ_FILE plus the generic
|
|
1658
|
+
// READ_RESULT_RANGE assembly; only the write direction needs this.)
|
|
1659
|
+
WRITE_FILE_RANGE: 17,
|
|
1660
|
+
// Fetch the next slice of an oversized result (any op). The host
|
|
1661
|
+
// publishes the first DATA_BUFFER bytes with the FULL length in
|
|
1662
|
+
// RESULT_LENGTH and retains the complete buffer; the worker loops
|
|
1663
|
+
// this op (FLAGS = offset, MODE = length) to assemble the rest.
|
|
1664
|
+
READ_RESULT_RANGE: 18,
|
|
1655
1665
|
// Special operations for I/O
|
|
1656
1666
|
WRITE_STDOUT: 100,
|
|
1657
1667
|
WRITE_STDERR: 101,
|
|
@@ -1663,11 +1673,18 @@ var OpCode = {
|
|
|
1663
1673
|
// Tool invocation (executor mode)
|
|
1664
1674
|
INVOKE_TOOL: 400
|
|
1665
1675
|
};
|
|
1666
|
-
var
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1676
|
+
var RequestState = {
|
|
1677
|
+
IDLE: 0,
|
|
1678
|
+
/** Worker has published an op. */
|
|
1679
|
+
REQUEST: 1,
|
|
1680
|
+
/** stop() cancellation wake. The host treats any non-REQUEST wake as
|
|
1681
|
+
* loop-abort (stop() also flips its `running` flag). */
|
|
1682
|
+
CANCELLED: 2
|
|
1683
|
+
};
|
|
1684
|
+
var ResultState = {
|
|
1685
|
+
NONE: 0,
|
|
1686
|
+
SUCCESS: 1,
|
|
1687
|
+
ERROR: 2
|
|
1671
1688
|
};
|
|
1672
1689
|
var ErrorCode = {
|
|
1673
1690
|
NONE: 0,
|
|
@@ -1678,32 +1695,65 @@ var ErrorCode = {
|
|
|
1678
1695
|
PERMISSION_DENIED: 5,
|
|
1679
1696
|
INVALID_PATH: 6,
|
|
1680
1697
|
IO_ERROR: 7,
|
|
1681
|
-
TIMEOUT: 8,
|
|
1682
1698
|
NETWORK_ERROR: 9,
|
|
1683
|
-
NETWORK_NOT_CONFIGURED: 10
|
|
1699
|
+
NETWORK_NOT_CONFIGURED: 10,
|
|
1700
|
+
NOT_EMPTY: 11,
|
|
1701
|
+
LOOP: 12,
|
|
1702
|
+
FILE_TOO_LARGE: 13,
|
|
1703
|
+
NO_SPACE: 14,
|
|
1704
|
+
BUSY: 15,
|
|
1705
|
+
READ_ONLY: 16,
|
|
1706
|
+
CROSS_DEVICE: 17
|
|
1684
1707
|
};
|
|
1708
|
+
var ERRNO_TO_WIRE = Object.assign(
|
|
1709
|
+
/* @__PURE__ */ Object.create(null),
|
|
1710
|
+
{
|
|
1711
|
+
ENOENT: ErrorCode.NOT_FOUND,
|
|
1712
|
+
EISDIR: ErrorCode.IS_DIRECTORY,
|
|
1713
|
+
ENOTDIR: ErrorCode.NOT_DIRECTORY,
|
|
1714
|
+
ENOTEMPTY: ErrorCode.NOT_EMPTY,
|
|
1715
|
+
EEXIST: ErrorCode.EXISTS,
|
|
1716
|
+
EPERM: ErrorCode.PERMISSION_DENIED,
|
|
1717
|
+
EACCES: ErrorCode.PERMISSION_DENIED,
|
|
1718
|
+
EINVAL: ErrorCode.INVALID_PATH,
|
|
1719
|
+
ELOOP: ErrorCode.LOOP,
|
|
1720
|
+
EFBIG: ErrorCode.FILE_TOO_LARGE,
|
|
1721
|
+
ENOSPC: ErrorCode.NO_SPACE,
|
|
1722
|
+
EBUSY: ErrorCode.BUSY,
|
|
1723
|
+
EROFS: ErrorCode.READ_ONLY,
|
|
1724
|
+
EXDEV: ErrorCode.CROSS_DEVICE
|
|
1725
|
+
}
|
|
1726
|
+
);
|
|
1727
|
+
var WIRE_TO_ERRNO = /* @__PURE__ */ Object.create(null);
|
|
1728
|
+
for (const [name, code] of Object.entries(ERRNO_TO_WIRE)) {
|
|
1729
|
+
WIRE_TO_ERRNO[code] = name;
|
|
1730
|
+
}
|
|
1731
|
+
function wireToErrnoName(code) {
|
|
1732
|
+
return Object.hasOwn(WIRE_TO_ERRNO, code) ? WIRE_TO_ERRNO[code] : void 0;
|
|
1733
|
+
}
|
|
1685
1734
|
var Offset = {
|
|
1686
1735
|
OP_CODE: 0,
|
|
1687
|
-
|
|
1736
|
+
REQUEST: 4,
|
|
1688
1737
|
PATH_LENGTH: 8,
|
|
1689
1738
|
DATA_LENGTH: 12,
|
|
1690
1739
|
RESULT_LENGTH: 16,
|
|
1691
1740
|
ERROR_CODE: 20,
|
|
1692
1741
|
FLAGS: 24,
|
|
1693
1742
|
MODE: 28,
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1743
|
+
RESULT_STATE: 32,
|
|
1744
|
+
PATH_BUFFER: 36,
|
|
1745
|
+
DATA_BUFFER: 4132
|
|
1746
|
+
// 36 + 4096
|
|
1697
1747
|
};
|
|
1698
1748
|
var Size = {
|
|
1699
|
-
CONTROL_REGION: 32,
|
|
1700
1749
|
PATH_BUFFER: 4096,
|
|
1701
|
-
// 8MB
|
|
1702
|
-
//
|
|
1703
|
-
//
|
|
1750
|
+
// 8MB transfer CHUNK size — not a semantic cap. Results larger than
|
|
1751
|
+
// this are assembled transparently (READ_RESULT_RANGE), and large
|
|
1752
|
+
// writes stream as WRITE_FILE_RANGE chunks. Sized to keep ordinary
|
|
1753
|
+
// ops single-transfer while bounding per-transfer copies.
|
|
1704
1754
|
DATA_BUFFER: 8388608,
|
|
1705
|
-
TOTAL:
|
|
1706
|
-
//
|
|
1755
|
+
TOTAL: 8392740
|
|
1756
|
+
// 36 + 4096 + 8MB
|
|
1707
1757
|
};
|
|
1708
1758
|
var Flags = {
|
|
1709
1759
|
NONE: 0,
|
|
@@ -1735,11 +1785,23 @@ var ProtocolBuffer = class {
|
|
|
1735
1785
|
setOpCode(code) {
|
|
1736
1786
|
_Atomics.store(this.int32View, Offset.OP_CODE / 4, code);
|
|
1737
1787
|
}
|
|
1738
|
-
|
|
1739
|
-
return _Atomics.load(
|
|
1788
|
+
getRequest() {
|
|
1789
|
+
return _Atomics.load(
|
|
1790
|
+
this.int32View,
|
|
1791
|
+
Offset.REQUEST / 4
|
|
1792
|
+
);
|
|
1793
|
+
}
|
|
1794
|
+
setRequest(request) {
|
|
1795
|
+
_Atomics.store(this.int32View, Offset.REQUEST / 4, request);
|
|
1796
|
+
}
|
|
1797
|
+
getResultState() {
|
|
1798
|
+
return _Atomics.load(
|
|
1799
|
+
this.int32View,
|
|
1800
|
+
Offset.RESULT_STATE / 4
|
|
1801
|
+
);
|
|
1740
1802
|
}
|
|
1741
|
-
|
|
1742
|
-
_Atomics.store(this.int32View, Offset.
|
|
1803
|
+
setResultState(state) {
|
|
1804
|
+
_Atomics.store(this.int32View, Offset.RESULT_STATE / 4, state);
|
|
1743
1805
|
}
|
|
1744
1806
|
getPathLength() {
|
|
1745
1807
|
return _Atomics.load(this.int32View, Offset.PATH_LENGTH / 4);
|
|
@@ -1832,6 +1894,20 @@ var ProtocolBuffer = class {
|
|
|
1832
1894
|
this.uint8View.set(data, Offset.DATA_BUFFER);
|
|
1833
1895
|
this.setResultLength(data.length);
|
|
1834
1896
|
}
|
|
1897
|
+
/**
|
|
1898
|
+
* Publish a result of ANY size: the first DATA_BUFFER bytes land in
|
|
1899
|
+
* the data region and RESULT_LENGTH carries the FULL length. The
|
|
1900
|
+
* worker detects the overflow and fetches the rest with
|
|
1901
|
+
* READ_RESULT_RANGE ops (served from the host's retained buffer).
|
|
1902
|
+
*/
|
|
1903
|
+
setResultPrefix(data) {
|
|
1904
|
+
if (data.length > 2147483647) {
|
|
1905
|
+
throw new Error(`Result too large: ${data.length} exceeds int32`);
|
|
1906
|
+
}
|
|
1907
|
+
const n = Math.min(data.length, Size.DATA_BUFFER);
|
|
1908
|
+
this.uint8View.set(data.subarray(0, n), Offset.DATA_BUFFER);
|
|
1909
|
+
this.setResultLength(data.length);
|
|
1910
|
+
}
|
|
1835
1911
|
getResultAsString() {
|
|
1836
1912
|
const result = this.getResult();
|
|
1837
1913
|
return new TextDecoder().decode(result);
|
|
@@ -1873,33 +1949,21 @@ var ProtocolBuffer = class {
|
|
|
1873
1949
|
)
|
|
1874
1950
|
};
|
|
1875
1951
|
}
|
|
1876
|
-
waitForReady(timeout) {
|
|
1877
|
-
return _Atomics.wait(
|
|
1878
|
-
this.int32View,
|
|
1879
|
-
Offset.STATUS / 4,
|
|
1880
|
-
Status.PENDING,
|
|
1881
|
-
timeout
|
|
1882
|
-
);
|
|
1883
|
-
}
|
|
1884
|
-
waitForReadyAsync(timeout) {
|
|
1885
|
-
return _Atomics.waitAsync(
|
|
1886
|
-
this.int32View,
|
|
1887
|
-
Offset.STATUS / 4,
|
|
1888
|
-
Status.PENDING,
|
|
1889
|
-
timeout
|
|
1890
|
-
);
|
|
1891
|
-
}
|
|
1892
1952
|
/**
|
|
1893
|
-
* Wait for
|
|
1894
|
-
* Returns immediately if
|
|
1953
|
+
* Wait for the request word to become REQUEST.
|
|
1954
|
+
* Returns immediately if already REQUEST; CANCELLED or any unexpected
|
|
1955
|
+
* state returns false (the caller's running-flag check aborts the loop).
|
|
1895
1956
|
*/
|
|
1896
1957
|
async waitUntilReady(timeout) {
|
|
1897
1958
|
const startTime = Date.now();
|
|
1898
1959
|
while (true) {
|
|
1899
|
-
const
|
|
1900
|
-
if (
|
|
1960
|
+
const request = this.getRequest();
|
|
1961
|
+
if (request === RequestState.REQUEST) {
|
|
1901
1962
|
return true;
|
|
1902
1963
|
}
|
|
1964
|
+
if (request !== RequestState.IDLE) {
|
|
1965
|
+
return false;
|
|
1966
|
+
}
|
|
1903
1967
|
const elapsed = Date.now() - startTime;
|
|
1904
1968
|
if (elapsed >= timeout) {
|
|
1905
1969
|
return false;
|
|
@@ -1907,8 +1971,8 @@ var ProtocolBuffer = class {
|
|
|
1907
1971
|
const remainingMs = timeout - elapsed;
|
|
1908
1972
|
const result = _Atomics.waitAsync(
|
|
1909
1973
|
this.int32View,
|
|
1910
|
-
Offset.
|
|
1911
|
-
|
|
1974
|
+
Offset.REQUEST / 4,
|
|
1975
|
+
RequestState.IDLE,
|
|
1912
1976
|
remainingMs
|
|
1913
1977
|
);
|
|
1914
1978
|
if (result.async) {
|
|
@@ -1919,20 +1983,25 @@ var ProtocolBuffer = class {
|
|
|
1919
1983
|
}
|
|
1920
1984
|
}
|
|
1921
1985
|
}
|
|
1986
|
+
/** Worker-side blocking wait on the RESULT word (host writes). */
|
|
1922
1987
|
waitForResult(timeout) {
|
|
1923
1988
|
return _Atomics.wait(
|
|
1924
1989
|
this.int32View,
|
|
1925
|
-
Offset.
|
|
1926
|
-
|
|
1990
|
+
Offset.RESULT_STATE / 4,
|
|
1991
|
+
ResultState.NONE,
|
|
1927
1992
|
timeout
|
|
1928
1993
|
);
|
|
1929
1994
|
}
|
|
1930
|
-
|
|
1931
|
-
return _Atomics.notify(this.int32View, Offset.
|
|
1995
|
+
notifyRequest() {
|
|
1996
|
+
return _Atomics.notify(this.int32View, Offset.REQUEST / 4);
|
|
1997
|
+
}
|
|
1998
|
+
notifyResult() {
|
|
1999
|
+
return _Atomics.notify(this.int32View, Offset.RESULT_STATE / 4);
|
|
1932
2000
|
}
|
|
1933
2001
|
reset() {
|
|
1934
2002
|
this.setOpCode(OpCode.NOOP);
|
|
1935
|
-
this.
|
|
2003
|
+
this.setRequest(RequestState.IDLE);
|
|
2004
|
+
this.setResultState(ResultState.NONE);
|
|
1936
2005
|
this.setPathLength(0);
|
|
1937
2006
|
this.setDataLength(0);
|
|
1938
2007
|
this.setResultLength(0);
|
|
@@ -1959,52 +2028,117 @@ var SyncBackend = class {
|
|
|
1959
2028
|
if (data) {
|
|
1960
2029
|
this.protocol.setData(data);
|
|
1961
2030
|
}
|
|
1962
|
-
this.protocol.
|
|
1963
|
-
this.protocol.
|
|
2031
|
+
this.protocol.setRequest(RequestState.REQUEST);
|
|
2032
|
+
this.protocol.notifyRequest();
|
|
1964
2033
|
const waitResult = this.protocol.waitForResult(this.operationTimeoutMs);
|
|
1965
2034
|
if (waitResult === "timed-out") {
|
|
1966
2035
|
return { success: false, error: "Operation timed out" };
|
|
1967
2036
|
}
|
|
1968
|
-
const
|
|
1969
|
-
if (
|
|
1970
|
-
|
|
2037
|
+
const resultState = this.protocol.getResultState();
|
|
2038
|
+
if (resultState === ResultState.SUCCESS) {
|
|
2039
|
+
const totalLength = this.protocol.getResultLength();
|
|
2040
|
+
if (totalLength <= Size.DATA_BUFFER) {
|
|
2041
|
+
return { success: true, result: this.protocol.getResult() };
|
|
2042
|
+
}
|
|
2043
|
+
const content = new Uint8Array(totalLength);
|
|
2044
|
+
content.set(this.protocol.getResult().subarray(0, Size.DATA_BUFFER), 0);
|
|
2045
|
+
let offset = Size.DATA_BUFFER;
|
|
2046
|
+
while (offset < totalLength) {
|
|
2047
|
+
const length = Math.min(Size.DATA_BUFFER, totalLength - offset);
|
|
2048
|
+
const slice = this.execSync(
|
|
2049
|
+
OpCode.READ_RESULT_RANGE,
|
|
2050
|
+
"",
|
|
2051
|
+
void 0,
|
|
2052
|
+
offset,
|
|
2053
|
+
length
|
|
2054
|
+
);
|
|
2055
|
+
if (!slice.success) {
|
|
2056
|
+
throw this.opError_("Failed to read result range", slice);
|
|
2057
|
+
}
|
|
2058
|
+
const chunk = slice.result ?? new Uint8Array(0);
|
|
2059
|
+
content.set(chunk, offset);
|
|
2060
|
+
offset += chunk.length;
|
|
2061
|
+
if (chunk.length === 0) {
|
|
2062
|
+
throw this.opError_("bridge returned an empty result slice", slice);
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
return { success: true, result: content };
|
|
2066
|
+
}
|
|
2067
|
+
if (resultState === ResultState.ERROR) {
|
|
2068
|
+
return {
|
|
2069
|
+
success: false,
|
|
2070
|
+
error: this.protocol.getResultAsString() || // Impossible by construction: every host error path publishes a
|
|
2071
|
+
// code and message. If this ever fires, the diagnostic payload
|
|
2072
|
+
// must identify the exact protocol state.
|
|
2073
|
+
`bridge protocol violation: op ${opCode} ERROR with empty message (wait=${waitResult}, errorCode=${this.protocol.getErrorCode()})`,
|
|
2074
|
+
errorCode: this.protocol.getErrorCode()
|
|
2075
|
+
};
|
|
1971
2076
|
}
|
|
1972
2077
|
return {
|
|
1973
2078
|
success: false,
|
|
1974
|
-
error:
|
|
2079
|
+
error: `bridge protocol violation: op ${opCode} woke with resultState ${resultState} (wait=${waitResult}, errorCode=${this.protocol.getErrorCode()})`,
|
|
2080
|
+
errorCode: this.protocol.getErrorCode()
|
|
1975
2081
|
};
|
|
1976
2082
|
}
|
|
2083
|
+
/** Build an op failure that preserves the bridge's numeric error code,
|
|
2084
|
+
* so downstream errno mapping prefers it over substring matching. */
|
|
2085
|
+
opError_(fallback, result) {
|
|
2086
|
+
const err = new Error(result.error || fallback);
|
|
2087
|
+
err.bridgeErrorCode = result.errorCode;
|
|
2088
|
+
if (result.errorCode !== void 0) {
|
|
2089
|
+
const name = wireToErrnoName(result.errorCode);
|
|
2090
|
+
if (name !== void 0) err.code = name;
|
|
2091
|
+
}
|
|
2092
|
+
return err;
|
|
2093
|
+
}
|
|
1977
2094
|
readFile(path) {
|
|
1978
2095
|
const result = this.execSync(OpCode.READ_FILE, path);
|
|
1979
2096
|
if (!result.success) {
|
|
1980
|
-
throw
|
|
2097
|
+
throw this.opError_("Failed to read file", result);
|
|
1981
2098
|
}
|
|
1982
2099
|
return result.result ?? new Uint8Array(0);
|
|
1983
2100
|
}
|
|
1984
2101
|
writeFile(path, data) {
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
2102
|
+
if (data.length <= Size.DATA_BUFFER) {
|
|
2103
|
+
const result = this.execSync(OpCode.WRITE_FILE, path, data);
|
|
2104
|
+
if (!result.success) {
|
|
2105
|
+
throw this.opError_("Failed to write file", result);
|
|
2106
|
+
}
|
|
2107
|
+
return;
|
|
2108
|
+
}
|
|
2109
|
+
let offset = 0;
|
|
2110
|
+
while (offset < data.length) {
|
|
2111
|
+
const chunk = data.subarray(offset, offset + Size.DATA_BUFFER);
|
|
2112
|
+
const result = this.execSync(
|
|
2113
|
+
OpCode.WRITE_FILE_RANGE,
|
|
2114
|
+
path,
|
|
2115
|
+
chunk,
|
|
2116
|
+
offset
|
|
2117
|
+
);
|
|
2118
|
+
if (!result.success) {
|
|
2119
|
+
throw this.opError_("Failed to write file", result);
|
|
2120
|
+
}
|
|
2121
|
+
offset += chunk.length;
|
|
1988
2122
|
}
|
|
1989
2123
|
}
|
|
1990
2124
|
stat(path) {
|
|
1991
2125
|
const result = this.execSync(OpCode.STAT, path);
|
|
1992
2126
|
if (!result.success) {
|
|
1993
|
-
throw
|
|
2127
|
+
throw this.opError_("Failed to stat", result);
|
|
1994
2128
|
}
|
|
1995
2129
|
return this.protocol.decodeStat();
|
|
1996
2130
|
}
|
|
1997
2131
|
lstat(path) {
|
|
1998
2132
|
const result = this.execSync(OpCode.LSTAT, path);
|
|
1999
2133
|
if (!result.success) {
|
|
2000
|
-
throw
|
|
2134
|
+
throw this.opError_("Failed to lstat", result);
|
|
2001
2135
|
}
|
|
2002
2136
|
return this.protocol.decodeStat();
|
|
2003
2137
|
}
|
|
2004
2138
|
readdir(path) {
|
|
2005
2139
|
const result = this.execSync(OpCode.READDIR, path);
|
|
2006
2140
|
if (!result.success) {
|
|
2007
|
-
throw
|
|
2141
|
+
throw this.opError_("Failed to readdir", result);
|
|
2008
2142
|
}
|
|
2009
2143
|
return JSON.parse(this.protocol.getResultAsString());
|
|
2010
2144
|
}
|
|
@@ -2012,7 +2146,7 @@ var SyncBackend = class {
|
|
|
2012
2146
|
const flags = recursive ? Flags.MKDIR_RECURSIVE : 0;
|
|
2013
2147
|
const result = this.execSync(OpCode.MKDIR, path, void 0, flags);
|
|
2014
2148
|
if (!result.success) {
|
|
2015
|
-
throw
|
|
2149
|
+
throw this.opError_("Failed to mkdir", result);
|
|
2016
2150
|
}
|
|
2017
2151
|
}
|
|
2018
2152
|
rm(path, recursive = false, force = false) {
|
|
@@ -2021,7 +2155,7 @@ var SyncBackend = class {
|
|
|
2021
2155
|
if (force) flags |= Flags.FORCE;
|
|
2022
2156
|
const result = this.execSync(OpCode.RM, path, void 0, flags);
|
|
2023
2157
|
if (!result.success) {
|
|
2024
|
-
throw
|
|
2158
|
+
throw this.opError_("Failed to rm", result);
|
|
2025
2159
|
}
|
|
2026
2160
|
}
|
|
2027
2161
|
exists(path) {
|
|
@@ -2034,33 +2168,33 @@ var SyncBackend = class {
|
|
|
2034
2168
|
appendFile(path, data) {
|
|
2035
2169
|
const result = this.execSync(OpCode.APPEND_FILE, path, data);
|
|
2036
2170
|
if (!result.success) {
|
|
2037
|
-
throw
|
|
2171
|
+
throw this.opError_("Failed to append file", result);
|
|
2038
2172
|
}
|
|
2039
2173
|
}
|
|
2040
2174
|
symlink(target, linkPath) {
|
|
2041
2175
|
const targetData = new TextEncoder().encode(target);
|
|
2042
2176
|
const result = this.execSync(OpCode.SYMLINK, linkPath, targetData);
|
|
2043
2177
|
if (!result.success) {
|
|
2044
|
-
throw
|
|
2178
|
+
throw this.opError_("Failed to symlink", result);
|
|
2045
2179
|
}
|
|
2046
2180
|
}
|
|
2047
2181
|
readlink(path) {
|
|
2048
2182
|
const result = this.execSync(OpCode.READLINK, path);
|
|
2049
2183
|
if (!result.success) {
|
|
2050
|
-
throw
|
|
2184
|
+
throw this.opError_("Failed to readlink", result);
|
|
2051
2185
|
}
|
|
2052
2186
|
return this.protocol.getResultAsString();
|
|
2053
2187
|
}
|
|
2054
2188
|
chmod(path, mode) {
|
|
2055
2189
|
const result = this.execSync(OpCode.CHMOD, path, void 0, 0, mode);
|
|
2056
2190
|
if (!result.success) {
|
|
2057
|
-
throw
|
|
2191
|
+
throw this.opError_("Failed to chmod", result);
|
|
2058
2192
|
}
|
|
2059
2193
|
}
|
|
2060
2194
|
realpath(path) {
|
|
2061
2195
|
const result = this.execSync(OpCode.REALPATH, path);
|
|
2062
2196
|
if (!result.success) {
|
|
2063
|
-
throw
|
|
2197
|
+
throw this.opError_("Failed to realpath", result);
|
|
2064
2198
|
}
|
|
2065
2199
|
return this.protocol.getResultAsString();
|
|
2066
2200
|
}
|
|
@@ -2068,28 +2202,28 @@ var SyncBackend = class {
|
|
|
2068
2202
|
const newPathData = new TextEncoder().encode(newPath);
|
|
2069
2203
|
const result = this.execSync(OpCode.RENAME, oldPath, newPathData);
|
|
2070
2204
|
if (!result.success) {
|
|
2071
|
-
throw
|
|
2205
|
+
throw this.opError_("Failed to rename", result);
|
|
2072
2206
|
}
|
|
2073
2207
|
}
|
|
2074
2208
|
copyFile(src, dest) {
|
|
2075
2209
|
const destData = new TextEncoder().encode(dest);
|
|
2076
2210
|
const result = this.execSync(OpCode.COPY_FILE, src, destData);
|
|
2077
2211
|
if (!result.success) {
|
|
2078
|
-
throw
|
|
2212
|
+
throw this.opError_("Failed to copyFile", result);
|
|
2079
2213
|
}
|
|
2080
2214
|
}
|
|
2081
2215
|
writeStdout(data) {
|
|
2082
2216
|
const encoded = new TextEncoder().encode(data);
|
|
2083
2217
|
const result = this.execSync(OpCode.WRITE_STDOUT, "", encoded);
|
|
2084
2218
|
if (!result.success) {
|
|
2085
|
-
throw
|
|
2219
|
+
throw this.opError_("Failed to write stdout", result);
|
|
2086
2220
|
}
|
|
2087
2221
|
}
|
|
2088
2222
|
writeStderr(data) {
|
|
2089
2223
|
const encoded = new TextEncoder().encode(data);
|
|
2090
2224
|
const result = this.execSync(OpCode.WRITE_STDERR, "", encoded);
|
|
2091
2225
|
if (!result.success) {
|
|
2092
|
-
throw
|
|
2226
|
+
throw this.opError_("Failed to write stderr", result);
|
|
2093
2227
|
}
|
|
2094
2228
|
}
|
|
2095
2229
|
exit(code) {
|
|
@@ -2103,7 +2237,7 @@ var SyncBackend = class {
|
|
|
2103
2237
|
const requestData = options ? new TextEncoder().encode(JSON.stringify(options)) : void 0;
|
|
2104
2238
|
const result = this.execSync(OpCode.HTTP_REQUEST, url, requestData);
|
|
2105
2239
|
if (!result.success) {
|
|
2106
|
-
throw
|
|
2240
|
+
throw this.opError_("HTTP request failed", result);
|
|
2107
2241
|
}
|
|
2108
2242
|
const responseJson = new TextDecoder().decode(result.result);
|
|
2109
2243
|
const parsed = JSON.parse(responseJson);
|
|
@@ -2126,7 +2260,7 @@ var SyncBackend = class {
|
|
|
2126
2260
|
const requestData = stdin ? new TextEncoder().encode(JSON.stringify({ stdin })) : void 0;
|
|
2127
2261
|
const result = this.execSync(OpCode.EXEC_COMMAND, command, requestData);
|
|
2128
2262
|
if (!result.success) {
|
|
2129
|
-
throw
|
|
2263
|
+
throw this.opError_("Command execution failed", result);
|
|
2130
2264
|
}
|
|
2131
2265
|
const responseJson = new TextDecoder().decode(result.result);
|
|
2132
2266
|
return JSON.parse(responseJson);
|
|
@@ -2139,7 +2273,7 @@ var SyncBackend = class {
|
|
|
2139
2273
|
const requestData = new TextEncoder().encode(JSON.stringify({ args }));
|
|
2140
2274
|
const result = this.execSync(OpCode.EXEC_COMMAND, command, requestData);
|
|
2141
2275
|
if (!result.success) {
|
|
2142
|
-
throw
|
|
2276
|
+
throw this.opError_("Command execution failed", result);
|
|
2143
2277
|
}
|
|
2144
2278
|
const responseJson = new TextDecoder().decode(result.result);
|
|
2145
2279
|
return JSON.parse(responseJson);
|
|
@@ -2152,7 +2286,7 @@ var SyncBackend = class {
|
|
|
2152
2286
|
const requestData = argsJson ? new TextEncoder().encode(argsJson) : void 0;
|
|
2153
2287
|
const result = this.execSync(OpCode.INVOKE_TOOL, path, requestData);
|
|
2154
2288
|
if (!result.success) {
|
|
2155
|
-
throw
|
|
2289
|
+
throw this.opError_("Tool invocation failed", result);
|
|
2156
2290
|
}
|
|
2157
2291
|
return new TextDecoder().decode(result.result);
|
|
2158
2292
|
}
|
|
@@ -3571,8 +3705,18 @@ function formatError(errorVal) {
|
|
|
3571
3705
|
}
|
|
3572
3706
|
return String(errorVal);
|
|
3573
3707
|
}
|
|
3574
|
-
function throwError(context, message) {
|
|
3575
|
-
|
|
3708
|
+
function throwError(context, message, code) {
|
|
3709
|
+
const err = context.newError(message);
|
|
3710
|
+
if (code !== void 0) {
|
|
3711
|
+
const codeHandle = context.newString(code);
|
|
3712
|
+
context.setProp(err, "code", codeHandle);
|
|
3713
|
+
codeHandle.dispose();
|
|
3714
|
+
}
|
|
3715
|
+
return { error: err };
|
|
3716
|
+
}
|
|
3717
|
+
function throwGuestError_(context, e, fallback) {
|
|
3718
|
+
const err = e;
|
|
3719
|
+
return throwError(context, err?.message || fallback, err?.code);
|
|
3576
3720
|
}
|
|
3577
3721
|
function isProcessExit(context, error, processExitMarker) {
|
|
3578
3722
|
const marker = context.getProp(error, PROCESS_EXIT_MARKER);
|
|
@@ -3816,7 +3960,7 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
3816
3960
|
backend.writeStdout(`${parts.join(" ")}
|
|
3817
3961
|
`);
|
|
3818
3962
|
} catch (e) {
|
|
3819
|
-
return
|
|
3963
|
+
return throwGuestError_(context, e, "write failed");
|
|
3820
3964
|
}
|
|
3821
3965
|
return context.undefined;
|
|
3822
3966
|
});
|
|
@@ -3831,7 +3975,7 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
3831
3975
|
backend.writeStderr(`${parts.join(" ")}
|
|
3832
3976
|
`);
|
|
3833
3977
|
} catch (e) {
|
|
3834
|
-
return
|
|
3978
|
+
return throwGuestError_(context, e, "write failed");
|
|
3835
3979
|
}
|
|
3836
3980
|
return context.undefined;
|
|
3837
3981
|
});
|
|
@@ -3846,7 +3990,7 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
3846
3990
|
backend.writeStderr(`${parts.join(" ")}
|
|
3847
3991
|
`);
|
|
3848
3992
|
} catch (e) {
|
|
3849
|
-
return
|
|
3993
|
+
return throwGuestError_(context, e, "write failed");
|
|
3850
3994
|
}
|
|
3851
3995
|
return context.undefined;
|
|
3852
3996
|
});
|
|
@@ -3863,7 +4007,7 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
3863
4007
|
const data = backend.readFile(path);
|
|
3864
4008
|
return context.newString(new TextDecoder().decode(data));
|
|
3865
4009
|
} catch (e) {
|
|
3866
|
-
return
|
|
4010
|
+
return throwGuestError_(context, e, "readFile failed");
|
|
3867
4011
|
}
|
|
3868
4012
|
}
|
|
3869
4013
|
);
|
|
@@ -3879,25 +4023,56 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
3879
4023
|
data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength)
|
|
3880
4024
|
);
|
|
3881
4025
|
} catch (e) {
|
|
3882
|
-
return
|
|
3883
|
-
context,
|
|
3884
|
-
e.message || "readFileBuffer failed"
|
|
3885
|
-
);
|
|
4026
|
+
return throwGuestError_(context, e, "readFileBuffer failed");
|
|
3886
4027
|
}
|
|
3887
4028
|
}
|
|
3888
4029
|
);
|
|
3889
4030
|
context.setProp(fsObj, "readFileBuffer", readFileBufferFn);
|
|
3890
4031
|
readFileBufferFn.dispose();
|
|
4032
|
+
const marshalWriteData = (dataHandle) => {
|
|
4033
|
+
if (context.typeof(dataHandle) === "string") {
|
|
4034
|
+
return new TextEncoder().encode(context.getString(dataHandle));
|
|
4035
|
+
}
|
|
4036
|
+
if (context.typeof(dataHandle) === "object") {
|
|
4037
|
+
const bufferHandle = context.getProp(dataHandle, "buffer");
|
|
4038
|
+
if (bufferHandle && context.typeof(bufferHandle) === "object") {
|
|
4039
|
+
const offsetHandle = context.getProp(dataHandle, "byteOffset");
|
|
4040
|
+
const lengthHandle = context.getProp(dataHandle, "byteLength");
|
|
4041
|
+
try {
|
|
4042
|
+
const raw = context.getArrayBuffer(bufferHandle).value;
|
|
4043
|
+
const view = raw instanceof Uint8Array ? raw : new Uint8Array(raw);
|
|
4044
|
+
const offset = offsetHandle && context.typeof(offsetHandle) === "number" ? context.getNumber(offsetHandle) : 0;
|
|
4045
|
+
const length = lengthHandle && context.typeof(lengthHandle) === "number" ? context.getNumber(lengthHandle) : view.byteLength - offset;
|
|
4046
|
+
if (offset < 0 || length < 0 || offset + length > view.byteLength) {
|
|
4047
|
+
throw new TypeError("writeFile data has an invalid byte window");
|
|
4048
|
+
}
|
|
4049
|
+
return view.slice(offset, offset + length);
|
|
4050
|
+
} finally {
|
|
4051
|
+
bufferHandle.dispose();
|
|
4052
|
+
offsetHandle?.dispose();
|
|
4053
|
+
lengthHandle?.dispose();
|
|
4054
|
+
}
|
|
4055
|
+
}
|
|
4056
|
+
bufferHandle?.dispose();
|
|
4057
|
+
try {
|
|
4058
|
+
const raw = context.getArrayBuffer(dataHandle).value;
|
|
4059
|
+
return raw instanceof Uint8Array ? raw : new Uint8Array(raw);
|
|
4060
|
+
} catch {
|
|
4061
|
+
}
|
|
4062
|
+
}
|
|
4063
|
+
throw new TypeError(
|
|
4064
|
+
"writeFile data must be a string, Buffer, TypedArray, or DataView"
|
|
4065
|
+
);
|
|
4066
|
+
};
|
|
3891
4067
|
const writeFileFn = context.newFunction(
|
|
3892
4068
|
"writeFile",
|
|
3893
4069
|
(pathHandle, dataHandle) => {
|
|
3894
4070
|
const path = context.getString(pathHandle);
|
|
3895
|
-
const data = context.getString(dataHandle);
|
|
3896
4071
|
try {
|
|
3897
|
-
backend.writeFile(path,
|
|
4072
|
+
backend.writeFile(path, marshalWriteData(dataHandle));
|
|
3898
4073
|
return context.undefined;
|
|
3899
4074
|
} catch (e) {
|
|
3900
|
-
return
|
|
4075
|
+
return throwGuestError_(context, e, "writeFile failed");
|
|
3901
4076
|
}
|
|
3902
4077
|
}
|
|
3903
4078
|
);
|
|
@@ -3916,7 +4091,7 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
3916
4091
|
mtime: stat.mtime.toISOString()
|
|
3917
4092
|
});
|
|
3918
4093
|
} catch (e) {
|
|
3919
|
-
return
|
|
4094
|
+
return throwGuestError_(context, e, "stat failed");
|
|
3920
4095
|
}
|
|
3921
4096
|
});
|
|
3922
4097
|
context.setProp(fsObj, "stat", statFn);
|
|
@@ -3929,7 +4104,7 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
3929
4104
|
const entries = backend.readdir(path);
|
|
3930
4105
|
return jsToHandle(context, entries);
|
|
3931
4106
|
} catch (e) {
|
|
3932
|
-
return
|
|
4107
|
+
return throwGuestError_(context, e, "readdir failed");
|
|
3933
4108
|
}
|
|
3934
4109
|
}
|
|
3935
4110
|
);
|
|
@@ -3950,7 +4125,7 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
3950
4125
|
backend.mkdir(path, recursive);
|
|
3951
4126
|
return context.undefined;
|
|
3952
4127
|
} catch (e) {
|
|
3953
|
-
return
|
|
4128
|
+
return throwGuestError_(context, e, "mkdir failed");
|
|
3954
4129
|
}
|
|
3955
4130
|
}
|
|
3956
4131
|
);
|
|
@@ -3973,7 +4148,7 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
3973
4148
|
backend.rm(path, recursive, force);
|
|
3974
4149
|
return context.undefined;
|
|
3975
4150
|
} catch (e) {
|
|
3976
|
-
return
|
|
4151
|
+
return throwGuestError_(context, e, "rm failed");
|
|
3977
4152
|
}
|
|
3978
4153
|
}
|
|
3979
4154
|
);
|
|
@@ -3992,12 +4167,11 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
3992
4167
|
"appendFile",
|
|
3993
4168
|
(pathHandle, dataHandle) => {
|
|
3994
4169
|
const path = context.getString(pathHandle);
|
|
3995
|
-
const data = context.getString(dataHandle);
|
|
3996
4170
|
try {
|
|
3997
|
-
backend.appendFile(path,
|
|
4171
|
+
backend.appendFile(path, marshalWriteData(dataHandle));
|
|
3998
4172
|
return context.undefined;
|
|
3999
4173
|
} catch (e) {
|
|
4000
|
-
return
|
|
4174
|
+
return throwGuestError_(context, e, "appendFile failed");
|
|
4001
4175
|
}
|
|
4002
4176
|
}
|
|
4003
4177
|
);
|
|
@@ -4016,7 +4190,7 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
4016
4190
|
mtime: s.mtime.toISOString()
|
|
4017
4191
|
});
|
|
4018
4192
|
} catch (e) {
|
|
4019
|
-
return
|
|
4193
|
+
return throwGuestError_(context, e, "lstat failed");
|
|
4020
4194
|
}
|
|
4021
4195
|
});
|
|
4022
4196
|
context.setProp(fsObj, "lstat", lstatFn);
|
|
@@ -4030,7 +4204,7 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
4030
4204
|
backend.symlink(target, linkPath);
|
|
4031
4205
|
return context.undefined;
|
|
4032
4206
|
} catch (e) {
|
|
4033
|
-
return
|
|
4207
|
+
return throwGuestError_(context, e, "symlink failed");
|
|
4034
4208
|
}
|
|
4035
4209
|
}
|
|
4036
4210
|
);
|
|
@@ -4044,7 +4218,7 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
4044
4218
|
const target = backend.readlink(path);
|
|
4045
4219
|
return context.newString(target);
|
|
4046
4220
|
} catch (e) {
|
|
4047
|
-
return
|
|
4221
|
+
return throwGuestError_(context, e, "readlink failed");
|
|
4048
4222
|
}
|
|
4049
4223
|
}
|
|
4050
4224
|
);
|
|
@@ -4059,7 +4233,7 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
4059
4233
|
backend.chmod(path, typeof mode === "number" ? mode : 0);
|
|
4060
4234
|
return context.undefined;
|
|
4061
4235
|
} catch (e) {
|
|
4062
|
-
return
|
|
4236
|
+
return throwGuestError_(context, e, "chmod failed");
|
|
4063
4237
|
}
|
|
4064
4238
|
}
|
|
4065
4239
|
);
|
|
@@ -4073,7 +4247,7 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
4073
4247
|
const resolved = backend.realpath(path);
|
|
4074
4248
|
return context.newString(resolved);
|
|
4075
4249
|
} catch (e) {
|
|
4076
|
-
return
|
|
4250
|
+
return throwGuestError_(context, e, "realpath failed");
|
|
4077
4251
|
}
|
|
4078
4252
|
}
|
|
4079
4253
|
);
|
|
@@ -4088,7 +4262,7 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
4088
4262
|
backend.rename(oldPath, newPath);
|
|
4089
4263
|
return context.undefined;
|
|
4090
4264
|
} catch (e) {
|
|
4091
|
-
return
|
|
4265
|
+
return throwGuestError_(context, e, "rename failed");
|
|
4092
4266
|
}
|
|
4093
4267
|
}
|
|
4094
4268
|
);
|
|
@@ -4103,7 +4277,7 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
4103
4277
|
backend.copyFile(src, dest);
|
|
4104
4278
|
return context.undefined;
|
|
4105
4279
|
} catch (e) {
|
|
4106
|
-
return
|
|
4280
|
+
return throwGuestError_(context, e, "copyFile failed");
|
|
4107
4281
|
}
|
|
4108
4282
|
}
|
|
4109
4283
|
);
|
|
@@ -4127,7 +4301,7 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
4127
4301
|
});
|
|
4128
4302
|
return jsToHandle(context, result);
|
|
4129
4303
|
} catch (e) {
|
|
4130
|
-
return
|
|
4304
|
+
return throwGuestError_(context, e, "fetch failed");
|
|
4131
4305
|
}
|
|
4132
4306
|
}
|
|
4133
4307
|
);
|
|
@@ -4148,7 +4322,7 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
4148
4322
|
const result = backend.execCommand(command, stdin);
|
|
4149
4323
|
return jsToHandle(context, result);
|
|
4150
4324
|
} catch (e) {
|
|
4151
|
-
return
|
|
4325
|
+
return throwGuestError_(context, e, "exec failed");
|
|
4152
4326
|
}
|
|
4153
4327
|
}
|
|
4154
4328
|
);
|
|
@@ -4163,7 +4337,7 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
4163
4337
|
const result = backend.execCommandArgs(command, args);
|
|
4164
4338
|
return jsToHandle(context, result);
|
|
4165
4339
|
} catch (e) {
|
|
4166
|
-
return
|
|
4340
|
+
return throwGuestError_(context, e, "exec failed");
|
|
4167
4341
|
}
|
|
4168
4342
|
}
|
|
4169
4343
|
);
|
|
@@ -4179,10 +4353,7 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
4179
4353
|
const resultJson = backend.invokeTool(path, argsJson);
|
|
4180
4354
|
return context.newString(resultJson);
|
|
4181
4355
|
} catch (e) {
|
|
4182
|
-
return
|
|
4183
|
-
context,
|
|
4184
|
-
e.message || "tool invocation failed"
|
|
4185
|
-
);
|
|
4356
|
+
return throwGuestError_(context, e, "tool invocation failed");
|
|
4186
4357
|
}
|
|
4187
4358
|
}
|
|
4188
4359
|
);
|
|
@@ -4310,7 +4481,13 @@ function setupContext(context, backend, input, processExitMarker) {
|
|
|
4310
4481
|
_fs.promises.unlink = _fs.promises.rm;
|
|
4311
4482
|
_fs.promises.rmdir = _fs.promises.rm;
|
|
4312
4483
|
_fs.promises.access = function(p) {
|
|
4313
|
-
|
|
4484
|
+
if (orig.exists(p)) return Promise.resolve();
|
|
4485
|
+
// Node-style error: prefixed message AND structured .code (the
|
|
4486
|
+
// sanctioned pattern \u2014 no errno literal at the Error call site).
|
|
4487
|
+
var msg = 'ENOENT: no such file or directory: ' + p;
|
|
4488
|
+
var e = new Error(msg);
|
|
4489
|
+
e.code = 'ENOENT';
|
|
4490
|
+
return Promise.reject(e);
|
|
4314
4491
|
};
|
|
4315
4492
|
|
|
4316
4493
|
// process enhancements
|
|
@@ -4640,11 +4817,14 @@ async function executeCode(input) {
|
|
|
4640
4817
|
}
|
|
4641
4818
|
return source;
|
|
4642
4819
|
} catch (e) {
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4820
|
+
const err = new Error(
|
|
4821
|
+
`Cannot find module '${moduleName}': ${e.message}`
|
|
4822
|
+
);
|
|
4823
|
+
const code = e.code;
|
|
4824
|
+
if (code !== void 0) {
|
|
4825
|
+
err.code = code;
|
|
4826
|
+
}
|
|
4827
|
+
return { error: err };
|
|
4648
4828
|
}
|
|
4649
4829
|
},
|
|
4650
4830
|
(baseModuleName, requestedName) => {
|