@poe-platform/safe-bash 0.1.799 → 0.1.801

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 (1076) hide show
  1. package/README.md +48 -22
  2. package/dist/image-ast/index.browser.js +1503 -98
  3. package/dist/image-ast/index.js +1503 -98
  4. package/dist/mp4-ast/types.d.ts +1 -0
  5. package/dist/office-package/zip.d.ts +2 -0
  6. package/dist/office-package/zip.js +1 -1
  7. package/dist/pdf-ast/index.js +5 -4
  8. package/dist/safe-bash/chunks/{chunk-LUOFIVNI.js → chunk-3NDIFSNM.js} +3 -3
  9. package/dist/safe-bash/chunks/chunk-3R3AANOR.js +26 -0
  10. package/dist/safe-bash/chunks/{chunk-TRVGCN3U.js → chunk-45PK3NWI.js} +4 -4
  11. package/dist/safe-bash/chunks/{chunk-KHMGTPD6.js → chunk-46Z5E5EV.js} +2 -2
  12. package/dist/safe-bash/chunks/{chunk-XB3B7KMM.js → chunk-6O77NL2S.js} +1 -1
  13. package/dist/safe-bash/chunks/{chunk-T3JTVIEP.js → chunk-6PAVEFT3.js} +1 -1
  14. package/dist/safe-bash/chunks/{chunk-PYVEAFJM.js → chunk-74GHTNJA.js} +3 -2
  15. package/dist/safe-bash/chunks/{chunk-LQHGH25W.js → chunk-7R5BDCG7.js} +1 -1
  16. package/dist/safe-bash/chunks/{chunk-WUNK5NXJ.js → chunk-7VNF5BFF.js} +1140 -1660
  17. package/dist/safe-bash/chunks/{chunk-NHOXKQNE.js → chunk-A7XEHALN.js} +6 -6
  18. package/dist/safe-bash/chunks/{chunk-MHZ24KEI.js → chunk-AM5ESLPH.js} +1 -1
  19. package/dist/safe-bash/chunks/{chunk-3L3T6LYV.js → chunk-AUSNDQTJ.js} +1 -1
  20. package/dist/safe-bash/chunks/{chunk-YG5WAHK7.js → chunk-B7TAL7S5.js} +1 -3
  21. package/dist/safe-bash/chunks/{chunk-K7IQZE7D.js → chunk-C5OWC2TL.js} +1 -1
  22. package/dist/safe-bash/chunks/{chunk-F3RV2F72.js → chunk-CHYGPFVM.js} +1 -1
  23. package/dist/safe-bash/chunks/{chunk-M4CFCXHN.js → chunk-CS4MNM6I.js} +1 -1
  24. package/dist/safe-bash/chunks/{chunk-H6JW3E4F.js → chunk-CTVWDACF.js} +1 -1
  25. package/dist/safe-bash/chunks/{chunk-KTGR4U57.js → chunk-D3ANYGMC.js} +2 -3
  26. package/dist/safe-bash/chunks/{chunk-ENR3HB2B.js → chunk-E7OYNDGL.js} +1 -2
  27. package/dist/safe-bash/chunks/{chunk-SOZK5JVX.js → chunk-FBUCWVTE.js} +1 -1
  28. package/dist/safe-bash/chunks/{chunk-NX2SQVON.js → chunk-FNDNHAGE.js} +46 -27
  29. package/dist/safe-bash/chunks/{chunk-KCVSVD65.js → chunk-I5HZ4FGE.js} +1 -1
  30. package/dist/safe-bash/chunks/{chunk-KMH2DF3I.js → chunk-ICFDYV64.js} +7 -2
  31. package/dist/safe-bash/chunks/{chunk-T5KKDMYB.js → chunk-IVRQ4BXL.js} +7 -1
  32. package/dist/safe-bash/chunks/{chunk-KV7PKOHV.js → chunk-IWDICZVK.js} +1 -1
  33. package/dist/safe-bash/chunks/{chunk-I4OAEOP6.js → chunk-J42RIHHJ.js} +1 -1
  34. package/dist/safe-bash/chunks/chunk-K6VCD7IY.js +106 -0
  35. package/dist/safe-bash/chunks/{chunk-63FXVDGF.js → chunk-LVOBFF4D.js} +1 -1
  36. package/dist/safe-bash/chunks/{chunk-U5NUZPCC.js → chunk-MHMMRCYC.js} +1 -1
  37. package/dist/safe-bash/chunks/{chunk-6HZYFL3H.js → chunk-NR3EM4LS.js} +1 -1
  38. package/dist/safe-bash/chunks/{chunk-VYZTG3GV.js → chunk-NZQXYWA3.js} +1 -1
  39. package/dist/safe-bash/chunks/{chunk-JSVX4VIA.js → chunk-OQRVVGR6.js} +3 -2
  40. package/dist/safe-bash/chunks/{chunk-B3DDEDH2.js → chunk-OV6IHKO6.js} +2 -2
  41. package/dist/safe-bash/chunks/{chunk-SPYL72GN.js → chunk-PQRAK7HU.js} +1196 -5781
  42. package/dist/safe-bash/chunks/chunk-SZH7EJLD.js +9221 -0
  43. package/dist/safe-bash/chunks/{chunk-AKC46AF6.js → chunk-TFIBK2GI.js} +8 -41
  44. package/dist/safe-bash/chunks/{chunk-ZNAFMYIA.js → chunk-UE5KZDEK.js} +2 -2
  45. package/dist/safe-bash/chunks/{chunk-QU3BVQ53.js → chunk-UTBUUFDM.js} +1 -1
  46. package/dist/safe-bash/chunks/{chunk-6IBTC4YL.js → chunk-VQDD3G76.js} +93 -39
  47. package/dist/safe-bash/chunks/{chunk-IUTD5FH5.js → chunk-VTH3MLDU.js} +2 -7
  48. package/dist/safe-bash/chunks/{chunk-LLZCZ24K.js → chunk-XVOSKJE2.js} +1 -1
  49. package/dist/safe-bash/chunks/{csvkit-W2UEKH6P.js → csvkit-TACDU7FC.js} +3 -3
  50. package/dist/safe-bash/chunks/{ffmpeg-42CGASMV.js → ffmpeg-WTC3TEFI.js} +2 -2
  51. package/dist/safe-bash/chunks/{gh-26GYLH6D.js → gh-6WU6PXL4.js} +2 -2
  52. package/dist/safe-bash/chunks/{git-YREKMUVD.js → git-EFZIGJW4.js} +2 -2
  53. package/dist/safe-bash/chunks/{imagemagick-3YIX4XO2.js → imagemagick-EIEYGWPF.js} +2 -2
  54. package/dist/safe-bash/chunks/{implementation-E3YMKU3Z.js → implementation-MLFHUQ5M.js} +2 -2
  55. package/dist/safe-bash/chunks/mmdc-ROQJT5HQ.js +118 -0
  56. package/dist/safe-bash/chunks/{pdfimages-UE2UISP2.js → pdfimages-DW7LWXFI.js} +2 -2
  57. package/dist/safe-bash/chunks/{pdfinfo-RGARKLI5.js → pdfinfo-TIP6XLUQ.js} +4 -12
  58. package/dist/safe-bash/chunks/{pdftk-JY3WVCCC.js → pdftk-DMG22ITZ.js} +2 -2
  59. package/dist/safe-bash/chunks/{pdftoppm-GPD3BMPY.js → pdftoppm-WNDYR72T.js} +2 -2
  60. package/dist/safe-bash/chunks/{pdftotext-K7GQ2QJZ.js → pdftotext-5IPZ4NI7.js} +2 -2
  61. package/dist/safe-bash/chunks/{qpdf-F4U7WUSU.js → qpdf-TTX2DIUA.js} +2 -2
  62. package/dist/safe-bash/chunks/{sips-RWENS7X5.js → sips-XYS46JPJ.js} +2 -2
  63. package/dist/safe-bash/chunks/{soffice-IT6W2C5F.js → soffice-TU73E5KL.js} +2 -2
  64. package/dist/safe-bash/chunks/{wkhtmltopdf-JYNDAHIZ.js → wkhtmltopdf-FSZ2CHGE.js} +2 -2
  65. package/dist/safe-bash/command-chunks/{chunk-QBGA56UH.js → chunk-2ELYGJDD.js} +7 -7
  66. package/dist/safe-bash/command-chunks/chunk-2FGJYFWZ.js +44 -0
  67. package/dist/safe-bash/command-chunks/chunk-2H4JTFIL.js +53 -0
  68. package/dist/safe-bash/command-chunks/{chunk-52PCQXD2.js → chunk-2NHI5F5S.js} +2 -1
  69. package/dist/safe-bash/command-chunks/{chunk-HDKVO47G.js → chunk-2SQEIUGJ.js} +3 -3
  70. package/dist/safe-bash/command-chunks/chunk-364TMWBT.js +946 -0
  71. package/dist/safe-bash/command-chunks/chunk-3E2OIS2J.js +7037 -0
  72. package/dist/safe-bash/command-chunks/chunk-3HHCU5YU.js +380 -0
  73. package/dist/safe-bash/command-chunks/{chunk-TF6OA2GK.js → chunk-3NV3HYT2.js} +1 -1
  74. package/dist/safe-bash/command-chunks/chunk-4B7Y7S6E.js +61 -0
  75. package/dist/safe-bash/command-chunks/{chunk-LLCXZKZ6.js → chunk-4BB2SWJ5.js} +2 -2
  76. package/dist/safe-bash/command-chunks/{chunk-IEXHHNOF.js → chunk-4J5CZ2DP.js} +2 -7
  77. package/dist/safe-bash/command-chunks/{chunk-WDHI3S6Y.js → chunk-4OOUQTQO.js} +1 -1
  78. package/dist/safe-bash/command-chunks/chunk-4ZHMW6F5.js +104 -0
  79. package/dist/safe-bash/command-chunks/{chunk-YMONDXET.js → chunk-4ZQWGOZB.js} +2 -2
  80. package/dist/safe-bash/command-chunks/chunk-5BSTFCXG.js +553 -0
  81. package/dist/safe-bash/command-chunks/{chunk-MKQVQMXO.js → chunk-5LU4UCBR.js} +1 -1
  82. package/dist/safe-bash/command-chunks/chunk-5PWJG2UK.js +174 -0
  83. package/dist/safe-bash/command-chunks/chunk-5TBUOBDE.js +346 -0
  84. package/dist/safe-bash/command-chunks/{chunk-JMPP4TCW.js → chunk-5UBXNSFZ.js} +3 -2
  85. package/dist/safe-bash/command-chunks/chunk-5XY4DTNG.js +34 -0
  86. package/dist/safe-bash/command-chunks/chunk-5ZMZ573Q.js +140 -0
  87. package/dist/safe-bash/command-chunks/{chunk-3NG75MOB.js → chunk-67GQA75T.js} +1 -1
  88. package/dist/safe-bash/command-chunks/chunk-67QKREJK.js +347 -0
  89. package/dist/safe-bash/command-chunks/{chunk-L6SU4S26.js → chunk-6B7WQIKB.js} +0 -7
  90. package/dist/safe-bash/command-chunks/chunk-6BNTBWIK.js +327 -0
  91. package/dist/safe-bash/command-chunks/chunk-6EPHJGGF.js +23 -0
  92. package/dist/safe-bash/command-chunks/chunk-6F4XCVON.js +266 -0
  93. package/dist/safe-bash/command-chunks/chunk-6KJ3LPI2.js +94 -0
  94. package/dist/safe-bash/command-chunks/{chunk-HLDTOR7M.js → chunk-6ZVI7LUY.js} +1 -1
  95. package/dist/safe-bash/command-chunks/{chunk-X6NJC3IC.js → chunk-75OFBY5R.js} +1 -1
  96. package/dist/safe-bash/command-chunks/chunk-7K6JYKPJ.js +422 -0
  97. package/dist/safe-bash/command-chunks/chunk-7N2LI2KO.js +206 -0
  98. package/dist/safe-bash/command-chunks/{chunk-MRW5HD2D.js → chunk-7O3E4LPT.js} +4 -22
  99. package/dist/safe-bash/command-chunks/chunk-7U7EXOXX.js +1392 -0
  100. package/dist/safe-bash/command-chunks/{chunk-6CYTRQ24.js → chunk-7VTKQUA5.js} +20 -17
  101. package/dist/safe-bash/command-chunks/{chunk-BZPAWTUL.js → chunk-AEF5BA3D.js} +1 -1
  102. package/dist/safe-bash/command-chunks/{pptx-GBPNWNEP-7EQEVXV5.js → chunk-AI5JAXQF.js} +34820 -18029
  103. package/dist/safe-bash/command-chunks/{chunk-63R3FEZJ.js → chunk-AIV5BF5W.js} +1 -1
  104. package/dist/safe-bash/command-chunks/{chunk-AYUTO323.js → chunk-AKJG2XD3.js} +2 -18
  105. package/dist/safe-bash/command-chunks/{chunk-J34TZVMW.js → chunk-ALDC4XP4.js} +0 -5
  106. package/dist/safe-bash/command-chunks/chunk-AMO3THU4.js +105 -0
  107. package/dist/safe-bash/command-chunks/chunk-ARBYOQUZ.js +65 -0
  108. package/dist/safe-bash/command-chunks/chunk-BAGCY35S.js +231 -0
  109. package/dist/safe-bash/command-chunks/chunk-BAXU7B5Z.js +101 -0
  110. package/dist/safe-bash/command-chunks/{chunk-44AHAB5O.js → chunk-BDSMROQZ.js} +1 -4
  111. package/dist/safe-bash/command-chunks/chunk-BNOU5YQS.js +182 -0
  112. package/dist/safe-bash/command-chunks/{chunk-4ZALPDBV.js → chunk-BPE5INLI.js} +2 -2
  113. package/dist/safe-bash/command-chunks/{chunk-OT4LZMLB.js → chunk-BR73BIOW.js} +1 -1
  114. package/dist/safe-bash/command-chunks/chunk-C5YYCQHW.js +1444 -0
  115. package/dist/safe-bash/command-chunks/chunk-C7I25AAL.js +25 -0
  116. package/dist/safe-bash/command-chunks/{chunk-4ONEXMD3.js → chunk-CAP7ZJSY.js} +8 -8
  117. package/dist/safe-bash/command-chunks/{chunk-DWFLVJC6.js → chunk-CCRHMAU5.js} +2 -1
  118. package/dist/safe-bash/command-chunks/chunk-CQ5YGOGB.js +150 -0
  119. package/dist/safe-bash/command-chunks/{chunk-JCNNOMBV.js → chunk-CQTRW45K.js} +3 -2
  120. package/dist/safe-bash/command-chunks/{chunk-N2F74VRO.js → chunk-CZ7EN3JG.js} +1 -1
  121. package/dist/safe-bash/command-chunks/chunk-DB453IE6.js +122 -0
  122. package/dist/safe-bash/command-chunks/{chunk-KKG4BAFZ.js → chunk-DIEPXUM4.js} +6 -0
  123. package/dist/safe-bash/command-chunks/chunk-DOKKNRRM.js +87 -0
  124. package/dist/safe-bash/command-chunks/{chunk-2PX5B7T5.js → chunk-DQAVUDDX.js} +2 -2
  125. package/dist/safe-bash/command-chunks/chunk-DT7BCTWY.js +249 -0
  126. package/dist/safe-bash/command-chunks/{chunk-6BETHLXZ.js → chunk-DZCY63VJ.js} +13 -11
  127. package/dist/safe-bash/command-chunks/{chunk-QUENU6GM.js → chunk-E55UKBIE.js} +3 -3
  128. package/dist/safe-bash/command-chunks/chunk-EK6YNAXT.js +343 -0
  129. package/dist/safe-bash/command-chunks/chunk-EQ4HV54N.js +22 -0
  130. package/dist/safe-bash/command-chunks/{chunk-HLGKIZ25.js → chunk-F6OYH562.js} +2 -0
  131. package/dist/safe-bash/command-chunks/{chunk-MC3VWLIZ.js → chunk-FDBUV4HJ.js} +28 -19
  132. package/dist/safe-bash/command-chunks/{chunk-7FKUC34S.js → chunk-FPVUD6TH.js} +6 -3
  133. package/dist/safe-bash/command-chunks/chunk-FXELCPFX.js +195 -0
  134. package/dist/safe-bash/command-chunks/chunk-FXOA7RBK.js +42 -0
  135. package/dist/safe-bash/command-chunks/{chunk-LPORMIZS.js → chunk-FZTK4MFI.js} +9 -9
  136. package/dist/safe-bash/command-chunks/{chunk-K543PB3I.js → chunk-G66QUHIZ.js} +6 -35
  137. package/dist/safe-bash/command-chunks/chunk-GFQZCKO6.js +272 -0
  138. package/dist/safe-bash/command-chunks/{chunk-CU5RLO62.js → chunk-GLOZX57Y.js} +92 -18
  139. package/dist/safe-bash/command-chunks/chunk-GMIHJYDG.js +331 -0
  140. package/dist/safe-bash/command-chunks/chunk-GOB777HR.js +97 -0
  141. package/dist/safe-bash/command-chunks/chunk-GRBWW4SG.js +48 -0
  142. package/dist/safe-bash/command-chunks/{chunk-PPNBNFAU.js → chunk-GYQ2HAKQ.js} +8 -8
  143. package/dist/safe-bash/command-chunks/chunk-H622NS6Z.js +11 -0
  144. package/dist/safe-bash/command-chunks/{chunk-UI32HWGS.js → chunk-HMOZ6XVJ.js} +1 -1
  145. package/dist/safe-bash/command-chunks/{chunk-AVSPNLWV.js → chunk-I237SNW5.js} +1 -1
  146. package/dist/safe-bash/command-chunks/{chunk-43GSSUAY.js → chunk-II77KPZN.js} +5 -5
  147. package/dist/safe-bash/command-chunks/{chunk-ZS3QPNUL.js → chunk-IR2BY7EL.js} +21 -6
  148. package/dist/safe-bash/command-chunks/{chunk-SG424QWS.js → chunk-JDYXY44P.js} +2 -2
  149. package/dist/safe-bash/command-chunks/chunk-JNZ3CVAE.js +147 -0
  150. package/dist/safe-bash/command-chunks/{chunk-4QJOYXVB.js → chunk-JV7LBUTP.js} +1 -1
  151. package/dist/safe-bash/command-chunks/{chunk-IKS2YXZQ.js → chunk-K67MWWWH.js} +3 -3
  152. package/dist/safe-bash/command-chunks/chunk-KFVV7ZJO.js +216 -0
  153. package/dist/safe-bash/command-chunks/{chunk-G4PNVO6Z.js → chunk-KP7AO66M.js} +1 -1
  154. package/dist/safe-bash/command-chunks/{chunk-KMCZ6P4O.js → chunk-KQLD3AED.js} +68 -7
  155. package/dist/safe-bash/command-chunks/chunk-KWESKQHR.js +25 -0
  156. package/dist/safe-bash/command-chunks/{chunk-YZ5SVZFD.js → chunk-KXU3IRUO.js} +3 -3
  157. package/dist/safe-bash/command-chunks/{chunk-C7IHMJEW.js → chunk-KZC5UWFF.js} +2 -2
  158. package/dist/safe-bash/command-chunks/{chunk-2WRTLCGK.js → chunk-LAOM65EE.js} +5 -5
  159. package/dist/safe-bash/command-chunks/chunk-LE5LZNHE.js +204 -0
  160. package/dist/safe-bash/command-chunks/{chunk-HFII3QYO.js → chunk-LWS62ISU.js} +46 -32
  161. package/dist/safe-bash/command-chunks/{chunk-BZDDAPSV.js → chunk-LWSBAWLT.js} +1 -1
  162. package/dist/safe-bash/command-chunks/chunk-MDH5T4OS.js +41 -0
  163. package/dist/safe-bash/command-chunks/{chunk-X7TM3AKW.js → chunk-MIXBO6U7.js} +20 -7
  164. package/dist/safe-bash/command-chunks/chunk-MM6HU6CX.js +20 -0
  165. package/dist/safe-bash/command-chunks/{chunk-MYJAZ3U2.js → chunk-MPL2466A.js} +2 -2
  166. package/dist/safe-bash/command-chunks/{chunk-HLBX5IRS.js → chunk-MQFIPHIQ.js} +46 -81
  167. package/dist/safe-bash/command-chunks/{chunk-ZJBR5Q5I.js → chunk-MSFXC3OC.js} +4 -4
  168. package/dist/safe-bash/command-chunks/{chunk-NI7MKJPN.js → chunk-MTQH74CF.js} +3 -55
  169. package/dist/safe-bash/command-chunks/chunk-MWUZZWXK.js +354 -0
  170. package/dist/safe-bash/command-chunks/chunk-N4PFUSRM.js +35 -0
  171. package/dist/safe-bash/command-chunks/chunk-NCD7PEWH.js +298 -0
  172. package/dist/safe-bash/command-chunks/chunk-NFGI5IGF.js +266 -0
  173. package/dist/safe-bash/command-chunks/{chunk-I3K5RYU4.js → chunk-NKFYQSES.js} +73 -26
  174. package/dist/safe-bash/command-chunks/{chunk-KVFCSLKK.js → chunk-NXEQ3ESQ.js} +6 -0
  175. package/dist/safe-bash/command-chunks/{chunk-NGWB2YBL.js → chunk-O4JQSB7O.js} +1 -1
  176. package/dist/safe-bash/command-chunks/{chunk-7L24L4UO.js → chunk-OQU6UT6X.js} +2 -20
  177. package/dist/safe-bash/command-chunks/{chunk-3VGGYEDH.js → chunk-ORYGZYKW.js} +4 -3
  178. package/dist/safe-bash/command-chunks/{chunk-ZXKW7SJ2.js → chunk-OYYV7ZAF.js} +2 -2
  179. package/dist/safe-bash/command-chunks/chunk-P2N33UMN.js +270 -0
  180. package/dist/safe-bash/command-chunks/{chunk-Q7Q5GM5S.js → chunk-P5APDEFB.js} +2 -2
  181. package/dist/safe-bash/command-chunks/{chunk-X2YQLGKS.js → chunk-PCEFOYA3.js} +240 -148
  182. package/dist/safe-bash/command-chunks/{chunk-OLQG7ZCN.js → chunk-PEF7K3UQ.js} +136 -75
  183. package/dist/safe-bash/command-chunks/chunk-PII4YEZW.js +123 -0
  184. package/dist/safe-bash/command-chunks/{chunk-AIRGA2SU.js → chunk-PMBFZXTK.js} +1 -1
  185. package/dist/safe-bash/command-chunks/{chunk-ZT4KSS2V.js → chunk-PTT3I223.js} +1 -1
  186. package/dist/safe-bash/command-chunks/{chunk-4Y3WVMK4.js → chunk-PV66YWHB.js} +1 -0
  187. package/dist/safe-bash/command-chunks/chunk-Q3EWDEUQ.js +185 -0
  188. package/dist/safe-bash/command-chunks/{chunk-AXK3H4PX.js → chunk-QJ33BHI4.js} +1 -1
  189. package/dist/safe-bash/command-chunks/chunk-QKFSRZGQ.js +1091 -0
  190. package/dist/safe-bash/command-chunks/{chunk-JZSNU2MY.js → chunk-QKJLP53H.js} +2 -2
  191. package/dist/safe-bash/command-chunks/{chunk-VVI4Z73I.js → chunk-QP4R6GLA.js} +5 -1
  192. package/dist/safe-bash/command-chunks/chunk-RMWQAAO5.js +2488 -0
  193. package/dist/safe-bash/command-chunks/{chunk-QDTBMSBE.js → chunk-RO62EWX6.js} +2 -2
  194. package/dist/safe-bash/command-chunks/{chunk-HRLIAMXC.js → chunk-RZZI24ZE.js} +7 -6
  195. package/dist/safe-bash/command-chunks/{chunk-PFAADCB5.js → chunk-SDNBCQ3X.js} +10 -24
  196. package/dist/safe-bash/command-chunks/chunk-SEM36PG5.js +11 -0
  197. package/dist/safe-bash/command-chunks/{chunk-36O5OT7E.js → chunk-T35Y7YQD.js} +1 -1
  198. package/dist/safe-bash/command-chunks/{chunk-ESMCX3YV.js → chunk-TGSNCQSR.js} +710 -143
  199. package/dist/safe-bash/command-chunks/chunk-TIOCQVUQ.js +557 -0
  200. package/dist/safe-bash/command-chunks/{chunk-T5H5UJQ3.js → chunk-TNOA7FCQ.js} +1 -1
  201. package/dist/safe-bash/command-chunks/{chunk-GN2TKLE7.js → chunk-TS65BJHG.js} +5 -5
  202. package/dist/safe-bash/command-chunks/chunk-TSCGT46G.js +363 -0
  203. package/dist/safe-bash/command-chunks/chunk-UG7SMZFF.js +178 -0
  204. package/dist/safe-bash/command-chunks/{chunk-KBEURXFF.js → chunk-UN6WS55J.js} +3 -3
  205. package/dist/safe-bash/command-chunks/chunk-UXSR5BZH.js +136 -0
  206. package/dist/safe-bash/command-chunks/{chunk-SX2X3IH4.js → chunk-V2V5OCL3.js} +1 -1
  207. package/dist/safe-bash/command-chunks/chunk-V6BEDRMQ.js +112 -0
  208. package/dist/safe-bash/command-chunks/chunk-V7A7DRTU.js +293 -0
  209. package/dist/safe-bash/command-chunks/{chunk-5SHGJ7NO.js → chunk-VA5ZHYYA.js} +73 -33
  210. package/dist/safe-bash/command-chunks/{chunk-J4PEQWSF.js → chunk-VGG2DL5Q.js} +0 -1
  211. package/dist/safe-bash/command-chunks/chunk-VPR5LQYX.js +1228 -0
  212. package/dist/safe-bash/command-chunks/{chunk-EIVW3X3N.js → chunk-VSRGNQCP.js} +11 -6
  213. package/dist/safe-bash/command-chunks/{chunk-TYVCKQDH.js → chunk-VXSLJH7G.js} +56 -6
  214. package/dist/safe-bash/command-chunks/{chunk-PXYOWWMV.js → chunk-W7RAD4EW.js} +4 -3
  215. package/dist/safe-bash/command-chunks/{src-UJOWAS2S.js → chunk-WD3ERGRY.js} +77 -277
  216. package/dist/safe-bash/command-chunks/{chunk-5ZSM4UFN.js → chunk-WECIOOQB.js} +8 -64
  217. package/dist/safe-bash/command-chunks/{chunk-YFSDDFGV.js → chunk-WH627NJL.js} +446 -53
  218. package/dist/safe-bash/command-chunks/chunk-WNE7FPVR.js +236 -0
  219. package/dist/safe-bash/command-chunks/{chunk-UKS2XJZI.js → chunk-WPYIOKE3.js} +4 -4
  220. package/dist/safe-bash/command-chunks/{chunk-HHP343KT.js → chunk-WTECBRU4.js} +1 -1
  221. package/dist/safe-bash/command-chunks/{chunk-AO6Z5EQ7.js → chunk-WVE64WM2.js} +6 -5
  222. package/dist/safe-bash/command-chunks/chunk-WVHONVZ4.js +594 -0
  223. package/dist/safe-bash/command-chunks/chunk-XIIBTGC5.js +580 -0
  224. package/dist/safe-bash/command-chunks/chunk-XJXU3VVH.js +737 -0
  225. package/dist/safe-bash/command-chunks/chunk-XNLFHHOC.js +63 -0
  226. package/dist/safe-bash/command-chunks/{chunk-XAFSZDY2.js → chunk-XS72HTMA.js} +11 -0
  227. package/dist/safe-bash/command-chunks/chunk-Y5INTD6S.js +220 -0
  228. package/dist/safe-bash/command-chunks/chunk-YIQACGEW.js +43 -0
  229. package/dist/safe-bash/command-chunks/chunk-YOF7R4OY.js +80 -0
  230. package/dist/safe-bash/command-chunks/{chunk-VZHRZMS7.js → chunk-YOFC45RK.js} +1 -1
  231. package/dist/safe-bash/command-chunks/{chunk-2FUAW6GO.js → chunk-Z45N42QC.js} +75 -11
  232. package/dist/safe-bash/command-chunks/chunk-ZHUWOUWB.js +618 -0
  233. package/dist/safe-bash/command-chunks/{chunk-OPUJSTHS.js → chunk-ZYHTWNAE.js} +215 -67
  234. package/dist/safe-bash/command-chunks/chunk-ZYXH3B66.js +636 -0
  235. package/dist/safe-bash/command-chunks/{model-store-L35QTZMJ.js → model-store-WPKMRPV4.js} +2 -2
  236. package/dist/safe-bash/command-chunks/pptx-7G52EJ6L-4JACH5FB.js +625 -0
  237. package/dist/safe-bash/command-chunks/python-worker-source-TYOFJMCW.js +4 -0
  238. package/dist/safe-bash/command-chunks/src-ICMQISAA.js +501 -0
  239. package/dist/safe-bash/commands/archive/create.d.ts +1 -17
  240. package/dist/safe-bash/commands/archive/create.js +1 -252
  241. package/dist/safe-bash/commands/archive/extract.d.ts +1 -11
  242. package/dist/safe-bash/commands/archive/extract.js +1 -640
  243. package/dist/safe-bash/commands/archive/format.d.ts +1 -32
  244. package/dist/safe-bash/commands/archive/format.js +1 -225
  245. package/dist/safe-bash/commands/archive/index.d.ts +5 -10
  246. package/dist/safe-bash/commands/archive/index.js +6 -931
  247. package/dist/safe-bash/commands/archive/listing.d.ts +1 -2
  248. package/dist/safe-bash/commands/archive/listing.js +1 -21
  249. package/dist/safe-bash/commands/archive/modes.d.ts +1 -5
  250. package/dist/safe-bash/commands/archive/modes.js +1 -182
  251. package/dist/safe-bash/commands/archive/options.d.ts +1 -53
  252. package/dist/safe-bash/commands/archive/options.js +1 -462
  253. package/dist/safe-bash/commands/archive/stream.d.ts +1 -22
  254. package/dist/safe-bash/commands/archive/stream.js +1 -188
  255. package/dist/safe-bash/commands/archive/transform.d.ts +1 -16
  256. package/dist/safe-bash/commands/archive/transform.js +1 -85
  257. package/dist/safe-bash/commands/archive/unzip/arguments.d.ts +1 -53
  258. package/dist/safe-bash/commands/archive/unzip/arguments.js +1 -322
  259. package/dist/safe-bash/commands/archive/unzip/safety.d.ts +1 -32
  260. package/dist/safe-bash/commands/archive/unzip/safety.js +1 -295
  261. package/dist/safe-bash/commands/archive/unzip.d.ts +1 -3
  262. package/dist/safe-bash/commands/archive/unzip.js +1 -398
  263. package/dist/safe-bash/commands/archive/zip/aes.d.ts +1 -17
  264. package/dist/safe-bash/commands/archive/zip/aes.js +1 -156
  265. package/dist/safe-bash/commands/archive/zip/comments.d.ts +1 -17
  266. package/dist/safe-bash/commands/archive/zip/comments.js +1 -83
  267. package/dist/safe-bash/commands/archive/zip/crc.d.ts +1 -1
  268. package/dist/safe-bash/commands/archive/zip/crc.js +1 -1
  269. package/dist/safe-bash/commands/archive/zip/crypto.d.ts +1 -19
  270. package/dist/safe-bash/commands/archive/zip/crypto.js +1 -118
  271. package/dist/safe-bash/commands/archive/zip/dates.d.ts +1 -4
  272. package/dist/safe-bash/commands/archive/zip/dates.js +1 -66
  273. package/dist/safe-bash/commands/archive/zip/environment.d.ts +1 -2
  274. package/dist/safe-bash/commands/archive/zip/environment.js +1 -62
  275. package/dist/safe-bash/commands/archive/zip/grow.d.ts +1 -3
  276. package/dist/safe-bash/commands/archive/zip/grow.js +1 -2
  277. package/dist/safe-bash/commands/archive/zip/help.d.ts +1 -4
  278. package/dist/safe-bash/commands/archive/zip/help.js +1 -182
  279. package/dist/safe-bash/commands/archive/zip/line-endings.d.ts +1 -2
  280. package/dist/safe-bash/commands/archive/zip/line-endings.js +1 -194
  281. package/dist/safe-bash/commands/archive/zip/log.d.ts +1 -22
  282. package/dist/safe-bash/commands/archive/zip/log.js +1 -159
  283. package/dist/safe-bash/commands/archive/zip/lzma.d.ts +1 -9
  284. package/dist/safe-bash/commands/archive/zip/lzma.js +1 -40
  285. package/dist/safe-bash/commands/archive/zip/move.d.ts +1 -11
  286. package/dist/safe-bash/commands/archive/zip/move.js +1 -59
  287. package/dist/safe-bash/commands/archive/zip/names.d.ts +1 -2
  288. package/dist/safe-bash/commands/archive/zip/names.js +1 -33
  289. package/dist/safe-bash/commands/archive/zip/options.d.ts +1 -13
  290. package/dist/safe-bash/commands/archive/zip/options.js +1 -124
  291. package/dist/safe-bash/commands/archive/zip/repair.d.ts +1 -10
  292. package/dist/safe-bash/commands/archive/zip/repair.js +1 -392
  293. package/dist/safe-bash/commands/archive/zip/safety.d.ts +1 -54
  294. package/dist/safe-bash/commands/archive/zip/safety.js +1 -360
  295. package/dist/safe-bash/commands/archive/zip/sfx.d.ts +1 -4
  296. package/dist/safe-bash/commands/archive/zip/sfx.js +1 -52
  297. package/dist/safe-bash/commands/archive/zip/test-command.d.ts +1 -5
  298. package/dist/safe-bash/commands/archive/zip/test-command.js +1 -101
  299. package/dist/safe-bash/commands/archive/zip/volumes.d.ts +1 -21
  300. package/dist/safe-bash/commands/archive/zip/volumes.js +1 -281
  301. package/dist/safe-bash/commands/archive/zip/zip64.d.ts +1 -30
  302. package/dist/safe-bash/commands/archive/zip/zip64.js +1 -227
  303. package/dist/safe-bash/commands/archive/zip-format.d.ts +1 -68
  304. package/dist/safe-bash/commands/archive/zip-format.js +1 -1075
  305. package/dist/safe-bash/commands/archive/zip.d.ts +1 -3
  306. package/dist/safe-bash/commands/archive/zip.js +1 -1523
  307. package/dist/safe-bash/commands/awk/index.d.ts +2 -0
  308. package/dist/safe-bash/commands/awk/index.js +2 -0
  309. package/dist/safe-bash/commands/bytes/compression/index.js +4 -2
  310. package/dist/safe-bash/commands/copy-preserve.d.ts +1 -0
  311. package/dist/safe-bash/commands/csplit/index.browser.js +2 -2
  312. package/dist/safe-bash/commands/curl/index.d.ts +2 -0
  313. package/dist/safe-bash/commands/curl/index.js +2 -0
  314. package/dist/safe-bash/commands/diff/index.d.ts +2 -0
  315. package/dist/safe-bash/commands/diff/index.js +2 -0
  316. package/dist/safe-bash/commands/diff-patch/diff-format.d.ts +1 -10
  317. package/dist/safe-bash/commands/diff-patch/diff-format.js +1 -237
  318. package/dist/safe-bash/commands/diff-patch/diff-options.d.ts +1 -38
  319. package/dist/safe-bash/commands/diff-patch/diff-options.js +1 -261
  320. package/dist/safe-bash/commands/diff-patch/diff-output.d.ts +1 -20
  321. package/dist/safe-bash/commands/diff-patch/diff-output.js +1 -290
  322. package/dist/safe-bash/commands/diff-patch/diff.d.ts +1 -2
  323. package/dist/safe-bash/commands/diff-patch/diff.js +1 -656
  324. package/dist/safe-bash/commands/diff-patch/index.d.ts +4 -5
  325. package/dist/safe-bash/commands/diff-patch/index.js +8 -333
  326. package/dist/safe-bash/commands/diff-patch/patch-envelope.d.ts +1 -2
  327. package/dist/safe-bash/commands/diff-patch/patch-envelope.js +1 -63
  328. package/dist/safe-bash/commands/diff-patch/patch-formats.d.ts +1 -7
  329. package/dist/safe-bash/commands/diff-patch/patch-formats.js +1 -264
  330. package/dist/safe-bash/commands/diff-patch/patch-gnu-paths.d.ts +1 -41
  331. package/dist/safe-bash/commands/diff-patch/patch-gnu-paths.js +1 -263
  332. package/dist/safe-bash/commands/diff-patch/patch-gnu-reject.d.ts +1 -3
  333. package/dist/safe-bash/commands/diff-patch/patch-gnu-reject.js +1 -100
  334. package/dist/safe-bash/commands/diff-patch/patch-path.d.ts +1 -3
  335. package/dist/safe-bash/commands/diff-patch/patch-path.js +1 -91
  336. package/dist/safe-bash/commands/diff-patch/patch-publication.d.ts +1 -13
  337. package/dist/safe-bash/commands/diff-patch/patch-publication.js +1 -107
  338. package/dist/safe-bash/commands/diff-patch/patch.d.ts +1 -2
  339. package/dist/safe-bash/commands/diff-patch/patch.js +1 -653
  340. package/dist/safe-bash/commands/diff-patch/shared.d.ts +1 -53
  341. package/dist/safe-bash/commands/diff-patch/shared.js +1 -267
  342. package/dist/safe-bash/commands/diff-patch/unified.d.ts +1 -52
  343. package/dist/safe-bash/commands/diff-patch/unified.js +1 -385
  344. package/dist/safe-bash/commands/directory-admission.d.ts +1 -3
  345. package/dist/safe-bash/commands/directory-admission.js +1 -26
  346. package/dist/safe-bash/commands/docx/index.browser.js +1 -1
  347. package/dist/safe-bash/commands/execution.js +19 -13
  348. package/dist/safe-bash/commands/factor/index.browser.js +2 -2
  349. package/dist/safe-bash/commands/filesystem.d.ts +1 -1
  350. package/dist/safe-bash/commands/filesystem.js +17 -13
  351. package/dist/safe-bash/commands/find/index.d.ts +2 -0
  352. package/dist/safe-bash/commands/find/index.js +2 -0
  353. package/dist/safe-bash/commands/find-format.d.ts +1 -20
  354. package/dist/safe-bash/commands/find-format.js +1 -161
  355. package/dist/safe-bash/commands/find.d.ts +2 -18
  356. package/dist/safe-bash/commands/find.js +2 -1236
  357. package/dist/safe-bash/commands/getopt/index.browser.js +2 -2
  358. package/dist/safe-bash/commands/gzip/index.d.ts +2 -0
  359. package/dist/safe-bash/commands/gzip/index.js +2 -0
  360. package/dist/safe-bash/commands/hexdump/index.browser.js +2 -2
  361. package/dist/safe-bash/commands/htmlq/index.d.ts +1 -1
  362. package/dist/safe-bash/commands/iconv/index.browser.js +2 -2
  363. package/dist/safe-bash/commands/line-endings/index.browser.js +2 -2
  364. package/dist/safe-bash/commands/line-endings/index.d.ts +1 -1
  365. package/dist/safe-bash/commands/line-endings/index.js +1 -262
  366. package/dist/safe-bash/commands/llm/index.browser.js +4 -2
  367. package/dist/safe-bash/commands/llm/providers/index.browser.js +1 -1
  368. package/dist/safe-bash/commands/mdq/index.browser.js +3 -3
  369. package/dist/safe-bash/commands/media/index.browser.js +1 -1
  370. package/dist/safe-bash/commands/metadata/chmod.d.ts +1 -4
  371. package/dist/safe-bash/commands/metadata/chmod.js +2 -63
  372. package/dist/safe-bash/commands/network/aggregate.d.ts +1 -4
  373. package/dist/safe-bash/commands/network/aggregate.js +1 -23
  374. package/dist/safe-bash/commands/network/args.d.ts +1 -68
  375. package/dist/safe-bash/commands/network/args.js +1 -321
  376. package/dist/safe-bash/commands/network/authorizer.d.ts +1 -6
  377. package/dist/safe-bash/commands/network/authorizer.js +1 -33
  378. package/dist/safe-bash/commands/network/body.d.ts +1 -9
  379. package/dist/safe-bash/commands/network/body.js +1 -393
  380. package/dist/safe-bash/commands/network/curl.d.ts +3 -13
  381. package/dist/safe-bash/commands/network/curl.js +6 -695
  382. package/dist/safe-bash/commands/network/deadline.d.ts +1 -2
  383. package/dist/safe-bash/commands/network/deadline.js +1 -14
  384. package/dist/safe-bash/commands/network/decode.d.ts +1 -2
  385. package/dist/safe-bash/commands/network/decode.js +1 -79
  386. package/dist/safe-bash/commands/network/fetch-transport.d.ts +1 -7
  387. package/dist/safe-bash/commands/network/fetch-transport.js +1 -94
  388. package/dist/safe-bash/commands/network/form-content-type.d.ts +1 -5
  389. package/dist/safe-bash/commands/network/form-content-type.js +1 -63
  390. package/dist/safe-bash/commands/network/form-headers.d.ts +1 -2
  391. package/dist/safe-bash/commands/network/form-headers.js +1 -35
  392. package/dist/safe-bash/commands/network/glob.d.ts +1 -7
  393. package/dist/safe-bash/commands/network/glob.js +1 -134
  394. package/dist/safe-bash/commands/network/index.browser.js +4 -12
  395. package/dist/safe-bash/commands/network/input.d.ts +1 -5
  396. package/dist/safe-bash/commands/network/input.js +1 -276
  397. package/dist/safe-bash/commands/network/output.d.ts +1 -6
  398. package/dist/safe-bash/commands/network/output.js +1 -131
  399. package/dist/safe-bash/commands/network/platform-portable.d.ts +1 -5
  400. package/dist/safe-bash/commands/network/platform-portable.js +1 -26
  401. package/dist/safe-bash/commands/network/private-address.d.ts +1 -1
  402. package/dist/safe-bash/commands/network/private-address.js +1 -44
  403. package/dist/safe-bash/commands/network/public.d.ts +2 -2
  404. package/dist/safe-bash/commands/network/public.js +2 -2
  405. package/dist/safe-bash/commands/network/shared.d.ts +1 -14
  406. package/dist/safe-bash/commands/network/shared.js +1 -71
  407. package/dist/safe-bash/commands/network/transport.js +2 -2
  408. package/dist/safe-bash/commands/network/types.d.ts +1 -37
  409. package/dist/safe-bash/commands/network/types.js +1 -31
  410. package/dist/safe-bash/commands/network/url.d.ts +1 -2
  411. package/dist/safe-bash/commands/network/url.js +1 -30
  412. package/dist/safe-bash/commands/network/wget.d.ts +3 -3
  413. package/dist/safe-bash/commands/network/wget.js +9 -332
  414. package/dist/safe-bash/commands/node/filesystem.js +3 -2
  415. package/dist/safe-bash/commands/node/index.browser.js +8 -9
  416. package/dist/safe-bash/commands/node/index.d.ts +3 -3
  417. package/dist/safe-bash/commands/node/index.js +5 -0
  418. package/dist/safe-bash/commands/node/safejs.d.ts +3 -3
  419. package/dist/safe-bash/commands/node/safejs.js +6 -1
  420. package/dist/safe-bash/commands/node/types.d.ts +1 -1
  421. package/dist/safe-bash/commands/node/types.js +1 -1
  422. package/dist/safe-bash/commands/node/unconfigured.d.ts +3 -0
  423. package/dist/safe-bash/commands/node/unconfigured.js +10 -0
  424. package/dist/safe-bash/commands/op/index.browser.js +3 -3
  425. package/dist/safe-bash/commands/patch/index.d.ts +2 -0
  426. package/dist/safe-bash/commands/patch/index.js +2 -0
  427. package/dist/safe-bash/commands/pdfinfo/index.js +2 -1
  428. package/dist/safe-bash/commands/pr/index.browser.js +2 -2
  429. package/dist/safe-bash/commands/predicates.js +3 -4
  430. package/dist/safe-bash/commands/python/host-capabilities.js +31 -14
  431. package/dist/safe-bash/commands/python/index.browser.js +11 -11
  432. package/dist/safe-bash/commands/python/llm-capability.d.ts +1 -0
  433. package/dist/safe-bash/commands/python/llm-capability.js +27 -7
  434. package/dist/safe-bash/commands/python/llm-module.js +11 -0
  435. package/dist/safe-bash/commands/python/manifest.d.ts +2 -0
  436. package/dist/safe-bash/commands/python/manifest.js +13 -6
  437. package/dist/safe-bash/commands/python/provisioning.js +1 -1
  438. package/dist/safe-bash/commands/python/shell-capability.d.ts +1 -0
  439. package/dist/safe-bash/commands/python/shell-capability.js +3 -2
  440. package/dist/safe-bash/commands/python/worker.browser.js +3 -3
  441. package/dist/safe-bash/commands/regex-execution/matching.js +1 -2
  442. package/dist/safe-bash/commands/regex-execution/public.browser.js +8 -8
  443. package/dist/safe-bash/commands/safejs/runtime.js +16 -7
  444. package/dist/safe-bash/commands/search/index.d.ts +1 -1
  445. package/dist/safe-bash/commands/search/index.js +1 -347
  446. package/dist/safe-bash/commands/search/portable.d.ts +2 -2
  447. package/dist/safe-bash/commands/search/portable.js +3 -2
  448. package/dist/safe-bash/commands/sed/index.d.ts +2 -0
  449. package/dist/safe-bash/commands/sed/index.js +2 -0
  450. package/dist/safe-bash/commands/standard.d.ts +1 -0
  451. package/dist/safe-bash/commands/standard.js +2 -1
  452. package/dist/safe-bash/commands/streams.js +6 -24
  453. package/dist/safe-bash/commands/tar/index.d.ts +2 -0
  454. package/dist/safe-bash/commands/tar/index.js +2 -0
  455. package/dist/safe-bash/commands/text-programs/awk-inspection.d.ts +1 -19
  456. package/dist/safe-bash/commands/text-programs/awk-inspection.js +1 -50
  457. package/dist/safe-bash/commands/text-programs/awk-pipes.d.ts +2 -0
  458. package/dist/safe-bash/commands/text-programs/awk-pipes.js +2 -0
  459. package/dist/safe-bash/commands/text-programs/awk-pretty.d.ts +1 -3
  460. package/dist/safe-bash/commands/text-programs/awk-pretty.js +1 -197
  461. package/dist/safe-bash/commands/text-programs/awk-quote.d.ts +1 -2
  462. package/dist/safe-bash/commands/text-programs/awk-quote.js +1 -15
  463. package/dist/safe-bash/commands/text-programs/awk-reader.d.ts +1 -42
  464. package/dist/safe-bash/commands/text-programs/awk-reader.js +1 -449
  465. package/dist/safe-bash/commands/text-programs/awk-retention.d.ts +1 -13
  466. package/dist/safe-bash/commands/text-programs/awk-retention.js +1 -51
  467. package/dist/safe-bash/commands/text-programs/awk-runtime.d.ts +1 -150
  468. package/dist/safe-bash/commands/text-programs/awk-runtime.js +1 -2627
  469. package/dist/safe-bash/commands/text-programs/awk-syntax.d.ts +1 -142
  470. package/dist/safe-bash/commands/text-programs/awk-syntax.js +1 -509
  471. package/dist/safe-bash/commands/text-programs/awk-values.d.ts +1 -32
  472. package/dist/safe-bash/commands/text-programs/awk-values.js +1 -386
  473. package/dist/safe-bash/commands/text-programs/awk.d.ts +1 -3
  474. package/dist/safe-bash/commands/text-programs/awk.js +1 -361
  475. package/dist/safe-bash/commands/text-programs/inplace.d.ts +1 -16
  476. package/dist/safe-bash/commands/text-programs/inplace.js +1 -155
  477. package/dist/safe-bash/commands/text-programs/sed.d.ts +1 -3
  478. package/dist/safe-bash/commands/text-programs/sed.js +1 -1647
  479. package/dist/safe-bash/commands/text.js +268 -364
  480. package/dist/safe-bash/commands/tsort/index.browser.js +2 -2
  481. package/dist/safe-bash/commands/unzip/index.d.ts +2 -0
  482. package/dist/safe-bash/commands/unzip/index.js +2 -0
  483. package/dist/safe-bash/commands/wget/index.d.ts +2 -0
  484. package/dist/safe-bash/commands/wget/index.js +2 -0
  485. package/dist/safe-bash/commands/xml/index.browser.js +2 -2
  486. package/dist/safe-bash/commands/yq/index.browser.js +8 -3
  487. package/dist/safe-bash/commands/yq/index.d.ts +1 -6
  488. package/dist/safe-bash/commands/yq/index.js +1 -36
  489. package/dist/safe-bash/commands/zip/index.d.ts +2 -0
  490. package/dist/safe-bash/commands/zip/index.js +2 -0
  491. package/dist/safe-bash/core.browser.js +2 -2
  492. package/dist/safe-bash/core.d.ts +14 -2
  493. package/dist/safe-bash/core.js +8 -2
  494. package/dist/safe-bash/fs/s3/index.d.ts +2 -2
  495. package/dist/safe-bash/fs/s3/index.js +1 -1
  496. package/dist/safe-bash/full-core.browser.js +321 -286
  497. package/dist/safe-bash/jobs.browser.js +5 -5
  498. package/dist/safe-bash/lazy-mmdc.d.ts +6 -0
  499. package/dist/safe-bash/lazy-mmdc.js +23 -0
  500. package/dist/safe-bash/opt-in/commands/dd/index.js +2 -0
  501. package/dist/safe-bash/opt-in/commands/yq/mike.js +6 -13
  502. package/dist/safe-bash/opt-in/commands/yq/native-work.d.ts +1 -0
  503. package/dist/safe-bash/opt-in/commands/yq/native-work.js +17 -0
  504. package/dist/safe-bash/opt-in/optional/commands/shuf/options.d.ts +1 -0
  505. package/dist/safe-bash/opt-in/optional/commands/shuf/options.js +2 -4
  506. package/dist/safe-bash/opt-in/optional/commands/shuf/shuf.js +2 -1
  507. package/dist/safe-bash/optional-host.browser.js +15 -11
  508. package/dist/safe-bash/optional-host.d.ts +1 -1
  509. package/dist/safe-bash/optional-host.js +1 -1
  510. package/dist/safe-bash/playwright/ability-execution.js +3 -2
  511. package/dist/safe-bash/playwright/adapter.js +1 -1
  512. package/dist/safe-bash/playwright/controller.js +9 -8
  513. package/dist/safe-bash/playwright/modal-capabilities.js +2 -1
  514. package/dist/safe-bash/playwright/native-json-snapshot.js +4 -3
  515. package/dist/safe-bash/playwright/native-snapshot.js +5 -4
  516. package/dist/safe-bash/playwright/open-options.js +3 -3
  517. package/dist/safe-bash/playwright/resource-limit.d.ts +2 -0
  518. package/dist/safe-bash/playwright/resource-limit.js +4 -0
  519. package/dist/safe-bash/playwright/session-configuration.js +8 -3
  520. package/dist/safe-bash/playwright/snapshot.js +8 -7
  521. package/dist/safe-bash/playwright/standard-capabilities.js +5 -4
  522. package/dist/safe-bash/plugins/composition.d.ts +1 -0
  523. package/dist/safe-bash/plugins/composition.js +3 -8
  524. package/dist/safe-bash/plugins/index.browser.js +27 -29
  525. package/dist/safe-bash/registry-entry.browser.js +28 -30
  526. package/dist/safe-bash/shell/arrays/bindings.d.ts +3 -5
  527. package/dist/safe-bash/shell/arrays/bindings.js +7 -3
  528. package/dist/safe-bash/shell/arrays/state.js +4 -0
  529. package/dist/safe-bash/shell/brace-expansion.js +1 -1
  530. package/dist/safe-bash/shell/dynamic-variables.d.ts +10 -0
  531. package/dist/safe-bash/shell/dynamic-variables.js +25 -0
  532. package/dist/safe-bash/shell/input.js +16 -14
  533. package/dist/safe-bash/shell/parser.js +8 -1
  534. package/dist/safe-bash/shell/runtime.d.ts +7 -4
  535. package/dist/safe-bash/shell/runtime.js +604 -802
  536. package/dist/safe-bash/shell/shell.js +2 -31
  537. package/dist/safe-bash/shell/types.d.ts +2 -0
  538. package/dist/safe-bash/shell/value-state.js +17 -2
  539. package/dist/safe-bash/shell/worker-limits.js +1 -0
  540. package/dist/safe-bash/shell-entry.browser.js +25 -27
  541. package/dist/safe-bash/trap.browser.d.ts +3 -0
  542. package/dist/safe-bash/trap.browser.js +14 -0
  543. package/dist/safe-bash/worker/host.js +1 -1
  544. package/dist/safe-bash/yq-browser/index.js +1 -1
  545. package/dist/safe-bash-base-encoding-engine/base.js +2 -2
  546. package/dist/safe-bash-base-encoding-engine/shared.js +1 -1
  547. package/dist/safe-bash-byte-input-engine/index.d.ts +3 -2
  548. package/dist/safe-bash-byte-input-engine/index.js +4 -1
  549. package/dist/safe-bash-checksum-engine/index.js +13 -6
  550. package/dist/safe-bash-command-apply-patch/apply.d.ts +1 -1
  551. package/dist/safe-bash-command-apply-patch/apply.js +4 -3
  552. package/dist/safe-bash-command-apply-patch/index.js +4 -4
  553. package/dist/safe-bash-command-apply-patch/matcher.js +1 -1
  554. package/dist/safe-bash-command-apply-patch/parser.js +1 -1
  555. package/dist/safe-bash-command-awk/LICENSE +21 -0
  556. package/dist/safe-bash-command-awk/awk-inspection.d.ts +19 -0
  557. package/dist/safe-bash-command-awk/awk-inspection.js +9 -0
  558. package/dist/safe-bash-command-awk/awk-pipes.d.ts +19 -0
  559. package/dist/safe-bash-command-awk/awk-pipes.js +8 -0
  560. package/dist/safe-bash-command-awk/awk-pretty.d.ts +3 -0
  561. package/dist/safe-bash-command-awk/awk-pretty.js +8 -0
  562. package/dist/safe-bash-command-awk/awk-quote.d.ts +2 -0
  563. package/dist/safe-bash-command-awk/awk-quote.js +7 -0
  564. package/dist/safe-bash-command-awk/awk-reader.d.ts +42 -0
  565. package/dist/safe-bash-command-awk/awk-reader.js +9 -0
  566. package/dist/safe-bash-command-awk/awk-retention.d.ts +13 -0
  567. package/dist/safe-bash-command-awk/awk-retention.js +7 -0
  568. package/dist/safe-bash-command-awk/awk-runtime.d.ts +151 -0
  569. package/dist/safe-bash-command-awk/awk-runtime.js +11 -0
  570. package/dist/safe-bash-command-awk/awk-syntax.d.ts +144 -0
  571. package/dist/safe-bash-command-awk/awk-syntax.js +14 -0
  572. package/dist/safe-bash-command-awk/awk-values.d.ts +32 -0
  573. package/dist/safe-bash-command-awk/awk-values.js +35 -0
  574. package/dist/safe-bash-command-awk/awk.d.ts +3 -0
  575. package/dist/safe-bash-command-awk/awk.js +16 -0
  576. package/dist/safe-bash-command-awk/index.d.ts +7 -0
  577. package/dist/safe-bash-command-awk/index.js +36 -0
  578. package/dist/safe-bash-command-bc/index.d.ts +6 -0
  579. package/dist/safe-bash-command-bc/index.js +136 -266
  580. package/dist/safe-bash-command-column/column.js +5 -5
  581. package/dist/safe-bash-command-column/display.d.ts +1 -1
  582. package/dist/safe-bash-command-column/display.js +1 -1
  583. package/dist/safe-bash-command-column/index.js +5 -5
  584. package/dist/safe-bash-command-column/internal.d.ts +0 -2
  585. package/dist/safe-bash-command-column/internal.js +1 -1
  586. package/dist/safe-bash-command-column/layout.js +4 -4
  587. package/dist/safe-bash-command-column/table.js +2 -2
  588. package/dist/safe-bash-command-comm/comm.js +1 -1
  589. package/dist/safe-bash-command-comm/index.js +1 -1
  590. package/dist/safe-bash-command-csplit/command.js +2 -2
  591. package/dist/safe-bash-command-csplit/index.js +2 -2
  592. package/dist/safe-bash-command-csvcut/index.d.ts +1 -0
  593. package/dist/safe-bash-command-csvcut/index.js +1 -0
  594. package/dist/safe-bash-command-csvgrep/index.d.ts +1 -0
  595. package/dist/safe-bash-command-csvgrep/index.js +2 -2
  596. package/dist/safe-bash-command-csvkit/contracts.d.ts +1 -0
  597. package/dist/safe-bash-command-csvkit/csvpy-interpreter.d.ts +2 -1
  598. package/dist/safe-bash-command-csvkit/default-csvpy.d.ts +11 -0
  599. package/dist/safe-bash-command-csvkit/errors.js +22 -0
  600. package/dist/safe-bash-command-csvkit/index.d.ts +1 -0
  601. package/dist/safe-bash-command-csvkit/index.js +180 -12
  602. package/dist/safe-bash-command-csvkit/python-worker-browser.d.ts +3 -0
  603. package/dist/safe-bash-command-csvkit/python-worker-browser.js +16 -0
  604. package/dist/safe-bash-command-csvkit/python-worker-contract.d.ts +20 -0
  605. package/dist/safe-bash-command-csvkit/python-worker-node.d.ts +3 -0
  606. package/dist/safe-bash-command-csvkit/python-worker-node.js +9 -0
  607. package/dist/safe-bash-command-csvkit/runtime.d.ts +1 -0
  608. package/dist/safe-bash-command-csvkit/sync-support.js +1 -1
  609. package/dist/safe-bash-command-curl/LICENSE +21 -0
  610. package/dist/safe-bash-command-curl/curl.d.ts +13 -0
  611. package/dist/safe-bash-command-curl/curl.js +9 -0
  612. package/dist/safe-bash-command-curl/index.d.ts +6 -0
  613. package/dist/safe-bash-command-curl/index.js +26 -0
  614. package/dist/safe-bash-command-dd/index.js +2 -0
  615. package/dist/safe-bash-command-diff/LICENSE +21 -0
  616. package/dist/safe-bash-command-diff/diff-format.d.ts +10 -0
  617. package/dist/safe-bash-command-diff/diff-format.js +10 -0
  618. package/dist/safe-bash-command-diff/diff-options.d.ts +38 -0
  619. package/dist/safe-bash-command-diff/diff-options.js +7 -0
  620. package/dist/safe-bash-command-diff/diff-output.d.ts +20 -0
  621. package/dist/safe-bash-command-diff/diff-output.js +19 -0
  622. package/dist/safe-bash-command-diff/diff.d.ts +2 -0
  623. package/dist/safe-bash-command-diff/diff.js +10 -0
  624. package/dist/safe-bash-command-diff/index.d.ts +8 -0
  625. package/dist/safe-bash-command-diff/index.js +34 -0
  626. package/dist/safe-bash-command-diff/sync.d.ts +2 -0
  627. package/dist/safe-bash-command-diff/sync.js +9 -0
  628. package/dist/safe-bash-command-diff3/index.js +5 -5
  629. package/dist/safe-bash-command-docx/index.d.ts +4 -4
  630. package/dist/safe-bash-command-docx/index.js +12 -5
  631. package/dist/safe-bash-command-dos2unix/index.d.ts +1 -0
  632. package/dist/safe-bash-command-dos2unix/index.js +225 -1
  633. package/dist/safe-bash-command-dos2unix/sync.d.ts +1 -0
  634. package/dist/safe-bash-command-exiftool/index.d.ts +1 -0
  635. package/dist/safe-bash-command-exiftool/index.js +2 -2
  636. package/dist/safe-bash-command-factor/command.js +2 -2
  637. package/dist/safe-bash-command-factor/index.js +2 -2
  638. package/dist/safe-bash-command-fd/index.js +9 -9
  639. package/dist/safe-bash-command-ffmpeg/index.js +117 -102
  640. package/dist/safe-bash-command-file/index.js +4 -4
  641. package/dist/safe-bash-command-file/shared.js +1 -1
  642. package/dist/safe-bash-command-find/LICENSE +21 -0
  643. package/dist/safe-bash-command-find/find-format.d.ts +20 -0
  644. package/dist/safe-bash-command-find/find-format.js +9 -0
  645. package/dist/safe-bash-command-find/find.d.ts +18 -0
  646. package/dist/safe-bash-command-find/find.js +10 -0
  647. package/dist/safe-bash-command-find/index.d.ts +13 -0
  648. package/dist/safe-bash-command-find/index.js +45 -0
  649. package/dist/safe-bash-command-fmt/index.js +7 -4
  650. package/dist/safe-bash-command-git/git_rust.wasm +0 -0
  651. package/dist/safe-bash-command-git/index.js +5 -7
  652. package/dist/safe-bash-command-git/wasm.generated.js +1 -1
  653. package/dist/safe-bash-command-gzip/LICENSE +21 -0
  654. package/dist/safe-bash-command-gzip/index.d.ts +11 -0
  655. package/dist/safe-bash-command-gzip/index.js +95 -0
  656. package/dist/safe-bash-command-hexdump/command.js +4 -4
  657. package/dist/safe-bash-command-hexdump/custom.d.ts +24 -0
  658. package/dist/safe-bash-command-hexdump/index.js +4 -4
  659. package/dist/safe-bash-command-hexdump/internal.d.ts +2 -0
  660. package/dist/safe-bash-command-hexdump/internal.js +1 -1
  661. package/dist/safe-bash-command-hexdump/io.js +2 -2
  662. package/dist/safe-bash-command-hexdump/options.d.ts +3 -0
  663. package/dist/safe-bash-command-hexdump/options.js +2 -2
  664. package/dist/safe-bash-command-hostname/index.js +1 -1
  665. package/dist/safe-bash-command-html-to-markdown/budget.js +1 -1
  666. package/dist/safe-bash-command-html-to-markdown/entities.js +3 -3
  667. package/dist/safe-bash-command-html-to-markdown/index.js +11 -11
  668. package/dist/safe-bash-command-html-to-markdown/input.js +5 -5
  669. package/dist/safe-bash-command-html-to-markdown/parser.d.ts +1 -0
  670. package/dist/safe-bash-command-html-to-markdown/parser.js +4 -4
  671. package/dist/safe-bash-command-html-to-markdown/render.js +5 -5
  672. package/dist/safe-bash-command-html-to-markdown/text.js +2 -2
  673. package/dist/safe-bash-command-htmlq/index.d.ts +1 -0
  674. package/dist/safe-bash-command-htmlq/index.js +39 -17
  675. package/dist/safe-bash-command-iconv/codec.js +1 -1
  676. package/dist/safe-bash-command-iconv/command.js +2 -2
  677. package/dist/safe-bash-command-iconv/index.js +2 -2
  678. package/dist/safe-bash-command-imagemagick/index.js +45 -35
  679. package/dist/safe-bash-command-join/index.js +1 -1
  680. package/dist/safe-bash-command-join/join.js +1 -1
  681. package/dist/safe-bash-command-jq/index.js +1 -1
  682. package/dist/safe-bash-command-jq/jq.js +1 -1
  683. package/dist/safe-bash-command-less/index.js +43 -28
  684. package/dist/safe-bash-command-llm/command.js +1 -1
  685. package/dist/safe-bash-command-llm/index.d.ts +1 -0
  686. package/dist/safe-bash-command-llm/index.js +16 -14
  687. package/dist/safe-bash-command-llm/openai.js +3 -3
  688. package/dist/safe-bash-command-llm/providers/index.js +3 -3
  689. package/dist/safe-bash-command-llm/providers/openai.js +3 -3
  690. package/dist/safe-bash-command-llm/stored-schema.d.ts +10 -0
  691. package/dist/safe-bash-command-mmdc/index.d.ts +1 -0
  692. package/dist/safe-bash-command-mmdc/index.js +13 -604
  693. package/dist/safe-bash-command-mmdc/settings.d.ts +2 -0
  694. package/dist/safe-bash-command-mmdc/settings.js +7 -0
  695. package/dist/safe-bash-command-numfmt/index.js +0 -11
  696. package/dist/safe-bash-command-od/index.js +101 -68
  697. package/dist/safe-bash-command-pandoc/command.js +4 -3
  698. package/dist/safe-bash-command-pandoc/defaults.d.ts +1 -0
  699. package/dist/safe-bash-command-pandoc/index.js +4 -3
  700. package/dist/safe-bash-command-pandoc/lua-filters.js +1 -1
  701. package/dist/safe-bash-command-pandoc/types.d.ts +3 -1
  702. package/dist/safe-bash-command-paste/index.js +1 -1
  703. package/dist/safe-bash-command-paste/paste.js +1 -1
  704. package/dist/safe-bash-command-patch/LICENSE +21 -0
  705. package/dist/safe-bash-command-patch/index.d.ts +8 -0
  706. package/dist/safe-bash-command-patch/index.js +38 -0
  707. package/dist/safe-bash-command-patch/patch-envelope.d.ts +2 -0
  708. package/dist/safe-bash-command-patch/patch-envelope.js +7 -0
  709. package/dist/safe-bash-command-patch/patch-formats.d.ts +7 -0
  710. package/dist/safe-bash-command-patch/patch-formats.js +9 -0
  711. package/dist/safe-bash-command-patch/patch-gnu-paths.d.ts +41 -0
  712. package/dist/safe-bash-command-patch/patch-gnu-paths.js +26 -0
  713. package/dist/safe-bash-command-patch/patch-gnu-reject.d.ts +3 -0
  714. package/dist/safe-bash-command-patch/patch-gnu-reject.js +7 -0
  715. package/dist/safe-bash-command-patch/patch-path.d.ts +3 -0
  716. package/dist/safe-bash-command-patch/patch-path.js +11 -0
  717. package/dist/safe-bash-command-patch/patch-publication.d.ts +13 -0
  718. package/dist/safe-bash-command-patch/patch-publication.js +7 -0
  719. package/dist/safe-bash-command-patch/patch.d.ts +2 -0
  720. package/dist/safe-bash-command-patch/patch.js +14 -0
  721. package/dist/safe-bash-command-patch/sync.d.ts +2 -0
  722. package/dist/safe-bash-command-patch/sync.js +7 -0
  723. package/dist/safe-bash-command-patch/unified.d.ts +52 -0
  724. package/dist/safe-bash-command-patch/unified.js +16 -0
  725. package/dist/safe-bash-command-pathchk/index.js +3 -13
  726. package/dist/safe-bash-command-pdfimages/index.js +62 -25
  727. package/dist/safe-bash-command-pdfinfo/index.d.ts +0 -23
  728. package/dist/safe-bash-command-pdfinfo/index.js +39 -782
  729. package/dist/safe-bash-command-pdftk/index.js +40 -12
  730. package/dist/safe-bash-command-pdftoppm/index.js +76 -30
  731. package/dist/safe-bash-command-pdftotext/index.js +37 -15
  732. package/dist/safe-bash-command-pptx/index.d.ts +4 -4
  733. package/dist/safe-bash-command-pptx/index.js +11 -5
  734. package/dist/safe-bash-command-pr/command.js +2 -2
  735. package/dist/safe-bash-command-pr/index.js +4 -4
  736. package/dist/safe-bash-command-qpdf/index.js +31 -18
  737. package/dist/safe-bash-command-rg/index.d.ts +1 -0
  738. package/dist/safe-bash-command-rg/index.js +222 -1
  739. package/dist/safe-bash-command-rg/rg-command.js +1 -1
  740. package/dist/safe-bash-command-rg/sync.d.ts +1 -0
  741. package/dist/safe-bash-command-sed/LICENSE +21 -0
  742. package/dist/safe-bash-command-sed/index.d.ts +7 -0
  743. package/dist/safe-bash-command-sed/index.js +28 -0
  744. package/dist/safe-bash-command-sed/inplace.d.ts +16 -0
  745. package/dist/safe-bash-command-sed/inplace.js +9 -0
  746. package/dist/safe-bash-command-sed/sed.d.ts +3 -0
  747. package/dist/safe-bash-command-sed/sed.js +8 -0
  748. package/dist/safe-bash-command-shuf/options.d.ts +1 -0
  749. package/dist/safe-bash-command-shuf/options.js +2 -4
  750. package/dist/safe-bash-command-shuf/shuf.js +2 -1
  751. package/dist/safe-bash-command-sips/index.js +111 -35
  752. package/dist/safe-bash-command-soffice/index.js +21 -17
  753. package/dist/safe-bash-command-split/index.js +3 -3
  754. package/dist/safe-bash-command-split/io.js +1 -1
  755. package/dist/safe-bash-command-split/outputs.js +2 -2
  756. package/dist/safe-bash-command-split/split.js +3 -3
  757. package/dist/safe-bash-command-sqlite3/btree.d.ts +1 -0
  758. package/dist/safe-bash-command-sqlite3/engine.d.ts +7 -2
  759. package/dist/safe-bash-command-sqlite3/index.js +436 -537
  760. package/dist/safe-bash-command-ssconvert/commands.js +9 -9
  761. package/dist/safe-bash-command-ssconvert/core.js +8 -8
  762. package/dist/safe-bash-command-ssconvert/formats/csv.js +9 -9
  763. package/dist/safe-bash-command-ssconvert/formats/ods.js +9 -9
  764. package/dist/safe-bash-command-ssconvert/formats/spreadsheetml.js +2 -2
  765. package/dist/safe-bash-command-ssconvert/formats/xls.js +9 -9
  766. package/dist/safe-bash-command-ssconvert/formats/xlsx.js +9 -9
  767. package/dist/safe-bash-command-ssconvert/index.js +21 -21
  768. package/dist/safe-bash-command-tar/LICENSE +21 -0
  769. package/dist/safe-bash-command-tar/create.d.ts +17 -0
  770. package/dist/safe-bash-command-tar/create.js +14 -0
  771. package/dist/safe-bash-command-tar/extract.d.ts +11 -0
  772. package/dist/safe-bash-command-tar/extract.js +14 -0
  773. package/dist/safe-bash-command-tar/format.d.ts +32 -0
  774. package/dist/safe-bash-command-tar/format.js +19 -0
  775. package/dist/safe-bash-command-tar/index.d.ts +8 -0
  776. package/dist/safe-bash-command-tar/index.js +551 -0
  777. package/dist/safe-bash-command-tar/listing.d.ts +2 -0
  778. package/dist/safe-bash-command-tar/listing.js +7 -0
  779. package/dist/safe-bash-command-tar/modes.d.ts +5 -0
  780. package/dist/safe-bash-command-tar/modes.js +16 -0
  781. package/dist/safe-bash-command-tar/options.d.ts +53 -0
  782. package/dist/safe-bash-command-tar/options.js +10 -0
  783. package/dist/safe-bash-command-tar/stream.d.ts +22 -0
  784. package/dist/safe-bash-command-tar/stream.js +15 -0
  785. package/dist/safe-bash-command-tar/transform.d.ts +16 -0
  786. package/dist/safe-bash-command-tar/transform.js +9 -0
  787. package/dist/safe-bash-command-tree/arguments.js +3 -3
  788. package/dist/safe-bash-command-tree/charset.js +1 -1
  789. package/dist/safe-bash-command-tree/index.js +4 -4
  790. package/dist/safe-bash-command-tree/io.js +1 -1
  791. package/dist/safe-bash-command-tree/pattern.js +2 -2
  792. package/dist/safe-bash-command-tree/tree.js +4 -4
  793. package/dist/safe-bash-command-unrtf/index.js +14 -7
  794. package/dist/safe-bash-command-unzip/LICENSE +21 -0
  795. package/dist/safe-bash-command-unzip/index.d.ts +7 -0
  796. package/dist/safe-bash-command-unzip/index.js +39 -0
  797. package/dist/safe-bash-command-unzip/sync.d.ts +3 -0
  798. package/dist/safe-bash-command-unzip/sync.js +9 -0
  799. package/dist/safe-bash-command-unzip/unzip/safety.d.ts +32 -0
  800. package/dist/safe-bash-command-unzip/unzip/safety.js +7 -0
  801. package/dist/safe-bash-command-unzip/unzip.d.ts +3 -0
  802. package/dist/safe-bash-command-unzip/unzip.js +8 -0
  803. package/dist/safe-bash-command-wget/LICENSE +21 -0
  804. package/dist/safe-bash-command-wget/index.d.ts +6 -0
  805. package/dist/safe-bash-command-wget/index.js +26 -0
  806. package/dist/safe-bash-command-wget/wget.d.ts +3 -0
  807. package/dist/safe-bash-command-wget/wget.js +7 -0
  808. package/dist/safe-bash-command-xan/argv.d.ts +4 -1
  809. package/dist/safe-bash-command-xan/argv.js +1 -1
  810. package/dist/safe-bash-command-xan/commands.js +6 -3
  811. package/dist/safe-bash-command-xan/csv.d.ts +1 -1
  812. package/dist/safe-bash-command-xan/csv.js +1 -1
  813. package/dist/safe-bash-command-xan/index.js +18 -17
  814. package/dist/safe-bash-command-xan/io.js +3 -3
  815. package/dist/safe-bash-command-xmllint/index.js +190 -50
  816. package/dist/safe-bash-command-xxd/index.js +105 -91
  817. package/dist/safe-bash-command-xz/command.d.ts +2 -0
  818. package/dist/safe-bash-command-xz/index.d.ts +1 -1
  819. package/dist/safe-bash-command-xz/index.js +11 -2
  820. package/dist/safe-bash-command-xz/options.d.ts +9 -1
  821. package/dist/safe-bash-command-xz/options.js +3 -1
  822. package/dist/safe-bash-command-yq/index.d.ts +4 -11
  823. package/dist/safe-bash-command-yq/index.js +3367 -670
  824. package/dist/safe-bash-command-yq/mike.js +6 -13
  825. package/dist/safe-bash-command-yq/native-work.d.ts +1 -0
  826. package/dist/safe-bash-command-yq/native-work.js +17 -0
  827. package/dist/safe-bash-command-yq/query.d.ts +11 -0
  828. package/dist/safe-bash-command-yq/query.js +735 -0
  829. package/dist/safe-bash-command-zip/LICENSE +21 -0
  830. package/dist/safe-bash-command-zip/index.d.ts +7 -0
  831. package/dist/safe-bash-command-zip/index.js +38 -0
  832. package/dist/safe-bash-command-zip/sync.d.ts +3 -0
  833. package/dist/safe-bash-command-zip/sync.js +9 -0
  834. package/dist/safe-bash-command-zip/zip.d.ts +3 -0
  835. package/dist/safe-bash-command-zip/zip.js +7 -0
  836. package/dist/safe-bash-compression-engine/files.js +4 -4
  837. package/dist/safe-bash-compression-engine/index.js +2 -2
  838. package/dist/safe-bash-compression-engine/operand.js +6 -6
  839. package/dist/safe-bash-compression-engine/stream.js +2 -2
  840. package/dist/safe-bash-compression-engine/zstd-decode.js +1 -1
  841. package/dist/safe-bash-contracts/command.js +1 -1
  842. package/dist/safe-bash-contracts/diagnostics.js +4 -4
  843. package/dist/safe-bash-contracts/escaping.js +12 -12
  844. package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
  845. package/dist/safe-bash-contracts/filesystem-output.js +8 -8
  846. package/dist/safe-bash-contracts/index.d.ts +1 -0
  847. package/dist/safe-bash-contracts/index.js +39 -35
  848. package/dist/safe-bash-contracts/io.d.ts +4 -1
  849. package/dist/safe-bash-contracts/io.js +4 -2
  850. package/dist/safe-bash-contracts/managed-abort.d.ts +10 -0
  851. package/dist/safe-bash-contracts/output.js +3 -3
  852. package/dist/safe-bash-diff-engine/LICENSE +21 -0
  853. package/dist/safe-bash-diff-engine/index.d.ts +1 -0
  854. package/dist/safe-bash-diff-engine/index.js +24 -0
  855. package/dist/safe-bash-diff-engine/shared.d.ts +54 -0
  856. package/dist/safe-bash-diff-engine/shared.js +19 -0
  857. package/dist/safe-bash-io-engine/commands/archive/internal.js +5 -23
  858. package/dist/safe-bash-io-engine/commands/directory-admission.d.ts +3 -0
  859. package/dist/safe-bash-io-engine/commands/directory-admission.js +34 -0
  860. package/dist/safe-bash-io-engine/commands/mode-change.d.ts +4 -0
  861. package/dist/safe-bash-io-engine/commands/mode-change.js +60 -0
  862. package/dist/safe-bash-io-engine/commands/search/requirements.js +2 -2
  863. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +44 -66
  864. package/dist/safe-bash-io-engine/internal.js +1 -1
  865. package/dist/safe-bash-io-engine/shell/pattern.js +8 -13
  866. package/dist/safe-bash-io-engine/shell/string-operations.js +1 -1
  867. package/dist/safe-bash-markdown-engine/commonmark-blocks.js +4 -4
  868. package/dist/safe-bash-markdown-engine/commonmark-inlines.js +4 -4
  869. package/dist/safe-bash-markdown-engine/commonmark-syntax.js +2 -2
  870. package/dist/safe-bash-markdown-engine/gfm-syntax.js +3 -3
  871. package/dist/safe-bash-markdown-engine/index.js +7 -7
  872. package/dist/safe-bash-mcp/index.browser.d.ts +161 -35
  873. package/dist/safe-bash-mcp/index.browser.js +417 -0
  874. package/dist/safe-bash-mcp/index.d.ts +66 -2
  875. package/dist/safe-bash-mcp/index.js +1838 -122
  876. package/dist/safe-bash-network-engine/LICENSE +21 -0
  877. package/dist/safe-bash-network-engine/aggregate.d.ts +4 -0
  878. package/dist/safe-bash-network-engine/aggregate.js +37 -0
  879. package/dist/safe-bash-network-engine/args.d.ts +68 -0
  880. package/dist/safe-bash-network-engine/args.js +19 -0
  881. package/dist/safe-bash-network-engine/authorizer.d.ts +6 -0
  882. package/dist/safe-bash-network-engine/authorizer.js +8 -0
  883. package/dist/safe-bash-network-engine/body.d.ts +9 -0
  884. package/dist/safe-bash-network-engine/body.js +374 -0
  885. package/dist/safe-bash-network-engine/deadline.d.ts +2 -0
  886. package/dist/safe-bash-network-engine/deadline.js +7 -0
  887. package/dist/safe-bash-network-engine/decode.d.ts +2 -0
  888. package/dist/safe-bash-network-engine/decode.js +80 -0
  889. package/dist/safe-bash-network-engine/fetch-transport.d.ts +7 -0
  890. package/dist/safe-bash-network-engine/fetch-transport.js +9 -0
  891. package/dist/safe-bash-network-engine/form-content-type.d.ts +5 -0
  892. package/dist/safe-bash-network-engine/form-content-type.js +8 -0
  893. package/dist/safe-bash-network-engine/form-headers.d.ts +2 -0
  894. package/dist/safe-bash-network-engine/form-headers.js +10 -0
  895. package/dist/safe-bash-network-engine/glob.d.ts +7 -0
  896. package/dist/safe-bash-network-engine/glob.js +124 -0
  897. package/dist/safe-bash-network-engine/index.d.ts +3 -0
  898. package/dist/safe-bash-network-engine/index.js +26 -0
  899. package/dist/safe-bash-network-engine/input.d.ts +5 -0
  900. package/dist/safe-bash-network-engine/input.js +255 -0
  901. package/dist/safe-bash-network-engine/output.d.ts +6 -0
  902. package/dist/safe-bash-network-engine/output.js +132 -0
  903. package/dist/safe-bash-network-engine/platform-portable.d.ts +5 -0
  904. package/dist/safe-bash-network-engine/platform-portable.js +19 -0
  905. package/dist/safe-bash-network-engine/private-address.d.ts +1 -0
  906. package/dist/safe-bash-network-engine/private-address.js +7 -0
  907. package/dist/safe-bash-network-engine/shared.d.ts +14 -0
  908. package/dist/safe-bash-network-engine/shared.js +23 -0
  909. package/dist/safe-bash-network-engine/types.d.ts +42 -0
  910. package/dist/safe-bash-network-engine/types.js +11 -0
  911. package/dist/safe-bash-network-engine/url.d.ts +2 -0
  912. package/dist/safe-bash-network-engine/url.js +8 -0
  913. package/dist/safe-bash-query-engine/capture.d.ts +1 -0
  914. package/dist/safe-bash-query-engine/capture.js +9 -7
  915. package/dist/safe-bash-query-engine/dates.d.ts +5 -1
  916. package/dist/safe-bash-query-engine/dates.js +10 -2
  917. package/dist/safe-bash-query-engine/delpaths.js +5 -5
  918. package/dist/safe-bash-query-engine/formats.js +3 -3
  919. package/dist/safe-bash-query-engine/index.js +15 -15
  920. package/dist/safe-bash-query-engine/indices.js +5 -5
  921. package/dist/safe-bash-query-engine/input.d.ts +1 -2
  922. package/dist/safe-bash-query-engine/input.js +2 -4
  923. package/dist/safe-bash-query-engine/interpreter.d.ts +5 -0
  924. package/dist/safe-bash-query-engine/interpreter.js +13 -13
  925. package/dist/safe-bash-query-engine/limits.js +1 -1
  926. package/dist/safe-bash-query-engine/parser.d.ts +8 -1
  927. package/dist/safe-bash-query-engine/parser.js +2 -2
  928. package/dist/safe-bash-query-engine/query-core.js +15 -15
  929. package/dist/safe-bash-query-engine/recurse.js +2 -2
  930. package/dist/safe-bash-query-engine/regex.d.ts +4 -2
  931. package/dist/safe-bash-query-engine/regex.js +10 -5
  932. package/dist/safe-bash-query-engine/split.js +2 -2
  933. package/dist/safe-bash-query-engine/splits.d.ts +1 -1
  934. package/dist/safe-bash-query-engine/splits.js +7 -6
  935. package/dist/safe-bash-query-engine/values.js +4 -4
  936. package/dist/safe-bash-regex-engine/ere/matcher.js +106 -34
  937. package/dist/safe-bash-regex-engine/execution/bounded-provider.js +55 -67
  938. package/dist/safe-bash-regex-engine/execution/portable.d.ts +0 -1
  939. package/dist/safe-bash-regex-engine/execution/portable.js +6 -10
  940. package/dist/safe-bash-regex-engine/execution/protocol.d.ts +0 -5
  941. package/dist/safe-bash-regex-engine/execution/protocol.js +1 -3
  942. package/dist/safe-bash-regex-engine/index.js +6 -4
  943. package/dist/safe-bash-regex-engine/text/budget.d.ts +1 -0
  944. package/dist/safe-bash-regex-engine/text/budget.js +1 -1
  945. package/dist/safe-bash-regex-engine/text/regex.d.ts +15 -0
  946. package/dist/safe-bash-regex-engine/text/regex.js +6 -4
  947. package/dist/safe-bash-regex-engine/text/replacement-buffer.js +2 -2
  948. package/dist/safe-bash-regex-engine/text/rust-syntax.js +2 -2
  949. package/dist/safe-bash-search-engine/ergonomic-regex.d.ts +12 -2
  950. package/dist/safe-bash-search-engine/ergonomic-regex.js +2 -2
  951. package/dist/safe-bash-search-engine/glob.js +2 -2
  952. package/dist/safe-bash-search-engine/grep.js +191 -229
  953. package/dist/safe-bash-search-engine/matcher.d.ts +6 -2
  954. package/dist/safe-bash-search-engine/matcher.js +30 -8
  955. package/dist/safe-bash-search-engine/options.js +1 -1
  956. package/dist/safe-bash-search-engine/output.d.ts +3 -2
  957. package/dist/safe-bash-search-engine/output.js +111 -30
  958. package/dist/safe-bash-search-engine/shared.d.ts +2 -0
  959. package/dist/safe-bash-search-engine/shared.js +2 -2
  960. package/dist/safe-bash-search-engine/walk.js +11 -10
  961. package/dist/safe-bash-table-text-engine/table-text/internal.d.ts +7 -5
  962. package/dist/safe-bash-table-text-engine/table-text/internal.js +39 -21
  963. package/dist/safe-bash-xml-engine/document.d.ts +1 -1
  964. package/dist/safe-bash-xml-engine/document.js +3 -3
  965. package/dist/safe-bash-xml-engine/evaluate.d.ts +1 -0
  966. package/dist/safe-bash-xml-engine/evaluate.js +4 -1
  967. package/dist/safe-bash-xml-engine/index.js +8 -6
  968. package/dist/safe-bash-xml-engine/io.js +1 -1
  969. package/dist/safe-bash-xml-engine/limits.d.ts +2 -0
  970. package/dist/safe-bash-xml-engine/limits.js +1 -1
  971. package/dist/safe-bash-xml-engine/predicate.d.ts +57 -0
  972. package/dist/safe-bash-xml-engine/query.d.ts +3 -15
  973. package/dist/safe-bash-xml-engine/query.js +3 -2
  974. package/dist/safe-bash-zip-engine/LICENSE +21 -0
  975. package/dist/safe-bash-zip-engine/index.d.ts +1 -0
  976. package/dist/safe-bash-zip-engine/index.js +32 -0
  977. package/dist/safe-bash-zip-engine/unzip/arguments.d.ts +53 -0
  978. package/dist/safe-bash-zip-engine/unzip/arguments.js +270 -0
  979. package/dist/safe-bash-zip-engine/zip/aes.d.ts +17 -0
  980. package/dist/safe-bash-zip-engine/zip/aes.js +15 -0
  981. package/dist/safe-bash-zip-engine/zip/comments.d.ts +17 -0
  982. package/dist/safe-bash-zip-engine/zip/comments.js +77 -0
  983. package/dist/safe-bash-zip-engine/zip/crc.d.ts +1 -0
  984. package/dist/safe-bash-zip-engine/zip/crc.js +7 -0
  985. package/dist/safe-bash-zip-engine/zip/crypto.d.ts +19 -0
  986. package/dist/safe-bash-zip-engine/zip/crypto.js +16 -0
  987. package/dist/safe-bash-zip-engine/zip/dates.d.ts +4 -0
  988. package/dist/safe-bash-zip-engine/zip/dates.js +68 -0
  989. package/dist/safe-bash-zip-engine/zip/environment.d.ts +2 -0
  990. package/dist/safe-bash-zip-engine/zip/environment.js +60 -0
  991. package/dist/safe-bash-zip-engine/zip/grow.d.ts +3 -0
  992. package/dist/safe-bash-zip-engine/zip/grow.js +7 -0
  993. package/dist/safe-bash-zip-engine/zip/help.d.ts +4 -0
  994. package/dist/safe-bash-zip-engine/zip/help.js +194 -0
  995. package/dist/safe-bash-zip-engine/zip/line-endings.d.ts +2 -0
  996. package/dist/safe-bash-zip-engine/zip/line-endings.js +165 -0
  997. package/dist/safe-bash-zip-engine/zip/log.d.ts +22 -0
  998. package/dist/safe-bash-zip-engine/zip/log.js +153 -0
  999. package/dist/safe-bash-zip-engine/zip/lzma.d.ts +9 -0
  1000. package/dist/safe-bash-zip-engine/zip/lzma.js +7 -0
  1001. package/dist/safe-bash-zip-engine/zip/move.d.ts +11 -0
  1002. package/dist/safe-bash-zip-engine/zip/move.js +57 -0
  1003. package/dist/safe-bash-zip-engine/zip/names.d.ts +2 -0
  1004. package/dist/safe-bash-zip-engine/zip/names.js +37 -0
  1005. package/dist/safe-bash-zip-engine/zip/options.d.ts +13 -0
  1006. package/dist/safe-bash-zip-engine/zip/options.js +23 -0
  1007. package/dist/safe-bash-zip-engine/zip/repair.d.ts +10 -0
  1008. package/dist/safe-bash-zip-engine/zip/repair.js +348 -0
  1009. package/dist/safe-bash-zip-engine/zip/safety.d.ts +54 -0
  1010. package/dist/safe-bash-zip-engine/zip/safety.js +19 -0
  1011. package/dist/safe-bash-zip-engine/zip/sfx.d.ts +4 -0
  1012. package/dist/safe-bash-zip-engine/zip/sfx.js +58 -0
  1013. package/dist/safe-bash-zip-engine/zip/test-command.d.ts +5 -0
  1014. package/dist/safe-bash-zip-engine/zip/test-command.js +98 -0
  1015. package/dist/safe-bash-zip-engine/zip/volumes.d.ts +21 -0
  1016. package/dist/safe-bash-zip-engine/zip/volumes.js +255 -0
  1017. package/dist/safe-bash-zip-engine/zip/zip64.d.ts +30 -0
  1018. package/dist/safe-bash-zip-engine/zip/zip64.js +25 -0
  1019. package/dist/safe-bash-zip-engine/zip-format.d.ts +68 -0
  1020. package/dist/safe-bash-zip-engine/zip-format.js +27 -0
  1021. package/dist/safe-playwright-cloudflare/browser-codegen.generated.d.ts +7 -7
  1022. package/dist/safe-playwright-cloudflare/browser-codegen.generated.js +866 -8069
  1023. package/dist/safe-playwright-cloudflare/browser-run-code-budget.d.ts +0 -1
  1024. package/dist/safe-playwright-cloudflare/browser-run-code-budget.js +0 -2
  1025. package/dist/safe-playwright-cloudflare/browser-trace-archive.d.ts +5 -1
  1026. package/dist/safe-playwright-cloudflare/browser-trace-archive.js +2 -1
  1027. package/dist/safe-playwright-cloudflare/browser-trace-budget.js +8 -4
  1028. package/dist/safe-playwright-cloudflare/shell-browser-resource.d.ts +2 -0
  1029. package/dist/safe-playwright-cloudflare/shell-browser-resource.js +3 -11
  1030. package/dist/safe-playwright-cloudflare/shell-playwright.d.ts +2 -0
  1031. package/dist/safe-playwright-cloudflare/shell-playwright.js +1 -1
  1032. package/dist/spreadsheet-engine/codecs/odf-hyperlinks.js +8 -2
  1033. package/dist/spreadsheet-engine/formulas/functions/captured-bessel-phase.js +2 -2
  1034. package/dist/spreadsheet-engine/formulas/label-references.js +54 -33
  1035. package/dist/spreadsheet-engine/formulas/parser.js +3 -1
  1036. package/dist/spreadsheet-engine/formulas/rewriting.js +13 -3
  1037. package/dist/spreadsheet-engine/io/publication.d.ts +1 -0
  1038. package/dist/spreadsheet-format-xls/biff-data-tables.js +4 -6
  1039. package/dist/spreadsheet-format-xls/biff-formulas.js +3 -0
  1040. package/dist/spreadsheet-format-xls/biff-label-ranges.js +9 -6
  1041. package/dist/spreadsheet-format-xls/biff.js +1 -1
  1042. package/dist/xlsx-ast/xlsx.js +8 -5
  1043. package/package.json +165 -15
  1044. package/dist/safe-bash/chunks/chunk-AZAJJVFX.js +0 -23017
  1045. package/dist/safe-bash/chunks/chunk-O4ZUCRGN.js +0 -13
  1046. package/dist/safe-bash/chunks/chunk-S264DZO2.js +0 -243
  1047. package/dist/safe-bash/chunks/chunk-WVG5SHHQ.js +0 -12
  1048. package/dist/safe-bash/chunks/chunk-ZW6K2J7P.js +0 -2652
  1049. package/dist/safe-bash/command-chunks/chunk-5MPOQ6V3.js +0 -181
  1050. package/dist/safe-bash/command-chunks/chunk-BIXLZ3OG.js +0 -14342
  1051. package/dist/safe-bash/command-chunks/chunk-DUYJE2HY.js +0 -14
  1052. package/dist/safe-bash/command-chunks/chunk-KAGBORIC.js +0 -88
  1053. package/dist/safe-bash/command-chunks/chunk-NETECMOF.js +0 -40
  1054. package/dist/safe-bash/command-chunks/chunk-XS3PGJU2.js +0 -343
  1055. package/dist/safe-bash/command-chunks/chunk-XTZALMLR.js +0 -488
  1056. package/dist/safe-bash/commands/archive/zip/aes-primitives-unavailable.d.ts +0 -2
  1057. package/dist/safe-bash/commands/archive/zip/aes-primitives-unavailable.js +0 -3
  1058. package/dist/safe-bash/commands/archive/zip/aes-primitives.d.ts +0 -2
  1059. package/dist/safe-bash/commands/archive/zip/aes-primitives.js +0 -3
  1060. package/dist/safe-bash/commands/xml/document.d.ts +0 -2
  1061. package/dist/safe-bash/commands/xml/document.js +0 -2
  1062. package/dist/safe-bash/commands/xml/evaluate.d.ts +0 -2
  1063. package/dist/safe-bash/commands/xml/evaluate.js +0 -2
  1064. package/dist/safe-bash/commands/xml/json.d.ts +0 -2
  1065. package/dist/safe-bash/commands/xml/json.js +0 -2
  1066. package/dist/safe-bash/commands/xml/limits.d.ts +0 -2
  1067. package/dist/safe-bash/commands/xml/limits.js +0 -2
  1068. package/dist/safe-bash/commands/xml/query.d.ts +0 -2
  1069. package/dist/safe-bash/commands/xml/query.js +0 -2
  1070. package/dist/safe-bash/command-chunks/{chunk-FIUFIDAO.js → chunk-2JRBIDAD.js} +3 -3
  1071. package/dist/safe-bash/command-chunks/{chunk-BWNXWI33.js → chunk-2LMZVE3I.js} +0 -0
  1072. package/dist/safe-bash/command-chunks/{chunk-B5BKA5WH.js → chunk-B5TAOCKD.js} +3 -3
  1073. package/dist/safe-bash/command-chunks/{chunk-2ENZ6JGA.js → chunk-KEV7C3KH.js} +3 -3
  1074. package/dist/safe-bash/command-chunks/{chunk-S62HELHU.js → chunk-PL6O4K6W.js} +3 -3
  1075. package/dist/safe-bash/command-chunks/{chunk-DDLQ5YDB.js → chunk-YHFXOX6U.js} +9 -9
  1076. package/dist/safe-bash/command-chunks/{chunk-DQMOM72Z.js → chunk-ZRRBXU3M.js} +4 -4
@@ -1,2652 +0,0 @@
1
- import {
2
- openFileOutput
3
- } from "./chunk-O4ZUCRGN.js";
4
- import {
5
- writeDiagnostic
6
- } from "./chunk-T5KKDMYB.js";
7
- import {
8
- byteLength,
9
- decodeBytes,
10
- encodeBytes
11
- } from "./chunk-KTGR4U57.js";
12
- import {
13
- shellValueByteLength,
14
- shellValueBytes
15
- } from "./chunk-I4OAEOP6.js";
16
- import {
17
- FsError,
18
- createOutputOperation
19
- } from "./chunk-IUTD5FH5.js";
20
- import {
21
- inheritYieldCheckpoint,
22
- normalizePath,
23
- posixPath,
24
- yieldTurn
25
- } from "./chunk-VYZTG3GV.js";
26
- import {
27
- getCommandArguments
28
- } from "./chunk-LQHGH25W.js";
29
- import {
30
- collectBytes,
31
- outputFailure,
32
- readBytes,
33
- toByteSource,
34
- writeBytes
35
- } from "./chunk-PYVEAFJM.js";
36
- import {
37
- builtInDirectContextExecutors,
38
- pathOf,
39
- syncCommandEvaluators
40
- } from "./chunk-ENR3HB2B.js";
41
- import {
42
- TransformStream,
43
- init_platform
44
- } from "./chunk-YG5WAHK7.js";
45
-
46
- // packages/safe-bash/src/commands/network/public.ts
47
- init_platform();
48
-
49
- // packages/safe-bash/src/commands/network/wget.ts
50
- init_platform();
51
-
52
- // packages/safe-bash/src/commands/network/shared.ts
53
- init_platform();
54
-
55
- // packages/safe-bash/src/commands/network/deadline.ts
56
- init_platform();
57
- function scheduleNetworkDeadline(milliseconds, expire) {
58
- const deadline = performance.now() + milliseconds;
59
- let timer;
60
- let closed = false;
61
- const arm = () => {
62
- if (closed || !Number.isFinite(deadline)) return;
63
- const remaining = deadline - performance.now();
64
- timer = setTimeout(remaining > 2147483647 ? arm : expire, Math.max(0, Math.min(remaining, 2147483647)));
65
- };
66
- arm();
67
- return () => {
68
- closed = true;
69
- clearTimeout(timer);
70
- };
71
- }
72
-
73
- // packages/safe-bash/src/commands/network/types.ts
74
- init_platform();
75
- var defaultNetworkLimits = Object.freeze({
76
- maxUploadBytes: Infinity,
77
- maxDownloadBytes: Infinity,
78
- maxBufferBytes: Infinity,
79
- maxHeaderBytes: Infinity,
80
- maxRedirects: Infinity,
81
- maxRetries: Infinity,
82
- maxUrls: Infinity,
83
- maxTimeMs: Infinity,
84
- maxTotalTimeMs: Infinity
85
- });
86
- var cloudflareWorkerNetworkLimits = Object.freeze({
87
- maxUploadBytes: 4 * 1024 * 1024,
88
- maxDownloadBytes: 4 * 1024 * 1024,
89
- maxBufferBytes: 1024 * 1024,
90
- maxHeaderBytes: 32 * 1024,
91
- maxRedirects: 2,
92
- maxRetries: 1,
93
- maxUrls: 8,
94
- maxTimeMs: 1e4,
95
- maxTotalTimeMs: 1e4
96
- });
97
- var CurlError = class extends Error {
98
- constructor(exitCode, message) {
99
- super(message);
100
- this.exitCode = exitCode;
101
- this.name = "CurlError";
102
- }
103
- exitCode;
104
- };
105
-
106
- // packages/safe-bash/src/commands/network/shared.ts
107
- var encode = (text) => new TextEncoder().encode(text);
108
- function limitsFor(overrides = {}) {
109
- const result = { ...defaultNetworkLimits, ...overrides };
110
- for (const [name, value] of Object.entries(overrides)) {
111
- const minimum = name === "maxRedirects" || name === "maxRetries" ? 0 : 1;
112
- if (value !== Infinity && (!Number.isSafeInteger(value) || value < minimum)) {
113
- throw new RangeError(`Invalid network limit: ${name}`);
114
- }
115
- }
116
- return Object.freeze(result);
117
- }
118
- async function withSignal(operation, signal) {
119
- signal.throwIfAborted();
120
- return new Promise((resolve, reject) => {
121
- const onAbort = () => {
122
- cleanup();
123
- reject(signal.reason);
124
- };
125
- const cleanup = () => signal.removeEventListener("abort", onAbort);
126
- signal.addEventListener("abort", onAbort, { once: true });
127
- Promise.resolve().then(operation).then((value) => {
128
- cleanup();
129
- resolve(value);
130
- }, (error) => {
131
- cleanup();
132
- reject(error);
133
- });
134
- });
135
- }
136
- async function delay(milliseconds, signal) {
137
- let cancel;
138
- try {
139
- await withSignal(() => new Promise((resolve) => {
140
- cancel = scheduleNetworkDeadline(milliseconds, resolve);
141
- }), signal);
142
- } finally {
143
- cancel?.();
144
- }
145
- }
146
- function header(headers, name) {
147
- return headers.find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1];
148
- }
149
- function networkError(error) {
150
- if (error instanceof CurlError) return error;
151
- const code = error && typeof error === "object" && "code" in error ? String(error.code) : "";
152
- if (["ENOTFOUND", "EAI_AGAIN"].includes(code)) return new CurlError(6, "Could not resolve host");
153
- if (["ECONNREFUSED", "ENETUNREACH", "EHOSTUNREACH"].includes(code)) return new CurlError(7, "Failed to connect");
154
- if (/CERT|SELF_SIGNED|UNABLE_TO_VERIFY/.test(code)) return new CurlError(60, "TLS certificate verification failed");
155
- if (/TLS|SSL/.test(code)) return new CurlError(35, "TLS handshake failed");
156
- return new CurlError(56, "Network transfer failed");
157
- }
158
- async function diagnostic(context, error) {
159
- await writeDiagnostic(context.stderr, `${context.command}: (${error.exitCode}) ${error.message}
160
- `, context.signal);
161
- }
162
- async function collectNetworkBytes(source, options) {
163
- if (Number.isFinite(options.maxBytes)) return collectBytes(source, options);
164
- const chunks = [];
165
- let size = 0;
166
- for await (const chunk of readBytes(source, options.signal)) {
167
- chunks.push(new Uint8Array(chunk));
168
- size += chunk.length;
169
- }
170
- const bytes = new Uint8Array(size);
171
- let offset = 0;
172
- for (const chunk of chunks) {
173
- bytes.set(chunk, offset);
174
- offset += chunk.length;
175
- }
176
- return bytes;
177
- }
178
-
179
- // packages/safe-bash/src/commands/network/args.ts
180
- init_platform();
181
-
182
- // packages/safe-bash/src/commands/network/platform-portable.ts
183
- init_platform();
184
- var requiresFiniteUrlLimits = true;
185
- function createDefaultHttpTransport() {
186
- throw new TypeError("Portable network commands require an explicit HTTP transport; inject createFetchTransport() or a host transport");
187
- }
188
- function randomBytes(length) {
189
- const bytes = new Uint8Array(length);
190
- globalThis.crypto.getRandomValues(bytes);
191
- return bytes;
192
- }
193
- function validateHeaderName(name) {
194
- if (!name.length) throw new TypeError("Invalid HTTP header name");
195
- for (const character of name) {
196
- const code = character.charCodeAt(0);
197
- if (!(code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || "!#$%&'*+-.^_`|~".includes(character))) {
198
- throw new TypeError("Invalid HTTP header name");
199
- }
200
- }
201
- }
202
- function validateHeaderValue(_name, value) {
203
- for (const character of value) {
204
- const code = character.charCodeAt(0);
205
- if (code !== 9 && (code < 32 || code === 127 || code > 255)) throw new TypeError("Invalid HTTP header value");
206
- }
207
- }
208
-
209
- // packages/safe-bash/src/commands/network/args.ts
210
- var values = {
211
- C: "continue-at",
212
- X: "request",
213
- d: "data",
214
- H: "header",
215
- u: "user",
216
- A: "user-agent",
217
- e: "referer",
218
- o: "output",
219
- D: "dump-header",
220
- w: "write-out",
221
- T: "upload-file",
222
- m: "max-time",
223
- F: "form",
224
- r: "range"
225
- };
226
- var flags = {
227
- L: "location",
228
- I: "head",
229
- i: "include",
230
- f: "fail",
231
- s: "silent",
232
- S: "show-error",
233
- G: "get",
234
- O: "remote-name",
235
- v: "verbose",
236
- q: "disable",
237
- N: "no-buffer",
238
- g: "globoff",
239
- h: "help",
240
- V: "version"
241
- };
242
- var longValues = /* @__PURE__ */ new Set([
243
- ...Object.values(values),
244
- "data-ascii",
245
- "data-raw",
246
- "data-binary",
247
- "data-urlencode",
248
- "url-query",
249
- "json",
250
- "form-string",
251
- "url",
252
- "oauth2-bearer",
253
- "max-redirs",
254
- "max-filesize",
255
- "retry",
256
- "retry-delay",
257
- "connect-timeout",
258
- "output-dir",
259
- "cacert",
260
- "etag-save",
261
- "etag-compare"
262
- ]);
263
- var booleans = {
264
- location: "location",
265
- head: "head",
266
- include: "include",
267
- "show-headers": "include",
268
- get: "get",
269
- "remote-name": "remoteName",
270
- fail: "fail",
271
- "fail-with-body": "failWithBody",
272
- silent: "silent",
273
- "show-error": "showError",
274
- verbose: "verbose",
275
- globoff: "globoff",
276
- compressed: "compressed",
277
- raw: "raw",
278
- "ignore-content-length": "ignoreContentLength"
279
- };
280
- function number(value, integral = false) {
281
- if (!(integral ? /^\d+$/ : /^\d+(?:\.\d+)?$/).test(value)) throw new CurlError(2, "Invalid numeric option");
282
- const parsed = Number(value);
283
- if (!Number.isFinite(parsed) || parsed < 0 || parsed > Number.MAX_SAFE_INTEGER) throw new CurlError(2, "Invalid numeric option");
284
- return parsed;
285
- }
286
- function timeoutSeconds(value) {
287
- const invalid = () => {
288
- throw new CurlError(2, "Invalid numeric option");
289
- };
290
- let index = 0;
291
- while (index < value.length && " \n\r\v\f".includes(value[index])) index++;
292
- const negative = value[index] === "-";
293
- if (negative || value[index] === "+") index++;
294
- const hexadecimal = value.slice(index, index + 2).toLowerCase() === "0x";
295
- if (hexadecimal) index += 2;
296
- const digits = hexadecimal ? "0123456789abcdef" : "0123456789";
297
- const radix = hexadecimal ? 16 : 10;
298
- let mantissa = 0;
299
- let digitCount = 0;
300
- let fractionDigits = 0;
301
- let point = false;
302
- for (; index < value.length; index++) {
303
- const character = value[index].toLowerCase();
304
- const digit = digits.indexOf(character);
305
- if (digit >= 0) {
306
- mantissa = mantissa * radix + digit;
307
- digitCount++;
308
- if (point) fractionDigits++;
309
- } else if (character === "." && !point) point = true;
310
- else break;
311
- }
312
- if (!digitCount) invalid();
313
- let exponent = 0;
314
- if (value[index]?.toLowerCase() === (hexadecimal ? "p" : "e")) {
315
- index++;
316
- const exponentNegative = value[index] === "-";
317
- if (exponentNegative || value[index] === "+") index++;
318
- const start = index;
319
- while (index < value.length && "0123456789".includes(value[index])) index++;
320
- if (index === start) invalid();
321
- exponent = Number(value.slice(start, index)) * (exponentNegative ? -1 : 1);
322
- }
323
- if (index !== value.length) invalid();
324
- const parsed = hexadecimal ? (negative ? -1 : 1) * mantissa * 2 ** (exponent - fractionDigits * 4) : Number(value);
325
- if (!Number.isFinite(parsed) || parsed < 0 || parsed > Number.MAX_SAFE_INTEGER) invalid();
326
- return parsed;
327
- }
328
- function validateRequestHeader(name, value) {
329
- try {
330
- validateHeaderName(name);
331
- validateHeaderValue(name, value);
332
- } catch {
333
- throw new CurlError(2, "Invalid HTTP header");
334
- }
335
- if (["host", "content-length", "transfer-encoding", "connection", "proxy-authorization", "upgrade", "expect"].includes(name.toLowerCase())) {
336
- throw new CurlError(2, "Transport-controlled HTTP header is not supported");
337
- }
338
- }
339
- function addHeader(result, raw) {
340
- const colon = raw.indexOf(":");
341
- const semicolon = colon < 0 && raw.endsWith(";");
342
- if (colon < 1 && !semicolon) throw new CurlError(2, "Invalid HTTP header");
343
- const name = semicolon ? raw.slice(0, -1) : raw.slice(0, colon);
344
- const value = semicolon ? "" : raw.slice(colon + 1).trim();
345
- validateRequestHeader(name, value);
346
- result.headers.push([name, value === "" && !semicolon ? null : value]);
347
- }
348
- function parseArguments(args, limits) {
349
- const result = {
350
- urls: [],
351
- data: [],
352
- headers: [],
353
- include: false,
354
- head: false,
355
- get: false,
356
- location: false,
357
- remoteName: false,
358
- fail: false,
359
- failWithBody: false,
360
- silent: false,
361
- showError: false,
362
- verbose: false,
363
- globoff: false,
364
- help: false,
365
- version: false,
366
- retries: 0,
367
- retryDelayMs: 0,
368
- maxTimeMs: limits.maxTimeMs,
369
- maxRedirects: limits.maxRedirects,
370
- maxFileSize: limits.maxDownloadBytes
371
- };
372
- const apply = (option, value) => {
373
- const positive = option.startsWith("no-") ? option.slice(3) : option;
374
- const property = Object.hasOwn(booleans, positive) ? booleans[positive] : void 0;
375
- if (property) {
376
- Object.assign(result, { [property]: !option.startsWith("no-") });
377
- if (property === "remoteName") {
378
- (result.outputs ??= []).push({ remoteName: result.remoteName });
379
- if (result.remoteName) delete result.output;
380
- }
381
- return;
382
- }
383
- switch (option) {
384
- case "continue-at": {
385
- if (value === "-") result.continueAt = "auto";
386
- else {
387
- if (!value || [...value].some((character) => !"0123456789".includes(character)) || !Number.isSafeInteger(Number(value))) {
388
- throw new CurlError(2, "Invalid resume offset");
389
- }
390
- result.continueAt = Number(value);
391
- }
392
- break;
393
- }
394
- case "etag-save":
395
- result.etagSave = value;
396
- break;
397
- case "etag-compare":
398
- result.etagCompare = value;
399
- break;
400
- case "cacert":
401
- result.caFile = value;
402
- break;
403
- case "http1.0":
404
- result.httpVersion = "1.0";
405
- break;
406
- case "http1.1":
407
- result.httpVersion = "1.1";
408
- break;
409
- case "url-query":
410
- (result.query ??= []).push({ kind: value.startsWith("+") ? "raw" : "urlencode", value: value.startsWith("+") ? value.slice(1) : value });
411
- break;
412
- case "request":
413
- if (!value || !/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/.test(value) || ["CONNECT", "TRACE"].includes(value.toUpperCase())) {
414
- throw new CurlError(2, "Invalid or unsupported HTTP method");
415
- }
416
- result.method = value;
417
- break;
418
- case "header":
419
- addHeader(result, value);
420
- break;
421
- case "range":
422
- try {
423
- validateHeaderValue("Range", value);
424
- } catch {
425
- throw new CurlError(2, "Invalid byte range");
426
- }
427
- result.range = value;
428
- break;
429
- case "user-agent":
430
- addHeader(result, `User-Agent: ${value}`);
431
- break;
432
- case "referer": {
433
- validateRequestHeader("Referer", value);
434
- const auto = value.indexOf(";auto");
435
- result.autoReferer = auto >= 0;
436
- result.referer = auto >= 0 ? value.slice(0, auto) : value;
437
- break;
438
- }
439
- case "user":
440
- if (!value.includes(":")) throw new CurlError(2, "Basic authentication requires user:password; prompting is unsupported");
441
- result.user = value;
442
- break;
443
- case "oauth2-bearer":
444
- result.bearer = value;
445
- break;
446
- case "data":
447
- case "data-ascii":
448
- result.data.push({ kind: "data", value });
449
- break;
450
- case "data-raw":
451
- result.data.push({ kind: "raw", value });
452
- break;
453
- case "data-binary":
454
- result.data.push({ kind: "binary", value });
455
- break;
456
- case "data-urlencode":
457
- result.data.push({ kind: "urlencode", value });
458
- break;
459
- case "json":
460
- case "form":
461
- case "form-string":
462
- result.data.push({ kind: option, value });
463
- break;
464
- case "output":
465
- result.output = value;
466
- result.remoteName = false;
467
- (result.outputs ??= []).push({ output: value, remoteName: false });
468
- break;
469
- case "output-dir":
470
- result.outputDirectory = value;
471
- break;
472
- case "dump-header":
473
- result.dumpHeader = value;
474
- break;
475
- case "write-out":
476
- result.writeOut = value;
477
- break;
478
- case "upload-file":
479
- result.upload = value;
480
- break;
481
- case "url":
482
- result.urls.push(value);
483
- break;
484
- case "max-time": {
485
- const milliseconds = timeoutSeconds(value) * 1e3;
486
- result.maxTimeMs = Math.min(milliseconds === 0 ? Infinity : milliseconds, limits.maxTimeMs);
487
- break;
488
- }
489
- case "connect-timeout": {
490
- const milliseconds = timeoutSeconds(value) * 1e3;
491
- if (milliseconds === 0) delete result.connectTimeoutMs;
492
- else result.connectTimeoutMs = Math.min(milliseconds, limits.maxTimeMs);
493
- break;
494
- }
495
- case "max-filesize":
496
- result.maxFileSize = Math.min(number(value, true), limits.maxDownloadBytes);
497
- break;
498
- case "max-redirs":
499
- result.maxRedirects = Math.min(number(value, true), limits.maxRedirects);
500
- break;
501
- case "retry":
502
- result.retries = Math.min(number(value, true), limits.maxRetries);
503
- break;
504
- case "retry-delay":
505
- result.retryDelayMs = Math.min(number(value) * 1e3, limits.maxTimeMs);
506
- break;
507
- case "help":
508
- result.help = true;
509
- break;
510
- case "version":
511
- result.version = true;
512
- break;
513
- case "disable":
514
- case "no-buffer":
515
- case "no-progress-meter":
516
- case "basic":
517
- break;
518
- default:
519
- throw new CurlError(2, "Unsupported curl option");
520
- }
521
- };
522
- let ended = false;
523
- for (let index = 0; index < args.length; index++) {
524
- const argument = args[index];
525
- if (ended || !argument.startsWith("-") || argument === "-") {
526
- result.urls.push(argument);
527
- continue;
528
- }
529
- if (argument === "--") {
530
- ended = true;
531
- continue;
532
- }
533
- if (argument.startsWith("--")) {
534
- const equals = argument.indexOf("=");
535
- const name = argument.slice(2, equals < 0 ? void 0 : equals);
536
- let value = equals < 0 ? void 0 : argument.slice(equals + 1);
537
- if (longValues.has(name)) {
538
- value ??= args[++index];
539
- if (value === void 0) throw new CurlError(2, "Option requires an argument");
540
- } else if (value !== void 0) throw new CurlError(2, "Unexpected option argument");
541
- apply(name, value);
542
- } else {
543
- for (let offset = 1; offset < argument.length; offset++) {
544
- const name = argument[offset];
545
- if (values[name]) {
546
- const value = argument.slice(offset + 1) || args[++index];
547
- if (value === void 0) throw new CurlError(2, "Option requires an argument");
548
- apply(values[name], value);
549
- break;
550
- }
551
- if (!flags[name]) throw new CurlError(2, "Unsupported curl option");
552
- apply(flags[name]);
553
- }
554
- }
555
- }
556
- if (!result.help && !result.version && !result.urls.length) throw new CurlError(2, "No URL specified");
557
- if (result.urls.length > limits.maxUrls) throw new CurlError(2, "URL count exceeds host limit");
558
- if (result.fail && result.failWithBody) throw new CurlError(2, "--fail and --fail-with-body are mutually exclusive");
559
- const form = result.data.some((part) => part.kind === "form" || part.kind === "form-string");
560
- if (result.upload !== void 0 && result.data.length || form && result.data.some((part) => !part.kind.startsWith("form")) || result.get && (form || result.upload !== void 0) || result.head && (result.upload !== void 0 || result.data.length > 0) && !result.get) {
561
- throw new CurlError(2, "Incompatible request body options");
562
- }
563
- if (result.data.some((part) => part.kind === "json") && result.data.some((part) => part.kind !== "json")) {
564
- throw new CurlError(2, "Mixing JSON and other data modes is unsupported");
565
- }
566
- return result;
567
- }
568
-
569
- // packages/safe-bash/src/commands/network/curl.ts
570
- init_platform();
571
-
572
- // packages/safe-bash/src/commands/network/aggregate.ts
573
- init_platform();
574
- function createDeadlineOutput(context, destination, remaining) {
575
- const lifetime = new AbortController();
576
- const signal = AbortSignal.any([context.signal, lifetime.signal]);
577
- const operation = createOutputOperation({ ...context, signal }, destination);
578
- if (operation.signal.aborted) return operation;
579
- const cancel = scheduleNetworkDeadline(remaining, () => lifetime.abort(new CurlError(28, "Operation timed out")));
580
- operation.registerCleanup(cancel);
581
- return operation;
582
- }
583
- async function deadlineDiagnostic(context, error, remaining) {
584
- const operation = createDeadlineOutput(context, context.stderr, remaining);
585
- try {
586
- await diagnostic({ ...context, stderr: operation.output, signal: operation.signal }, error);
587
- } finally {
588
- await operation.close();
589
- }
590
- }
591
-
592
- // packages/safe-bash/src/commands/network/url.ts
593
- init_platform();
594
- function curlRequestTarget(text) {
595
- const scheme = text.indexOf("://");
596
- if (scheme < 0) throw new CurlError(3, "Malformed URL; explicit HTTP(S) scheme required");
597
- let start = scheme + 3;
598
- while (start < text.length && !"/?#".includes(text[start])) {
599
- if (text[start] === "\\") throw new CurlError(3, "Malformed URL authority");
600
- start++;
601
- }
602
- const fragment = text.indexOf("#", start);
603
- const target = text.slice(start, fragment < 0 ? void 0 : fragment);
604
- const queryIndex = target.indexOf("?");
605
- const path = queryIndex < 0 ? target : target.slice(0, queryIndex);
606
- const query = queryIndex < 0 ? "" : target.slice(queryIndex);
607
- const segments = [];
608
- for (const segment of (path || "/").split("/")) {
609
- if (segment === "..") {
610
- if (segments.length > 1) segments.pop();
611
- } else if (segment !== ".") segments.push(segment);
612
- }
613
- if (path.endsWith("/.") || path.endsWith("/..")) segments.push("");
614
- return (segments.join("/") || "/") + query;
615
- }
616
-
617
- // packages/safe-bash/src/commands/network/glob.ts
618
- init_platform();
619
- function decimal(text) {
620
- if (!text || ![...text].every((char) => char >= "0" && char <= "9")) throw new CurlError(3, "Malformed URL range");
621
- const value = Number(text);
622
- if (!Number.isSafeInteger(value)) throw new CurlError(3, "Malformed URL range");
623
- return value;
624
- }
625
- function range(text, maximum, admit) {
626
- const parts = text.split(":");
627
- if (parts.length > 2) throw new CurlError(3, "Malformed URL range");
628
- const ends = parts[0].split("-");
629
- if (ends.length !== 2) throw new CurlError(3, "Malformed URL range");
630
- const [left, right] = ends;
631
- const character = left.length === 1 && right.length === 1 && (left >= "a" && right <= "z" && right >= "a" || left >= "A" && right <= "Z" && right >= "A");
632
- const start = character ? left.charCodeAt(0) : decimal(left);
633
- const end = character ? right.charCodeAt(0) : decimal(right);
634
- const step = parts[1] === void 0 ? 1 : decimal(parts[1]);
635
- if (start > end || step === 0 || step > end - start + 1) throw new CurlError(3, "Malformed URL range");
636
- const count = Math.floor((end - start) / step) + 1;
637
- if (count > maximum) throw new CurlError(2, "URL count exceeds host limit");
638
- const width = !character && left.startsWith("0") ? left.length : 0;
639
- admit(count, count * Math.max(width, character ? 1 : String(end).length));
640
- return Array.from({ length: count }, (_, index) => character ? String.fromCharCode(start + index * step) : String(start + index * step).padStart(width, "0"));
641
- }
642
- function expandUrls(urls, globoff, limits) {
643
- const result = [];
644
- let bytes = 0;
645
- let work = 0;
646
- const charge = (size) => {
647
- work += size;
648
- if (work > limits.maxBufferBytes) throw new CurlError(2, "URL expansion work exceeds host limit");
649
- };
650
- for (const input of urls) {
651
- let expanded = [{ url: "", captures: [] }];
652
- const append = (suffix) => {
653
- const retained = expanded.reduce((total, item) => total + byteLength(item.url) + byteLength(suffix) + item.captures.reduce((size, value) => size + byteLength(value), 0), bytes);
654
- if (retained > limits.maxBufferBytes) throw new CurlError(2, "Expanded URLs exceed host buffer limit");
655
- charge(retained - bytes);
656
- expanded = expanded.map((item) => ({ ...item, url: item.url + suffix }));
657
- };
658
- for (let index = 0; index < input.length; ) {
659
- const char = input[index];
660
- if (globoff) {
661
- append(input.slice(index));
662
- break;
663
- }
664
- if (char === "\\" && "{}[]".includes(input[index + 1] ?? " ")) {
665
- append(input[index + 1]);
666
- index += 2;
667
- continue;
668
- }
669
- if (char !== "{" && char !== "[") {
670
- if (char === "}" || char === "]") throw new CurlError(3, "Unmatched URL glob delimiter");
671
- let end = index + 1;
672
- while (end < input.length && !"{}[]\\".includes(input[end])) end++;
673
- append(input.slice(index, end));
674
- index = end;
675
- continue;
676
- }
677
- const close = input.indexOf(char === "{" ? "}" : "]", index + 1);
678
- if (close < 0) throw new CurlError(3, "Unmatched URL glob delimiter");
679
- const content = input.slice(index + 1, close);
680
- if (char === "{" && content === "") throw new CurlError(3, "Malformed URL glob");
681
- if (char === "[" && content.includes(":") && input.slice(0, index).endsWith("//")) {
682
- append(input.slice(index, close + 1));
683
- index = close + 1;
684
- continue;
685
- }
686
- if ([...content].some((value) => "{}[]".includes(value))) throw new CurlError(3, "Nested URL globs are unsupported");
687
- const maximum = Math.floor((limits.maxUrls - result.length) / expanded.length);
688
- const admit = (count, valueBytes) => {
689
- const prefixBytes = expanded.reduce((total, item) => total + byteLength(item.url) + item.captures.reduce((size, capture) => size + byteLength(capture), 0), 0);
690
- const retained = count * prefixBytes + expanded.length * valueBytes * 2;
691
- if (retained + bytes > limits.maxBufferBytes) throw new CurlError(2, "Expanded URLs exceed host buffer limit");
692
- charge(retained);
693
- };
694
- const values2 = char === "{" ? content.split(",") : range(content, maximum, admit);
695
- if (values2.length > maximum) throw new CurlError(2, "URL count exceeds host limit");
696
- if (char === "{") admit(values2.length, values2.reduce((total, value) => total + byteLength(value), 0));
697
- const next = [];
698
- for (const item of expanded) for (const value of values2) {
699
- next.push({ url: item.url + value, captures: [...item.captures, value] });
700
- }
701
- expanded = next;
702
- index = close + 1;
703
- }
704
- for (const item of expanded) {
705
- bytes += byteLength(item.url) + item.captures.reduce((total, value) => total + byteLength(value), 0);
706
- if (bytes > limits.maxBufferBytes) throw new CurlError(2, "Expanded URLs exceed host buffer limit");
707
- if (result.length >= limits.maxUrls) throw new CurlError(2, "URL count exceeds host limit");
708
- result.push(item);
709
- }
710
- }
711
- return result;
712
- }
713
- function globFilename(template, captures) {
714
- let output = "";
715
- for (let index = 0; index < template.length; ) {
716
- if (template[index] !== "#") {
717
- output += template[index++];
718
- continue;
719
- }
720
- let end = index + 1;
721
- while (end < template.length && template[end] >= "0" && template[end] <= "9") end++;
722
- const number2 = Number(template.slice(index + 1, end));
723
- const capture = captures[number2 - 1];
724
- output += capture === void 0 ? template.slice(index, end) : capture;
725
- index = end;
726
- }
727
- return output;
728
- }
729
-
730
- // packages/safe-bash/src/commands/network/input.ts
731
- init_platform();
732
- function whitespace(character) {
733
- return " \r\n\v\f".includes(character);
734
- }
735
- function configArguments(text) {
736
- const args = [];
737
- for (const line of text.split("\n")) {
738
- let offset = 0;
739
- while (offset < line.length && whitespace(line[offset])) offset++;
740
- if (offset === line.length || line[offset] === "#") continue;
741
- const start = offset;
742
- const dashed = line[offset] === "-";
743
- while (offset < line.length && !whitespace(line[offset]) && (dashed || !"=:".includes(line[offset]))) offset++;
744
- const option = line.slice(start, offset);
745
- args.push(dashed ? option : `--${option}`);
746
- while (offset < line.length && whitespace(line[offset])) offset++;
747
- if (!dashed && "=:".includes(line[offset] ?? "\0")) offset++;
748
- while (offset < line.length && whitespace(line[offset])) offset++;
749
- if (offset === line.length) continue;
750
- let value = "";
751
- if (line[offset] === '"') {
752
- offset++;
753
- let closed = false;
754
- while (offset < line.length) {
755
- let character = line[offset++];
756
- if (character === '"') {
757
- closed = true;
758
- break;
759
- }
760
- if (character === "\\" && offset < line.length) {
761
- character = line[offset++];
762
- character = { n: "\n", r: "\r", t: " ", v: "\v" }[character] ?? character;
763
- }
764
- value += character;
765
- }
766
- if (!closed) throw new CurlError(2, "Unterminated config string");
767
- if (line.slice(offset).trim()) throw new CurlError(2, "Unexpected config string suffix");
768
- } else value = line.slice(offset).trimEnd();
769
- args.push(value);
770
- }
771
- return args;
772
- }
773
- function variableName(name) {
774
- return name.length > 0 && [...name].every((character) => "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_".includes(character));
775
- }
776
- async function parseCurlInput(context, limits) {
777
- const variables = /* @__PURE__ */ new Map();
778
- const output = [];
779
- let inputBytes = 0;
780
- let outputBytes = 0;
781
- let optionCount = 0;
782
- const admit = (value) => {
783
- inputBytes += byteLength(value);
784
- if (inputBytes > limits.maxBufferBytes) throw new CurlError(2, "Curl input exceeds host buffer limit");
785
- return value;
786
- };
787
- const append = (value) => {
788
- outputBytes += byteLength(value);
789
- if (outputBytes > limits.maxBufferBytes) throw new CurlError(2, "Expanded arguments exceed host buffer limit");
790
- output.push(value);
791
- };
792
- const read = async (file) => {
793
- try {
794
- const maxBytes = limits.maxBufferBytes - inputBytes;
795
- const bytes = file === "-" ? await collectNetworkBytes(context.stdin, { signal: context.signal, maxBytes }) : await withSignal(() => context.fs.readFile(pathOf(context, file), { signal: context.signal, ...Number.isFinite(maxBytes) ? { maxBytes } : {} }), context.signal);
796
- context.signal.throwIfAborted();
797
- inputBytes += bytes.length;
798
- if (inputBytes > limits.maxBufferBytes) throw new CurlError(2, "Curl input exceeds host buffer limit");
799
- return encodeBytes(bytes);
800
- } catch (error) {
801
- context.signal.throwIfAborted();
802
- if (error instanceof CurlError) throw error;
803
- throw new CurlError(26, "Failed to read virtual curl input");
804
- }
805
- };
806
- const expand = (value) => {
807
- let result = "";
808
- let size = 0;
809
- let offset = 0;
810
- const appendPiece = (piece) => {
811
- size += byteLength(piece);
812
- if (size > limits.maxBufferBytes) throw new CurlError(2, "Variable expansion exceeds host buffer limit");
813
- result += piece;
814
- };
815
- while (offset < value.length) {
816
- const start = value.indexOf("{{", offset);
817
- if (start < 0) {
818
- appendPiece(value.slice(offset));
819
- break;
820
- }
821
- appendPiece(value.slice(offset, start));
822
- const end = value.indexOf("}}", start + 2);
823
- if (end < 0) {
824
- appendPiece(value.slice(start));
825
- break;
826
- }
827
- const [name, ...functions] = value.slice(start + 2, end).split(":");
828
- if (!variableName(name)) throw new CurlError(2, "Invalid expansion variable");
829
- let bytes = variables.get(name) ?? new Uint8Array(0);
830
- for (const functionName of functions) {
831
- const requireSpace = (length) => {
832
- if (length > limits.maxBufferBytes) throw new CurlError(2, "Variable transformation exceeds host buffer limit");
833
- };
834
- switch (functionName) {
835
- case "trim": {
836
- let start2 = 0, end2 = bytes.length;
837
- while (start2 < end2 && whitespace(String.fromCharCode(bytes[start2]))) start2++;
838
- while (end2 > start2 && whitespace(String.fromCharCode(bytes[end2 - 1]))) end2--;
839
- bytes = bytes.subarray(start2, end2);
840
- break;
841
- }
842
- case "json": {
843
- requireSpace(bytes.length * 6);
844
- bytes = encodeBytes(JSON.stringify(new TextDecoder("utf-8", { fatal: true }).decode(bytes)).slice(1, -1));
845
- break;
846
- }
847
- case "url": {
848
- requireSpace(bytes.length * 3);
849
- let encoded = "";
850
- for (const byte of bytes) {
851
- const character = String.fromCharCode(byte);
852
- encoded += "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~".includes(character) ? character : `%${byte.toString(16).toUpperCase().padStart(2, "0")}`;
853
- }
854
- bytes = encodeBytes(encoded);
855
- break;
856
- }
857
- case "b64":
858
- requireSpace(Math.ceil(bytes.length / 3) * 4);
859
- bytes = encodeBytes(decodeBytes(bytes, "base64"));
860
- break;
861
- default:
862
- throw new CurlError(2, "Unsupported variable expansion function");
863
- }
864
- }
865
- let replacement;
866
- try {
867
- replacement = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
868
- } catch {
869
- throw new CurlError(2, "Binary variable requires url or b64 expansion");
870
- }
871
- if (replacement.includes("\0")) throw new CurlError(2, "Variable expansion contains NUL");
872
- appendPiece(replacement);
873
- offset = end + 2;
874
- }
875
- return result;
876
- };
877
- const define = async (value) => {
878
- const fromEnv = value.startsWith("%");
879
- const spec = fromEnv ? value.slice(1) : value;
880
- let delimiter = spec.indexOf("=");
881
- const at = spec.indexOf("@");
882
- if (delimiter < 0 || at >= 0 && at < delimiter) delimiter = at;
883
- const name = delimiter < 0 ? spec : spec.slice(0, delimiter);
884
- if (!variableName(name)) throw new CurlError(2, "Invalid variable name");
885
- let content = fromEnv && context.env[name] !== void 0 ? encodeBytes(admit(context.env[name])) : void 0;
886
- if (content === void 0) {
887
- if (delimiter < 0) {
888
- if (fromEnv) throw new CurlError(2, "Required environment variable is unset");
889
- content = new Uint8Array(0);
890
- } else content = spec[delimiter] === "@" ? await read(spec.slice(delimiter + 1)) : encodeBytes(admit(spec.slice(delimiter + 1)));
891
- }
892
- variables.set(name, content);
893
- };
894
- let ended = false;
895
- const visit = async (args, depth) => {
896
- if (depth > 16) throw new CurlError(2, "Config nesting exceeds host limit");
897
- for (let index = 0; index < args.length; index++) {
898
- context.signal.throwIfAborted();
899
- if (++optionCount > limits.maxBufferBytes) throw new CurlError(2, "Curl option count exceeds host limit");
900
- const argument = args[index];
901
- if (ended || argument === "-" || !argument.startsWith("-")) {
902
- append(argument);
903
- continue;
904
- }
905
- if (argument === "--") {
906
- ended = true;
907
- append(argument);
908
- continue;
909
- }
910
- const apply = async (name, attached) => {
911
- const expanded = name.startsWith("expand-");
912
- const base = expanded ? name.slice(7) : name;
913
- const takesValue = longValues.has(base) || base === "config" || base === "variable";
914
- if (expanded && !longValues.has(base)) throw new CurlError(2, "Unsupported expand option");
915
- if (!takesValue) {
916
- if (attached !== void 0) throw new CurlError(2, "Unexpected option argument");
917
- append(`--${name}`);
918
- return;
919
- }
920
- const value = attached ?? args[++index];
921
- if (value === void 0) throw new CurlError(2, "Option requires an argument");
922
- const resolved = expanded ? expand(value) : value;
923
- if (base === "config") await visit(configArguments(decodeBytes(await read(resolved), "utf8")), depth + 1);
924
- else if (base === "variable") await define(resolved);
925
- else if (base === "header" && resolved.startsWith("@")) {
926
- const text = decodeBytes(await read(resolved.slice(1)), "utf8");
927
- for (const raw of text.split("\n")) {
928
- context.signal.throwIfAborted();
929
- const line = raw.endsWith("\r") ? raw.slice(0, -1) : raw;
930
- if (!line || line.startsWith("#")) continue;
931
- append("--header");
932
- append(line);
933
- }
934
- } else {
935
- append(`--${base}`);
936
- append(resolved);
937
- }
938
- };
939
- if (argument.startsWith("--")) {
940
- const equals = argument.indexOf("=");
941
- await apply(argument.slice(2, equals < 0 ? void 0 : equals), equals < 0 ? void 0 : argument.slice(equals + 1));
942
- } else {
943
- for (let offset = 1; offset < argument.length; offset++) {
944
- const short = argument[offset];
945
- const name = short === "K" ? "config" : values[short];
946
- if (name) {
947
- await apply(name, argument.slice(offset + 1) || void 0);
948
- break;
949
- }
950
- if (!flags[short]) throw new CurlError(2, "Unsupported curl option");
951
- await apply(flags[short]);
952
- }
953
- }
954
- }
955
- };
956
- await visit(context.args, 0);
957
- return parseArguments(output, limits);
958
- }
959
-
960
- // packages/safe-bash/src/commands/network/body.ts
961
- init_platform();
962
-
963
- // packages/safe-bash/src/commands/network/form-headers.ts
964
- init_platform();
965
- function validatePartHeader(header2) {
966
- const colon = header2.indexOf(":");
967
- if (colon <= 0) throw new CurlError(2, "Invalid multipart part header");
968
- for (const character of header2.slice(0, colon)) {
969
- const code = character.charCodeAt(0);
970
- if (!(code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || "!#$%&'*+-.^_`|~".includes(character)))
971
- throw new CurlError(2, "Invalid multipart part header");
972
- }
973
- for (const character of header2) {
974
- const code = character.charCodeAt(0);
975
- if (code < 32 && code !== 9 || code === 127)
976
- throw new CurlError(2, "Invalid multipart part header");
977
- }
978
- return header2;
979
- }
980
- function filePartHeaders(bytes) {
981
- const headers = [];
982
- for (let line of decodeBytes(encodeBytes(bytes), "utf8").split("\n")) {
983
- if (line.endsWith("\r")) line = line.slice(0, -1);
984
- if (!line || line.startsWith("#")) continue;
985
- if ((line.startsWith(" ") || line.startsWith(" ")) && headers.length) {
986
- headers[headers.length - 1] += " " + line.trim();
987
- validatePartHeader(headers[headers.length - 1]);
988
- } else headers.push(validatePartHeader(line));
989
- }
990
- return headers;
991
- }
992
-
993
- // packages/safe-bash/src/commands/network/form-content-type.ts
994
- init_platform();
995
- function token(character) {
996
- if (character === void 0) return false;
997
- const code = character.charCodeAt(0);
998
- return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || "!#$%&'*+-.^_`|~".includes(character);
999
- }
1000
- function formContentType(input, start, fileList = false) {
1001
- let end = start;
1002
- const invalid = () => {
1003
- throw new CurlError(2, "Invalid multipart content type");
1004
- };
1005
- const readToken = () => {
1006
- const begin = end;
1007
- while (token(input[end])) end++;
1008
- if (end === begin) invalid();
1009
- };
1010
- const whitespace2 = () => {
1011
- while (input[end] === " " || input[end] === " ") end++;
1012
- };
1013
- readToken();
1014
- if (input[end++] !== "/") invalid();
1015
- readToken();
1016
- whitespace2();
1017
- while (end < input.length) {
1018
- if (fileList && input[end] === ",") break;
1019
- if (input[end] !== ";") invalid();
1020
- const separator = end++;
1021
- whitespace2();
1022
- if (["type=", "filename=", "encoder=", "headers="].some((attribute) => input.startsWith(attribute, end))) {
1023
- return { value: input.slice(start, separator), end: separator };
1024
- }
1025
- readToken();
1026
- whitespace2();
1027
- if (input[end++] !== "=") invalid();
1028
- whitespace2();
1029
- if (input[end] === '"') {
1030
- end++;
1031
- let closed = false;
1032
- while (end < input.length) {
1033
- const character = input[end++];
1034
- if (character === '"') {
1035
- closed = true;
1036
- break;
1037
- }
1038
- const literal = character === "\\" ? input[end++] : character;
1039
- if (literal === void 0 || literal.charCodeAt(0) < 32 || literal.charCodeAt(0) === 127) invalid();
1040
- }
1041
- if (!closed) invalid();
1042
- } else readToken();
1043
- whitespace2();
1044
- }
1045
- return { value: input.slice(start, end), end };
1046
- }
1047
-
1048
- // packages/safe-bash/src/commands/network/body.ts
1049
- function multipartBoundary() {
1050
- let boundary = "virtual-bash-";
1051
- for (const byte of randomBytes(18)) boundary += byte.toString(16).padStart(2, "0");
1052
- return boundary;
1053
- }
1054
- function percent(bytes) {
1055
- let output = "";
1056
- for (const byte of bytes) output += byte >= 65 && byte <= 90 || byte >= 97 && byte <= 122 || byte >= 48 && byte <= 57 || [45, 46, 95, 126].includes(byte) ? String.fromCharCode(byte) : byte === 32 ? "+" : `%${byte.toString(16).toUpperCase().padStart(2, "0")}`;
1057
- return encode(output);
1058
- }
1059
- function dataPart(argument) {
1060
- const value = argument.value;
1061
- if (argument.kind === "urlencode") {
1062
- const equals = value.indexOf("=");
1063
- if (equals >= 0) return [{ bytes: encode(equals ? `${value.slice(0, equals)}=` : "") }, { bytes: encode(value.slice(equals + 1)), urlencode: true }];
1064
- const at = value.indexOf("@");
1065
- if (at >= 0) return [{ prefix: encode(at ? `${value.slice(0, at)}=` : ""), file: value.slice(at + 1), urlencode: true }];
1066
- return [{ bytes: encode(value), urlencode: true }];
1067
- }
1068
- if (argument.kind !== "raw" && value.startsWith("@")) return [{ file: value.slice(1), strip: argument.kind === "data" }];
1069
- return [{ bytes: encode(value) }];
1070
- }
1071
- function quoted(value) {
1072
- if (/[\r\n\0]/.test(value)) throw new CurlError(2, "Invalid multipart field metadata");
1073
- return value.replace(/["\\]/g, "\\$&");
1074
- }
1075
- function formWord(input, start, file) {
1076
- const delimiter = (character) => character === ";" || file && character === ",";
1077
- if (input[start] === '"') {
1078
- let value = "";
1079
- for (let index = start + 1; index < input.length; index++) {
1080
- const character = input[index];
1081
- if (character === '"') {
1082
- let end2 = index + 1;
1083
- while (end2 < input.length && !delimiter(input[end2])) end2++;
1084
- return { value, end: end2 };
1085
- }
1086
- if (character === "\\" && (input[index + 1] === "\\" || input[index + 1] === '"')) {
1087
- value += input[++index];
1088
- } else value += character;
1089
- }
1090
- }
1091
- let end = start;
1092
- while (end < input.length && !delimiter(input[end])) end++;
1093
- return { value: input.slice(start, end), end };
1094
- }
1095
- var multipartContentTypes = /* @__PURE__ */ new Map([
1096
- ["gif", "image/gif"],
1097
- ["jpg", "image/jpeg"],
1098
- ["jpeg", "image/jpeg"],
1099
- ["png", "image/png"],
1100
- ["svg", "image/svg+xml"],
1101
- ["txt", "text/plain"],
1102
- ["html", "text/html"],
1103
- ["htm", "text/html"],
1104
- ["pdf", "application/pdf"],
1105
- ["xml", "application/xml"]
1106
- ]);
1107
- function filenameContentType(filename) {
1108
- const basename = posixPath.basename(filename);
1109
- const dot = basename.lastIndexOf(".");
1110
- return dot < 0 ? void 0 : multipartContentTypes.get(basename.slice(dot + 1).toLowerCase());
1111
- }
1112
- function multipart(argument, boundary) {
1113
- const equals = argument.value.indexOf("=");
1114
- if (equals < 0) throw new CurlError(2, "Multipart form requires name=value");
1115
- const name = quoted(argument.value.slice(0, equals));
1116
- const input = argument.value.slice(equals + 1);
1117
- const upload = argument.kind === "form" && input.startsWith("@");
1118
- const isFile = argument.kind === "form" && (upload || input.startsWith("<"));
1119
- const entries = [];
1120
- let start = isFile ? 1 : 0;
1121
- do {
1122
- const word = argument.kind === "form" ? formWord(input, start, isFile) : { value: input, end: input.length };
1123
- const entry = { value: word.value };
1124
- if (isFile) {
1125
- if (!word.value) throw new CurlError(2, "Empty multipart file operand");
1126
- entry.file = word.value;
1127
- if (upload) entry.filename = posixPath.basename(word.value);
1128
- }
1129
- let end = word.end;
1130
- while (end < input.length && input[end] !== ",") {
1131
- const attributeStart = end + 1;
1132
- if (input.startsWith("type=", attributeStart)) {
1133
- const attribute = formContentType(input, attributeStart + 5, upload);
1134
- entry.type = attribute.value;
1135
- end = attribute.end;
1136
- } else if (input.startsWith("filename=", attributeStart)) {
1137
- const attribute = formWord(input, attributeStart + 9, upload);
1138
- entry.filename = attribute.value;
1139
- end = attribute.end;
1140
- } else if (input.startsWith("headers=", attributeStart)) {
1141
- const file = input[attributeStart + 8] === "@";
1142
- const attribute = formWord(input, attributeStart + 8 + (file ? 1 : 0), upload);
1143
- if (!attribute.value) throw new CurlError(2, "Empty multipart header operand");
1144
- (entry.headers ??= []).push({ value: file ? attribute.value : validatePartHeader(attribute.value), file });
1145
- end = attribute.end;
1146
- } else if (input.startsWith("encoder=", attributeStart)) {
1147
- const attribute = formWord(input, attributeStart + 8, upload);
1148
- entry.encoder = attribute.value.toLowerCase();
1149
- end = attribute.end;
1150
- if (!["binary", "8bit", "7bit", "base64", "quoted-printable"].includes(entry.encoder))
1151
- throw new CurlError(2, "Unsupported multipart transfer encoder");
1152
- } else throw new CurlError(2, "Unsupported multipart form attribute");
1153
- }
1154
- entries.push(entry);
1155
- if (end === input.length) break;
1156
- if (!upload) throw new CurlError(2, "Unsupported multipart file list");
1157
- start = end + 1;
1158
- } while (start <= input.length);
1159
- const mixed = entries.length > 1;
1160
- const childBoundary = mixed ? multipartBoundary() : boundary;
1161
- const disposition = `form-data${name ? `; name="${name}"` : ""}`;
1162
- const parts = [];
1163
- if (mixed) parts.push({ bytes: encode(`--${boundary}\r
1164
- Content-Disposition: ${disposition}\r
1165
- Content-Type: multipart/mixed; boundary=${childBoundary}\r
1166
- \r
1167
- `) });
1168
- for (const entry of entries) {
1169
- let preamble = `--${childBoundary}\r
1170
- Content-Disposition: ${mixed ? "attachment" : disposition}`;
1171
- if (entry.filename !== void 0) preamble += `; filename="${quoted(entry.filename)}"`;
1172
- preamble += "\r\n";
1173
- if (entry.type || entry.filename !== void 0) {
1174
- const inferred = entry.filename === void 0 ? void 0 : filenameContentType(entry.filename) ?? (entry.file === void 0 ? void 0 : filenameContentType(entry.file));
1175
- preamble += `Content-Type: ${entry.type ?? inferred ?? "application/octet-stream"}\r
1176
- `;
1177
- }
1178
- if (entry.encoder) preamble += `Content-Transfer-Encoding: ${entry.encoder}\r
1179
- `;
1180
- const encoding = entry.encoder === void 0 ? {} : { encoder: entry.encoder };
1181
- parts.push({ bytes: encode(preamble), headers: entry.headers ?? [] }, entry.file !== void 0 ? { file: entry.file, ...encoding } : { bytes: encode(entry.value), ...encoding }, { bytes: encode("\r\n") });
1182
- }
1183
- if (mixed) parts.push({ bytes: encode(`--${childBoundary}--\r
1184
- \r
1185
- `) });
1186
- return parts;
1187
- }
1188
- async function* transfer(source, encoder, signal) {
1189
- if (!encoder || encoder === "binary" || encoder === "8bit") {
1190
- yield* source;
1191
- return;
1192
- }
1193
- let pending = [];
1194
- let column = 0;
1195
- let output = "";
1196
- const quotedByte = (byte, next, after) => {
1197
- if (byte === 13 && next === 10) {
1198
- output += "\r\n";
1199
- column = 0;
1200
- return 2;
1201
- }
1202
- const trailing = next === void 0 || next === 13 && after === 10;
1203
- const literal = byte >= 33 && byte <= 126 && byte !== 61 || (byte === 32 || byte === 9) && !trailing;
1204
- const token2 = literal ? String.fromCharCode(byte) : `=${byte.toString(16).toUpperCase().padStart(2, "0")}`;
1205
- if (column + token2.length > 75) {
1206
- output += "=\r\n";
1207
- column = 0;
1208
- }
1209
- output += token2;
1210
- column += token2.length;
1211
- return 1;
1212
- };
1213
- for await (const raw of source) {
1214
- for (let offset = 0; offset < raw.length; offset += 16 * 1024) {
1215
- signal.throwIfAborted();
1216
- const chunk = raw.subarray(offset, offset + 16 * 1024);
1217
- if (encoder === "7bit") {
1218
- if (chunk.some((byte) => byte > 127)) throw new CurlError(26, "Non-ASCII byte in 7bit multipart data");
1219
- yield chunk;
1220
- continue;
1221
- }
1222
- pending.push(...chunk);
1223
- let consumed = 0;
1224
- if (encoder === "base64") {
1225
- while (pending.length - consumed >= 57) {
1226
- if (column) output += "\r\n";
1227
- output += decodeBytes(encodeBytes(pending.slice(consumed, consumed + 57)), "base64");
1228
- consumed += 57;
1229
- column = 76;
1230
- }
1231
- } else {
1232
- while (pending.length - consumed >= 3)
1233
- consumed += quotedByte(pending[consumed], pending[consumed + 1], pending[consumed + 2]);
1234
- }
1235
- pending = pending.slice(consumed);
1236
- if (output) {
1237
- yield encode(output);
1238
- output = "";
1239
- }
1240
- await yieldTurn(signal);
1241
- }
1242
- }
1243
- signal.throwIfAborted();
1244
- if (encoder === "base64" && pending.length) {
1245
- if (column) output += "\r\n";
1246
- output += decodeBytes(encodeBytes(pending), "base64");
1247
- } else if (encoder === "quoted-printable") {
1248
- for (let i = 0; i < pending.length; )
1249
- i += quotedByte(pending[i], pending[i + 1], pending[i + 2]);
1250
- }
1251
- if (output) yield encode(output);
1252
- }
1253
- function createBody(context, args, limits) {
1254
- if (!args.data.length && args.upload === void 0) return void 0;
1255
- const parts = [];
1256
- let contentType;
1257
- const form = args.data.some((part) => part.kind.startsWith("form"));
1258
- if (form) {
1259
- const boundary = multipartBoundary();
1260
- contentType = `multipart/form-data; boundary=${boundary}`;
1261
- for (const argument of args.data) parts.push(...multipart(argument, boundary));
1262
- parts.push({ bytes: encode(`--${boundary}--\r
1263
- `) });
1264
- } else if (args.upload !== void 0) parts.push({ file: args.upload });
1265
- else {
1266
- const json = args.data[0]?.kind === "json";
1267
- contentType = json ? "application/json" : "application/x-www-form-urlencoded";
1268
- args.data.forEach((argument, index) => {
1269
- if (index && !json) parts.push({ bytes: encode("&"), separator: true });
1270
- parts.push(...dataPart(argument));
1271
- });
1272
- }
1273
- const hasStdin = parts.some((part) => part.file === "-");
1274
- let opened = false;
1275
- let replayComplete = false;
1276
- let replayable = true;
1277
- let cachedBytes = 0;
1278
- let cache = [];
1279
- let stdinUsed = false;
1280
- const source = async function* (part, signal) {
1281
- if (part.bytes !== void 0) {
1282
- if (!part.headers) {
1283
- yield part.bytes;
1284
- return;
1285
- }
1286
- const headers = [];
1287
- let headerBytes = 0;
1288
- for (const header2 of part.headers) {
1289
- signal.throwIfAborted();
1290
- if (header2.file) {
1291
- const bytes = await collectNetworkBytes(source({ file: header2.value }, signal), {
1292
- signal,
1293
- maxBytes: Math.min(limits.maxBufferBytes, limits.maxUploadBytes) - headerBytes
1294
- });
1295
- headerBytes += bytes.length;
1296
- headers.push(...filePartHeaders(bytes));
1297
- } else {
1298
- headerBytes += encode(header2.value).length;
1299
- if (headerBytes > Math.min(limits.maxBufferBytes, limits.maxUploadBytes))
1300
- throw new CurlError(63, "Multipart headers exceed host byte limit");
1301
- headers.push(header2.value);
1302
- }
1303
- }
1304
- const overridden = new Set(headers.map((header2) => header2.slice(0, header2.indexOf(":")).toLowerCase()));
1305
- const defaults = decodeBytes(encodeBytes(part.bytes), "utf8").split("\r\n");
1306
- const preamble = defaults.filter((line, index) => index === 0 || line && !overridden.has(line.slice(0, line.indexOf(":")).toLowerCase()));
1307
- yield encode([...preamble, ...headers, "", ""].join("\r\n"));
1308
- return;
1309
- }
1310
- if (part.file === "-") {
1311
- if (!stdinUsed) {
1312
- stdinUsed = true;
1313
- yield* readBytes(context.stdin, signal);
1314
- }
1315
- return;
1316
- }
1317
- try {
1318
- const path = pathOf(context, part.file);
1319
- const capabilities = await context.fs.capabilitiesFor?.(path, { signal }) ?? context.fs.capabilities;
1320
- signal.throwIfAborted();
1321
- if (context.fs.readStream && capabilities.streamingRead !== false) yield* readBytes(context.fs.readStream(path, { signal }), signal);
1322
- else yield await context.fs.readFile(path, { signal, ...Number.isFinite(Math.min(limits.maxBufferBytes, limits.maxUploadBytes)) ? { maxBytes: Math.min(limits.maxBufferBytes, limits.maxUploadBytes) } : {} });
1323
- } catch (error) {
1324
- signal.throwIfAborted();
1325
- if (error instanceof CurlError) throw error;
1326
- throw new CurlError(26, "Failed to read virtual upload file");
1327
- }
1328
- };
1329
- return {
1330
- ...contentType === void 0 ? {} : { contentType },
1331
- open(signal) {
1332
- return (async function* () {
1333
- if (hasStdin && opened) {
1334
- if (!replayComplete || !replayable) throw new CurlError(65, "Cannot replay stdin upload within the host buffer limit");
1335
- for (const chunk of cache) {
1336
- signal.throwIfAborted();
1337
- yield chunk.slice();
1338
- }
1339
- return;
1340
- }
1341
- opened = true;
1342
- let count = 0;
1343
- let chunks = 0;
1344
- for (const part of parts) {
1345
- if (part.separator && count === 0) continue;
1346
- let prefix = part.prefix;
1347
- for await (const raw of transfer(source(part, signal), part.encoder, signal)) {
1348
- if (++chunks % 256 === 0) await yieldTurn(signal);
1349
- for (let offset = 0; offset < raw.length; offset += 16 * 1024) {
1350
- signal.throwIfAborted();
1351
- let chunk = raw.subarray(offset, offset + 16 * 1024);
1352
- if (part.strip) chunk = chunk.filter((byte) => byte !== 0 && byte !== 10 && byte !== 13);
1353
- if (part.urlencode) chunk = percent(chunk);
1354
- count += chunk.length + (prefix?.length ?? 0);
1355
- if (count > limits.maxUploadBytes) throw new CurlError(63, "Upload exceeds host byte limit");
1356
- if (prefix?.length) {
1357
- const prefixed = new Uint8Array(prefix.length + chunk.length);
1358
- prefixed.set(prefix);
1359
- prefixed.set(chunk, prefix.length);
1360
- chunk = prefixed;
1361
- prefix = void 0;
1362
- }
1363
- if (hasStdin && replayable) {
1364
- cachedBytes += chunk.length;
1365
- if (cachedBytes > limits.maxBufferBytes) {
1366
- replayable = false;
1367
- cache = [];
1368
- } else cache.push(new Uint8Array(chunk));
1369
- }
1370
- if (chunk.length) yield chunk;
1371
- }
1372
- }
1373
- }
1374
- replayComplete = true;
1375
- })();
1376
- }
1377
- };
1378
- }
1379
- async function queryData(body, signal, limits) {
1380
- try {
1381
- return decodeBytes(encodeBytes(await collectNetworkBytes(body.open(signal), { signal, maxBytes: limits.maxBufferBytes })), "utf8");
1382
- } catch (error) {
1383
- signal.throwIfAborted();
1384
- if (error instanceof CurlError) throw error;
1385
- throw new CurlError(63, "Query data exceeds host buffer limit");
1386
- }
1387
- }
1388
-
1389
- // packages/safe-bash/src/commands/network/decode.ts
1390
- init_platform();
1391
- var maxEncodingLayers = 4;
1392
- async function* decodeContent(source, encoding, signal, maxBytes) {
1393
- let layers = 1;
1394
- for (const character of encoding) {
1395
- if (character === "," && ++layers > maxEncodingLayers) throw new CurlError(61, "Too many content encoding layers");
1396
- }
1397
- const formats = encoding.split(",").map((value) => value.trim().toLowerCase()).filter((value) => value !== "identity");
1398
- if (formats.some((value) => value !== "gzip" && value !== "deflate")) throw new CurlError(61, "Unsupported content encoding");
1399
- if (!formats.length) {
1400
- yield* source;
1401
- return;
1402
- }
1403
- const iterator = readBytes(source, signal)[Symbol.asyncIterator]();
1404
- let inputError;
1405
- let inputFailed = false;
1406
- let stream = new ReadableStream({
1407
- async pull(controller) {
1408
- try {
1409
- const next = await iterator.next();
1410
- if (next.done) controller.close();
1411
- else controller.enqueue(new Uint8Array(next.value));
1412
- } catch (error) {
1413
- inputFailed = true;
1414
- inputError = error;
1415
- controller.error(error);
1416
- }
1417
- },
1418
- async cancel() {
1419
- await iterator.return?.(void 0);
1420
- }
1421
- }, { highWaterMark: 0 });
1422
- let budgetError;
1423
- for (const format of formats.reverse()) {
1424
- let decodedBytes = 0;
1425
- stream = stream.pipeThrough(new DecompressionStream(format)).pipeThrough(new TransformStream({
1426
- transform(chunk, controller) {
1427
- signal.throwIfAborted();
1428
- decodedBytes += chunk.byteLength;
1429
- if (decodedBytes > maxBytes) {
1430
- budgetError = new CurlError(63, "Decoded response exceeds download byte limit");
1431
- throw budgetError;
1432
- }
1433
- controller.enqueue(chunk);
1434
- }
1435
- }));
1436
- }
1437
- const reader = stream.getReader();
1438
- try {
1439
- while (true) {
1440
- const next = await withSignal(() => reader.read(), signal);
1441
- if (next.done) return;
1442
- yield next.value;
1443
- }
1444
- } catch {
1445
- signal.throwIfAborted();
1446
- if (inputFailed) throw inputError;
1447
- if (budgetError) throw budgetError;
1448
- throw new CurlError(61, "Invalid compressed response body");
1449
- } finally {
1450
- await reader.cancel().catch(() => void 0);
1451
- await iterator.return(void 0).catch(() => void 0);
1452
- reader.releaseLock();
1453
- }
1454
- }
1455
-
1456
- // packages/safe-bash/src/commands/network/output.ts
1457
- init_platform();
1458
- function responseHeaders(response, maxBytes) {
1459
- if (!Number.isInteger(response.status) || response.status < 100 || response.status > 599 || /[\r\n]/.test(response.statusText)) {
1460
- throw new CurlError(56, "Invalid HTTP response status");
1461
- }
1462
- const version = response.httpVersion ?? "1.1";
1463
- if (!/^\d(?:\.\d)?$/.test(version)) throw new CurlError(56, "Invalid HTTP response version");
1464
- let text = `HTTP/${version} ${response.status} ${response.statusText}\r
1465
- `;
1466
- for (const [name, value] of response.headers) {
1467
- if (!/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/.test(name) || /[\r\n\0]/.test(value)) throw new CurlError(56, "Invalid HTTP response header");
1468
- text += `${name}: ${value}\r
1469
- `;
1470
- if (byteLength(text, "latin1") > maxBytes) throw new CurlError(63, "Response headers exceed host byte limit");
1471
- }
1472
- return new Uint8Array(encodeBytes(`${text}\r
1473
- `, "latin1"));
1474
- }
1475
- async function writeOutput(context, path, source, signal, append = false, preserveEmpty = false) {
1476
- if (path === void 0 || path === "-") {
1477
- try {
1478
- for await (const chunk of readBytes(source, signal)) {
1479
- try {
1480
- await writeBytes(context.stdout, chunk, signal);
1481
- } catch {
1482
- signal.throwIfAborted();
1483
- throw new CurlError(23, "Failed writing output");
1484
- }
1485
- }
1486
- } catch (error) {
1487
- await context.stdout[outputFailure]?.(error);
1488
- throw error;
1489
- }
1490
- return;
1491
- }
1492
- try {
1493
- let target = preserveEmpty ? void 0 : await openFileOutput({ ...context, signal, outputBudget: "independent" }, pathOf(context, path), append ? "a" : "w");
1494
- try {
1495
- for await (const chunk of readBytes(source, target?.signal ?? signal)) {
1496
- if (preserveEmpty && chunk.length === 0) continue;
1497
- target ??= await openFileOutput({ ...context, signal, outputBudget: "independent" }, pathOf(context, path), append ? "a" : "w");
1498
- await target.sink.write(chunk);
1499
- }
1500
- await target?.finish();
1501
- } catch (error) {
1502
- await target?.abort(error);
1503
- throw error;
1504
- }
1505
- } catch (error) {
1506
- signal.throwIfAborted();
1507
- if (error instanceof CurlError) throw error;
1508
- throw new CurlError(23, error instanceof FsError ? `Failed writing virtual output file: ${error.message}` : "Failed writing virtual output file");
1509
- }
1510
- }
1511
- async function dumpHeaders(context, path, bytes, append, signal) {
1512
- try {
1513
- if (path === "-") await writeBytes(context.stdout, bytes, signal);
1514
- else {
1515
- const target = await openFileOutput({ ...context, signal, outputBudget: "independent" }, pathOf(context, path), append ? "a" : "w");
1516
- try {
1517
- await target.sink.write(bytes);
1518
- await target.finish();
1519
- } catch (error) {
1520
- await target.abort(error);
1521
- throw error;
1522
- }
1523
- }
1524
- } catch {
1525
- signal.throwIfAborted();
1526
- throw new CurlError(23, "Failed writing response headers");
1527
- }
1528
- }
1529
- function writeOutFormat(format, values2, maxBytes) {
1530
- let result = "";
1531
- let bytes = 0;
1532
- const sizes = /* @__PURE__ */ new Map();
1533
- const append = (text) => {
1534
- let size = sizes.get(text);
1535
- if (size === void 0) {
1536
- size = byteLength(text);
1537
- sizes.set(text, size);
1538
- }
1539
- if (size > maxBytes - bytes) throw new CurlError(63, "Write-out exceeds host buffer limit");
1540
- bytes += size;
1541
- result += text;
1542
- };
1543
- for (let index = 0; index < format.length; index++) {
1544
- const character = format[index];
1545
- if (character === "\\") {
1546
- const next = format[++index];
1547
- append(next === "n" ? "\n" : next === "r" ? "\r" : next === "t" ? " " : next === void 0 ? "\\" : `\\${next}`);
1548
- } else if (character === "%" && format[index + 1] === "%") {
1549
- append("%");
1550
- index++;
1551
- } else if (character === "%" && format[index + 1] === "{") {
1552
- const end = format.indexOf("}", index + 2);
1553
- if (end < 0) throw new CurlError(2, "Invalid write-out format");
1554
- const name = format.slice(index + 2, end);
1555
- if (!Object.hasOwn(values2, name)) throw new CurlError(2, "Unsupported write-out variable");
1556
- append(values2[name]);
1557
- index = end;
1558
- } else {
1559
- const start = index;
1560
- while (index + 1 < format.length && format[index + 1] !== "%" && format[index + 1] !== "\\") index++;
1561
- append(format.slice(start, index + 1));
1562
- }
1563
- }
1564
- return encode(result);
1565
- }
1566
-
1567
- // packages/safe-bash/src/commands/network/curl.ts
1568
- var retryStatuses = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504]);
1569
- var redirectStatuses = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
1570
- var writeOutDefaults = Object.freeze({
1571
- http_code: "000",
1572
- response_code: "000",
1573
- url_effective: "",
1574
- redirect_url: "",
1575
- content_type: "",
1576
- size_download: "0",
1577
- size_upload: "0",
1578
- num_redirects: "0",
1579
- num_retries: "0",
1580
- time_total: "0.000000",
1581
- exitcode: "0",
1582
- errormsg: "",
1583
- filename_effective: "",
1584
- method: "GET",
1585
- http_version: ""
1586
- });
1587
- function parseUrl(text, redirect = false) {
1588
- if (/[\s\x00-\x1f\x7f]/.test(text)) throw new CurlError(3, "Malformed URL");
1589
- let url;
1590
- try {
1591
- url = new URL(text);
1592
- } catch {
1593
- throw new CurlError(3, "Malformed URL; explicit HTTP(S) scheme required");
1594
- }
1595
- if (!["http:", "https:"].includes(url.protocol)) throw new CurlError(1, "Only HTTP and HTTPS are supported");
1596
- if (!url.hostname) throw new CurlError(3, "Malformed URL");
1597
- let user;
1598
- if (url.username || url.password) {
1599
- if (redirect) throw new CurlError(3, "Redirect URLs may not supply credentials");
1600
- try {
1601
- user = `${decodeURIComponent(url.username)}:${decodeURIComponent(url.password)}`;
1602
- } catch {
1603
- throw new CurlError(3, "Malformed URL credentials");
1604
- }
1605
- url.username = "";
1606
- url.password = "";
1607
- }
1608
- url.hash = "";
1609
- return { url, ...user === void 0 ? {} : { user } };
1610
- }
1611
- function requestHeaders(args, contentType, user, scoped, maxBytes, previous) {
1612
- const json = args.data[0]?.kind === "json";
1613
- if (json) contentType = "application/json";
1614
- const defaults = [["Accept", json ? "application/json" : "*/*"], ["User-Agent", args.agent ?? "virtual-bash-curl/0.0"]];
1615
- if (contentType !== void 0) defaults.push(["Content-Type", contentType]);
1616
- if (args.compressed) defaults.push(["Accept-Encoding", "gzip, deflate"]);
1617
- const referer = args.autoReferer && previous !== void 0 ? previous : args.referer;
1618
- if (referer) {
1619
- validateRequestHeader("Referer", referer);
1620
- defaults.push(["Referer", referer]);
1621
- }
1622
- if (scoped && args.etag !== void 0) defaults.push(["If-None-Match", args.etag]);
1623
- if (args.range !== void 0) defaults.push(["Range", `bytes=${args.range}`]);
1624
- if (scoped && user !== void 0) defaults.push(["Authorization", `Basic ${decodeBytes(encodeBytes(user), "base64")}`]);
1625
- if (scoped && args.bearer !== void 0) {
1626
- if (/[\r\n\0]/.test(args.bearer)) throw new CurlError(2, "Invalid bearer token");
1627
- defaults.push(["Authorization", `Bearer ${args.bearer}`]);
1628
- }
1629
- const custom = scoped ? args.headers : [];
1630
- const names = new Set(custom.map(([name]) => name.toLowerCase()));
1631
- const result = [
1632
- ...defaults.filter(([name]) => !names.has(name.toLowerCase())),
1633
- ...custom.filter((entry) => entry[1] !== null)
1634
- ];
1635
- if (result.reduce((size, [name, value]) => size + byteLength(name + value) + 4, 0) > maxBytes) {
1636
- throw new CurlError(63, "Request headers exceed host byte limit");
1637
- }
1638
- return result;
1639
- }
1640
- async function stop(response, signal) {
1641
- if (!response) return;
1642
- const cleanup = Promise.resolve().then(() => response.dispose());
1643
- void cleanup.catch(() => {
1644
- });
1645
- if (!signal.aborted) await withSignal(() => cleanup, signal).catch(() => {
1646
- });
1647
- }
1648
- function pipeClosed(error) {
1649
- return error instanceof Error && "code" in error && error.code === "EPIPE";
1650
- }
1651
- function remoteFilename(url) {
1652
- if (url.pathname === "/") return "curl_response";
1653
- const name = posixPath.basename(url.pathname);
1654
- if (!name || name === "/" || name === "." || name === "..") throw new CurlError(23, "URL has no safe remote filename");
1655
- return name;
1656
- }
1657
- async function existingSize(context, output, signal) {
1658
- try {
1659
- return (await context.fs.stat(pathOf(context, output), { signal })).size;
1660
- } catch (error) {
1661
- signal.throwIfAborted();
1662
- if (error instanceof FsError && error.code === "ENOENT") return void 0;
1663
- throw new CurlError(23, "Failed inspecting virtual output file");
1664
- }
1665
- }
1666
- function createCurlCommand(options) {
1667
- return createTransferCommand(options, {
1668
- name: "curl",
1669
- help: "Usage: curl [HTTP(S) URL] [-X METHOD] [-H HEADER] [-d DATA] [-L] [-o VFSFILE]\nExplicit host authorization is required. See network/README.md for supported flags and limits.\n",
1670
- version: "virtual-bash curl 0.0 (HTTP HTTPS; Node streaming transport)\n",
1671
- parse: parseCurlInput,
1672
- status: (code) => code
1673
- });
1674
- }
1675
- function createTransferCommand(options, profile) {
1676
- if (typeof options?.authorize !== "function") throw new TypeError(`${profile.name} requires an explicit network authorizer`);
1677
- const limits = limitsFor(options.limits);
1678
- if (requiresFiniteUrlLimits && (!Number.isFinite(limits.maxUrls) || !Number.isFinite(limits.maxBufferBytes))) {
1679
- throw new TypeError("Portable network commands require finite maxUrls and maxBufferBytes limits");
1680
- }
1681
- const transport = options.transport ?? createDefaultHttpTransport({ maxHeaderBytes: limits.maxHeaderBytes });
1682
- if (typeof transport !== "function") throw new TypeError("Invalid HTTP transport");
1683
- const authorize = options.authorize;
1684
- const executions = /* @__PURE__ */ new WeakMap();
1685
- const def = {
1686
- name: profile.name,
1687
- async execute(context) {
1688
- context.signal.throwIfAborted();
1689
- const scope = context.executionScope ?? {};
1690
- let started = executions.get(scope) ?? performance.now();
1691
- const parsing = new AbortController();
1692
- const parsingSignal = AbortSignal.any([context.signal, parsing.signal]);
1693
- inheritYieldCheckpoint(context.signal, parsingSignal);
1694
- const cancelParsingDeadline = scheduleNetworkDeadline(
1695
- limits.maxTotalTimeMs - (performance.now() - started),
1696
- () => parsing.abort(new CurlError(28, "Operation timed out"))
1697
- );
1698
- let args;
1699
- let expanded;
1700
- try {
1701
- if (context.args.reduce((size, value) => size + byteLength(value), 0) > limits.maxBufferBytes) throw new CurlError(2, "Arguments exceed host buffer limit");
1702
- args = await withSignal(() => profile.parse({ ...context, signal: parsingSignal }, limits), parsingSignal);
1703
- parsingSignal.throwIfAborted();
1704
- if (performance.now() - started >= limits.maxTotalTimeMs) throw new CurlError(28, "Operation timed out");
1705
- if (args.help || args.version) {
1706
- await writeBytes(context.stdout, encode(args.version ? profile.version : profile.help), context.signal);
1707
- return { exitCode: 0 };
1708
- }
1709
- if (args.connectTimeoutMs !== void 0 && transport.supportsConnectTimeout !== true) {
1710
- throw new CurlError(2, "Transport cannot enforce connection timeout");
1711
- }
1712
- if (args.caFile !== void 0 && transport.supportsRequestCa !== true) {
1713
- throw new CurlError(2, "Transport cannot enforce request CA trust");
1714
- }
1715
- if (args.httpVersion !== void 0 && !transport.supportedHttpVersions?.includes(args.httpVersion)) {
1716
- throw new CurlError(2, "Transport cannot enforce requested HTTP version");
1717
- }
1718
- if (args.ignoreContentLength && transport.supportsIgnoreContentLength !== true) {
1719
- throw new CurlError(2, "Transport cannot enforce ignored Content-Length");
1720
- }
1721
- expanded = expandUrls(args.urls, args.globoff, limits);
1722
- for (const item of expanded) parseUrl(item.url);
1723
- if (!args.download) {
1724
- expanded = args.urls.flatMap((url, index) => expandUrls([url], args.globoff, limits).map((item) => ({ ...item, destination: args.outputs?.[index] ?? { remoteName: false } })));
1725
- }
1726
- } catch (error) {
1727
- context.signal.throwIfAborted();
1728
- const failure = error instanceof CurlError ? error : new CurlError(2, `Invalid ${profile.name} arguments`);
1729
- const reported = new CurlError(profile.status(failure.exitCode), failure.message);
1730
- if (failure.exitCode === 28) {
1731
- try {
1732
- await deadlineDiagnostic(context, reported, 0);
1733
- } catch (error2) {
1734
- context.signal.throwIfAborted();
1735
- if (!(error2 instanceof CurlError)) throw error2;
1736
- }
1737
- } else await diagnostic(context, reported);
1738
- return { exitCode: profile.status(failure.exitCode) };
1739
- } finally {
1740
- cancelParsingDeadline();
1741
- }
1742
- started = Math.min(started, executions.get(scope) ?? started);
1743
- executions.set(scope, started);
1744
- let exitCode = 0;
1745
- const headerState = { dumped: false };
1746
- for (const item of expanded) {
1747
- context.signal.throwIfAborted();
1748
- if (performance.now() - started >= limits.maxTotalTimeMs) {
1749
- const failure = new CurlError(28, "Operation timed out");
1750
- if (!args.silent || args.showError) {
1751
- try {
1752
- await deadlineDiagnostic(context, failure, 0);
1753
- } catch (error) {
1754
- context.signal.throwIfAborted();
1755
- if (!(error instanceof CurlError)) throw error;
1756
- }
1757
- }
1758
- return { exitCode: profile.status(failure.exitCode) };
1759
- }
1760
- const transferArgs = { ...args };
1761
- if (item.destination) {
1762
- delete transferArgs.output;
1763
- transferArgs.remoteName = item.destination.remoteName;
1764
- if (item.destination.output !== void 0) transferArgs.output = item.destination.output;
1765
- }
1766
- if (transferArgs.output !== void 0) transferArgs.output = globFilename(transferArgs.output, item.captures);
1767
- const code = await transfer2(context, transferArgs, item.url, limits, transport, authorize, started, profile.status, headerState);
1768
- exitCode = args.download ? code || exitCode : code;
1769
- }
1770
- return { exitCode };
1771
- }
1772
- };
1773
- builtInDirectContextExecutors.add(def.execute);
1774
- return def;
1775
- }
1776
- async function transfer2(context, args, input, limits, transport, authorize, started, status, headerState) {
1777
- const start = performance.now();
1778
- const remaining = () => Math.min(args.maxTimeMs - (performance.now() - start), limits.maxTotalTimeMs - (performance.now() - started));
1779
- const hasFileOutput = args.etagSave !== void 0 && args.etagSave !== "-" || args.remoteName || args.output !== void 0 && args.output !== "-" || args.dumpHeader !== void 0 && args.dumpHeader !== "-";
1780
- const operation = createDeadlineOutput(context, hasFileOutput ? { write: (chunk) => context.stdout.write(chunk) } : context.stdout, remaining());
1781
- const signal = operation.signal;
1782
- const borrowed = context.stdout.ownedOutput ? { [Symbol.asyncIterator]() {
1783
- const iterator = context.stdin[Symbol.asyncIterator]();
1784
- return { next: () => iterator.next() };
1785
- } } : context.stdin;
1786
- let response;
1787
- let failure;
1788
- const values2 = { ...writeOutDefaults };
1789
- let format = args.writeOut;
1790
- let formatReady = false;
1791
- let dumped = false;
1792
- let downloaded = 0;
1793
- let uploaded = 0;
1794
- let included = [];
1795
- let closedOutput = false;
1796
- const publish = async (bytes) => {
1797
- const writing = createDeadlineOutput(context, context.stdout, remaining());
1798
- try {
1799
- await writeBytes(writing.output, bytes, writing.signal);
1800
- } catch (error) {
1801
- context.signal.throwIfAborted();
1802
- if (!pipeClosed(error)) throw error;
1803
- closedOutput = true;
1804
- } finally {
1805
- await writing.close();
1806
- }
1807
- };
1808
- try {
1809
- if (args.etagCompare !== void 0) {
1810
- let bytes;
1811
- try {
1812
- bytes = await withSignal(() => context.fs.readFile(pathOf(context, args.etagCompare), { signal, ...Number.isFinite(limits.maxBufferBytes) ? { maxBytes: limits.maxBufferBytes } : {} }), signal);
1813
- } catch (error) {
1814
- signal.throwIfAborted();
1815
- if (!(error instanceof FsError && error.code === "ENOENT")) throw new CurlError(26, "Failed reading virtual ETag file");
1816
- bytes = new Uint8Array();
1817
- }
1818
- if (bytes.length > limits.maxBufferBytes) throw new CurlError(63, "ETag file exceeds host buffer limit");
1819
- const text = decodeBytes(encodeBytes(bytes), "latin1");
1820
- args.etag = text.split("\r").join("").split("\n").join("") || '""';
1821
- validateRequestHeader("If-None-Match", args.etag);
1822
- }
1823
- let ca;
1824
- if (args.caFile !== void 0) {
1825
- try {
1826
- const bytes = await withSignal(() => context.fs.readFile(pathOf(context, args.caFile), { signal, ...Number.isFinite(limits.maxBufferBytes) ? { maxBytes: limits.maxBufferBytes } : {} }), signal);
1827
- signal.throwIfAborted();
1828
- if (bytes.length > limits.maxBufferBytes) throw new CurlError(77, "CA certificate exceeds host buffer limit");
1829
- ca = new Uint8Array(bytes);
1830
- } catch {
1831
- signal.throwIfAborted();
1832
- throw new CurlError(77, "Failed reading virtual CA certificate file");
1833
- }
1834
- }
1835
- if (format?.startsWith("@")) {
1836
- try {
1837
- const bytes = format === "@-" ? await collectNetworkBytes(borrowed, { signal, maxBytes: limits.maxBufferBytes }) : await withSignal(() => context.fs.readFile(pathOf(context, format.slice(1)), { signal, ...Number.isFinite(limits.maxBufferBytes) ? { maxBytes: limits.maxBufferBytes } : {} }), signal);
1838
- format = decodeBytes(encodeBytes(bytes), "utf8");
1839
- } catch {
1840
- signal.throwIfAborted();
1841
- throw new CurlError(26, "Failed reading write-out format");
1842
- }
1843
- }
1844
- if (format !== void 0) {
1845
- writeOutFormat(format, values2, limits.maxBufferBytes);
1846
- formatReady = true;
1847
- }
1848
- const parsed = parseUrl(input);
1849
- const initial = parsed.url;
1850
- const rawTarget = curlRequestTarget(input);
1851
- let initialTarget = rawTarget;
1852
- const initialSearch = initial.search;
1853
- if (args.query?.length) {
1854
- const queryArgs = { ...args, data: args.query };
1855
- delete queryArgs.upload;
1856
- const queryBody = createBody({ ...context, stdin: borrowed }, queryArgs, limits);
1857
- const encoded = await queryData(queryBody, signal, limits);
1858
- let query = "";
1859
- for (let index = 0; index < encoded.length; index++) {
1860
- const character = encoded[index];
1861
- if (character.charCodeAt(0) < 33 || character.charCodeAt(0) > 126) throw new CurlError(3, "Query data must be URL encoded");
1862
- if (character === "%" && index + 2 < encoded.length && "0123456789abcdefABCDEF".includes(encoded[index + 1]) && "0123456789abcdefABCDEF".includes(encoded[index + 2])) {
1863
- query += encoded.slice(index, index + 3).toLowerCase();
1864
- index += 2;
1865
- } else query += character;
1866
- }
1867
- initial.search += `${initial.search ? "&" : "?"}${query}`;
1868
- }
1869
- let body = createBody({ ...context, stdin: borrowed }, args, limits);
1870
- if (args.get && body) {
1871
- const query = await queryData(body, signal, limits);
1872
- if (/[^\x21-\x7e]/.test(query)) throw new CurlError(3, "GET data must be URL encoded");
1873
- initial.search += `${initial.search ? "&" : "?"}${query.replace(/%[0-9a-f]{2}/gi, (escape) => escape.toLowerCase())}`;
1874
- body = void 0;
1875
- }
1876
- if (initial.search !== initialSearch) initialTarget += initial.search.slice(initialSearch.length);
1877
- let output = args.remoteName ? args.directoryIndex && initial.pathname.endsWith("/") ? args.directoryIndex : remoteFilename(initial) : args.output;
1878
- if (args.outputDirectory !== void 0 && output !== void 0 && output !== "-" && (!args.download || args.remoteName)) {
1879
- output = `${args.outputDirectory}/${output}`;
1880
- }
1881
- values2.filename_effective = output && output !== "-" ? output : "";
1882
- let resumeOffset = 0;
1883
- if (args.continueAt !== void 0) {
1884
- resumeOffset = args.continueAt === "auto" ? output && output !== "-" ? await existingSize(context, output, signal) ?? 0 : 0 : args.continueAt;
1885
- }
1886
- if (args.download && !args.download.spider && output && output !== "-") {
1887
- if (args.download.noClobber && !args.download.contentDisposition && await existingSize(context, output, signal) !== void 0) return 0;
1888
- if (args.download.resume) resumeOffset = await existingSize(context, output, signal) ?? 0;
1889
- }
1890
- if (output && output !== "-" && args.dumpHeader && args.dumpHeader !== "-" && normalizePath(pathOf(context, output)) === normalizePath(pathOf(context, args.dumpHeader))) {
1891
- throw new CurlError(23, "Body and header output files must differ");
1892
- }
1893
- const initialRequestMethod = args.head || args.download?.spider ? "HEAD" : args.get ? "GET" : args.upload !== void 0 ? "PUT" : body ? "POST" : "GET";
1894
- const initialMethod = args.method ?? initialRequestMethod;
1895
- requestHeaders(args, body?.contentType, args.user ?? parsed.user, true, limits.maxHeaderBytes);
1896
- attempts: for (let attempt = 0; attempt <= args.retries; attempt++) {
1897
- if (attempt && args.download?.resume && output && output !== "-") resumeOffset = await existingSize(context, output, signal) ?? 0;
1898
- values2.num_retries = String(attempt);
1899
- downloaded = 0;
1900
- uploaded = 0;
1901
- failure = void 0;
1902
- let current = new URL(initial);
1903
- let currentUrl = current.origin + initialTarget;
1904
- let method = initialMethod;
1905
- let requestMethod = initialRequestMethod;
1906
- let currentBody = body;
1907
- let credentialsInScope = true;
1908
- let previous;
1909
- let redirects = 0;
1910
- included = [];
1911
- let headerBytes = 0;
1912
- while (true) {
1913
- signal.throwIfAborted();
1914
- if (remaining() <= 0) throw new CurlError(28, "Operation timed out");
1915
- values2.url_effective = currentUrl;
1916
- values2.method = method;
1917
- let denyPrivateNetworks = false;
1918
- let allowed;
1919
- try {
1920
- allowed = await withSignal(() => authorize({
1921
- url: currentUrl,
1922
- method,
1923
- attempt,
1924
- signal,
1925
- requirePrivateNetworkDeny() {
1926
- denyPrivateNetworks = true;
1927
- },
1928
- ...previous === void 0 ? {} : { redirectFrom: previous }
1929
- }), signal);
1930
- } catch {
1931
- signal.throwIfAborted();
1932
- throw new CurlError(7, "Network authorization failed");
1933
- }
1934
- if (remaining() <= 0) throw new CurlError(28, "Operation timed out");
1935
- if (allowed !== true) throw new CurlError(7, "Network access denied by host policy");
1936
- const policy = denyPrivateNetworks ? { denyPrivateNetworks: true } : {};
1937
- if (policy.denyPrivateNetworks && transport.supportsPrivateNetworkDeny !== true) {
1938
- throw new CurlError(7, "Transport cannot enforce private network policy");
1939
- }
1940
- const headers = requestHeaders(resumeOffset ? { ...args, range: `${resumeOffset}-` } : args, currentBody?.contentType, args.user ?? parsed.user, credentialsInScope, limits.maxHeaderBytes, previous);
1941
- if (args.verbose) await writeBytes(context.stderr, encode(`> ${method} ${current.origin}
1942
- ${headers.map(([name]) => `> ${name}: [redacted]
1943
- `).join("")}`), signal);
1944
- const upload = currentBody && (async function* () {
1945
- for await (const chunk of currentBody.open(signal)) {
1946
- uploaded += chunk.length;
1947
- yield chunk;
1948
- }
1949
- })();
1950
- try {
1951
- response = await operation.acquire(async () => {
1952
- const acquired = await transport({
1953
- url: currentUrl,
1954
- method,
1955
- headers,
1956
- signal,
1957
- responseBodyMode: args.download && method === "HEAD" || args.head || args.download?.spider ? "omit" : args.fail ? "omit-on-http-error" : "read",
1958
- ...args.httpVersion === void 0 ? {} : { httpVersion: args.httpVersion },
1959
- ...args.ignoreContentLength ? { ignoreContentLength: true } : {},
1960
- registerCleanup: operation.registerCleanup,
1961
- ...policy,
1962
- ...upload ? { body: upload } : {},
1963
- ...ca === void 0 ? {} : { ca },
1964
- ...args.connectTimeoutMs === void 0 ? {} : { connectTimeoutMs: args.connectTimeoutMs }
1965
- });
1966
- let cleanup;
1967
- return { ...acquired, dispose() {
1968
- cleanup ??= Promise.resolve().then(() => acquired.dispose());
1969
- return cleanup;
1970
- } };
1971
- }, (result) => result.dispose());
1972
- } catch (error) {
1973
- signal.throwIfAborted();
1974
- const code = error && typeof error === "object" && "code" in error ? error.code : void 0;
1975
- if (args.retryTransport && (code === "ECONNRESET" || code === "ETIMEDOUT" || code === "EPIPE") && attempt < args.retries) {
1976
- await delay(args.retryDelayMs || Math.min(1e3 * 2 ** attempt, 6e5), signal);
1977
- continue attempts;
1978
- }
1979
- throw error;
1980
- }
1981
- const block = responseHeaders(response, limits.maxHeaderBytes);
1982
- headerBytes += block.length;
1983
- if (headerBytes > limits.maxHeaderBytes) throw new CurlError(63, "Combined response headers exceed host byte limit");
1984
- values2.http_code = values2.response_code = String(response.status).padStart(3, "0");
1985
- values2.content_type = header(response.headers, "content-type") ?? "";
1986
- values2.http_version = response.httpVersion ?? "1.1";
1987
- if (args.verbose) await writeBytes(context.stderr, encode(`< HTTP ${response.status}
1988
- `), signal);
1989
- if (args.dumpHeader !== void 0) {
1990
- if (args.dumpHeader === "-") await publish(block);
1991
- else {
1992
- await dumpHeaders(context, args.dumpHeader, block, dumped || headerState.dumped, signal);
1993
- headerState.dumped = true;
1994
- }
1995
- dumped = true;
1996
- }
1997
- if (args.etagSave !== void 0) {
1998
- const tag = header(response.headers, "etag");
1999
- const bytes = tag === void 0 ? new Uint8Array() : new Uint8Array(encodeBytes(`${tag}
2000
- `, "latin1"));
2001
- if (args.etagSave === "-") await publish(bytes);
2002
- else await writeOutput(context, args.etagSave, toByteSource(bytes), signal);
2003
- }
2004
- if (args.head || args.include) included.push(block);
2005
- const location = header(response.headers, "location");
2006
- if (redirectStatuses.has(response.status) && location !== void 0) {
2007
- let target;
2008
- let targetUrl;
2009
- try {
2010
- const base = currentUrl.split("?")[0];
2011
- const colon = location.indexOf(":");
2012
- const boundary = [...location].findIndex((character) => "/?#".includes(character));
2013
- const resolved = colon >= 0 && (boundary < 0 || colon < boundary) ? location : location.startsWith("//") ? current.protocol + location : location.startsWith("/") ? current.origin + location : location.startsWith("?") ? base + location : location.startsWith("#") || location === "" ? currentUrl + location : base.slice(0, base.lastIndexOf("/") + 1) + location;
2014
- target = parseUrl(resolved, true).url;
2015
- targetUrl = target.origin + curlRequestTarget(resolved);
2016
- } catch (error) {
2017
- if (error instanceof CurlError) throw error;
2018
- throw new CurlError(3, "Malformed redirect URL");
2019
- }
2020
- values2.redirect_url = targetUrl;
2021
- if (args.location) {
2022
- if (redirects++ >= args.maxRedirects) throw new CurlError(47, "Maximum redirects exceeded");
2023
- if (current.protocol === "https:" && target.protocol === "http:") throw new CurlError(1, "HTTPS-to-HTTP redirects are disabled");
2024
- if (target.origin !== current.origin) credentialsInScope = false;
2025
- if (response.status === 303 && method !== "HEAD" || [301, 302].includes(response.status) && requestMethod === "POST") {
2026
- currentBody = void 0;
2027
- requestMethod = "GET";
2028
- if (args.method === void 0) method = "GET";
2029
- }
2030
- previous = currentUrl;
2031
- current = target;
2032
- currentUrl = targetUrl;
2033
- values2.num_redirects = String(redirects);
2034
- await stop(response, signal);
2035
- response = void 0;
2036
- continue;
2037
- }
2038
- }
2039
- break;
2040
- }
2041
- if (!response) throw new CurlError(56, "No HTTP response");
2042
- if (args.download?.contentDisposition && args.remoteName) {
2043
- const disposition = header(response.headers, "content-disposition");
2044
- const parameter = disposition?.split(";").map((part) => part.trim()).find((part) => part.slice(0, part.indexOf("=")).toLowerCase() === "filename");
2045
- if (parameter) {
2046
- let filename = parameter.slice(parameter.indexOf("=") + 1).trim();
2047
- if (filename.startsWith('"') && filename.endsWith('"')) filename = filename.slice(1, -1);
2048
- filename = posixPath.basename(filename.split("\\").join("/"));
2049
- if (filename && filename !== "." && filename !== ".." && !filename.includes("\0")) output = args.outputDirectory === void 0 ? filename : `${args.outputDirectory}/${filename}`;
2050
- }
2051
- }
2052
- if (args.download?.noClobber && output && output !== "-" && await existingSize(context, output, signal) !== void 0) return 0;
2053
- let append = false;
2054
- if (resumeOffset && response.status === 206) {
2055
- const range2 = header(response.headers, "content-range") ?? "";
2056
- if (!range2.startsWith(`bytes ${resumeOffset}-`)) throw new CurlError(args.continueAt === void 0 ? 56 : 33, "Invalid resume Content-Range");
2057
- append = true;
2058
- }
2059
- if (resumeOffset && response.status === 416) {
2060
- if (header(response.headers, "content-range") === `bytes */${resumeOffset}`) return 0;
2061
- }
2062
- if (resumeOffset && args.continueAt !== void 0 && !append) throw new CurlError(33, "Server does not support resuming this transfer");
2063
- if (response.status >= 400 && (args.fail || args.failWithBody)) failure = new CurlError(22, `HTTP response status ${response.status}`);
2064
- const suppressBody = response.status === 304 || args.fail && failure !== void 0;
2065
- const readBody = !(args.download && method === "HEAD") && !args.head && !suppressBody;
2066
- let published = 0;
2067
- if (!args.download?.spider && (!suppressBody || included.length)) {
2068
- if (args.download && output && output !== "-") await context.fs.mkdir(posixPath.dirname(pathOf(context, output)), { recursive: true, signal });
2069
- const length = args.ignoreContentLength ? void 0 : header(response.headers, "content-length");
2070
- if (readBody && length && /^\d+$/.test(length) && Number(length) > args.maxFileSize) throw new CurlError(63, "Response exceeds download byte limit");
2071
- const final = response;
2072
- const encoding = header(final.headers, "content-encoding");
2073
- const writing = output === void 0 || output === "-" ? createOutputOperation({ ...context, signal }, context.stdout) : void 0;
2074
- const bodySignal = writing?.signal ?? signal;
2075
- const source = (async function* () {
2076
- for (const bytes of included) {
2077
- published += bytes.length;
2078
- yield bytes;
2079
- }
2080
- if (readBody) {
2081
- if (args.raw && final.contentDecoded && encoding) throw new CurlError(61, "Transport cannot preserve encoded response bytes");
2082
- if (args.raw && header(final.headers, "transfer-encoding")) throw new CurlError(61, "Raw transfer encoding is unsupported by this transport");
2083
- let chunks = 0;
2084
- const encoded = (async function* () {
2085
- for await (const chunk of readBytes(final.body, bodySignal)) {
2086
- downloaded += chunk.length;
2087
- if (downloaded > args.maxFileSize) throw new CurlError(63, "Response exceeds download byte limit");
2088
- yield chunk;
2089
- }
2090
- if (!final.contentDecoded && length && /^\d+$/.test(length) && downloaded !== Number(length)) throw new CurlError(18, "Partial HTTP response body");
2091
- })();
2092
- const decoded = args.compressed && !args.raw && !final.contentDecoded && encoding ? decodeContent(encoded, encoding, bodySignal, args.maxFileSize) : encoded;
2093
- let outputBytes = 0;
2094
- try {
2095
- for await (const chunk of decoded) {
2096
- if (++chunks % 256 === 0) {
2097
- await yieldTurn(context.signal);
2098
- bodySignal.throwIfAborted();
2099
- }
2100
- outputBytes += chunk.length;
2101
- if (outputBytes > args.maxFileSize) throw new CurlError(63, "Decoded response exceeds download byte limit");
2102
- published += chunk.length;
2103
- yield chunk;
2104
- }
2105
- } catch (error) {
2106
- bodySignal.throwIfAborted();
2107
- if (!(error instanceof CurlError) && !final.contentDecoded && length && /^\d+$/.test(length) && downloaded < Number(length)) throw new CurlError(18, "Partial HTTP response body");
2108
- throw networkError(error);
2109
- }
2110
- }
2111
- })();
2112
- try {
2113
- await writeOutput(writing ? { ...context, stdout: writing.output } : context, output, source, bodySignal, append, args.failWithBody && failure !== void 0);
2114
- } catch (error) {
2115
- context.signal.throwIfAborted();
2116
- if (!pipeClosed(error)) throw error;
2117
- closedOutput = true;
2118
- } finally {
2119
- await writing?.close();
2120
- }
2121
- }
2122
- if (retryStatuses.has(response.status) && attempt < args.retries) {
2123
- if (failure && (!args.silent || args.showError)) await deadlineDiagnostic(context, new CurlError(status(failure.exitCode), failure.message), remaining());
2124
- const after = header(response.headers, "retry-after");
2125
- let wait = args.retryDelayMs || Math.min(1e3 * 2 ** attempt, 6e5);
2126
- if (after !== void 0) {
2127
- const parsed2 = /^\d+$/.test(after) ? Number(after) * 1e3 : Date.parse(after) - Date.now();
2128
- if (Number.isFinite(parsed2)) wait = Math.max(wait, parsed2);
2129
- }
2130
- await stop(response, signal);
2131
- response = void 0;
2132
- if (published && output !== void 0 && output !== "-" && !args.download?.resume) await writeOutput(context, output, toByteSource(""), signal);
2133
- await delay(Math.min(wait, limits.maxTimeMs), signal);
2134
- continue;
2135
- }
2136
- break;
2137
- }
2138
- } catch (error) {
2139
- if (context.signal.aborted) throw context.signal.reason;
2140
- if (pipeClosed(error)) closedOutput = true;
2141
- else if (!hasFileOutput && context.stdout.ownedOutput?.consumerClosed.aborted) failure = new CurlError(23, "Failed writing output");
2142
- else failure = signal.aborted && signal.reason instanceof CurlError ? signal.reason : networkError(error);
2143
- } finally {
2144
- try {
2145
- await operation.close();
2146
- } finally {
2147
- context.signal.throwIfAborted();
2148
- }
2149
- }
2150
- values2.size_download = String(downloaded);
2151
- values2.size_upload = String(uploaded);
2152
- values2.time_total = ((performance.now() - start) / 1e3).toFixed(6);
2153
- values2.exitcode = String(failure?.exitCode ?? 0);
2154
- values2.errormsg = failure?.message ?? "";
2155
- if (format !== void 0 && formatReady) {
2156
- try {
2157
- await publish(writeOutFormat(format, values2, limits.maxBufferBytes));
2158
- } catch (error) {
2159
- context.signal.throwIfAborted();
2160
- failure = error instanceof CurlError ? error : new CurlError(23, "Failed writing write-out result");
2161
- }
2162
- }
2163
- if (failure && (!args.silent || args.showError)) {
2164
- try {
2165
- await deadlineDiagnostic(context, new CurlError(status(failure.exitCode), failure.message), remaining());
2166
- } catch (error) {
2167
- context.signal.throwIfAborted();
2168
- if (!(error instanceof CurlError)) throw error;
2169
- failure = error;
2170
- }
2171
- }
2172
- return failure ? status(failure.exitCode) : closedOutput ? 141 : 0;
2173
- }
2174
-
2175
- // packages/safe-bash/src/commands/network/wget.ts
2176
- async function parseWget(context, limits) {
2177
- const carrier = getCommandArguments(context);
2178
- let argumentBytes = 0;
2179
- for (const value of carrier.values) {
2180
- if (typeof value === "string" && value.length > limits.maxBufferBytes) throw new CurlError(2, "Arguments exceed host buffer limit");
2181
- argumentBytes += shellValueByteLength(value);
2182
- if (argumentBytes > limits.maxBufferBytes) throw new CurlError(2, "Arguments exceed host buffer limit");
2183
- if (typeof value === "string") {
2184
- for (let index = 0; index < value.length; index++) {
2185
- if (index % 1024 === 0) await yieldTurn(context.signal);
2186
- const code = value.charCodeAt(index);
2187
- if (code >= 55296 && code <= 56319) {
2188
- const next = value.charCodeAt(++index);
2189
- if (!(next >= 56320 && next <= 57343)) throw new CurlError(2, "Arguments must be valid UTF-8");
2190
- } else if (code >= 56320 && code <= 57343) throw new CurlError(2, "Arguments must be valid UTF-8");
2191
- }
2192
- continue;
2193
- }
2194
- const bytes = shellValueBytes(value);
2195
- const decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
2196
- for (let offset = 0; offset < bytes.length; offset += 1024) {
2197
- await yieldTurn(context.signal);
2198
- try {
2199
- decoder.decode(bytes.subarray(offset, offset + 1024), { stream: offset + 1024 < bytes.length });
2200
- } catch (error) {
2201
- context.signal.throwIfAborted();
2202
- if (!(error instanceof TypeError) || "code" in error && error.code !== "ERR_ENCODING_INVALID_ENCODED_DATA") throw error;
2203
- throw new CurlError(2, "Arguments must be valid UTF-8");
2204
- }
2205
- }
2206
- }
2207
- const result = {
2208
- urls: [],
2209
- data: [],
2210
- headers: [],
2211
- include: false,
2212
- head: false,
2213
- get: false,
2214
- location: true,
2215
- remoteName: true,
2216
- fail: true,
2217
- failWithBody: false,
2218
- silent: false,
2219
- showError: false,
2220
- verbose: false,
2221
- globoff: true,
2222
- help: false,
2223
- version: false,
2224
- retries: Math.min(19, limits.maxRetries),
2225
- retryDelayMs: 0,
2226
- maxTimeMs: limits.maxTimeMs,
2227
- maxRedirects: limits.maxRedirects,
2228
- maxFileSize: limits.maxDownloadBytes,
2229
- agent: "virtual-bash-wget/0.0",
2230
- retryTransport: true,
2231
- directoryIndex: "index.html",
2232
- download: { spider: false, resume: false, noClobber: false, contentDisposition: false }
2233
- };
2234
- const number2 = (value, integral) => {
2235
- let start = 0;
2236
- let end = value.length;
2237
- if (!integral) {
2238
- while (start < end && " \n\r\v\f".includes(value[start])) start++;
2239
- while (end > start && " \n\r\v\f".includes(value[end - 1])) end--;
2240
- }
2241
- let multiplier = 1;
2242
- if (!integral) {
2243
- const units = { s: 1, m: 60, h: 3600, d: 86400 };
2244
- const unit = units[value[end - 1]];
2245
- if (unit !== void 0) {
2246
- multiplier = unit;
2247
- end--;
2248
- }
2249
- }
2250
- let position = start;
2251
- if (!integral && (value[position] === "+" || value[position] === "-")) position++;
2252
- let digits = 0;
2253
- let dot = false;
2254
- for (; position < end; position++) {
2255
- const character = value[position];
2256
- if (character >= "0" && character <= "9") digits++;
2257
- else if (!integral && character === "." && !dot) dot = true;
2258
- else throw new CurlError(2, "Invalid numeric option");
2259
- }
2260
- if (!digits) throw new CurlError(2, "Invalid numeric option");
2261
- const parsed = Number(value.slice(start, end)) * multiplier;
2262
- if (!Number.isFinite(parsed) || parsed < 0 || parsed > Number.MAX_SAFE_INTEGER) throw new CurlError(2, "Invalid numeric option");
2263
- return parsed;
2264
- };
2265
- const bodies = {};
2266
- const headers = /* @__PURE__ */ new Map();
2267
- let agent;
2268
- let referer;
2269
- let ended = false;
2270
- let inputFile;
2271
- for (let index = 0; index < context.args.length; index++) {
2272
- if (index % 128 === 0) await yieldTurn(context.signal);
2273
- const argument = context.args[index];
2274
- if (ended || !argument.startsWith("-") || argument === "-") {
2275
- result.urls.push(argument);
2276
- continue;
2277
- }
2278
- if (argument === "--") {
2279
- ended = true;
2280
- continue;
2281
- }
2282
- if (!argument.startsWith("--")) {
2283
- for (let position = 1; position < argument.length; position++) {
2284
- if (position % 1024 === 0) await yieldTurn(context.signal);
2285
- const flag2 = argument[position];
2286
- if (flag2 === "q") result.silent = true;
2287
- else if (flag2 === "c") result.download.resume = true;
2288
- else if (flag2 === "n" && argument[position + 1] === "c") {
2289
- result.download.noClobber = true;
2290
- position++;
2291
- } else if (flag2 === "n" && argument[position + 1] === "v") position++;
2292
- else if (flag2 === "h") result.help = true;
2293
- else if (flag2 === "r") throw new CurlError(2, "Recursive mirroring is unsupported");
2294
- else if (["O", "P", "i", "T", "t"].includes(flag2)) {
2295
- const output = position + 1 < argument.length ? argument.slice(position + 1) : context.args[++index];
2296
- if (!output) throw new CurlError(2, `-${flag2} requires a nonempty argument`);
2297
- if (flag2 === "O") {
2298
- result.output = output;
2299
- result.remoteName = false;
2300
- } else if (flag2 === "P") result.outputDirectory = output;
2301
- else if (flag2 === "i") inputFile = output;
2302
- else if (flag2 === "T") {
2303
- const seconds = number2(output, false);
2304
- result.maxTimeMs = Math.min(seconds === 0 ? Infinity : seconds * 1e3, limits.maxTimeMs);
2305
- } else {
2306
- const tries = number2(output, true);
2307
- result.retries = tries === 0 ? limits.maxRetries : Math.min(tries - 1, limits.maxRetries);
2308
- }
2309
- break;
2310
- } else throw new CurlError(2, `Unsupported option: -${flag2}`);
2311
- }
2312
- continue;
2313
- }
2314
- if (argument === "--quiet") {
2315
- result.silent = true;
2316
- continue;
2317
- }
2318
- if (argument === "--no-verbose") continue;
2319
- if (argument === "--help") {
2320
- result.help = true;
2321
- continue;
2322
- }
2323
- if (argument === "--version") {
2324
- result.version = true;
2325
- continue;
2326
- }
2327
- if (argument === "--spider") {
2328
- result.download.spider = true;
2329
- continue;
2330
- }
2331
- if (argument === "--continue") {
2332
- result.download.resume = true;
2333
- continue;
2334
- }
2335
- if (argument === "--no-clobber") {
2336
- result.download.noClobber = true;
2337
- continue;
2338
- }
2339
- if (argument === "--content-disposition") {
2340
- result.download.contentDisposition = true;
2341
- continue;
2342
- }
2343
- if (argument === "--recursive") throw new CurlError(2, "Recursive mirroring is unsupported");
2344
- const equal = argument.indexOf("=");
2345
- const flag = equal < 0 ? argument : argument.slice(0, equal);
2346
- let operand;
2347
- if (["--directory-prefix", "--input-file", "--output-document", "--timeout", "--tries", "--method", "--post-data", "--post-file", "--body-data", "--body-file", "--header", "--user-agent", "--referer"].includes(flag)) {
2348
- operand = equal < 0 ? context.args[++index] : argument.slice(equal + 1);
2349
- } else throw new CurlError(2, `Unsupported option: ${argument}`);
2350
- if (operand === void 0) throw new CurlError(2, `${flag} requires an argument`);
2351
- if (flag === "--output-document") {
2352
- if (!operand) throw new CurlError(2, "Output filename must not be empty");
2353
- result.output = operand;
2354
- result.remoteName = false;
2355
- } else if (flag === "--directory-prefix") result.outputDirectory = operand;
2356
- else if (flag === "--input-file") inputFile = operand;
2357
- else if (flag === "--timeout") {
2358
- const seconds = number2(operand, false);
2359
- result.maxTimeMs = Math.min(seconds === 0 ? Infinity : seconds * 1e3, limits.maxTimeMs);
2360
- } else if (flag === "--tries") {
2361
- const tries = number2(operand, true);
2362
- result.retries = tries === 0 ? limits.maxRetries : Math.min(tries - 1, limits.maxRetries);
2363
- } else if (flag === "--header") {
2364
- if (operand === "") {
2365
- headers.clear();
2366
- continue;
2367
- }
2368
- const colon = operand.indexOf(":");
2369
- if (colon < 1) throw new CurlError(2, "Invalid HTTP header");
2370
- const name = operand.slice(0, colon);
2371
- const value = operand.slice(colon + 1).trim();
2372
- validateRequestHeader(name, value);
2373
- headers.set(name.toLowerCase(), [name, value]);
2374
- } else if (flag === "--user-agent") {
2375
- validateRequestHeader("User-Agent", operand);
2376
- agent = operand;
2377
- } else if (flag === "--referer") {
2378
- validateRequestHeader("Referer", operand);
2379
- referer = operand;
2380
- } else if (flag === "--method") {
2381
- try {
2382
- validateHeaderName(operand);
2383
- } catch {
2384
- throw new CurlError(2, "Invalid or unsupported HTTP method");
2385
- }
2386
- result.method = operand.toUpperCase();
2387
- if (["CONNECT", "TRACE"].includes(result.method)) throw new CurlError(2, "Invalid or unsupported HTTP method");
2388
- } else {
2389
- const bodyFlag = flag;
2390
- if (bodyFlag.endsWith("-file") && !operand) throw new CurlError(2, "Upload filename must not be empty");
2391
- bodies[bodyFlag] = operand;
2392
- }
2393
- }
2394
- if (agent !== void 0 && !headers.has("user-agent")) result.headers.push(["User-Agent", agent === "" ? null : agent]);
2395
- if (referer !== void 0 && !headers.has("referer")) result.headers.push(["Referer", referer]);
2396
- result.headers.push(...headers.values());
2397
- const post = bodies["--post-data"] !== void 0 || bodies["--post-file"] !== void 0;
2398
- const customBody = bodies["--body-data"] !== void 0 || bodies["--body-file"] !== void 0;
2399
- if (post && result.method !== void 0 || customBody && result.method === void 0 || bodies["--post-data"] !== void 0 && bodies["--post-file"] !== void 0 || bodies["--body-data"] !== void 0 && bodies["--body-file"] !== void 0) {
2400
- throw new CurlError(2, "Incompatible request body options: use --post-data or --post-file, or --method with --body-data or --body-file");
2401
- }
2402
- const data = bodies["--post-data"] ?? bodies["--body-data"];
2403
- const file = bodies["--post-file"] ?? bodies["--body-file"];
2404
- if (data !== void 0) result.data.push({ kind: "raw", value: data });
2405
- else if (file !== void 0) result.data.push({ kind: "binary", value: `@${file === "-" ? "./-" : file}` });
2406
- if (!result.help && !result.version) {
2407
- if (inputFile !== void 0) {
2408
- let bytes;
2409
- try {
2410
- bytes = inputFile === "-" ? await collectNetworkBytes(context.stdin, { signal: context.signal, maxBytes: limits.maxBufferBytes }) : await context.fs.readFile(pathOf(context, inputFile), { signal: context.signal, ...Number.isFinite(limits.maxBufferBytes) ? { maxBytes: limits.maxBufferBytes } : {} });
2411
- } catch {
2412
- context.signal.throwIfAborted();
2413
- throw new CurlError(26, "Failed reading virtual URL input file");
2414
- }
2415
- let text;
2416
- try {
2417
- text = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
2418
- } catch {
2419
- throw new CurlError(2, "URL input must be valid UTF-8");
2420
- }
2421
- let start = 0;
2422
- let lines = 0;
2423
- for (let index = 0; index <= text.length; index++) {
2424
- if (index % 1024 === 0) await yieldTurn(context.signal);
2425
- if (index !== text.length && text[index] !== "\n") continue;
2426
- if (index === text.length && start === index) break;
2427
- if (++lines > 4096) throw new CurlError(2, "URL input exceeds 4096-line limit");
2428
- const url = text.slice(start, index).trim();
2429
- start = index + 1;
2430
- if (url) result.urls.push(url);
2431
- if (result.urls.length > limits.maxUrls) throw new CurlError(2, "URL count exceeds host limit");
2432
- }
2433
- }
2434
- if (!result.urls.length) throw new CurlError(2, "An HTTP(S) URL is required");
2435
- if (result.urls.length > limits.maxUrls) throw new CurlError(2, "URL count exceeds host limit");
2436
- if (result.download.resume && result.download.noClobber) throw new CurlError(2, "Continue and no-clobber are incompatible");
2437
- if (result.output === "-" && (result.download.resume || result.download.noClobber)) throw new CurlError(2, "Download controls require a file output");
2438
- }
2439
- return result;
2440
- }
2441
- function createWgetCommand(options) {
2442
- return createTransferCommand(options, {
2443
- name: "wget",
2444
- parse: parseWget,
2445
- help: "Usage: wget [-O FILE|-] [-q|-nv] [-T SECONDS] [-t COUNT] [URL ...]\nDownloads: --spider | -c/--continue | -nc/--no-clobber | -P/--directory-prefix DIR | --content-disposition\nInput: -i/--input-file FILE (VFS URL list; '-' reads stdin)\nRequest headers: --header 'NAME: VALUE' | --user-agent AGENT | --referer URL\nRequest bodies: --post-data DATA | --post-file FILE | --method METHOD [--body-data DATA | --body-file FILE]\nBody files are read from the VFS. Downloads require explicit host authorization. Recursive mirroring is unsupported.\nTimeout (--timeout) is aggregate and host-capped; --tries=0 remains host-capped.\n",
2446
- version: "virtual-bash wget 0.0 (bounded HTTP HTTPS)\n",
2447
- status: (code) => code === 0 ? 0 : [1, 2, 3].includes(code) ? 2 : [23, 26].includes(code) ? 3 : code === 60 ? 5 : code === 22 ? 8 : 4
2448
- });
2449
- }
2450
-
2451
- // packages/safe-bash/src/commands/network/fetch-transport.ts
2452
- init_platform();
2453
- function requestBody(source, signal) {
2454
- if (!source) return void 0;
2455
- const iterator = source[Symbol.asyncIterator]();
2456
- return new ReadableStream({
2457
- async pull(controller) {
2458
- try {
2459
- signal.throwIfAborted();
2460
- const next = await iterator.next();
2461
- if (next.done) controller.close();
2462
- else controller.enqueue(next.value);
2463
- } catch (error) {
2464
- controller.error(error);
2465
- }
2466
- },
2467
- async cancel(reason) {
2468
- await iterator.return?.(reason);
2469
- }
2470
- });
2471
- }
2472
- function createFetchTransport(options = {}) {
2473
- const fetchRequest = options.fetch ?? globalThis.fetch;
2474
- if (typeof fetchRequest !== "function") throw new TypeError("Fetch is unavailable");
2475
- return async (input) => {
2476
- input.signal.throwIfAborted();
2477
- if (input.ca !== void 0) throw new CurlError(2, "Fetch transport cannot enforce request CA trust");
2478
- if (input.httpVersion !== void 0) throw new CurlError(2, "Transport cannot enforce requested HTTP version");
2479
- if (input.ignoreContentLength) throw new CurlError(2, "Transport cannot enforce ignored Content-Length");
2480
- const url = new URL(input.url);
2481
- if (url.protocol !== "http:" && url.protocol !== "https:") throw new CurlError(1, "Unsupported protocol");
2482
- if (input.denyPrivateNetworks === true) throw new CurlError(7, "Fetch transport cannot enforce private-network denial");
2483
- if (curlRequestTarget(input.url) !== url.pathname + url.search) {
2484
- throw new CurlError(2, "Fetch transport cannot preserve the literal request target");
2485
- }
2486
- const stopped = new AbortController();
2487
- const signal = AbortSignal.any([input.signal, stopped.signal]);
2488
- const body = requestBody(input.body, signal);
2489
- const headers = new Headers();
2490
- for (const [name, value] of input.headers) headers.append(name, value);
2491
- const request = new Request(url, {
2492
- method: input.method,
2493
- headers,
2494
- body,
2495
- credentials: "omit",
2496
- redirect: "manual",
2497
- signal,
2498
- ...body ? { duplex: "half" } : {}
2499
- });
2500
- let response;
2501
- const dispose = async () => {
2502
- stopped.abort();
2503
- if (response?.body) await response.body.cancel().catch(() => void 0);
2504
- };
2505
- input.registerCleanup?.(dispose);
2506
- response = await fetchRequest(request);
2507
- const reader = response.body?.getReader();
2508
- const responseBody = reader ? (async function* () {
2509
- try {
2510
- while (true) {
2511
- input.signal.throwIfAborted();
2512
- const next = await reader.read();
2513
- if (next.done) return;
2514
- yield next.value;
2515
- }
2516
- } finally {
2517
- reader.releaseLock();
2518
- }
2519
- })() : (async function* () {
2520
- })();
2521
- return {
2522
- status: response.status,
2523
- statusText: response.statusText,
2524
- headers: [...response.headers.entries()],
2525
- body: responseBody,
2526
- contentDecoded: options.contentDecoded ?? true,
2527
- dispose
2528
- };
2529
- };
2530
- }
2531
-
2532
- // packages/safe-bash/src/commands/network/authorizer.ts
2533
- init_platform();
2534
-
2535
- // packages/safe-bash/src/commands/network/private-address.ts
2536
- init_platform();
2537
- function privateIPv4(first, second) {
2538
- return first === 10 || first === 127 || first === 0 || first === 169 && second === 254 || first === 192 && second === 168 || first === 172 && second >= 16 && second <= 31 || first === 100 && second >= 64 && second <= 127 || first === 198 && second >= 18 && second <= 19 || first >= 224;
2539
- }
2540
- function privateHostname(input) {
2541
- const hostname = input.toLowerCase().replace(/\.$/u, "").replace(/^\[|\]$/gu, "");
2542
- if (hostname === "localhost" || hostname.endsWith(".localhost") || hostname === "::1") return true;
2543
- if (hostname.includes(":")) {
2544
- const [prefix, suffix] = hostname.split("::");
2545
- const leading = prefix ? prefix.split(":") : [];
2546
- const trailing = suffix ? suffix.split(":") : [];
2547
- const hextets = new Array(8).fill(0);
2548
- for (let index = 0; index < leading.length; index++) hextets[index] = Number.parseInt(leading[index], 16);
2549
- for (let index = 0; index < trailing.length; index++) hextets[8 - trailing.length + index] = Number.parseInt(trailing[index], 16);
2550
- if (hextets.every((value) => value === 0)) return true;
2551
- const mappedIPv4 = hextets.slice(0, 5).every((value) => value === 0) && hextets[5] === 65535;
2552
- const translatedIPv4 = hextets.slice(0, 4).every((value) => value === 0) && hextets[4] === 65535 && hextets[5] === 0;
2553
- const nat64IPv4 = hextets[0] === 100 && hextets[1] === 65435 && hextets.slice(2, 6).every((value) => value === 0);
2554
- const compatibleIPv4 = hextets.slice(0, 6).every((value) => value === 0);
2555
- if (mappedIPv4 || translatedIPv4 || nat64IPv4 || compatibleIPv4) {
2556
- return privateIPv4(hextets[6] >>> 8, hextets[6] & 255);
2557
- }
2558
- if (hextets[0] === 8194) return privateIPv4(hextets[1] >>> 8, hextets[1] & 255);
2559
- return (hextets[0] & 65024) === 64512 || (hextets[0] & 65472) === 65152 || (hextets[0] & 65472) === 65216 || (hextets[0] & 65280) === 65280 || hextets[0] === 100 && hextets[1] === 65435 && hextets[2] === 1;
2560
- }
2561
- const parts = hostname.split(".");
2562
- if (parts.length !== 4 || parts.some((part) => !part || Array.from(part).some((character) => character < "0" || character > "9"))) return false;
2563
- const octets = parts.map(Number);
2564
- if (octets.some((value) => value < 0 || value > 255)) return false;
2565
- const [first, second] = octets;
2566
- return privateIPv4(first, second);
2567
- }
2568
-
2569
- // packages/safe-bash/src/commands/network/authorizer.ts
2570
- function createOriginAuthorizer(allowlist = "*", options = {}) {
2571
- const denyPrivateNetworks = options.denyPrivateNetworks === true;
2572
- const origins = /* @__PURE__ */ new Set();
2573
- const hosts = /* @__PURE__ */ new Set();
2574
- for (const entry of allowlist === "*" ? [] : allowlist) {
2575
- const value = entry.trim();
2576
- if (!value) throw new TypeError("Origin allowlist entries must not be empty");
2577
- if (value.includes("://")) {
2578
- const url = new URL(value);
2579
- if (url.pathname !== "/" || url.search || url.hash || url.username || url.password) {
2580
- throw new TypeError(`Origin allowlist entry must be an origin: ${entry}`);
2581
- }
2582
- origins.add(url.origin);
2583
- } else {
2584
- if (value.includes("/") || value.includes("@")) throw new TypeError(`Invalid hostname allowlist entry: ${entry}`);
2585
- hosts.add(value.toLowerCase().replace(/\.$/u, ""));
2586
- }
2587
- }
2588
- return (request) => {
2589
- const url = new URL(request.url);
2590
- const hostname = url.hostname.toLowerCase().replace(/\.$/u, "");
2591
- if (denyPrivateNetworks) {
2592
- request.requirePrivateNetworkDeny?.();
2593
- if (privateHostname(hostname)) return false;
2594
- }
2595
- return allowlist === "*" || origins.has(url.origin) || hosts.has(hostname);
2596
- };
2597
- }
2598
-
2599
- // packages/safe-bash/src/commands/network/public.ts
2600
- function createNetworkCommands(options) {
2601
- return [createCurlCommand(options), createWgetCommand(options)];
2602
- }
2603
- function networkCommands(options) {
2604
- const definitions = createNetworkCommands(options);
2605
- return {
2606
- name: "network-commands",
2607
- setup(host) {
2608
- if (!options.replace) {
2609
- for (const definition of definitions) if (host.commands.has(definition.name)) throw new Error(`Command already registered: ${definition.name}`);
2610
- }
2611
- for (const definition of definitions) host.commands.register(definition, { replace: options.replace ?? false });
2612
- }
2613
- };
2614
- }
2615
- var createCurlCommands = createNetworkCommands;
2616
- var curlCommands = networkCommands;
2617
- var CURL_HELP = "Usage: curl [HTTP(S) URL] [-X METHOD] [-H HEADER] [-d DATA] [-L] [-o VFSFILE]\nExplicit host authorization is required. See network/README.md for supported flags and limits.\n";
2618
- var CURL_VERSION = "virtual-bash curl 0.0 (HTTP HTTPS; Node streaming transport)\n";
2619
- var WGET_HELP = "Usage: wget [-O FILE|-] [-q|-nv] [-T SECONDS] [-t COUNT] [URL ...]\nDownloads: --spider | -c/--continue | -nc/--no-clobber | -P/--directory-prefix DIR | --content-disposition\nInput: -i/--input-file FILE (VFS URL list; '-' reads stdin)\nRequest headers: --header 'NAME: VALUE' | --user-agent AGENT | --referer URL\nRequest bodies: --post-data DATA | --post-file FILE | --method METHOD [--body-data DATA | --body-file FILE]\nBody files are read from the VFS. Downloads require explicit host authorization. Recursive mirroring is unsupported.\nTimeout (--timeout) is aggregate and host-capped; --tries=0 remains host-capped.\n";
2620
- var WGET_VERSION = "virtual-bash wget 0.0 (bounded HTTP HTTPS)\n";
2621
- function evalSyncCurl(opArgs) {
2622
- if (opArgs.length === 1) {
2623
- if (opArgs[0] === "-V" || opArgs[0] === "--version") return CURL_VERSION;
2624
- if (opArgs[0] === "-h" || opArgs[0] === "--help") return CURL_HELP;
2625
- }
2626
- return void 0;
2627
- }
2628
- function evalSyncWget(opArgs) {
2629
- if (opArgs.length === 1) {
2630
- if (opArgs[0] === "-V" || opArgs[0] === "--version") return WGET_VERSION;
2631
- if (opArgs[0] === "-h" || opArgs[0] === "--help") return WGET_HELP;
2632
- }
2633
- return void 0;
2634
- }
2635
- syncCommandEvaluators.evalSyncCurl = evalSyncCurl;
2636
- syncCommandEvaluators.evalSyncWget = evalSyncWget;
2637
-
2638
- export {
2639
- defaultNetworkLimits,
2640
- cloudflareWorkerNetworkLimits,
2641
- CurlError,
2642
- createCurlCommand,
2643
- createWgetCommand,
2644
- createFetchTransport,
2645
- createOriginAuthorizer,
2646
- createNetworkCommands,
2647
- networkCommands,
2648
- createCurlCommands,
2649
- curlCommands,
2650
- evalSyncCurl,
2651
- evalSyncWget
2652
- };