@poe-platform/safe-bash 0.1.630 → 0.1.632

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 (357) hide show
  1. package/README.md +1 -0
  2. package/dist/office-package/compression.d.ts +19 -0
  3. package/dist/office-package/compression.js +186 -0
  4. package/dist/office-package/runtime.d.ts +11 -0
  5. package/dist/office-package/runtime.js +28 -0
  6. package/dist/safe-bash/chunks/{bz2-B2RXT4EX.js → bz2-ACU4EOVE.js} +2 -2
  7. package/dist/safe-bash/chunks/chunk-2E4KBFO6.js +239 -0
  8. package/dist/safe-bash/chunks/chunk-2E4KBFO6.js.map +7 -0
  9. package/dist/safe-bash/chunks/chunk-3E5M2WEL.js +33 -0
  10. package/dist/safe-bash/chunks/chunk-3E5M2WEL.js.map +7 -0
  11. package/dist/safe-bash/chunks/{chunk-KQ6J7JHQ.js → chunk-3LD67SER.js} +12 -10
  12. package/dist/safe-bash/chunks/{chunk-KQ6J7JHQ.js.map → chunk-3LD67SER.js.map} +1 -1
  13. package/dist/safe-bash/chunks/{chunk-6LSSEOG7.js → chunk-6HNK7Q66.js} +11 -7
  14. package/dist/safe-bash/chunks/{chunk-6LSSEOG7.js.map → chunk-6HNK7Q66.js.map} +1 -1
  15. package/dist/safe-bash/chunks/{chunk-AD7UAP5B.js → chunk-7EEWZY5S.js} +10 -8
  16. package/dist/safe-bash/chunks/{chunk-AD7UAP5B.js.map → chunk-7EEWZY5S.js.map} +1 -1
  17. package/dist/safe-bash/chunks/{chunk-RNKTWFEM.js → chunk-CDBQXRWL.js} +3 -3
  18. package/dist/safe-bash/chunks/{chunk-UYX72YHY.js → chunk-CHHAB5SS.js} +10 -74
  19. package/dist/safe-bash/chunks/{chunk-UYX72YHY.js.map → chunk-CHHAB5SS.js.map} +3 -3
  20. package/dist/safe-bash/chunks/{chunk-6YSBXTTJ.js → chunk-EI4X5ETX.js} +12 -10
  21. package/dist/safe-bash/chunks/{chunk-6YSBXTTJ.js.map → chunk-EI4X5ETX.js.map} +1 -1
  22. package/dist/safe-bash/chunks/{chunk-KZ7QCYNT.js → chunk-GIBLUW2U.js} +13 -9
  23. package/dist/safe-bash/chunks/{chunk-KZ7QCYNT.js.map → chunk-GIBLUW2U.js.map} +1 -1
  24. package/dist/safe-bash/chunks/chunk-GPV7ZFYS.js +1528 -0
  25. package/dist/safe-bash/chunks/chunk-GPV7ZFYS.js.map +7 -0
  26. package/dist/safe-bash/chunks/{chunk-N5CYTGBN.js → chunk-H3E67KTZ.js} +13 -9
  27. package/dist/safe-bash/chunks/{chunk-N5CYTGBN.js.map → chunk-H3E67KTZ.js.map} +1 -1
  28. package/dist/safe-bash/chunks/{chunk-AFH57PPL.js → chunk-IEKESMO4.js} +3 -3
  29. package/dist/safe-bash/chunks/{chunk-DPJWEGIX.js → chunk-JLBIUYT3.js} +2 -2
  30. package/dist/safe-bash/chunks/chunk-JZDO5MC3.js +77 -0
  31. package/dist/safe-bash/chunks/chunk-JZDO5MC3.js.map +7 -0
  32. package/dist/safe-bash/chunks/{chunk-GFZKQIPL.js → chunk-LA6BX562.js} +8 -6
  33. package/dist/safe-bash/chunks/{chunk-GFZKQIPL.js.map → chunk-LA6BX562.js.map} +1 -1
  34. package/dist/safe-bash/chunks/{chunk-PVJJFCGA.js → chunk-M3GPCYSP.js} +2 -2
  35. package/dist/safe-bash/chunks/{chunk-FWDMJTQO.js → chunk-NDCZ3UBP.js} +13 -9
  36. package/dist/safe-bash/chunks/{chunk-FWDMJTQO.js.map → chunk-NDCZ3UBP.js.map} +1 -1
  37. package/dist/safe-bash/chunks/{chunk-2KL6W6NB.js → chunk-O2EVBRKF.js} +1 -2
  38. package/dist/safe-bash/chunks/chunk-OFT77XIB.js +389 -0
  39. package/dist/safe-bash/chunks/chunk-OFT77XIB.js.map +7 -0
  40. package/dist/safe-bash/chunks/{chunk-PCLOK32J.js → chunk-PC6BEIAF.js} +13 -9
  41. package/dist/safe-bash/chunks/{chunk-PCLOK32J.js.map → chunk-PC6BEIAF.js.map} +1 -1
  42. package/dist/safe-bash/chunks/{chunk-3M5F7LD5.js → chunk-QWKP7ZU7.js} +13 -9
  43. package/dist/safe-bash/chunks/{chunk-3M5F7LD5.js.map → chunk-QWKP7ZU7.js.map} +1 -1
  44. package/dist/safe-bash/chunks/chunk-THXJ6CLF.js +53 -0
  45. package/dist/safe-bash/chunks/chunk-THXJ6CLF.js.map +7 -0
  46. package/dist/safe-bash/chunks/{chunk-K7W6Q6FN.js → chunk-V73A742N.js} +58 -16
  47. package/dist/safe-bash/chunks/chunk-V73A742N.js.map +7 -0
  48. package/dist/safe-bash/chunks/{chunk-4BYUV5PA.js → chunk-VN3ZGME3.js} +12 -8
  49. package/dist/safe-bash/chunks/{chunk-4BYUV5PA.js.map → chunk-VN3ZGME3.js.map} +1 -1
  50. package/dist/safe-bash/chunks/{chunk-3BZ5NQ73.js → chunk-WECHUK3Y.js} +369 -36
  51. package/dist/safe-bash/chunks/chunk-WECHUK3Y.js.map +7 -0
  52. package/dist/safe-bash/chunks/{chunk-X55AMTNM.js → chunk-WIOEUR7D.js} +14 -10
  53. package/dist/safe-bash/chunks/{chunk-X55AMTNM.js.map → chunk-WIOEUR7D.js.map} +1 -1
  54. package/dist/safe-bash/chunks/chunk-WPIOO4NX.js +443 -0
  55. package/dist/safe-bash/chunks/chunk-WPIOO4NX.js.map +7 -0
  56. package/dist/safe-bash/chunks/{chunk-C7QNJ3D4.js → chunk-WYTI64IU.js} +2 -2
  57. package/dist/safe-bash/chunks/{xz-AVXFDXW4.js → xz-U4QDTPZL.js} +2 -2
  58. package/dist/safe-bash/chunks/{zstd-R6RPHJYO.js → zstd-OG5RPYXO.js} +2 -2
  59. package/dist/safe-bash/commands/archive/zip/crc.d.ts +2 -0
  60. package/dist/safe-bash/commands/archive/zip/crc.d.ts.map +1 -0
  61. package/dist/safe-bash/commands/archive/zip/crc.js +7 -0
  62. package/dist/safe-bash/commands/archive/zip/crc.js.map +1 -0
  63. package/dist/safe-bash/commands/archive/zip/crypto.d.ts +4 -0
  64. package/dist/safe-bash/commands/archive/zip/crypto.d.ts.map +1 -0
  65. package/dist/safe-bash/commands/archive/zip/crypto.js +34 -0
  66. package/dist/safe-bash/commands/archive/zip/crypto.js.map +1 -0
  67. package/dist/safe-bash/commands/archive/zip/help.d.ts +3 -0
  68. package/dist/safe-bash/commands/archive/zip/help.d.ts.map +1 -0
  69. package/dist/safe-bash/commands/archive/zip/help.js +87 -0
  70. package/dist/safe-bash/commands/archive/zip/help.js.map +1 -0
  71. package/dist/safe-bash/commands/archive/zip/move.d.ts +12 -0
  72. package/dist/safe-bash/commands/archive/zip/move.d.ts.map +1 -0
  73. package/dist/safe-bash/commands/archive/zip/move.js +60 -0
  74. package/dist/safe-bash/commands/archive/zip/move.js.map +1 -0
  75. package/dist/safe-bash/commands/archive/zip/options.js +5 -5
  76. package/dist/safe-bash/commands/archive/zip/options.js.map +1 -1
  77. package/dist/safe-bash/commands/archive/zip-format.d.ts +1 -1
  78. package/dist/safe-bash/commands/archive/zip-format.d.ts.map +1 -1
  79. package/dist/safe-bash/commands/archive/zip-format.js +14 -17
  80. package/dist/safe-bash/commands/archive/zip-format.js.map +1 -1
  81. package/dist/safe-bash/commands/archive/zip.d.ts.map +1 -1
  82. package/dist/safe-bash/commands/archive/zip.js +45 -15
  83. package/dist/safe-bash/commands/archive/zip.js.map +1 -1
  84. package/dist/safe-bash/commands/bytes/compression/bounded-codec.d.ts +2 -0
  85. package/dist/safe-bash/commands/bytes/compression/bounded-codec.d.ts.map +1 -1
  86. package/dist/safe-bash/commands/bytes/compression/bounded-codec.js +4 -0
  87. package/dist/safe-bash/commands/bytes/compression/bounded-codec.js.map +1 -1
  88. package/dist/safe-bash/commands/bytes/compression/codec.d.ts +4 -24
  89. package/dist/safe-bash/commands/bytes/compression/codec.d.ts.map +1 -1
  90. package/dist/safe-bash/commands/bytes/compression/codec.js +12 -168
  91. package/dist/safe-bash/commands/bytes/compression/codec.js.map +1 -1
  92. package/dist/safe-bash/commands/cmp.js +1 -1
  93. package/dist/safe-bash/commands/cmp.js.map +1 -1
  94. package/dist/safe-bash/commands/csplit/index.browser.js +10 -7
  95. package/dist/safe-bash/commands/docx/index.browser.js +54 -0
  96. package/dist/safe-bash/commands/docx/index.browser.js.map +7 -0
  97. package/dist/safe-bash/commands/docx/index.d.ts +25 -0
  98. package/dist/safe-bash/commands/docx/index.d.ts.map +1 -0
  99. package/dist/safe-bash/commands/docx/index.js +42 -0
  100. package/dist/safe-bash/commands/docx/index.js.map +1 -0
  101. package/dist/safe-bash/commands/docx/io.d.ts +15 -0
  102. package/dist/safe-bash/commands/docx/io.d.ts.map +1 -0
  103. package/dist/safe-bash/commands/docx/io.js +16 -0
  104. package/dist/safe-bash/commands/docx/io.js.map +1 -0
  105. package/dist/safe-bash/commands/factor/index.browser.js +7 -5
  106. package/dist/safe-bash/commands/filesystem.d.ts.map +1 -1
  107. package/dist/safe-bash/commands/filesystem.js +9 -1
  108. package/dist/safe-bash/commands/filesystem.js.map +1 -1
  109. package/dist/safe-bash/commands/getopt/index.browser.js +7 -5
  110. package/dist/safe-bash/commands/hexdump/index.browser.js +8 -6
  111. package/dist/safe-bash/commands/iconv/index.browser.js +8 -6
  112. package/dist/safe-bash/commands/line-endings/index.browser.js +10 -7
  113. package/dist/safe-bash/commands/llm/index.browser.js +10 -8
  114. package/dist/safe-bash/commands/llm/providers/index.browser.js +3 -3
  115. package/dist/safe-bash/commands/network/index.browser.js +11 -8
  116. package/dist/safe-bash/commands/node/index.browser.js +8 -6
  117. package/dist/safe-bash/commands/op/index.browser.js +3 -3
  118. package/dist/safe-bash/commands/op/index.js +0 -1
  119. package/dist/safe-bash/commands/op/index.js.map +2 -2
  120. package/dist/safe-bash/commands/pptx/index.d.ts +29 -0
  121. package/dist/safe-bash/commands/pptx/index.d.ts.map +1 -0
  122. package/dist/safe-bash/commands/pptx/index.js +153 -0
  123. package/dist/safe-bash/commands/pptx/index.js.map +1 -0
  124. package/dist/safe-bash/commands/pr/index.browser.js +8 -6
  125. package/dist/safe-bash/commands/predicates.js +1 -1
  126. package/dist/safe-bash/commands/python/execution.d.ts +3 -0
  127. package/dist/safe-bash/commands/python/execution.d.ts.map +1 -0
  128. package/dist/safe-bash/commands/python/execution.js +193 -0
  129. package/dist/safe-bash/commands/python/execution.js.map +1 -0
  130. package/dist/safe-bash/commands/python/index.browser.js +21 -0
  131. package/dist/safe-bash/commands/python/index.browser.js.map +7 -0
  132. package/dist/safe-bash/commands/python/index.d.ts +49 -0
  133. package/dist/safe-bash/commands/python/index.d.ts.map +1 -0
  134. package/dist/safe-bash/commands/python/index.js +317 -0
  135. package/dist/safe-bash/commands/python/index.js.map +1 -0
  136. package/dist/safe-bash/commands/python/installation.d.ts +9 -0
  137. package/dist/safe-bash/commands/python/installation.d.ts.map +1 -0
  138. package/dist/safe-bash/commands/python/installation.js +80 -0
  139. package/dist/safe-bash/commands/python/installation.js.map +1 -0
  140. package/dist/safe-bash/commands/python/invocation.d.ts +10 -0
  141. package/dist/safe-bash/commands/python/invocation.d.ts.map +1 -0
  142. package/dist/safe-bash/commands/python/invocation.js +81 -0
  143. package/dist/safe-bash/commands/python/invocation.js.map +1 -0
  144. package/dist/safe-bash/commands/python/node.d.ts +12 -0
  145. package/dist/safe-bash/commands/python/node.d.ts.map +1 -0
  146. package/dist/safe-bash/commands/python/node.js +33 -0
  147. package/dist/safe-bash/commands/python/node.js.map +1 -0
  148. package/dist/safe-bash/commands/python/provisioning-runtime.d.ts +5 -0
  149. package/dist/safe-bash/commands/python/provisioning-runtime.d.ts.map +1 -0
  150. package/dist/safe-bash/commands/python/provisioning-runtime.js +179 -0
  151. package/dist/safe-bash/commands/python/provisioning-runtime.js.map +1 -0
  152. package/dist/safe-bash/commands/python/provisioning.d.ts +49 -0
  153. package/dist/safe-bash/commands/python/provisioning.d.ts.map +1 -0
  154. package/dist/safe-bash/commands/python/provisioning.js +320 -0
  155. package/dist/safe-bash/commands/python/provisioning.js.map +1 -0
  156. package/dist/safe-bash/commands/python/reply.d.ts +3 -0
  157. package/dist/safe-bash/commands/python/reply.d.ts.map +1 -0
  158. package/dist/safe-bash/commands/python/reply.js +103 -0
  159. package/dist/safe-bash/commands/python/reply.js.map +1 -0
  160. package/dist/safe-bash/commands/python/worker.browser.js +736 -0
  161. package/dist/safe-bash/commands/python/worker.browser.js.map +7 -0
  162. package/dist/safe-bash/commands/python/worker.d.ts +47 -0
  163. package/dist/safe-bash/commands/python/worker.d.ts.map +1 -0
  164. package/dist/safe-bash/commands/python/worker.js +373 -0
  165. package/dist/safe-bash/commands/python/worker.js.map +1 -0
  166. package/dist/safe-bash/commands/tsort/index.browser.js +8 -6
  167. package/dist/safe-bash/commands/xml/index.browser.js +9 -7
  168. package/dist/safe-bash/commands/yq/index.browser.js +10 -8
  169. package/dist/safe-bash/commands/yq/index.d.ts.map +1 -1
  170. package/dist/safe-bash/commands/yq/index.js +32 -4
  171. package/dist/safe-bash/commands/yq/index.js.map +1 -1
  172. package/dist/safe-bash/commands/yq/parser.d.ts.map +1 -1
  173. package/dist/safe-bash/commands/yq/parser.js +21 -5
  174. package/dist/safe-bash/commands/yq/parser.js.map +1 -1
  175. package/dist/safe-bash/contracts/command.d.ts +2 -0
  176. package/dist/safe-bash/contracts/command.d.ts.map +1 -1
  177. package/dist/safe-bash/contracts/command.js +6 -2
  178. package/dist/safe-bash/contracts/command.js.map +1 -1
  179. package/dist/safe-bash/contracts/filesystem-descriptor.d.ts +13 -0
  180. package/dist/safe-bash/contracts/filesystem-descriptor.d.ts.map +1 -0
  181. package/dist/safe-bash/contracts/filesystem-descriptor.js +189 -0
  182. package/dist/safe-bash/contracts/filesystem-descriptor.js.map +1 -0
  183. package/dist/safe-bash/contracts/filesystem-output-budget.d.ts +15 -0
  184. package/dist/safe-bash/contracts/filesystem-output-budget.d.ts.map +1 -0
  185. package/dist/safe-bash/contracts/filesystem-output-budget.js +69 -0
  186. package/dist/safe-bash/contracts/filesystem-output-budget.js.map +1 -0
  187. package/dist/safe-bash/contracts/filesystem-output.d.ts +11 -5
  188. package/dist/safe-bash/contracts/filesystem-output.d.ts.map +1 -1
  189. package/dist/safe-bash/contracts/filesystem-output.js +229 -20
  190. package/dist/safe-bash/contracts/filesystem-output.js.map +1 -1
  191. package/dist/safe-bash/contracts/io.d.ts +29 -0
  192. package/dist/safe-bash/contracts/io.d.ts.map +1 -1
  193. package/dist/safe-bash/contracts/io.js +317 -37
  194. package/dist/safe-bash/contracts/io.js.map +1 -1
  195. package/dist/safe-bash/core.browser.js +5502 -2210
  196. package/dist/safe-bash/core.browser.js.map +4 -4
  197. package/dist/safe-bash/core.d.ts +1 -0
  198. package/dist/safe-bash/core.d.ts.map +1 -1
  199. package/dist/safe-bash/core.js +1 -0
  200. package/dist/safe-bash/core.js.map +1 -1
  201. package/dist/safe-bash/opt-in/commands/cmp/compare.js +95 -0
  202. package/dist/safe-bash/opt-in/commands/cmp/index.d.ts +6 -0
  203. package/dist/safe-bash/opt-in/commands/cmp/index.js +99 -0
  204. package/dist/safe-bash/opt-in/commands/cmp/io.js +218 -0
  205. package/dist/safe-bash/opt-in/commands/cmp/options.d.ts +24 -0
  206. package/dist/safe-bash/opt-in/commands/cmp/options.js +195 -0
  207. package/dist/safe-bash/opt-in/commands/dd/conversions.js +152 -0
  208. package/dist/safe-bash/opt-in/commands/dd/index.d.ts +18 -0
  209. package/dist/safe-bash/opt-in/commands/dd/index.js +561 -0
  210. package/dist/safe-bash/opt-in/commands/dd/io.d.ts +31 -0
  211. package/dist/safe-bash/opt-in/commands/dd/io.js +244 -0
  212. package/dist/safe-bash/opt-in/commands/dd/options.js +184 -0
  213. package/dist/safe-bash/opt-in/commands/dd/report.js +69 -0
  214. package/dist/safe-bash/opt-in/commands/install/arguments.js +224 -0
  215. package/dist/safe-bash/opt-in/commands/install/index.d.ts +6 -0
  216. package/dist/safe-bash/opt-in/commands/install/index.js +678 -0
  217. package/dist/safe-bash/opt-in/commands/install/mode.js +71 -0
  218. package/dist/safe-bash/opt-in/commands/install/options.d.ts +36 -0
  219. package/dist/safe-bash/opt-in/commands/install/options.js +27 -0
  220. package/dist/safe-bash/opt-in/commands/shuf/args.js +179 -0
  221. package/dist/safe-bash/opt-in/commands/shuf/index.d.ts +6 -0
  222. package/dist/safe-bash/opt-in/commands/shuf/index.js +20 -0
  223. package/dist/safe-bash/opt-in/commands/shuf/input.js +93 -0
  224. package/dist/safe-bash/opt-in/commands/shuf/options.d.ts +9 -0
  225. package/dist/safe-bash/opt-in/commands/shuf/options.js +8 -0
  226. package/dist/safe-bash/opt-in/commands/shuf/random.js +114 -0
  227. package/dist/safe-bash/opt-in/commands/shuf/shuf.d.ts +3 -0
  228. package/dist/safe-bash/opt-in/commands/shuf/shuf.js +230 -0
  229. package/dist/safe-bash/opt-in/commands/shuf/usage.js +24 -0
  230. package/dist/safe-bash/opt-in/commands/truncate/arguments.js +186 -0
  231. package/dist/safe-bash/opt-in/commands/truncate/index.d.ts +9 -0
  232. package/dist/safe-bash/opt-in/commands/truncate/index.js +244 -0
  233. package/dist/safe-bash/opt-in/commands/yes/index.d.ts +11 -0
  234. package/dist/safe-bash/opt-in/commands/yes/index.js +167 -0
  235. package/dist/safe-bash/opt-in/commands/yq/arguments.js +177 -0
  236. package/dist/safe-bash/opt-in/commands/yq/evaluate.js +564 -0
  237. package/dist/safe-bash/opt-in/commands/yq/expression.js +183 -0
  238. package/dist/safe-bash/opt-in/commands/yq/inplace.js +65 -0
  239. package/dist/safe-bash/opt-in/commands/yq/mike.d.ts +9 -0
  240. package/dist/safe-bash/opt-in/commands/yq/mike.js +192 -0
  241. package/dist/safe-bash/opt-in/commands/yq/native-encoder.js +165 -0
  242. package/dist/safe-bash/opt-in/commands/yq/native-work.d.ts +44 -0
  243. package/dist/safe-bash/opt-in/commands/yq/native-work.js +188 -0
  244. package/dist/safe-bash/opt-in/commands/yq/nodes.js +621 -0
  245. package/dist/safe-bash/opt-in/entrypoints/arrays.d.ts +1 -0
  246. package/dist/safe-bash/opt-in/entrypoints/arrays.js +1 -0
  247. package/dist/safe-bash/opt-in/entrypoints/cmp.d.ts +2 -0
  248. package/dist/safe-bash/opt-in/entrypoints/cmp.js +1 -0
  249. package/dist/safe-bash/opt-in/entrypoints/dd.d.ts +2 -0
  250. package/dist/safe-bash/opt-in/entrypoints/dd.js +1 -0
  251. package/dist/safe-bash/opt-in/entrypoints/devices.d.ts +2 -0
  252. package/dist/safe-bash/opt-in/entrypoints/devices.js +1 -0
  253. package/dist/safe-bash/opt-in/entrypoints/install.d.ts +2 -0
  254. package/dist/safe-bash/opt-in/entrypoints/install.js +1 -0
  255. package/dist/safe-bash/opt-in/entrypoints/jobs.d.ts +1 -0
  256. package/dist/safe-bash/opt-in/entrypoints/jobs.js +1 -0
  257. package/dist/safe-bash/opt-in/entrypoints/mapfile.d.ts +1 -0
  258. package/dist/safe-bash/opt-in/entrypoints/mapfile.js +1 -0
  259. package/dist/safe-bash/opt-in/entrypoints/read.d.ts +2 -0
  260. package/dist/safe-bash/opt-in/entrypoints/read.js +1 -0
  261. package/dist/safe-bash/opt-in/entrypoints/shuf.d.ts +2 -0
  262. package/dist/safe-bash/opt-in/entrypoints/shuf.js +1 -0
  263. package/dist/safe-bash/opt-in/entrypoints/trap.d.ts +2 -0
  264. package/dist/safe-bash/opt-in/entrypoints/trap.js +1 -0
  265. package/dist/safe-bash/opt-in/entrypoints/truncate.d.ts +2 -0
  266. package/dist/safe-bash/opt-in/entrypoints/truncate.js +1 -0
  267. package/dist/safe-bash/opt-in/entrypoints/yes.d.ts +2 -0
  268. package/dist/safe-bash/opt-in/entrypoints/yes.js +1 -0
  269. package/dist/safe-bash/opt-in/entrypoints/yq.d.ts +3 -0
  270. package/dist/safe-bash/opt-in/entrypoints/yq.js +1 -0
  271. package/dist/safe-bash/opt-in/fs/devices/index.d.ts +8 -0
  272. package/dist/safe-bash/opt-in/fs/devices/index.js +292 -0
  273. package/dist/safe-bash/opt-in/optional.d.ts +28 -0
  274. package/dist/safe-bash/opt-in/optional.js +14 -0
  275. package/dist/safe-bash/opt-in/shell/extensions/arrays/index.d.ts +2 -0
  276. package/dist/safe-bash/opt-in/shell/extensions/arrays/index.js +4 -0
  277. package/dist/safe-bash/opt-in/shell/extensions/jobs/index.d.ts +2 -0
  278. package/dist/safe-bash/opt-in/shell/extensions/jobs/index.js +291 -0
  279. package/dist/safe-bash/opt-in/shell/extensions/jobs/state.js +374 -0
  280. package/dist/safe-bash/opt-in/shell/extensions/mapfile/index.d.ts +24 -0
  281. package/dist/safe-bash/opt-in/shell/extensions/mapfile/index.js +338 -0
  282. package/dist/safe-bash/opt-in/shell/extensions/read/index.d.ts +5 -0
  283. package/dist/safe-bash/opt-in/shell/extensions/read/index.js +351 -0
  284. package/dist/safe-bash/opt-in/shell/extensions/trap/index.d.ts +9 -0
  285. package/dist/safe-bash/opt-in/shell/extensions/trap/index.js +210 -0
  286. package/dist/safe-bash/optional-host.d.ts +5 -0
  287. package/dist/safe-bash/optional-host.d.ts.map +1 -0
  288. package/dist/safe-bash/optional-host.js +3 -0
  289. package/dist/safe-bash/optional-host.js.map +1 -0
  290. package/dist/safe-bash/shell/arrays/bindings.d.ts +15 -5
  291. package/dist/safe-bash/shell/arrays/bindings.d.ts.map +1 -1
  292. package/dist/safe-bash/shell/arrays/bindings.js +131 -23
  293. package/dist/safe-bash/shell/arrays/bindings.js.map +1 -1
  294. package/dist/safe-bash/shell/arrays/ledger.d.ts +1 -0
  295. package/dist/safe-bash/shell/arrays/ledger.d.ts.map +1 -1
  296. package/dist/safe-bash/shell/arrays/ledger.js +19 -0
  297. package/dist/safe-bash/shell/arrays/ledger.js.map +1 -1
  298. package/dist/safe-bash/shell/arrays/state.d.ts.map +1 -1
  299. package/dist/safe-bash/shell/arrays/state.js +3 -1
  300. package/dist/safe-bash/shell/arrays/state.js.map +1 -1
  301. package/dist/safe-bash/shell/arrays/syntax.d.ts +4 -1
  302. package/dist/safe-bash/shell/arrays/syntax.d.ts.map +1 -1
  303. package/dist/safe-bash/shell/arrays/syntax.js +3 -3
  304. package/dist/safe-bash/shell/arrays/syntax.js.map +1 -1
  305. package/dist/safe-bash/shell/conditional.js +1 -1
  306. package/dist/safe-bash/shell/descriptors.d.ts +31 -0
  307. package/dist/safe-bash/shell/descriptors.d.ts.map +1 -0
  308. package/dist/safe-bash/shell/descriptors.js +234 -0
  309. package/dist/safe-bash/shell/descriptors.js.map +1 -0
  310. package/dist/safe-bash/shell/diagnostic-name-ranges.d.ts +2 -0
  311. package/dist/safe-bash/shell/diagnostic-name-ranges.d.ts.map +1 -0
  312. package/dist/safe-bash/shell/diagnostic-name-ranges.js +717 -0
  313. package/dist/safe-bash/shell/diagnostic-name-ranges.js.map +1 -0
  314. package/dist/safe-bash/shell/diagnostic-name.d.ts +3 -0
  315. package/dist/safe-bash/shell/diagnostic-name.d.ts.map +1 -0
  316. package/dist/safe-bash/shell/diagnostic-name.js +89 -0
  317. package/dist/safe-bash/shell/diagnostic-name.js.map +1 -0
  318. package/dist/safe-bash/shell/display.js +1 -1
  319. package/dist/safe-bash/shell/display.js.map +1 -1
  320. package/dist/safe-bash/shell/extensions.d.ts +188 -0
  321. package/dist/safe-bash/shell/extensions.d.ts.map +1 -0
  322. package/dist/safe-bash/shell/extensions.js +141 -0
  323. package/dist/safe-bash/shell/extensions.js.map +1 -0
  324. package/dist/safe-bash/shell/input.d.ts +66 -14
  325. package/dist/safe-bash/shell/input.d.ts.map +1 -1
  326. package/dist/safe-bash/shell/input.js +947 -173
  327. package/dist/safe-bash/shell/input.js.map +1 -1
  328. package/dist/safe-bash/shell/parser.d.ts +38 -6
  329. package/dist/safe-bash/shell/parser.d.ts.map +1 -1
  330. package/dist/safe-bash/shell/parser.js +339 -52
  331. package/dist/safe-bash/shell/parser.js.map +1 -1
  332. package/dist/safe-bash/shell/runtime.d.ts +92 -20
  333. package/dist/safe-bash/shell/runtime.d.ts.map +1 -1
  334. package/dist/safe-bash/shell/runtime.js +2547 -689
  335. package/dist/safe-bash/shell/runtime.js.map +1 -1
  336. package/dist/safe-bash/shell/shell.d.ts.map +1 -1
  337. package/dist/safe-bash/shell/shell.js +52 -21
  338. package/dist/safe-bash/shell/shell.js.map +1 -1
  339. package/dist/safe-bash/shell/types.d.ts +4 -0
  340. package/dist/safe-bash/shell/types.d.ts.map +1 -1
  341. package/dist/safe-bash/shell/types.js.map +1 -1
  342. package/package.json +92 -4
  343. package/dist/safe-bash/chunks/chunk-3BZ5NQ73.js.map +0 -7
  344. package/dist/safe-bash/chunks/chunk-4DBWBEU7.js +0 -194
  345. package/dist/safe-bash/chunks/chunk-4DBWBEU7.js.map +0 -7
  346. package/dist/safe-bash/chunks/chunk-CXMIIXJA.js +0 -178
  347. package/dist/safe-bash/chunks/chunk-CXMIIXJA.js.map +0 -7
  348. package/dist/safe-bash/chunks/chunk-K7W6Q6FN.js.map +0 -7
  349. /package/dist/safe-bash/chunks/{bz2-B2RXT4EX.js.map → bz2-ACU4EOVE.js.map} +0 -0
  350. /package/dist/safe-bash/chunks/{chunk-RNKTWFEM.js.map → chunk-CDBQXRWL.js.map} +0 -0
  351. /package/dist/safe-bash/chunks/{chunk-AFH57PPL.js.map → chunk-IEKESMO4.js.map} +0 -0
  352. /package/dist/safe-bash/chunks/{chunk-DPJWEGIX.js.map → chunk-JLBIUYT3.js.map} +0 -0
  353. /package/dist/safe-bash/chunks/{chunk-PVJJFCGA.js.map → chunk-M3GPCYSP.js.map} +0 -0
  354. /package/dist/safe-bash/chunks/{chunk-2KL6W6NB.js.map → chunk-O2EVBRKF.js.map} +0 -0
  355. /package/dist/safe-bash/chunks/{chunk-C7QNJ3D4.js.map → chunk-WYTI64IU.js.map} +0 -0
  356. /package/dist/safe-bash/chunks/{xz-AVXFDXW4.js.map → xz-U4QDTPZL.js.map} +0 -0
  357. /package/dist/safe-bash/chunks/{zstd-R6RPHJYO.js.map → zstd-OG5RPYXO.js.map} +0 -0
@@ -0,0 +1,1528 @@
1
+ import {
2
+ openCommandFile
3
+ } from "./chunk-2E4KBFO6.js";
4
+ import {
5
+ PythonInvocationError,
6
+ parsePythonInvocation
7
+ } from "./chunk-JZDO5MC3.js";
8
+ import {
9
+ createOutputOperation
10
+ } from "./chunk-CDBQXRWL.js";
11
+ import {
12
+ inheritYieldCheckpoint,
13
+ yieldTurn
14
+ } from "./chunk-THXJ6CLF.js";
15
+ import {
16
+ validateExitCode
17
+ } from "./chunk-CHHAB5SS.js";
18
+ import {
19
+ dirname,
20
+ resolvePath
21
+ } from "./chunk-JLBIUYT3.js";
22
+ import {
23
+ FsError,
24
+ readBytes,
25
+ writeBytes
26
+ } from "./chunk-WPIOO4NX.js";
27
+ import {
28
+ init_platform
29
+ } from "./chunk-O2EVBRKF.js";
30
+
31
+ // packages/safe-bash/src/commands/python/index.ts
32
+ init_platform();
33
+ import { PythonFileSystem, PythonStatTranslator } from "@poe-platform/safe-fs/core";
34
+
35
+ // packages/safe-bash/src/commands/python/reply.ts
36
+ init_platform();
37
+ function encodePythonReply(value, maxBytes) {
38
+ let used = 0;
39
+ const ancestors = /* @__PURE__ */ new Set();
40
+ const reserve = (bytes) => {
41
+ used += bytes;
42
+ if (used > maxBytes) throw new FsError("EFBIG", { syscall: "python reply" });
43
+ };
44
+ const string = (text) => {
45
+ if (text.length + 2 > maxBytes - used) throw new FsError("EFBIG", { syscall: "python reply" });
46
+ reserve(2);
47
+ for (let index = 0; index < text.length; index++) {
48
+ const code = text.charCodeAt(index);
49
+ if (code < 32) reserve([8, 9, 10, 12, 13].includes(code) ? 2 : 6);
50
+ else if (code === 34 || code === 92) reserve(2);
51
+ else if (code < 128) reserve(1);
52
+ else if (code < 2048) reserve(2);
53
+ else if (code >= 55296 && code <= 56319 && text.charCodeAt(index + 1) >= 56320 && text.charCodeAt(index + 1) <= 57343) {
54
+ reserve(4);
55
+ index++;
56
+ } else reserve(code >= 55296 && code <= 57343 ? 6 : 3);
57
+ }
58
+ return text;
59
+ };
60
+ const own = (input, depth) => {
61
+ if (depth > 64) throw new FsError("EFBIG", { syscall: "python reply" });
62
+ if (input === null || input === void 0) {
63
+ reserve(4);
64
+ return null;
65
+ }
66
+ if (typeof input === "string") return string(input);
67
+ if (typeof input === "number") {
68
+ reserve(Number.isFinite(input) ? String(input).length : 4);
69
+ return input;
70
+ }
71
+ if (typeof input === "boolean") {
72
+ reserve(input ? 4 : 5);
73
+ return input;
74
+ }
75
+ if (typeof input !== "object") throw new TypeError("Invalid Python reply value");
76
+ if (ancestors.has(input)) throw new TypeError("Cyclic Python reply value");
77
+ ancestors.add(input);
78
+ try {
79
+ if (input instanceof Uint8Array || Array.isArray(input)) {
80
+ if (input.length > maxBytes - used) throw new FsError("EFBIG", { syscall: "python reply" });
81
+ reserve(2);
82
+ const output2 = [];
83
+ for (let index = 0; index < input.length; index++) {
84
+ if (index) reserve(1);
85
+ const descriptor = Object.getOwnPropertyDescriptor(input, String(index));
86
+ if (descriptor && !("value" in descriptor)) throw new TypeError("Accessor Python reply");
87
+ output2.push(own(descriptor?.value, depth + 1));
88
+ }
89
+ return output2;
90
+ }
91
+ reserve(2);
92
+ const output = /* @__PURE__ */ Object.create(null);
93
+ let count = 0;
94
+ let visited = 0;
95
+ for (const key in input) {
96
+ if (!Object.hasOwn(input, key)) continue;
97
+ if (++visited > maxBytes) throw new FsError("EFBIG", { syscall: "python reply" });
98
+ const descriptor = Object.getOwnPropertyDescriptor(input, key);
99
+ if (!("value" in descriptor)) throw new TypeError("Accessor Python reply");
100
+ if (descriptor.value === void 0 || typeof descriptor.value === "function") continue;
101
+ if (count++) reserve(1);
102
+ string(key);
103
+ reserve(1);
104
+ output[key] = own(descriptor.value, depth + 1);
105
+ }
106
+ return output;
107
+ } finally {
108
+ ancestors.delete(input);
109
+ }
110
+ };
111
+ const owned = own(value, 0);
112
+ return new TextEncoder().encode(JSON.stringify(owned));
113
+ }
114
+
115
+ // packages/safe-bash/src/commands/python/installation.ts
116
+ init_platform();
117
+ var pythonInstallationHelp = `Usage: python -m pip install [-r FILE | --requirement FILE] PACKAGE ...
118
+ Installs compatible wheels and dependencies using the configured Pyodide installer.
119
+ PACKAGE is a package requirement or a canonical filesystem wheel path.
120
+ Supported options: -r, --requirement, -h, --help, --.
121
+ All other pip options and commands are unsupported, including --upgrade,
122
+ --force-reinstall, --no-index, --no-deps, --target, --user, --prefix, --root, --editable,
123
+ --index-url, --extra-index-url, --find-links, --trusted-host, --require-hashes,
124
+ --constraint, --dry-run, --quiet, --verbose and cache/build/configuration flags.
125
+ Configure transport and integrity through the Python package SDK configuration.
126
+ `;
127
+ function parsePythonInstallation(args) {
128
+ let pipArgs;
129
+ scan: for (let index = 0; index < args.length; index++) {
130
+ const option = args[index];
131
+ if (option === "--" || option === "-" || !option.startsWith("-") || option.startsWith("--")) return void 0;
132
+ for (let offset = 1; offset < option.length; offset++) {
133
+ const flag = option[offset];
134
+ if ("h?V".includes(flag)) return void 0;
135
+ if ("cmWX".includes(flag)) {
136
+ const operand = option.slice(offset + 1) || args[++index];
137
+ if (flag === "c") return void 0;
138
+ if (flag === "m") {
139
+ if (operand !== "pip") return void 0;
140
+ pipArgs = args.slice(index + 1);
141
+ break scan;
142
+ }
143
+ break;
144
+ }
145
+ }
146
+ }
147
+ if (!pipArgs) return void 0;
148
+ const packages = [];
149
+ const requirements = [];
150
+ if (pipArgs.length === 0) return { packages, requirements, help: true };
151
+ if (pipArgs[0] === "--help" || pipArgs[0] === "-h") {
152
+ if (pipArgs.length > 1) throw new PythonInvocationError("unsupported pip option or argument after help: " + pipArgs[1]);
153
+ return { packages, requirements, help: true };
154
+ }
155
+ if (pipArgs[0] !== "install") throw new PythonInvocationError("unsupported pip command " + pipArgs[0]);
156
+ let operands = false;
157
+ let help = false;
158
+ for (let index = 1; index < pipArgs.length; index++) {
159
+ const option = pipArgs[index];
160
+ if (operands || !option.startsWith("-")) {
161
+ packages.push(option);
162
+ continue;
163
+ }
164
+ if (option === "--") {
165
+ operands = true;
166
+ continue;
167
+ }
168
+ if (option === "--help" || option === "-h") {
169
+ help = true;
170
+ continue;
171
+ }
172
+ if (option === "-r" || option === "--requirement" || option.startsWith("--requirement=") || option.startsWith("-r")) {
173
+ const path = option.startsWith("--requirement=") ? option.slice("--requirement=".length) : option !== "-r" && option.startsWith("-r") ? option.slice(2) : pipArgs[++index];
174
+ if (!path || path.startsWith("-")) throw new PythonInvocationError(option + " requires a path");
175
+ requirements.push(path);
176
+ continue;
177
+ }
178
+ throw new PythonInvocationError("unsupported pip option " + option);
179
+ }
180
+ if (!help && packages.length === 0 && requirements.length === 0) throw new PythonInvocationError("pip install requires at least one package or requirements file");
181
+ return { packages, requirements, help };
182
+ }
183
+
184
+ // packages/safe-bash/src/commands/python/provisioning.ts
185
+ init_platform();
186
+
187
+ // node_modules/@noble/hashes/sha2.js
188
+ init_platform();
189
+
190
+ // node_modules/@noble/hashes/_md.js
191
+ init_platform();
192
+
193
+ // node_modules/@noble/hashes/_u64.js
194
+ init_platform();
195
+ var U32_MASK64 = /* @__PURE__ */ (() => BigInt(2 ** 32 - 1))();
196
+ var _32n = /* @__PURE__ */ BigInt(32);
197
+ function fromBig(n, le = false) {
198
+ if (le)
199
+ return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
200
+ return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
201
+ }
202
+ function split(lst, le = false) {
203
+ const len = lst.length;
204
+ let Ah = new Uint32Array(len);
205
+ let Al = new Uint32Array(len);
206
+ for (let i = 0; i < len; i++) {
207
+ const { h, l } = fromBig(lst[i], le);
208
+ [Ah[i], Al[i]] = [h, l];
209
+ }
210
+ return [Ah, Al];
211
+ }
212
+ var fromNumH = (n) => n / 2 ** 32 | 0;
213
+ var fromNumL = (n) => n >>> 0;
214
+ function setU64FromNum(view, byteOffset, n, isLE) {
215
+ const h = fromNumH(n);
216
+ const l = fromNumL(n);
217
+ view.setUint32(byteOffset, isLE ? l : h, isLE);
218
+ view.setUint32(byteOffset + 4, isLE ? h : l, isLE);
219
+ }
220
+ var shrSH = (h, _l, s) => h >>> s;
221
+ var shrSL = (h, l, s) => h << 32 - s | l >>> s;
222
+ var rotrSH = (h, l, s) => h >>> s | l << 32 - s;
223
+ var rotrSL = (h, l, s) => h << 32 - s | l >>> s;
224
+ var rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
225
+ var rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
226
+ function add(Ah, Al, Bh, Bl) {
227
+ const l = (Al >>> 0) + (Bl >>> 0);
228
+ return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
229
+ }
230
+ var add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
231
+ var add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
232
+ var add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
233
+ var add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
234
+ var add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
235
+ var add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
236
+
237
+ // node_modules/@noble/hashes/utils.js
238
+ init_platform();
239
+ function isBytes(a) {
240
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
241
+ }
242
+ var atitle = (title) => title ? `"${title}" ` : "";
243
+ function anumber(n, title = "") {
244
+ if (typeof n !== "number")
245
+ throw new TypeError(atitle(title) + "expected number, got " + typeof n);
246
+ if (!Number.isSafeInteger(n) || n < 0)
247
+ throw new RangeError(atitle(title) + "expected integer >= 0, got " + n);
248
+ return n;
249
+ }
250
+ function abytes(value, length, title = "") {
251
+ if (isBytes(value) && (length === void 0 || value.length === length))
252
+ return value;
253
+ if (length !== void 0)
254
+ anumber(length, "length");
255
+ const bytes = isBytes(value);
256
+ const ofLen = length !== void 0 ? ` of length ${length}` : "";
257
+ const got = bytes ? `length=${value.length}` : `type=${typeof value}`;
258
+ const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
259
+ if (!bytes)
260
+ throw new TypeError(message);
261
+ throw new RangeError(message);
262
+ }
263
+ var aobject = (value, label) => {
264
+ if (value === null || typeof value !== "object" || Array.isArray(value))
265
+ throw new TypeError((label === "object" ? "" : `"${label}" `) + "expected object, got type=" + typeof value);
266
+ };
267
+ var aopts = (value, label) => {
268
+ aobject(value, label);
269
+ const proto = Object.getPrototypeOf(value);
270
+ if (proto !== Object.prototype && proto !== null)
271
+ throw new TypeError(`"${label}" expected plain object`);
272
+ if (Object.hasOwn(value, "__proto__"))
273
+ throw new TypeError(`"${label}.__proto__" is not allowed`);
274
+ };
275
+ function aexists(instance, checkFinished = true) {
276
+ if (instance.destroyed)
277
+ throw new Error("hash was destroyed");
278
+ if (checkFinished && instance.finished)
279
+ throw new Error("digest() was already called");
280
+ }
281
+ function aoutput(out, instance) {
282
+ abytes(out, void 0, "output");
283
+ const min = instance.outputLen;
284
+ if (!(out.length >= min)) {
285
+ throw new RangeError('"output" expected length >= ' + min);
286
+ }
287
+ }
288
+ function clean(...arrays) {
289
+ for (let i = 0; i < arrays.length; i++) {
290
+ arrays[i].fill(0);
291
+ }
292
+ }
293
+ function createView(arr) {
294
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
295
+ }
296
+ function rotr(word, shift) {
297
+ return word << 32 - shift | word >>> shift;
298
+ }
299
+ function rotl(word, shift) {
300
+ return word << shift | word >>> 32 - shift >>> 0;
301
+ }
302
+ var hasHexBuiltin = /* @__PURE__ */ (() => (
303
+ // @ts-ignore
304
+ typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function"
305
+ ))();
306
+ var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
307
+ function bytesToHex(bytes) {
308
+ abytes(bytes);
309
+ if (hasHexBuiltin)
310
+ return bytes.toHex();
311
+ let hex = "";
312
+ for (let i = 0; i < bytes.length; i++) {
313
+ hex += hexes[bytes[i]];
314
+ }
315
+ return hex;
316
+ }
317
+ function checkOpts(defaults, opts, title = "opts") {
318
+ aopts(defaults, "defaults");
319
+ if (opts !== void 0)
320
+ aopts(opts, title);
321
+ const merged = Object.assign(/* @__PURE__ */ Object.create(null), defaults, opts);
322
+ return merged;
323
+ }
324
+ function createHasher(hashCons, info = {}) {
325
+ if (typeof hashCons !== "function")
326
+ throw new TypeError('"hashCons" expected function, got type=' + typeof hashCons);
327
+ info = checkOpts({}, info, "info");
328
+ const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
329
+ const tmp = hashCons(void 0);
330
+ hashC.outputLen = tmp.outputLen;
331
+ hashC.blockLen = tmp.blockLen;
332
+ hashC.canXOF = tmp.canXOF;
333
+ hashC.create = (opts) => hashCons(opts);
334
+ Object.assign(hashC, info);
335
+ return Object.freeze(hashC);
336
+ }
337
+ var oidNist = (suffix) => ({
338
+ // Current NIST hashAlgs suffixes used here fit in one DER subidentifier octet.
339
+ // Larger suffix values would need base-128 OID encoding and a different length byte.
340
+ oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
341
+ });
342
+
343
+ // node_modules/@noble/hashes/_md.js
344
+ function Chi(a, b, c) {
345
+ return a & b ^ ~a & c;
346
+ }
347
+ function Maj(a, b, c) {
348
+ return a & b ^ a & c ^ b & c;
349
+ }
350
+ var HashMD = class {
351
+ blockLen;
352
+ outputLen;
353
+ canXOF = false;
354
+ padOffset;
355
+ isLE;
356
+ // For partial updates less than block size
357
+ buffer;
358
+ view;
359
+ finished = false;
360
+ length = 0;
361
+ pos = 0;
362
+ destroyed = false;
363
+ constructor(blockLen, outputLen, padOffset, isLE) {
364
+ this.blockLen = blockLen;
365
+ this.outputLen = outputLen;
366
+ this.padOffset = padOffset;
367
+ this.isLE = isLE;
368
+ this.buffer = new Uint8Array(blockLen);
369
+ this.view = createView(this.buffer);
370
+ }
371
+ update(data) {
372
+ aexists(this);
373
+ abytes(data);
374
+ const { view, buffer, blockLen } = this;
375
+ const len = data.length;
376
+ let processed = false;
377
+ for (let pos = 0; pos < len; ) {
378
+ const take = Math.min(blockLen - this.pos, len - pos);
379
+ if (take === blockLen) {
380
+ const dataView = createView(data);
381
+ for (; blockLen <= len - pos; pos += blockLen)
382
+ this.process(dataView, pos);
383
+ processed = true;
384
+ continue;
385
+ }
386
+ buffer.set(pos === 0 && take === len ? data : data.subarray(pos, pos + take), this.pos);
387
+ this.pos += take;
388
+ pos += take;
389
+ if (this.pos === blockLen) {
390
+ this.process(view, 0);
391
+ this.pos = 0;
392
+ processed = true;
393
+ }
394
+ }
395
+ this.length += data.length;
396
+ if (processed)
397
+ this.roundClean();
398
+ return this;
399
+ }
400
+ digestInto(out) {
401
+ aexists(this);
402
+ aoutput(out, this);
403
+ this.finished = true;
404
+ const { buffer, view, blockLen, isLE } = this;
405
+ let { pos } = this;
406
+ buffer[pos++] = 128;
407
+ buffer.fill(0, pos);
408
+ if (this.padOffset > blockLen - pos) {
409
+ this.process(view, 0);
410
+ buffer.fill(0);
411
+ }
412
+ setU64FromNum(view, blockLen - 8, this.length * 8, isLE);
413
+ this.process(view, 0);
414
+ this.roundClean();
415
+ const oview = out === buffer ? view : createView(out);
416
+ const len = this.outputLen;
417
+ const outLen = len / 4;
418
+ const state = this.get();
419
+ if (len % 4 || outLen > state.length)
420
+ throw new Error("invalid outputLen");
421
+ for (let i = 0; i < outLen; i++)
422
+ oview.setUint32(4 * i, state[i], isLE);
423
+ }
424
+ digest() {
425
+ const { buffer, outputLen } = this;
426
+ this.digestInto(buffer);
427
+ const res = buffer.slice(0, outputLen);
428
+ this.destroy();
429
+ return res;
430
+ }
431
+ _cloneIntoMeta(to) {
432
+ const { buffer, length, finished, destroyed, pos } = this;
433
+ to.destroyed = destroyed;
434
+ to.finished = finished;
435
+ to.length = length;
436
+ to.pos = pos;
437
+ if (pos)
438
+ to.buffer.set(buffer);
439
+ return to;
440
+ }
441
+ clone() {
442
+ return this._cloneInto();
443
+ }
444
+ };
445
+ var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
446
+ 1779033703,
447
+ 3144134277,
448
+ 1013904242,
449
+ 2773480762,
450
+ 1359893119,
451
+ 2600822924,
452
+ 528734635,
453
+ 1541459225
454
+ ]);
455
+ var SHA224_IV = /* @__PURE__ */ Uint32Array.from([
456
+ 3238371032,
457
+ 914150663,
458
+ 812702999,
459
+ 4144912697,
460
+ 4290775857,
461
+ 1750603025,
462
+ 1694076839,
463
+ 3204075428
464
+ ]);
465
+ var SHA384_IV = /* @__PURE__ */ Uint32Array.from([
466
+ 3418070365,
467
+ 3238371032,
468
+ 1654270250,
469
+ 914150663,
470
+ 2438529370,
471
+ 812702999,
472
+ 355462360,
473
+ 4144912697,
474
+ 1731405415,
475
+ 4290775857,
476
+ 2394180231,
477
+ 1750603025,
478
+ 3675008525,
479
+ 1694076839,
480
+ 1203062813,
481
+ 3204075428
482
+ ]);
483
+ var SHA512_IV = /* @__PURE__ */ Uint32Array.from([
484
+ 1779033703,
485
+ 4089235720,
486
+ 3144134277,
487
+ 2227873595,
488
+ 1013904242,
489
+ 4271175723,
490
+ 2773480762,
491
+ 1595750129,
492
+ 1359893119,
493
+ 2917565137,
494
+ 2600822924,
495
+ 725511199,
496
+ 528734635,
497
+ 4215389547,
498
+ 1541459225,
499
+ 327033209
500
+ ]);
501
+
502
+ // node_modules/@noble/hashes/sha2.js
503
+ var SHA256_K = /* @__PURE__ */ Uint32Array.from([
504
+ 1116352408,
505
+ 1899447441,
506
+ 3049323471,
507
+ 3921009573,
508
+ 961987163,
509
+ 1508970993,
510
+ 2453635748,
511
+ 2870763221,
512
+ 3624381080,
513
+ 310598401,
514
+ 607225278,
515
+ 1426881987,
516
+ 1925078388,
517
+ 2162078206,
518
+ 2614888103,
519
+ 3248222580,
520
+ 3835390401,
521
+ 4022224774,
522
+ 264347078,
523
+ 604807628,
524
+ 770255983,
525
+ 1249150122,
526
+ 1555081692,
527
+ 1996064986,
528
+ 2554220882,
529
+ 2821834349,
530
+ 2952996808,
531
+ 3210313671,
532
+ 3336571891,
533
+ 3584528711,
534
+ 113926993,
535
+ 338241895,
536
+ 666307205,
537
+ 773529912,
538
+ 1294757372,
539
+ 1396182291,
540
+ 1695183700,
541
+ 1986661051,
542
+ 2177026350,
543
+ 2456956037,
544
+ 2730485921,
545
+ 2820302411,
546
+ 3259730800,
547
+ 3345764771,
548
+ 3516065817,
549
+ 3600352804,
550
+ 4094571909,
551
+ 275423344,
552
+ 430227734,
553
+ 506948616,
554
+ 659060556,
555
+ 883997877,
556
+ 958139571,
557
+ 1322822218,
558
+ 1537002063,
559
+ 1747873779,
560
+ 1955562222,
561
+ 2024104815,
562
+ 2227730452,
563
+ 2361852424,
564
+ 2428436474,
565
+ 2756734187,
566
+ 3204031479,
567
+ 3329325298
568
+ ]);
569
+ var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
570
+ var SHA2_32B = class extends HashMD {
571
+ // We cannot use array here since array allows indexing by variable
572
+ // which means optimizer/compiler cannot use registers.
573
+ // Numeric initializers matter: starting the fields as `undefined` changes
574
+ // V8's field representation and makes sha256 3x slower (measured).
575
+ A = 0;
576
+ B = 0;
577
+ C = 0;
578
+ D = 0;
579
+ E = 0;
580
+ F = 0;
581
+ G = 0;
582
+ H = 0;
583
+ constructor(outputLen, IV) {
584
+ super(64, outputLen, 8, false);
585
+ this.A = IV[0] | 0;
586
+ this.B = IV[1] | 0;
587
+ this.C = IV[2] | 0;
588
+ this.D = IV[3] | 0;
589
+ this.E = IV[4] | 0;
590
+ this.F = IV[5] | 0;
591
+ this.G = IV[6] | 0;
592
+ this.H = IV[7] | 0;
593
+ }
594
+ get() {
595
+ const { A, B, C, D, E, F, G, H } = this;
596
+ return [A, B, C, D, E, F, G, H];
597
+ }
598
+ // prettier-ignore
599
+ set(A, B, C, D, E, F, G, H) {
600
+ this.A = A | 0;
601
+ this.B = B | 0;
602
+ this.C = C | 0;
603
+ this.D = D | 0;
604
+ this.E = E | 0;
605
+ this.F = F | 0;
606
+ this.G = G | 0;
607
+ this.H = H | 0;
608
+ }
609
+ _cloneInto(to) {
610
+ (to ||= new this.constructor()).set(...this.get());
611
+ return this._cloneIntoMeta(to);
612
+ }
613
+ process(view, offset) {
614
+ for (let i = 0; i < 16; i++, offset += 4)
615
+ SHA256_W[i] = view.getUint32(offset, false);
616
+ for (let i = 16; i < 64; i++) {
617
+ const W15 = SHA256_W[i - 15];
618
+ const W2 = SHA256_W[i - 2];
619
+ const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
620
+ const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
621
+ SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
622
+ }
623
+ let { A, B, C, D, E, F, G, H } = this;
624
+ for (let i = 0; i < 64; i++) {
625
+ const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
626
+ const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
627
+ const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
628
+ const T2 = sigma0 + Maj(A, B, C) | 0;
629
+ H = G;
630
+ G = F;
631
+ F = E;
632
+ E = D + T1 | 0;
633
+ D = C;
634
+ C = B;
635
+ B = A;
636
+ A = T1 + T2 | 0;
637
+ }
638
+ A = A + this.A | 0;
639
+ B = B + this.B | 0;
640
+ C = C + this.C | 0;
641
+ D = D + this.D | 0;
642
+ E = E + this.E | 0;
643
+ F = F + this.F | 0;
644
+ G = G + this.G | 0;
645
+ H = H + this.H | 0;
646
+ this.set(A, B, C, D, E, F, G, H);
647
+ }
648
+ roundClean() {
649
+ clean(SHA256_W);
650
+ }
651
+ destroy() {
652
+ this.destroyed = true;
653
+ this.set(0, 0, 0, 0, 0, 0, 0, 0);
654
+ clean(this.buffer);
655
+ }
656
+ };
657
+ var _SHA256 = class extends SHA2_32B {
658
+ constructor() {
659
+ super(32, SHA256_IV);
660
+ }
661
+ };
662
+ var _SHA224 = class extends SHA2_32B {
663
+ constructor() {
664
+ super(28, SHA224_IV);
665
+ }
666
+ };
667
+ var K512 = /* @__PURE__ */ (() => split([
668
+ "0x428a2f98d728ae22",
669
+ "0x7137449123ef65cd",
670
+ "0xb5c0fbcfec4d3b2f",
671
+ "0xe9b5dba58189dbbc",
672
+ "0x3956c25bf348b538",
673
+ "0x59f111f1b605d019",
674
+ "0x923f82a4af194f9b",
675
+ "0xab1c5ed5da6d8118",
676
+ "0xd807aa98a3030242",
677
+ "0x12835b0145706fbe",
678
+ "0x243185be4ee4b28c",
679
+ "0x550c7dc3d5ffb4e2",
680
+ "0x72be5d74f27b896f",
681
+ "0x80deb1fe3b1696b1",
682
+ "0x9bdc06a725c71235",
683
+ "0xc19bf174cf692694",
684
+ "0xe49b69c19ef14ad2",
685
+ "0xefbe4786384f25e3",
686
+ "0x0fc19dc68b8cd5b5",
687
+ "0x240ca1cc77ac9c65",
688
+ "0x2de92c6f592b0275",
689
+ "0x4a7484aa6ea6e483",
690
+ "0x5cb0a9dcbd41fbd4",
691
+ "0x76f988da831153b5",
692
+ "0x983e5152ee66dfab",
693
+ "0xa831c66d2db43210",
694
+ "0xb00327c898fb213f",
695
+ "0xbf597fc7beef0ee4",
696
+ "0xc6e00bf33da88fc2",
697
+ "0xd5a79147930aa725",
698
+ "0x06ca6351e003826f",
699
+ "0x142929670a0e6e70",
700
+ "0x27b70a8546d22ffc",
701
+ "0x2e1b21385c26c926",
702
+ "0x4d2c6dfc5ac42aed",
703
+ "0x53380d139d95b3df",
704
+ "0x650a73548baf63de",
705
+ "0x766a0abb3c77b2a8",
706
+ "0x81c2c92e47edaee6",
707
+ "0x92722c851482353b",
708
+ "0xa2bfe8a14cf10364",
709
+ "0xa81a664bbc423001",
710
+ "0xc24b8b70d0f89791",
711
+ "0xc76c51a30654be30",
712
+ "0xd192e819d6ef5218",
713
+ "0xd69906245565a910",
714
+ "0xf40e35855771202a",
715
+ "0x106aa07032bbd1b8",
716
+ "0x19a4c116b8d2d0c8",
717
+ "0x1e376c085141ab53",
718
+ "0x2748774cdf8eeb99",
719
+ "0x34b0bcb5e19b48a8",
720
+ "0x391c0cb3c5c95a63",
721
+ "0x4ed8aa4ae3418acb",
722
+ "0x5b9cca4f7763e373",
723
+ "0x682e6ff3d6b2b8a3",
724
+ "0x748f82ee5defb2fc",
725
+ "0x78a5636f43172f60",
726
+ "0x84c87814a1f0ab72",
727
+ "0x8cc702081a6439ec",
728
+ "0x90befffa23631e28",
729
+ "0xa4506cebde82bde9",
730
+ "0xbef9a3f7b2c67915",
731
+ "0xc67178f2e372532b",
732
+ "0xca273eceea26619c",
733
+ "0xd186b8c721c0c207",
734
+ "0xeada7dd6cde0eb1e",
735
+ "0xf57d4f7fee6ed178",
736
+ "0x06f067aa72176fba",
737
+ "0x0a637dc5a2c898a6",
738
+ "0x113f9804bef90dae",
739
+ "0x1b710b35131c471b",
740
+ "0x28db77f523047d84",
741
+ "0x32caab7b40c72493",
742
+ "0x3c9ebe0a15c9bebc",
743
+ "0x431d67c49c100d4c",
744
+ "0x4cc5d4becb3e42b6",
745
+ "0x597f299cfc657e2a",
746
+ "0x5fcb6fab3ad6faec",
747
+ "0x6c44198c4a475817"
748
+ ].map((n) => BigInt(n))))();
749
+ var SHA512_Kh = /* @__PURE__ */ (() => K512[0])();
750
+ var SHA512_Kl = /* @__PURE__ */ (() => K512[1])();
751
+ var SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
752
+ var SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
753
+ var SHA2_64B = class extends HashMD {
754
+ // We cannot use array here since array allows indexing by variable
755
+ // which means optimizer/compiler cannot use registers.
756
+ // h -- high 32 bits, l -- low 32 bits
757
+ // Numeric initializers matter: starting the fields as `undefined` changes
758
+ // V8's field representation and slows hashing down (measured on sha256).
759
+ Ah = 0;
760
+ Al = 0;
761
+ Bh = 0;
762
+ Bl = 0;
763
+ Ch = 0;
764
+ Cl = 0;
765
+ Dh = 0;
766
+ Dl = 0;
767
+ Eh = 0;
768
+ El = 0;
769
+ Fh = 0;
770
+ Fl = 0;
771
+ Gh = 0;
772
+ Gl = 0;
773
+ Hh = 0;
774
+ Hl = 0;
775
+ constructor(outputLen, IV) {
776
+ super(128, outputLen, 16, false);
777
+ this.Ah = IV[0] | 0;
778
+ this.Al = IV[1] | 0;
779
+ this.Bh = IV[2] | 0;
780
+ this.Bl = IV[3] | 0;
781
+ this.Ch = IV[4] | 0;
782
+ this.Cl = IV[5] | 0;
783
+ this.Dh = IV[6] | 0;
784
+ this.Dl = IV[7] | 0;
785
+ this.Eh = IV[8] | 0;
786
+ this.El = IV[9] | 0;
787
+ this.Fh = IV[10] | 0;
788
+ this.Fl = IV[11] | 0;
789
+ this.Gh = IV[12] | 0;
790
+ this.Gl = IV[13] | 0;
791
+ this.Hh = IV[14] | 0;
792
+ this.Hl = IV[15] | 0;
793
+ }
794
+ // prettier-ignore
795
+ get() {
796
+ const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
797
+ return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];
798
+ }
799
+ // prettier-ignore
800
+ set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {
801
+ this.Ah = Ah | 0;
802
+ this.Al = Al | 0;
803
+ this.Bh = Bh | 0;
804
+ this.Bl = Bl | 0;
805
+ this.Ch = Ch | 0;
806
+ this.Cl = Cl | 0;
807
+ this.Dh = Dh | 0;
808
+ this.Dl = Dl | 0;
809
+ this.Eh = Eh | 0;
810
+ this.El = El | 0;
811
+ this.Fh = Fh | 0;
812
+ this.Fl = Fl | 0;
813
+ this.Gh = Gh | 0;
814
+ this.Gl = Gl | 0;
815
+ this.Hh = Hh | 0;
816
+ this.Hl = Hl | 0;
817
+ }
818
+ _cloneInto(to) {
819
+ (to ||= new this.constructor()).set(...this.get());
820
+ return this._cloneIntoMeta(to);
821
+ }
822
+ process(view, offset) {
823
+ for (let i = 0; i < 16; i++, offset += 4) {
824
+ SHA512_W_H[i] = view.getUint32(offset);
825
+ SHA512_W_L[i] = view.getUint32(offset += 4);
826
+ }
827
+ for (let i = 16; i < 80; i++) {
828
+ const W15h = SHA512_W_H[i - 15] | 0;
829
+ const W15l = SHA512_W_L[i - 15] | 0;
830
+ const s0h = rotrSH(W15h, W15l, 1) ^ rotrSH(W15h, W15l, 8) ^ shrSH(W15h, W15l, 7);
831
+ const s0l = rotrSL(W15h, W15l, 1) ^ rotrSL(W15h, W15l, 8) ^ shrSL(W15h, W15l, 7);
832
+ const W2h = SHA512_W_H[i - 2] | 0;
833
+ const W2l = SHA512_W_L[i - 2] | 0;
834
+ const s1h = rotrSH(W2h, W2l, 19) ^ rotrBH(W2h, W2l, 61) ^ shrSH(W2h, W2l, 6);
835
+ const s1l = rotrSL(W2h, W2l, 19) ^ rotrBL(W2h, W2l, 61) ^ shrSL(W2h, W2l, 6);
836
+ const SUMl = add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
837
+ const SUMh = add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);
838
+ SHA512_W_H[i] = SUMh | 0;
839
+ SHA512_W_L[i] = SUMl | 0;
840
+ }
841
+ let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
842
+ for (let i = 0; i < 80; i++) {
843
+ const sigma1h = rotrSH(Eh, El, 14) ^ rotrSH(Eh, El, 18) ^ rotrBH(Eh, El, 41);
844
+ const sigma1l = rotrSL(Eh, El, 14) ^ rotrSL(Eh, El, 18) ^ rotrBL(Eh, El, 41);
845
+ const CHIh = Eh & Fh ^ ~Eh & Gh;
846
+ const CHIl = El & Fl ^ ~El & Gl;
847
+ const T1ll = add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
848
+ const T1h = add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
849
+ const T1l = T1ll | 0;
850
+ const sigma0h = rotrSH(Ah, Al, 28) ^ rotrBH(Ah, Al, 34) ^ rotrBH(Ah, Al, 39);
851
+ const sigma0l = rotrSL(Ah, Al, 28) ^ rotrBL(Ah, Al, 34) ^ rotrBL(Ah, Al, 39);
852
+ const MAJh = Ah & Bh ^ Ah & Ch ^ Bh & Ch;
853
+ const MAJl = Al & Bl ^ Al & Cl ^ Bl & Cl;
854
+ Hh = Gh | 0;
855
+ Hl = Gl | 0;
856
+ Gh = Fh | 0;
857
+ Gl = Fl | 0;
858
+ Fh = Eh | 0;
859
+ Fl = El | 0;
860
+ ({ h: Eh, l: El } = add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
861
+ Dh = Ch | 0;
862
+ Dl = Cl | 0;
863
+ Ch = Bh | 0;
864
+ Cl = Bl | 0;
865
+ Bh = Ah | 0;
866
+ Bl = Al | 0;
867
+ const All = add3L(T1l, sigma0l, MAJl);
868
+ Ah = add3H(All, T1h, sigma0h, MAJh);
869
+ Al = All | 0;
870
+ }
871
+ ({ h: Ah, l: Al } = add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
872
+ ({ h: Bh, l: Bl } = add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
873
+ ({ h: Ch, l: Cl } = add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
874
+ ({ h: Dh, l: Dl } = add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
875
+ ({ h: Eh, l: El } = add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
876
+ ({ h: Fh, l: Fl } = add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
877
+ ({ h: Gh, l: Gl } = add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
878
+ ({ h: Hh, l: Hl } = add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
879
+ this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
880
+ }
881
+ roundClean() {
882
+ clean(SHA512_W_H, SHA512_W_L);
883
+ }
884
+ destroy() {
885
+ this.destroyed = true;
886
+ clean(this.buffer);
887
+ this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
888
+ }
889
+ };
890
+ var _SHA512 = class extends SHA2_64B {
891
+ constructor() {
892
+ super(64, SHA512_IV);
893
+ }
894
+ };
895
+ var _SHA384 = class extends SHA2_64B {
896
+ constructor() {
897
+ super(48, SHA384_IV);
898
+ }
899
+ };
900
+ var sha256 = /* @__PURE__ */ createHasher(
901
+ () => new _SHA256(),
902
+ /* @__PURE__ */ oidNist(1)
903
+ );
904
+ var sha224 = /* @__PURE__ */ createHasher(
905
+ () => new _SHA224(),
906
+ /* @__PURE__ */ oidNist(4)
907
+ );
908
+ var sha512 = /* @__PURE__ */ createHasher(
909
+ () => new _SHA512(),
910
+ /* @__PURE__ */ oidNist(3)
911
+ );
912
+ var sha384 = /* @__PURE__ */ createHasher(
913
+ () => new _SHA384(),
914
+ /* @__PURE__ */ oidNist(2)
915
+ );
916
+
917
+ // packages/safe-bash/src/commands/python/provisioning.ts
918
+ var pythonDocumentPackages = Object.freeze([
919
+ "lxml==6.0.2",
920
+ "pillow==12.2.0",
921
+ "python-docx==1.2.0",
922
+ "openpyxl==3.1.5",
923
+ "XlsxWriter==3.2.9",
924
+ "pypdf==6.18.1",
925
+ "fpdf2==2.8.8",
926
+ "fonttools==4.65.0",
927
+ "defusedxml==0.7.1",
928
+ "et-xmlfile==2.0.0",
929
+ "typing-extensions==4.16.0"
930
+ ]);
931
+ var encoder = new TextEncoder();
932
+ var decoder = new TextDecoder();
933
+ var runtimeKey = "pyodide-314.0.6-cp314-emscripten-wasm32-v1";
934
+ function digest(value) {
935
+ return Array.from(sha256(value), (byte) => byte.toString(16).padStart(2, "0")).join("");
936
+ }
937
+ function failure(message) {
938
+ return Object.assign(new Error(message), { code: "EPACKAGE" });
939
+ }
940
+ function missing(error) {
941
+ return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
942
+ }
943
+ function normalizeRequirement(value, cwd) {
944
+ const requirement = value.trim();
945
+ if (!requirement || requirement.startsWith("-")) throw failure(`Unsupported requirement: ${value}`);
946
+ if (requirement.endsWith(".whl") && !requirement.includes("://")) return "file://" + resolvePath(cwd, requirement).split("/").map(encodeURIComponent).join("/");
947
+ return requirement;
948
+ }
949
+ function checkSession(session) {
950
+ session.signal.throwIfAborted();
951
+ if (session.closed) throw failure("Python package session is closed");
952
+ }
953
+ function createPythonPackageEnvironment(options = {}) {
954
+ if (options.cache && options.cacheDirectory) throw new TypeError("Choose package cache or cacheDirectory, not both");
955
+ if (options.profile !== void 0 && options.profile !== "documents") throw new TypeError("Unknown Python package profile");
956
+ const maxBytes = options.maxDownloadBytes ?? 64 * 1024 * 1024;
957
+ if (!Number.isSafeInteger(maxBytes) || maxBytes < 1) throw new RangeError("maxDownloadBytes must be a positive integer");
958
+ const maxCacheBytes = options.maxCacheBytes ?? 128 * 1024 * 1024;
959
+ if (!Number.isSafeInteger(maxCacheBytes) || maxCacheBytes < 1) throw new RangeError("maxCacheBytes must be a positive integer");
960
+ const memory = /* @__PURE__ */ new Map();
961
+ let memoryBytes = 0;
962
+ const defaultCache = {
963
+ async get(key) {
964
+ return memory.get(key)?.slice();
965
+ },
966
+ async set(key, value) {
967
+ const manifestKey = runtimeKey + "-environment";
968
+ if (key === manifestKey && value.length > maxCacheBytes) throw failure("Python package manifest exceeds maxCacheBytes");
969
+ const previous = memory.get(key);
970
+ if (previous) {
971
+ memoryBytes -= previous.length;
972
+ memory.delete(key);
973
+ }
974
+ if (value.length > maxCacheBytes) return;
975
+ while (memory.size && (memoryBytes + value.length > maxCacheBytes || memory.size >= 1024)) {
976
+ const oldest = Array.from(memory.keys()).find((entry) => entry !== manifestKey);
977
+ if (oldest === void 0) return;
978
+ memoryBytes -= memory.get(oldest).length;
979
+ memory.delete(oldest);
980
+ }
981
+ memory.set(key, value.slice());
982
+ memoryBytes += value.length;
983
+ }
984
+ };
985
+ const sessions = /* @__PURE__ */ new Map();
986
+ let counter = 0;
987
+ let committing = Promise.resolve();
988
+ async function prepare(context) {
989
+ context.signal.throwIfAborted();
990
+ const directory = options.cacheDirectory === void 0 ? void 0 : resolvePath(context.cwd, options.cacheDirectory, runtimeKey);
991
+ const cache = options.cache ?? (directory === void 0 ? defaultCache : {
992
+ async get(key) {
993
+ try {
994
+ return await context.fs.readFile(resolvePath(directory, key), { signal: context.signal, maxBytes });
995
+ } catch (error) {
996
+ if (missing(error)) return void 0;
997
+ throw error;
998
+ }
999
+ },
1000
+ async set(key, bytes) {
1001
+ await context.fs.mkdir(directory, { recursive: true, signal: context.signal });
1002
+ await context.fs.writeFile(resolvePath(directory, key), bytes, { signal: context.signal });
1003
+ }
1004
+ });
1005
+ const stored = await cache.get(runtimeKey + "-environment");
1006
+ context.signal.throwIfAborted();
1007
+ if (stored && stored.length > maxBytes) throw failure("Python package manifest exceeds maxDownloadBytes");
1008
+ const manifest = stored === void 0 ? "" : decoder.decode(stored);
1009
+ let previous;
1010
+ try {
1011
+ previous = stored === void 0 ? [] : JSON.parse(manifest);
1012
+ } catch {
1013
+ throw failure("Invalid Python package environment manifest");
1014
+ }
1015
+ if (!Array.isArray(previous) || previous.some((value) => typeof value !== "string")) throw failure("Invalid Python package environment manifest");
1016
+ const requirements = [...previous, ...options.profile === "documents" ? pythonDocumentPackages : [], ...options.requirements ?? [], ...context.requirements ?? []].map((value) => normalizeRequirement(value, context.cwd));
1017
+ for (const file of [...options.requirementFiles ?? [], ...context.requirementFiles ?? []]) {
1018
+ const path = resolvePath(context.cwd, file);
1019
+ let source;
1020
+ try {
1021
+ source = decoder.decode(await context.fs.readFile(path, { signal: context.signal, maxBytes: 1024 * 1024 }));
1022
+ } catch (error) {
1023
+ context.signal.throwIfAborted();
1024
+ throw failure(`Cannot read Python requirements ${path}: ${error instanceof Error ? error.message : String(error)}`);
1025
+ }
1026
+ for (const line of source.split("\n")) {
1027
+ const text = line.trim();
1028
+ if (!text || text.startsWith("#")) continue;
1029
+ if (text.endsWith("\\") || text.startsWith("-")) throw failure(`Unsupported requirements option or continuation in ${path}: ${text}`);
1030
+ const comment = text.indexOf(" #");
1031
+ requirements.push(normalizeRequirement(comment < 0 ? text : text.slice(0, comment), dirname(path)));
1032
+ }
1033
+ }
1034
+ context.signal.throwIfAborted();
1035
+ const session = String(++counter);
1036
+ const unique = [...new Set(requirements)];
1037
+ const aborted = () => {
1038
+ const current = sessions.get(session);
1039
+ if (current) {
1040
+ current.closed = true;
1041
+ current.opened.clear();
1042
+ }
1043
+ sessions.delete(session);
1044
+ };
1045
+ sessions.set(session, { ...context, cache, offline: context.offline ?? options.offline ?? false, requirements: unique, opened: /* @__PURE__ */ new Map(), opening: false, closed: false, manifest, aborted });
1046
+ context.signal.addEventListener("abort", aborted, { once: true });
1047
+ return { session, requirements: unique, offline: context.offline ?? options.offline ?? false };
1048
+ }
1049
+ async function dispatch(op, args, _context) {
1050
+ _context.signal.throwIfAborted();
1051
+ const session = sessions.get(String(args[0]));
1052
+ if (!session) throw failure("Python package session is closed");
1053
+ checkSession(session);
1054
+ if (op === "package-commit") {
1055
+ const pinned = args[1];
1056
+ if (!Array.isArray(pinned) || pinned.some((value) => typeof value !== "string")) throw failure("Invalid installed package manifest");
1057
+ const merged = [.../* @__PURE__ */ new Set([...session.requirements, ...pinned])];
1058
+ const manifestBytes = encoder.encode(JSON.stringify(merged));
1059
+ if (manifestBytes.length > maxBytes) throw failure("Python package manifest exceeds maxDownloadBytes");
1060
+ const commit = committing.then(async () => {
1061
+ checkSession(session);
1062
+ const current = await session.cache.get(runtimeKey + "-environment");
1063
+ checkSession(session);
1064
+ if (current && current.length > maxBytes) throw failure("Python package manifest exceeds maxDownloadBytes");
1065
+ if ((current === void 0 ? "" : decoder.decode(current)) !== session.manifest) throw failure("Python package environment changed during installation; retry the command");
1066
+ await session.cache.set(runtimeKey + "-environment", manifestBytes);
1067
+ checkSession(session);
1068
+ });
1069
+ committing = commit.catch(() => {
1070
+ });
1071
+ await commit;
1072
+ options.onProgress?.({ phase: "installed" });
1073
+ return null;
1074
+ }
1075
+ if (op === "package-read") {
1076
+ const bytes = session.opened.get(String(args[1]));
1077
+ const offset = args[2];
1078
+ const length = args[3];
1079
+ if (!bytes || !Number.isSafeInteger(offset) || !Number.isSafeInteger(length) || offset < 0 || length < 1 || length > 65536) throw failure("Invalid package chunk request");
1080
+ return Array.from(bytes.subarray(offset, offset + length));
1081
+ }
1082
+ if (op === "package-close") {
1083
+ session.opened.delete(String(args[1]));
1084
+ return null;
1085
+ }
1086
+ if (op !== "package-open" || typeof args[1] !== "string") throw failure("Invalid package operation");
1087
+ if (session.opening) throw failure("Package download already in progress");
1088
+ session.opening = true;
1089
+ session.opened.clear();
1090
+ try {
1091
+ const url = args[1];
1092
+ const expected = args[2];
1093
+ if (expected !== void 0 && expected !== null && (typeof expected !== "string" || expected.length !== 64 || Array.from(expected).some((c) => !"0123456789abcdef".includes(c)))) throw failure("Invalid SHA-256 package integrity value");
1094
+ const address = runtimeKey + "-url-" + digest(encoder.encode(url));
1095
+ const metadata = await session.cache.get(address);
1096
+ checkSession(session);
1097
+ let bytes;
1098
+ let headers = [];
1099
+ if (metadata) {
1100
+ if (metadata.length > maxBytes) throw failure("Python package cache metadata exceeds maxDownloadBytes");
1101
+ let record;
1102
+ try {
1103
+ record = JSON.parse(decoder.decode(metadata));
1104
+ } catch {
1105
+ throw failure(`Invalid package cache metadata: ${url}`);
1106
+ }
1107
+ if (typeof record !== "object" || record === null || typeof record.digest !== "string" || record.digest.length !== 64 || Array.from(record.digest).some((char) => !"0123456789abcdef".includes(char)) || !Array.isArray(record.headers) || record.headers.some((pair) => !Array.isArray(pair) || pair.length !== 2 || pair.some((value) => typeof value !== "string"))) throw failure(`Invalid package cache metadata: ${url}`);
1108
+ bytes = await session.cache.get(runtimeKey + "-sha256-" + record.digest);
1109
+ headers = record.headers;
1110
+ checkSession(session);
1111
+ if (bytes && bytes.length > maxBytes) throw failure("Cached package exceeds maxDownloadBytes");
1112
+ if (bytes) bytes = Uint8Array.from(bytes);
1113
+ if (bytes && digest(bytes) !== record.digest) throw failure(`Package cache integrity mismatch: ${url}`);
1114
+ if (bytes) options.onProgress?.({ phase: "cached", url, bytes: bytes.length });
1115
+ }
1116
+ if (!bytes) {
1117
+ if (url.startsWith("file:") || url.startsWith("emfs:")) {
1118
+ const path = new URL(url);
1119
+ if (path.host && path.host !== "localhost") throw failure("Local wheels must use the canonical filesystem");
1120
+ try {
1121
+ bytes = await session.fs.readFile(decodeURIComponent(path.pathname), { signal: session.signal, maxBytes });
1122
+ } catch (error) {
1123
+ checkSession(session);
1124
+ throw failure(`Cannot read canonical Python wheel ${path.pathname}: ${error instanceof Error ? error.message : String(error)}`);
1125
+ }
1126
+ } else {
1127
+ if (session.offline) throw failure(`Offline package cache miss: ${url}`);
1128
+ if (!options.transport || !options.authorize) throw failure("Python package download requires configured transport and authorization");
1129
+ let current = new URL(url);
1130
+ let redirectFrom;
1131
+ for (let redirect = 0; ; redirect++) {
1132
+ if (current.protocol !== "https:" && current.protocol !== "http:") throw failure(`Unsupported package transport protocol: ${current.protocol}`);
1133
+ if (current.username || current.password) throw failure("Package URLs with credentials are unsupported");
1134
+ let denyPrivate = false;
1135
+ const allowed = await options.authorize({ url: current.href, method: "GET", attempt: 0, signal: session.signal, ...redirectFrom === void 0 ? {} : { redirectFrom }, requirePrivateNetworkDeny() {
1136
+ denyPrivate = true;
1137
+ } });
1138
+ checkSession(session);
1139
+ if (!allowed) throw failure(`Python package download authorization denied: ${current.href}`);
1140
+ if (denyPrivate && !options.transport.supportsPrivateNetworkDeny) throw failure("Package transport cannot enforce private network denial");
1141
+ checkSession(session);
1142
+ const response = await options.transport({ url: current.href, method: "GET", headers: [["accept", "application/vnd.pypi.simple.v1+json, application/json;q=0.9, */*;q=0.1"]], signal: session.signal, ...denyPrivate ? { denyPrivateNetworks: true } : {} });
1143
+ try {
1144
+ checkSession(session);
1145
+ if ([301, 302, 303, 307, 308].includes(response.status)) {
1146
+ if (redirect >= 5) throw failure("Too many package redirects");
1147
+ const location = response.headers.find(([key2]) => key2.toLowerCase() === "location")?.[1];
1148
+ if (!location) throw failure("Package redirect has no location");
1149
+ redirectFrom = current.href;
1150
+ current = new URL(location, current);
1151
+ continue;
1152
+ }
1153
+ if (response.status < 200 || response.status >= 300) throw failure(`Package download failed: HTTP ${response.status} ${current.href}`);
1154
+ headers = response.headers;
1155
+ const encoding = headers.find(([key2]) => key2.toLowerCase() === "content-encoding")?.[1].trim().toLowerCase();
1156
+ const length = headers.find(([key2]) => key2.toLowerCase() === "content-length")?.[1];
1157
+ const total = length === void 0 || encoding !== void 0 && encoding !== "identity" ? void 0 : Number(length);
1158
+ if (total !== void 0 && Number.isFinite(total) && total > maxBytes) throw failure("Package download exceeds maxDownloadBytes");
1159
+ const chunks = [];
1160
+ let count = 0;
1161
+ for await (const chunk of response.body) {
1162
+ checkSession(session);
1163
+ if (chunk.length === 0) continue;
1164
+ count += chunk.length;
1165
+ if (count > maxBytes) throw failure("Package download exceeds maxDownloadBytes");
1166
+ chunks.push(Uint8Array.from(chunk));
1167
+ options.onProgress?.({ phase: "download", url, bytes: count, ...typeof total === "number" && Number.isSafeInteger(total) ? { totalBytes: total } : {} });
1168
+ }
1169
+ bytes = new Uint8Array(count);
1170
+ let offset = 0;
1171
+ for (const chunk of chunks) {
1172
+ bytes.set(chunk, offset);
1173
+ offset += chunk.length;
1174
+ }
1175
+ break;
1176
+ } finally {
1177
+ await response.dispose();
1178
+ }
1179
+ }
1180
+ }
1181
+ checkSession(session);
1182
+ if (expected && digest(bytes) !== expected) throw failure(`Package integrity mismatch: ${url}`);
1183
+ const hash = digest(bytes);
1184
+ const metadataBytes = encoder.encode(JSON.stringify({ digest: hash, headers }));
1185
+ if (metadataBytes.length > maxBytes) throw failure("Python package cache metadata exceeds maxDownloadBytes");
1186
+ await session.cache.set(runtimeKey + "-sha256-" + hash, Uint8Array.from(bytes));
1187
+ checkSession(session);
1188
+ await session.cache.set(address, metadataBytes);
1189
+ checkSession(session);
1190
+ }
1191
+ checkSession(session);
1192
+ if (expected && digest(bytes) !== expected) throw failure(`Package integrity mismatch: ${url}`);
1193
+ const key = digest(bytes);
1194
+ session.opened.set(key, bytes);
1195
+ return { key, size: bytes.length, headers };
1196
+ } finally {
1197
+ session.opening = false;
1198
+ }
1199
+ }
1200
+ return { prepare, dispatch, finish(start) {
1201
+ const session = sessions.get(start.session);
1202
+ if (session) {
1203
+ session.closed = true;
1204
+ session.opened.clear();
1205
+ session.signal.removeEventListener("abort", session.aborted);
1206
+ }
1207
+ sessions.delete(start.session);
1208
+ } };
1209
+ }
1210
+
1211
+ // packages/safe-bash/src/commands/python/index.ts
1212
+ var PythonInputChunkError = class extends RangeError {
1213
+ };
1214
+ function createPythonCommands(options) {
1215
+ if (typeof options?.createWorker !== "function") throw new TypeError("Python requires an explicit interpreter worker factory");
1216
+ const maxTransferBytes = options.maxTransferBytes ?? 65536;
1217
+ const maxOpenFiles = options.maxOpenFiles ?? 256;
1218
+ const maxConcurrentWorkers = options.maxConcurrentWorkers ?? 4;
1219
+ const maxInputChunkBytes = options.maxInputChunkBytes ?? 1048576;
1220
+ if (!Number.isSafeInteger(maxConcurrentWorkers) || maxConcurrentWorkers < 1 || maxConcurrentWorkers > 64) throw new RangeError("Invalid Python worker concurrency limit");
1221
+ if (!Number.isSafeInteger(maxInputChunkBytes) || maxInputChunkBytes < 1 || maxInputChunkBytes > 16777216) throw new RangeError("Invalid Python input chunk limit");
1222
+ let activeWorkers = 0;
1223
+ for (const size of [maxTransferBytes, maxOpenFiles]) if (!Number.isSafeInteger(size) || size < 1 || size > 1048576) throw new RangeError("Invalid Python resource limit");
1224
+ const runtimeMount = options.runtimeMount ?? "/.pyodide-runtime";
1225
+ if (!runtimeMount.startsWith("/") || runtimeMount === "/" || runtimeMount.slice(1).includes("/") || runtimeMount.includes("\0") || runtimeMount.split("/").some((part) => part === ".." || part === ".")) throw new TypeError("Python runtime mount must be an absolute top-level canonical path");
1226
+ const environment = createPythonPackageEnvironment({
1227
+ ...options.provisioning,
1228
+ requirements: [...options.provisioning?.requirements ?? [], ...options.packages ?? []],
1229
+ requirementFiles: [...options.provisioning?.requirementFiles ?? [], ...options.requirements ?? []],
1230
+ ...options.packageProfile ? { profile: options.packageProfile } : {}
1231
+ });
1232
+ const execute = async (context) => {
1233
+ let installation;
1234
+ try {
1235
+ parsePythonInvocation(context.args, context.env);
1236
+ installation = parsePythonInstallation(context.args);
1237
+ } catch (error) {
1238
+ if (!(error instanceof PythonInvocationError)) throw error;
1239
+ await writeBytes(context.stderr, new TextEncoder().encode("python: " + error.message + "\n"), context.signal);
1240
+ return { exitCode: 2 };
1241
+ }
1242
+ if (installation?.help) {
1243
+ await writeBytes(context.stdout, new TextEncoder().encode(pythonInstallationHelp), context.signal);
1244
+ return { exitCode: 0 };
1245
+ }
1246
+ context.signal.throwIfAborted();
1247
+ if (activeWorkers >= maxConcurrentWorkers) {
1248
+ await writeBytes(context.stderr, new TextEncoder().encode("python: worker capacity exhausted\n"), context.signal);
1249
+ return { exitCode: 1 };
1250
+ }
1251
+ const controller = new AbortController();
1252
+ const signal = AbortSignal.any([context.signal, controller.signal]);
1253
+ inheritYieldCheckpoint(context.signal, signal);
1254
+ const fileContext = { ...context, descriptorCleanup: "caller" };
1255
+ const metadata = new PythonStatTranslator();
1256
+ const service = new PythonFileSystem(context.fs, {
1257
+ cwd: context.cwd,
1258
+ signal,
1259
+ maxTransferBytes,
1260
+ maxOpenFiles,
1261
+ open: (path, settings) => openCommandFile(fileContext, path, settings)
1262
+ });
1263
+ let stdoutOperation;
1264
+ let stderrOperation;
1265
+ let endpoint;
1266
+ let packages;
1267
+ let unsubscribe;
1268
+ let admitted = false;
1269
+ let closed = false;
1270
+ let closing;
1271
+ const pending = /* @__PURE__ */ new Set();
1272
+ const input = readBytes(context.stdin, signal)[Symbol.asyncIterator]();
1273
+ let fragment;
1274
+ let offset = 0;
1275
+ let inputBytes = 0;
1276
+ let rejectRun;
1277
+ const close = () => {
1278
+ if (closing) return closing;
1279
+ let finish;
1280
+ let fail;
1281
+ closing = new Promise((resolve, reject) => {
1282
+ finish = resolve;
1283
+ fail = reject;
1284
+ });
1285
+ closed = true;
1286
+ controller.abort(new Error("Python invocation retired"));
1287
+ void (async () => {
1288
+ signal.removeEventListener("abort", aborted);
1289
+ const subscription = Promise.resolve().then(() => unsubscribe?.());
1290
+ const termination = Promise.resolve().then(() => endpoint?.terminate());
1291
+ const results = await Promise.allSettled([subscription, termination, service.close(), stdoutOperation?.close(), stderrOperation?.close(), ...pending]);
1292
+ await input.return?.(void 0);
1293
+ fragment = void 0;
1294
+ if (packages) environment.finish(packages);
1295
+ for (const result2 of results) if (result2.status === "rejected") throw result2.reason;
1296
+ })().then(() => {
1297
+ if (admitted) {
1298
+ activeWorkers--;
1299
+ admitted = false;
1300
+ }
1301
+ finish();
1302
+ }, (reason) => {
1303
+ fail(reason);
1304
+ });
1305
+ return closing;
1306
+ };
1307
+ const aborted = () => {
1308
+ rejectRun?.(signal.reason);
1309
+ };
1310
+ context.registerCleanup?.(close);
1311
+ let primary;
1312
+ let result = 1;
1313
+ try {
1314
+ signal.throwIfAborted();
1315
+ activeWorkers++;
1316
+ admitted = true;
1317
+ const outputContext = { signal, ...context.registerCleanup ? { registerCleanup: context.registerCleanup } : {} };
1318
+ stdoutOperation = createOutputOperation(outputContext, context.stdout);
1319
+ stderrOperation = createOutputOperation(outputContext, context.stderr);
1320
+ if (typeof SharedArrayBuffer !== "function") throw new Error("Python worker filesystem requires SharedArrayBuffer");
1321
+ const shared = new SharedArrayBuffer(8 + maxTransferBytes * 6 + 65536);
1322
+ const control = new Int32Array(shared, 0, 2);
1323
+ const payload = new Uint8Array(shared, 8);
1324
+ const reply = (value, status) => {
1325
+ if (closed) return;
1326
+ let bytes;
1327
+ try {
1328
+ bytes = encodePythonReply(value, payload.length);
1329
+ } catch (error) {
1330
+ if (typeof error !== "object" || error === null || !("code" in error) || error.code !== "EFBIG") throw error;
1331
+ bytes = encodePythonReply({ code: "EFBIG" }, payload.length);
1332
+ status = 2;
1333
+ }
1334
+ payload.set(bytes);
1335
+ Atomics.store(control, 1, bytes.length);
1336
+ Atomics.store(control, 0, status);
1337
+ Atomics.notify(control, 0);
1338
+ };
1339
+ const dispatch = async (request) => {
1340
+ signal.throwIfAborted();
1341
+ if (request.op.startsWith("package-")) return environment.dispatch(request.op, request.args, { fs: context.fs, cwd: context.cwd, signal });
1342
+ if (request.op === "stdin") {
1343
+ const length = request.args[0];
1344
+ if (!Number.isSafeInteger(length) || length < 1 || length > maxTransferBytes) throw new RangeError("Invalid Python input request");
1345
+ let pulls = 0;
1346
+ while (!fragment || offset === fragment.length) {
1347
+ if (++pulls % 128 === 0) await yieldTurn(signal);
1348
+ const next = await input.next();
1349
+ if (next.done) return [];
1350
+ inputBytes += next.value.length;
1351
+ context.inputBudget?.check(inputBytes);
1352
+ if (next.value.length > maxInputChunkBytes) throw new PythonInputChunkError("Python input chunk exceeds maxInputChunkBytes");
1353
+ fragment = Uint8Array.from(next.value);
1354
+ offset = 0;
1355
+ }
1356
+ const end = Math.min(fragment.length, offset + length);
1357
+ const bytes = Array.from(fragment.subarray(offset, end));
1358
+ offset = end;
1359
+ return bytes;
1360
+ }
1361
+ if (request.op === "stdout" || request.op === "stderr") {
1362
+ const bytes = request.args[0];
1363
+ if (!Array.isArray(bytes) || bytes.length > maxTransferBytes || bytes.some((value2) => !Number.isInteger(value2) || value2 < 0 || value2 > 255)) throw new TypeError("Invalid Python output bytes");
1364
+ const operation = request.op === "stdout" ? stdoutOperation : stderrOperation;
1365
+ await writeBytes(operation.output, Uint8Array.from(bytes), signal);
1366
+ return bytes.length;
1367
+ }
1368
+ const value = await service.dispatch(request);
1369
+ return request.op === "stat" || request.op === "lstat" || request.op === "fstat" ? metadata.translate(value) : value;
1370
+ };
1371
+ options.onProgress?.({ phase: "initializing", command: context.command });
1372
+ const preparation = environment.prepare({
1373
+ fs: context.fs,
1374
+ cwd: context.cwd,
1375
+ signal,
1376
+ ...installation ? { requirements: installation.packages, requirementFiles: installation.requirements } : {}
1377
+ }).then((value) => {
1378
+ packages = value;
1379
+ });
1380
+ pending.add(preparation);
1381
+ try {
1382
+ await preparation;
1383
+ } finally {
1384
+ pending.delete(preparation);
1385
+ }
1386
+ signal.throwIfAborted();
1387
+ endpoint = options.createWorker();
1388
+ signal.throwIfAborted();
1389
+ result = await new Promise((resolve, reject) => {
1390
+ let settled = false;
1391
+ const fail = (reason) => {
1392
+ settled = true;
1393
+ reject(reason);
1394
+ };
1395
+ rejectRun = fail;
1396
+ signal.addEventListener("abort", aborted, { once: true });
1397
+ unsubscribe = endpoint.subscribe((value) => {
1398
+ if (closed || settled) return;
1399
+ if (typeof value !== "object" || value === null) {
1400
+ fail(new TypeError("Invalid Python worker message"));
1401
+ return;
1402
+ }
1403
+ const message = value;
1404
+ if (message.type === "ready") {
1405
+ try {
1406
+ options.onProgress?.({ phase: "ready", command: context.command });
1407
+ } catch (error) {
1408
+ fail(error);
1409
+ }
1410
+ return;
1411
+ }
1412
+ if (message.type === "exit") {
1413
+ if (pending.size) {
1414
+ fail(new TypeError("Python worker exited with an outstanding request"));
1415
+ return;
1416
+ }
1417
+ try {
1418
+ const status = validateExitCode(message.exitCode);
1419
+ settled = true;
1420
+ resolve(status);
1421
+ } catch (error) {
1422
+ fail(error);
1423
+ }
1424
+ return;
1425
+ }
1426
+ if (message.type === "error") {
1427
+ settled = true;
1428
+ const diagnostic = "python: " + (typeof message.message === "string" ? message.message : "Python worker failed") + "\n";
1429
+ const work2 = writeBytes(stderrOperation.output, new TextEncoder().encode(diagnostic), signal).then(
1430
+ () => {
1431
+ pending.delete(work2);
1432
+ resolve(1);
1433
+ },
1434
+ (error) => {
1435
+ pending.delete(work2);
1436
+ reject(error);
1437
+ }
1438
+ );
1439
+ pending.add(work2);
1440
+ return;
1441
+ }
1442
+ if (typeof message.op !== "string" || !Array.isArray(message.args) || pending.size) {
1443
+ fail(new TypeError("Invalid concurrent Python worker request"));
1444
+ return;
1445
+ }
1446
+ const work = dispatch({ op: message.op, args: message.args }).then(
1447
+ (value2) => {
1448
+ pending.delete(work);
1449
+ reply(value2, 1);
1450
+ },
1451
+ (error) => {
1452
+ pending.delete(work);
1453
+ if (signal.aborted) {
1454
+ fail(signal.reason);
1455
+ return;
1456
+ }
1457
+ if (typeof message.op === "string" && message.op.startsWith("package-")) {
1458
+ reply({ code: "EPACKAGE", message: error instanceof Error ? error.message : String(error) }, 2);
1459
+ return;
1460
+ }
1461
+ if (typeof error !== "object" || error === null || !("code" in error) || typeof error.code !== "string") {
1462
+ fail(error);
1463
+ return;
1464
+ }
1465
+ reply({ code: error.code }, 2);
1466
+ }
1467
+ );
1468
+ pending.add(work);
1469
+ void work.catch(fail);
1470
+ }, fail);
1471
+ if (settled) return;
1472
+ const start = { type: "start", shared, invocation: { args: [...context.args], cwd: context.cwd, env: { ...context.env } }, runtimeMount, maxTransferBytes, ...packages ? { packages } : {}, installOnly: !!installation };
1473
+ signal.throwIfAborted();
1474
+ endpoint.postMessage(start);
1475
+ });
1476
+ } catch (reason) {
1477
+ if (!signal.aborted && (reason instanceof PythonInputChunkError || reason instanceof Error && "code" in reason && reason.code === "EPACKAGE")) {
1478
+ try {
1479
+ await writeBytes(stderrOperation.output, new TextEncoder().encode("python: " + reason.message + "\n"), signal);
1480
+ } catch (error) {
1481
+ primary = { reason: error };
1482
+ }
1483
+ } else primary = { reason };
1484
+ }
1485
+ try {
1486
+ await close();
1487
+ } catch (reason) {
1488
+ primary ??= { reason };
1489
+ }
1490
+ try {
1491
+ options.onProgress?.({ phase: "finished", command: context.command });
1492
+ } catch (reason) {
1493
+ primary ??= { reason };
1494
+ }
1495
+ context.signal.throwIfAborted();
1496
+ if (primary) throw primary.reason;
1497
+ return { exitCode: result };
1498
+ };
1499
+ return ["python", "python3"].map((name) => ({ name, description: "Python with an explicit synchronous interpreter worker and canonical filesystem", execute }));
1500
+ }
1501
+ function pythonCommands(options) {
1502
+ const commands = createPythonCommands(options);
1503
+ return { name: "python-commands", setup(host) {
1504
+ if (!options.replace) {
1505
+ for (const command of commands) if (host.commands.has(command.name)) throw new Error(`Command already registered: ${command.name}`);
1506
+ }
1507
+ for (const command of commands) host.commands.register(command, { replace: options.replace ?? false });
1508
+ } };
1509
+ }
1510
+
1511
+ export {
1512
+ clean,
1513
+ rotl,
1514
+ bytesToHex,
1515
+ createHasher,
1516
+ Chi,
1517
+ Maj,
1518
+ HashMD,
1519
+ sha256,
1520
+ sha224,
1521
+ sha512,
1522
+ sha384,
1523
+ pythonDocumentPackages,
1524
+ createPythonPackageEnvironment,
1525
+ createPythonCommands,
1526
+ pythonCommands
1527
+ };
1528
+ //# sourceMappingURL=chunk-GPV7ZFYS.js.map