just-bash-nx 2.14.4

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.
Files changed (894) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +201 -0
  3. package/README.md +573 -0
  4. package/dist/AGENTS.md +325 -0
  5. package/dist/Bash.d.ts +229 -0
  6. package/dist/ast/types.d.ts +609 -0
  7. package/dist/banned-patterns-test.d.ts +1 -0
  8. package/dist/bin/chunks/alias-3GODYSFD.js +2 -0
  9. package/dist/bin/chunks/awk2-RSUCURL4.js +2 -0
  10. package/dist/bin/chunks/base64-43M2R3GA.js +2 -0
  11. package/dist/bin/chunks/basename-KBUKWB2E.js +2 -0
  12. package/dist/bin/chunks/bash-6ZHZ6BX7.js +2 -0
  13. package/dist/bin/chunks/cat-XZIJZXKP.js +2 -0
  14. package/dist/bin/chunks/chmod-N5CQATDW.js +2 -0
  15. package/dist/bin/chunks/chunk-22NDZXS5.js +33 -0
  16. package/dist/bin/chunks/chunk-26NO42TF.js +14 -0
  17. package/dist/bin/chunks/chunk-2W2SCVT6.js +140 -0
  18. package/dist/bin/chunks/chunk-3MBAUIBB.js +7 -0
  19. package/dist/bin/chunks/chunk-3Y32LPNT.js +2 -0
  20. package/dist/bin/chunks/chunk-4CFAYBLV.js +21 -0
  21. package/dist/bin/chunks/chunk-4OALHZXB.js +2 -0
  22. package/dist/bin/chunks/chunk-4PRVMER6.js +2 -0
  23. package/dist/bin/chunks/chunk-4VDEBYW7.js +2 -0
  24. package/dist/bin/chunks/chunk-54G6AE72.js +32 -0
  25. package/dist/bin/chunks/chunk-5G2VOPPJ.js +7 -0
  26. package/dist/bin/chunks/chunk-5WFYIUU2.js +3 -0
  27. package/dist/bin/chunks/chunk-6KZRLMG3.js +8 -0
  28. package/dist/bin/chunks/chunk-7ADG3DNO.js +8 -0
  29. package/dist/bin/chunks/chunk-7BORMNPQ.js +2 -0
  30. package/dist/bin/chunks/chunk-7G3MC56B.js +7 -0
  31. package/dist/bin/chunks/chunk-AAW7UMPO.js +9 -0
  32. package/dist/bin/chunks/chunk-AXWFPG37.js +10 -0
  33. package/dist/bin/chunks/chunk-AZ3RUDR2.js +9 -0
  34. package/dist/bin/chunks/chunk-BGGF3ELU.js +5 -0
  35. package/dist/bin/chunks/chunk-BYDV4VEF.js +3 -0
  36. package/dist/bin/chunks/chunk-CGE2EHYP.js +5 -0
  37. package/dist/bin/chunks/chunk-CM4532DS.js +36 -0
  38. package/dist/bin/chunks/chunk-CQG2HEAL.js +5 -0
  39. package/dist/bin/chunks/chunk-D5WP4CKS.js +3 -0
  40. package/dist/bin/chunks/chunk-DOXYBGNA.js +12 -0
  41. package/dist/bin/chunks/chunk-E5BDLLK6.js +15 -0
  42. package/dist/bin/chunks/chunk-EJQKHROT.js +14 -0
  43. package/dist/bin/chunks/chunk-EONWONZV.js +2 -0
  44. package/dist/bin/chunks/chunk-EPPBDXOG.js +8 -0
  45. package/dist/bin/chunks/chunk-EUXCM6C4.js +12 -0
  46. package/dist/bin/chunks/chunk-EWDHVLQL.js +21 -0
  47. package/dist/bin/chunks/chunk-F3LGZXLQ.js +9 -0
  48. package/dist/bin/chunks/chunk-FA2CHD73.js +16 -0
  49. package/dist/bin/chunks/chunk-FIHFXGT6.js +287 -0
  50. package/dist/bin/chunks/chunk-FLPVVSN5.js +5 -0
  51. package/dist/bin/chunks/chunk-FSZWFMB4.js +16 -0
  52. package/dist/bin/chunks/chunk-GO6FXSC4.js +6 -0
  53. package/dist/bin/chunks/chunk-GOJZHH3L.js +6 -0
  54. package/dist/bin/chunks/chunk-GTNBSMZR.js +23 -0
  55. package/dist/bin/chunks/chunk-IDGH4PGU.js +3 -0
  56. package/dist/bin/chunks/chunk-IO2FYBEM.js +6 -0
  57. package/dist/bin/chunks/chunk-ITA43A73.js +7 -0
  58. package/dist/bin/chunks/chunk-JBABAK44.js +4 -0
  59. package/dist/bin/chunks/chunk-JDNI5HBX.js +33 -0
  60. package/dist/bin/chunks/chunk-JLX6YWGA.js +3 -0
  61. package/dist/bin/chunks/chunk-JQBC3FXE.js +8 -0
  62. package/dist/bin/chunks/chunk-JTF74J6E.js +2 -0
  63. package/dist/bin/chunks/chunk-KCMUAACL.js +19 -0
  64. package/dist/bin/chunks/chunk-KGOUQS5A.js +2 -0
  65. package/dist/bin/chunks/chunk-L6XUBS6H.js +84 -0
  66. package/dist/bin/chunks/chunk-LCDPWJBA.js +15 -0
  67. package/dist/bin/chunks/chunk-LGJM5YFT.js +17 -0
  68. package/dist/bin/chunks/chunk-LIYVQA3X.js +2 -0
  69. package/dist/bin/chunks/chunk-LJKIWB5F.js +4 -0
  70. package/dist/bin/chunks/chunk-LMK6G2HH.js +8 -0
  71. package/dist/bin/chunks/chunk-LOJMXC4F.js +5 -0
  72. package/dist/bin/chunks/chunk-MAVV76T4.js +2 -0
  73. package/dist/bin/chunks/chunk-MO4RPBN2.js +2 -0
  74. package/dist/bin/chunks/chunk-MRP4ZCD7.js +6 -0
  75. package/dist/bin/chunks/chunk-N43DJTSI.js +2 -0
  76. package/dist/bin/chunks/chunk-NAX7MTAR.js +21 -0
  77. package/dist/bin/chunks/chunk-NSUMEERA.js +12 -0
  78. package/dist/bin/chunks/chunk-NTW6IA45.js +2 -0
  79. package/dist/bin/chunks/chunk-OBH7XN5N.js +1 -0
  80. package/dist/bin/chunks/chunk-OBI37ZY4.js +9 -0
  81. package/dist/bin/chunks/chunk-OOJCYVYF.js +2 -0
  82. package/dist/bin/chunks/chunk-ORUYSLP4.js +16 -0
  83. package/dist/bin/chunks/chunk-OXHVTSNH.js +74 -0
  84. package/dist/bin/chunks/chunk-PNI5NMXP.js +100 -0
  85. package/dist/bin/chunks/chunk-PPBQJBC2.js +5 -0
  86. package/dist/bin/chunks/chunk-PQNTKMH3.js +6 -0
  87. package/dist/bin/chunks/chunk-PS4LOXE5.js +8 -0
  88. package/dist/bin/chunks/chunk-PXVBSPBE.js +2 -0
  89. package/dist/bin/chunks/chunk-RA3TG4UK.js +9 -0
  90. package/dist/bin/chunks/chunk-RBQGQWGV.js +10 -0
  91. package/dist/bin/chunks/chunk-RJSAGJQJ.js +11 -0
  92. package/dist/bin/chunks/chunk-RLNOQILG.js +2 -0
  93. package/dist/bin/chunks/chunk-ROJPSS6N.js +3 -0
  94. package/dist/bin/chunks/chunk-RT7TRQVZ.js +3 -0
  95. package/dist/bin/chunks/chunk-S3QAKT3R.js +11 -0
  96. package/dist/bin/chunks/chunk-S7OHMN3F.js +6 -0
  97. package/dist/bin/chunks/chunk-SGA7Y45Z.js +17 -0
  98. package/dist/bin/chunks/chunk-SXRVLCZ4.js +2 -0
  99. package/dist/bin/chunks/chunk-TEFXEYX3.js +3 -0
  100. package/dist/bin/chunks/chunk-THALLNXT.js +7 -0
  101. package/dist/bin/chunks/chunk-TTNNO45C.js +17 -0
  102. package/dist/bin/chunks/chunk-UFJFAFSS.js +28 -0
  103. package/dist/bin/chunks/chunk-V7ZOPVQS.js +2 -0
  104. package/dist/bin/chunks/chunk-VNER2XXL.js +7 -0
  105. package/dist/bin/chunks/chunk-WLBA7L7U.js +23 -0
  106. package/dist/bin/chunks/chunk-WWZVR5NN.js +6 -0
  107. package/dist/bin/chunks/chunk-WXMBDX4P.js +14 -0
  108. package/dist/bin/chunks/chunk-XXCTETRW.js +11 -0
  109. package/dist/bin/chunks/chunk-XY5HGZW5.js +8 -0
  110. package/dist/bin/chunks/chunk-YEKSVVRC.js +11 -0
  111. package/dist/bin/chunks/chunk-YLE2OYY6.js +2 -0
  112. package/dist/bin/chunks/chunk-YMMJLYIX.js +2 -0
  113. package/dist/bin/chunks/chunk-YTIURC67.js +2 -0
  114. package/dist/bin/chunks/chunk-YU6OGPZR.js +5 -0
  115. package/dist/bin/chunks/chunk-YWZOGBFE.js +9 -0
  116. package/dist/bin/chunks/chunk-ZA4HUKJ3.js +13 -0
  117. package/dist/bin/chunks/chunk-ZKC5HQYO.js +14 -0
  118. package/dist/bin/chunks/chunk-ZSVBYEY4.js +6 -0
  119. package/dist/bin/chunks/chunk-ZUDPEMHG.js +63 -0
  120. package/dist/bin/chunks/clear-KRGKPFOI.js +2 -0
  121. package/dist/bin/chunks/column-XGV32UPN.js +2 -0
  122. package/dist/bin/chunks/comm-R3F3Z5DX.js +2 -0
  123. package/dist/bin/chunks/cp-XH2ZB7WT.js +2 -0
  124. package/dist/bin/chunks/curl-2DCNBIKJ.js +26 -0
  125. package/dist/bin/chunks/cut-5EY2XPXX.js +2 -0
  126. package/dist/bin/chunks/date-WUPBL2TL.js +2 -0
  127. package/dist/bin/chunks/diff-5NUI5BHG.js +2 -0
  128. package/dist/bin/chunks/dirname-5FAOMLBL.js +2 -0
  129. package/dist/bin/chunks/du-LDAPXSGF.js +2 -0
  130. package/dist/bin/chunks/echo-2MUAOGUE.js +2 -0
  131. package/dist/bin/chunks/env-NTPN5QYM.js +2 -0
  132. package/dist/bin/chunks/expand-26XPP5KB.js +2 -0
  133. package/dist/bin/chunks/expansion-QUT3FT7V.js +2 -0
  134. package/dist/bin/chunks/expr-G4EF4POQ.js +2 -0
  135. package/dist/bin/chunks/file-MMSHRWCJ.js +2 -0
  136. package/dist/bin/chunks/find-7CVMEZBO.js +2 -0
  137. package/dist/bin/chunks/flag-coverage-UJISFT4M.js +2 -0
  138. package/dist/bin/chunks/fold-XSVNTAWH.js +2 -0
  139. package/dist/bin/chunks/grep-7BJ7HFBM.js +2 -0
  140. package/dist/bin/chunks/gzip-LHOO65AN.js +2 -0
  141. package/dist/bin/chunks/head-YMNRW3F3.js +2 -0
  142. package/dist/bin/chunks/help-DVG4AAGE.js +2 -0
  143. package/dist/bin/chunks/history-UUKG55YW.js +2 -0
  144. package/dist/bin/chunks/hostname-WY6RKE32.js +2 -0
  145. package/dist/bin/chunks/html-to-markdown-V6PK6S5U.js +2 -0
  146. package/dist/bin/chunks/join-Y4Q5WVVE.js +2 -0
  147. package/dist/bin/chunks/jq-4JWOFG7X.js +2 -0
  148. package/dist/bin/chunks/js-exec-RWEELTC2.js +97 -0
  149. package/dist/bin/chunks/js-exec-worker.js +4380 -0
  150. package/dist/bin/chunks/ln-EGC4HRXZ.js +2 -0
  151. package/dist/bin/chunks/ls-WONXDVOX.js +2 -0
  152. package/dist/bin/chunks/md5sum-NCLXV2S3.js +2 -0
  153. package/dist/bin/chunks/mkdir-Z47OISSR.js +2 -0
  154. package/dist/bin/chunks/mv-OY7X62QC.js +2 -0
  155. package/dist/bin/chunks/nl-XH3L75DR.js +2 -0
  156. package/dist/bin/chunks/od-52FBC34W.js +2 -0
  157. package/dist/bin/chunks/paste-3UVLMQ2K.js +2 -0
  158. package/dist/bin/chunks/printf-NA7DYZBO.js +2 -0
  159. package/dist/bin/chunks/pwd-6VBAPL3Y.js +2 -0
  160. package/dist/bin/chunks/python3-JUJKPBFB.js +12 -0
  161. package/dist/bin/chunks/readlink-BD5VFOC5.js +2 -0
  162. package/dist/bin/chunks/rev-UHEPS2UL.js +2 -0
  163. package/dist/bin/chunks/rg-DK6FRF6Q.js +2 -0
  164. package/dist/bin/chunks/rm-L3NZOLLG.js +2 -0
  165. package/dist/bin/chunks/rmdir-5KLM4EA6.js +2 -0
  166. package/dist/bin/chunks/sed-WWXBUNG3.js +2 -0
  167. package/dist/bin/chunks/seq-V7KBLSQ7.js +2 -0
  168. package/dist/bin/chunks/sha1sum-BHNJ5ALF.js +2 -0
  169. package/dist/bin/chunks/sha256sum-HJJ3NJ5L.js +2 -0
  170. package/dist/bin/chunks/sleep-ND6FZRZ4.js +2 -0
  171. package/dist/bin/chunks/sort-7GENYU2I.js +2 -0
  172. package/dist/bin/chunks/split-YWV64TJH.js +2 -0
  173. package/dist/bin/chunks/sqlite3-CVNFMP3Z.js +2 -0
  174. package/dist/bin/chunks/stat-XS2LXYS2.js +2 -0
  175. package/dist/bin/chunks/strings-XXKZCWY5.js +2 -0
  176. package/dist/bin/chunks/tac-T42SKDDI.js +2 -0
  177. package/dist/bin/chunks/tail-V537TDFR.js +2 -0
  178. package/dist/bin/chunks/tar-GTGFEWDS.js +2 -0
  179. package/dist/bin/chunks/tee-HK2SYCAR.js +2 -0
  180. package/dist/bin/chunks/time-5R4QWCYF.js +2 -0
  181. package/dist/bin/chunks/timeout-Z24MNWOP.js +2 -0
  182. package/dist/bin/chunks/touch-DWKSZGOQ.js +2 -0
  183. package/dist/bin/chunks/tr-4FPGAEVB.js +2 -0
  184. package/dist/bin/chunks/tree-HEKABARE.js +2 -0
  185. package/dist/bin/chunks/true-DP5UZP52.js +2 -0
  186. package/dist/bin/chunks/unexpand-OYZ7KOYR.js +2 -0
  187. package/dist/bin/chunks/uniq-TMSAIZM3.js +2 -0
  188. package/dist/bin/chunks/wc-ZIV3TFVG.js +2 -0
  189. package/dist/bin/chunks/which-5PO4LAOG.js +2 -0
  190. package/dist/bin/chunks/whoami-E7PN2UWC.js +2 -0
  191. package/dist/bin/chunks/worker.js +3136 -0
  192. package/dist/bin/chunks/xan-FKXPSPE5.js +2 -0
  193. package/dist/bin/chunks/xan-view-6J5MMMQB.js +2 -0
  194. package/dist/bin/chunks/xargs-SCYIFXOW.js +2 -0
  195. package/dist/bin/chunks/yq-RGXFWYJN.js +2 -0
  196. package/dist/bin/just-bash.js +754 -0
  197. package/dist/bin/shell/chunks/alias-3GODYSFD.js +2 -0
  198. package/dist/bin/shell/chunks/awk2-RSUCURL4.js +2 -0
  199. package/dist/bin/shell/chunks/base64-43M2R3GA.js +2 -0
  200. package/dist/bin/shell/chunks/basename-KBUKWB2E.js +2 -0
  201. package/dist/bin/shell/chunks/bash-6ZHZ6BX7.js +2 -0
  202. package/dist/bin/shell/chunks/cat-XZIJZXKP.js +2 -0
  203. package/dist/bin/shell/chunks/chmod-N5CQATDW.js +2 -0
  204. package/dist/bin/shell/chunks/chunk-22NDZXS5.js +33 -0
  205. package/dist/bin/shell/chunks/chunk-26NO42TF.js +14 -0
  206. package/dist/bin/shell/chunks/chunk-2W2SCVT6.js +140 -0
  207. package/dist/bin/shell/chunks/chunk-3MBAUIBB.js +7 -0
  208. package/dist/bin/shell/chunks/chunk-3Y32LPNT.js +2 -0
  209. package/dist/bin/shell/chunks/chunk-4CFAYBLV.js +21 -0
  210. package/dist/bin/shell/chunks/chunk-4OALHZXB.js +2 -0
  211. package/dist/bin/shell/chunks/chunk-4PRVMER6.js +2 -0
  212. package/dist/bin/shell/chunks/chunk-4VDEBYW7.js +2 -0
  213. package/dist/bin/shell/chunks/chunk-54G6AE72.js +32 -0
  214. package/dist/bin/shell/chunks/chunk-5G2VOPPJ.js +7 -0
  215. package/dist/bin/shell/chunks/chunk-5WFYIUU2.js +3 -0
  216. package/dist/bin/shell/chunks/chunk-6KZRLMG3.js +8 -0
  217. package/dist/bin/shell/chunks/chunk-7ADG3DNO.js +8 -0
  218. package/dist/bin/shell/chunks/chunk-7BORMNPQ.js +2 -0
  219. package/dist/bin/shell/chunks/chunk-7G3MC56B.js +7 -0
  220. package/dist/bin/shell/chunks/chunk-AAW7UMPO.js +9 -0
  221. package/dist/bin/shell/chunks/chunk-AXWFPG37.js +10 -0
  222. package/dist/bin/shell/chunks/chunk-AZ3RUDR2.js +9 -0
  223. package/dist/bin/shell/chunks/chunk-BGGF3ELU.js +5 -0
  224. package/dist/bin/shell/chunks/chunk-BYDV4VEF.js +3 -0
  225. package/dist/bin/shell/chunks/chunk-CGE2EHYP.js +5 -0
  226. package/dist/bin/shell/chunks/chunk-CM4532DS.js +36 -0
  227. package/dist/bin/shell/chunks/chunk-CQG2HEAL.js +5 -0
  228. package/dist/bin/shell/chunks/chunk-D5WP4CKS.js +3 -0
  229. package/dist/bin/shell/chunks/chunk-DOXYBGNA.js +12 -0
  230. package/dist/bin/shell/chunks/chunk-E5BDLLK6.js +15 -0
  231. package/dist/bin/shell/chunks/chunk-EJQKHROT.js +14 -0
  232. package/dist/bin/shell/chunks/chunk-EONWONZV.js +2 -0
  233. package/dist/bin/shell/chunks/chunk-EPPBDXOG.js +8 -0
  234. package/dist/bin/shell/chunks/chunk-EUXCM6C4.js +12 -0
  235. package/dist/bin/shell/chunks/chunk-EWDHVLQL.js +21 -0
  236. package/dist/bin/shell/chunks/chunk-F3LGZXLQ.js +9 -0
  237. package/dist/bin/shell/chunks/chunk-FA2CHD73.js +16 -0
  238. package/dist/bin/shell/chunks/chunk-FIHFXGT6.js +287 -0
  239. package/dist/bin/shell/chunks/chunk-FLPVVSN5.js +5 -0
  240. package/dist/bin/shell/chunks/chunk-FSZWFMB4.js +16 -0
  241. package/dist/bin/shell/chunks/chunk-GO6FXSC4.js +6 -0
  242. package/dist/bin/shell/chunks/chunk-GOJZHH3L.js +6 -0
  243. package/dist/bin/shell/chunks/chunk-GTNBSMZR.js +23 -0
  244. package/dist/bin/shell/chunks/chunk-HC7WB764.js +2 -0
  245. package/dist/bin/shell/chunks/chunk-IDGH4PGU.js +3 -0
  246. package/dist/bin/shell/chunks/chunk-IO2FYBEM.js +6 -0
  247. package/dist/bin/shell/chunks/chunk-ITA43A73.js +7 -0
  248. package/dist/bin/shell/chunks/chunk-JBABAK44.js +4 -0
  249. package/dist/bin/shell/chunks/chunk-JDNI5HBX.js +33 -0
  250. package/dist/bin/shell/chunks/chunk-JLX6YWGA.js +3 -0
  251. package/dist/bin/shell/chunks/chunk-JQBC3FXE.js +8 -0
  252. package/dist/bin/shell/chunks/chunk-JTF74J6E.js +2 -0
  253. package/dist/bin/shell/chunks/chunk-KCMUAACL.js +19 -0
  254. package/dist/bin/shell/chunks/chunk-KGOUQS5A.js +2 -0
  255. package/dist/bin/shell/chunks/chunk-L6XUBS6H.js +84 -0
  256. package/dist/bin/shell/chunks/chunk-LCDPWJBA.js +15 -0
  257. package/dist/bin/shell/chunks/chunk-LGJM5YFT.js +17 -0
  258. package/dist/bin/shell/chunks/chunk-LIYVQA3X.js +2 -0
  259. package/dist/bin/shell/chunks/chunk-LJKIWB5F.js +4 -0
  260. package/dist/bin/shell/chunks/chunk-LMK6G2HH.js +8 -0
  261. package/dist/bin/shell/chunks/chunk-LOJMXC4F.js +5 -0
  262. package/dist/bin/shell/chunks/chunk-MAVV76T4.js +2 -0
  263. package/dist/bin/shell/chunks/chunk-MO4RPBN2.js +2 -0
  264. package/dist/bin/shell/chunks/chunk-MRP4ZCD7.js +6 -0
  265. package/dist/bin/shell/chunks/chunk-N43DJTSI.js +2 -0
  266. package/dist/bin/shell/chunks/chunk-NAX7MTAR.js +21 -0
  267. package/dist/bin/shell/chunks/chunk-NSUMEERA.js +12 -0
  268. package/dist/bin/shell/chunks/chunk-NTW6IA45.js +2 -0
  269. package/dist/bin/shell/chunks/chunk-OBH7XN5N.js +1 -0
  270. package/dist/bin/shell/chunks/chunk-OBI37ZY4.js +9 -0
  271. package/dist/bin/shell/chunks/chunk-OOJCYVYF.js +2 -0
  272. package/dist/bin/shell/chunks/chunk-ORUYSLP4.js +16 -0
  273. package/dist/bin/shell/chunks/chunk-OXHVTSNH.js +74 -0
  274. package/dist/bin/shell/chunks/chunk-PNI5NMXP.js +100 -0
  275. package/dist/bin/shell/chunks/chunk-PPBQJBC2.js +5 -0
  276. package/dist/bin/shell/chunks/chunk-PQNTKMH3.js +6 -0
  277. package/dist/bin/shell/chunks/chunk-PS4LOXE5.js +8 -0
  278. package/dist/bin/shell/chunks/chunk-RA3TG4UK.js +9 -0
  279. package/dist/bin/shell/chunks/chunk-RBQGQWGV.js +10 -0
  280. package/dist/bin/shell/chunks/chunk-RJSAGJQJ.js +11 -0
  281. package/dist/bin/shell/chunks/chunk-RLNOQILG.js +2 -0
  282. package/dist/bin/shell/chunks/chunk-ROJPSS6N.js +3 -0
  283. package/dist/bin/shell/chunks/chunk-RT7TRQVZ.js +3 -0
  284. package/dist/bin/shell/chunks/chunk-S3QAKT3R.js +11 -0
  285. package/dist/bin/shell/chunks/chunk-S7OHMN3F.js +6 -0
  286. package/dist/bin/shell/chunks/chunk-SGA7Y45Z.js +17 -0
  287. package/dist/bin/shell/chunks/chunk-SXRVLCZ4.js +2 -0
  288. package/dist/bin/shell/chunks/chunk-TEFXEYX3.js +3 -0
  289. package/dist/bin/shell/chunks/chunk-THALLNXT.js +7 -0
  290. package/dist/bin/shell/chunks/chunk-TTNNO45C.js +17 -0
  291. package/dist/bin/shell/chunks/chunk-UFJFAFSS.js +28 -0
  292. package/dist/bin/shell/chunks/chunk-V7ZOPVQS.js +2 -0
  293. package/dist/bin/shell/chunks/chunk-VNER2XXL.js +7 -0
  294. package/dist/bin/shell/chunks/chunk-WLBA7L7U.js +23 -0
  295. package/dist/bin/shell/chunks/chunk-WWZVR5NN.js +6 -0
  296. package/dist/bin/shell/chunks/chunk-WXMBDX4P.js +14 -0
  297. package/dist/bin/shell/chunks/chunk-XXCTETRW.js +11 -0
  298. package/dist/bin/shell/chunks/chunk-XY5HGZW5.js +8 -0
  299. package/dist/bin/shell/chunks/chunk-YEKSVVRC.js +11 -0
  300. package/dist/bin/shell/chunks/chunk-YLE2OYY6.js +2 -0
  301. package/dist/bin/shell/chunks/chunk-YMMJLYIX.js +2 -0
  302. package/dist/bin/shell/chunks/chunk-YTIURC67.js +2 -0
  303. package/dist/bin/shell/chunks/chunk-YU6OGPZR.js +5 -0
  304. package/dist/bin/shell/chunks/chunk-YWZOGBFE.js +9 -0
  305. package/dist/bin/shell/chunks/chunk-ZA4HUKJ3.js +13 -0
  306. package/dist/bin/shell/chunks/chunk-ZKC5HQYO.js +14 -0
  307. package/dist/bin/shell/chunks/chunk-ZSVBYEY4.js +6 -0
  308. package/dist/bin/shell/chunks/chunk-ZUDPEMHG.js +63 -0
  309. package/dist/bin/shell/chunks/clear-KRGKPFOI.js +2 -0
  310. package/dist/bin/shell/chunks/column-XGV32UPN.js +2 -0
  311. package/dist/bin/shell/chunks/comm-R3F3Z5DX.js +2 -0
  312. package/dist/bin/shell/chunks/cp-XH2ZB7WT.js +2 -0
  313. package/dist/bin/shell/chunks/curl-2DCNBIKJ.js +26 -0
  314. package/dist/bin/shell/chunks/cut-5EY2XPXX.js +2 -0
  315. package/dist/bin/shell/chunks/date-WUPBL2TL.js +2 -0
  316. package/dist/bin/shell/chunks/diff-5NUI5BHG.js +2 -0
  317. package/dist/bin/shell/chunks/dirname-5FAOMLBL.js +2 -0
  318. package/dist/bin/shell/chunks/du-LDAPXSGF.js +2 -0
  319. package/dist/bin/shell/chunks/echo-2MUAOGUE.js +2 -0
  320. package/dist/bin/shell/chunks/env-NTPN5QYM.js +2 -0
  321. package/dist/bin/shell/chunks/expand-26XPP5KB.js +2 -0
  322. package/dist/bin/shell/chunks/expansion-QUT3FT7V.js +2 -0
  323. package/dist/bin/shell/chunks/expr-G4EF4POQ.js +2 -0
  324. package/dist/bin/shell/chunks/file-MMSHRWCJ.js +2 -0
  325. package/dist/bin/shell/chunks/find-7CVMEZBO.js +2 -0
  326. package/dist/bin/shell/chunks/flag-coverage-UJISFT4M.js +2 -0
  327. package/dist/bin/shell/chunks/fold-XSVNTAWH.js +2 -0
  328. package/dist/bin/shell/chunks/grep-7BJ7HFBM.js +2 -0
  329. package/dist/bin/shell/chunks/gzip-LHOO65AN.js +2 -0
  330. package/dist/bin/shell/chunks/head-YMNRW3F3.js +2 -0
  331. package/dist/bin/shell/chunks/help-DVG4AAGE.js +2 -0
  332. package/dist/bin/shell/chunks/history-UUKG55YW.js +2 -0
  333. package/dist/bin/shell/chunks/hostname-WY6RKE32.js +2 -0
  334. package/dist/bin/shell/chunks/html-to-markdown-V6PK6S5U.js +2 -0
  335. package/dist/bin/shell/chunks/join-Y4Q5WVVE.js +2 -0
  336. package/dist/bin/shell/chunks/jq-4JWOFG7X.js +2 -0
  337. package/dist/bin/shell/chunks/js-exec-AKWY6BP5.js +97 -0
  338. package/dist/bin/shell/chunks/ln-EGC4HRXZ.js +2 -0
  339. package/dist/bin/shell/chunks/ls-WONXDVOX.js +2 -0
  340. package/dist/bin/shell/chunks/md5sum-NCLXV2S3.js +2 -0
  341. package/dist/bin/shell/chunks/mkdir-Z47OISSR.js +2 -0
  342. package/dist/bin/shell/chunks/mv-OY7X62QC.js +2 -0
  343. package/dist/bin/shell/chunks/nl-XH3L75DR.js +2 -0
  344. package/dist/bin/shell/chunks/od-52FBC34W.js +2 -0
  345. package/dist/bin/shell/chunks/paste-3UVLMQ2K.js +2 -0
  346. package/dist/bin/shell/chunks/printf-NA7DYZBO.js +2 -0
  347. package/dist/bin/shell/chunks/pwd-6VBAPL3Y.js +2 -0
  348. package/dist/bin/shell/chunks/python3-RRCCYJKA.js +12 -0
  349. package/dist/bin/shell/chunks/readlink-BD5VFOC5.js +2 -0
  350. package/dist/bin/shell/chunks/rev-UHEPS2UL.js +2 -0
  351. package/dist/bin/shell/chunks/rg-DK6FRF6Q.js +2 -0
  352. package/dist/bin/shell/chunks/rm-L3NZOLLG.js +2 -0
  353. package/dist/bin/shell/chunks/rmdir-5KLM4EA6.js +2 -0
  354. package/dist/bin/shell/chunks/sed-WWXBUNG3.js +2 -0
  355. package/dist/bin/shell/chunks/seq-V7KBLSQ7.js +2 -0
  356. package/dist/bin/shell/chunks/sha1sum-BHNJ5ALF.js +2 -0
  357. package/dist/bin/shell/chunks/sha256sum-HJJ3NJ5L.js +2 -0
  358. package/dist/bin/shell/chunks/sleep-ND6FZRZ4.js +2 -0
  359. package/dist/bin/shell/chunks/sort-7GENYU2I.js +2 -0
  360. package/dist/bin/shell/chunks/split-YWV64TJH.js +2 -0
  361. package/dist/bin/shell/chunks/sqlite3-CVNFMP3Z.js +2 -0
  362. package/dist/bin/shell/chunks/stat-XS2LXYS2.js +2 -0
  363. package/dist/bin/shell/chunks/strings-XXKZCWY5.js +2 -0
  364. package/dist/bin/shell/chunks/tac-T42SKDDI.js +2 -0
  365. package/dist/bin/shell/chunks/tail-V537TDFR.js +2 -0
  366. package/dist/bin/shell/chunks/tar-GTGFEWDS.js +2 -0
  367. package/dist/bin/shell/chunks/tee-HK2SYCAR.js +2 -0
  368. package/dist/bin/shell/chunks/time-5R4QWCYF.js +2 -0
  369. package/dist/bin/shell/chunks/timeout-Z24MNWOP.js +2 -0
  370. package/dist/bin/shell/chunks/touch-DWKSZGOQ.js +2 -0
  371. package/dist/bin/shell/chunks/tr-4FPGAEVB.js +2 -0
  372. package/dist/bin/shell/chunks/tree-HEKABARE.js +2 -0
  373. package/dist/bin/shell/chunks/true-DP5UZP52.js +2 -0
  374. package/dist/bin/shell/chunks/unexpand-OYZ7KOYR.js +2 -0
  375. package/dist/bin/shell/chunks/uniq-TMSAIZM3.js +2 -0
  376. package/dist/bin/shell/chunks/wc-ZIV3TFVG.js +2 -0
  377. package/dist/bin/shell/chunks/which-5PO4LAOG.js +2 -0
  378. package/dist/bin/shell/chunks/whoami-E7PN2UWC.js +2 -0
  379. package/dist/bin/shell/chunks/xan-FKXPSPE5.js +2 -0
  380. package/dist/bin/shell/chunks/xan-view-6J5MMMQB.js +2 -0
  381. package/dist/bin/shell/chunks/xargs-SCYIFXOW.js +2 -0
  382. package/dist/bin/shell/chunks/yq-RGXFWYJN.js +2 -0
  383. package/dist/bin/shell/shell.js +733 -0
  384. package/dist/browser.d.ts +23 -0
  385. package/dist/bundle/browser.js +1515 -0
  386. package/dist/bundle/chunks/alias-JE7RI5QX.js +1 -0
  387. package/dist/bundle/chunks/awk2-JFGEGLFP.js +1 -0
  388. package/dist/bundle/chunks/base64-4YMZCVJ5.js +1 -0
  389. package/dist/bundle/chunks/basename-AA2KJYZQ.js +1 -0
  390. package/dist/bundle/chunks/bash-IJWYRKFO.js +1 -0
  391. package/dist/bundle/chunks/cat-RDUMLXKC.js +1 -0
  392. package/dist/bundle/chunks/chmod-SYMGL4JA.js +1 -0
  393. package/dist/bundle/chunks/chunk-24IMIIXA.js +1 -0
  394. package/dist/bundle/chunks/chunk-3THT3N7L.js +1 -0
  395. package/dist/bundle/chunks/chunk-3ZUFRYJ4.js +1 -0
  396. package/dist/bundle/chunks/chunk-43RSSTFA.js +73 -0
  397. package/dist/bundle/chunks/chunk-44UOCSGV.js +1 -0
  398. package/dist/bundle/chunks/chunk-4GTNDTRF.js +7 -0
  399. package/dist/bundle/chunks/chunk-4HHKTUW3.js +2 -0
  400. package/dist/bundle/chunks/chunk-4Q4SM6WR.js +4 -0
  401. package/dist/bundle/chunks/chunk-55VFSPNA.js +2 -0
  402. package/dist/bundle/chunks/chunk-5PYKJV42.js +4 -0
  403. package/dist/bundle/chunks/chunk-5QMZ5MUS.js +4 -0
  404. package/dist/bundle/chunks/chunk-5QVNJEHU.js +8 -0
  405. package/dist/bundle/chunks/chunk-5V6VZH6T.js +1 -0
  406. package/dist/bundle/chunks/chunk-62RKD26F.js +20 -0
  407. package/dist/bundle/chunks/chunk-64BAICW3.js +1 -0
  408. package/dist/bundle/chunks/chunk-74CEPOFO.js +22 -0
  409. package/dist/bundle/chunks/chunk-7ESWU5HP.js +14 -0
  410. package/dist/bundle/chunks/chunk-7L36YK2X.js +2 -0
  411. package/dist/bundle/chunks/chunk-7TSDKFEO.js +1 -0
  412. package/dist/bundle/chunks/chunk-A4HU7SVR.js +2 -0
  413. package/dist/bundle/chunks/chunk-A4JSPFCI.js +6 -0
  414. package/dist/bundle/chunks/chunk-A5O5YHGN.js +1 -0
  415. package/dist/bundle/chunks/chunk-A65PWWJC.js +2 -0
  416. package/dist/bundle/chunks/chunk-A7A2DBEE.js +6 -0
  417. package/dist/bundle/chunks/chunk-A7ICOL4V.js +13 -0
  418. package/dist/bundle/chunks/chunk-ALLTKNUZ.js +5 -0
  419. package/dist/bundle/chunks/chunk-APT7OOP2.js +1 -0
  420. package/dist/bundle/chunks/chunk-B53Y5JFV.js +8 -0
  421. package/dist/bundle/chunks/chunk-BAQA74XA.js +1 -0
  422. package/dist/bundle/chunks/chunk-CWQS3NFK.js +1 -0
  423. package/dist/bundle/chunks/chunk-D4J545R4.js +11 -0
  424. package/dist/bundle/chunks/chunk-D6CWQ5DW.js +5 -0
  425. package/dist/bundle/chunks/chunk-D6EWIDSU.js +20 -0
  426. package/dist/bundle/chunks/chunk-D7MEQ3VN.js +4 -0
  427. package/dist/bundle/chunks/chunk-DBKNVD4L.js +9 -0
  428. package/dist/bundle/chunks/chunk-DCAAORBQ.js +1 -0
  429. package/dist/bundle/chunks/chunk-DXB73IDG.js +1 -0
  430. package/dist/bundle/chunks/chunk-EEXR5ZDP.js +2 -0
  431. package/dist/bundle/chunks/chunk-EIZGF4BS.js +8 -0
  432. package/dist/bundle/chunks/chunk-F23WWYKW.js +16 -0
  433. package/dist/bundle/chunks/chunk-GCTKCWKD.js +3 -0
  434. package/dist/bundle/chunks/chunk-GFQRA5P5.js +7 -0
  435. package/dist/bundle/chunks/chunk-GJTDUJ5Q.js +10 -0
  436. package/dist/bundle/chunks/chunk-GOV5EKKI.js +9 -0
  437. package/dist/bundle/chunks/chunk-GXVXFKBA.js +5 -0
  438. package/dist/bundle/chunks/chunk-HDQ56CKY.js +15 -0
  439. package/dist/bundle/chunks/chunk-HJQJAYMS.js +2 -0
  440. package/dist/bundle/chunks/chunk-HJWBQKYG.js +5 -0
  441. package/dist/bundle/chunks/chunk-HL6NGDO2.js +22 -0
  442. package/dist/bundle/chunks/chunk-HWBSOZZR.js +35 -0
  443. package/dist/bundle/chunks/chunk-HWKDQ44K.js +3 -0
  444. package/dist/bundle/chunks/chunk-I57KEIP3.js +10 -0
  445. package/dist/bundle/chunks/chunk-IPJHKYVM.js +1 -0
  446. package/dist/bundle/chunks/chunk-IVYA2HK4.js +286 -0
  447. package/dist/bundle/chunks/chunk-JVPRLUMK.js +7 -0
  448. package/dist/bundle/chunks/chunk-KMEYNNUA.js +15 -0
  449. package/dist/bundle/chunks/chunk-KX3P26DQ.js +1 -0
  450. package/dist/bundle/chunks/chunk-LL3S3NLB.js +1 -0
  451. package/dist/bundle/chunks/chunk-LTZRCH7N.js +31 -0
  452. package/dist/bundle/chunks/chunk-LWEGUNWT.js +7 -0
  453. package/dist/bundle/chunks/chunk-MDDMCKUK.js +6 -0
  454. package/dist/bundle/chunks/chunk-MDLLFABN.js +4 -0
  455. package/dist/bundle/chunks/chunk-MHTUABJP.js +8 -0
  456. package/dist/bundle/chunks/chunk-MIZPJHVH.js +7 -0
  457. package/dist/bundle/chunks/chunk-MLXIYONF.js +15 -0
  458. package/dist/bundle/chunks/chunk-MYE6AGBJ.js +16 -0
  459. package/dist/bundle/chunks/chunk-NAERJDUW.js +8 -0
  460. package/dist/bundle/chunks/chunk-NCNPKYJZ.js +2 -0
  461. package/dist/bundle/chunks/chunk-NUFRM6SI.js +0 -0
  462. package/dist/bundle/chunks/chunk-NUYSJFDK.js +7 -0
  463. package/dist/bundle/chunks/chunk-OCLXQMOG.js +6 -0
  464. package/dist/bundle/chunks/chunk-OCS6LSEM.js +13 -0
  465. package/dist/bundle/chunks/chunk-OJDRYQWQ.js +1 -0
  466. package/dist/bundle/chunks/chunk-P7UWRQ44.js +139 -0
  467. package/dist/bundle/chunks/chunk-PBXLG62G.js +8 -0
  468. package/dist/bundle/chunks/chunk-PP6PSHAB.js +4 -0
  469. package/dist/bundle/chunks/chunk-PXTK5WE2.js +20 -0
  470. package/dist/bundle/chunks/chunk-PYDZ2LCK.js +16 -0
  471. package/dist/bundle/chunks/chunk-PYSFUGCK.js +10 -0
  472. package/dist/bundle/chunks/chunk-QCDB2VPH.js +6 -0
  473. package/dist/bundle/chunks/chunk-QJ7O6ZN3.js +5 -0
  474. package/dist/bundle/chunks/chunk-R6QSAL5T.js +1 -0
  475. package/dist/bundle/chunks/chunk-R6VWJ2ZL.js +1 -0
  476. package/dist/bundle/chunks/chunk-RPNGRAAP.js +7 -0
  477. package/dist/bundle/chunks/chunk-SDNKECQQ.js +5 -0
  478. package/dist/bundle/chunks/chunk-T56QNPHK.js +14 -0
  479. package/dist/bundle/chunks/chunk-TLSUDHID.js +6 -0
  480. package/dist/bundle/chunks/chunk-TOMNU26N.js +4 -0
  481. package/dist/bundle/chunks/chunk-TXBZCHCQ.js +5 -0
  482. package/dist/bundle/chunks/chunk-U6NMAV24.js +32 -0
  483. package/dist/bundle/chunks/chunk-V7TAPXDL.js +27 -0
  484. package/dist/bundle/chunks/chunk-VBEY5J6R.js +99 -0
  485. package/dist/bundle/chunks/chunk-VJFXDYWH.js +10 -0
  486. package/dist/bundle/chunks/chunk-VOBGTVA6.js +6 -0
  487. package/dist/bundle/chunks/chunk-VXBA5RYO.js +5 -0
  488. package/dist/bundle/chunks/chunk-VYOJP4TV.js +13 -0
  489. package/dist/bundle/chunks/chunk-WKFATFPP.js +4 -0
  490. package/dist/bundle/chunks/chunk-X2AJGDEF.js +1 -0
  491. package/dist/bundle/chunks/chunk-XIZSGUXJ.js +62 -0
  492. package/dist/bundle/chunks/chunk-XKQRETAK.js +1 -0
  493. package/dist/bundle/chunks/chunk-XVDPCNWR.js +11 -0
  494. package/dist/bundle/chunks/chunk-YSHZL3MF.js +32 -0
  495. package/dist/bundle/chunks/chunk-YTNYSM6T.js +11 -0
  496. package/dist/bundle/chunks/chunk-Z6LRHWXI.js +13 -0
  497. package/dist/bundle/chunks/chunk-Z7JVV2SM.js +12 -0
  498. package/dist/bundle/chunks/clear-5CZ5X4YR.js +1 -0
  499. package/dist/bundle/chunks/column-WLPMMSTS.js +1 -0
  500. package/dist/bundle/chunks/comm-5SLSESQG.js +1 -0
  501. package/dist/bundle/chunks/cp-XOYR4ABJ.js +1 -0
  502. package/dist/bundle/chunks/curl-47BFPSFW.js +25 -0
  503. package/dist/bundle/chunks/cut-OPC3VAGB.js +1 -0
  504. package/dist/bundle/chunks/date-DD7FVA2V.js +1 -0
  505. package/dist/bundle/chunks/diff-HJF2MPDN.js +1 -0
  506. package/dist/bundle/chunks/dirname-LEMTZZFS.js +1 -0
  507. package/dist/bundle/chunks/du-WO2ENHXQ.js +1 -0
  508. package/dist/bundle/chunks/echo-O45JWWI2.js +1 -0
  509. package/dist/bundle/chunks/env-5EPCWSXR.js +1 -0
  510. package/dist/bundle/chunks/expand-DTNXU4LQ.js +1 -0
  511. package/dist/bundle/chunks/expansion-UGGADTZC.js +1 -0
  512. package/dist/bundle/chunks/expr-DNFUYZGY.js +1 -0
  513. package/dist/bundle/chunks/file-IGDTDPLG.js +1 -0
  514. package/dist/bundle/chunks/find-KNMMLVJD.js +1 -0
  515. package/dist/bundle/chunks/flag-coverage-B26Z36PC.js +1 -0
  516. package/dist/bundle/chunks/fold-LDSORVYE.js +1 -0
  517. package/dist/bundle/chunks/grep-2UMHPO7Y.js +1 -0
  518. package/dist/bundle/chunks/gzip-AQXSGOVS.js +1 -0
  519. package/dist/bundle/chunks/head-HT2B6D2J.js +1 -0
  520. package/dist/bundle/chunks/help-VVWX7SA5.js +1 -0
  521. package/dist/bundle/chunks/history-J4QRNGRO.js +1 -0
  522. package/dist/bundle/chunks/hostname-BK6HG2DE.js +1 -0
  523. package/dist/bundle/chunks/html-to-markdown-TFCECAGV.js +1 -0
  524. package/dist/bundle/chunks/join-GG2LDHE5.js +1 -0
  525. package/dist/bundle/chunks/jq-CRLZNLQG.js +1 -0
  526. package/dist/bundle/chunks/js-exec-VXN6TZ7U.js +96 -0
  527. package/dist/bundle/chunks/js-exec-worker.js +4380 -0
  528. package/dist/bundle/chunks/ln-4TRFBYAT.js +1 -0
  529. package/dist/bundle/chunks/ls-KSXFZCWH.js +1 -0
  530. package/dist/bundle/chunks/md5sum-INMIK4DX.js +1 -0
  531. package/dist/bundle/chunks/mkdir-TDEMSB6C.js +1 -0
  532. package/dist/bundle/chunks/mv-Z6MORUFL.js +1 -0
  533. package/dist/bundle/chunks/nl-U5YJDM32.js +1 -0
  534. package/dist/bundle/chunks/od-VJEF2UR5.js +1 -0
  535. package/dist/bundle/chunks/paste-7N6AFSDS.js +1 -0
  536. package/dist/bundle/chunks/printf-CX64KX2P.js +1 -0
  537. package/dist/bundle/chunks/pwd-D4OZ7N27.js +1 -0
  538. package/dist/bundle/chunks/python3-BFV3N3GY.js +11 -0
  539. package/dist/bundle/chunks/readlink-MI4GCHJF.js +1 -0
  540. package/dist/bundle/chunks/rev-XOSYPP45.js +1 -0
  541. package/dist/bundle/chunks/rg-KYSTAD4Q.js +1 -0
  542. package/dist/bundle/chunks/rm-RTZG23RL.js +1 -0
  543. package/dist/bundle/chunks/rmdir-XTQXT7RK.js +1 -0
  544. package/dist/bundle/chunks/sed-OFX3F4FE.js +1 -0
  545. package/dist/bundle/chunks/seq-RN5ZUASB.js +1 -0
  546. package/dist/bundle/chunks/sha1sum-VJPNLNU6.js +1 -0
  547. package/dist/bundle/chunks/sha256sum-PI32XWXY.js +1 -0
  548. package/dist/bundle/chunks/sleep-VZFPZFWA.js +1 -0
  549. package/dist/bundle/chunks/sort-DCNRDA7U.js +1 -0
  550. package/dist/bundle/chunks/split-SITCSYCZ.js +1 -0
  551. package/dist/bundle/chunks/sqlite3-56UMWEY3.js +1 -0
  552. package/dist/bundle/chunks/stat-BT5A227F.js +1 -0
  553. package/dist/bundle/chunks/strings-7PLOGTPD.js +1 -0
  554. package/dist/bundle/chunks/tac-SJGXQ4T2.js +1 -0
  555. package/dist/bundle/chunks/tail-S5ULNTJU.js +1 -0
  556. package/dist/bundle/chunks/tar-LYLTEJV3.js +1 -0
  557. package/dist/bundle/chunks/tee-O7VXZDCO.js +1 -0
  558. package/dist/bundle/chunks/time-DEUO3QV2.js +1 -0
  559. package/dist/bundle/chunks/timeout-VRKMCG72.js +1 -0
  560. package/dist/bundle/chunks/touch-DX2IJOQ4.js +1 -0
  561. package/dist/bundle/chunks/tr-2HXZRDSW.js +1 -0
  562. package/dist/bundle/chunks/tree-LYXBS7DC.js +1 -0
  563. package/dist/bundle/chunks/true-WHJNXCHG.js +1 -0
  564. package/dist/bundle/chunks/unexpand-RGTMIGZM.js +1 -0
  565. package/dist/bundle/chunks/uniq-SUNANL47.js +1 -0
  566. package/dist/bundle/chunks/wc-TQB3VNOX.js +1 -0
  567. package/dist/bundle/chunks/which-XZHEH76L.js +1 -0
  568. package/dist/bundle/chunks/whoami-DGKU3D2X.js +1 -0
  569. package/dist/bundle/chunks/worker.js +3136 -0
  570. package/dist/bundle/chunks/xan-DHUKCGIW.js +1 -0
  571. package/dist/bundle/chunks/xan-view-OW2TB7Z3.js +1 -0
  572. package/dist/bundle/chunks/xargs-I6EZUCYF.js +1 -0
  573. package/dist/bundle/chunks/yq-NDDDSAXH.js +1 -0
  574. package/dist/bundle/index.cjs +2178 -0
  575. package/dist/bundle/index.js +709 -0
  576. package/dist/commands/alias/alias.d.ts +6 -0
  577. package/dist/commands/awk/ast.d.ts +202 -0
  578. package/dist/commands/awk/awk2.d.ts +9 -0
  579. package/dist/commands/awk/builtins.d.ts +17 -0
  580. package/dist/commands/awk/interpreter/context.d.ts +75 -0
  581. package/dist/commands/awk/interpreter/expressions.d.ts +17 -0
  582. package/dist/commands/awk/interpreter/fields.d.ts +25 -0
  583. package/dist/commands/awk/interpreter/index.d.ts +8 -0
  584. package/dist/commands/awk/interpreter/interpreter.d.ts +54 -0
  585. package/dist/commands/awk/interpreter/statements.d.ts +11 -0
  586. package/dist/commands/awk/interpreter/type-coercion.d.ts +32 -0
  587. package/dist/commands/awk/interpreter/types.d.ts +13 -0
  588. package/dist/commands/awk/interpreter/variables.d.ts +35 -0
  589. package/dist/commands/awk/lexer.d.ts +100 -0
  590. package/dist/commands/awk/parser2-print.d.ts +35 -0
  591. package/dist/commands/awk/parser2.d.ts +81 -0
  592. package/dist/commands/base64/base64.d.ts +7 -0
  593. package/dist/commands/basename/basename.d.ts +4 -0
  594. package/dist/commands/bash/bash.d.ts +6 -0
  595. package/dist/commands/browser-excluded.d.ts +16 -0
  596. package/dist/commands/cat/cat.d.ts +4 -0
  597. package/dist/commands/chmod/chmod.d.ts +4 -0
  598. package/dist/commands/clear/clear.d.ts +4 -0
  599. package/dist/commands/column/column.d.ts +11 -0
  600. package/dist/commands/comm/comm.d.ts +12 -0
  601. package/dist/commands/cp/cp.d.ts +4 -0
  602. package/dist/commands/curl/curl.d.ts +8 -0
  603. package/dist/commands/curl/form.d.ts +21 -0
  604. package/dist/commands/curl/help.d.ts +9 -0
  605. package/dist/commands/curl/parse.d.ts +9 -0
  606. package/dist/commands/curl/response-formatting.d.ts +20 -0
  607. package/dist/commands/curl/types.d.ts +31 -0
  608. package/dist/commands/cut/cut.d.ts +4 -0
  609. package/dist/commands/date/date.d.ts +7 -0
  610. package/dist/commands/diff/diff.d.ts +7 -0
  611. package/dist/commands/dirname/dirname.d.ts +4 -0
  612. package/dist/commands/du/du.d.ts +4 -0
  613. package/dist/commands/duration.d.ts +5 -0
  614. package/dist/commands/echo/echo.d.ts +4 -0
  615. package/dist/commands/env/env.d.ts +6 -0
  616. package/dist/commands/expand/expand.d.ts +12 -0
  617. package/dist/commands/expand/unexpand.d.ts +12 -0
  618. package/dist/commands/expr/expr.d.ts +9 -0
  619. package/dist/commands/file/file.d.ts +9 -0
  620. package/dist/commands/find/find.d.ts +4 -0
  621. package/dist/commands/find/matcher.d.ts +69 -0
  622. package/dist/commands/find/parser.d.ts +2 -0
  623. package/dist/commands/find/types.d.ts +88 -0
  624. package/dist/commands/flag-coverage.d.ts +2 -0
  625. package/dist/commands/fold/fold.d.ts +12 -0
  626. package/dist/commands/format-mode.d.ts +4 -0
  627. package/dist/commands/fuzz-flags-types.d.ts +17 -0
  628. package/dist/commands/fuzz-flags.d.ts +8 -0
  629. package/dist/commands/grep/grep.d.ts +8 -0
  630. package/dist/commands/gzip/gzip.d.ts +13 -0
  631. package/dist/commands/head/head-tail-shared.d.ts +38 -0
  632. package/dist/commands/head/head.d.ts +4 -0
  633. package/dist/commands/help/help.d.ts +4 -0
  634. package/dist/commands/help.d.ts +16 -0
  635. package/dist/commands/history/history.d.ts +4 -0
  636. package/dist/commands/hostname/hostname.d.ts +11 -0
  637. package/dist/commands/html-to-markdown/html-to-markdown.d.ts +9 -0
  638. package/dist/commands/join/join.d.ts +12 -0
  639. package/dist/commands/jq/jq.d.ts +9 -0
  640. package/dist/commands/js-exec/fetch-polyfill.d.ts +6 -0
  641. package/dist/commands/js-exec/js-exec-worker.d.ts +30 -0
  642. package/dist/commands/js-exec/js-exec.d.ts +11 -0
  643. package/dist/commands/js-exec/module-shims.d.ts +29 -0
  644. package/dist/commands/js-exec/path-polyfill.d.ts +6 -0
  645. package/dist/commands/ln/ln.d.ts +4 -0
  646. package/dist/commands/ls/ls.d.ts +4 -0
  647. package/dist/commands/md5sum/checksum.d.ts +7 -0
  648. package/dist/commands/md5sum/md5sum.d.ts +4 -0
  649. package/dist/commands/md5sum/sha1sum.d.ts +4 -0
  650. package/dist/commands/md5sum/sha256sum.d.ts +4 -0
  651. package/dist/commands/mkdir/mkdir.d.ts +4 -0
  652. package/dist/commands/mv/mv.d.ts +4 -0
  653. package/dist/commands/nl/nl.d.ts +12 -0
  654. package/dist/commands/od/od.d.ts +12 -0
  655. package/dist/commands/paste/paste.d.ts +4 -0
  656. package/dist/commands/printf/escapes.d.ts +25 -0
  657. package/dist/commands/printf/printf.d.ts +4 -0
  658. package/dist/commands/printf/strftime.d.ts +9 -0
  659. package/dist/commands/pwd/pwd.d.ts +4 -0
  660. package/dist/commands/python3/python3.d.ts +16 -0
  661. package/dist/commands/python3/worker.d.ts +28 -0
  662. package/dist/commands/query-engine/builtins/array-builtins.d.ts +20 -0
  663. package/dist/commands/query-engine/builtins/control-builtins.d.ts +18 -0
  664. package/dist/commands/query-engine/builtins/date-builtins.d.ts +15 -0
  665. package/dist/commands/query-engine/builtins/format-builtins.d.ts +11 -0
  666. package/dist/commands/query-engine/builtins/index-builtins.d.ts +16 -0
  667. package/dist/commands/query-engine/builtins/index.d.ts +17 -0
  668. package/dist/commands/query-engine/builtins/math-builtins.d.ts +15 -0
  669. package/dist/commands/query-engine/builtins/navigation-builtins.d.ts +18 -0
  670. package/dist/commands/query-engine/builtins/object-builtins.d.ts +15 -0
  671. package/dist/commands/query-engine/builtins/path-builtins.d.ts +20 -0
  672. package/dist/commands/query-engine/builtins/sql-builtins.d.ts +16 -0
  673. package/dist/commands/query-engine/builtins/string-builtins.d.ts +15 -0
  674. package/dist/commands/query-engine/builtins/type-builtins.d.ts +11 -0
  675. package/dist/commands/query-engine/evaluator.d.ts +41 -0
  676. package/dist/commands/query-engine/index.d.ts +8 -0
  677. package/dist/commands/query-engine/parser-types.d.ts +171 -0
  678. package/dist/commands/query-engine/parser.d.ts +9 -0
  679. package/dist/commands/query-engine/path-operations.d.ts +15 -0
  680. package/dist/commands/query-engine/safe-object.d.ts +83 -0
  681. package/dist/commands/query-engine/value-operations.d.ts +41 -0
  682. package/dist/commands/readlink/readlink.d.ts +4 -0
  683. package/dist/commands/registry.d.ts +56 -0
  684. package/dist/commands/rev/rev.d.ts +13 -0
  685. package/dist/commands/rg/file-types.d.ts +49 -0
  686. package/dist/commands/rg/gitignore.d.ts +98 -0
  687. package/dist/commands/rg/rg-options.d.ts +61 -0
  688. package/dist/commands/rg/rg-parser.d.ts +20 -0
  689. package/dist/commands/rg/rg-search.d.ts +15 -0
  690. package/dist/commands/rg/rg.d.ts +14 -0
  691. package/dist/commands/rm/rm.d.ts +4 -0
  692. package/dist/commands/rmdir/rmdir.d.ts +4 -0
  693. package/dist/commands/search-engine/index.d.ts +10 -0
  694. package/dist/commands/search-engine/matcher.d.ts +60 -0
  695. package/dist/commands/search-engine/regex.d.ts +33 -0
  696. package/dist/commands/sed/executor.d.ts +7 -0
  697. package/dist/commands/sed/lexer.d.ts +86 -0
  698. package/dist/commands/sed/parser.d.ts +18 -0
  699. package/dist/commands/sed/sed-regex.d.ts +23 -0
  700. package/dist/commands/sed/sed.d.ts +4 -0
  701. package/dist/commands/sed/types.d.ts +216 -0
  702. package/dist/commands/seq/seq.d.ts +16 -0
  703. package/dist/commands/sleep/sleep.d.ts +4 -0
  704. package/dist/commands/sort/comparator.d.ts +9 -0
  705. package/dist/commands/sort/parser.d.ts +11 -0
  706. package/dist/commands/sort/sort.d.ts +4 -0
  707. package/dist/commands/sort/types.d.ts +30 -0
  708. package/dist/commands/split/split.d.ts +12 -0
  709. package/dist/commands/sqlite3/formatters.d.ts +15 -0
  710. package/dist/commands/sqlite3/sqlite3.d.ts +22 -0
  711. package/dist/commands/sqlite3/worker.d.ts +45 -0
  712. package/dist/commands/stat/stat.d.ts +4 -0
  713. package/dist/commands/strings/strings.d.ts +12 -0
  714. package/dist/commands/tac/tac.d.ts +11 -0
  715. package/dist/commands/tail/tail.d.ts +4 -0
  716. package/dist/commands/tar/archive.d.ts +135 -0
  717. package/dist/commands/tar/bzip2-compress.d.ts +17 -0
  718. package/dist/commands/tar/tar-options.d.ts +37 -0
  719. package/dist/commands/tar/tar.d.ts +10 -0
  720. package/dist/commands/tee/tee.d.ts +4 -0
  721. package/dist/commands/time/time.d.ts +27 -0
  722. package/dist/commands/timeout/timeout.d.ts +4 -0
  723. package/dist/commands/touch/touch.d.ts +4 -0
  724. package/dist/commands/tr/tr.d.ts +4 -0
  725. package/dist/commands/tree/tree.d.ts +4 -0
  726. package/dist/commands/true/true.d.ts +6 -0
  727. package/dist/commands/uniq/uniq.d.ts +4 -0
  728. package/dist/commands/wc/wc.d.ts +4 -0
  729. package/dist/commands/which/which.d.ts +4 -0
  730. package/dist/commands/whoami/whoami.d.ts +11 -0
  731. package/dist/commands/worker-bridge/bridge-handler.d.ts +71 -0
  732. package/dist/commands/worker-bridge/protocol.d.ts +140 -0
  733. package/dist/commands/worker-bridge/sync-backend.d.ts +81 -0
  734. package/dist/commands/xan/aggregation.d.ts +20 -0
  735. package/dist/commands/xan/column-selection.d.ts +19 -0
  736. package/dist/commands/xan/csv.d.ts +37 -0
  737. package/dist/commands/xan/moonblade-parser.d.ts +80 -0
  738. package/dist/commands/xan/moonblade-to-jq.d.ts +12 -0
  739. package/dist/commands/xan/moonblade-tokenizer.d.ts +25 -0
  740. package/dist/commands/xan/subcommands.d.ts +15 -0
  741. package/dist/commands/xan/xan-agg.d.ts +8 -0
  742. package/dist/commands/xan/xan-columns.d.ts +8 -0
  743. package/dist/commands/xan/xan-core.d.ts +10 -0
  744. package/dist/commands/xan/xan-data.d.ts +52 -0
  745. package/dist/commands/xan/xan-filter.d.ts +8 -0
  746. package/dist/commands/xan/xan-map.d.ts +11 -0
  747. package/dist/commands/xan/xan-reshape.d.ts +40 -0
  748. package/dist/commands/xan/xan-simple.d.ts +40 -0
  749. package/dist/commands/xan/xan-view.d.ts +12 -0
  750. package/dist/commands/xan/xan.d.ts +10 -0
  751. package/dist/commands/xargs/xargs.d.ts +4 -0
  752. package/dist/commands/yq/formats.d.ts +64 -0
  753. package/dist/commands/yq/yq.d.ts +13 -0
  754. package/dist/custom-commands.d.ts +42 -0
  755. package/dist/fs/encoding.d.ts +17 -0
  756. package/dist/fs/in-memory-fs/in-memory-fs.d.ts +73 -0
  757. package/dist/fs/in-memory-fs/index.d.ts +1 -0
  758. package/dist/fs/init.d.ts +22 -0
  759. package/dist/fs/interface.d.ts +229 -0
  760. package/dist/fs/mountable-fs/index.d.ts +1 -0
  761. package/dist/fs/mountable-fs/mountable-fs.d.ts +116 -0
  762. package/dist/fs/overlay-fs/index.d.ts +1 -0
  763. package/dist/fs/overlay-fs/overlay-fs.d.ts +163 -0
  764. package/dist/fs/path-utils.d.ts +46 -0
  765. package/dist/fs/read-write-fs/index.d.ts +1 -0
  766. package/dist/fs/read-write-fs/read-write-fs.d.ts +96 -0
  767. package/dist/fs/real-fs-utils.d.ts +90 -0
  768. package/dist/fs/sanitize-error.d.ts +19 -0
  769. package/dist/index.d.cts +27 -0
  770. package/dist/index.d.ts +27 -0
  771. package/dist/interpreter/alias-expansion.d.ts +23 -0
  772. package/dist/interpreter/arithmetic.d.ts +24 -0
  773. package/dist/interpreter/assignment-expansion.d.ts +24 -0
  774. package/dist/interpreter/builtin-dispatch.d.ts +39 -0
  775. package/dist/interpreter/builtins/break.d.ts +6 -0
  776. package/dist/interpreter/builtins/cd.d.ts +6 -0
  777. package/dist/interpreter/builtins/compgen.d.ts +26 -0
  778. package/dist/interpreter/builtins/complete.d.ts +17 -0
  779. package/dist/interpreter/builtins/compopt.d.ts +28 -0
  780. package/dist/interpreter/builtins/continue.d.ts +6 -0
  781. package/dist/interpreter/builtins/declare-array-parsing.d.ts +14 -0
  782. package/dist/interpreter/builtins/declare-print.d.ts +39 -0
  783. package/dist/interpreter/builtins/declare.d.ts +35 -0
  784. package/dist/interpreter/builtins/dirs.d.ts +29 -0
  785. package/dist/interpreter/builtins/eval.d.ts +9 -0
  786. package/dist/interpreter/builtins/exit.d.ts +5 -0
  787. package/dist/interpreter/builtins/export.d.ts +14 -0
  788. package/dist/interpreter/builtins/getopts.d.ts +18 -0
  789. package/dist/interpreter/builtins/hash.d.ts +19 -0
  790. package/dist/interpreter/builtins/help.d.ts +12 -0
  791. package/dist/interpreter/builtins/index.d.ts +45 -0
  792. package/dist/interpreter/builtins/let.d.ts +18 -0
  793. package/dist/interpreter/builtins/local.d.ts +6 -0
  794. package/dist/interpreter/builtins/mapfile.d.ts +17 -0
  795. package/dist/interpreter/builtins/read.d.ts +6 -0
  796. package/dist/interpreter/builtins/return.d.ts +6 -0
  797. package/dist/interpreter/builtins/set.d.ts +9 -0
  798. package/dist/interpreter/builtins/shift.d.ts +15 -0
  799. package/dist/interpreter/builtins/shopt.d.ts +7 -0
  800. package/dist/interpreter/builtins/source.d.ts +6 -0
  801. package/dist/interpreter/builtins/unset.d.ts +16 -0
  802. package/dist/interpreter/builtins/variable-assignment.d.ts +66 -0
  803. package/dist/interpreter/command-resolution.d.ts +43 -0
  804. package/dist/interpreter/conditionals.d.ts +17 -0
  805. package/dist/interpreter/control-flow.d.ts +21 -0
  806. package/dist/interpreter/defense-aware-command-context.d.ts +6 -0
  807. package/dist/interpreter/errors.d.ts +158 -0
  808. package/dist/interpreter/expansion/analysis.d.ts +37 -0
  809. package/dist/interpreter/expansion/arith-text-expansion.d.ts +20 -0
  810. package/dist/interpreter/expansion/array-pattern-ops.d.ts +21 -0
  811. package/dist/interpreter/expansion/array-prefix-suffix.d.ts +46 -0
  812. package/dist/interpreter/expansion/array-slice-transform.d.ts +36 -0
  813. package/dist/interpreter/expansion/array-word-expansion.d.ts +39 -0
  814. package/dist/interpreter/expansion/brace-range.d.ts +20 -0
  815. package/dist/interpreter/expansion/command-substitution.d.ts +23 -0
  816. package/dist/interpreter/expansion/glob-escape.d.ts +32 -0
  817. package/dist/interpreter/expansion/indirect-expansion.d.ts +42 -0
  818. package/dist/interpreter/expansion/parameter-ops.d.ts +113 -0
  819. package/dist/interpreter/expansion/pattern-expansion.d.ts +23 -0
  820. package/dist/interpreter/expansion/pattern-removal.d.ts +18 -0
  821. package/dist/interpreter/expansion/pattern.d.ts +23 -0
  822. package/dist/interpreter/expansion/positional-params.d.ts +59 -0
  823. package/dist/interpreter/expansion/prompt.d.ts +39 -0
  824. package/dist/interpreter/expansion/quoting.d.ts +13 -0
  825. package/dist/interpreter/expansion/tilde.d.ts +12 -0
  826. package/dist/interpreter/expansion/unquoted-expansion.d.ts +76 -0
  827. package/dist/interpreter/expansion/variable-attrs.d.ts +19 -0
  828. package/dist/interpreter/expansion/variable.d.ts +36 -0
  829. package/dist/interpreter/expansion/word-glob-expansion.d.ts +33 -0
  830. package/dist/interpreter/expansion/word-split.d.ts +29 -0
  831. package/dist/interpreter/expansion.d.ts +53 -0
  832. package/dist/interpreter/functions.d.ts +12 -0
  833. package/dist/interpreter/helpers/array.d.ts +43 -0
  834. package/dist/interpreter/helpers/condition.d.ts +22 -0
  835. package/dist/interpreter/helpers/errors.d.ts +8 -0
  836. package/dist/interpreter/helpers/file-tests.d.ts +33 -0
  837. package/dist/interpreter/helpers/ifs.d.ts +104 -0
  838. package/dist/interpreter/helpers/loop.d.ts +24 -0
  839. package/dist/interpreter/helpers/nameref.d.ts +65 -0
  840. package/dist/interpreter/helpers/numeric-compare.d.ts +13 -0
  841. package/dist/interpreter/helpers/quoting.d.ts +24 -0
  842. package/dist/interpreter/helpers/readonly.d.ts +45 -0
  843. package/dist/interpreter/helpers/regex.d.ts +8 -0
  844. package/dist/interpreter/helpers/result.d.ts +60 -0
  845. package/dist/interpreter/helpers/shell-constants.d.ts +25 -0
  846. package/dist/interpreter/helpers/shellopts.d.ts +28 -0
  847. package/dist/interpreter/helpers/statements.d.ts +20 -0
  848. package/dist/interpreter/helpers/string-compare.d.ts +24 -0
  849. package/dist/interpreter/helpers/string-tests.d.ts +13 -0
  850. package/dist/interpreter/helpers/tilde.d.ts +13 -0
  851. package/dist/interpreter/helpers/variable-tests.d.ts +9 -0
  852. package/dist/interpreter/helpers/word-matching.d.ts +26 -0
  853. package/dist/interpreter/helpers/word-parts.d.ts +22 -0
  854. package/dist/interpreter/helpers/xtrace.d.ts +18 -0
  855. package/dist/interpreter/index.d.ts +3 -0
  856. package/dist/interpreter/interpreter.d.ts +77 -0
  857. package/dist/interpreter/pipeline-execution.d.ts +16 -0
  858. package/dist/interpreter/redirections.d.ts +51 -0
  859. package/dist/interpreter/simple-command-assignments.d.ts +29 -0
  860. package/dist/interpreter/subshell-group.d.ts +32 -0
  861. package/dist/interpreter/type-command.d.ts +37 -0
  862. package/dist/interpreter/types.d.ts +344 -0
  863. package/dist/limits.d.ts +52 -0
  864. package/dist/network/allow-list/shared.d.ts +57 -0
  865. package/dist/network/allow-list.d.ts +59 -0
  866. package/dist/network/fetch.d.ts +25 -0
  867. package/dist/network/index.d.ts +7 -0
  868. package/dist/network/types.d.ts +155 -0
  869. package/dist/parser/arithmetic-parser.d.ts +23 -0
  870. package/dist/parser/arithmetic-primaries.d.ts +45 -0
  871. package/dist/parser/command-parser.d.ts +10 -0
  872. package/dist/parser/compound-parser.d.ts +28 -0
  873. package/dist/parser/conditional-parser.d.ts +8 -0
  874. package/dist/parser/expansion-parser.d.ts +16 -0
  875. package/dist/parser/lexer.d.ts +197 -0
  876. package/dist/parser/parser-substitution.d.ts +62 -0
  877. package/dist/parser/parser.d.ts +135 -0
  878. package/dist/parser/types.d.ts +25 -0
  879. package/dist/parser/word-parser.d.ts +33 -0
  880. package/dist/sandbox/Command.d.ts +35 -0
  881. package/dist/sandbox/Sandbox.d.ts +90 -0
  882. package/dist/sandbox/index.d.ts +2 -0
  883. package/dist/shell-metadata.d.ts +25 -0
  884. package/dist/timers.d.ts +4 -0
  885. package/dist/types.d.ts +198 -0
  886. package/dist/utils/args.d.ts +55 -0
  887. package/dist/utils/constants.d.ts +15 -0
  888. package/dist/utils/file-reader.d.ts +67 -0
  889. package/dist/utils/glob.d.ts +25 -0
  890. package/dist/vitest-setup.d.ts +1 -0
  891. package/package.json +127 -0
  892. package/vendor/cpython-emscripten/python.cjs +2 -0
  893. package/vendor/cpython-emscripten/python.wasm +3 -0
  894. package/vendor/cpython-emscripten/python313.zip +0 -0
@@ -0,0 +1,3136 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ // src/commands/python3/worker.ts
9
+ import { createRequire } from "node:module";
10
+ import { dirname } from "node:path";
11
+ import { parentPort, workerData } from "node:worker_threads";
12
+
13
+ // src/fs/sanitize-error.ts
14
+ function sanitizeWithUnixPrefixes(message, includeHostRuntimePrefixes, includeFileUrls) {
15
+ if (!message) return message;
16
+ let sanitized = message.replace(/\n\s+at\s.*/g, "");
17
+ if (includeFileUrls) {
18
+ sanitized = sanitized.replace(/\bfile:\/\/\/?[^\s'",)}\]:]+/g, "<path>");
19
+ }
20
+ sanitized = sanitized.replace(
21
+ includeHostRuntimePrefixes ? /(?:\/(?:Users|home|private|var|opt|Library|System|usr|etc|tmp|nix|snap|workspace|root|srv|mnt|app))\b[^\s'",)}\]:]*/g : /(?:\/(?:Users|home|private|var|opt|Library|System|usr|etc|tmp|nix|snap))\b[^\s'",)}\]:]*/g,
22
+ "<path>"
23
+ );
24
+ sanitized = sanitized.replace(/node:internal\/[^\s'",)}\]:]+/g, "<internal>");
25
+ sanitized = sanitized.replace(/[A-Z]:\\[^\s'",)}\]:]+/g, "<path>");
26
+ if (includeFileUrls) {
27
+ sanitized = sanitized.replace(/\\\\[^\s\\]+\\[^\s'",)}\]:]+/g, "<path>");
28
+ }
29
+ return sanitized;
30
+ }
31
+ function sanitizeErrorMessage(message) {
32
+ return sanitizeWithUnixPrefixes(message, false, false);
33
+ }
34
+ function sanitizeHostErrorMessage(message) {
35
+ return sanitizeWithUnixPrefixes(message, true, true);
36
+ }
37
+
38
+ // src/security/blocked-globals.ts
39
+ function getBlockedGlobals() {
40
+ const globals = [
41
+ // Direct code execution vectors
42
+ {
43
+ prop: "Function",
44
+ target: globalThis,
45
+ violationType: "function_constructor",
46
+ strategy: "throw",
47
+ reason: "Function constructor allows arbitrary code execution"
48
+ },
49
+ {
50
+ prop: "eval",
51
+ target: globalThis,
52
+ violationType: "eval",
53
+ strategy: "throw",
54
+ reason: "eval() allows arbitrary code execution"
55
+ },
56
+ // Timer functions with string argument allow code execution
57
+ {
58
+ prop: "setTimeout",
59
+ target: globalThis,
60
+ violationType: "setTimeout",
61
+ strategy: "throw",
62
+ reason: "setTimeout with string argument allows code execution"
63
+ },
64
+ {
65
+ prop: "setInterval",
66
+ target: globalThis,
67
+ violationType: "setInterval",
68
+ strategy: "throw",
69
+ reason: "setInterval with string argument allows code execution"
70
+ },
71
+ {
72
+ prop: "setImmediate",
73
+ target: globalThis,
74
+ violationType: "setImmediate",
75
+ strategy: "throw",
76
+ reason: "setImmediate could be used to escape sandbox context"
77
+ },
78
+ // Note: We intentionally do NOT block `process` entirely because:
79
+ // 1. Node.js internals (Promise resolution, etc.) use process.nextTick
80
+ // 2. Blocking process entirely breaks normal async operation
81
+ // 3. The primary code execution vectors (Function, eval) are already blocked
82
+ // However, we DO block specific dangerous process properties.
83
+ {
84
+ prop: "env",
85
+ target: process,
86
+ violationType: "process_env",
87
+ strategy: "throw",
88
+ reason: "process.env could leak sensitive environment variables",
89
+ // Node.js internals and bundled dependencies read these env vars
90
+ // during module loading, file watching, and I/O within the
91
+ // AsyncLocalStorage context. None are user secrets.
92
+ allowedKeys: /* @__PURE__ */ new Set([
93
+ // Node.js core
94
+ "NODE_V8_COVERAGE",
95
+ "NODE_DEBUG",
96
+ "NODE_DEBUG_NATIVE",
97
+ "NODE_COMPILE_CACHE",
98
+ "WATCH_REPORT_DEPENDENCIES",
99
+ // Dependencies
100
+ "FORCE_COLOR",
101
+ // chalk/supports-color
102
+ "DEBUG",
103
+ // debug package
104
+ "UNDICI_NO_FG",
105
+ // undici (Node.js fetch)
106
+ "JEST_WORKER_ID",
107
+ // jest/vitest worker detection
108
+ "__MINIMATCH_TESTING_PLATFORM__",
109
+ // minimatch
110
+ "LOG_TOKENS",
111
+ // query engine debug logging
112
+ "LOG_STREAM"
113
+ // query engine debug logging
114
+ ])
115
+ },
116
+ {
117
+ prop: "binding",
118
+ target: process,
119
+ violationType: "process_binding",
120
+ strategy: "throw",
121
+ reason: "process.binding provides access to native Node.js modules"
122
+ },
123
+ {
124
+ prop: "_linkedBinding",
125
+ target: process,
126
+ violationType: "process_binding",
127
+ strategy: "throw",
128
+ reason: "process._linkedBinding provides access to native Node.js modules"
129
+ },
130
+ {
131
+ prop: "dlopen",
132
+ target: process,
133
+ violationType: "process_dlopen",
134
+ strategy: "throw",
135
+ reason: "process.dlopen allows loading native addons"
136
+ },
137
+ {
138
+ prop: "getBuiltinModule",
139
+ target: process,
140
+ violationType: "process_get_builtin_module",
141
+ strategy: "throw",
142
+ reason: "process.getBuiltinModule allows loading native Node.js modules (fs, child_process, vm)"
143
+ },
144
+ // Note: process.mainModule is handled specially in defense-in-depth-box.ts
145
+ // and worker-defense-in-depth.ts because it may be undefined in ESM contexts
146
+ // but we still want to block both reading and setting it.
147
+ // Process control vectors
148
+ {
149
+ prop: "exit",
150
+ target: process,
151
+ violationType: "process_exit",
152
+ strategy: "throw",
153
+ reason: "process.exit could terminate the interpreter"
154
+ },
155
+ {
156
+ prop: "abort",
157
+ target: process,
158
+ violationType: "process_exit",
159
+ strategy: "throw",
160
+ reason: "process.abort could crash the interpreter"
161
+ },
162
+ {
163
+ prop: "kill",
164
+ target: process,
165
+ violationType: "process_kill",
166
+ strategy: "throw",
167
+ reason: "process.kill could signal other processes"
168
+ },
169
+ // Privilege escalation vectors
170
+ {
171
+ prop: "setuid",
172
+ target: process,
173
+ violationType: "process_setuid",
174
+ strategy: "throw",
175
+ reason: "process.setuid could escalate privileges"
176
+ },
177
+ {
178
+ prop: "setgid",
179
+ target: process,
180
+ violationType: "process_setuid",
181
+ strategy: "throw",
182
+ reason: "process.setgid could escalate privileges"
183
+ },
184
+ {
185
+ prop: "seteuid",
186
+ target: process,
187
+ violationType: "process_setuid",
188
+ strategy: "throw",
189
+ reason: "process.seteuid could escalate effective user privileges"
190
+ },
191
+ {
192
+ prop: "setegid",
193
+ target: process,
194
+ violationType: "process_setuid",
195
+ strategy: "throw",
196
+ reason: "process.setegid could escalate effective group privileges"
197
+ },
198
+ {
199
+ prop: "initgroups",
200
+ target: process,
201
+ violationType: "process_setuid",
202
+ strategy: "throw",
203
+ reason: "process.initgroups could modify supplementary group IDs"
204
+ },
205
+ {
206
+ prop: "setgroups",
207
+ target: process,
208
+ violationType: "process_setuid",
209
+ strategy: "throw",
210
+ reason: "process.setgroups could modify supplementary group IDs"
211
+ },
212
+ // File permission manipulation
213
+ {
214
+ prop: "umask",
215
+ target: process,
216
+ violationType: "process_umask",
217
+ strategy: "throw",
218
+ reason: "process.umask could modify file creation permissions"
219
+ },
220
+ // Information disclosure vectors
221
+ // Note: process.argv is an array (object) so gets an object proxy
222
+ {
223
+ prop: "argv",
224
+ target: process,
225
+ violationType: "process_argv",
226
+ strategy: "throw",
227
+ reason: "process.argv may contain secrets in CLI arguments"
228
+ },
229
+ // Note: process.execPath is a string primitive, handled specially
230
+ // in defense-in-depth-box.ts and worker-defense-in-depth.ts
231
+ // Note: process.connected is a boolean primitive, handled specially
232
+ // in defense-in-depth-box.ts and worker-defense-in-depth.ts
233
+ // Working directory access/manipulation
234
+ {
235
+ prop: "cwd",
236
+ target: process,
237
+ violationType: "process_chdir",
238
+ strategy: "throw",
239
+ reason: "process.cwd could disclose real host working directory path"
240
+ },
241
+ {
242
+ prop: "chdir",
243
+ target: process,
244
+ violationType: "process_chdir",
245
+ strategy: "throw",
246
+ reason: "process.chdir could confuse the interpreter's CWD tracking"
247
+ },
248
+ // Diagnostic report (leaks full environment, host paths, system info)
249
+ {
250
+ prop: "report",
251
+ target: process,
252
+ violationType: "process_report",
253
+ strategy: "throw",
254
+ reason: "process.report could disclose full environment, host paths, and system info"
255
+ },
256
+ // Environment file loading (Node 21.7+)
257
+ {
258
+ prop: "loadEnvFile",
259
+ target: process,
260
+ violationType: "process_env",
261
+ strategy: "throw",
262
+ reason: "process.loadEnvFile could load env files bypassing env proxy"
263
+ },
264
+ // Exception handler manipulation
265
+ {
266
+ prop: "setUncaughtExceptionCaptureCallback",
267
+ target: process,
268
+ violationType: "process_exception_handler",
269
+ strategy: "throw",
270
+ reason: "setUncaughtExceptionCaptureCallback could intercept security errors"
271
+ },
272
+ // IPC communication vectors (may be undefined in non-IPC contexts)
273
+ {
274
+ prop: "send",
275
+ target: process,
276
+ violationType: "process_send",
277
+ strategy: "throw",
278
+ reason: "process.send could communicate with parent process in IPC contexts"
279
+ },
280
+ {
281
+ prop: "channel",
282
+ target: process,
283
+ violationType: "process_channel",
284
+ strategy: "throw",
285
+ reason: "process.channel could access IPC channel to parent process"
286
+ },
287
+ // Timing side-channel vectors
288
+ {
289
+ prop: "cpuUsage",
290
+ target: process,
291
+ violationType: "process_timing",
292
+ strategy: "throw",
293
+ reason: "process.cpuUsage could enable timing side-channel attacks"
294
+ },
295
+ {
296
+ prop: "memoryUsage",
297
+ target: process,
298
+ violationType: "process_timing",
299
+ strategy: "throw",
300
+ reason: "process.memoryUsage could enable timing side-channel attacks"
301
+ },
302
+ {
303
+ prop: "hrtime",
304
+ target: process,
305
+ violationType: "process_timing",
306
+ strategy: "throw",
307
+ reason: "process.hrtime could enable timing side-channel attacks"
308
+ },
309
+ // We also don't block `require` because:
310
+ // 1. It may not exist in all environments (ESM)
311
+ // 2. import() is the modern escape vector and can't be blocked this way
312
+ // Reference leak vectors
313
+ {
314
+ prop: "WeakRef",
315
+ target: globalThis,
316
+ violationType: "weak_ref",
317
+ strategy: "throw",
318
+ reason: "WeakRef could be used to leak references outside sandbox"
319
+ },
320
+ {
321
+ prop: "FinalizationRegistry",
322
+ target: globalThis,
323
+ violationType: "finalization_registry",
324
+ strategy: "throw",
325
+ reason: "FinalizationRegistry could be used to leak references outside sandbox"
326
+ },
327
+ // Introspection/interception vectors (freeze instead of throw)
328
+ // SECURITY RATIONALE: Reflect is frozen (not blocked) because:
329
+ // 1. Defense infrastructure uses Reflect.apply/get/set/construct internally
330
+ // 2. Frozen Reflect cannot be mutated but remains fully functional
331
+ // 3. Reflect.construct(Function, ['code']) IS safe because globalThis.Function
332
+ // is replaced with a blocking proxy — Reflect.construct receives the proxy
333
+ // 4. Security depends on NEVER leaking original Function/eval references.
334
+ // If an unpatched Function ref leaked, Reflect.construct would bypass defense.
335
+ {
336
+ prop: "Reflect",
337
+ target: globalThis,
338
+ violationType: "reflect",
339
+ strategy: "freeze",
340
+ reason: "Reflect provides introspection capabilities"
341
+ },
342
+ {
343
+ prop: "Proxy",
344
+ target: globalThis,
345
+ violationType: "proxy",
346
+ strategy: "throw",
347
+ reason: "Proxy allows intercepting and modifying object behavior"
348
+ },
349
+ // WebAssembly allows arbitrary code execution
350
+ {
351
+ prop: "WebAssembly",
352
+ target: globalThis,
353
+ violationType: "webassembly",
354
+ strategy: "throw",
355
+ reason: "WebAssembly allows executing arbitrary compiled code"
356
+ },
357
+ // SharedArrayBuffer and Atomics can enable side-channel attacks
358
+ {
359
+ prop: "SharedArrayBuffer",
360
+ target: globalThis,
361
+ violationType: "shared_array_buffer",
362
+ strategy: "throw",
363
+ reason: "SharedArrayBuffer could enable side-channel communication or timing attacks"
364
+ },
365
+ {
366
+ prop: "Atomics",
367
+ target: globalThis,
368
+ violationType: "atomics",
369
+ strategy: "throw",
370
+ reason: "Atomics could enable side-channel communication or timing attacks"
371
+ },
372
+ // Note: Error.prepareStackTrace is handled specially in defense-in-depth-box.ts
373
+ // because we only want to block SETTING it, not reading (V8 reads it internally)
374
+ // Timing side-channel: performance.now() provides sub-millisecond resolution
375
+ // Note: Date.now() is intentionally NOT blocked — it's used for $SECONDS,
376
+ // date command, and has only ~1ms resolution (vs process.hrtime at ns).
377
+ {
378
+ prop: "performance",
379
+ target: globalThis,
380
+ violationType: "performance_timing",
381
+ strategy: "throw",
382
+ reason: "performance.now() provides sub-millisecond timing for side-channel attacks"
383
+ },
384
+ // Block direct access to process.stdout and process.stderr to prevent
385
+ // writing to the host's actual stdout/stderr, bypassing the interpreter's
386
+ // output accumulation.
387
+ {
388
+ prop: "stdout",
389
+ target: process,
390
+ violationType: "process_stdout",
391
+ strategy: "throw",
392
+ reason: "process.stdout could bypass interpreter output to write to host stdout"
393
+ },
394
+ {
395
+ prop: "stderr",
396
+ target: process,
397
+ violationType: "process_stderr",
398
+ strategy: "throw",
399
+ reason: "process.stderr could bypass interpreter output to write to host stderr"
400
+ },
401
+ // Prototype pollution vectors
402
+ {
403
+ prop: "__defineGetter__",
404
+ target: Object.prototype,
405
+ violationType: "prototype_mutation",
406
+ strategy: "throw",
407
+ reason: "__defineGetter__ allows prototype pollution via getter injection"
408
+ },
409
+ {
410
+ prop: "__defineSetter__",
411
+ target: Object.prototype,
412
+ violationType: "prototype_mutation",
413
+ strategy: "throw",
414
+ reason: "__defineSetter__ allows prototype pollution via setter injection"
415
+ },
416
+ {
417
+ prop: "__lookupGetter__",
418
+ target: Object.prototype,
419
+ violationType: "prototype_mutation",
420
+ strategy: "throw",
421
+ reason: "__lookupGetter__ enables introspection for prototype pollution attacks"
422
+ },
423
+ {
424
+ prop: "__lookupSetter__",
425
+ target: Object.prototype,
426
+ violationType: "prototype_mutation",
427
+ strategy: "throw",
428
+ reason: "__lookupSetter__ enables introspection for prototype pollution attacks"
429
+ },
430
+ // Freeze JSON and Math to prevent mutation of built-in utility objects
431
+ {
432
+ prop: "JSON",
433
+ target: globalThis,
434
+ violationType: "json_mutation",
435
+ strategy: "freeze",
436
+ reason: "Freeze JSON to prevent mutation of parsing/serialization"
437
+ },
438
+ {
439
+ prop: "Math",
440
+ target: globalThis,
441
+ violationType: "math_mutation",
442
+ strategy: "freeze",
443
+ reason: "Freeze Math to prevent mutation of math utilities"
444
+ }
445
+ ];
446
+ try {
447
+ const AsyncFunction = Object.getPrototypeOf(async () => {
448
+ }).constructor;
449
+ if (AsyncFunction && AsyncFunction !== Function) {
450
+ globals.push({
451
+ prop: "constructor",
452
+ target: Object.getPrototypeOf(async () => {
453
+ }),
454
+ violationType: "async_function_constructor",
455
+ strategy: "throw",
456
+ reason: "AsyncFunction constructor allows arbitrary async code execution"
457
+ });
458
+ }
459
+ } catch {
460
+ }
461
+ try {
462
+ const GeneratorFunction = Object.getPrototypeOf(
463
+ function* () {
464
+ }
465
+ ).constructor;
466
+ if (GeneratorFunction && GeneratorFunction !== Function) {
467
+ globals.push({
468
+ prop: "constructor",
469
+ target: Object.getPrototypeOf(function* () {
470
+ }),
471
+ violationType: "generator_function_constructor",
472
+ strategy: "throw",
473
+ reason: "GeneratorFunction constructor allows arbitrary generator code execution"
474
+ });
475
+ }
476
+ } catch {
477
+ }
478
+ try {
479
+ const AsyncGeneratorFunction = Object.getPrototypeOf(
480
+ async function* () {
481
+ }
482
+ ).constructor;
483
+ if (AsyncGeneratorFunction && AsyncGeneratorFunction !== Function && AsyncGeneratorFunction !== Object.getPrototypeOf(async () => {
484
+ }).constructor) {
485
+ globals.push({
486
+ prop: "constructor",
487
+ target: Object.getPrototypeOf(async function* () {
488
+ }),
489
+ violationType: "async_generator_function_constructor",
490
+ strategy: "throw",
491
+ reason: "AsyncGeneratorFunction constructor allows arbitrary async generator code execution"
492
+ });
493
+ }
494
+ } catch {
495
+ }
496
+ return globals.filter((g) => {
497
+ try {
498
+ return g.target[g.prop] !== void 0;
499
+ } catch {
500
+ return false;
501
+ }
502
+ });
503
+ }
504
+
505
+ // src/security/defense-in-depth-box.ts
506
+ var IS_BROWSER = typeof __BROWSER__ !== "undefined" && __BROWSER__;
507
+ var AsyncLocalStorageClass = null;
508
+ if (!IS_BROWSER) {
509
+ try {
510
+ const { AsyncLocalStorage } = __require("node:async_hooks");
511
+ AsyncLocalStorageClass = AsyncLocalStorage;
512
+ } catch {
513
+ }
514
+ }
515
+ var executionContext = !IS_BROWSER && AsyncLocalStorageClass ? new AsyncLocalStorageClass() : null;
516
+
517
+ // src/security/worker-defense-in-depth.ts
518
+ var DEFENSE_IN_DEPTH_NOTICE = "\n\nThis is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com";
519
+ var WorkerSecurityViolationError = class extends Error {
520
+ constructor(message, violation) {
521
+ super(message + DEFENSE_IN_DEPTH_NOTICE);
522
+ this.violation = violation;
523
+ this.name = "WorkerSecurityViolationError";
524
+ }
525
+ violation;
526
+ };
527
+ var MAX_STORED_VIOLATIONS = 1e3;
528
+ function generateExecutionId() {
529
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
530
+ return crypto.randomUUID();
531
+ }
532
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
533
+ const r = Math.random() * 16 | 0;
534
+ const v = c === "x" ? r : r & 3 | 8;
535
+ return v.toString(16);
536
+ });
537
+ }
538
+ var WorkerDefenseInDepth = class {
539
+ config;
540
+ isActivated = false;
541
+ originalDescriptors = [];
542
+ violations = [];
543
+ executionId;
544
+ /**
545
+ * Original Proxy constructor, captured before patching.
546
+ * This is captured at instance creation time to ensure we get the unpatched version.
547
+ */
548
+ originalProxy;
549
+ /**
550
+ * Recursion guard to prevent infinite loops when proxy traps trigger
551
+ * code that accesses the same proxied object (e.g., process.env).
552
+ */
553
+ inTrap = false;
554
+ /**
555
+ * Create and activate the worker defense layer.
556
+ *
557
+ * @param config - Configuration for the defense layer
558
+ */
559
+ constructor(config) {
560
+ this.originalProxy = Proxy;
561
+ this.config = config;
562
+ this.executionId = generateExecutionId();
563
+ if (config.enabled !== false) {
564
+ this.activate();
565
+ }
566
+ }
567
+ /**
568
+ * Get statistics about the defense layer.
569
+ */
570
+ getStats() {
571
+ return {
572
+ violationsBlocked: this.violations.length,
573
+ violations: [...this.violations],
574
+ isActive: this.isActivated
575
+ };
576
+ }
577
+ /**
578
+ * Clear stored violations. Useful for testing.
579
+ */
580
+ clearViolations() {
581
+ this.violations = [];
582
+ }
583
+ /**
584
+ * Get the execution ID for this worker.
585
+ */
586
+ getExecutionId() {
587
+ return this.executionId;
588
+ }
589
+ /**
590
+ * Deactivate the defense layer and restore original globals.
591
+ * Typically only needed for testing.
592
+ */
593
+ deactivate() {
594
+ if (!this.isActivated) {
595
+ return;
596
+ }
597
+ this.restorePatches();
598
+ this.isActivated = false;
599
+ }
600
+ /**
601
+ * Activate the defense layer by applying patches.
602
+ */
603
+ activate() {
604
+ if (this.isActivated) {
605
+ return;
606
+ }
607
+ this.applyPatches();
608
+ this.isActivated = true;
609
+ }
610
+ /**
611
+ * Get a human-readable path for a target object and property.
612
+ */
613
+ getPathForTarget(target, prop) {
614
+ if (target === globalThis) {
615
+ return `globalThis.${prop}`;
616
+ }
617
+ if (typeof process !== "undefined" && target === process) {
618
+ return `process.${prop}`;
619
+ }
620
+ if (target === Error) {
621
+ return `Error.${prop}`;
622
+ }
623
+ if (target === Function.prototype) {
624
+ return `Function.prototype.${prop}`;
625
+ }
626
+ if (target === Object.prototype) {
627
+ return `Object.prototype.${prop}`;
628
+ }
629
+ return `<object>.${prop}`;
630
+ }
631
+ /**
632
+ * Record a violation and invoke the callback.
633
+ * In worker context, blocking always happens (no audit mode context check).
634
+ */
635
+ recordViolation(type, path, message) {
636
+ const violation = {
637
+ timestamp: Date.now(),
638
+ type,
639
+ message,
640
+ path,
641
+ stack: new Error().stack,
642
+ executionId: this.executionId
643
+ };
644
+ if (this.violations.length < MAX_STORED_VIOLATIONS) {
645
+ this.violations.push(violation);
646
+ }
647
+ if (this.config.onViolation) {
648
+ try {
649
+ this.config.onViolation(violation);
650
+ } catch (e) {
651
+ console.debug(
652
+ "[WorkerDefenseInDepth] onViolation callback threw:",
653
+ e instanceof Error ? e.message : e
654
+ );
655
+ }
656
+ }
657
+ return violation;
658
+ }
659
+ /**
660
+ * Create a blocking proxy for a function.
661
+ * In worker context, always blocks (no context check needed).
662
+ */
663
+ createBlockingProxy(original, path, violationType) {
664
+ const self = this;
665
+ const auditMode = this.config.auditMode;
666
+ return new this.originalProxy(original, {
667
+ apply(target, thisArg, args) {
668
+ const message = `${path} is blocked in worker context`;
669
+ const violation = self.recordViolation(violationType, path, message);
670
+ if (!auditMode) {
671
+ throw new WorkerSecurityViolationError(message, violation);
672
+ }
673
+ return Reflect.apply(target, thisArg, args);
674
+ },
675
+ construct(target, args, newTarget) {
676
+ const message = `${path} constructor is blocked in worker context`;
677
+ const violation = self.recordViolation(violationType, path, message);
678
+ if (!auditMode) {
679
+ throw new WorkerSecurityViolationError(message, violation);
680
+ }
681
+ return Reflect.construct(target, args, newTarget);
682
+ }
683
+ });
684
+ }
685
+ /**
686
+ * Create a blocking proxy for an object (blocks all property access).
687
+ */
688
+ createBlockingObjectProxy(original, path, violationType, allowedKeys) {
689
+ const self = this;
690
+ const auditMode = this.config.auditMode;
691
+ return new this.originalProxy(original, {
692
+ get(target, prop, receiver) {
693
+ if (self.inTrap) {
694
+ return Reflect.get(target, prop, receiver);
695
+ }
696
+ if (allowedKeys && typeof prop === "string" && allowedKeys.has(prop)) {
697
+ return Reflect.get(target, prop, receiver);
698
+ }
699
+ self.inTrap = true;
700
+ try {
701
+ const fullPath = `${path}.${String(prop)}`;
702
+ const message = `${fullPath} is blocked in worker context`;
703
+ const violation = self.recordViolation(
704
+ violationType,
705
+ fullPath,
706
+ message
707
+ );
708
+ if (!auditMode) {
709
+ throw new WorkerSecurityViolationError(message, violation);
710
+ }
711
+ return Reflect.get(target, prop, receiver);
712
+ } finally {
713
+ self.inTrap = false;
714
+ }
715
+ },
716
+ set(target, prop, value, receiver) {
717
+ if (self.inTrap) {
718
+ return Reflect.set(target, prop, value, receiver);
719
+ }
720
+ self.inTrap = true;
721
+ try {
722
+ const fullPath = `${path}.${String(prop)}`;
723
+ const message = `${fullPath} modification is blocked in worker context`;
724
+ const violation = self.recordViolation(
725
+ violationType,
726
+ fullPath,
727
+ message
728
+ );
729
+ if (!auditMode) {
730
+ throw new WorkerSecurityViolationError(message, violation);
731
+ }
732
+ return Reflect.set(target, prop, value, receiver);
733
+ } finally {
734
+ self.inTrap = false;
735
+ }
736
+ },
737
+ ownKeys(target) {
738
+ if (self.inTrap) {
739
+ return Reflect.ownKeys(target);
740
+ }
741
+ self.inTrap = true;
742
+ try {
743
+ const message = `${path} enumeration is blocked in worker context`;
744
+ const violation = self.recordViolation(violationType, path, message);
745
+ if (!auditMode) {
746
+ throw new WorkerSecurityViolationError(message, violation);
747
+ }
748
+ return Reflect.ownKeys(target);
749
+ } finally {
750
+ self.inTrap = false;
751
+ }
752
+ },
753
+ getOwnPropertyDescriptor(target, prop) {
754
+ if (self.inTrap) {
755
+ return Reflect.getOwnPropertyDescriptor(target, prop);
756
+ }
757
+ self.inTrap = true;
758
+ try {
759
+ const fullPath = `${path}.${String(prop)}`;
760
+ const message = `${fullPath} descriptor access is blocked in worker context`;
761
+ const violation = self.recordViolation(
762
+ violationType,
763
+ fullPath,
764
+ message
765
+ );
766
+ if (!auditMode) {
767
+ throw new WorkerSecurityViolationError(message, violation);
768
+ }
769
+ return Reflect.getOwnPropertyDescriptor(target, prop);
770
+ } finally {
771
+ self.inTrap = false;
772
+ }
773
+ },
774
+ has(target, prop) {
775
+ if (self.inTrap) {
776
+ return Reflect.has(target, prop);
777
+ }
778
+ self.inTrap = true;
779
+ try {
780
+ const fullPath = `${path}.${String(prop)}`;
781
+ const message = `${fullPath} existence check is blocked in worker context`;
782
+ const violation = self.recordViolation(
783
+ violationType,
784
+ fullPath,
785
+ message
786
+ );
787
+ if (!auditMode) {
788
+ throw new WorkerSecurityViolationError(message, violation);
789
+ }
790
+ return Reflect.has(target, prop);
791
+ } finally {
792
+ self.inTrap = false;
793
+ }
794
+ },
795
+ deleteProperty(target, prop) {
796
+ if (self.inTrap) {
797
+ return Reflect.deleteProperty(target, prop);
798
+ }
799
+ self.inTrap = true;
800
+ try {
801
+ const fullPath = `${path}.${String(prop)}`;
802
+ const message = `${fullPath} deletion is blocked in worker context`;
803
+ const violation = self.recordViolation(
804
+ violationType,
805
+ fullPath,
806
+ message
807
+ );
808
+ if (!auditMode) {
809
+ throw new WorkerSecurityViolationError(message, violation);
810
+ }
811
+ return Reflect.deleteProperty(target, prop);
812
+ } finally {
813
+ self.inTrap = false;
814
+ }
815
+ },
816
+ setPrototypeOf(target, proto) {
817
+ if (self.inTrap) {
818
+ return Reflect.setPrototypeOf(target, proto);
819
+ }
820
+ self.inTrap = true;
821
+ try {
822
+ const message = `${path} setPrototypeOf is blocked in worker context`;
823
+ const violation = self.recordViolation(violationType, path, message);
824
+ if (!auditMode) {
825
+ throw new WorkerSecurityViolationError(message, violation);
826
+ }
827
+ return Reflect.setPrototypeOf(target, proto);
828
+ } finally {
829
+ self.inTrap = false;
830
+ }
831
+ },
832
+ defineProperty(target, prop, descriptor) {
833
+ if (self.inTrap) {
834
+ return Reflect.defineProperty(target, prop, descriptor);
835
+ }
836
+ self.inTrap = true;
837
+ try {
838
+ const fullPath = `${path}.${String(prop)}`;
839
+ const message = `${fullPath} defineProperty is blocked in worker context`;
840
+ const violation = self.recordViolation(
841
+ violationType,
842
+ fullPath,
843
+ message
844
+ );
845
+ if (!auditMode) {
846
+ throw new WorkerSecurityViolationError(message, violation);
847
+ }
848
+ return Reflect.defineProperty(target, prop, descriptor);
849
+ } finally {
850
+ self.inTrap = false;
851
+ }
852
+ }
853
+ });
854
+ }
855
+ /**
856
+ * Apply security patches to dangerous globals.
857
+ */
858
+ applyPatches() {
859
+ const blockedGlobals = getBlockedGlobals();
860
+ const excludeTypes = new Set(this.config.excludeViolationTypes ?? []);
861
+ for (const blocked of blockedGlobals) {
862
+ if (excludeTypes.has(blocked.violationType)) {
863
+ continue;
864
+ }
865
+ this.applyPatch(blocked);
866
+ }
867
+ if (!excludeTypes.has("function_constructor")) {
868
+ this.protectConstructorChain(excludeTypes);
869
+ }
870
+ if (!excludeTypes.has("error_prepare_stack_trace")) {
871
+ this.protectErrorPrepareStackTrace();
872
+ }
873
+ if (!excludeTypes.has("module_load")) {
874
+ this.protectModuleLoad();
875
+ }
876
+ if (!excludeTypes.has("module_resolve_filename")) {
877
+ this.protectModuleResolveFilename();
878
+ }
879
+ if (!excludeTypes.has("process_main_module")) {
880
+ this.protectProcessMainModule();
881
+ }
882
+ if (!excludeTypes.has("process_exec_path")) {
883
+ this.protectProcessExecPath();
884
+ }
885
+ if (!excludeTypes.has("process_connected")) {
886
+ this.protectProcessConnected();
887
+ }
888
+ this.lockWellKnownSymbols();
889
+ if (!excludeTypes.has("proxy")) {
890
+ this.protectProxyRevocable();
891
+ }
892
+ }
893
+ /**
894
+ * Lock well-known Symbol properties on built-in constructors/prototypes.
895
+ */
896
+ lockWellKnownSymbols() {
897
+ const lock = (obj, sym) => {
898
+ try {
899
+ const desc = Object.getOwnPropertyDescriptor(obj, sym);
900
+ if (desc?.configurable) {
901
+ if ("value" in desc) {
902
+ Object.defineProperty(obj, sym, {
903
+ ...desc,
904
+ configurable: false,
905
+ writable: false
906
+ });
907
+ return;
908
+ }
909
+ Object.defineProperty(obj, sym, { ...desc, configurable: false });
910
+ }
911
+ } catch {
912
+ }
913
+ };
914
+ for (const ctor of [Array, Map, Set, RegExp, Promise]) {
915
+ lock(ctor, Symbol.species);
916
+ }
917
+ for (const proto of [
918
+ Array.prototype,
919
+ String.prototype,
920
+ Map.prototype,
921
+ Set.prototype
922
+ ]) {
923
+ lock(proto, Symbol.iterator);
924
+ }
925
+ lock(Symbol.prototype, Symbol.toPrimitive);
926
+ lock(Date.prototype, Symbol.toPrimitive);
927
+ for (const sym of [
928
+ Symbol.match,
929
+ Symbol.matchAll,
930
+ Symbol.replace,
931
+ Symbol.search,
932
+ Symbol.split
933
+ ]) {
934
+ lock(RegExp.prototype, sym);
935
+ }
936
+ lock(Function.prototype, Symbol.hasInstance);
937
+ lock(Array.prototype, Symbol.unscopables);
938
+ for (const proto of [
939
+ Map.prototype,
940
+ Set.prototype,
941
+ Promise.prototype,
942
+ ArrayBuffer.prototype
943
+ ]) {
944
+ lock(proto, Symbol.toStringTag);
945
+ }
946
+ try {
947
+ const stackDesc = Object.getOwnPropertyDescriptor(
948
+ Error,
949
+ "stackTraceLimit"
950
+ );
951
+ this.originalDescriptors.push({
952
+ target: Error,
953
+ prop: "stackTraceLimit",
954
+ descriptor: stackDesc
955
+ });
956
+ Object.defineProperty(Error, "stackTraceLimit", {
957
+ value: Error.stackTraceLimit,
958
+ writable: false,
959
+ configurable: true
960
+ });
961
+ } catch {
962
+ }
963
+ }
964
+ /**
965
+ * Block Proxy.revocable to prevent bypassing Proxy constructor blocking.
966
+ *
967
+ * Proxy.revocable internally uses the real Proxy constructor, so it bypasses
968
+ * our blocking proxy on globalThis.Proxy. We replace it with a wrapper that
969
+ * always blocks in worker context.
970
+ */
971
+ protectProxyRevocable() {
972
+ const self = this;
973
+ const auditMode = this.config.auditMode;
974
+ try {
975
+ const originalRevocable = this.originalProxy.revocable;
976
+ if (typeof originalRevocable !== "function") return;
977
+ const descriptor = Object.getOwnPropertyDescriptor(
978
+ this.originalProxy,
979
+ "revocable"
980
+ );
981
+ this.originalDescriptors.push({
982
+ target: this.originalProxy,
983
+ prop: "revocable",
984
+ descriptor
985
+ });
986
+ Object.defineProperty(this.originalProxy, "revocable", {
987
+ value: function revocable(_target, _handler) {
988
+ const message = "Proxy.revocable is blocked in worker context";
989
+ const violation = self.recordViolation(
990
+ "proxy",
991
+ "Proxy.revocable",
992
+ message
993
+ );
994
+ if (!auditMode) {
995
+ throw new WorkerSecurityViolationError(message, violation);
996
+ }
997
+ return originalRevocable(_target, _handler);
998
+ },
999
+ writable: false,
1000
+ configurable: true
1001
+ // Must be configurable for restoration
1002
+ });
1003
+ } catch {
1004
+ }
1005
+ }
1006
+ /**
1007
+ * Protect against .constructor.constructor escape vector.
1008
+ * @param excludeTypes - Set of violation types to skip
1009
+ */
1010
+ protectConstructorChain(excludeTypes) {
1011
+ let AsyncFunction = null;
1012
+ let GeneratorFunction = null;
1013
+ let AsyncGeneratorFunction = null;
1014
+ try {
1015
+ AsyncFunction = Object.getPrototypeOf(async () => {
1016
+ }).constructor;
1017
+ } catch {
1018
+ }
1019
+ try {
1020
+ GeneratorFunction = Object.getPrototypeOf(function* () {
1021
+ }).constructor;
1022
+ } catch {
1023
+ }
1024
+ try {
1025
+ AsyncGeneratorFunction = Object.getPrototypeOf(
1026
+ async function* () {
1027
+ }
1028
+ ).constructor;
1029
+ } catch {
1030
+ }
1031
+ this.patchPrototypeConstructor(
1032
+ Function.prototype,
1033
+ "Function.prototype.constructor",
1034
+ "function_constructor"
1035
+ );
1036
+ if (!excludeTypes.has("async_function_constructor") && AsyncFunction && AsyncFunction !== Function) {
1037
+ this.patchPrototypeConstructor(
1038
+ AsyncFunction.prototype,
1039
+ "AsyncFunction.prototype.constructor",
1040
+ "async_function_constructor"
1041
+ );
1042
+ }
1043
+ if (!excludeTypes.has("generator_function_constructor") && GeneratorFunction && GeneratorFunction !== Function) {
1044
+ this.patchPrototypeConstructor(
1045
+ GeneratorFunction.prototype,
1046
+ "GeneratorFunction.prototype.constructor",
1047
+ "generator_function_constructor"
1048
+ );
1049
+ }
1050
+ if (!excludeTypes.has("async_generator_function_constructor") && AsyncGeneratorFunction && AsyncGeneratorFunction !== Function && AsyncGeneratorFunction !== AsyncFunction) {
1051
+ this.patchPrototypeConstructor(
1052
+ AsyncGeneratorFunction.prototype,
1053
+ "AsyncGeneratorFunction.prototype.constructor",
1054
+ "async_generator_function_constructor"
1055
+ );
1056
+ }
1057
+ }
1058
+ /**
1059
+ * Protect Error.prepareStackTrace from being set.
1060
+ */
1061
+ protectErrorPrepareStackTrace() {
1062
+ const self = this;
1063
+ const auditMode = this.config.auditMode;
1064
+ try {
1065
+ const originalDescriptor = Object.getOwnPropertyDescriptor(
1066
+ Error,
1067
+ "prepareStackTrace"
1068
+ );
1069
+ this.originalDescriptors.push({
1070
+ target: Error,
1071
+ prop: "prepareStackTrace",
1072
+ descriptor: originalDescriptor
1073
+ });
1074
+ let currentValue = originalDescriptor?.value;
1075
+ Object.defineProperty(Error, "prepareStackTrace", {
1076
+ get() {
1077
+ return currentValue;
1078
+ },
1079
+ set(value) {
1080
+ const message = "Error.prepareStackTrace modification is blocked in worker context";
1081
+ const violation = self.recordViolation(
1082
+ "error_prepare_stack_trace",
1083
+ "Error.prepareStackTrace",
1084
+ message
1085
+ );
1086
+ if (!auditMode) {
1087
+ throw new WorkerSecurityViolationError(message, violation);
1088
+ }
1089
+ currentValue = value;
1090
+ },
1091
+ configurable: true
1092
+ });
1093
+ } catch {
1094
+ }
1095
+ }
1096
+ /**
1097
+ * Patch a prototype's constructor property.
1098
+ *
1099
+ * Returns a proxy that allows reading properties (like .name) but blocks
1100
+ * calling the constructor as a function (which would allow code execution).
1101
+ */
1102
+ patchPrototypeConstructor(prototype, path, violationType) {
1103
+ const self = this;
1104
+ const auditMode = this.config.auditMode;
1105
+ try {
1106
+ const originalDescriptor = Object.getOwnPropertyDescriptor(
1107
+ prototype,
1108
+ "constructor"
1109
+ );
1110
+ this.originalDescriptors.push({
1111
+ target: prototype,
1112
+ prop: "constructor",
1113
+ descriptor: originalDescriptor
1114
+ });
1115
+ const originalValue = originalDescriptor?.value;
1116
+ const constructorProxy = originalValue && typeof originalValue === "function" ? new this.originalProxy(originalValue, {
1117
+ apply(_target, _thisArg, _args) {
1118
+ const message = `${path} invocation is blocked in worker context`;
1119
+ const violation = self.recordViolation(
1120
+ violationType,
1121
+ path,
1122
+ message
1123
+ );
1124
+ if (!auditMode) {
1125
+ throw new WorkerSecurityViolationError(message, violation);
1126
+ }
1127
+ return void 0;
1128
+ },
1129
+ construct(_target, _args, _newTarget) {
1130
+ const message = `${path} construction is blocked in worker context`;
1131
+ const violation = self.recordViolation(
1132
+ violationType,
1133
+ path,
1134
+ message
1135
+ );
1136
+ if (!auditMode) {
1137
+ throw new WorkerSecurityViolationError(message, violation);
1138
+ }
1139
+ return {};
1140
+ },
1141
+ // Allow all property access (like .name, .prototype, etc.)
1142
+ get(target, prop, receiver) {
1143
+ return Reflect.get(target, prop, receiver);
1144
+ },
1145
+ getPrototypeOf(target) {
1146
+ return Reflect.getPrototypeOf(target);
1147
+ },
1148
+ has(target, prop) {
1149
+ return Reflect.has(target, prop);
1150
+ },
1151
+ ownKeys(target) {
1152
+ return Reflect.ownKeys(target);
1153
+ },
1154
+ getOwnPropertyDescriptor(target, prop) {
1155
+ return Reflect.getOwnPropertyDescriptor(target, prop);
1156
+ }
1157
+ }) : originalValue;
1158
+ Object.defineProperty(prototype, "constructor", {
1159
+ get() {
1160
+ return constructorProxy;
1161
+ },
1162
+ set(value) {
1163
+ const message = `${path} modification is blocked in worker context`;
1164
+ const violation = self.recordViolation(violationType, path, message);
1165
+ if (!auditMode) {
1166
+ throw new WorkerSecurityViolationError(message, violation);
1167
+ }
1168
+ Object.defineProperty(this, "constructor", {
1169
+ value,
1170
+ writable: true,
1171
+ configurable: true
1172
+ });
1173
+ },
1174
+ configurable: true
1175
+ });
1176
+ } catch {
1177
+ }
1178
+ }
1179
+ /**
1180
+ * Protect process.mainModule from being accessed or set.
1181
+ *
1182
+ * The attack vector is:
1183
+ * ```
1184
+ * process.mainModule.require('child_process').execSync('whoami')
1185
+ * process.mainModule.constructor._load('vm')
1186
+ * ```
1187
+ *
1188
+ * process.mainModule may be undefined in ESM contexts but could exist in
1189
+ * CommonJS workers. We block both reading and setting.
1190
+ */
1191
+ protectProcessMainModule() {
1192
+ if (typeof process === "undefined") return;
1193
+ const self = this;
1194
+ const auditMode = this.config.auditMode;
1195
+ try {
1196
+ const originalDescriptor = Object.getOwnPropertyDescriptor(
1197
+ process,
1198
+ "mainModule"
1199
+ );
1200
+ this.originalDescriptors.push({
1201
+ target: process,
1202
+ prop: "mainModule",
1203
+ descriptor: originalDescriptor
1204
+ });
1205
+ const currentValue = originalDescriptor?.value;
1206
+ if (currentValue !== void 0) {
1207
+ Object.defineProperty(process, "mainModule", {
1208
+ get() {
1209
+ const message = "process.mainModule access is blocked in worker context";
1210
+ const violation = self.recordViolation(
1211
+ "process_main_module",
1212
+ "process.mainModule",
1213
+ message
1214
+ );
1215
+ if (!auditMode) {
1216
+ throw new WorkerSecurityViolationError(message, violation);
1217
+ }
1218
+ return currentValue;
1219
+ },
1220
+ set(value) {
1221
+ const message = "process.mainModule modification is blocked in worker context";
1222
+ const violation = self.recordViolation(
1223
+ "process_main_module",
1224
+ "process.mainModule",
1225
+ message
1226
+ );
1227
+ if (!auditMode) {
1228
+ throw new WorkerSecurityViolationError(message, violation);
1229
+ }
1230
+ Object.defineProperty(process, "mainModule", {
1231
+ value,
1232
+ writable: true,
1233
+ configurable: true
1234
+ });
1235
+ },
1236
+ configurable: true
1237
+ });
1238
+ }
1239
+ } catch {
1240
+ }
1241
+ }
1242
+ /**
1243
+ * Protect process.execPath from being read or set in worker context.
1244
+ *
1245
+ * process.execPath is a string primitive (not an object), so it cannot be
1246
+ * proxied via the normal blocked globals mechanism. We use Object.defineProperty
1247
+ * with getter/setter (same pattern as protectProcessMainModule).
1248
+ */
1249
+ protectProcessExecPath() {
1250
+ if (typeof process === "undefined") return;
1251
+ const self = this;
1252
+ const auditMode = this.config.auditMode;
1253
+ try {
1254
+ const originalDescriptor = Object.getOwnPropertyDescriptor(
1255
+ process,
1256
+ "execPath"
1257
+ );
1258
+ this.originalDescriptors.push({
1259
+ target: process,
1260
+ prop: "execPath",
1261
+ descriptor: originalDescriptor
1262
+ });
1263
+ const currentValue = originalDescriptor?.value ?? process.execPath;
1264
+ Object.defineProperty(process, "execPath", {
1265
+ get() {
1266
+ const message = "process.execPath access is blocked in worker context";
1267
+ const violation = self.recordViolation(
1268
+ "process_exec_path",
1269
+ "process.execPath",
1270
+ message
1271
+ );
1272
+ if (!auditMode) {
1273
+ throw new WorkerSecurityViolationError(message, violation);
1274
+ }
1275
+ return currentValue;
1276
+ },
1277
+ set(value) {
1278
+ const message = "process.execPath modification is blocked in worker context";
1279
+ const violation = self.recordViolation(
1280
+ "process_exec_path",
1281
+ "process.execPath",
1282
+ message
1283
+ );
1284
+ if (!auditMode) {
1285
+ throw new WorkerSecurityViolationError(message, violation);
1286
+ }
1287
+ Object.defineProperty(process, "execPath", {
1288
+ value,
1289
+ writable: true,
1290
+ configurable: true
1291
+ });
1292
+ },
1293
+ configurable: true
1294
+ });
1295
+ } catch {
1296
+ }
1297
+ }
1298
+ /**
1299
+ * Protect process.connected from being read or set in worker context.
1300
+ *
1301
+ * process.connected is a boolean primitive (not an object), so it cannot be
1302
+ * proxied via the normal blocked globals mechanism. We use Object.defineProperty
1303
+ * with getter/setter (same pattern as protectProcessExecPath).
1304
+ *
1305
+ * Only protects if process.connected exists (IPC contexts).
1306
+ */
1307
+ protectProcessConnected() {
1308
+ if (typeof process === "undefined") return;
1309
+ if (process.connected === void 0) return;
1310
+ const self = this;
1311
+ const auditMode = this.config.auditMode;
1312
+ try {
1313
+ const originalDescriptor = Object.getOwnPropertyDescriptor(
1314
+ process,
1315
+ "connected"
1316
+ );
1317
+ this.originalDescriptors.push({
1318
+ target: process,
1319
+ prop: "connected",
1320
+ descriptor: originalDescriptor
1321
+ });
1322
+ const currentValue = originalDescriptor?.value ?? process.connected;
1323
+ Object.defineProperty(process, "connected", {
1324
+ get() {
1325
+ const message = "process.connected access is blocked in worker context";
1326
+ const violation = self.recordViolation(
1327
+ "process_connected",
1328
+ "process.connected",
1329
+ message
1330
+ );
1331
+ if (!auditMode) {
1332
+ throw new WorkerSecurityViolationError(message, violation);
1333
+ }
1334
+ return currentValue;
1335
+ },
1336
+ set(value) {
1337
+ const message = "process.connected modification is blocked in worker context";
1338
+ const violation = self.recordViolation(
1339
+ "process_connected",
1340
+ "process.connected",
1341
+ message
1342
+ );
1343
+ if (!auditMode) {
1344
+ throw new WorkerSecurityViolationError(message, violation);
1345
+ }
1346
+ Object.defineProperty(process, "connected", {
1347
+ value,
1348
+ writable: true,
1349
+ configurable: true
1350
+ });
1351
+ },
1352
+ configurable: true
1353
+ });
1354
+ } catch {
1355
+ }
1356
+ }
1357
+ /**
1358
+ * Protect Module._load from being called.
1359
+ *
1360
+ * The attack vector is:
1361
+ * ```
1362
+ * module.constructor._load('child_process')
1363
+ * require.main.constructor._load('vm')
1364
+ * ```
1365
+ *
1366
+ * We access the Module class and replace _load with a blocking proxy.
1367
+ */
1368
+ protectModuleLoad() {
1369
+ const self = this;
1370
+ const auditMode = this.config.auditMode;
1371
+ try {
1372
+ let ModuleClass = null;
1373
+ if (typeof process !== "undefined") {
1374
+ const mainModule = process.mainModule;
1375
+ if (mainModule && typeof mainModule === "object") {
1376
+ ModuleClass = mainModule.constructor;
1377
+ }
1378
+ }
1379
+ if (!ModuleClass && typeof __require !== "undefined" && typeof __require.main !== "undefined") {
1380
+ ModuleClass = __require.main.constructor;
1381
+ }
1382
+ if (!ModuleClass || typeof ModuleClass._load !== "function") {
1383
+ return;
1384
+ }
1385
+ const original = ModuleClass._load;
1386
+ const descriptor = Object.getOwnPropertyDescriptor(ModuleClass, "_load");
1387
+ this.originalDescriptors.push({
1388
+ target: ModuleClass,
1389
+ prop: "_load",
1390
+ descriptor
1391
+ });
1392
+ const path = "Module._load";
1393
+ const proxy = new this.originalProxy(original, {
1394
+ apply(_target, _thisArg, _args) {
1395
+ const message = `${path} is blocked in worker context`;
1396
+ const violation = self.recordViolation("module_load", path, message);
1397
+ if (!auditMode) {
1398
+ throw new WorkerSecurityViolationError(message, violation);
1399
+ }
1400
+ return Reflect.apply(_target, _thisArg, _args);
1401
+ }
1402
+ });
1403
+ Object.defineProperty(ModuleClass, "_load", {
1404
+ value: proxy,
1405
+ writable: true,
1406
+ configurable: true
1407
+ });
1408
+ } catch {
1409
+ }
1410
+ }
1411
+ /**
1412
+ * Protect Module._resolveFilename from being called in worker context.
1413
+ *
1414
+ * Module._resolveFilename is called for both require() and import() resolution.
1415
+ * Blocking it catches file-based import() specifiers.
1416
+ *
1417
+ * data: and blob: URLs are handled by ESM loader hooks registered
1418
+ * in the main thread (DefenseInDepthBox.protectDynamicImport).
1419
+ */
1420
+ protectModuleResolveFilename() {
1421
+ const self = this;
1422
+ const auditMode = this.config.auditMode;
1423
+ try {
1424
+ let ModuleClass = null;
1425
+ if (typeof process !== "undefined") {
1426
+ const mainModule = process.mainModule;
1427
+ if (mainModule && typeof mainModule === "object") {
1428
+ ModuleClass = mainModule.constructor;
1429
+ }
1430
+ }
1431
+ if (!ModuleClass && typeof __require !== "undefined" && typeof __require.main !== "undefined") {
1432
+ ModuleClass = __require.main.constructor;
1433
+ }
1434
+ if (!ModuleClass || typeof ModuleClass._resolveFilename !== "function") {
1435
+ return;
1436
+ }
1437
+ const original = ModuleClass._resolveFilename;
1438
+ const descriptor = Object.getOwnPropertyDescriptor(
1439
+ ModuleClass,
1440
+ "_resolveFilename"
1441
+ );
1442
+ this.originalDescriptors.push({
1443
+ target: ModuleClass,
1444
+ prop: "_resolveFilename",
1445
+ descriptor
1446
+ });
1447
+ const path = "Module._resolveFilename";
1448
+ const proxy = new this.originalProxy(original, {
1449
+ apply(_target, _thisArg, _args) {
1450
+ const message = `${path} is blocked in worker context`;
1451
+ const violation = self.recordViolation(
1452
+ "module_resolve_filename",
1453
+ path,
1454
+ message
1455
+ );
1456
+ if (!auditMode) {
1457
+ throw new WorkerSecurityViolationError(message, violation);
1458
+ }
1459
+ return Reflect.apply(_target, _thisArg, _args);
1460
+ }
1461
+ });
1462
+ Object.defineProperty(ModuleClass, "_resolveFilename", {
1463
+ value: proxy,
1464
+ writable: true,
1465
+ configurable: true
1466
+ });
1467
+ } catch {
1468
+ }
1469
+ }
1470
+ /**
1471
+ * Apply a single patch to a blocked global.
1472
+ */
1473
+ applyPatch(blocked) {
1474
+ const { target, prop, violationType, strategy } = blocked;
1475
+ try {
1476
+ const original = target[prop];
1477
+ if (original === void 0) {
1478
+ return;
1479
+ }
1480
+ const descriptor = Object.getOwnPropertyDescriptor(target, prop);
1481
+ this.originalDescriptors.push({ target, prop, descriptor });
1482
+ if (strategy === "freeze") {
1483
+ if (typeof original === "object" && original !== null) {
1484
+ Object.freeze(original);
1485
+ }
1486
+ } else {
1487
+ const path = this.getPathForTarget(target, prop);
1488
+ const proxy = typeof original === "function" ? this.createBlockingProxy(
1489
+ original,
1490
+ path,
1491
+ violationType
1492
+ ) : this.createBlockingObjectProxy(
1493
+ original,
1494
+ path,
1495
+ violationType,
1496
+ blocked.allowedKeys
1497
+ );
1498
+ Object.defineProperty(target, prop, {
1499
+ value: proxy,
1500
+ writable: true,
1501
+ configurable: true
1502
+ });
1503
+ }
1504
+ } catch {
1505
+ }
1506
+ }
1507
+ /**
1508
+ * Restore all original values.
1509
+ */
1510
+ restorePatches() {
1511
+ for (let i = this.originalDescriptors.length - 1; i >= 0; i--) {
1512
+ const { target, prop, descriptor } = this.originalDescriptors[i];
1513
+ try {
1514
+ if (descriptor) {
1515
+ Object.defineProperty(target, prop, descriptor);
1516
+ } else {
1517
+ delete target[prop];
1518
+ }
1519
+ } catch {
1520
+ }
1521
+ }
1522
+ this.originalDescriptors = [];
1523
+ }
1524
+ };
1525
+
1526
+ // src/security/wasm-callback.ts
1527
+ function sanitizeUnknownError(error) {
1528
+ const message = error instanceof Error ? error.message : String(error);
1529
+ return sanitizeErrorMessage(message);
1530
+ }
1531
+ function wrapWasmCallback(component, phase, callback) {
1532
+ return (...args) => {
1533
+ try {
1534
+ return callback(...args);
1535
+ } catch (error) {
1536
+ const message = sanitizeUnknownError(error);
1537
+ throw new Error(`${component} ${phase} callback failed: ${message}`);
1538
+ }
1539
+ };
1540
+ }
1541
+
1542
+ // src/security/trusted-globals.ts
1543
+ var _SharedArrayBuffer = globalThis.SharedArrayBuffer;
1544
+ var _Atomics = globalThis.Atomics;
1545
+ var _performanceNow = performance.now.bind(performance);
1546
+ var _Headers = globalThis.Headers;
1547
+
1548
+ // src/commands/worker-bridge/protocol.ts
1549
+ var OpCode = {
1550
+ NOOP: 0,
1551
+ READ_FILE: 1,
1552
+ WRITE_FILE: 2,
1553
+ STAT: 3,
1554
+ READDIR: 4,
1555
+ MKDIR: 5,
1556
+ RM: 6,
1557
+ EXISTS: 7,
1558
+ APPEND_FILE: 8,
1559
+ SYMLINK: 9,
1560
+ READLINK: 10,
1561
+ LSTAT: 11,
1562
+ CHMOD: 12,
1563
+ REALPATH: 13,
1564
+ RENAME: 14,
1565
+ COPY_FILE: 15,
1566
+ // Special operations for I/O
1567
+ WRITE_STDOUT: 100,
1568
+ WRITE_STDERR: 101,
1569
+ EXIT: 102,
1570
+ // HTTP operations
1571
+ HTTP_REQUEST: 200,
1572
+ // Sub-shell execution
1573
+ EXEC_COMMAND: 300
1574
+ };
1575
+ var Status = {
1576
+ PENDING: 0,
1577
+ READY: 1,
1578
+ SUCCESS: 2,
1579
+ ERROR: 3
1580
+ };
1581
+ var ErrorCode = {
1582
+ NONE: 0,
1583
+ NOT_FOUND: 1,
1584
+ IS_DIRECTORY: 2,
1585
+ NOT_DIRECTORY: 3,
1586
+ EXISTS: 4,
1587
+ PERMISSION_DENIED: 5,
1588
+ INVALID_PATH: 6,
1589
+ IO_ERROR: 7,
1590
+ TIMEOUT: 8,
1591
+ NETWORK_ERROR: 9,
1592
+ NETWORK_NOT_CONFIGURED: 10
1593
+ };
1594
+ var Offset = {
1595
+ OP_CODE: 0,
1596
+ STATUS: 4,
1597
+ PATH_LENGTH: 8,
1598
+ DATA_LENGTH: 12,
1599
+ RESULT_LENGTH: 16,
1600
+ ERROR_CODE: 20,
1601
+ FLAGS: 24,
1602
+ MODE: 28,
1603
+ PATH_BUFFER: 32,
1604
+ DATA_BUFFER: 4128
1605
+ // 32 + 4096
1606
+ };
1607
+ var Size = {
1608
+ CONTROL_REGION: 32,
1609
+ PATH_BUFFER: 4096,
1610
+ // 1MB limit applies to all FS read/write operations through the bridge.
1611
+ // Files larger than this will be truncated. This is tight — consider
1612
+ // increasing if real workloads hit the cap. Reduced from 16MB for faster tests.
1613
+ DATA_BUFFER: 1048576,
1614
+ TOTAL: 1052704
1615
+ // 32 + 4096 + 1MB
1616
+ };
1617
+ var Flags = {
1618
+ NONE: 0,
1619
+ RECURSIVE: 1,
1620
+ FORCE: 2,
1621
+ MKDIR_RECURSIVE: 1
1622
+ };
1623
+ var StatLayout = {
1624
+ IS_FILE: 0,
1625
+ IS_DIRECTORY: 1,
1626
+ IS_SYMLINK: 2,
1627
+ MODE: 4,
1628
+ SIZE: 8,
1629
+ MTIME: 16,
1630
+ TOTAL: 24
1631
+ };
1632
+ var ProtocolBuffer = class {
1633
+ int32View;
1634
+ uint8View;
1635
+ dataView;
1636
+ constructor(buffer) {
1637
+ this.int32View = new Int32Array(buffer);
1638
+ this.uint8View = new Uint8Array(buffer);
1639
+ this.dataView = new DataView(buffer);
1640
+ }
1641
+ getOpCode() {
1642
+ return _Atomics.load(this.int32View, Offset.OP_CODE / 4);
1643
+ }
1644
+ setOpCode(code) {
1645
+ _Atomics.store(this.int32View, Offset.OP_CODE / 4, code);
1646
+ }
1647
+ getStatus() {
1648
+ return _Atomics.load(this.int32View, Offset.STATUS / 4);
1649
+ }
1650
+ setStatus(status) {
1651
+ _Atomics.store(this.int32View, Offset.STATUS / 4, status);
1652
+ }
1653
+ getPathLength() {
1654
+ return _Atomics.load(this.int32View, Offset.PATH_LENGTH / 4);
1655
+ }
1656
+ setPathLength(length) {
1657
+ _Atomics.store(this.int32View, Offset.PATH_LENGTH / 4, length);
1658
+ }
1659
+ getDataLength() {
1660
+ return _Atomics.load(this.int32View, Offset.DATA_LENGTH / 4);
1661
+ }
1662
+ setDataLength(length) {
1663
+ _Atomics.store(this.int32View, Offset.DATA_LENGTH / 4, length);
1664
+ }
1665
+ getResultLength() {
1666
+ return _Atomics.load(this.int32View, Offset.RESULT_LENGTH / 4);
1667
+ }
1668
+ setResultLength(length) {
1669
+ _Atomics.store(this.int32View, Offset.RESULT_LENGTH / 4, length);
1670
+ }
1671
+ getErrorCode() {
1672
+ return _Atomics.load(
1673
+ this.int32View,
1674
+ Offset.ERROR_CODE / 4
1675
+ );
1676
+ }
1677
+ setErrorCode(code) {
1678
+ _Atomics.store(this.int32View, Offset.ERROR_CODE / 4, code);
1679
+ }
1680
+ getFlags() {
1681
+ return _Atomics.load(this.int32View, Offset.FLAGS / 4);
1682
+ }
1683
+ setFlags(flags) {
1684
+ _Atomics.store(this.int32View, Offset.FLAGS / 4, flags);
1685
+ }
1686
+ getMode() {
1687
+ return _Atomics.load(this.int32View, Offset.MODE / 4);
1688
+ }
1689
+ setMode(mode) {
1690
+ _Atomics.store(this.int32View, Offset.MODE / 4, mode);
1691
+ }
1692
+ getPath() {
1693
+ const length = this.getPathLength();
1694
+ const bytes = this.uint8View.slice(
1695
+ Offset.PATH_BUFFER,
1696
+ Offset.PATH_BUFFER + length
1697
+ );
1698
+ return new TextDecoder().decode(bytes);
1699
+ }
1700
+ setPath(path) {
1701
+ const encoded = new TextEncoder().encode(path);
1702
+ if (encoded.length > Size.PATH_BUFFER) {
1703
+ throw new Error(`Path too long: ${encoded.length} > ${Size.PATH_BUFFER}`);
1704
+ }
1705
+ this.uint8View.set(encoded, Offset.PATH_BUFFER);
1706
+ this.setPathLength(encoded.length);
1707
+ }
1708
+ getData() {
1709
+ const length = this.getDataLength();
1710
+ return this.uint8View.slice(
1711
+ Offset.DATA_BUFFER,
1712
+ Offset.DATA_BUFFER + length
1713
+ );
1714
+ }
1715
+ setData(data) {
1716
+ if (data.length > Size.DATA_BUFFER) {
1717
+ throw new Error(`Data too large: ${data.length} > ${Size.DATA_BUFFER}`);
1718
+ }
1719
+ this.uint8View.set(data, Offset.DATA_BUFFER);
1720
+ this.setDataLength(data.length);
1721
+ }
1722
+ getDataAsString() {
1723
+ const data = this.getData();
1724
+ return new TextDecoder().decode(data);
1725
+ }
1726
+ setDataFromString(str) {
1727
+ const encoded = new TextEncoder().encode(str);
1728
+ this.setData(encoded);
1729
+ }
1730
+ getResult() {
1731
+ const length = this.getResultLength();
1732
+ return this.uint8View.slice(
1733
+ Offset.DATA_BUFFER,
1734
+ Offset.DATA_BUFFER + length
1735
+ );
1736
+ }
1737
+ setResult(data) {
1738
+ if (data.length > Size.DATA_BUFFER) {
1739
+ throw new Error(`Result too large: ${data.length} > ${Size.DATA_BUFFER}`);
1740
+ }
1741
+ this.uint8View.set(data, Offset.DATA_BUFFER);
1742
+ this.setResultLength(data.length);
1743
+ }
1744
+ getResultAsString() {
1745
+ const result = this.getResult();
1746
+ return new TextDecoder().decode(result);
1747
+ }
1748
+ setResultFromString(str) {
1749
+ const encoded = new TextEncoder().encode(str);
1750
+ this.setResult(encoded);
1751
+ }
1752
+ encodeStat(stat) {
1753
+ this.uint8View[Offset.DATA_BUFFER + StatLayout.IS_FILE] = stat.isFile ? 1 : 0;
1754
+ this.uint8View[Offset.DATA_BUFFER + StatLayout.IS_DIRECTORY] = stat.isDirectory ? 1 : 0;
1755
+ this.uint8View[Offset.DATA_BUFFER + StatLayout.IS_SYMLINK] = stat.isSymbolicLink ? 1 : 0;
1756
+ this.dataView.setInt32(
1757
+ Offset.DATA_BUFFER + StatLayout.MODE,
1758
+ stat.mode,
1759
+ true
1760
+ );
1761
+ const size = Math.min(stat.size, Number.MAX_SAFE_INTEGER);
1762
+ this.dataView.setFloat64(Offset.DATA_BUFFER + StatLayout.SIZE, size, true);
1763
+ this.dataView.setFloat64(
1764
+ Offset.DATA_BUFFER + StatLayout.MTIME,
1765
+ stat.mtime.getTime(),
1766
+ true
1767
+ );
1768
+ this.setResultLength(StatLayout.TOTAL);
1769
+ }
1770
+ decodeStat() {
1771
+ return {
1772
+ isFile: this.uint8View[Offset.DATA_BUFFER + StatLayout.IS_FILE] === 1,
1773
+ isDirectory: this.uint8View[Offset.DATA_BUFFER + StatLayout.IS_DIRECTORY] === 1,
1774
+ isSymbolicLink: this.uint8View[Offset.DATA_BUFFER + StatLayout.IS_SYMLINK] === 1,
1775
+ mode: this.dataView.getInt32(Offset.DATA_BUFFER + StatLayout.MODE, true),
1776
+ size: this.dataView.getFloat64(
1777
+ Offset.DATA_BUFFER + StatLayout.SIZE,
1778
+ true
1779
+ ),
1780
+ mtime: new Date(
1781
+ this.dataView.getFloat64(Offset.DATA_BUFFER + StatLayout.MTIME, true)
1782
+ )
1783
+ };
1784
+ }
1785
+ waitForReady(timeout) {
1786
+ return _Atomics.wait(
1787
+ this.int32View,
1788
+ Offset.STATUS / 4,
1789
+ Status.PENDING,
1790
+ timeout
1791
+ );
1792
+ }
1793
+ waitForReadyAsync(timeout) {
1794
+ return _Atomics.waitAsync(
1795
+ this.int32View,
1796
+ Offset.STATUS / 4,
1797
+ Status.PENDING,
1798
+ timeout
1799
+ );
1800
+ }
1801
+ /**
1802
+ * Wait for status to become READY.
1803
+ * Returns immediately if status is already READY, or waits until it changes.
1804
+ */
1805
+ async waitUntilReady(timeout) {
1806
+ const startTime = Date.now();
1807
+ while (true) {
1808
+ const status = this.getStatus();
1809
+ if (status === Status.READY) {
1810
+ return true;
1811
+ }
1812
+ const elapsed = Date.now() - startTime;
1813
+ if (elapsed >= timeout) {
1814
+ return false;
1815
+ }
1816
+ const remainingMs = timeout - elapsed;
1817
+ const result = _Atomics.waitAsync(
1818
+ this.int32View,
1819
+ Offset.STATUS / 4,
1820
+ status,
1821
+ remainingMs
1822
+ );
1823
+ if (result.async) {
1824
+ const waitResult = await result.value;
1825
+ if (waitResult === "timed-out") {
1826
+ return false;
1827
+ }
1828
+ }
1829
+ }
1830
+ }
1831
+ waitForResult(timeout) {
1832
+ return _Atomics.wait(
1833
+ this.int32View,
1834
+ Offset.STATUS / 4,
1835
+ Status.READY,
1836
+ timeout
1837
+ );
1838
+ }
1839
+ notify() {
1840
+ return _Atomics.notify(this.int32View, Offset.STATUS / 4);
1841
+ }
1842
+ reset() {
1843
+ this.setOpCode(OpCode.NOOP);
1844
+ this.setStatus(Status.PENDING);
1845
+ this.setPathLength(0);
1846
+ this.setDataLength(0);
1847
+ this.setResultLength(0);
1848
+ this.setErrorCode(ErrorCode.NONE);
1849
+ this.setFlags(Flags.NONE);
1850
+ this.setMode(0);
1851
+ }
1852
+ };
1853
+
1854
+ // src/commands/worker-bridge/sync-backend.ts
1855
+ var SyncBackend = class {
1856
+ protocol;
1857
+ operationTimeoutMs;
1858
+ constructor(sharedBuffer, operationTimeoutMs = 3e4) {
1859
+ this.protocol = new ProtocolBuffer(sharedBuffer);
1860
+ this.operationTimeoutMs = operationTimeoutMs;
1861
+ }
1862
+ execSync(opCode, path, data, flags = 0, mode = 0) {
1863
+ this.protocol.reset();
1864
+ this.protocol.setOpCode(opCode);
1865
+ this.protocol.setPath(path);
1866
+ this.protocol.setFlags(flags);
1867
+ this.protocol.setMode(mode);
1868
+ if (data) {
1869
+ this.protocol.setData(data);
1870
+ }
1871
+ this.protocol.setStatus(Status.READY);
1872
+ this.protocol.notify();
1873
+ const waitResult = this.protocol.waitForResult(this.operationTimeoutMs);
1874
+ if (waitResult === "timed-out") {
1875
+ return { success: false, error: "Operation timed out" };
1876
+ }
1877
+ const status = this.protocol.getStatus();
1878
+ if (status === Status.SUCCESS) {
1879
+ return { success: true, result: this.protocol.getResult() };
1880
+ }
1881
+ return {
1882
+ success: false,
1883
+ error: this.protocol.getResultAsString() || `Error code: ${this.protocol.getErrorCode()}`
1884
+ };
1885
+ }
1886
+ readFile(path) {
1887
+ const result = this.execSync(OpCode.READ_FILE, path);
1888
+ if (!result.success) {
1889
+ throw new Error(result.error || "Failed to read file");
1890
+ }
1891
+ return result.result ?? new Uint8Array(0);
1892
+ }
1893
+ writeFile(path, data) {
1894
+ const result = this.execSync(OpCode.WRITE_FILE, path, data);
1895
+ if (!result.success) {
1896
+ throw new Error(result.error || "Failed to write file");
1897
+ }
1898
+ }
1899
+ stat(path) {
1900
+ const result = this.execSync(OpCode.STAT, path);
1901
+ if (!result.success) {
1902
+ throw new Error(result.error || "Failed to stat");
1903
+ }
1904
+ return this.protocol.decodeStat();
1905
+ }
1906
+ lstat(path) {
1907
+ const result = this.execSync(OpCode.LSTAT, path);
1908
+ if (!result.success) {
1909
+ throw new Error(result.error || "Failed to lstat");
1910
+ }
1911
+ return this.protocol.decodeStat();
1912
+ }
1913
+ readdir(path) {
1914
+ const result = this.execSync(OpCode.READDIR, path);
1915
+ if (!result.success) {
1916
+ throw new Error(result.error || "Failed to readdir");
1917
+ }
1918
+ return JSON.parse(this.protocol.getResultAsString());
1919
+ }
1920
+ mkdir(path, recursive = false) {
1921
+ const flags = recursive ? Flags.MKDIR_RECURSIVE : 0;
1922
+ const result = this.execSync(OpCode.MKDIR, path, void 0, flags);
1923
+ if (!result.success) {
1924
+ throw new Error(result.error || "Failed to mkdir");
1925
+ }
1926
+ }
1927
+ rm(path, recursive = false, force = false) {
1928
+ let flags = 0;
1929
+ if (recursive) flags |= Flags.RECURSIVE;
1930
+ if (force) flags |= Flags.FORCE;
1931
+ const result = this.execSync(OpCode.RM, path, void 0, flags);
1932
+ if (!result.success) {
1933
+ throw new Error(result.error || "Failed to rm");
1934
+ }
1935
+ }
1936
+ exists(path) {
1937
+ const result = this.execSync(OpCode.EXISTS, path);
1938
+ if (!result.success) {
1939
+ return false;
1940
+ }
1941
+ return result.result?.[0] === 1;
1942
+ }
1943
+ appendFile(path, data) {
1944
+ const result = this.execSync(OpCode.APPEND_FILE, path, data);
1945
+ if (!result.success) {
1946
+ throw new Error(result.error || "Failed to append file");
1947
+ }
1948
+ }
1949
+ symlink(target, linkPath) {
1950
+ const targetData = new TextEncoder().encode(target);
1951
+ const result = this.execSync(OpCode.SYMLINK, linkPath, targetData);
1952
+ if (!result.success) {
1953
+ throw new Error(result.error || "Failed to symlink");
1954
+ }
1955
+ }
1956
+ readlink(path) {
1957
+ const result = this.execSync(OpCode.READLINK, path);
1958
+ if (!result.success) {
1959
+ throw new Error(result.error || "Failed to readlink");
1960
+ }
1961
+ return this.protocol.getResultAsString();
1962
+ }
1963
+ chmod(path, mode) {
1964
+ const result = this.execSync(OpCode.CHMOD, path, void 0, 0, mode);
1965
+ if (!result.success) {
1966
+ throw new Error(result.error || "Failed to chmod");
1967
+ }
1968
+ }
1969
+ realpath(path) {
1970
+ const result = this.execSync(OpCode.REALPATH, path);
1971
+ if (!result.success) {
1972
+ throw new Error(result.error || "Failed to realpath");
1973
+ }
1974
+ return this.protocol.getResultAsString();
1975
+ }
1976
+ rename(oldPath, newPath) {
1977
+ const newPathData = new TextEncoder().encode(newPath);
1978
+ const result = this.execSync(OpCode.RENAME, oldPath, newPathData);
1979
+ if (!result.success) {
1980
+ throw new Error(result.error || "Failed to rename");
1981
+ }
1982
+ }
1983
+ copyFile(src, dest) {
1984
+ const destData = new TextEncoder().encode(dest);
1985
+ const result = this.execSync(OpCode.COPY_FILE, src, destData);
1986
+ if (!result.success) {
1987
+ throw new Error(result.error || "Failed to copyFile");
1988
+ }
1989
+ }
1990
+ writeStdout(data) {
1991
+ const encoded = new TextEncoder().encode(data);
1992
+ const result = this.execSync(OpCode.WRITE_STDOUT, "", encoded);
1993
+ if (!result.success) {
1994
+ throw new Error(result.error || "Failed to write stdout");
1995
+ }
1996
+ }
1997
+ writeStderr(data) {
1998
+ const encoded = new TextEncoder().encode(data);
1999
+ const result = this.execSync(OpCode.WRITE_STDERR, "", encoded);
2000
+ if (!result.success) {
2001
+ throw new Error(result.error || "Failed to write stderr");
2002
+ }
2003
+ }
2004
+ exit(code) {
2005
+ this.execSync(OpCode.EXIT, "", void 0, code);
2006
+ }
2007
+ /**
2008
+ * Make an HTTP request through the main thread's secureFetch.
2009
+ * Returns the response as a parsed object.
2010
+ */
2011
+ httpRequest(url, options) {
2012
+ const requestData = options ? new TextEncoder().encode(JSON.stringify(options)) : void 0;
2013
+ const result = this.execSync(OpCode.HTTP_REQUEST, url, requestData);
2014
+ if (!result.success) {
2015
+ throw new Error(result.error || "HTTP request failed");
2016
+ }
2017
+ const responseJson = new TextDecoder().decode(result.result);
2018
+ const parsed = JSON.parse(responseJson);
2019
+ const bodyBase64 = parsed.bodyBase64 ?? "";
2020
+ const body = atob(bodyBase64);
2021
+ return {
2022
+ status: parsed.status,
2023
+ statusText: parsed.statusText,
2024
+ headers: parsed.headers,
2025
+ url: parsed.url,
2026
+ body,
2027
+ bodyBase64
2028
+ };
2029
+ }
2030
+ /**
2031
+ * Execute a shell command through the main thread's exec function.
2032
+ * Returns the result as { stdout, stderr, exitCode }.
2033
+ */
2034
+ execCommand(command, stdin) {
2035
+ const requestData = stdin ? new TextEncoder().encode(JSON.stringify({ stdin })) : void 0;
2036
+ const result = this.execSync(OpCode.EXEC_COMMAND, command, requestData);
2037
+ if (!result.success) {
2038
+ throw new Error(result.error || "Command execution failed");
2039
+ }
2040
+ const responseJson = new TextDecoder().decode(result.result);
2041
+ return JSON.parse(responseJson);
2042
+ }
2043
+ /**
2044
+ * Execute a shell command with structured args (shell-escaped on the main thread).
2045
+ * Prevents command injection from unsanitized args.
2046
+ */
2047
+ execCommandArgs(command, args) {
2048
+ const requestData = new TextEncoder().encode(JSON.stringify({ args }));
2049
+ const result = this.execSync(OpCode.EXEC_COMMAND, command, requestData);
2050
+ if (!result.success) {
2051
+ throw new Error(result.error || "Command execution failed");
2052
+ }
2053
+ const responseJson = new TextDecoder().decode(result.result);
2054
+ return JSON.parse(responseJson);
2055
+ }
2056
+ };
2057
+
2058
+ // src/commands/python3/worker.ts
2059
+ import { readFileSync } from "node:fs";
2060
+ var require2 = createRequire(import.meta.url);
2061
+ var CPYTHON_ENTRY_BASENAME = "/vendor/cpython-emscripten/python.cjs";
2062
+ var CPYTHON_STDLIB_BASENAME = "/vendor/cpython-emscripten/python313.zip";
2063
+ var moduleLoadGuardInstalled = false;
2064
+ function normalizePath(path) {
2065
+ return path.replace(/\\/g, "/");
2066
+ }
2067
+ function isApprovedCpythonEntryPath(path) {
2068
+ return normalizePath(path).endsWith(CPYTHON_ENTRY_BASENAME);
2069
+ }
2070
+ function isApprovedStdlibZipPath(path) {
2071
+ return normalizePath(path).endsWith(CPYTHON_STDLIB_BASENAME);
2072
+ }
2073
+ function assertApprovedPath(path, kind) {
2074
+ const ok = kind === "cpython-entry" ? isApprovedCpythonEntryPath(path) : isApprovedStdlibZipPath(path);
2075
+ if (!ok) {
2076
+ throw new Error(
2077
+ `[Defense-in-depth] rejected ${kind} path outside approved vendor bundle: ${path}`
2078
+ );
2079
+ }
2080
+ }
2081
+ try {
2082
+ const NodeModule = require2("node:module");
2083
+ if (typeof NodeModule._load === "function") {
2084
+ const originalLoad = NodeModule._load;
2085
+ const blockedModules = /* @__PURE__ */ new Set([
2086
+ "child_process",
2087
+ "node:child_process",
2088
+ "cluster",
2089
+ "node:cluster",
2090
+ "dgram",
2091
+ "node:dgram",
2092
+ "dns",
2093
+ "node:dns",
2094
+ "net",
2095
+ "node:net",
2096
+ "tls",
2097
+ "node:tls",
2098
+ "vm",
2099
+ "node:vm",
2100
+ "v8",
2101
+ "node:v8",
2102
+ "inspector",
2103
+ "node:inspector",
2104
+ "inspector/promises",
2105
+ "node:inspector/promises",
2106
+ "trace_events",
2107
+ "node:trace_events",
2108
+ "perf_hooks",
2109
+ "node:perf_hooks",
2110
+ "worker_threads",
2111
+ "node:worker_threads"
2112
+ ]);
2113
+ NodeModule._load = function(request, ...rest) {
2114
+ if (blockedModules.has(request)) {
2115
+ throw new Error(
2116
+ `[Defense-in-depth] require('${request}') is blocked in worker context`
2117
+ );
2118
+ }
2119
+ return originalLoad.apply(this, [request, ...rest]);
2120
+ };
2121
+ moduleLoadGuardInstalled = true;
2122
+ }
2123
+ } catch {
2124
+ }
2125
+ var cpythonEntryPath;
2126
+ try {
2127
+ cpythonEntryPath = require2.resolve(
2128
+ "../../../vendor/cpython-emscripten/python.cjs"
2129
+ );
2130
+ } catch (_e) {
2131
+ cpythonEntryPath = dirname(import.meta.url).replace("file://", "") + "/../../../vendor/cpython-emscripten/python.cjs";
2132
+ }
2133
+ assertApprovedPath(cpythonEntryPath, "cpython-entry");
2134
+ var cpythonDir = dirname(cpythonEntryPath);
2135
+ var stdlibZipPath = `${cpythonDir}/python313.zip`;
2136
+ assertApprovedPath(stdlibZipPath, "cpython-stdlib");
2137
+ function createHOSTFS(backend, FS, PATH) {
2138
+ const ERRNO_CODES = Object.assign(
2139
+ /* @__PURE__ */ Object.create(null),
2140
+ {
2141
+ EPERM: 63,
2142
+ ENOENT: 44,
2143
+ EIO: 29,
2144
+ EBADF: 8,
2145
+ EAGAIN: 6,
2146
+ EACCES: 2,
2147
+ EBUSY: 10,
2148
+ EEXIST: 20,
2149
+ ENOTDIR: 54,
2150
+ EISDIR: 31,
2151
+ EINVAL: 28,
2152
+ EMFILE: 33,
2153
+ ENOSPC: 51,
2154
+ ESPIPE: 70,
2155
+ EROFS: 69,
2156
+ ENOTEMPTY: 55,
2157
+ ENOSYS: 52,
2158
+ ENOTSUP: 138,
2159
+ ENODATA: 42
2160
+ }
2161
+ );
2162
+ function realPath(node) {
2163
+ const parts = [];
2164
+ while (node.parent !== node) {
2165
+ parts.push(node.name);
2166
+ node = node.parent;
2167
+ }
2168
+ parts.push(node.mount.opts.root);
2169
+ parts.reverse();
2170
+ return PATH.join(...parts);
2171
+ }
2172
+ function tryFSOperation(f) {
2173
+ try {
2174
+ return f();
2175
+ } catch (e) {
2176
+ const msg = e?.message?.toLowerCase() || (typeof e === "string" ? e.toLowerCase() : "");
2177
+ let code = ERRNO_CODES.EIO;
2178
+ if (msg.includes("no such file") || msg.includes("not found")) {
2179
+ code = ERRNO_CODES.ENOENT;
2180
+ } else if (msg.includes("is a directory")) {
2181
+ code = ERRNO_CODES.EISDIR;
2182
+ } else if (msg.includes("not a directory")) {
2183
+ code = ERRNO_CODES.ENOTDIR;
2184
+ } else if (msg.includes("already exists")) {
2185
+ code = ERRNO_CODES.EEXIST;
2186
+ } else if (msg.includes("permission")) {
2187
+ code = ERRNO_CODES.EACCES;
2188
+ } else if (msg.includes("not empty")) {
2189
+ code = ERRNO_CODES.ENOTEMPTY;
2190
+ }
2191
+ throw new FS.ErrnoError(code);
2192
+ }
2193
+ }
2194
+ function getMode(path) {
2195
+ return tryFSOperation(() => {
2196
+ const stat = backend.stat(path);
2197
+ let mode = stat.mode & 511;
2198
+ if (stat.isDirectory) {
2199
+ mode |= 16384;
2200
+ } else if (stat.isSymbolicLink) {
2201
+ mode |= 40960;
2202
+ } else {
2203
+ mode |= 32768;
2204
+ }
2205
+ return mode;
2206
+ });
2207
+ }
2208
+ const HOSTFS = {
2209
+ mount(_mount) {
2210
+ return HOSTFS.createNode(null, "/", 16877, 0);
2211
+ },
2212
+ createNode(parent, name, mode, dev) {
2213
+ if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {
2214
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
2215
+ }
2216
+ const node = FS.createNode(parent, name, mode, dev);
2217
+ node.node_ops = HOSTFS.node_ops;
2218
+ node.stream_ops = HOSTFS.stream_ops;
2219
+ return node;
2220
+ },
2221
+ node_ops: {
2222
+ getattr(node) {
2223
+ const path = realPath(node);
2224
+ return tryFSOperation(() => {
2225
+ const stat = backend.stat(path);
2226
+ let mode = stat.mode & 511;
2227
+ if (stat.isDirectory) {
2228
+ mode |= 16384;
2229
+ } else if (stat.isSymbolicLink) {
2230
+ mode |= 40960;
2231
+ } else {
2232
+ mode |= 32768;
2233
+ }
2234
+ return {
2235
+ dev: 1,
2236
+ ino: node.id,
2237
+ mode,
2238
+ nlink: 1,
2239
+ uid: 0,
2240
+ gid: 0,
2241
+ rdev: 0,
2242
+ size: stat.size,
2243
+ atime: stat.mtime,
2244
+ mtime: stat.mtime,
2245
+ ctime: stat.mtime,
2246
+ blksize: 4096,
2247
+ blocks: Math.ceil(stat.size / 512)
2248
+ };
2249
+ });
2250
+ },
2251
+ setattr(node, attr) {
2252
+ const path = realPath(node);
2253
+ const mode = attr.mode;
2254
+ if (mode !== void 0) {
2255
+ tryFSOperation(() => backend.chmod(path, mode));
2256
+ node.mode = mode;
2257
+ }
2258
+ if (attr.size !== void 0) {
2259
+ tryFSOperation(() => {
2260
+ const content = backend.readFile(path);
2261
+ const newContent = content.slice(0, attr.size);
2262
+ backend.writeFile(path, newContent);
2263
+ });
2264
+ }
2265
+ },
2266
+ lookup(parent, name) {
2267
+ const path = PATH.join2(realPath(parent), name);
2268
+ const mode = getMode(path);
2269
+ return HOSTFS.createNode(parent, name, mode);
2270
+ },
2271
+ mknod(parent, name, mode, _dev) {
2272
+ const node = HOSTFS.createNode(parent, name, mode, _dev);
2273
+ const path = realPath(node);
2274
+ tryFSOperation(() => {
2275
+ if (FS.isDir(node.mode)) {
2276
+ backend.mkdir(path, false);
2277
+ } else {
2278
+ backend.writeFile(path, new Uint8Array(0));
2279
+ }
2280
+ });
2281
+ return node;
2282
+ },
2283
+ rename(oldNode, newDir, newName) {
2284
+ const oldPath = realPath(oldNode);
2285
+ const newPath = PATH.join2(realPath(newDir), newName);
2286
+ tryFSOperation(() => {
2287
+ const content = backend.readFile(oldPath);
2288
+ backend.writeFile(newPath, content);
2289
+ backend.rm(oldPath, false, false);
2290
+ });
2291
+ oldNode.name = newName;
2292
+ },
2293
+ unlink(parent, name) {
2294
+ const path = PATH.join2(realPath(parent), name);
2295
+ tryFSOperation(() => backend.rm(path, false, false));
2296
+ },
2297
+ rmdir(parent, name) {
2298
+ const path = PATH.join2(realPath(parent), name);
2299
+ tryFSOperation(() => backend.rm(path, false, false));
2300
+ },
2301
+ readdir(node) {
2302
+ const path = realPath(node);
2303
+ return tryFSOperation(() => backend.readdir(path));
2304
+ },
2305
+ symlink(parent, newName, oldPath) {
2306
+ const newPath = PATH.join2(realPath(parent), newName);
2307
+ tryFSOperation(() => backend.symlink(oldPath, newPath));
2308
+ },
2309
+ readlink(node) {
2310
+ const path = realPath(node);
2311
+ return tryFSOperation(() => backend.readlink(path));
2312
+ }
2313
+ },
2314
+ stream_ops: {
2315
+ open(stream) {
2316
+ const path = realPath(stream.node);
2317
+ const flags = stream.flags;
2318
+ const O_WRONLY = 1;
2319
+ const O_RDWR = 2;
2320
+ const O_CREAT = 64;
2321
+ const O_TRUNC = 512;
2322
+ const O_APPEND = 1024;
2323
+ const accessMode = flags & 3;
2324
+ const isWrite = accessMode === O_WRONLY || accessMode === O_RDWR;
2325
+ const isCreate = (flags & O_CREAT) !== 0;
2326
+ const isTruncate = (flags & O_TRUNC) !== 0;
2327
+ const isAppend = (flags & O_APPEND) !== 0;
2328
+ if (FS.isDir(stream.node.mode)) {
2329
+ return;
2330
+ }
2331
+ let content;
2332
+ try {
2333
+ if (isTruncate && isWrite) {
2334
+ content = new Uint8Array(0);
2335
+ } else {
2336
+ content = backend.readFile(path);
2337
+ }
2338
+ } catch (_e) {
2339
+ if (isCreate && isWrite) {
2340
+ content = new Uint8Array(0);
2341
+ } else {
2342
+ throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
2343
+ }
2344
+ }
2345
+ stream.hostContent = content;
2346
+ stream.hostModified = isTruncate && isWrite;
2347
+ stream.hostPath = path;
2348
+ if (isAppend) {
2349
+ stream.position = content.length;
2350
+ }
2351
+ },
2352
+ close(stream) {
2353
+ const hostPath = stream.hostPath;
2354
+ const hostContent = stream.hostContent;
2355
+ if (stream.hostModified && hostContent && hostPath) {
2356
+ tryFSOperation(() => backend.writeFile(hostPath, hostContent));
2357
+ }
2358
+ delete stream.hostContent;
2359
+ delete stream.hostModified;
2360
+ delete stream.hostPath;
2361
+ },
2362
+ read(stream, buffer, offset, length, position) {
2363
+ const content = stream.hostContent;
2364
+ if (!content) return 0;
2365
+ const size = content.length;
2366
+ if (position >= size) return 0;
2367
+ const bytesToRead = Math.min(length, size - position);
2368
+ buffer.set(content.subarray(position, position + bytesToRead), offset);
2369
+ return bytesToRead;
2370
+ },
2371
+ write(stream, buffer, offset, length, position) {
2372
+ let content = stream.hostContent || new Uint8Array(0);
2373
+ const newSize = Math.max(content.length, position + length);
2374
+ if (newSize > content.length) {
2375
+ const newContent = new Uint8Array(newSize);
2376
+ newContent.set(content);
2377
+ content = newContent;
2378
+ stream.hostContent = content;
2379
+ }
2380
+ content.set(buffer.subarray(offset, offset + length), position);
2381
+ stream.hostModified = true;
2382
+ return length;
2383
+ },
2384
+ llseek(stream, offset, whence) {
2385
+ const SEEK_CUR = 1;
2386
+ const SEEK_END = 2;
2387
+ let position = offset;
2388
+ if (whence === SEEK_CUR) {
2389
+ position += stream.position;
2390
+ } else if (whence === SEEK_END) {
2391
+ if (FS.isFile(stream.node.mode)) {
2392
+ const content = stream.hostContent;
2393
+ position += content ? content.length : 0;
2394
+ }
2395
+ }
2396
+ if (position < 0) {
2397
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
2398
+ }
2399
+ return position;
2400
+ }
2401
+ }
2402
+ };
2403
+ return HOSTFS;
2404
+ }
2405
+ function generateSetupCode(input) {
2406
+ const envSetup = Object.entries(input.env).map(([key, value]) => {
2407
+ return `os.environ[${JSON.stringify(key)}] = ${JSON.stringify(value)}`;
2408
+ }).join("\n");
2409
+ const argv0 = input.scriptPath || "python3";
2410
+ const argvList = [argv0, ...input.args].map((arg) => JSON.stringify(arg)).join(", ");
2411
+ return `
2412
+ import os
2413
+ import sys
2414
+ import json
2415
+
2416
+ ${envSetup}
2417
+
2418
+ sys.argv = [${argvList}]
2419
+
2420
+ # Path redirection: redirect /absolute paths to /host mount
2421
+ def _should_redirect(path):
2422
+ return (isinstance(path, str) and
2423
+ path.startswith('/') and
2424
+ not path.startswith('/lib') and
2425
+ not path.startswith('/proc') and
2426
+ not path.startswith('/host') and
2427
+ not path.startswith('/_jb_http'))
2428
+
2429
+ # builtins.open
2430
+ import builtins
2431
+ _orig_open = builtins.open
2432
+ def _redir_open(path, mode='r', *args, **kwargs):
2433
+ if _should_redirect(path):
2434
+ path = '/host' + path
2435
+ return _orig_open(path, mode, *args, **kwargs)
2436
+ builtins.open = _redir_open
2437
+
2438
+ # os file operations
2439
+ _orig_listdir = os.listdir
2440
+ def _redir_listdir(path='.'):
2441
+ if _should_redirect(path):
2442
+ path = '/host' + path
2443
+ return _orig_listdir(path)
2444
+ os.listdir = _redir_listdir
2445
+
2446
+ _orig_exists = os.path.exists
2447
+ def _redir_exists(path):
2448
+ if _should_redirect(path):
2449
+ path = '/host' + path
2450
+ return _orig_exists(path)
2451
+ os.path.exists = _redir_exists
2452
+
2453
+ _orig_isfile = os.path.isfile
2454
+ def _redir_isfile(path):
2455
+ if _should_redirect(path):
2456
+ path = '/host' + path
2457
+ return _orig_isfile(path)
2458
+ os.path.isfile = _redir_isfile
2459
+
2460
+ _orig_isdir = os.path.isdir
2461
+ def _redir_isdir(path):
2462
+ if _should_redirect(path):
2463
+ path = '/host' + path
2464
+ return _orig_isdir(path)
2465
+ os.path.isdir = _redir_isdir
2466
+
2467
+ _orig_stat = os.stat
2468
+ def _redir_stat(path, *args, **kwargs):
2469
+ if _should_redirect(path):
2470
+ path = '/host' + path
2471
+ return _orig_stat(path, *args, **kwargs)
2472
+ os.stat = _redir_stat
2473
+
2474
+ _orig_mkdir = os.mkdir
2475
+ def _redir_mkdir(path, *args, **kwargs):
2476
+ if _should_redirect(path):
2477
+ path = '/host' + path
2478
+ return _orig_mkdir(path, *args, **kwargs)
2479
+ os.mkdir = _redir_mkdir
2480
+
2481
+ _orig_makedirs = os.makedirs
2482
+ def _redir_makedirs(path, *args, **kwargs):
2483
+ if _should_redirect(path):
2484
+ path = '/host' + path
2485
+ return _orig_makedirs(path, *args, **kwargs)
2486
+ os.makedirs = _redir_makedirs
2487
+
2488
+ _orig_remove = os.remove
2489
+ def _redir_remove(path, *args, **kwargs):
2490
+ if _should_redirect(path):
2491
+ path = '/host' + path
2492
+ return _orig_remove(path, *args, **kwargs)
2493
+ os.remove = _redir_remove
2494
+
2495
+ _orig_rmdir = os.rmdir
2496
+ def _redir_rmdir(path, *args, **kwargs):
2497
+ if _should_redirect(path):
2498
+ path = '/host' + path
2499
+ return _orig_rmdir(path, *args, **kwargs)
2500
+ os.rmdir = _redir_rmdir
2501
+
2502
+ _orig_getcwd = os.getcwd
2503
+ def _redir_getcwd():
2504
+ cwd = _orig_getcwd()
2505
+ if cwd.startswith('/host'):
2506
+ return cwd[5:]
2507
+ return cwd
2508
+ os.getcwd = _redir_getcwd
2509
+
2510
+ _orig_chdir = os.chdir
2511
+ def _redir_chdir(path):
2512
+ if _should_redirect(path):
2513
+ path = '/host' + path
2514
+ return _orig_chdir(path)
2515
+ os.chdir = _redir_chdir
2516
+
2517
+ # glob
2518
+ import glob as _glob_module
2519
+ _orig_glob = _glob_module.glob
2520
+ def _redir_glob(pathname, *args, **kwargs):
2521
+ if _should_redirect(pathname):
2522
+ pathname = '/host' + pathname
2523
+ return _orig_glob(pathname, *args, **kwargs)
2524
+ _glob_module.glob = _redir_glob
2525
+
2526
+ _orig_iglob = _glob_module.iglob
2527
+ def _redir_iglob(pathname, *args, **kwargs):
2528
+ if _should_redirect(pathname):
2529
+ pathname = '/host' + pathname
2530
+ return _orig_iglob(pathname, *args, **kwargs)
2531
+ _glob_module.iglob = _redir_iglob
2532
+
2533
+ # os.walk
2534
+ _orig_walk = os.walk
2535
+ def _redir_walk(top, *args, **kwargs):
2536
+ redirected = False
2537
+ if _should_redirect(top):
2538
+ top = '/host' + top
2539
+ redirected = True
2540
+ for dirpath, dirnames, filenames in _orig_walk(top, *args, **kwargs):
2541
+ if redirected and dirpath.startswith('/host'):
2542
+ dirpath = dirpath[5:] if len(dirpath) > 5 else '/'
2543
+ yield dirpath, dirnames, filenames
2544
+ os.walk = _redir_walk
2545
+
2546
+ # os.scandir
2547
+ _orig_scandir = os.scandir
2548
+ def _redir_scandir(path='.'):
2549
+ if _should_redirect(path):
2550
+ path = '/host' + path
2551
+ return _orig_scandir(path)
2552
+ os.scandir = _redir_scandir
2553
+
2554
+ # io.open
2555
+ import io as _io_module
2556
+ _io_module.open = builtins.open
2557
+
2558
+ # shutil
2559
+ import shutil as _shutil_module
2560
+
2561
+ _orig_shutil_copy = _shutil_module.copy
2562
+ def _redir_shutil_copy(src, dst, *args, **kwargs):
2563
+ if _should_redirect(src): src = '/host' + src
2564
+ if _should_redirect(dst): dst = '/host' + dst
2565
+ return _orig_shutil_copy(src, dst, *args, **kwargs)
2566
+ _shutil_module.copy = _redir_shutil_copy
2567
+
2568
+ _orig_shutil_copy2 = _shutil_module.copy2
2569
+ def _redir_shutil_copy2(src, dst, *args, **kwargs):
2570
+ if _should_redirect(src): src = '/host' + src
2571
+ if _should_redirect(dst): dst = '/host' + dst
2572
+ return _orig_shutil_copy2(src, dst, *args, **kwargs)
2573
+ _shutil_module.copy2 = _redir_shutil_copy2
2574
+
2575
+ _orig_shutil_copyfile = _shutil_module.copyfile
2576
+ def _redir_shutil_copyfile(src, dst, *args, **kwargs):
2577
+ if _should_redirect(src): src = '/host' + src
2578
+ if _should_redirect(dst): dst = '/host' + dst
2579
+ return _orig_shutil_copyfile(src, dst, *args, **kwargs)
2580
+ _shutil_module.copyfile = _redir_shutil_copyfile
2581
+
2582
+ _orig_shutil_copytree = _shutil_module.copytree
2583
+ def _redir_shutil_copytree(src, dst, *args, **kwargs):
2584
+ if _should_redirect(src): src = '/host' + src
2585
+ if _should_redirect(dst): dst = '/host' + dst
2586
+ return _orig_shutil_copytree(src, dst, *args, **kwargs)
2587
+ _shutil_module.copytree = _redir_shutil_copytree
2588
+
2589
+ _orig_shutil_move = _shutil_module.move
2590
+ def _redir_shutil_move(src, dst, *args, **kwargs):
2591
+ if _should_redirect(src): src = '/host' + src
2592
+ if _should_redirect(dst): dst = '/host' + dst
2593
+ return _orig_shutil_move(src, dst, *args, **kwargs)
2594
+ _shutil_module.move = _redir_shutil_move
2595
+
2596
+ _orig_shutil_rmtree = _shutil_module.rmtree
2597
+ def _redir_shutil_rmtree(path, *args, **kwargs):
2598
+ if _should_redirect(path): path = '/host' + path
2599
+ return _orig_shutil_rmtree(path, *args, **kwargs)
2600
+ _shutil_module.rmtree = _redir_shutil_rmtree
2601
+
2602
+ # pathlib.Path
2603
+ from pathlib import Path
2604
+
2605
+ def _redirect_path(p):
2606
+ s = str(p)
2607
+ if _should_redirect(s):
2608
+ return Path('/host' + s)
2609
+ return p
2610
+
2611
+ Path._orig_stat = Path.stat
2612
+ def _path_stat(self, *args, **kwargs):
2613
+ return _redirect_path(self)._orig_stat(*args, **kwargs)
2614
+ Path.stat = _path_stat
2615
+
2616
+ Path._orig_exists = Path.exists
2617
+ def _path_exists(self):
2618
+ return _redirect_path(self)._orig_exists()
2619
+ Path.exists = _path_exists
2620
+
2621
+ Path._orig_is_file = Path.is_file
2622
+ def _path_is_file(self):
2623
+ return _redirect_path(self)._orig_is_file()
2624
+ Path.is_file = _path_is_file
2625
+
2626
+ Path._orig_is_dir = Path.is_dir
2627
+ def _path_is_dir(self):
2628
+ return _redirect_path(self)._orig_is_dir()
2629
+ Path.is_dir = _path_is_dir
2630
+
2631
+ Path._orig_open = Path.open
2632
+ def _path_open(self, *args, **kwargs):
2633
+ return _redirect_path(self)._orig_open(*args, **kwargs)
2634
+ Path.open = _path_open
2635
+
2636
+ Path._orig_read_text = Path.read_text
2637
+ def _path_read_text(self, *args, **kwargs):
2638
+ return _redirect_path(self)._orig_read_text(*args, **kwargs)
2639
+ Path.read_text = _path_read_text
2640
+
2641
+ Path._orig_read_bytes = Path.read_bytes
2642
+ def _path_read_bytes(self):
2643
+ return _redirect_path(self)._orig_read_bytes()
2644
+ Path.read_bytes = _path_read_bytes
2645
+
2646
+ Path._orig_write_text = Path.write_text
2647
+ def _path_write_text(self, *args, **kwargs):
2648
+ return _redirect_path(self)._orig_write_text(*args, **kwargs)
2649
+ Path.write_text = _path_write_text
2650
+
2651
+ Path._orig_write_bytes = Path.write_bytes
2652
+ def _path_write_bytes(self, data):
2653
+ return _redirect_path(self)._orig_write_bytes(data)
2654
+ Path.write_bytes = _path_write_bytes
2655
+
2656
+ Path._orig_mkdir = Path.mkdir
2657
+ def _path_mkdir(self, *args, **kwargs):
2658
+ return _redirect_path(self)._orig_mkdir(*args, **kwargs)
2659
+ Path.mkdir = _path_mkdir
2660
+
2661
+ Path._orig_rmdir = Path.rmdir
2662
+ def _path_rmdir(self):
2663
+ return _redirect_path(self)._orig_rmdir()
2664
+ Path.rmdir = _path_rmdir
2665
+
2666
+ Path._orig_unlink = Path.unlink
2667
+ def _path_unlink(self, *args, **kwargs):
2668
+ return _redirect_path(self)._orig_unlink(*args, **kwargs)
2669
+ Path.unlink = _path_unlink
2670
+
2671
+ Path._orig_iterdir = Path.iterdir
2672
+ def _path_iterdir(self):
2673
+ redirected = _redirect_path(self)
2674
+ for p in redirected._orig_iterdir():
2675
+ s = str(p)
2676
+ if s.startswith('/host'):
2677
+ yield Path(s[5:])
2678
+ else:
2679
+ yield p
2680
+ Path.iterdir = _path_iterdir
2681
+
2682
+ Path._orig_glob = Path.glob
2683
+ def _path_glob(self, pattern):
2684
+ redirected = _redirect_path(self)
2685
+ for p in redirected._orig_glob(pattern):
2686
+ s = str(p)
2687
+ if s.startswith('/host'):
2688
+ yield Path(s[5:])
2689
+ else:
2690
+ yield p
2691
+ Path.glob = _path_glob
2692
+
2693
+ Path._orig_rglob = Path.rglob
2694
+ def _path_rglob(self, pattern):
2695
+ redirected = _redirect_path(self)
2696
+ for p in redirected._orig_rglob(pattern):
2697
+ s = str(p)
2698
+ if s.startswith('/host'):
2699
+ yield Path(s[5:])
2700
+ else:
2701
+ yield p
2702
+ Path.rglob = _path_rglob
2703
+
2704
+ # Set cwd to host mount
2705
+ os.chdir('/host' + ${JSON.stringify(input.cwd)})
2706
+ `;
2707
+ }
2708
+ function createHTTPFS(backend, FS) {
2709
+ let lastResponse = null;
2710
+ const encoder = new TextEncoder();
2711
+ const decoder = new TextDecoder();
2712
+ const HTTPFS = {
2713
+ mount(_mount) {
2714
+ return HTTPFS.createNode(null, "/", 16877, 0);
2715
+ },
2716
+ createNode(parent, name, mode, dev) {
2717
+ const node = FS.createNode(parent, name, mode, dev);
2718
+ node.node_ops = HTTPFS.node_ops;
2719
+ node.stream_ops = HTTPFS.stream_ops;
2720
+ return node;
2721
+ },
2722
+ node_ops: {
2723
+ getattr(node) {
2724
+ const isDir = node.name === "/" || node.parent === node;
2725
+ return {
2726
+ dev: 1,
2727
+ ino: node.id,
2728
+ mode: isDir ? 16877 : 33206,
2729
+ nlink: 1,
2730
+ uid: 0,
2731
+ gid: 0,
2732
+ rdev: 0,
2733
+ size: lastResponse ? lastResponse.length : 0,
2734
+ atime: /* @__PURE__ */ new Date(),
2735
+ mtime: /* @__PURE__ */ new Date(),
2736
+ ctime: /* @__PURE__ */ new Date(),
2737
+ blksize: 4096,
2738
+ blocks: 0
2739
+ };
2740
+ },
2741
+ setattr(_node, _attr) {
2742
+ },
2743
+ lookup(parent, name) {
2744
+ return HTTPFS.createNode(parent, name, 33206);
2745
+ },
2746
+ mknod(parent, name, mode, _dev) {
2747
+ return HTTPFS.createNode(parent, name, mode);
2748
+ },
2749
+ rename() {
2750
+ },
2751
+ unlink() {
2752
+ },
2753
+ rmdir() {
2754
+ },
2755
+ readdir(_node) {
2756
+ return ["request"];
2757
+ },
2758
+ symlink() {
2759
+ },
2760
+ readlink(_node) {
2761
+ return "";
2762
+ }
2763
+ },
2764
+ stream_ops: {
2765
+ open(stream) {
2766
+ delete stream.hostContent;
2767
+ stream.hostModified = false;
2768
+ const accessMode = stream.flags & 3;
2769
+ const isRead = accessMode === 0;
2770
+ if (isRead && lastResponse) {
2771
+ stream.hostContent = lastResponse;
2772
+ }
2773
+ },
2774
+ close(stream) {
2775
+ if (stream.hostModified && stream.hostContent) {
2776
+ const reqJson = decoder.decode(stream.hostContent);
2777
+ try {
2778
+ const req = JSON.parse(reqJson);
2779
+ const result = backend.httpRequest(req.url, {
2780
+ method: req.method || "GET",
2781
+ headers: req.headers || void 0,
2782
+ body: req.body || void 0
2783
+ });
2784
+ lastResponse = encoder.encode(JSON.stringify(result));
2785
+ } catch (e) {
2786
+ const message = sanitizeHostErrorMessage(e.message);
2787
+ lastResponse = encoder.encode(JSON.stringify({ error: message }));
2788
+ }
2789
+ }
2790
+ delete stream.hostContent;
2791
+ delete stream.hostModified;
2792
+ },
2793
+ read(stream, buffer, offset, length, position) {
2794
+ const content = stream.hostContent;
2795
+ if (!content) return 0;
2796
+ const size = content.length;
2797
+ if (position >= size) return 0;
2798
+ const bytesToRead = Math.min(length, size - position);
2799
+ buffer.set(content.subarray(position, position + bytesToRead), offset);
2800
+ return bytesToRead;
2801
+ },
2802
+ write(stream, buffer, offset, length, position) {
2803
+ let content = stream.hostContent || new Uint8Array(0);
2804
+ const newSize = Math.max(content.length, position + length);
2805
+ if (newSize > content.length) {
2806
+ const newContent = new Uint8Array(newSize);
2807
+ newContent.set(content);
2808
+ content = newContent;
2809
+ stream.hostContent = content;
2810
+ }
2811
+ content.set(buffer.subarray(offset, offset + length), position);
2812
+ stream.hostModified = true;
2813
+ return length;
2814
+ },
2815
+ llseek(stream, offset, whence) {
2816
+ let position = offset;
2817
+ if (whence === 1)
2818
+ position += stream.position;
2819
+ else if (whence === 2) {
2820
+ const content = stream.hostContent;
2821
+ position += content ? content.length : 0;
2822
+ }
2823
+ if (position < 0) throw new FS.ErrnoError(28);
2824
+ return position;
2825
+ }
2826
+ }
2827
+ };
2828
+ return HTTPFS;
2829
+ }
2830
+ function generateHttpBridgeCode() {
2831
+ return `
2832
+ # HTTP bridge: jb_http module
2833
+ # Write request JSON to /_jb_http/request (custom FS triggers HTTP via SharedArrayBuffer)
2834
+ # Then read response JSON from same path.
2835
+
2836
+ import base64 as _base64
2837
+
2838
+ class _JbHttpResponse:
2839
+ """HTTP response object similar to requests.Response"""
2840
+ def __init__(self, data):
2841
+ self.status_code = data.get('status', 0)
2842
+ self.reason = data.get('statusText', '')
2843
+ # @banned-pattern-ignore: Python code, not JavaScript
2844
+ self.headers = data.get('headers', {})
2845
+ self.url = data.get('url', '')
2846
+ self._error = data.get('error')
2847
+ b64 = data.get('bodyBase64')
2848
+ if b64 is not None:
2849
+ self.content = _base64.b64decode(b64)
2850
+ self.text = self.content.decode('utf-8', errors='replace')
2851
+ else:
2852
+ self.content = b''
2853
+ self.text = data.get('body', '')
2854
+
2855
+ @property
2856
+ def ok(self):
2857
+ return 200 <= self.status_code < 300
2858
+
2859
+ def json(self):
2860
+ return json.loads(self.text)
2861
+
2862
+ def raise_for_status(self):
2863
+ if self._error:
2864
+ raise Exception(self._error)
2865
+ if not self.ok:
2866
+ raise Exception(f"HTTP {self.status_code}: {self.reason}")
2867
+
2868
+ class _JbHttp:
2869
+ """HTTP client that bridges to just-bash's secureFetch via custom FS"""
2870
+ def _do_request(self, method, url, headers=None, body=None):
2871
+ import json as _json
2872
+ req = _json.dumps({'url': url, 'method': method, 'headers': headers, 'body': body})
2873
+ # Write request to HTTPFS \u2014 close triggers the HTTP call synchronously
2874
+ with _orig_open('/_jb_http/request', 'w') as f:
2875
+ f.write(req)
2876
+ # Read response (cached by HTTPFS from the HTTP call above)
2877
+ with _orig_open('/_jb_http/request', 'r') as f:
2878
+ return _json.loads(f.read())
2879
+
2880
+ def request(self, method, url, headers=None, data=None, json_data=None):
2881
+ if json_data is not None:
2882
+ data = json.dumps(json_data)
2883
+ headers = headers or {}
2884
+ headers['Content-Type'] = 'application/json'
2885
+ result = self._do_request(method, url, headers, data)
2886
+ if 'error' in result and result.get('status') is None:
2887
+ raise Exception(result['error'])
2888
+ return _JbHttpResponse(result)
2889
+
2890
+ def get(self, url, headers=None, **kwargs):
2891
+ return self.request('GET', url, headers=headers, **kwargs)
2892
+
2893
+ def post(self, url, headers=None, data=None, json=None, **kwargs):
2894
+ return self.request('POST', url, headers=headers, data=data, json_data=json, **kwargs)
2895
+
2896
+ def put(self, url, headers=None, data=None, json=None, **kwargs):
2897
+ return self.request('PUT', url, headers=headers, data=data, json_data=json, **kwargs)
2898
+
2899
+ def delete(self, url, headers=None, **kwargs):
2900
+ return self.request('DELETE', url, headers=headers, **kwargs)
2901
+
2902
+ def head(self, url, headers=None, **kwargs):
2903
+ return self.request('HEAD', url, headers=headers, **kwargs)
2904
+
2905
+ def patch(self, url, headers=None, data=None, json=None, **kwargs):
2906
+ return self.request('PATCH', url, headers=headers, data=data, json_data=json, **kwargs)
2907
+
2908
+ import types
2909
+ jb_http = types.ModuleType('jb_http')
2910
+ jb_http._client = _JbHttp()
2911
+ jb_http.get = jb_http._client.get
2912
+ jb_http.post = jb_http._client.post
2913
+ jb_http.put = jb_http._client.put
2914
+ jb_http.delete = jb_http._client.delete
2915
+ jb_http.head = jb_http._client.head
2916
+ jb_http.patch = jb_http._client.patch
2917
+ jb_http.request = jb_http._client.request
2918
+ jb_http.Response = _JbHttpResponse
2919
+ sys.modules['jb_http'] = jb_http
2920
+ `;
2921
+ }
2922
+ var cachedStdlibZip = new Uint8Array(readFileSync(stdlibZipPath));
2923
+ function wrapWorkerMessage(protocolToken, message) {
2924
+ const wrapped = /* @__PURE__ */ Object.create(null);
2925
+ if (!message || typeof message !== "object") {
2926
+ wrapped.success = false;
2927
+ wrapped.error = "Worker attempted to post non-object message";
2928
+ wrapped.protocolToken = protocolToken;
2929
+ return wrapped;
2930
+ }
2931
+ for (const [key, value] of Object.entries(message))
2932
+ wrapped[key] = value;
2933
+ wrapped.protocolToken = protocolToken;
2934
+ return wrapped;
2935
+ }
2936
+ function postWorkerMessage(protocolToken, message) {
2937
+ try {
2938
+ parentPort?.postMessage(wrapWorkerMessage(protocolToken, message));
2939
+ } catch (error) {
2940
+ console.debug(
2941
+ "[python3-worker] failed to post worker message:",
2942
+ sanitizeUnknownError(error)
2943
+ );
2944
+ }
2945
+ }
2946
+ async function runPython(input) {
2947
+ if (!moduleLoadGuardInstalled) {
2948
+ return {
2949
+ success: false,
2950
+ error: "Defense-in-depth module-loader guard failed to initialize; refusing to execute Python worker"
2951
+ };
2952
+ }
2953
+ const backend = new SyncBackend(input.sharedBuffer, input.timeoutMs);
2954
+ assertApprovedPath(cpythonEntryPath, "cpython-entry");
2955
+ const createPythonModule = require2(cpythonEntryPath);
2956
+ let moduleReady = false;
2957
+ const pendingStdout = [];
2958
+ const pendingStderr = [];
2959
+ let Module;
2960
+ try {
2961
+ const onPreRun = wrapWasmCallback(
2962
+ "python3-worker",
2963
+ "preRun",
2964
+ (mod) => {
2965
+ mod.FS.mkdirTree("/lib");
2966
+ mod.FS.writeFile("/lib/python313.zip", cachedStdlibZip);
2967
+ mod.ENV.PYTHONHOME = "/";
2968
+ mod.ENV.PYTHONPATH = "/lib/python313.zip";
2969
+ }
2970
+ );
2971
+ const onPrint = wrapWasmCallback(
2972
+ "python3-worker",
2973
+ "print",
2974
+ (text) => {
2975
+ if (moduleReady) {
2976
+ backend.writeStdout(`${text}
2977
+ `);
2978
+ } else {
2979
+ pendingStdout.push(`${text}
2980
+ `);
2981
+ }
2982
+ }
2983
+ );
2984
+ const onPrintErr = wrapWasmCallback(
2985
+ "python3-worker",
2986
+ "printErr",
2987
+ (text) => {
2988
+ if (typeof text === "string" && (text.includes("Could not find platform") || text.includes("LLVM Profile Error"))) {
2989
+ return;
2990
+ }
2991
+ if (moduleReady) {
2992
+ backend.writeStderr(`${text}
2993
+ `);
2994
+ } else {
2995
+ pendingStderr.push(`${text}
2996
+ `);
2997
+ }
2998
+ }
2999
+ );
3000
+ Module = await createPythonModule({
3001
+ noInitialRun: true,
3002
+ preRun: [onPreRun],
3003
+ print: onPrint,
3004
+ printErr: onPrintErr
3005
+ });
3006
+ } catch (e) {
3007
+ const message = sanitizeHostErrorMessage(e.message);
3008
+ return {
3009
+ success: false,
3010
+ error: `Failed to load CPython: ${message}`
3011
+ };
3012
+ }
3013
+ activateDefense(input.protocolToken);
3014
+ moduleReady = true;
3015
+ for (const text of pendingStdout) backend.writeStdout(text);
3016
+ for (const text of pendingStderr) backend.writeStderr(text);
3017
+ const HOSTFS = createHOSTFS(backend, Module.FS, Module.PATH);
3018
+ try {
3019
+ Module.FS.mkdir("/host");
3020
+ Module.FS.mount(HOSTFS, { root: "/" }, "/host");
3021
+ } catch (e) {
3022
+ const message = sanitizeHostErrorMessage(e.message);
3023
+ return {
3024
+ success: false,
3025
+ error: `Failed to mount HOSTFS: ${message}`
3026
+ };
3027
+ }
3028
+ const HTTPFS = createHTTPFS(backend, Module.FS);
3029
+ try {
3030
+ Module.FS.mkdir("/_jb_http");
3031
+ Module.FS.mount(HTTPFS, { root: "/" }, "/_jb_http");
3032
+ } catch (e) {
3033
+ const message = sanitizeHostErrorMessage(e.message);
3034
+ return {
3035
+ success: false,
3036
+ error: `Failed to mount HTTPFS: ${message}`
3037
+ };
3038
+ }
3039
+ const setupCode = generateSetupCode(input);
3040
+ const httpBridgeCode = generateHttpBridgeCode();
3041
+ const wrappedCode = `
3042
+ import sys
3043
+ _jb_exit_code = 0
3044
+ try:
3045
+ ${setupCode.split("\n").map((line) => ` ${line}`).join("\n")}
3046
+ ${httpBridgeCode.split("\n").map((line) => ` ${line}`).join("\n")}
3047
+ ${input.pythonCode.split("\n").map((line) => ` ${line}`).join("\n")}
3048
+ except SystemExit as e:
3049
+ _jb_exit_code = e.code if isinstance(e.code, int) else (1 if e.code else 0)
3050
+ except Exception as e:
3051
+ import traceback
3052
+ traceback.print_exc()
3053
+ _jb_exit_code = 1
3054
+ sys.exit(_jb_exit_code)
3055
+ `;
3056
+ try {
3057
+ Module.FS.mkdir("/tmp");
3058
+ } catch (_e) {
3059
+ }
3060
+ const encoder = new TextEncoder();
3061
+ const scriptPath = "/tmp/_jb_script.py";
3062
+ const scriptData = encoder.encode(wrappedCode);
3063
+ Module.FS.writeFile(scriptPath, scriptData);
3064
+ try {
3065
+ const ret = Module.callMain([scriptPath]);
3066
+ const exitCode = (typeof ret === "number" ? ret : 0) || process.exitCode || 0;
3067
+ backend.exit(exitCode);
3068
+ return { success: true };
3069
+ } catch (e) {
3070
+ const error = e;
3071
+ const exitCode = error.status ?? process.exitCode ?? 1;
3072
+ backend.exit(exitCode);
3073
+ return { success: true };
3074
+ }
3075
+ }
3076
+ var defense = null;
3077
+ function activateDefense(protocolToken) {
3078
+ if (defense) return;
3079
+ const _DateNow = Date.now;
3080
+ const degraded = { now: () => _DateNow(), timeOrigin: _DateNow() };
3081
+ Object.defineProperty(globalThis, "performance", {
3082
+ value: degraded,
3083
+ writable: true,
3084
+ configurable: true
3085
+ });
3086
+ const onViolation = wrapWasmCallback(
3087
+ "python3-worker",
3088
+ "onViolation",
3089
+ (v) => {
3090
+ postWorkerMessage(protocolToken, {
3091
+ type: "security-violation",
3092
+ violation: v
3093
+ });
3094
+ }
3095
+ );
3096
+ defense = new WorkerDefenseInDepth({
3097
+ excludeViolationTypes: [
3098
+ // SharedArrayBuffer/Atomics: Used by sync-fs-backend.ts for synchronous
3099
+ // filesystem communication between the WASM thread and the main thread.
3100
+ "shared_array_buffer",
3101
+ "atomics",
3102
+ // performance: Excluded because we replaced it above with a ms-precision
3103
+ // stub. Defense doesn't need to block it — it's already degraded.
3104
+ "performance_timing"
3105
+ ],
3106
+ onViolation
3107
+ });
3108
+ }
3109
+ process.on("uncaughtException", (e) => {
3110
+ if (!activeProtocolToken) {
3111
+ return;
3112
+ }
3113
+ const message = sanitizeHostErrorMessage(e.message);
3114
+ postWorkerMessage(activeProtocolToken, {
3115
+ success: false,
3116
+ error: `Worker uncaught exception: ${message}`
3117
+ });
3118
+ });
3119
+ var activeProtocolToken = null;
3120
+ if (parentPort) {
3121
+ if (workerData) {
3122
+ const input = workerData;
3123
+ activeProtocolToken = input.protocolToken;
3124
+ runPython(input).then((result) => {
3125
+ result.defenseStats = defense?.getStats();
3126
+ postWorkerMessage(input.protocolToken, result);
3127
+ }).catch((e) => {
3128
+ const message = sanitizeUnknownError(e);
3129
+ postWorkerMessage(input.protocolToken, {
3130
+ success: false,
3131
+ error: message,
3132
+ defenseStats: defense?.getStats()
3133
+ });
3134
+ });
3135
+ }
3136
+ }