@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,1466 +0,0 @@
1
- import {
2
- createPythonPackageEnvironment,
3
- pythonDocumentPackages
4
- } from "./chunk-R4NPYXQX.js";
5
- import {
6
- pythonShellDispatchActive
7
- } from "./chunk-NHAG4DWL.js";
8
- import {
9
- PythonInvocationError,
10
- parsePythonInvocation
11
- } from "./chunk-5EFNQ6FY.js";
12
- import {
13
- pythonLlmProvider
14
- } from "./chunk-YYRVGXJH.js";
15
- import {
16
- PythonFailure,
17
- isPythonFailureCategory,
18
- reportPythonFailure
19
- } from "./chunk-TO6UNFEF.js";
20
- import {
21
- createPythonHostBridge
22
- } from "./chunk-EPYJSPOY.js";
23
-
24
- // packages/safe-bash-command-python/src/executor.ts
25
- import { PythonFileSystem, PythonStatTranslator } from "@poe-platform/safe-fs/core";
26
- import { validateExitCode } from "../../safe-bash-contracts/command.js";
27
- import { openCommandFile } from "../../safe-bash-contracts/filesystem-descriptor.js";
28
-
29
- // packages/safe-bash-command-python/src/reply.ts
30
- import { FsError } from "../../safe-bash-contracts/errors.js";
31
- function encodePythonReply(value, maxBytes) {
32
- let used = 0;
33
- const ancestors = /* @__PURE__ */ new Set();
34
- const reserve = (bytes) => {
35
- used += bytes;
36
- if (used > maxBytes) throw new FsError("EFBIG", { syscall: "python reply" });
37
- };
38
- const string = (text) => {
39
- if (text.length + 2 > maxBytes - used) throw new FsError("EFBIG", { syscall: "python reply" });
40
- reserve(2);
41
- for (let index = 0; index < text.length; index++) {
42
- const code = text.charCodeAt(index);
43
- if (code < 32) reserve([8, 9, 10, 12, 13].includes(code) ? 2 : 6);
44
- else if (code === 34 || code === 92) reserve(2);
45
- else if (code < 128) reserve(1);
46
- else if (code < 2048) reserve(2);
47
- else if (code >= 55296 && code <= 56319 && text.charCodeAt(index + 1) >= 56320 && text.charCodeAt(index + 1) <= 57343) {
48
- reserve(4);
49
- index++;
50
- } else reserve(code >= 55296 && code <= 57343 ? 6 : 3);
51
- }
52
- return text;
53
- };
54
- const own = (input, depth) => {
55
- if (depth > 64) throw new FsError("EFBIG", { syscall: "python reply" });
56
- if (input === null || input === void 0) {
57
- reserve(4);
58
- return null;
59
- }
60
- if (typeof input === "string") return string(input);
61
- if (typeof input === "number") {
62
- reserve(Number.isFinite(input) ? String(input).length : 4);
63
- return input;
64
- }
65
- if (typeof input === "boolean") {
66
- reserve(input ? 4 : 5);
67
- return input;
68
- }
69
- if (typeof input !== "object") throw new TypeError("Invalid Python reply value");
70
- if (ancestors.has(input)) throw new TypeError("Cyclic Python reply value");
71
- ancestors.add(input);
72
- try {
73
- if (input instanceof Uint8Array || Array.isArray(input)) {
74
- if (input.length > maxBytes - used) throw new FsError("EFBIG", { syscall: "python reply" });
75
- reserve(2);
76
- const output2 = [];
77
- for (let index = 0; index < input.length; index++) {
78
- if (index) reserve(1);
79
- const descriptor = Object.getOwnPropertyDescriptor(input, String(index));
80
- if (descriptor && !("value" in descriptor)) throw new TypeError("Accessor Python reply");
81
- output2.push(own(descriptor?.value, depth + 1));
82
- }
83
- return output2;
84
- }
85
- reserve(2);
86
- const output = /* @__PURE__ */ Object.create(null);
87
- let count = 0;
88
- let visited = 0;
89
- for (const key in input) {
90
- if (!Object.hasOwn(input, key)) continue;
91
- if (++visited > maxBytes) throw new FsError("EFBIG", { syscall: "python reply" });
92
- const descriptor = Object.getOwnPropertyDescriptor(input, key);
93
- if (!("value" in descriptor)) throw new TypeError("Accessor Python reply");
94
- if (descriptor.value === void 0 || typeof descriptor.value === "function") continue;
95
- if (count++) reserve(1);
96
- string(key);
97
- reserve(1);
98
- output[key] = own(descriptor.value, depth + 1);
99
- }
100
- return output;
101
- } finally {
102
- ancestors.delete(input);
103
- }
104
- };
105
- const owned = own(value, 0);
106
- return new TextEncoder().encode(JSON.stringify(owned));
107
- }
108
-
109
- // packages/safe-bash-command-python/src/installation.ts
110
- var pythonInstallationHelp = `Usage: python -m pip install [-r FILE | --requirement FILE] PACKAGE ...
111
- Installs compatible wheels and dependencies using the configured Pyodide installer.
112
- PACKAGE is a package requirement or a canonical filesystem wheel path.
113
- Supported options: -r, --requirement, -h, --help, --.
114
- All other pip options and commands are unsupported, including --upgrade,
115
- --force-reinstall, --no-index, --no-deps, --target, --user, --prefix, --root, --editable,
116
- --index-url, --extra-index-url, --find-links, --trusted-host, --require-hashes,
117
- --constraint, --dry-run, --quiet, --verbose and cache/build/configuration flags.
118
- Configure transport and integrity through the Python package SDK configuration.
119
- `;
120
- function parsePythonInstallation(args) {
121
- let pipArgs;
122
- scan: for (let index = 0; index < args.length; index++) {
123
- const option = args[index];
124
- if (option === "--" || option === "-" || !option.startsWith("-") || option.startsWith("--")) return void 0;
125
- for (let offset = 1; offset < option.length; offset++) {
126
- const flag = option[offset];
127
- if ("h?V".includes(flag)) return void 0;
128
- if ("cmWX".includes(flag)) {
129
- const operand = option.slice(offset + 1) || args[++index];
130
- if (flag === "c") return void 0;
131
- if (flag === "m") {
132
- if (operand !== "pip") return void 0;
133
- pipArgs = args.slice(index + 1);
134
- break scan;
135
- }
136
- break;
137
- }
138
- }
139
- }
140
- if (!pipArgs) return void 0;
141
- const packages = [];
142
- const requirements = [];
143
- if (pipArgs.length === 0) return { packages, requirements, help: true };
144
- if (pipArgs[0] === "--help" || pipArgs[0] === "-h") {
145
- if (pipArgs.length > 1) throw new PythonInvocationError("unsupported pip option or argument after help: " + pipArgs[1]);
146
- return { packages, requirements, help: true };
147
- }
148
- if (pipArgs[0] !== "install") throw new PythonInvocationError("unsupported pip command " + pipArgs[0]);
149
- let operands = false;
150
- let help = false;
151
- for (let index = 1; index < pipArgs.length; index++) {
152
- const option = pipArgs[index];
153
- if (operands || !option.startsWith("-")) {
154
- packages.push(option);
155
- continue;
156
- }
157
- if (option === "--") {
158
- operands = true;
159
- continue;
160
- }
161
- if (option === "--help" || option === "-h") {
162
- help = true;
163
- continue;
164
- }
165
- if (option === "-r" || option === "--requirement" || option.startsWith("--requirement=") || option.startsWith("-r")) {
166
- const path = option.startsWith("--requirement=") ? option.slice("--requirement=".length) : option !== "-r" && option.startsWith("-r") ? option.slice(2) : pipArgs[++index];
167
- if (!path || path.startsWith("-")) throw new PythonInvocationError(option + " requires a path");
168
- requirements.push(path);
169
- continue;
170
- }
171
- throw new PythonInvocationError("unsupported pip option " + option);
172
- }
173
- if (!help && packages.length === 0 && requirements.length === 0) throw new PythonInvocationError("pip install requires at least one package or requirements file");
174
- return { packages, requirements, help };
175
- }
176
-
177
- // packages/safe-bash-command-python/src/executor.ts
178
- import { readBytes, writeBytes } from "../../safe-bash-contracts/io.js";
179
- import { createOutputOperation } from "../../safe-bash-contracts/output.js";
180
- import { inheritYieldCheckpoint, yieldTurn } from "../../safe-bash-contracts/yield.js";
181
-
182
- // packages/safe-bash-command-python/src/llm-functions-loader.ts
183
- import { createLlmSpool, createLlmToolRegistry } from "../../safe-bash-command-llm/index.js";
184
- import { toByteSource } from "../../safe-bash-contracts/index.js";
185
-
186
- // packages/safe-bash-command-python/src/llm-functions-program.ts
187
- var pythonLlmFunctionsProgram = /* @__PURE__ */ (() => String.raw`
188
- import asyncio, codecs, inspect, json
189
- import safe_host
190
- from _poe_llm_capability import bridge
191
- from llm.cli import _tools_from_code, _gather_tools
192
- from llm import ToolOutput, Tool, Toolbox, get_tools, get_plugins
193
- from llm.models import _wrap_tools, _get_instance
194
- from llm_safe_host import _attachment_type
195
-
196
-
197
- def send(op, **fields):
198
- return safe_host.call("llm_tools", dict(op=op, **fields))
199
-
200
-
201
- def load_definition(definition):
202
- if "\n" in definition or not definition.endswith(".py"):
203
- send("admit", size=len(definition.encode("utf-8")))
204
- return definition
205
- decoder = codecs.getincrementaldecoder("utf-8")()
206
- chunks = []
207
- try:
208
- with open(definition, "rb") as source:
209
- for chunk in iter(lambda: source.read(4096), b""):
210
- send("admit", size=len(chunk))
211
- chunks.append(decoder.decode(chunk))
212
- chunks.append(decoder.decode(b"", final=True))
213
- except FileNotFoundError:
214
- from click import ClickException
215
- raise ClickException("File not found: " + definition)
216
- code = "".join(chunks).replace("\r\n", "\n").replace("\r", "\n")
217
- return code + "\n" if "\n" not in code and code.endswith(".py") else code
218
-
219
-
220
- def write_text(identifier, value):
221
- for offset in range(0, len(value), 4096):
222
- send("text", id=identifier, text=value[offset:offset + 4096])
223
-
224
-
225
- def write_attachment(identifier, attachment):
226
- mime = _attachment_type(attachment)
227
- if attachment.content:
228
- descriptor = dict(mimeType=mime, id=attachment.id())
229
- handle = send("attachment", id=identifier, descriptor=descriptor)
230
- content = memoryview(attachment.content)
231
- for offset in range(0, len(content), 4096):
232
- send("bytes", id=identifier, attachment=handle, bytes=list(content[offset:offset + 4096]))
233
- elif attachment.path:
234
- handle = send("attachment", id=identifier, descriptor=dict(mimeType=mime, id=attachment.id()))
235
- with open(attachment.path, "rb") as source:
236
- for chunk in iter(lambda: source.read(4096), b""):
237
- send("bytes", id=identifier, attachment=handle, bytes=list(chunk))
238
- elif attachment.url:
239
- send("attachment", id=identifier, descriptor=dict(mimeType=mime, id=attachment.id(), url=attachment.url))
240
- else:
241
- send("attachment", id=identifier, descriptor=dict(mimeType=mime, id=attachment.id()))
242
-
243
-
244
- async def main():
245
- definitions = send("definitions")
246
- selection = send("selection")
247
- names = selection.get("names", [])
248
- discovery = selection.get("discovery", False)
249
- tools = []
250
- try:
251
- plugin_query = selection.get("pluginQuery")
252
- if plugin_query is not None:
253
- plugins = get_plugins(plugin_query["all"])
254
- hooks = set(plugin_query["hooks"])
255
- if hooks:
256
- plugins = [plugin for plugin in plugins if hooks.intersection(plugin["hooks"])]
257
- send("plugins", plugins=plugins)
258
- registered = get_tools() if discovery and not names else {}
259
- functions = []
260
- for definition in definitions:
261
- functions.extend(_tools_from_code(load_definition(definition)))
262
- if discovery:
263
- if names:
264
- registered = {tool.name: tool for tool in functions + _gather_tools(names, [])}
265
- else:
266
- for tool in functions:
267
- registered[tool.name] = tool
268
- entries = [(key, tool, None) for key, tool in registered.items()]
269
- else:
270
- entries = [(tool.name, tool, None) for tool in functions]
271
- for selection_index, selected in enumerate(_gather_tools(names, [])):
272
- entries.extend((tool.name, tool, selection_index) for tool in _wrap_tools([selected]))
273
- for key, tool, selection_index in entries:
274
- if not isinstance(tool, Tool):
275
- methods = []
276
- for method in tool.method_tools():
277
- methods.append(dict(name=method.name, description=method.description,
278
- inputSchema=method.input_schema,
279
- signature=str(inspect.signature(method.implementation)).replace("(self, ", "(").replace("(self)", "()")))
280
- send("toolbox", name=key, tools=methods)
281
- continue
282
- index = len(tools)
283
- tools.append(tool)
284
- send("register", index=index, name=tool.name, registryKey=key, description=tool.description,
285
- plugin=tool.plugin, selectionIndex=selection_index, inputSchema=tool.input_schema,
286
- signature=str(inspect.signature(tool.implementation)),
287
- asynchronous=inspect.iscoroutinefunction(tool.implementation))
288
- except Exception as error:
289
- send("failed", message=getattr(error, "message", str(error)))
290
- return
291
- send("ready", prepare=any(isinstance(_get_instance(tool.implementation), Toolbox) for tool in tools))
292
- pending = set()
293
- cancelled = False
294
-
295
- async def execute(command):
296
- identifier = command["id"]
297
- try:
298
- if command.get("prepare"):
299
- asynchronous = command.get("asynchronous", False)
300
- flag = "_async_prepared" if asynchronous else "_prepared"
301
- instances = []
302
- for tool in {tool.name: tool for tool in tools}.values():
303
- instance = _get_instance(tool.implementation)
304
- if isinstance(instance, Toolbox) and not getattr(instance, flag, False):
305
- instances.append(instance)
306
- for instance in instances:
307
- if asynchronous:
308
- await instance.prepare_async()
309
- else:
310
- instance.prepare()
311
- setattr(instance, flag, True)
312
- send("done", id=identifier)
313
- return
314
- output = tools[command["tool"]].implementation(**command["arguments"])
315
- if inspect.isawaitable(output):
316
- output = await output
317
- attachments = []
318
- if isinstance(output, ToolOutput):
319
- attachments, output = output.attachments, output.output
320
- if not isinstance(output, str):
321
- output = json.dumps(output, default=repr)
322
- write_text(identifier, output)
323
- for attachment in attachments:
324
- write_attachment(identifier, attachment)
325
- send("done", id=identifier)
326
- except Exception as error:
327
- send("error", id=identifier, message=str(error))
328
-
329
- def completed(task):
330
- pending.discard(task)
331
- # Host transport failures already reject all outstanding calls. Retrieve
332
- # the exception so a completed task cannot leak an unobserved failure.
333
- if not task.cancelled():
334
- task.exception()
335
-
336
- try:
337
- while True:
338
- command = await bridge.wait("begin", capability="llm_tools", value=dict(op="next"))
339
- if command is None:
340
- break
341
- if command.get("cancel"):
342
- cancelled = True
343
- break
344
- task = asyncio.create_task(execute(command))
345
- pending.add(task)
346
- task.add_done_callback(completed)
347
- if pending and not cancelled:
348
- await asyncio.gather(*pending)
349
- finally:
350
- for task in pending:
351
- task.cancel()
352
- if pending:
353
- await asyncio.gather(*pending, return_exceptions=True)
354
-
355
- asyncio.run(main())
356
- `)();
357
-
358
- // packages/safe-bash-command-python/src/llm-functions-loader.ts
359
- function deferred() {
360
- let resolve, reject;
361
- const promise = new Promise((yes, no) => {
362
- resolve = yes;
363
- reject = no;
364
- });
365
- return { promise, resolve, reject };
366
- }
367
- function record(value) {
368
- if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("Invalid Python tool protocol");
369
- return value;
370
- }
371
- function createPythonLlmToolLoader(options) {
372
- if (!options.createExecutor) throw new TypeError("Python tool loading requires an asynchronous executor");
373
- const capabilitiesByArguments = /* @__PURE__ */ new WeakMap();
374
- const command = createPythonExecutorCommands({ ...options, createCapabilities: (current) => {
375
- const capabilities = options.createCapabilities?.(current) ?? {};
376
- if (capabilities.llm_tools) throw new Error("Python tool capability is reserved");
377
- const capability = capabilitiesByArguments.get(current.args);
378
- if (!capability) throw new Error("Unknown Python tool invocation");
379
- return { ...capabilities, llm_tools: capability };
380
- } })[0];
381
- return async ({ context, definitions, toolNames = [], discovery = false, pluginQuery, maxInputBytes, maxOutputBytes }) => {
382
- if (!Array.isArray(definitions) || definitions.some((value) => typeof value !== "string")) throw new TypeError("Python tool definitions must be strings");
383
- if (!Array.isArray(toolNames) || toolNames.some((value) => typeof value !== "string") || typeof discovery !== "boolean") throw new TypeError("Invalid Python tool selection");
384
- if (pluginQuery && (typeof pluginQuery.all !== "boolean" || !Array.isArray(pluginQuery.hooks) || pluginQuery.hooks.some((value) => typeof value !== "string"))) throw new TypeError("Invalid Python plugin query");
385
- for (const limit of [maxInputBytes, maxOutputBytes]) if (limit !== Infinity && (!Number.isSafeInteger(limit) || limit < 0)) throw new RangeError("Invalid Python tool byte limit");
386
- context.signal.throwIfAborted();
387
- const controller = new AbortController();
388
- const runtimeController = new AbortController();
389
- const signal = AbortSignal.any([context.signal, controller.signal]);
390
- const ready = deferred();
391
- const tools = [];
392
- const toolboxes = [];
393
- let plugins;
394
- const spools = /* @__PURE__ */ new Set();
395
- const jobs = /* @__PURE__ */ new Map();
396
- const queue = [];
397
- let waiter;
398
- let serial = 0, controls = 0, loaded = false, initializationFailed = false, closed = false, closing;
399
- const encoder = new TextEncoder();
400
- const fail = (error) => {
401
- ready.reject(error);
402
- queue.length = 0;
403
- if (waiter) {
404
- waiter.resolve({ cancel: true });
405
- waiter = void 0;
406
- } else queue.push({ cancel: true });
407
- for (const job of jobs.values()) job.result.reject(error);
408
- jobs.clear();
409
- controller.abort(error);
410
- };
411
- const aborted = () => fail(signal.reason);
412
- signal.addEventListener("abort", aborted, { once: true });
413
- const spool = async () => {
414
- const value = await createLlmSpool(context.fs, context.cwd, signal);
415
- spools.add(value);
416
- if (closed || signal.aborted) {
417
- await value.close();
418
- spools.delete(value);
419
- signal.throwIfAborted();
420
- throw new Error("Python tool session is closed");
421
- }
422
- return value;
423
- };
424
- const source = (value) => ({ bytes: value.replay(), async dispose() {
425
- try {
426
- await value.close();
427
- } finally {
428
- spools.delete(value);
429
- }
430
- } });
431
- const invoke = async (fields, callContext) => {
432
- signal.throwIfAborted();
433
- callContext.signal.throwIfAborted();
434
- if (closed) throw new Error("Python tool session is closed");
435
- const stop = () => fail(callContext.signal.reason);
436
- callContext.signal.addEventListener("abort", stop, { once: true });
437
- let output;
438
- try {
439
- output = await spool();
440
- callContext.signal.throwIfAborted();
441
- const result = deferred(), id = ++serial;
442
- jobs.set(id, { result, output, attachments: [], files: /* @__PURE__ */ new Map(), bytes: 0, limit: Math.min(callContext.maxBytes, maxOutputBytes) });
443
- const request = { id, ...fields };
444
- if (waiter) {
445
- waiter.resolve(request);
446
- waiter = void 0;
447
- } else queue.push(request);
448
- return await result.promise;
449
- } catch (error) {
450
- if (output) {
451
- await output.close();
452
- spools.delete(output);
453
- }
454
- throw error;
455
- } finally {
456
- callContext.signal.removeEventListener("abort", stop);
457
- }
458
- };
459
- const prepare = async (callContext, mode) => {
460
- const result = await invoke({ prepare: true, asynchronous: mode.async }, callContext);
461
- await result.source?.dispose();
462
- };
463
- const dispatch = async (value) => {
464
- const message = record(value);
465
- if (message.op !== "next" && message.op !== "failed") signal.throwIfAborted();
466
- if (message.op === "definitions") return [...definitions];
467
- if (message.op === "selection") return { names: [...toolNames], discovery, ...pluginQuery ? { pluginQuery: { all: pluginQuery.all, hooks: [...pluginQuery.hooks] } } : {} };
468
- if (message.op === "admit") {
469
- if (typeof message.size !== "number" || !Number.isSafeInteger(message.size) || message.size < 0) throw new TypeError("Invalid Python definition byte count");
470
- controls += message.size;
471
- if (controls > maxInputBytes) {
472
- const error = new RangeError("Python tool definition byte limit exceeded");
473
- fail(error);
474
- throw error;
475
- }
476
- return null;
477
- }
478
- if (message.op === "failed") {
479
- initializationFailed = true;
480
- fail(new Error(String(message.message)));
481
- return null;
482
- }
483
- if (message.op === "register" || message.op === "toolbox" || message.op === "plugins") {
484
- controls += encoder.encode(JSON.stringify(message)).length;
485
- if (controls > maxInputBytes) throw new RangeError("Python tool definition byte limit exceeded");
486
- }
487
- if (message.op === "plugins") {
488
- if (loaded || plugins || !pluginQuery || !Array.isArray(message.plugins)) throw new TypeError("Invalid Python plugin discovery");
489
- plugins = Object.freeze(message.plugins.map((value2) => {
490
- const plugin = record(value2);
491
- if (typeof plugin.name !== "string" || !Array.isArray(plugin.hooks) || plugin.hooks.some((hook) => typeof hook !== "string") || plugin.version !== void 0 && typeof plugin.version !== "string") throw new TypeError("Invalid Python plugin metadata");
492
- return Object.freeze({ name: plugin.name, hooks: Object.freeze(plugin.hooks), ...typeof plugin.version === "string" ? { version: plugin.version } : {} });
493
- }));
494
- return null;
495
- }
496
- if (message.op === "toolbox") {
497
- if (loaded || typeof message.name !== "string" || !Array.isArray(message.tools)) throw new TypeError("Invalid Python toolbox registration");
498
- const methods = message.tools.map((value2) => {
499
- const method = record(value2);
500
- const tool = {
501
- name: String(method.name),
502
- inputSchema: record(method.inputSchema),
503
- ...typeof method.description === "string" ? { description: method.description } : {},
504
- ...typeof method.signature === "string" ? { signature: method.signature } : {}
505
- };
506
- if (typeof method.name !== "string") throw new TypeError("Invalid Python toolbox method");
507
- createLlmToolRegistry([tool]);
508
- return tool;
509
- });
510
- toolboxes.push({ name: message.name, tools: methods });
511
- return null;
512
- }
513
- if (message.op === "register") {
514
- if (loaded || message.index !== tools.length || typeof message.name !== "string" || typeof message.signature !== "string" || typeof message.asynchronous !== "boolean") throw new TypeError("Invalid Python tool registration");
515
- const index = tools.length;
516
- const tool = {
517
- name: message.name,
518
- inputSchema: record(message.inputSchema),
519
- signature: message.signature,
520
- ...typeof message.description === "string" ? { description: message.description } : {},
521
- ...typeof message.plugin === "string" ? { plugin: message.plugin } : {},
522
- ...typeof message.registryKey === "string" ? { registryKey: message.registryKey } : {},
523
- ...typeof message.selectionIndex === "number" ? { selectionIndex: message.selectionIndex } : {},
524
- async: message.asynchronous,
525
- async implementation(args, callContext) {
526
- return invoke({ tool: index, arguments: args }, callContext);
527
- }
528
- };
529
- createLlmToolRegistry([tool]);
530
- tools.push(tool);
531
- return null;
532
- }
533
- if (message.op === "ready") {
534
- if (loaded) throw new Error("Python tools already loaded");
535
- if (message.prepare === true) for (let index = 0; index < tools.length; index++) tools[index] = { ...tools[index], prepare };
536
- loaded = true;
537
- ready.resolve();
538
- return null;
539
- }
540
- if (message.op === "next") {
541
- if (signal.aborted) return { cancel: true };
542
- if (!loaded || waiter) throw new Error("Invalid Python tool request queue");
543
- if (queue.length) return queue.shift();
544
- waiter = deferred();
545
- return waiter.promise;
546
- }
547
- if (typeof message.id !== "number") throw new TypeError("Invalid Python tool call identity");
548
- const job = jobs.get(message.id);
549
- if (!job) throw new Error("Unknown Python tool call");
550
- if (message.op === "text" || message.op === "bytes") {
551
- let bytes, target = job.output;
552
- if (message.op === "text") {
553
- if (typeof message.text !== "string" || message.text.length > 8192) throw new TypeError("Invalid Python tool output window");
554
- bytes = encoder.encode(message.text);
555
- if (bytes.length > 16384) throw new TypeError("Invalid Python tool output window");
556
- } else {
557
- if (!Array.isArray(message.bytes) || message.bytes.length > 4096 || message.bytes.some((value2) => typeof value2 !== "number" || !Number.isInteger(value2) || value2 < 0 || value2 > 255)) throw new TypeError("Invalid Python attachment window");
558
- if (typeof message.attachment !== "number" || !job.files.has(message.attachment)) throw new Error("Unknown Python attachment");
559
- target = job.files.get(message.attachment);
560
- bytes = Uint8Array.from(message.bytes);
561
- }
562
- if (bytes.length > job.limit - job.bytes) throw new RangeError("Python tool output byte limit exceeded");
563
- job.bytes += bytes.length;
564
- await target.write(bytes);
565
- return null;
566
- }
567
- if (message.op === "attachment") {
568
- const metadata = record(message.descriptor);
569
- if (typeof metadata.mimeType !== "string" || typeof metadata.id !== "string" || metadata.url !== void 0 && typeof metadata.url !== "string") throw new TypeError("Invalid Python tool attachment");
570
- const size = encoder.encode(JSON.stringify(metadata)).length;
571
- if (size > job.limit - job.bytes) throw new RangeError("Python tool attachment metadata limit exceeded");
572
- job.bytes += size;
573
- const index = job.attachments.length;
574
- if (metadata.url !== void 0) job.attachments.push({ mimeType: metadata.mimeType, id: metadata.id, url: metadata.url });
575
- else {
576
- const file = await spool();
577
- job.files.set(index, file);
578
- job.attachments.push({ mimeType: metadata.mimeType, id: metadata.id, source: source(file) });
579
- }
580
- return index;
581
- }
582
- if (message.op === "error") {
583
- jobs.delete(message.id);
584
- await Promise.all([job.output, ...job.files.values()].map(async (value2) => {
585
- await value2.close();
586
- spools.delete(value2);
587
- }));
588
- job.result.reject(new Error(String(message.message)));
589
- return null;
590
- }
591
- if (message.op === "done") {
592
- jobs.delete(message.id);
593
- job.result.resolve({ source: source(job.output), attachments: job.attachments });
594
- return null;
595
- }
596
- throw new TypeError("Invalid Python tool operation");
597
- };
598
- const capability = { async call(value) {
599
- try {
600
- return await dispatch(value);
601
- } catch (error) {
602
- fail(error);
603
- throw error;
604
- }
605
- } };
606
- const { registerCleanup: ignoredParentCleanup, ...isolatedContext } = context;
607
- const invocation = { ...isolatedContext, signal: runtimeController.signal, command: "python", args: ["-c", pythonLlmFunctionsProgram], stdin: toByteSource("") };
608
- capabilitiesByArguments.set(invocation.args, capability);
609
- const running = Promise.resolve().then(() => command.execute(invocation)).then(
610
- (result) => {
611
- if (!closed) fail(new Error(`Python tool interpreter exited with status ${result.exitCode}`));
612
- },
613
- (error) => {
614
- if (!closed) fail(error);
615
- }
616
- );
617
- const close = () => closing ??= (async () => {
618
- closed = true;
619
- if (loaded && !signal.aborted && !jobs.size) {
620
- if (waiter) {
621
- waiter.resolve(null);
622
- waiter = void 0;
623
- } else queue.push(null);
624
- } else {
625
- controller.abort(new Error("Python tool session closed"));
626
- if (!loaded && !initializationFailed) runtimeController.abort(signal.reason);
627
- }
628
- await running;
629
- capabilitiesByArguments.delete(invocation.args);
630
- controller.abort(new Error("Python tool session closed"));
631
- signal.removeEventListener("abort", aborted);
632
- await Promise.all([...spools].map((value) => value.close()));
633
- spools.clear();
634
- })();
635
- context.registerCleanup?.(close);
636
- try {
637
- signal.throwIfAborted();
638
- await ready.promise;
639
- return { tools: Object.freeze(tools), toolboxes: Object.freeze(toolboxes), ...plugins ? { plugins } : {}, close };
640
- } catch (error) {
641
- await close();
642
- throw error;
643
- }
644
- };
645
- }
646
-
647
- // packages/safe-bash-command-python/src/llm-manifest.ts
648
- var pythonLlmManifest = {
649
- "llm": "0.27.1",
650
- "pyodide": "314.0.6",
651
- "distributions": [
652
- {
653
- "name": "llm",
654
- "version": "0.27.1",
655
- "url": "https://files.pythonhosted.org/packages/6c/67/47585c961ff2299749e519891681025c2685b75801e3f784ee232853c5b0/llm-0.27.1-py3-none-any.whl",
656
- "sha256": "a884a575062fbea8c2b129708a80e146fa9682bd1c444d8d7b028196107de727",
657
- "bytes": 82500,
658
- "expandedBytes": 348753,
659
- "nativeModules": [],
660
- "file": "llm-0.27.1-py3-none-any.whl"
661
- },
662
- {
663
- "name": "pydantic",
664
- "version": "2.12.5",
665
- "url": "https://files.pythonhosted.org/packages/5a/87/b70ad306ebb6f9b585f114d0ac2137d792b48be34d732d60e597c2f8465a/pydantic-2.12.5-py3-none-any.whl",
666
- "sha256": "e561593fccf61e8a20fc46dfc2dfe075b8be7d0188df33f221ad1f0139180f9d",
667
- "bytes": 463580,
668
- "expandedBytes": 1851456,
669
- "nativeModules": [],
670
- "file": "pydantic-2.12.5-py3-none-any.whl"
671
- },
672
- {
673
- "name": "pydantic-core",
674
- "version": "2.41.5",
675
- "url": "https://cdn.jsdelivr.net/pyodide/v314.0.6/full/pydantic_core-2.41.5-cp314-cp314-pyemscripten_2026_0_wasm32.whl",
676
- "sha256": "9802bd7a5e6679ec4c13be778f19f021e6147459c89cc916b913f7970f86dddb",
677
- "bytes": 1310163,
678
- "expandedBytes": 4592549,
679
- "nativeModules": [
680
- {
681
- "path": "pydantic_core/_pydantic_core.cpython-314-wasm32-emscripten.so",
682
- "bytes": 4275289,
683
- "sha256": "94477475eb48c67b6b25fd47a7955c1d01479f7971522aff90215bb517be8246"
684
- }
685
- ],
686
- "file": "pydantic_core-2.41.5-cp314-cp314-pyemscripten_2026_0_wasm32.whl"
687
- },
688
- {
689
- "name": "httpx",
690
- "version": "0.28.1",
691
- "url": "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl",
692
- "sha256": "d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad",
693
- "bytes": 73517,
694
- "expandedBytes": 295303,
695
- "nativeModules": [],
696
- "file": "httpx-0.28.1-py3-none-any.whl"
697
- },
698
- {
699
- "name": "click",
700
- "version": "8.1.8",
701
- "url": "https://files.pythonhosted.org/packages/7e/d4/7ebdbd03970677812aac39c869717059dbb71a4cfc033ca6e5221787892c/click-8.1.8-py3-none-any.whl",
702
- "sha256": "63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2",
703
- "bytes": 98188,
704
- "expandedBytes": 355272,
705
- "nativeModules": [],
706
- "file": "click-8.1.8-py3-none-any.whl"
707
- },
708
- {
709
- "name": "sqlite-utils",
710
- "version": "3.38",
711
- "url": "https://files.pythonhosted.org/packages/4d/eb/f8e8e827805f810838efff3311cccd2601238c5fa3fc35c1f878709e161b/sqlite_utils-3.38-py3-none-any.whl",
712
- "sha256": "8a27441015c3b2ef475f555861f7a2592f73bc60d247af9803a11b65fc605bf9",
713
- "bytes": 68183,
714
- "expandedBytes": 278821,
715
- "nativeModules": [],
716
- "file": "sqlite_utils-3.38-py3-none-any.whl"
717
- },
718
- {
719
- "name": "sqlite-migrate",
720
- "version": "0.1b0",
721
- "url": "https://files.pythonhosted.org/packages/df/92/994545b912e6d6feb40323047f02ca039321e690aa2c27afcd5c4105e37b/sqlite_migrate-0.1b0-py3-none-any.whl",
722
- "sha256": "a4125e35e1de3dc56b6b6ec60e9833ce0ce20192b929ddcb2d4246c5098859c6",
723
- "bytes": 9986,
724
- "expandedBytes": 25349,
725
- "nativeModules": [],
726
- "file": "sqlite_migrate-0.1b0-py3-none-any.whl"
727
- },
728
- {
729
- "name": "python-ulid",
730
- "version": "3.0.0",
731
- "url": "https://files.pythonhosted.org/packages/63/4e/cc2ba2c0df2589f35a4db8473b8c2ba9bbfc4acdec4a94f1c78934d2350f/python_ulid-3.0.0-py3-none-any.whl",
732
- "sha256": "e4c4942ff50dbd79167ad01ac725ec58f924b4018025ce22c858bfcff99a5e31",
733
- "bytes": 11194,
734
- "expandedBytes": 30439,
735
- "nativeModules": [],
736
- "file": "python_ulid-3.0.0-py3-none-any.whl"
737
- },
738
- {
739
- "name": "condense-json",
740
- "version": "0.1.3",
741
- "url": "https://files.pythonhosted.org/packages/28/5f/63badd4924358fad1efa6defd66eef700ccf8783c0e44098987f867e8b1f/condense_json-0.1.3-py3-none-any.whl",
742
- "sha256": "e0a3d42db4f44a89e74af8737d8e517e97420be0f7e5437087f4decfd38c3366",
743
- "bytes": 8432,
744
- "expandedBytes": 21056,
745
- "nativeModules": [],
746
- "file": "condense_json-0.1.3-py3-none-any.whl"
747
- },
748
- {
749
- "name": "puremagic",
750
- "version": "1.30",
751
- "url": "https://files.pythonhosted.org/packages/91/ed/1e347d85d05b37a8b9a039ca832e5747e1e5248d0bd66042783ef48b4a37/puremagic-1.30-py3-none-any.whl",
752
- "sha256": "5eeeb2dd86f335b9cfe8e205346612197af3500c6872dffebf26929f56e9d3c1",
753
- "bytes": 43304,
754
- "expandedBytes": 185153,
755
- "nativeModules": [],
756
- "file": "puremagic-1.30-py3-none-any.whl"
757
- },
758
- {
759
- "name": "anyio",
760
- "version": "4.15.1",
761
- "url": "https://files.pythonhosted.org/packages/12/b8/4bd346e22b28902df4d651910f5242c28d84e4a5c2435ca5c3f797ed7e2e/anyio-4.15.1-py3-none-any.whl",
762
- "sha256": "6152fdbbf9a77fdec97731721bebf7c4c44f7c29b424b0065826173efc7ed101",
763
- "bytes": 132079,
764
- "expandedBytes": 539217,
765
- "nativeModules": [],
766
- "file": "anyio-4.15.1-py3-none-any.whl"
767
- },
768
- {
769
- "name": "httpcore",
770
- "version": "1.0.9",
771
- "url": "https://files.pythonhosted.org/packages/7e/f5/f66802a942d491edb555dd61e3a9961140fd64c90bce1eafd741609d334d/httpcore-1.0.9-py3-none-any.whl",
772
- "sha256": "2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55",
773
- "bytes": 78784,
774
- "expandedBytes": 288016,
775
- "nativeModules": [],
776
- "file": "httpcore-1.0.9-py3-none-any.whl"
777
- },
778
- {
779
- "name": "typing-extensions",
780
- "version": "4.16.0",
781
- "url": "https://files.pythonhosted.org/packages/49/d3/b8441a820a491ddfc024b0b0cf0393375b75ea13866d9c66727e54c2fc80/typing_extensions-4.16.0-py3-none-any.whl",
782
- "sha256": "481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8",
783
- "bytes": 45571,
784
- "expandedBytes": 182767,
785
- "nativeModules": [],
786
- "file": "typing_extensions-4.16.0-py3-none-any.whl"
787
- },
788
- {
789
- "name": "annotated-types",
790
- "version": "0.8.0",
791
- "url": "https://files.pythonhosted.org/packages/99/91/8acff4f5e50511b911bbccb72b8628a49c68ce14148cd9f6431094859a90/annotated_types-0.8.0-py3-none-any.whl",
792
- "sha256": "f072f4d804ea359e4eaf198b1af7a8b0943881a87f31bb764f8bf219bb9419e0",
793
- "bytes": 13427,
794
- "expandedBytes": 36347,
795
- "nativeModules": [],
796
- "file": "annotated_types-0.8.0-py3-none-any.whl"
797
- },
798
- {
799
- "name": "click-default-group",
800
- "version": "1.2.4",
801
- "url": "https://files.pythonhosted.org/packages/2c/1a/aff8bb287a4b1400f69e09a53bd65de96aa5cee5691925b38731c67fc695/click_default_group-1.2.4-py2.py3-none-any.whl",
802
- "sha256": "9b60486923720e7fc61731bdb32b617039aba820e22e1c88766b1125592eaa5f",
803
- "bytes": 4123,
804
- "expandedBytes": 8671,
805
- "nativeModules": [],
806
- "file": "click_default_group-1.2.4-py2.py3-none-any.whl"
807
- },
808
- {
809
- "name": "h11",
810
- "version": "0.16.0",
811
- "url": "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl",
812
- "sha256": "63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86",
813
- "bytes": 37515,
814
- "expandedBytes": 103935,
815
- "nativeModules": [],
816
- "file": "h11-0.16.0-py3-none-any.whl"
817
- },
818
- {
819
- "name": "idna",
820
- "version": "3.20",
821
- "url": "https://files.pythonhosted.org/packages/58/a2/bb081bab032533a855d44de1d56f8e8426114ff1ba5d1f07a438a0a654f8/idna-3.20-py3-none-any.whl",
822
- "sha256": "ab7ae7122974553370f0bdb919e1a960b2cd1bc1ef0276416d896db81c14582c",
823
- "bytes": 69583,
824
- "expandedBytes": 342091,
825
- "nativeModules": [],
826
- "file": "idna-3.20-py3-none-any.whl"
827
- },
828
- {
829
- "name": "typing-inspection",
830
- "version": "0.4.4",
831
- "url": "https://files.pythonhosted.org/packages/67/81/4add07e5172b7ac40d8ed5ff580409a7801a4fe26d529bdd915401dabfbe/typing_inspection-0.4.4-py3-none-any.whl",
832
- "sha256": "65b8397ba37ccbce054456aaccddfc91e6e3083c92824df348d96ca832f3f147",
833
- "bytes": 14750,
834
- "expandedBytes": 54538,
835
- "nativeModules": [],
836
- "file": "typing_inspection-0.4.4-py3-none-any.whl"
837
- },
838
- {
839
- "name": "certifi",
840
- "version": "2026.7.22",
841
- "url": "https://files.pythonhosted.org/packages/0b/a7/71ac2cff56fec219ed242bb11b8efb69fcc4bec75db06fb7bfe35de520e6/certifi-2026.7.22-py3-none-any.whl",
842
- "sha256": "62f22742b58a1a33014a2b6b706588a8d7e2a88ae7bd1a6ebe8c992928483775",
843
- "bytes": 136983,
844
- "expandedBytes": 248921,
845
- "nativeModules": [],
846
- "file": "certifi-2026.7.22-py3-none-any.whl"
847
- },
848
- {
849
- "name": "pluggy",
850
- "version": "1.6.0",
851
- "url": "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl",
852
- "sha256": "e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746",
853
- "bytes": 20538,
854
- "expandedBytes": 65823,
855
- "nativeModules": [],
856
- "file": "pluggy-1.6.0-py3-none-any.whl"
857
- },
858
- {
859
- "name": "python-dateutil",
860
- "version": "2.9.0.post0",
861
- "url": "https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl",
862
- "sha256": "a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427",
863
- "bytes": 229892,
864
- "expandedBytes": 441579,
865
- "nativeModules": [],
866
- "file": "python_dateutil-2.9.0.post0-py2.py3-none-any.whl"
867
- },
868
- {
869
- "name": "six",
870
- "version": "1.17.0",
871
- "url": "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl",
872
- "sha256": "4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274",
873
- "bytes": 11050,
874
- "expandedBytes": 37975,
875
- "nativeModules": [],
876
- "file": "six-1.17.0-py2.py3-none-any.whl"
877
- },
878
- {
879
- "name": "pyyaml",
880
- "version": "6.0.3",
881
- "url": "https://cdn.jsdelivr.net/pyodide/v314.0.6/full/pyyaml-6.0.3-cp314-cp314-pyemscripten_2026_0_wasm32.whl",
882
- "sha256": "b1447216501f0d3aef290558fe33691dd51b0839e70f9a970defb12b36d82df8",
883
- "bytes": 111318,
884
- "expandedBytes": 439274,
885
- "nativeModules": [
886
- {
887
- "path": "yaml/_yaml.cpython-314-wasm32-emscripten.so",
888
- "bytes": 214986,
889
- "sha256": "a3b18ccfd3c043f10f4ae4044bea14079f14a30707bf5c6ddf1f6dc61abaffc1"
890
- }
891
- ],
892
- "file": "pyyaml-6.0.3-cp314-cp314-pyemscripten_2026_0_wasm32.whl"
893
- },
894
- {
895
- "name": "sniffio",
896
- "version": "1.3.1",
897
- "url": "https://files.pythonhosted.org/packages/e9/44/75a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40/sniffio-1.3.1-py3-none-any.whl",
898
- "sha256": "2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2",
899
- "bytes": 10235,
900
- "expandedBytes": 22921,
901
- "nativeModules": [],
902
- "file": "sniffio-1.3.1-py3-none-any.whl"
903
- },
904
- {
905
- "name": "sqlite-fts4",
906
- "version": "1.0.3",
907
- "url": "https://files.pythonhosted.org/packages/51/29/0096e8b1811aaa78cfb296996f621f41120c21c2f5cd448ae1d54979d9fc/sqlite_fts4-1.0.3-py3-none-any.whl",
908
- "sha256": "0359edd8dea6fd73c848989e1e2b1f31a50fe5f9d7272299ff0e8dbaa62d035f",
909
- "bytes": 9972,
910
- "expandedBytes": 28735,
911
- "nativeModules": [],
912
- "file": "sqlite_fts4-1.0.3-py3-none-any.whl"
913
- },
914
- {
915
- "name": "tabulate",
916
- "version": "0.10.0",
917
- "url": "https://files.pythonhosted.org/packages/99/55/db07de81b5c630da5cbf5c7df646580ca26dfaefa593667fc6f2fe016d2e/tabulate-0.10.0-py3-none-any.whl",
918
- "sha256": "f0b0622e567335c8fabaaa659f1b33bcb6ddfe2e496071b743aa113f8774f2d3",
919
- "bytes": 39814,
920
- "expandedBytes": 150857,
921
- "nativeModules": [],
922
- "file": "tabulate-0.10.0-py3-none-any.whl"
923
- }
924
- ]
925
- };
926
-
927
- // packages/safe-bash-command-python/src/llm-packages.ts
928
- var pythonLlmPackages = pythonLlmManifest;
929
- function installPythonLlmPackages(runtime, assets) {
930
- if (runtime.version !== pythonLlmManifest.pyodide) throw new Error("LLM packages require the pinned Python runtime");
931
- if (assets.length !== pythonLlmManifest.distributions.length) throw new Error("Incomplete Python LLM package assets");
932
- const root = "/lib/python3.14/site-packages";
933
- const wheelRoot = root + "/llm-wheels";
934
- runtime.FS.mkdirTree(wheelRoot);
935
- const paths = [];
936
- for (const distribution of pythonLlmManifest.distributions) {
937
- const asset = assets.find((asset2) => asset2.file === distribution.file);
938
- if (!asset || asset.bytes.byteLength !== distribution.bytes) throw new Error("Invalid Python LLM package asset: " + distribution.file);
939
- if (distribution.nativeModules.length || ["llm", "puremagic"].includes(distribution.name)) {
940
- runtime.unpackArchive(asset.bytes, "zip", { extractDir: root });
941
- } else {
942
- const path = wheelRoot + "/" + distribution.file;
943
- runtime.FS.writeFile(path, asset.bytes);
944
- paths.push(path);
945
- }
946
- }
947
- runtime.FS.writeFile(root + "/readline.py", new TextEncoder().encode(
948
- '"""Readline key bindings for the non-terminal Worker input stream."""\ndef parse_and_bind(binding):\n import sys\n if sys.stdin.isatty():\n raise OSError("Terminal line editing is unavailable in this runtime")\n'
949
- ));
950
- runtime.FS.writeFile(root + "/llm_safe_host.py", new TextEncoder().encode(pythonLlmProvider));
951
- const metadata = root + "/llm_safe_host-0.1.dist-info";
952
- runtime.FS.mkdirTree(metadata);
953
- runtime.FS.writeFile(metadata + "/METADATA", new TextEncoder().encode("Metadata-Version: 2.1\nName: llm-safe-host\nVersion: 0.1\n"));
954
- runtime.FS.writeFile(metadata + "/entry_points.txt", new TextEncoder().encode("[llm]\nsafe_host = llm_safe_host\n"));
955
- runtime.globals.set("_safe_llm_wheel_paths", JSON.stringify(paths));
956
- try {
957
- runtime.runPython(String.raw`
958
- import json, sys
959
- sys.path.extend(json.loads(_safe_llm_wheel_paths))
960
- def _install_safe_llm_import():
961
- if any(getattr(finder, "_safe_llm_provider", False) for finder in sys.meta_path):
962
- return
963
- def configure_plugins(module):
964
- module.DEFAULT_PLUGINS = ("llm.default_plugins.default_tools",)
965
- module.LLM_LOAD_PLUGINS = "llm-safe-host"
966
-
967
- def configure_provider(module):
968
- configure_plugins(module.plugins)
969
- module.plugins.load_plugins()
970
- from llm_safe_host import restrict_providers
971
- restrict_providers()
972
-
973
- class HostLlmFinder:
974
- _safe_llm_provider = True
975
- def find_spec(self, fullname, path=None, target=None):
976
- if fullname not in ("llm", "llm.plugins"):
977
- return None
978
- for finder in tuple(sys.meta_path):
979
- if finder is self:
980
- continue
981
- spec = finder.find_spec(fullname, path, target)
982
- if spec is None:
983
- continue
984
- original = spec.loader
985
- class HostLlmLoader:
986
- def create_module(self, spec):
987
- return original.create_module(spec)
988
- def exec_module(self, module):
989
- original.exec_module(module)
990
- if fullname == "llm.plugins":
991
- configure_plugins(module)
992
- else:
993
- configure_provider(module)
994
- def __getattr__(self, name):
995
- return getattr(original, name)
996
- spec.loader = HostLlmLoader()
997
- return spec
998
- return None
999
-
1000
- sys.meta_path.insert(0, HostLlmFinder())
1001
- if "llm" in sys.modules:
1002
- configure_provider(sys.modules["llm"])
1003
- _install_safe_llm_import()
1004
- del _install_safe_llm_import
1005
- `);
1006
- } finally {
1007
- runtime.globals.delete("_safe_llm_wheel_paths");
1008
- }
1009
- }
1010
-
1011
- // packages/safe-bash-command-python/src/executor.ts
1012
- var PythonInputChunkError = class extends RangeError {
1013
- };
1014
- function createPythonExecutorCommands(options) {
1015
- if (!options || typeof options.createWorker === "function" === (typeof options.createExecutor === "function") || options.createWorker !== void 0 && typeof options.createWorker !== "function" || options.createExecutor !== void 0 && typeof options.createExecutor !== "function") throw new PythonFailure("executor-unavailable");
1016
- if (options.createCapabilities && !options.createExecutor) throw new TypeError("Python host capabilities require an asynchronous executor");
1017
- if (options.onDiagnostic !== void 0 && typeof options.onDiagnostic !== "function") throw new TypeError("Python onDiagnostic must be a function");
1018
- if (options.environment && options.provisioning) throw new TypeError("A borrowed Python environment cannot be combined with provisioning options");
1019
- const maxTransferBytes = options.maxTransferBytes ?? Infinity;
1020
- const transferChunkBytes = Math.min(maxTransferBytes, 65536);
1021
- const maxOpenFiles = options.maxOpenFiles;
1022
- const maxConcurrentWorkers = options.maxConcurrentWorkers ?? Infinity;
1023
- const maxInputChunkBytes = options.maxInputChunkBytes ?? Infinity;
1024
- if (maxConcurrentWorkers !== Infinity && (!Number.isSafeInteger(maxConcurrentWorkers) || maxConcurrentWorkers < 1)) throw new RangeError("Invalid Python worker concurrency limit");
1025
- if (maxInputChunkBytes !== Infinity && (!Number.isSafeInteger(maxInputChunkBytes) || maxInputChunkBytes < 1)) throw new RangeError("Invalid Python input chunk limit");
1026
- let activeWorkers = 0;
1027
- for (const size of [maxTransferBytes, maxOpenFiles, options.maxDirectoryEntries]) if (size !== void 0 && size !== Infinity && (!Number.isSafeInteger(size) || size < 1)) throw new RangeError("Invalid Python resource limit");
1028
- const runtimeMount = options.runtimeMount ?? "/.pyodide-runtime";
1029
- 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");
1030
- const environment = options.environment ?? createPythonPackageEnvironment(options.provisioning);
1031
- const execute = async (context) => {
1032
- if (pythonShellDispatchActive(context.executionScope)) {
1033
- await writeBytes(context.stderr, new TextEncoder().encode("python: nested Python execution is unavailable while the parent interpreter is suspended\n"), context.signal);
1034
- return { exitCode: 1 };
1035
- }
1036
- let installation;
1037
- try {
1038
- parsePythonInvocation(context.args, context.env);
1039
- installation = parsePythonInstallation(context.args);
1040
- } catch (error) {
1041
- if (!(error instanceof PythonInvocationError)) throw error;
1042
- await writeBytes(context.stderr, new TextEncoder().encode("python: " + error.message + "\n"), context.signal);
1043
- return { exitCode: 2 };
1044
- }
1045
- if (installation?.help) {
1046
- await writeBytes(context.stdout, new TextEncoder().encode(pythonInstallationHelp), context.signal);
1047
- return { exitCode: 0 };
1048
- }
1049
- context.signal.throwIfAborted();
1050
- if (activeWorkers >= maxConcurrentWorkers) {
1051
- const failure = reportPythonFailure("capacity", void 0, options.onDiagnostic);
1052
- await writeBytes(context.stderr, new TextEncoder().encode("python: " + failure.message + "\n"), context.signal);
1053
- return { exitCode: 1 };
1054
- }
1055
- const controller = new AbortController();
1056
- const signal = AbortSignal.any([context.signal, controller.signal]);
1057
- inheritYieldCheckpoint(context.signal, signal);
1058
- const fileContext = { ...context, descriptorCleanup: "caller" };
1059
- const metadata = new PythonStatTranslator();
1060
- const service = new PythonFileSystem(context.fs, {
1061
- cwd: context.cwd,
1062
- signal,
1063
- maxTransferBytes,
1064
- ...maxOpenFiles === void 0 ? {} : { maxOpenFiles },
1065
- ...options.maxDirectoryEntries === void 0 ? {} : { maxDirectoryEntries: options.maxDirectoryEntries },
1066
- open: (path, settings) => openCommandFile(fileContext, path, settings)
1067
- });
1068
- let hostBridge;
1069
- let stdoutOperation;
1070
- let stderrOperation;
1071
- let endpoint;
1072
- let executor;
1073
- let packages;
1074
- let unsubscribe;
1075
- let admitted = false;
1076
- let closed = false;
1077
- let closing;
1078
- const pending = /* @__PURE__ */ new Set();
1079
- const input = readBytes(context.stdin, signal)[Symbol.asyncIterator]();
1080
- let fragment;
1081
- let offset = 0;
1082
- let inputBytes = 0;
1083
- let rejectRun;
1084
- const close = () => {
1085
- if (closing) return closing;
1086
- let finish;
1087
- let fail;
1088
- closing = new Promise((resolve, reject) => {
1089
- finish = resolve;
1090
- fail = reject;
1091
- });
1092
- closed = true;
1093
- controller.abort(new Error("Python invocation retired"));
1094
- void (async () => {
1095
- signal.removeEventListener("abort", aborted);
1096
- const subscription = Promise.resolve().then(() => unsubscribe?.());
1097
- const termination = Promise.resolve().then(() => executor ? executor.terminate() : endpoint?.terminate());
1098
- const filesystemRetirement = termination.finally(() => service.close());
1099
- const results = await Promise.allSettled([subscription, termination, filesystemRetirement, hostBridge?.close(), stdoutOperation?.close(), stderrOperation?.close(), ...pending]);
1100
- await input.return?.(void 0);
1101
- fragment = void 0;
1102
- if (packages) environment.finish(packages);
1103
- if (results[1]?.status === "fulfilled" && admitted) {
1104
- activeWorkers--;
1105
- admitted = false;
1106
- }
1107
- for (const result2 of results) if (result2.status === "rejected") throw result2.reason;
1108
- })().then(() => {
1109
- if (admitted) {
1110
- activeWorkers--;
1111
- admitted = false;
1112
- }
1113
- finish();
1114
- }, (reason) => {
1115
- fail(reportPythonFailure("cleanup", reason, options.onDiagnostic));
1116
- });
1117
- return closing;
1118
- };
1119
- const aborted = () => {
1120
- rejectRun?.(signal.reason);
1121
- };
1122
- context.registerCleanup?.(close);
1123
- let primary;
1124
- let ready = false;
1125
- const filesystemDiagnostics = /* @__PURE__ */ new Set();
1126
- let result = 1;
1127
- try {
1128
- signal.throwIfAborted();
1129
- activeWorkers++;
1130
- admitted = true;
1131
- const outputContext = { signal, ...context.registerCleanup ? { registerCleanup: context.registerCleanup } : {} };
1132
- stdoutOperation = createOutputOperation(outputContext, context.stdout);
1133
- stderrOperation = createOutputOperation(outputContext, context.stderr);
1134
- const diagnoseFilesystemFailure = async (operation, error) => {
1135
- if (typeof error !== "object" || error === null || !("code" in error) || error.code !== "ENOTSUP") return;
1136
- const category = operation === "open" ? "filesystem-open" : operation === "read" ? "filesystem-read" : operation === "write" || operation === "ftruncate" ? "filesystem-write" : operation === "readdir" ? "filesystem-directory" : "filesystem-operation";
1137
- if (!filesystemDiagnostics.has(category)) {
1138
- filesystemDiagnostics.add(category);
1139
- const failure = reportPythonFailure(category, error, options.onDiagnostic);
1140
- await writeBytes(stderrOperation.output, new TextEncoder().encode("python: " + failure.message + "\n"), signal);
1141
- }
1142
- };
1143
- const dispatch = async (request) => {
1144
- if (request.op === "close") return service.dispatch(request);
1145
- signal.throwIfAborted();
1146
- if (request.op.startsWith("package-")) return environment.dispatch(request.op, request.args, { fs: context.fs, cwd: context.cwd, signal });
1147
- if (request.op === "stdin") {
1148
- const length = request.args[0];
1149
- if (!Number.isSafeInteger(length) || length < 1 || length > maxTransferBytes) throw new RangeError("Invalid Python input request");
1150
- let pulls = 0;
1151
- while (!fragment || offset === fragment.length) {
1152
- if (++pulls % 128 === 0) await yieldTurn(signal);
1153
- const next = await input.next();
1154
- if (next.done) return [];
1155
- inputBytes += next.value.length;
1156
- context.inputBudget?.check(inputBytes);
1157
- if (next.value.length > maxInputChunkBytes) throw new PythonInputChunkError("Python input chunk exceeds maxInputChunkBytes");
1158
- fragment = Uint8Array.from(next.value);
1159
- offset = 0;
1160
- }
1161
- const end = Math.min(fragment.length, offset + length);
1162
- const bytes = Array.from(fragment.subarray(offset, end));
1163
- offset = end;
1164
- return bytes;
1165
- }
1166
- if (request.op === "stdout" || request.op === "stderr") {
1167
- const bytes = request.args[0];
1168
- if (!Array.isArray(bytes) || bytes.length > maxTransferBytes || bytes.some((value2) => !Number.isInteger(value2) || value2 < 0 || value2 > 255)) throw new TypeError("Invalid Python output bytes");
1169
- const operation = request.op === "stdout" ? stdoutOperation : stderrOperation;
1170
- await writeBytes(operation.output, Uint8Array.from(bytes), signal);
1171
- return bytes.length;
1172
- }
1173
- const value = await service.dispatch(request);
1174
- return request.op === "stat" || request.op === "lstat" || request.op === "fstat" ? metadata.translate(value) : value;
1175
- };
1176
- if (options.createCapabilities) {
1177
- const capabilityInput = { async *[Symbol.asyncIterator]() {
1178
- while (true) {
1179
- const bytes = await dispatch({ op: "stdin", args: [transferChunkBytes] });
1180
- if (!bytes.length) break;
1181
- yield Uint8Array.from(bytes);
1182
- }
1183
- } };
1184
- hostBridge = createPythonHostBridge(options.createCapabilities({ ...context, stdin: capabilityInput, signal }), { ...options.capabilityLimits, signal });
1185
- }
1186
- options.onProgress?.({ phase: "initializing", command: context.command });
1187
- const preparation = environment.prepare({
1188
- fs: context.fs,
1189
- cwd: context.cwd,
1190
- signal,
1191
- requirements: [...options.packages ?? [], ...options.packageProfile ? pythonDocumentPackages : [], ...installation?.packages ?? []],
1192
- requirementFiles: [...options.requirements ?? [], ...installation?.requirements ?? []]
1193
- }).then((value) => {
1194
- packages = value;
1195
- });
1196
- pending.add(preparation);
1197
- try {
1198
- await preparation;
1199
- } finally {
1200
- pending.delete(preparation);
1201
- }
1202
- signal.throwIfAborted();
1203
- if (options.createExecutor) {
1204
- try {
1205
- executor = options.createExecutor();
1206
- } catch (reason) {
1207
- throw reportPythonFailure(reason instanceof PythonFailure ? reason.category : "startup", reason, options.onDiagnostic);
1208
- }
1209
- if (!executor || typeof executor.run !== "function" || typeof executor.terminate !== "function") throw reportPythonFailure("executor-unavailable", void 0, options.onDiagnostic);
1210
- let requesting = false;
1211
- let running = true;
1212
- const start = {
1213
- invocation: { command: context.command, args: [...context.args], cwd: context.cwd, env: { ...context.env } },
1214
- ...hostBridge ? { host: hostBridge } : {},
1215
- runtimeMount,
1216
- maxTransferBytes,
1217
- signal,
1218
- ...packages ? { packages } : {},
1219
- installOnly: !!installation,
1220
- onReady() {
1221
- if (closed || !running || signal.aborted || ready) return;
1222
- ready = true;
1223
- try {
1224
- options.onProgress?.({ phase: "ready", command: context.command });
1225
- } catch (reason) {
1226
- running = false;
1227
- rejectRun?.(reason);
1228
- throw reason;
1229
- }
1230
- },
1231
- async dispatch(request) {
1232
- if (!request || typeof request.op !== "string" || !Array.isArray(request.args)) throw reportPythonFailure("transport-unavailable", void 0, options.onDiagnostic);
1233
- const releasing = request.op === "close";
1234
- if (!releasing) signal.throwIfAborted();
1235
- if (closed && !releasing || !running || requesting) throw reportPythonFailure("transport-unavailable", void 0, options.onDiagnostic);
1236
- requesting = true;
1237
- const operation = Promise.resolve().then(() => dispatch(request)).catch(async (error) => {
1238
- if (releasing) throw error;
1239
- signal.throwIfAborted();
1240
- if (error instanceof PythonInputChunkError) rejectRun?.(error);
1241
- if (request.op.startsWith("package-")) throw Object.assign(reportPythonFailure("runtime-assets", error, options.onDiagnostic), { code: "EPACKAGE" });
1242
- await diagnoseFilesystemFailure(request.op, error);
1243
- throw error;
1244
- });
1245
- const tracked2 = operation.then(() => {
1246
- }, () => {
1247
- });
1248
- pending.add(tracked2);
1249
- try {
1250
- return await operation;
1251
- } finally {
1252
- requesting = false;
1253
- pending.delete(tracked2);
1254
- }
1255
- }
1256
- };
1257
- const execution = Promise.resolve().then(() => {
1258
- signal.throwIfAborted();
1259
- return executor.run(start);
1260
- }).catch((reason) => {
1261
- running = false;
1262
- if (signal.aborted) throw signal.reason;
1263
- throw reportPythonFailure(reason instanceof PythonFailure ? reason.category : ready ? "runtime" : "startup", reason, options.onDiagnostic);
1264
- }).then((status) => {
1265
- running = false;
1266
- if (requesting) throw reportPythonFailure("transport-unavailable", void 0, options.onDiagnostic);
1267
- try {
1268
- return validateExitCode(status);
1269
- } catch (reason) {
1270
- throw reportPythonFailure("transport-unavailable", reason, options.onDiagnostic);
1271
- }
1272
- });
1273
- const tracked = execution.then(() => {
1274
- }, () => {
1275
- });
1276
- pending.add(tracked);
1277
- void tracked.then(() => pending.delete(tracked));
1278
- result = await new Promise((resolve, reject) => {
1279
- rejectRun = reject;
1280
- signal.addEventListener("abort", aborted, { once: true });
1281
- if (signal.aborted) aborted();
1282
- execution.then(resolve, reject);
1283
- });
1284
- } else {
1285
- let shared;
1286
- try {
1287
- shared = new SharedArrayBuffer(8 + transferChunkBytes * 6 + 65536);
1288
- } catch (reason) {
1289
- throw reportPythonFailure("transport-unavailable", reason, options.onDiagnostic);
1290
- }
1291
- const control = new Int32Array(shared, 0, 2);
1292
- const payload = new Uint8Array(shared, 8);
1293
- const reply = (value, status) => {
1294
- if (closed) return;
1295
- let bytes;
1296
- try {
1297
- bytes = encodePythonReply(value, payload.length);
1298
- } catch (error) {
1299
- if (typeof error !== "object" || error === null || !("code" in error) || error.code !== "EFBIG") throw error;
1300
- bytes = encodePythonReply({ code: "EFBIG" }, payload.length);
1301
- status = 2;
1302
- }
1303
- payload.set(bytes);
1304
- try {
1305
- Atomics.store(control, 1, bytes.length);
1306
- Atomics.store(control, 0, status);
1307
- Atomics.notify(control, 0);
1308
- } catch (reason) {
1309
- throw reportPythonFailure("transport-unavailable", reason, options.onDiagnostic);
1310
- }
1311
- };
1312
- try {
1313
- endpoint = options.createWorker();
1314
- } catch (reason) {
1315
- throw reportPythonFailure(reason instanceof PythonFailure ? reason.category : "startup", reason, options.onDiagnostic);
1316
- }
1317
- signal.throwIfAborted();
1318
- result = await new Promise((resolve, reject) => {
1319
- let settled = false;
1320
- const fail = (reason) => {
1321
- settled = true;
1322
- reject(reason);
1323
- };
1324
- rejectRun = fail;
1325
- signal.addEventListener("abort", aborted, { once: true });
1326
- const transportFailure = (reason) => {
1327
- fail(reportPythonFailure("transport-unavailable", reason, options.onDiagnostic));
1328
- };
1329
- try {
1330
- unsubscribe = endpoint.subscribe((value) => {
1331
- if (closed || settled) return;
1332
- if (typeof value !== "object" || value === null) {
1333
- transportFailure(new TypeError("Invalid Python worker message"));
1334
- return;
1335
- }
1336
- const message = value;
1337
- if (message.type === "ready") {
1338
- ready = true;
1339
- try {
1340
- options.onProgress?.({ phase: "ready", command: context.command });
1341
- } catch (error) {
1342
- fail(error);
1343
- }
1344
- return;
1345
- }
1346
- if (message.type === "exit") {
1347
- if (pending.size) {
1348
- transportFailure(new TypeError("Python worker exited with an outstanding request"));
1349
- return;
1350
- }
1351
- try {
1352
- const status = validateExitCode(message.exitCode);
1353
- settled = true;
1354
- resolve(status);
1355
- } catch (error) {
1356
- transportFailure(error);
1357
- }
1358
- return;
1359
- }
1360
- if (message.type === "error") {
1361
- fail(reportPythonFailure(isPythonFailureCategory(message.category) ? message.category : ready ? "runtime" : "startup", message.message, options.onDiagnostic));
1362
- return;
1363
- }
1364
- if (typeof message.op !== "string" || !Array.isArray(message.args) || pending.size) {
1365
- transportFailure(new TypeError("Invalid concurrent Python worker request"));
1366
- return;
1367
- }
1368
- const work = dispatch({ op: message.op, args: message.args }).then(
1369
- (value2) => {
1370
- pending.delete(work);
1371
- reply(value2, 1);
1372
- },
1373
- async (error) => {
1374
- if (signal.aborted) {
1375
- pending.delete(work);
1376
- fail(signal.reason);
1377
- return;
1378
- }
1379
- if (typeof message.op === "string" && message.op.startsWith("package-")) {
1380
- const failure = reportPythonFailure("runtime-assets", error, options.onDiagnostic);
1381
- pending.delete(work);
1382
- reply({ code: "EPACKAGE", message: failure.message }, 2);
1383
- return;
1384
- }
1385
- if (typeof error !== "object" || error === null || !("code" in error) || typeof error.code !== "string") {
1386
- pending.delete(work);
1387
- fail(error);
1388
- return;
1389
- }
1390
- await diagnoseFilesystemFailure(message.op, error);
1391
- pending.delete(work);
1392
- reply({ code: error.code }, 2);
1393
- }
1394
- );
1395
- pending.add(work);
1396
- void work.catch((reason) => {
1397
- pending.delete(work);
1398
- fail(reason);
1399
- });
1400
- }, transportFailure);
1401
- } catch (reason) {
1402
- transportFailure(reason);
1403
- }
1404
- if (settled) return;
1405
- const start = { type: "start", shared, invocation: { command: context.command, args: [...context.args], cwd: context.cwd, env: { ...context.env } }, runtimeMount, maxTransferBytes: transferChunkBytes, ...packages ? { packages } : {}, installOnly: !!installation };
1406
- signal.throwIfAborted();
1407
- try {
1408
- endpoint.postMessage(start);
1409
- } catch (reason) {
1410
- transportFailure(reason);
1411
- }
1412
- });
1413
- }
1414
- } catch (reason) {
1415
- if (!signal.aborted && reason instanceof PythonInputChunkError) {
1416
- try {
1417
- await writeBytes(stderrOperation.output, new TextEncoder().encode("python: " + reason.message + "\n"), signal);
1418
- } catch (error) {
1419
- primary = { reason: error };
1420
- }
1421
- } else if (!signal.aborted && typeof reason === "object" && reason !== null && "code" in reason && reason.code === "EPACKAGE") {
1422
- primary = { reason: reportPythonFailure("runtime-assets", reason, options.onDiagnostic) };
1423
- } else primary = { reason };
1424
- }
1425
- try {
1426
- await close();
1427
- } catch (reason) {
1428
- primary ??= { reason };
1429
- }
1430
- try {
1431
- options.onProgress?.({ phase: "finished", command: context.command });
1432
- } catch (reason) {
1433
- primary ??= { reason };
1434
- }
1435
- context.signal.throwIfAborted();
1436
- if (primary) {
1437
- if (!(primary.reason instanceof PythonFailure)) throw primary.reason;
1438
- const failure = primary.reason;
1439
- await writeBytes(context.stderr, new TextEncoder().encode("python: " + failure.message + "\n"), context.signal);
1440
- return { exitCode: 1 };
1441
- }
1442
- return { exitCode: result };
1443
- };
1444
- return ["python", "python3"].map((name) => ({ name, description: "Python with an explicit interpreter executor and canonical filesystem", execute }));
1445
- }
1446
- function pythonExecutorCommands(options) {
1447
- if (!options || typeof options.createWorker === "function" === (typeof options.createExecutor === "function")) throw new PythonFailure("executor-unavailable");
1448
- if (options?.environment && options.provisioning) throw new TypeError("A borrowed Python environment cannot be combined with provisioning options");
1449
- const { provisioning, ...configuration } = options;
1450
- const environment = options.environment ?? createPythonPackageEnvironment(provisioning);
1451
- const commands = createPythonExecutorCommands({ ...configuration, environment });
1452
- return { name: "python-commands", ...options.environment ? {} : { dispose: environment.dispose }, setup(host) {
1453
- if (!options.replace) {
1454
- for (const command of commands) if (host.commands.has(command.name)) throw new Error(`Command already registered: ${command.name}`);
1455
- }
1456
- for (const command of commands) host.commands.register(command, { replace: options.replace ?? false });
1457
- } };
1458
- }
1459
-
1460
- export {
1461
- createPythonLlmToolLoader,
1462
- pythonLlmPackages,
1463
- installPythonLlmPackages,
1464
- createPythonExecutorCommands,
1465
- pythonExecutorCommands
1466
- };