@poe-platform/safe-bash 0.1.822 → 0.1.824

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 (291) hide show
  1. package/dist/safe-bash/chunks/{chunk-HNT2MR4W.js → chunk-363QOIDR.js} +2 -1
  2. package/dist/safe-bash/chunks/chunk-AGHV53VF.js +42 -0
  3. package/dist/safe-bash/chunks/{chunk-VF3Q2V3E.js → chunk-RAFD5ZAH.js} +1 -1
  4. package/dist/safe-bash/chunks/{chunk-67QE3JLU.js → chunk-TZRVK3NU.js} +1 -1
  5. package/dist/safe-bash/chunks/{chunk-IRJS54AA.js → chunk-VWLQDZFF.js} +20 -12
  6. package/dist/safe-bash/chunks/{chunk-NAETSXBW.js → chunk-ZJAXMB5M.js} +1 -1
  7. package/dist/safe-bash/command-chunks/{chunk-LDR3PPM3.js → chunk-22QEL76N.js} +3 -3
  8. package/dist/safe-bash/command-chunks/{chunk-QX3WKBLI.js → chunk-36FV6BAG.js} +5 -3
  9. package/dist/safe-bash/command-chunks/{chunk-BSLXS4PE.js → chunk-3DH5QBZC.js} +1 -1
  10. package/dist/safe-bash/command-chunks/{chunk-ZSHXZ3XG.js → chunk-3EAZRKI4.js} +7 -7
  11. package/dist/safe-bash/command-chunks/{chunk-5EFNQ6FY.js → chunk-3EBQOZET.js} +216 -1
  12. package/dist/safe-bash/command-chunks/{chunk-KQE2D7PX.js → chunk-3HUCLYKJ.js} +2 -2
  13. package/dist/safe-bash/command-chunks/{chunk-J4I7KCQQ.js → chunk-4JABZEDO.js} +4 -4
  14. package/dist/safe-bash/command-chunks/{chunk-PVKSBXHB.js → chunk-4M6D4IUB.js} +4 -4
  15. package/dist/safe-bash/command-chunks/{chunk-UVM6QG2H.js → chunk-4MVQE6CT.js} +1 -1
  16. package/dist/safe-bash/command-chunks/{chunk-QWQHLMDX.js → chunk-4VTB4DGE.js} +3 -3
  17. package/dist/safe-bash/command-chunks/{chunk-JQPDVCBU.js → chunk-565AAQTV.js} +3 -3
  18. package/dist/safe-bash/command-chunks/{chunk-JSW6YH6T.js → chunk-5PRXCH54.js} +5 -5
  19. package/dist/safe-bash/command-chunks/{chunk-42OQIFPW.js → chunk-5RLK2QSY.js} +3 -3
  20. package/dist/safe-bash/command-chunks/{chunk-PYYAX5FB.js → chunk-63WEGFLL.js} +16 -16
  21. package/dist/safe-bash/command-chunks/{chunk-5QR4LTAK.js → chunk-6KZXFPOT.js} +6 -6
  22. package/dist/safe-bash/command-chunks/{chunk-LJLB7TBN.js → chunk-6YTXU3NF.js} +6 -6
  23. package/dist/safe-bash/command-chunks/{chunk-NNYOPI7K.js → chunk-7NF44M2V.js} +5 -5
  24. package/dist/safe-bash/command-chunks/{chunk-ZRHKXN6W.js → chunk-7RQGRFHJ.js} +2 -2
  25. package/dist/safe-bash/command-chunks/{chunk-QGSY4ZAU.js → chunk-7UYBNOOM.js} +2 -2
  26. package/dist/safe-bash/command-chunks/{chunk-WOT2YXBT.js → chunk-7ZQVMPSB.js} +213 -42
  27. package/dist/safe-bash/command-chunks/{chunk-6REH56FL.js → chunk-AA254KE5.js} +4 -4
  28. package/dist/safe-bash/command-chunks/{chunk-2VSNIHIW.js → chunk-APUXNXXQ.js} +11 -11
  29. package/dist/safe-bash/command-chunks/{chunk-4VHCA4KK.js → chunk-AVSINNZ6.js} +80 -3
  30. package/dist/safe-bash/command-chunks/{chunk-XE75H5ZZ.js → chunk-AVXSR5MO.js} +6 -6
  31. package/dist/safe-bash/command-chunks/{chunk-22D6Q6SW.js → chunk-BKCVCMUX.js} +2 -2
  32. package/dist/safe-bash/command-chunks/{chunk-UDRJKA3P.js → chunk-C23L4HZB.js} +2 -2
  33. package/dist/safe-bash/command-chunks/{chunk-PAEAEFK3.js → chunk-C3EEMMQL.js} +3 -3
  34. package/dist/safe-bash/command-chunks/{chunk-NDJPULBE.js → chunk-CEKBIZGU.js} +2 -2
  35. package/dist/safe-bash/command-chunks/{chunk-75OUKYCM.js → chunk-CH5JDE3C.js} +1 -1
  36. package/dist/safe-bash/command-chunks/{chunk-XNVL6AOV.js → chunk-CIYGC7WU.js} +6 -6
  37. package/dist/safe-bash/command-chunks/{chunk-RUXY7GN5.js → chunk-CMJBRGU2.js} +1 -1
  38. package/dist/safe-bash/command-chunks/{chunk-DGFMOT4O.js → chunk-CO4HYNPS.js} +1 -1
  39. package/dist/safe-bash/command-chunks/{chunk-TMJG745A.js → chunk-CQLZM75U.js} +3 -3
  40. package/dist/safe-bash/command-chunks/{chunk-T2LZWXWF.js → chunk-DBCTHLB5.js} +4 -4
  41. package/dist/safe-bash/command-chunks/{chunk-6RE4MZYM.js → chunk-DBEJMI7J.js} +1 -1
  42. package/dist/safe-bash/command-chunks/{chunk-XXUMECE4.js → chunk-DEEZYCOQ.js} +6 -6
  43. package/dist/safe-bash/command-chunks/{chunk-YJMS5Q4Y.js → chunk-DHTTI7CE.js} +8 -8
  44. package/dist/safe-bash/command-chunks/{chunk-D3WMD32B.js → chunk-DLLGOC4Q.js} +6 -6
  45. package/dist/safe-bash/command-chunks/{chunk-HVLF3Y4B.js → chunk-DYCYAIET.js} +5 -5
  46. package/dist/safe-bash/command-chunks/{chunk-BZLLQWRK.js → chunk-E5CDHXFA.js} +2 -2
  47. package/dist/safe-bash/command-chunks/{chunk-5NC2IQMQ.js → chunk-EV7A5FNN.js} +1 -1
  48. package/dist/safe-bash/command-chunks/{chunk-MCUDSE4H.js → chunk-EWECMOQ5.js} +1 -1
  49. package/dist/safe-bash/command-chunks/{chunk-2YC6MWQB.js → chunk-EY3UE26F.js} +1 -1
  50. package/dist/safe-bash/command-chunks/{chunk-ZQ4NQ24M.js → chunk-FJLVISSD.js} +4 -4
  51. package/dist/safe-bash/command-chunks/{chunk-WOO3YO2X.js → chunk-HTMGN3KL.js} +4 -4
  52. package/dist/safe-bash/command-chunks/{chunk-2E53ZL5D.js → chunk-HU72CZBN.js} +4 -4
  53. package/dist/safe-bash/command-chunks/{chunk-AH3ZEPAN.js → chunk-IGHFIRXK.js} +1 -1
  54. package/dist/safe-bash/command-chunks/{chunk-R4NPYXQX.js → chunk-IKBTII7C.js} +285 -70
  55. package/dist/safe-bash/command-chunks/{chunk-J3ISXTYB.js → chunk-JTEAYB72.js} +2 -2
  56. package/dist/safe-bash/command-chunks/{chunk-NR7POLKP.js → chunk-KCS25XUJ.js} +2 -2
  57. package/dist/safe-bash/command-chunks/chunk-LKAFLJ5L.js +123 -0
  58. package/dist/safe-bash/command-chunks/{chunk-EU5SR3LS.js → chunk-LSH6UKCT.js} +2 -2
  59. package/dist/safe-bash/command-chunks/{chunk-WV3C6BRD.js → chunk-MHZ7UTRX.js} +5 -5
  60. package/dist/safe-bash/command-chunks/{chunk-K6J3KFQ2.js → chunk-MSA5BQFK.js} +3 -3
  61. package/dist/safe-bash/command-chunks/{chunk-OMD45J52.js → chunk-MW3L6JB7.js} +6 -6
  62. package/dist/safe-bash/command-chunks/{chunk-AR65HNNX.js → chunk-N2TN7IBE.js} +1 -1
  63. package/dist/safe-bash/command-chunks/chunk-NNGWTDVJ.js +2819 -0
  64. package/dist/safe-bash/command-chunks/{chunk-NWA7ZJDV.js → chunk-NU64GWGN.js} +3 -3
  65. package/dist/safe-bash/command-chunks/{chunk-4Q3HP33O.js → chunk-NW3S6T6R.js} +146 -123
  66. package/dist/safe-bash/command-chunks/chunk-NXCJNPL3.js +47 -0
  67. package/dist/safe-bash/command-chunks/{chunk-GAYTDZPP.js → chunk-ORWYNKKL.js} +3 -3
  68. package/dist/safe-bash/command-chunks/{chunk-FCGMSOF6.js → chunk-P6YTNXRV.js} +1 -1
  69. package/dist/safe-bash/command-chunks/{chunk-3RDEX4AF.js → chunk-PAS4YSNN.js} +1 -1
  70. package/dist/safe-bash/command-chunks/{chunk-RKAL5VFP.js → chunk-PLVFJ6FF.js} +255 -616
  71. package/dist/safe-bash/command-chunks/{chunk-TTPT3OME.js → chunk-PSNTCRL5.js} +4 -4
  72. package/dist/safe-bash/command-chunks/{chunk-CJIFJ45R.js → chunk-QBCEAYQT.js} +1 -1
  73. package/dist/safe-bash/command-chunks/{chunk-FGK6HLSY.js → chunk-QC2RWSYM.js} +3 -3
  74. package/dist/safe-bash/command-chunks/{chunk-HCZITM4C.js → chunk-QPY3NCMC.js} +5 -5
  75. package/dist/safe-bash/command-chunks/{chunk-3TXPZLFI.js → chunk-R6RVR6ZZ.js} +5 -5
  76. package/dist/safe-bash/command-chunks/{chunk-HQFX5XKV.js → chunk-RB7XAYO2.js} +3 -3
  77. package/dist/safe-bash/command-chunks/{chunk-6PDXNY3T.js → chunk-RF5VEKFU.js} +9 -9
  78. package/dist/safe-bash/command-chunks/{chunk-VAMBWXDV.js → chunk-RUAGHZNF.js} +18 -18
  79. package/dist/safe-bash/command-chunks/{chunk-3MFYCMQU.js → chunk-S2T7DDGY.js} +16 -16
  80. package/dist/safe-bash/command-chunks/{chunk-LZHFVNEV.js → chunk-S3QYSI5E.js} +1 -1
  81. package/dist/safe-bash/command-chunks/{chunk-ZLMCWAAU.js → chunk-STTXZKR6.js} +3 -3
  82. package/dist/safe-bash/command-chunks/{chunk-AXUHORS3.js → chunk-SUYSZJI3.js} +1 -1
  83. package/dist/safe-bash/command-chunks/{chunk-C5SLY3RB.js → chunk-U2C6A3QO.js} +1 -1
  84. package/dist/safe-bash/command-chunks/{chunk-HCJWEB6P.js → chunk-U6IEK2CI.js} +7 -7
  85. package/dist/safe-bash/command-chunks/{chunk-NN6OWOJG.js → chunk-UC6DUY3K.js} +2 -2
  86. package/dist/safe-bash/command-chunks/{chunk-64L57DEI.js → chunk-UQTU7H6T.js} +9 -9
  87. package/dist/safe-bash/command-chunks/{chunk-I7MEH76L.js → chunk-UYNJF5QN.js} +1 -1
  88. package/dist/safe-bash/command-chunks/{chunk-ARA57PMC.js → chunk-V5PVNBOS.js} +4 -4
  89. package/dist/safe-bash/command-chunks/{chunk-IAHYG67O.js → chunk-V5ZBRM5R.js} +3 -3
  90. package/dist/safe-bash/command-chunks/{chunk-ZZ6EIACJ.js → chunk-VGHRMAI4.js} +5 -5
  91. package/dist/safe-bash/command-chunks/{chunk-DZTT5SLG.js → chunk-VP7R7HKY.js} +5 -5
  92. package/dist/safe-bash/command-chunks/{chunk-TP5MZHCB.js → chunk-W5Y7Y7PS.js} +3 -3
  93. package/dist/safe-bash/command-chunks/{chunk-ZTW2E5OT.js → chunk-WAE3OCOU.js} +3 -3
  94. package/dist/safe-bash/command-chunks/{chunk-DBYY7IDI.js → chunk-WCM47S5A.js} +10 -10
  95. package/dist/safe-bash/command-chunks/{chunk-U6VSRO6E.js → chunk-WNVBS4GV.js} +4 -4
  96. package/dist/safe-bash/command-chunks/{chunk-CXOAMPOV.js → chunk-WUIS2INH.js} +13 -13
  97. package/dist/safe-bash/command-chunks/{chunk-4HJEZGYN.js → chunk-YODHIRPW.js} +7 -7
  98. package/dist/safe-bash/command-chunks/{chunk-C3FERGHU.js → chunk-YRMTOLG5.js} +3 -3
  99. package/dist/safe-bash/command-chunks/{chunk-GQV5RWMN.js → chunk-ZFXHSFTU.js} +1 -1
  100. package/dist/safe-bash/command-chunks/{chunk-YXIJOYT6.js → chunk-ZUOCXDYW.js} +1 -1
  101. package/dist/safe-bash/command-chunks/{chunk-LBBJ5S3W.js → chunk-ZZKJPLIH.js} +1 -1
  102. package/dist/safe-bash/command-chunks/{engine-UPLVIV72-IGXUDNO5.js → engine-UPLVIV72-MSSFJLK4.js} +1 -1
  103. package/dist/safe-bash/command-chunks/{prompt-tool-debug-ERJKK3XZ.js → prompt-tool-debug-3POFNRYP.js} +5 -5
  104. package/dist/safe-bash/commands/bc/index.browser.js +1 -1
  105. package/dist/safe-bash/commands/llm/index.browser.js +3 -1
  106. package/dist/safe-bash/commands/llm/index.js +1 -1
  107. package/dist/safe-bash/commands/python/executor.browser.js +12 -1
  108. package/dist/safe-bash/commands/python/executor.js +1 -1
  109. package/dist/safe-bash/commands/python/index.browser.js +23 -1
  110. package/dist/safe-bash/commands/python/index.js +1 -1
  111. package/dist/safe-bash/commands/python/source-archive.d.ts +2 -0
  112. package/dist/safe-bash/commands/python/source-archive.js +2 -0
  113. package/dist/safe-bash/commands/python/source-zip.d.ts +2 -0
  114. package/dist/safe-bash/commands/python/source-zip.js +2 -0
  115. package/dist/safe-bash/core.browser.js +2 -2
  116. package/dist/safe-bash/full-core.browser.js +30 -6
  117. package/dist/safe-bash/plugins/index.browser.js +3 -3
  118. package/dist/safe-bash/registry-entry.browser.js +2 -2
  119. package/dist/safe-bash/search.browser.js +1 -1
  120. package/dist/safe-bash/shell/runtime.d.ts +2 -2
  121. package/dist/safe-bash/shell/runtime.js +11 -2
  122. package/dist/safe-bash/shell/sync-extra-evaluators.js +12 -12
  123. package/dist/safe-bash/shell-entry.browser.js +2 -2
  124. package/dist/safe-bash-command-exiftool/index.js +41 -0
  125. package/dist/safe-bash-command-git/git_rust.wasm +0 -0
  126. package/dist/safe-bash-command-llm/collections.js +24 -65
  127. package/dist/safe-bash-command-llm/command.js +6 -6
  128. package/dist/safe-bash-command-llm/fragment-loaders.d.ts +3 -2
  129. package/dist/safe-bash-command-llm/index.d.ts +3 -2
  130. package/dist/safe-bash-command-llm/index.js +10 -8
  131. package/dist/safe-bash-command-llm/loader-provider.d.ts +25 -0
  132. package/dist/safe-bash-command-llm/openai-sse.js +2 -2
  133. package/dist/safe-bash-command-llm/openai.js +4 -4
  134. package/dist/safe-bash-command-llm/providers/index.js +4 -4
  135. package/dist/safe-bash-command-llm/providers/openai.js +4 -4
  136. package/dist/safe-bash-command-llm/python-unicode.d.ts +2 -0
  137. package/dist/safe-bash-command-llm/templates.d.ts +7 -2
  138. package/dist/safe-bash-command-llm/types.d.ts +7 -1
  139. package/dist/safe-bash-command-mcp/index.browser.js +3 -0
  140. package/dist/safe-bash-command-mcp/index.js +3 -0
  141. package/dist/safe-bash-command-playwright-cli/index.js +36 -36
  142. package/dist/safe-bash-command-playwright-cli/playwright/abilities.js +7 -7
  143. package/dist/safe-bash-command-playwright-cli/playwright/adapter.js +3 -3
  144. package/dist/safe-bash-command-playwright-cli/playwright/capability-events.js +1 -1
  145. package/dist/safe-bash-command-playwright-cli/playwright/capability-result.js +1 -1
  146. package/dist/safe-bash-command-playwright-cli/playwright/controller.js +15 -15
  147. package/dist/safe-bash-command-playwright-cli/playwright/download-capabilities.js +1 -1
  148. package/dist/safe-bash-command-playwright-cli/playwright/drop-capability.js +1 -1
  149. package/dist/safe-bash-command-playwright-cli/playwright/index.js +35 -35
  150. package/dist/safe-bash-command-playwright-cli/playwright/modal-capabilities.js +1 -1
  151. package/dist/safe-bash-command-playwright-cli/playwright/native-evaluation.js +1 -1
  152. package/dist/safe-bash-command-playwright-cli/playwright/native-json-snapshot.js +1 -1
  153. package/dist/safe-bash-command-playwright-cli/playwright/native-snapshot.js +1 -1
  154. package/dist/safe-bash-command-playwright-cli/playwright/native-storage-replacement.js +2 -2
  155. package/dist/safe-bash-command-playwright-cli/playwright/profile.js +3 -3
  156. package/dist/safe-bash-command-playwright-cli/playwright/recording-capabilities.js +1 -1
  157. package/dist/safe-bash-command-playwright-cli/playwright/route-capabilities.js +1 -1
  158. package/dist/safe-bash-command-playwright-cli/playwright/snapshot.js +1 -1
  159. package/dist/safe-bash-command-playwright-cli/playwright/standard-capabilities.js +6 -6
  160. package/dist/safe-bash-command-playwright-cli/playwright/storage-capabilities.js +5 -5
  161. package/dist/safe-bash-command-playwright-cli/playwright/tracing-capabilities.js +1 -1
  162. package/dist/safe-bash-command-playwright-cli/playwright/webmcp-capabilities.js +1 -1
  163. package/dist/safe-bash-command-python/build-backend.d.ts +93 -0
  164. package/dist/safe-bash-command-python/build-dependencies.d.ts +13 -0
  165. package/dist/safe-bash-command-python/build-environment.d.ts +3 -0
  166. package/dist/safe-bash-command-python/build-wheel.d.ts +8 -0
  167. package/dist/safe-bash-command-python/executor.d.ts +12 -2
  168. package/dist/safe-bash-command-python/executor.js +27 -4
  169. package/dist/safe-bash-command-python/index.js +27 -4
  170. package/dist/safe-bash-command-python/jspi.js +2 -2
  171. package/dist/safe-bash-command-python/llm-assets-node.js +1 -1
  172. package/dist/safe-bash-command-python/llm-fragment-loader.d.ts +6 -0
  173. package/dist/safe-bash-command-python/llm-functions-loader.d.ts +5 -1
  174. package/dist/safe-bash-command-python/llm-loader-discovery.d.ts +13 -0
  175. package/dist/safe-bash-command-python/llm-package-manager.d.ts +7 -0
  176. package/dist/safe-bash-command-python/llm-template-loader.d.ts +6 -0
  177. package/dist/safe-bash-command-python/manifest.d.ts +17 -0
  178. package/dist/safe-bash-command-python/provisioning.d.ts +37 -5
  179. package/dist/safe-bash-command-python/provisioning.js +2 -1
  180. package/dist/safe-bash-command-python/source-archive.d.ts +4 -0
  181. package/dist/safe-bash-command-python/source-archive.js +136 -0
  182. package/dist/safe-bash-command-python/source-environment.d.ts +12 -0
  183. package/dist/safe-bash-command-python/source-snapshot.d.ts +8 -0
  184. package/dist/safe-bash-command-python/source-zip.d.ts +8 -0
  185. package/dist/safe-bash-command-python/source-zip.js +8 -0
  186. package/dist/safe-bash-command-python/worker.js +3 -185
  187. package/dist/safe-bash-command-safejs/index.js +5 -5
  188. package/dist/safe-bash-command-safejs/runtime.js +3 -3
  189. package/dist/safe-bash-command-ssconvert/index.js +8 -8
  190. package/dist/safe-bash-compression-engine/bounded-codec.js +2 -2
  191. package/dist/safe-bash-compression-engine/codec-loader.js +1 -1
  192. package/dist/safe-bash-compression-engine/files.js +5 -5
  193. package/dist/safe-bash-compression-engine/index.js +4 -4
  194. package/dist/safe-bash-compression-engine/operand.js +5 -5
  195. package/dist/safe-bash-compression-engine/stream.js +4 -4
  196. package/dist/safe-bash-compression-engine/zstd-decode.js +3 -3
  197. package/dist/safe-bash-csv-engine/index.js +1 -1
  198. package/dist/safe-bash-csv-engine/python-utf7.d.ts +18 -0
  199. package/dist/safe-bash-csv-engine/text-decoder.d.ts +1 -0
  200. package/dist/safe-bash-csv-engine/text-decoder.js +5 -3
  201. package/dist/safe-bash-presentation-engine/accessibility.js +15 -15
  202. package/dist/safe-bash-presentation-engine/animation-editing.js +5 -5
  203. package/dist/safe-bash-presentation-engine/animations.js +5 -5
  204. package/dist/safe-bash-presentation-engine/backgrounds.js +6 -6
  205. package/dist/safe-bash-presentation-engine/chart-editing.js +18 -18
  206. package/dist/safe-bash-presentation-engine/chart-object-operations.js +12 -12
  207. package/dist/safe-bash-presentation-engine/charts.js +15 -15
  208. package/dist/safe-bash-presentation-engine/command-placeholder.js +39 -39
  209. package/dist/safe-bash-presentation-engine/comments.js +6 -6
  210. package/dist/safe-bash-presentation-engine/connector-operations.js +16 -16
  211. package/dist/safe-bash-presentation-engine/connectors.js +13 -13
  212. package/dist/safe-bash-presentation-engine/diff.js +21 -21
  213. package/dist/safe-bash-presentation-engine/drawing-format.js +7 -7
  214. package/dist/safe-bash-presentation-engine/drawing-operations.js +15 -15
  215. package/dist/safe-bash-presentation-engine/drawing-schema.js +8 -8
  216. package/dist/safe-bash-presentation-engine/equations.js +6 -6
  217. package/dist/safe-bash-presentation-engine/fields.js +6 -6
  218. package/dist/safe-bash-presentation-engine/image-extraction.js +7 -7
  219. package/dist/safe-bash-presentation-engine/image-formatting.js +16 -16
  220. package/dist/safe-bash-presentation-engine/image-insertion.js +6 -6
  221. package/dist/safe-bash-presentation-engine/image-replacement.js +7 -7
  222. package/dist/safe-bash-presentation-engine/images.js +6 -6
  223. package/dist/safe-bash-presentation-engine/index.js +104 -104
  224. package/dist/safe-bash-presentation-engine/layouts.js +5 -5
  225. package/dist/safe-bash-presentation-engine/links.js +5 -5
  226. package/dist/safe-bash-presentation-engine/masters.js +4 -4
  227. package/dist/safe-bash-presentation-engine/media-editing.js +13 -13
  228. package/dist/safe-bash-presentation-engine/media-extraction.js +7 -7
  229. package/dist/safe-bash-presentation-engine/media.js +6 -6
  230. package/dist/safe-bash-presentation-engine/memberships.js +5 -5
  231. package/dist/safe-bash-presentation-engine/notes.js +6 -6
  232. package/dist/safe-bash-presentation-engine/ole-insertion.js +6 -6
  233. package/dist/safe-bash-presentation-engine/opaque-objects.js +2 -2
  234. package/dist/safe-bash-presentation-engine/package-tools.js +6 -6
  235. package/dist/safe-bash-presentation-engine/presentation-model.js +38 -38
  236. package/dist/safe-bash-presentation-engine/presentation-settings.js +5 -5
  237. package/dist/safe-bash-presentation-engine/properties.js +6 -6
  238. package/dist/safe-bash-presentation-engine/retained-inspection.js +3 -3
  239. package/dist/safe-bash-presentation-engine/retained-text.js +16 -16
  240. package/dist/safe-bash-presentation-engine/sanitize.js +7 -7
  241. package/dist/safe-bash-presentation-engine/selectors.js +2 -2
  242. package/dist/safe-bash-presentation-engine/shape-groups.js +15 -15
  243. package/dist/safe-bash-presentation-engine/shape-operations.js +14 -14
  244. package/dist/safe-bash-presentation-engine/shape-path-operations.js +16 -16
  245. package/dist/safe-bash-presentation-engine/shape-paths.js +5 -5
  246. package/dist/safe-bash-presentation-engine/shape-selection.js +15 -15
  247. package/dist/safe-bash-presentation-engine/shape-transforms.js +5 -5
  248. package/dist/safe-bash-presentation-engine/shapes.js +11 -11
  249. package/dist/safe-bash-presentation-engine/slide-copy.js +7 -7
  250. package/dist/safe-bash-presentation-engine/slide-import.js +6 -6
  251. package/dist/safe-bash-presentation-engine/slide-merge-split.js +8 -8
  252. package/dist/safe-bash-presentation-engine/slide-model.js +25 -25
  253. package/dist/safe-bash-presentation-engine/slide-removal.js +7 -7
  254. package/dist/safe-bash-presentation-engine/slide-transfer-budget.js +2 -2
  255. package/dist/safe-bash-presentation-engine/slides.js +5 -5
  256. package/dist/safe-bash-presentation-engine/table-operations.js +17 -17
  257. package/dist/safe-bash-presentation-engine/table-spans.js +16 -16
  258. package/dist/safe-bash-presentation-engine/tables.js +15 -15
  259. package/dist/safe-bash-presentation-engine/tags.js +6 -6
  260. package/dist/safe-bash-presentation-engine/template-bindings.js +16 -16
  261. package/dist/safe-bash-presentation-engine/template-repeat.js +26 -26
  262. package/dist/safe-bash-presentation-engine/text-fitting.js +11 -11
  263. package/dist/safe-bash-presentation-engine/text-frames.js +11 -11
  264. package/dist/safe-bash-presentation-engine/text-paragraphs.js +11 -11
  265. package/dist/safe-bash-presentation-engine/text-reading.js +3 -3
  266. package/dist/safe-bash-presentation-engine/text-replacement.js +6 -6
  267. package/dist/safe-bash-presentation-engine/text-runs.js +8 -8
  268. package/dist/safe-bash-presentation-engine/themes.js +5 -5
  269. package/dist/safe-bash-presentation-engine/transitions.js +6 -6
  270. package/dist/safe-bash-presentation-engine/validation.js +2 -2
  271. package/dist/safe-bash-presentation-engine/xml-parts.js +5 -5
  272. package/dist/safe-bash-zip-engine/index.js +1 -1
  273. package/dist/safe-bash-zip-engine/zip/repair.js +1 -1
  274. package/dist/safe-bash-zip-engine/zip/sfx.js +1 -1
  275. package/dist/safe-bash-zip-engine/zip-format.d.ts +3 -1
  276. package/dist/safe-bash-zip-engine/zip-format.js +1 -1
  277. package/dist/safe-playwright-cloudflare/shell-browser-resource.d.ts +1 -1
  278. package/dist/safe-playwright-cloudflare/shell-browser-resource.js +35 -20
  279. package/package.json +13 -3
  280. package/dist/safe-bash/chunks/chunk-PSD2RSOS.js +0 -31
  281. package/dist/safe-bash/command-chunks/chunk-RHXV2KG5.js +0 -1466
  282. package/dist/safe-bash/command-chunks/{biff-AYJZR2YV-YFF3BK43.js → biff-AYJZR2YV-2BK47I2W.js} +1 -1
  283. package/dist/safe-bash/command-chunks/{chunk-SKDJCMGI.js → chunk-ATUZ7J3B.js} +3 -3
  284. package/dist/safe-bash/command-chunks/{chunk-4Q4R3VZU.js → chunk-ETFJ4L7F.js} +0 -0
  285. package/dist/safe-bash/command-chunks/{chunk-QWHBQBPB.js → chunk-EXDMIGZY.js} +6 -6
  286. package/dist/safe-bash/command-chunks/{chunk-SKF6PGA5.js → chunk-I2OKE2NI.js} +3 -3
  287. package/dist/safe-bash/command-chunks/{chunk-2H6RJPCQ.js → chunk-JDDZRKC4.js} +3 -3
  288. package/dist/safe-bash/command-chunks/{chunk-3TP4SSPS.js → chunk-SRXARACJ.js} +3 -3
  289. package/dist/safe-bash/command-chunks/{chunk-D54L2IOZ.js → chunk-Y7UXJ77P.js} +3 -3
  290. package/dist/safe-bash/command-chunks/{dif-BXKPQOCO-FVJYYGYB.js → dif-BXKPQOCO-4KB3RC6G.js} +4 -4
  291. package/dist/safe-bash/command-chunks/{sylk-25D7TL2Y-NJKBZZTF.js → sylk-25D7TL2Y-RU6ANKGT.js} +4 -4
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  openRetainedPresentationIndex
3
- } from "./chunk-LZHFVNEV.js";
3
+ } from "./chunk-S3QYSI5E.js";
4
4
  import {
5
5
  stageRetainedOutput,
6
6
  streamJson
@@ -13,14 +13,14 @@ import {
13
13
  loadShared,
14
14
  nextRel,
15
15
  relPart
16
- } from "./chunk-UDRJKA3P.js";
16
+ } from "./chunk-C23L4HZB.js";
17
17
  import {
18
18
  SelectionError,
19
19
  decodeSelectionToken
20
- } from "./chunk-SKF6PGA5.js";
20
+ } from "./chunk-I2OKE2NI.js";
21
21
  import {
22
22
  openRetainedPresentationValidation
23
- } from "./chunk-SKDJCMGI.js";
23
+ } from "./chunk-ATUZ7J3B.js";
24
24
  import {
25
25
  dialects
26
26
  } from "./chunk-P3LHQOX7.js";
@@ -10,7 +10,7 @@ import {
10
10
  } from "./chunk-DMOWQSKN.js";
11
11
  import {
12
12
  readPlaywrightStorageState
13
- } from "./chunk-3TP4SSPS.js";
13
+ } from "./chunk-SRXARACJ.js";
14
14
  import {
15
15
  parsePlaywrightStorageState
16
16
  } from "./chunk-YMZQFL3O.js";
@@ -1,9 +1,123 @@
1
+ import {
2
+ openPythonPackageFile
3
+ } from "./chunk-NXCJNPL3.js";
4
+
5
+ // packages/safe-bash-command-python/src/package-download.ts
6
+ import { FsError } from "../../safe-bash-contracts/index.js";
7
+ import { resolvePath } from "../../safe-bash-contracts/path.js";
8
+ import { interruptible } from "../../safe-bash-contracts/runtime-control.js";
9
+ import { yieldTurn } from "../../safe-bash-contracts/yield.js";
10
+ var serial = 0;
11
+ async function stagePythonPackage(context, directory, body, maxBytes, progress, verify, publish) {
12
+ const { fs, signal } = context, settings = { signal };
13
+ const caps = await fs.capabilitiesFor?.(directory, settings) ?? fs.capabilities;
14
+ if (!caps.retainedStagingWrite || !caps.retainedStagingCleanup || !caps.retainedRead || !fs.createStagedFile || !fs.openReadFile || publish && (!caps.atomicFileStaging || !fs.publishStagedFile)) return void 0;
15
+ const parent = await fs.stat(directory, settings);
16
+ let stage;
17
+ for (let attempt = 0; attempt < 16; attempt++) {
18
+ try {
19
+ stage = await fs.createStagedFile(resolvePath(directory, ".python-package-" + ++serial), "wheel", { type: "file", data: new Uint8Array(0) }, { parent, mode: 384, retainCleanup: true, signal });
20
+ break;
21
+ } catch (error) {
22
+ signal.throwIfAborted();
23
+ if (!(error instanceof FsError) || error.code !== "EEXIST") throw error;
24
+ }
25
+ }
26
+ if (!stage) throw new Error("Python package staging names exhausted");
27
+ const owner = stage;
28
+ let artifact;
29
+ let closing;
30
+ const close = () => closing ??= (async () => {
31
+ try {
32
+ await artifact?.close();
33
+ } finally {
34
+ try {
35
+ await owner.cleanup?.remove();
36
+ } finally {
37
+ await owner.cleanup?.close();
38
+ }
39
+ }
40
+ })();
41
+ try {
42
+ if (!owner.cleanup || !owner.writer) throw new Error("Python package staging handles missing");
43
+ let count = 0;
44
+ const iterator = body[Symbol.asyncIterator]();
45
+ let ended = false;
46
+ try {
47
+ while (true) {
48
+ const next = await interruptible(Promise.resolve().then(() => {
49
+ signal.throwIfAborted();
50
+ return iterator.next();
51
+ }), signal);
52
+ signal.throwIfAborted();
53
+ if (next.done) {
54
+ ended = true;
55
+ break;
56
+ }
57
+ const bytes = next.value;
58
+ if (!(bytes instanceof Uint8Array)) throw new TypeError("Python package body must yield bytes");
59
+ if (count + bytes.length > maxBytes) throw new Error("Package download exceeds maxDownloadBytes");
60
+ for (let offset = 0; offset < bytes.length; offset += 65536) {
61
+ const chunk = Uint8Array.from(bytes.subarray(offset, offset + 65536));
62
+ await owner.writer.write(chunk, settings);
63
+ count += chunk.length;
64
+ await yieldTurn(signal);
65
+ }
66
+ if (bytes.length) progress(count);
67
+ }
68
+ } finally {
69
+ if (!ended) {
70
+ const returned = Promise.resolve().then(() => iterator.return?.());
71
+ if (signal.aborted) void returned.catch(() => {
72
+ });
73
+ else await interruptible(returned, signal);
74
+ }
75
+ }
76
+ const stat = await owner.writer.finish(settings);
77
+ if (stat.size !== count) throw new Error("Python package staging size mismatch");
78
+ artifact = await openPythonPackageFile(context, owner.file.path, maxBytes, stat);
79
+ if (!artifact) throw new Error("Python package retained reads unavailable");
80
+ verify(artifact.key);
81
+ if (publish) {
82
+ const key = artifact.key, path = publish(key);
83
+ await artifact.close();
84
+ artifact = void 0;
85
+ let destination = null;
86
+ try {
87
+ destination = await fs.lstat(path, settings);
88
+ } catch (error) {
89
+ if (!(error instanceof FsError) || error.code !== "ENOENT") throw error;
90
+ }
91
+ await fs.publishStagedFile({ ...owner, file: { ...owner.file, stat } }, path, { parent, destination, signal });
92
+ artifact = await openPythonPackageFile(context, path, maxBytes);
93
+ if (!artifact || artifact.key !== key) throw new Error("Published Python package integrity mismatch");
94
+ }
95
+ return { ...artifact, close };
96
+ } catch (error) {
97
+ try {
98
+ await close();
99
+ } catch (cleanup) {
100
+ throw new AggregateError([error, cleanup], error instanceof Error ? error.message : "Python package download failed");
101
+ }
102
+ throw error;
103
+ }
104
+ }
105
+
1
106
  // packages/safe-bash-command-python/src/provisioning.ts
2
107
  import { sha256 } from "@noble/hashes/sha2.js";
3
108
  import { resolvePath as resolve, dirname } from "../../safe-bash-contracts/path.js";
4
109
  import { inheritYieldCheckpoint } from "../../safe-bash-contracts/yield.js";
5
110
 
6
111
  // packages/safe-bash-command-python/src/manifest.ts
112
+ function readPackageManifest(value) {
113
+ const strings = (values) => Array.isArray(values) && values.every((item) => typeof item === "string");
114
+ if (Array.isArray(value)) return strings(value) ? value : void 0;
115
+ if (!value || typeof value !== "object") return;
116
+ const record = value, version = record.version;
117
+ if (![1, 2, 3].includes(version) || Object.keys(value).length !== (version === 1 ? 2 : 3)) return;
118
+ if (version !== 1 && (!Array.isArray(record.records) || !record.records.every((row) => Array.isArray(row) && row.length === version + 3 && row.every((part, index) => index > 2 && index < 5 ? strings(part) : typeof part === "string" || index === 5 && part === null)))) return;
119
+ return strings(record.installed) ? record.installed : void 0;
120
+ }
7
121
  var PythonPackageConflictError = class extends Error {
8
122
  code = "EPACKAGECONFLICT";
9
123
  retryable = true;
@@ -117,6 +231,11 @@ var decoder = new TextDecoder();
117
231
  function digest(value) {
118
232
  return Array.from(sha256(value), (byte) => byte.toString(16).padStart(2, "0")).join("");
119
233
  }
234
+ function validDigest(value) {
235
+ if (typeof value !== "string" || value.length !== 64) return false;
236
+ for (const char of value) if (!"0123456789abcdef".includes(char)) return false;
237
+ return true;
238
+ }
120
239
  function failure(message, cause) {
121
240
  return Object.assign(new Error(message, { cause }), { code: "EPACKAGE" });
122
241
  }
@@ -140,35 +259,49 @@ function createPythonPackageEnvironment(options = {}) {
140
259
  const manifestKey = options.manifestStore ? pythonPackageRuntimeKey + "-environment-" + digest(encoder.encode(JSON.stringify(options.scope))) : pythonPackageRuntimeKey + "-environment";
141
260
  if (options.profile !== void 0 && options.profile !== "documents") throw new TypeError("Unknown Python package profile");
142
261
  const maxBytes = options.maxDownloadBytes ?? Infinity;
143
- if (options.maxDownloadBytes !== void 0 && (!Number.isSafeInteger(maxBytes) || maxBytes < 1)) throw new RangeError("maxDownloadBytes must be a positive integer");
144
262
  const maxManifestBytes = options.maxManifestBytes ?? Infinity;
145
263
  const maxMetadataBytes = options.maxMetadataBytes ?? Infinity;
146
- for (const name of ["maxManifestBytes", "maxMetadataBytes", "maxRequirementBytes"]) {
264
+ for (const name of ["maxDownloadBytes", "maxManifestBytes", "maxMetadataBytes", "maxRequirementBytes", "maxCacheBytes"]) {
147
265
  const value = options[name];
148
266
  if (value !== void 0 && (!Number.isSafeInteger(value) || value < 1)) throw new RangeError(`${name} must be a positive integer`);
149
267
  }
268
+ const cacheRecord = (key, headers, url) => {
269
+ const bytes = encoder.encode(JSON.stringify({ digest: key, headers, url }));
270
+ if (bytes.length > maxMetadataBytes) throw failure("Python package cache metadata exceeds maxMetadataBytes");
271
+ return bytes;
272
+ };
150
273
  const maxCacheBytes = options.maxCacheBytes;
151
- if (maxCacheBytes !== void 0 && (!Number.isSafeInteger(maxCacheBytes) || maxCacheBytes < 1)) throw new RangeError("maxCacheBytes must be a positive integer");
152
274
  const defaultCache = createPythonPackageCache(maxCacheBytes === void 0 ? {} : { maxBytes: maxCacheBytes });
153
275
  const sessions = /* @__PURE__ */ new Map();
154
276
  const controller = new AbortController();
155
277
  const pending = /* @__PURE__ */ new Set();
156
- let disposed = false;
157
- let disposing;
158
- const admit = (operation) => (...args) => {
159
- if (disposed) return Promise.reject(failure("Python package environment is disposed"));
160
- const work = Promise.resolve().then(() => {
161
- if (disposed) throw failure("Python package environment is disposed");
162
- return operation(...args);
163
- });
278
+ let cleanupFailure;
279
+ const track = (work, cleanup = false) => {
164
280
  pending.add(work);
165
- void work.then(() => {
166
- pending.delete(work);
167
- }, () => {
281
+ void work.then(() => pending.delete(work), (error) => {
282
+ if (cleanup) cleanupFailure ??= { error };
168
283
  pending.delete(work);
169
284
  });
170
285
  return work;
171
286
  };
287
+ function release(session, all = false) {
288
+ const artifacts = all ? [...session.retained.values()] : [];
289
+ if (all) session.retained.clear();
290
+ if (session.opened) {
291
+ artifacts.push(session.opened);
292
+ session.opened = void 0;
293
+ }
294
+ if (!artifacts.length) return session.retiring ?? Promise.resolve();
295
+ return track(session.retiring = Promise.allSettled([session.retiring, ...artifacts.map((artifact) => Promise.resolve().then(() => artifact.close?.()))]).then((results) => {
296
+ for (const result of results) if (result.status === "rejected") throw result.reason;
297
+ }), true);
298
+ }
299
+ let disposed = false;
300
+ let disposing;
301
+ const admit = (operation) => (...args) => track(Promise.resolve().then(() => {
302
+ if (disposed) throw failure("Python package environment is disposed");
303
+ return operation(...args);
304
+ }));
172
305
  let counter = 0;
173
306
  let committing = Promise.resolve();
174
307
  async function prepare(input) {
@@ -176,20 +309,20 @@ function createPythonPackageEnvironment(options = {}) {
176
309
  const signal = AbortSignal.any([input.signal, controller.signal, invocation.signal]);
177
310
  inheritYieldCheckpoint(input.signal, signal);
178
311
  const context = { ...input, signal };
179
- context.signal.throwIfAborted();
312
+ signal.throwIfAborted();
180
313
  const directory = options.cacheDirectory === void 0 ? void 0 : resolve(context.cwd, options.cacheDirectory, pythonPackageRuntimeKey);
181
314
  const cache = options.cache ?? (directory === void 0 ? defaultCache : {
182
315
  async get(key) {
183
316
  try {
184
- return await context.fs.readFile(resolve(directory, key), { signal: context.signal });
317
+ return await context.fs.readFile(resolve(directory, key), { signal });
185
318
  } catch (error) {
186
319
  if (missing(error)) return void 0;
187
320
  throw error;
188
321
  }
189
322
  },
190
323
  async set(key, bytes) {
191
- await context.fs.mkdir(directory, { recursive: true, signal: context.signal });
192
- await context.fs.writeFile(resolve(directory, key), bytes, { signal: context.signal });
324
+ await context.fs.mkdir(directory, { recursive: true, signal });
325
+ await context.fs.writeFile(resolve(directory, key), bytes, { signal });
193
326
  }
194
327
  });
195
328
  const manifestCache = options.cacheDirectory === void 0 ? defaultCache : cache;
@@ -198,15 +331,15 @@ function createPythonPackageEnvironment(options = {}) {
198
331
  try {
199
332
  snapshot = await options.manifestStore.get(manifestKey, context);
200
333
  } catch (error) {
201
- context.signal.throwIfAborted();
334
+ signal.throwIfAborted();
202
335
  throw failure("Cannot read Python package environment manifest", error);
203
336
  }
204
337
  }
205
- context.signal.throwIfAborted();
338
+ signal.throwIfAborted();
206
339
  if (snapshot !== void 0 && (typeof snapshot !== "object" || snapshot === null || typeof snapshot.revision !== "string" || !snapshot.revision || snapshot.revision.length > 1024 || !(snapshot.bytes instanceof Uint8Array))) throw failure("Invalid Python package manifest snapshot");
207
340
  const manifestRevision = snapshot?.revision;
208
341
  const stored = options.manifestStore ? snapshot?.bytes : await manifestCache.get(manifestKey);
209
- context.signal.throwIfAborted();
342
+ signal.throwIfAborted();
210
343
  if (stored && stored.length > maxManifestBytes) throw failure("Python package manifest exceeds maxManifestBytes");
211
344
  const manifest = stored === void 0 ? "" : decoder.decode(stored);
212
345
  let previous;
@@ -215,39 +348,47 @@ function createPythonPackageEnvironment(options = {}) {
215
348
  } catch {
216
349
  throw failure("Invalid Python package environment manifest");
217
350
  }
218
- if (!Array.isArray(previous) || previous.some((value) => typeof value !== "string")) throw failure("Invalid Python package environment manifest");
219
- const requirements = [...previous, ...options.profile === "documents" ? pythonDocumentPackages : [], ...options.requirements ?? [], ...context.requirements ?? []].map((value) => normalizeRequirement(value, context.cwd));
351
+ const saved = readPackageManifest(previous);
352
+ if (!saved) throw failure("Invalid Python package environment manifest");
353
+ const legacy = Array.isArray(previous);
354
+ const restore = saved.map((value) => normalizeRequirement(value, context.cwd));
355
+ const requirements = [...options.profile === "documents" ? pythonDocumentPackages : [], ...options.requirements ?? [], ...context.requirements ?? []].map((value) => normalizeRequirement(value, context.cwd));
220
356
  for (const file of [...options.requirementFiles ?? [], ...context.requirementFiles ?? []]) {
221
357
  const path = resolve(context.cwd, file);
222
358
  let source;
223
359
  try {
224
- source = decoder.decode(await context.fs.readFile(path, { signal: context.signal, ...options.maxRequirementBytes === void 0 ? {} : { maxBytes: options.maxRequirementBytes } }));
360
+ source = decoder.decode(await context.fs.readFile(path, { signal, ...options.maxRequirementBytes === void 0 ? {} : { maxBytes: options.maxRequirementBytes } }));
225
361
  } catch (error) {
226
- context.signal.throwIfAborted();
362
+ signal.throwIfAborted();
227
363
  throw failure(`Cannot read Python requirements ${path}: ${error instanceof Error ? error.message : String(error)}`);
228
364
  }
229
365
  for (const line of source.split("\n")) {
230
- const comment = line.split("").findIndex((character, index) => character === "#" && (index === 0 || line[index - 1].trim() === ""));
366
+ let comment = line.indexOf("#");
367
+ while (comment > 0 && line[comment - 1].trim()) comment = line.indexOf("#", comment + 1);
231
368
  const text = (comment < 0 ? line : line.slice(0, comment)).trim();
232
369
  if (!text) continue;
233
- if (text.endsWith("\\") || text.startsWith("-")) throw failure(`Unsupported requirements option or continuation in ${path}: ${text}`);
234
- requirements.push(normalizeRequirement(text, dirname(path)));
370
+ if (text.endsWith("\\")) throw failure(`Unsupported requirements continuation in ${path}: ${text}`);
371
+ requirements.push(text[0] === "-" && options.prepareRequirements ? text : normalizeRequirement(text, dirname(path)));
235
372
  }
236
373
  }
237
- context.signal.throwIfAborted();
374
+ if ((options.editable?.length || context.editable?.length) && !options.prepareRequirements) throw failure("Editable packages require a source package environment");
375
+ const requested = [...new Set(await options.prepareRequirements?.(requirements, context) ?? requirements)];
376
+ signal.throwIfAborted();
238
377
  const session = String(++counter);
239
- const unique = [...new Set(requirements)];
378
+ const unique = [.../* @__PURE__ */ new Set([...restore, ...requested])];
240
379
  const aborted = () => {
241
380
  const current = sessions.get(session);
242
381
  if (current) {
243
382
  current.closed = true;
244
- current.opened.clear();
383
+ void release(current, true);
245
384
  }
246
- sessions.delete(session);
247
385
  };
248
- sessions.set(session, { ...context, cache, manifestCache, manifestRevision, controller: invocation, offline: context.offline ?? options.offline ?? false, requirements: unique, opened: /* @__PURE__ */ new Map(), opening: false, closed: false, manifest, aborted });
249
- context.signal.addEventListener("abort", aborted, { once: true });
250
- return { session, requirements: unique, offline: context.offline ?? options.offline ?? false };
386
+ const offline = context.offline ?? options.offline ?? false;
387
+ sessions.set(session, { ...context, cacheDirectory: directory, noCache: context.noCache ?? options.noCache ?? false, cache, manifestCache, manifestRevision, controller: invocation, offline, requirements: unique, opening: false, retained: /* @__PURE__ */ new Map(), closed: false, manifest, aborted });
388
+ signal.addEventListener("abort", aborted, { once: true });
389
+ const controls = {};
390
+ for (const key of ["pre", "upgrade", "forceReinstall"]) if (context[key] ?? options[key]) controls[key] = true;
391
+ return { session, requirements: unique, restore, requested, legacy, records: previous.records, ...controls, ...input.uninstall ? { uninstall: input.uninstall } : {}, offline };
251
392
  }
252
393
  async function dispatch(op, args, _context) {
253
394
  _context.signal.throwIfAborted();
@@ -255,10 +396,13 @@ function createPythonPackageEnvironment(options = {}) {
255
396
  if (!session) throw failure("Python package session is closed");
256
397
  checkSession(session);
257
398
  if (op === "package-commit") {
399
+ await release(session, true);
400
+ checkSession(session);
258
401
  const pinned = args[1];
259
- if (!Array.isArray(pinned) || pinned.some((value) => typeof value !== "string")) throw failure("Invalid installed package manifest");
260
- const merged = [.../* @__PURE__ */ new Set([...session.requirements, ...pinned])];
261
- const manifestBytes = encoder.encode(JSON.stringify(merged));
402
+ const saved = readPackageManifest(pinned);
403
+ if (!saved) throw failure("Invalid installed package manifest");
404
+ const state = Array.isArray(pinned) ? [.../* @__PURE__ */ new Set([...session.requirements, ...saved])] : { ...pinned, installed: [...new Set(saved)] };
405
+ const manifestBytes = encoder.encode(JSON.stringify(state));
262
406
  if (manifestBytes.length > maxManifestBytes) throw failure("Python package manifest exceeds maxManifestBytes");
263
407
  const commit = committing.then(async () => {
264
408
  checkSession(session);
@@ -282,46 +426,88 @@ function createPythonPackageEnvironment(options = {}) {
282
426
  options.onProgress?.({ phase: "installed" });
283
427
  return null;
284
428
  }
285
- if (op === "package-read") {
286
- const bytes = session.opened.get(String(args[1]));
287
- const offset = args[2];
288
- const length = args[3];
289
- if (!bytes || !Number.isSafeInteger(offset) || !Number.isSafeInteger(length) || offset < 0 || length < 1 || length > 65536) throw failure("Invalid package chunk request");
290
- return Array.from(bytes.subarray(offset, offset + length));
429
+ if (op === "package-read" || op === "package-read-retained") {
430
+ const artifact = op === "package-read" ? session.opened : session.retained.get(String(args[1])), offset = args[2], length = args[3];
431
+ if (!artifact || op === "package-read" && artifact.key !== String(args[1]) || !Number.isSafeInteger(offset) || !Number.isSafeInteger(length) || offset < 0 || length < 1 || length > 65536) throw failure("Invalid package chunk request");
432
+ const bytes = await artifact.read(offset, length);
433
+ checkSession(session);
434
+ return Array.from(bytes);
435
+ }
436
+ if (op === "package-retain") {
437
+ const artifact = session.opened;
438
+ if (!artifact || artifact.key !== String(args[1])) throw failure("Invalid package retention request");
439
+ const token = String(++counter);
440
+ session.retained.set(token, artifact);
441
+ session.opened = void 0;
442
+ return { token, key: artifact.key, size: artifact.size };
291
443
  }
292
444
  if (op === "package-close") {
293
- session.opened.delete(String(args[1]));
445
+ if (session.opened?.key === String(args[1])) await release(session);
294
446
  return null;
295
447
  }
296
448
  if (op !== "package-open" || typeof args[1] !== "string") throw failure("Invalid package operation");
297
449
  if (session.opening) throw failure("Package download already in progress");
298
450
  session.opening = true;
299
- session.opened.clear();
300
451
  try {
301
- const url = args[1];
452
+ await release(session);
453
+ checkSession(session);
454
+ const url = args[1], { cacheDirectory, noCache } = session;
302
455
  const expected = args[2];
303
- 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");
456
+ let responseUrl = url;
457
+ const verifyIntegrity = (key2) => {
458
+ if (expected && key2 !== expected) throw failure(`Package integrity mismatch: ${url}`);
459
+ };
460
+ if (expected !== void 0 && expected !== null && !validDigest(expected)) throw failure("Invalid SHA-256 package integrity value");
304
461
  const address = pythonPackageRuntimeKey + "-url-" + digest(encoder.encode(url));
305
462
  const canonicalWheel = url.startsWith("file:") || url.startsWith("emfs:");
306
- const metadata = canonicalWheel ? void 0 : await session.cache.get(address);
463
+ const metadata = canonicalWheel || noCache || args[3] === "metadata" && !session.offline ? void 0 : await session.cache.get(address);
307
464
  checkSession(session);
308
- let bytes;
465
+ let key = "", bytes;
309
466
  let headers = [];
467
+ const adopt = async (artifact, ready) => {
468
+ session.opened = artifact;
469
+ try {
470
+ checkSession(session);
471
+ await ready();
472
+ checkSession(session);
473
+ return { key: artifact.key, size: artifact.size, headers, url: responseUrl };
474
+ } catch (error) {
475
+ await release(session);
476
+ throw error;
477
+ }
478
+ };
310
479
  if (metadata) {
311
480
  if (metadata.length > maxMetadataBytes) throw failure("Python package cache metadata exceeds maxMetadataBytes");
312
481
  let record;
313
482
  try {
314
483
  record = JSON.parse(decoder.decode(metadata));
315
484
  } catch {
316
- throw failure(`Invalid package cache metadata: ${url}`);
317
485
  }
318
- 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}`);
319
- bytes = await session.cache.get(pythonPackageRuntimeKey + "-sha256-" + record.digest);
486
+ if (typeof record !== "object" || record === null || !validDigest(record.digest) || record.url !== void 0 && typeof record.url !== "string" || !Array.isArray(record.headers) || record.headers.some((pair) => !Array.isArray(pair) || pair.length !== 2 || pair.some((value2) => typeof value2 !== "string"))) throw failure(`Invalid package cache metadata: ${url}`);
320
487
  headers = record.headers;
488
+ responseUrl = record.url ?? url;
489
+ let absent = false;
490
+ if (cacheDirectory) {
491
+ let artifact;
492
+ try {
493
+ artifact = await openPythonPackageFile(session, resolve(cacheDirectory, pythonPackageRuntimeKey + "-sha256-" + record.digest), maxBytes);
494
+ } catch (error) {
495
+ if (!missing(error)) throw error;
496
+ absent = true;
497
+ }
498
+ if (artifact) {
499
+ return await adopt(artifact, () => {
500
+ if (artifact.key !== record.digest) throw failure(`Package cache integrity mismatch: ${url}`);
501
+ verifyIntegrity(artifact.key);
502
+ options.onProgress?.({ phase: "cached", url, bytes: artifact.size });
503
+ });
504
+ }
505
+ }
506
+ bytes = absent ? void 0 : await session.cache.get(pythonPackageRuntimeKey + "-sha256-" + record.digest);
321
507
  checkSession(session);
322
508
  if (bytes && bytes.length > maxBytes) throw failure("Cached package exceeds maxDownloadBytes");
323
509
  if (bytes) bytes = Uint8Array.from(bytes);
324
- if (bytes && digest(bytes) !== record.digest) throw failure(`Package cache integrity mismatch: ${url}`);
510
+ if (bytes && (key = digest(bytes)) !== record.digest) throw failure(`Package cache integrity mismatch: ${url}`);
325
511
  if (bytes) options.onProgress?.({ phase: "cached", url, bytes: bytes.length });
326
512
  }
327
513
  if (!bytes) {
@@ -329,7 +515,11 @@ function createPythonPackageEnvironment(options = {}) {
329
515
  const path = new URL(url);
330
516
  if (path.host && path.host !== "localhost") throw failure("Local wheels must use the canonical filesystem");
331
517
  try {
332
- bytes = await session.fs.readFile(decodeURIComponent(path.pathname), { signal: session.signal, ...Number.isFinite(maxBytes) ? { maxBytes } : {} });
518
+ const artifact = await openPythonPackageFile(session, decodeURIComponent(path.pathname), maxBytes);
519
+ if (artifact) {
520
+ return await adopt(artifact, () => verifyIntegrity(artifact.key));
521
+ }
522
+ bytes = Uint8Array.from(await session.fs.readFile(decodeURIComponent(path.pathname), { signal: session.signal, ...Number.isFinite(maxBytes) ? { maxBytes } : {} }));
333
523
  } catch (error) {
334
524
  checkSession(session);
335
525
  throw failure(`Cannot read canonical Python wheel ${path.pathname}: ${error instanceof Error ? error.message : String(error)}`);
@@ -363,10 +553,34 @@ function createPythonPackageEnvironment(options = {}) {
363
553
  }
364
554
  if (response.status < 200 || response.status >= 300) throw failure(`Package download failed: HTTP ${response.status} ${current.href}`);
365
555
  headers = response.headers;
556
+ responseUrl = current.href;
366
557
  const encoding = headers.find(([key2]) => key2.toLowerCase() === "content-encoding")?.[1].trim().toLowerCase();
367
558
  const length = headers.find(([key2]) => key2.toLowerCase() === "content-length")?.[1];
368
559
  const total = length === void 0 || encoding !== void 0 && encoding !== "identity" ? void 0 : Number(length);
369
560
  if (total !== void 0 && Number.isFinite(total) && total > maxBytes) throw failure("Package download exceeds maxDownloadBytes");
561
+ const progress = (count2) => options.onProgress?.({ phase: "download", url, bytes: count2, ...typeof total === "number" && Number.isSafeInteger(total) ? { totalBytes: total } : {} });
562
+ if (cacheDirectory || noCache) {
563
+ const directory = cacheDirectory ?? session.cwd;
564
+ if (cacheDirectory) await session.fs.mkdir(directory, { recursive: true, signal: session.signal });
565
+ let metadataBytes;
566
+ const artifact = await stagePythonPackage(
567
+ session,
568
+ directory,
569
+ response.body,
570
+ maxBytes,
571
+ progress,
572
+ (key2) => {
573
+ verifyIntegrity(key2);
574
+ if (!noCache) metadataBytes = cacheRecord(key2, headers, responseUrl);
575
+ },
576
+ noCache ? void 0 : (key2) => resolve(directory, pythonPackageRuntimeKey + "-sha256-" + key2)
577
+ );
578
+ if (artifact) {
579
+ return await adopt(artifact, async () => {
580
+ if (!noCache) await session.cache.set(address, metadataBytes);
581
+ });
582
+ }
583
+ }
370
584
  const chunks = [];
371
585
  let count = 0;
372
586
  for await (const chunk of response.body) {
@@ -375,7 +589,7 @@ function createPythonPackageEnvironment(options = {}) {
375
589
  count += chunk.length;
376
590
  if (count > maxBytes) throw failure("Package download exceeds maxDownloadBytes");
377
591
  chunks.push(Uint8Array.from(chunk));
378
- options.onProgress?.({ phase: "download", url, bytes: count, ...typeof total === "number" && Number.isSafeInteger(total) ? { totalBytes: total } : {} });
592
+ progress(count);
379
593
  }
380
594
  bytes = new Uint8Array(count);
381
595
  let offset = 0;
@@ -390,20 +604,19 @@ function createPythonPackageEnvironment(options = {}) {
390
604
  }
391
605
  }
392
606
  checkSession(session);
393
- if (expected && digest(bytes) !== expected) throw failure(`Package integrity mismatch: ${url}`);
394
- const hash = digest(bytes);
395
- const metadataBytes = encoder.encode(JSON.stringify({ digest: hash, headers }));
396
- if (metadataBytes.length > maxMetadataBytes) throw failure("Python package cache metadata exceeds maxMetadataBytes");
397
- await session.cache.set(pythonPackageRuntimeKey + "-sha256-" + hash, Uint8Array.from(bytes));
398
- checkSession(session);
399
- if (!canonicalWheel) await session.cache.set(address, metadataBytes);
400
- checkSession(session);
607
+ verifyIntegrity(key = digest(bytes));
608
+ if (!noCache) {
609
+ const metadataBytes = cacheRecord(key, headers, responseUrl);
610
+ await session.cache.set(pythonPackageRuntimeKey + "-sha256-" + key, Uint8Array.from(bytes));
611
+ checkSession(session);
612
+ if (!canonicalWheel) await session.cache.set(address, metadataBytes);
613
+ }
401
614
  }
402
615
  checkSession(session);
403
- if (expected && digest(bytes) !== expected) throw failure(`Package integrity mismatch: ${url}`);
404
- const key = digest(bytes);
405
- session.opened.set(key, bytes);
406
- return { key, size: bytes.length, headers };
616
+ verifyIntegrity(key);
617
+ const value = bytes;
618
+ session.opened = { key, size: bytes.length, read: (offset, length) => value.subarray(offset, offset + length) };
619
+ return { key, size: bytes.length, headers, url: responseUrl };
407
620
  } finally {
408
621
  session.opening = false;
409
622
  }
@@ -415,11 +628,11 @@ function createPythonPackageEnvironment(options = {}) {
415
628
  const session = sessions.get(start.session);
416
629
  if (session) {
417
630
  session.closed = true;
418
- session.opened.clear();
419
631
  session.signal.removeEventListener("abort", session.aborted);
420
632
  session.controller.abort(failure("Python package session is closed"));
633
+ sessions.delete(start.session);
634
+ return release(session, true);
421
635
  }
422
- sessions.delete(start.session);
423
636
  },
424
637
  dispose() {
425
638
  if (!disposing) {
@@ -428,6 +641,7 @@ function createPythonPackageEnvironment(options = {}) {
428
641
  disposing = Promise.allSettled([...pending]).then(() => {
429
642
  sessions.clear();
430
643
  defaultCache.dispose();
644
+ if (cleanupFailure) throw cleanupFailure.error;
431
645
  });
432
646
  }
433
647
  return disposing;
@@ -436,6 +650,7 @@ function createPythonPackageEnvironment(options = {}) {
436
650
  }
437
651
 
438
652
  export {
653
+ stagePythonPackage,
439
654
  PythonPackageConflictError,
440
655
  createPythonPackageManifestStore,
441
656
  createPythonPackageCache,
@@ -12,10 +12,10 @@ import {
12
12
  relPart,
13
13
  required,
14
14
  unique
15
- } from "./chunk-UDRJKA3P.js";
15
+ } from "./chunk-C23L4HZB.js";
16
16
  import {
17
17
  SelectionError
18
- } from "./chunk-SKF6PGA5.js";
18
+ } from "./chunk-I2OKE2NI.js";
19
19
  import {
20
20
  parseXmlPart
21
21
  } from "./chunk-YWP62BAZ.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  dashPresets,
3
3
  patternPresets
4
- } from "./chunk-NDJPULBE.js";
4
+ } from "./chunk-CEKBIZGU.js";
5
5
  import {
6
6
  themeColorSlots
7
- } from "./chunk-75OUKYCM.js";
7
+ } from "./chunk-CH5JDE3C.js";
8
8
 
9
9
  // packages/safe-bash-presentation-engine/src/drawing-schema.ts
10
10
  var ratio = { type: "number", minimum: 0, maximum: 1 };